@w5s/pnpm-plugin-config 1.0.0-alpha.2

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.js ADDED
@@ -0,0 +1,95 @@
1
+ //#region src/defaultConfig.ts
2
+ const defaultConfig = Object.freeze({
3
+ allowBuilds: {
4
+ "@swc/core": true,
5
+ "core-js": true,
6
+ "es5-ext": true,
7
+ "esbuild": true,
8
+ "lefthook": true,
9
+ "nx": true,
10
+ "protobufjs": true
11
+ },
12
+ blockExoticSubdeps: true,
13
+ enableGlobalVirtualStore: true,
14
+ enablePrePostScripts: false,
15
+ ignorePatchFailures: false,
16
+ minimumReleaseAge: 1440,
17
+ minimumReleaseAgeExclude: ["@w5s/*"],
18
+ optimisticRepeatInstall: true,
19
+ overrides: {},
20
+ resolutionMode: "lowest-direct",
21
+ trustPolicy: "no-downgrade",
22
+ trustPolicyIgnoreAfter: 10080,
23
+ verifyDepsBeforeRun: "install"
24
+ });
25
+ //#endregion
26
+ //#region src/PnpmUserConfig.ts
27
+ function arrayMerge(base, extension) {
28
+ const baseArray = base ?? [];
29
+ const extensionArray = extension ?? [];
30
+ if (baseArray.length === 0 && extensionArray.length === 0) return void 0;
31
+ return [.../* @__PURE__ */ new Set([...baseArray, ...extensionArray])];
32
+ }
33
+ function objectMergeDefault(base, extension, property) {
34
+ return {
35
+ ...base[property],
36
+ ...extension[property]
37
+ };
38
+ }
39
+ function objectMergeForce(base, extension, property) {
40
+ return {
41
+ ...extension[property],
42
+ ...base[property]
43
+ };
44
+ }
45
+ /**
46
+ * @namespace
47
+ */
48
+ const PnpmUserConfig = Object.freeze({
49
+ /**
50
+ * Merge two configs immutably. `extension` values win; `base` fills in
51
+ * undefined slots. `allowBuilds` and `overrides` are deep-merged (extension
52
+ * entries win). `minimumReleaseAgeExclude` is merged as a deduplicated union
53
+ * of both arrays. A `hoistPattern` of `['*']` in extension is normalized to
54
+ * `[]` following pnpm-plugin-better-defaults behavior.
55
+ *
56
+ * @param base
57
+ * @param extension
58
+ */
59
+ merge(base, extension) {
60
+ const hoistPattern = extension.hoistPattern?.length === 1 && extension.hoistPattern[0] === "*" ? [] : extension.hoistPattern ?? base.hoistPattern;
61
+ return {
62
+ ...extension,
63
+ allowBuilds: objectMergeForce(base, extension, "allowBuilds"),
64
+ blockExoticSubdeps: extension.blockExoticSubdeps ?? base.blockExoticSubdeps,
65
+ enableGlobalVirtualStore: extension.enableGlobalVirtualStore ?? base.enableGlobalVirtualStore,
66
+ enablePrePostScripts: extension.enablePrePostScripts ?? base.enablePrePostScripts,
67
+ hoistPattern,
68
+ ignorePatchFailures: extension.ignorePatchFailures ?? base.ignorePatchFailures,
69
+ minimumReleaseAge: extension.minimumReleaseAge ?? base.minimumReleaseAge,
70
+ minimumReleaseAgeExclude: arrayMerge(base.minimumReleaseAgeExclude, extension.minimumReleaseAgeExclude),
71
+ optimisticRepeatInstall: extension.optimisticRepeatInstall ?? base.optimisticRepeatInstall,
72
+ overrides: objectMergeDefault(base, extension, "overrides"),
73
+ publicHoistPattern: extension.publicHoistPattern ?? base.publicHoistPattern,
74
+ resolutionMode: extension.resolutionMode ?? base.resolutionMode,
75
+ trustPolicy: extension.trustPolicy ?? base.trustPolicy,
76
+ trustPolicyIgnoreAfter: extension.trustPolicyIgnoreAfter ?? base.trustPolicyIgnoreAfter,
77
+ verifyDepsBeforeRun: extension.verifyDepsBeforeRun ?? base.verifyDepsBeforeRun
78
+ };
79
+ } });
80
+ //#endregion
81
+ //#region src/hooks.ts
82
+ const hooks = { updateConfig(config) {
83
+ return PnpmUserConfig.merge(defaultConfig, config);
84
+ } };
85
+ //#endregion
86
+ //#region src/meta.ts
87
+ const meta = Object.freeze({
88
+ buildNumber: 1,
89
+ name: "@w5s/pnpm-plugin-config",
90
+ version: "1.0.0-alpha.2"
91
+ });
92
+ //#endregion
93
+ export { PnpmUserConfig, defaultConfig, hooks, meta };
94
+
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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 },\n blockExoticSubdeps: true,\n enableGlobalVirtualStore: true,\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> | undefined,\n extension: ReadonlyArray<T> | undefined,\n): Array<T> | undefined {\n const baseArray = base ?? [];\n const extensionArray = 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` is merged as a deduplicated union\n * of both arrays. A `hoistPattern` of `['*']` in extension is normalized to\n * `[]` following pnpm-plugin-better-defaults behavior.\n *\n * @param base\n * @param extension\n */\n merge(base: PnpmUserConfig, extension: PnpmUserConfig): PnpmUserConfig {\n const hoistPattern =\n extension.hoistPattern?.length === 1 && extension.hoistPattern[0] === '*'\n ? []\n : (extension.hoistPattern ?? base.hoistPattern);\n\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,\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: extension.publicHoistPattern ?? base.publicHoistPattern,\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,aAAa;EACb,WAAW;EACX,WAAW;EACX,WAAW;EACX,YAAY;EACZ,MAAM;EACN,cAAc;CAChB;CACA,oBAAoB;CACpB,0BAA0B;CAC1B,sBAAsB;CACtB,qBAAqB;CACrB,mBAAmB;CACnB,0BAA0B,CAAC,QAAQ;CACnC,yBAAyB;CACzB,WAAW,CAAC;CACZ,gBAAgB;CAChB,aAAa;CACb,wBAAwB;CACxB,qBAAqB;AACvB,CAA0B;;;ACrB1B,SAAS,WACP,MACA,WACsB;CACtB,MAAM,YAAY,QAAQ,CAAC;CAC3B,MAAM,iBAAiB,aAAa,CAAC;CACrC,IAAI,UAAU,WAAW,KAAK,eAAe,WAAW,GAAG,OAAO,KAAA;CAClE,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,WAAW,GAAG,cAAc,CAAC,CAAC;AACvD;AAEA,SAAS,mBACP,MACA,WACA,UACe;CACf,OAAO;EACL,GAAG,KAAK;EACR,GAAG,UAAU;CACf;AACF;AAEA,SAAS,iBACP,MACA,WACA,UACe;CACf,OAAO;EACL,GAAG,UAAU;EACb,GAAG,KAAK;CACV;AACF;;;;AAKA,MAAa,iBAAiB,OAAO,OAAO;;;;;;;;;;;AAW1C,MAAM,MAAsB,WAA2C;CACrE,MAAM,eACJ,UAAU,cAAc,WAAW,KAAK,UAAU,aAAa,OAAO,MAClE,CAAC,IACA,UAAU,gBAAgB,KAAK;CAEtC,OAAO;EACL,GAAG;EACH,aAAa,iBAAiB,MAAM,WAAW,aAAa;EAC5D,oBAAoB,UAAU,sBAAsB,KAAK;EACzD,0BAA0B,UAAU,4BAA4B,KAAK;EACrE,sBAAsB,UAAU,wBAAwB,KAAK;EAC7D;EACA,qBAAqB,UAAU,uBAAuB,KAAK;EAC3D,mBAAmB,UAAU,qBAAqB,KAAK;EACvD,0BAA0B,WACxB,KAAK,0BACL,UAAU,wBACZ;EACA,yBAAyB,UAAU,2BAA2B,KAAK;EACnE,WAAW,mBAAmB,MAAM,WAAW,WAAW;EAC1D,oBAAoB,UAAU,sBAAsB,KAAK;EACzD,gBAAgB,UAAU,kBAAkB,KAAK;EACjD,aAAa,UAAU,eAAe,KAAK;EAC3C,wBAAwB,UAAU,0BAA0B,KAAK;EACjE,qBAAqB,UAAU,uBAAuB,KAAK;CAC7D;AACF,EACF,CAAC;;;ACzED,MAAa,QAAQ,EACnB,aAAa,QAAQ;CACnB,OAAO,eAAe,MAAM,eAAe,MAAM;AACnD,EACF;;;ACTA,MAAa,OAAO,OAAO,OAAO;CAEhC,aAAa;CAEb,MAAA;CAEA,SAAA;AACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@w5s/pnpm-plugin-config",
3
+ "version": "1.0.0-alpha.2",
4
+ "description": "Shared pnpm configuration plugin with org defaults",
5
+ "keywords": [
6
+ "pnpm",
7
+ "pnpm-config",
8
+ "config"
9
+ ],
10
+ "homepage": "https://github.com/w5s/project-config/blob/main/packages/pnpm-plugin-config#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/w5s/project-config/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git@github.com:w5s/project-config.git",
17
+ "directory": "packages/pnpm-plugin-config"
18
+ },
19
+ "license": "UNLICENSED",
20
+ "type": "module",
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ ".": "./dist/index.js",
24
+ "./pnpmfile.mjs": "./pnpmfile.mjs",
25
+ "./internal/*": null
26
+ },
27
+ "files": [
28
+ "dist/",
29
+ "pnpmfile.mjs",
30
+ "src/",
31
+ "!**/*.spec.*",
32
+ "!**/__tests__/**"
33
+ ],
34
+ "scripts": {
35
+ "postpack": "clean-package restore"
36
+ },
37
+ "engines": {
38
+ "node": ">=20.0.0"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "sideEffect": false,
44
+ "gitHead": "777b9cf23d9ef48f1c048ccb49e3fa91d1774f1a"
45
+ }
package/pnpmfile.mjs ADDED
@@ -0,0 +1 @@
1
+ export { hooks } from './dist/index.js';
@@ -0,0 +1,3 @@
1
+ import type { Config } from '@pnpm/config';
2
+
3
+ export type PnpmConfig = Config;
@@ -0,0 +1,8 @@
1
+ /** Mutable config passed to and returned from `updateConfig`. */
2
+
3
+ import type { PnpmUserConfig } from './PnpmUserConfig.js';
4
+
5
+ /** Hooks exported by this plugin's pnpmfile. */
6
+ export interface PnpmHooks {
7
+ updateConfig?: (config: PnpmUserConfig) => PnpmUserConfig | Promise<PnpmUserConfig>;
8
+ }
@@ -0,0 +1,79 @@
1
+ import type { PnpmConfig } from './PnpmConfig.js';
2
+
3
+ export type PnpmUserConfig = Partial<PnpmConfig>;
4
+
5
+ function arrayMerge<T>(
6
+ base: ReadonlyArray<T> | undefined,
7
+ extension: ReadonlyArray<T> | undefined,
8
+ ): Array<T> | undefined {
9
+ const baseArray = base ?? [];
10
+ const extensionArray = extension ?? [];
11
+ if (baseArray.length === 0 && extensionArray.length === 0) return undefined;
12
+ return [...new Set([...baseArray, ...extensionArray])];
13
+ }
14
+
15
+ function objectMergeDefault<P extends string, V extends object>(
16
+ base: Partial<Record<P, V>>,
17
+ extension: Partial<Record<P, V>>,
18
+ property: P,
19
+ ): undefined | V {
20
+ return {
21
+ ...base[property],
22
+ ...extension[property],
23
+ } as V;
24
+ }
25
+
26
+ function objectMergeForce<P extends string, V extends object>(
27
+ base: Partial<Record<P, V>>,
28
+ extension: Partial<Record<P, V>>,
29
+ property: P,
30
+ ): undefined | V {
31
+ return {
32
+ ...extension[property],
33
+ ...base[property],
34
+ } as V;
35
+ }
36
+
37
+ /**
38
+ * @namespace
39
+ */
40
+ export const PnpmUserConfig = Object.freeze({
41
+ /**
42
+ * Merge two configs immutably. `extension` values win; `base` fills in
43
+ * undefined slots. `allowBuilds` and `overrides` are deep-merged (extension
44
+ * entries win). `minimumReleaseAgeExclude` is merged as a deduplicated union
45
+ * of both arrays. A `hoistPattern` of `['*']` in extension is normalized to
46
+ * `[]` following pnpm-plugin-better-defaults behavior.
47
+ *
48
+ * @param base
49
+ * @param extension
50
+ */
51
+ 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
+ return {
58
+ ...extension,
59
+ allowBuilds: objectMergeForce(base, extension, 'allowBuilds'),
60
+ blockExoticSubdeps: extension.blockExoticSubdeps ?? base.blockExoticSubdeps,
61
+ enableGlobalVirtualStore: extension.enableGlobalVirtualStore ?? base.enableGlobalVirtualStore,
62
+ enablePrePostScripts: extension.enablePrePostScripts ?? base.enablePrePostScripts,
63
+ hoistPattern,
64
+ ignorePatchFailures: extension.ignorePatchFailures ?? base.ignorePatchFailures,
65
+ minimumReleaseAge: extension.minimumReleaseAge ?? base.minimumReleaseAge,
66
+ minimumReleaseAgeExclude: arrayMerge(
67
+ base.minimumReleaseAgeExclude,
68
+ extension.minimumReleaseAgeExclude,
69
+ ),
70
+ optimisticRepeatInstall: extension.optimisticRepeatInstall ?? base.optimisticRepeatInstall,
71
+ overrides: objectMergeDefault(base, extension, 'overrides'),
72
+ publicHoistPattern: extension.publicHoistPattern ?? base.publicHoistPattern,
73
+ resolutionMode: extension.resolutionMode ?? base.resolutionMode,
74
+ trustPolicy: extension.trustPolicy ?? base.trustPolicy,
75
+ trustPolicyIgnoreAfter: extension.trustPolicyIgnoreAfter ?? base.trustPolicyIgnoreAfter,
76
+ verifyDepsBeforeRun: extension.verifyDepsBeforeRun ?? base.verifyDepsBeforeRun,
77
+ } as PnpmUserConfig;
78
+ },
79
+ });
@@ -0,0 +1,26 @@
1
+ import type { PnpmUserConfig } from './PnpmUserConfig.js';
2
+
3
+ // Opinionated defaults inspired by @pnpm/plugin-better-defaults, extended with org-specific settings.
4
+ export const defaultConfig = Object.freeze({
5
+ allowBuilds: {
6
+ '@swc/core': true,
7
+ 'core-js': true,
8
+ 'es5-ext': true,
9
+ 'esbuild': true,
10
+ 'lefthook': true,
11
+ 'nx': true,
12
+ 'protobufjs': true,
13
+ },
14
+ blockExoticSubdeps: true,
15
+ enableGlobalVirtualStore: true,
16
+ enablePrePostScripts: false,
17
+ ignorePatchFailures: false,
18
+ minimumReleaseAge: 1 * 24 * 60,
19
+ minimumReleaseAgeExclude: ['@w5s/*'],
20
+ optimisticRepeatInstall: true,
21
+ overrides: {},
22
+ resolutionMode: 'lowest-direct',
23
+ trustPolicy: 'no-downgrade',
24
+ trustPolicyIgnoreAfter: 7 * 24 * 60,
25
+ verifyDepsBeforeRun: 'install',
26
+ } satisfies PnpmUserConfig);
package/src/hooks.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { PnpmHooks } from './PnpmHooks.js';
2
+
3
+ import { defaultConfig } from './defaultConfig.js';
4
+ import { PnpmUserConfig } from './PnpmUserConfig.js';
5
+
6
+ export const hooks = {
7
+ updateConfig(config) {
8
+ return PnpmUserConfig.merge(defaultConfig, config);
9
+ },
10
+ } satisfies PnpmHooks;
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './defaultConfig.js';
2
+ export { hooks } from './hooks.js';
3
+ export { meta } from './meta.js';
4
+ export * from './PnpmConfig.js';
5
+ export * from './PnpmHooks.js';
6
+ export * from './PnpmUserConfig.js';
package/src/meta.ts ADDED
@@ -0,0 +1,8 @@
1
+ export const meta = Object.freeze({
2
+ // @ts-ignore - these variables are injected at build time
3
+ buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,
4
+ // @ts-ignore - these variables are injected at build time
5
+ name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,
6
+ // @ts-ignore - these variables are injected at build time
7
+ version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,
8
+ });