nx 17.3.0 → 17.3.2

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.
Files changed (57) hide show
  1. package/bin/init-local.js +1 -34
  2. package/bin/run-executor.js +1 -1
  3. package/package.json +14 -14
  4. package/src/adapter/compat.d.ts +1 -1
  5. package/src/adapter/compat.js +1 -0
  6. package/src/command-line/affected/command-object.d.ts +4 -4
  7. package/src/command-line/affected/command-object.js +4 -4
  8. package/src/command-line/graph/graph.js +1 -1
  9. package/src/command-line/init/implementation/utils.js +1 -0
  10. package/src/command-line/init/init-v1.js +1 -1
  11. package/src/command-line/nx-commands.js +1 -0
  12. package/src/command-line/report/report.js +1 -1
  13. package/src/command-line/run/command-object.d.ts +4 -0
  14. package/src/command-line/run/command-object.js +10 -1
  15. package/src/command-line/run/run-one.js +2 -2
  16. package/src/command-line/yargs-utils/shared-options.js +4 -1
  17. package/src/config/project-graph.d.ts +2 -2
  18. package/src/config/workspaces.d.ts +1 -1
  19. package/src/config/workspaces.js +2 -2
  20. package/src/core/graph/main.js +1 -1
  21. package/src/core/graph/styles.css +1 -1
  22. package/src/daemon/client/client.js +1 -1
  23. package/src/devkit-exports.js +1 -1
  24. package/src/executors/run-script/run-script.impl.js +41 -19
  25. package/src/hasher/hash-task.js +1 -1
  26. package/src/hasher/task-hasher.d.ts +4 -4
  27. package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +1 -1
  28. package/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +1 -1
  29. package/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +1 -1
  30. package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +1 -1
  31. package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +1 -1
  32. package/src/plugins/js/utils/register.d.ts +1 -1
  33. package/src/plugins/js/utils/register.js +2 -0
  34. package/src/plugins/package-json-workspaces/create-nodes.js +23 -2
  35. package/src/plugins/target-defaults/target-defaults-plugin.js +28 -22
  36. package/src/project-graph/file-utils.d.ts +1 -1
  37. package/src/project-graph/file-utils.js +2 -2
  38. package/src/project-graph/nx-deps-cache.js +1 -1
  39. package/src/project-graph/project-graph-builder.d.ts +1 -1
  40. package/src/project-graph/project-graph-builder.js +1 -1
  41. package/src/tasks-runner/create-task-graph.js +1 -1
  42. package/src/tasks-runner/init-tasks-runner.js +1 -1
  43. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +2 -4
  44. package/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.js +1 -2
  45. package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +1 -2
  46. package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +1 -2
  47. package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +1 -2
  48. package/src/tasks-runner/run-command.js +4 -4
  49. package/src/tasks-runner/task-env.js +1 -2
  50. package/src/tasks-runner/utils.d.ts +1 -1
  51. package/src/utils/nx-plugin.deprecated.d.ts +6 -6
  52. package/src/utils/nx-plugin.deprecated.js +1 -1
  53. package/src/utils/output.d.ts +3 -0
  54. package/src/utils/output.js +35 -2
  55. package/src/utils/package-json.d.ts +1 -2
  56. package/src/utils/typescript.js +1 -1
  57. package/src/utils/workspace-configuration-check.js +1 -1
@@ -140,7 +140,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
140
140
  title: `TaskGraph is now required as an argument to hashTask`,
141
141
  bodyLines: [
142
142
  `The TaskGraph object can be retrieved from the context`,
143
- 'This will result in an error in Nx 18',
143
+ 'This will result in an error in Nx 19',
144
144
  ],
145
145
  });
146
146
  taskGraph_ = taskGraph;
@@ -150,7 +150,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
150
150
  title: `The environment variables are now required as an argument to hashTask`,
151
151
  bodyLines: [
152
152
  `Please pass the environment variables used when running the task`,
153
- 'This will result in an error in Nx 18',
153
+ 'This will result in an error in Nx 19',
154
154
  ],
155
155
  });
156
156
  env = process.env;
@@ -163,7 +163,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
163
163
  title: `TaskGraph is now required as an argument to hashTasks`,
164
164
  bodyLines: [
165
165
  `The TaskGraph object can be retrieved from the context`,
166
- 'This will result in an error in Nx 18',
166
+ 'This will result in an error in Nx 19',
167
167
  ],
168
168
  });
169
169
  taskGraph_ = taskGraph;
@@ -173,7 +173,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
173
173
  title: `The environment variables are now required as an argument to hashTasks`,
