@depup/angular-devkit__schematics-cli 21.2.2-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -0
  3. package/bin/schematics.d.ts +15 -0
  4. package/bin/schematics.js +513 -0
  5. package/bin/schematics.js.map +1 -0
  6. package/blank/factory.d.ts +10 -0
  7. package/blank/factory.js +83 -0
  8. package/blank/factory.js.map +1 -0
  9. package/blank/project-files/.gitignore.template +19 -0
  10. package/blank/project-files/.npmignore.template +4 -0
  11. package/blank/project-files/README.md +28 -0
  12. package/blank/project-files/package.json +25 -0
  13. package/blank/project-files/src/collection.json +4 -0
  14. package/blank/project-files/tsconfig.json +24 -0
  15. package/blank/schema.d.ts +24 -0
  16. package/blank/schema.js +16 -0
  17. package/blank/schema.js.map +1 -0
  18. package/blank/schema.json +27 -0
  19. package/blank/schematic-files/src/__name@dasherize__/index.ts.template +10 -0
  20. package/blank/schematic-files/src/__name@dasherize__/index_spec.ts.template +14 -0
  21. package/changes.json +10 -0
  22. package/collection.json +14 -0
  23. package/package.json +60 -0
  24. package/schematic/factory.d.ts +10 -0
  25. package/schematic/factory.js +36 -0
  26. package/schematic/factory.js.map +1 -0
  27. package/schematic/files/.gitignore.template +18 -0
  28. package/schematic/files/.npmignore.template +3 -0
  29. package/schematic/files/README.md +28 -0
  30. package/schematic/files/package.json +25 -0
  31. package/schematic/files/src/collection.json +36 -0
  32. package/schematic/files/src/my-full-schematic/files/test2 +6 -0
  33. package/schematic/files/src/my-full-schematic/files/test__INDEX__ +2 -0
  34. package/schematic/files/src/my-full-schematic/index.ts +53 -0
  35. package/schematic/files/src/my-full-schematic/index_spec.ts +24 -0
  36. package/schematic/files/src/my-full-schematic/schema.json +16 -0
  37. package/schematic/files/src/my-other-schematic/index.ts +27 -0
  38. package/schematic/files/src/my-other-schematic/index_spec.ts +14 -0
  39. package/schematic/files/src/my-schematic/index.ts +26 -0
  40. package/schematic/files/src/my-schematic/index_spec.ts +14 -0
  41. package/schematic/files/tsconfig.json +23 -0
  42. package/schematic/schema.d.ts +24 -0
  43. package/schematic/schema.js +16 -0
  44. package/schematic/schema.js.map +1 -0
  45. package/schematic/schema.json +23 -0
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.default = default_1;
11
+ const core_1 = require("@angular-devkit/core");
12
+ const schematics_1 = require("@angular-devkit/schematics");
13
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
14
+ function addSchematicToCollectionJson(collectionPath, schematicName, description) {
15
+ return (tree) => {
16
+ const collectionJson = tree.readJson(collectionPath);
17
+ if (!(0, core_1.isJsonObject)(collectionJson) || !(0, core_1.isJsonObject)(collectionJson.schematics)) {
18
+ throw new Error('Invalid collection.json; schematics needs to be an object.');
19
+ }
20
+ collectionJson['schematics'][schematicName] = description;
21
+ tree.overwrite(collectionPath, JSON.stringify(collectionJson, undefined, 2));
22
+ };
23
+ }
24
+ function default_1(options) {
25
+ const schematicsVersion = require('@angular-devkit/schematics/package.json').version;
26
+ const coreVersion = require('@angular-devkit/core/package.json').version;
27
+ // Verify if we need to create a full project, or just add a new schematic.
28
+ return (tree, context) => {
29
+ if (!options.name) {
30
+ throw new schematics_1.SchematicsException('name option is required.');
31
+ }
32
+ let collectionPath;
33
+ try {
34
+ const packageJson = tree.readJson('/package.json');
35
+ if (typeof packageJson.schematics === 'string') {
36
+ const p = (0, core_1.normalize)(packageJson.schematics);
37
+ if (tree.exists(p)) {
38
+ collectionPath = p;
39
+ }
40
+ }
41
+ }
42
+ catch { }
43
+ let source = (0, schematics_1.apply)((0, schematics_1.url)('./schematic-files'), [
44
+ (0, schematics_1.applyTemplates)({
45
+ ...options,
46
+ coreVersion,
47
+ schematicsVersion,
48
+ dot: '.',
49
+ camelize: core_1.strings.camelize,
50
+ dasherize: core_1.strings.dasherize,
51
+ }),
52
+ ]);
53
+ // Simply create a new schematic project.
54
+ if (!collectionPath) {
55
+ collectionPath = (0, core_1.normalize)('/' + options.name + '/src/collection.json');
56
+ source = (0, schematics_1.apply)((0, schematics_1.url)('./project-files'), [
57
+ (0, schematics_1.move)('package.json', 'package.json.template'),
58
+ (0, schematics_1.applyTemplates)({
59
+ ...options,
60
+ coreVersion,
61
+ schematicsVersion,
62
+ dot: '.',
63
+ camelize: core_1.strings.camelize,
64
+ dasherize: core_1.strings.dasherize,
65
+ }),
66
+ (0, schematics_1.mergeWith)(source),
67
+ (0, schematics_1.move)(options.name),
68
+ ]);
69
+ context.addTask(new tasks_1.NodePackageInstallTask({
70
+ workingDirectory: options.name,
71
+ packageManager: options.packageManager,
72
+ }));
73
+ }
74
+ return (0, schematics_1.chain)([
75
+ (0, schematics_1.mergeWith)(source),
76
+ addSchematicToCollectionJson(collectionPath, core_1.strings.dasherize(options.name), {
77
+ description: 'A blank schematic.',
78
+ factory: './' + core_1.strings.dasherize(options.name) + '/index#' + core_1.strings.camelize(options.name),
79
+ }),
80
+ ]);
81
+ };
82
+ }
83
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["factory.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAmCH,4BAoEC;AArGD,+CAA0F;AAC1F,2DAWoC;AACpC,4DAA0E;AAG1E,SAAS,4BAA4B,CACnC,cAAoB,EACpB,aAAqB,EACrB,WAAuB;IAEvB,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAErD,IAAI,CAAC,IAAA,mBAAY,EAAC,cAAc,CAAC,IAAI,CAAC,IAAA,mBAAY,EAAC,cAAc,CAAC,UAAU,CAA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+
2
+ # Outputs
3
+ src/**/*.js
4
+ src/**/*.js.map
5
+ src/**/*.d.ts
6
+
7
+ # IDEs
8
+ .idea/
9
+ jsconfig.json
10
+ .vscode/
11
+
12
+ # Misc
13
+ node_modules/
14
+ npm-debug.log*
15
+ yarn-error.log*
16
+
17
+ # Mac OSX Finder files.
18
+ **/.DS_Store
19
+ .DS_Store
@@ -0,0 +1,4 @@
1
+
2
+ # Ignores TypeScript files, but keeps definitions.
3
+ *.ts
4
+ !*.d.ts
@@ -0,0 +1,28 @@
1
+ # Getting Started With Schematics
2
+
3
+ This repository is a basic Schematic implementation that serves as a starting point to create and publish Schematics to NPM.
4
+
5
+ ### Testing
6
+
7
+ To test locally, install `@angular-devkit/schematics-cli` globally and use the `schematics` command line tool. That tool acts the same as the `generate` command of the Angular CLI, but also has a debug mode.
8
+
9
+ Check the documentation with
10
+
11
+ ```bash
12
+ schematics --help
13
+ ```
14
+
15
+ ### Unit Testing
16
+
17
+ `npm run test` will run the unit tests, using Jasmine as a runner and test framework.
18
+
19
+ ### Publishing
20
+
21
+ To publish, simply do:
22
+
23
+ ```bash
24
+ npm run build
25
+ npm publish
26
+ ```
27
+
28
+ That's it!
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "<%= dasherize(name) %>",
3
+ "version": "0.0.0",
4
+ "description": "A blank schematics",
5
+ "scripts": {
6
+ "build": "tsc -p tsconfig.json",
7
+ "test": "npm run build && jasmine src/**/*_spec.js"
8
+ },
9
+ "keywords": [
10
+ "schematics"
11
+ ],
12
+ "author": "<%= author %>",
13
+ "license": "MIT",
14
+ "schematics": "./src/collection.json",
15
+ "dependencies": {
16
+ "@angular-devkit/core": "^<%= coreVersion %>",
17
+ "@angular-devkit/schematics": "^<%= schematicsVersion %>",
18
+ "typescript": "~5.9.2"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^20.17.19",
22
+ "@types/jasmine": "~6.0.0",
23
+ "jasmine": "^6.0.0"
24
+ }
25
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {}
4
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": "tsconfig",
4
+ "lib": ["es2018", "dom"],
5
+ "declaration": true,
6
+ "module": "commonjs",
7
+ "moduleResolution": "node",
8
+ "noEmitOnError": true,
9
+ "noFallthroughCasesInSwitch": true,
10
+ "noImplicitAny": true,
11
+ "noImplicitThis": true,
12
+ "noUnusedParameters": true,
13
+ "noUnusedLocals": true,
14
+ "rootDir": "src/",
15
+ "skipDefaultLibCheck": true,
16
+ "skipLibCheck": true,
17
+ "sourceMap": true,
18
+ "strictNullChecks": true,
19
+ "target": "es6",
20
+ "types": ["jasmine", "node"]
21
+ },
22
+ "include": ["src/**/*"],
23
+ "exclude": ["src/*/files/**/*"]
24
+ }
@@ -0,0 +1,24 @@
1
+ export type Schema = {
2
+ /**
3
+ * Author for the new schematic.
4
+ */
5
+ author?: string;
6
+ /**
7
+ * The package name for the new schematic.
8
+ */
9
+ name?: string;
10
+ /**
11
+ * The package manager used to install dependencies.
12
+ */
13
+ packageManager?: PackageManager;
14
+ [property: string]: any;
15
+ };
16
+ /**
17
+ * The package manager used to install dependencies.
18
+ */
19
+ export declare enum PackageManager {
20
+ Bun = "bun",
21
+ Npm = "npm",
22
+ Pnpm = "pnpm",
23
+ Yarn = "yarn"
24
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ // THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
3
+ // CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.PackageManager = void 0;
6
+ /**
7
+ * The package manager used to install dependencies.
8
+ */
9
+ var PackageManager;
10
+ (function (PackageManager) {
11
+ PackageManager["Bun"] = "bun";
12
+ PackageManager["Npm"] = "npm";
13
+ PackageManager["Pnpm"] = "pnpm";
14
+ PackageManager["Yarn"] = "yarn";
15
+ })(PackageManager || (exports.PackageManager = PackageManager = {}));
16
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,oFAAoF;;;AAkBpF;;GAEG;AACH,IAAY,cAKX;AALD,WAAY,cAAc;IACtB,6BAAW,CAAA;IACX,6BAAW,CAAA;IACX,+BAAa,CAAA;IACb,+BAAa,CAAA;AACjB,CAAC,EALW,cAAc,8BAAd,cAAc,QAKzB"}
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "SchematicsSchematicSchema",
4
+ "title": "Schematic Options Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "The package name for the new schematic.",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ }
14
+ },
15
+ "packageManager": {
16
+ "description": "The package manager used to install dependencies.",
17
+ "type": "string",
18
+ "enum": ["npm", "yarn", "pnpm", "bun"],
19
+ "default": "npm"
20
+ },
21
+ "author": {
22
+ "type": "string",
23
+ "description": "Author for the new schematic."
24
+ }
25
+ },
26
+ "required": []
27
+ }
@@ -0,0 +1,10 @@
1
+ import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
2
+
3
+
4
+ // You don't have to export the function as default. You can also have more than one rule factory
5
+ // per file.
6
+ export function <%= camelize(name) %>(_options: any): Rule {
7
+ return (tree: Tree, _context: SchematicContext) => {
8
+ return tree;
9
+ };
10
+ }
@@ -0,0 +1,14 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
3
+ import * as path from 'path';
4
+
5
+ const collectionPath = path.join(__dirname, '../collection.json');
6
+
7
+ describe('<%= dasherize(name) %>', () => {
8
+ it('works', async () => {
9
+ const runner = new SchematicTestRunner('schematics', collectionPath);
10
+ const tree = await runner.runSchematic('<%= dasherize(name) %>', {}, Tree.empty());
11
+
12
+ expect(tree.files).toEqual([]);
13
+ });
14
+ });
package/changes.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "bumped": {
3
+ "@inquirer/prompts": {
4
+ "from": "7.10.1",
5
+ "to": "^8.3.2"
6
+ }
7
+ },
8
+ "timestamp": "2026-03-17T16:30:45.247Z",
9
+ "totalUpdated": 1
10
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "schematics": {
3
+ "blank": {
4
+ "factory": "./blank/factory",
5
+ "schema": "./blank/schema.json",
6
+ "description": "Create an empty schematic project or add a blank schematic to the current project."
7
+ },
8
+ "schematic": {
9
+ "factory": "./schematic/factory",
10
+ "schema": "./schematic/schema.json",
11
+ "description": "Create a Schematic template which can be built and published directly to NPM."
12
+ }
13
+ }
14
+ }
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@depup/angular-devkit__schematics-cli",
3
+ "version": "21.2.2-depup.0",
4
+ "description": "[DepUp] Angular Schematics - CLI",
5
+ "homepage": "https://github.com/angular/angular-cli",
6
+ "bin": {
7
+ "schematics": "bin/schematics.js"
8
+ },
9
+ "keywords": [
10
+ "depup",
11
+ "dependency-bumped",
12
+ "updated-deps",
13
+ "@angular-devkit/schematics-cli",
14
+ "Angular CLI",
15
+ "Angular DevKit",
16
+ "angular",
17
+ "blueprints",
18
+ "code generation",
19
+ "devkit",
20
+ "scaffolding",
21
+ "schematics",
22
+ "sdk",
23
+ "template",
24
+ "tooling"
25
+ ],
26
+ "schematics": "./collection.json",
27
+ "dependencies": {
28
+ "@angular-devkit/core": "21.2.2",
29
+ "@angular-devkit/schematics": "21.2.2",
30
+ "@inquirer/prompts": "^8.3.2"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/angular/angular-cli.git"
35
+ },
36
+ "packageManager": "pnpm@10.31.0",
37
+ "engines": {
38
+ "node": "^20.19.0 || ^22.12.0 || >=24.0.0",
39
+ "npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
40
+ "yarn": ">= 1.13.0"
41
+ },
42
+ "author": "Angular Authors",
43
+ "license": "MIT",
44
+ "bugs": {
45
+ "url": "https://github.com/angular/angular-cli/issues"
46
+ },
47
+ "depup": {
48
+ "changes": {
49
+ "@inquirer/prompts": {
50
+ "from": "7.10.1",
51
+ "to": "^8.3.2"
52
+ }
53
+ },
54
+ "depsUpdated": 1,
55
+ "originalPackage": "@angular-devkit/schematics-cli",
56
+ "originalVersion": "21.2.2",
57
+ "processedAt": "2026-03-17T16:30:51.753Z",
58
+ "smokeTest": "failed"
59
+ }
60
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import { Rule } from '@angular-devkit/schematics';
9
+ import { Schema } from './schema';
10
+ export default function (options: Schema): Rule;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.default = default_1;
11
+ const core_1 = require("@angular-devkit/core");
12
+ const schematics_1 = require("@angular-devkit/schematics");
13
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
14
+ function default_1(options) {
15
+ const schematicsVersion = require('@angular-devkit/schematics/package.json').version;
16
+ const coreVersion = require('@angular-devkit/core/package.json').version;
17
+ return (_, context) => {
18
+ context.addTask(new tasks_1.NodePackageInstallTask({
19
+ workingDirectory: options.name,
20
+ packageManager: options.packageManager,
21
+ }));
22
+ return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
23
+ // The `package.json` name is kept to allow renovate to update the dependency versions
24
+ (0, schematics_1.move)('package.json', 'package.json.template'),
25
+ (0, schematics_1.partitionApplyMerge)((p) => !/\/src\/.*?\/files\//.test(p), (0, schematics_1.applyTemplates)({
26
+ ...options,
27
+ coreVersion,
28
+ schematicsVersion,
29
+ dot: '.',
30
+ dasherize: core_1.strings.dasherize,
31
+ })),
32
+ (0, schematics_1.move)(options.name),
33
+ ]));
34
+ };
35
+ }
36
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["factory.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAeH,4BA8BC;AA3CD,+CAA+C;AAC/C,2DAQoC;AACpC,4DAA0E;AAG1E,mBAAyB,OAAe;IACtC,MAAM,iBAAiB,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC,OAAO,CAAC;IACrF,MAAM,WAAW,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC,OAAO,CAAC;IAEzE,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE;QACpB,OAAO,CAAC,OAAO,CACb,IAAI,8BAAsB,CAAC;YACzB,gBAAgB,EAAE,OAAO,CAAC,IAAI;YAC9B,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CACH,CAAC;QAEF,OAAO,IAAA,sBAAS,EACd,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE;YACpB,sFAAsF;YACtF,IAAA,iBAAI,EAAC,cAAc,EAAE,uBAAuB,CAAC;YAC7C,IAAA,gCAAmB,EACjB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,EACrC,IAAA,2BAAc,EAAC;gBACb,GAAG,OAAO;gBACV,WAAW;gBACX,iBAAiB;gBACjB,GAAG,EAAE,GAAG;gBACR,SAAS,EAAE,cAAO,CAAC,SAAS;aAC7B,CAAC,CACH;YACD,IAAA,iBAAI,EAAC,OAAO,CAAC,IAAI,CAAC;SACnB,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ # Outputs
2
+ src/**/*.js
3
+ src/**/*.js.map
4
+ src/**/*.d.ts
5
+
6
+ # IDEs
7
+ .idea/
8
+ jsconfig.json
9
+ .vscode/
10
+
11
+ # Misc
12
+ node_modules/
13
+ npm-debug.log*
14
+ yarn-error.log*
15
+
16
+ # Mac OSX Finder files.
17
+ **/.DS_Store
18
+ .DS_Store
@@ -0,0 +1,3 @@
1
+ # Ignores TypeScript files, but keeps definitions.
2
+ *.ts
3
+ !*.d.ts
@@ -0,0 +1,28 @@
1
+ # Getting Started With Schematics
2
+
3
+ This repository is a basic Schematic implementation that serves as a starting point to create and publish Schematics to NPM.
4
+
5
+ ### Testing
6
+
7
+ To test locally, install `@angular-devkit/schematics-cli` globally and use the `schematics` command line tool. That tool acts the same as the `generate` command of the Angular CLI, but also has a debug mode.
8
+
9
+ Check the documentation with
10
+
11
+ ```bash
12
+ schematics --help
13
+ ```
14
+
15
+ ### Unit Testing
16
+
17
+ `npm run test` will run the unit tests, using Jasmine as a runner and test framework.
18
+
19
+ ### Publishing
20
+
21
+ To publish, simply do:
22
+
23
+ ```bash
24
+ npm run build
25
+ npm publish
26
+ ```
27
+
28
+ That's it!
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "<%= dasherize(name) %>",
3
+ "version": "0.0.0",
4
+ "description": "A schematics",
5
+ "scripts": {
6
+ "build": "tsc -p tsconfig.json",
7
+ "test": "npm run build && jasmine src/**/*_spec.js"
8
+ },
9
+ "keywords": [
10
+ "schematics"
11
+ ],
12
+ "author": "<%= author %>",
13
+ "license": "MIT",
14
+ "schematics": "./src/collection.json",
15
+ "dependencies": {
16
+ "@angular-devkit/core": "^<%= coreVersion %>",
17
+ "@angular-devkit/schematics": "^<%= schematicsVersion %>"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^20.17.19",
21
+ "@types/jasmine": "~6.0.0",
22
+ "jasmine": "~6.0.0",
23
+ "typescript": "~5.9.2"
24
+ }
25
+ }
@@ -0,0 +1,36 @@
1
+ // By default, collection.json is a Loose-format JSON5 format, which means it's loaded using a
2
+ // special loader and you can use comments, as well as single quotes or no-quotes for standard
3
+ // JavaScript identifiers.
4
+ // Note that this is only true for collection.json and it depends on the tooling itself.
5
+ // We read package.json using a require() call, which is standard JSON.
6
+ {
7
+ // This is just to indicate to your IDE that there is a schema for collection.json.
8
+ "$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
9
+
10
+ // Schematics are listed as a map of schematicName => schematicDescription.
11
+ // Each description contains a description field which is required, a factory reference,
12
+ // an extends field and a schema reference.
13
+ // The extends field points to another schematic (either in the same collection or a
14
+ // separate collection using the format collectionName:schematicName).
15
+ // The factory is required, except when using the extends field. Then the factory can
16
+ // overwrite the extended schematic factory.
17
+ "schematics": {
18
+ "my-schematic": {
19
+ "description": "An example schematic",
20
+ "factory": "./my-schematic/index#mySchematic"
21
+ },
22
+ "my-other-schematic": {
23
+ "description": "A schematic that uses another schematics.",
24
+ "factory": "./my-other-schematic"
25
+ },
26
+ "my-full-schematic": {
27
+ "description": "A schematic using a source and a schema to validate options.",
28
+ "factory": "./my-full-schematic",
29
+ "schema": "./my-full-schematic/schema.json"
30
+ },
31
+ "my-extend-schematic": {
32
+ "description": "A schematic that extends another schematic.",
33
+ "extends": "my-full-schematic"
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,6 @@
1
+
2
+ <% if (name) { %>
3
+ Hello <%= name %>, I'm a schematic.
4
+ <% } else { %>
5
+ Why don't you give me your name with --name?
6
+ <% } %>
@@ -0,0 +1,2 @@
1
+
2
+ This is test #<%= INDEX %>.
@@ -0,0 +1,53 @@
1
+ import {
2
+ Rule,
3
+ SchematicContext,
4
+ Tree,
5
+ apply,
6
+ chain,
7
+ mergeWith,
8
+ schematic,
9
+ template,
10
+ url,
11
+ } from '@angular-devkit/schematics';
12
+
13
+ // Instead of `any`, it would make sense here to get a schema-to-dts package and output the
14
+ // interfaces so you get type-safe options.
15
+ export default function (options: any): Rule {
16
+ // The chain rule allows us to chain multiple rules and apply them one after the other.
17
+ return chain([
18
+ (_tree: Tree, context: SchematicContext) => {
19
+ // Show the options for this Schematics.
20
+ context.logger.info('My Full Schematic: ' + JSON.stringify(options));
21
+ },
22
+
23
+ // The schematic Rule calls the schematic from the same collection, with the options
24
+ // passed in. Please note that if the schematic has a schema, the options will be
25
+ // validated and could throw, e.g. if a required option is missing.
26
+ schematic('my-other-schematic', { option: true }),
27
+
28
+ // The mergeWith() rule merge two trees; one that's coming from a Source (a Tree with no
29
+ // base), and the one as input to the rule. You can think of it like rebasing a Source on
30
+ // top of your current set of changes. In this case, the Source is that apply function.
31
+ // The apply() source takes a Source, and apply rules to it. In our case, the Source is
32
+ // url(), which takes an URL and returns a Tree that contains all the files from that URL
33
+ // in it. In this case, we use the relative path `./files`, and so two files are going to
34
+ // be created (test1, and test2).
35
+ // We then apply the template() rule, which takes a tree and apply two templates to it:
36
+ // path templates: this template replaces instances of __X__ in paths with the value of
37
+ // X from the options passed to template(). If the value of X is a
38
+ // function, the function will be called. If the X is undefined or it
39
+ // returns null (not empty string), the file or path will be removed.
40
+ // content template: this is similar to EJS, but does so in place (there's no special
41
+ // extension), does not support additional functions if you don't pass
42
+ // them in, and only work on text files (we use an algorithm to detect
43
+ // if a file is binary or not).
44
+ mergeWith(
45
+ apply(url('./files'), [
46
+ template({
47
+ INDEX: options.index,
48
+ name: options.name,
49
+ }),
50
+ ]),
51
+ ),
52
+ ]);
53
+ }
@@ -0,0 +1,24 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
3
+ import * as path from 'path';
4
+
5
+ // SchematicTestRunner needs an absolute path to the collection to test.
6
+ const collectionPath = path.join(__dirname, '../collection.json');
7
+
8
+ describe('my-full-schematic', () => {
9
+ it('requires required option', async () => {
10
+ // We test that
11
+ const runner = new SchematicTestRunner('schematics', collectionPath);
12
+ await expectAsync(
13
+ runner.runSchematic('my-full-schematic', {}, Tree.empty())
14
+ ).toBeRejected();
15
+ });
16
+
17
+ it('works', async () => {
18
+ const runner = new SchematicTestRunner('schematics', collectionPath);
19
+ const tree = await runner.runSchematic('my-full-schematic', { name: 'str' }, Tree.empty());
20
+
21
+ // Listing files
22
+ expect(tree.files.sort()).toEqual(['/allo', '/hola', '/test1', '/test2']);
23
+ });
24
+ });