@nx/js 17.0.4 → 17.0.6

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 (54) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -9
  3. package/babel.js +16 -36
  4. package/executors.json +1 -1
  5. package/migrations.json +0 -56
  6. package/package.json +9 -9
  7. package/src/executors/node/node.impl.js +1 -1
  8. package/src/executors/node/schema.json +1 -1
  9. package/src/executors/release-publish/release-publish.impl.js +32 -135
  10. package/src/executors/release-publish/schema.d.ts +0 -2
  11. package/src/executors/release-publish/schema.json +1 -1
  12. package/src/executors/swc/schema.json +1 -1
  13. package/src/executors/swc/swc.impl.js +7 -6
  14. package/src/executors/verdaccio/schema.json +1 -1
  15. package/src/executors/verdaccio/verdaccio.impl.js +1 -1
  16. package/src/generators/convert-to-swc/schema.json +1 -1
  17. package/src/generators/init/init.js +2 -3
  18. package/src/generators/init/schema.d.ts +0 -1
  19. package/src/generators/init/schema.json +1 -7
  20. package/src/generators/library/files/{readme → lib}/README.md +1 -1
  21. package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +1 -5
  22. package/src/generators/library/library.d.ts +1 -1
  23. package/src/generators/library/library.js +29 -171
  24. package/src/generators/library/schema.json +2 -8
  25. package/src/generators/release-version/release-version.d.ts +1 -2
  26. package/src/generators/release-version/release-version.js +86 -341
  27. package/src/generators/release-version/schema.json +4 -26
  28. package/src/generators/release-version/utils/resolve-local-package-dependencies.d.ts +1 -7
  29. package/src/generators/release-version/utils/resolve-local-package-dependencies.js +4 -14
  30. package/src/generators/release-version/utils/resolve-version-spec.js +1 -4
  31. package/src/generators/setup-build/generator.js +0 -3
  32. package/src/generators/setup-build/schema.json +1 -1
  33. package/src/generators/setup-verdaccio/schema.json +1 -1
  34. package/src/utils/add-local-registry-scripts.js +6 -26
  35. package/src/utils/assets/copy-assets-handler.js +4 -4
  36. package/src/utils/buildable-libs-utils.js +2 -6
  37. package/src/utils/find-npm-dependencies.d.ts +1 -2
  38. package/src/utils/find-npm-dependencies.js +11 -28
  39. package/src/utils/inline.js +4 -6
  40. package/src/utils/minimal-publish-script.d.ts +2 -0
  41. package/src/utils/minimal-publish-script.js +74 -0
  42. package/src/utils/schema.d.ts +0 -3
  43. package/src/utils/swc/get-swcrc-path.d.ts +1 -4
  44. package/src/utils/swc/get-swcrc-path.js +1 -6
  45. package/src/utils/swc/inline.d.ts +1 -1
  46. package/src/utils/swc/inline.js +2 -1
  47. package/src/utils/typescript/ast-utils.js +3 -2
  48. package/src/utils/typescript/ts-config.js +0 -1
  49. package/src/utils/versions.d.ts +4 -4
  50. package/src/utils/versions.js +4 -4
  51. package/src/generators/release-version/utils/update-lock-file.d.ts +0 -5
  52. package/src/generators/release-version/utils/update-lock-file.js +0 -105
  53. package/src/utils/npm-config.d.ts +0 -25
  54. package/src/utils/npm-config.js +0 -90
@@ -9,7 +9,6 @@ const startLocalRegistryScript = (localRegistryTarget) => `
9
9
  */
10
10
  import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
11
11
  import { execFileSync } from 'child_process';
12
- import { releasePublish, releaseVersion } from 'nx/release';
13
12
 
14
13
  export default async () => {
15
14
  // local registry target to run
@@ -22,21 +21,12 @@ export default async () => {
22
21
  storage,
23
22
  verbose: false,
24
23
  });
25
-
26
- await releaseVersion({
27
- specifier: '0.0.0-e2e',
28
- stageChanges: false,
29
- gitCommit: false,
30
- gitTag: false,
31
- firstRelease: true,
32
- generatorOptionsOverrides: {
33
- skipLockFileUpdate: true
34
- }
35
- });
36
- await releasePublish({
37
- tag: 'e2e',
38
- firstRelease: true
39
- });
24
+ const nx = require.resolve('nx');
25
+ execFileSync(
26
+ nx,
27
+ ['run-many', '--targets', 'publish', '--ver', '0.0.0-e2e', '--tag', 'e2e'],
28
+ { env: process.env, stdio: 'inherit' }
29
+ );
40
30
  };
41
31
  `;
