pnpm-settings-migrator 0.2.0 → 0.3.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/dist/cli.mjs +12 -22
- package/dist/index.d.mts +24 -2
- package/dist/index.mjs +15 -23
- package/package.json +16 -16
package/dist/cli.mjs
CHANGED
|
@@ -11,21 +11,15 @@ import { getColor } from "consola/utils";
|
|
|
11
11
|
import camelcaseKeys from "camelcase-keys";
|
|
12
12
|
import { readIniFile } from "read-ini-file";
|
|
13
13
|
import { kebabCase } from "uncase";
|
|
14
|
-
|
|
15
14
|
//#region package.json
|
|
16
15
|
var name = "pnpm-settings-migrator";
|
|
17
|
-
var version = "0.
|
|
18
|
-
|
|
16
|
+
var version = "0.3.0";
|
|
19
17
|
//#endregion
|
|
20
18
|
//#region src/constants.ts
|
|
21
19
|
const NPMRC = ".npmrc";
|
|
22
20
|
const PACKAGE_JSON = "package.json";
|
|
23
21
|
const PNPM_WORKSPACE_YAML = "pnpm-workspace.yaml";
|
|
24
22
|
/**
|
|
25
|
-
* Default indent: 2 spaces
|
|
26
|
-
*/
|
|
27
|
-
const DEFAULT_INDENT = 2;
|
|
28
|
-
/**
|
|
29
23
|
* @see {@link https://github.com/pnpm/pnpm/blob/main/packages/types/src/package.ts}
|
|
30
24
|
*/
|
|
31
25
|
const PNPM_SETTINGS_FIELDS = [
|
|
@@ -36,21 +30,26 @@ const PNPM_SETTINGS_FIELDS = [
|
|
|
36
30
|
"auditConfig",
|
|
37
31
|
"configDependencies",
|
|
38
32
|
"executionEnv",
|
|
33
|
+
"httpProxy",
|
|
34
|
+
"httpsProxy",
|
|
39
35
|
"ignoredBuiltDependencies",
|
|
40
36
|
"ignoredOptionalDependencies",
|
|
41
37
|
"ignorePatchFailures",
|
|
42
38
|
"neverBuiltDependencies",
|
|
39
|
+
"nodeDownloadMirrors",
|
|
40
|
+
"noProxy",
|
|
41
|
+
"npmrcAuthFile",
|
|
43
42
|
"onlyBuiltDependencies",
|
|
44
43
|
"onlyBuiltDependenciesFile",
|
|
45
44
|
"overrides",
|
|
46
45
|
"packageExtensions",
|
|
47
46
|
"patchedDependencies",
|
|
48
47
|
"peerDependencyRules",
|
|
48
|
+
"registries",
|
|
49
49
|
"requiredScripts",
|
|
50
50
|
"supportedArchitectures",
|
|
51
51
|
"updateConfig"
|
|
52
52
|
];
|
|
53
|
-
|
|
54
53
|
//#endregion
|
|
55
54
|
//#region src/options.ts
|
|
56
55
|
/**
|
|
@@ -107,7 +106,6 @@ function resolveStrategy(strategy) {
|
|
|
107
106
|
if (VALID_STRATEGIES.includes(strategy)) return strategy;
|
|
108
107
|
throw new Error(`Invalid strategy: ${strategy}. Expected one of: ${VALID_STRATEGIES.join(", ")}`);
|
|
109
108
|
}
|
|
110
|
-
|
|
111
109
|
//#endregion
|
|
112
110
|
//#region src/utils/fs.ts
|
|
113
111
|
/**
|
|
@@ -134,17 +132,13 @@ async function fsReadFile(path) {
|
|
|
134
132
|
async function fsWriteFile(path, content) {
|
|
135
133
|
await writeFile(path, `${content.trimEnd()}\n`, "utf-8");
|
|
136
134
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
//#region src/utils/color.ts
|
|
140
|
-
const cyan = getColor("cyan");
|
|
141
|
-
const yellow = getColor("yellow");
|
|
135
|
+
getColor("cyan");
|
|
136
|
+
getColor("yellow");
|
|
142
137
|
const dim = getColor("dim");
|
|
143
138
|
const green = getColor("green");
|
|
144
139
|
const red = getColor("red");
|
|
145
140
|
const bold = getColor("bold");
|
|
146
141
|
const magenta = getColor("magenta");
|
|
147
|
-
|
|
148
142
|
//#endregion
|
|
149
143
|
//#region src/utils/merge.ts
|
|
150
144
|
/**
|
|
@@ -220,7 +214,6 @@ function mergeWithArrayDedupe(existing, incoming) {
|
|
|
220
214
|
}
|
|
221
215
|
return result;
|
|
222
216
|
}
|
|
223
|
-
|
|
224
217
|
//#endregion
|
|
225
218
|
//#region src/utils/npmrc.ts
|
|
226
219
|
/**
|
|
@@ -267,7 +260,6 @@ async function pruneNpmrc(path) {
|
|
|
267
260
|
async function readNpmrc(path) {
|
|
268
261
|
return camelcaseKeys(await readIniFile(path));
|
|
269
262
|
}
|
|
270
|
-
|
|
271
263
|
//#endregion
|
|
272
264
|
//#region src/core.ts
|
|
273
265
|
/**
|
|
@@ -321,9 +313,9 @@ async function migratePnpmSettings(rawOptions = {}) {
|
|
|
321
313
|
consola.warn("No pnpm settings files to migrate");
|
|
322
314
|
return;
|
|
323
315
|
}
|
|
324
|
-
let packageJsonIndent =
|
|
316
|
+
let packageJsonIndent = 2;
|
|
325
317
|
let packageJsonObject = {};
|
|
326
|
-
let pnpmWorkspaceYamlIndent =
|
|
318
|
+
let pnpmWorkspaceYamlIndent = 2;
|
|
327
319
|
let pnpmWorkspaceYamlObject = {};
|
|
328
320
|
if (packageJsonExists) {
|
|
329
321
|
const content = await fsReadFile(packageJsonPath);
|
|
@@ -373,7 +365,6 @@ async function migratePnpmSettings(rawOptions = {}) {
|
|
|
373
365
|
throw err;
|
|
374
366
|
}
|
|
375
367
|
}
|
|
376
|
-
|
|
377
368
|
//#endregion
|
|
378
369
|
//#region src/cli.ts
|
|
379
370
|
const cli = cac(name);
|
|
@@ -391,6 +382,5 @@ cli.command("").action(async (options) => {
|
|
|
391
382
|
}
|
|
392
383
|
});
|
|
393
384
|
cli.parse();
|
|
394
|
-
|
|
395
385
|
//#endregion
|
|
396
|
-
export {
|
|
386
|
+
export {};
|
package/dist/index.d.mts
CHANGED
|
@@ -84,11 +84,33 @@ interface PackageJson {
|
|
|
84
84
|
* @pg
|
|
85
85
|
*/
|
|
86
86
|
type NpmRC = Record<string, any>;
|
|
87
|
+
/**
|
|
88
|
+
* Deprecated `pnpm` settings in `package.json`
|
|
89
|
+
* @see {@link https://github.com/pnpm/pnpm/blob/main/core/types/CHANGELOG.md#major-changes}
|
|
90
|
+
*/
|
|
91
|
+
interface PnpmSettingsDeprecated {
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated
|
|
94
|
+
*/
|
|
95
|
+
ignoredBuiltDependencies?: string[];
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated
|
|
98
|
+
*/
|
|
99
|
+
neverBuiltDependencies?: string[];
|
|
100
|
+
/**
|
|
101
|
+
* @deprecated
|
|
102
|
+
*/
|
|
103
|
+
onlyBuiltDependencies?: string[];
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated
|
|
106
|
+
*/
|
|
107
|
+
onlyBuiltDependenciesFile?: string;
|
|
108
|
+
}
|
|
87
109
|
/**
|
|
88
110
|
* `pnpm-workspace` types
|
|
89
111
|
* @pg
|
|
90
112
|
*/
|
|
91
|
-
type PnpmWorkspace = PnpmSettings & PnpmWorkspaceLegacy;
|
|
113
|
+
type PnpmWorkspace = PnpmSettings & PnpmSettingsDeprecated & PnpmWorkspaceLegacy;
|
|
92
114
|
//#endregion
|
|
93
115
|
//#region src/core.d.ts
|
|
94
116
|
/**
|
|
@@ -151,4 +173,4 @@ declare function migratePnpmSettings(rawOptions?: Options): Promise<void>;
|
|
|
151
173
|
*/
|
|
152
174
|
declare function resolveOptions(options?: Options): Required<Options>;
|
|
153
175
|
//#endregion
|
|
154
|
-
export { MergeStrategy, NpmRC, Options, PackageJson, PnpmWorkspace, PnpmWorkspaceLegacy, migratePnpmSettings, resolveOptions };
|
|
176
|
+
export { MergeStrategy, NpmRC, Options, PackageJson, PnpmSettingsDeprecated, PnpmWorkspace, PnpmWorkspaceLegacy, migratePnpmSettings, resolveOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -10,16 +10,11 @@ import { getColor } from "consola/utils";
|
|
|
10
10
|
import camelcaseKeys from "camelcase-keys";
|
|
11
11
|
import { readIniFile } from "read-ini-file";
|
|
12
12
|
import { kebabCase } from "uncase";
|
|
13
|
-
|
|
14
13
|
//#region src/constants.ts
|
|
15
14
|
const NPMRC = ".npmrc";
|
|
16
15
|
const PACKAGE_JSON = "package.json";
|
|
17
16
|
const PNPM_WORKSPACE_YAML = "pnpm-workspace.yaml";
|
|
18
17
|
/**
|
|
19
|
-
* Default indent: 2 spaces
|
|
20
|
-
*/
|
|
21
|
-
const DEFAULT_INDENT = 2;
|
|
22
|
-
/**
|
|
23
18
|
* @see {@link https://github.com/pnpm/pnpm/blob/main/packages/types/src/package.ts}
|
|
24
19
|
*/
|
|
25
20
|
const PNPM_SETTINGS_FIELDS = [
|
|
@@ -30,21 +25,26 @@ const PNPM_SETTINGS_FIELDS = [
|
|
|
30
25
|
"auditConfig",
|
|
31
26
|
"configDependencies",
|
|
32
27
|
"executionEnv",
|
|
28
|
+
"httpProxy",
|
|
29
|
+
"httpsProxy",
|
|
33
30
|
"ignoredBuiltDependencies",
|
|
34
31
|
"ignoredOptionalDependencies",
|
|
35
32
|
"ignorePatchFailures",
|
|
36
33
|
"neverBuiltDependencies",
|
|
34
|
+
"nodeDownloadMirrors",
|
|
35
|
+
"noProxy",
|
|
36
|
+
"npmrcAuthFile",
|
|
37
37
|
"onlyBuiltDependencies",
|
|
38
38
|
"onlyBuiltDependenciesFile",
|
|
39
39
|
"overrides",
|
|
40
40
|
"packageExtensions",
|
|
41
41
|
"patchedDependencies",
|
|
42
42
|
"peerDependencyRules",
|
|
43
|
+
"registries",
|
|
43
44
|
"requiredScripts",
|
|
44
45
|
"supportedArchitectures",
|
|
45
46
|
"updateConfig"
|
|
46
47
|
];
|
|
47
|
-
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region src/options.ts
|
|
50
50
|
/**
|
|
@@ -101,7 +101,6 @@ function resolveStrategy(strategy) {
|
|
|
101
101
|
if (VALID_STRATEGIES.includes(strategy)) return strategy;
|
|
102
102
|
throw new Error(`Invalid strategy: ${strategy}. Expected one of: ${VALID_STRATEGIES.join(", ")}`);
|
|
103
103
|
}
|
|
104
|
-
|
|
105
104
|
//#endregion
|
|
106
105
|
//#region src/utils/fs.ts
|
|
107
106
|
/**
|
|
@@ -128,17 +127,13 @@ async function fsReadFile(path) {
|
|
|
128
127
|
async function fsWriteFile(path, content) {
|
|
129
128
|
await writeFile(path, `${content.trimEnd()}\n`, "utf-8");
|
|
130
129
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
//#region src/utils/color.ts
|
|
134
|
-
const cyan = getColor("cyan");
|
|
135
|
-
const yellow = getColor("yellow");
|
|
130
|
+
getColor("cyan");
|
|
131
|
+
getColor("yellow");
|
|
136
132
|
const dim = getColor("dim");
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
133
|
+
getColor("green");
|
|
134
|
+
getColor("red");
|
|
135
|
+
getColor("bold");
|
|
136
|
+
getColor("magenta");
|
|
142
137
|
//#endregion
|
|
143
138
|
//#region src/utils/merge.ts
|
|
144
139
|
/**
|
|
@@ -214,7 +209,6 @@ function mergeWithArrayDedupe(existing, incoming) {
|
|
|
214
209
|
}
|
|
215
210
|
return result;
|
|
216
211
|
}
|
|
217
|
-
|
|
218
212
|
//#endregion
|
|
219
213
|
//#region src/utils/npmrc.ts
|
|
220
214
|
/**
|
|
@@ -261,7 +255,6 @@ async function pruneNpmrc(path) {
|
|
|
261
255
|
async function readNpmrc(path) {
|
|
262
256
|
return camelcaseKeys(await readIniFile(path));
|
|
263
257
|
}
|
|
264
|
-
|
|
265
258
|
//#endregion
|
|
266
259
|
//#region src/core.ts
|
|
267
260
|
/**
|
|
@@ -315,9 +308,9 @@ async function migratePnpmSettings(rawOptions = {}) {
|
|
|
315
308
|
consola.warn("No pnpm settings files to migrate");
|
|
316
309
|
return;
|
|
317
310
|
}
|
|
318
|
-
let packageJsonIndent =
|
|
311
|
+
let packageJsonIndent = 2;
|
|
319
312
|
let packageJsonObject = {};
|
|
320
|
-
let pnpmWorkspaceYamlIndent =
|
|
313
|
+
let pnpmWorkspaceYamlIndent = 2;
|
|
321
314
|
let pnpmWorkspaceYamlObject = {};
|
|
322
315
|
if (packageJsonExists) {
|
|
323
316
|
const content = await fsReadFile(packageJsonPath);
|
|
@@ -367,6 +360,5 @@ async function migratePnpmSettings(rawOptions = {}) {
|
|
|
367
360
|
throw err;
|
|
368
361
|
}
|
|
369
362
|
}
|
|
370
|
-
|
|
371
363
|
//#endregion
|
|
372
|
-
export { migratePnpmSettings, resolveOptions };
|
|
364
|
+
export { migratePnpmSettings, resolveOptions };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pnpm-settings-migrator",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "Move pnpm settings from `pnpm` field in `package.json` and `.npmrc` file to `pnpm-workspace.yaml`",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"migrator",
|
|
@@ -37,31 +37,31 @@
|
|
|
37
37
|
},
|
|
38
38
|
"sideEffects": false,
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ntnyq/utils": "^0.11.
|
|
41
|
-
"@pnpm/types": "^
|
|
40
|
+
"@ntnyq/utils": "^0.11.6",
|
|
41
|
+
"@pnpm/types": "^1100.0.0",
|
|
42
42
|
"cac": "^7.0.0",
|
|
43
43
|
"camelcase-keys": "^10.0.2",
|
|
44
44
|
"consola": "^3.4.2",
|
|
45
|
-
"defu": "^6.1.
|
|
45
|
+
"defu": "^6.1.7",
|
|
46
46
|
"detect-indent": "^7.0.2",
|
|
47
47
|
"pathe": "^2.0.3",
|
|
48
|
-
"read-ini-file": "^
|
|
48
|
+
"read-ini-file": "^5.0.0",
|
|
49
49
|
"uncase": "^0.2.0",
|
|
50
|
-
"yaml": "^2.8.
|
|
50
|
+
"yaml": "^2.8.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@ntnyq/eslint-config": "^6.0.
|
|
54
|
-
"@types/node": "^25.
|
|
55
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
56
|
-
"bumpp": "^
|
|
57
|
-
"eslint": "^10.0
|
|
53
|
+
"@ntnyq/eslint-config": "^6.0.1",
|
|
54
|
+
"@types/node": "^25.6.0",
|
|
55
|
+
"@typescript/native-preview": "^7.0.0-dev.20260410.1",
|
|
56
|
+
"bumpp": "^11.0.1",
|
|
57
|
+
"eslint": "^10.2.0",
|
|
58
58
|
"husky": "^9.1.7",
|
|
59
|
-
"nano-staged": "^0.
|
|
59
|
+
"nano-staged": "^1.0.2",
|
|
60
60
|
"npm-run-all2": "^8.0.4",
|
|
61
|
-
"oxfmt": "^0.
|
|
62
|
-
"tsdown": "^0.21.
|
|
63
|
-
"typescript": "^
|
|
64
|
-
"vitest": "^4.
|
|
61
|
+
"oxfmt": "^0.44.0",
|
|
62
|
+
"tsdown": "^0.21.7",
|
|
63
|
+
"typescript": "^6.0.2",
|
|
64
|
+
"vitest": "^4.1.4"
|
|
65
65
|
},
|
|
66
66
|
"nano-staged": {
|
|
67
67
|
"*.{js,ts,mjs,tsx,md,yml,yaml,toml,json}": "eslint --fix",
|