nx 18.1.0-canary.20240229-f6a183c → 18.1.0-canary.20240302-8bde48f

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/migrations.json CHANGED
@@ -86,7 +86,7 @@
86
86
  "18.0.0-disable-adding-plugins-for-existing-workspaces": {
87
87
  "cli": "nx",
88
88
  "version": "18.0.0-beta.2",
89
- "description": "Updates .env to disabled adding plugins when generating projects in an existing Nx workspace",
89
+ "description": "Updates nx.json to disabled adding plugins when generating projects in an existing Nx workspace",
90
90
  "implementation": "./src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces",
91
91
  "x-repair-skip": true
92
92
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "18.1.0-canary.20240229-f6a183c",
3
+ "version": "18.1.0-canary.20240302-8bde48f",
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": {
@@ -66,7 +66,7 @@
66
66
  "yargs-parser": "21.1.1",
67
67
  "node-machine-id": "1.1.12",
68
68
  "ora": "5.3.0",
69
- "@nrwl/tao": "18.1.0-canary.20240229-f6a183c"
69
+ "@nrwl/tao": "18.1.0-canary.20240302-8bde48f"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@swc-node/register": "^1.8.0",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-x64": "18.1.0-canary.20240229-f6a183c",
85
- "@nx/nx-darwin-arm64": "18.1.0-canary.20240229-f6a183c",
86
- "@nx/nx-linux-x64-gnu": "18.1.0-canary.20240229-f6a183c",
87
- "@nx/nx-linux-x64-musl": "18.1.0-canary.20240229-f6a183c",
88
- "@nx/nx-win32-x64-msvc": "18.1.0-canary.20240229-f6a183c",
89
- "@nx/nx-linux-arm64-gnu": "18.1.0-canary.20240229-f6a183c",
90
- "@nx/nx-linux-arm64-musl": "18.1.0-canary.20240229-f6a183c",
91
- "@nx/nx-linux-arm-gnueabihf": "18.1.0-canary.20240229-f6a183c",
92
- "@nx/nx-win32-arm64-msvc": "18.1.0-canary.20240229-f6a183c",
93
- "@nx/nx-freebsd-x64": "18.1.0-canary.20240229-f6a183c"
84
+ "@nx/nx-darwin-x64": "18.1.0-canary.20240302-8bde48f",
85
+ "@nx/nx-darwin-arm64": "18.1.0-canary.20240302-8bde48f",
86
+ "@nx/nx-linux-x64-gnu": "18.1.0-canary.20240302-8bde48f",
87
+ "@nx/nx-linux-x64-musl": "18.1.0-canary.20240302-8bde48f",
88
+ "@nx/nx-win32-x64-msvc": "18.1.0-canary.20240302-8bde48f",
89
+ "@nx/nx-linux-arm64-gnu": "18.1.0-canary.20240302-8bde48f",
90
+ "@nx/nx-linux-arm64-musl": "18.1.0-canary.20240302-8bde48f",
91
+ "@nx/nx-linux-arm-gnueabihf": "18.1.0-canary.20240302-8bde48f",
92
+ "@nx/nx-win32-arm64-msvc": "18.1.0-canary.20240302-8bde48f",
93
+ "@nx/nx-freebsd-x64": "18.1.0-canary.20240302-8bde48f"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -101,6 +101,10 @@
101
101
  "type": "boolean",
102
102
  "description": "Specifies whether the daemon should be used for the default tasks runner."
103
103
  },
