@yarn-tool/pkg-entry-util 3.0.13 → 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.
@@ -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":";;AAAA,4CAGC;AAED,gDAGC;AAED,wCAGC;AAED,4CAGC;AAED,0DAGC;AAvBD,SAAgB,gBAAgB,CAAC,MAAc;IAE9C,OAAO,QAAQ,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AACtC,CAAC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,IAAY;IAE3D,OAAO,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;AAChC,CAAC;AAED,SAAgB,cAAc,CAAC,MAAc,EAAE,IAAY;IAE1D,OAAO,kBAAkB,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAA;AAC1D,CAAC;AAED,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,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":["export function _dummyEchoPrefix(prefix: string)\n{\n\treturn `echo ${prefix ?? ''}`.trim();\n}\n\nexport function _dummyEchoTextCore(pre: string, text: string)\n{\n\treturn `${pre} ${text}`.trim();\n}\n\nexport function _dummyEchoText(prefix: string, text: string)\n{\n\treturn _dummyEchoTextCore(_dummyEchoPrefix(prefix), text)\n}\n\nexport function isDummyEchoMaybe(value: string)\n{\n\treturn value?.length && value.startsWith('echo ') && !value.includes('&')\n}\n\nexport function isDummyEchoMaybeOrEmpty(value: string)\n{\n\treturn !value?.length || (value.startsWith('echo ') && !value.includes('&'))\n}\n"]}
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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yarn-tool/pkg-entry-util",
3
- "version": "3.0.13",
3
+ "version": "3.0.15",
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",
@@ -41,24 +41,26 @@
41
41
  "author": "bluelovers",
42
42
  "main": "lib/index.js",
43
43
  "scripts": {
44
- "coverage": "yarn run test -- --coverage",
44
+ "coverage": "pnpm run test -- --coverage",
45
45
  "lint": "ynpx --quiet eslint -- **/*.ts",
46
- "test": "jest --passWithNoTests",
46
+ "test": "node --run test:node",
47
47
  "test:jest": "jest --passWithNoTests",
48
- "test:jest:coverage": "yarn run test:jest -- --coverage",
49
- "test:jest:snapshot": "yarn run test:jest -- -u",
48
+ "test:jest:coverage": "pnpm run test:jest -- --coverage",
49
+ "test:jest:snapshot": "pnpm run test:jest -- -u",
50
50
  "test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
51
- "test:snapshot": "yarn run test -- -u",
51
+ "test:node": "tsx --test --test-update-snapshots **/*.node-spec.ts **/*.node-test.ts **/*.spec.ts **/*.test.ts",
52
+ "test:snapshot": "pnpm run test -u",
53
+ "test:tsc": "tsc --noEmit & echo typescript check done",
52
54
  "test:tsd": "ynpx tsd",
53
55
  "test:tsdx": "ynpx @bluelovers/tsdx test --passWithNoTests",
54
- "build:dts": "ynpx dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner & echo build:dts",
56
+ "build:dts": "ynpx @bluelovers/dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner & echo build:dts",
55
57
  "build:tsdx": "ynpx @bluelovers/tsdx build --target node --name index",
56
- "preversion": "echo preversion && yarn run test",
58
+ "preversion": "echo preversion && pnpm run test",
57
59
  "version": "echo version",
58
60
  "postversion": "echo postversion",
59
61
  "prepublish": "echo prepublish",
60
62
  "prepublishOnly": "echo prepublishOnly",
61
- "prepublishOnly:update": "yarn run ncu && yarn run sort-package-json",
63
+ "prepublishOnly:update": "pnpm run ncu && pnpm run sort-package-json",
62
64
  "publish": "echo publish",
63
65
  "postpublish": "echo postpublish",
64
66
  "postpublishOnly": "echo postpublishOnly",
@@ -67,15 +69,15 @@
67
69
  "tsc:showConfig": "ynpx get-current-tsconfig -p"
68
70
  },
69
71
  "dependencies": {
70
- "@ts-type/package-dts": "^3.0.9",
71
- "@yarn-tool/find-root": "^2.0.24",
72
- "@yarn-tool/resolve-package": "^3.0.9",
73
- "fs-extra": "^11.3.4",
72
+ "@ts-type/package-dts": "^3.0.14",
73
+ "@yarn-tool/find-root": "^2.0.26",
74
+ "@yarn-tool/require-resolve": "^4.0.10",
75
+ "fs-extra": "^11.4.1",
74
76
  "tslib": ">=2.8.1",
75
- "upath2": "^3.1.23"
77
+ "upath2": "^3.1.25"
76
78
  },
77
79
  "publishConfig": {
78
80
  "access": "public"
79
81
  },
80
- "gitHead": "8c939a673ef0f088d4a3aa8a240ed6c28d390f98"
82
+ "gitHead": "471c63ee11851f0ac3487f23d1c472936f99b460"
81
83
  }