@yarn-tool/static-file 3.0.4 → 3.0.6

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +9 -4
  3. package/__root.d.ts +28 -0
  4. package/__root.js +28 -0
  5. package/__root.js.map +1 -1
  6. package/file/.gitignore +10 -0
  7. package/file/README.md +11 -1
  8. package/file/gitignore +15 -0
  9. package/file/jest.config.auto.js +81 -15
  10. package/file/jest.config.js +3 -1
  11. package/file/npmrc +2 -1
  12. package/file/nvmrc +1 -1
  13. package/file/pnpm-workspace.yaml +19 -0
  14. package/file/test/__root.ts +3 -0
  15. package/file/tsconfig.json +5 -0
  16. package/file/tsdx/tsconfig.json.tpl +7 -0
  17. package/file/ws-root/jest-preset.js +32 -3
  18. package/file/ws-root/jest.config.js +3 -2
  19. package/index.d.ts +25 -0
  20. package/index.js +25 -0
  21. package/index.js.map +1 -1
  22. package/lib/const.d.ts +57 -3
  23. package/lib/const.js +81 -8
  24. package/lib/const.js.map +1 -1
  25. package/lib/copyStaticFiles.d.ts +50 -0
  26. package/lib/copyStaticFiles.js +48 -0
  27. package/lib/copyStaticFiles.js.map +1 -1
  28. package/lib/copyStaticFilesEntry.d.ts +50 -0
  29. package/lib/copyStaticFilesEntry.js +48 -0
  30. package/lib/copyStaticFilesEntry.js.map +1 -1
  31. package/lib/getRowOfStaticFilesMapArray.d.ts +40 -0
  32. package/lib/getRowOfStaticFilesMapArray.js +32 -0
  33. package/lib/getRowOfStaticFilesMapArray.js.map +1 -1
  34. package/lib/getStaticFile.d.ts +42 -0
  35. package/lib/getStaticFile.js +34 -0
  36. package/lib/getStaticFile.js.map +1 -1
  37. package/lib/parseStaticMap.d.ts +39 -0
  38. package/lib/parseStaticMap.js +7 -0
  39. package/lib/parseStaticMap.js.map +1 -1
  40. package/lib/reMapStaticFilesMapArray.d.ts +39 -0
  41. package/lib/reMapStaticFilesMapArray.js +36 -0
  42. package/lib/reMapStaticFilesMapArray.js.map +1 -1
  43. package/lib/replaceTargetOfStaticFilesMapArrayEntry.d.ts +33 -0
  44. package/lib/replaceTargetOfStaticFilesMapArrayEntry.js +25 -0
  45. package/lib/replaceTargetOfStaticFilesMapArrayEntry.js.map +1 -1
  46. package/lib/root/getRootCopyStaticFiles.d.ts +54 -0
  47. package/lib/root/getRootCopyStaticFiles.js +47 -0
  48. package/lib/root/getRootCopyStaticFiles.js.map +1 -1
  49. package/lib/types.d.ts +73 -0
  50. package/lib/types.js.map +1 -1
  51. package/lib/ws/wsCopyStaticFiles.d.ts +50 -0
  52. package/lib/ws/wsCopyStaticFiles.js +50 -0
  53. package/lib/ws/wsCopyStaticFiles.js.map +1 -1
  54. package/package.json +4 -4
  55. package/file/github/workflows/linter.yml +0 -57
  56. package/file/node-version +0 -1
  57. package/file/tsdx/index.cjs +0 -5
  58. package/file/tsdx/index.cjs.map +0 -1
  59. package/file/tsdx/index.d.cts +0 -2
  60. package/file/ws-root/__root_ws.d.ts +0 -2
  61. package/file/ws-root/__root_ws.js +0 -7
  62. package/file/ws-root/__root_ws.js.map +0 -1
  63. /package/file/{browserslistrc → ws-root/browserslistrc} +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,69 @@
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.6](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/static-file@3.0.5...@yarn-tool/static-file@3.0.6) (2026-03-04)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * 在 test、lint 及 lerna 相關腳本結尾添加 `--` 以確保額外參數能正確傳遞。
12
+
13
+
14
+
15
+ ### 🐛 Bug Fixes
16
+
17
+ * 在 test、lint 及 lerna 相關腳本結尾添加 `--` 以確保額外參數能正確傳遞。 ([88b7b15](https://github.com/bluelovers/ws-yarn-workspaces/commit/88b7b1535bbda94526591cbb4231b6040df11d4e))
18
+
19
+
20
+
21
+ ## [3.0.5](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/static-file@3.0.4...@yarn-tool/static-file@3.0.5) (2026-03-02)
22
+
23
+
24
+ ### BREAKING CHANGES
25
+
26
+ * **static-file:** 重新組織 const.ts 中的檔案映射
27
+
28
+
29
+
30
+ ### 🐛 Bug Fixes
31
+
32
+ * **config:** 更新 npmrc/pnpm-workspace.yaml 工作區設定 ([c127220](https://github.com/bluelovers/ws-yarn-workspaces/commit/c127220ce308de9409a1bc3b72b5bcf2e01432ce))
33
+ * **static-file:** 補齊 gitignore 規則並修正 jest 配置註解 ([d2e7101](https://github.com/bluelovers/ws-yarn-workspaces/commit/d2e710116f3a3a3632a21839cd9629edaee66a8a))
34
+
35
+
36
+ ### ✨ Features
37
+
38
+ * **yarn-tool:** 簡化靜態檔案複製配置並新增測試路徑常數 ([8f7660c](https://github.com/bluelovers/ws-yarn-workspaces/commit/8f7660c6df39b7cfd2c69a019f02a5f840193092))
39
+
40
+
41
+ ### 📦 Code Refactoring
42
+
43
+ * **jest-config:** 更改模組載入機制並完善文件註解 ([8c1efb9](https://github.com/bluelovers/ws-yarn-workspaces/commit/8c1efb94efc6ca5e6f2a8eec20c428a6449fc5e7))
44
+ * **static-file:** 重構 tsconfig 靜態檔案映射並更新 gitignore ([e79863e](https://github.com/bluelovers/ws-yarn-workspaces/commit/e79863ef29cb41a28d7fa53082a676907c149368))
45
+
46
+
47
+ ### 📚 Documentation
48
+
49
+ * **@yarn-tool/ws-find-up-paths:** 新增雙語 JSDoc 註解並更新 README 文件 ([514a876](https://github.com/bluelovers/ws-yarn-workspaces/commit/514a876771481be67af4a41853582776dc444bb9))
50
+ * **setup-module-env:** 為 tsdx 設定模組添加完整的 JSDoc 文檔註釋 ([5def98a](https://github.com/bluelovers/ws-yarn-workspaces/commit/5def98ab905bb3dc50d2d00e5f3f3d4da5d23cf3))
51
+
52
+
53
+ ### 🛠 Build System
54
+
55
+ * update build ([51d49ad](https://github.com/bluelovers/ws-yarn-workspaces/commit/51d49adaa1f1fbfac4a299007dbf406d7ee7a4c7))
56
+
57
+
58
+ ### ♻️ Chores
59
+
60
+ * Add test config and global types for tsdx ([88a8df6](https://github.com/bluelovers/ws-yarn-workspaces/commit/88a8df6eef5dc59d9e0d9268b21706dceb5ab2a1))
61
+ * update README installation commands and add JSDoc comments ([2caaee5](https://github.com/bluelovers/ws-yarn-workspaces/commit/2caaee5185b452ec82768faacc27422aec8104b1))
62
+ * add __root.ts test utility to workspace packages ([a771727](https://github.com/bluelovers/ws-yarn-workspaces/commit/a7717278883c86d9ed8ab89f42070d3385c173a7))
63
+ * **deps:** 升級路徑與檔案系統相關依賴版本 ([78d395b](https://github.com/bluelovers/ws-yarn-workspaces/commit/78d395b5469feecc85f250ca2d8b4977161e7618))
64
+ * **deps:** 升級多項依賴套件版本 ([1382602](https://github.com/bluelovers/ws-yarn-workspaces/commit/1382602ca94ff236b251fd1481b6332468de4621))
65
+ * **static-file:** 重新組織 const.ts 中的檔案映射 ([43b04e0](https://github.com/bluelovers/ws-yarn-workspaces/commit/43b04e0884b4dcf1ecd39267a68893291136788c))
66
+
67
+
68
+
6
69
  ## [3.0.4](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/static-file@3.0.3...@yarn-tool/static-file@3.0.4) (2025-09-07)
7
70
 
8
71
 
package/README.md CHANGED
@@ -1,12 +1,17 @@
1
1
  # README.md
2
2
 
3
- <%= description %>
3
+
4
4
 
5
5
  ## install
6
6
 
7
7
  ```bash
8
- yarn add <%= name %>
9
- yarn-tool add <%= name %>
10
- yt add <%= name %>
8
+ yarn add @yarn-tool/static-file
9
+
10
+ yarn-tool add @yarn-tool/static-file
11
+ yt add @yarn-tool/static-file
12
+
13
+ pnpm add @yarn-tool/static-file
14
+
15
+ npm install @yarn-tool/static-file
11
16
  ```
12
17
 
package/__root.d.ts CHANGED
@@ -1 +1,29 @@
1
+ /**
2
+ * Static files root directory constant / 靜態檔案根目錄常量
3
+ *
4
+ * This module exports the root directory path where static files are located.
5
+ * 此模組匯出靜態檔案所在的根目錄路徑。
6
+ *
7
+ * The `__STATIC_ROOT` constant is used internally to locate the static files
8
+ * that will be copied to target directories.
9
+ * `__STATIC_ROOT` 常量在內部用於定位將被複製到目標目錄的靜態檔案。
10
+ *
11
+ * @module __root
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { __STATIC_ROOT } from '@yarn-tool/static-file/__root';
16
+ *
17
+ * console.log(__STATIC_ROOT);
18
+ * // Outputs the path to the static files directory
19
+ * // 輸出靜態檔案目錄的路徑
20
+ * ```
21
+ */
22
+ /**
23
+ * The root directory path of the static files / 靜態檔案的根目錄路徑
24
+ *
25
+ * This is the directory where the `file/` folder containing all static
26
+ * configuration templates is located.
27
+ * 這是包含所有靜態配置模板的 `file/` 資料夾所在的目錄。
28
+ */
1
29
  export declare const __STATIC_ROOT: string;
package/__root.js CHANGED
@@ -1,5 +1,33 @@
1
1
  "use strict";
2
+ /**
3
+ * Static files root directory constant / 靜態檔案根目錄常量
4
+ *
5
+ * This module exports the root directory path where static files are located.
6
+ * 此模組匯出靜態檔案所在的根目錄路徑。
7
+ *
8
+ * The `__STATIC_ROOT` constant is used internally to locate the static files
9
+ * that will be copied to target directories.
10
+ * `__STATIC_ROOT` 常量在內部用於定位將被複製到目標目錄的靜態檔案。
11
+ *
12
+ * @module __root
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { __STATIC_ROOT } from '@yarn-tool/static-file/__root';
17
+ *
18
+ * console.log(__STATIC_ROOT);
19
+ * // Outputs the path to the static files directory
20
+ * // 輸出靜態檔案目錄的路徑
21
+ * ```
22
+ */
2
23
  Object.defineProperty(exports, "__esModule", { value: true });
3
24
  exports.__STATIC_ROOT = void 0;
25
+ /**
26
+ * The root directory path of the static files / 靜態檔案的根目錄路徑
27
+ *
28
+ * This is the directory where the `file/` folder containing all static
29
+ * configuration templates is located.
30
+ * 這是包含所有靜態配置模板的 `file/` 資料夾所在的目錄。
31
+ */
4
32
  exports.__STATIC_ROOT = __dirname;
5
33
  //# sourceMappingURL=__root.js.map
package/__root.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"__root.js","sourceRoot":"","sources":["__root.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,SAAS,CAAC","sourcesContent":["export const __STATIC_ROOT = __dirname;\n"]}
1
+ {"version":3,"file":"__root.js","sourceRoot":"","sources":["__root.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH;;;;;;GAMG;AACU,QAAA,aAAa,GAAG,SAAS,CAAC","sourcesContent":["/**\n * Static files root directory constant / 靜態檔案根目錄常量\n *\n * This module exports the root directory path where static files are located.\n * 此模組匯出靜態檔案所在的根目錄路徑。\n *\n * The `__STATIC_ROOT` constant is used internally to locate the static files\n * that will be copied to target directories.\n * `__STATIC_ROOT` 常量在內部用於定位將被複製到目標目錄的靜態檔案。\n *\n * @module __root\n *\n * @example\n * ```typescript\n * import { __STATIC_ROOT } from '@yarn-tool/static-file/__root';\n *\n * console.log(__STATIC_ROOT);\n * // Outputs the path to the static files directory\n * // 輸出靜態檔案目錄的路徑\n * ```\n */\n\n/**\n * The root directory path of the static files / 靜態檔案的根目錄路徑\n *\n * This is the directory where the `file/` folder containing all static\n * configuration templates is located.\n * 這是包含所有靜態配置模板的 `file/` 資料夾所在的目錄。\n */\nexport const __STATIC_ROOT = __dirname;\n"]}
@@ -0,0 +1,10 @@
1
+ __root_ws.js
2
+ __root_ws.d.ts
3
+ __root.js
4
+ __root.d.ts
5
+ temp.js
6
+ temp.d.ts
7
+ index.cjs
8
+ index.d.cts
9
+ index.mjs
10
+ index.d.mts
package/file/README.md CHANGED
@@ -2,11 +2,21 @@
2
2
 
3
3
  <%= description %>
4
4
 
5
- ## install
5
+ ## 安裝 (Installation)
6
6
 
7
7
  ```bash
8
+ # 使用 yarn / Using yarn
8
9
  yarn add <%= name %>
10
+
11
+ # 使用 yarn-tool / Using yarn-tool
9
12
  yarn-tool add <%= name %>
13
+ # yt 是 yarn-tool 的別名 / yt is an alias for yarn-tool
10
14
  yt add <%= name %>
15
+
16
+ # 使用 pnpm / Using pnpm
17
+ pnpm add <%= name %>
18
+
19
+ # 使用 npm / Using npm
20
+ npm install <%= name %>
11
21
  ```
12
22
 
package/file/gitignore CHANGED
@@ -132,6 +132,7 @@ bin/**/*.d.cts
132
132
  *.tgz
133
133
  /tsconfig.json.tpl
134
134
  /.eslintrc.json.tpl
135
+ !test/tsconfig.json
135
136
  !tsconfig.json
136
137
  !.eslintrc.json
137
138
  yarn-error.log
@@ -168,7 +169,11 @@ coverage
168
169
  tsconfig.esm.json.tpl
169
170
 
170
171
  .browserslistrc
172
+
171
173
  .nvmrc
174
+ .node-version
175
+ !/.nvmrc
176
+ !/.node-version
172
177
 
173
178
  /.eslintignore
174
179
  /package.d.ts
@@ -226,3 +231,13 @@ dist/*.umd.*.*s
226
231
  !/.storybook/
227
232
 
228
233
  test/fixtures/.gitkeep
234
+
235
+ !.clinerules
236
+ !.kilocode
237
+ !.cline
238
+ !.junie
239
+ !.gemini
240
+ !.copilot
241
+ !.claude
242
+ !.agents
243
+ !.aiassistant
@@ -1,18 +1,59 @@
1
1
  // @ts-check
2
2
 
3
+ /**
4
+ * Jest 自動配置模組
5
+ * Jest Auto Configuration Module
6
+ *
7
+ * 此模組自動偵測並配置 Jest 測試環境,支援多層級配置解析
8
+ * This module automatically detects and configures Jest test environment with multi-level configuration resolution
9
+ */
10
+
3
11
  const { basename, extname, dirname } = require('path');
4
12
 
5
13
  /**
6
- * // @type { import('@jest/types').Config.InitialOptions }
7
- * @type { import('ts-jest').InitialOptionsTsJest }
14
+ * Jest 配置物件
15
+ * Jest configuration object
16
+ *
17
+ * @type { import('ts-jest').JestConfigWithTsJest }
8
18
  */
9
19
  let jestConfig = {
10
20
 
11
21
  }
12
22
 
13
23
  /**
14
- * @param {string} name
15
- * @returns {string}
24
+ * 嘗試使用 `@yarn-tool/require-resolve` 載入模組的工具函數
25
+ * Utility function for lazy loading modules
26
+ *
27
+ * @param {string} name - 模組名稱 Module name
28
+ * @param {string[]} [paths] - 搜尋路徑 Search paths
29
+ * @private
30
+ */
31
+ function _lazyRequire(name, paths)
32
+ {
33
+ let m;
34
+ try
35
+ {
36
+ // 嘗試使用 require-resolve 工具載入模組
37
+ // Try to load module using require-resolve tool
38
+ m = require('@yarn-tool/require-resolve').requireExtra(name, {
39
+ includeCurrentDirectory: true,
40
+ includeGlobal: true,
41
+ paths,
42
+ });
43
+ }
44
+ catch (e) {}
45
+
46
+ // 如果失敗則使用標準 require
47
+ // If failed, use standard require
48
+ return typeof m === 'undefined' ? require(name) : m;
49
+ }
50
+
51
+ /**
52
+ * 嘗試使用 `@yarn-tool/require-resolve` 解析模組路徑的工具函數
53
+ * Utility function for resolving module paths
54
+ *
55
+ * @param {string} name - 模組名稱 Module name
56
+ * @returns {string} - 解析後的路徑 Resolved path
16
57
  * @private
17
58
  */
18
59
  function _requireResolve(name)
@@ -21,9 +62,11 @@ function _requireResolve(name)
21
62
 
22
63
  try
23
64
  {
24
- // @ts-ignore
25
- const { requireResolveExtra, requireResolveCore } = require('@yarn-tool/require-resolve');
65
+ /** @type {import('@yarn-tool/require-resolve')} */
66
+ const { requireResolveExtra, requireResolveCore } = _lazyRequire('@yarn-tool/require-resolve');
26
67
 
68
+ // 嘗試從多個路徑解析 TSDX 相關模組
69
+ // Try to resolve TSDX related modules from multiple paths
27
70
  const paths = [
28
71
  requireResolveExtra('@bluelovers/tsdx').result,
29
72
  requireResolveExtra('tsdx').result,
@@ -40,6 +83,8 @@ function _requireResolve(name)
40
83
 
41
84
  }
42
85
 
86
+ // 如果都失敗,使用標準 resolve
87
+ // If all failed, use standard resolve
43
88
  result = result || require.resolve(name);
44
89
 
45
90
  console.info('[require.resolve]', name, '=>', result)
@@ -47,19 +92,27 @@ function _requireResolve(name)
47
92
  return result
48
93
  }
49
94
 
50
- let _ok = true;
95
+ // 配置解析狀態標誌
96
+ // Configuration resolution status flag
97
+ let _isNeedConfig = true;
51
98
 
52
99
  try
53
100
  {
101
+ // 第一層:搜尋工作區中的配置檔案
102
+ // First level: Search for configuration files in workspace
54
103
  if (!jestConfig.preset)
55
104
  {
105
+ /** @type {import('@yarn-tool/ws-find-up-paths')} */
106
+ const { findUpPathsWorkspaces } = _lazyRequire('@yarn-tool/ws-find-up-paths');
56
107
 
57
- let result = require('@yarn-tool/ws-find-up-paths').findUpPathsWorkspaces([
108
+ // 向上搜尋 jest-preset.js 和 jest.config.js
109
+ // Search upwards for jest-preset.js and jest.config.js
110
+ let result = findUpPathsWorkspaces([
58
111
  'jest-preset.js',
59
112
  'jest.config.js',
60
113
  ], {
61
- ignoreCurrentPackage: true,
62
- onlyFiles: true,
114
+ ignoreCurrentPackage: true, // 忽略當前套件
115
+ onlyFiles: true, // 只搜尋檔案
63
116
  }).result;
64
117
 
65
118
  if (result)
@@ -69,9 +122,14 @@ try
69
122
  switch (name)
70
123
  {
71
124
  case 'jest-preset':
125
+ // 如果是 jest-preset.js,使用其目錄作為 preset
126
+ // If it's jest-preset.js, use its directory as preset
127
+ // @ts-ignore
72
128
  jestConfig.preset = dirname(result);
73
129
  break;
74
130
  default:
131
+ // 其他情況,載入配置檔案內容
132
+ // Otherwise, load the configuration file content
75
133
  jestConfig = {
76
134
  ...require(result),
77
135
  jestConfig,
@@ -79,7 +137,7 @@ try
79
137
  break;
80
138
  }
81
139
 
82
- _ok = false;
140
+ _isNeedConfig = false;
83
141
  }
84
142
  }
85
143
  }
@@ -90,13 +148,16 @@ catch (e)
90
148
 
91
149
  try
92
150
  {
93
- if (_ok && !jestConfig.preset)
151
+ // 第二層:嘗試解析 @bluelovers/jest-config
152
+ // Second level: Try to resolve @bluelovers/jest-config
153
+ if (_isNeedConfig && !jestConfig.preset)
94
154
  {
95
155
  let result = _requireResolve('@bluelovers/jest-config/package.json');
96
156
  if (result)
97
157
  {
158
+ // @ts-ignore
98
159
  jestConfig.preset = dirname(result);
99
- _ok = false;
160
+ _isNeedConfig = false;
100
161
  }
101
162
  }
102
163
  }
@@ -105,12 +166,17 @@ catch (e)
105
166
 
106
167
  }
107
168
 
108
- if (_ok && !jestConfig.preset)
169
+ if (_isNeedConfig && !jestConfig.preset)
109
170
  {
171
+ // 第三層:使用預設的 @bluelovers/jest-config
172
+ // Third level: Use default @bluelovers/jest-config
173
+ // @ts-ignore
110
174
  jestConfig.preset = '@bluelovers/jest-config';
111
- _ok = false;
175
+ _isNeedConfig = false;
112
176
  }
113
177
 
178
+ // 輸出最終的 preset 設定
179
+ // Output the final preset configuration
114
180
  console.info(`jest.config.preset: ${jestConfig.preset}`);
115
181
 
116
182
  module.exports = jestConfig
@@ -1,6 +1,8 @@
1
1
  // @ts-check
2
+ // @deprecated replace by jest.config.auto.js
2
3
 
3
4
  const { join, dirname } = require('path');
5
+ // @ts-ignore
4
6
  const { tryRealpath } = require('jest-util');
5
7
  const { tmpdir } = require('os');
6
8
 
@@ -76,7 +78,7 @@ const testExt = [
76
78
  const cacheDirectory = getCacheDirectory();
77
79
 
78
80
  /**
79
- * // @type { import('@jest/types').Config.InitialOptions }
81
+ * @_type { import('@jest/types').Config.InitialOptions }
80
82
  * @type { import('ts-jest').InitialOptionsTsJest }
81
83
  */
82
84
  const jestConfig = {
package/file/npmrc CHANGED
@@ -1,4 +1,5 @@
1
1
  registry=https://registry.npmjs.org/
2
2
  color=always
3
3
  package-manager-strict=false
4
- public-hoist-pattern[]=@types/*
4
+ link-workspace-packages=true
5
+ save-workspace-protocol=false
package/file/nvmrc CHANGED
@@ -1 +1 @@
1
- node
1
+ lts/*
@@ -3,3 +3,22 @@ packages:
3
3
  - 'packages/*'
4
4
  # exclude packages that are inside test/ directories
5
5
  - '!**/test/**'
6
+
7
+ publicHoistPattern:
8
+ - "ts-type"
9
+ - "@bluelovers/tsconfig"
10
+ - "@bluelovers/jest-config"
11
+ - "@types/node"
12
+ - "@types/jest"
13
+ - "jest"
14
+ - "ts-jest"
15
+ - "ts-node"
16
+ - "tsx"
17
+ - "tslib"
18
+
19
+ linkWorkspacePackages: true
20
+ saveWorkspaceProtocol: false
21
+ # ignoreWorkspaceRootCheck: true
22
+
23
+ # onlyBuiltDependencies: []
24
+ # ignoredBuiltDependencies: []
@@ -3,3 +3,6 @@ import { join } from "path";
3
3
  export const __ROOT = join(__dirname, '..');
4
4
 
5
5
  export const isWin = process.platform === "win32";
6
+
7
+ export const __TEST_ROOT = join(__ROOT, 'test');
8
+ export const __TEST_FIXTURES = join(__TEST_ROOT, 'fixtures');
@@ -0,0 +1,5 @@
1
+ {
2
+ "compilerOptions": {
3
+ "noEmit": true
4
+ }
5
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "emitDeclarationOnly": true,
5
+ "noEmit": true
6
+ }
7
+ }
@@ -1,8 +1,37 @@
1
- const { mixinJestConfig } = require('@bluelovers/jest-config');
1
+ /**
2
+ * 嘗試使用 `@yarn-tool/require-resolve` 載入模組的工具函數
3
+ * Utility function for lazy loading modules
4
+ *
5
+ * @param {string} name - 模組名稱 Module name
6
+ * @param {string[]} [paths] - 搜尋路徑 Search paths
7
+ * @private
8
+ */
9
+ function _lazyRequire(name, paths)
10
+ {
11
+ let m;
12
+ try
13
+ {
14
+ // 嘗試使用 require-resolve 工具載入模組
15
+ // Try to load module using require-resolve tool
16
+ m = require('@yarn-tool/require-resolve').requireExtra(name, {
17
+ includeCurrentDirectory: true,
18
+ includeGlobal: true,
19
+ paths,
20
+ });
21
+ }
22
+ catch (e) {}
23
+
24
+ // 如果失敗則使用標準 require
25
+ // If failed, use standard require
26
+ return typeof m === 'undefined' ? require(name) : m;
27
+ }
28
+
29
+ /** @type {import('@bluelovers/jest-config')} */
30
+ const { mixinJestConfig } = _lazyRequire('@bluelovers/jest-config');
2
31
 
3
32
  /**
4
- * // @type { import('@jest/types').Config.InitialOptions }
5
- * // @type { import('ts-jest').InitialOptionsTsJest }
33
+ * @_type { import('@jest/types').Config.InitialOptions }
34
+ * @_type { import('ts-jest').InitialOptionsTsJest }
6
35
  * @type { import('ts-jest').JestConfigWithTsJest }
7
36
  */
8
37
  const jestConfig = mixinJestConfig({}, true, {
@@ -2,8 +2,9 @@
2
2
  const { resolve } = require('path');
3
3
 
4
4
  /**
5
- * // @type { import('@jest/types').Config.InitialOptions }
6
- * @type { import('ts-jest').InitialOptionsTsJest }
5
+ * @_type { import('@jest/types').Config.InitialOptions }
6
+ * @_type { import('ts-jest').InitialOptionsTsJest }
7
+ * @type { import('ts-jest').JestConfigWithTsJest }
7
8
  */
8
9
  const jestConfig = {
9
10
  preset: __dirname,
package/index.d.ts CHANGED
@@ -1,3 +1,28 @@
1
+ /**
2
+ * @yarn-tool/static-file
3
+ *
4
+ * A utility for copying static configuration files to yarn workspace projects.
5
+ * 用於將靜態配置檔案複製到 yarn 工作區專案的工具。
6
+ *
7
+ * This package provides functionality to copy predefined static files
8
+ * (such as .gitignore, tsconfig.json, etc.) to target directories.
9
+ * 此套件提供將預定義的靜態檔案(如 .gitignore、tsconfig.json 等)
10
+ * 複製到目標目錄的功能。
11
+ *
12
+ * @packageDocumentation
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { copyStaticFiles } from '@yarn-tool/static-file';
17
+ *
18
+ * // Copy default static files to current directory
19
+ * // 將預設靜態檔案複製到當前目錄
20
+ * copyStaticFiles({
21
+ * cwd: process.cwd(),
22
+ * overwrite: true
23
+ * });
24
+ * ```
25
+ */
1
26
  import { copyStaticFiles } from './lib/copyStaticFiles';
2
27
  export { copyStaticFiles };
3
28
  export default copyStaticFiles;
package/index.js CHANGED
@@ -1,6 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.copyStaticFiles = void 0;
4
+ /**
5
+ * @yarn-tool/static-file
6
+ *
7
+ * A utility for copying static configuration files to yarn workspace projects.
8
+ * 用於將靜態配置檔案複製到 yarn 工作區專案的工具。
9
+ *
10
+ * This package provides functionality to copy predefined static files
11
+ * (such as .gitignore, tsconfig.json, etc.) to target directories.
12
+ * 此套件提供將預定義的靜態檔案(如 .gitignore、tsconfig.json 等)
13
+ * 複製到目標目錄的功能。
14
+ *
15
+ * @packageDocumentation
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { copyStaticFiles } from '@yarn-tool/static-file';
20
+ *
21
+ * // Copy default static files to current directory
22
+ * // 將預設靜態檔案複製到當前目錄
23
+ * copyStaticFiles({
24
+ * cwd: process.cwd(),
25
+ * overwrite: true
26
+ * });
27
+ * ```
28
+ */
4
29
  const copyStaticFiles_1 = require("./lib/copyStaticFiles");
5
30
  Object.defineProperty(exports, "copyStaticFiles", { enumerable: true, get: function () { return copyStaticFiles_1.copyStaticFiles; } });
6
31
  exports.default = copyStaticFiles_1.copyStaticFiles;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AAE/C,gGAFA,iCAAe,OAEA;AAExB,kBAAe,iCAAe,CAAC","sourcesContent":["import { copyStaticFiles } from './lib/copyStaticFiles';\n\nexport { copyStaticFiles }\n\nexport default copyStaticFiles;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,2DAAwD;AAE/C,gGAFA,iCAAe,OAEA;AAExB,kBAAe,iCAAe,CAAC","sourcesContent":["/**\n * @yarn-tool/static-file\n *\n * A utility for copying static configuration files to yarn workspace projects.\n * 用於將靜態配置檔案複製到 yarn 工作區專案的工具。\n *\n * This package provides functionality to copy predefined static files\n * (such as .gitignore, tsconfig.json, etc.) to target directories.\n * 此套件提供將預定義的靜態檔案(如 .gitignore、tsconfig.json 等)\n * 複製到目標目錄的功能。\n *\n * @packageDocumentation\n *\n * @example\n * ```typescript\n * import { copyStaticFiles } from '@yarn-tool/static-file';\n *\n * // Copy default static files to current directory\n * // 將預設靜態檔案複製到當前目錄\n * copyStaticFiles({\n * cwd: process.cwd(),\n * overwrite: true\n * });\n * ```\n */\nimport { copyStaticFiles } from './lib/copyStaticFiles';\n\nexport { copyStaticFiles }\n\nexport default copyStaticFiles;\n"]}