104
+ "useInferencePlugins": {
105
+ "type": "boolean",
106
+ "description": "Specifies whether to add inference plugins when generating new projects."
107
+ },
104
108
  "release": {
105
109
  "type": "object",
106
110
  "description": "Configuration for the nx release commands.",
@@ -1,2 +1,2 @@
1
1
  export declare const allowedProjectExtensions: readonly ["tags", "implicitDependencies", "configFilePath", "$schema", "generators", "namedInputs", "name", "files", "root", "sourceRoot", "projectType", "release", "includedScripts"];
2
- export declare const allowedWorkspaceExtensions: readonly ["implicitDependencies", "affected", "defaultBase", "tasksRunnerOptions", "workspaceLayout", "plugins", "targetDefaults", "files", "generators", "namedInputs", "extends", "cli", "pluginsConfig", "defaultProject", "installation", "release", "nxCloudAccessToken", "nxCloudUrl", "nxCloudEncryptionKey", "parallel", "cacheDirectory", "useDaemonProcess"];
2
+ export declare const allowedWorkspaceExtensions: readonly ["implicitDependencies", "affected", "defaultBase", "tasksRunnerOptions", "workspaceLayout", "plugins", "targetDefaults", "files", "generators", "namedInputs", "extends", "cli", "pluginsConfig", "defaultProject", "installation", "release", "nxCloudAccessToken", "nxCloudUrl", "nxCloudEncryptionKey", "parallel", "cacheDirectory", "useDaemonProcess", "useInferencePlugins"];
@@ -58,6 +58,7 @@ exports.allowedWorkspaceExtensions = [
58
58
  'parallel',
59
59
  'cacheDirectory',
60
60
  'useDaemonProcess',
61
+ 'useInferencePlugins',
61
62
  ];
62
63
  if (!patched) {
63
64
  Module.prototype.require = function () {
@@ -97,7 +97,8 @@ async function initializePlugin(pkgName, options) {
97
97
  }
98
98
  else {
99
99
  updatePackageScripts =
100
- process.env.NX_ADD_PLUGINS !== 'false' &&
100
+ (0, nx_json_1.readNxJson)().useInferencePlugins !== false &&
101
+ process.env.NX_ADD_PLUGINS !== 'false' &&
101
102
  coreNxPlugins.includes(pkgName);
102
103
  }
103
104
  await (0, child_process_2.runNxAsync)(`g ${pkgName}:${initGenerator} --keepExistingVersions${updatePackageScripts ? ' --updatePackageScripts' : ''}`, {
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsInitCommand = void 0;
4
4
  const shared_options_1 = require("../yargs-utils/shared-options");
5
- const useV2 = process.env['NX_ADD_PLUGINS'] !== 'false';
5
+ const nx_json_1 = require("../../config/nx-json");
6
+ const useV2 = process.env['NX_ADD_PLUGINS'] !== 'false' &&
7
+ (0, nx_json_1.readNxJson)().useInferencePlugins !== false;
6
8
  exports.yargsInitCommand = {
7
9
  command: 'init',
8
10
  describe: 'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx.',
@@ -108,6 +108,7 @@ const npmPackageToPluginMap = {
108
108
  vite: '@nx/vite',
109
109
  vitest: '@nx/vite',
110
110
  webpack: '@nx/webpack',
111
+ rollup: '@nx/rollup',
111
112
  // Testing tools
112
113
  jest: '@nx/jest',
113
114
  cypress: '@nx/cypress',
@@ -360,6 +360,9 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
360
360
  return;
361
361
  }
362
362
  function resolveChangelogRenderer(changelogRendererPath) {
363
+ const interpolatedChangelogRendererPath = (0, utils_1.interpolate)(changelogRendererPath, {
364
+ workspaceRoot: workspace_root_1.workspaceRoot,
365
+ });
363
366
  // Try and load the provided (or default) changelog renderer
364
367
  let changelogRenderer;
365
368
  let cleanupTranspiler = () => { };
@@ -368,7 +371,7 @@ function resolveChangelogRenderer(changelogRendererPath) {
368
371
  if (rootTsconfigPath) {
369
372
  cleanupTranspiler = (0, register_1.registerTsProject)(rootTsconfigPath);
370
373
  }
371
- const r = require(changelogRendererPath);
374
+ const r = require(interpolatedChangelogRendererPath);
372
375
  changelogRenderer = r.default || r;
373
376
  }
374
377
  catch {
@@ -14,11 +14,25 @@ function escapeRegExp(string) {
14
14
  const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/g;
15
15
  async function getLatestGitTagForPattern(releaseTagPattern, additionalInterpolationData = {}) {
16
16
  try {
17
- const tags = await (0, exec_command_1.execCommand)('git', ['tag', '--sort', '-v:refname']).then((r) => r
17
+ let tags;
18
+ tags = await (0, exec_command_1.execCommand)('git', [
19
+ 'tag',
20
+ '--sort',
21
+ '-v:refname',
22
+ '--merged',
23
+ ]).then((r) => r
18
24
  .trim()
19
25
  .split('\n')
20
26
  .map((t) => t.trim())
21
27
  .filter(Boolean));
28
+ if (!tags.length) {
29
+ // try again, but include all tags on the repo instead of just --merged ones
30
+ tags = await (0, exec_command_1.execCommand)('git', ['tag', '--sort', '-v:refname']).then((r) => r
31
+ .trim()
32
+ .split('\n')
33
+ .map((t) => t.trim())
34
+ .filter(Boolean));
35
+ }
22
36
  if (!tags.length) {
23
37
  return null;
24
38
  }
@@ -358,6 +358,10 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
358
358
  * Set this to false to disable the daemon.
359
359
  */
360
360
  useDaemonProcess?: boolean;
361
+ /**
362
+ * Set this to false to disable adding inference plugins when generating new projects
363
+ */
364
+ useInferencePlugins?: boolean;
361
365
  }
362
366
  export type PluginConfiguration = string | {
363
367
  plugin: string;
@@ -44,7 +44,7 @@ export type { PackageManager } from './utils/package-manager';
44
44
  /**
45
45
  * @category Package Manager
46
46
  */
47
- export { getPackageManagerCommand, detectPackageManager, getPackageManagerVersion, } from './utils/package-manager';
47
+ export { getPackageManagerCommand, detectPackageManager, getPackageManagerVersion, isWorkspacesEnabled, } from './utils/package-manager';
48
48
  /**
49
49
  * @category Commands
50
50
  */
@@ -4,7 +4,7 @@
4
4
  * Try hard to not add to this API to reduce the surface area we need to maintain.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.glob = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.Workspaces = void 0;
7
+ exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.glob = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.isWorkspacesEnabled = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.Workspaces = void 0;
8
8
  // TODO(v19): Remove this export
9
9
  /**
10
10
  * @category Workspace
@@ -30,6 +30,7 @@ var package_manager_1 = require("./utils/package-manager");
30
30
  Object.defineProperty(exports, "getPackageManagerCommand", { enumerable: true, get: function () { return package_manager_1.getPackageManagerCommand; } });
31
31
  Object.defineProperty(exports, "detectPackageManager", { enumerable: true, get: function () { return package_manager_1.detectPackageManager; } });
32
32
  Object.defineProperty(exports, "getPackageManagerVersion", { enumerable: true, get: function () { return package_manager_1.getPackageManagerVersion; } });
33
+ Object.defineProperty(exports, "isWorkspacesEnabled", { enumerable: true, get: function () { return package_manager_1.isWorkspacesEnabled; } });
33
34
  /**
34
35
  * @category Commands
35
36
  */
@@ -35,6 +35,7 @@ function addProjectConfiguration(tree, projectName, projectConfiguration, standa
35
35
  throw new Error(`Cannot create a new project ${projectName} at ${projectConfiguration.root}. A project already exists in this directory.`);
36
36
  }
37
37
  delete projectConfiguration.$schema;
38
+ handleEmptyTargets(projectName, projectConfiguration);
38
39
  (0, json_1.writeJson)(tree, projectConfigFile, {
39
40
  name: projectName,
40
41
  $schema: getRelativeProjectJsonSchemaPath(tree, projectConfiguration),
@@ -55,6 +56,7 @@ function updateProjectConfiguration(tree, projectName, projectConfiguration) {
55
56
  if (!tree.exists(projectConfigFile)) {
56
57
  throw new Error(`Cannot update Project ${projectName} at ${projectConfiguration.root}. It either doesn't exist yet, or may not use project.json for configuration. Use \`addProjectConfiguration()\` instead if you want to create a new project.`);
57
58
  }
59
+ handleEmptyTargets(projectName, projectConfiguration);
58
60
  (0, json_1.writeJson)(tree, projectConfigFile, {
59
61
  name: projectConfiguration.name ?? projectName,
60
62
  $schema: getRelativeProjectJsonSchemaPath(tree, projectConfiguration),
@@ -131,7 +133,7 @@ function readAndCombineAllProjectConfigurations(tree) {
131
133
  const patterns = [
132
134
  '**/project.json',
133
135
  'project.json',
134
- ...(0, package_json_workspaces_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p)),
136
+ ...(0, package_json_workspaces_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true })),
135
137
  ];
136
138
  const projectGlobPatterns = (0, retrieve_workspace_files_1.configurationGlobs)([
137
139
  project_json_1.ProjectJsonProjectsPlugin,
@@ -237,3 +239,15 @@ function toNewFormat(w) {
237
239
  }
238
240
  return w;
239
241
  }
242
+ function handleEmptyTargets(projectName, projectConfiguration) {
243
+ if (projectConfiguration.targets &&
244
+ !Object.keys(projectConfiguration.targets).length) {
245
+ // Re-order `targets` to appear after the `// target` comment.
246
+ delete projectConfiguration.targets;
247
+ projectConfiguration['// targets'] = `to see all targets run: nx show project ${projectName} --web`;
248
+ projectConfiguration.targets = {};
249
+ }
250
+ else {
251
+ delete projectConfiguration['// targets'];
252
+ }
253
+ }
@@ -1,29 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const logger_1 = require("../../utils/logger");
4
- const ignore_1 = require("ignore");
3
+ const nx_json_1 = require("../../generators/utils/nx-json");
5
4
  function migrate(tree) {
6
- const ig = (0, ignore_1.default)();
7
- try {
8
- ig.add(tree.read('.gitignore', 'utf-8'));
9
- if (ig.ignores('.env')) {
10
- logger_1.logger.warn('NX The NX_ADD_PLUGINS=false environment variable was added to your .env file for backwards compatibility. However, your .env is ignored by git. Other contributors should add this key to their .env file or ensure that the environment variable is set to false when generating code with Nx.');
11
- }
12
- }
13
- catch { }
14
- if (!tree.exists('.env')) {
15
- tree.write('.env', '');
16
- }
17
- const dotenv = tree.read('.env', 'utf-8');
18
- const newDotenvContents = [
19
- '# Nx 18 enables using plugins to infer targets by default',
20
- '# This is disabled for existing workspaces to maintain compatibility',
21
- '# For more info, see: https://nx.dev/concepts/inferred-tasks',
22
- 'NX_ADD_PLUGINS=false',
23
- ];
24
- if (dotenv.length) {
25
- newDotenvContents.unshift(dotenv, '');
26
- }
27
- tree.write('.env', newDotenvContents.join('\n'));
5
+ const nxJson = (0, nx_json_1.readNxJson)(tree);
6
+ nxJson.useInferencePlugins = false;
7
+ (0, nx_json_1.updateNxJson)(tree, nxJson);
28
8
  }
29
9
  exports.default = migrate;
@@ -67,6 +67,7 @@ function getTranspiler(compilerOptions) {
67
67
  }
68
68
  compilerOptions.lib = ['es2021'];
69
69
  compilerOptions.module = ts.ModuleKind.CommonJS;
70
+ compilerOptions.moduleResolution = ts.ModuleResolutionKind.Node10;
70
71
  compilerOptions.target = ts.ScriptTarget.ES2021;
71
72
  compilerOptions.inlineSourceMap = true;
72
73
  compilerOptions.skipLibCheck = true;
@@ -1,11 +1,22 @@
1
1
  import { TargetConfiguration } from '../../config/workspace-json-project-json';
2
2
  import { NxPluginV2 } from '../../project-graph/plugins';
3
3
  /**
4
- * This symbol marks that a target provides information which should modify a target already registered
4
+ * This marks that a target provides information which should modify a target already registered
5
5
  * on the project via other plugins. If the target has not already been registered, and this symbol is true,
6
6
  * the information provided by it will be discarded.
7
+ *
8
+ * NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
9
+ * between the plugin-worker and the main process.
7
10
  */
8
- export declare const ONLY_MODIFIES_EXISTING_TARGET: unique symbol;
11
+ export declare const ONLY_MODIFIES_EXISTING_TARGET = "NX_ONLY_MODIFIES_EXISTING_TARGET";
12
+ /**
13
+ * This is used to override the source file for the target defaults plugin.
14
+ * This allows the plugin to use the project files as the context, but point to nx.json as the source file.
15
+ *
16
+ * NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
17
+ * between the plugin-worker and the main process.
18
+ */
19
+ export declare const OVERRIDE_SOURCE_FILE = "NX_OVERRIDE_SOURCE_FILE";
9
20
  export declare const TargetDefaultsPlugin: NxPluginV2;
10
21
  export default TargetDefaultsPlugin;
11
22
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTargetInfo = exports.TargetDefaultsPlugin = exports.ONLY_MODIFIES_EXISTING_TARGET = void 0;
3
+ exports.getTargetInfo = exports.TargetDefaultsPlugin = exports.OVERRIDE_SOURCE_FILE = exports.ONLY_MODIFIES_EXISTING_TARGET = void 0;
4
4
  const minimatch_1 = require("minimatch");
5
5
  const node_fs_1 = require("node:fs");
6
6
  const node_path_1 = require("node:path");
@@ -9,11 +9,22 @@ const globs_1 = require("../../utils/globs");
9
9
  const package_json_1 = require("../../utils/package-json");
10
10
  const package_json_workspaces_1 = require("../package-json-workspaces");
11
11
  /**
12
- * This symbol marks that a target provides information which should modify a target already registered
12
+ * This marks that a target provides information which should modify a target already registered
13
13
  * on the project via other plugins. If the target has not already been registered, and this symbol is true,
14
14
  * the information provided by it will be discarded.
15
+ *
16
+ * NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
17
+ * between the plugin-worker and the main process.
15
18
  */
16
- exports.ONLY_MODIFIES_EXISTING_TARGET = Symbol('ONLY_MODIFIES_EXISTING_TARGET');
19
+ exports.ONLY_MODIFIES_EXISTING_TARGET = 'NX_ONLY_MODIFIES_EXISTING_TARGET';
20
+ /**
21
+ * This is used to override the source file for the target defaults plugin.
22
+ * This allows the plugin to use the project files as the context, but point to nx.json as the source file.
23
+ *
24
+ * NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
25
+ * between the plugin-worker and the main process.
26
+ */
27
+ exports.OVERRIDE_SOURCE_FILE = 'NX_OVERRIDE_SOURCE_FILE';
17
28
  exports.TargetDefaultsPlugin = {
18
29
  name: 'nx/core/target-defaults',
19
30
  createNodes: [
@@ -71,6 +82,7 @@ exports.TargetDefaultsPlugin = {
71
82
  targets: modifiedTargets,
72
83
  },
73
84
  },
85
+ [exports.OVERRIDE_SOURCE_FILE]: 'nx.json',
74
86
  };
75
87
  },
76
88
  ],
@@ -125,7 +137,7 @@ function getTargetInfo(target, projectJsonTargets, packageJsonTargets) {
125
137
  return {
126
138
  executor: 'nx:run-commands',
127
139
  options: {
128
- command: projectJsonTarget.options?.command,
140
+ command: targetOptions?.command,
129
141
  },
130
142
  };
131
143
  }
@@ -159,7 +171,7 @@ function getTargetExecutor(target, projectJsonTargets, packageJsonTargets) {
159
171
  const projectJsonTargetConfiguration = projectJsonTargets?.[target];
160
172
  const packageJsonTargetConfiguration = packageJsonTargets?.[target];
161
173
  if (!projectJsonTargetConfiguration && packageJsonTargetConfiguration) {
162
- return packageJsonTargetConfiguration?.executor ?? 'nx:run-script';
174
+ return packageJsonTargetConfiguration?.executor;
163
175
  }
164
176
  if (projectJsonTargetConfiguration?.executor) {
165
177
  return projectJsonTargetConfiguration.executor;
@@ -161,13 +161,17 @@ plugins, root = workspace_root_1.workspaceRoot) {
161
161
  const configurationSourceMaps = {};
162
162
  for (const result of results.flat()) {
163
163
  const { projects: projectNodes, externalNodes: pluginExternalNodes, file, pluginName, } = result;
164
+ const sourceInfo = [file, pluginName];
165
+ if (result[target_defaults_plugin_1.OVERRIDE_SOURCE_FILE]) {
166
+ sourceInfo[0] = result[target_defaults_plugin_1.OVERRIDE_SOURCE_FILE];
167
+ }
164
168
  for (const node in projectNodes) {
165
169
  const project = {
166
170
  root: node,
167
171
  ...projectNodes[node],
168
172
  };
169
173
  try {
170
- mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, [file, pluginName]);
174
+ mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInfo);
171
175
  }
172
176
  catch (e) {
173
177
  throw new utils_1.CreateNodesError(`Unable to merge project information for "${project.root}" from ${result.file} using plugin ${result.pluginName}.`, e);
@@ -195,6 +199,10 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
195
199
  // to provide better error messaging.
196
200
  const errors = new Map();
197
201
  for (const [root, configuration] of projectRootMap.entries()) {
202
+ // We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
203
+ // Strip it before returning configuration for usage.
204
+ if (configuration['// targets'])
205
+ delete configuration['// targets'];
198
206
  if (!configuration.name) {
199
207
  try {
200
208
  const { name } = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
@@ -16,6 +16,12 @@ export interface PackageManagerCommands {
16
16
  * Detects which package manager is used in the workspace based on the lock file.
17
17
  */
18
18
  export declare function detectPackageManager(dir?: string): PackageManager;
19
+ /**
20
+ * Returns true if the workspace is using npm workspaces, yarn workspaces, or pnpm workspaces.
21
+ * @param packageManager The package manager to use. If not provided, it will be detected based on the lock file.
22
+ * @param root The directory the commands will be ran inside of. Defaults to the current workspace's root.
23
+ */
24
+ export declare function isWorkspacesEnabled(packageManager?: PackageManager, root?: string): boolean;
19
25
  /**
20
26
  * Returns commands for the package manager used in the workspace.
21
27
  * By default, the package manager is derived based on the lock file,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.packageRegistryPack = exports.packageRegistryView = exports.resolvePackageVersionUsingInstallation = exports.resolvePackageVersionUsingRegistry = exports.createTempNpmDirectory = exports.copyPackageManagerConfigurationFiles = exports.modifyYarnRcToFitNewDirectory = exports.modifyYarnRcYmlToFitNewDirectory = exports.findFileInPackageJsonDirectory = exports.getPackageManagerVersion = exports.getPackageManagerCommand = exports.detectPackageManager = void 0;
3
+ exports.packageRegistryPack = exports.packageRegistryView = exports.resolvePackageVersionUsingInstallation = exports.resolvePackageVersionUsingRegistry = exports.createTempNpmDirectory = exports.copyPackageManagerConfigurationFiles = exports.modifyYarnRcToFitNewDirectory = exports.modifyYarnRcYmlToFitNewDirectory = exports.findFileInPackageJsonDirectory = exports.getPackageManagerVersion = exports.getPackageManagerCommand = exports.isWorkspacesEnabled = exports.detectPackageManager = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const fs_1 = require("fs");
6
6
  const fs_extra_1 = require("fs-extra");
@@ -9,6 +9,7 @@ const semver_1 = require("semver");
9
9
  const tmp_1 = require("tmp");
10
10
  const util_1 = require("util");
11
11
  const configuration_1 = require("../config/configuration");
12
+ const file_utils_1 = require("../project-graph/file-utils");
12
13
  const fileutils_1 = require("./fileutils");
13
14
  const package_json_1 = require("./package-json");
14
15
  const workspace_root_1 = require("./workspace-root");
@@ -26,6 +27,20 @@ function detectPackageManager(dir = '') {
26
27
  : 'npm'));
27
28
  }
28
29
  exports.detectPackageManager = detectPackageManager;
30
+ /**
31
+ * Returns true if the workspace is using npm workspaces, yarn workspaces, or pnpm workspaces.
32
+ * @param packageManager The package manager to use. If not provided, it will be detected based on the lock file.
33
+ * @param root The directory the commands will be ran inside of. Defaults to the current workspace's root.
34
+ */
35
+ function isWorkspacesEnabled(packageManager = detectPackageManager(), root = workspace_root_1.workspaceRoot) {
36
+ if (packageManager === 'pnpm') {
37
+ return (0, fs_1.existsSync)((0, path_1.join)(root, 'pnpm-workspace.yaml'));
38
+ }
39
+ // yarn and pnpm both use the same 'workspaces' property in package.json
40
+ const packageJson = (0, file_utils_1.readPackageJson)();
41
+ return !!packageJson?.workspaces;
42
+ }
43
+ exports.isWorkspacesEnabled = isWorkspacesEnabled;
29
44
  /**
30
45
  * Returns commands for the package manager used in the workspace.
31
46
  * By default, the package manager is derived based on the lock file,