@nx/js 0.0.0-pr-30418-e91f47d → 0.0.0-pr-30457-dee3a4c
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/package.json +3 -5
- package/src/generators/library/library.js +3 -4
- package/src/generators/library/utils/add-release-config.d.ts +1 -1
- package/src/generators/library/utils/add-release-config.js +7 -21
- package/src/generators/release-version/release-version.d.ts +1 -1
- package/src/generators/release-version/release-version.js +10 -11
- package/src/generators/release-version/schema.d.ts +1 -1
- package/src/generators/release-version/schema.json +4 -23
- package/src/generators/release-version/utils/update-lock-file.d.ts +2 -7
- package/src/generators/release-version/utils/update-lock-file.js +9 -12
- package/src/plugins/typescript/plugin.js +53 -3
- package/src/generators/release-version/version-actions.d.ts +0 -28
- package/src/generators/release-version/version-actions.js +0 -224
- package/src/utils/typescript/tsnode-register.d.ts +0 -1
- package/src/utils/typescript/tsnode-register.js +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-30457-dee3a4c",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
|
|
6
6
|
"repository": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.23.2",
|
|
40
40
|
"@babel/preset-typescript": "^7.22.5",
|
|
41
41
|
"@babel/runtime": "^7.22.6",
|
|
42
|
-
"@nx/devkit": "0.0.0-pr-
|
|
43
|
-
"@nx/workspace": "0.0.0-pr-
|
|
42
|
+
"@nx/devkit": "0.0.0-pr-30457-dee3a4c",
|
|
43
|
+
"@nx/workspace": "0.0.0-pr-30457-dee3a4c",
|
|
44
44
|
"@zkochan/js-yaml": "0.0.7",
|
|
45
45
|
"babel-plugin-const-enum": "^1.0.1",
|
|
46
46
|
"babel-plugin-macros": "^3.1.0",
|
|
@@ -60,8 +60,6 @@
|
|
|
60
60
|
"semver": "^7.5.3",
|
|
61
61
|
"source-map-support": "0.5.19",
|
|
62
62
|
"tinyglobby": "^0.2.12",
|
|
63
|
-
"ts-node": "10.9.1",
|
|
64
|
-
"tsconfig-paths": "^4.1.2",
|
|
65
63
|
"tslib": "^2.3.0"
|
|
66
64
|
},
|
|
67
65
|
"peerDependencies": {
|
|
@@ -8,10 +8,8 @@ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project
|
|
|
8
8
|
const prompt_1 = require("@nx/devkit/src/generators/prompt");
|
|
9
9
|
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
10
10
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
11
|
-
const use_legacy_versioning_1 = require("nx/src/command-line/release/config/use-legacy-versioning");
|
|
12
11
|
const path_1 = require("path");
|
|
13
12
|
const generator_prompts_1 = require("../../utils/generator-prompts");
|
|
14
|
-
const sort_fields_1 = require("../../utils/package-json/sort-fields");
|
|
15
13
|
const update_package_json_1 = require("../../utils/package-json/update-package-json");
|
|
16
14
|
const add_swc_config_1 = require("../../utils/swc/add-swc-config");
|
|
17
15
|
const add_swc_dependencies_1 = require("../../utils/swc/add-swc-dependencies");
|
|
@@ -23,6 +21,7 @@ const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
|
23
21
|
const ts_solution_setup_1 = require("../../utils/typescript/ts-solution-setup");
|
|
24
22
|
const versions_1 = require("../../utils/versions");
|
|
25
23
|
const init_1 = require("../init/init");
|
|
24
|
+
const sort_fields_1 = require("../../utils/package-json/sort-fields");
|
|
26
25
|
const add_release_config_1 = require("./utils/add-release-config");
|
|
27
26
|
const defaultOutputDirectory = 'dist';
|
|
28
27
|
async function libraryGenerator(tree, schema) {
|
|
@@ -159,8 +158,8 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
159
158
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
160
159
|
}
|
|
161
160
|
async function configureProject(tree, options) {
|
|
162
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
163
161
|
if (options.hasPlugin) {
|
|
162
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
164
163
|
(0, plugin_1.ensureProjectIsIncludedInPluginRegistrations)(nxJson, options.projectRoot, options.bundler === 'none' ? null : 'build');
|
|
165
164
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
166
165
|
}
|
|
@@ -218,7 +217,7 @@ async function configureProject(tree, options) {
|
|
|
218
217
|
await (0, add_release_config_1.addReleaseConfigForTsSolution)(tree, options.name, projectConfiguration);
|
|
219
218
|
}
|
|
220
219
|
else {
|
|
221
|
-
await (0, add_release_config_1.addReleaseConfigForNonTsSolution)(
|
|
220
|
+
await (0, add_release_config_1.addReleaseConfigForNonTsSolution)(tree, options.name, projectConfiguration, defaultOutputDirectory);
|
|
222
221
|
}
|
|
223
222
|
}
|
|
224
223
|
if (!options.useProjectJson) {
|
|
@@ -7,5 +7,5 @@ export declare function addReleaseConfigForTsSolution(tree: Tree, projectName: s
|
|
|
7
7
|
* Add release configuration for non-ts solution projects
|
|
8
8
|
* Add release option in project.json and add packageRoot to nx-release-publish target
|
|
9
9
|
*/
|
|
10
|
-
export declare function addReleaseConfigForNonTsSolution(
|
|
10
|
+
export declare function addReleaseConfigForNonTsSolution(tree: Tree, projectName: string, projectConfiguration: ProjectConfiguration, defaultOutputDirectory?: string): Promise<ProjectConfiguration>;
|
|
11
11
|
export declare function releaseTasks(tree: Tree): Promise<GeneratorCallback>;
|
|
@@ -91,7 +91,7 @@ async function addReleaseConfigForTsSolution(tree, projectName, projectConfigura
|
|
|
91
91
|
* Add release configuration for non-ts solution projects
|
|
92
92
|
* Add release option in project.json and add packageRoot to nx-release-publish target
|
|
93
93
|
*/
|
|
94
|
-
async function addReleaseConfigForNonTsSolution(
|
|
94
|
+
async function addReleaseConfigForNonTsSolution(tree, projectName, projectConfiguration, defaultOutputDirectory = 'dist') {
|
|
95
95
|
const packageRoot = (0, devkit_1.joinPathFragments)(defaultOutputDirectory, '{projectRoot}');
|
|
96
96
|
projectConfiguration.targets ??= {};
|
|
97
97
|
projectConfiguration.targets['nx-release-publish'] = {
|
|
@@ -99,31 +99,17 @@ async function addReleaseConfigForNonTsSolution(useLegacyVersioning, tree, proje
|
|
|
99
99
|
packageRoot,
|
|
100
100
|
},
|
|
101
101
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
packageRoot,
|
|
107
|
-
// using git tags to determine the current version is required here because
|
|
108
|
-
// the version in the package root is overridden with every build
|
|
109
|
-
currentVersionResolver: 'git-tag',
|
|
110
|
-
fallbackCurrentVersionResolver: 'disk',
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
// TODO: re-evaluate this config in new versions
|
|
117
|
-
projectConfiguration.release = {
|
|
118
|
-
version: {
|
|
119
|
-
manifestRootsToUpdate: [packageRoot],
|
|
102
|
+
projectConfiguration.release = {
|
|
103
|
+
version: {
|
|
104
|
+
generatorOptions: {
|
|
105
|
+
packageRoot,
|
|
120
106
|
// using git tags to determine the current version is required here because
|
|
121
107
|
// the version in the package root is overridden with every build
|
|
122
108
|
currentVersionResolver: 'git-tag',
|
|
123
109
|
fallbackCurrentVersionResolver: 'disk',
|
|
124
110
|
},
|
|
125
|
-
}
|
|
126
|
-
}
|
|
111
|
+
},
|
|
112
|
+
};
|
|
127
113
|
await addReleaseConfigForTsSolution(tree, projectName, projectConfiguration);
|
|
128
114
|
return projectConfiguration;
|
|
129
115
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
import { ReleaseVersionGeneratorResult } from 'nx/src/command-line/release/version
|
|
2
|
+
import { ReleaseVersionGeneratorResult } from 'nx/src/command-line/release/version';
|
|
3
3
|
import { ReleaseVersionGeneratorSchema } from './schema';
|
|
4
4
|
export declare function releaseVersionGenerator(tree: Tree, options: ReleaseVersionGeneratorSchema): Promise<ReleaseVersionGeneratorResult>;
|
|
5
5
|
export default releaseVersionGenerator;
|
|
@@ -11,7 +11,7 @@ const config_1 = require("nx/src/command-line/release/config/config");
|
|
|
11
11
|
const git_1 = require("nx/src/command-line/release/utils/git");
|
|
12
12
|
const resolve_semver_specifier_1 = require("nx/src/command-line/release/utils/resolve-semver-specifier");
|
|
13
13
|
const semver_1 = require("nx/src/command-line/release/utils/semver");
|
|
14
|
-
const
|
|
14
|
+
const version_1 = require("nx/src/command-line/release/version");
|
|
15
15
|
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
16
16
|
const ora = require("ora");
|
|
17
17
|
const semver_2 = require("semver");
|
|
@@ -39,10 +39,10 @@ async function releaseVersionGenerator(tree, options) {
|
|
|
39
39
|
options.specifier = options.specifier.replace(/^v/, '');
|
|
40
40
|
}
|
|
41
41
|
if (options.versionPrefix &&
|
|
42
|
-
|
|
42
|
+
version_1.validReleaseVersionPrefixes.indexOf(options.versionPrefix) === -1) {
|
|
43
43
|
throw new Error(`Invalid value for version.generatorOptions.versionPrefix: "${options.versionPrefix}"
|
|
44
44
|
|
|
45
|
-
Valid values are: ${
|
|
45
|
+
Valid values are: ${version_1.validReleaseVersionPrefixes
|
|
46
46
|
.map((s) => `"${s}"`)
|
|
47
47
|
.join(', ')}`);
|
|
48
48
|
}
|
|
@@ -54,6 +54,7 @@ Valid values are: ${version_legacy_1.validReleaseVersionPrefixes
|
|
|
54
54
|
const updateDependents = options.updateDependents ?? 'auto';
|
|
55
55
|
const updateDependentsBump = resolvePreIdSpecifier('patch', options.preid);
|
|
56
56
|
// Sort the projects topologically if update dependents is enabled
|
|
57
|
+
// TODO: maybe move this sorting to the command level?
|
|
57
58
|
const projects = updateDependents === 'never' ||
|
|
58
59
|
options.releaseGroup.projectsRelationship !== 'independent'
|
|
59
60
|
? options.projects
|
|
@@ -286,6 +287,8 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
286
287
|
logger.buffer(`🚫 No changes were detected using git history and the conventional commits standard.`);
|
|
287
288
|
break;
|
|
288
289
|
}
|
|
290
|
+
// TODO: reevaluate this prerelease logic/workflow for independent projects
|
|
291
|
+
//
|
|
289
292
|
// Always assume that if the current version is a prerelease, then the next version should be a prerelease.
|
|
290
293
|
// Users must manually graduate from a prerelease to a release by providing an explicit specifier.
|
|
291
294
|
if ((0, semver_2.prerelease)(currentVersion ?? '')) {
|
|
@@ -487,7 +490,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
487
490
|
}
|
|
488
491
|
continue;
|
|
489
492
|
}
|
|
490
|
-
const newVersion = (0,
|
|
493
|
+
const newVersion = (0, version_1.deriveNewSemverVersion)(currentVersion, specifier, options.preid);
|
|
491
494
|
versionData[projectName].newVersion = newVersion;
|
|
492
495
|
(0, devkit_1.writeJson)(tree, packageJsonPath, {
|
|
493
496
|
...packageJson,
|
|
@@ -553,7 +556,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
553
556
|
}
|
|
554
557
|
// Bump the dependent's version if applicable and record it in the version data
|
|
555
558
|
if (forceVersionBump) {
|
|
556
|
-
const newPackageVersion = (0,
|
|
559
|
+
const newPackageVersion = (0, version_1.deriveNewSemverVersion)(currentPackageVersion, forceVersionBump, options.preid);
|
|
557
560
|
json.version = newPackageVersion;
|
|
558
561
|
// Look up any dependent projects from the transitiveLocalPackageDependents list
|
|
559
562
|
const transitiveDependentProjects = transitiveLocalPackageDependents.filter((localPackageDependency) => localPackageDependency.target === dependentProject.source);
|
|
@@ -663,10 +666,7 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
663
666
|
deletedFiles.push(...(await cb(opts.dryRun)));
|
|
664
667
|
}
|
|
665
668
|
const cwd = tree.root;
|
|
666
|
-
changedFiles.push(...(await (0, update_lock_file_1.updateLockFile)(cwd,
|
|
667
|
-
...opts,
|
|
668
|
-
useLegacyVersioning: true,
|
|
669
|
-
})));
|
|
669
|
+
changedFiles.push(...(await (0, update_lock_file_1.updateLockFile)(cwd, opts)));
|
|
670
670
|
return { changedFiles, deletedFiles };
|
|
671
671
|
},
|
|
672
672
|
};
|
|
@@ -697,8 +697,7 @@ function createResolvePackageRoot(customPackageRoot) {
|
|
|
697
697
|
return projectNode.data.root;
|
|
698
698
|
}
|
|
699
699
|
if (projectNode.data.root === '.') {
|
|
700
|
-
// This is a temporary workaround to fix NXC-574 until NXC-573 is resolved
|
|
701
|
-
// This has been fixed in "versioning v2"
|
|
700
|
+
// TODO This is a temporary workaround to fix NXC-574 until NXC-573 is resolved
|
|
702
701
|
return projectNode.data.root;
|
|
703
702
|
}
|
|
704
703
|
return (0, utils_1.interpolate)(customPackageRoot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ReleaseVersionGeneratorSchema } from 'nx/src/command-line/release/version
|
|
1
|
+
export { ReleaseVersionGeneratorSchema } from 'nx/src/command-line/release/version';
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
"properties": {
|
|
9
9
|
"projects": {
|
|
10
10
|
"type": "array",
|
|
11
|
-
"hidden": true,
|
|
12
|
-
"$comment": "This is not configured/passed by the user. It is provided by the version command.",
|
|
13
11
|
"description": "The ProjectGraphProjectNodes being versioned in the current execution.",
|
|
14
12
|
"items": {
|
|
15
13
|
"type": "object"
|
|
@@ -17,33 +15,16 @@
|
|
|
17
15
|
},
|
|
18
16
|
"projectGraph": {
|
|
19
17
|
"type": "object",
|
|
20
|
-
"hidden": true,
|
|
21
|
-
"$comment": "This is not configured/passed by the user. It is provided by the version command.",
|
|
22
18
|
"description": "ProjectGraph instance"
|
|
23
19
|
},
|
|
24
|
-
"releaseGroup": {
|
|
25
|
-
"type": "object",
|
|
26
|
-
"hidden": true,
|
|
27
|
-
"$comment": "This is not configured/passed by the user. It is provided by the version command.",
|
|
28
|
-
"description": "The resolved release group configuration, including name, relevant to all projects in the current execution."
|
|
29
|
-
},
|
|
30
|
-
"conventionalCommitsConfig": {
|
|
31
|
-
"type": "object",
|
|
32
|
-
"hidden": true,
|
|
33
|
-
"$comment": "This is not configured/passed by the user. It is provided by the version command.",
|
|
34
|
-
"description": "The conventional commits configuration to use when determining the next version of the project.",
|
|
35
|
-
"default": {}
|
|
36
|
-
},
|
|
37
|
-
"firstRelease": {
|
|
38
|
-
"type": "boolean",
|
|
39
|
-
"hidden": true,
|
|
40
|
-
"$comment": "This is not configured/passed by the user. It is provided by the version command.",
|
|
41
|
-
"description": "Whether this is the first release of the project (which skips some validation within the generator)."
|
|
42
|
-
},
|
|
43
20
|
"specifier": {
|
|
44
21
|
"type": "string",
|
|
45
22
|
"description": "Exact version or semver keyword to apply to the selected release group. Overrides specifierSource."
|
|
46
23
|
},
|
|
24
|
+
"releaseGroup": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"description": "The resolved release group configuration, including name, relevant to all projects in the current execution."
|
|
27
|
+
},
|
|
47
28
|
"specifierSource": {
|
|
48
29
|
"type": "string",
|
|
49
30
|
"default": "prompt",
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
export declare function updateLockFile(cwd: string, { dryRun, verbose,
|
|
1
|
+
export declare function updateLockFile(cwd: string, { dryRun, verbose, generatorOptions, }: {
|
|
2
2
|
dryRun?: boolean;
|
|
3
3
|
verbose?: boolean;
|
|
4
|
-
|
|
5
|
-
options?: {
|
|
6
|
-
skipLockFileUpdate?: boolean;
|
|
7
|
-
installArgs?: string;
|
|
8
|
-
installIgnoreScripts?: boolean;
|
|
9
|
-
};
|
|
4
|
+
generatorOptions?: Record<string, unknown>;
|
|
10
5
|
}): Promise<string[]>;
|
|
@@ -7,8 +7,8 @@ const client_1 = require("nx/src/daemon/client/client");
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
8
8
|
const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
|
|
9
9
|
const semver_1 = require("semver");
|
|
10
|
-
async function updateLockFile(cwd, { dryRun, verbose,
|
|
11
|
-
if (
|
|
10
|
+
async function updateLockFile(cwd, { dryRun, verbose, generatorOptions, }) {
|
|
11
|
+
if (generatorOptions?.skipLockFileUpdate) {
|
|
12
12
|
if (verbose) {
|
|
13
13
|
console.log('\nSkipped lock file update because skipLockFileUpdate was set.');
|
|
14
14
|
}
|
|
@@ -36,10 +36,10 @@ async function updateLockFile(cwd, { dryRun, verbose, useLegacyVersioning, optio
|
|
|
36
36
|
await client_1.daemonClient.stop();
|
|
37
37
|
}
|
|
38
38
|
const packageManagerCommands = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
39
|
-
let installArgs =
|
|
39
|
+
let installArgs = generatorOptions?.installArgs || '';
|
|
40
40
|
devkit_1.output.logSingleLine(`Updating ${packageManager} lock file`);
|
|
41
41
|
let env = {};
|
|
42
|
-
if (
|
|
42
|
+
if (generatorOptions?.installIgnoreScripts) {
|
|
43
43
|
if (packageManager === 'yarn') {
|
|
44
44
|
env = { YARN_ENABLE_SCRIPTS: 'false' };
|
|
45
45
|
}
|
|
@@ -62,7 +62,7 @@ async function updateLockFile(cwd, { dryRun, verbose, useLegacyVersioning, optio
|
|
|
62
62
|
if (dryRun) {
|
|
63
63
|
return [];
|
|
64
64
|
}
|
|
65
|
-
execLockFileUpdate(command, cwd, env
|
|
65
|
+
execLockFileUpdate(command, cwd, env);
|
|
66
66
|
if (isDaemonEnabled) {
|
|
67
67
|
try {
|
|
68
68
|
await client_1.daemonClient.startInBackground();
|
|
@@ -79,7 +79,7 @@ async function updateLockFile(cwd, { dryRun, verbose, useLegacyVersioning, optio
|
|
|
79
79
|
}
|
|
80
80
|
return [lockFile];
|
|
81
81
|
}
|
|
82
|
-
function execLockFileUpdate(command, cwd, env
|
|
82
|
+
function execLockFileUpdate(command, cwd, env = {}) {
|
|
83
83
|
try {
|
|
84
84
|
const LARGE_BUFFER = 1024 * 1000000;
|
|
85
85
|
(0, child_process_1.execSync)(command, {
|
|
@@ -93,16 +93,13 @@ function execLockFileUpdate(command, cwd, env, useLegacyVersioning) {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
catch (e) {
|
|
96
|
-
const configPathStart = useLegacyVersioning
|
|
97
|
-
? 'release.version.generatorOptions'
|
|
98
|
-
: 'release.version.versionActionsOptions';
|
|
99
96
|
devkit_1.output.error({
|
|
100
97
|
title: `Error updating lock file with command '${command}'`,
|
|
101
98
|
bodyLines: [
|
|
102
99
|
`Verify that '${command}' succeeds when run from the workspace root.`,
|
|
103
|
-
`To configure a string of arguments to be passed to this command, set the '
|
|
104
|
-
`To ignore install lifecycle scripts, set '
|
|
105
|
-
`To disable this step entirely, set '
|
|
100
|
+
`To configure a string of arguments to be passed to this command, set the 'release.version.generatorOptions.installArgs' property in nx.json.`,
|
|
101
|
+
`To ignore install lifecycle scripts, set 'release.version.generatorOptions.installIgnoreScripts' to true in nx.json.`,
|
|
102
|
+
`To disable this step entirely, set 'release.version.generatorOptions.skipLockFileUpdate' to true in nx.json.`,
|
|
106
103
|
],
|
|
107
104
|
});
|
|
108
105
|
throw e;
|
|
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createNodes = exports.createNodesV2 = exports.PLUGIN_NAME = exports.createDependencies = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
6
|
-
const picomatch = require("picomatch");
|
|
7
6
|
const node_fs_1 = require("node:fs");
|
|
8
7
|
const node_path_1 = require("node:path");
|
|
9
8
|
const posix = require("node:path/posix");
|
|
10
9
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
10
|
+
const picomatch = require("picomatch");
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
12
12
|
const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
|
|
13
13
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
14
14
|
const util_1 = require("./util");
|
|
15
|
+
let ts;
|
|
15
16
|
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
16
17
|
let tsConfigCache;
|
|
17
18
|
const tsConfigCachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, 'tsconfig-files.hash');
|
|
@@ -144,6 +145,9 @@ async function getConfigFileHash(configFilePath, workspaceRoot, projectRoot, opt
|
|
|
144
145
|
lockFileHash,
|
|
145
146
|
optionsHash,
|
|
146
147
|
...(packageJson ? [(0, file_hasher_1.hashObject)(packageJson)] : []),
|
|
148
|
+
// change this to bust the cache when making changes that would yield
|
|
149
|
+
// different results for the same hash
|
|
150
|
+
(0, file_hasher_1.hashObject)({ bust: 1 }),
|
|
147
151
|
]);
|
|
148
152
|
}
|
|
149
153
|
function checkIfConfigFileShouldBeProject(configFilePath, projectRoot, context) {
|
|
@@ -260,10 +264,57 @@ function getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferen
|
|
|
260
264
|
...Object.entries(internalProjectReferences),
|
|
261
265
|
];
|
|
262
266
|
const absoluteProjectRoot = (0, node_path_1.join)(workspaceRoot, projectRoot);
|
|
267
|
+
if (!ts) {
|
|
268
|
+
ts = require('typescript');
|
|
269
|
+
}
|
|
270
|
+
// https://github.com/microsoft/TypeScript/blob/19b777260b26aac5707b1efd34202054164d4a9d/src/compiler/utilities.ts#L9869
|
|
271
|
+
const supportedTSExtensions = [
|
|
272
|
+
ts.Extension.Ts,
|
|
273
|
+
ts.Extension.Tsx,
|
|
274
|
+
ts.Extension.Dts,
|
|
275
|
+
ts.Extension.Cts,
|
|
276
|
+
ts.Extension.Dcts,
|
|
277
|
+
ts.Extension.Mts,
|
|
278
|
+
ts.Extension.Dmts,
|
|
279
|
+
];
|
|
280
|
+
// https://github.com/microsoft/TypeScript/blob/19b777260b26aac5707b1efd34202054164d4a9d/src/compiler/utilities.ts#L9878
|
|
281
|
+
const allSupportedExtensions = [
|
|
282
|
+
ts.Extension.Ts,
|
|
283
|
+
ts.Extension.Tsx,
|
|
284
|
+
ts.Extension.Dts,
|
|
285
|
+
ts.Extension.Js,
|
|
286
|
+
ts.Extension.Jsx,
|
|
287
|
+
ts.Extension.Cts,
|
|
288
|
+
ts.Extension.Dcts,
|
|
289
|
+
ts.Extension.Cjs,
|
|
290
|
+
ts.Extension.Mts,
|
|
291
|
+
ts.Extension.Dmts,
|
|
292
|
+
ts.Extension.Mjs,
|
|
293
|
+
];
|
|
294
|
+
const normalizeInput = (input, config) => {
|
|
295
|
+
const extensions = config.options.allowJs
|
|
296
|
+
? [...allSupportedExtensions]
|
|
297
|
+
: [...supportedTSExtensions];
|
|
298
|
+
if (config.options.resolveJsonModule) {
|
|
299
|
+
extensions.push(ts.Extension.Json);
|
|
300
|
+
}
|
|
301
|
+
const segments = input.split('/');
|
|
302
|
+
// An "includes" path "foo" is implicitly a glob "foo/**/*" if its last
|
|
303
|
+
// segment has no extension, and does not contain any glob characters
|
|
304
|
+
// itself.
|
|
305
|
+
// https://github.com/microsoft/TypeScript/blob/19b777260b26aac5707b1efd34202054164d4a9d/src/compiler/utilities.ts#L9577-L9585
|
|
306
|
+
if (!/[.*?]/.test(segments.at(-1))) {
|
|
307
|
+
return extensions.map((ext) => `${segments.join('/')}/**/*${ext}`);
|
|
308
|
+
}
|
|
309
|
+
return [input];
|
|
310
|
+
};
|
|
263
311
|
projectTsConfigFiles.forEach(([configPath, config]) => {
|
|
264
312
|
configFiles.add(configPath);
|
|
265
313
|
const offset = (0, node_path_1.relative)(absoluteProjectRoot, (0, node_path_1.dirname)(configPath));
|
|
266
|
-
(config.raw?.include ?? []).forEach((p) =>
|
|
314
|
+
(config.raw?.include ?? []).forEach((p) => {
|
|
315
|
+
const normalized = normalizeInput((0, node_path_1.join)(offset, p), config);
|
|
316
|
+
normalized.forEach((input) => includePaths.add(input));
|
|
317
|
+
});
|
|
267
318
|
if (config.raw?.exclude) {
|
|
268
319
|
/**
|
|
269
320
|
* We need to filter out the exclude paths that are already included in
|
|
@@ -563,7 +614,6 @@ function getExtendedFilesHash(extendedConfigFile, workspaceRoot) {
|
|
|
563
614
|
}
|
|
564
615
|
return hashes.join('|');
|
|
565
616
|
}
|
|
566
|
-
let ts;
|
|
567
617
|
function readTsConfig(tsConfigPath, workspaceRoot) {
|
|
568
618
|
if (!ts) {
|
|
569
619
|
ts = require('typescript');
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ProjectGraph, Tree } from '@nx/devkit';
|
|
2
|
-
import { ManifestData, VersionActions } from 'nx/release';
|
|
3
|
-
import type { NxReleaseVersionV2Configuration } from 'nx/src/config/nx-json';
|
|
4
|
-
export default class JsVersionActions extends VersionActions {
|
|
5
|
-
manifestFilename: string;
|
|
6
|
-
static createAfterAllProjectsVersionedCallback(cwd: string, opts: {
|
|
7
|
-
dryRun?: boolean;
|
|
8
|
-
verbose?: boolean;
|
|
9
|
-
versionActionsOptions?: Record<string, unknown>;
|
|
10
|
-
}): () => Promise<{
|
|
11
|
-
changedFiles: string[];
|
|
12
|
-
deletedFiles: any[];
|
|
13
|
-
}>;
|
|
14
|
-
readSourceManifestData(tree: Tree): Promise<ManifestData>;
|
|
15
|
-
readCurrentVersionFromSourceManifest(tree: Tree): Promise<string>;
|
|
16
|
-
readCurrentVersionFromRegistry(tree: Tree, currentVersionResolverMetadata: NxReleaseVersionV2Configuration['currentVersionResolverMetadata']): Promise<{
|
|
17
|
-
currentVersion: string;
|
|
18
|
-
logText: string;
|
|
19
|
-
}>;
|
|
20
|
-
readCurrentVersionOfDependency(tree: Tree, projectGraph: ProjectGraph, dependencyProjectName: string): Promise<{
|
|
21
|
-
currentVersion: string | null;
|
|
22
|
-
dependencyCollection: string | null;
|
|
23
|
-
}>;
|
|
24
|
-
isLocalDependencyProtocol(versionSpecifier: string): boolean;
|
|
25
|
-
updateProjectVersion(tree: Tree, newVersion: string): Promise<string[]>;
|
|
26
|
-
updateProjectDependencies(tree: Tree, projectGraph: ProjectGraph, dependenciesToUpdate: Record<string, string>): Promise<string[]>;
|
|
27
|
-
private parseDependencies;
|
|
28
|
-
}
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
const node_child_process_1 = require("node:child_process");
|
|
5
|
-
const node_path_1 = require("node:path");
|
|
6
|
-
const release_1 = require("nx/release");
|
|
7
|
-
const npm_config_1 = require("../../utils/npm-config");
|
|
8
|
-
const resolve_version_spec_1 = require("./utils/resolve-version-spec");
|
|
9
|
-
const update_lock_file_1 = require("./utils/update-lock-file");
|
|
10
|
-
const chalk = require("chalk");
|
|
11
|
-
// Cache at the module level to avoid re-detecting the package manager for each instance
|
|
12
|
-
let pm;
|
|
13
|
-
class JsVersionActions extends release_1.VersionActions {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this.manifestFilename = 'package.json';
|
|
17
|
-
}
|
|
18
|
-
static createAfterAllProjectsVersionedCallback(cwd, opts) {
|
|
19
|
-
return async () => {
|
|
20
|
-
return {
|
|
21
|
-
changedFiles: await (0, update_lock_file_1.updateLockFile)(cwd, {
|
|
22
|
-
...opts,
|
|
23
|
-
useLegacyVersioning: false,
|
|
24
|
-
}),
|
|
25
|
-
deletedFiles: [],
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
async readSourceManifestData(tree) {
|
|
30
|
-
const sourcePackageJsonPath = this.getSourceManifestPath();
|
|
31
|
-
try {
|
|
32
|
-
const packageJson = (0, devkit_1.readJson)(tree, sourcePackageJsonPath);
|
|
33
|
-
const dependencies = this.parseDependencies(packageJson);
|
|
34
|
-
return {
|
|
35
|
-
name: packageJson.name,
|
|
36
|
-
currentVersion: packageJson.version,
|
|
37
|
-
dependencies,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
throw new Error(`Unable to read the package.json file at ${sourcePackageJsonPath}, please ensure that the file exists and is valid`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async readCurrentVersionFromSourceManifest(tree) {
|
|
45
|
-
const sourcePackageJsonPath = this.getSourceManifestPath();
|
|
46
|
-
try {
|
|
47
|
-
const packageJson = (0, devkit_1.readJson)(tree, sourcePackageJsonPath);
|
|
48
|
-
return packageJson.version;
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
throw new Error(`Unable to determine the current version for project "${this.projectGraphNode.name}" from ${sourcePackageJsonPath}, please ensure that the "version" field is set within the package.json file`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async readCurrentVersionFromRegistry(tree, currentVersionResolverMetadata) {
|
|
55
|
-
const sourceManifestPath = this.getSourceManifestPath();
|
|
56
|
-
const sourceManifestRoot = (0, node_path_1.dirname)(sourceManifestPath);
|
|
57
|
-
const packageJson = (0, devkit_1.readJson)(tree, sourceManifestPath);
|
|
58
|
-
const packageName = packageJson.name;
|
|
59
|
-
const metadata = currentVersionResolverMetadata;
|
|
60
|
-
const registryArg = typeof metadata?.registry === 'string' ? metadata.registry : undefined;
|
|
61
|
-
const tagArg = typeof metadata?.tag === 'string' ? metadata.tag : undefined;
|
|
62
|
-
const warnFn = (message) => {
|
|
63
|
-
console.log(chalk.keyword('orange')(message));
|
|
64
|
-
};
|
|
65
|
-
const { registry, tag, registryConfigKey } = await (0, npm_config_1.parseRegistryOptions)(devkit_1.workspaceRoot, {
|
|
66
|
-
packageRoot: sourceManifestRoot,
|
|
67
|
-
packageJson,
|
|
68
|
-
}, {
|
|
69
|
-
registry: registryArg,
|
|
70
|
-
tag: tagArg,
|
|
71
|
-
}, warnFn);
|
|
72
|
-
let currentVersion = null;
|
|
73
|
-
try {
|
|
74
|
-
// Must be non-blocking async to allow spinner to render
|
|
75
|
-
currentVersion = await new Promise((resolve, reject) => {
|
|
76
|
-
(0, node_child_process_1.exec)(`npm view ${packageName} version --"${registryConfigKey}=${registry}" --tag=${tag}`, {
|
|
77
|
-
windowsHide: false,
|
|
78
|
-
}, (error, stdout, stderr) => {
|
|
79
|
-
if (error) {
|
|
80
|
-
return reject(error);
|
|
81
|
-
}
|
|
82
|
-
if (stderr) {
|
|
83
|
-
return reject(stderr);
|
|
84
|
-
}
|
|
85
|
-
return resolve(stdout.trim());
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
catch { }
|
|
90
|
-
return {
|
|
91
|
-
currentVersion,
|
|
92
|
-
// Make troubleshooting easier by including the registry and tag data in the log text
|
|
93
|
-
logText: `"${registryConfigKey}=${registry}" tag=${tag}`,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
async readCurrentVersionOfDependency(tree, projectGraph, dependencyProjectName) {
|
|
97
|
-
const json = (0, devkit_1.readJson)(tree, this.getSourceManifestPath());
|
|
98
|
-
// Resolve the package name from the project graph metadata, as it may not match the project name
|
|
99
|
-
const dependencyPackageName = projectGraph.nodes[dependencyProjectName].data.metadata?.js?.packageName;
|
|
100
|
-
const dependencyTypes = [
|
|
101
|
-
'dependencies',
|
|
102
|
-
'devDependencies',
|
|
103
|
-
'peerDependencies',
|
|
104
|
-
'optionalDependencies',
|
|
105
|
-
];
|
|
106
|
-
let currentVersion = null;
|
|
107
|
-
let dependencyCollection = null;
|
|
108
|
-
for (const depType of dependencyTypes) {
|
|
109
|
-
if (json[depType] && json[depType][dependencyPackageName]) {
|
|
110
|
-
currentVersion = json[depType][dependencyPackageName];
|
|
111
|
-
dependencyCollection = depType;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
currentVersion,
|
|
117
|
-
dependencyCollection,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
// NOTE: The TODOs were carried over from the original implementation, they are not yet implemented
|
|
121
|
-
isLocalDependencyProtocol(versionSpecifier) {
|
|
122
|
-
const localPackageProtocols = [
|
|
123
|
-
'file:', // all package managers
|
|
124
|
-
'workspace:', // not npm
|
|
125
|
-
// TODO: Support portal protocol at the project graph level before enabling here
|
|
126
|
-
// 'portal:', // modern yarn only
|
|
127
|
-
];
|
|
128
|
-
// Not using a supported local protocol
|
|
129
|
-
if (!localPackageProtocols.some((protocol) => versionSpecifier.startsWith(protocol))) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
// Supported by all package managers
|
|
133
|
-
if (versionSpecifier.startsWith('file:')) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
// Determine specific package manager in use
|
|
137
|
-
if (!pm) {
|
|
138
|
-
pm = (0, devkit_1.detectPackageManager)();
|
|
139
|
-
// pmVersion = getPackageManagerVersion(pm);
|
|
140
|
-
}
|
|
141
|
-
if (pm === 'npm' && versionSpecifier.startsWith('workspace:')) {
|
|
142
|
-
throw new Error(`The "workspace:" protocol is not yet supported by npm (https://github.com/npm/rfcs/issues/765). Please ensure you have a valid setup according to your package manager before attempting to release packages.`);
|
|
143
|
-
}
|
|
144
|
-
// TODO: Support portal protocol at the project graph level before enabling here
|
|
145
|
-
// if (
|
|
146
|
-
// version.startsWith('portal:') &&
|
|
147
|
-
// (pm !== 'yarn' || lt(pmVersion, '2.0.0'))
|
|
148
|
-
// ) {
|
|
149
|
-
// throw new Error(
|
|
150
|
-
// `The "portal:" protocol is only supported by yarn@2.0.0 and above. Please ensure you have a valid setup according to your package manager before attempting to release packages.`
|
|
151
|
-
// );
|
|
152
|
-
// }
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
async updateProjectVersion(tree, newVersion) {
|
|
156
|
-
const logMessages = [];
|
|
157
|
-
for (const manifestPath of this.manifestsToUpdate) {
|
|
158
|
-
(0, devkit_1.updateJson)(tree, manifestPath, (json) => {
|
|
159
|
-
json.version = newVersion;
|
|
160
|
-
return json;
|
|
161
|
-
});
|
|
162
|
-
logMessages.push(`✍️ New version ${newVersion} written to manifest: ${manifestPath}`);
|
|
163
|
-
}
|
|
164
|
-
return logMessages;
|
|
165
|
-
}
|
|
166
|
-
async updateProjectDependencies(tree, projectGraph, dependenciesToUpdate) {
|
|
167
|
-
const numDependenciesToUpdate = Object.keys(dependenciesToUpdate).length;
|
|
168
|
-
const depText = numDependenciesToUpdate === 1 ? 'dependency' : 'dependencies';
|
|
169
|
-
if (numDependenciesToUpdate === 0) {
|
|
170
|
-
return [];
|
|
171
|
-
}
|
|
172
|
-
const logMessages = [];
|
|
173
|
-
for (const manifestPath of this.manifestsToUpdate) {
|
|
174
|
-
(0, devkit_1.updateJson)(tree, manifestPath, (json) => {
|
|
175
|
-
const dependencyTypes = [
|
|
176
|
-
'dependencies',
|
|
177
|
-
'devDependencies',
|
|
178
|
-
'peerDependencies',
|
|
179
|
-
'optionalDependencies',
|
|
180
|
-
];
|
|
181
|
-
for (const depType of dependencyTypes) {
|
|
182
|
-
if (json[depType]) {
|
|
183
|
-
for (const [dep, version] of Object.entries(dependenciesToUpdate)) {
|
|
184
|
-
// Resolve the package name from the project graph metadata, as it may not match the project name
|
|
185
|
-
const packageName = projectGraph.nodes[dep].data.metadata?.js?.packageName;
|
|
186
|
-
if (!packageName) {
|
|
187
|
-
throw new Error(`Unable to determine the package name for project "${dep}" from the project graph metadata, please ensure that the "@nx/js" plugin is installed and the project graph has been built. If the issue persists, please report this issue on https://github.com/nrwl/nx/issues`);
|
|
188
|
-
}
|
|
189
|
-
if (json[depType][packageName]) {
|
|
190
|
-
json[depType][packageName] = version;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return json;
|
|
196
|
-
});
|
|
197
|
-
logMessages.push(`✍️ Updated ${numDependenciesToUpdate} ${depText} in manifest: ${manifestPath}`);
|
|
198
|
-
}
|
|
199
|
-
return logMessages;
|
|
200
|
-
}
|
|
201
|
-
parseDependencies(packageJson) {
|
|
202
|
-
const result = {};
|
|
203
|
-
const dependencyCollections = [
|
|
204
|
-
'dependencies',
|
|
205
|
-
'devDependencies',
|
|
206
|
-
'peerDependencies',
|
|
207
|
-
'optionalDependencies',
|
|
208
|
-
];
|
|
209
|
-
for (const depCollection of dependencyCollections) {
|
|
210
|
-
if (packageJson[depCollection]) {
|
|
211
|
-
result[depCollection] = {};
|
|
212
|
-
for (const [dep, spec] of Object.entries(packageJson[depCollection])) {
|
|
213
|
-
const resolvedSpec = (0, resolve_version_spec_1.resolveVersionSpec)(dep, packageJson.version, spec, this.projectGraphNode.data.root);
|
|
214
|
-
result[depCollection][dep] = {
|
|
215
|
-
resolvedVersion: resolvedSpec,
|
|
216
|
-
rawVersionSpec: spec,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return result;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
exports.default = JsVersionActions;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function tsNodeRegister(file: string, tsConfig?: string): void;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tsNodeRegister = tsNodeRegister;
|
|
4
|
-
function tsNodeRegister(file, tsConfig) {
|
|
5
|
-
if (!file?.endsWith('.ts'))
|
|
6
|
-
return;
|
|
7
|
-
// Register TS compiler lazily
|
|
8
|
-
require('ts-node').register({
|
|
9
|
-
project: tsConfig,
|
|
10
|
-
compilerOptions: {
|
|
11
|
-
module: 'CommonJS',
|
|
12
|
-
types: ['node'],
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
if (!tsConfig)
|
|
16
|
-
return;
|
|
17
|
-
// Register paths in tsConfig
|
|
18
|
-
const tsconfigPaths = require('tsconfig-paths');
|
|
19
|
-
const { absoluteBaseUrl: baseUrl, paths } = tsconfigPaths.loadConfig(tsConfig);
|
|
20
|
-
if (baseUrl && paths) {
|
|
21
|
-
tsconfigPaths.register({ baseUrl, paths });
|
|
22
|
-
}
|
|
23
|
-
}
|