pnpm-settings-migrator 0.0.5 → 0.0.7
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/README.md
CHANGED
|
@@ -52,6 +52,13 @@ Disable removing pnpm settings in `.npmrc` file.
|
|
|
52
52
|
|
|
53
53
|
Disable removing `pnpm` field in `package.json`.
|
|
54
54
|
|
|
55
|
+
### `---no-newline-between`
|
|
56
|
+
|
|
57
|
+
- **Type**: `boolean`
|
|
58
|
+
- **Default**: `false`
|
|
59
|
+
|
|
60
|
+
Disable adding newlines between each root keys.
|
|
61
|
+
|
|
55
62
|
## Context
|
|
56
63
|
|
|
57
64
|
- [Moving settings to pnpm-workspace.yaml](https://github.com/orgs/pnpm/discussions/9037)
|
package/dist/cli.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export {
|
|
2
|
+
export { };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import { cac } from 'cac';
|
|
3
3
|
import { consola } from 'consola';
|
|
4
|
-
import { b as bold, d as dim, a as magenta, m as migratePnpmSettings, g as green, c as red } from './shared/pnpm-settings-migrator.
|
|
4
|
+
import { b as bold, d as dim, a as magenta, m as migratePnpmSettings, g as green, c as red } from './shared/pnpm-settings-migrator.D1Qw10Y6.mjs';
|
|
5
5
|
import '@ntnyq/utils';
|
|
6
6
|
import 'defu';
|
|
7
7
|
import 'detect-indent';
|
|
8
|
-
import 'js-yaml';
|
|
9
8
|
import 'pathe';
|
|
9
|
+
import 'yaml';
|
|
10
10
|
import 'node:fs/promises';
|
|
11
11
|
import 'consola/utils';
|
|
12
12
|
import 'camelcase-keys';
|
|
@@ -14,12 +14,15 @@ import 'read-ini-file';
|
|
|
14
14
|
import 'uncase';
|
|
15
15
|
|
|
16
16
|
const name = "pnpm-settings-migrator";
|
|
17
|
-
const version = "0.0.
|
|
17
|
+
const version = "0.0.7";
|
|
18
18
|
|
|
19
19
|
const cli = cac(name);
|
|
20
20
|
cli.version(version).option("--cwd [cwd]", "Current working directory").option("--sort-keys", "Sort keys when write pnpm-workspace.yaml").option(
|
|
21
21
|
"--no-yarn-resolutions",
|
|
22
22
|
"Disable migrating resolutions field in package.json"
|
|
23
|
+
).option(
|
|
24
|
+
"--no-newline-between",
|
|
25
|
+
"Disable adding newlines between each root keys"
|
|
23
26
|
).option("--no-clean-npmrc", "Disable removing pnpm settings in .npmrc file").option(
|
|
24
27
|
"--no-clean-package-json",
|
|
25
28
|
"Disable removing pnpm field in package.json"
|
package/dist/index.d.mts
CHANGED
|
@@ -19,6 +19,11 @@ interface Options {
|
|
|
19
19
|
* @default process.cwd()
|
|
20
20
|
*/
|
|
21
21
|
cwd?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Add newlines between each root keys like pnpm does
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
newlineBetween?: boolean;
|
|
22
27
|
/**
|
|
23
28
|
* Sort keys when write `pnpm-workspace.yaml`
|
|
24
29
|
*
|
|
@@ -81,4 +86,5 @@ type NpmRC = Record<string, any>;
|
|
|
81
86
|
*/
|
|
82
87
|
type PnpmWorkspace = PnpmSettings & PnpmWorkspaceLegacy;
|
|
83
88
|
|
|
84
|
-
export {
|
|
89
|
+
export { migratePnpmSettings, resolveOptions };
|
|
90
|
+
export type { NpmRC, Options, PackageJson, PnpmWorkspace, PnpmWorkspaceLegacy };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { m as migratePnpmSettings, r as resolveOptions } from './shared/pnpm-settings-migrator.
|
|
1
|
+
export { m as migratePnpmSettings, r as resolveOptions } from './shared/pnpm-settings-migrator.D1Qw10Y6.mjs';
|
|
2
2
|
import '@ntnyq/utils';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'defu';
|
|
5
5
|
import 'detect-indent';
|
|
6
|
-
import 'js-yaml';
|
|
7
6
|
import 'pathe';
|
|
7
|
+
import 'yaml';
|
|
8
8
|
import 'node:process';
|
|
9
9
|
import 'node:fs/promises';
|
|
10
10
|
import 'consola/utils';
|
package/dist/shared/{pnpm-settings-migrator.D3JrUqMg.mjs → pnpm-settings-migrator.D1Qw10Y6.mjs}
RENAMED
|
@@ -2,8 +2,8 @@ import { pick } from '@ntnyq/utils';
|
|
|
2
2
|
import consola from 'consola';
|
|
3
3
|
import { defu } from 'defu';
|
|
4
4
|
import detectIndent from 'detect-indent';
|
|
5
|
-
import { load, dump } from 'js-yaml';
|
|
6
5
|
import { resolve } from 'pathe';
|
|
6
|
+
import { parse, Document } from 'yaml';
|
|
7
7
|
import process from 'node:process';
|
|
8
8
|
import { access, readFile, writeFile } from 'node:fs/promises';
|
|
9
9
|
import { getColor } from 'consola/utils';
|
|
@@ -20,6 +20,7 @@ const PNPM_SETTINGS_FIELDS = [
|
|
|
20
20
|
"allowNonAppliedPatches",
|
|
21
21
|
"auditConfig",
|
|
22
22
|
"configDependencies",
|
|
23
|
+
"dangerouslyAllowAllBuilds",
|
|
23
24
|
"executionEnv",
|
|
24
25
|
"ignoredBuiltDependencies",
|
|
25
26
|
"ignoredOptionalDependencies",
|
|
@@ -40,6 +41,7 @@ function resolveOptions(options = {}) {
|
|
|
40
41
|
cleanNpmrc: options.cleanNpmrc ?? true,
|
|
41
42
|
cleanPackageJson: options.cleanPackageJson ?? true,
|
|
42
43
|
cwd: options.cwd ?? process.cwd(),
|
|
44
|
+
newlineBetween: options.newlineBetween ?? true,
|
|
43
45
|
sortKeys: options.sortKeys ?? false,
|
|
44
46
|
strategy: options.strategy ?? "merge",
|
|
45
47
|
yarnResolutions: options.yarnResolutions ?? true
|
|
@@ -106,7 +108,7 @@ async function migratePnpmSettings(rawOptions = {}) {
|
|
|
106
108
|
if (isPnpmWorkspaceExist) {
|
|
107
109
|
const content = await fsReadFile(pnpmWorkspaceYamlPath);
|
|
108
110
|
pnpmWorkspaceYamlIndent = detectIndent(content).amount;
|
|
109
|
-
pnpmWorkspaceYamlObject =
|
|
111
|
+
pnpmWorkspaceYamlObject = parse(content);
|
|
110
112
|
}
|
|
111
113
|
const pnpmSettingsInNpmrc = isNpmrcExist ? pick(await readNpmrc(npmrcPath), PNPM_SETTINGS_FIELDS) : {};
|
|
112
114
|
if (!packageJsonObject.pnpm && (!options.yarnResolutions || !packageJsonObject.resolutions) && !Object.keys(pnpmSettingsInNpmrc).length) {
|
|
@@ -127,13 +129,20 @@ async function migratePnpmSettings(rawOptions = {}) {
|
|
|
127
129
|
...pnpmSettingsInNpmrc,
|
|
128
130
|
...pnpmSettingsInPackageJson
|
|
129
131
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
})
|
|
136
|
-
|
|
132
|
+
const yamlDocument = new Document({
|
|
133
|
+
indent: pnpmWorkspaceYamlIndent,
|
|
134
|
+
sortMapEntries: options.sortKeys
|
|
135
|
+
});
|
|
136
|
+
Object.entries(pnpmWorkspaceResult).forEach(([key, value], index) => {
|
|
137
|
+
yamlDocument.add({ key, value });
|
|
138
|
+
if (options.newlineBetween && index < Object.keys(pnpmWorkspaceResult).length - 1) {
|
|
139
|
+
yamlDocument.add({
|
|
140
|
+
key: "",
|
|
141
|
+
value: null
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
await fsWriteFile(pnpmWorkspaceYamlPath, yamlDocument.toString());
|
|
137
146
|
if (isNpmrcExist && options.cleanNpmrc) {
|
|
138
147
|
await pruneNpmrc(npmrcPath);
|
|
139
148
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pnpm-settings-migrator",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
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,33 +37,32 @@
|
|
|
37
37
|
},
|
|
38
38
|
"sideEffects": false,
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ntnyq/utils": "^0.
|
|
41
|
-
"@pnpm/types": "^1000.
|
|
40
|
+
"@ntnyq/utils": "^0.7.0",
|
|
41
|
+
"@pnpm/types": "^1000.5.0",
|
|
42
42
|
"cac": "^6.7.14",
|
|
43
43
|
"camelcase-keys": "^9.1.3",
|
|
44
|
-
"consola": "^3.4.
|
|
44
|
+
"consola": "^3.4.2",
|
|
45
45
|
"defu": "^6.1.4",
|
|
46
46
|
"detect-indent": "^7.0.1",
|
|
47
|
-
"js-yaml": "^4.1.0",
|
|
48
47
|
"pathe": "^2.0.3",
|
|
49
48
|
"read-ini-file": "^4.0.0",
|
|
50
|
-
"uncase": "^0.0
|
|
49
|
+
"uncase": "^0.1.0",
|
|
50
|
+
"yaml": "^2.7.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@ntnyq/eslint-config": "^4.
|
|
53
|
+
"@ntnyq/eslint-config": "^4.2.0",
|
|
54
54
|
"@ntnyq/prettier-config": "^2.0.0",
|
|
55
|
-
"@types/
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"eslint": "^9.22.0",
|
|
55
|
+
"@types/node": "^22.15.17",
|
|
56
|
+
"bumpp": "^10.1.0",
|
|
57
|
+
"eslint": "^9.26.0",
|
|
59
58
|
"husky": "^9.1.7",
|
|
60
59
|
"nano-staged": "^0.8.0",
|
|
61
|
-
"npm-run-all2": "^
|
|
60
|
+
"npm-run-all2": "^8.0.1",
|
|
62
61
|
"prettier": "^3.5.3",
|
|
63
|
-
"tsx": "^4.19.
|
|
64
|
-
"typescript": "^5.8.
|
|
62
|
+
"tsx": "^4.19.4",
|
|
63
|
+
"typescript": "^5.8.3",
|
|
65
64
|
"unbuild": "^3.5.0",
|
|
66
|
-
"vitest": "^3.
|
|
65
|
+
"vitest": "^3.1.3"
|
|
67
66
|
},
|
|
68
67
|
"engines": {
|
|
69
68
|
"node": ">=18.18.0"
|