@yarn-tool/static-file 3.0.3 → 3.0.5

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 (72) hide show
  1. package/CHANGELOG.md +64 -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/github/dependabot.yml +39 -0
  9. package/file/github/workflows/action-yarnlock-dedupe.yml +3 -5
  10. package/file/github/workflows/build.yml +1 -0
  11. package/file/github/workflows/cmd-rebase.yml +28 -0
  12. package/file/github/workflows/codeql-analysis.yml +52 -0
  13. package/file/github/workflows/coverage.yml +2 -0
  14. package/file/github/workflows/yarn-lock-changes.yml +3 -0
  15. package/file/gitignore +15 -0
  16. package/file/jest.config.auto.js +81 -15
  17. package/file/jest.config.js +3 -1
  18. package/file/npmrc +3 -0
  19. package/file/nvmrc +1 -1
  20. package/file/pnpm-workspace.yaml +19 -0
  21. package/file/test/__root.ts +3 -0
  22. package/file/test/temp.ts +4 -0
  23. package/file/tsconfig.json +5 -0
  24. package/file/tsdx/tsconfig.json.tpl +7 -0
  25. package/file/ws-root/jest-preset.js +32 -3
  26. package/file/ws-root/jest.config.js +3 -2
  27. package/index.d.ts +25 -0
  28. package/index.js +25 -0
  29. package/index.js.map +1 -1
  30. package/lib/const.d.ts +57 -3
  31. package/lib/const.js +92 -7
  32. package/lib/const.js.map +1 -1
  33. package/lib/copyStaticFiles.d.ts +50 -0
  34. package/lib/copyStaticFiles.js +48 -0
  35. package/lib/copyStaticFiles.js.map +1 -1
  36. package/lib/copyStaticFilesEntry.d.ts +50 -0
  37. package/lib/copyStaticFilesEntry.js +48 -0
  38. package/lib/copyStaticFilesEntry.js.map +1 -1
  39. package/lib/getRowOfStaticFilesMapArray.d.ts +40 -0
  40. package/lib/getRowOfStaticFilesMapArray.js +32 -0
  41. package/lib/getRowOfStaticFilesMapArray.js.map +1 -1
  42. package/lib/getStaticFile.d.ts +42 -0
  43. package/lib/getStaticFile.js +34 -0
  44. package/lib/getStaticFile.js.map +1 -1
  45. package/lib/parseStaticMap.d.ts +39 -0
  46. package/lib/parseStaticMap.js +7 -0
  47. package/lib/parseStaticMap.js.map +1 -1
  48. package/lib/reMapStaticFilesMapArray.d.ts +39 -0
  49. package/lib/reMapStaticFilesMapArray.js +36 -0
  50. package/lib/reMapStaticFilesMapArray.js.map +1 -1
  51. package/lib/replaceTargetOfStaticFilesMapArrayEntry.d.ts +33 -0
  52. package/lib/replaceTargetOfStaticFilesMapArrayEntry.js +25 -0
  53. package/lib/replaceTargetOfStaticFilesMapArrayEntry.js.map +1 -1
  54. package/lib/root/getRootCopyStaticFiles.d.ts +54 -0
  55. package/lib/root/getRootCopyStaticFiles.js +47 -0
  56. package/lib/root/getRootCopyStaticFiles.js.map +1 -1
  57. package/lib/types.d.ts +73 -0
  58. package/lib/types.js.map +1 -1
  59. package/lib/ws/wsCopyStaticFiles.d.ts +50 -0
  60. package/lib/ws/wsCopyStaticFiles.js +50 -0
  61. package/lib/ws/wsCopyStaticFiles.js.map +1 -1
  62. package/package.json +3 -3
  63. package/file/test/__root.d.ts +0 -2
  64. package/file/test/__root.js +0 -7
  65. package/file/test/__root.js.map +0 -1
  66. package/file/tsdx/index.cjs +0 -5
  67. package/file/tsdx/index.cjs.map +0 -1
  68. package/file/tsdx/index.d.cts +0 -2
  69. package/file/ws-root/__root_ws.d.ts +0 -2
  70. package/file/ws-root/__root_ws.js +0 -7
  71. package/file/ws-root/__root_ws.js.map +0 -1
  72. /package/file/{browserslistrc → ws-root/browserslistrc} +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,70 @@
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.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)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * **static-file:** 重新組織 const.ts 中的檔案映射
12
+
13
+
14
+
15
+ ### 🐛 Bug Fixes
16
+
17
+ * **config:** 更新 npmrc/pnpm-workspace.yaml 工作區設定 ([c127220](https://github.com/bluelovers/ws-yarn-workspaces/commit/c127220ce308de9409a1bc3b72b5bcf2e01432ce))
18
+ * **static-file:** 補齊 gitignore 規則並修正 jest 配置註解 ([d2e7101](https://github.com/bluelovers/ws-yarn-workspaces/commit/d2e710116f3a3a3632a21839cd9629edaee66a8a))
19
+
20
+
21
+ ### ✨ Features
22
+
23
+ * **yarn-tool:** 簡化靜態檔案複製配置並新增測試路徑常數 ([8f7660c](https://github.com/bluelovers/ws-yarn-workspaces/commit/8f7660c6df39b7cfd2c69a019f02a5f840193092))
24
+
25
+
26
+ ### 📦 Code Refactoring
27
+
28
+ * **jest-config:** 更改模組載入機制並完善文件註解 ([8c1efb9](https://github.com/bluelovers/ws-yarn-workspaces/commit/8c1efb94efc6ca5e6f2a8eec20c428a6449fc5e7))
29
+ * **static-file:** 重構 tsconfig 靜態檔案映射並更新 gitignore ([e79863e](https://github.com/bluelovers/ws-yarn-workspaces/commit/e79863ef29cb41a28d7fa53082a676907c149368))
30
+
31
+
32
+ ### 📚 Documentation
33
+
34
+ * **@yarn-tool/ws-find-up-paths:** 新增雙語 JSDoc 註解並更新 README 文件 ([514a876](https://github.com/bluelovers/ws-yarn-workspaces/commit/514a876771481be67af4a41853582776dc444bb9))
35
+ * **setup-module-env:** 為 tsdx 設定模組添加完整的 JSDoc 文檔註釋 ([5def98a](https://github.com/bluelovers/ws-yarn-workspaces/commit/5def98ab905bb3dc50d2d00e5f3f3d4da5d23cf3))
36
+
37
+
38
+ ### 🛠 Build System
39
+
40
+ * update build ([51d49ad](https://github.com/bluelovers/ws-yarn-workspaces/commit/51d49adaa1f1fbfac4a299007dbf406d7ee7a4c7))
41
+
42
+
43
+ ### ♻️ Chores
44
+
45
+ * Add test config and global types for tsdx ([88a8df6](https://github.com/bluelovers/ws-yarn-workspaces/commit/88a8df6eef5dc59d9e0d9268b21706dceb5ab2a1))
46
+ * update README installation commands and add JSDoc comments ([2caaee5](https://github.com/bluelovers/ws-yarn-workspaces/commit/2caaee5185b452ec82768faacc27422aec8104b1))
47
+ * add __root.ts test utility to workspace packages ([a771727](https://github.com/bluelovers/ws-yarn-workspaces/commit/a7717278883c86d9ed8ab89f42070d3385c173a7))
48
+ * **deps:** 升級路徑與檔案系統相關依賴版本 ([78d395b](https://github.com/bluelovers/ws-yarn-workspaces/commit/78d395b5469feecc85f250ca2d8b4977161e7618))
49
+ * **deps:** 升級多項依賴套件版本 ([1382602](https://github.com/bluelovers/ws-yarn-workspaces/commit/1382602ca94ff236b251fd1481b6332468de4621))
50
+ * **static-file:** 重新組織 const.ts 中的檔案映射 ([43b04e0](https://github.com/bluelovers/ws-yarn-workspaces/commit/43b04e0884b4dcf1ecd39267a68893291136788c))
51
+
52
+
53
+
54
+ ## [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)
55
+
56
+
57
+
58
+ ### ⚙️ Continuous Integration
59
+
60
+ * comment - Automatic Rebase ([55fc9a2](https://github.com/bluelovers/ws-yarn-workspaces/commit/55fc9a20dbf31883cf36ece29a3dcb64cf2f024e))
61
+
62
+
63
+ ### ♻️ Chores
64
+
65
+ * update pnpm config ([7b529b3](https://github.com/bluelovers/ws-yarn-workspaces/commit/7b529b37af6f53550025143a54714fa07013c6a4))
66
+ * add new static files ([994fcef](https://github.com/bluelovers/ws-yarn-workspaces/commit/994fcef7ae3af7d102cfa837bbf0678102b44910))
67
+
68
+
69
+
6
70
  ## [3.0.3](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/static-file@3.0.2...@yarn-tool/static-file@3.0.3) (2024-05-03)
7
71
 
8
72
 
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
 
@@ -0,0 +1,39 @@
1
+ # `dependabot.yml` file with updates
2
+ # disabled for Docker and limited for npm
3
+ # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuring-dependabot-version-updates#example-disabling-version-updates-for-some-dependencies
4
+
5
+ version: 2
6
+ updates:
7
+ # Configuration for Dockerfile
8
+ - package-ecosystem: "docker"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
12
+ # Disable all pull requests for Docker dependencies
13
+ open-pull-requests-limit: 0
14
+
15
+ # Configuration for npm
16
+ - package-ecosystem: "npm"
17
+ directory: "/"
18
+ schedule:
19
+ interval: "weekly"
20
+ ignore:
21
+ # Ignore updates to packages that start with 'aws'
22
+ # Wildcards match zero or more arbitrary characters
23
+ - dependency-name: "aws*"
24
+ # Ignore some updates to the 'express' package
25
+ - dependency-name: "express"
26
+ # Ignore only new versions for 4.x and 5.x
27
+ versions: ["4.x", "5.x"]
28
+ # For all packages, ignore all patch updates
29
+ - dependency-name: "*"
30
+ update-types: ["version-update:semver-patch"]
31
+ open-pull-requests-limit: 0
32
+ -
33
+ package-ecosystem: "mix"
34
+ directory: "/"
35
+ schedule:
36
+ interval: "weekly"
37
+ # Disable version updates for hex dependencies
38
+ open-pull-requests-limit: 0
39
+
@@ -9,11 +9,6 @@ on:
9
9
  # - next
10
10
  # - canary
11
11
  pull_request:
12
- branches:
13
- - master
14
- - main
15
- - next
16
- - canary
17
12
  paths:
18
13
  - yarn.lock
19
14
 
@@ -23,6 +18,9 @@ jobs:
23
18
  #if: "contains(github.event.head_commit.message, '[skip ci]')"
24
19
  steps:
25
20
  - uses: actions/checkout@v2
21
+ with:
22
+ fetch-depth: 2
23
+ token: ${{ secrets.GITHUB_TOKEN }}
26
24
  - name: yarn.lock deduplication
27
25
  uses: bluelovers/action-yarnlock-dedupe@v1
28
26
  - name: commit yarn.lock
@@ -39,6 +39,7 @@ jobs:
39
39
  - uses: actions/checkout@main
40
40
  with:
41
41
  fetch-depth: 2
42
+ token: ${{ secrets.GITHUB_TOKEN }}
42
43
  - name: Set up Node.js ${{ matrix.node-version }}
43
44
  uses: actions/setup-node@main
44
45
  with:
@@ -0,0 +1,28 @@
1
+ name: comment - Automatic Rebase
2
+ on:
3
+ issue_comment:
4
+ types: [ created ]
5
+ jobs:
6
+ rebase:
7
+ name: Rebase
8
+ runs-on: ubuntu-latest
9
+ if: >-
10
+ github.event.issue.pull_request != '' &&
11
+ (
12
+ contains(github.event.comment.body, '/rebase') ||
13
+ contains(github.event.comment.body, '/autosquash')
14
+ )
15
+ steps:
16
+ -
17
+ name: Checkout the latest code
18
+ uses: actions/checkout@v3
19
+ with:
20
+ token: ${{ secrets.GITHUB_TOKEN }}
21
+ fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
22
+ -
23
+ name: Automatic Rebase
24
+ uses: cirrus-actions/rebase@1.8
25
+ with:
26
+ autosquash: ${{ contains(github.event.comment.body, '/autosquash') || contains(github.event.comment.body, '/rebase-autosquash') }}
27
+ env:
28
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,52 @@
1
+ name: CodeQL
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ branches:
7
+ - main
8
+ push:
9
+ branches:
10
+ - main
11
+ schedule:
12
+ - cron: '31 7 * * 3'
13
+
14
+ permissions:
15
+ actions: read
16
+ checks: write
17
+ contents: read
18
+ security-events: write
19
+
20
+ jobs:
21
+ analyze:
22
+ name: Analyze
23
+ runs-on: ubuntu-latest
24
+ if: "!contains(github.event.head_commit.message, '[skip ci]')"
25
+
26
+ strategy:
27
+ fail-fast: false
28
+ matrix:
29
+ language:
30
+ - TypeScript
31
+
32
+ steps:
33
+ - name: Checkout
34
+ id: checkout
35
+ uses: actions/checkout@v4
36
+ with:
37
+ fetch-depth: 2
38
+ token: ${{ secrets.GITHUB_TOKEN }}
39
+ - name: Initialize CodeQL
40
+ id: initialize
41
+ uses: github/codeql-action/init@v3
42
+ with:
43
+ languages: ${{ matrix.language }}
44
+ source-root: src
45
+
46
+ - name: Autobuild
47
+ id: autobuild
48
+ uses: github/codeql-action/autobuild@v3
49
+
50
+ - name: Perform CodeQL Analysis
51
+ id: analyze
52
+ uses: github/codeql-action/analyze@v3
@@ -22,6 +22,8 @@ jobs:
22
22
 
23
23
  steps:
24
24
  - uses: actions/checkout@main
25
+ fetch-depth: 2
26
+ token: ${{ secrets.GITHUB_TOKEN }}
25
27
  - name: Set up Node.js ${{ matrix.node-version }}
26
28
  uses: actions/setup-node@main
27
29
  with:
@@ -1,5 +1,6 @@
1
1
  name: Yarn Lock Changes
2
2
  on:
3
+ workflow_dispatch:
3
4
  pull_request:
4
5
  paths:
5
6
  - yarn.lock
@@ -17,6 +18,8 @@ jobs:
17
18
  -
18
19
  name: Checkout
19
20
  uses: actions/checkout@v3
21
+ fetch-depth: 2
22
+ token: ${{ secrets.GITHUB_TOKEN }}
20
23
  -
21
24
  name: Yarn Lock Changes
22
25
  # Please use `main` as version before the stable release will be published as `v1`.
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,2 +1,5 @@
1
1
  registry=https://registry.npmjs.org/
2
2
  color=always
3
+ package-manager-strict=false
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,4 @@
1
+ /**
2
+ * Created by user on 2024/5/31.
3
+ */
4
+
@@ -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
+ }