@yarn-tool/pkg-entry-util 3.0.37 → 3.0.39
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/CHANGELOG.md +28 -0
- package/lib/field/exports.d.ts +1 -1
- package/lib/field/exports.js.map +1 -1
- package/lib/field/scripts-auto.d.ts +1 -1
- package/lib/field/scripts-auto.js +13 -3
- package/lib/field/scripts-auto.js.map +1 -1
- package/lib/field/scripts.d.ts +5 -1
- package/lib/field/scripts.js +4 -0
- package/lib/field/scripts.js.map +1 -1
- package/lib/preset/scripts/ws-root-scripts.d.ts +1 -1
- package/lib/preset/scripts/ws-root-scripts.js +1 -1
- package/lib/preset/scripts/ws-root-scripts.js.map +1 -1
- package/lib/util/scripts/util.d.ts +4 -0
- package/lib/util/scripts/util.js +8 -0
- package/lib/util/scripts/util.js.map +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.0.39](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/pkg-entry-util@3.0.38...@yarn-tool/pkg-entry-util@3.0.39) (2026-11-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### 📦 Code Refactoring
|
|
11
|
+
|
|
12
|
+
* **types:** 優化類型定義以解決字串字面量與泛型衝突 ([b81e566](https://github.com/bluelovers/ws-yarn-workspaces/commit/b81e566fdd9b703846e2a2f4f8881320c2adaf61))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [3.0.38](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/pkg-entry-util@3.0.37...@yarn-tool/pkg-entry-util@3.0.38) (2026-11-27)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### ✨ Features
|
|
20
|
+
|
|
21
|
+
* **@yarn-tool/pkg-entry-util:** 支援 Lerna 版本管理腳本與自動修復邏輯 ([b4cd677](https://github.com/bluelovers/ws-yarn-workspaces/commit/b4cd6773f2e981ad5b82536a8c5030c71c438010))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### 📦 Code Refactoring
|
|
25
|
+
|
|
26
|
+
* **@yarn-tool/pkg-entry-util:** 優化腳本自動修復邏輯並新增工具函式 ([2619ff1](https://github.com/bluelovers/ws-yarn-workspaces/commit/2619ff125845283383a2760c1816b520a8393d3d))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### 🛠 Build System
|
|
30
|
+
|
|
31
|
+
* update build ([2031a66](https://github.com/bluelovers/ws-yarn-workspaces/commit/2031a66d229c9fc91b63271f5d54a21930c403aa))
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
## [3.0.37](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/pkg-entry-util@3.0.36...@yarn-tool/pkg-entry-util@3.0.37) (2026-11-26)
|
|
7
35
|
|
|
8
36
|
**Note:** Version bump only for package @yarn-tool/pkg-entry-util
|
package/lib/field/exports.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare function pkgExportsAddPJsonEntry<T extends IPackageJson>(pkg: T):
|
|
|
36
36
|
* @param {PackageExportsEntry | PackageExportsFallback} value - exports 的值 / exports value
|
|
37
37
|
* @returns {boolean} 是否為有效的 PackageExportsEntry / Whether it's a valid PackageExportsEntry
|
|
38
38
|
*/
|
|
39
|
-
export declare function _isPackageExportsEntry(entry: string | keyof keyof IPackageJson["exports"], value: PackageExportsEntry | PackageExportsFallback): value is PackageExportsEntry;
|
|
39
|
+
export declare function _isPackageExportsEntry(entry: (string & {}) | keyof keyof IPackageJson["exports"], value: PackageExportsEntry | PackageExportsFallback): value is PackageExportsEntry;
|
|
40
40
|
/**
|
|
41
41
|
* 驗證 package exports 路徑是否存在
|
|
42
42
|
* Verify if package exports paths exist
|
package/lib/field/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["exports.ts"],"names":[],"mappings":";;AAqBA,oEAYC;AAUD,0DAKC;AAaD,wDAKC;AAgBD,4CA6FC;AAzKD,uCAA0C;AAC1C,oDAAoD;AACpD,gEAAgF;AAEhF;;;;;;;;;;GAUG;AACH,SAAgB,4BAA4B,CAAoC,UAAa;;IAE5F,IAAI,OAAO,UAAU,KAAK,QAAQ,EAClC,CAAC;QACA;;;WAGG;QACH,MAAA,UAAU,CAAC,gBAAgB,qCAA3B,UAAU,CAAC,gBAAgB,IAAM,gBAAgB,EAAC;IACnD,CAAC;IAED,OAAO,UAAU,CAAA;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAyB,GAAM;IAErE,4BAA4B,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAE1C,OAAO,GAAG,CAAA;AACX,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["exports.ts"],"names":[],"mappings":";;AAqBA,oEAYC;AAUD,0DAKC;AAaD,wDAKC;AAgBD,4CA6FC;AAzKD,uCAA0C;AAC1C,oDAAoD;AACpD,gEAAgF;AAEhF;;;;;;;;;;GAUG;AACH,SAAgB,4BAA4B,CAAoC,UAAa;;IAE5F,IAAI,OAAO,UAAU,KAAK,QAAQ,EAClC,CAAC;QACA;;;WAGG;QACH,MAAA,UAAU,CAAC,gBAAgB,qCAA3B,UAAU,CAAC,gBAAgB,IAAM,gBAAgB,EAAC;IACnD,CAAC;IAED,OAAO,UAAU,CAAA;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAyB,GAAM;IAErE,4BAA4B,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAE1C,OAAO,GAAG,CAAA;AACX,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB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,CAAC;wBAErD;;;;;2BAKG;wBACH,IAAI,CAAC,IAAI,EACT,CAAC;4BACA,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,sBAAsB,IAAI,GAAG,CAAC,CAAC;wBAC3D,CAAC;oBAEF,CAAC,CAAC,CACF;gBACF,CAAC;YACF,CAAC,CAAC,CACF;YAED;;;eAGG;YACH,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EACnB,CAAC;gBACA,IAAI,GAAG,GAAG,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,GAAG,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAEhH,+CAA+C;gBAC/C,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;gBAChB,0CAA0C;gBAC1C,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;gBACxB,mDAAmD;gBACnD,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC;gBAE7B,MAAM,GAAG,CAAC;YACX,CAAC;QACF,CAAC;IAEF,CAAC;IAED,OAAO,IAAY,CAAA;AACpB,CAAC","sourcesContent":["/**\n * 處理 package.json exports 欄位的工具模組\n * Utility module for handling package.json exports field\n */\nimport { IPackageJson } from '@ts-type/package-dts/package-json';\nimport { PackageExportsEntry, PackageExportsFallback } from '@ts-type/package-dts/types/package.json';\nimport { pathExistsSync } from 'fs-extra';\nimport { findRootLazy } from '@yarn-tool/find-root';\nimport { resolvePackage, resolvePackageRoot } from '@yarn-tool/require-resolve';\n\n/**\n * 在 exports 物件中添加 package.json entry 的核心函數\n * Core function to add package.json entry in exports object\n *\n * 確保 exports 包含 './package.json' 入口點,讓外部可以匯入 package.json\n * Ensure exports includes './package.json' entry point for external package.json import\n *\n * @template T - exports 欄位類型 / exports field type\n * @param {T} pkgExports - package.json 的 exports 物件 / exports object from package.json\n * @returns {T} 修正後的 exports 物件 / Corrected exports object\n */\nexport function _pkgExportsAddPJsonEntryCore<T extends IPackageJson[\"exports\"]>(pkgExports: T)\n{\n\tif (typeof pkgExports === 'object')\n\t{\n\t\t/**\n\t\t * 若 './package.json' entry 不存在則添加(`??=` 保留使用者自訂的值)\n\t\t * Add './package.json' entry if not exists (`??=` keeps a user-defined value)\n\t\t */\n\t\tpkgExports['./package.json'] ??= './package.json';\n\t}\n\n\treturn pkgExports\n}\n\n/**\n * 在 package.json 的 exports 欄位中添加 package.json entry\n * Add package.json entry to exports field in package.json\n *\n * @template T - package.json 類型 / package.json type\n * @param {T} pkg - package.json 物件 / package.json object\n * @returns {T} 修正後的 package.json 物件 / Corrected package.json object\n */\nexport function pkgExportsAddPJsonEntry<T extends IPackageJson>(pkg: T)\n{\n\t_pkgExportsAddPJsonEntryCore(pkg.exports);\n\n\treturn pkg\n}\n\n/**\n * 判斷是否為有效的 package exports entry\n * Determine if it's a valid package exports entry\n *\n * 檢查 entry 是否以 './' 開頭且值不為空\n * Check if entry starts with './' and value is not empty\n *\n * @param {string} entry - exports 的鍵名 / exports key name\n * @param {PackageExportsEntry | PackageExportsFallback} value - exports 的值 / exports value\n * @returns {boolean} 是否為有效的 PackageExportsEntry / Whether it's a valid PackageExportsEntry\n */\nexport function _isPackageExportsEntry(entry: (string & {}) | keyof keyof IPackageJson[\"exports\"],\n\tvalue: PackageExportsEntry | PackageExportsFallback,\n): value is PackageExportsEntry\n{\n\treturn entry.startsWith('./') && !!(value ?? false)\n}\n\n/**\n * 驗證 package exports 路徑是否存在\n * Verify if package exports paths exist\n *\n * 檢查 exports 中定義的所有檔案路徑是否存在於檔案系統中\n * Check if all file paths defined in exports exist in the file system\n *\n * @template T - package.json 類型 / package.json type\n * @param {T} pkg - package.json 物件 / package.json object\n * @param {object} options - 選項 / Options\n * @param {string} options.cwd - 當前工作目錄 / Current working directory\n * @returns {null} 無返回值 / No return value\n * @throws {Error} 當 exports 路徑不存在時拋出錯誤 / Throws error when exports paths don't exist\n */\nexport function pkgExportsVerify<T extends IPackageJson>(pkg: T, options?: {\n\tcwd?: string,\n})\n{\n\tif (typeof pkg.exports === 'object')\n\t{\n\t\t/**\n\t\t * 尋找套件根目錄;僅在「非工作區且找得到 package.json」時才驗證,\n\t\t * 工作區情境下交由各成員套件自行驗證,避免重複或誤報\n\t\t * Find the package root; verify only when it is not a workspace and a\n\t\t * package.json exists, since workspace members verify themselves\n\t\t */\n\t\tconst rootData = findRootLazy({\n\t\t\tcwd: options?.cwd,\n\t\t});\n\n\t\tif (!rootData.isWorkspace && rootData.pkg)\n\t\t{\n\t\t\tconst list: string[] = [];\n\t\t\t/**\n\t\t\t * 遍歷所有 exports entry 檢查路徑\n\t\t\t * Iterate all exports entries to check paths\n\t\t\t */\n\t\t\tObject.entries(pkg.exports)\n\t\t\t\t.forEach(([entry, value]) =>\n\t\t\t\t{\n\t\t\t\t\tif (_isPackageExportsEntry(entry, value))\n\t\t\t\t\t{\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * 以套件根目錄建立解析器,讓 `./xxx` 相對路徑能解析為實際檔案位置\n\t\t\t\t\t\t * Build a resolver from the package root so `./xxx` relative\n\t\t\t\t\t\t * paths can be resolved to their real file locations\n\t\t\t\t\t\t */\n\t\t\t\t\t\tconst _ = resolvePackage(rootData.pkg);\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * 將值轉換為陣列並檢查每個檔案路徑\n\t\t\t\t\t\t * Convert value to array and check each file path\n\t\t\t\t\t\t */\n\t\t\t\t\t\t([typeof value === 'string' ? value : Object.values(value)] as string[])\n\t\t\t\t\t\t\t.flat()\n\t\t\t\t\t\t\t.forEach(file =>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * 跳過包含萬用字元 '*' 的路徑檢查\n\t\t\t\t\t\t\t\t * Skip path check for wildcard '*' patterns\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\tif (file.includes?.('*'))\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst bool = pathExistsSync(_.resolveLocation(file));\n\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * 先收集所有錯誤再一次性拋出,\n\t\t\t\t\t\t\t\t * 讓使用者一次看到全部問題而非逐次修正\n\t\t\t\t\t\t\t\t * Collect all errors before throwing so users see\n\t\t\t\t\t\t\t\t * every problem at once instead of fixing one by one\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\tif (!bool)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlist.push(`path of '${entry}' does not exist: '${file}'`);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t;\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t;\n\n\t\t\t/**\n\t\t\t * 若有錯誤則拋出包含詳細資訊的錯誤\n\t\t\t * Throw error with details if there are any issues\n\t\t\t */\n\t\t\tif (list.length > 0)\n\t\t\t{\n\t\t\t\tlet err = new Error(`Invalid package exports: ${rootData.pkg}\\n${list.slice().map(v => ` - ${v}`).join('\\n')}`);\n\n\t\t\t\t// @ts-ignore - 附加錯誤詳細資訊 / Attach error details\n\t\t\t\terr.list = list;\n\t\t\t\t// @ts-ignore - 附加根目錄資訊 / Attach root data\n\t\t\t\terr.rootData = rootData;\n\t\t\t\t// @ts-ignore - 附加 exports 資訊 / Attach exports info\n\t\t\t\terr.pkgExports = pkg.exports;\n\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\n\t}\n\n\treturn null as null\n}\n"]}
|
|
@@ -98,7 +98,7 @@ export declare function createWorkspaceRootScripts(): {
|
|
|
98
98
|
"postpublishOnly:ws-root-changelog": string;
|
|
99
99
|
preversion: EnumScriptsEntry;
|
|
100
100
|
postversion: string;
|
|
101
|
-
version:
|
|
101
|
+
version: EnumScriptsEntry;
|
|
102
102
|
"lerna:publish": string;
|
|
103
103
|
"build:all": string;
|
|
104
104
|
"build:since": string;
|
|
@@ -94,7 +94,10 @@ function fixPkgScriptsAuto(scripts, rootData, options) {
|
|
|
94
94
|
*/
|
|
95
95
|
function fixWsRootScriptsAuto(scripts, options) {
|
|
96
96
|
return _fixScriptsAuto(scripts, options, (_scripts) => {
|
|
97
|
-
_fillMissingScripts(_scripts,
|
|
97
|
+
_fillMissingScripts(_scripts, createWorkspaceRootScripts());
|
|
98
|
+
if ((0, dummy_1.isDummyEchoMaybe)(scripts === null || scripts === void 0 ? void 0 : scripts.version)) {
|
|
99
|
+
_scripts.version = "node --run prepublishOnly:lerna" /* EnumScriptsEntry.VERSION_LERNA */;
|
|
100
|
+
}
|
|
98
101
|
});
|
|
99
102
|
}
|
|
100
103
|
/**
|
|
@@ -121,6 +124,7 @@ function createWorkspaceRootScripts() {
|
|
|
121
124
|
* @returns 共用 scripts 模板
|
|
122
125
|
*/
|
|
123
126
|
function createSharedScriptsAuto(rootData) {
|
|
127
|
+
var _a, _b;
|
|
124
128
|
/** 預設測試腳本:尚無測試時以佔位訊息提示 */
|
|
125
129
|
let sharedScript = {
|
|
126
130
|
"test": "echo \"Error: no test specified\"" /* EnumScriptsEntry.NO_TEST_SPECIFIED */,
|
|
@@ -132,11 +136,17 @@ function createSharedScriptsAuto(rootData) {
|
|
|
132
136
|
* 讓發布前先跑一次版本遞增流程
|
|
133
137
|
*/
|
|
134
138
|
if (rootData.isRoot && !rootData.isWorkspace) {
|
|
135
|
-
sharedScript.prepublishOnly
|
|
139
|
+
if ((0, dummy_1.isDummyEchoMaybe)(sharedScript.prepublishOnly)) {
|
|
140
|
+
delete sharedScript.prepublishOnly;
|
|
141
|
+
}
|
|
142
|
+
(_a = sharedScript.prepublishOnly) !== null && _a !== void 0 ? _a : (sharedScript.prepublishOnly = "node --run preversion" /* EnumScriptsEntry.RUN_PREVERSION */);
|
|
136
143
|
}
|
|
137
144
|
if (rootData.hasWorkspace) {
|
|
138
145
|
if (rootData.isPkg) {
|
|
139
|
-
sharedScript.version
|
|
146
|
+
if ((0, dummy_1.isDummyEchoMaybe)(sharedScript.version)) {
|
|
147
|
+
delete sharedScript.version;
|
|
148
|
+
}
|
|
149
|
+
(_b = sharedScript.version) !== null && _b !== void 0 ? _b : (sharedScript.version = "node --run prepublishOnly:lerna" /* EnumScriptsEntry.VERSION_LERNA */);
|
|
140
150
|
}
|
|
141
151
|
}
|
|
142
152
|
else if (rootData.isRoot) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts-auto.js","sourceRoot":"","sources":["scripts-auto.ts"],"names":[],"mappings":";;AA6EA,kEAQC;AAUD,8CAmBC;AAWD,
|
|
1
|
+
{"version":3,"file":"scripts-auto.js","sourceRoot":"","sources":["scripts-auto.ts"],"names":[],"mappings":";;AA6EA,kEAQC;AAUD,8CAmBC;AAWD,oDAWC;AAUD,gEAGC;AAcD,0DAmDC;AAWD,8DAMC;AA/ND,uCAA4E;AAC5E,iDAAkF;AAClF,+DAA0F;AAC1F,iEAAoE;AACpE,uEAAgF;AAChF,mDAA2D;AAY3D;;;;GAIG;AACH,SAAS,eAAe,CAAC,OAAgC,EAAE,OAAwC,EAAE,IAAiC;IAErI,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,EAC1B,CAAC;QACA,OAAO,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IACtB,CAAC;IAED,MAAM,QAAQ,GAAa,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IAEzC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEf,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,OAAiB,EAAE,MAA8B;IAE7E,MAAM;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,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AEf,OAAO,YAAY,CAAC;AACrB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,yBAAyB,CAAC,OAAgC,EAAE,YAAqC;IAEhH,OAAO,mBAAmB,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EAAE;QACzC,GAAG,IAAA,oCAAsB,GAAE;QAC3B,GAAG,YAAY;KACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * package.json scripts 自動設定模組\n *\n * 依 rootData 表達的專案角色(根目錄 / workspace / 一般套件)套用對應的預設腳本與修復規則,\n * 作為各初始化與修復流程取得 scripts 預設值的統一入口\n */\nimport { IPackageJson } from '@ts-type/package-dts/package-json';\nimport { IFindRootReturnType } from '@yarn-tool/find-root';\nimport { EnumScriptsEntry, scriptsEntryIsNoTestSpecified } from './scripts';\nimport { isDummyEchoMaybe, isDummyEchoMaybeOrEmpty } from '../util/scripts/dummy';\nimport { defaultPkgScripts, defaultPkgNotOldExists } from '../preset/scripts/pkg-scripts';\nimport { defaultRootScripts } from '../preset/scripts/root-scripts';\nimport { defaultWorkspaceRootScripts } from '../preset/scripts/ws-root-scripts';\nimport { fillDummyScripts } from '../preset/scripts/dummy';\n\n/** 已初始化的 scripts 物件型別 */\ntype IScripts = NonNullable<IPackageJson['scripts']>;\n\n/** 預設腳本補齊的選項 */\nexport interface IFillScriptsOptions\n{\n\t/** 跳過預設腳本補齊,僅確保 scripts 物件存在 */\n\tnoFillScripts?: boolean;\n}\n\n/**\n * 統一處理 noFillScripts 與 scripts 初始化:\n * noFillScripts 時略過補齊、僅確保 scripts 物件存在,\n * 否則建立已初始化的 scripts 後交由 fill 補齊缺失腳本\n */\nfunction _fixScriptsAuto(scripts: IPackageJson['scripts'], options: IFillScriptsOptions | undefined, fill: (scripts: IScripts) => void): IScripts\n{\n\tif (options?.noFillScripts)\n\t{\n\t\treturn scripts ?? {};\n\t}\n\n\tconst _scripts: IScripts = scripts ?? {};\n\n\tfill(_scripts);\n\n\treturn _scripts;\n}\n\n/**\n * 以 source 補齊尚不存在的腳本鍵(??=),不覆寫既有值\n */\nfunction _fillMissingScripts(scripts: IScripts, source: Record<string, string>): IScripts\n{\n\tObject\n\t\t.entries(source)\n\t\t.forEach(([key, value]) =>\n\t\t{\n\t\t\tscripts[key] ??= value;\n\t\t})\n\t;\n\n\treturn scripts;\n}\n\n/**\n * 取得 workspace 根目錄的預設腳本並補上 dummy 佔位生命週期腳本,\n * prefix 作為 echo 前綴,用於區分腳本的來源\n */\nfunction _workspaceRootScripts(prefix?: string)\n{\n\treturn fillDummyScripts(defaultWorkspaceRootScripts(), prefix);\n}\n\n/**\n * 移除「未指定測試」的佔位 test 腳本\n *\n * 佔位訊息代表測試尚未設定,留著會掩蓋後續補上的真實測試腳本\n *\n * @param scripts - package.json 的 scripts 欄位\n * @returns 原地修改後的 scripts\n */\nexport function removeNoTestSpecifiedScript(scripts: IPackageJson['scripts'])\n{\n\tif (scripts && scriptsEntryIsNoTestSpecified(scripts.test))\n\t{\n\t\tdelete scripts.test;\n\t}\n\n\treturn scripts;\n}\n\n/**\n * 依 rootData 補齊一般套件的預設腳本並修復 preversion\n *\n * @param scripts - package.json 的 scripts 欄位\n * @param rootData - 根目錄資訊,用於判定是否為根套件\n * @param options - 補齊選項\n * @returns 補齊後的 scripts\n */\nexport function fixPkgScriptsAuto(scripts: IPackageJson['scripts'], rootData: IFindRootReturnType, options?: IFillScriptsOptions): IScripts\n{\n\treturn _fixScriptsAuto(scripts, options, (_scripts) =>\n\t{\n\t\t/**\n\t\t * 預設腳本僅補上尚不存在的鍵,\n\t\t * 讓使用者自訂的同名腳本不被預設值覆蓋\n\t\t */\n\t\t_fillMissingScripts(_scripts, defaultPkgScripts());\n\n\t\t/**\n\t\t * 非根套件:preversion 缺失或僅是 dummy echo 時,\n\t\t * 補上會實際執行測試的 preversion,避免發布前未經驗證\n\t\t */\n\t\tif (!rootData.isRoot && !_scripts['_preversion']?.length && isDummyEchoMaybeOrEmpty(_scripts.preversion))\n\t\t{\n\t\t\t_scripts.preversion = EnumScriptsEntry.preversion;\n\t\t}\n\t});\n}\n\n/**\n * 補齊 workspace 根目錄的預設腳本\n *\n * 只填補尚不存在的腳本,不覆寫使用者自訂的同名腳本\n *\n * @param scripts - package.json 的 scripts 欄位\n * @param options - 補齊選項\n * @returns 補齊後的 scripts\n */\nexport function fixWsRootScriptsAuto(scripts: IPackageJson['scripts'], options?: IFillScriptsOptions): IScripts\n{\n\treturn _fixScriptsAuto(scripts, options, (_scripts) =>\n\t{\n\t\t_fillMissingScripts(_scripts, createWorkspaceRootScripts());\n\n\t\tif (isDummyEchoMaybe(scripts?.version))\n\t\t{\n\t\t\t_scripts.version = EnumScriptsEntry.VERSION_LERNA;\n\t\t}\n\t});\n}\n\n/**\n * 建立新 workspace 根目錄專用的預設 scripts\n *\n * 以 workspace 根目錄預設腳本為底,再補上 dummy 佔位的生命週期腳本,\n * 已存在的腳本不會被覆蓋\n *\n * @returns 可直接寫入 package.json 的 scripts\n */\nexport function createWorkspaceRootScripts()\n{\n\treturn _workspaceRootScripts('workspaces');\n}\n\n/**\n * 建立專案初始化流程共用的 scripts 模板\n *\n * 依 rootData 的角色補上對應腳本:\n *\n * - 單一專案根目錄:合併根目錄專用的發布與版本腳本\n * - workspaces 根目錄:腳本交由 workspaces 設定管理,不額外追加\n * - 一般套件:維持共用模板\n *\n * @param rootData - 根目錄資訊\n * @returns 共用 scripts 模板\n */\nexport function createSharedScriptsAuto(rootData: IFindRootReturnType)\n{\n\t/** 預設測試腳本:尚無測試時以佔位訊息提示 */\n\tlet sharedScript: IScripts = {\n\t\t\"test\": EnumScriptsEntry.NO_TEST_SPECIFIED,\n\t};\n\n\t/** 補上 dummy 佔位的生命週期腳本 */\n\tfillDummyScripts(sharedScript);\n\n\t/**\n\t * 單一專案根目錄:prepublishOnly 接續 preversion,\n\t * 讓發布前先跑一次版本遞增流程\n\t */\n\tif (rootData.isRoot && !rootData.isWorkspace)\n\t{\n\t\tif (isDummyEchoMaybe(sharedScript.prepublishOnly))\n\t\t{\n\t\t\tdelete sharedScript.prepublishOnly;\n\t\t}\n\t\tsharedScript.prepublishOnly ??= EnumScriptsEntry.RUN_PREVERSION;\n\t}\n\n\tif (rootData.hasWorkspace)\n\t{\n\t\tif (rootData.isPkg)\n\t\t{\n\t\t\tif (isDummyEchoMaybe(sharedScript.version))\n\t\t\t{\n\t\t\t\tdelete sharedScript.version;\n\t\t\t}\n\t\t\tsharedScript.version ??= EnumScriptsEntry.VERSION_LERNA;\n\t\t}\n\t}\n\telse if (rootData.isRoot)\n\t{\n\t\tsharedScript = {\n\t\t\t...sharedScript,\n\t\t\t...defaultRootScripts(),\n\t\t};\n\t}\n\n\t/**\n\t * preversion 先保留 echo 提示,再接上會實際執行測試的指令\n\t */\n\tsharedScript.preversion = [\n\t\t\"echo preversion\",\n\t\tEnumScriptsEntry.preversion,\n\t].join(' && ');\n\n\treturn sharedScript;\n}\n\n/**\n * 為新建立的套件補上完整預設腳本\n *\n * 以新套件專用的完整預設腳本為底,套用共用模板,僅補上尚不存在的腳本\n *\n * @param scripts - package.json 的 scripts 欄位\n * @param sharedScript - 共用 scripts 模板\n * @returns 補齊後的 scripts\n */\nexport function fillNewPackageScriptsAuto(scripts: IPackageJson['scripts'], sharedScript: IPackageJson['scripts']): IScripts\n{\n\treturn _fillMissingScripts(scripts ?? {}, {\n\t\t...defaultPkgNotOldExists(),\n\t\t...sharedScript,\n\t});\n}\n"]}
|
package/lib/field/scripts.d.ts
CHANGED
|
@@ -41,7 +41,11 @@ export declare const enum EnumScriptsEntry {
|
|
|
41
41
|
/** 更新所有依賴至最新版 */
|
|
42
42
|
NCU = "yarn-tool ncu -u",
|
|
43
43
|
/** 排序 package.json 欄位 */
|
|
44
|
-
SORT_PACKAGE_JSON = "yarn-tool sort"
|
|
44
|
+
SORT_PACKAGE_JSON = "yarn-tool sort",
|
|
45
|
+
/** Lerna 版本管理 */
|
|
46
|
+
VERSION_LERNA = "node --run prepublishOnly:lerna",
|
|
47
|
+
/** 執行 preversion 腳本 */
|
|
48
|
+
RUN_PREVERSION = "node --run preversion"
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
47
51
|
* 判斷腳本命令是否為「未指定測試」的佔位訊息
|
package/lib/field/scripts.js
CHANGED
|
@@ -47,6 +47,10 @@ var EnumScriptsEntry;
|
|
|
47
47
|
EnumScriptsEntry["NCU"] = "yarn-tool ncu -u";
|
|
48
48
|
/** 排序 package.json 欄位 */
|
|
49
49
|
EnumScriptsEntry["SORT_PACKAGE_JSON"] = "yarn-tool sort";
|
|
50
|
+
/** Lerna 版本管理 */
|
|
51
|
+
EnumScriptsEntry["VERSION_LERNA"] = "node --run prepublishOnly:lerna";
|
|
52
|
+
/** 執行 preversion 腳本 */
|
|
53
|
+
EnumScriptsEntry["RUN_PREVERSION"] = "node --run preversion";
|
|
50
54
|
})(EnumScriptsEntry || (exports.EnumScriptsEntry = EnumScriptsEntry = {}));
|
|
51
55
|
/**
|
|
52
56
|
* 判斷腳本命令是否為「未指定測試」的佔位訊息
|
package/lib/field/scripts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["scripts.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["scripts.ts"],"names":[],"mappings":";;;AAsEA,sEAGC;AAxED;;;;;GAKG;AACH,IAAkB,gBAoDjB;AApDD,WAAkB,gBAAgB;IAEjC,gCAAgC;IAChC,wDAAoC,CAAA;IACpC,+CAA+C;IAC/C,2HAAuG,CAAA;IAEvG,aAAa;IACb,4DAAwC,CAAA;IAExC;;OAEG;IACH,mFAA+D,CAAA;IAC/D,+FAA2E,CAAA;IAE3E,yBAAyB;IACzB,2EAAuD,CAAA;IACvD,8BAA8B;IAC9B,0FAAsE,CAAA;IAEtE,qCAAqC;IACrC,8KAA0J,CAAA;IAC1J,uCAAuC;IACvC,mGAA+E,CAAA;IAC/E,eAAe;IACf,iGAA6E,CAAA;IAC7E,wBAAwB;IACxB,+FAA2E,CAAA;IAE3E,0BAA0B;IAC1B,yFAAqE,CAAA;IACrE,2BAA2B;IAC3B,+FAA2E,CAAA;IAE3E,4BAA4B;IAC5B,gDAA4B,CAAA;IAE5B,uBAAuB;IACvB,uFAAmE,CAAA;IACnE,4BAA4B;IAC5B,oEAAgD,CAAA;IAChD,iBAAiB;IACjB,4CAAwB,CAAA;IACxB,yBAAyB;IACzB,wDAAoC,CAAA;IAEpC,iBAAiB;IACjB,qEAAiD,CAAA;IAEjD,uBAAuB;IACvB,4DAAwC,CAAA;AACzC,CAAC,EApDiB,gBAAgB,gCAAhB,gBAAgB,QAoDjC;AAED;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CAAC,KAAa;IAE1D,OAAO,KAAK,gGAA4C,IAAI,KAAK,iFAAuC,CAAA;AACzG,CAAC","sourcesContent":["\n/**\n * 常用腳本命令字串列舉\n *\n * 集中管理預設腳本的命令內容,讓各預設腳本模組引用同一份字串,\n * 避免命令在多處重複定義後逐漸不一致\n */\nexport const enum EnumScriptsEntry\n{\n\t/** 以 Jest 執行測試,且在沒有測試檔時仍視為成功 */\n\tJEST_TEST = \"jest --passWithNoTests\",\n\t/** 以 Node.js 原生 test runner(經 tsx)執行測試並更新快照 */\n\tNODE_TEST = \"node --run test:node:bin -- **/*.node-spec.ts **/*.node-test.ts **/*.spec.ts **/*.test.ts\",\n\n\t/** 預設測試命令 */\n\tDEFAULT_TEST = \"node --run test:node --\",\n\n\t/**\n\t * TypeScript 型別檢查:以 `&` 連結 echo,讓檢查完成後仍有成功訊息\n\t */\n\tTSC_TEST = \"tsc --noEmit & echo Type checking completed (main)\",\n\tTSC_TEST2 = \"cd test && tsc --noEmit & echo Type checking completed (test)\",\n\n\t/** 未指定測試的預設錯誤訊息(不中斷流程)*/\n\tNO_TEST_SPECIFIED = \"echo \\\"Error: no test specified\\\"\",\n\t/** 同上,但以 `exit 1` 讓腳本以失敗結束 */\n\tNO_TEST_SPECIFIED_EXIT = \"echo \\\"Error: no test specified\\\" && exit 1\",\n\n\t/** 以 dts-bundle-generator 產生打包型別檔 */\n\tBUILD_DTS_BUNDLE = \"ynpx @bluelovers/dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle\",\n\t/** 複製已存在的型別檔到 dist(Windows copy 指令) */\n\tBUILD_DTS_COPY = \"copy .\\\\src\\\\index.d.ts .\\\\dist\\\\index.d.ts & echo build:dts\",\n\t/** 僅輸出型別宣告檔 */\n\tBUILD_DTS_TSC_EMIT = \"tsc --emitDeclarationOnly --declaration --noEmit false\",\n\t/** 完整型別建構:先 emit 再複製 */\n\tBUILD_DTS_TSC = \"node --run build:dts:tsc:emit & node --run build:dts:copy\",\n\n\t/** 以 TSDX 建構 JS bundle */\n\tBUILD_TSDX = \"ynpx @bluelovers/tsdx build --target node --name index\",\n\t/** 建構 JS 與打包型別檔(兩者依序執行) */\n\tBUILD_TSDX_AND_DTS = \"node --run build:tsdx && node --run build:dts:bundle\",\n\n\t/** 版本遞增前先跑測試,避免發布未經驗證的版本 */\n\tpreversion = \"pnpm run test\",\n\n\t/** 發布前檢查套件二進位檔是否可執行 */\n\tPREPUBLISH_ONLY_CHECK_BIN = \"ynpx --quiet @yarn-tool/check-pkg-bin\",\n\t/** 顯示目前生效的 TypeScript 設定 */\n\tTSC_SHOW_CONFIG = \"ynpx get-current-tsconfig -p\",\n\t/** 更新所有依賴至最新版 */\n\tNCU = \"yarn-tool ncu -u\",\n\t/** 排序 package.json 欄位 */\n\tSORT_PACKAGE_JSON = \"yarn-tool sort\",\n\n\t/** Lerna 版本管理 */\n\tVERSION_LERNA = \"node --run prepublishOnly:lerna\",\n\n\t/** 執行 preversion 腳本 */\n\tRUN_PREVERSION = \"node --run preversion\",\n}\n\n/**\n * 判斷腳本命令是否為「未指定測試」的佔位訊息\n *\n * 同時涵蓋會中斷(`exit 1`)與不會中斷兩種變體,\n * 讓呼叫端不必自行比較兩組字串\n *\n * @param value - 要檢查的腳本命令\n * @returns 是否為未指定測試的佔位訊息\n */\nexport function scriptsEntryIsNoTestSpecified(value: string): value is EnumScriptsEntry.NO_TEST_SPECIFIED_EXIT | EnumScriptsEntry.NO_TEST_SPECIFIED\n{\n\treturn value === EnumScriptsEntry.NO_TEST_SPECIFIED_EXIT || value === EnumScriptsEntry.NO_TEST_SPECIFIED\n}\n"]}
|
|
@@ -57,7 +57,7 @@ export declare function defaultWorkspaceRootScripts(): {
|
|
|
57
57
|
preversion: EnumScriptsEntry;
|
|
58
58
|
/** Fix after version bump */
|
|
59
59
|
postversion: string;
|
|
60
|
-
version:
|
|
60
|
+
version: EnumScriptsEntry;
|
|
61
61
|
/** Lerna publish */
|
|
62
62
|
"lerna:publish": string;
|
|
63
63
|
"build:all": string;
|
|
@@ -72,7 +72,7 @@ function defaultWorkspaceRootScripts() {
|
|
|
72
72
|
"preversion": "pnpm run test" /* EnumScriptsEntry.preversion */,
|
|
73
73
|
/** Fix after version bump */
|
|
74
74
|
"postversion": "yarn-tool fix-all --noStaticFiles",
|
|
75
|
-
'version':
|
|
75
|
+
'version': "node --run prepublishOnly:lerna" /* EnumScriptsEntry.VERSION_LERNA */,
|
|
76
76
|
/** Lerna publish */
|
|
77
77
|
"lerna:publish": bumpVersion(),
|
|
78
78
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-root-scripts.js","sourceRoot":"","sources":["ws-root-scripts.ts"],"names":[],"mappings":";;AAkBA,wCAaC;AAiBD,kEAkGC;AAlJD,+DAAiE;AAGjE;;;;;;;;;;;;;;GAcG;AACH,SAAgB,cAAc,CAAmB,MAAS;IAEzD,MAAM,GAAG,GAAG,GAAG,MAAM,MAAe,CAAC;IACrC,MAAM,KAAK,GAAG,GAAG,MAAM,QAAiB,CAAC;IAEzC,OAAO;QACN,CAAC,GAAG,CAAC,EAAE,oBAAoB,MAAM,kBAAkB;QACnD,CAAC,KAAK,CAAC,EAA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,EAAE,2CAA2C;QAEnE,yBAAyB;QACzB,uBAAuB,EAAE,8CAA8C;QAEvE,yBAAyB;QACzB,KAAK,EAAE,mBAAmB;QAC1B,UAAU,+CAAsB;QAChC,QAAQ,EAAE,uBAAuB;QAEjC,sBAAsB;QACtB,mBAAmB,EAAE,sEAAsE;QAC3F,wBAAwB,2DAAoC;QAC5D,sBAAsB,EAAE,mBAAmB;QAE3C,YAAY;QACZ,iBAAiB,EAAE,qEAAqE;QAExF,gBAAgB;QAChB,mCAAmC,EAAE,6LAA6L;QAElO,sBAAsB;QACtB,sDAAsD;KACtD,CAAA;AACF,CAAC","sourcesContent":["import { defaultSharedRootScripts } from './shared-root-scripts';\nimport { EnumScriptsEntry } from '../../field/scripts';\n\n/**\n * 產生「全部執行」與「僅變更執行」腳本對\n *\n * 為指定腳本名稱產生對應的 `:all`(全部工作區)與 `:since`(僅變更)版本\n *\n * @template T - 基礎腳本名稱\n * @param script - 基礎腳本名稱\n * @returns 包含 all 與 since 變體的腳本物件\n *\n * @example\n * ```typescript\n * _runAllOrSince('test')\n * // 返回: { 'test:all': 'yarn-tool ws run test --concurrency 1', 'test:since': 'node --run test:all -- --since' }\n * ```\n */\nexport function _runAllOrSince<T extends string>(script: T)\n{\n\tconst all = `${script}:all` as const;\n\tconst since = `${script}:since` as const;\n\n\treturn {\n\t\t[all]: `yarn-tool ws run ${script} --concurrency 1`,\n\t\t[since]: `node --run ${script}:all -- --since`,\n\t} as ({\n\t\t[x in `${T}:all`]: string;\n\t} & {\n\t\t[y in `${T}:since`]: string;\n\t})\n}\n\n/**\n * 工作區根目錄預設腳本\n *\n * 適用於 monorepo 工作區根目錄的完整管理腳本集合\n *\n * @returns 包含工作區管理腳本的物件\n *\n * 核心功能:\n * - 跨工作區腳本執行(全部或僅變更)\n * - Lerna 發布流程\n * - 發布前檢查與準備\n * - 相依工作區連結修復\n * - 統一依賴更新\n * - 發布後變更日誌更新\n */\nexport function defaultWorkspaceRootScripts()\n{\n\t/**\n\t * 產生 Lerna 版本遞增與發布命令\n\t *\n\t * @param bump - 版本遞增類型(patch|minor|major)\n\t * @returns 組合命令字串\n\t */\n\tconst bumpVersion = (bump?: 'major' | 'minor' | 'patch') => {\n\t\treturn [\n\t\t\t`node --run prepublishOnly:root`,\n\t\t\t`lerna publish --no-private` + (bump ? ` --yes --bump ${bump}` : ''),\n\t\t\t`pnpm run postpublishOnly`,\n\t\t].join(' && ')\n\t}\n\n\treturn {\n\t\t...defaultSharedRootScripts(),\n\n\t\t\"test\": \"node --run test:since\",\n\n\t\t/**\n\t\t * 動態產生 all/since 腳本對\n\t\t */\n\t\t..._runAllOrSince('test'),\n\t\t// ..._runAllOrSince('test:tsd'),\n\t\t..._runAllOrSince('test:snapshot'),\n\t\t..._runAllOrSince('build'),\n\t\t// ..._runAllOrSince('review'),\n\t\t// ..._runAllOrSince('coverage'),\n\t\t// ..._runAllOrSince('lint'),\n\n\t\t/** Test before version bump */\n\t\t\"preversion\": EnumScriptsEntry.preversion,\n\n\t\t/** Fix after version bump */\n\t\t\"postversion\": \"yarn-tool fix-all --noStaticFiles\",\n\n\t\t'version': EnumScriptsEntry.VERSION_LERNA,\n\n\t\t/** Lerna publish */\n\t\t\"lerna:publish\": bumpVersion(),\n\n\t\t/**\n\t\t * 動態產生各類版本發布腳本\n\t\t */\n\t\t...([\n\t\t\t'patch',\n\t\t\t'minor',\n\t\t\t'major',\n\t\t] as const).reduce((a, bump, idx) => {\n\t\t\t/**\n\t\t\t * 只在第一個(patch)迭代建立 `yes` 與 `yes:force` 兩個預設別名,\n\t\t\t * 讓使用者不必指定版本類型也能一鍵發布\n\t\t\t */\n\t\t\tif (idx === 0)\n\t\t\t{\n\t\t\t\ta[`lerna:publish:yes`] = `node --run lerna:publish:yes:${bump} --`;\n\t\t\t\ta[`lerna:publish:yes:force`] = `lerna publish --no-private --yes --bump ${bump} --force-publish`;\n\t\t\t}\n\t\t\ta[`lerna:publish:yes:${bump}`] = bumpVersion(bump);\n\t\t\treturn a\n\t\t}, {} as Record<string, string>),\n\n\t\t/** 發布前檢查與修復 */\n\t\t\"prepublishOnly:root\": \"node --run prepublishOnly:check-bin && node --run prepare:fix-ws-links\",\n\n\t\t/** Lockfile sync */\n\t\t\"prepublishOnly:lockfile\": \"ynpx --quiet sync-lockfile\",\n\n\t\t/** pkg bin check */\n\t\t\"prepublishOnly:check-bin\": EnumScriptsEntry.PREPUBLISH_ONLY_CHECK_BIN,\n\n\t\t/** Workspace links fix */\n\t\t\"prepare:fix-ws-links\": \"echo ynpx --quiet @yarn-tool/fix-ws-links\",\n\n\t\t/** Pre-publish update */\n\t\t\"prepublishOnly:update\": \"pnpm run ncu && node --run sort-package-json\",\n\n\t\t/** Dependency updates */\n\t\t\"ncu\": \"node --run ncu:ws\",\n\t\t\"ncu:root\": EnumScriptsEntry.NCU,\n\t\t\"ncu:ws\": \"yarn-tool ncu -u --AA\",\n\n\t\t/** package.json 排序 */\n\t\t\"sort-package-json\": \"node --run sort-package-json:root && node --run sort-package-json:ws\",\n\t\t\"sort-package-json:root\": EnumScriptsEntry.SORT_PACKAGE_JSON,\n\t\t\"sort-package-json:ws\": \"yarn-tool ws sort\",\n\n\t\t/** 發布後執行 */\n\t\t\"postpublishOnly\": \"node --run postpublishOnly:ws-root-changelog & echo postpublishOnly\",\n\n\t\t/** 根目錄變更日誌更新 */\n\t\t\"postpublishOnly:ws-root-changelog\": \"ynpx ws-root-changelog & git add ./CHANGELOG.md & git commit ./CHANGELOG.md -m \\\"chore(changelog): update changelog toc in workspaces root\\\" & echo update changelog toc in workspaces root\",\n\n\t\t/** TypeScript 設定顯示 */\n\t\t// \"tsc:showConfig\": EnumScriptsEntry.TSC_SHOW_CONFIG,\n\t}\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IPackageJson } from '@ts-type/package-dts';
|
|
2
|
+
export declare function _isScriptExists<K extends Extract<keyof T, string> | (string & {}), T extends IPackageJson['scripts'] = IPackageJson['scripts']>(scripts: T, name: K): scripts is T & {
|
|
3
|
+
[key in K]: string & {};
|
|
4
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._isScriptExists = _isScriptExists;
|
|
4
|
+
function _isScriptExists(scripts, name) {
|
|
5
|
+
var _a;
|
|
6
|
+
return ((_a = scripts === null || scripts === void 0 ? void 0 : scripts[name]) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":";;AAEA,0CAKC;AALD,SAAgB,eAAe,CAAkH,OAAU,EAAE,IAAO;;IAInK,OAAO,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,IAAI,CAAC,0CAAE,MAAM,IAAG,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { IPackageJson } from '@ts-type/package-dts';\n\nexport function _isScriptExists<K extends Extract<keyof T, string> | (string & {}), T extends IPackageJson['scripts'] = IPackageJson['scripts']>(scripts: T, name: K): scripts is T & {\n\t[key in K]: string & {};\n}\n{\n\treturn scripts?.[name]?.length > 0;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarn-tool/pkg-entry-util",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.39",
|
|
4
4
|
"description": "用於處理 package.json entry 相關欄位的工具庫,包含 bin、exports、publishConfig 欄位的修復與驗證功能,並提供各類套件的預設 npm scripts(工作區根目錄、一般套件、根目錄套件)/ Utility for handling package.json entry fields including bin, exports, publishConfig fix/verification, plus preset npm scripts for workspace root, regular packages, and root packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yarn",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"publishConfig": {
|
|
85
85
|
"access": "public"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "709ecc0c135fbac5bf873d9e67e2b79ca4c5405d"
|
|
88
88
|
}
|