@nx/workspace 22.7.0-pr.35019.f500fd7 → 22.7.0-rc.0

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/assets.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "outDir": "dist/packages/workspace",
3
+ "assets": [
4
+ {
5
+ "glob": "**/files/**"
6
+ },
7
+ {
8
+ "glob": "**/files/**/.gitkeep"
9
+ },
10
+ {
11
+ "glob": "**/files-integrated-repo/**"
12
+ },
13
+ {
14
+ "glob": "**/files-integrated-repo/**/.gitkeep"
15
+ },
16
+ {
17
+ "glob": "**/files-package-based-repo/**"
18
+ },
19
+ {
20
+ "glob": "**/files-readme/**"
21
+ },
22
+ {
23
+ "glob": "**/files-root-app/**"
24
+ },
25
+ { "glob": "presets/*.json" },
26
+ { "glob": "package.json" },
27
+ { "glob": "executors.json" },
28
+ { "glob": "generators.json" },
29
+ { "glob": "migrations.json" },
30
+ { "glob": "src/**/schema.json" },
31
+ {
32
+ "glob": "src/**/schema.d.ts"
33
+ },
34
+ "LICENSE"
35
+ ]
36
+ }
package/executors.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
- "executors": {
3
- "counter": {
4
- "implementation": "./src/executors/counter/counter.impl",
5
- "batchImplementation": "./src/executors/counter/counter.impl#batchCounter",
6
- "schema": "./src/executors/counter/schema.json",
7
- "description": "A dummy executor useful for E2E tests.",
8
- "hidden": true
2
+ "executors": {
3
+ "counter": {
4
+ "implementation": "./src/executors/counter/counter.impl",
5
+ "batchImplementation": "./src/executors/counter/counter.impl#batchCounter",
6
+ "schema": "./src/executors/counter/schema.json",
7
+ "description": "A dummy executor useful for E2E tests.",
8
+ "hidden": true
9
+ }
9
10
  }
10
- }
11
11
  }
