@nx/js 0.0.0-pr-3-4fa8cf8 → 0.0.0-pr-30418-4f79396
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 -3
- package/src/generators/library/library.js +4 -3
- package/src/generators/library/utils/add-release-config.d.ts +1 -1
- package/src/generators/library/utils/add-release-config.js +21 -7
- package/src/generators/release-version/release-version.js +4 -1
- package/src/generators/release-version/schema.d.ts +1 -1
- package/src/generators/release-version/schema.json +23 -4
- package/src/generators/release-version/utils/update-lock-file.d.ts +7 -2
- package/src/generators/release-version/utils/update-lock-file.js +12 -9
- package/src/generators/release-version/version-actions.d.ts +28 -0
- package/src/generators/release-version/version-actions.js +213 -0
- package/src/plugins/typescript/util.js +0 -1
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-30418-4f79396",
|
|
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-30418-4f79396",
|
|
43
|
+
"@nx/workspace": "0.0.0-pr-30418-4f79396",
|
|
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",
|
|
@@ -8,8 +8,10 @@ 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");
|
|
11
12
|
const path_1 = require("path");
|
|
12
13
|
const generator_prompts_1 = require("../../utils/generator-prompts");
|
|
14
|
+
const sort_fields_1 = require("../../utils/package-json/sort-fields");
|
|
13
15
|
const update_package_json_1 = require("../../utils/package-json/update-package-json");
|
|
14
16
|
const add_swc_config_1 = require("../../utils/swc/add-swc-config");
|
|
15
17
|
const add_swc_dependencies_1 = require("../../utils/swc/add-swc-dependencies");
|
|
@@ -21,7 +23,6 @@ const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
|
21
23
|
const ts_solution_setup_1 = require("../../utils/typescript/ts-solution-setup");
|
|
22
24
|
const versions_1 = require("../../utils/versions");
|
|
23
25
|
const init_1 = require("../init/init");
|
|
24
|
-
const sort_fields_1 = require("../../utils/package-json/sort-fields");
|
|
25
26
|
const add_release_config_1 = require("./utils/add-release-config");
|
|
26
27
|
const defaultOutputDirectory = 'dist';
|
|
27
28
|
async function libraryGenerator(tree, schema) {
|
|
@@ -158,8 +159,8 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
158
159
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
159
160
|
}
|
|
160
161
|
async function configureProject(tree, options) {
|
|
162
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
161
163
|
if (options.hasPlugin) {
|
|
162
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
163
164
|
(0, plugin_1.ensureProjectIsIncludedInPluginRegistrations)(nxJson, options.projectRoot, options.bundler === 'none' ? null : 'build');
|
|
164
165
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
165
166
|
}
|
|
@@ -217,7 +218,7 @@ async function configureProject(tree, options) {
|
|
|
217
218
|
await (0, add_release_config_1.addReleaseConfigForTsSolution)(tree, options.name, projectConfiguration);
|
|
218
219
|
}
|
|
219
220
|
else {
|
|
220
|
-
await (0, add_release_config_1.addReleaseConfigForNonTsSolution)(tree, options.name, projectConfiguration, defaultOutputDirectory);
|
|
221
|
+
await (0, add_release_config_1.addReleaseConfigForNonTsSolution)((0, use_legacy_versioning_1.shouldUseLegacyVersioning)(nxJson.release), tree, options.name, projectConfiguration, defaultOutputDirectory);
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
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(tree: Tree, projectName: string, projectConfiguration: ProjectConfiguration, defaultOutputDirectory?: string): Promise<ProjectConfiguration>;
|
|
10
|
+
export declare function addReleaseConfigForNonTsSolution(useLegacyVersioning: boolean, 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(tree, projectName, projectConfiguration, defaultOutputDirectory = 'dist') {
|
|
94
|
+
async function addReleaseConfigForNonTsSolution(useLegacyVersioning, 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,17 +99,31 @@ async function addReleaseConfigForNonTsSolution(tree, projectName, projectConfig
|
|
|
99
99
|
packageRoot,
|
|
100
100
|
},
|
|
101
101
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
if (useLegacyVersioning) {
|
|
103
|
+
projectConfiguration.release = {
|
|
104
|
+
version: {
|
|
105
|
+
generatorOptions: {
|
|
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],
|
|
106
120
|
// using git tags to determine the current version is required here because
|
|
107
121
|
// the version in the package root is overridden with every build
|
|
108
122
|
currentVersionResolver: 'git-tag',
|
|
109
123
|
fallbackCurrentVersionResolver: 'disk',
|
|
110
124
|
},
|
|
111
|
-
}
|
|
112
|
-
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
113
127
|
await addReleaseConfigForTsSolution(tree, projectName, projectConfiguration);
|
|
114
128
|
return projectConfiguration;
|
|
115
129
|
}
|
|
@@ -666,7 +666,10 @@ To fix this you will either need to add a package.json file at that location, or
|
|
|
666
666
|
deletedFiles.push(...(await cb(opts.dryRun)));
|
|
667
667
|
}
|
|
668
668
|
const cwd = tree.root;
|
|
669
|
-
changedFiles.push(...(await (0, update_lock_file_1.updateLockFile)(cwd,
|
|
669
|
+
changedFiles.push(...(await (0, update_lock_file_1.updateLockFile)(cwd, {
|
|
670
|
+
...opts,
|
|
671
|
+
useLegacyVersioning: true,
|
|
672
|
+
})));
|
|
670
673
|
return { changedFiles, deletedFiles };
|
|
671
674
|
},
|
|
672
675
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ReleaseVersionGeneratorSchema } from 'nx/src/command-line/release/version';
|
|
1
|
+
export { ReleaseVersionGeneratorSchema } from 'nx/src/command-line/release/version-legacy';
|
|
@@ -8,6 +8,8 @@
|
|
|
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.",
|
|
11
13
|
"description": "The ProjectGraphProjectNodes being versioned in the current execution.",
|
|
12
14
|
"items": {
|
|
13
15
|
"type": "object"
|
|
@@ -15,16 +17,33 @@
|
|
|
15
17
|
},
|
|
16
18
|
"projectGraph": {
|
|
17
19
|
"type": "object",
|
|
20
|
+
"hidden": true,
|
|
21
|
+
"$comment": "This is not configured/passed by the user. It is provided by the version command.",
|
|
18
22
|
"description": "ProjectGraph instance"
|
|
19
23
|
},
|
|
20
|
-
"specifier": {
|
|
21
|
-
"type": "string",
|
|
22
|
-
"description": "Exact version or semver keyword to apply to the selected release group. Overrides specifierSource."
|
|
23
|
-
},
|
|
24
24
|
"releaseGroup": {
|
|
25
25
|
"type": "object",
|
|
26
|
+
"hidden": true,
|
|
27
|
+
"$comment": "This is not configured/passed by the user. It is provided by the version command.",
|
|
26
28
|
"description": "The resolved release group configuration, including name, relevant to all projects in the current execution."
|
|
27
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
|
+
"specifier": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "Exact version or semver keyword to apply to the selected release group. Overrides specifierSource."
|
|
46
|
+
},
|
|
28
47
|
"specifierSource": {
|
|
29
48
|
"type": "string",
|
|
30
49
|
"default": "prompt",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
export declare function updateLockFile(cwd: string, { dryRun, verbose,
|
|
1
|
+
export declare function updateLockFile(cwd: string, { dryRun, verbose, useLegacyVersioning, options, }: {
|
|
2
2
|
dryRun?: boolean;
|
|
3
3
|
verbose?: boolean;
|
|
4
|
-
|
|
4
|
+
useLegacyVersioning?: boolean;
|
|
5
|
+
options?: {
|
|
6
|
+
skipLockFileUpdate?: boolean;
|
|
7
|
+
installArgs?: string;
|
|
8
|
+
installIgnoreScripts?: boolean;
|
|
9
|
+
};
|
|
5
10
|
}): 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, useLegacyVersioning, options, }) {
|
|
11
|
+
if (options?.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, generatorOptions, }) {
|
|
|
36
36
|
await client_1.daemonClient.stop();
|
|
37
37
|
}
|
|
38
38
|
const packageManagerCommands = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
39
|
-
let installArgs =
|
|
39
|
+
let installArgs = options?.installArgs || '';
|
|
40
40
|
devkit_1.output.logSingleLine(`Updating ${packageManager} lock file`);
|
|
41
41
|
let env = {};
|
|
42
|
-
if (
|
|
42
|
+
if (options?.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, generatorOptions, }) {
|
|
|
62
62
|
if (dryRun) {
|
|
63
63
|
return [];
|
|
64
64
|
}
|
|
65
|
-
execLockFileUpdate(command, cwd, env);
|
|
65
|
+
execLockFileUpdate(command, cwd, env, useLegacyVersioning);
|
|
66
66
|
if (isDaemonEnabled) {
|
|
67
67
|
try {
|
|
68
68
|
await client_1.daemonClient.startInBackground();
|
|
@@ -79,7 +79,7 @@ async function updateLockFile(cwd, { dryRun, verbose, generatorOptions, }) {
|
|
|
79
79
|
}
|
|
80
80
|
return [lockFile];
|
|
81
81
|
}
|
|
82
|
-
function execLockFileUpdate(command, cwd, env
|
|
82
|
+
function execLockFileUpdate(command, cwd, env, useLegacyVersioning) {
|
|
83
83
|
try {
|
|
84
84
|
const LARGE_BUFFER = 1024 * 1000000;
|
|
85
85
|
(0, child_process_1.execSync)(command, {
|
|
@@ -93,13 +93,16 @@ function execLockFileUpdate(command, cwd, env = {}) {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
catch (e) {
|
|
96
|
+
const configPathStart = useLegacyVersioning
|
|
97
|
+
? 'release.version.generatorOptions'
|
|
98
|
+
: 'release.version.versionActionsOptions';
|
|
96
99
|
devkit_1.output.error({
|
|
97
100
|
title: `Error updating lock file with command '${command}'`,
|
|
98
101
|
bodyLines: [
|
|
99
102
|
`Verify that '${command}' succeeds when run from the workspace root.`,
|
|
100
|
-
`To configure a string of arguments to be passed to this command, set the '
|
|
101
|
-
`To ignore install lifecycle scripts, set '
|
|
102
|
-
`To disable this step entirely, set '
|
|
103
|
+
`To configure a string of arguments to be passed to this command, set the '${configPathStart}.installArgs' property in nx.json.`,
|
|
104
|
+
`To ignore install lifecycle scripts, set '${configPathStart}.installIgnoreScripts' to true in nx.json.`,
|
|
105
|
+
`To disable this step entirely, set '${configPathStart}.skipLockFileUpdate' to true in nx.json.`,
|
|
103
106
|
],
|
|
104
107
|
});
|
|
105
108
|
throw e;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
getCurrentVersionOfDependency(tree: Tree, projectGraph: ProjectGraph, dependencyProjectName: string): Promise<{
|
|
21
|
+
currentVersion: string | null;
|
|
22
|
+
dependencyCollection: string | null;
|
|
23
|
+
}>;
|
|
24
|
+
isLocalDependencyProtocol(versionSpecifier: string): boolean;
|
|
25
|
+
writeVersionToManifests(tree: Tree, newVersion: string): Promise<void>;
|
|
26
|
+
updateDependencies(tree: Tree, projectGraph: ProjectGraph, dependenciesToUpdate: Record<string, string>): Promise<void>;
|
|
27
|
+
private parseDependencies;
|
|
28
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
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 getCurrentVersionOfDependency(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 writeVersionToManifests(tree, newVersion) {
|
|
156
|
+
for (const manifestPath of this.manifestsToUpdate) {
|
|
157
|
+
(0, devkit_1.updateJson)(tree, manifestPath, (json) => {
|
|
158
|
+
json.version = newVersion;
|
|
159
|
+
return json;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async updateDependencies(tree, projectGraph, dependenciesToUpdate) {
|
|
164
|
+
for (const manifestPath of this.manifestsToUpdate) {
|
|
165
|
+
(0, devkit_1.updateJson)(tree, manifestPath, (json) => {
|
|
166
|
+
const dependencyTypes = [
|
|
167
|
+
'dependencies',
|
|
168
|
+
'devDependencies',
|
|
169
|
+
'peerDependencies',
|
|
170
|
+
'optionalDependencies',
|
|
171
|
+
];
|
|
172
|
+
for (const depType of dependencyTypes) {
|
|
173
|
+
if (json[depType]) {
|
|
174
|
+
for (const [dep, version] of Object.entries(dependenciesToUpdate)) {
|
|
175
|
+
// Resolve the package name from the project graph metadata, as it may not match the project name
|
|
176
|
+
const packageName = projectGraph.nodes[dep].data.metadata?.js?.packageName;
|
|
177
|
+
if (!packageName) {
|
|
178
|
+
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`);
|
|
179
|
+
}
|
|
180
|
+
if (json[depType][packageName]) {
|
|
181
|
+
json[depType][packageName] = version;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return json;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
parseDependencies(packageJson) {
|
|
191
|
+
const result = {};
|
|
192
|
+
const dependencyCollections = [
|
|
193
|
+
'dependencies',
|
|
194
|
+
'devDependencies',
|
|
195
|
+
'peerDependencies',
|
|
196
|
+
'optionalDependencies',
|
|
197
|
+
];
|
|
198
|
+
for (const depCollection of dependencyCollections) {
|
|
199
|
+
if (packageJson[depCollection]) {
|
|
200
|
+
result[depCollection] = {};
|
|
201
|
+
for (const [dep, spec] of Object.entries(packageJson[depCollection])) {
|
|
202
|
+
const resolvedSpec = (0, resolve_version_spec_1.resolveVersionSpec)(dep, packageJson.version, spec, this.projectGraphNode.data.root);
|
|
203
|
+
result[depCollection][dep] = {
|
|
204
|
+
resolvedVersion: resolvedSpec,
|
|
205
|
+
rawVersionSpec: spec,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.default = JsVersionActions;
|
|
@@ -29,7 +29,6 @@ function addBuildAndWatchDepsTargets(workspaceRoot, projectRoot, targets, option
|
|
|
29
29
|
dependsOn: ['^build'],
|
|
30
30
|
};
|
|
31
31
|
targets[options.watchDepsTargetName ?? 'watch-deps'] = {
|
|
32
|
-
continuous: true,
|
|
33
32
|
dependsOn: [buildDepsTargetName],
|
|
34
33
|
command: `${pmc.exec} nx watch --projects ${projectName} --includeDependentProjects -- ${pmc.exec} nx ${buildDepsTargetName} ${projectName}`,
|
|
35
34
|
};
|