@nx/workspace 22.7.0-beta.1 → 22.7.0-beta.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.
@@ -0,0 +1,111 @@
1
+ const path = require('path');
2
+
3
+ const prettierDir = path.dirname(
4
+ require.resolve('prettier', {
5
+ paths: [path.join(__dirname, '../../../node_modules')],
6
+ })
7
+ );
8
+
9
+ // Load standalone prettier (no dynamic imports)
10
+ const standalone = require(path.join(prettierDir, 'standalone.js'));
11
+
12
+ // Pre-load CJS parser plugins (no dynamic imports)
13
+ const pluginNames = [
14
+ 'babel',
15
+ 'estree',
16
+ 'typescript',
17
+ 'html',
18
+ 'postcss',
19
+ 'markdown',
20
+ 'angular',
21
+ 'yaml',
22
+ ];
23
+ const plugins = pluginNames.map((name) =>
24
+ require(path.join(prettierDir, 'plugins', `${name}.js`))
25
+ );
26
+
27
+ const prettierMock = {
28
+ ...standalone,
29
+ resolveConfig: async () => null,
30
+ resolveConfigFile: async () => null,
31
+ clearConfigCache: () => {},
32
+ getFileInfo: async (filePath) => {
33
+ const ext = path.extname(filePath);
34
+ const parserMap = {
35
+ '.ts': 'typescript',
36
+ '.tsx': 'typescript',
37
+ '.js': 'babel',
38
+ '.jsx': 'babel',
39
+ '.mjs': 'babel',
40
+ '.cjs': 'babel',
41
+ '.json': 'json',
42
+ '.css': 'css',
43
+ '.scss': 'scss',
44
+ '.less': 'less',
45
+ '.html': 'html',
46
+ '.md': 'markdown',
47
+ '.yaml': 'yaml',
48
+ '.yml': 'yaml',
49
+ };
50
+ return { ignored: false, inferredParser: parserMap[ext] || null };
51
+ },
52
+ async format(source, options = {}) {
53
+ try {
54
+ return await standalone.format(source, {
55
+ ...options,
56
+ plugins: [...plugins, ...(options.plugins || [])],
57
+ });
58
+ } catch (e) {
59
+ return source;
60
+ }
61
+ },
62
+ async check(source, options = {}) {
63
+ try {
64
+ return await standalone.check(source, {
65
+ ...options,
66
+ plugins: [...plugins, ...(options.plugins || [])],
67
+ });
68
+ } catch (e) {
69
+ return true;
70
+ }
71
+ },
72
+ async formatWithCursor(source, options = {}) {
73
+ try {
74
+ return await standalone.formatWithCursor(source, {
75
+ ...options,
76
+ plugins: [...plugins, ...(options.plugins || [])],
77
+ });
78
+ } catch (e) {
79
+ return { formatted: source, cursorOffset: options.cursorOffset || 0 };
80
+ }
81
+ },
82
+ };
83
+
84
+ const handler = {
85
+ get(target, prop) {
86
+ if (prop === '__esModule') return true;
87
+ if (prop === 'default') return prettierMock;
88
+ return prettierMock[prop];
89
+ },
90
+ has(target, prop) {
91
+ return prop === '__esModule' || prop === 'default' || prop in prettierMock;
92
+ },
93
+ ownKeys() {
94
+ return [...Object.keys(prettierMock), '__esModule', 'default'];
95
+ },
96
+ getOwnPropertyDescriptor(target, prop) {
97
+ if (prop === '__esModule')
98
+ return { configurable: true, enumerable: true, value: true };
99
+ if (prop === 'default')
100
+ return { configurable: true, enumerable: true, value: prettierMock };
101
+ if (prop in prettierMock)
102
+ return {
103
+ configurable: true,
104
+ enumerable: true,
105
+ value: prettierMock[prop],
106
+ };
107
+ return undefined;
108
+ },
109
+ };
110
+
111
+ module.exports = new Proxy({}, handler);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/workspace",
3
- "version": "22.7.0-beta.1",
3
+ "version": "22.7.0-beta.2",
4
4
  "private": false,
5
5
  "description": "The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "@nx/devkit": "22.7.0-beta.1",
41
+ "@nx/devkit": "22.7.0-beta.2",
42
42
  "@zkochan/js-yaml": "0.0.7",
43
43
  "chalk": "^4.1.0",
44
44
  "enquirer": "~2.3.6",
@@ -46,10 +46,10 @@
46
46
  "semver": "^7.6.3",
47
47
  "tslib": "^2.3.0",
48
48
  "yargs-parser": "21.1.1",
49
- "nx": "22.7.0-beta.1"
49
+ "nx": "22.7.0-beta.2"
50
50
  },
