@nestjs/schematics 11.0.9 → 12.0.0-alpha.1
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/files/js/package.json +10 -10
- package/dist/lib/application/files/ts/package.json +3 -3
- package/dist/lib/application/files/ts/tsconfig.json +0 -1
- package/dist/lib/application/files/ts-esm/.prettierrc +4 -0
- package/dist/lib/application/files/ts-esm/README.md +98 -0
- package/dist/lib/application/files/ts-esm/eslint.config.mjs +34 -0
- package/dist/lib/application/files/ts-esm/nest-cli.json +8 -0
- package/dist/lib/application/files/ts-esm/package.json +50 -0
- package/dist/lib/application/files/ts-esm/src/app.controller.__specFileSuffix__.ts +22 -0
- package/dist/lib/application/files/ts-esm/src/app.controller.ts +12 -0
- package/dist/lib/application/files/ts-esm/src/app.module.ts +10 -0
- package/dist/lib/application/files/ts-esm/src/app.service.ts +8 -0
- package/dist/lib/application/files/ts-esm/src/main.ts +8 -0
- package/dist/lib/application/files/ts-esm/test/app.e2e-__specFileSuffix__.ts +25 -0
- package/dist/lib/application/files/ts-esm/tsconfig.build.json +4 -0
- package/dist/lib/application/files/ts-esm/tsconfig.json +24 -0
- package/dist/lib/application/files/ts-esm/vitest.config.e2e.ts +10 -0
- package/dist/lib/application/files/ts-esm/vitest.config.ts +10 -0
- package/dist/lib/application/schema.json +14 -0
- package/dist/lib/library/files/ts/tsconfig.lib.json +1 -0
- package/dist/lib/sub-app/files/ts/tsconfig.app.json +1 -0
- package/dist/lib/sub-app/workspace/ts/tsconfig.app.json +1 -0
- package/package.json +21 -49
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -18
- package/dist/lib/application/application.factory.d.ts +0 -3
- package/dist/lib/application/application.factory.js +0 -63
- package/dist/lib/class/class.factory.d.ts +0 -3
- package/dist/lib/class/class.factory.js +0 -51
- package/dist/lib/client-app/angular/angular.factory.d.ts +0 -3
- package/dist/lib/client-app/angular/angular.factory.js +0 -103
- package/dist/lib/configuration/configuration.factory.d.ts +0 -3
- package/dist/lib/configuration/configuration.factory.js +0 -27
- package/dist/lib/controller/controller.factory.d.ts +0 -3
- package/dist/lib/controller/controller.factory.js +0 -72
- package/dist/lib/decorator/decorator.factory.d.ts +0 -3
- package/dist/lib/decorator/decorator.factory.js +0 -35
- package/dist/lib/defaults.d.ts +0 -14
- package/dist/lib/defaults.js +0 -17
- package/dist/lib/filter/filter.factory.d.ts +0 -3
- package/dist/lib/filter/filter.factory.js +0 -43
- package/dist/lib/gateway/gateway.factory.d.ts +0 -3
- package/dist/lib/gateway/gateway.factory.js +0 -72
- package/dist/lib/guard/guard.factory.d.ts +0 -3
- package/dist/lib/guard/guard.factory.js +0 -43
- package/dist/lib/interceptor/interceptor.factory.d.ts +0 -3
- package/dist/lib/interceptor/interceptor.factory.js +0 -44
- package/dist/lib/interface/interface.factory.d.ts +0 -3
- package/dist/lib/interface/interface.factory.js +0 -34
- package/dist/lib/library/library.factory.d.ts +0 -3
- package/dist/lib/library/library.factory.js +0 -216
- package/dist/lib/middleware/middleware.factory.d.ts +0 -3
- package/dist/lib/middleware/middleware.factory.js +0 -43
- package/dist/lib/module/module.factory.d.ts +0 -3
- package/dist/lib/module/module.factory.js +0 -60
- package/dist/lib/pipe/pipe.factory.d.ts +0 -3
- package/dist/lib/pipe/pipe.factory.js +0 -44
- package/dist/lib/provider/provider.factory.d.ts +0 -3
- package/dist/lib/provider/provider.factory.js +0 -76
- package/dist/lib/readers/file-system.reader.d.ts +0 -10
- package/dist/lib/readers/file-system.reader.js +0 -45
- package/dist/lib/readers/index.d.ts +0 -2
- package/dist/lib/readers/index.js +0 -18
- package/dist/lib/readers/reader.d.ts +0 -7
- package/dist/lib/readers/reader.js +0 -2
- package/dist/lib/resolver/resolver.factory.d.ts +0 -3
- package/dist/lib/resolver/resolver.factory.js +0 -71
- package/dist/lib/resource/resource.factory.d.ts +0 -3
- package/dist/lib/resource/resource.factory.js +0 -145
- package/dist/lib/service/service.factory.d.ts +0 -3
- package/dist/lib/service/service.factory.js +0 -74
- package/dist/lib/sub-app/sub-app.factory.d.ts +0 -3
- package/dist/lib/sub-app/sub-app.factory.js +0 -271
- package/dist/utils/dependencies.utils.d.ts +0 -15
- package/dist/utils/dependencies.utils.js +0 -42
- package/dist/utils/formatting.d.ts +0 -1
- package/dist/utils/formatting.js +0 -12
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.js +0 -27
- package/dist/utils/jest-module-mapper.d.ts +0 -1
- package/dist/utils/jest-module-mapper.js +0 -9
- package/dist/utils/json-file.util.d.ts +0 -15
- package/dist/utils/json-file.util.js +0 -72
- package/dist/utils/metadata.manager.d.ts +0 -13
- package/dist/utils/metadata.manager.js +0 -175
- package/dist/utils/module-import.declarator.d.ts +0 -10
- package/dist/utils/module-import.declarator.js +0 -40
- package/dist/utils/module-metadata.declarator.d.ts +0 -4
- package/dist/utils/module-metadata.declarator.js +0 -12
- package/dist/utils/module.declarator.d.ts +0 -23
- package/dist/utils/module.declarator.js +0 -34
- package/dist/utils/module.finder.d.ts +0 -13
- package/dist/utils/module.finder.js +0 -25
- package/dist/utils/name.parser.d.ts +0 -12
- package/dist/utils/name.parser.js +0 -17
- package/dist/utils/object-sorting.d.ts +0 -1
- package/dist/utils/object-sorting.js +0 -13
- package/dist/utils/path.solver.d.ts +0 -4
- package/dist/utils/path.solver.js +0 -12
- package/dist/utils/source-root.helpers.d.ts +0 -6
- package/dist/utils/source-root.helpers.js +0 -24
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = main;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const formatting_1 = require("../../utils/formatting");
|
|
7
|
-
const name_parser_1 = require("../../utils/name.parser");
|
|
8
|
-
const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
9
|
-
function main(options) {
|
|
10
|
-
options = transform(options);
|
|
11
|
-
return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
|
|
12
|
-
}
|
|
13
|
-
function transform(options) {
|
|
14
|
-
const target = Object.assign({}, options);
|
|
15
|
-
if (!target.name) {
|
|
16
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
17
|
-
}
|
|
18
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
19
|
-
target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
|
|
20
|
-
target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
|
|
21
|
-
target.path = target.flat
|
|
22
|
-
? target.path
|
|
23
|
-
: (0, core_1.join)(target.path, target.name);
|
|
24
|
-
return target;
|
|
25
|
-
}
|
|
26
|
-
function generate(options) {
|
|
27
|
-
return (context) => (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
28
|
-
(0, schematics_1.template)({
|
|
29
|
-
...core_1.strings,
|
|
30
|
-
...options,
|
|
31
|
-
}),
|
|
32
|
-
(0, schematics_1.move)(options.path),
|
|
33
|
-
])(context);
|
|
34
|
-
}
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = main;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const jsonc_parser_1 = require("jsonc-parser");
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
8
|
-
const defaults_1 = require("../defaults");
|
|
9
|
-
const readers_1 = require("../readers");
|
|
10
|
-
function main(options) {
|
|
11
|
-
options = transform(options);
|
|
12
|
-
return (0, schematics_1.chain)([
|
|
13
|
-
addLibraryToCliOptions(options.path, options.name),
|
|
14
|
-
updatePackageJson(options),
|
|
15
|
-
updateJestEndToEnd(options),
|
|
16
|
-
updateTsConfig(options.name, options.prefix, options.path),
|
|
17
|
-
(0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(generate(options))),
|
|
18
|
-
]);
|
|
19
|
-
}
|
|
20
|
-
function getDefaultLibraryPrefix(defaultLibraryPrefix = '@app') {
|
|
21
|
-
const fileSystemReader = new readers_1.FileSystemReader(process.cwd());
|
|
22
|
-
const content = fileSystemReader.readSyncAnyOf([
|
|
23
|
-
'nest-cli.json',
|
|
24
|
-
'.nestcli.json',
|
|
25
|
-
'.nest-cli.json',
|
|
26
|
-
'nest.json',
|
|
27
|
-
]);
|
|
28
|
-
try {
|
|
29
|
-
const nestJson = JSON.parse(content || '{}');
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(nestJson, 'defaultLibraryPrefix')) {
|
|
31
|
-
return nestJson['defaultLibraryPrefix'];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return defaultLibraryPrefix;
|
|
36
|
-
}
|
|
37
|
-
return defaultLibraryPrefix;
|
|
38
|
-
}
|
|
39
|
-
function transform(options) {
|
|
40
|
-
const target = Object.assign({}, options);
|
|
41
|
-
const defaultSourceRoot = options.rootDir !== undefined ? options.rootDir : defaults_1.DEFAULT_LIB_PATH;
|
|
42
|
-
if (!target.name) {
|
|
43
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
44
|
-
}
|
|
45
|
-
target.language = target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
|
|
46
|
-
target.name = (0, utils_1.normalizeToKebabOrSnakeCase)(target.name);
|
|
47
|
-
target.path =
|
|
48
|
-
target.path !== undefined
|
|
49
|
-
? (0, core_1.join)((0, core_1.normalize)(defaultSourceRoot), target.path)
|
|
50
|
-
: (0, core_1.normalize)(defaultSourceRoot);
|
|
51
|
-
target.prefix = target.prefix || getDefaultLibraryPrefix();
|
|
52
|
-
return target;
|
|
53
|
-
}
|
|
54
|
-
function updatePackageJson(options) {
|
|
55
|
-
return (host) => {
|
|
56
|
-
if (!host.exists('package.json')) {
|
|
57
|
-
return host;
|
|
58
|
-
}
|
|
59
|
-
const distRoot = (0, core_1.join)(options.path, options.name, 'src');
|
|
60
|
-
const packageKey = options.prefix
|
|
61
|
-
? options.prefix + '/' + options.name
|
|
62
|
-
: options.name;
|
|
63
|
-
return updateJsonFile(host, 'package.json', (packageJson) => {
|
|
64
|
-
updateNpmScripts(packageJson.scripts, options);
|
|
65
|
-
updateJestConfig(packageJson.jest, options, packageKey, distRoot);
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function updateJestConfig(jestOptions, options, packageKey, distRoot) {
|
|
70
|
-
if (!jestOptions) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (jestOptions.rootDir === defaults_1.DEFAULT_PATH_NAME) {
|
|
74
|
-
jestOptions.rootDir = '.';
|
|
75
|
-
jestOptions.coverageDirectory = './coverage';
|
|
76
|
-
}
|
|
77
|
-
const defaultSourceRoot = options.rootDir !== undefined ? options.rootDir : defaults_1.DEFAULT_LIB_PATH;
|
|
78
|
-
const jestSourceRoot = `<rootDir>/${defaultSourceRoot}/`;
|
|
79
|
-
if (!jestOptions.roots) {
|
|
80
|
-
jestOptions.roots = ['<rootDir>/src/', jestSourceRoot];
|
|
81
|
-
}
|
|
82
|
-
else if (jestOptions.roots.indexOf(jestSourceRoot) < 0) {
|
|
83
|
-
jestOptions.roots.push(jestSourceRoot);
|
|
84
|
-
}
|
|
85
|
-
if (!jestOptions.moduleNameMapper) {
|
|
86
|
-
jestOptions.moduleNameMapper = {};
|
|
87
|
-
}
|
|
88
|
-
const packageRoot = (0, core_1.join)('<rootDir>', distRoot);
|
|
89
|
-
const newMapper = (0, utils_1.createModuleNameMapper)(packageKey, packageRoot);
|
|
90
|
-
Object.assign(jestOptions.moduleNameMapper, newMapper);
|
|
91
|
-
(0, utils_1.inPlaceSortByKeys)(jestOptions.moduleNameMapper);
|
|
92
|
-
}
|
|
93
|
-
function updateNpmScripts(scripts, options) {
|
|
94
|
-
if (!scripts) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const defaultFormatScriptName = 'format';
|
|
98
|
-
if (!scripts[defaultFormatScriptName]) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (scripts[defaultFormatScriptName] &&
|
|
102
|
-
scripts[defaultFormatScriptName].indexOf(defaults_1.DEFAULT_PATH_NAME) >= 0) {
|
|
103
|
-
const defaultSourceRoot = options.rootDir !== undefined ? options.rootDir : defaults_1.DEFAULT_LIB_PATH;
|
|
104
|
-
scripts[defaultFormatScriptName] =
|
|
105
|
-
`prettier --write "src/**/*.ts" "test/**/*.ts" "${defaultSourceRoot}/**/*.ts"`;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function updateJestEndToEnd(options) {
|
|
109
|
-
return (host) => {
|
|
110
|
-
const pathToFile = (0, core_1.join)('test', 'jest-e2e.json');
|
|
111
|
-
if (!host.exists(pathToFile)) {
|
|
112
|
-
return host;
|
|
113
|
-
}
|
|
114
|
-
const distRoot = (0, core_1.join)(options.path, options.name, 'src');
|
|
115
|
-
const packageKey = options.prefix
|
|
116
|
-
? options.prefix + '/' + options.name
|
|
117
|
-
: options.name;
|
|
118
|
-
return updateJsonFile(host, pathToFile, (jestOptions) => {
|
|
119
|
-
if (!jestOptions.moduleNameMapper) {
|
|
120
|
-
jestOptions.moduleNameMapper = {};
|
|
121
|
-
}
|
|
122
|
-
const packageRoot = '<rootDir>/../' + distRoot;
|
|
123
|
-
const newMapper = (0, utils_1.createModuleNameMapper)(packageKey, packageRoot);
|
|
124
|
-
Object.assign(jestOptions.moduleNameMapper, newMapper);
|
|
125
|
-
(0, utils_1.inPlaceSortByKeys)(jestOptions.moduleNameMapper);
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function updateJsonFile(host, path, callback) {
|
|
130
|
-
const source = host.read(path);
|
|
131
|
-
if (source) {
|
|
132
|
-
const sourceText = source.toString('utf-8');
|
|
133
|
-
const json = (0, jsonc_parser_1.parse)(sourceText);
|
|
134
|
-
callback(json);
|
|
135
|
-
host.overwrite(path, JSON.stringify(json, null, 2));
|
|
136
|
-
}
|
|
137
|
-
return host;
|
|
138
|
-
}
|
|
139
|
-
function updateTsConfig(packageName, packagePrefix, root) {
|
|
140
|
-
return (host) => {
|
|
141
|
-
if (!host.exists('tsconfig.json')) {
|
|
142
|
-
return host;
|
|
143
|
-
}
|
|
144
|
-
const distRoot = (0, core_1.join)(root, packageName, 'src');
|
|
145
|
-
const packageKey = packagePrefix
|
|
146
|
-
? packagePrefix + '/' + packageName
|
|
147
|
-
: packageName;
|
|
148
|
-
return updateJsonFile(host, 'tsconfig.json', (tsconfig) => {
|
|
149
|
-
if (!tsconfig.compilerOptions) {
|
|
150
|
-
tsconfig.compilerOptions = {};
|
|
151
|
-
}
|
|
152
|
-
if (!tsconfig.compilerOptions.baseUrl) {
|
|
153
|
-
tsconfig.compilerOptions.baseUrl = './';
|
|
154
|
-
}
|
|
155
|
-
if (!tsconfig.compilerOptions.paths) {
|
|
156
|
-
tsconfig.compilerOptions.paths = {};
|
|
157
|
-
}
|
|
158
|
-
if (!tsconfig.compilerOptions.paths[packageKey]) {
|
|
159
|
-
tsconfig.compilerOptions.paths[packageKey] = [];
|
|
160
|
-
}
|
|
161
|
-
tsconfig.compilerOptions.paths[packageKey].push(distRoot);
|
|
162
|
-
const deepPackagePath = packageKey + '/*';
|
|
163
|
-
if (!tsconfig.compilerOptions.paths[deepPackagePath]) {
|
|
164
|
-
tsconfig.compilerOptions.paths[deepPackagePath] = [];
|
|
165
|
-
}
|
|
166
|
-
tsconfig.compilerOptions.paths[deepPackagePath].push(distRoot + '/*');
|
|
167
|
-
(0, utils_1.inPlaceSortByKeys)(tsconfig.compilerOptions.paths);
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function addLibraryToCliOptions(projectRoot, projectName) {
|
|
172
|
-
const rootPath = (0, core_1.join)(projectRoot, projectName);
|
|
173
|
-
const project = {
|
|
174
|
-
type: defaults_1.PROJECT_TYPE.LIBRARY,
|
|
175
|
-
root: rootPath,
|
|
176
|
-
entryFile: 'index',
|
|
177
|
-
sourceRoot: (0, core_1.join)(rootPath, 'src'),
|
|
178
|
-
compilerOptions: {
|
|
179
|
-
tsConfigPath: (0, core_1.join)(rootPath, 'tsconfig.lib.json'),
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
return (host) => {
|
|
183
|
-
const nestFileExists = host.exists('nest.json');
|
|
184
|
-
let nestCliFileExists = host.exists('nest-cli.json');
|
|
185
|
-
if (!nestCliFileExists && !nestFileExists) {
|
|
186
|
-
host.create('nest-cli.json', '{}');
|
|
187
|
-
nestCliFileExists = true;
|
|
188
|
-
}
|
|
189
|
-
return updateJsonFile(host, nestCliFileExists ? 'nest-cli.json' : 'nest.json', (optionsFile) => {
|
|
190
|
-
if (!optionsFile.projects) {
|
|
191
|
-
optionsFile.projects = {};
|
|
192
|
-
}
|
|
193
|
-
if (!optionsFile.compilerOptions) {
|
|
194
|
-
optionsFile.compilerOptions = {};
|
|
195
|
-
}
|
|
196
|
-
if (optionsFile.compilerOptions.webpack === undefined) {
|
|
197
|
-
optionsFile.compilerOptions.webpack = true;
|
|
198
|
-
}
|
|
199
|
-
if (optionsFile.projects[projectName]) {
|
|
200
|
-
throw new schematics_1.SchematicsException(`Project "${projectName}" exists in this workspace already.`);
|
|
201
|
-
}
|
|
202
|
-
optionsFile.projects[projectName] = project;
|
|
203
|
-
(0, utils_1.inPlaceSortByKeys)(optionsFile.projects);
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
function generate(options) {
|
|
208
|
-
const path = (0, core_1.join)(options.path, options.name);
|
|
209
|
-
return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
210
|
-
(0, schematics_1.template)({
|
|
211
|
-
...core_1.strings,
|
|
212
|
-
...options,
|
|
213
|
-
}),
|
|
214
|
-
(0, schematics_1.move)(path),
|
|
215
|
-
]);
|
|
216
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = main;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const formatting_1 = require("../../utils/formatting");
|
|
7
|
-
const name_parser_1 = require("../../utils/name.parser");
|
|
8
|
-
const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
9
|
-
function main(options) {
|
|
10
|
-
options = transform(options);
|
|
11
|
-
return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
|
|
12
|
-
}
|
|
13
|
-
function transform(options) {
|
|
14
|
-
const target = Object.assign({}, options);
|
|
15
|
-
if (!target.name) {
|
|
16
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
17
|
-
}
|
|
18
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
19
|
-
target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
|
|
20
|
-
target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
|
|
21
|
-
target.language = target.language !== undefined ? target.language : 'ts';
|
|
22
|
-
target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
|
|
23
|
-
target.path = target.flat
|
|
24
|
-
? target.path
|
|
25
|
-
: (0, core_1.join)(target.path, target.name);
|
|
26
|
-
return target;
|
|
27
|
-
}
|
|
28
|
-
function generate(options) {
|
|
29
|
-
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
30
|
-
options.spec
|
|
31
|
-
? (0, schematics_1.noop)()
|
|
32
|
-
: (0, schematics_1.filter)((path) => {
|
|
33
|
-
const languageExtension = options.language || 'ts';
|
|
34
|
-
const suffix = `.__specFileSuffix__.${languageExtension}`;
|
|
35
|
-
return !path.endsWith(suffix);
|
|
36
|
-
}),
|
|
37
|
-
(0, schematics_1.template)({
|
|
38
|
-
...core_1.strings,
|
|
39
|
-
...options,
|
|
40
|
-
}),
|
|
41
|
-
(0, schematics_1.move)(options.path),
|
|
42
|
-
])(context);
|
|
43
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = main;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const formatting_1 = require("../../utils/formatting");
|
|
7
|
-
const module_declarator_1 = require("../../utils/module.declarator");
|
|
8
|
-
const module_finder_1 = require("../../utils/module.finder");
|
|
9
|
-
const name_parser_1 = require("../../utils/name.parser");
|
|
10
|
-
const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
11
|
-
function main(options) {
|
|
12
|
-
options = transform(options);
|
|
13
|
-
return (tree, context) => {
|
|
14
|
-
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
15
|
-
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
16
|
-
addDeclarationToModule(options),
|
|
17
|
-
(0, schematics_1.mergeWith)(generate(options)),
|
|
18
|
-
]))(tree, context);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function transform(source) {
|
|
22
|
-
const target = Object.assign({}, source);
|
|
23
|
-
target.metadata = 'imports';
|
|
24
|
-
target.type = 'module';
|
|
25
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
26
|
-
target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
|
|
27
|
-
target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
|
|
28
|
-
target.language = target.language !== undefined ? target.language : 'ts';
|
|
29
|
-
target.path = target.flat
|
|
30
|
-
? target.path
|
|
31
|
-
: (0, core_1.join)(target.path, target.name);
|
|
32
|
-
return target;
|
|
33
|
-
}
|
|
34
|
-
function generate(options) {
|
|
35
|
-
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
36
|
-
(0, schematics_1.template)({
|
|
37
|
-
...core_1.strings,
|
|
38
|
-
...options,
|
|
39
|
-
}),
|
|
40
|
-
(0, schematics_1.move)(options.path),
|
|
41
|
-
])(context);
|
|
42
|
-
}
|
|
43
|
-
function addDeclarationToModule(options) {
|
|
44
|
-
return (tree) => {
|
|
45
|
-
if (options.skipImport !== undefined && options.skipImport) {
|
|
46
|
-
return tree;
|
|
47
|
-
}
|
|
48
|
-
options.module = new module_finder_1.ModuleFinder(tree).find({
|
|
49
|
-
name: options.name,
|
|
50
|
-
path: options.path,
|
|
51
|
-
});
|
|
52
|
-
if (!options.module) {
|
|
53
|
-
return tree;
|
|
54
|
-
}
|
|
55
|
-
const content = tree.read(options.module).toString();
|
|
56
|
-
const declarator = new module_declarator_1.ModuleDeclarator();
|
|
57
|
-
tree.overwrite(options.module, declarator.declare(content, options));
|
|
58
|
-
return tree;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = main;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const formatting_1 = require("../../utils/formatting");
|
|
7
|
-
const name_parser_1 = require("../../utils/name.parser");
|
|
8
|
-
const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
9
|
-
function main(options) {
|
|
10
|
-
options = transform(options);
|
|
11
|
-
return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
|
|
12
|
-
}
|
|
13
|
-
function transform(options) {
|
|
14
|
-
const target = Object.assign({}, options);
|
|
15
|
-
if (!target.name) {
|
|
16
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
17
|
-
}
|
|
18
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
19
|
-
target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
|
|
20
|
-
target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
|
|
21
|
-
target.language = target.language !== undefined ? target.language : 'ts';
|
|
22
|
-
target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
|
|
23
|
-
target.path = target.flat
|
|
24
|
-
? target.path
|
|
25
|
-
: (0, core_1.join)(target.path, target.name);
|
|
26
|
-
return target;
|
|
27
|
-
}
|
|
28
|
-
function generate(options) {
|
|
29
|
-
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
30
|
-
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
|
|
31
|
-
options.spec
|
|
32
|
-
? (0, schematics_1.noop)()
|
|
33
|
-
: (0, schematics_1.filter)((path) => {
|
|
34
|
-
const languageExtension = options.language || 'ts';
|
|
35
|
-
const suffix = `.__specFileSuffix__.${languageExtension}`;
|
|
36
|
-
return !path.endsWith(suffix);
|
|
37
|
-
}),
|
|
38
|
-
(0, schematics_1.template)({
|
|
39
|
-
...core_1.strings,
|
|
40
|
-
...options,
|
|
41
|
-
}),
|
|
42
|
-
(0, schematics_1.move)(options.path),
|
|
43
|
-
])(context);
|
|
44
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = main;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const formatting_1 = require("../../utils/formatting");
|
|
7
|
-
const module_declarator_1 = require("../../utils/module.declarator");
|
|
8
|
-
const module_finder_1 = require("../../utils/module.finder");
|
|
9
|
-
const name_parser_1 = require("../../utils/name.parser");
|
|
10
|
-
const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
11
|
-
function main(options) {
|
|
12
|
-
options = transform(options);
|
|
13
|
-
return (tree, context) => {
|
|
14
|
-
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
15
|
-
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
16
|
-
addDeclarationToModule(options),
|
|
17
|
-
(0, schematics_1.mergeWith)(generate(options)),
|
|
18
|
-
]))(tree, context);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function transform(options) {
|
|
22
|
-
const target = Object.assign({}, options);
|
|
23
|
-
target.metadata = 'providers';
|
|
24
|
-
target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
|
|
25
|
-
if (!target.name) {
|
|
26
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
27
|
-
}
|
|
28
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
29
|
-
target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
|
|
30
|
-
if (target.name.includes('.')) {
|
|
31
|
-
target.className = core_1.strings.classify(target.name).replace('.', '');
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
target.className = core_1.strings.classify(target.name);
|
|
35
|
-
}
|
|
36
|
-
target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
|
|
37
|
-
target.language = target.language !== undefined ? target.language : 'ts';
|
|
38
|
-
target.path = target.flat
|
|
39
|
-
? target.path
|
|
40
|
-
: (0, core_1.join)(target.path, target.name);
|
|
41
|
-
return target;
|
|
42
|
-
}
|
|
43
|
-
function generate(options) {
|
|
44
|
-
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
45
|
-
options.spec
|
|
46
|
-
? (0, schematics_1.noop)()
|
|
47
|
-
: (0, schematics_1.filter)((path) => {
|
|
48
|
-
const languageExtension = options.language || 'ts';
|
|
49
|
-
const suffix = `.__specFileSuffix__.${languageExtension}`;
|
|
50
|
-
return !path.endsWith(suffix);
|
|
51
|
-
}),
|
|
52
|
-
(0, schematics_1.template)({
|
|
53
|
-
...core_1.strings,
|
|
54
|
-
...options,
|
|
55
|
-
}),
|
|
56
|
-
(0, schematics_1.move)(options.path),
|
|
57
|
-
])(context);
|
|
58
|
-
}
|
|
59
|
-
function addDeclarationToModule(options) {
|
|
60
|
-
return (tree) => {
|
|
61
|
-
if (options.skipImport !== undefined && options.skipImport) {
|
|
62
|
-
return tree;
|
|
63
|
-
}
|
|
64
|
-
options.module = new module_finder_1.ModuleFinder(tree).find({
|
|
65
|
-
name: options.name,
|
|
66
|
-
path: options.path,
|
|
67
|
-
});
|
|
68
|
-
if (!options.module) {
|
|
69
|
-
return tree;
|
|
70
|
-
}
|
|
71
|
-
const content = tree.read(options.module).toString();
|
|
72
|
-
const declarator = new module_declarator_1.ModuleDeclarator();
|
|
73
|
-
tree.overwrite(options.module, declarator.declare(content, options));
|
|
74
|
-
return tree;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Reader } from './reader';
|
|
2
|
-
export declare class FileSystemReader implements Reader {
|
|
3
|
-
private readonly directory;
|
|
4
|
-
constructor(directory: string);
|
|
5
|
-
list(): Promise<string[]>;
|
|
6
|
-
read(name: string): Promise<string>;
|
|
7
|
-
readSync(name: string): string;
|
|
8
|
-
readAnyOf(filenames: string[]): Promise<string | undefined>;
|
|
9
|
-
readSyncAnyOf(filenames: string[]): string | undefined;
|
|
10
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileSystemReader = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
class FileSystemReader {
|
|
7
|
-
directory;
|
|
8
|
-
constructor(directory) {
|
|
9
|
-
this.directory = directory;
|
|
10
|
-
}
|
|
11
|
-
list() {
|
|
12
|
-
return fs.promises.readdir(this.directory);
|
|
13
|
-
}
|
|
14
|
-
read(name) {
|
|
15
|
-
return fs.promises.readFile(path.join(this.directory, name), 'utf8');
|
|
16
|
-
}
|
|
17
|
-
readSync(name) {
|
|
18
|
-
return fs.readFileSync(path.join(this.directory, name), 'utf8');
|
|
19
|
-
}
|
|
20
|
-
async readAnyOf(filenames) {
|
|
21
|
-
try {
|
|
22
|
-
for (const file of filenames) {
|
|
23
|
-
return await this.read(file);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return filenames.length > 0
|
|
28
|
-
? await this.readAnyOf(filenames.slice(1, filenames.length))
|
|
29
|
-
: undefined;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
readSyncAnyOf(filenames) {
|
|
33
|
-
try {
|
|
34
|
-
for (const file of filenames) {
|
|
35
|
-
return this.readSync(file);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
return filenames.length > 0
|
|
40
|
-
? this.readSyncAnyOf(filenames.slice(1, filenames.length))
|
|
41
|
-
: undefined;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.FileSystemReader = FileSystemReader;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./reader"), exports);
|
|
18
|
-
__exportStar(require("./file-system.reader"), exports);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export interface Reader {
|
|
2
|
-
list(): string[] | Promise<string[]>;
|
|
3
|
-
read(name: string): string | Promise<string>;
|
|
4
|
-
readSync(name: string): string;
|
|
5
|
-
readAnyOf(filenames: string[]): string | Promise<string | undefined>;
|
|
6
|
-
readSyncAnyOf(filenames: string[]): string | undefined;
|
|
7
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = main;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const formatting_1 = require("../../utils/formatting");
|
|
7
|
-
const module_declarator_1 = require("../../utils/module.declarator");
|
|
8
|
-
const module_finder_1 = require("../../utils/module.finder");
|
|
9
|
-
const name_parser_1 = require("../../utils/name.parser");
|
|
10
|
-
const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
11
|
-
function main(options) {
|
|
12
|
-
options = transform(options);
|
|
13
|
-
return (tree, context) => {
|
|
14
|
-
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
15
|
-
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
16
|
-
addDeclarationToModule(options),
|
|
17
|
-
(0, schematics_1.mergeWith)(generate(options)),
|
|
18
|
-
]))(tree, context);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function transform(options) {
|
|
22
|
-
const target = Object.assign({}, options);
|
|
23
|
-
if (!target.name) {
|
|
24
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
25
|
-
}
|
|
26
|
-
target.metadata = 'providers';
|
|
27
|
-
target.type = 'resolver';
|
|
28
|
-
target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
|
|
29
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
30
|
-
target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
|
|
31
|
-
target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
|
|
32
|
-
target.language = target.language !== undefined ? target.language : 'ts';
|
|
33
|
-
target.path = target.flat
|
|
34
|
-
? target.path
|
|
35
|
-
: (0, core_1.join)(target.path, target.name);
|
|
36
|
-
return target;
|
|
37
|
-
}
|
|
38
|
-
function generate(options) {
|
|
39
|
-
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
40
|
-
options.spec
|
|
41
|
-
? (0, schematics_1.noop)()
|
|
42
|
-
: (0, schematics_1.filter)((path) => {
|
|
43
|
-
const languageExtension = options.language || 'ts';
|
|
44
|
-
const suffix = `.__specFileSuffix__.${languageExtension}`;
|
|
45
|
-
return !path.endsWith(suffix);
|
|
46
|
-
}),
|
|
47
|
-
(0, schematics_1.template)({
|
|
48
|
-
...core_1.strings,
|
|
49
|
-
...options,
|
|
50
|
-
}),
|
|
51
|
-
(0, schematics_1.move)(options.path),
|
|
52
|
-
])(context);
|
|
53
|
-
}
|
|
54
|
-
function addDeclarationToModule(options) {
|
|
55
|
-
return (tree) => {
|
|
56
|
-
if (options.skipImport !== undefined && options.skipImport) {
|
|
57
|
-
return tree;
|
|
58
|
-
}
|
|
59
|
-
options.module = new module_finder_1.ModuleFinder(tree).find({
|
|
60
|
-
name: options.name,
|
|
61
|
-
path: options.path,
|
|
62
|
-
});
|
|
63
|
-
if (!options.module) {
|
|
64
|
-
return tree;
|
|
65
|
-
}
|
|
66
|
-
const content = tree.read(options.module).toString();
|
|
67
|
-
const declarator = new module_declarator_1.ModuleDeclarator();
|
|
68
|
-
tree.overwrite(options.module, declarator.declare(content, options));
|
|
69
|
-
return tree;
|
|
70
|
-
};
|
|
71
|
-
}
|