nx 20.7.0-canary.20250320-2a0d89d → 20.7.0-canary.20250321-cad4d26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "20.7.0-canary.20250320-2a0d89d",
3
+ "version": "20.7.0-canary.20250321-cad4d26",
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": {
@@ -82,16 +82,16 @@
82
82
  }
83
83
  },
84
84
  "optionalDependencies": {
85
- "@nx/nx-darwin-arm64": "20.7.0-canary.20250320-2a0d89d",
86
- "@nx/nx-darwin-x64": "20.7.0-canary.20250320-2a0d89d",
87
- "@nx/nx-freebsd-x64": "20.7.0-canary.20250320-2a0d89d",
88
- "@nx/nx-linux-arm-gnueabihf": "20.7.0-canary.20250320-2a0d89d",
89
- "@nx/nx-linux-arm64-gnu": "20.7.0-canary.20250320-2a0d89d",
90
- "@nx/nx-linux-arm64-musl": "20.7.0-canary.20250320-2a0d89d",
91
- "@nx/nx-linux-x64-gnu": "20.7.0-canary.20250320-2a0d89d",
92
- "@nx/nx-linux-x64-musl": "20.7.0-canary.20250320-2a0d89d",
93
- "@nx/nx-win32-arm64-msvc": "20.7.0-canary.20250320-2a0d89d",
94
- "@nx/nx-win32-x64-msvc": "20.7.0-canary.20250320-2a0d89d"
85
+ "@nx/nx-darwin-arm64": "20.7.0-canary.20250321-cad4d26",
86
+ "@nx/nx-darwin-x64": "20.7.0-canary.20250321-cad4d26",
87
+ "@nx/nx-freebsd-x64": "20.7.0-canary.20250321-cad4d26",
88
+ "@nx/nx-linux-arm-gnueabihf": "20.7.0-canary.20250321-cad4d26",
89
+ "@nx/nx-linux-arm64-gnu": "20.7.0-canary.20250321-cad4d26",
90
+ "@nx/nx-linux-arm64-musl": "20.7.0-canary.20250321-cad4d26",
91
+ "@nx/nx-linux-x64-gnu": "20.7.0-canary.20250321-cad4d26",
92
+ "@nx/nx-linux-x64-musl": "20.7.0-canary.20250321-cad4d26",
93
+ "@nx/nx-win32-arm64-msvc": "20.7.0-canary.20250321-cad4d26",
94
+ "@nx/nx-win32-x64-msvc": "20.7.0-canary.20250321-cad4d26"
95
95
  },
96
96
  "nx-migrations": {
97
97
  "migrations": "./migrations.json",
@@ -25,3 +25,4 @@ export * from './project-graph/error-types';
25
25
  export { registerTsProject } from './plugins/js/utils/register';
26
26
  export { interpolate } from './tasks-runner/utils';
27
27
  export { isCI } from './utils/is-ci';
28
+ export { isUsingPrettierInTree } from './utils/is-using-prettier';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCI = exports.interpolate = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
3
+ exports.isUsingPrettierInTree = exports.isCI = exports.interpolate = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /**
6
6
  * Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
@@ -53,3 +53,5 @@ var utils_1 = require("./tasks-runner/utils");
53
53
  Object.defineProperty(exports, "interpolate", { enumerable: true, get: function () { return utils_1.interpolate; } });
54
54
  var is_ci_1 = require("./utils/is-ci");
55
55
  Object.defineProperty(exports, "isCI", { enumerable: true, get: function () { return is_ci_1.isCI; } });
56
+ var is_using_prettier_1 = require("./utils/is-using-prettier");
57
+ Object.defineProperty(exports, "isUsingPrettierInTree", { enumerable: true, get: function () { return is_using_prettier_1.isUsingPrettierInTree; } });
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatChangedFilesWithPrettierIfAvailable = formatChangedFilesWithPrettierIfAvailable;
4
4
  exports.formatFilesWithPrettierIfAvailable = formatFilesWithPrettierIfAvailable;
5
5
  const path = require("path");
6
+ const is_using_prettier_1 = require("../../utils/is-using-prettier");
6
7
  /**
7
8
  * Formats all the created or updated files using Prettier
8
9
  * @param tree - the file system tree
@@ -19,6 +20,13 @@ async function formatFilesWithPrettierIfAvailable(files, root, options) {
19
20
  let prettier;
20
21
  try {
21
22
  prettier = await Promise.resolve().then(() => require('prettier'));
23
+ /**
24
+ * Even after we discovered prettier in node_modules, we need to be sure that the user is intentionally using prettier
25
+ * before proceeding to format with it.
26
+ */
27
+ if (!(0, is_using_prettier_1.isUsingPrettier)(root)) {
28
+ return results;
29
+ }
22
30
  }
