@nx/js 23.1.0-beta.5 → 23.1.0-beta.6
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/dist/src/utils/prettier.js +17 -13
- package/package.json +4 -4
|
@@ -5,14 +5,23 @@ exports.generatePrettierSetup = generatePrettierSetup;
|
|
|
5
5
|
exports.resolvePrettierConfigPath = resolvePrettierConfigPath;
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const versions_1 = require("./versions");
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// Prettier v3 (ESM) exposes its API as named exports; v2 (CJS) exposes it under
|
|
9
|
+
// `.default` when loaded via `import()`. Return whichever carries the API, or
|
|
10
|
+
// null if prettier isn't installed.
|
|
11
|
+
async function importPrettier() {
|
|
10
12
|
try {
|
|
11
|
-
|
|
13
|
+
const imported = await import('prettier');
|
|
14
|
+
return (imported.resolveConfig ? imported : imported.default);
|
|
12
15
|
}
|
|
13
16
|
catch {
|
|
14
17
|
return null;
|
|
15
18
|
}
|
|
19
|
+
}
|
|
20
|
+
async function resolveUserExistingPrettierConfig() {
|
|
21
|
+
const prettier = await importPrettier();
|
|
22
|
+
if (!prettier) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
16
25
|
try {
|
|
17
26
|
const filepath = await prettier.resolveConfigFile();
|
|
18
27
|
if (!filepath) {
|
|
@@ -76,18 +85,13 @@ function generatePrettierSetup(tree, options) {
|
|
|
76
85
|
: (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { prettier: versions_1.prettierVersion });
|
|
77
86
|
}
|
|
78
87
|
async function resolvePrettierConfigPath(tree) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
prettier = await import('prettier');
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
88
|
+
const prettier = await importPrettier();
|
|
89
|
+
if (!prettier) {
|
|
84
90
|
return null;
|
|
85
91
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return filePath;
|
|
90
|
-
}
|
|
92
|
+
const configFilePath = await prettier.resolveConfigFile();
|
|
93
|
+
if (configFilePath) {
|
|
94
|
+
return configFilePath;
|
|
91
95
|
}
|
|
92
96
|
if (!tree) {
|
|
93
97
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "23.1.0-beta.
|
|
3
|
+
"version": "23.1.0-beta.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -144,11 +144,11 @@
|
|
|
144
144
|
"source-map-support": "0.5.19",
|
|
145
145
|
"tinyglobby": "^0.2.12",
|
|
146
146
|
"tslib": "^2.3.0",
|
|
147
|
-
"@nx/devkit": "23.1.0-beta.
|
|
148
|
-
"@nx/workspace": "23.1.0-beta.
|
|
147
|
+
"@nx/devkit": "23.1.0-beta.6",
|
|
148
|
+
"@nx/workspace": "23.1.0-beta.6"
|
|
149
149
|
},
|
|
150
150
|
"devDependencies": {
|
|
151
|
-
"nx": "23.1.0-beta.
|
|
151
|
+
"nx": "23.1.0-beta.6"
|
|
152
152
|
},
|
|
153
153
|
"peerDependencies": {
|
|
154
154
|
"@swc/cli": ">=0.6.0 <0.9.0",
|