@w5s/pnpm-plugin-config 1.0.0-alpha.5 → 1.0.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/index.d.ts +8 -4
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/PnpmUserConfig.ts +13 -14
- package/src/defaultConfig.ts +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,17 @@ import { Cafs, ResolvedFrom } from "@pnpm/cafs-types";
|
|
|
2
2
|
//#region src/defaultConfig.d.ts
|
|
3
3
|
declare const defaultConfig: Readonly<{
|
|
4
4
|
allowBuilds: {
|
|
5
|
+
'@parcel/watcher': true;
|
|
5
6
|
'@swc/core': true;
|
|
6
7
|
'core-js': true;
|
|
8
|
+
'core-js-pure': true;
|
|
9
|
+
electron: true;
|
|
7
10
|
'es5-ext': true;
|
|
8
11
|
esbuild: true;
|
|
9
12
|
lefthook: true;
|
|
10
13
|
nx: true;
|
|
11
14
|
protobufjs: true;
|
|
12
|
-
|
|
15
|
+
sharp: true;
|
|
13
16
|
};
|
|
14
17
|
blockExoticSubdeps: true;
|
|
15
18
|
enablePrePostScripts: false;
|
|
@@ -1254,9 +1257,10 @@ declare const PnpmUserConfig: Readonly<{
|
|
|
1254
1257
|
/**
|
|
1255
1258
|
* Merge two configs immutably. `extension` values win; `base` fills in
|
|
1256
1259
|
* undefined slots. `allowBuilds` and `overrides` are deep-merged (extension
|
|
1257
|
-
* entries win). `minimumReleaseAgeExclude`
|
|
1258
|
-
*
|
|
1259
|
-
*
|
|
1260
|
+
* entries win). `minimumReleaseAgeExclude`, `hoistPattern`, and
|
|
1261
|
+
* `publicHoistPattern` are merged as deduplicated unions of both arrays
|
|
1262
|
+
* (base first, extension second — so pnpm `!`-negation entries in extension
|
|
1263
|
+
* can exclude org defaults).
|
|
1260
1264
|
*
|
|
1261
1265
|
* @param base
|
|
1262
1266
|
* @param extension
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
//#region src/defaultConfig.ts
|
|
2
2
|
const defaultConfig = Object.freeze({
|
|
3
3
|
allowBuilds: {
|
|
4
|
+
"@parcel/watcher": true,
|
|
4
5
|
"@swc/core": true,
|
|
5
6
|
"core-js": true,
|
|
7
|
+
"core-js-pure": true,
|
|
8
|
+
"electron": true,
|
|
6
9
|
"es5-ext": true,
|
|
7
10
|
"esbuild": true,
|
|
8
11
|
"lefthook": true,
|
|
9
12
|
"nx": true,
|
|
10
13
|
"protobufjs": true,
|
|
11
|
-
"
|
|
14
|
+
"sharp": true
|
|
12
15
|
},
|
|
13
16
|
blockExoticSubdeps: true,
|
|
14
17
|
enablePrePostScripts: false,
|
|
@@ -25,8 +28,8 @@ const defaultConfig = Object.freeze({
|
|
|
25
28
|
//#endregion
|
|
26
29
|
//#region src/PnpmUserConfig.ts
|
|
27
30
|
function arrayMerge(base, extension) {
|
|
28
|
-
const baseArray = base
|
|
29
|
-
const extensionArray = extension
|
|
31
|
+
const baseArray = base == null ? [] : Array.isArray(base) ? base : [base];
|
|
32
|
+
const extensionArray = extension == null ? [] : Array.isArray(extension) ? extension : [extension];
|
|
30
33
|
if (baseArray.length === 0 && extensionArray.length === 0) return void 0;
|
|
31
34
|
return [.../* @__PURE__ */ new Set([...baseArray, ...extensionArray])];
|
|
32
35
|
}
|
|
@@ -49,28 +52,28 @@ const PnpmUserConfig = Object.freeze({
|
|
|
49
52
|
/**
|
|
50
53
|
* Merge two configs immutably. `extension` values win; `base` fills in
|
|
51
54
|
* undefined slots. `allowBuilds` and `overrides` are deep-merged (extension
|
|
52
|
-
* entries win). `minimumReleaseAgeExclude`
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
+
* entries win). `minimumReleaseAgeExclude`, `hoistPattern`, and
|
|
56
|
+
* `publicHoistPattern` are merged as deduplicated unions of both arrays
|
|
57
|
+
* (base first, extension second — so pnpm `!`-negation entries in extension
|
|
58
|
+
* can exclude org defaults).
|
|
55
59
|
*
|
|
56
60
|
* @param base
|
|
57
61
|
* @param extension
|
|
58
62
|
*/
|
|
59
63
|
merge(base, extension) {
|
|
60
|
-
const hoistPattern = extension.hoistPattern?.length === 1 && extension.hoistPattern[0] === "*" ? [] : extension.hoistPattern ?? base.hoistPattern;
|
|
61
64
|
return {
|
|
62
65
|
...extension,
|
|
63
66
|
allowBuilds: objectMergeForce(base, extension, "allowBuilds"),
|
|
64
67
|
blockExoticSubdeps: extension.blockExoticSubdeps ?? base.blockExoticSubdeps,
|
|
65
68
|
enableGlobalVirtualStore: extension.enableGlobalVirtualStore ?? base.enableGlobalVirtualStore,
|
|
66
69
|
enablePrePostScripts: extension.enablePrePostScripts ?? base.enablePrePostScripts,
|
|
67
|
-
hoistPattern,
|
|
70
|
+
hoistPattern: arrayMerge(base.hoistPattern, extension.hoistPattern),
|
|
68
71
|
ignorePatchFailures: extension.ignorePatchFailures ?? base.ignorePatchFailures,
|
|
69
72
|
minimumReleaseAge: extension.minimumReleaseAge ?? base.minimumReleaseAge,
|
|
70
73
|
minimumReleaseAgeExclude: arrayMerge(base.minimumReleaseAgeExclude, extension.minimumReleaseAgeExclude),
|
|
71
74
|
optimisticRepeatInstall: extension.optimisticRepeatInstall ?? base.optimisticRepeatInstall,
|
|
72
75
|
overrides: objectMergeDefault(base, extension, "overrides"),
|
|
73
|
-
publicHoistPattern:
|
|
76
|
+
publicHoistPattern: arrayMerge(base.publicHoistPattern, extension.publicHoistPattern),
|
|
74
77
|
resolutionMode: extension.resolutionMode ?? base.resolutionMode,
|
|
75
78
|
trustPolicy: extension.trustPolicy ?? base.trustPolicy,
|
|
76
79
|
trustPolicyIgnoreAfter: extension.trustPolicyIgnoreAfter ?? base.trustPolicyIgnoreAfter,
|
|
@@ -87,7 +90,7 @@ const hooks = { updateConfig(config) {
|
|
|
87
90
|
const meta = Object.freeze({
|
|
88
91
|
buildNumber: 1,
|
|
89
92
|
name: "@w5s/pnpm-plugin-config",
|
|
90
|
-
version: "1.0.0
|
|
93
|
+
version: "1.0.0"
|
|
91
94
|
});
|
|
92
95
|
//#endregion
|
|
93
96
|
export { PnpmUserConfig, defaultConfig, hooks, meta };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/defaultConfig.ts","../src/PnpmUserConfig.ts","../src/hooks.ts","../src/meta.ts"],"sourcesContent":["import type { PnpmUserConfig } from './PnpmUserConfig.js';\n\n// Opinionated defaults inspired by @pnpm/plugin-better-defaults, extended with org-specific settings.\nexport const defaultConfig = Object.freeze({\n allowBuilds: {\n '@swc/core': true,\n 'core-js': true,\n 'es5-ext': true,\n 'esbuild': true,\n 'lefthook': true,\n 'nx': true,\n 'protobufjs': true,\n '
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/defaultConfig.ts","../src/PnpmUserConfig.ts","../src/hooks.ts","../src/meta.ts"],"sourcesContent":["import type { PnpmUserConfig } from './PnpmUserConfig.js';\n\n// Opinionated defaults inspired by @pnpm/plugin-better-defaults, extended with org-specific settings.\nexport const defaultConfig = Object.freeze({\n allowBuilds: {\n '@parcel/watcher': true,\n '@swc/core': true,\n 'core-js': true,\n 'core-js-pure': true,\n 'electron': true,\n 'es5-ext': true,\n 'esbuild': true,\n 'lefthook': true,\n 'nx': true,\n 'protobufjs': true,\n 'sharp': true,\n },\n blockExoticSubdeps: true,\n // enableGlobalVirtualStore: true, FIXME: this does not work\n enablePrePostScripts: false,\n ignorePatchFailures: false,\n minimumReleaseAge: 1 * 24 * 60,\n minimumReleaseAgeExclude: ['@w5s/*'],\n optimisticRepeatInstall: true,\n overrides: {},\n resolutionMode: 'lowest-direct',\n trustPolicy: 'no-downgrade',\n trustPolicyIgnoreAfter: 7 * 24 * 60,\n verifyDepsBeforeRun: 'install',\n} satisfies PnpmUserConfig);\n","import type { PnpmConfig } from './PnpmConfig.js';\n\nexport type PnpmUserConfig = Partial<PnpmConfig>;\n\nfunction arrayMerge<T>(\n base: ReadonlyArray<T> | T | undefined,\n extension: ReadonlyArray<T> | T | undefined,\n): Array<T> | undefined {\n const baseArray = base == null ? [] : Array.isArray(base) ? base : [base];\n const extensionArray = extension == null ? [] : Array.isArray(extension) ? extension : [extension];\n if (baseArray.length === 0 && extensionArray.length === 0) return undefined;\n return [...new Set([...baseArray, ...extensionArray])];\n}\n\nfunction objectMergeDefault<P extends string, V extends object>(\n base: Partial<Record<P, V>>,\n extension: Partial<Record<P, V>>,\n property: P,\n): undefined | V {\n return {\n ...base[property],\n ...extension[property],\n } as V;\n}\n\nfunction objectMergeForce<P extends string, V extends object>(\n base: Partial<Record<P, V>>,\n extension: Partial<Record<P, V>>,\n property: P,\n): undefined | V {\n return {\n ...extension[property],\n ...base[property],\n } as V;\n}\n\n/**\n * @namespace\n */\nexport const PnpmUserConfig = Object.freeze({\n /**\n * Merge two configs immutably. `extension` values win; `base` fills in\n * undefined slots. `allowBuilds` and `overrides` are deep-merged (extension\n * entries win). `minimumReleaseAgeExclude`, `hoistPattern`, and\n * `publicHoistPattern` are merged as deduplicated unions of both arrays\n * (base first, extension second — so pnpm `!`-negation entries in extension\n * can exclude org defaults).\n *\n * @param base\n * @param extension\n */\n merge(base: PnpmUserConfig, extension: PnpmUserConfig): PnpmUserConfig {\n return {\n ...extension,\n allowBuilds: objectMergeForce(base, extension, 'allowBuilds'),\n blockExoticSubdeps: extension.blockExoticSubdeps ?? base.blockExoticSubdeps,\n enableGlobalVirtualStore: extension.enableGlobalVirtualStore ?? base.enableGlobalVirtualStore,\n enablePrePostScripts: extension.enablePrePostScripts ?? base.enablePrePostScripts,\n hoistPattern: arrayMerge(base.hoistPattern, extension.hoistPattern),\n ignorePatchFailures: extension.ignorePatchFailures ?? base.ignorePatchFailures,\n minimumReleaseAge: extension.minimumReleaseAge ?? base.minimumReleaseAge,\n minimumReleaseAgeExclude: arrayMerge(\n base.minimumReleaseAgeExclude,\n extension.minimumReleaseAgeExclude,\n ),\n optimisticRepeatInstall: extension.optimisticRepeatInstall ?? base.optimisticRepeatInstall,\n overrides: objectMergeDefault(base, extension, 'overrides'),\n publicHoistPattern: arrayMerge(\n base.publicHoistPattern,\n extension.publicHoistPattern,\n ),\n resolutionMode: extension.resolutionMode ?? base.resolutionMode,\n trustPolicy: extension.trustPolicy ?? base.trustPolicy,\n trustPolicyIgnoreAfter: extension.trustPolicyIgnoreAfter ?? base.trustPolicyIgnoreAfter,\n verifyDepsBeforeRun: extension.verifyDepsBeforeRun ?? base.verifyDepsBeforeRun,\n } as PnpmUserConfig;\n },\n});\n","import type { PnpmHooks } from './PnpmHooks.js';\n\nimport { defaultConfig } from './defaultConfig.js';\nimport { PnpmUserConfig } from './PnpmUserConfig.js';\n\nexport const hooks = {\n updateConfig(config) {\n return PnpmUserConfig.merge(defaultConfig, config);\n },\n} satisfies PnpmHooks;\n","export const meta = Object.freeze({\n // @ts-ignore - these variables are injected at build time\n buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\n // @ts-ignore - these variables are injected at build time\n name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,\n // @ts-ignore - these variables are injected at build time\n version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n});\n"],"mappings":";AAGA,MAAa,gBAAgB,OAAO,OAAO;CACzC,aAAa;EACX,mBAAmB;EACnB,aAAa;EACb,WAAW;EACX,gBAAgB;EAChB,YAAY;EACZ,WAAW;EACX,WAAW;EACX,YAAY;EACZ,MAAM;EACN,cAAc;EACd,SAAS;CACX;CACA,oBAAoB;CAEpB,sBAAsB;CACtB,qBAAqB;CACrB,mBAAmB;CACnB,0BAA0B,CAAC,QAAQ;CACnC,yBAAyB;CACzB,WAAW,CAAC;CACZ,gBAAgB;CAChB,aAAa;CACb,wBAAwB;CACxB,qBAAqB;AACvB,CAA0B;;;ACzB1B,SAAS,WACP,M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AO,eAAe,MAAM,eAAe,MAAM;AACnD,EACF;;;ACTA,MAAa,OAAO,OAAO,OAAO;CAEhC,aAAa;CAEb,MAAA;CAEA,SAAA;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/pnpm-plugin-config",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Shared pnpm configuration plugin with org defaults",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"sideEffect": false,
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "9870a62900cd2c974bed8800ed520335f8843c38"
|
|
45
45
|
}
|
package/src/PnpmUserConfig.ts
CHANGED
|
@@ -3,11 +3,11 @@ import type { PnpmConfig } from './PnpmConfig.js';
|
|
|
3
3
|
export type PnpmUserConfig = Partial<PnpmConfig>;
|
|
4
4
|
|
|
5
5
|
function arrayMerge<T>(
|
|
6
|
-
base: ReadonlyArray<T> | undefined,
|
|
7
|
-
extension: ReadonlyArray<T> | undefined,
|
|
6
|
+
base: ReadonlyArray<T> | T | undefined,
|
|
7
|
+
extension: ReadonlyArray<T> | T | undefined,
|
|
8
8
|
): Array<T> | undefined {
|
|
9
|
-
const baseArray = base
|
|
10
|
-
const extensionArray = extension
|
|
9
|
+
const baseArray = base == null ? [] : Array.isArray(base) ? base : [base];
|
|
10
|
+
const extensionArray = extension == null ? [] : Array.isArray(extension) ? extension : [extension];
|
|
11
11
|
if (baseArray.length === 0 && extensionArray.length === 0) return undefined;
|
|
12
12
|
return [...new Set([...baseArray, ...extensionArray])];
|
|
13
13
|
}
|
|
@@ -41,26 +41,22 @@ export const PnpmUserConfig = Object.freeze({
|
|
|
41
41
|
/**
|
|
42
42
|
* Merge two configs immutably. `extension` values win; `base` fills in
|
|
43
43
|
* undefined slots. `allowBuilds` and `overrides` are deep-merged (extension
|
|
44
|
-
* entries win). `minimumReleaseAgeExclude`
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* entries win). `minimumReleaseAgeExclude`, `hoistPattern`, and
|
|
45
|
+
* `publicHoistPattern` are merged as deduplicated unions of both arrays
|
|
46
|
+
* (base first, extension second — so pnpm `!`-negation entries in extension
|
|
47
|
+
* can exclude org defaults).
|
|
47
48
|
*
|
|
48
49
|
* @param base
|
|
49
50
|
* @param extension
|
|
50
51
|
*/
|
|
51
52
|
merge(base: PnpmUserConfig, extension: PnpmUserConfig): PnpmUserConfig {
|
|
52
|
-
const hoistPattern =
|
|
53
|
-
extension.hoistPattern?.length === 1 && extension.hoistPattern[0] === '*'
|
|
54
|
-
? []
|
|
55
|
-
: (extension.hoistPattern ?? base.hoistPattern);
|
|
56
|
-
|
|
57
53
|
return {
|
|
58
54
|
...extension,
|
|
59
55
|
allowBuilds: objectMergeForce(base, extension, 'allowBuilds'),
|
|
60
56
|
blockExoticSubdeps: extension.blockExoticSubdeps ?? base.blockExoticSubdeps,
|
|
61
57
|
enableGlobalVirtualStore: extension.enableGlobalVirtualStore ?? base.enableGlobalVirtualStore,
|
|
62
58
|
enablePrePostScripts: extension.enablePrePostScripts ?? base.enablePrePostScripts,
|
|
63
|
-
hoistPattern,
|
|
59
|
+
hoistPattern: arrayMerge(base.hoistPattern, extension.hoistPattern),
|
|
64
60
|
ignorePatchFailures: extension.ignorePatchFailures ?? base.ignorePatchFailures,
|
|
65
61
|
minimumReleaseAge: extension.minimumReleaseAge ?? base.minimumReleaseAge,
|
|
66
62
|
minimumReleaseAgeExclude: arrayMerge(
|
|
@@ -69,7 +65,10 @@ export const PnpmUserConfig = Object.freeze({
|
|
|
69
65
|
),
|
|
70
66
|
optimisticRepeatInstall: extension.optimisticRepeatInstall ?? base.optimisticRepeatInstall,
|
|
71
67
|
overrides: objectMergeDefault(base, extension, 'overrides'),
|
|
72
|
-
publicHoistPattern:
|
|
68
|
+
publicHoistPattern: arrayMerge(
|
|
69
|
+
base.publicHoistPattern,
|
|
70
|
+
extension.publicHoistPattern,
|
|
71
|
+
),
|
|
73
72
|
resolutionMode: extension.resolutionMode ?? base.resolutionMode,
|
|
74
73
|
trustPolicy: extension.trustPolicy ?? base.trustPolicy,
|
|
75
74
|
trustPolicyIgnoreAfter: extension.trustPolicyIgnoreAfter ?? base.trustPolicyIgnoreAfter,
|
package/src/defaultConfig.ts
CHANGED
|
@@ -3,14 +3,17 @@ import type { PnpmUserConfig } from './PnpmUserConfig.js';
|
|
|
3
3
|
// Opinionated defaults inspired by @pnpm/plugin-better-defaults, extended with org-specific settings.
|
|
4
4
|
export const defaultConfig = Object.freeze({
|
|
5
5
|
allowBuilds: {
|
|
6
|
+
'@parcel/watcher': true,
|
|
6
7
|
'@swc/core': true,
|
|
7
8
|
'core-js': true,
|
|
9
|
+
'core-js-pure': true,
|
|
10
|
+
'electron': true,
|
|
8
11
|
'es5-ext': true,
|
|
9
12
|
'esbuild': true,
|
|
10
13
|
'lefthook': true,
|
|
11
14
|
'nx': true,
|
|
12
15
|
'protobufjs': true,
|
|
13
|
-
'
|
|
16
|
+
'sharp': true,
|
|
14
17
|
},
|
|
15
18
|
blockExoticSubdeps: true,
|
|
16
19
|
// enableGlobalVirtualStore: true, FIXME: this does not work
|