@nx/devkit 0.0.0-pr-22179-271588f
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/LICENSE +22 -0
- package/README.md +68 -0
- package/index.d.ts +14 -0
- package/index.js +18 -0
- package/migrations.json +18 -0
- package/ngcli-adapter.d.ts +4 -0
- package/ngcli-adapter.js +11 -0
- package/nx.d.ts +1 -0
- package/nx.js +19 -0
- package/package.json +50 -0
- package/public-api.d.ts +78 -0
- package/public-api.js +100 -0
- package/src/executors/parse-target-string.d.ts +44 -0
- package/src/executors/parse-target-string.js +55 -0
- package/src/executors/read-target-options.d.ts +8 -0
- package/src/executors/read-target-options.js +38 -0
- package/src/generators/add-build-target-defaults.d.ts +2 -0
- package/src/generators/add-build-target-defaults.js +18 -0
- package/src/generators/artifact-name-and-directory-utils.d.ts +48 -0
- package/src/generators/artifact-name-and-directory-utils.js +239 -0
- package/src/generators/executor-options-utils.d.ts +21 -0
- package/src/generators/executor-options-utils.js +49 -0
- package/src/generators/format-files.d.ts +6 -0
- package/src/generators/format-files.js +91 -0
- package/src/generators/generate-files.d.ts +26 -0
- package/src/generators/generate-files.js +91 -0
- package/src/generators/project-name-and-root-utils.d.ts +47 -0
- package/src/generators/project-name-and-root-utils.js +298 -0
- package/src/generators/run-tasks-in-serial.d.ts +7 -0
- package/src/generators/run-tasks-in-serial.js +16 -0
- package/src/generators/to-js.d.ts +11 -0
- package/src/generators/to-js.js +24 -0
- package/src/generators/typescript/insert-import.d.ts +1 -0
- package/src/generators/typescript/insert-import.js +5 -0
- package/src/generators/typescript/insert-statement.d.ts +1 -0
- package/src/generators/typescript/insert-statement.js +5 -0
- package/src/generators/update-ts-configs-to-js.d.ts +4 -0
- package/src/generators/update-ts-configs-to-js.js +49 -0
- package/src/generators/visit-not-ignored-files.d.ts +5 -0
- package/src/generators/visit-not-ignored-files.js +41 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-9-0/migrate-mf-util-usage.d.ts +4 -0
- package/src/migrations/update-16-9-0/migrate-mf-util-usage.js +201 -0
- package/src/tasks/install-packages-task.d.ts +10 -0
- package/src/tasks/install-packages-task.js +41 -0
- package/src/utils/async-iterable/combine-async-iterables.d.ts +3 -0
- package/src/utils/async-iterable/combine-async-iterables.js +58 -0
- package/src/utils/async-iterable/create-async-iterable.d.ts +6 -0
- package/src/utils/async-iterable/create-async-iterable.js +58 -0
- package/src/utils/async-iterable/index.d.ts +4 -0
- package/src/utils/async-iterable/index.js +7 -0
- package/src/utils/async-iterable/map-async-iteratable.d.ts +1 -0
- package/src/utils/async-iterable/map-async-iteratable.js +18 -0
- package/src/utils/async-iterable/tap-async-iteratable.d.ts +1 -0
- package/src/utils/async-iterable/tap-async-iteratable.js +11 -0
- package/src/utils/binary-extensions.d.ts +1 -0
- package/src/utils/binary-extensions.js +275 -0
- package/src/utils/calculate-hash-for-create-nodes.d.ts +2 -0
- package/src/utils/calculate-hash-for-create-nodes.js +16 -0
- package/src/utils/config-utils.d.ts +4 -0
- package/src/utils/config-utils.js +75 -0
- package/src/utils/convert-nx-executor.d.ts +7 -0
- package/src/utils/convert-nx-executor.js +89 -0
- package/src/utils/get-named-inputs.d.ts +8 -0
- package/src/utils/get-named-inputs.js +26 -0
- package/src/utils/get-workspace-layout.d.ts +24 -0
- package/src/utils/get-workspace-layout.js +52 -0
- package/src/utils/invoke-nx-generator.d.ts +6 -0
- package/src/utils/invoke-nx-generator.js +172 -0
- package/src/utils/log-show-project-command.d.ts +1 -0
- package/src/utils/log-show-project-command.js +14 -0
- package/src/utils/move-dir.d.ts +5 -0
- package/src/utils/move-dir.js +28 -0
- package/src/utils/names.d.ts +18 -0
- package/src/utils/names.js +63 -0
- package/src/utils/offset-from-root.d.ts +13 -0
- package/src/utils/offset-from-root.js +29 -0
- package/src/utils/package-json.d.ts +78 -0
- package/src/utils/package-json.js +375 -0
- package/src/utils/replace-package.d.ts +2 -0
- package/src/utils/replace-package.js +125 -0
- package/src/utils/replace-project-configuration-with-plugin.d.ts +3 -0
- package/src/utils/replace-project-configuration-with-plugin.js +136 -0
- package/src/utils/rxjs-for-await.d.ts +109 -0
- package/src/utils/rxjs-for-await.js +363 -0
- package/src/utils/semver.d.ts +1 -0
- package/src/utils/semver.js +18 -0
- package/src/utils/string-change.d.ts +62 -0
- package/src/utils/string-change.js +109 -0
- package/src/utils/string-utils.d.ts +95 -0
- package/src/utils/string-utils.js +147 -0
- package/src/utils/update-package-scripts.d.ts +3 -0
- package/src/utils/update-package-scripts.js +175 -0
- package/src/utils/versions.d.ts +1 -0
- package/src/utils/versions.js +4 -0
- package/testing.d.ts +1 -0
- package/testing.js +5 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isBinaryPath = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const binaryExtensions = new Set([
|
|
6
|
+
// types originally from https://github.com/sindresorhus/binary-extensions/blob/40e44b510d87a63dcf42300bc8fbcb105f45a61c/binary-extensions.json
|
|
7
|
+
'.3dm',
|
|
8
|
+
'.3ds',
|
|
9
|
+
'.3g2',
|
|
10
|
+
'.3gp',
|
|
11
|
+
'.7z',
|
|
12
|
+
'.a',
|
|
13
|
+
'.aac',
|
|
14
|
+
'.adp',
|
|
15
|
+
'.ai',
|
|
16
|
+
'.aif',
|
|
17
|
+
'.aiff',
|
|
18
|
+
'.alz',
|
|
19
|
+
'.ape',
|
|
20
|
+
'.apk',
|
|
21
|
+
'.appimage',
|
|
22
|
+
'.ar',
|
|
23
|
+
'.arj',
|
|
24
|
+
'.asf',
|
|
25
|
+
'.au',
|
|
26
|
+
'.avi',
|
|
27
|
+
'.bak',
|
|
28
|
+
'.baml',
|
|
29
|
+
'.bh',
|
|
30
|
+
'.bin',
|
|
31
|
+
'.bk',
|
|
32
|
+
'.bmp',
|
|
33
|
+
'.btif',
|
|
34
|
+
'.bz2',
|
|
35
|
+
'.bzip2',
|
|
36
|
+
'.cab',
|
|
37
|
+
'.caf',
|
|
38
|
+
'.cgm',
|
|
39
|
+
'.class',
|
|
40
|
+
'.cmx',
|
|
41
|
+
'.cpio',
|
|
42
|
+
'.cr2',
|
|
43
|
+
'.cur',
|
|
44
|
+
'.dat',
|
|
45
|
+
'.dcm',
|
|
46
|
+
'.deb',
|
|
47
|
+
'.dex',
|
|
48
|
+
'.djvu',
|
|
49
|
+
'.dll',
|
|
50
|
+
'.dmg',
|
|
51
|
+
'.dng',
|
|
52
|
+
'.doc',
|
|
53
|
+
'.docm',
|
|
54
|
+
'.docx',
|
|
55
|
+
'.dot',
|
|
56
|
+
'.dotm',
|
|
57
|
+
'.dra',
|
|
58
|
+
'.DS_Store',
|
|
59
|
+
'.dsk',
|
|
60
|
+
'.dts',
|
|
61
|
+
'.dtshd',
|
|
62
|
+
'.dvb',
|
|
63
|
+
'.dwg',
|
|
64
|
+
'.dxf',
|
|
65
|
+
'.ecelp4800',
|
|
66
|
+
'.ecelp7470',
|
|
67
|
+
'.ecelp9600',
|
|
68
|
+
'.egg',
|
|
69
|
+
'.eol',
|
|
70
|
+
'.eot',
|
|
71
|
+
'.epub',
|
|
72
|
+
'.exe',
|
|
73
|
+
'.f4v',
|
|
74
|
+
'.fbs',
|
|
75
|
+
'.fh',
|
|
76
|
+
'.fla',
|
|
77
|
+
'.flac',
|
|
78
|
+
'.flatpak',
|
|
79
|
+
'.fli',
|
|
80
|
+
'.flv',
|
|
81
|
+
'.fpx',
|
|
82
|
+
'.fst',
|
|
83
|
+
'.fvt',
|
|
84
|
+
'.g3',
|
|
85
|
+
'.gh',
|
|
86
|
+
'.gif',
|
|
87
|
+
'.glb',
|
|
88
|
+
'.graffle',
|
|
89
|
+
'.gz',
|
|
90
|
+
'.gzip',
|
|
91
|
+
'.h261',
|
|
92
|
+
'.h263',
|
|
93
|
+
'.h264',
|
|
94
|
+
'.icns',
|
|
95
|
+
'.ico',
|
|
96
|
+
'.ief',
|
|
97
|
+
'.img',
|
|
98
|
+
'.ipa',
|
|
99
|
+
'.iso',
|
|
100
|
+
'.jar',
|
|
101
|
+
'.jpeg',
|
|
102
|
+
'.jpg',
|
|
103
|
+
'.jpgv',
|
|
104
|
+
'.jpm',
|
|
105
|
+
'.jxr',
|
|
106
|
+
'.key',
|
|
107
|
+
'.keystore',
|
|
108
|
+
'.ktx',
|
|
109
|
+
'.lha',
|
|
110
|
+
'.lib',
|
|
111
|
+
'.lvp',
|
|
112
|
+
'.lz',
|
|
113
|
+
'.lzh',
|
|
114
|
+
'.lzma',
|
|
115
|
+
'.lzo',
|
|
116
|
+
'.m3u',
|
|
117
|
+
'.m4a',
|
|
118
|
+
'.m4v',
|
|
119
|
+
'.mar',
|
|
120
|
+
'.mdi',
|
|
121
|
+
'.mht',
|
|
122
|
+
'.mid',
|
|
123
|
+
'.midi',
|
|
124
|
+
'.mj2',
|
|
125
|
+
'.mka',
|
|
126
|
+
'.mkv',
|
|
127
|
+
'.mmr',
|
|
128
|
+
'.mng',
|
|
129
|
+
'.mobi',
|
|
130
|
+
'.mov',
|
|
131
|
+
'.movie',
|
|
132
|
+
'.mp3',
|
|
133
|
+
'.mp4',
|
|
134
|
+
'.mp4a',
|
|
135
|
+
'.mpeg',
|
|
136
|
+
'.mpg',
|
|
137
|
+
'.mpga',
|
|
138
|
+
'.msi',
|
|
139
|
+
'.mxu',
|
|
140
|
+
'.nef',
|
|
141
|
+
'.npx',
|
|
142
|
+
'.numbers',
|
|
143
|
+
'.nupkg',
|
|
144
|
+
'.o',
|
|
145
|
+
'.odp',
|
|
146
|
+
'.ods',
|
|
147
|
+
'.odt',
|
|
148
|
+
'.oga',
|
|
149
|
+
'.ogg',
|
|
150
|
+
'.ogv',
|
|
151
|
+
'.otf',
|
|
152
|
+
'.ott',
|
|
153
|
+
'.pages',
|
|
154
|
+
'.pbm',
|
|
155
|
+
'.pbf',
|
|
156
|
+
'.pcx',
|
|
157
|
+
'.pdb',
|
|
158
|
+
'.pdf',
|
|
159
|
+
'.pea',
|
|
160
|
+
'.pgm',
|
|
161
|
+
'.pic',
|
|
162
|
+
'.png',
|
|
163
|
+
'.pnm',
|
|
164
|
+
'.pot',
|
|
165
|
+
'.potm',
|
|
166
|
+
'.potx',
|
|
167
|
+
'.ppa',
|
|
168
|
+
'.ppam',
|
|
169
|
+
'.ppm',
|
|
170
|
+
'.pps',
|
|
171
|
+
'.ppsm',
|
|
172
|
+
'.ppsx',
|
|
173
|
+
'.ppt',
|
|
174
|
+
'.pptm',
|
|
175
|
+
'.pptx',
|
|
176
|
+
'.psd',
|
|
177
|
+
'.pxd',
|
|
178
|
+
'.pxz',
|
|
179
|
+
'.pya',
|
|
180
|
+
'.pyc',
|
|
181
|
+
'.pyo',
|
|
182
|
+
'.pyv',
|
|
183
|
+
'.qt',
|
|
184
|
+
'.rar',
|
|
185
|
+
'.ras',
|
|
186
|
+
'.raw',
|
|
187
|
+
'.resources',
|
|
188
|
+
'.rgb',
|
|
189
|
+
'.rip',
|
|
190
|
+
'.rlc',
|
|
191
|
+
'.rmf',
|
|
192
|
+
'.rmvb',
|
|
193
|
+
'.rpm',
|
|
194
|
+
'.rtf',
|
|
195
|
+
'.rz',
|
|
196
|
+
'.s3m',
|
|
197
|
+
'.s7z',
|
|
198
|
+
'.scpt',
|
|
199
|
+
'.sgi',
|
|
200
|
+
'.shar',
|
|
201
|
+
'.snap',
|
|
202
|
+
'.sil',
|
|
203
|
+
'.sketch',
|
|
204
|
+
'.slk',
|
|
205
|
+
'.smv',
|
|
206
|
+
'.snk',
|
|
207
|
+
'.so',
|
|
208
|
+
'.stl',
|
|
209
|
+
'.suo',
|
|
210
|
+
'.sub',
|
|
211
|
+
'.swf',
|
|
212
|
+
'.tar',
|
|
213
|
+
'.tbz',
|
|
214
|
+
'.tbz2',
|
|
215
|
+
'.tga',
|
|
216
|
+
'.tgz',
|
|
217
|
+
'.thmx',
|
|
218
|
+
'.tif',
|
|
219
|
+
'.tiff',
|
|
220
|
+
'.tlz',
|
|
221
|
+
'.ttc',
|
|
222
|
+
'.ttf',
|
|
223
|
+
'.txz',
|
|
224
|
+
'.udf',
|
|
225
|
+
'.uvh',
|
|
226
|
+
'.uvi',
|
|
227
|
+
'.uvm',
|
|
228
|
+
'.uvp',
|
|
229
|
+
'.uvs',
|
|
230
|
+
'.uvu',
|
|
231
|
+
'.viv',
|
|
232
|
+
'.vob',
|
|
233
|
+
'.war',
|
|
234
|
+
'.wav',
|
|
235
|
+
'.wax',
|
|
236
|
+
'.wbmp',
|
|
237
|
+
'.wdp',
|
|
238
|
+
'.weba',
|
|
239
|
+
'.webm',
|
|
240
|
+
'.webp',
|
|
241
|
+
'.whl',
|
|
242
|
+
'.wim',
|
|
243
|
+
'.wm',
|
|
244
|
+
'.wma',
|
|
245
|
+
'.wmv',
|
|
246
|
+
'.wmx',
|
|
247
|
+
'.woff',
|
|
248
|
+
'.woff2',
|
|
249
|
+
'.wrm',
|
|
250
|
+
'.wvx',
|
|
251
|
+
'.xbm',
|
|
252
|
+
'.xif',
|
|
253
|
+
'.xla',
|
|
254
|
+
'.xlam',
|
|
255
|
+
'.xls',
|
|
256
|
+
'.xlsb',
|
|
257
|
+
'.xlsm',
|
|
258
|
+
'.xlsx',
|
|
259
|
+
'.xlt',
|
|
260
|
+
'.xltm',
|
|
261
|
+
'.xltx',
|
|
262
|
+
'.xm',
|
|
263
|
+
'.xmind',
|
|
264
|
+
'.xpi',
|
|
265
|
+
'.xpm',
|
|
266
|
+
'.xwd',
|
|
267
|
+
'.xz',
|
|
268
|
+
'.z',
|
|
269
|
+
'.zip',
|
|
270
|
+
'.zipx',
|
|
271
|
+
]);
|
|
272
|
+
function isBinaryPath(path) {
|
|
273
|
+
return binaryExtensions.has((0, path_1.extname)(path).toLowerCase());
|
|
274
|
+
}
|
|
275
|
+
exports.isBinaryPath = isBinaryPath;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateHashForCreateNodes = void 0;
|
|
4
|
+
const nx_1 = require("../../nx");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const { hashWithWorkspaceContext, hashArray, hashObject } = (0, nx_1.requireNx)();
|
|
7
|
+
function calculateHashForCreateNodes(projectRoot, options, context, additionalGlobs = []) {
|
|
8
|
+
return hashArray([
|
|
9
|
+
hashWithWorkspaceContext(context.workspaceRoot, [
|
|
10
|
+
(0, path_1.join)(projectRoot, '**/*'),
|
|
11
|
+
...additionalGlobs,
|
|
12
|
+
]),
|
|
13
|
+
hashObject(options),
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
16
|
+
exports.calculateHashForCreateNodes = calculateHashForCreateNodes;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare let dynamicImport: Function;
|
|
2
|
+
export declare function loadConfigFile<T extends object = any>(configFilePath: string): Promise<T>;
|
|
3
|
+
export declare function getRootTsConfigPath(): string | null;
|
|
4
|
+
export declare function getRootTsConfigFileName(): string | null;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRootTsConfigFileName = exports.getRootTsConfigPath = exports.loadConfigFile = exports.dynamicImport = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const nx_1 = require("../../nx");
|
|
7
|
+
const { workspaceRoot, registerTsProject } = (0, nx_1.requireNx)();
|
|
8
|
+
exports.dynamicImport = new Function('modulePath', 'return import(modulePath);');
|
|
9
|
+
async function loadConfigFile(configFilePath) {
|
|
10
|
+
{
|
|
11
|
+
let module;
|
|
12
|
+
if ((0, path_1.extname)(configFilePath) === '.ts') {
|
|
13
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.dirname)(configFilePath));
|
|
14
|
+
const tsConfigPath = siblingFiles.includes('tsconfig.json')
|
|
15
|
+
? (0, path_1.join)((0, path_1.dirname)(configFilePath), 'tsconfig.json')
|
|
16
|
+
: getRootTsConfigPath();
|
|
17
|
+
if (tsConfigPath) {
|
|
18
|
+
const unregisterTsProject = registerTsProject(tsConfigPath);
|
|
19
|
+
try {
|
|
20
|
+
module = await load(configFilePath);
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
unregisterTsProject();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
module = await load(configFilePath);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
module = await load(configFilePath);
|
|
32
|
+
}
|
|
33
|
+
return module.default ?? module;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.loadConfigFile = loadConfigFile;
|
|
37
|
+
function getRootTsConfigPath() {
|
|
38
|
+
const tsConfigFileName = getRootTsConfigFileName();
|
|
39
|
+
return tsConfigFileName ? (0, path_1.join)(workspaceRoot, tsConfigFileName) : null;
|
|
40
|
+
}
|
|
41
|
+
exports.getRootTsConfigPath = getRootTsConfigPath;
|
|
42
|
+
function getRootTsConfigFileName() {
|
|
43
|
+
for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
|
|
44
|
+
const pathExists = (0, fs_1.existsSync)((0, path_1.join)(workspaceRoot, tsConfigName));
|
|
45
|
+
if (pathExists) {
|
|
46
|
+
return tsConfigName;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
exports.getRootTsConfigFileName = getRootTsConfigFileName;
|
|
52
|
+
/**
|
|
53
|
+
* Load the module after ensuring that the require cache is cleared.
|
|
54
|
+
*/
|
|
55
|
+
async function load(path) {
|
|
56
|
+
// Clear cache if the path is in the cache
|
|
57
|
+
if (require.cache[path]) {
|
|
58
|
+
for (const k of Object.keys(require.cache)) {
|
|
59
|
+
delete require.cache[k];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
// Try using `require` first, which works for CJS modules.
|
|
64
|
+
// Modules are CJS unless it is named `.mjs` or `package.json` sets type to "module".
|
|
65
|
+
return require(path);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
if (e.code === 'ERR_REQUIRE_ESM') {
|
|
69
|
+
// If `require` fails to load ESM, try dynamic `import()`.
|
|
70
|
+
return await (0, exports.dynamicImport)(`${path}?t=${Date.now()}`);
|
|
71
|
+
}
|
|
72
|
+
// Re-throw all other errors
|
|
73
|
+
throw e;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertNxExecutor = void 0;
|
|
4
|
+
const nx_1 = require("../../nx");
|
|
5
|
+
const { Workspaces, readNxJsonFromDisk, retrieveProjectConfigurationsWithAngularProjects, shutdownPluginWorkers, } = (0, nx_1.requireNx)();
|
|
6
|
+
/**
|
|
7
|
+
* Convert an Nx Executor into an Angular Devkit Builder
|
|
8
|
+
*
|
|
9
|
+
* Use this to expose a compatible Angular Builder
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
12
|
+
function convertNxExecutor(executor) {
|
|
13
|
+
const builderFunction = (options, builderContext) => {
|
|
14
|
+
const workspaces = new Workspaces(builderContext.workspaceRoot);
|
|
15
|
+
const nxJsonConfiguration = readNxJsonFromDisk
|
|
16
|
+
? readNxJsonFromDisk(builderContext.workspaceRoot)
|
|
17
|
+
: // TODO(v19): remove readNxJson. This is to be backwards compatible with Nx 16.5 and below.
|
|
18
|
+
workspaces.readNxJson();
|
|
19
|
+
const promise = async () => {
|
|
20
|
+
const projectsConfigurations = retrieveProjectConfigurationsWithAngularProjects
|
|
21
|
+
? {
|
|
22
|
+
version: 2,
|
|
23
|
+
projects: await retrieveProjectConfigurationsWithAngularProjects(builderContext.workspaceRoot, nxJsonConfiguration).then((p) => p.projectNodes ?? p.projects),
|
|
24
|
+
}
|
|
25
|
+
: // TODO(v19): remove retrieveProjectConfigurations. This is to be backwards compatible with Nx 16.5 and below.
|
|
26
|
+
workspaces.readProjectsConfigurations({
|
|
27
|
+
_includeProjectsFromAngularJson: true,
|
|
28
|
+
});
|
|
29
|
+
shutdownPluginWorkers?.();
|
|
30
|
+
const context = {
|
|
31
|
+
root: builderContext.workspaceRoot,
|
|
32
|
+
projectName: builderContext.target.project,
|
|
33
|
+
targetName: builderContext.target.target,
|
|
34
|
+
target: builderContext.target.target,
|
|
35
|
+
configurationName: builderContext.target.configuration,
|
|
36
|
+
projectsConfigurations,
|
|
37
|
+
nxJsonConfiguration,
|
|
38
|
+
cwd: process.cwd(),
|
|
39
|
+
projectGraph: null,
|
|
40
|
+
taskGraph: null,
|
|
41
|
+
isVerbose: false,
|
|
42
|
+
};
|
|
43
|
+
return executor(options, context);
|
|
44
|
+
};
|
|
45
|
+
return toObservable(promise());
|
|
46
|
+
};
|
|
47
|
+
return require('@angular-devkit/architect').createBuilder(builderFunction);
|
|
48
|
+
}
|
|
49
|
+
exports.convertNxExecutor = convertNxExecutor;
|
|
50
|
+
function toObservable(promiseOrAsyncIterator) {
|
|
51
|
+
return new (require('rxjs').Observable)((subscriber) => {
|
|
52
|
+
promiseOrAsyncIterator
|
|
53
|
+
.then((value) => {
|
|
54
|
+
if (!value.next) {
|
|
55
|
+
subscriber.next(value);
|
|
56
|
+
subscriber.complete();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
let asyncIterator = value;
|
|
60
|
+
function recurse(iterator) {
|
|
61
|
+
iterator
|
|
62
|
+
.next()
|
|
63
|
+
.then((result) => {
|
|
64
|
+
if (!result.done) {
|
|
65
|
+
subscriber.next(result.value);
|
|
66
|
+
recurse(iterator);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (result.value) {
|
|
70
|
+
subscriber.next(result.value);
|
|
71
|
+
}
|
|
72
|
+
subscriber.complete();
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
.catch((e) => {
|
|
76
|
+
subscriber.error(e);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
recurse(asyncIterator);
|
|
80
|
+
return () => {
|
|
81
|
+
asyncIterator.return();
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
.catch((err) => {
|
|
86
|
+
subscriber.error(err);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CreateNodesContext } from 'nx/src/devkit-exports';
|
|
2
|
+
import type { InputDefinition } from 'nx/src/config/workspace-json-project-json';
|
|
3
|
+
/**
|
|
4
|
+
* Get the named inputs available for a directory
|
|
5
|
+
*/
|
|
6
|
+
export declare function getNamedInputs(directory: string, context: CreateNodesContext): {
|
|
7
|
+
[inputName: string]: (string | InputDefinition)[];
|
|
8
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNamedInputs = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const nx_1 = require("../../nx");
|
|
7
|
+
const { readJsonFile } = (0, nx_1.requireNx)();
|
|
8
|
+
/**
|
|
9
|
+
* Get the named inputs available for a directory
|
|
10
|
+
*/
|
|
11
|
+
function getNamedInputs(directory, context) {
|
|
12
|
+
const projectJsonPath = (0, path_1.join)(directory, 'project.json');
|
|
13
|
+
const projectJson = (0, fs_1.existsSync)(projectJsonPath)
|
|
14
|
+
? readJsonFile(projectJsonPath)
|
|
15
|
+
: null;
|
|
16
|
+
const packageJsonPath = (0, path_1.join)(directory, 'package.json');
|
|
17
|
+
const packageJson = (0, fs_1.existsSync)(packageJsonPath)
|
|
18
|
+
? readJsonFile(packageJsonPath)
|
|
19
|
+
: null;
|
|
20
|
+
return {
|
|
21
|
+
...context.nxJsonConfiguration.namedInputs,
|
|
22
|
+
...packageJson?.nx?.namedInputs,
|
|
23
|
+
...projectJson?.namedInputs,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.getNamedInputs = getNamedInputs;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Tree } from 'nx/src/generators/tree';
|
|
2
|
+
/**
|
|
3
|
+
* Returns workspace defaults. It includes defaults folders for apps and libs,
|
|
4
|
+
* and the default scope.
|
|
5
|
+
*
|
|
6
|
+
* Example:
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* { appsDir: 'apps', libsDir: 'libs' }
|
|
10
|
+
* ```
|
|
11
|
+
* @param tree - file system tree
|
|
12
|
+
*/
|
|
13
|
+
export declare function getWorkspaceLayout(tree: Tree): {
|
|
14
|
+
appsDir: string;
|
|
15
|
+
libsDir: string;
|
|
16
|
+
standaloneAsDefault: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Experimental
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractLayoutDirectory(directory?: string): {
|
|
22
|
+
layoutDirectory: string | null;
|
|
23
|
+
projectDirectory?: string;
|
|
24
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractLayoutDirectory = exports.getWorkspaceLayout = void 0;
|
|
4
|
+
const nx_1 = require("../../nx");
|
|
5
|
+
const { readNxJson } = (0, nx_1.requireNx)();
|
|
6
|
+
/**
|
|
7
|
+
* Returns workspace defaults. It includes defaults folders for apps and libs,
|
|
8
|
+
* and the default scope.
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* { appsDir: 'apps', libsDir: 'libs' }
|
|
14
|
+
* ```
|
|
15
|
+
* @param tree - file system tree
|
|
16
|
+
*/
|
|
17
|
+
function getWorkspaceLayout(tree) {
|
|
18
|
+
const nxJson = readNxJson(tree);
|
|
19
|
+
return {
|
|
20
|
+
appsDir: nxJson?.workspaceLayout?.appsDir ??
|
|
21
|
+
inOrderOfPreference(tree, ['apps', 'packages'], '.'),
|
|
22
|
+
libsDir: nxJson?.workspaceLayout?.libsDir ??
|
|
23
|
+
inOrderOfPreference(tree, ['libs', 'packages'], '.'),
|
|
24
|
+
standaloneAsDefault: true,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.getWorkspaceLayout = getWorkspaceLayout;
|
|
28
|
+
/**
|
|
29
|
+
* Experimental
|
|
30
|
+
*/
|
|
31
|
+
function extractLayoutDirectory(directory) {
|
|
32
|
+
if (directory) {
|
|
33
|
+
directory = directory.startsWith('/') ? directory.substring(1) : directory;
|
|
34
|
+
for (let dir of ['apps', 'libs', 'packages']) {
|
|
35
|
+
if (directory.startsWith(dir + '/') || directory === dir) {
|
|
36
|
+
return {
|
|
37
|
+
layoutDirectory: dir,
|
|
38
|
+
projectDirectory: directory.substring(dir.length + 1),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { layoutDirectory: null, projectDirectory: directory };
|
|
44
|
+
}
|
|
45
|
+
exports.extractLayoutDirectory = extractLayoutDirectory;
|
|
46
|
+
function inOrderOfPreference(tree, selectedFolders, defaultChoice) {
|
|
47
|
+
for (let i = 0; i < selectedFolders.length; ++i) {
|
|
48
|
+
if (tree.exists(selectedFolders[i]))
|
|
49
|
+
return selectedFolders[i];
|
|
50
|
+
}
|
|
51
|
+
return defaultChoice;
|
|
52
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Generator } from 'nx/src/config/misc-interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Convert an Nx Generator into an Angular Devkit Schematic.
|
|
4
|
+
* @param generator The Nx generator to convert to an Angular Devkit Schematic.
|
|
5
|
+
*/
|
|
6
|
+
export declare function convertNxGenerator<T = any>(generator: Generator<T>, skipWritingConfigInOldFormat?: boolean): (generatorOptions: T) => (tree: any, context: any) => Promise<any>;
|