nx 19.8.0 → 19.8.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.json +2 -1
- package/bin/nx.js +10 -2
- package/package.json +12 -12
- package/schemas/nx-schema.json +26 -21
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +1 -0
- package/src/command-line/activate-powerpack/activate-powerpack.js +3 -1
- package/src/command-line/add/add.js +4 -2
- package/src/command-line/connect/view-logs.js +1 -0
- package/src/command-line/exec/exec.js +6 -1
- package/src/command-line/format/format.js +3 -1
- package/src/command-line/graph/graph.js +1 -0
- package/src/command-line/init/implementation/angular/integrated-workspace.js +4 -1
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +5 -2
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +3 -1
- package/src/command-line/init/implementation/dot-nx/nxw.js +1 -0
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +3 -1
- package/src/command-line/init/implementation/react/index.js +17 -5
- package/src/command-line/init/implementation/utils.js +5 -1
- package/src/command-line/init/init-v1.js +1 -0
- package/src/command-line/init/init-v2.js +2 -1
- package/src/command-line/migrate/command-object.js +4 -0
- package/src/command-line/migrate/migrate.js +1 -1
- package/src/command-line/release/config/version-plans.js +3 -1
- package/src/command-line/release/utils/exec-command.js +1 -0
- package/src/command-line/release/utils/github.js +1 -0
- package/src/command-line/release/utils/launch-editor.js +6 -1
- package/src/command-line/release/version.js +6 -3
- package/src/command-line/report/report.d.ts +3 -1
- package/src/command-line/report/report.js +17 -2
- package/src/command-line/run/run.js +1 -0
- package/src/command-line/sync/sync.js +5 -4
- package/src/command-line/watch/watch.js +1 -0
- package/src/config/nx-json.d.ts +4 -0
- package/src/daemon/client/client.d.ts +4 -1
- package/src/daemon/client/generate-help-output.js +1 -0
- package/src/daemon/server/sync-generators.d.ts +4 -1
- package/src/daemon/server/sync-generators.js +33 -15
- package/src/executors/run-commands/run-commands.impl.js +1 -0
- package/src/executors/run-script/run-script.impl.js +1 -0
- package/src/native/index.d.ts +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +1 -1
- package/src/project-graph/file-utils.js +1 -0
- package/src/tasks-runner/cache.d.ts +3 -1
- package/src/tasks-runner/cache.js +12 -13
- package/src/tasks-runner/default-tasks-runner.js +1 -1
- package/src/tasks-runner/life-cycles/formatting-utils.d.ts +1 -1
- package/src/tasks-runner/life-cycles/formatting-utils.js +27 -15
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +3 -0
- package/src/tasks-runner/task-orchestrator.d.ts +3 -1
- package/src/tasks-runner/task-orchestrator.js +3 -2
- package/src/tasks-runner/tasks-schedule.js +1 -1
- package/src/utils/ab-testing.js +4 -1
- package/src/utils/child-process.js +5 -3
- package/src/utils/command-line-utils.js +7 -1
- package/src/utils/default-base.js +5 -2
- package/src/utils/git-utils.index-filter.js +2 -1
- package/src/utils/git-utils.js +4 -0
- package/src/utils/git-utils.tree-filter.js +3 -1
- package/src/utils/powerpack.d.ts +1 -1
- package/src/utils/powerpack.js +3 -8
- package/src/utils/sync-generators.d.ts +13 -3
- package/src/utils/sync-generators.js +99 -25
- package/src/utils/task-history.d.ts +2 -2
- package/src/utils/task-history.js +4 -1
@@ -12,8 +12,8 @@ function syncHandler(options) {
|
|
12
12
|
return (0, handle_errors_1.handleErrors)(options.verbose, async () => {
|
13
13
|
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
|
14
14
|
const nxJson = (0, nx_json_1.readNxJson)();
|
15
|
-
const
|
16
|
-
if (!
|
15
|
+
const { globalGenerators, taskGenerators } = await (0, sync_generators_1.collectAllRegisteredSyncGenerators)(projectGraph, nxJson);
|
16
|
+
if (!globalGenerators.length && !taskGenerators.length) {
|
17
17
|
output_1.output.success({
|
18
18
|
title: options.check
|
19
19
|
? 'The workspace is up to date'
|
@@ -22,6 +22,7 @@ function syncHandler(options) {
|
|
22
22
|
});
|
23
23
|
return 0;
|
24
24
|
}
|
25
|
+
const syncGenerators = Array.from(new Set([...globalGenerators, ...taskGenerators]));
|
25
26
|
const results = await (0, sync_generators_1.getSyncGeneratorChanges)(syncGenerators);
|
26
27
|
if (!results.length) {
|
27
28
|
output_1.output.success({
|
@@ -33,7 +34,7 @@ function syncHandler(options) {
|
|
33
34
|
return 0;
|
34
35
|
}
|
35
36
|
const { failedGeneratorsCount, areAllResultsFailures, anySyncGeneratorsFailed, } = (0, sync_generators_1.processSyncGeneratorResultErrors)(results);
|
36
|
-
const failedSyncGeneratorsFixMessageLines = (0, sync_generators_1.getFailedSyncGeneratorsFixMessageLines)(results, options.verbose);
|
37
|
+
const failedSyncGeneratorsFixMessageLines = (0, sync_generators_1.getFailedSyncGeneratorsFixMessageLines)(results, options.verbose, new Set(globalGenerators));
|
37
38
|
if (areAllResultsFailures) {
|
38
39
|
output_1.output.error({
|
39
40
|
title: `The workspace is probably out of sync because ${failedGeneratorsCount === 1
|
@@ -71,7 +72,7 @@ function syncHandler(options) {
|
|
71
72
|
spinner.fail();
|
72
73
|
output_1.output.error({
|
73
74
|
title: 'Failed to sync the workspace',
|
74
|
-
bodyLines: (0, sync_generators_1.getFlushFailureMessageLines)(flushResult, options.verbose),
|
75
|
+
bodyLines: (0, sync_generators_1.getFlushFailureMessageLines)(flushResult, options.verbose, new Set(globalGenerators)),
|
75
76
|
});
|
76
77
|
return 1;
|
77
78
|
}
|
package/src/config/nx-json.d.ts
CHANGED
@@ -462,6 +462,10 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
|
462
462
|
* Configuration for the `nx sync` command.
|
463
463
|
*/
|
464
464
|
sync?: NxSyncConfiguration;
|
465
|
+
/**
|
466
|
+
* Enable the new experimental db based cache
|
467
|
+
*/
|
468
|
+
enableDbCache?: boolean;
|
465
469
|
}
|
466
470
|
export type PluginConfiguration = string | ExpandedPluginConfiguration;
|
467
471
|
export type ExpandedPluginConfiguration<T = unknown> = {
|
@@ -55,7 +55,10 @@ export declare class DaemonClient {
|
|
55
55
|
recordTaskRuns(taskRuns: TaskRun[]): Promise<void>;
|
56
56
|
getSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorRunResult[]>;
|
57
57
|
flushSyncGeneratorChangesToDisk(generators: string[]): Promise<FlushSyncGeneratorChangesResult>;
|
58
|
-
getRegisteredSyncGenerators(): Promise<
|
58
|
+
getRegisteredSyncGenerators(): Promise<{
|
59
|
+
globalGenerators: string[];
|
60
|
+
taskGenerators: string[];
|
61
|
+
}>;
|
59
62
|
updateWorkspaceContext(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
|
60
63
|
isServerAvailable(): Promise<boolean>;
|
61
64
|
private sendToDaemonViaQueue;
|
@@ -11,6 +11,7 @@ function generateDaemonHelpOutput() {
|
|
11
11
|
*/
|
12
12
|
const res = (0, child_process_1.spawnSync)(process.execPath, ['./exec-is-server-available.js'], {
|
13
13
|
cwd: __dirname,
|
14
|
+
windowsHide: true,
|
14
15
|
});
|
15
16
|
const isServerAvailable = res?.stdout?.toString().trim().indexOf('true') > -1;
|
16
17
|
if (!isServerAvailable) {
|
@@ -3,7 +3,10 @@ import { type FlushSyncGeneratorChangesResult, type SyncGeneratorRunResult } fro
|
|
3
3
|
export declare function getCachedSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorRunResult[]>;
|
4
4
|
export declare function flushSyncGeneratorChangesToDisk(generators: string[]): Promise<FlushSyncGeneratorChangesResult>;
|
5
5
|
export declare function collectAndScheduleSyncGenerators(projectGraph: ProjectGraph): void;
|
6
|
-
export declare function getCachedRegisteredSyncGenerators(): Promise<
|
6
|
+
export declare function getCachedRegisteredSyncGenerators(): Promise<{
|
7
|
+
globalGenerators: string[];
|
8
|
+
taskGenerators: string[];
|
9
|
+
}>;
|
7
10
|
/**
|
8
11
|
* @internal
|
9
12
|
*/
|
@@ -72,11 +72,16 @@ function collectAndScheduleSyncGenerators(projectGraph) {
|
|
72
72
|
// a change imply we need to re-run all the generators
|
73
73
|
// make sure to schedule all the collected generators
|
74
74
|
scheduledGenerators.clear();
|
75
|
-
if (!registeredSyncGenerators.size
|
75
|
+
if (!registeredSyncGenerators.globalGenerators.size &&
|
76
|
+
!registeredSyncGenerators.taskGenerators.size) {
|
76
77
|
// there are no generators to run
|
77
78
|
return;
|
78
79
|
}
|
79
|
-
|
80
|
+
const uniqueSyncGenerators = new Set([
|
81
|
+
...registeredSyncGenerators.globalGenerators,
|
82
|
+
...registeredSyncGenerators.taskGenerators,
|
83
|
+
]);
|
84
|
+
for (const generator of uniqueSyncGenerators) {
|
80
85
|
scheduledGenerators.add(generator);
|
81
86
|
}
|
82
87
|
log('scheduling:', [...scheduledGenerators]);
|
@@ -102,7 +107,7 @@ function collectAndScheduleSyncGenerators(projectGraph) {
|
|
102
107
|
}
|
103
108
|
async function getCachedRegisteredSyncGenerators() {
|
104
109
|
log('get registered sync generators');
|
105
|
-
if (!
|
110
|
+
if (!registeredGlobalSyncGenerators && !registeredTaskSyncGenerators) {
|
106
111
|
log('no registered sync generators, collecting them');
|
107
112
|
const { projectGraph } = await (0, project_graph_incremental_recomputation_1.getCachedSerializedProjectGraphPromise)();
|
108
113
|
collectAllRegisteredSyncGenerators(projectGraph);
|
@@ -110,7 +115,10 @@ async function getCachedRegisteredSyncGenerators() {
|
|
110
115
|
else {
|
111
116
|
log('registered sync generators already collected, returning them');
|
112
117
|
}
|
113
|
-
return
|
118
|
+
return {
|
119
|
+
globalGenerators: [...registeredGlobalSyncGenerators],
|
120
|
+
taskGenerators: [...registeredTaskSyncGenerators],
|
121
|
+
};
|
114
122
|
}
|
115
123
|
async function getFromCacheOrRunGenerators(generators) {
|
116
124
|
let projects;
|
@@ -296,23 +304,33 @@ function collectAllRegisteredSyncGenerators(projectGraph) {
|
|
296
304
|
else {
|
297
305
|
log('nx.json hash is the same, not collecting global sync generators');
|
298
306
|
}
|
299
|
-
const generators = new Set([
|
300
|
-
...registeredTaskSyncGenerators,
|
301
|
-
...registeredGlobalSyncGenerators,
|
302
|
-
]);
|
303
307
|
if (!registeredSyncGenerators) {
|
304
|
-
registeredSyncGenerators =
|
308
|
+
registeredSyncGenerators = {
|
309
|
+
globalGenerators: registeredGlobalSyncGenerators,
|
310
|
+
taskGenerators: registeredTaskSyncGenerators,
|
311
|
+
};
|
305
312
|
return;
|
306
313
|
}
|
307
|
-
for (const generator of registeredSyncGenerators) {
|
308
|
-
if (!
|
309
|
-
registeredSyncGenerators.delete(generator);
|
314
|
+
for (const generator of registeredSyncGenerators.globalGenerators) {
|
315
|
+
if (!registeredGlobalSyncGenerators.has(generator)) {
|
316
|
+
registeredSyncGenerators.globalGenerators.delete(generator);
|
310
317
|
syncGeneratorsCacheResultPromises.delete(generator);
|
311
318
|
}
|
312
319
|
}
|
313
|
-
for (const generator of
|
314
|
-
if (!
|
315
|
-
registeredSyncGenerators.
|
320
|
+
for (const generator of registeredSyncGenerators.taskGenerators) {
|
321
|
+
if (!registeredTaskSyncGenerators.has(generator)) {
|
322
|
+
registeredSyncGenerators.taskGenerators.delete(generator);
|
323
|
+
syncGeneratorsCacheResultPromises.delete(generator);
|
324
|
+
}
|
325
|
+
}
|
326
|
+
for (const generator of registeredGlobalSyncGenerators) {
|
327
|
+
if (!registeredSyncGenerators.globalGenerators.has(generator)) {
|
328
|
+
registeredSyncGenerators.globalGenerators.add(generator);
|
329
|
+
}
|
330
|
+
}
|
331
|
+
for (const generator of registeredTaskSyncGenerators) {
|
332
|
+
if (!registeredSyncGenerators.taskGenerators.has(generator)) {
|
333
|
+
registeredSyncGenerators.taskGenerators.add(generator);
|
316
334
|
}
|
317
335
|
}
|
318
336
|
}
|
package/src/native/index.d.ts
CHANGED
@@ -28,7 +28,7 @@ export declare class ImportResult {
|
|
28
28
|
|
29
29
|
export declare class NxCache {
|
30
30
|
cacheDirectory: string
|
31
|
-
constructor(workspaceRoot: string, cachePath: string, dbConnection: ExternalObject<Connection
|
31
|
+
constructor(workspaceRoot: string, cachePath: string, dbConnection: ExternalObject<Connection>, linkTaskDetails?: boolean | undefined | null)
|
32
32
|
get(hash: string): CachedResult | null
|
33
33
|
put(hash: string, terminalOutput: string, outputs: Array<string>, code: number): void
|
34
34
|
applyRemoteCacheResults(hash: string, result: CachedResult): void
|
Binary file
|
@@ -32,7 +32,7 @@ function getRootPackageName(tree) {
|
|
32
32
|
}
|
33
33
|
function getNxInitDate() {
|
34
34
|
try {
|
35
|
-
const nxInitIso = (0, child_process_1.execSync)('git log --diff-filter=A --follow --format=%aI -- nx.json | tail -1', { stdio: 'pipe' })
|
35
|
+
const nxInitIso = (0, child_process_1.execSync)('git log --diff-filter=A --follow --format=%aI -- nx.json | tail -1', { stdio: 'pipe', windowsHide: true })
|
36
36
|
.toString()
|
37
37
|
.trim();
|
38
38
|
const nxInitDate = new Date(nxInitIso);
|
@@ -91,6 +91,7 @@ function defaultReadFileAtRevision(file, revision) {
|
|
91
91
|
: (0, child_process_1.execSync)(`git show ${revision}:${filePathInGitRepository}`, {
|
92
92
|
maxBuffer: exports.TEN_MEGABYTES,
|
93
93
|
stdio: ['pipe', 'pipe', 'ignore'],
|
94
|
+
windowsHide: true,
|
94
95
|
})
|
95
96
|
.toString()
|
96
97
|
.trim();
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { DefaultTasksRunnerOptions, RemoteCache } from './default-tasks-runner';
|
2
2
|
import { Task } from '../config/task-graph';
|
3
|
+
import { NxJsonConfiguration } from '../config/nx-json';
|
3
4
|
export type CachedResult = {
|
4
5
|
terminalOutput: string;
|
5
6
|
outputsPath: string;
|
@@ -10,7 +11,7 @@ export type TaskWithCachedResult = {
|
|
10
11
|
task: Task;
|
11
12
|
cachedResult: CachedResult;
|
12
13
|
};
|
13
|
-
export declare function getCache(options: DefaultTasksRunnerOptions): DbCache | Cache;
|
14
|
+
export declare function getCache(nxJson: NxJsonConfiguration, options: DefaultTasksRunnerOptions): DbCache | Cache;
|
14
15
|
export declare class DbCache {
|
15
16
|
private readonly options;
|
16
17
|
private cache;
|
@@ -30,6 +31,7 @@ export declare class DbCache {
|
|
30
31
|
private _getRemoteCache;
|
31
32
|
private getPowerpackS3Cache;
|
32
33
|
private getPowerpackSharedCache;
|
34
|
+
private getPowerpackCache;
|
33
35
|
private resolvePackage;
|
34
36
|
private assertCacheIsValid;
|
35
37
|
}
|
@@ -18,9 +18,9 @@ const update_manager_1 = require("../nx-cloud/update-manager");
|
|
18
18
|
const get_cloud_options_1 = require("../nx-cloud/utilities/get-cloud-options");
|
19
19
|
const is_ci_1 = require("../utils/is-ci");
|
20
20
|
const output_1 = require("../utils/output");
|
21
|
-
function getCache(options) {
|
21
|
+
function getCache(nxJson, options) {
|
22
22
|
return process.env.NX_DISABLE_DB !== 'true' &&
|
23
|
-
process.env.NX_DB_CACHE === 'true'
|
23
|
+
(nxJson.enableDbCache === true || process.env.NX_DB_CACHE === 'true')
|
24
24
|
? new DbCache({
|
25
25
|
// Remove this in Nx 21
|
26
26
|
nxCloudRemoteCache: (0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())
|
@@ -114,23 +114,21 @@ class DbCache {
|
|
114
114
|
null);
|
115
115
|
}
|
116
116
|
}
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
catch {
|
123
|
-
return null;
|
124
|
-
}
|
117
|
+
getPowerpackS3Cache() {
|
118
|
+
return this.getPowerpackCache('@nx/powerpack-s3-cache');
|
119
|
+
}
|
120
|
+
getPowerpackSharedCache() {
|
121
|
+
return this.getPowerpackCache('@nx/powerpack-shared-fs-cache');
|
125
122
|
}
|
126
|
-
async
|
123
|
+
async getPowerpackCache(pkg) {
|
124
|
+
let getRemoteCache = null;
|
127
125
|
try {
|
128
|
-
|
129
|
-
return getRemoteCache();
|
126
|
+
getRemoteCache = (await Promise.resolve(`${this.resolvePackage(pkg)}`).then(s => require(s))).getRemoteCache;
|
130
127
|
}
|
131
128
|
catch {
|
132
129
|
return null;
|
133
130
|
}
|
131
|
+
return getRemoteCache();
|
134
132
|
}
|
135
133
|
resolvePackage(pkg) {
|
136
134
|
return require.resolve(pkg, {
|
@@ -183,6 +181,7 @@ class Cache {
|
|
183
181
|
stdio: 'ignore',
|
184
182
|
detached: true,
|
185
183
|
shell: false,
|
184
|
+
windowsHide: true,
|
186
185
|
});
|
187
186
|
p.unref();
|
188
187
|
}
|
@@ -56,7 +56,7 @@ const defaultTasksRunner = async (tasks, options, context) => {
|
|
56
56
|
};
|
57
57
|
exports.defaultTasksRunner = defaultTasksRunner;
|
58
58
|
async function runAllTasks(tasks, options, context) {
|
59
|
-
const orchestrator = new task_orchestrator_1.TaskOrchestrator(context.hasher, context.initiatingProject, context.projectGraph, context.taskGraph, options, context.nxArgs?.nxBail, context.daemon, context.nxArgs?.outputStyle);
|
59
|
+
const orchestrator = new task_orchestrator_1.TaskOrchestrator(context.hasher, context.initiatingProject, context.projectGraph, context.taskGraph, context.nxJson, options, context.nxArgs?.nxBail, context.daemon, context.nxArgs?.outputStyle);
|
60
60
|
return orchestrator.run();
|
61
61
|
}
|
62
62
|
exports.default = exports.defaultTasksRunner;
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { Task } from '../../config/task-graph';
|
2
2
|
export declare function formatFlags(leftPadding: string, flag: string, value: any): string;
|
3
|
-
export declare function formatTargetsAndProjects(projectNames: string[], targets: string[], tasks: Task[]):
|
3
|
+
export declare function formatTargetsAndProjects(projectNames: string[], targets: string[], tasks: Task[]): string;
|
@@ -20,24 +20,36 @@ function formatValue(value) {
|
|
20
20
|
}
|
21
21
|
}
|
22
22
|
function formatTargetsAndProjects(projectNames, targets, tasks) {
|
23
|
-
|
24
|
-
|
25
|
-
let
|
26
|
-
const
|
27
|
-
|
28
|
-
|
23
|
+
let targetsText = '';
|
24
|
+
let projectsText = '';
|
25
|
+
let dependentTasksText = '';
|
26
|
+
const tasksTargets = new Set();
|
27
|
+
const tasksProjects = new Set();
|
28
|
+
const dependentTasks = new Set();
|
29
|
+
tasks.forEach((task) => {
|
30
|
+
tasksTargets.add(task.target.target);
|
31
|
+
tasksProjects.add(task.target.project);
|
32
|
+
if (!projectNames.includes(task.target.project) ||
|
33
|
+
!targets.includes(task.target.target)) {
|
34
|
+
dependentTasks.add(task);
|
35
|
+
}
|
36
|
+
});
|
37
|
+
targets = targets.filter((t) => tasksTargets.has(t)); // filter out targets that don't exist
|
38
|
+
projectNames = projectNames.filter((p) => tasksProjects.has(p)); // filter out projects that don't exist
|
29
39
|
if (targets.length === 1) {
|
30
|
-
|
40
|
+
targetsText = `target ${output_1.output.bold(targets[0])}`;
|
31
41
|
}
|
32
42
|
else {
|
33
|
-
|
34
|
-
.map((t) => output_1.output.bold(t))
|
35
|
-
.join(', ')} for ${project}`;
|
43
|
+
targetsText = `targets ${targets.map((t) => output_1.output.bold(t)).join(', ')}`;
|
36
44
|
}
|
37
|
-
|
38
|
-
|
39
|
-
if (dependentTasks > 0) {
|
40
|
-
text += ` and ${output_1.output.bold(dependentTasks)} ${dependentTasks === 1 ? 'task' : 'tasks'} ${projectNames.length === 1 ? 'it depends on' : 'they depend on'}`;
|
45
|
+
if (projectNames.length === 1) {
|
46
|
+
projectsText = `project ${projectNames[0]}`;
|
41
47
|
}
|
42
|
-
|
48
|
+
else {
|
49
|
+
projectsText = `${projectNames.length} projects`;
|
50
|
+
}
|
51
|
+
if (dependentTasks.size > 0) {
|
52
|
+
dependentTasksText = ` and ${output_1.output.bold(dependentTasks.size)} ${dependentTasks.size === 1 ? 'task' : 'tasks'} ${projectNames.length === 1 ? 'it depends on' : 'they depend on'}`;
|
53
|
+
}
|
54
|
+
return `${targetsText} for ${projectsText}${dependentTasksText}`;
|
43
55
|
}
|
@@ -31,6 +31,9 @@ class TaskHistoryLifeCycle {
|
|
31
31
|
}
|
32
32
|
async endCommand() {
|
33
33
|
const entries = Array.from(this.taskRuns);
|
34
|
+
if (!this.taskHistory) {
|
35
|
+
return;
|
36
|
+
}
|
34
37
|
await this.taskHistory.recordTaskRuns(entries.map(([_, v]) => v));
|
35
38
|
const flakyTasks = await this.taskHistory.getFlakyTasks(entries.map(([hash]) => hash));
|
36
39
|
if (flakyTasks.length > 0) {
|
@@ -4,11 +4,13 @@ import { TaskStatus } from './tasks-runner';
|
|
4
4
|
import { ProjectGraph } from '../config/project-graph';
|
5
5
|
import { TaskGraph } from '../config/task-graph';
|
6
6
|
import { DaemonClient } from '../daemon/client/client';
|
7
|
+
import { NxJsonConfiguration } from '../config/nx-json';
|
7
8
|
export declare class TaskOrchestrator {
|
8
9
|
private readonly hasher;
|
9
10
|
private readonly initiatingProject;
|
10
11
|
private readonly projectGraph;
|
11
12
|
private readonly taskGraph;
|
13
|
+
private readonly nxJson;
|
12
14
|
private readonly options;
|
13
15
|
private readonly bail;
|
14
16
|
private readonly daemon;
|
@@ -24,7 +26,7 @@ export declare class TaskOrchestrator {
|
|
24
26
|
private waitingForTasks;
|
25
27
|
private groups;
|
26
28
|
private bailed;
|
27
|
-
constructor(hasher: TaskHasher, initiatingProject: string | undefined, projectGraph: ProjectGraph, taskGraph: TaskGraph, options: DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient, outputStyle: string);
|
29
|
+
constructor(hasher: TaskHasher, initiatingProject: string | undefined, projectGraph: ProjectGraph, taskGraph: TaskGraph, nxJson: NxJsonConfiguration, options: DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient, outputStyle: string);
|
28
30
|
run(): Promise<{
|
29
31
|
[id: string]: TaskStatus;
|
30
32
|
}>;
|
@@ -17,16 +17,17 @@ const output_1 = require("../utils/output");
|
|
17
17
|
const params_1 = require("../utils/params");
|
18
18
|
class TaskOrchestrator {
|
19
19
|
// endregion internal state
|
20
|
-
constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon, outputStyle) {
|
20
|
+
constructor(hasher, initiatingProject, projectGraph, taskGraph, nxJson, options, bail, daemon, outputStyle) {
|
21
21
|
this.hasher = hasher;
|
22
22
|
this.initiatingProject = initiatingProject;
|
23
23
|
this.projectGraph = projectGraph;
|
24
24
|
this.taskGraph = taskGraph;
|
25
|
+
this.nxJson = nxJson;
|
25
26
|
this.options = options;
|
26
27
|
this.bail = bail;
|
27
28
|
this.daemon = daemon;
|
28
29
|
this.outputStyle = outputStyle;
|
29
|
-
this.cache = (0, cache_1.getCache)(this.options);
|
30
|
+
this.cache = (0, cache_1.getCache)(this.nxJson, this.options);
|
30
31
|
this.forkedProcessTaskRunner = new forked_process_task_runner_1.ForkedProcessTaskRunner(this.options);
|
31
32
|
this.tasksSchedule = new tasks_schedule_1.TasksSchedule(this.projectGraph, this.taskGraph, this.options);
|
32
33
|
// region internal state
|
@@ -13,7 +13,7 @@ class TasksSchedule {
|
|
13
13
|
this.notScheduledTaskGraph = this.taskGraph;
|
14
14
|
this.reverseTaskDeps = (0, utils_1.calculateReverseDeps)(this.taskGraph);
|
15
15
|
this.reverseProjectGraph = (0, operators_1.reverse)(this.projectGraph);
|
16
|
-
this.taskHistory =
|
16
|
+
this.taskHistory = (0, task_history_1.getTaskHistory)();
|
17
17
|
this.scheduledBatches = [];
|
18
18
|
this.scheduledTasks = [];
|
19
19
|
this.runningTasks = new Set();
|
package/src/utils/ab-testing.js
CHANGED
@@ -97,7 +97,10 @@ function shouldRecordStats() {
|
|
97
97
|
return true;
|
98
98
|
}
|
99
99
|
try {
|
100
|
-
const stdout = (0, node_child_process_1.execSync)(pmc.getRegistryUrl, {
|
100
|
+
const stdout = (0, node_child_process_1.execSync)(pmc.getRegistryUrl, {
|
101
|
+
encoding: 'utf-8',
|
102
|
+
windowsHide: true,
|
103
|
+
});
|
101
104
|
const url = new URL(stdout.trim());
|
102
105
|
// don't record stats when testing locally
|
103
106
|
return url.hostname !== 'localhost';
|
@@ -16,6 +16,7 @@ function runNxSync(cmd, options) {
|
|
16
16
|
else {
|
17
17
|
options ??= {};
|
18
18
|
options.cwd ??= process.cwd();
|
19
|
+
options.windowsHide ??= true;
|
19
20
|
const offsetFromRoot = (0, path_1.relative)(options.cwd, (0, workspace_root_1.workspaceRootInner)(options.cwd, null));
|
20
21
|
if (process.platform === 'win32') {
|
21
22
|
baseCmd = '.\\' + (0, path_1.join)(`${offsetFromRoot}`, 'nx.bat');
|
@@ -34,6 +35,7 @@ async function runNxAsync(cmd, options) {
|
|
34
35
|
else {
|
35
36
|
options ??= {};
|
36
37
|
options.cwd ??= process.cwd();
|
38
|
+
options.windowsHide ??= true;
|
37
39
|
const offsetFromRoot = (0, path_1.relative)(options.cwd, (0, workspace_root_1.workspaceRootInner)(options.cwd, null));
|
38
40
|
if (process.platform === 'win32') {
|
39
41
|
baseCmd = '.\\' + (0, path_1.join)(`${offsetFromRoot}`, 'nx.bat');
|
@@ -46,13 +48,13 @@ async function runNxAsync(cmd, options) {
|
|
46
48
|
if (options?.silent) {
|
47
49
|
delete options.silent;
|
48
50
|
}
|
49
|
-
|
51
|
+
return new Promise((resolve, reject) => {
|
50
52
|
const child = (0, child_process_1.exec)(`${baseCmd} ${cmd}`, options, (error, stdout, stderr) => {
|
51
53
|
if (error) {
|
52
|
-
reject(error);
|
54
|
+
reject(stderr || stdout || error.message);
|
53
55
|
}
|
54
56
|
else {
|
55
|
-
resolve(
|
57
|
+
resolve();
|
56
58
|
}
|
57
59
|
});
|
58
60
|
if (!silent) {
|
@@ -222,6 +222,7 @@ function getMergeBase(base, head = 'HEAD') {
|
|
222
222
|
maxBuffer: file_utils_1.TEN_MEGABYTES,
|
223
223
|
cwd: workspace_root_1.workspaceRoot,
|
224
224
|
stdio: 'pipe',
|
225
|
+
windowsHide: true,
|
225
226
|
})
|
226
227
|
.toString()
|
227
228
|
.trim();
|
@@ -232,6 +233,7 @@ function getMergeBase(base, head = 'HEAD') {
|
|
232
233
|
maxBuffer: file_utils_1.TEN_MEGABYTES,
|
233
234
|
cwd: workspace_root_1.workspaceRoot,
|
234
235
|
stdio: 'pipe',
|
236
|
+
windowsHide: true,
|
235
237
|
})
|
236
238
|
.toString()
|
237
239
|
.trim();
|
@@ -245,7 +247,11 @@ function getFilesUsingBaseAndHead(base, head) {
|
|
245
247
|
return parseGitOutput(`git diff --name-only --no-renames --relative "${base}" "${head}"`);
|
246
248
|
}
|
247
249
|
function parseGitOutput(command) {
|
248
|
-
return (0, child_process_1.execSync)(command, {
|
250
|
+
return (0, child_process_1.execSync)(command, {
|
251
|
+
maxBuffer: file_utils_1.TEN_MEGABYTES,
|
252
|
+
cwd: workspace_root_1.workspaceRoot,
|
253
|
+
windowsHide: true,
|
254
|
+
})
|
249
255
|
.toString('utf-8')
|
250
256
|
.split('\n')
|
251
257
|
.map((a) => a.trim())
|
@@ -5,8 +5,11 @@ const child_process_1 = require("child_process");
|
|
5
5
|
function deduceDefaultBase() {
|
6
6
|
const nxDefaultBase = 'main';
|
7
7
|
try {
|
8
|
-
return ((0, child_process_1.execSync)('git config --get init.defaultBranch'
|
9
|
-
|
8
|
+
return ((0, child_process_1.execSync)('git config --get init.defaultBranch', {
|
9
|
+
windowsHide: true,
|
10
|
+
})
|
11
|
+
.toString()
|
12
|
+
.trim() || nxDefaultBase);
|
10
13
|
}
|
11
14
|
catch {
|
12
15
|
return nxDefaultBase;
|
@@ -9,9 +9,10 @@ try {
|
|
9
9
|
const { execSync } = require('child_process');
|
10
10
|
// NOTE: Using env vars because Windows PowerShell has its own handling of quotes (") messes up quotes in args, even if escaped.
|
11
11
|
const src = process.env.NX_IMPORT_SOURCE;
|
12
|
-
execSync('git read-tree --empty', { stdio: 'inherit' });
|
12
|
+
execSync('git read-tree --empty', { stdio: 'inherit', windowsHide: true });
|
13
13
|
execSync(`git reset ${process.env.GIT_COMMIT} -- "${src}"`, {
|
14
14
|
stdio: 'inherit',
|
15
|
+
windowsHide: true,
|
15
16
|
});
|
16
17
|
}
|
17
18
|
catch (error) {
|
package/src/utils/git-utils.js
CHANGED
@@ -36,6 +36,7 @@ class GitRepository {
|
|
36
36
|
getGitRootPath(cwd) {
|
37
37
|
return (0, child_process_1.execSync)('git rev-parse --show-toplevel', {
|
38
38
|
cwd,
|
39
|
+
windowsHide: true,
|
39
40
|
})
|
40
41
|
.toString()
|
41
42
|
.trim();
|
@@ -176,6 +177,7 @@ function getGithubSlugOrNull() {
|
|
176
177
|
try {
|
177
178
|
const gitRemote = (0, child_process_1.execSync)('git remote -v', {
|
178
179
|
stdio: 'pipe',
|
180
|
+
windowsHide: true,
|
179
181
|
}).toString();
|
180
182
|
// If there are no remotes, we default to github
|
181
183
|
if (!gitRemote || gitRemote.length === 0) {
|
@@ -226,6 +228,7 @@ function commitChanges(commitMessage, directory) {
|
|
226
228
|
stdio: 'pipe',
|
227
229
|
input: commitMessage,
|
228
230
|
cwd: directory,
|
231
|
+
windowsHide: true,
|
229
232
|
});
|
230
233
|
}
|
231
234
|
catch (err) {
|
@@ -247,6 +250,7 @@ function getLatestCommitSha() {
|
|
247
250
|
return (0, child_process_1.execSync)('git rev-parse HEAD', {
|
248
251
|
encoding: 'utf8',
|
249
252
|
stdio: 'pipe',
|
253
|
+
windowsHide: true,
|
250
254
|
}).trim();
|
251
255
|
}
|
252
256
|
catch {
|
@@ -14,7 +14,9 @@ try {
|
|
14
14
|
// NOTE: Using env vars because Windows PowerShell has its own handling of quotes (") messes up quotes in args, even if escaped.
|
15
15
|
const src = process.env.NX_IMPORT_SOURCE;
|
16
16
|
const dest = process.env.NX_IMPORT_DESTINATION;
|
17
|
-
const files = execSync(`git ls-files -z ${src}
|
17
|
+
const files = execSync(`git ls-files -z ${src}`, {
|
18
|
+
windowsHide: true,
|
19
|
+
})
|
18
20
|
.toString()
|
19
21
|
.trim()
|
20
22
|
.split('\x00')
|
package/src/utils/powerpack.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export declare function printPowerpackLicense(): Promise<void>;
|
2
|
-
export declare function getPowerpackLicenseInformation(): Promise<
|
2
|
+
export declare function getPowerpackLicenseInformation(): Promise<import("@nx/powerpack-license").PowerpackLicense>;
|
3
3
|
export declare class NxPowerpackNotInstalledError extends Error {
|
4
4
|
constructor(e: Error);
|
5
5
|
}
|
package/src/utils/powerpack.js
CHANGED
@@ -9,22 +9,17 @@ const workspace_root_1 = require("./workspace-root");
|
|
9
9
|
async function printPowerpackLicense() {
|
10
10
|
try {
|
11
11
|
const { organizationName, seatCount, workspaceCount } = await getPowerpackLicenseInformation();
|
12
|
-
logger_1.logger.log(`Nx Powerpack Licensed to ${organizationName} for ${seatCount} user${seatCount > 1 ? '' : 's'} in ${workspaceCount} workspace${workspaceCount > 1 ? '' : 's'}`);
|
12
|
+
logger_1.logger.log(`Nx Powerpack Licensed to ${organizationName} for ${seatCount} user${seatCount > 1 ? '' : 's'} in ${workspaceCount === 9999 ? 'an unlimited number of' : workspaceCount} workspace${workspaceCount > 1 ? '' : 's'}`);
|
13
13
|
}
|
14
14
|
catch { }
|
15
15
|
}
|
16
16
|
async function getPowerpackLicenseInformation() {
|
17
17
|
try {
|
18
|
-
const { getPowerpackLicenseInformation } = (await Promise.resolve().then(() => require(
|
19
|
-
// @ts-ignore
|
20
|
-
'@nx/powerpack-license'
|
21
|
-
// TODO(@FrozenPandaz): Provide the right type here.
|
22
|
-
)));
|
23
|
-
// )) as typeof import('@nx/powerpack-license');
|
18
|
+
const { getPowerpackLicenseInformation } = (await Promise.resolve().then(() => require('@nx/powerpack-license')));
|
24
19
|
return getPowerpackLicenseInformation(workspace_root_1.workspaceRoot);
|
25
20
|
}
|
26
21
|
catch (e) {
|
27
|
-
if ('code' in e && e.code === '
|
22
|
+
if ('code' in e && e.code === 'MODULE_NOT_FOUND') {
|
28
23
|
throw new NxPowerpackNotInstalledError(e);
|
29
24
|
}
|
30
25
|
throw e;
|