nx 19.3.0-canary.20240608-55197fb → 19.3.0-canary.20240611-1600875
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +12 -12
- package/src/command-line/release/utils/git.d.ts +2 -2
- package/src/command-line/release/utils/git.js +19 -11
- package/src/command-line/release/version.js +1 -1
- package/src/generators/utils/project-configuration.js +1 -1
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
- package/src/plugins/package-json-workspaces/create-nodes.js +24 -10
- package/src/project-graph/file-utils.js +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "19.3.0-canary.
|
3
|
+
"version": "19.3.0-canary.20240611-1600875",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -70,7 +70,7 @@
|
|
70
70
|
"yargs-parser": "21.1.1",
|
71
71
|
"node-machine-id": "1.1.12",
|
72
72
|
"ora": "5.3.0",
|
73
|
-
"@nrwl/tao": "19.3.0-canary.
|
73
|
+
"@nrwl/tao": "19.3.0-canary.20240611-1600875"
|
74
74
|
},
|
75
75
|
"peerDependencies": {
|
76
76
|
"@swc-node/register": "^1.8.0",
|
@@ -85,16 +85,16 @@
|
|
85
85
|
}
|
86
86
|
},
|
87
87
|
"optionalDependencies": {
|
88
|
-
"@nx/nx-darwin-x64": "19.3.0-canary.
|
89
|
-
"@nx/nx-darwin-arm64": "19.3.0-canary.
|
90
|
-
"@nx/nx-linux-x64-gnu": "19.3.0-canary.
|
91
|
-
"@nx/nx-linux-x64-musl": "19.3.0-canary.
|
92
|
-
"@nx/nx-win32-x64-msvc": "19.3.0-canary.
|
93
|
-
"@nx/nx-linux-arm64-gnu": "19.3.0-canary.
|
94
|
-
"@nx/nx-linux-arm64-musl": "19.3.0-canary.
|
95
|
-
"@nx/nx-linux-arm-gnueabihf": "19.3.0-canary.
|
96
|
-
"@nx/nx-win32-arm64-msvc": "19.3.0-canary.
|
97
|
-
"@nx/nx-freebsd-x64": "19.3.0-canary.
|
88
|
+
"@nx/nx-darwin-x64": "19.3.0-canary.20240611-1600875",
|
89
|
+
"@nx/nx-darwin-arm64": "19.3.0-canary.20240611-1600875",
|
90
|
+
"@nx/nx-linux-x64-gnu": "19.3.0-canary.20240611-1600875",
|
91
|
+
"@nx/nx-linux-x64-musl": "19.3.0-canary.20240611-1600875",
|
92
|
+
"@nx/nx-win32-x64-msvc": "19.3.0-canary.20240611-1600875",
|
93
|
+
"@nx/nx-linux-arm64-gnu": "19.3.0-canary.20240611-1600875",
|
94
|
+
"@nx/nx-linux-arm64-musl": "19.3.0-canary.20240611-1600875",
|
95
|
+
"@nx/nx-linux-arm-gnueabihf": "19.3.0-canary.20240611-1600875",
|
96
|
+
"@nx/nx-win32-arm64-msvc": "19.3.0-canary.20240611-1600875",
|
97
|
+
"@nx/nx-freebsd-x64": "19.3.0-canary.20240611-1600875"
|
98
98
|
},
|
99
99
|
"nx-migrations": {
|
100
100
|
"migrations": "./migrations.json",
|
@@ -27,12 +27,12 @@ export declare function getLatestGitTagForPattern(releaseTagPattern: string, add
|
|
27
27
|
extractedVersion: string;
|
28
28
|
} | null>;
|
29
29
|
export declare function getGitDiff(from: string | undefined, to?: string): Promise<RawGitCommit[]>;
|
30
|
-
export declare function
|
31
|
-
export declare function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, }: {
|
30
|
+
export declare function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, cwd, }: {
|
32
31
|
changedFiles?: string[];
|
33
32
|
deletedFiles?: string[];
|
34
33
|
dryRun?: boolean;
|
35
34
|
verbose?: boolean;
|
35
|
+
cwd?: string;
|
36
36
|
logFn?: (...messages: string[]) => void;
|
37
37
|
}): Promise<string>;
|
38
38
|
export declare function gitCommit({ messages, additionalArgs, dryRun, verbose, logFn, }: {
|
@@ -1,11 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getFirstGitCommit = exports.getCommitHash = exports.parseGitCommit = exports.parseConventionalCommitsMessage = exports.parseCommits = exports.gitPush = exports.gitTag = exports.gitCommit = exports.gitAdd = exports.
|
3
|
+
exports.getFirstGitCommit = exports.getCommitHash = exports.parseGitCommit = exports.parseConventionalCommitsMessage = exports.parseCommits = exports.gitPush = exports.gitTag = exports.gitCommit = exports.gitAdd = exports.getGitDiff = exports.getLatestGitTagForPattern = void 0;
|
4
4
|
/**
|
5
5
|
* Special thanks to changelogen for the original inspiration for many of these utilities:
|
6
6
|
* https://github.com/unjs/changelogen
|
7
7
|
*/
|
8
8
|
const utils_1 = require("../../../tasks-runner/utils");
|
9
|
+
const app_root_1 = require("../../../utils/app-root");
|
9
10
|
const exec_command_1 = require("./exec-command");
|
10
11
|
function escapeRegExp(string) {
|
11
12
|
return string.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
|
@@ -97,18 +98,21 @@ async function getGitDiff(from, to = 'HEAD') {
|
|
97
98
|
});
|
98
99
|
}
|
99
100
|
exports.getGitDiff = getGitDiff;
|
100
|
-
async function getChangedTrackedFiles() {
|
101
|
-
const result = await (0, exec_command_1.execCommand)('git', ['status', '--porcelain']
|
101
|
+
async function getChangedTrackedFiles(cwd) {
|
102
|
+
const result = await (0, exec_command_1.execCommand)('git', ['status', '--porcelain'], {
|
103
|
+
cwd,
|
104
|
+
});
|
102
105
|
const lines = result.split('\n').filter((l) => l.trim().length > 0);
|
103
106
|
return new Set(lines.map((l) => l.substring(3)));
|
104
107
|
}
|
105
|
-
|
106
|
-
async function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, }) {
|
108
|
+
async function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, cwd, }) {
|
107
109
|
logFn = logFn || console.log;
|
110
|
+
// Default to running git add related commands from the workspace root
|
111
|
+
cwd = cwd || app_root_1.workspaceRoot;
|
108
112
|
let ignoredFiles = [];
|
109
113
|
let filesToAdd = [];
|
110
114
|
for (const f of changedFiles ?? []) {
|
111
|
-
const isFileIgnored = await isIgnored(f);
|
115
|
+
const isFileIgnored = await isIgnored(f, cwd);
|
112
116
|
if (isFileIgnored) {
|
113
117
|
ignoredFiles.push(f);
|
114
118
|
}
|
@@ -117,9 +121,9 @@ async function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, }) {
|
|
117
121
|
}
|
118
122
|
}
|
119
123
|
if (deletedFiles?.length > 0) {
|
120
|
-
const changedTrackedFiles = await getChangedTrackedFiles();
|
124
|
+
const changedTrackedFiles = await getChangedTrackedFiles(cwd);
|
121
125
|
for (const f of deletedFiles ?? []) {
|
122
|
-
const isFileIgnored = await isIgnored(f);
|
126
|
+
const isFileIgnored = await isIgnored(f, cwd);
|
123
127
|
if (isFileIgnored) {
|
124
128
|
ignoredFiles.push(f);
|
125
129
|
// git add will fail if trying to add an untracked file that doesn't exist
|
@@ -151,13 +155,17 @@ async function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, }) {
|
|
151
155
|
if (dryRun) {
|
152
156
|
return;
|
153
157
|
}
|
154
|
-
return (0, exec_command_1.execCommand)('git', commandArgs
|
158
|
+
return (0, exec_command_1.execCommand)('git', commandArgs, {
|
159
|
+
cwd,
|
160
|
+
});
|
155
161
|
}
|
156
162
|
exports.gitAdd = gitAdd;
|
157
|
-
async function isIgnored(filePath) {
|
163
|
+
async function isIgnored(filePath, cwd) {
|
158
164
|
try {
|
159
165
|
// This command will error if the file is not ignored
|
160
|
-
await (0, exec_command_1.execCommand)('git', ['check-ignore', filePath]
|
166
|
+
await (0, exec_command_1.execCommand)('git', ['check-ignore', filePath], {
|
167
|
+
cwd,
|
168
|
+
});
|
161
169
|
return true;
|
162
170
|
}
|
163
171
|
catch {
|
@@ -378,7 +378,7 @@ function resolveGeneratorData({ collectionName, generatorName, configGeneratorOp
|
|
378
378
|
* the @nx/js generator config in their nx.json so we need to be clear about what the problem is)
|
379
379
|
*/
|
380
380
|
if (collectionName === '@nx/js') {
|
381
|
-
throw new Error('The @nx/js plugin is required in order to version your JavaScript packages.
|
381
|
+
throw new Error('The @nx/js plugin is required in order to version your JavaScript packages. Run "nx add @nx/js" to add it to your workspace.');
|
382
382
|
}
|
383
383
|
throw new Error(`Unable to resolve the package ${collectionName} in order to load the generator called ${generatorName}. Is the package installed?`);
|
384
384
|
}
|
@@ -147,7 +147,7 @@ function readAndCombineAllProjectConfigurations(tree) {
|
|
147
147
|
}
|
148
148
|
else if ((0, path_1.basename)(projectFile) === 'package.json') {
|
149
149
|
const packageJson = (0, json_1.readJson)(tree, projectFile);
|
150
|
-
const config = (0, package_json_workspaces_1.buildProjectConfigurationFromPackageJson)(packageJson, projectFile, (0, nx_json_1.readNxJson)(tree));
|
150
|
+
const config = (0, package_json_workspaces_1.buildProjectConfigurationFromPackageJson)(packageJson, tree.root, projectFile, (0, nx_json_1.readNxJson)(tree));
|
151
151
|
if (!rootMap[config.root]) {
|
152
152
|
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
|
153
153
|
// Inferred targets, tags, etc don't show up when running generators
|
@@ -4,14 +4,14 @@ import { PackageJson } from '../../utils/package-json';
|
|
4
4
|
import { CreateNodes } from '../../project-graph/plugins';
|
5
5
|
export declare const createNodes: CreateNodes;
|
6
6
|
export declare function buildPackageJsonWorkspacesMatcher(workspaceRoot: string, readJson: (string: any) => any): (p: string) => boolean;
|
7
|
-
export declare function createNodeFromPackageJson(pkgJsonPath: string,
|
7
|
+
export declare function createNodeFromPackageJson(pkgJsonPath: string, workspaceRoot: string): {
|
8
8
|
projects: {
|
9
9
|
[x: string]: ProjectConfiguration & {
|
10
10
|
name: string;
|
11
11
|
};
|
12
12
|
};
|
13
13
|
};
|
14
|
-
export declare function buildProjectConfigurationFromPackageJson(packageJson: PackageJson,
|
14
|
+
export declare function buildProjectConfigurationFromPackageJson(packageJson: PackageJson, workspaceRoot: string, packageJsonPath: string, nxJson: NxJsonConfiguration): ProjectConfiguration & {
|
15
15
|
name: string;
|
16
16
|
};
|
17
17
|
/**
|
@@ -50,9 +50,9 @@ function buildPackageJsonWorkspacesMatcher(workspaceRoot, readJson) {
|
|
50
50
|
negativePatterns.every((negative) => (0, minimatch_1.minimatch)(p, negative));
|
51
51
|
}
|
52
52
|
exports.buildPackageJsonWorkspacesMatcher = buildPackageJsonWorkspacesMatcher;
|
53
|
-
function createNodeFromPackageJson(pkgJsonPath,
|
54
|
-
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(
|
55
|
-
const project = buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(
|
53
|
+
function createNodeFromPackageJson(pkgJsonPath, workspaceRoot) {
|
54
|
+
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspaceRoot, pkgJsonPath));
|
55
|
+
const project = buildProjectConfigurationFromPackageJson(json, workspaceRoot, pkgJsonPath, (0, nx_json_1.readNxJson)(workspaceRoot));
|
56
56
|
return {
|
57
57
|
projects: {
|
58
58
|
[project.root]: project,
|
@@ -60,21 +60,27 @@ function createNodeFromPackageJson(pkgJsonPath, root) {
|
|
60
60
|
};
|
61
61
|
}
|
62
62
|
exports.createNodeFromPackageJson = createNodeFromPackageJson;
|
63
|
-
function buildProjectConfigurationFromPackageJson(packageJson,
|
64
|
-
const normalizedPath =
|
65
|
-
const
|
66
|
-
|
63
|
+
function buildProjectConfigurationFromPackageJson(packageJson, workspaceRoot, packageJsonPath, nxJson) {
|
64
|
+
const normalizedPath = packageJsonPath.split('\\').join('/');
|
65
|
+
const projectRoot = (0, node_path_1.dirname)(normalizedPath);
|
66
|
+
const siblingProjectJson = tryReadJson((0, node_path_1.join)(workspaceRoot, projectRoot, 'project.json'));
|
67
|
+
if (siblingProjectJson) {
|
68
|
+
for (const target of Object.keys(siblingProjectJson?.targets ?? {})) {
|
69
|
+
delete packageJson.scripts?.[target];
|
70
|
+
}
|
71
|
+
}
|
72
|
+
if (!packageJson.name && projectRoot === '.') {
|
67
73
|
throw new Error('Nx requires the root package.json to specify a name if it is being used as an Nx project.');
|
68
74
|
}
|
69
75
|
let name = packageJson.name ?? (0, to_project_name_1.toProjectName)(normalizedPath);
|
70
76
|
const projectType = nxJson?.workspaceLayout?.appsDir != nxJson?.workspaceLayout?.libsDir &&
|
71
77
|
nxJson?.workspaceLayout?.appsDir &&
|
72
|
-
|
78
|
+
projectRoot.startsWith(nxJson.workspaceLayout.appsDir)
|
73
79
|
? 'application'
|
74
80
|
: 'library';
|
75
81
|
return {
|
76
|
-
root:
|
77
|
-
sourceRoot:
|
82
|
+
root: projectRoot,
|
83
|
+
sourceRoot: projectRoot,
|
78
84
|
name,
|
79
85
|
projectType,
|
80
86
|
...packageJson.nx,
|
@@ -136,3 +142,11 @@ function normalizePatterns(patterns) {
|
|
136
142
|
function removeRelativePath(pattern) {
|
137
143
|
return pattern.startsWith('./') ? pattern.substring(2) : pattern;
|
138
144
|
}
|
145
|
+
function tryReadJson(path) {
|
146
|
+
try {
|
147
|
+
return (0, fileutils_1.readJsonFile)(path);
|
148
|
+
}
|
149
|
+
catch {
|
150
|
+
return null;
|
151
|
+
}
|
152
|
+
}
|
@@ -162,7 +162,7 @@ function getProjectsSync(root, nxJson) {
|
|
162
162
|
}
|
163
163
|
else if ((0, path_1.basename)(projectFile) === 'package.json') {
|
164
164
|
const packageJson = (0, fileutils_1.readJsonFile)(projectFile);
|
165
|
-
const config = (0, package_json_workspaces_1.buildProjectConfigurationFromPackageJson)(packageJson, projectFile, nxJson);
|
165
|
+
const config = (0, package_json_workspaces_1.buildProjectConfigurationFromPackageJson)(packageJson, root, projectFile, nxJson);
|
166
166
|
if (!rootMap[config.root]) {
|
167
167
|
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
|
168
168
|
// Inferred targets, tags, etc don't show up when running generators
|