package/generators.json CHANGED
@@ -1,64 +1,64 @@
1
1
  {
2
- "name": "nx/workspace",
3
- "version": "0.1",
4
- "generators": {
5
- "preset": {
6
- "factory": "./src/generators/preset/preset#presetGenerator",
7
- "schema": "./src/generators/preset/schema.json",
8
- "description": "Create application in an empty workspace.",
9
- "x-use-standalone-layout": true,
10
- "hidden": true
11
- },
12
- "move": {
13
- "factory": "./src/generators/move/move",
14
- "schema": "./src/generators/move/schema.json",
15
- "aliases": ["mv"],
16
- "description": "Move an application or library to another folder."
17
- },
18
- "remove": {
19
- "factory": "./src/generators/remove/remove#removeGenerator",
20
- "schema": "./src/generators/remove/schema.json",
21
- "aliases": ["rm"],
22
- "description": "Remove an application or library."
23
- },
24
- "convert-to-monorepo": {
25
- "factory": "./src/generators/convert-to-monorepo/convert-to-monorepo",
26
- "schema": "./src/generators/convert-to-monorepo/schema.json",
27
- "description": "Convert a Nx project to a monorepo."
28
- },
29
- "new": {
30
- "factory": "./src/generators/new/new#newGenerator",
31
- "schema": "./src/generators/new/schema.json",
32
- "description": "Create a workspace.",
33
- "hidden": true
34
- },
35
- "run-commands": {
36
- "factory": "./src/generators/run-commands/run-commands#runCommandsGenerator",
37
- "schema": "./src/generators/run-commands/schema.json",
38
- "aliases": ["run-command", "target"],
39
- "description": "Generates a target to run any command in the terminal."
40
- },
41
- "fix-configuration": {
42
- "factory": "./src/generators/convert-to-nx-project/convert-to-nx-project#convertToNxProjectGenerator",
43
- "schema": "./src/generators/convert-to-nx-project/schema.json",
44
- "aliases": ["convert-to-nx-project"],
45
- "description": "Fixes projects configuration"
46
- },
47
- "npm-package": {
48
- "factory": "./src/generators/npm-package/npm-package#npmPackageGenerator",
49
- "schema": "./src/generators/npm-package/schema.json",
50
- "description": "Create a minimal NPM package.",
51
- "x-type": "library"
52
- },
53
- "ci-workflow": {
54
- "factory": "./src/generators/ci-workflow/ci-workflow#ciWorkflowGenerator",
55
- "schema": "./src/generators/ci-workflow/schema.json",
56
- "description": "Generate a CI workflow."
57
- },
58
- "infer-targets": {
59
- "factory": "./src/generators/infer-targets/infer-targets",
60
- "schema": "./src/generators/infer-targets/schema.json",
61
- "description": "Convert Nx projects to use inferred targets."
2
+ "name": "nx/workspace",
3
+ "version": "0.1",
4
+ "generators": {
5
+ "preset": {
6
+ "factory": "./src/generators/preset/preset#presetGenerator",
7
+ "schema": "./src/generators/preset/schema.json",
8
+ "description": "Create application in an empty workspace.",
9
+ "x-use-standalone-layout": true,
10
+ "hidden": true
11
+ },
12
+ "move": {
13
+ "factory": "./src/generators/move/move",
14
+ "schema": "./src/generators/move/schema.json",
15
+ "aliases": ["mv"],
16
+ "description": "Move an application or library to another folder."
17
+ },
18
+ "remove": {
19
+ "factory": "./src/generators/remove/remove#removeGenerator",
20
+ "schema": "./src/generators/remove/schema.json",
21
+ "aliases": ["rm"],
22
+ "description": "Remove an application or library."
23
+ },
24
+ "convert-to-monorepo": {
25
+ "factory": "./src/generators/convert-to-monorepo/convert-to-monorepo",
26
+ "schema": "./src/generators/convert-to-monorepo/schema.json",
27
+ "description": "Convert a Nx project to a monorepo."
28
+ },
29
+ "new": {
30
+ "factory": "./src/generators/new/new#newGenerator",
31
+ "schema": "./src/generators/new/schema.json",
32
+ "description": "Create a workspace.",
33
+ "hidden": true
34
+ },
35
+ "run-commands": {
36
+ "factory": "./src/generators/run-commands/run-commands#runCommandsGenerator",
37
+ "schema": "./src/generators/run-commands/schema.json",
38
+ "aliases": ["run-command", "target"],
39
+ "description": "Generates a target to run any command in the terminal."
40
+ },
41
+ "fix-configuration": {
42
+ "factory": "./src/generators/convert-to-nx-project/convert-to-nx-project#convertToNxProjectGenerator",
43
+ "schema": "./src/generators/convert-to-nx-project/schema.json",
44
+ "aliases": ["convert-to-nx-project"],
45
+ "description": "Fixes projects configuration"
46
+ },
47
+ "npm-package": {
48
+ "factory": "./src/generators/npm-package/npm-package#npmPackageGenerator",
49
+ "schema": "./src/generators/npm-package/schema.json",
50
+ "description": "Create a minimal NPM package.",
51
+ "x-type": "library"
52
+ },
53
+ "ci-workflow": {
54
+ "factory": "./src/generators/ci-workflow/ci-workflow#ciWorkflowGenerator",
55
+ "schema": "./src/generators/ci-workflow/schema.json",
56
+ "description": "Generate a CI workflow."
57
+ },
58
+ "infer-targets": {
59
+ "factory": "./src/generators/infer-targets/infer-targets",
60
+ "schema": "./src/generators/infer-targets/schema.json",
61
+ "description": "Convert Nx projects to use inferred targets."
62
+ }
62
63
  }
63
- }
64
64
  }
package/migrations.json CHANGED
@@ -1,57 +1,57 @@
1
1
  {
2
- "generators": {},
3
- "packageJsonUpdates": {
4
- "20.2.0": {
5
- "version": "20.2.0-beta.5",
6
- "x-prompt": "Do you want to update to TypeScript v5.6?",
7
- "requires": {
8
- "typescript": ">=5.5.0 <5.6.0"
9
- },
10
- "packages": {
11
- "typescript": {
12
- "version": "~5.6.2",
13
- "alwaysAddToPackageJson": false
2
+ "generators": {},
3
+ "packageJsonUpdates": {
4
+ "20.2.0": {
5
+ "version": "20.2.0-beta.5",
6
+ "x-prompt": "Do you want to update to TypeScript v5.6?",
7
+ "requires": {
8
+ "typescript": ">=5.5.0 <5.6.0"
9
+ },
10
+ "packages": {
11
+ "typescript": {
12
+ "version": "~5.6.2",
13
+ "alwaysAddToPackageJson": false
14
+ }
15
+ }
16
+ },
17
+ "20.4.0": {
18
+ "version": "20.4.0-beta.1",
19
+ "x-prompt": "Do you want to update to TypeScript v5.7?",
20
+ "requires": {
21
+ "typescript": ">=5.6.0 <5.7.0"
22
+ },
23
+ "packages": {
24
+ "typescript": {
25
+ "version": "~5.7.2",
26
+ "alwaysAddToPackageJson": false
27
+ }
28
+ }
29
+ },
30
+ "21.2.0": {
31
+ "version": "21.2.0-beta.0",
32
+ "x-prompt": "Do you want to update to TypeScript v5.8?",
33
+ "requires": {
34
+ "typescript": ">=5.7.0 <5.8.0"
35
+ },
36
+ "packages": {
37
+ "typescript": {
38
+ "version": "~5.8.2",
39
+ "alwaysAddToPackageJson": false
40
+ }
41
+ }
42
+ },
43
+ "21.5.0": {
44
+ "version": "21.5.0-beta.2",
45
+ "x-prompt": "Do you want to update to TypeScript v5.9?",
46
+ "requires": {
47
+ "typescript": ">=5.8.0 <5.9.0"
48
+ },
49
+ "packages": {
50
+ "typescript": {
51
+ "version": "~5.9.2",
52
+ "alwaysAddToPackageJson": false
53
+ }
54
+ }
14
55
  }
15
- }
16
- },
17
- "20.4.0": {
18
- "version": "20.4.0-beta.1",
19
- "x-prompt": "Do you want to update to TypeScript v5.7?",
20
- "requires": {
21
- "typescript": ">=5.6.0 <5.7.0"
22
- },
23
- "packages": {
24
- "typescript": {
25
- "version": "~5.7.2",
26
- "alwaysAddToPackageJson": false
27
- }
28
- }
29
- },
30
- "21.2.0": {
31
- "version": "21.2.0-beta.0",
32
- "x-prompt": "Do you want to update to TypeScript v5.8?",
33
- "requires": {
34
- "typescript": ">=5.7.0 <5.8.0"
35
- },
36
- "packages": {
37
- "typescript": {
38
- "version": "~5.8.2",
39
- "alwaysAddToPackageJson": false
40
- }
41
- }
42
- },
43
- "21.5.0": {
44
- "version": "21.5.0-beta.2",
45
- "x-prompt": "Do you want to update to TypeScript v5.9?",
46
- "requires": {
47
- "typescript": ">=5.8.0 <5.9.0"
48
- },
49
- "packages": {
50
- "typescript": {
51
- "version": "~5.9.2",
52
- "alwaysAddToPackageJson": false
53
- }
54
- }
55
56
  }
56
- }
57
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/workspace",
3
- "version": "22.7.0-pr.35019.f500fd7",
3
+ "version": "22.7.0-rc.0",
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": {
@@ -20,7 +20,8 @@
20
20
  "CLI"
21
21
  ],
22
22
  "main": "./index.js",
23
- "typings": "./index.d.ts",
23
+ "type": "commonjs",
24
+ "types": "./index.d.ts",
24
25
  "author": "Victor Savkin",
25
26
  "license": "MIT",
26
27
  "bugs": {
@@ -38,22 +39,20 @@
38
39
  }
39
40
  },
40
41
  "dependencies": {
41
- "@nx/devkit": "22.7.0-pr.35019.f500fd7",
42
+ "@nx/devkit": "22.7.0-rc.0",
42
43
  "@zkochan/js-yaml": "0.0.7",
43
44
  "chalk": "^4.1.0",
44
45
  "enquirer": "~2.3.6",
45
- "picomatch": "4.0.2",
46
+ "picomatch": "4.0.4",
46
47
  "semver": "^7.6.3",
47
48
  "tslib": "^2.3.0",
48
49
  "yargs-parser": "21.1.1",
49
- "nx": "22.7.0-pr.35019.f500fd7"
50
+ "nx": "22.7.0-rc.0"
50
51
  },
51
52
  "devDependencies": {
52
- "nx": "22.7.0-pr.35019.f500fd7"
53
+ "nx": "22.7.0-rc.0"
53
54
  },
54
55
  "publishConfig": {
55
56
  "access": "public"
56
- },
57
- "types": "./index.d.ts",
58
- "type": "commonjs"
57
+ }
59
58
  }