42
32
  const stopLocalRegistryScript = `
@@ -59,16 +49,6 @@ function addLocalRegistryScripts(tree) {
59
49
  if (!tree.exists(startLocalRegistryPath)) {
60
50
  tree.write(startLocalRegistryPath, startLocalRegistryScript(localRegistryTarget));
61
51
  }
62
- else {
63
- const existingStartLocalRegistryScript = tree
64
- .read(startLocalRegistryPath)
65
- .toString();
66
- if (!existingStartLocalRegistryScript.includes('nx/release')) {
67
- devkit_1.output.warn({
68
- title: 'Your `start-local-registry.ts` script may be outdated. To ensure that newly generated packages are published appropriately when running end to end tests, update this script to use Nx Release. See https://nx.dev/recipes/nx-release/update-local-registry-setup for details.',
69
- });
70
- }
71
- }
72
52
  if (!tree.exists(stopLocalRegistryPath)) {
73
53
  tree.write(stopLocalRegistryPath, stopLocalRegistryScript);
74
54
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CopyAssetsHandler = exports.defaultFileEventHandler = void 0;
4
- const minimatch_1 = require("minimatch");
4
+ const minimatch = require("minimatch");
5
5
  const path = require("path");
6
6
  const fse = require("fs-extra");
7
7
  const ignore_1 = require("ignore");
@@ -114,8 +114,8 @@ class CopyAssetsHandler {
114
114
  for (const event of events) {
115
115
  const pathFromRoot = path.relative(this.rootDir, event.path);
116
116
  for (const ag of this.assetGlobs) {
117
- if ((0, minimatch_1.minimatch)(pathFromRoot, ag.pattern) &&
118
- !ag.ignore?.some((ig) => (0, minimatch_1.minimatch)(pathFromRoot, ig)) &&
117
+ if (minimatch(pathFromRoot, ag.pattern) &&
118
+ !ag.ignore?.some((ig) => minimatch(pathFromRoot, ig)) &&
119
119
  !this.ignore.ignores(pathFromRoot)) {
120
120
  const relPath = path.relative(ag.input, pathFromRoot);
121
121
  const destPath = relPath.startsWith('..') ? pathFromRoot : relPath;
@@ -134,7 +134,7 @@ class CopyAssetsHandler {
134
134
  }
135
135
  filesToEvent(files, assetGlob) {
136
136
  return files.reduce((acc, src) => {
137
- if (!assetGlob.ignore?.some((ig) => (0, minimatch_1.minimatch)(src, ig)) &&
137
+ if (!assetGlob.ignore?.some((ig) => minimatch(src, ig)) &&
138
138
  !this.ignore.ignores(src)) {
139
139
  const relPath = path.relative(assetGlob.input, src);
140
140
  const dest = relPath.startsWith('..') ? src : relPath;
@@ -84,8 +84,7 @@ function calculateProjectDependencies(projGraph, root, projectName, targetName,
84
84
  exports.calculateProjectDependencies = calculateProjectDependencies;
85
85
  function collectDependencies(project, projGraph, acc, shallow, areTopLevelDeps = true) {
86
86
  (projGraph.dependencies[project] || []).forEach((dependency) => {
87
- const existingEntry = acc.find((dep) => dep.name === dependency.target);
88
- if (!existingEntry) {
87
+ if (!acc.some((dep) => dep.name === dependency.target)) {
89
88
  // Temporary skip this. Currently the set of external nodes is built from package.json, not lock file.
90
89
  // As a result, some nodes might be missing. This should not cause any issues, we can just skip them.
91
90
  if (dependency.target.startsWith('npm:') &&
@@ -97,9 +96,6 @@ function collectDependencies(project, projGraph, acc, shallow, areTopLevelDeps =
97
96
  collectDependencies(dependency.target, projGraph, acc, shallow, false);
98
97
  }
99
98
  }
100
- else if (areTopLevelDeps && !existingEntry.isTopLevel) {
101
- existingEntry.isTopLevel = true;
102
- }
103
99
  });
104
100
  return acc;
105
101
  }
@@ -127,7 +123,7 @@ function calculateDependenciesFromTaskGraph(taskGraph, projectGraph, root, proje
127
123
  const depTask = taskGraph.tasks[taskName];
128
124
  const depProjectNode = projectGraph.nodes?.[depTask.target.project];
129
125
  if (depProjectNode?.type !== 'lib') {
130
- continue;
126
+ return null;
131
127
  }
132
128
  let outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)(depTask.target, depTask.overrides, depProjectNode);
133
129
  if (outputs.length === 0) {
@@ -1,9 +1,8 @@
1
- import { type ProjectFileMap, type ProjectGraph, type ProjectGraphProjectNode } from '@nx/devkit';
1
+ import { type ProjectGraph, type ProjectGraphProjectNode, type ProjectFileMap } from '@nx/devkit';
2
2
  /**
3
3
  * Finds all npm dependencies and their expected versions for a given project.
4
4
  */
5
5
  export declare function findNpmDependencies(workspaceRoot: string, sourceProject: ProjectGraphProjectNode, projectGraph: ProjectGraph, projectFileMap: ProjectFileMap, buildTarget: string, options?: {
6
6
  includeTransitiveDependencies?: boolean;
7
7
  ignoredFiles?: string[];
8
- useLocalPathsForWorkspaceDependencies?: boolean;
9
8
  }): Record<string, string>;
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findNpmDependencies = void 0;
4
4
  const path_1 = require("path");
5
5
  const configuration_1 = require("nx/src/config/configuration");
6
+ const task_hasher_1 = require("nx/src/hasher/task-hasher");
6
7
  const devkit_1 = require("@nx/devkit");
7
8
  const fileutils_1 = require("nx/src/utils/fileutils");
8
9
  const project_graph_1 = require("nx/src/config/project-graph");
9
10
  const ts_config_1 = require("./typescript/ts-config");
10
- const task_hasher_1 = require("nx/src/hasher/task-hasher");
11
11
  /**
12
12
  * Finds all npm dependencies and their expected versions for a given project.
13
13
  */
@@ -21,7 +21,7 @@ function findNpmDependencies(workspaceRoot, sourceProject, projectGraph, project
21
21
  if (seen?.has(currentProject.name))
22
22
  return;
23
23
  seen?.add(currentProject.name);
24
- collectDependenciesFromFileMap(workspaceRoot, currentProject, projectGraph, projectFileMap, buildTarget, options.ignoredFiles, options.useLocalPathsForWorkspaceDependencies, collectedDeps);
24
+ collectDependenciesFromFileMap(workspaceRoot, currentProject, projectGraph, projectFileMap, buildTarget, options.ignoredFiles, collectedDeps);
25
25
  collectHelperDependencies(workspaceRoot, currentProject, projectGraph, buildTarget, collectedDeps);
26
26
  if (options.includeTransitiveDependencies) {
27
27
  const projectDeps = projectGraph.dependencies[currentProject.name];
@@ -38,7 +38,7 @@ function findNpmDependencies(workspaceRoot, sourceProject, projectGraph, project
38
38
  exports.findNpmDependencies = findNpmDependencies;
39
39
  // Keep track of workspace libs we already read package.json for so we don't read from disk again.
40
40
  const seenWorkspaceDeps = {};
41
- function collectDependenciesFromFileMap(workspaceRoot, sourceProject, projectGraph, projectFileMap, buildTarget, ignoredFiles, useLocalPathsForWorkspaceDependencies, npmDeps) {
41
+ function collectDependenciesFromFileMap(workspaceRoot, sourceProject, projectGraph, projectFileMap, buildTarget, ignoredFiles, npmDeps) {
42
42
  const rawFiles = projectFileMap[sourceProject.name];
43
43
  if (!rawFiles)
44
44
  return;
@@ -82,27 +82,12 @@ function collectDependenciesFromFileMap(workspaceRoot, sourceProject, projectGra
82
82
  workspaceDep.data.targets[buildTarget] &&
83
83
  // Make sure package.json exists and has a valid name.
84
84
  packageJson?.name) {
85
- let version;
86
- if (useLocalPathsForWorkspaceDependencies) {
87
- // Find the relative `file:...` path and use that as the version value.
88
- // This is useful for monorepos like Nx where the release will handle setting the correct version in dist.
89
- const depRoot = (0, path_1.join)(workspaceRoot, workspaceDep.data.root);
90
- const ownRoot = (0, path_1.join)(workspaceRoot, sourceProject.data.root);
91
- const relativePath = (0, path_1.relative)(ownRoot, depRoot);
92
- const filePath = (0, devkit_1.normalizePath)(relativePath); // normalize slashes for windows
93
- version = `file:${filePath}`;
94
- }
95
- else {
96
- // Otherwise, read the version from the dependencies `package.json` file.
97
- // This is useful for monorepos that commit release versions.
98
- // Users can also set version as "*" in source `package.json` files, which will be the value set here.
99
- // This is useful if they use custom scripts to update them in dist.
100
- version = packageJson.version ?? '*'; // fallback in case version is missing
101
- }
102
- npmDeps[packageJson.name] = version;
85
+ // This is a workspace lib so we can't reliably read in a specific version since it depends on how the workspace is set up.
86
+ // ASSUMPTION: Most users will use '*' for workspace lib versions. Otherwise, they can manually update it.
87
+ npmDeps[packageJson.name] = '*';
103
88
  seenWorkspaceDeps[workspaceDep.name] = {
104
89
  name: packageJson.name,
105
- version,
90
+ version: '*',
106
91
  };
107
92
  }
108
93
  }
@@ -121,9 +106,8 @@ function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, b
121
106
  return;
122
107
  if (target.executor === '@nx/js:tsc' && target.options?.tsConfig) {
123
108
  const tsConfig = (0, ts_config_1.readTsConfig)((0, path_1.join)(workspaceRoot, target.options.tsConfig));
124
- if (tsConfig?.options['importHelpers'] &&
125
- projectGraph.externalNodes['npm:tslib']?.type === 'npm') {
126
- npmDeps['tslib'] = projectGraph.externalNodes['npm:tslib'].data.version;
109
+ if (tsConfig?.options['importHelpers']) {
110
+ npmDeps['tslib'] = projectGraph.externalNodes['npm:tslib']?.data.version;
127
111
  }
128
112
  }
129
113
  if (target.executor === '@nx/js:swc') {
@@ -133,10 +117,9 @@ function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, b
133
117
  const swcConfig = (0, fileutils_1.fileExists)(swcConfigPath)
134
118
  ? (0, devkit_1.readJsonFile)(swcConfigPath)
135
119
  : {};
136
- if (swcConfig?.jsc?.externalHelpers &&
137
- projectGraph.externalNodes['npm:@swc/helpers']?.type === 'npm') {
120
+ if (swcConfig?.jsc?.externalHelpers) {
138
121
  npmDeps['@swc/helpers'] =
139
- projectGraph.externalNodes['npm:@swc/helpers'].data.version;
122
+ projectGraph.externalNodes['npm:@swc/helpers']?.data.version;
140
123
  }
141
124
  }
142
125
  }
@@ -161,11 +161,9 @@ function movePackage(from, to) {
161
161
  (0, fs_extra_1.copySync)(from, to, { overwrite: true });
162
162
  }
163
163
  function updateImports(destOutputPath, inlinedDepsDestOutputRecord) {
164
- const pathAliases = Object.keys(inlinedDepsDestOutputRecord);
165
- if (pathAliases.length == 0) {
166
- return;
167
- }
168
- const importRegex = new RegExp(pathAliases.map((pathAlias) => `["'](${pathAlias})["']`).join('|'), 'g');
164
+ const importRegex = new RegExp(Object.keys(inlinedDepsDestOutputRecord)
165
+ .map((pathAlias) => `["'](${pathAlias})["']`)
166
+ .join('|'), 'g');
169
167
  recursiveUpdateImport(destOutputPath, importRegex, inlinedDepsDestOutputRecord);
170
168
  }
