@yarn-tool/static-file 3.0.17 → 3.0.18
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 +10 -0
- package/file/jest.config.auto.js +208 -0
- package/file/test/__root.ts +47 -0
- package/file/test/fixtures/.gitkeep +0 -0
- package/file/test/temp.ts +2 -0
- package/file/tsconfig.esm.json.tpl +14 -0
- package/file/tsdx.config.js +14 -0
- package/file/ws-root/__root_ws.ts +5 -0
- package/file/ws-root/jest.config.js +13 -0
- package/package.json +6 -8
- package/file/test/__root.js.map +0 -1
- package/file/test/temp.js.map +0 -1
- package/file/tsdx/index.cjs.map +0 -1
- package/file/ws-root/__root_ws.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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.18](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/static-file@3.0.17...@yarn-tool/static-file@3.0.18) (2026-09-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### ⚙️ Continuous Integration
|
|
11
|
+
|
|
12
|
+
* **@yarn-tool/static-file:** 自動化更新 .gitignore 與 .npmignore 中的靜態檔案排除清單 ([1841063](https://github.com/bluelovers/ws-yarn-workspaces/commit/1841063c025c0d9e561386b8b4e91e19c24d8bfc))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
## [3.0.17](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/static-file@3.0.16...@yarn-tool/static-file@3.0.17) (2026-09-06)
|
|
7
17
|
|
|
8
18
|
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// @ts-check
|
|
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
|
+
|
|
11
|
+
const { basename, extname, dirname } = require('path');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Jest 配置物件
|
|
15
|
+
* Jest configuration object
|
|
16
|
+
*
|
|
17
|
+
* @type { import('ts-jest').JestConfigWithTsJest }
|
|
18
|
+
*/
|
|
19
|
+
let jestConfig = {}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 嘗試使用 `@yarn-tool/require-resolve` 載入模組的工具函數
|
|
23
|
+
* Utility function for lazy loading modules
|
|
24
|
+
*
|
|
25
|
+
* @param {string} name - 模組名稱 Module name
|
|
26
|
+
* @param {string[]} [paths] - 搜尋路徑 Search paths
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
function _lazyRequire(name, paths)
|
|
30
|
+
{
|
|
31
|
+
let m;
|
|
32
|
+
try
|
|
33
|
+
{
|
|
34
|
+
/**
|
|
35
|
+
* 嘗試使用 require-resolve 工具載入模組
|
|
36
|
+
* Try to load module using require-resolve tool
|
|
37
|
+
*/
|
|
38
|
+
m = require('@yarn-tool/require-resolve').requireExtra(name, {
|
|
39
|
+
includeCurrentDirectory: true,
|
|
40
|
+
includeGlobal: true,
|
|
41
|
+
paths,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (e)
|
|
45
|
+
{}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 如果失敗則使用標準 require
|
|
49
|
+
* If failed, use standard require
|
|
50
|
+
*/
|
|
51
|
+
return typeof m === 'undefined' ? require(name) : m;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 嘗試使用 `@yarn-tool/require-resolve` 解析模組路徑的工具函數
|
|
56
|
+
* Utility function for resolving module paths
|
|
57
|
+
*
|
|
58
|
+
* @param {string} name - 模組名稱 Module name
|
|
59
|
+
* @returns {string} - 解析後的路徑 Resolved path
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
function _requireResolve(name)
|
|
63
|
+
{
|
|
64
|
+
let result;
|
|
65
|
+
|
|
66
|
+
try
|
|
67
|
+
{
|
|
68
|
+
/** @type {import('@yarn-tool/require-resolve')} */
|
|
69
|
+
const { requireResolveExtra, requireResolveCore } = _lazyRequire('@yarn-tool/require-resolve');
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 嘗試從多個路徑解析 TSDX 相關模組
|
|
73
|
+
* Try to resolve TSDX related modules from multiple paths
|
|
74
|
+
*/
|
|
75
|
+
const paths = [
|
|
76
|
+
requireResolveExtra('@bluelovers/tsdx').result,
|
|
77
|
+
requireResolveExtra('tsdx').result,
|
|
78
|
+
].filter(Boolean);
|
|
79
|
+
|
|
80
|
+
result = requireResolveCore(name, {
|
|
81
|
+
includeGlobal: true,
|
|
82
|
+
includeCurrentDirectory: true,
|
|
83
|
+
paths,
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
catch (e)
|
|
87
|
+
{
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 如果都失敗,使用標準 resolve
|
|
93
|
+
* If all failed, use standard resolve
|
|
94
|
+
*/
|
|
95
|
+
result = result || require.resolve(name);
|
|
96
|
+
|
|
97
|
+
console.info('[require.resolve]', name, '=>', result)
|
|
98
|
+
|
|
99
|
+
return result
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 配置解析狀態標誌
|
|
104
|
+
* Configuration resolution status flag
|
|
105
|
+
*/
|
|
106
|
+
let _isNeedConfig = true;
|
|
107
|
+
|
|
108
|
+
try
|
|
109
|
+
{
|
|
110
|
+
/**
|
|
111
|
+
* 第一層:搜尋工作區中的配置檔案
|
|
112
|
+
* First level: Search for configuration files in workspace
|
|
113
|
+
*/
|
|
114
|
+
if (!jestConfig.preset)
|
|
115
|
+
{
|
|
116
|
+
/** @type {import('@yarn-tool/ws-find-up-paths')} */
|
|
117
|
+
const { findUpPathsWorkspaces } = _lazyRequire('@yarn-tool/ws-find-up-paths');
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 向上搜尋 jest-preset.js 和 jest.config.js
|
|
121
|
+
* Search upwards for jest-preset.js and jest.config.js
|
|
122
|
+
*/
|
|
123
|
+
let result = findUpPathsWorkspaces([
|
|
124
|
+
'jest-preset.js',
|
|
125
|
+
'jest.config.js',
|
|
126
|
+
], {
|
|
127
|
+
/** 忽略當前套件 / Ignore current package */
|
|
128
|
+
ignoreCurrentPackage: true,
|
|
129
|
+
/** 只搜尋檔案 / Only search for files */
|
|
130
|
+
onlyFiles: true,
|
|
131
|
+
}).result;
|
|
132
|
+
|
|
133
|
+
if (result)
|
|
134
|
+
{
|
|
135
|
+
let name = basename(result, extname(result))
|
|
136
|
+
|
|
137
|
+
switch (name)
|
|
138
|
+
{
|
|
139
|
+
/**
|
|
140
|
+
* 如果是 jest-preset.js,使用其目錄作為 preset
|
|
141
|
+
* If it's jest-preset.js, use its directory as preset
|
|
142
|
+
*/
|
|
143
|
+
case 'jest-preset':
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
// jestConfig.preset = dirname(result);
|
|
146
|
+
jestConfig.preset = result;
|
|
147
|
+
break;
|
|
148
|
+
/**
|
|
149
|
+
* 其他情況,載入配置檔案內容
|
|
150
|
+
* Otherwise, load the configuration file content
|
|
151
|
+
*/
|
|
152
|
+
default:
|
|
153
|
+
jestConfig = {
|
|
154
|
+
...require(result),
|
|
155
|
+
jestConfig,
|
|
156
|
+
};
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
_isNeedConfig = false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch (e)
|
|
165
|
+
{
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
try
|
|
170
|
+
{
|
|
171
|
+
/**
|
|
172
|
+
* 第二層:嘗試解析 @bluelovers/jest-config
|
|
173
|
+
* Second level: Try to resolve @bluelovers/jest-config
|
|
174
|
+
*/
|
|
175
|
+
if (_isNeedConfig && !jestConfig.preset)
|
|
176
|
+
{
|
|
177
|
+
let result = _requireResolve('@bluelovers/jest-config/package.json');
|
|
178
|
+
if (result)
|
|
179
|
+
{
|
|
180
|
+
// @ts-ignore
|
|
181
|
+
jestConfig.preset = dirname(result);
|
|
182
|
+
_isNeedConfig = false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (e)
|
|
187
|
+
{
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (_isNeedConfig && !jestConfig.preset)
|
|
192
|
+
{
|
|
193
|
+
/**
|
|
194
|
+
* 第三層:使用預設的 @bluelovers/jest-config
|
|
195
|
+
* Third level: Use default @bluelovers/jest-config
|
|
196
|
+
*/
|
|
197
|
+
// @ts-ignore
|
|
198
|
+
jestConfig.preset = '@bluelovers/jest-config';
|
|
199
|
+
_isNeedConfig = false;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 輸出最終的 preset 設定
|
|
204
|
+
* Output the final preset configuration
|
|
205
|
+
*/
|
|
206
|
+
console.info(`jest.config.preset: ${jestConfig.preset}`);
|
|
207
|
+
|
|
208
|
+
module.exports = jestConfig
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 測試路徑架構 / Test Path Structure
|
|
3
|
+
*
|
|
4
|
+
* test/
|
|
5
|
+
* ├── fixtures/ ← 測試資料夾(唯讀)
|
|
6
|
+
* └── temp/ ← 臨時檔案(可寫,永遠建立子資料夾)
|
|
7
|
+
* ├── fake-lib/
|
|
8
|
+
* └── temp-pkg/
|
|
9
|
+
*/
|
|
10
|
+
/// <reference types="node" />
|
|
11
|
+
import path from 'upath2';
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
import { __ROOT_CORE as __ROOT } from './__root-core.cjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 專案根目錄
|
|
17
|
+
*/
|
|
18
|
+
export { __ROOT }
|
|
19
|
+
|
|
20
|
+
export const isWin = process.platform === "win32";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 測試資料夾
|
|
24
|
+
*
|
|
25
|
+
* @default test
|
|
26
|
+
*/
|
|
27
|
+
export const __TEST_ROOT = path.join(__ROOT, 'test');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 測試資料夾(唯讀)
|
|
31
|
+
*
|
|
32
|
+
* @default test/fixtures
|
|
33
|
+
*/
|
|
34
|
+
export const __TEST_FIXTURES = path.join(__TEST_ROOT, 'fixtures');
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 臨時檔案(可寫,永遠建立子資料夾)
|
|
38
|
+
*
|
|
39
|
+
* test/
|
|
40
|
+
* ├── fixtures/ ← 測試資料夾(唯讀)
|
|
41
|
+
* └── temp/ ← 臨時檔案(可寫,永遠建立子資料夾)
|
|
42
|
+
* ├── fake-lib/
|
|
43
|
+
* └── temp-pkg/
|
|
44
|
+
*
|
|
45
|
+
* @default test/temp
|
|
46
|
+
*/
|
|
47
|
+
export const __TEST_TEMP = path.join(__TEST_ROOT, 'temp');
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Not transpiled with TypeScript or Babel, so use plain Es6/Node.js!
|
|
2
|
+
module.exports = {
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This function will run for each entry/format/env combination
|
|
6
|
+
*/
|
|
7
|
+
rollup(config, options) {
|
|
8
|
+
|
|
9
|
+
config.output.preferConst = true;
|
|
10
|
+
|
|
11
|
+
return config;
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// DO NOT EDIT THIS FILE
|
|
2
|
+
const { resolve } = require('path');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @_type { import('@jest/types').Config.InitialOptions }
|
|
6
|
+
* @_type { import('ts-jest').InitialOptionsTsJest }
|
|
7
|
+
* @type { import('ts-jest').JestConfigWithTsJest }
|
|
8
|
+
*/
|
|
9
|
+
const jestConfig = {
|
|
10
|
+
preset: __dirname,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = jestConfig
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarn-tool/static-file",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://github.com/bluelovers/ws-yarn-workspaces/tree/master/packages/@yarn-tool/static-file#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
"author": "",
|
|
16
16
|
"main": "index.js",
|
|
17
17
|
"scripts": {
|
|
18
|
-
"coverage": "npx nyc npm run test",
|
|
19
|
-
"lint": "npx eslint **/*.ts",
|
|
20
18
|
"test": "node --run test:jest --",
|
|
21
19
|
"test:jest": "jest --passWithNoTests",
|
|
22
20
|
"test:jest:coverage": "pnpm run test:jest -- --coverage",
|
|
@@ -25,10 +23,10 @@
|
|
|
25
23
|
"test:tsd": "ynpx tsd",
|
|
26
24
|
"npm:publish": "npm publish",
|
|
27
25
|
"preversion": "pnpm run test",
|
|
28
|
-
"prepublishOnly": "
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
26
|
+
"prepublishOnly": "node --run fix:ignore",
|
|
27
|
+
"ncu": "yarn-tool ncu -u",
|
|
28
|
+
"sort-package-json": "yarn-tool sort",
|
|
29
|
+
"fix:ignore": "tsx test/scripts/update-npmignore-static-files.ts",
|
|
32
30
|
"tsc:showConfig": "ynpx get-current-tsconfig -p"
|
|
33
31
|
},
|
|
34
32
|
"dependencies": {
|
|
@@ -38,5 +36,5 @@
|
|
|
38
36
|
"publishConfig": {
|
|
39
37
|
"access": "public"
|
|
40
38
|
},
|
|
41
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "98d097882fd29058be00d45ff225929538d323d0"
|
|
42
40
|
}
|
package/file/test/__root.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"__root.js","sourceRoot":"","sources":["__root.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;GAQG;AACH,8BAA8B;AAC9B,4DAA0B;AAC1B,aAAa;AACb,uDAA0D;AAKjD,uFALe,6BAAM,OAKf;AAEF,QAAA,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AAElD;;;;GAIG;AACU,QAAA,WAAW,GAAG,gBAAI,CAAC,IAAI,CAAC,6BAAM,EAAE,MAAM,CAAC,CAAC;AAErD;;;;GAIG;AACU,QAAA,eAAe,GAAG,gBAAI,CAAC,IAAI,CAAC,mBAAW,EAAE,UAAU,CAAC,CAAC;AAElE;;;;;;;;;;GAUG;AACU,QAAA,WAAW,GAAG,gBAAI,CAAC,IAAI,CAAC,mBAAW,EAAE,MAAM,CAAC,CAAC","sourcesContent":["/**\n * 測試路徑架構 / Test Path Structure\n *\n * test/\n * ├── fixtures/ ← 測試資料夾(唯讀)\n * └── temp/ ← 臨時檔案(可寫,永遠建立子資料夾)\n * ├── fake-lib/\n * └── temp-pkg/\n */\n/// <reference types=\"node\" />\nimport path from 'upath2';\n// @ts-ignore\nimport { __ROOT_CORE as __ROOT } from './__root-core.cjs';\n\n/**\n * 專案根目錄\n */\nexport { __ROOT }\n\nexport const isWin = process.platform === \"win32\";\n\n/**\n * 測試資料夾\n *\n * @default test\n */\nexport const __TEST_ROOT = path.join(__ROOT, 'test');\n\n/**\n * 測試資料夾(唯讀)\n *\n * @default test/fixtures\n */\nexport const __TEST_FIXTURES = path.join(__TEST_ROOT, 'fixtures');\n\n/**\n * 臨時檔案(可寫,永遠建立子資料夾)\n *\n * test/\n * ├── fixtures/ ← 測試資料夾(唯讀)\n * └── temp/ ← 臨時檔案(可寫,永遠建立子資料夾)\n * ├── fake-lib/\n * └── temp-pkg/\n *\n * @default test/temp\n */\nexport const __TEST_TEMP = path.join(__TEST_ROOT, 'temp');\n"]}
|
package/file/test/temp.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"temp.js","sourceRoot":"","sources":["temp.ts"],"names":[],"mappings":";AAAA,8BAA8B","sourcesContent":["/// <reference types=\"node\" />\n\n"]}
|
package/file/tsdx/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["index.cts"],"names":[],"mappings":";;AAAA,4DAAwB;AAGxB,iBAAS,eAAC,CAAA","sourcesContent":["import _ from './index';\n\n// @ts-ignore\nexport = _\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"__root_ws.js","sourceRoot":"","sources":["__root_ws.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAEf,QAAA,SAAS,GAAG,IAAA,WAAI,EAAC,SAAS,CAAC,CAAC;AAE5B,QAAA,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC","sourcesContent":["import { join } from \"path\";\n\nexport const __ROOT_WS = join(__dirname);\n\nexport const isWin = process.platform === \"win32\";\n"]}
|