23
31
  catch { }
24
32
  if (!prettier) {
@@ -6,5 +6,9 @@ const tree_1 = require("../tree");
6
6
  * Creates a host for testing.
7
7
  */
8
8
  function createTree() {
9
- return new tree_1.FsTree('/virtual', false);
9
+ const tree = new tree_1.FsTree('/virtual', false);
10
+ // Allow prettier formatting to be applied to the tree for backwards compatibility within v20
11
+ // TODO: Decouple formatFiles and other formatting utilities from prettier to avoid this
12
+ tree.write('.prettierrc', '{}');
13
+ return tree;
10
14
  }
Binary file
@@ -134,8 +134,8 @@ class TaskOrchestrator {
134
134
  const shouldCopyOutputsFromCache =
135
135
  // No output files to restore
136
136
  !!outputs.length &&
137
- // Remote caches are restored to output dirs when applied
138
- !cachedResult.remote &&
137
+ // Remote caches are restored to output dirs when applied and using db cache
138
+ (!cachedResult.remote || !(0, cache_1.dbCacheEnabled)(this.nxJson)) &&
139
139
  // Output files have not been touched since last run
140
140
  (await this.shouldCopyOutputsFromCache(outputs, task.hash));
141
141
  if (shouldCopyOutputsFromCache) {
@@ -0,0 +1,3 @@
1
+ import type { Tree } from '../generators/tree';
2
+ export declare function isUsingPrettier(root: string): boolean;
3
+ export declare function isUsingPrettierInTree(tree: Tree): boolean;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUsingPrettier = isUsingPrettier;
4
+ exports.isUsingPrettierInTree = isUsingPrettierInTree;
5
+ const node_fs_1 = require("node:fs");
6
+ const node_path_1 = require("node:path");
7
+ const json_1 = require("../generators/utils/json");
8
+ const fileutils_1 = require("./fileutils");
9
+ /**
10
+ * Possible configuration files are taken from https://prettier.io/docs/configuration
11
+ */
12
+ const configFiles = [
13
+ '.prettierrc',
14
+ '.prettierrc.json',
15
+ '.prettierrc.yml',
16
+ '.prettierrc.yaml',
17
+ '.prettierrc.json5',
18
+ '.prettierrc.js',
19
+ 'prettier.config.js',
20
+ '.prettierrc.ts',
21
+ 'prettier.config.ts',
22
+ '.prettierrc.mjs',
23
+ 'prettier.config.mjs',
24
+ '.prettierrc.mts',
25
+ 'prettier.config.mts',
26
+ '.prettierrc.cjs',
27
+ 'prettier.config.cjs',
28
+ '.prettierrc.cts',
29
+ 'prettier.config.cts',
30
+ '.prettierrc.toml',
31
+ ];
32
+ function isUsingPrettier(root) {
33
+ for (const file of configFiles) {
34
+ if ((0, node_fs_1.existsSync)(file)) {
35
+ return true;
36
+ }
37
+ }
38
+ // Even if no file is present, it is possible the user is configuring prettier via their package.json
39
+ const packageJsonPath = (0, node_path_1.join)(root, 'package.json');
40
+ if ((0, node_fs_1.existsSync)(packageJsonPath)) {
41
+ const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
42
+ if (packageJson.prettier) {
43
+ return true;
44
+ }
45
+ }
46
+ return false;
47
+ }
48
+ function isUsingPrettierInTree(tree) {
49
+ for (const file of configFiles) {
50
+ if (tree.exists(file)) {
51
+ return true;
52
+ }
53
+ }
54
+ // Even if no file is present, it is possible the user is configuring prettier via their package.json
55
+ if (tree.exists('package.json')) {
56
+ const packageJson = (0, json_1.readJson)(tree, 'package.json');
57
+ if (packageJson.prettier) {
58
+ return true;
59
+ }
60
+ }
61
+ return false;
62
+ }