nx 19.4.0-canary.20240626-3a2e8d4 → 19.4.0-canary.20240627-c2c6a13
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +14 -14
- package/src/command-line/connect/connect-to-nx-cloud.d.ts +1 -1
- package/src/command-line/connect/connect-to-nx-cloud.js +16 -25
- package/src/command-line/graph/graph.d.ts +1 -0
- package/src/command-line/graph/graph.js +12 -1
- package/src/command-line/run/command-object.js +2 -1
- package/src/config/workspace-json-project-json.d.ts +1 -0
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/daemon/socket-utils.d.ts +1 -0
- package/src/daemon/socket-utils.js +6 -1
- package/src/executors/run-commands/run-commands.impl.js +19 -14
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +68 -33
- package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +5 -0
- package/src/nx-cloud/utilities/url-shorten.d.ts +2 -1
- package/src/nx-cloud/utilities/url-shorten.js +47 -11
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +9 -2
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +5 -0
- package/src/project-graph/plugins/internal-api.js +1 -1
- package/src/project-graph/plugins/isolation/index.d.ts +1 -1
- package/src/project-graph/plugins/isolation/index.js +3 -15
- package/src/project-graph/plugins/isolation/messaging.d.ts +6 -3
- package/src/project-graph/plugins/isolation/messaging.js +9 -3
- package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
- package/src/project-graph/plugins/isolation/plugin-pool.js +125 -51
- package/src/project-graph/plugins/isolation/plugin-worker.js +128 -107
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
- package/src/tasks-runner/task-env.d.ts +13 -0
- package/src/tasks-runner/task-env.js +41 -26
- package/src/utils/git-utils.d.ts +1 -1
- package/src/utils/git-utils.js +13 -2
- package/src/utils/nx-cloud-utils.d.ts +1 -1
- package/src/utils/nx-cloud-utils.js +1 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getEnvVariablesForTask = exports.getTaskSpecificEnv = exports.getEnvVariablesForBatchProcess = void 0;
|
3
|
+
exports.unloadDotEnvFile = exports.loadAndExpandDotEnvFile = exports.getEnvVariablesForTask = exports.getTaskSpecificEnv = exports.getEnvVariablesForBatchProcess = void 0;
|
4
4
|
const dotenv_1 = require("dotenv");
|
5
5
|
const dotenv_expand_1 = require("dotenv-expand");
|
6
6
|
const workspace_root_1 = require("../utils/workspace-root");
|
@@ -75,9 +75,42 @@ function getNxEnvVariablesForTask(task, forceColor, skipNxCache, captureStderr,
|
|
75
75
|
...env,
|
76
76
|
};
|
77
77
|
}
|
78
|
-
|
78
|
+
/**
|
79
|
+
* This function loads a .env file and expands the variables in it.
|
80
|
+
* It is going to override existing environmentVariables.
|
81
|
+
* @param filename
|
82
|
+
* @param environmentVariables
|
83
|
+
*/
|
84
|
+
function loadAndExpandDotEnvFile(filename, environmentVariables, override = false) {
|
85
|
+
const myEnv = (0, dotenv_1.config)({
|
86
|
+
path: filename,
|
87
|
+
processEnv: environmentVariables,
|
88
|
+
override,
|
89
|
+
});
|
90
|
+
return (0, dotenv_expand_1.expand)({
|
91
|
+
...myEnv,
|
92
|
+
processEnv: environmentVariables,
|
93
|
+
});
|
94
|
+
}
|
95
|
+
exports.loadAndExpandDotEnvFile = loadAndExpandDotEnvFile;
|
96
|
+
/**
|
97
|
+
* This function unloads a .env file and removes the variables in it from the environmentVariables.
|
98
|
+
* @param filename
|
99
|
+
* @param environmentVariables
|
100
|
+
*/
|
101
|
+
function unloadDotEnvFile(filename, environmentVariables, override = false) {
|
102
|
+
const parsedDotEnvFile = {};
|
103
|
+
loadAndExpandDotEnvFile(filename, parsedDotEnvFile, override);
|
104
|
+
Object.keys(parsedDotEnvFile).forEach((envVarKey) => {
|
105
|
+
if (environmentVariables[envVarKey] === parsedDotEnvFile[envVarKey]) {
|
106
|
+
delete environmentVariables[envVarKey];
|
107
|
+
}
|
108
|
+
});
|
109
|
+
}
|
110
|
+
exports.unloadDotEnvFile = unloadDotEnvFile;
|
111
|
+
function getEnvFilesForTask(task) {
|
79
112
|
// Collect dot env files that may pertain to a task
|
80
|
-
|
113
|
+
return [
|
81
114
|
// Load DotEnv Files for a configuration in the project root
|
82
115
|
...(task.target.configuration
|
83
116
|
? [
|
@@ -122,35 +155,17 @@ function loadDotEnvFilesForTask(task, environmentVariables) {
|
|
122
155
|
`.env.local`,
|
123
156
|
`.env`,
|
124
157
|
];
|
158
|
+
}
|
159
|
+
function loadDotEnvFilesForTask(task, environmentVariables) {
|
160
|
+
const dotEnvFiles = getEnvFilesForTask(task);
|
125
161
|
for (const file of dotEnvFiles) {
|
126
|
-
|
127
|
-
path: file,
|
128
|
-
processEnv: environmentVariables,
|
129
|
-
// Do not override existing env variables as we load
|
130
|
-
override: false,
|
131
|
-
});
|
132
|
-
environmentVariables = {
|
133
|
-
...(0, dotenv_expand_1.expand)({
|
134
|
-
...myEnv,
|
135
|
-
ignoreProcessEnv: true, // Do not override existing env variables as we load
|
136
|
-
}).parsed,
|
137
|
-
...environmentVariables,
|
138
|
-
};
|
162
|
+
loadAndExpandDotEnvFile(file, environmentVariables);
|
139
163
|
}
|
140
164
|
return environmentVariables;
|
141
165
|
}
|
142
166
|
function unloadDotEnvFiles(environmentVariables) {
|
143
|
-
const unloadDotEnvFile = (filename) => {
|
144
|
-
let parsedDotEnvFile = {};
|
145
|
-
(0, dotenv_1.config)({ path: filename, processEnv: parsedDotEnvFile });
|
146
|
-
Object.keys(parsedDotEnvFile).forEach((envVarKey) => {
|
147
|
-
if (environmentVariables[envVarKey] === parsedDotEnvFile[envVarKey]) {
|
148
|
-
delete environmentVariables[envVarKey];
|
149
|
-
}
|
150
|
-
});
|
151
|
-
};
|
152
167
|
for (const file of ['.env', '.local.env', '.env.local']) {
|
153
|
-
unloadDotEnvFile(file);
|
168
|
+
unloadDotEnvFile(file, environmentVariables);
|
154
169
|
}
|
155
170
|
return environmentVariables;
|
156
171
|
}
|
package/src/utils/git-utils.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
export declare function getGithubSlugOrNull(): string | null;
|
2
2
|
export declare function extractUserAndRepoFromGitHubUrl(gitRemotes: string): string | null;
|
3
|
-
export declare function commitChanges(commitMessage: string): string | null;
|
3
|
+
export declare function commitChanges(commitMessage: string, directory?: string): string | null;
|
4
4
|
export declare function getLatestCommitSha(): string | null;
|
package/src/utils/git-utils.js
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getLatestCommitSha = exports.commitChanges = exports.extractUserAndRepoFromGitHubUrl = exports.getGithubSlugOrNull = void 0;
|
4
4
|
const child_process_1 = require("child_process");
|
5
|
+
const devkit_exports_1 = require("../devkit-exports");
|
5
6
|
function getGithubSlugOrNull() {
|
6
7
|
try {
|
7
8
|
const gitRemote = (0, child_process_1.execSync)('git remote -v').toString();
|
@@ -38,17 +39,27 @@ function parseGitHubUrl(url) {
|
|
38
39
|
}
|
39
40
|
return null;
|
40
41
|
}
|
41
|
-
function commitChanges(commitMessage) {
|
42
|
+
function commitChanges(commitMessage, directory) {
|
42
43
|
try {
|
43
44
|
(0, child_process_1.execSync)('git add -A', { encoding: 'utf8', stdio: 'pipe' });
|
44
45
|
(0, child_process_1.execSync)('git commit --no-verify -F -', {
|
45
46
|
encoding: 'utf8',
|
46
47
|
stdio: 'pipe',
|
47
48
|
input: commitMessage,
|
49
|
+
cwd: directory,
|
48
50
|
});
|
49
51
|
}
|
50
52
|
catch (err) {
|
51
|
-
|
53
|
+
if (directory) {
|
54
|
+
// We don't want to throw during create-nx-workspace
|
55
|
+
// because maybe there was an error when setting up git
|
56
|
+
// initially.
|
57
|
+
devkit_exports_1.logger.verbose(`Git may not be set up correctly for this new workspace.
|
58
|
+
${err}`);
|
59
|
+
}
|
60
|
+
else {
|
61
|
+
throw new Error(`Error committing changes:\n${err.stderr}`);
|
62
|
+
}
|
52
63
|
}
|
53
64
|
return getLatestCommitSha();
|
54
65
|
}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { NxJsonConfiguration } from '../config/nx-json';
|
2
|
-
export declare function isNxCloudUsed(nxJson: NxJsonConfiguration):
|
2
|
+
export declare function isNxCloudUsed(nxJson: NxJsonConfiguration): boolean;
|
3
3
|
export declare function getNxCloudUrl(nxJson: NxJsonConfiguration): string;
|
4
4
|
export declare function getNxCloudToken(nxJson: NxJsonConfiguration): string;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getNxCloudToken = exports.getNxCloudUrl = exports.isNxCloudUsed = void 0;
|
4
4
|
function isNxCloudUsed(nxJson) {
|
5
|
-
return (process.env.NX_CLOUD_ACCESS_TOKEN ||
|
5
|
+
return (!!process.env.NX_CLOUD_ACCESS_TOKEN ||
|
6
6
|
!!nxJson.nxCloudAccessToken ||
|
7
7
|
!!Object.values(nxJson.tasksRunnerOptions ?? {}).find((r) => r.runner == '@nrwl/nx-cloud' || r.runner == 'nx-cloud'));
|
8
8
|
}
|