@nestjs/schematics 12.0.0-alpha.8 → 12.0.0-alpha.9
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.
- package/dist/lib/application/application.factory.js +6 -2
- package/dist/lib/application/files/js/package.json +5 -5
- package/dist/lib/application/files/js/test/app.e2e-__specFileSuffix__.js +4 -0
- package/dist/lib/application/files/ts/test/app.e2e-__specFileSuffix__.ts +4 -0
- package/dist/lib/application/schema.json +5 -0
- package/dist/lib/class/class.factory.js +2 -0
- package/dist/lib/class/schema.json +5 -0
- package/dist/lib/controller/controller.factory.js +2 -0
- package/dist/lib/controller/schema.json +5 -0
- package/dist/lib/decorator/decorator.factory.js +7 -2
- package/dist/lib/decorator/schema.json +5 -0
- package/dist/lib/filter/filter.factory.js +2 -0
- package/dist/lib/filter/schema.json +5 -0
- package/dist/lib/gateway/gateway.factory.js +2 -0
- package/dist/lib/gateway/schema.json +5 -0
- package/dist/lib/guard/guard.factory.js +2 -0
- package/dist/lib/guard/schema.json +5 -0
- package/dist/lib/interceptor/interceptor.factory.js +2 -0
- package/dist/lib/interceptor/schema.json +5 -0
- package/dist/lib/interface/interface.factory.js +7 -2
- package/dist/lib/interface/schema.json +5 -0
- package/dist/lib/library/library.factory.js +3 -1
- package/dist/lib/library/schema.json +5 -0
- package/dist/lib/middleware/middleware.factory.js +2 -0
- package/dist/lib/middleware/schema.json +5 -0
- package/dist/lib/module/module.factory.js +3 -1
- package/dist/lib/module/schema.json +5 -0
- package/dist/lib/pipe/pipe.factory.js +2 -0
- package/dist/lib/pipe/schema.json +5 -0
- package/dist/lib/provider/provider.factory.js +2 -0
- package/dist/lib/provider/schema.json +5 -0
- package/dist/lib/resolver/resolver.factory.js +2 -0
- package/dist/lib/resolver/schema.json +5 -0
- package/dist/lib/resource/resource.factory.js +2 -0
- package/dist/lib/resource/schema.json +5 -0
- package/dist/lib/service/schema.json +5 -0
- package/dist/lib/service/service.factory.js +2 -0
- package/dist/lib/sub-app/schema.json +5 -0
- package/dist/lib/sub-app/sub-app.factory.js +2 -0
- package/dist/utils/format-files.rule.d.ts +3 -0
- package/dist/utils/format-files.rule.js +45 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +7 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
|
-
import { apply, filter, mergeWith, move, noop, template, url, } from '@angular-devkit/schematics';
|
|
2
|
+
import { apply, chain, filter, mergeWith, move, noop, template, url, } from '@angular-devkit/schematics';
|
|
3
3
|
import { basename, parse } from 'path';
|
|
4
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
4
5
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
5
6
|
import { DEFAULT_AUTHOR, DEFAULT_DESCRIPTION, DEFAULT_LANGUAGE, DEFAULT_VERSION, } from '../defaults.js';
|
|
6
7
|
export function main(options) {
|
|
@@ -9,7 +10,10 @@ export function main(options) {
|
|
|
9
10
|
? options.name
|
|
10
11
|
: options.directory;
|
|
11
12
|
options = transform(options);
|
|
12
|
-
return
|
|
13
|
+
return chain([
|
|
14
|
+
mergeWith(generate(options, path)),
|
|
15
|
+
options.format === true ? formatFiles() : noop(),
|
|
16
|
+
]);
|
|
13
17
|
}
|
|
14
18
|
function transform(options) {
|
|
15
19
|
const target = Object.assign({}, options);
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"@babel/node": "7.29.0",
|
|
27
27
|
"@babel/plugin-proposal-decorators": "7.29.0",
|
|
28
28
|
"@babel/plugin-transform-runtime": "7.29.0",
|
|
29
|
-
"@babel/preset-env": "7.29.
|
|
30
|
-
"@babel/register": "7.
|
|
31
|
-
"@babel/runtime": "7.
|
|
32
|
-
"jest": "30.2
|
|
29
|
+
"@babel/preset-env": "7.29.5",
|
|
30
|
+
"@babel/register": "7.29.3",
|
|
31
|
+
"@babel/runtime": "7.29.2",
|
|
32
|
+
"jest": "30.4.2",
|
|
33
33
|
"nodemon": "3.1.14",
|
|
34
|
-
"prettier": "3.8.
|
|
34
|
+
"prettier": "3.8.3",
|
|
35
35
|
"supertest": "7.2.2"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -79,6 +79,11 @@
|
|
|
79
79
|
"type": "string",
|
|
80
80
|
"default": "spec",
|
|
81
81
|
"description": "Specifies the file suffix of spec files."
|
|
82
|
+
},
|
|
83
|
+
"format": {
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"default": false,
|
|
86
|
+
"description": "Format generated files using Prettier if available."
|
|
82
87
|
}
|
|
83
88
|
},
|
|
84
89
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { NameParser } from '../../utils/name.parser.js';
|
|
5
6
|
import { isEsmProject, mergeSourceRoot, } from '../../utils/source-root.helpers.js';
|
|
@@ -13,6 +14,7 @@ export function main(options) {
|
|
|
13
14
|
return tree;
|
|
14
15
|
},
|
|
15
16
|
mergeWith(generate(options)),
|
|
17
|
+
options.format === true ? formatFiles() : noop(),
|
|
16
18
|
]);
|
|
17
19
|
}
|
|
18
20
|
function transform(options) {
|
|
@@ -44,6 +44,11 @@
|
|
|
44
44
|
"className": {
|
|
45
45
|
"type": "string",
|
|
46
46
|
"description": "Class name to be used internally."
|
|
47
|
+
},
|
|
48
|
+
"format": {
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"default": false,
|
|
51
|
+
"description": "Format generated files using Prettier if available."
|
|
47
52
|
}
|
|
48
53
|
},
|
|
49
54
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, branchAndMerge, chain, filter, mergeWith, move, noop, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { ModuleDeclarator, } from '../../utils/module.declarator.js';
|
|
5
6
|
import { ModuleFinder } from '../../utils/module.finder.js';
|
|
@@ -16,6 +17,7 @@ export function main(options) {
|
|
|
16
17
|
mergeSourceRoot(options),
|
|
17
18
|
mergeWith(generate(options)),
|
|
18
19
|
addDeclarationToModule(options),
|
|
20
|
+
options.format === true ? formatFiles() : noop(),
|
|
19
21
|
]))(tree, context);
|
|
20
22
|
};
|
|
21
23
|
}
|
|
@@ -49,6 +49,11 @@
|
|
|
49
49
|
"type": "string",
|
|
50
50
|
"default": "spec",
|
|
51
51
|
"description": "Specifies the file suffix of spec files."
|
|
52
|
+
},
|
|
53
|
+
"format": {
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"default": false,
|
|
56
|
+
"description": "Format generated files using Prettier if available."
|
|
52
57
|
}
|
|
53
58
|
},
|
|
54
59
|
"required": ["name"]
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
|
-
import { apply, chain, mergeWith, move, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
2
|
+
import { apply, chain, mergeWith, noop, move, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { NameParser } from '../../utils/name.parser.js';
|
|
5
6
|
import { mergeSourceRoot } from '../../utils/source-root.helpers.js';
|
|
6
7
|
export function main(options) {
|
|
7
8
|
options = transform(options);
|
|
8
|
-
return chain([
|
|
9
|
+
return chain([
|
|
10
|
+
mergeSourceRoot(options),
|
|
11
|
+
mergeWith(generate(options)),
|
|
12
|
+
options.format === true ? formatFiles() : noop(),
|
|
13
|
+
]);
|
|
9
14
|
}
|
|
10
15
|
function transform(options) {
|
|
11
16
|
const target = Object.assign({}, options);
|
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
"type": "boolean",
|
|
31
31
|
"default": true,
|
|
32
32
|
"description": "Flag to indicate if a directory is created."
|
|
33
|
+
},
|
|
34
|
+
"format": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"default": false,
|
|
37
|
+
"description": "Format generated files using Prettier if available."
|
|
33
38
|
}
|
|
34
39
|
},
|
|
35
40
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { NameParser } from '../../utils/name.parser.js';
|
|
5
6
|
import { isEsmProject, mergeSourceRoot, } from '../../utils/source-root.helpers.js';
|
|
@@ -12,6 +13,7 @@ export function main(options) {
|
|
|
12
13
|
return tree;
|
|
13
14
|
},
|
|
14
15
|
mergeWith(generate(options)),
|
|
16
|
+
options.format === true ? formatFiles() : noop(),
|
|
15
17
|
]);
|
|
16
18
|
}
|
|
17
19
|
function transform(options) {
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"type": "string",
|
|
41
41
|
"default": "spec",
|
|
42
42
|
"description": "Specifies the file suffix of spec files."
|
|
43
|
+
},
|
|
44
|
+
"format": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Format generated files using Prettier if available."
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, branchAndMerge, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { ModuleDeclarator, } from '../../utils/module.declarator.js';
|
|
5
6
|
import { ModuleFinder } from '../../utils/module.finder.js';
|
|
@@ -13,6 +14,7 @@ export function main(options) {
|
|
|
13
14
|
mergeSourceRoot(options),
|
|
14
15
|
addDeclarationToModule(options),
|
|
15
16
|
mergeWith(generate(options)),
|
|
17
|
+
options.format === true ? formatFiles() : noop(),
|
|
16
18
|
]))(tree, context);
|
|
17
19
|
};
|
|
18
20
|
}
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"type": "string",
|
|
41
41
|
"default": "spec",
|
|
42
42
|
"description": "Specifies the file suffix of spec files."
|
|
43
|
+
},
|
|
44
|
+
"format": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Format generated files using Prettier if available."
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { NameParser } from '../../utils/name.parser.js';
|
|
5
6
|
import { isEsmProject, mergeSourceRoot, } from '../../utils/source-root.helpers.js';
|
|
@@ -12,6 +13,7 @@ export function main(options) {
|
|
|
12
13
|
return tree;
|
|
13
14
|
},
|
|
14
15
|
mergeWith(generate(options)),
|
|
16
|
+
options.format === true ? formatFiles() : noop(),
|
|
15
17
|
]);
|
|
16
18
|
}
|
|
17
19
|
function transform(options) {
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"type": "string",
|
|
41
41
|
"default": "spec",
|
|
42
42
|
"description": "Specifies the file suffix of spec files."
|
|
43
|
+
},
|
|
44
|
+
"format": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Format generated files using Prettier if available."
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { NameParser } from '../../utils/name.parser.js';
|
|
5
6
|
import { isEsmProject, mergeSourceRoot, } from '../../utils/source-root.helpers.js';
|
|
@@ -12,6 +13,7 @@ export function main(options) {
|
|
|
12
13
|
return tree;
|
|
13
14
|
},
|
|
14
15
|
mergeWith(generate(options)),
|
|
16
|
+
options.format === true ? formatFiles() : noop(),
|
|
15
17
|
]);
|
|
16
18
|
}
|
|
17
19
|
function transform(options) {
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"type": "string",
|
|
41
41
|
"default": "spec",
|
|
42
42
|
"description": "Specifies the file suffix of spec files."
|
|
43
|
+
},
|
|
44
|
+
"format": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Format generated files using Prettier if available."
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"required": ["name"]
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
|
-
import { apply, chain, mergeWith, move, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
2
|
+
import { apply, chain, mergeWith, noop, move, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { NameParser } from '../../utils/name.parser.js';
|
|
5
6
|
import { mergeSourceRoot } from '../../utils/source-root.helpers.js';
|
|
6
7
|
export function main(options) {
|
|
7
8
|
options = transform(options);
|
|
8
|
-
return chain([
|
|
9
|
+
return chain([
|
|
10
|
+
mergeSourceRoot(options),
|
|
11
|
+
mergeWith(generate(options)),
|
|
12
|
+
options.format === true ? formatFiles() : noop(),
|
|
13
|
+
]);
|
|
9
14
|
}
|
|
10
15
|
function transform(options) {
|
|
11
16
|
const target = Object.assign({}, options);
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"type": "boolean",
|
|
27
27
|
"default": true,
|
|
28
28
|
"description": "Flag to indicate if a directory is created."
|
|
29
|
+
},
|
|
30
|
+
"format": {
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"default": false,
|
|
33
|
+
"description": "Format generated files using Prettier if available."
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"required": ["name"]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join, normalize, strings } from '@angular-devkit/core';
|
|
2
|
-
import { apply, branchAndMerge, chain, mergeWith, move, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
2
|
+
import { apply, branchAndMerge, chain, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
3
|
import { parse } from 'jsonc-parser';
|
|
4
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
4
5
|
import { createModuleNameMapper, inPlaceSortByKeys, normalizeToKebabOrSnakeCase, } from '../../utils/index.js';
|
|
5
6
|
import { DEFAULT_LANGUAGE, DEFAULT_LIB_PATH, DEFAULT_PATH_NAME, PROJECT_TYPE, } from '../defaults.js';
|
|
6
7
|
import { FileSystemReader } from '../readers/index.js';
|
|
@@ -17,6 +18,7 @@ export function main(options) {
|
|
|
17
18
|
return tree;
|
|
18
19
|
},
|
|
19
20
|
branchAndMerge(mergeWith(generate(options))),
|
|
21
|
+
options.format === true ? formatFiles() : noop(),
|
|
20
22
|
]);
|
|
21
23
|
}
|
|
22
24
|
function getDefaultLibraryPrefix(defaultLibraryPrefix = '@app') {
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"type": "string",
|
|
37
37
|
"default": "spec",
|
|
38
38
|
"description": "Specifies the file suffix of spec files."
|
|
39
|
+
},
|
|
40
|
+
"format": {
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"default": false,
|
|
43
|
+
"description": "Format generated files using Prettier if available."
|
|
39
44
|
}
|
|
40
45
|
},
|
|
41
46
|
"required": ["name", "prefix"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { NameParser } from '../../utils/name.parser.js';
|
|
5
6
|
import { isEsmProject, mergeSourceRoot, } from '../../utils/source-root.helpers.js';
|
|
@@ -12,6 +13,7 @@ export function main(options) {
|
|
|
12
13
|
return tree;
|
|
13
14
|
},
|
|
14
15
|
mergeWith(generate(options)),
|
|
16
|
+
options.format === true ? formatFiles() : noop(),
|
|
15
17
|
]);
|
|
16
18
|
}
|
|
17
19
|
function transform(options) {
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"type": "string",
|
|
41
41
|
"default": "spec",
|
|
42
42
|
"description": "Specifies the file suffix of spec files."
|
|
43
|
+
},
|
|
44
|
+
"format": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Format generated files using Prettier if available."
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
|
-
import { apply, branchAndMerge, chain, mergeWith, move, template, url, } from '@angular-devkit/schematics';
|
|
2
|
+
import { apply, branchAndMerge, chain, mergeWith, move, noop, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { ModuleDeclarator, } from '../../utils/module.declarator.js';
|
|
5
6
|
import { ModuleFinder } from '../../utils/module.finder.js';
|
|
@@ -12,6 +13,7 @@ export function main(options) {
|
|
|
12
13
|
mergeSourceRoot(options),
|
|
13
14
|
addDeclarationToModule(options),
|
|
14
15
|
mergeWith(generate(options)),
|
|
16
|
+
options.format === true ? formatFiles() : noop(),
|
|
15
17
|
]))(tree, context);
|
|
16
18
|
};
|
|
17
19
|
}
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"type": "boolean",
|
|
41
41
|
"default": false,
|
|
42
42
|
"description": "Flag to indicate if a directory is created."
|
|
43
|
+
},
|
|
44
|
+
"format": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Format generated files using Prettier if available."
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { NameParser } from '../../utils/name.parser.js';
|
|
5
6
|
import { isEsmProject, mergeSourceRoot, } from '../../utils/source-root.helpers.js';
|
|
@@ -12,6 +13,7 @@ export function main(options) {
|
|
|
12
13
|
return tree;
|
|
13
14
|
},
|
|
14
15
|
mergeWith(generate(options)),
|
|
16
|
+
options.format === true ? formatFiles() : noop(),
|
|
15
17
|
]);
|
|
16
18
|
}
|
|
17
19
|
function transform(options) {
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"type": "string",
|
|
41
41
|
"default": "spec",
|
|
42
42
|
"description": "Specifies the file suffix of spec files."
|
|
43
|
+
},
|
|
44
|
+
"format": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Format generated files using Prettier if available."
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, branchAndMerge, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { ModuleDeclarator, } from '../../utils/module.declarator.js';
|
|
5
6
|
import { ModuleFinder } from '../../utils/module.finder.js';
|
|
@@ -13,6 +14,7 @@ export function main(options) {
|
|
|
13
14
|
mergeSourceRoot(options),
|
|
14
15
|
addDeclarationToModule(options),
|
|
15
16
|
mergeWith(generate(options)),
|
|
17
|
+
options.format === true ? formatFiles() : noop(),
|
|
16
18
|
]))(tree, context);
|
|
17
19
|
};
|
|
18
20
|
}
|
|
@@ -44,6 +44,11 @@
|
|
|
44
44
|
"className": {
|
|
45
45
|
"type": "string",
|
|
46
46
|
"description": "Class name to be used internally."
|
|
47
|
+
},
|
|
48
|
+
"format": {
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"default": false,
|
|
51
|
+
"description": "Format generated files using Prettier if available."
|
|
47
52
|
}
|
|
48
53
|
},
|
|
49
54
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, branchAndMerge, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { ModuleDeclarator, } from '../../utils/module.declarator.js';
|
|
5
6
|
import { ModuleFinder } from '../../utils/module.finder.js';
|
|
@@ -13,6 +14,7 @@ export function main(options) {
|
|
|
13
14
|
mergeSourceRoot(options),
|
|
14
15
|
addDeclarationToModule(options),
|
|
15
16
|
mergeWith(generate(options)),
|
|
17
|
+
options.format === true ? formatFiles() : noop(),
|
|
16
18
|
]))(tree, context);
|
|
17
19
|
};
|
|
18
20
|
}
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"type": "string",
|
|
41
41
|
"default": "spec",
|
|
42
42
|
"description": "Specifies the file suffix of spec files."
|
|
43
|
+
},
|
|
44
|
+
"format": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Format generated files using Prettier if available."
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"required": ["name"]
|
|
@@ -5,6 +5,7 @@ import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks/index.j
|
|
|
5
5
|
import pluralize from 'pluralize';
|
|
6
6
|
import { ModuleDeclarator, ModuleFinder, } from '../../index.js';
|
|
7
7
|
import { addPackageJsonDependency, getPackageJsonDependency, NodeDependencyType, } from '../../utils/dependencies.utils.js';
|
|
8
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
8
9
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
9
10
|
import { NameParser } from '../../utils/name.parser.js';
|
|
10
11
|
import { isEsmProject, mergeSourceRoot, } from '../../utils/source-root.helpers.js';
|
|
@@ -17,6 +18,7 @@ export function main(options) {
|
|
|
17
18
|
mergeSourceRoot(options),
|
|
18
19
|
addDeclarationToModule(options),
|
|
19
20
|
mergeWith(generate(options)),
|
|
21
|
+
options.format === true ? formatFiles() : noop(),
|
|
20
22
|
]))(tree, context);
|
|
21
23
|
};
|
|
22
24
|
}
|
|
@@ -89,6 +89,11 @@
|
|
|
89
89
|
"message": "Would you like to generate CRUD entry points?",
|
|
90
90
|
"type": "confirmation"
|
|
91
91
|
}
|
|
92
|
+
},
|
|
93
|
+
"format": {
|
|
94
|
+
"type": "boolean",
|
|
95
|
+
"default": false,
|
|
96
|
+
"description": "Format generated files using Prettier if available."
|
|
92
97
|
}
|
|
93
98
|
},
|
|
94
99
|
"required": ["name"]
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"type": "string",
|
|
41
41
|
"default": "spec",
|
|
42
42
|
"description": "Specifies the file suffix of spec files."
|
|
43
|
+
},
|
|
44
|
+
"format": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Format generated files using Prettier if available."
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"required": ["name"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, strings } from '@angular-devkit/core';
|
|
2
2
|
import { apply, branchAndMerge, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
3
4
|
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
5
|
import { ModuleDeclarator, } from '../../utils/module.declarator.js';
|
|
5
6
|
import { ModuleFinder } from '../../utils/module.finder.js';
|
|
@@ -16,6 +17,7 @@ export function main(options) {
|
|
|
16
17
|
mergeSourceRoot(options),
|
|
17
18
|
addDeclarationToModule(options),
|
|
18
19
|
mergeWith(generate(options)),
|
|
20
|
+
options.format === true ? formatFiles() : noop(),
|
|
19
21
|
]))(tree, context);
|
|
20
22
|
};
|
|
21
23
|
}
|
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
"type": "string",
|
|
32
32
|
"default": "spec",
|
|
33
33
|
"description": "Specifies the file suffix of spec files."
|
|
34
|
+
},
|
|
35
|
+
"format": {
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"default": false,
|
|
38
|
+
"description": "Format generated files using Prettier if available."
|
|
34
39
|
}
|
|
35
40
|
},
|
|
36
41
|
"required": ["name"]
|
|
@@ -2,6 +2,7 @@ import { join, normalize, strings } from '@angular-devkit/core';
|
|
|
2
2
|
import { apply, branchAndMerge, chain, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
3
|
import { existsSync, readFileSync } from 'fs';
|
|
4
4
|
import { parse, stringify } from 'comment-json';
|
|
5
|
+
import { formatFiles } from '../../utils/format-files.rule.js';
|
|
5
6
|
import { inPlaceSortByKeys, normalizeToKebabOrSnakeCase, } from '../../utils/index.js';
|
|
6
7
|
import { DEFAULT_APPS_PATH, DEFAULT_APP_NAME, DEFAULT_DIR_ENTRY_APP, DEFAULT_LANGUAGE, DEFAULT_LIB_PATH, DEFAULT_PATH_NAME, PROJECT_TYPE, TEST_ENV, } from '../defaults.js';
|
|
7
8
|
import { isEsmProject } from '../../utils/source-root.helpers.js';
|
|
@@ -24,6 +25,7 @@ export function main(options) {
|
|
|
24
25
|
return tree;
|
|
25
26
|
},
|
|
26
27
|
branchAndMerge(mergeWith(generate(options))),
|
|
28
|
+
options.format === true ? formatFiles() : noop(),
|
|
27
29
|
]);
|
|
28
30
|
}
|
|
29
31
|
function getAppNameFromPackageJson() {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const FORMATTABLE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'];
|
|
2
|
+
export function formatFiles(paths) {
|
|
3
|
+
return async (tree, _context) => {
|
|
4
|
+
let prettier;
|
|
5
|
+
try {
|
|
6
|
+
prettier = await import('prettier');
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return tree;
|
|
10
|
+
}
|
|
11
|
+
const candidates = (paths ??
|
|
12
|
+
tree.actions
|
|
13
|
+
.filter((action) => action.kind === 'c' ||
|
|
14
|
+
action.kind === 'o' ||
|
|
15
|
+
action.kind === 'r')
|
|
16
|
+
.map((action) => action.path))
|
|
17
|
+
.map((p) => (typeof p === 'string' ? p : String(p)))
|
|
18
|
+
.filter((p) => FORMATTABLE_EXTENSIONS.some((ext) => p.endsWith(ext)));
|
|
19
|
+
const uniquePaths = Array.from(new Set(candidates));
|
|
20
|
+
for (const filePath of uniquePaths) {
|
|
21
|
+
if (!tree.exists(filePath)) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const buffer = tree.read(filePath);
|
|
25
|
+
if (!buffer) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const source = buffer.toString('utf-8');
|
|
29
|
+
try {
|
|
30
|
+
const resolvedOptions = (await prettier.resolveConfig(filePath)) ?? undefined;
|
|
31
|
+
const formatted = await prettier.format(source, {
|
|
32
|
+
...resolvedOptions,
|
|
33
|
+
filepath: filePath,
|
|
34
|
+
});
|
|
35
|
+
if (formatted !== source) {
|
|
36
|
+
tree.overwrite(filePath, formatted);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return tree;
|
|
44
|
+
};
|
|
45
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/schematics",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.9",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@schematics)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -65,8 +65,14 @@
|
|
|
65
65
|
"vitest": "4.0.18"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
+
"prettier": "^3.0.0",
|
|
68
69
|
"typescript": ">=6.0.0"
|
|
69
70
|
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"prettier": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
70
76
|
"schematics": "./dist/collection.json",
|
|
71
77
|
"lint-staged": {
|
|
72
78
|
"**/*.{ts,json}": []
|