nx 19.0.6 → 19.0.8

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.
@@ -2,7 +2,7 @@ const { join, basename } = require('path');
2
2
  const { copyFileSync, existsSync, mkdirSync } = require('fs');
3
3
  const Module = require('module');
4
4
  const { nxVersion } = require('../utils/versions');
5
- const { nativeFileCacheLocation } = require('./native-file-cache-location');
5
+ const { getNativeFileCacheLocation } = require('./native-file-cache-location');
6
6
 
7
7
  const nxPackages = new Set([
8
8
  '@nx/nx-android-arm64',
@@ -54,6 +54,7 @@ Module._load = function (request, parent, isMain) {
54
54
  const fileName = basename(nativeLocation);
55
55
 
56
56
  // we copy the file to a workspace-scoped tmp directory and prefix with nxVersion to avoid stale files being loaded
57
+ const nativeFileCacheLocation = getNativeFileCacheLocation();
57
58
  const tmpFile = join(nativeFileCacheLocation, nxVersion + '-' + fileName);
58
59
  if (existsSync(tmpFile)) {
59
60
  return originalLoad.apply(this, [tmpFile, parent, isMain]);
@@ -1 +1 @@
1
- export declare const nativeFileCacheLocation: string;
1
+ export declare function getNativeFileCacheLocation(): string;
@@ -1,8 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nativeFileCacheLocation = void 0;
3
+ exports.getNativeFileCacheLocation = void 0;
4
4
  const os_1 = require("os");
5
5
  const path_1 = require("path");
6
6
  const crypto_1 = require("crypto");
7
7
  const workspace_root_1 = require("../utils/workspace-root");
8
- exports.nativeFileCacheLocation = (0, path_1.join)((0, os_1.tmpdir)(), 'nx-native-file-cache', (0, crypto_1.createHash)('sha256').update(workspace_root_1.workspaceRoot).digest('hex'));
8
+ function getNativeFileCacheLocation() {
9
+ if (process.env.NX_NATIVE_FILE_CACHE_DIRECTORY) {
10
+ return process.env.NX_NATIVE_FILE_CACHE_DIRECTORY;
11
+ }
12
+ else {
13
+ const shortHash = (0, crypto_1.createHash)('sha256')
14
+ .update((0, os_1.userInfo)().username)
15
+ .update(workspace_root_1.workspaceRoot)
16
+ .digest('hex')
17
+ .substring(0, 7);
18
+ return (0, path_1.join)((0, os_1.tmpdir)(), `nx-native-file-cache-${shortHash}`);
19
+ }
20
+ }
21
+ exports.getNativeFileCacheLocation = getNativeFileCacheLocation;
@@ -16,7 +16,7 @@ function loadPnpmHoistedDepsDefinition() {
16
16
  const fullPath = `${workspace_root_1.workspaceRoot}/node_modules/.modules.yaml`;
17
17
  if ((0, fs_1.existsSync)(fullPath)) {
18
18
  const content = (0, fs_1.readFileSync)(fullPath, 'utf-8');
19
- const { load } = require('js-yaml');
19
+ const { load } = require('@zkochan/js-yaml');
20
20
  return load(content)?.hoistedDependencies ?? {};
21
21
  }
22
22
  else {
@@ -32,7 +32,7 @@ exports.loadPnpmHoistedDepsDefinition = loadPnpmHoistedDepsDefinition;
32
32
  * https://github.com/pnpm/pnpm/blob/af3e5559d377870d4c3d303429b3ed1a4e64fedc/lockfile/lockfile-file/src/read.ts#L91
33
33
  */
34
34
  function parseAndNormalizePnpmLockfile(content) {
35
- const { load } = require('js-yaml');
35
+ const { load } = require('@zkochan/js-yaml');
36
36
  const lockFileData = load(content);
37
37
  return revertFromInlineSpecifiersFormatIfNecessary(convertFromLockfileFileMutable(lockFileData));
38
38
  }
@@ -77,7 +77,7 @@ function stringifyToPnpmYaml(lockfile) {
77
77
  const adaptedLockfile = isLockfileV6
78
78
  ? convertToInlineSpecifiersFormat(lockfile)
79
79
  : lockfile;
80
- const { dump } = require('js-yaml');
80
+ const { dump } = require('@zkochan/js-yaml');
81
81
  return dump(sortLockfileKeys(normalizeLockfile(adaptedLockfile, isLockfileV6)), LOCKFILE_YAML_FORMAT);
82
82
  }
83
83
  exports.stringifyToPnpmYaml = stringifyToPnpmYaml;
@@ -277,6 +277,10 @@ plugins) {
277
277
  sourceInfo[0] = result[symbols_1.OVERRIDE_SOURCE_FILE];
278
278
  }
279
279
  for (const node in projectNodes) {
280
+ // Handles `{projects: {'libs/foo': undefined}}`.
281
+ if (!projectNodes[node]) {
282
+ continue;
283
+ }
280
284
  const project = {
281
285
  root: node,
282
286
  ...projectNodes[node],
@@ -35,7 +35,7 @@ exports.readJsonFile = readJsonFile;
35
35
  */
36
36
  function readYamlFile(path, options) {
37
37
  const content = (0, fs_1.readFileSync)(path, 'utf-8');
38
- const { load } = require('js-yaml');
38
+ const { load } = require('@zkochan/js-yaml');
39
39
  return load(content, { ...options, filename: path });
40
40
  }
41
41
  exports.readYamlFile = readYamlFile;
@@ -1,4 +1,5 @@
1
1
  import { InputDefinition, TargetConfiguration } from '../config/workspace-json-project-json';
2
+ import { PackageManagerCommands } from './package-manager';
2
3
  export interface NxProjectPackageJsonConfiguration {
3
4
  implicitDependencies?: string[];
4
5
  tags?: string[];
@@ -65,7 +66,7 @@ export declare function normalizePackageGroup(packageGroup: PackageGroup): Array
65
66
  export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigrationsConfiguration & {
66
67
  packageGroup?: ArrayPackageGroup;
67
68
  };
68
- export declare function buildTargetFromScript(script: string, scripts?: Record<string, string>): TargetConfiguration;
69
+ export declare function buildTargetFromScript(script: string, scripts: Record<string, string>, packageManagerCommand: PackageManagerCommands): TargetConfiguration;
69
70
  export declare function readTargetsFromPackageJson(packageJson: PackageJson): Record<string, TargetConfiguration<any>>;
70
71
  /**
71
72
  * Uses `require.resolve` to read the package.json for a module.
@@ -39,8 +39,7 @@ function readNxMigrateConfig(json) {
39
39
  };
40
40
  }
41
41
  exports.readNxMigrateConfig = readNxMigrateConfig;
42
- function buildTargetFromScript(script, scripts = {}) {
43
- const packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)();
42
+ function buildTargetFromScript(script, scripts = {}, packageManagerCommand) {
44
43
  return {
45
44
  executor: 'nx:run-script',
46
45
  options: {
@@ -53,13 +52,14 @@ function buildTargetFromScript(script, scripts = {}) {
53
52
  };
54
53
  }
55
54
  exports.buildTargetFromScript = buildTargetFromScript;
55
+ let packageManagerCommand;
56
56
  function readTargetsFromPackageJson(packageJson) {
57
57
  const { scripts, nx, private: isPrivate } = packageJson ?? {};
58
58
  const res = {};
59
59
  const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
60
- //
60
+ packageManagerCommand ??= (0, package_manager_1.getPackageManagerCommand)();
61
61
  for (const script of includedScripts) {
62
- res[script] = buildTargetFromScript(script, scripts);
62
+ res[script] = buildTargetFromScript(script, scripts, packageManagerCommand);
63
63
  }
64
64
  for (const targetName in nx?.targets) {
65
65
  res[targetName] = (0, project_configuration_utils_1.mergeTargetConfigurations)(nx?.targets[targetName], res[targetName]);