171
169
  function recursiveUpdateImport(dirPath, importRegex, inlinedDepsDestOutputRecord, rootParentDir) {
@@ -179,7 +177,7 @@ function recursiveUpdateImport(dirPath, importRegex, inlinedDepsDestOutputRecord
179
177
  const updatedContent = fileContent.replace(importRegex, (matched) => {
180
178
  const result = matched.replace(/['"]/g, '');
181
179
  // If a match is the same as the rootParentDir, we're checking its own files so we return the matched as in no changes.
182
- if (result === rootParentDir || !inlinedDepsDestOutputRecord[result])
180
+ if (result === rootParentDir)
183
181
  return matched;
184
182
  const importPath = `"${(0, path_1.relative)(dirPath, inlinedDepsDestOutputRecord[result])}"`;
185
183
  return (0, devkit_1.normalizePath)(importPath);
@@ -0,0 +1,2 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export declare function addMinimalPublishScript(tree: Tree): string;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addMinimalPublishScript = void 0;
4
+ const publishScriptContent = `
5
+ /**
6
+ * This is a minimal script to publish your package to "npm".
7
+ * This is meant to be used as-is or customize as you see fit.
8
+ *
9
+ * This script is executed on "dist/path/to/library" as "cwd" by default.
10
+ *
11
+ * You might need to authenticate with NPM before running this script.
12
+ */
13
+
14
+ import { execSync } from 'child_process';
15
+ import { readFileSync, writeFileSync } from 'fs';
16
+
17
+ import devkit from '@nx/devkit';
18
+ const { readCachedProjectGraph } = devkit;
19
+
20
+ function invariant(condition, message) {
21
+ if (!condition) {
22
+ console.error(message);
23
+ process.exit(1);
24
+ }
25
+ }
26
+
27
+ // Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag}
28
+ // Default "tag" to "next" so we won't publish the "latest" tag by accident.
29
+ const [, , name, version, tag = 'next'] = process.argv;
30
+
31
+ // A simple SemVer validation to validate the version
32
+ const validVersion = /^\\d+\\.\\d+\\.\\d+(-\\w+\\.\\d+)?/;
33
+ invariant(
34
+ version && validVersion.test(version),
35
+ \`No version provided or version did not match Semantic Versioning, expected: #.#.#-tag.# or #.#.#, got \${version}.\`
36
+ );
37
+
38
+
39
+ const graph = readCachedProjectGraph();
40
+ const project = graph.nodes[name];
41
+
42
+ invariant(
43
+ project,
44
+ \`Could not find project "\${name}" in the workspace. Is the project.json configured correctly?\`
45
+ );
46
+
47
+ const outputPath = project.data?.targets?.build?.options?.outputPath;
48
+ invariant(
49
+ outputPath,
50
+ \`Could not find "build.options.outputPath" of project "\${name}". Is project.json configured correctly?\`
51
+ );
52
+
53
+ process.chdir(outputPath);
54
+
55
+ // Updating the version in "package.json" before publishing
56
+ try {
57
+ const json = JSON.parse(readFileSync(\`package.json\`).toString());
58
+ json.version = version;
59
+ writeFileSync(\`package.json\`, JSON.stringify(json, null, 2));
60
+ } catch (e) {
61
+ console.error(\`Error reading package.json file from library build output.\`);
62
+ }
63
+
64
+ // Execute "npm publish" to publish
65
+ execSync(\`npm publish --access public --tag \${tag}\`);
66
+ `;
67
+ function addMinimalPublishScript(tree) {
68
+ const publishScriptPath = 'tools/scripts/publish.mjs';
69
+ if (!tree.exists(publishScriptPath)) {
70
+ tree.write(publishScriptPath, publishScriptContent);
71
+ }
72
+ return publishScriptPath;
73
+ }
74
+ exports.addMinimalPublishScript = addMinimalPublishScript;
@@ -14,7 +14,6 @@ export interface LibraryGeneratorSchema {
14
14
  skipFormat?: boolean;
15
15
  tags?: string;
16
16
  skipTsConfig?: boolean;
17
- skipPackageJson?: boolean;
18
17
  includeBabelRc?: boolean;
19
18
  unitTestRunner?: 'jest' | 'vitest' | 'none';
20
19
  linter?: Linter;
@@ -33,7 +32,6 @@ export interface LibraryGeneratorSchema {
33
32
  minimal?: boolean;
34
33
  rootProject?: boolean;
35
34
  simpleName?: boolean;
36
- addPlugin?: boolean;
37
35
  }
38
36
 
39
37
  export interface ExecutorOptions {
@@ -83,5 +81,4 @@ export interface NormalizedSwcExecutorOptions
83
81
  swcExclude: string[];
84
82
  skipTypeCheck: boolean;
85
83
  swcCliOptions: SwcCliOptions;
86
- tmpSwcrcPath: string;
87
84
  }
@@ -1,5 +1,2 @@
1
1
  import { SwcExecutorOptions } from '../schema';
2
- export declare function getSwcrcPath(options: SwcExecutorOptions, contextRoot: string, projectRoot: string): {
3
- swcrcPath: string;
4
- tmpSwcrcPath: string;
5
- };
2
+ export declare function getSwcrcPath(options: SwcExecutorOptions, contextRoot: string, projectRoot: string): string;
@@ -3,13 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSwcrcPath = void 0;
4
4
  const path_1 = require("path");
5
5
  function getSwcrcPath(options, contextRoot, projectRoot) {
6
- const swcrcPath = options.swcrc
6
+ return options.swcrc
7
7
  ? (0, path_1.join)(contextRoot, options.swcrc)
8
8
  : (0, path_1.join)(contextRoot, projectRoot, '.swcrc');
9
- const tmpSwcrcPath = (0, path_1.join)(contextRoot, projectRoot, 'tmp', '.generated.swcrc');
10
- return {
11
- swcrcPath,
12
- tmpSwcrcPath,
13
- };
14
9
  }
15
10
  exports.getSwcrcPath = getSwcrcPath;
@@ -1,2 +1,2 @@
1
1
  import type { InlineProjectGraph } from '../inline';
2
- export declare function generateTmpSwcrc(inlineProjectGraph: InlineProjectGraph, swcrcPath: string, tmpSwcrcPath: string): string;
2
+ export declare function generateTmpSwcrc(inlineProjectGraph: InlineProjectGraph, swcrcPath: string): string;
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateTmpSwcrc = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- function generateTmpSwcrc(inlineProjectGraph, swcrcPath, tmpSwcrcPath) {
5
+ function generateTmpSwcrc(inlineProjectGraph, swcrcPath) {
6
6
  const swcrc = (0, devkit_1.readJsonFile)(swcrcPath);
7
7
  swcrc['exclude'] = swcrc['exclude'].concat(Object.values(inlineProjectGraph.externals).map((external) => `${external.root}/**/.*.ts$`), 'node_modules/**/*.ts$');
8
+ const tmpSwcrcPath = `tmp${swcrcPath}`;
8
9
  (0, devkit_1.writeJsonFile)(tmpSwcrcPath, swcrc);
9
10
  return tmpSwcrcPath;
10
11
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findNodes = exports.findClass = exports.addMethod = exports.addParameterToConstructor = exports.replaceNodeValue = exports.getImport = exports.addGlobal = exports.insertImport = exports.removeChange = exports.replaceChange = exports.insertChange = exports.resolveModuleByImport = void 0;
4
+ // TODO(colum): replace when https://github.com/nrwl/nx/pull/15497 is merged
5
+ const typescript_1 = require("@nx/workspace/src/utilities/typescript");
4
6
  const ensure_typescript_1 = require("./ensure-typescript");
5
7
  const devkit_1 = require("@nx/devkit");
6
8
  const path_1 = require("path");
7
- const get_source_nodes_1 = require("./get-source-nodes");
8
9
  const normalizedAppRoot = devkit_1.workspaceRoot.replace(/\\/g, '/');
9
10
  let tsModule;
10
11
  let compilerHost;
@@ -227,7 +228,7 @@ function findClass(source, className, silent = false) {
227
228
  if (!tsModule) {
228
229
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
229
230
  }
230
- const nodes = (0, get_source_nodes_1.getSourceNodes)(source);
231
+ const nodes = (0, typescript_1.getSourceNodes)(source);
231
232
  const clazz = nodes.filter((n) => n.kind === tsModule.SyntaxKind.ClassDeclaration &&
232
233
  n.name.text === className)[0];
233
234
  if (!clazz && !silent) {
@@ -46,7 +46,6 @@ function getRootTsConfigFileName(tree) {
46
46
  exports.getRootTsConfigFileName = getRootTsConfigFileName;
47
47
  function addTsConfigPath(tree, importPath, lookupPaths) {
48
48
  (0, devkit_1.updateJson)(tree, getRootTsConfigPathInTree(tree), (json) => {
49
- json.compilerOptions ??= {};
50
49
  const c = json.compilerOptions;
51
50
  c.paths ??= {};
52
51
  if (c.paths[importPath]) {
@@ -4,14 +4,14 @@ export declare const prettierVersion = "^2.6.2";
4
4
  export declare const swcCliVersion = "~0.1.62";
5
5
  export declare const swcCoreVersion = "~1.3.85";
6
6
  export declare const swcHelpersVersion = "~0.5.2";
7
- export declare const swcNodeVersion = "~1.8.0";
7
+ export declare const swcNodeVersion = "~1.6.7";
8
8
  export declare const tsLibVersion = "^2.3.0";
9
- export declare const typesNodeVersion = "18.16.9";
9
+ export declare const typesNodeVersion = "18.7.1";
10
10
  export declare const verdaccioVersion = "^5.0.4";
11
- export declare const typescriptVersion = "~5.4.2";
11
+ export declare const typescriptVersion = "~5.1.3";
12
12
  /**
13
13
  * The minimum version is currently determined from the lowest version
14
14
  * that's supported by the lowest Angular supported version, e.g.
15
15
  * `npm view @angular/compiler-cli@14.0.0 peerDependencies.typescript`
16
16
  */
17
- export declare const supportedTypescriptVersions = ">=4.8.2";
17
+ export declare const supportedTypescriptVersions = ">=4.6.2";
@@ -7,15 +7,15 @@ exports.prettierVersion = '^2.6.2';
7
7
  exports.swcCliVersion = '~0.1.62';
8
8
  exports.swcCoreVersion = '~1.3.85';
9
9
  exports.swcHelpersVersion = '~0.5.2';
10
- exports.swcNodeVersion = '~1.8.0';
10
+ exports.swcNodeVersion = '~1.6.7';
11
11
  exports.tsLibVersion = '^2.3.0';
12
- exports.typesNodeVersion = '18.16.9';
12
+ exports.typesNodeVersion = '18.7.1';
13
13
  exports.verdaccioVersion = '^5.0.4';
14
14
  // Typescript
15
- exports.typescriptVersion = '~5.4.2';
15
+ exports.typescriptVersion = '~5.1.3';
16
16
  /**
17
17
  * The minimum version is currently determined from the lowest version
18
18
  * that's supported by the lowest Angular supported version, e.g.
19
19
  * `npm view @angular/compiler-cli@14.0.0 peerDependencies.typescript`
20
20
  */
21
- exports.supportedTypescriptVersions = '>=4.8.2';
21
+ exports.supportedTypescriptVersions = '>=4.6.2';
@@ -1,5 +0,0 @@
1
- export declare function updateLockFile(cwd: string, { dryRun, verbose, generatorOptions, }: {
2
- dryRun?: boolean;
3
- verbose?: boolean;
4
- generatorOptions?: Record<string, unknown>;
5
- }): Promise<string[]>;
@@ -1,105 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateLockFile = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const child_process_1 = require("child_process");
6
- const client_1 = require("nx/src/daemon/client/client");
7
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
8
- const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
9
- const semver_1 = require("semver");
10
- async function updateLockFile(cwd, { dryRun, verbose, generatorOptions, }) {
11
- if (generatorOptions?.skipLockFileUpdate) {
12
- if (verbose) {
13
- console.log('\nSkipped lock file update because skipLockFileUpdate was set.');
14
- }
15
- return [];
16
- }
17
- const packageManager = (0, devkit_1.detectPackageManager)(cwd);
18
- if (packageManager === 'yarn' &&
19
- !(0, semver_1.gte)((0, devkit_1.getPackageManagerVersion)(packageManager), '2.0.0')) {
20
- // yarn classic does not store workspace data in the lock file, so we don't need to update it
21
- if (verbose) {
22
- console.log('\nSkipped lock file update because it is not necessary for Yarn Classic.');
23
- }
24
- return [];
25
- }
26
- const workspacesEnabled = (0, devkit_1.isWorkspacesEnabled)(packageManager, cwd);
27
- if (!workspacesEnabled) {
28
- if (verbose) {
29
- console.log(`\nSkipped lock file update because ${packageManager} workspaces are not enabled.`);
30
- }
31
- return [];
32
- }
33
- const isDaemonEnabled = client_1.daemonClient.enabled();
34
- if (!dryRun && isDaemonEnabled) {
35
- // if not in dry-run temporarily stop the daemon, as it will error if the lock file is updated
36
- await client_1.daemonClient.stop();
37
- }
38
- const packageManagerCommands = (0, devkit_1.getPackageManagerCommand)(packageManager);
39
- let installArgs = generatorOptions?.installArgs || '';
40
- devkit_1.output.logSingleLine(`Updating ${packageManager} lock file`);
41
- let env = {};
42
- if (generatorOptions?.installIgnoreScripts) {
43
- if (packageManager === 'yarn') {
44
- env = { YARN_ENABLE_SCRIPTS: 'false' };
45
- }
46
- else {
47
- // npm and pnpm use the same --ignore-scripts option
48
- installArgs = `${installArgs} --ignore-scripts`.trim();
49
- }
50
- }
51
- const lockFile = (0, lock_file_1.getLockFileName)(packageManager);
52
- const command = `${packageManagerCommands.updateLockFile} ${installArgs}`.trim();
53
- if (verbose) {
54
- if (dryRun) {
55
- console.log(`Would update ${lockFile} with the following command, but --dry-run was set:`);
56
- }
57
- else {
58
- console.log(`Updating ${lockFile} with the following command:`);
59
- }
60
- console.log(command);
61
- }
62
- if (dryRun) {
63
- return [];
64
- }
65
- execLockFileUpdate(command, cwd, env);
66
- if (isDaemonEnabled) {
67
- try {
68
- await client_1.daemonClient.startInBackground();
69
- }
70
- catch (e) {
71
- // If the daemon fails to start, we don't want to prevent the user from continuing, so we just log the error and move on
72
- if (verbose) {
73
- devkit_1.output.warn({
74
- title: 'Unable to restart the Nx Daemon. It will be disabled until you run "nx reset"',
75
- bodyLines: [e.message],
76
- });
77
- }
78
- }
79
- }
80
- return [lockFile];
81
- }
82
- exports.updateLockFile = updateLockFile;
83
- function execLockFileUpdate(command, cwd, env = {}) {
84
- try {
85
- (0, child_process_1.execSync)(command, {
86
- cwd,
87
- env: {
88
- ...process.env,
89
- ...env,
90
- },
91
- });
92
- }
93
- catch (e) {
94
- devkit_1.output.error({
95
- title: `Error updating lock file with command '${command}'`,
96
- bodyLines: [
97
- `Verify that '${command}' succeeds when run from the workspace root.`,
98
- `To configure a string of arguments to be passed to this command, set the 'release.version.generatorOptions.installArgs' property in nx.json.`,
99
- `To ignore install lifecycle scripts, set 'release.version.generatorOptions.installIgnoreScripts' to true in nx.json.`,
100
- `To disable this step entirely, set 'release.version.skipLockFileUpdate' to true in nx.json.`,
101
- ],
102
- });
103
- throw e;
104
- }
105
- }
@@ -1,25 +0,0 @@
1
- import { PackageJson } from 'nx/src/utils/package-json';
2
- export declare function parseRegistryOptions(cwd: string, pkg: {
3
- packageRoot: string;
4
- packageJson: PackageJson;
5
- }, options: {
6
- registry?: string;
7
- tag?: string;
8
- }, logWarnFn?: (message: string) => void): Promise<{
9
- registry: string;
10
- tag: string;
11
- registryConfigKey: string;
12
- }>;
13
- /**
14
- * Returns the npm registry that is used for publishing.
15
- *
16
- * @param scope the scope of the package for which to determine the registry
17
- * @param cwd the directory where the npm config should be read from
18
- */
19
- export declare function getNpmRegistry(cwd: string, scope?: string): Promise<string>;
20
- /**
21
- * Returns the npm tag that is used for publishing.
22
- *
23
- * @param cwd the directory where the npm config should be read from
24
- */
25
- export declare function getNpmTag(cwd: string): Promise<string>;