@yarn-tool/pkg-entry-util 3.0.14 → 3.0.15
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 +51 -0
- package/README.md +83 -13
- package/lib/field/bin.js +21 -6
- package/lib/field/bin.js.map +1 -1
- package/lib/field/exports.js +35 -12
- package/lib/field/exports.js.map +1 -1
- package/lib/field/fixEmpty.js +22 -0
- package/lib/field/fixEmpty.js.map +1 -1
- package/lib/field/publishConfig.js +13 -10
- package/lib/field/publishConfig.js.map +1 -1
- package/lib/field/scripts.d.ts +46 -1
- package/lib/field/scripts.js +46 -1
- package/lib/field/scripts.js.map +1 -1
- package/lib/preset/scripts/dummy.js +18 -5
- package/lib/preset/scripts/dummy.js.map +1 -1
- package/lib/preset/scripts/pkg-scripts.d.ts +12 -15
- package/lib/preset/scripts/pkg-scripts.js +14 -12
- package/lib/preset/scripts/pkg-scripts.js.map +1 -1
- package/lib/preset/scripts/root-scripts.d.ts +4 -3
- package/lib/preset/scripts/root-scripts.js +4 -1
- package/lib/preset/scripts/root-scripts.js.map +1 -1
- package/lib/preset/scripts/shared-root-scripts.d.ts +2 -0
- package/lib/preset/scripts/shared-root-scripts.js +2 -0
- package/lib/preset/scripts/shared-root-scripts.js.map +1 -1
- package/lib/preset/scripts/ws-root-scripts.d.ts +1 -0
- package/lib/preset/scripts/ws-root-scripts.js +16 -4
- package/lib/preset/scripts/ws-root-scripts.js.map +1 -1
- package/lib/util/scripts/dummy.d.ts +57 -0
- package/lib/util/scripts/dummy.js +57 -0
- package/lib/util/scripts/dummy.js.map +1 -1
- package/package.json +9 -7
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":";;;AA6DA,sEAGC;AA/DD;;;;;;;;GAQG;AACH,IAAkB,gBAqCjB;AArCD,WAAkB,gBAAgB;IAEjC,mFAAmF;IACnF,wDAAoC,CAAA;IACpC,uHAAuH;IACvH,kIAA8G,CAAA;IAE9G,oCAAoC;IACpC,4DAAwC,CAAA;IAExC;;;OAGG;IACH,0EAAsD,CAAA;IAEtD,gFAAgF;IAChF,2EAAuD,CAAA;IACvD,wFAAwF;IACxF,0FAAsE,CAAA;IAEtE,qGAAqG;IACrG,8KAA0J,CAAA;IAC1J,2GAA2G;IAC3G,mGAA+E,CAAA;IAC/E,6CAA6C;IAC7C,iGAA6E,CAAA;IAC7E,iEAAiE;IACjE,+FAA2E,CAAA;IAE3E,0DAA0D;IAC1D,yFAAqE,CAAA;IACrE,gFAAgF;IAChF,+FAA2E,CAAA;IAE3E,oGAAoG;IACpG,gDAA4B,CAAA;AAC7B,CAAC,EArCiB,gBAAgB,gCAAhB,gBAAgB,QAqCjC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,6BAA6B,CAAC,KAAa;IAE1D,OAAO,KAAK,gGAA4C,IAAI,KAAK,iFAAuC,CAAA;AACzG,CAAC","sourcesContent":["\n/**\n * 常用腳本命令字串列舉\n * Enum of common script command strings\n *\n * 集中管理預設腳本的命令內容,讓各預設腳本模組引用同一份字串,\n * 避免命令在多處重複定義後逐漸不一致\n * Centralizes the command strings so every preset script module shares a\n * single source, preventing drift caused by duplicated definitions\n */\nexport const enum EnumScriptsEntry\n{\n\t/** 以 Jest 執行測試,且在沒有測試檔時仍視為成功 / Run Jest tests, passing when no test files exist */\n\tJEST_TEST = \"jest --passWithNoTests\",\n\t/** 以 Node.js 原生 test runner(經 tsx)執行測試並更新快照 / Run tests via Node's native runner (through tsx) and update snapshots */\n\tNODE_TEST = \"tsx --test --test-update-snapshots **/*.node-spec.ts **/*.node-test.ts **/*.spec.ts **/*.test.ts\",\n\n\t/** 預設測試命令 / Default test command */\n\tDEFAULT_TEST = \"node --run test:node --\",\n\n\t/**\n\t * TypeScript 型別檢查:以 `&` 連結 echo,讓檢查完成後仍有成功訊息\n\t * Type check: chained with `&` so a completion message is printed afterward\n\t */\n\tTSC_TEST = \"tsc --noEmit & echo typescript check done\",\n\n\t/** 未指定測試的預設錯誤訊息(不中斷流程)/ Default \"no test specified\" message (does not abort) */\n\tNO_TEST_SPECIFIED = \"echo \\\"Error: no test specified\\\"\",\n\t/** 同上,但以 `exit 1` 讓腳本以失敗結束 / Same as above, but exits with code 1 to fail the script */\n\tNO_TEST_SPECIFIED_EXIT = \"echo \\\"Error: no test specified\\\" && exit 1\",\n\n\t/** 以 dts-bundle-generator 產生打包型別檔 / Generate a bundled declaration file with 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 指令)/ Copy an existing declaration file into dist (Windows copy command) */\n\tBUILD_DTS_COPY = \"copy .\\\\src\\\\index.d.ts .\\\\dist\\\\index.d.ts & echo build:dts\",\n\t/** 僅輸出型別宣告檔 / Emit declaration files only */\n\tBUILD_DTS_TSC_EMIT = \"tsc --emitDeclarationOnly --declaration --noEmit false\",\n\t/** 完整型別建構:先 emit 再複製 / Full type build: emit first, then copy */\n\tBUILD_DTS_TSC = \"node --run build:dts:tsc:emit & node --run build:dts:copy\",\n\n\t/** 以 TSDX 建構 JS bundle / Build the JS bundle with TSDX */\n\tBUILD_TSDX = \"ynpx @bluelovers/tsdx build --target node --name index\",\n\t/** 建構 JS 與打包型別檔(兩者依序執行)/ Build JS and bundled declarations (run in sequence) */\n\tBUILD_TSDX_AND_DTS = \"node --run build:tsdx && node --run build:dts:bundle\",\n\n\t/** 版本遞增前先跑測試,避免發布未經驗證的版本 / Run tests before a version bump so unverified code is never published */\n\tpreversion = \"pnpm run test\",\n}\n\n/**\n * 判斷腳本命令是否為「未指定測試」的佔位訊息\n * Check whether a script command is the \"no test specified\" placeholder\n *\n * 同時涵蓋會中斷(`exit 1`)與不會中斷兩種變體,\n * 讓呼叫端不必自行比較兩組字串\n * Covers both the aborting (`exit 1`) and non-aborting variants so callers\n * need not compare two literals themselves\n *\n * @param value - 要檢查的腳本命令 / the script command to check\n * @returns 是否為未指定測試的佔位訊息 / whether it is the \"no test specified\" placeholder\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"]}
|
|
@@ -28,9 +28,22 @@ const dummy_1 = require("../../util/scripts/dummy");
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
function _fillDummyScriptsCore(scripts, prefix, fields) {
|
|
31
|
+
/**
|
|
32
|
+
* 允許不傳入 scripts 時從空物件開始累積,
|
|
33
|
+
* 讓 `fillDummyScripts()` 可直接取得一份全新預設腳本
|
|
34
|
+
* Allow starting from an empty object when no scripts is passed, so
|
|
35
|
+
* `fillDummyScripts()` can produce a fresh default script set on its own
|
|
36
|
+
*/
|
|
31
37
|
// @ts-ignore
|
|
32
38
|
scripts !== null && scripts !== void 0 ? scripts : (scripts = {});
|
|
39
|
+
/** 整批腳本共用同一個 echo 前綴,確保輸出訊息可辨識來源套件 */
|
|
33
40
|
let text = (0, dummy_1._dummyEchoPrefix)(prefix);
|
|
41
|
+
/**
|
|
42
|
+
* 僅填補尚不存在的腳本鍵(`??=`),
|
|
43
|
+
* 保留使用者已自訂的腳本不被預設佔位符覆蓋
|
|
44
|
+
* Fill only missing keys (`??=`), leaving user-defined scripts
|
|
45
|
+
* untouched instead of overwriting them with placeholders
|
|
46
|
+
*/
|
|
34
47
|
fields.forEach(k => {
|
|
35
48
|
var _a;
|
|
36
49
|
// @ts-ignore
|
|
@@ -77,15 +90,15 @@ function fillDummyScripts(scripts, prefix) {
|
|
|
77
90
|
'preversion',
|
|
78
91
|
'version',
|
|
79
92
|
'prepublishOnly',
|
|
80
|
-
'postversion',
|
|
93
|
+
// 'postversion',
|
|
81
94
|
'publish',
|
|
82
95
|
'prepublish',
|
|
83
96
|
'postpublish',
|
|
84
97
|
'postpublishOnly',
|
|
85
|
-
'prepare',
|
|
86
|
-
'prepack',
|
|
87
|
-
'pack',
|
|
88
|
-
'postpack',
|
|
98
|
+
// 'prepare',
|
|
99
|
+
// 'prepack',
|
|
100
|
+
// 'pack',
|
|
101
|
+
// 'postpack',
|
|
89
102
|
'pretest',
|
|
90
103
|
'ci:build',
|
|
91
104
|
'ci:install',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dummy.js","sourceRoot":"","sources":["dummy.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAuBH,
|
|
1
|
+
{"version":3,"file":"dummy.js","sourceRoot":"","sources":["dummy.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAuBH,sDA2BC;AAoCD,4CAmBC;AAtGD,oDAA4D;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,qBAAqB,CAAmC,OAAU,EAAE,MAAc,EAAE,MAAyC;IAE5I;;;;;OAKG;IACH,aAAa;IACb,OAAO,aAAP,OAAO,cAAP,OAAO,IAAP,OAAO,GAAK,EAAE,EAAC;IAEf,sCAAsC;IACtC,IAAI,IAAI,GAAG,IAAA,wBAAgB,EAAC,MAAM,CAAC,CAAC;IAEpC;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;;QAElB,aAAa;QACb,MAAA,OAAO,CAAC,CAAC,qCAAT,OAAO,CAAC,CAAC,IAAM,GAAG,IAAI,IAAI,CAAC,EAAE,EAAA;IAC9B,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,gBAAgB,CAAmC,OAAW,EAAE,MAAe;IAE9F,OAAO,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE;QAC7C,YAAY;QACZ,SAAS;QACT,gBAAgB;QAChB,iBAAiB;QACjB,SAAS;QACT,YAAY;QACZ,aAAa;QACb,iBAAiB;QACjB,aAAa;QACb,aAAa;QACb,UAAU;QACV,cAAc;QACd,SAAS;QACT,UAAU;QACV,YAAY;KACH,CAAC,CAAC;AACb,CAAC","sourcesContent":["/**\n * 虛擬腳本填充工具 / Dummy Scripts Filler Utility\n *\n * 提供用於填充 package.json scripts 欄位中生命週期腳本佔位符的功能\n * Provides functionality to fill lifecycle script placeholders in package.json scripts field\n */\n\nimport { ITSArrayListMaybeReadonly } from 'ts-type/lib/type/base';\nimport { _dummyEchoPrefix } from '../../util/scripts/dummy';\n\n/**\n * 核心虛擬腳本填充函數 / Core dummy scripts filler function\n *\n * 為指定的腳本欄位填充 echo 命令作為佔位符\n * Fills echo commands as placeholders for specified script fields\n *\n * @template T - 腳本物件類型 / Script object type\n * @param scripts - 腳本物件 / Script object\n * @param prefix - echo 前綴文字 / Echo prefix text\n * @param fields - 要填充的腳本名稱陣列 / Array of script names to fill\n * @returns 填充後的腳本物件 / Filled script object\n *\n * @example\n * ```typescript\n * _fillDummyScriptsCore({}, 'workspaces', ['preversion', 'postversion'])\n * // 返回: { preversion: 'echo workspaces preversion', postversion: 'echo workspaces postversion' }\n * ```\n */\nexport function _fillDummyScriptsCore<T extends Record<string, string>>(scripts: T, prefix: string, fields: ITSArrayListMaybeReadonly<string>)\n{\n\t/**\n\t * 允許不傳入 scripts 時從空物件開始累積,\n\t * 讓 `fillDummyScripts()` 可直接取得一份全新預設腳本\n\t * Allow starting from an empty object when no scripts is passed, so\n\t * `fillDummyScripts()` can produce a fresh default script set on its own\n\t */\n\t// @ts-ignore\n\tscripts ??= {};\n\n\t/** 整批腳本共用同一個 echo 前綴,確保輸出訊息可辨識來源套件 */\n\tlet text = _dummyEchoPrefix(prefix);\n\n\t/**\n\t * 僅填補尚不存在的腳本鍵(`??=`),\n\t * 保留使用者已自訂的腳本不被預設佔位符覆蓋\n\t * Fill only missing keys (`??=`), leaving user-defined scripts\n\t * untouched instead of overwriting them with placeholders\n\t */\n\tfields.forEach(k =>\n\t{\n\t\t// @ts-ignore\n\t\tscripts[k] ??= `${text} ${k}`\n\t});\n\n\treturn scripts;\n}\n\n/**\n * 填充虛擬生命週期腳本 / Fill dummy lifecycle scripts\n *\n * 為 package.json 的標準生命週期腳本填充佔位符命令\n * Fills placeholder commands for standard lifecycle scripts in package.json\n *\n * 包含以下腳本 / Includes following scripts:\n * - preversion: 版本更新前執行 / Run before version bump\n * - version: 版本更新時執行 / Run on version bump\n * - prepublishOnly: 發布前執行 / Run before publish\n * - postversion: 版本更新後執行 / Run after version bump\n * - publish: 發布時執行 / Run on publish\n * - prepublish: 發布前執行(舊版)/ Run before publish (legacy)\n * - postpublish: 發布後執行 / Run after publish\n * - postpublishOnly: 發布後執行 / Run after publish only\n * - prepare: 準備階段執行 / Run during prepare\n * - prepack: 打包前執行 / Run before pack\n * - pack: 打包時執行 / Run on pack\n * - postpack: 打包後執行 / Run after pack\n * - pretest: 測試前執行 / Run before test\n * - ci:build: CI 建置階段 / CI build stage\n * - ci:install: CI 安裝階段 / CI install stage\n *\n * @template T - 腳本物件類型 / Script object type\n * @param scripts - 腳本物件(可選)/ Script object (optional)\n * @param prefix - echo 前綴文字(可選)/ Echo prefix text (optional)\n * @returns 填充後的腳本物件 / Filled script object\n *\n * @example\n * ```typescript\n * fillDummyScripts({}, 'my-package')\n * // 返回包含所有生命週期腳本的物件\n * ```\n */\nexport function fillDummyScripts<T extends Record<string, string>>(scripts?: T, prefix?: string)\n{\n\treturn _fillDummyScriptsCore(scripts, prefix, [\n\t\t'preversion',\n\t\t'version',\n\t\t'prepublishOnly',\n\t\t// 'postversion',\n\t\t'publish',\n\t\t'prepublish',\n\t\t'postpublish',\n\t\t'postpublishOnly',\n\t\t// 'prepare',\n\t\t// 'prepack',\n\t\t// 'pack',\n\t\t// 'postpack',\n\t\t'pretest',\n\t\t'ci:build',\n\t\t'ci:install',\n\t] as const);\n}\n"]}
|
|
@@ -24,12 +24,12 @@ import { EnumScriptsEntry } from '../../field/scripts';
|
|
|
24
24
|
* - tsc:showConfig: 顯示 TypeScript 設定 / Show TypeScript config
|
|
25
25
|
*/
|
|
26
26
|
export declare function defaultPkgScripts(): {
|
|
27
|
-
test:
|
|
27
|
+
test: EnumScriptsEntry;
|
|
28
28
|
coverage: string;
|
|
29
29
|
"test:jest": EnumScriptsEntry;
|
|
30
|
+
"test:node": EnumScriptsEntry;
|
|
31
|
+
"test:tsc": EnumScriptsEntry;
|
|
30
32
|
"test:snapshot": string;
|
|
31
|
-
"test:jest:snapshot": string;
|
|
32
|
-
"test:jest:coverage": string;
|
|
33
33
|
"test:tsd": string;
|
|
34
34
|
"tsc:showConfig": string;
|
|
35
35
|
};
|
|
@@ -61,27 +61,24 @@ export declare function defaultPkgScripts(): {
|
|
|
61
61
|
*/
|
|
62
62
|
export declare function defaultPkgNotOldExists(): {
|
|
63
63
|
"test:mocha": string;
|
|
64
|
+
"test:jest:snapshot": string;
|
|
65
|
+
"test:jest:coverage": string;
|
|
64
66
|
"test:tsdx": string;
|
|
65
67
|
"build:dts:bundle": EnumScriptsEntry;
|
|
66
|
-
"build:dts:copy":
|
|
67
|
-
"build:dts:tsc:emit":
|
|
68
|
-
"build:dts:tsc":
|
|
69
|
-
"build:tsdx":
|
|
68
|
+
"build:dts:copy": EnumScriptsEntry;
|
|
69
|
+
"build:dts:tsc:emit": EnumScriptsEntry;
|
|
70
|
+
"build:dts:tsc": EnumScriptsEntry;
|
|
71
|
+
"build:tsdx": EnumScriptsEntry;
|
|
70
72
|
"build:microbundle": string;
|
|
71
|
-
lint: string;
|
|
72
|
-
"lint:eslint": string;
|
|
73
|
-
review: string;
|
|
74
|
-
"review:test": string;
|
|
75
|
-
"review:coverage": string;
|
|
76
73
|
"sort-package-json": string;
|
|
77
74
|
"tsc:default": string;
|
|
78
75
|
"tsc:esm": string;
|
|
79
|
-
test:
|
|
76
|
+
test: EnumScriptsEntry;
|
|
80
77
|
coverage: string;
|
|
81
78
|
"test:jest": EnumScriptsEntry;
|
|
79
|
+
"test:node": EnumScriptsEntry;
|
|
80
|
+
"test:tsc": EnumScriptsEntry;
|
|
82
81
|
"test:snapshot": string;
|
|
83
|
-
"test:jest:snapshot": string;
|
|
84
|
-
"test:jest:coverage": string;
|
|
85
82
|
"test:tsd": string;
|
|
86
83
|
"tsc:showConfig": string;
|
|
87
84
|
};
|
|
@@ -28,12 +28,12 @@ exports.defaultPkgNotOldExists = defaultPkgNotOldExists;
|
|
|
28
28
|
*/
|
|
29
29
|
function defaultPkgScripts() {
|
|
30
30
|
return {
|
|
31
|
-
"test": "node --run test:
|
|
31
|
+
"test": "node --run test:node --" /* EnumScriptsEntry.DEFAULT_TEST */,
|
|
32
32
|
"coverage": "pnpm run test --coverage",
|
|
33
33
|
"test:jest": "jest --passWithNoTests" /* EnumScriptsEntry.JEST_TEST */,
|
|
34
|
+
"test:node": "tsx --test --test-update-snapshots **/*.node-spec.ts **/*.node-test.ts **/*.spec.ts **/*.test.ts" /* EnumScriptsEntry.NODE_TEST */,
|
|
35
|
+
"test:tsc": "tsc --noEmit & echo typescript check done" /* EnumScriptsEntry.TSC_TEST */,
|
|
34
36
|
"test:snapshot": "pnpm run test -u",
|
|
35
|
-
"test:jest:snapshot": "node --run test:jest -- -u",
|
|
36
|
-
"test:jest:coverage": "node --run test:jest -- --coverage",
|
|
37
37
|
"test:tsd": "ynpx tsd",
|
|
38
38
|
"tsc:showConfig": "ynpx get-current-tsconfig -p",
|
|
39
39
|
};
|
|
@@ -68,18 +68,20 @@ function defaultPkgNotOldExists() {
|
|
|
68
68
|
return {
|
|
69
69
|
...defaultPkgScripts(),
|
|
70
70
|
"test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
|
|
71
|
+
"test:jest:snapshot": "node --run test:jest -- -u",
|
|
72
|
+
"test:jest:coverage": "node --run test:jest -- --coverage",
|
|
71
73
|
"test:tsdx": "ynpx @bluelovers/tsdx test --passWithNoTests",
|
|
72
74
|
"build:dts:bundle": "ynpx @bluelovers/dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle" /* EnumScriptsEntry.BUILD_DTS_BUNDLE */,
|
|
73
|
-
"build:dts:copy": "copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts"
|
|
74
|
-
"build:dts:tsc:emit": "tsc --emitDeclarationOnly --declaration --noEmit false"
|
|
75
|
-
"build:dts:tsc": "node --run build:dts:tsc:emit
|
|
76
|
-
"build:tsdx": "ynpx @bluelovers/tsdx build --target node --name index"
|
|
75
|
+
"build:dts:copy": "copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts" /* EnumScriptsEntry.BUILD_DTS_COPY */,
|
|
76
|
+
"build:dts:tsc:emit": "tsc --emitDeclarationOnly --declaration --noEmit false" /* EnumScriptsEntry.BUILD_DTS_TSC_EMIT */,
|
|
77
|
+
"build:dts:tsc": "node --run build:dts:tsc:emit & node --run build:dts:copy" /* EnumScriptsEntry.BUILD_DTS_TSC */,
|
|
78
|
+
"build:tsdx": "ynpx @bluelovers/tsdx build --target node --name index" /* EnumScriptsEntry.BUILD_TSDX */,
|
|
77
79
|
"build:microbundle": "ynpx microbundle --target node",
|
|
78
|
-
"lint": "node --run lint:eslint --",
|
|
79
|
-
"lint:eslint": "ynpx eslint --ext .ts,.tsx,.mts,.cts ./",
|
|
80
|
-
"review": "node --run review:coverage",
|
|
81
|
-
"review:test": "yarn run lint && yarn run test",
|
|
82
|
-
"review:coverage": "yarn run lint && yarn run coverage",
|
|
80
|
+
// "lint": "node --run lint:eslint --",
|
|
81
|
+
// "lint:eslint": "ynpx eslint --ext .ts,.tsx,.mts,.cts ./",
|
|
82
|
+
// "review": "node --run review:coverage",
|
|
83
|
+
// "review:test": "yarn run lint && yarn run test",
|
|
84
|
+
// "review:coverage": "yarn run lint && yarn run coverage",
|
|
83
85
|
"sort-package-json": "yarn-tool sort",
|
|
84
86
|
"tsc:default": "tsc -p tsconfig.json",
|
|
85
87
|
"tsc:esm": "tsc -p tsconfig.esm.json",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg-scripts.js","sourceRoot":"","sources":["pkg-scripts.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAsBH,
|
|
1
|
+
{"version":3,"file":"pkg-scripts.js","sourceRoot":"","sources":["pkg-scripts.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAsBH,8CAaC;AA4BD,wDAuBC;AAlFD;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,iBAAiB;IAEhC,OAAO;QACN,MAAM,+DAA+B;QACrC,UAAU,EAAE,0BAA0B;QACtC,WAAW,2DAA4B;QACvC,WAAW,qIAA4B;QACvC,UAAU,6EAA2B;QACrC,eAAe,EAAE,kBAAkB;QAEnC,UAAU,EAAE,UAAU;QACtB,gBAAgB,EAAE,8BAA8B;KAChD,CAAA;AACF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,sBAAsB;IAErC,OAAO;QACN,GAAG,iBAAiB,EAAE;QACtB,YAAY,EAAE,oHAAoH;QAClI,oBAAoB,EAAE,4BAA4B;QAClD,oBAAoB,EAAE,oCAAoC;QAC1D,WAAW,EAAE,8CAA8C;QAC3D,kBAAkB,iLAAmC;QACrD,gBAAgB,sGAAiC;QACjD,oBAAoB,oGAAqC;QACzD,eAAe,kGAAgC;QAC/C,YAAY,4FAA6B;QACzC,mBAAmB,EAAE,gCAAgC;QACrD,uCAAuC;QACvC,4DAA4D;QAC5D,0CAA0C;QAC1C,mDAAmD;QACnD,2DAA2D;QAC3D,mBAAmB,EAAE,gBAAgB;QACrC,aAAa,EAAE,sBAAsB;QACrC,SAAS,EAAE,0BAA0B;KACrC,CAAA;AACF,CAAC","sourcesContent":["/**\n * 套件腳本預設 / Package Scripts Preset\n *\n * 提供標準套件(非根目錄、非工作區根目錄)的預設 npm scripts\n * Provides default npm scripts for standard packages (non-root, non-workspace-root)\n */\n\nimport { EnumScriptsEntry } from '../../field/scripts';\n\n/**\n * 標準套件預設腳本 / Default scripts for standard packages\n *\n * 適用於一般套件專案的常用測試與建構腳本\n * Common test and build scripts for general package projects\n *\n * @returns 包含標準腳本的物件 / Object containing standard scripts\n *\n * 包含腳本 / Includes scripts:\n * - test: 執行 Jest 測試 / Run Jest tests\n * - coverage: 執行測試並產生覆蓋率報告 / Run tests with coverage\n * - test:jest: Jest 測試命令 / Jest test command\n * - test:snapshot: 更新測試快照 / Update test snapshots\n * - test:jest:snapshot: 更新 Jest 快照 / Update Jest snapshots\n * - test:jest:coverage: Jest 測試含覆蓋率 / Jest test with coverage\n * - test:tsd: 執行 TypeScript 型別檢查 / Run TypeScript type checking\n * - tsc:showConfig: 顯示 TypeScript 設定 / Show TypeScript config\n */\nexport function defaultPkgScripts()\n{\n\treturn {\n\t\t\"test\": EnumScriptsEntry.DEFAULT_TEST,\n\t\t\"coverage\": \"pnpm run test --coverage\",\n\t\t\"test:jest\": EnumScriptsEntry.JEST_TEST,\n\t\t\"test:node\": EnumScriptsEntry.NODE_TEST,\n\t\t\"test:tsc\": EnumScriptsEntry.TSC_TEST,\n\t\t\"test:snapshot\": \"pnpm run test -u\",\n\n\t\t\"test:tsd\": \"ynpx tsd\",\n\t\t\"tsc:showConfig\": \"ynpx get-current-tsconfig -p\",\n\t}\n}\n\n/**\n * 新套件預設腳本 / Default scripts for new packages\n *\n * 適用於初始化新套件時的完整腳本集合\n * Complete set of scripts for initializing new packages\n *\n * @returns 包含完整開發腳本的物件 / Object containing complete development scripts\n *\n * 額外包含腳本 / Additional scripts:\n * - test:mocha: Mocha 測試執行 / Mocha test execution\n * - test:tsdx: TSDX 測試 / TSDX testing\n * - build:dts:bundle: 建構型別宣告檔 / Build type declaration files\n * - build:dts:copy: 複製型別宣告檔 / Copy type declaration files\n * - build:dts:tsc:emit: TypeScript 型別輸出 / TypeScript type emit\n * - build:dts:tsc: 完整型別建構 / Complete type build\n * - build:tsdx: TSDX 建構 / TSDX build\n * - build:microbundle: Microbundle 建構 / Microbundle build\n * - lint: ESLint 檢查 / ESLint check\n * - lint:eslint: ESLint 執行 / ESLint execution\n * - review: 完整審查流程 / Complete review process\n * - review:test: 測試審查 / Test review\n * - review:coverage: 覆蓋率審查 / Coverage review\n * - sort-package-json: 排序 package.json / Sort package.json\n * - tsc:default: 預設 TypeScript 編譯 / Default TypeScript compilation\n * - tsc:esm: ESM TypeScript 編譯 / ESM TypeScript compilation\n */\nexport function defaultPkgNotOldExists()\n{\n\treturn {\n\t\t...defaultPkgScripts(),\n\t\t\"test:mocha\": \"ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \\\"!(node_modules)/**/*.{test,spec}.{ts,tsx}\\\"\",\n\t\t\"test:jest:snapshot\": \"node --run test:jest -- -u\",\n\t\t\"test:jest:coverage\": \"node --run test:jest -- --coverage\",\n\t\t\"test:tsdx\": \"ynpx @bluelovers/tsdx test --passWithNoTests\",\n\t\t\"build:dts:bundle\": EnumScriptsEntry.BUILD_DTS_BUNDLE,\n\t\t\"build:dts:copy\": EnumScriptsEntry.BUILD_DTS_COPY,\n\t\t\"build:dts:tsc:emit\": EnumScriptsEntry.BUILD_DTS_TSC_EMIT,\n\t\t\"build:dts:tsc\": EnumScriptsEntry.BUILD_DTS_TSC,\n\t\t\"build:tsdx\": EnumScriptsEntry.BUILD_TSDX,\n\t\t\"build:microbundle\": \"ynpx microbundle --target node\",\n\t\t// \"lint\": \"node --run lint:eslint --\",\n\t\t// \"lint:eslint\": \"ynpx eslint --ext .ts,.tsx,.mts,.cts ./\",\n\t\t// \"review\": \"node --run review:coverage\",\n\t\t// \"review:test\": \"yarn run lint && yarn run test\",\n\t\t// \"review:coverage\": \"yarn run lint && yarn run coverage\",\n\t\t\"sort-package-json\": \"yarn-tool sort\",\n\t\t\"tsc:default\": \"tsc -p tsconfig.json\",\n\t\t\"tsc:esm\": \"tsc -p tsconfig.esm.json\",\n\t}\n}\n"]}
|
|
@@ -54,13 +54,14 @@ export declare function defaultRootScripts(): {
|
|
|
54
54
|
"install:resetLockfile": string;
|
|
55
55
|
"install:frozenLockfile": string;
|
|
56
56
|
"ws:fix-all": string;
|
|
57
|
+
"ws:fix-all:addStaticFiles": string;
|
|
57
58
|
"ws:fix-all:resetStaticFiles": string;
|
|
58
|
-
test:
|
|
59
|
+
test: import("../../field/scripts").EnumScriptsEntry;
|
|
59
60
|
coverage: string;
|
|
60
61
|
"test:jest": import("../../field/scripts").EnumScriptsEntry;
|
|
62
|
+
"test:node": import("../../field/scripts").EnumScriptsEntry;
|
|
63
|
+
"test:tsc": import("../../field/scripts").EnumScriptsEntry;
|
|
61
64
|
"test:snapshot": string;
|
|
62
|
-
"test:jest:snapshot": string;
|
|
63
|
-
"test:jest:coverage": string;
|
|
64
65
|
"test:tsd": string;
|
|
65
66
|
"tsc:showConfig": string;
|
|
66
67
|
};
|
|
@@ -59,7 +59,10 @@ function defaultRootScripts() {
|
|
|
59
59
|
"version:bump": "yarn-tool version",
|
|
60
60
|
"npm:publish": "npm publish",
|
|
61
61
|
"npm:publish:bump": bumpVersion(),
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
|
+
* 動態產生各類版本遞增腳本
|
|
64
|
+
* Dynamically generate version bump scripts
|
|
65
|
+
*/
|
|
63
66
|
...[
|
|
64
67
|
'patch',
|
|
65
68
|
'minor',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-scripts.js","sourceRoot":"","sources":["root-scripts.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAmCH,
|
|
1
|
+
{"version":3,"file":"root-scripts.js","sourceRoot":"","sources":["root-scripts.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAmCH,gDAiDC;AAlFD,+DAAiE;AACjE,+CAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,kBAAkB;IAEjC;;;;;OAKG;IACH,MAAM,WAAW,GAAG,CAAC,IAAiD,EAAE,EAAE;QAEzE,OAAO;YACN,yBAAyB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9D,aAAa;SACb,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACf,CAAC,CAAA;IAED,OAAO;QACN,GAAG,IAAA,+BAAiB,GAAE;QACtB,GAAG,IAAA,8CAAwB,GAAE;QAC7B,0BAA0B,EAAE,uCAAuC;QACnE,cAAc,EAAE,mBAAmB;QACnC,aAAa,EAAE,aAAa;QAC5B,kBAAkB,EAAE,WAAW,EAAE;QAEjC;;;WAGG;QACH,GAAI;YACH,OAAO;YACP,OAAO;YACP,OAAO;YACP,YAAY;SACF,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;YAEnC,CAAC,CAAC,gBAAgB,IAAI,EAAE,CAAC,GAAG,yBAAyB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC3F,CAAC,CAAC,oBAAoB,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;YAClD,OAAO,CAAC,CAAA;QACT,CAAC,EAAE,EAA4B,CAAC;QAEhC,wBAAwB,EAAE,yEAAyE;QACnG,qBAAqB,EAAE,6BAA6B;QACpD,uBAAuB,EAAE,6DAA6D;QACtF,sBAAsB,EAAE,wBAAwB;QAChD,aAAa,EAAE,4IAA4I;QAC3J,KAAK,EAAE,kBAAkB;QACzB,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,aAAa;KACzB,CAAA;AACF,CAAC","sourcesContent":["/**\n * 根目錄套件腳本預設 / Root Package Scripts Preset\n *\n * 提供根目錄套件(非工作區)的預設 npm scripts\n * Provides default npm scripts for root packages (non-workspace)\n */\n\nimport { defaultSharedRootScripts } from './shared-root-scripts';\nimport { defaultPkgScripts } from './pkg-scripts';\n\n/**\n * 根目錄套件預設腳本 / Default scripts for root packages\n *\n * 適用於 monorepo 根目錄或獨立套件的發布與版本管理\n * Suitable for monorepo root or standalone package publishing and version management\n *\n * @returns 包含根目錄管理腳本的物件 / Object containing root management scripts\n *\n * 核心功能 / Core features:\n * - 版本號遞增與發布 / Version bumping and publishing\n * - npm 發布流程 / npm publishing workflow\n * - 發布後自動化(changelog、git 提交與標籤)/ Post-publish automation (changelog, git commit, tags)\n * - 依賴更新與清理 / Dependency updates and cleanup\n *\n * 包含腳本 / Includes scripts:\n * - prepublishOnly:check-bin: 發布前檢查二進位檔 / Check binaries before publish\n * - version:bump: 版本號遞增 / Version bump\n * - npm:publish: npm 發布 / npm publish\n * - npm:publish:bump: 遞增並發布 / Bump and publish\n * - version:bump:patch|minor|major|prerelease: 特定版本遞增 / Specific version bumps\n * - npm:publish:bump:patch|minor|major|prerelease: 特定版本發布 / Specific version publishing\n * - postpublish:git:commit: 發布後提交 / Post-publish git commit\n * - postpublish:git:tag: 發布後標籤 / Post-publish git tag\n * - postpublish:changelog: 更新變更日誌 / Update changelog\n * - postpublish:git:push: 推送標籤 / Push tags\n * - postpublish: 完整發布後流程 / Complete post-publish workflow\n * - ncu: 更新依賴 / Update dependencies\n * - pnpm:dedupe: 清理重複依賴 / Deduplicate dependencies\n * - ncu:pnpm: pnpm 更新 / pnpm update\n */\nexport function defaultRootScripts()\n{\n\t/**\n\t * 產生版本遞增與發布命令 / Generate version bump and publish command\n\t *\n\t * @param bump - 版本遞增類型 / Version bump type\n\t * @returns 組合命令字串 / Combined command string\n\t */\n\tconst bumpVersion = (bump?: 'major' | 'minor' | 'patch' | 'prerelease') =>\n\t{\n\t\treturn [\n\t\t\t`node --run version:bump` + (bump ? ` -- --bump ${bump}` : ''),\n\t\t\t`npm publish`,\n\t\t].join(' && ')\n\t}\n\n\treturn {\n\t\t...defaultPkgScripts(),\n\t\t...defaultSharedRootScripts(),\n\t\t\"prepublishOnly:check-bin\": \"ynpx --quiet @yarn-tool/check-pkg-bin\",\n\t\t\"version:bump\": \"yarn-tool version\",\n\t\t\"npm:publish\": \"npm publish\",\n\t\t\"npm:publish:bump\": bumpVersion(),\n\n\t\t/**\n\t\t * 動態產生各類版本遞增腳本\n\t\t * Dynamically generate version bump scripts\n\t\t */\n\t\t...([\n\t\t\t'patch',\n\t\t\t'minor',\n\t\t\t'major',\n\t\t\t'prerelease',\n\t\t] as const).reduce((a, bump, idx) =>\n\t\t{\n\t\t\ta[`version:bump:${bump}`] = `node --run version:bump` + (bump ? ` -- --bump ${bump}` : '');\n\t\t\ta[`npm:publish:bump:${bump}`] = bumpVersion(bump);\n\t\t\treturn a\n\t\t}, {} as Record<string, string>),\n\n\t\t\"postpublish:git:commit\": `git commit -m \"chore(release): publish\" . & echo postpublish:git:commit`,\n\t\t\"postpublish:git:tag\": `ynpx --quiet @yarn-tool/tag`,\n\t\t\"postpublish:changelog\": `ynpx --quiet @yarn-tool/changelog && git add ./CHANGELOG.md`,\n\t\t\"postpublish:git:push\": `git push --follow-tags`,\n\t\t\"postpublish\": `node --run postpublish:changelog && node --run postpublish:git:commit && node --run postpublish:git:tag && node --run postpublish:git:push`,\n\t\t\"ncu\": \"yarn-tool ncu -u\",\n\t\t\"pnpm:dedupe\": \"pnpm dedupe\",\n\t\t\"ncu:pnpm\": \"pnpm update\",\n\t}\n}\n"]}
|
|
@@ -48,6 +48,8 @@ export declare function defaultSharedRootScripts(): {
|
|
|
48
48
|
"install:frozenLockfile": string;
|
|
49
49
|
/** 修復所有工作區問題 / Fix all workspace issues */
|
|
50
50
|
"ws:fix-all": string;
|
|
51
|
+
/** 修復時一併補齊靜態檔案 / Also add missing static files while fixing */
|
|
52
|
+
"ws:fix-all:addStaticFiles": string;
|
|
51
53
|
/** 修復並重置靜態檔 / Fix and reset static files */
|
|
52
54
|
"ws:fix-all:resetStaticFiles": string;
|
|
53
55
|
};
|
|
@@ -66,6 +66,8 @@ function defaultSharedRootScripts() {
|
|
|
66
66
|
"install:frozenLockfile": "yarn-tool install --frozen-lockfile",
|
|
67
67
|
/** 修復所有工作區問題 / Fix all workspace issues */
|
|
68
68
|
"ws:fix-all": "yarn-tool fix-all --overwriteHostedGitInfo",
|
|
69
|
+
/** 修復時一併補齊靜態檔案 / Also add missing static files while fixing */
|
|
70
|
+
"ws:fix-all:addStaticFiles": "node --run ws:fix-all -- --addStaticFiles",
|
|
69
71
|
/** 修復並重置靜態檔 / Fix and reset static files */
|
|
70
72
|
"ws:fix-all:resetStaticFiles": "node --run ws:fix-all -- --resetStaticFiles",
|
|
71
73
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-root-scripts.js","sourceRoot":"","sources":["shared-root-scripts.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA4CH,
|
|
1
|
+
{"version":3,"file":"shared-root-scripts.js","sourceRoot":"","sources":["shared-root-scripts.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA4CH,4DA+BC;AAzED;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG;IACpC,WAAW;IACX,OAAO;IACP,MAAM;IACN,MAAM;IAEN,YAAY;IAEZ,SAAS;IACT,KAAK;IAEL,SAAS;IACT,MAAM;IAEN,yBAAyB;IACzB,sBAAsB;IAEtB,4BAA4B;CACnB,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,wBAAwB;IAEvC,OAAO;QACN;;;;;WAKG;QACH,YAAY,EAAE,4BAA4B;QAC1C,iBAAiB,EAAE,iDAAiD,6BAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACrG,iBAAiB,EAAE,0DAA0D,6BAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAE9G,oCAAoC;QACpC,sBAAsB,EAAE,mBAAmB;QAE3C,4CAA4C;QAC5C,uBAAuB,EAAE,oCAAoC;QAE7D,6CAA6C;QAC7C,wBAAwB,EAAE,qCAAqC;QAE/D,2CAA2C;QAC3C,YAAY,EAAE,4CAA4C;QAE1D,+DAA+D;QAC/D,2BAA2B,EAAE,2CAA2C;QAExE,4CAA4C;QAC5C,6BAA6B,EAAE,6CAA6C;KAC5E,CAAA;AACF,CAAC","sourcesContent":["/**\n * 共享根目錄腳本預設 / Shared Root Scripts Preset\n *\n * 提供根目錄套件共用的預設 npm scripts\n * Provides shared npm scripts for root packages\n *\n * 此模組被 root-scripts 和 ws-root-scripts 共用\n * This module is shared by root-scripts and ws-root-scripts\n */\n\n/**\n * CI 環境安裝腳本 / CI environment install script\n *\n * 安裝核心開發工具:yarn-tool、lerna、ynpx、ts-node、ts-jest、jest、typescript、jest-config、tsx、pnpm\n * Installs core development tools\n */\nexport const _defaultCiInstallDeps = [\n\t'yarn-tool',\n\t'lerna',\n\t'ynpx',\n\t'pnpm',\n\n\t'typescript',\n\n\t'ts-node',\n\t'tsx',\n\n\t'ts-jest',\n\t'jest',\n\n\t'@bluelovers/jest-config',\n\t'@bluelovers/tsconfig',\n\n\t'@yarn-tool/require-resolve',\n] as const;\n\n/**\n * 共享根目錄預設腳本 / Shared root default scripts\n *\n * 適用於所有根目錄類型的通用管理腳本\n * General management scripts for all root package types\n *\n * @returns 包含共享根目錄腳本的物件 / Object containing shared root scripts\n *\n * 包含腳本 / Includes scripts:\n * - ci:install: CI 環境安裝與依賴設定 / CI environment install and dependency setup\n * - test:jest:clearCache: 清除 Jest 快取 / Clear Jest cache\n * - install:resetLockfile: 重置鎖定檔安裝 / Install with reset lockfile\n * - install:frozenLockfile: 凍結鎖定檔安裝 / Install with frozen lockfile\n * - ws:fix-all: 修復所有工作區問題 / Fix all workspace issues\n * - ws:fix-all:resetStaticFiles: 修復並重置靜態檔 / Fix and reset static files\n */\nexport function defaultSharedRootScripts()\n{\n\treturn {\n\t\t/**\n\t\t * CI 環境安裝腳本 / CI environment install script\n\t\t *\n\t\t * 安裝核心開發工具:yarn-tool、lerna、ynpx、ts-node、ts-jest、jest、typescript、jest-config、tsx、pnpm\n\t\t * Installs core development tools\n\t\t */\n\t\t\"ci:install\": `node --run ci:install:pnpm`,\n\t\t\"ci:install:yarn\": `yarn install --frozen-lockfile && yarn add -W ${_defaultCiInstallDeps.join(\" \")}`,\n\t\t\"ci:install:pnpm\": `pnpm install --frozen-lockfile && pnpm add --workspace ${_defaultCiInstallDeps.join(\" \")}`,\n\n\t\t/** 清除 Jest 快取 / Clear Jest cache */\n\t\t\"test:jest:clearCache\": \"jest --clearCache\",\n\n\t\t/** 重置鎖定檔安裝 / Install with reset lockfile */\n\t\t\"install:resetLockfile\": \"yarn-tool install --reset-lockfile\",\n\n\t\t/** 凍結鎖定檔安裝 / Install with frozen lockfile */\n\t\t\"install:frozenLockfile\": \"yarn-tool install --frozen-lockfile\",\n\n\t\t/** 修復所有工作區問題 / Fix all workspace issues */\n\t\t\"ws:fix-all\": \"yarn-tool fix-all --overwriteHostedGitInfo\",\n\n\t\t/** 修復時一併補齊靜態檔案 / Also add missing static files while fixing */\n\t\t\"ws:fix-all:addStaticFiles\": \"node --run ws:fix-all -- --addStaticFiles\",\n\n\t\t/** 修復並重置靜態檔 / Fix and reset static files */\n\t\t\"ws:fix-all:resetStaticFiles\": \"node --run ws:fix-all -- --resetStaticFiles\",\n\t}\n}\n"]}
|
|
@@ -91,7 +91,10 @@ function defaultWorkspaceRootScripts() {
|
|
|
91
91
|
return {
|
|
92
92
|
...(0, shared_root_scripts_1.defaultSharedRootScripts)(),
|
|
93
93
|
"test": "node --run test:since",
|
|
94
|
-
|
|
94
|
+
/**
|
|
95
|
+
* 動態產生 all/since 腳本對
|
|
96
|
+
* Dynamically generate all/since script pairs
|
|
97
|
+
*/
|
|
95
98
|
..._runAllOrSince('test'),
|
|
96
99
|
..._runAllOrSince('test:tsd'),
|
|
97
100
|
..._runAllOrSince('test:snapshot'),
|
|
@@ -100,17 +103,26 @@ function defaultWorkspaceRootScripts() {
|
|
|
100
103
|
..._runAllOrSince('coverage'),
|
|
101
104
|
..._runAllOrSince('lint'),
|
|
102
105
|
/** 版本更新前測試 / Test before version bump */
|
|
103
|
-
"preversion": "
|
|
106
|
+
"preversion": "pnpm run test" /* EnumScriptsEntry.preversion */,
|
|
104
107
|
/** 版本更新後修復 / Fix after version bump */
|
|
105
|
-
"postversion": "yarn-tool fix-all",
|
|
108
|
+
"postversion": "yarn-tool fix-all --noStaticFiles",
|
|
106
109
|
/** Lerna 發布 / Lerna publish */
|
|
107
110
|
"lerna:publish": bumpVersion(),
|
|
108
|
-
|
|
111
|
+
/**
|
|
112
|
+
* 動態產生各類版本發布腳本
|
|
113
|
+
* Dynamically generate version publish scripts
|
|
114
|
+
*/
|
|
109
115
|
...[
|
|
110
116
|
'patch',
|
|
111
117
|
'minor',
|
|
112
118
|
'major',
|
|
113
119
|
].reduce((a, bump, idx) => {
|
|
120
|
+
/**
|
|
121
|
+
* 只在第一個(patch)迭代建立 `yes` 與 `yes:force` 兩個預設別名,
|
|
122
|
+
* 讓使用者不必指定版本類型也能一鍵發布
|
|
123
|
+
* Create the `yes` and `yes:force` default aliases only on the first
|
|
124
|
+
* (patch) iteration, so users can publish without picking a bump type
|
|
125
|
+
*/
|
|
114
126
|
if (idx === 0) {
|
|
115
127
|
a[`lerna:publish:yes`] = `node --run lerna:publish:yes:${bump} --`;
|
|
116
128
|
a[`lerna:publish:yes:force`] = `lerna publish --no-private --yes --bump ${bump} --force-publish`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-root-scripts.js","sourceRoot":"","sources":["ws-root-scripts.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAqBH,wCAaC;AA2CD,
|
|
1
|
+
{"version":3,"file":"ws-root-scripts.js","sourceRoot":"","sources":["ws-root-scripts.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAqBH,wCAaC;AA2CD,kEAoGC;AA/KD,+DAAiE;AAGjE;;;;;;;;;;;;;;;GAeG;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,EAAE,cAAc,MAAM,iBAAiB;KAK7C,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,SAAgB,2BAA2B;IAE1C;;;;;OAKG;IACH,MAAM,WAAW,GAAG,CAAC,IAAkC,EAAE,EAAE;QAC1D,OAAO;YACN,gCAAgC;YAChC,4BAA4B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpE,0BAA0B;SAC1B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACf,CAAC,CAAA;IAED,OAAO;QACN,GAAG,IAAA,8CAAwB,GAAE;QAE7B,MAAM,EAAE,uBAAuB;QAE/B;;;WAGG;QACH,GAAG,cAAc,CAAC,MAAM,CAAC;QACzB,GAAG,cAAc,CAAC,UAAU,CAAC;QAC7B,GAAG,cAAc,CAAC,eAAe,CAAC;QAClC,GAAG,cAAc,CAAC,OAAO,CAAC;QAC1B,GAAG,cAAc,CAAC,QAAQ,CAAC;QAC3B,GAAG,cAAc,CAAC,UAAU,CAAC;QAC7B,GAAG,cAAc,CAAC,MAAM,CAAC;QAEzB,yCAAyC;QACzC,YAAY,mDAA6B;QAEzC,uCAAuC;QACvC,aAAa,EAAE,mCAAmC;QAElD,+BAA+B;QAC/B,eAAe,EAAE,WAAW,EAAE;QAE9B;;;WAGG;QACH,GAAI;YACH,OAAO;YACP,OAAO;YACP,OAAO;SACG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;YACnC;;;;;eAKG;YACH,IAAI,GAAG,KAAK,CAAC,EACb,CAAC;gBACA,CAAC,CAAC,mBAAmB,CAAC,GAAG,gCAAgC,IAAI,KAAK,CAAC;gBACnE,CAAC,CAAC,yBAAyB,CAAC,GAAG,2CAA2C,IAAI,kBAAkB,CAAC;YAClG,CAAC;YACD,CAAC,CAAC,qBAAqB,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;YACnD,OAAO,CAAC,CAAA;QACT,CAAC,EAAE,EAA4B,CAAC;QAEhC,8CAA8C;QAC9C,qBAAqB,EAAE,wEAAwE;QAE/F,4BAA4B;QAC5B,yBAAyB,EAAE,4BAA4B;QAEvD,4BAA4B;QAC5B,0BAA0B,EAAE,uCAAuC;QAEnE,oCAAoC;QACpC,sBAAsB,EAAE,2CAA2C;QAEnE,iCAAiC;QACjC,uBAAuB,EAAE,8CAA8C;QAEvE,gCAAgC;QAChC,KAAK,EAAE,mBAAmB;QAC1B,UAAU,EAAE,kBAAkB;QAC9B,QAAQ,EAAE,uBAAuB;QAEjC,6CAA6C;QAC7C,mBAAmB,EAAE,sEAAsE;QAC3F,wBAAwB,EAAE,gBAAgB;QAC1C,sBAAsB,EAAE,mBAAmB;QAE3C,qCAAqC;QACrC,iBAAiB,EAAE,qEAAqE;QAExF,wCAAwC;QACxC,mCAAmC,EAAE,6LAA6L;QAElO,kDAAkD;QAClD,gBAAgB,EAAE,8BAA8B;KAChD,CAAA;AACF,CAAC","sourcesContent":["/**\n * 工作區根目錄腳本預設 / Workspace Root Scripts Preset\n *\n * 提供 Yarn/Lerna 工作區根目錄的預設 npm scripts\n * Provides default npm scripts for Yarn/Lerna workspace root\n */\n\nimport { defaultSharedRootScripts } from './shared-root-scripts';\nimport { EnumScriptsEntry } from '../../field/scripts';\n\n/**\n * 產生「全部執行」與「僅變更執行」腳本對 / Generate \"all\" and \"since\" script pairs\n *\n * 為指定腳本名稱產生對應的 `:all`(全部工作區)與 `:since`(僅變更)版本\n * Generates corresponding `:all` (all workspaces) and `:since` (changed only) versions\n *\n * @template T - 基礎腳本名稱 / Base script name\n * @param script - 基礎腳本名稱 / Base script name\n * @returns 包含 all 與 since 變體的腳本物件 / Object containing all and since variants\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 * 工作區根目錄預設腳本 / Default scripts for workspace root\n *\n * 適用於 monorepo 工作區根目錄的完整管理腳本集合\n * Complete management script set for monorepo workspace root\n *\n * @returns 包含工作區管理腳本的物件 / Object containing workspace management scripts\n *\n * 核心功能 / Core features:\n * - 跨工作區腳本執行(全部或僅變更)/ Cross-workspace script execution (all or changed only)\n * - Lerna 發布流程 / Lerna publishing workflow\n * - 發布前檢查與準備 / Pre-publish checks and preparation\n * - 相依工作區連結修復 / Dependency workspace links fixing\n * - 統一依賴更新 / Unified dependency updates\n * - 發布後變更日誌更新 / Post-publish changelog updates\n *\n * 包含腳本 / Includes scripts:\n * - test: 執行變更工作區測試 / Run changed workspaces tests\n * - test:all|test:since: 全部/變更測試 / All/changed tests\n * - test:tsd:all|test:tsd:since: 型別檢查 / Type checking\n * - test:snapshot:all|test:snapshot:since: 快照更新 / Snapshot updates\n * - build:all|build:since: 建構 / Build\n * - review:all|review:since: 審查 / Review\n * - coverage:all|coverage:since: 覆蓋率 / Coverage\n * - lint:all|lint:since: 檢查 / Lint\n * - preversion: 版本更新前測試 / Pre-version test\n * - postversion: 版本更新後修復 / Post-version fix\n * - lerna:publish: Lerna 發布 / Lerna publish\n * - lerna:publish:yes|lerna:publish:yes:force: 確認發布 / Confirmed publish\n * - lerna:publish:yes:patch|minor|major: 特定版本發布 / Specific version publish\n * - prepublishOnly:root: 發布前檢查與修復 / Pre-publish checks and fixes\n * - prepublishOnly:lockfile: 鎖定檔同步 / Lockfile sync\n * - prepublishOnly:check-bin: 二進位檔檢查 / Binary check\n * - prepare:fix-ws-links: 工作區連結修復 / Workspace links fix\n * - prepublishOnly:update: 發布前更新 / Pre-publish update\n * - ncu:root|ncu:ws: 根目錄/工作區依賴更新 / Root/workspace dependency updates\n * - sort-package-json:root|sort-package-json:ws: package.json 排序 / package.json sorting\n * - postpublishOnly: 發布後執行 / Post-publish execution\n * - postpublishOnly:ws-root-changelog: 根目錄變更日誌更新 / Root changelog update\n * - tsc:showConfig: TypeScript 設定顯示 / TypeScript config display\n */\nexport function defaultWorkspaceRootScripts()\n{\n\t/**\n\t * 產生 Lerna 版本遞增與發布命令 / Generate Lerna version bump and publish command\n\t *\n\t * @param bump - 版本遞增類型(patch|minor|major)/ Version bump type\n\t * @returns 組合命令字串 / Combined command string\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 * Dynamically generate all/since script pairs\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/** Lerna 發布 / Lerna publish */\n\t\t\"lerna:publish\": bumpVersion(),\n\n\t\t/**\n\t\t * 動態產生各類版本發布腳本\n\t\t * Dynamically generate version publish scripts\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 * Create the `yes` and `yes:force` default aliases only on the first\n\t\t\t * (patch) iteration, so users can publish without picking a bump type\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/** 發布前檢查與修復 / Pre-publish checks and fixes */\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/** 二進位檔檢查 / Binary check */\n\t\t\"prepublishOnly:check-bin\": \"ynpx --quiet @yarn-tool/check-pkg-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\": \"yarn-tool ncu -u\",\n\t\t\"ncu:ws\": \"yarn-tool ncu -u --AA\",\n\n\t\t/** package.json 排序 / package.json sorting */\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\": \"yarn-tool sort\",\n\t\t\"sort-package-json:ws\": \"yarn-tool ws sort\",\n\n\t\t/** 發布後執行 / Post-publish execution */\n\t\t\"postpublishOnly\": \"node --run postpublishOnly:ws-root-changelog & echo postpublishOnly\",\n\n\t\t/** 根目錄變更日誌更新 / Root changelog update */\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 設定顯示 / TypeScript config display */\n\t\t\"tsc:showConfig\": \"ynpx get-current-tsconfig -p\",\n\t}\n}\n"]}
|
|
@@ -1,5 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 產生 echo 前綴片段
|
|
3
|
+
* Build the echo prefix fragment
|
|
4
|
+
*
|
|
5
|
+
* @param prefix - 前綴文字(可為 undefined)/ the prefix text (may be undefined)
|
|
6
|
+
* @returns 形如 `echo <prefix>` 的字串,前綴為空時僅回傳 `echo`
|
|
7
|
+
* a string like `echo <prefix>`, reduced to `echo` when empty
|
|
8
|
+
*
|
|
9
|
+
* @note `??` 處理 undefined、`trim()` 處理空字串造成的多餘空白,
|
|
10
|
+
* 兩者缺一都會在邊界情況留下尾隨空白
|
|
11
|
+
* `??` handles undefined and `trim()` removes the extra space from an
|
|
12
|
+
* empty prefix; both are needed to avoid trailing spaces at the edges
|
|
13
|
+
*/
|
|
1
14
|
export declare function _dummyEchoPrefix(prefix: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* 組合 echo 指令的前綴與內容
|
|
17
|
+
* Join the prefix and text of an echo command
|
|
18
|
+
*
|
|
19
|
+
* @param pre - 已產生的前綴(如 `echo my-pkg`)/ the already-built prefix (e.g. `echo my-pkg`)
|
|
20
|
+
* @param text - 要附加的內容 / the text to append
|
|
21
|
+
* @returns 完整的 echo 指令 / the full echo command
|
|
22
|
+
*/
|
|
2
23
|
export declare function _dummyEchoTextCore(pre: string, text: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* 由 prefix 與 text 組出完整的 dummy echo 指令
|
|
26
|
+
* Compose a full dummy echo command from prefix and text
|
|
27
|
+
*
|
|
28
|
+
* @param prefix - echo 前綴文字 / the echo prefix text
|
|
29
|
+
* @param text - 要附加的內容 / the text to append
|
|
30
|
+
* @returns 完整的 echo 指令 / the full echo command
|
|
31
|
+
*/
|
|
3
32
|
export declare function _dummyEchoText(prefix: string, text: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* 粗略判斷值是否可能是 dummy echo 指令
|
|
35
|
+
* Roughly check whether a value may be a dummy echo command
|
|
36
|
+
*
|
|
37
|
+
* @param value - 要檢查的腳本命令 / the script command to check
|
|
38
|
+
* @returns 可能是 dummy echo 時回傳 truthy,否則回傳 falsy
|
|
39
|
+
* truthy when it may be a dummy echo, falsy otherwise
|
|
40
|
+
*
|
|
41
|
+
* @note 回傳型別為 `number | boolean | undefined`(`value?.length` 可能是 0),
|
|
42
|
+
* 呼叫端應只作為 truthy 判斷使用;
|
|
43
|
+
* 排除 `&` 是因為真正的指令常以 `cmdA & cmdB` 串接,不該被誤認為 dummy
|
|
44
|
+
* The return type is `number | boolean | undefined` (`value?.length` can be 0),
|
|
45
|
+
* so callers must treat it as a truthy check only;
|
|
46
|
+
* `&` is excluded because real commands are often chained as `cmdA & cmdB`
|
|
47
|
+
* and must not be mistaken for a dummy
|
|
48
|
+
*/
|
|
4
49
|
export declare function isDummyEchoMaybe(value: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* 判斷值是否為空或可能是 dummy echo 指令
|
|
52
|
+
* Check whether a value is empty or may be a dummy echo command
|
|
53
|
+
*
|
|
54
|
+
* @param value - 要檢查的腳本命令 / the script command to check
|
|
55
|
+
* @returns 空值或可能是 dummy echo 時回傳 true / true when empty or possibly a dummy echo
|
|
56
|
+
*
|
|
57
|
+
* @note 與 `isDummyEchoMaybe` 互補:此版本會把空值也視為「可覆寫」,
|
|
58
|
+
* 適合用於決定是否填充預設腳本
|
|
59
|
+
* Complements `isDummyEchoMaybe`: empty values count as overwritable
|
|
60
|
+
* here, which suits deciding whether to fill in a default script
|
|
61
|
+
*/
|
|
5
62
|
export declare function isDummyEchoMaybeOrEmpty(value: string): boolean;
|
|
@@ -5,18 +5,75 @@ exports._dummyEchoTextCore = _dummyEchoTextCore;
|
|
|
5
5
|
exports._dummyEchoText = _dummyEchoText;
|
|
6
6
|
exports.isDummyEchoMaybe = isDummyEchoMaybe;
|
|
7
7
|
exports.isDummyEchoMaybeOrEmpty = isDummyEchoMaybeOrEmpty;
|
|
8
|
+
/**
|
|
9
|
+
* 產生 echo 前綴片段
|
|
10
|
+
* Build the echo prefix fragment
|
|
11
|
+
*
|
|
12
|
+
* @param prefix - 前綴文字(可為 undefined)/ the prefix text (may be undefined)
|
|
13
|
+
* @returns 形如 `echo <prefix>` 的字串,前綴為空時僅回傳 `echo`
|
|
14
|
+
* a string like `echo <prefix>`, reduced to `echo` when empty
|
|
15
|
+
*
|
|
16
|
+
* @note `??` 處理 undefined、`trim()` 處理空字串造成的多餘空白,
|
|
17
|
+
* 兩者缺一都會在邊界情況留下尾隨空白
|
|
18
|
+
* `??` handles undefined and `trim()` removes the extra space from an
|
|
19
|
+
* empty prefix; both are needed to avoid trailing spaces at the edges
|
|
20
|
+
*/
|
|
8
21
|
function _dummyEchoPrefix(prefix) {
|
|
9
22
|
return `echo ${prefix !== null && prefix !== void 0 ? prefix : ''}`.trim();
|
|
10
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* 組合 echo 指令的前綴與內容
|
|
26
|
+
* Join the prefix and text of an echo command
|
|
27
|
+
*
|
|
28
|
+
* @param pre - 已產生的前綴(如 `echo my-pkg`)/ the already-built prefix (e.g. `echo my-pkg`)
|
|
29
|
+
* @param text - 要附加的內容 / the text to append
|
|
30
|
+
* @returns 完整的 echo 指令 / the full echo command
|
|
31
|
+
*/
|
|
11
32
|
function _dummyEchoTextCore(pre, text) {
|
|
12
33
|
return `${pre} ${text}`.trim();
|
|
13
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* 由 prefix 與 text 組出完整的 dummy echo 指令
|
|
37
|
+
* Compose a full dummy echo command from prefix and text
|
|
38
|
+
*
|
|
39
|
+
* @param prefix - echo 前綴文字 / the echo prefix text
|
|
40
|
+
* @param text - 要附加的內容 / the text to append
|
|
41
|
+
* @returns 完整的 echo 指令 / the full echo command
|
|
42
|
+
*/
|
|
14
43
|
function _dummyEchoText(prefix, text) {
|
|
15
44
|
return _dummyEchoTextCore(_dummyEchoPrefix(prefix), text);
|
|
16
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* 粗略判斷值是否可能是 dummy echo 指令
|
|
48
|
+
* Roughly check whether a value may be a dummy echo command
|
|
49
|
+
*
|
|
50
|
+
* @param value - 要檢查的腳本命令 / the script command to check
|
|
51
|
+
* @returns 可能是 dummy echo 時回傳 truthy,否則回傳 falsy
|
|
52
|
+
* truthy when it may be a dummy echo, falsy otherwise
|
|
53
|
+
*
|
|
54
|
+
* @note 回傳型別為 `number | boolean | undefined`(`value?.length` 可能是 0),
|
|
55
|
+
* 呼叫端應只作為 truthy 判斷使用;
|
|
56
|
+
* 排除 `&` 是因為真正的指令常以 `cmdA & cmdB` 串接,不該被誤認為 dummy
|
|
57
|
+
* The return type is `number | boolean | undefined` (`value?.length` can be 0),
|
|
58
|
+
* so callers must treat it as a truthy check only;
|
|
59
|
+
* `&` is excluded because real commands are often chained as `cmdA & cmdB`
|
|
60
|
+
* and must not be mistaken for a dummy
|
|
61
|
+
*/
|
|
17
62
|
function isDummyEchoMaybe(value) {
|
|
18
63
|
return (value === null || value === void 0 ? void 0 : value.length) && value.startsWith('echo ') && !value.includes('&');
|
|
19
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* 判斷值是否為空或可能是 dummy echo 指令
|
|
67
|
+
* Check whether a value is empty or may be a dummy echo command
|
|
68
|
+
*
|
|
69
|
+
* @param value - 要檢查的腳本命令 / the script command to check
|
|
70
|
+
* @returns 空值或可能是 dummy echo 時回傳 true / true when empty or possibly a dummy echo
|
|
71
|
+
*
|
|
72
|
+
* @note 與 `isDummyEchoMaybe` 互補:此版本會把空值也視為「可覆寫」,
|
|
73
|
+
* 適合用於決定是否填充預設腳本
|
|
74
|
+
* Complements `isDummyEchoMaybe`: empty values count as overwritable
|
|
75
|
+
* here, which suits deciding whether to fill in a default script
|
|
76
|
+
*/
|
|
20
77
|
function isDummyEchoMaybeOrEmpty(value) {
|
|
21
78
|
return !(value === null || value === void 0 ? void 0 : value.length) || (value.startsWith('echo ') && !value.includes('&'));
|
|
22
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dummy.js","sourceRoot":"","sources":["dummy.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"dummy.js","sourceRoot":"","sources":["dummy.ts"],"names":[],"mappings":";;AAaA,4CAGC;AAUD,gDAGC;AAUD,wCAGC;AAkBD,4CAGC;AAcD,0DAGC;AAhFD;;;;;;;;;;;;GAYG;AACH,SAAgB,gBAAgB,CAAC,MAAc;IAE9C,OAAO,QAAQ,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AACtC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,GAAW,EAAE,IAAY;IAE3D,OAAO,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;AAChC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,IAAY;IAE1D,OAAO,kBAAkB,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAA;AAC1D,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,gBAAgB,CAAC,KAAa;IAE7C,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,KAAI,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAC1E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,uBAAuB,CAAC,KAAa;IAEpD,OAAO,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAA,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;AAC7E,CAAC","sourcesContent":["/**\n * 產生 echo 前綴片段\n * Build the echo prefix fragment\n *\n * @param prefix - 前綴文字(可為 undefined)/ the prefix text (may be undefined)\n * @returns 形如 `echo <prefix>` 的字串,前綴為空時僅回傳 `echo`\n * a string like `echo <prefix>`, reduced to `echo` when empty\n *\n * @note `??` 處理 undefined、`trim()` 處理空字串造成的多餘空白,\n * 兩者缺一都會在邊界情況留下尾隨空白\n * `??` handles undefined and `trim()` removes the extra space from an\n * empty prefix; both are needed to avoid trailing spaces at the edges\n */\nexport function _dummyEchoPrefix(prefix: string)\n{\n\treturn `echo ${prefix ?? ''}`.trim();\n}\n\n/**\n * 組合 echo 指令的前綴與內容\n * Join the prefix and text of an echo command\n *\n * @param pre - 已產生的前綴(如 `echo my-pkg`)/ the already-built prefix (e.g. `echo my-pkg`)\n * @param text - 要附加的內容 / the text to append\n * @returns 完整的 echo 指令 / the full echo command\n */\nexport function _dummyEchoTextCore(pre: string, text: string)\n{\n\treturn `${pre} ${text}`.trim();\n}\n\n/**\n * 由 prefix 與 text 組出完整的 dummy echo 指令\n * Compose a full dummy echo command from prefix and text\n *\n * @param prefix - echo 前綴文字 / the echo prefix text\n * @param text - 要附加的內容 / the text to append\n * @returns 完整的 echo 指令 / the full echo command\n */\nexport function _dummyEchoText(prefix: string, text: string)\n{\n\treturn _dummyEchoTextCore(_dummyEchoPrefix(prefix), text)\n}\n\n/**\n * 粗略判斷值是否可能是 dummy echo 指令\n * Roughly check whether a value may be a dummy echo command\n *\n * @param value - 要檢查的腳本命令 / the script command to check\n * @returns 可能是 dummy echo 時回傳 truthy,否則回傳 falsy\n * truthy when it may be a dummy echo, falsy otherwise\n *\n * @note 回傳型別為 `number | boolean | undefined`(`value?.length` 可能是 0),\n * 呼叫端應只作為 truthy 判斷使用;\n * 排除 `&` 是因為真正的指令常以 `cmdA & cmdB` 串接,不該被誤認為 dummy\n * The return type is `number | boolean | undefined` (`value?.length` can be 0),\n * so callers must treat it as a truthy check only;\n * `&` is excluded because real commands are often chained as `cmdA & cmdB`\n * and must not be mistaken for a dummy\n */\nexport function isDummyEchoMaybe(value: string)\n{\n\treturn value?.length && value.startsWith('echo ') && !value.includes('&')\n}\n\n/**\n * 判斷值是否為空或可能是 dummy echo 指令\n * Check whether a value is empty or may be a dummy echo command\n *\n * @param value - 要檢查的腳本命令 / the script command to check\n * @returns 空值或可能是 dummy echo 時回傳 true / true when empty or possibly a dummy echo\n *\n * @note 與 `isDummyEchoMaybe` 互補:此版本會把空值也視為「可覆寫」,\n * 適合用於決定是否填充預設腳本\n * Complements `isDummyEchoMaybe`: empty values count as overwritable\n * here, which suits deciding whether to fill in a default script\n */\nexport function isDummyEchoMaybeOrEmpty(value: string)\n{\n\treturn !value?.length || (value.startsWith('echo ') && !value.includes('&'))\n}\n"]}
|