ngx-material-schematics
Advanced tools
Comparing version
{ | ||
"name": "ngx-material-schematics", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A blank schematics", | ||
@@ -16,3 +16,3 @@ "licenses": [ | ||
"ng-add": { | ||
"save": "devDependencies" | ||
"save": false | ||
}, | ||
@@ -42,2 +42,3 @@ "scripts": { | ||
"devDependencies": { | ||
"@schematics/angular": "^13.1.1", | ||
"@types/jasmine": "~3.10.0", | ||
@@ -44,0 +45,0 @@ "@types/node": "^12.11.1", |
@@ -15,12 +15,19 @@ "use strict"; | ||
const path = require("path"); | ||
const collectionPath = path.join(__dirname, '../collection.json'); | ||
describe('ng-add', () => { | ||
it('works', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath); | ||
const tree = yield runner | ||
.runSchematicAsync('ng-add', {}, schematics_1.Tree.empty()) | ||
const collectionPath = path.join(__dirname, "../collection.json"); | ||
describe("ng-add", () => { | ||
let appTree; | ||
let schematicRunner; | ||
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () { | ||
schematicRunner = new testing_1.SchematicTestRunner("ngx-material-schematics", require.resolve(collectionPath)); | ||
appTree = new testing_1.UnitTestTree(new schematics_1.HostTree()); | ||
appTree.create("/package.json", JSON.stringify({})); | ||
})); | ||
it("works", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const tree = yield schematicRunner | ||
.runSchematicAsync("ng-add", undefined, appTree) | ||
.toPromise(); | ||
expect(tree.files).toEqual([]); | ||
const packageJSONContent = JSON.parse(tree.readContent("/package.json")); | ||
expect(packageJSONContent.devDependencies["ngx-material-schematics"]).toBeTruthy(); | ||
})); | ||
}); | ||
//# sourceMappingURL=index_spec.js.map |
@@ -5,4 +5,16 @@ "use strict"; | ||
const tasks_1 = require("@angular-devkit/schematics/tasks"); | ||
const utils_1 = require("../utils"); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const packageJSON = require("../../package.json"); | ||
function ngAdd(_options) { | ||
return (tree, _context) => { | ||
if (!tree.exists("package.json")) { | ||
throw new Error("Could not find a `package.json` file at the root of your workspace"); | ||
} | ||
const projectPackageJSON = tree.read("package.json").toString("utf-8"); | ||
const json = JSON.parse(projectPackageJSON); | ||
json.devDependencies = json.devDependencies || {}; | ||
json.devDependencies[packageJSON.name] = packageJSON.version; | ||
json.devDependencies = (0, utils_1.sortObjectByKeys)(json.devDependencies); | ||
tree.overwrite("package.json", JSON.stringify(json, null, 2)); | ||
_context.addTask(new tasks_1.NodePackageInstallTask()); | ||
@@ -9,0 +21,0 @@ _context.logger.info(` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
38614
83.24%23
4.55%147
14.84%4
33.33%1
Infinity%