51
51
  "devDependencies": {
52
- "nx": "22.7.0-beta.1"
52
+ "nx": "22.7.0-beta.2"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateCypressConfig = updateCypressConfig;
4
- const path = require("path");
4
+ const tslib_1 = require("tslib");
5
+ const path = tslib_1.__importStar(require("path"));
5
6
  /**
6
7
  * Updates the videos and screenshots folders in the cypress.json/cypress.config.ts if it exists (i.e. we're moving an e2e project)
7
8
  *
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updatePackageJson = updatePackageJson;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const path = require("path");
6
+ const path = tslib_1.__importStar(require("path"));
6
7
  /**
7
8
  * Updates the name in the package.json if it exists.
8
9
  *
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateProjectRootFiles = updateProjectRootFiles;
4
4
  exports.updateFilesForRootProjects = updateFilesForRootProjects;
5
5
  exports.updateFilesForNonRootProjects = updateFilesForNonRootProjects;
6
+ const tslib_1 = require("tslib");
6
7
  const devkit_1 = require("@nx/devkit");
7
- const path = require("path");
8
+ const path = tslib_1.__importStar(require("path"));
8
9
  const path_1 = require("path");
9
10
  const allowedExt = ['.ts', '.js', '.json', '.cts', '.cjs'];
10
11
  /**
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateStorybookConfig = updateStorybookConfig;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const path = require("path");
6
+ const path = tslib_1.__importStar(require("path"));
6
7
  const path_1 = require("path");
7
8
  /**
8
9
  * Updates relative path to root storybook config for `main.js` & `webpack.config.js`
@@ -2,12 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addPresetDependencies = addPresetDependencies;
4
4
  exports.generatePreset = generatePreset;
5
+ const tslib_1 = require("tslib");
5
6
  const devkit_1 = require("@nx/devkit");
6
7
  const presets_1 = require("../utils/presets");
7
8
  const versions_1 = require("../../utils/versions");
8
9
  const get_npm_package_version_1 = require("../utils/get-npm-package-version");
9
10
  const path_1 = require("path");
10
- const yargsParser = require("yargs-parser");
11
+ const yargs_parser_1 = tslib_1.__importDefault(require("yargs-parser"));
11
12
  const child_process_1 = require("child_process");
12
13
  const installation_directory_1 = require("nx/src/utils/installation-directory");
13
14
  function addPresetDependencies(host, options) {
@@ -15,7 +16,7 @@ function addPresetDependencies(host, options) {
15
16
  return (0, devkit_1.addDependenciesToPackageJson)(host, dependencies, dev, (0, path_1.join)(options.directory, 'package.json'));
16
17
  }
17
18
  function generatePreset(host, opts) {
18
- const parsedArgs = yargsParser(process.argv, {
19
+ const parsedArgs = (0, yargs_parser_1.default)(process.argv, {
19
20
  boolean: ['interactive'],
20
21
  default: {
21
22
  interactive: true,
@@ -21,7 +21,7 @@ async function newGenerator(tree, opts) {
21
21
  (0, child_process_1.execSync)(pmc.preInstall, {
22
22
  cwd: (0, devkit_1.joinPathFragments)(tree.root, options.directory),
23
23
  stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
24
- windowsHide: false,
24
+ windowsHide: true,
25
25
  });
26
26
  }
27
27
  (0, devkit_1.installPackagesTask)(tree, false, options.directory, options.packageManager);
@@ -16,7 +16,7 @@ function getNpmPackageVersion(packageName, packageVersion) {
16
16
  const npmBin = process.platform === 'win32' ? 'npm.cmd' : 'npm';
17
17
  const version = require('child_process').execFileSync(npmBin, ['view', packageSpec, 'version', '--json'], {
18
18
  stdio: ['pipe', 'pipe', 'ignore'],
19
- windowsHide: false,
19
+ windowsHide: true,
20
20
  });
21
21
  if (version) {
22
22
  // package@1.12 => ["1.12.0", "1.12.1"]
@@ -6,7 +6,7 @@ function deduceDefaultBase() {
6
6
  const nxDefaultBase = 'main';
7
7
  try {
8
8
  return ((0, child_process_1.execSync)('git config --get init.defaultBranch', {
9
- windowsHide: false,
9
+ windowsHide: true,
10
10
  })
11
11
  .toString()
12
12
  .trim() || nxDefaultBase);
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.output = void 0;
4
- const chalk = require("chalk");
4
+ const tslib_1 = require("tslib");
5
+ const chalk = tslib_1.__importStar(require("chalk"));
5
6
  /**
6
7
  * Automatically disable styling applied by chalk if CI=true
7
8
  */