174
174
  bodyLines: [
175
175
  `Please pass the environment variables used when running the tasks`,
176
- 'This will result in an error in Nx 18',
176
+ 'This will result in an error in Nx 19',
177
177
  ],
178
178
  });
179
179
  env = process.env;
@@ -35,8 +35,7 @@ function getEnvVariablesForTask(task, taskSpecificEnv, forceColor, skipNxCache,
35
35
  delete res.NX_STREAM_OUTPUT;
36
36
  delete res.NX_PREFIX_OUTPUT;
37
37
  }
38
- delete res.NX_BASE;
39
- delete res.NX_HEAD;
38
+ // we don't reset NX_BASE or NX_HEAD because those are set by the user and should be preserved
40
39
  delete res.NX_SET_CLI;
41
40
  return res;
42
41
  }
@@ -18,7 +18,7 @@ declare class InvalidOutputsError extends Error {
18
18
  export declare function validateOutputs(outputs: string[]): void;
19
19
  export declare function transformLegacyOutputs(projectRoot: string, error: InvalidOutputsError): string[];
20
20
  /**
21
- * @deprecated Pass the target and overrides instead. This will be removed in v18.
21
+ * @deprecated Pass the target and overrides instead. This will be removed in v19.
22
22
  */
23
23
  export declare function getOutputsForTargetAndConfiguration(task: Task, node: ProjectGraphProjectNode): string[];
24
24
  export declare function getOutputsForTargetAndConfiguration(target: Task['target'] | Task, overrides: Task['overrides'] | ProjectGraphProjectNode, node: ProjectGraphProjectNode): string[];
@@ -2,30 +2,30 @@ import { ProjectGraphProcessor } from '../config/project-graph';
2
2
  import { TargetConfiguration } from '../config/workspace-json-project-json';
3
3
  import { LoadedNxPlugin } from './nx-plugin';
4
4
  /**
5
- * @deprecated Add targets to the projects in a {@link CreateNodes} function instead. This will be removed in Nx 18
5
+ * @deprecated Add targets to the projects in a {@link CreateNodes} function instead. This will be removed in Nx 19
6
6
  */
7
7
  export type ProjectTargetConfigurator = (file: string) => Record<string, TargetConfiguration>;
8
8
  /**
9
- * @deprecated Use {@link NxPluginV2} instead. This will be removed in Nx 18
9
+ * @deprecated Use {@link NxPluginV2} instead. This will be removed in Nx 19
10
10
  */
11
11
  export type NxPluginV1 = {
12
12
  name: string;
13
13
  /**
14
- * @deprecated Use {@link CreateNodes} and {@link CreateDependencies} instead. This will be removed in Nx 18
14
+ * @deprecated Use {@link CreateNodes} and {@link CreateDependencies} instead. This will be removed in Nx 19
15
15
  */
16
16
  processProjectGraph?: ProjectGraphProcessor;
17
17
  /**
18
- * @deprecated Add targets to the projects inside of {@link CreateNodes} instead. This will be removed in Nx 18
18
+ * @deprecated Add targets to the projects inside of {@link CreateNodes} instead. This will be removed in Nx 19
19
19
  */
20
20
  registerProjectTargets?: ProjectTargetConfigurator;
21
21
  /**
22
22
  * A glob pattern to search for non-standard project files.
23
23
  * @example: ["*.csproj", "pom.xml"]
24
- * @deprecated Use {@link CreateNodes} instead. This will be removed in Nx 18
24
+ * @deprecated Use {@link CreateNodes} instead. This will be removed in Nx 19
25
25
  */
26
26
  projectFilePatterns?: string[];
27
27
  };
28
28
  /**
29
- * @todo(@agentender) v18: Remove this fn when we remove readWorkspaceConfig
29
+ * @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
30
30
  */
31
31
  export declare function getDefaultPluginsSync(root: string): LoadedNxPlugin[];
@@ -6,7 +6,7 @@ const project_json_1 = require("../plugins/project-json/build-nodes/project-json
6
6
  const target_defaults_plugin_1 = require("../plugins/target-defaults/target-defaults-plugin");
7
7
  const package_json_workspaces_1 = require("../plugins/package-json-workspaces");
8
8
  /**
9
- * @todo(@agentender) v18: Remove this fn when we remove readWorkspaceConfig
9
+ * @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
10
10
  */
11
11
  function getDefaultPluginsSync(root) {
12
12
  const plugins = [
@@ -58,6 +58,9 @@ declare class CLIOutput {
58
58
  success({ title, bodyLines }: CLISuccessMessageConfig): void;
59
59
  logSingleLine(message: string): void;
60
60
  logCommand(message: string, taskStatus?: TaskStatus): void;
61
+ logCommandOutput(message: string, taskStatus: TaskStatus, output: string): void;
62
+ private getCommandWithStatus;
63
+ private getStatusIcon;
61
64
  private normalizeMessage;
62
65
  private addTaskStatus;
63
66
  log({ title, bodyLines, color }: CLIWarnMessageConfig & {
@@ -5,6 +5,8 @@ const chalk = require("chalk");
5
5
  const os_1 = require("os");
6
6
  const readline = require("readline");
7
7
  const is_ci_1 = require("./is-ci");
8
+ const GH_GROUP_PREFIX = '::group::';
9
+ const GH_GROUP_SUFFIX = '::endgroup::';
8
10
  /**
9
11
  * Automatically disable styling applied by chalk if CI=true
10
12
  */
@@ -152,11 +154,42 @@ class CLIOutput {
152
154
  }
153
155
  logCommand(message, taskStatus) {
154
156
  this.addNewline();
155
- const commandOutput = chalk.dim('> ') + this.formatCommand(this.normalizeMessage(message));
156
- const commandOutputWithStatus = this.addTaskStatus(taskStatus, commandOutput);
157
+ this.writeToStdOut(this.getCommandWithStatus(message, taskStatus));
158
+ this.addNewline();
159
+ this.addNewline();
160
+ }
161
+ logCommandOutput(message, taskStatus, output) {
162
+ let commandOutputWithStatus = this.getCommandWithStatus(message, taskStatus);
163
+ if (process.env.GITHUB_ACTIONS) {
164
+ const icon = this.getStatusIcon(taskStatus);
165
+ commandOutputWithStatus = `${GH_GROUP_PREFIX}${icon} ${commandOutputWithStatus}`;
166
+ }
167
+ this.addNewline();
157
168
  this.writeToStdOut(commandOutputWithStatus);
158
169
  this.addNewline();
159
170
  this.addNewline();
171
+ this.writeToStdOut(output);
172
+ if (process.env.GITHUB_ACTIONS) {
173
+ this.writeToStdOut(GH_GROUP_SUFFIX);
174
+ }
175
+ }
176
+ getCommandWithStatus(message, taskStatus) {
177
+ const commandOutput = chalk.dim('> ') + this.formatCommand(this.normalizeMessage(message));
178
+ return this.addTaskStatus(taskStatus, commandOutput);
179
+ }
180
+ getStatusIcon(taskStatus) {
181
+ switch (taskStatus) {
182
+ case 'success':
183
+ return '✔️';
184
+ case 'failure':
185
+ return '❌';
186
+ case 'skipped':
187
+ case 'local-cache-kept-existing':
188
+ return '⏩';
189
+ case 'local-cache':
190
+ case 'remote-cache':
191
+ return '🔁';
192
+ }
160
193
  }
161
194
  normalizeMessage(message) {
162
195
  if (message.startsWith('nx run ')) {
@@ -1,12 +1,11 @@
1
1
  import { InputDefinition, TargetConfiguration } from '../config/workspace-json-project-json';
2
- export type PackageJsonTargetConfiguration = Omit<TargetConfiguration, 'executor'>;
3
2
  export interface NxProjectPackageJsonConfiguration {
4
3
  implicitDependencies?: string[];
5
4
  tags?: string[];
6
5
  namedInputs?: {
7
6
  [inputName: string]: (string | InputDefinition)[];
8
7
  };
9
- targets?: Record<string, PackageJsonTargetConfiguration>;
8
+ targets?: Record<string, TargetConfiguration>;
10
9
  includedScripts?: string[];
11
10
  }
12
11
  export type ArrayPackageGroup = {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // TODO(v18): Nx Devkit 15 depends on this file. Remove this when we no longer support Nx Devkit 15
2
+ // TODO(v19): Nx Devkit 15 depends on this file. Remove this when we no longer support Nx Devkit 15
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const tslib_1 = require("tslib");
5
5
  tslib_1.__exportStar(require("../plugins/js/utils/typescript"), exports);
@@ -6,7 +6,7 @@ const fs_1 = require("fs");
6
6
  const path_1 = require("path");
7
7
  const output_1 = require("./output");
8
8
  const fileutils_1 = require("../utils/fileutils");
9
- //TODO: vsavkin remove after Nx 18
9
+ //TODO: vsavkin remove after Nx 19
10
10
  function workspaceConfigurationCheck() {
11
11
  if ((0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'workspace.json'))) {
12
12
  output_1.output.warn({