@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.
Files changed (98) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -0
  3. package/index.d.ts +14 -0
  4. package/index.js +18 -0
  5. package/migrations.json +18 -0
  6. package/ngcli-adapter.d.ts +4 -0
  7. package/ngcli-adapter.js +11 -0
  8. package/nx.d.ts +1 -0
  9. package/nx.js +19 -0
  10. package/package.json +50 -0
  11. package/public-api.d.ts +78 -0
  12. package/public-api.js +100 -0
  13. package/src/executors/parse-target-string.d.ts +44 -0
  14. package/src/executors/parse-target-string.js +55 -0
  15. package/src/executors/read-target-options.d.ts +8 -0
  16. package/src/executors/read-target-options.js +38 -0
  17. package/src/generators/add-build-target-defaults.d.ts +2 -0
  18. package/src/generators/add-build-target-defaults.js +18 -0
  19. package/src/generators/artifact-name-and-directory-utils.d.ts +48 -0
  20. package/src/generators/artifact-name-and-directory-utils.js +239 -0
  21. package/src/generators/executor-options-utils.d.ts +21 -0
  22. package/src/generators/executor-options-utils.js +49 -0
  23. package/src/generators/format-files.d.ts +6 -0
  24. package/src/generators/format-files.js +91 -0
  25. package/src/generators/generate-files.d.ts +26 -0
  26. package/src/generators/generate-files.js +91 -0
  27. package/src/generators/project-name-and-root-utils.d.ts +47 -0
  28. package/src/generators/project-name-and-root-utils.js +298 -0
  29. package/src/generators/run-tasks-in-serial.d.ts +7 -0
  30. package/src/generators/run-tasks-in-serial.js +16 -0
  31. package/src/generators/to-js.d.ts +11 -0
  32. package/src/generators/to-js.js +24 -0
  33. package/src/generators/typescript/insert-import.d.ts +1 -0
  34. package/src/generators/typescript/insert-import.js +5 -0
  35. package/src/generators/typescript/insert-statement.d.ts +1 -0
  36. package/src/generators/typescript/insert-statement.js +5 -0
  37. package/src/generators/update-ts-configs-to-js.d.ts +4 -0
  38. package/src/generators/update-ts-configs-to-js.js +49 -0
  39. package/src/generators/visit-not-ignored-files.d.ts +5 -0
  40. package/src/generators/visit-not-ignored-files.js +41 -0
  41. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  42. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  43. package/src/migrations/update-16-9-0/migrate-mf-util-usage.d.ts +4 -0
  44. package/src/migrations/update-16-9-0/migrate-mf-util-usage.js +201 -0
  45. package/src/tasks/install-packages-task.d.ts +10 -0
  46. package/src/tasks/install-packages-task.js +41 -0
  47. package/src/utils/async-iterable/combine-async-iterables.d.ts +3 -0
  48. package/src/utils/async-iterable/combine-async-iterables.js +58 -0
  49. package/src/utils/async-iterable/create-async-iterable.d.ts +6 -0
  50. package/src/utils/async-iterable/create-async-iterable.js +58 -0
  51. package/src/utils/async-iterable/index.d.ts +4 -0
  52. package/src/utils/async-iterable/index.js +7 -0
  53. package/src/utils/async-iterable/map-async-iteratable.d.ts +1 -0
  54. package/src/utils/async-iterable/map-async-iteratable.js +18 -0
  55. package/src/utils/async-iterable/tap-async-iteratable.d.ts +1 -0
  56. package/src/utils/async-iterable/tap-async-iteratable.js +11 -0
  57. package/src/utils/binary-extensions.d.ts +1 -0
  58. package/src/utils/binary-extensions.js +275 -0
  59. package/src/utils/calculate-hash-for-create-nodes.d.ts +2 -0
  60. package/src/utils/calculate-hash-for-create-nodes.js +16 -0
  61. package/src/utils/config-utils.d.ts +4 -0
  62. package/src/utils/config-utils.js +75 -0
  63. package/src/utils/convert-nx-executor.d.ts +7 -0
  64. package/src/utils/convert-nx-executor.js +89 -0
  65. package/src/utils/get-named-inputs.d.ts +8 -0
  66. package/src/utils/get-named-inputs.js +26 -0
  67. package/src/utils/get-workspace-layout.d.ts +24 -0
  68. package/src/utils/get-workspace-layout.js +52 -0
  69. package/src/utils/invoke-nx-generator.d.ts +6 -0
  70. package/src/utils/invoke-nx-generator.js +172 -0
  71. package/src/utils/log-show-project-command.d.ts +1 -0
  72. package/src/utils/log-show-project-command.js +14 -0
  73. package/src/utils/move-dir.d.ts +5 -0
  74. package/src/utils/move-dir.js +28 -0
  75. package/src/utils/names.d.ts +18 -0
  76. package/src/utils/names.js +63 -0
  77. package/src/utils/offset-from-root.d.ts +13 -0
  78. package/src/utils/offset-from-root.js +29 -0
  79. package/src/utils/package-json.d.ts +78 -0
  80. package/src/utils/package-json.js +375 -0
  81. package/src/utils/replace-package.d.ts +2 -0
  82. package/src/utils/replace-package.js +125 -0
  83. package/src/utils/replace-project-configuration-with-plugin.d.ts +3 -0
  84. package/src/utils/replace-project-configuration-with-plugin.js +136 -0
  85. package/src/utils/rxjs-for-await.d.ts +109 -0
  86. package/src/utils/rxjs-for-await.js +363 -0
  87. package/src/utils/semver.d.ts +1 -0
  88. package/src/utils/semver.js +18 -0
  89. package/src/utils/string-change.d.ts +62 -0
  90. package/src/utils/string-change.js +109 -0
  91. package/src/utils/string-utils.d.ts +95 -0
  92. package/src/utils/string-utils.js +147 -0
  93. package/src/utils/update-package-scripts.d.ts +3 -0
  94. package/src/utils/update-package-scripts.js +175 -0
  95. package/src/utils/versions.d.ts +1 -0
  96. package/src/utils/versions.js +4 -0
  97. package/testing.d.ts +1 -0
  98. package/testing.js +5 -0
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setCwd = exports.determineProjectNameAndRootOptions = void 0;
4
+ const enquirer_1 = require("enquirer");
5
+ const path_1 = require("path");
6
+ const nx_1 = require("../../nx");
7
+ const get_workspace_layout_1 = require("../utils/get-workspace-layout");
8
+ const names_1 = require("../utils/names");
9
+ const { joinPathFragments, logger, normalizePath, output, readJson, stripIndents, workspaceRoot, } = (0, nx_1.requireNx)();
10
+ async function determineProjectNameAndRootOptions(tree, options) {
11
+ if (!options.projectNameAndRootFormat &&
12
+ (process.env.NX_INTERACTIVE !== 'true' || !isTTY())) {
13
+ options.projectNameAndRootFormat = 'derived';
14
+ }
15
+ validateName(options.name, options.projectNameAndRootFormat);
16
+ const formats = getProjectNameAndRootFormats(tree, options);
17
+ const format = options.projectNameAndRootFormat ?? (await determineFormat(formats));
18
+ if (format === 'derived' && options.callingGenerator) {
19
+ logDeprecationMessage(options.callingGenerator, formats);
20
+ }
21
+ return {
22
+ ...formats[format],
23
+ projectNameAndRootFormat: format,
24
+ };
25
+ }
26
+ exports.determineProjectNameAndRootOptions = determineProjectNameAndRootOptions;
27
+ function validateName(name, projectNameAndRootFormat) {
28
+ if (projectNameAndRootFormat === 'derived' && name.startsWith('@')) {
29
+ throw new Error(`The project name "${name}" cannot start with "@" when the "projectNameAndRootFormat" is "derived".`);
30
+ }
31
+ /**
32
+ * Matches two types of project names:
33
+ *
34
+ * 1. Valid npm package names (e.g., '@scope/name' or 'name').
35
+ * 2. Names starting with a letter and can contain any character except whitespace and ':'.
36
+ *
37
+ * The second case is to support the legacy behavior (^[a-zA-Z].*$) with the difference
38
+ * that it doesn't allow the ":" character. It was wrong to allow it because it would
39
+ * conflict with the notation for tasks.
40
+ */
41
+ const pattern = '(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$';
42
+ const validationRegex = new RegExp(pattern);
43
+ if (!validationRegex.test(name)) {
44
+ throw new Error(`The project name should match the pattern "${pattern}". The provided value "${name}" does not match.`);
45
+ }
46
+ }
47
+ function logDeprecationMessage(callingGenerator, formats) {
48
+ logger.warn(stripIndents `
49
+ In Nx 19, generating projects will no longer derive the name and root.
50
+ Please provide the exact project name and root in the future.
51
+ Example: nx g ${callingGenerator} ${formats['derived'].projectName} --directory ${formats['derived'].projectRoot}
52
+ `);
53
+ }
54
+ async function determineFormat(formats) {
55
+ if (!formats.derived) {
56
+ return 'as-provided';
57
+ }
58
+ const asProvidedDescription = `As provided:
59
+ Name: ${formats['as-provided'].projectName}
60
+ Root: ${formats['as-provided'].projectRoot}`;
61
+ const asProvidedSelectedValue = `${formats['as-provided'].projectName} @ ${formats['as-provided'].projectRoot}`;
62
+ const derivedDescription = `Derived:
63
+ Name: ${formats['derived'].projectName}
64
+ Root: ${formats['derived'].projectRoot}`;
65
+ const derivedSelectedValue = `${formats['derived'].projectName} @ ${formats['derived'].projectRoot}`;
66
+ if (asProvidedSelectedValue === derivedSelectedValue) {
67
+ return 'as-provided';
68
+ }
69
+ const result = await (0, enquirer_1.prompt)({
70
+ type: 'select',
71
+ name: 'format',
72
+ message: 'What should be the project name and where should it be generated?',
73
+ choices: [
74
+ {
75
+ message: asProvidedDescription,
76
+ name: asProvidedSelectedValue,
77
+ },
78
+ {
79
+ message: derivedDescription,
80
+ name: derivedSelectedValue,
81
+ },
82
+ ],
83
+ initial: 0,
84
+ }).then(({ format }) => format === asProvidedSelectedValue ? 'as-provided' : 'derived');
85
+ return result;
86
+ }
87
+ function getProjectNameAndRootFormats(tree, options) {
88
+ const directory = options.directory
89
+ ? normalizePath(options.directory.replace(/^\.?\//, ''))
90
+ : undefined;
91
+ const { name: asProvidedParsedName, directory: asProvidedParsedDirectory } = parseNameForAsProvided(options.name);
92
+ if (asProvidedParsedDirectory && directory) {
93
+ throw new Error(`You can't specify both a directory (${options.directory}) and a name with a directory path (${options.name}). ` +
94
+ `Please specify either a directory or a name with a directory path.`);
95
+ }
96
+ const asProvidedOptions = getAsProvidedOptions(tree, {
97
+ ...options,
98
+ directory: directory ?? asProvidedParsedDirectory,
99
+ name: asProvidedParsedName,
100
+ });
101
+ if (options.projectNameAndRootFormat === 'as-provided') {
102
+ return {
103
+ 'as-provided': asProvidedOptions,
104
+ derived: undefined,
105
+ };
106
+ }
107
+ if (asProvidedOptions.projectName.startsWith('@')) {
108
+ if (!options.projectNameAndRootFormat) {
109
+ output.warn({
110
+ title: `The provided name "${options.name}" contains a scoped project name and this is not supported by the "${options.callingGenerator}" when using the "derived" format.`,
111
+ bodyLines: [
112
+ `The generator will try to generate the project "${asProvidedOptions.projectName}" using the "as-provided" format at "${asProvidedOptions.projectRoot}".`,
113
+ ],
114
+ });
115
+ return {
116
+ 'as-provided': asProvidedOptions,
117
+ derived: undefined,
118
+ };
119
+ }
120
+ throw new Error(`The provided name "${options.name}" contains a scoped project name and this is not supported by the "${options.callingGenerator}" when using the "derived" format. ` +
121
+ `Please provide a name without "@" or use the "as-provided" format.`);
122
+ }
123
+ const { name: derivedParsedName, directory: derivedParsedDirectory } = parseNameForDerived(options.name);
124
+ const derivedOptions = getDerivedOptions(tree, {
125
+ ...options,
126
+ directory: directory ?? derivedParsedDirectory,
127
+ name: derivedParsedName,
128
+ });
129
+ return {
130
+ 'as-provided': asProvidedOptions,
131
+ derived: derivedOptions,
132
+ };
133
+ }
134
+ function getAsProvidedOptions(tree, options) {
135
+ let projectSimpleName;
136
+ let projectFileName;
137
+ if (options.name.startsWith('@')) {
138
+ const [_scope, ...rest] = options.name.split('/');
139
+ projectFileName = rest.join('-');
140
+ projectSimpleName = rest.pop();
141
+ }
142
+ else {
143
+ projectSimpleName = options.name;
144
+ projectFileName = options.name;
145
+ }
146
+ let projectRoot;
147
+ const relativeCwd = getRelativeCwd();
148
+ if (options.directory) {
149
+ // append the directory to the current working directory if it doesn't start with it
150
+ if (options.directory === relativeCwd ||
151
+ options.directory.startsWith(`${relativeCwd}/`)) {
152
+ projectRoot = options.directory;
153
+ }
154
+ else {
155
+ projectRoot = joinPathFragments(relativeCwd, options.directory);
156
+ }
157
+ }
158
+ else if (options.rootProject) {
159
+ projectRoot = '.';
160
+ }
161
+ else {
162
+ projectRoot = relativeCwd;
163
+ // append the project name to the current working directory if it doesn't end with it
164
+ if (!relativeCwd.endsWith(options.name)) {
165
+ projectRoot = joinPathFragments(relativeCwd, options.name);
166
+ }
167
+ }
168
+ let importPath = undefined;
169
+ if (options.projectType === 'library') {
170
+ importPath = options.importPath;
171
+ if (!importPath) {
172
+ if (options.name.startsWith('@')) {
173
+ importPath = options.name;
174
+ }
175
+ else {
176
+ const npmScope = getNpmScope(tree);
177
+ importPath =
178
+ projectRoot === '.'
179
+ ? readJson(tree, 'package.json').name ??
180
+ getImportPath(npmScope, options.name)
181
+ : getImportPath(npmScope, options.name);
182
+ }
183
+ }
184
+ }
185
+ return {
186
+ projectName: options.name,
187
+ names: {
188
+ projectSimpleName,
189
+ projectFileName,
190
+ },
191
+ importPath,
192
+ projectRoot,
193
+ };
194
+ }
195
+ function getDerivedOptions(tree, options) {
196
+ const name = (0, names_1.names)(options.name).fileName;
197
+ let { projectDirectory, layoutDirectory } = getDirectories(tree, options.directory, options.projectType);
198
+ const projectDirectoryWithoutLayout = projectDirectory
199
+ ? `${(0, names_1.names)(projectDirectory).fileName}/${name}`
200
+ : options.rootProject
201
+ ? '.'
202
+ : name;
203
+ // the project name uses the directory without the layout directory
204
+ const projectName = projectDirectoryWithoutLayout === '.'
205
+ ? name
206
+ : projectDirectoryWithoutLayout.replace(/\//g, '-');
207
+ const projectSimpleName = name;
208
+ let projectRoot = projectDirectoryWithoutLayout;
209
+ if (projectDirectoryWithoutLayout !== '.') {
210
+ // prepend the layout directory
211
+ projectRoot = joinPathFragments(layoutDirectory, projectRoot);
212
+ }
213
+ let importPath;
214
+ if (options.projectType === 'library') {
215
+ importPath = options.importPath;
216
+ if (!importPath) {
217
+ const npmScope = getNpmScope(tree);
218
+ importPath =
219
+ projectRoot === '.'
220
+ ? readJson(tree, 'package.json').name ??
221
+ getImportPath(npmScope, projectName)
222
+ : getImportPath(npmScope, projectDirectoryWithoutLayout);
223
+ }
224
+ }
225
+ return {
226
+ projectName,
227
+ names: {
228
+ projectSimpleName,
229
+ projectFileName: projectName,
230
+ },
231
+ importPath,
232
+ projectRoot,
233
+ };
234
+ }
235
+ function getDirectories(tree, directory, projectType) {
236
+ let { projectDirectory, layoutDirectory } = (0, get_workspace_layout_1.extractLayoutDirectory)(directory);
237
+ if (!layoutDirectory) {
238
+ const { appsDir, libsDir } = (0, get_workspace_layout_1.getWorkspaceLayout)(tree);
239
+ layoutDirectory = projectType === 'application' ? appsDir : libsDir;
240
+ }
241
+ return { projectDirectory, layoutDirectory };
242
+ }
243
+ function getImportPath(npmScope, name) {
244
+ return npmScope ? `${npmScope === '@' ? '' : '@'}${npmScope}/${name}` : name;
245
+ }
246
+ function getNpmScope(tree) {
247
+ const { name } = tree.exists('package.json')
248
+ ? readJson(tree, 'package.json')
249
+ : { name: null };
250
+ return name?.startsWith('@') ? name.split('/')[0].substring(1) : undefined;
251
+ }
252
+ function isTTY() {
253
+ return !!process.stdout.isTTY && process.env['CI'] !== 'true';
254
+ }
255
+ /**
256
+ * When running a script with the package manager (e.g. `npm run`), the package manager will
257
+ * traverse the directory tree upwards until it finds a `package.json` and will set `process.cwd()`
258
+ * to the folder where it found it. The actual working directory is stored in the INIT_CWD
259
+ * environment variable (see here: https://docs.npmjs.com/cli/v9/commands/npm-run-script#description).
260
+ */
261
+ function getCwd() {
262
+ return process.env.INIT_CWD?.startsWith(workspaceRoot)
263
+ ? process.env.INIT_CWD
264
+ : process.cwd();
265
+ }
266
+ function getRelativeCwd() {
267
+ return normalizePath((0, path_1.relative)(workspaceRoot, getCwd())).replace(/\/$/, '');
268
+ }
269
+ /**
270
+ * Function for setting cwd during testing
271
+ */
272
+ function setCwd(path) {
273
+ process.env.INIT_CWD = (0, path_1.join)(workspaceRoot, path);
274
+ }
275
+ exports.setCwd = setCwd;
276
+ function parseNameForAsProvided(rawName) {
277
+ const directory = normalizePath(rawName);
278
+ if (rawName.includes('@')) {
279
+ const index = directory.lastIndexOf('@');
280
+ if (index === 0) {
281
+ return { name: rawName, directory: undefined };
282
+ }
283
+ const name = directory.substring(index);
284
+ return { name, directory };
285
+ }
286
+ if (rawName.includes('/')) {
287
+ const index = directory.lastIndexOf('/');
288
+ const name = directory.substring(index + 1);
289
+ return { name, directory };
290
+ }
291
+ return { name: rawName, directory: undefined };
292
+ }
293
+ function parseNameForDerived(rawName) {
294
+ const parsedName = normalizePath(rawName).split('/');
295
+ const name = parsedName.pop();
296
+ const directory = parsedName.length ? parsedName.join('/') : undefined;
297
+ return { name, directory };
298
+ }
@@ -0,0 +1,7 @@
1
+ import type { GeneratorCallback } from 'nx/src/config/misc-interfaces';
2
+ /**
3
+ * Run tasks in serial
4
+ *
5
+ * @param tasks The tasks to run in serial.
6
+ */
7
+ export declare function runTasksInSerial(...tasks: GeneratorCallback[]): GeneratorCallback;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runTasksInSerial = void 0;
4
+ /**
5
+ * Run tasks in serial
6
+ *
7
+ * @param tasks The tasks to run in serial.
8
+ */
9
+ function runTasksInSerial(...tasks) {
10
+ return async () => {
11
+ for (const task of tasks) {
12
+ await task();
13
+ }
14
+ };
15
+ }
16
+ exports.runTasksInSerial = runTasksInSerial;
@@ -0,0 +1,11 @@
1
+ import type { Tree } from 'nx/src/generators/tree';
2
+ import type { ScriptTarget, ModuleKind } from 'typescript';
3
+ export type ToJSOptions = {
4
+ target?: ScriptTarget;
5
+ module?: ModuleKind;
6
+ extension: '.js' | '.mjs' | '.cjs';
7
+ };
8
+ /**
9
+ * Rename and transpile any new typescript files created to javascript files
10
+ */
11
+ export declare function toJS(tree: Tree, options?: ToJSOptions): void;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toJS = void 0;
4
+ const versions_1 = require("../utils/versions");
5
+ const package_json_1 = require("../utils/package-json");
6
+ /**
7
+ * Rename and transpile any new typescript files created to javascript files
8
+ */
9
+ function toJS(tree, options) {
10
+ const { JsxEmit, ScriptTarget, transpile, ModuleKind } = (0, package_json_1.ensurePackage)('typescript', versions_1.typescriptVersion);
11
+ for (const c of tree.listChanges()) {
12
+ if ((c.path.endsWith('.ts') || c.path.endsWith('tsx')) &&
13
+ c.type === 'CREATE') {
14
+ tree.write(c.path, transpile(c.content.toString('utf-8'), {
15
+ allowJs: true,
16
+ jsx: JsxEmit.Preserve,
17
+ target: options?.target ?? ScriptTarget.ESNext,
18
+ module: options?.module ?? ModuleKind.ESNext,
19
+ }));
20
+ tree.rename(c.path, c.path.replace(/\.tsx?$/, options?.extension ?? '.js'));
21
+ }
22
+ }
23
+ }
24
+ exports.toJS = toJS;
@@ -0,0 +1 @@
1
+ export declare function insertImport(): void;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.insertImport = void 0;
4
+ function insertImport() { }
5
+ exports.insertImport = insertImport;
@@ -0,0 +1 @@
1
+ export declare function insertImport(): void;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.insertImport = void 0;
4
+ function insertImport() { }
5
+ exports.insertImport = insertImport;
@@ -0,0 +1,4 @@
1
+ import type { Tree } from 'nx/src/generators/tree';
2
+ export declare function updateTsConfigsToJs(tree: Tree, options: {
3
+ projectRoot: string;
4
+ }): void;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateTsConfigsToJs = void 0;
4
+ const nx_1 = require("../../nx");
5
+ const { updateJson } = (0, nx_1.requireNx)();
6
+ function updateTsConfigsToJs(tree, options) {
7
+ let updateConfigPath;
8
+ const paths = {
9
+ tsConfig: `${options.projectRoot}/tsconfig.json`,
10
+ tsConfigLib: `${options.projectRoot}/tsconfig.lib.json`,
11
+ tsConfigApp: `${options.projectRoot}/tsconfig.app.json`,
12
+ };
13
+ const getProjectType = (tree) => {
14
+ if (tree.exists(paths.tsConfigApp)) {
15
+ return 'application';
16
+ }
17
+ if (tree.exists(paths.tsConfigLib)) {
18
+ return 'library';
19
+ }
20
+ throw new Error(`project is missing tsconfig.lib.json or tsconfig.app.json`);
21
+ };
22
+ updateJson(tree, paths.tsConfig, (json) => {
23
+ if (json.compilerOptions) {
24
+ json.compilerOptions.allowJs = true;
25
+ }
26
+ else {
27
+ json.compilerOptions = { allowJs: true };
28
+ }
29
+ return json;
30
+ });
31
+ const projectType = getProjectType(tree);
32
+ if (projectType === 'library') {
33
+ updateConfigPath = paths.tsConfigLib;
34
+ }
35
+ if (projectType === 'application') {
36
+ updateConfigPath = paths.tsConfigApp;
37
+ }
38
+ updateJson(tree, updateConfigPath, (json) => {
39
+ json.include = uniq([...json.include, 'src/**/*.js']);
40
+ json.exclude = uniq([
41
+ ...json.exclude,
42
+ 'src/**/*.spec.js',
43
+ 'src/**/*.test.js',
44
+ ]);
45
+ return json;
46
+ });
47
+ }
48
+ exports.updateTsConfigsToJs = updateTsConfigsToJs;
49
+ const uniq = (value) => [...new Set(value)];
@@ -0,0 +1,5 @@
1
+ import type { Tree } from 'nx/src/generators/tree';
2
+ /**
3
+ * Utility to act on all files in a tree that are not ignored by git.
4
+ */
5
+ export declare function visitNotIgnoredFiles(tree: Tree, dirPath: string, visitor: (path: string) => void): void;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.visitNotIgnoredFiles = void 0;
4
+ const ignore_1 = require("ignore");
5
+ const path_1 = require("path");
6
+ /**
7
+ * Utility to act on all files in a tree that are not ignored by git.
8
+ */
9
+ function visitNotIgnoredFiles(tree, dirPath = tree.root, visitor) {
10
+ // TODO (v17): use packages/nx/src/utils/ignore.ts
11
+ let ig;
12
+ if (tree.exists('.gitignore')) {
13
+ ig = (0, ignore_1.default)();
14
+ ig.add('.git');
15
+ ig.add(tree.read('.gitignore', 'utf-8'));
16
+ }
17
+ if (tree.exists('.nxignore')) {
18
+ ig ??= (0, ignore_1.default)();
19
+ ig.add(tree.read('.nxignore', 'utf-8'));
20
+ }
21
+ dirPath = normalizePathRelativeToRoot(dirPath, tree.root);
22
+ if (dirPath !== '' && ig?.ignores(dirPath)) {
23
+ return;
24
+ }
25
+ for (const child of tree.children(dirPath)) {
26
+ const fullPath = (0, path_1.join)(dirPath, child);
27
+ if (ig?.ignores(fullPath)) {
28
+ continue;
29
+ }
30
+ if (tree.isFile(fullPath)) {
31
+ visitor(fullPath);
32
+ }
33
+ else {
34
+ visitNotIgnoredFiles(tree, fullPath, visitor);
35
+ }
36
+ }
37
+ }
38
+ exports.visitNotIgnoredFiles = visitNotIgnoredFiles;
39
+ function normalizePathRelativeToRoot(path, root) {
40
+ return (0, path_1.relative)(root, (0, path_1.join)(root, path)).split(path_1.sep).join('/');
41
+ }
@@ -0,0 +1,2 @@
1
+ import type { Tree } from 'nx/src/generators/tree';
2
+ export default function replacePackage(tree: Tree): Promise<void>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const format_files_1 = require("../../generators/format-files");
4
+ const replace_package_1 = require("../../utils/replace-package");
5
+ async function replacePackage(tree) {
6
+ await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/devkit', '@nx/devkit');
7
+ await (0, format_files_1.formatFiles)(tree);
8
+ }
9
+ exports.default = replacePackage;
@@ -0,0 +1,4 @@
1
+ import type { Tree } from 'nx/src/generators/tree';
2
+ import type { GeneratorCallback } from 'nx/src/config/misc-interfaces';
3
+ declare const _default: (tree: Tree) => Promise<GeneratorCallback | void>;
4
+ export default _default;