package/project.json CHANGED
@@ -6,77 +6,8 @@
6
6
  "targets": {
7
7
  "build": {
8
8
  "outputs": ["{workspaceRoot}/dist/packages/workspace/README.md"],
9
- "command": "node ./scripts/copy-readme.js workspace"
10
- },
11
- "legacy-post-build": {
12
- "executor": "@nx/workspace-plugin:legacy-post-build",
13
- "options": {
14
- "tsConfig": "./tsconfig.lib.json",
15
- "assets": [
16
- {
17
- "input": "packages/workspace",
18
- "glob": "**/files/**",
19
- "output": "/"
20
- },
21
- {
22
- "input": "packages/workspace",
23
- "glob": "**/files/**/.gitkeep",
24
- "output": "/"
25
- },
26
- {
27
- "input": "packages/workspace",
28
- "glob": "**/files-integrated-repo/**",
29
- "output": "/"
30
- },
31
- {
32
- "input": "packages/workspace",
33
- "glob": "**/files-integrated-repo/**/.gitkeep",
34
- "output": "/"
35
- },
36
- {
37
- "input": "packages/workspace",
38
- "glob": "**/files-package-based-repo/**",
39
- "output": "/"
40
- },
41
- {
42
- "input": "packages/workspace",
43
- "glob": "**/files-readme/**",
44
- "output": "/"
45
- },
46
- {
47
- "glob": "**/files-packaged-based-repo/**/.gitkeep",
48
- "input": "packages/workspace",
49
- "output": "/"
50
- },
51
- {
52
- "input": "packages/workspace",
53
- "glob": "**/files-root-app/**",
54
- "output": "/"
55
- },
56
- {
57
- "input": "packages/workspace",
58
- "glob": "**/*.json",
59
- "ignore": ["**/tsconfig*.json", "project.json", ".eslintrc.json"],
60
- "output": "/"
61
- },
62
- {
63
- "input": "packages/workspace",
64
- "glob": "**/*.{js,css,html,svg}",
65
- "ignore": ["**/jest.config.js"],
66
- "output": "/"
67
- },
68
- {
69
- "input": "packages/workspace",
70
- "glob": "**/*.d.ts",
71
- "output": "/"
72
- },
73
- {
74
- "input": "",
75
- "glob": "LICENSE",
76
- "output": "/"
77
- }
78
- ]
79
- }
9
+ "command": "node ./scripts/copy-readme.js workspace",
10
+ "inputs": ["copyReadme"]
80
11
  },
81
12
  "add-extra-dependencies": {
82
13
  "command": "node ./scripts/add-dependency-to-build.js workspace nx"
@@ -48,7 +48,7 @@ jobs:
48
48
  - run: <%= packageManagerInstall %><% if(hasCypress){ %>
49
49
  - run: <%= packageManagerPrefix %> cypress install<% } %><% if(hasPlaywright){ %>
50
50
  - run: <%= packageManagerPrefix %> playwright install --with-deps<% } %><% if(!useRunMany){ %>
51
- - uses: nrwl/nx-set-shas@v4<% } %>
51
+ - uses: nrwl/nx-set-shas@v5<% } %>
52
52
 
53
53
  <% for (const command of commands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
54
54
  # <%- comment %><% } %><% } %><% if (command.command) { %>
@@ -35,12 +35,12 @@ function updateImports(tree, schema, project) {
35
35
  if (tree.exists(tsConfigPath)) {
36
36
  tsConfig = (0, devkit_1.readJson)(tree, tsConfigPath);
37
37
  const sourceRoot = (0, project_config_1.getProjectSourceRoot)(project, tree);
38
- mainEntryPointImportPath = Object.keys(tsConfig.compilerOptions?.paths ?? {}).find((path) => tsConfig.compilerOptions.paths[path].some((x) => x.startsWith(ensureTrailingSlash(sourceRoot))));
39
- secondaryEntryPointImportPaths = Object.keys(tsConfig.compilerOptions?.paths ?? {}).filter((path) => tsConfig.compilerOptions.paths[path].some((x) => x.startsWith(ensureTrailingSlash(project.root)) &&
40
- !x.startsWith(ensureTrailingSlash(sourceRoot))));
38
+ mainEntryPointImportPath = Object.keys(tsConfig.compilerOptions?.paths ?? {}).find((path) => tsConfig.compilerOptions.paths[path].some((x) => stripDotSlash(x).startsWith(ensureTrailingSlash(sourceRoot))));
39
+ secondaryEntryPointImportPaths = Object.keys(tsConfig.compilerOptions?.paths ?? {}).filter((path) => tsConfig.compilerOptions.paths[path].some((x) => stripDotSlash(x).startsWith(ensureTrailingSlash(project.root)) &&
40
+ !stripDotSlash(x).startsWith(ensureTrailingSlash(sourceRoot))));
41
41
  // Next.js libs have a custom path for the server we need to update that as well
42
42
  // example "paths": { @acme/lib/server : ['libs/lib/src/server.ts'] }
43
- serverEntryPointImportPath = Object.keys(tsConfig.compilerOptions?.paths ?? {}).find((path) => tsConfig.compilerOptions.paths[path].some((x) => x.startsWith(ensureTrailingSlash(sourceRoot)) &&
43
+ serverEntryPointImportPath = Object.keys(tsConfig.compilerOptions?.paths ?? {}).find((path) => tsConfig.compilerOptions.paths[path].some((x) => stripDotSlash(x).startsWith(ensureTrailingSlash(sourceRoot)) &&
44
44
  x.includes('server') &&
45
45
  path.endsWith('server')));
46
46
  }
@@ -130,7 +130,11 @@ function updateTsConfigPaths(tsConfig, projectRef, tsConfigPath, projectRoot, sc
130
130
  `${tsConfigPath} compilerOptions.paths`,
131
131
  ].join(' '));
132
132
  }
133
- const updatedPath = path.map((x) => (0, devkit_1.joinPathFragments)(projectRoot.to, (0, path_1.relative)(projectRoot.from, x)));
133
+ const updatedPath = path.map((x) => {
134
+ const hadDotSlash = x.startsWith('./');
135
+ const result = (0, devkit_1.joinPathFragments)(projectRoot.to, (0, path_1.relative)(projectRoot.from, stripDotSlash(x)));
136
+ return hadDotSlash && !result.startsWith('./') ? `./${result}` : result;
137
+ });
134
138
  if (schema.updateImportPath && projectRef.to) {
135
139
  tsConfig.compilerOptions.paths[projectRef.to] = updatedPath;
136
140
  if (projectRef.from !== projectRef.to) {
@@ -144,6 +148,9 @@ function updateTsConfigPaths(tsConfig, projectRef, tsConfigPath, projectRoot, sc
144
148
  function ensureTrailingSlash(path) {
145
149
  return path.endsWith('/') ? path : `${path}/`;
146
150
  }
151
+ function stripDotSlash(path) {
152
+ return path.startsWith('./') ? path.slice(2) : path;
153
+ }
147
154
  /**
148
155
  * Changes imports in a file from one import to another
149
156
  */
@@ -1 +1 @@
1
- {"version":3,"file":"jest-project.config.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/generators/remove/lib/__fixtures__/jest-project.config.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,wBAaE"}
1
+ {"version":3,"file":"jest-project.config.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/generators/remove/lib/__fixtures__/jest-project.config.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,wBAaE"}
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable */
4
3
  exports.default = {
5
4
  displayName: 'node-app',
6
5
  preset: './jest.preset.js',
@@ -1 +1 @@
1
- {"version":3,"file":"update-tsconfig.d.ts","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/remove/lib/update-tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,IAAI,EAEL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAQnC;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAsC9D"}
1
+ {"version":3,"file":"update-tsconfig.d.ts","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/remove/lib/update-tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,IAAI,EAEL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAQnC;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAoC9D"}
@@ -31,7 +31,8 @@ async function updateTsconfig(tree, schema) {
31
31
  else {
32
32
  for (const importPath in json.compilerOptions.paths) {
33
33
  for (const path of json.compilerOptions.paths[importPath]) {
34
- const project = (0, find_project_for_path_1.findProjectForPath)((0, devkit_1.normalizePath)(path), projectMapping);
34
+ const normalized = (0, devkit_1.normalizePath)(path).replace(/^\.\//, '');
35
+ const project = (0, find_project_for_path_1.findProjectForPath)(normalized, projectMapping);
35
36
  if (project === schema.projectName) {
36
37
  delete json.compilerOptions.paths[importPath];
37
38
  break;
@@ -1,111 +0,0 @@
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);