@yarn-tool/static-file 3.0.33 → 3.0.34

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 (52) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/file/gitignore +16 -13
  3. package/file/npmignore +79 -14
  4. package/lib/const.d.ts +18 -1
  5. package/lib/const.js +20 -2
  6. package/lib/const.js.map +1 -1
  7. package/lib/copyStaticFilesByRootData.d.ts +52 -0
  8. package/lib/copyStaticFilesByRootData.js +53 -0
  9. package/lib/copyStaticFilesByRootData.js.map +1 -0
  10. package/package.json +5 -3
  11. package/playwright.config.js.map +1 -0
  12. package/test/copyStaticFiles.test.js.map +1 -1
  13. package/test/copyStaticFiles.test.ts.snapshot +2 -22
  14. package/test/copyStaticFilesByRootData.test.js.map +1 -0
  15. package/test/copyStaticFilesByRootData.test.ts.snapshot +634 -0
  16. package/test/fixtures/empty-pkg/package.json +4 -0
  17. package/test/fixtures/out/gitignore +16 -13
  18. package/test/fixtures/out/npmignore +79 -14
  19. package/test/fixtures/split/git/00-header.txt +1 -1
  20. package/test/fixtures/split/git/10-project.txt +1 -1
  21. package/test/fixtures/split/git/20-test.txt +1 -1
  22. package/test/fixtures/split/git/40-env.txt +1 -1
  23. package/test/fixtures/split/git/90-misc.txt +1 -1
  24. package/test/fixtures/split/git/99-whitelist.txt +1 -1
  25. package/test/fixtures/split/npm/01-hidden.txt +1 -1
  26. package/test/fixtures/split/npm/05-source.txt +1 -1
  27. package/test/fixtures/split/npm/10-project.txt +1 -1
  28. package/test/fixtures/split/npm/20-test.txt +3 -1
  29. package/test/fixtures/split/npm/30-ide.txt +1 -1
  30. package/test/fixtures/split/npm/40-env.txt +1 -1
  31. package/test/fixtures/split/npm/90-misc.txt +1 -1
  32. package/test/fixtures/split/other/90-duplicates.txt +2 -2
  33. package/test/fixtures/split/shared/10-project.txt +1 -1
  34. package/test/fixtures/split/shared/20-test.txt +4 -1
  35. package/test/fixtures/split/shared/30-ide.txt +1 -1
  36. package/test/fixtures/split/shared/40-env.txt +1 -1
  37. package/test/fixtures/split/shared/90-misc.txt +1 -1
  38. package/test/scripts/compose-split-ignore-files.js +1 -1
  39. package/test/scripts/compose-split-ignore-files.js.map +1 -1
  40. package/test/scripts/lib/ignore-split.d.ts +24 -64
  41. package/test/scripts/lib/ignore-split.js +41 -75
  42. package/test/scripts/lib/ignore-split.js.map +1 -1
  43. package/test/scripts/split-ignore-files.js +19 -19
  44. package/test/scripts/split-ignore-files.js.map +1 -1
  45. package/test/scripts/update-npmignore-static-files.js +25 -2
  46. package/test/scripts/update-npmignore-static-files.js.map +1 -1
  47. package/file/playwright.config.ts +0 -6
  48. package/file/test/__root.js.map +0 -1
  49. package/file/test/temp.js.map +0 -1
  50. package/file/tsdx/index.cjs.map +0 -1
  51. package/file/tsdx/index.js.map +0 -1
  52. package/file/ws-root/__root_ws.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "empty-pkg",
3
+ "version": "1.0.0"
4
+ }
@@ -1,7 +1,7 @@
1
- # 檔案頭 / file header · git 專用 / git only
1
+ # file header · git only
2
2
  # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
3
3
 
4
- # 專案檔 / project files · git 專用 / git only
4
+ # project files · git only
5
5
  # next.js
6
6
  # production
7
7
  /build
@@ -13,7 +13,7 @@ vue.config.js.map
13
13
  /.eslintignore
14
14
  node_modules/.cache
15
15
  .yarn-integrity
16
- # *.map 對應檔(共用輔助產生)/ *.map files (generated by shared helper)
16
+ # *.map files (generated by shared helper)
17
17
  *.js.map
18
18
  *.cjs.map
19
19
  *.mjs.map
@@ -32,7 +32,7 @@ dist/*.umd.*.*s
32
32
  out/
33
33
  node_modules_
34
34
 
35
- # 專案檔 / project files · 兩類共用 / shared
35
+ # project files · shared
36
36
  # dependencies
37
37
  node_modules
38
38
  /.pnp
@@ -75,8 +75,8 @@ tsc-multi.json.tpl
75
75
 
76
76
  /src/index.ts.tpl
77
77
 
78
- # 測試檔 / test files · git 專用 / git only
79
- # 測試建置產物(共用輔助產生)/ test build artifacts (generated by shared helper)
78
+ # test files · git only
79
+ # test build artifacts (generated by shared helper)
80
80
  test/temp*
81
81
  test/**/*.map
82
82
  tests/temp*
@@ -151,7 +151,7 @@ jest.config.js.map
151
151
  /test/*.tpl
152
152
  test/fixtures/.gitkeep
153
153
 
154
- # 測試檔 / test files · 兩類共用 / shared
154
+ # test files · shared
155
155
  # testing
156
156
  .nyc_output
157
157
  coverage
@@ -159,9 +159,12 @@ coverage
159
159
  *.spec.d.ts
160
160
  *.spec.js
161
161
 
162
+ /playwright.config.d.ts
163
+ /playwright.config.js
164
+
162
165
  test-results/.last-run.json
163
166
 
164
- # IDE 與編輯器設定 / IDE & editor settings · 兩類共用 / shared
167
+ # IDE & editor settings · shared
165
168
  .idea
166
169
  .vscode
167
170
  *.suo
@@ -170,7 +173,7 @@ test-results/.last-run.json
170
173
  *.sln
171
174
  *.sw?
172
175
 
173
- # 環境設定 / environment settings · git 專用 / git only
176
+ # environment settings · git only
174
177
  *.pem
175
178
  .env.development.local
176
179
  .env.test.local
@@ -181,20 +184,20 @@ test-results/.last-run.json
181
184
  .nowignore
182
185
  /certificates
183
186
 
184
- # 環境設定 / environment settings · 兩類共用 / shared
187
+ # environment settings · shared
185
188
  # local env files
186
189
  .env.local
187
190
  # vercel
188
191
  .vercel
189
192
  .env.*.local
190
193
 
191
- # 未分類 / unclassified · git 專用 / git only
194
+ # unclassified · git only
192
195
  # misc
193
196
  .DS_Store
194
197
  .opt-in
195
198
  .opt-out
196
199
 
197
- # 未分類 / unclassified · 兩類共用 / shared
200
+ # unclassified · shared
198
201
  ~ci.list.txt
199
202
  ~ci.log.txt
200
203
  ~ci.errors.txt
@@ -206,7 +209,7 @@ test-results/.last-run.json
206
209
  .logs
207
210
  .agentbridge
208
211
 
209
- # 白名單例外 / whitelist exceptions · git 專用 / git only
212
+ # whitelist exceptions · git only
210
213
  !test/tsconfig.json
211
214
  !tsconfig.json
212
215
  !.eslintrc.json
@@ -1,9 +1,9 @@
1
- # 根目錄隱藏檔 / root hidden files · npm 發布專用 / npm publish only
1
+ # root hidden files · npm publish only
2
2
  /.*
3
3
 
4
- # npm 來源檔規則 / npm source rules · npm 發布專用 / npm publish only
4
+ # npm source rules · npm publish only
5
5
  *.ts
6
- # npm 來源與聲明檔規則(共用輔助產生)/ npm source & declaration rules (generated by shared helper)
6
+ # npm source & declaration rules (generated by shared helper)
7
7
  !*.d.ts
8
8
  /bin/**/*.d.ts
9
9
  /bin/*.d.ts
@@ -20,7 +20,7 @@
20
20
  !/src/**/*.mts
21
21
  !/src/**/*.tsx
22
22
 
23
- # 專案檔 / project files · npm 發布專用 / npm publish only
23
+ # project files · npm publish only
24
24
  tsconfig.json
25
25
  .github
26
26
  /src/**/*.jsx
@@ -52,7 +52,7 @@ bin/tsconfig.*.json
52
52
  !/README.md
53
53
  !/CHANGELOG.md
54
54
 
55
- # 專案檔 / project files · 兩類共用 / shared
55
+ # project files · shared
56
56
  # dependencies
57
57
  node_modules
58
58
  /.pnp
@@ -95,7 +95,7 @@ tsc-multi.json.tpl
95
95
 
96
96
  /src/index.ts.tpl
97
97
 
98
- # 測試檔 / test files · npm 發布專用 / npm publish only
98
+ # test files · npm publish only
99
99
  test
100
100
  .gitkeep
101
101
  tests
@@ -105,7 +105,7 @@ __tests__
105
105
  karma.conf.js
106
106
  jest.config.*
107
107
  /jest-preset.*
108
- # spec / test 副檔名矩陣(共用輔助產生)/ spec & test filename matrix (generated by shared helper)
108
+ # spec & test filename matrix (generated by shared helper)
109
109
  *.spec.ts
110
110
 
111
111
  *.spec.d.cts
@@ -163,6 +163,66 @@ jest.config.*
163
163
 
164
164
  *.node-test.d.tsx
165
165
  *.node-test.tsx
166
+
167
+ *.playwright-spec.d.ts
168
+ *.playwright-spec.js
169
+ *.playwright-spec.ts
170
+
171
+ *.playwright-spec.d.cts
172
+ *.playwright-spec.cjs
173
+ *.playwright-spec.cts
174
+
175
+ *.playwright-spec.d.mts
176
+ *.playwright-spec.mjs
177
+ *.playwright-spec.mts
178
+
179
+ *.playwright-spec.d.tsx
180
+ *.playwright-spec.tsx
181
+
182
+ *.playwright-test.d.ts
183
+ *.playwright-test.js
184
+ *.playwright-test.ts
185
+
186
+ *.playwright-test.d.cts
187
+ *.playwright-test.cjs
188
+ *.playwright-test.cts
189
+
190
+ *.playwright-test.d.mts
191
+ *.playwright-test.mjs
192
+ *.playwright-test.mts
193
+
194
+ *.playwright-test.d.tsx
195
+ *.playwright-test.tsx
196
+
197
+ *.playwright.spec.d.ts
198
+ *.playwright.spec.js
199
+ *.playwright.spec.ts
200
+
201
+ *.playwright.spec.d.cts
202
+ *.playwright.spec.cjs
203
+ *.playwright.spec.cts
204
+
205
+ *.playwright.spec.d.mts
206
+ *.playwright.spec.mjs
207
+ *.playwright.spec.mts
208
+
209
+ *.playwright.spec.d.tsx
210
+ *.playwright.spec.tsx
211
+
212
+ *.playwright.test.d.ts
213
+ *.playwright.test.js
214
+ *.playwright.test.ts
215
+
216
+ *.playwright.test.d.cts
217
+ *.playwright.test.cjs
218
+ *.playwright.test.cts
219
+
220
+ *.playwright.test.d.mts
221
+ *.playwright.test.mjs
222
+ *.playwright.test.mts
223
+
224
+ *.playwright.test.d.tsx
225
+ *.playwright.test.tsx
166
226
  __mocks__
167
227
  __snapshots__
168
228
  *.snap
@@ -173,7 +233,9 @@ __fixtures__
173
233
  *.stories.*
174
234
  ./stories/
175
235
 
176
- # 測試檔 / test files · 兩類共用 / shared
236
+ /playwright.config.ts
237
+
238
+ # test files · shared
177
239
  # testing
178
240
  .nyc_output
179
241
  coverage
@@ -181,12 +243,15 @@ coverage
181
243
  *.spec.d.ts
182
244
  *.spec.js
183
245
 
246
+ /playwright.config.d.ts
247
+ /playwright.config.js
248
+
184
249
  test-results/.last-run.json
185
250
 
186
- # IDE 與編輯器設定 / IDE & editor settings · npm 發布專用 / npm publish only
251
+ # IDE & editor settings · npm publish only
187
252
  intellij-style-guide.xml
188
253
 
189
- # IDE 與編輯器設定 / IDE & editor settings · 兩類共用 / shared
254
+ # IDE & editor settings · shared
190
255
  .idea
191
256
  .vscode
192
257
  *.suo
@@ -195,22 +260,22 @@ intellij-style-guide.xml
195
260
  *.sln
196
261
  *.sw?
197
262
 
198
- # 環境設定 / environment settings · npm 發布專用 / npm publish only
263
+ # environment settings · npm publish only
199
264
  now.json
200
265
 
201
- # 環境設定 / environment settings · 兩類共用 / shared
266
+ # environment settings · shared
202
267
  # local env files
203
268
  .env.local
204
269
  # vercel
205
270
  .vercel
206
271
  .env.*.local
207
272
 
208
- # 未分類 / unclassified · npm 發布專用 / npm publish only
273
+ # unclassified · npm publish only
209
274
  /~*
210
275
  cz-adapter
211
276
  openspec/
212
277
 
213
- # 未分類 / unclassified · 兩類共用 / shared
278
+ # unclassified · shared
214
279
  ~ci.list.txt
215
280
  ~ci.log.txt
216
281
  ~ci.errors.txt
@@ -1,2 +1,2 @@
1
- # 檔案頭 / file header · git 專用 / git only
1
+ # file header · git only
2
2
  # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
@@ -1,4 +1,4 @@
1
- # 專案檔 / project files · git 專用 / git only
1
+ # project files · git only
2
2
  # next.js
3
3
  # production
4
4
  /build
@@ -1,4 +1,4 @@
1
- # 測試檔 / test files · git 專用 / git only
1
+ # test files · git only
2
2
  # %gen:test-build-artifacts%
3
3
  .nycrc
4
4
  #jest.config.js
@@ -1,4 +1,4 @@
1
- # 環境設定 / environment settings · git 專用 / git only
1
+ # environment settings · git only
2
2
  *.pem
3
3
  .env.development.local
4
4
  .env.test.local
@@ -1,4 +1,4 @@
1
- # 未分類 / unclassified · git 專用 / git only
1
+ # unclassified · git only
2
2
  # misc
3
3
  .DS_Store
4
4
  .opt-in
@@ -1,4 +1,4 @@
1
- # 白名單例外 / whitelist exceptions · git 專用 / git only
1
+ # whitelist exceptions · git only
2
2
  !test/tsconfig.json
3
3
  !tsconfig.json
4
4
  !.eslintrc.json
@@ -1,2 +1,2 @@
1
- # 根目錄隱藏檔 / root hidden files · npm 發布專用 / npm publish only
1
+ # root hidden files · npm publish only
2
2
  /.*
@@ -1,4 +1,4 @@
1
- # npm 來源檔規則 / npm source rules · npm 發布專用 / npm publish only
1
+ # npm source rules · npm publish only
2
2
  *.ts
3
3
  # %gen:npm-source-declarations%
4
4
  !/src/**/*.ts
@@ -1,4 +1,4 @@
1
- # 專案檔 / project files · npm 發布專用 / npm publish only
1
+ # project files · npm publish only
2
2
  tsconfig.json
3
3
  .github
4
4
  /src/**/*.jsx
@@ -1,4 +1,4 @@
1
- # 測試檔 / test files · npm 發布專用 / npm publish only
1
+ # test files · npm publish only
2
2
  test
3
3
  .gitkeep
4
4
  tests
@@ -18,3 +18,5 @@ __fixtures__
18
18
  /fixture/
19
19
  *.stories.*
20
20
  ./stories/
21
+
22
+ /playwright.config.ts
@@ -1,2 +1,2 @@
1
- # IDE 與編輯器設定 / IDE & editor settings · npm 發布專用 / npm publish only
1
+ # IDE & editor settings · npm publish only
2
2
  intellij-style-guide.xml
@@ -1,2 +1,2 @@
1
- # 環境設定 / environment settings · npm 發布專用 / npm publish only
1
+ # environment settings · npm publish only
2
2
  now.json
@@ -1,4 +1,4 @@
1
- # 未分類 / unclassified · npm 發布專用 / npm publish only
1
+ # unclassified · npm publish only
2
2
  /~*
3
3
  cz-adapter
4
4
  openspec/
@@ -14,7 +14,7 @@ test/temp*/
14
14
  **/node_modules/
15
15
  jest.config.js
16
16
 
17
- # git 專用檔中重複出現 / duplicated in the gitignore source
17
+ # duplicated in the gitignore source
18
18
  node_modules
19
19
  .env.local
20
20
  npm-debug.log*
@@ -26,7 +26,7 @@ yarn-error.log*
26
26
  /*.tpl
27
27
  /build
28
28
 
29
- # npm 發布專用檔中重複出現 / duplicated in the npmignore source
29
+ # duplicated in the npmignore source
30
30
  .git
31
31
  jest.config.js
32
32
  __tests__
@@ -1,4 +1,4 @@
1
- # 專案檔 / project files · 兩類共用 / shared
1
+ # project files · shared
2
2
  # dependencies
3
3
  node_modules
4
4
  /.pnp
@@ -1,4 +1,4 @@
1
- # 測試檔 / test files · 兩類共用 / shared
1
+ # test files · shared
2
2
  # testing
3
3
  .nyc_output
4
4
  coverage
@@ -6,4 +6,7 @@ coverage
6
6
  *.spec.d.ts
7
7
  *.spec.js
8
8
 
9
+ /playwright.config.d.ts
10
+ /playwright.config.js
11
+
9
12
  test-results/.last-run.json
@@ -1,4 +1,4 @@
1
- # IDE 與編輯器設定 / IDE & editor settings · 兩類共用 / shared
1
+ # IDE & editor settings · shared
2
2
  .idea
3
3
  .vscode
4
4
  *.suo
@@ -1,4 +1,4 @@
1
- # 環境設定 / environment settings · 兩類共用 / shared
1
+ # environment settings · shared
2
2
  # local env files
3
3
  .env.local
4
4
  # vercel
@@ -1,4 +1,4 @@
1
- # 未分類 / unclassified · 兩類共用 / shared
1
+ # unclassified · shared
2
2
  ~ci.list.txt
3
3
  ~ci.log.txt
4
4
  ~ci.errors.txt
@@ -47,7 +47,7 @@ const OUT_ROOT = (0, path_1.join)(__root_1.__ROOT, 'test', 'fixtures', 'out');
47
47
  function compose(target) {
48
48
  const lines = [];
49
49
  for (const topic of ignore_split_1.TOPICS) {
50
- for (const bucket of [target, 'shared']) {
50
+ for (const bucket of [target, ignore_split_1.EnumIgnoreSplitTargetBucket.shared]) {
51
51
  const fragment = (0, ignore_split_1.readSplitFragment)(bucket, topic.id);
52
52
  if (fragment.length === 0) {
53
53
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"compose-split-ignore-files.js","sourceRoot":"","sources":["compose-split-ignore-files.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,+BAA4B;AAC5B,iEAA8D;AAC9D,sCAAmC;AAEnC,qDAK4B;AAE5B;;GAEG;AACH,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,eAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AAEzD;;;;;;GAMG;AACH,SAAS,OAAO,CAAC,MAAgC;IAEhD,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,qBAAM,EAC1B,CAAC;QACA,KAAK,MAAM,MAAM,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAU,EAChD,CAAC;YACA,MAAM,QAAQ,GAAG,IAAA,gCAAiB,EAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YAErD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EACzB,CAAC;gBACA,SAAS;YACV,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC7B,CAAC;IACF,CAAC;IAED,OAAO,IAAA,oCAAqB,EAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,SAAS,IAAI;IAEZ,KAAK,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,mCAAoB,EACvD,CAAC;QACA,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAEtC;;;;;;WAMG;QACH,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QAEzD,UAAU,CAAC,IAAI,EAAE,CAAC;QAElB,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,KAAK,UAAU,CAAC,KAAK,CAAC,MAAM,SAAS,CAAC,CAAC;IACpE,CAAC;AACF,CAAC;AAED,IAAI,EAAE,CAAC","sourcesContent":["/**\n * 將 test/fixtures/split/ 的分類片段組合成新的 gitignore 與 npmignore\n * Compose the classified fragments under test/fixtures/split/ into new gitignore and npmignore files\n *\n * 組合規則:\n * 1. 逐主題({@link TOPICS} 順序)先放目標分類片段(git 或 npm),再放共用片段,\n * 片段之間以單一空行分隔。\n * 2. `# %gen:NAME%` 佔位行由 lib/ignore-split 的共用產生器展開。\n * 3. other/ 分類(重複與冗餘規則)永不輸出。\n * 4. 行陣列直接作為內容交給 IgnoreFile 保存(支援陣列內容與自動 EOF 結尾換行),\n * 預設優化會去重(保留最後一筆)。\n *\n * Composition rules:\n * 1. Per topic (in {@link TOPICS} order), the target-bucket fragment comes first\n * and the shared fragment follows, with a single blank line between fragments.\n * 2. `# %gen:NAME%` placeholders are expanded by the shared generators in\n * lib/ignore-split.\n * 3. The other/ bucket (duplicated and redundant rules) is never emitted.\n * 4. The line array goes to IgnoreFile as content directly (array content and\n * automatic EOF newline); the default optimization dedupes rules (keeping\n * the last occurrence).\n *\n * 待組合的分類與輸出檔名請見 lib 的 {@link IGNORE_SPLIT_TARGETS}(單一事實來源)。\n * The targets and their output file names come from {@link IGNORE_SPLIT_TARGETS}\n * in the lib (the single source of truth).\n *\n * 執行 / run: tsx packages/@yarn-tool/static-file/test/scripts/compose-split-ignore-files.ts\n * 輸出 / output: test/fixtures/out/gitignore、test/fixtures/out/npmignore\n */\nimport { join } from 'path';\nimport { IgnoreFile } from '@yarn-tool/ignore/lib/IgnoreFile';\nimport { __ROOT } from '../__root';\nimport type { IIgnoreSplitTargetBucket } from './lib/ignore-split';\nimport {\n\tIGNORE_SPLIT_TARGETS,\n\tTOPICS,\n\texpandGenPlaceholders,\n\treadSplitFragment,\n} from './lib/ignore-split';\n\n/**\n * 組合結果的輸出目錄 / Output directory of the composed files\n */\nconst OUT_ROOT = join(__ROOT, 'test', 'fixtures', 'out');\n\n/**\n * 組合單一目標分類的行陣列\n * Assemble the line array for a single target bucket\n *\n * @param target - 目標分類:git 或 npm / Target bucket: git or npm\n * @returns 展開佔位後的完整行陣列 / The full line array after expanding placeholders\n */\nfunction compose(target: IIgnoreSplitTargetBucket): string[]\n{\n\tconst lines: string[] = [];\n\n\tfor (const topic of TOPICS)\n\t{\n\t\tfor (const bucket of [target, 'shared'] as const)\n\t\t{\n\t\t\tconst fragment = readSplitFragment(bucket, topic.id);\n\n\t\t\tif (fragment.length === 0)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlines.push(...fragment, '');\n\t\t}\n\t}\n\n\treturn expandGenPlaceholders(lines);\n}\n\n/**\n * 腳本進入點:組合兩份 ignore 檔並輸出到 test/fixtures/out\n * Script entry: compose both ignore files and write them to test/fixtures/out\n */\nfunction main(): void\n{\n\tfor (const { bucket, fileName } of IGNORE_SPLIT_TARGETS)\n\t{\n\t\tconst path = join(OUT_ROOT, fileName);\n\n\t\t/**\n\t\t * 行陣列直接交給 IgnoreFile:建構子接受陣列內容,\n\t\t * 結尾空行(EOF 換行)自動記錄並於輸出時還原,無需自行展開或補空行\n\t\t * The line array goes straight into IgnoreFile: the constructor accepts\n\t\t * array content, and the trailing blank (the EOF newline) is recorded\n\t\t * automatically and restored on output — no manual spread or blank needed\n\t\t */\n\t\tconst ignoreFile = new IgnoreFile(path, compose(bucket));\n\n\t\tignoreFile.save();\n\n\t\tconsole.log(`composed ${path} (${ignoreFile.lines.length} lines)`);\n\t}\n}\n\nmain();\n"]}
1
+ {"version":3,"file":"compose-split-ignore-files.js","sourceRoot":"","sources":["compose-split-ignore-files.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,+BAA4B;AAC5B,iEAA8D;AAC9D,sCAAmC;AAEnC,qDAM4B;AAE5B;;GAEG;AACH,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,eAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AAEzD;;;;;;GAMG;AACH,SAAS,OAAO,CAAC,MAAgC;IAEhD,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,qBAAM,EAC1B,CAAC;QACA,KAAK,MAAM,MAAM,IAAI,CAAC,MAAM,EAAE,0CAA2B,CAAC,MAAM,CAAU,EAC1E,CAAC;YACA,MAAM,QAAQ,GAAG,IAAA,gCAAiB,EAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YAErD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EACzB,CAAC;gBACA,SAAS;YACV,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC7B,CAAC;IACF,CAAC;IAED,OAAO,IAAA,oCAAqB,EAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,SAAS,IAAI;IAEZ,KAAK,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,mCAAoB,EACvD,CAAC;QACA,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAEtC;;;;;;WAMG;QACH,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QAEzD,UAAU,CAAC,IAAI,EAAE,CAAC;QAElB,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,KAAK,UAAU,CAAC,KAAK,CAAC,MAAM,SAAS,CAAC,CAAC;IACpE,CAAC;AACF,CAAC;AAED,IAAI,EAAE,CAAC","sourcesContent":["/**\n * 將 test/fixtures/split/ 的分類片段組合成新的 gitignore 與 npmignore\n * Compose the classified fragments under test/fixtures/split/ into new gitignore and npmignore files\n *\n * 組合規則:\n * 1. 逐主題({@link TOPICS} 順序)先放目標分類片段(git 或 npm),再放共用片段,\n * 片段之間以單一空行分隔。\n * 2. `# %gen:NAME%` 佔位行由 lib/ignore-split 的共用產生器展開。\n * 3. other/ 分類(重複與冗餘規則)永不輸出。\n * 4. 行陣列直接作為內容交給 IgnoreFile 保存(支援陣列內容與自動 EOF 結尾換行),\n * 預設優化會去重(保留最後一筆)。\n *\n * Composition rules:\n * 1. Per topic (in {@link TOPICS} order), the target-bucket fragment comes first\n * and the shared fragment follows, with a single blank line between fragments.\n * 2. `# %gen:NAME%` placeholders are expanded by the shared generators in\n * lib/ignore-split.\n * 3. The other/ bucket (duplicated and redundant rules) is never emitted.\n * 4. The line array goes to IgnoreFile as content directly (array content and\n * automatic EOF newline); the default optimization dedupes rules (keeping\n * the last occurrence).\n *\n * 待組合的分類與輸出檔名請見 lib 的 {@link IGNORE_SPLIT_TARGETS}(單一事實來源)。\n * The targets and their output file names come from {@link IGNORE_SPLIT_TARGETS}\n * in the lib (the single source of truth).\n *\n * 執行 / run: tsx packages/@yarn-tool/static-file/test/scripts/compose-split-ignore-files.ts\n * 輸出 / output: test/fixtures/out/gitignore、test/fixtures/out/npmignore\n */\nimport { join } from 'path';\nimport { IgnoreFile } from '@yarn-tool/ignore/lib/IgnoreFile';\nimport { __ROOT } from '../__root';\nimport type { IIgnoreSplitTargetBucket } from './lib/ignore-split';\nimport {\n\tEnumIgnoreSplitTargetBucket,\n\tIGNORE_SPLIT_TARGETS,\n\tTOPICS,\n\texpandGenPlaceholders,\n\treadSplitFragment,\n} from './lib/ignore-split';\n\n/**\n * 組合結果的輸出目錄 / Output directory of the composed files\n */\nconst OUT_ROOT = join(__ROOT, 'test', 'fixtures', 'out');\n\n/**\n * 組合單一目標分類的行陣列\n * Assemble the line array for a single target bucket\n *\n * @param target - 目標分類:git 或 npm / Target bucket: git or npm\n * @returns 展開佔位後的完整行陣列 / The full line array after expanding placeholders\n */\nfunction compose(target: IIgnoreSplitTargetBucket): string[]\n{\n\tconst lines: string[] = [];\n\n\tfor (const topic of TOPICS)\n\t{\n\t\tfor (const bucket of [target, EnumIgnoreSplitTargetBucket.shared] as const)\n\t\t{\n\t\t\tconst fragment = readSplitFragment(bucket, topic.id);\n\n\t\t\tif (fragment.length === 0)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlines.push(...fragment, '');\n\t\t}\n\t}\n\n\treturn expandGenPlaceholders(lines);\n}\n\n/**\n * 腳本進入點:組合兩份 ignore 檔並輸出到 test/fixtures/out\n * Script entry: compose both ignore files and write them to test/fixtures/out\n */\nfunction main(): void\n{\n\tfor (const { bucket, fileName } of IGNORE_SPLIT_TARGETS)\n\t{\n\t\tconst path = join(OUT_ROOT, fileName);\n\n\t\t/**\n\t\t * 行陣列直接交給 IgnoreFile:建構子接受陣列內容,\n\t\t * 結尾空行(EOF 換行)自動記錄並於輸出時還原,無需自行展開或補空行\n\t\t * The line array goes straight into IgnoreFile: the constructor accepts\n\t\t * array content, and the trailing blank (the EOF newline) is recorded\n\t\t * automatically and restored on output — no manual spread or blank needed\n\t\t */\n\t\tconst ignoreFile = new IgnoreFile(path, compose(bucket));\n\n\t\tignoreFile.save();\n\n\t\tconsole.log(`composed ${path} (${ignoreFile.lines.length} lines)`);\n\t}\n}\n\nmain();\n"]}
@@ -1,10 +1,13 @@
1
+ export declare enum EnumIgnoreSplitTargetBucket {
2
+ git = "git",
3
+ npm = "npm",
4
+ shared = "shared",
5
+ other = "other"
6
+ }
1
7
  /**
2
8
  * 二層分類主題,陣列順序即全域組合順序
3
- * Second-level topics; the array order is the global assembly order
4
9
  *
5
10
  * 編號前綴刻意留出間隙(05、10、20…),方便日後插入新主題而不需重排。
6
- * The numeric prefixes leave gaps (05, 10, 20…) so new topics can be inserted
7
- * without renumbering the rest.
8
11
  */
9
12
  export declare const TOPICS: readonly [{
10
13
  readonly id: "00-header";
@@ -45,161 +48,118 @@ export declare const TOPICS: readonly [{
45
48
  }];
46
49
  /**
47
50
  * 主題 id 的聯合型別,由 {@link TOPICS} 派生
48
- * Union of topic ids, derived from {@link TOPICS}
49
51
  */
50
52
  export type IIgnoreSplitTopicId = typeof TOPICS[number]['id'];
51
53
  /**
52
54
  * 會輸出到組合結果的分類(other 永不輸出)
53
- * Buckets emitted into the composed output (other is never emitted)
54
55
  */
55
- export declare const EMITTED_BUCKETS: readonly ["git", "npm", "shared"];
56
+ export declare const EMITTED_BUCKETS: readonly [EnumIgnoreSplitTargetBucket.git, EnumIgnoreSplitTargetBucket.npm, EnumIgnoreSplitTargetBucket.shared];
56
57
  /**
57
58
  * 輸出分類的聯合型別,由 {@link EMITTED_BUCKETS} 派生
58
- * Union of emitted buckets, derived from {@link EMITTED_BUCKETS}
59
59
  */
60
60
  export type IIgnoreSplitEmittedBucket = typeof EMITTED_BUCKETS[number];
61
- /**
62
- * 全部分類的聯合型別(含永不輸出的 other)
63
- * Union of all buckets (including the never-emitted other)
64
- */
65
- export type IIgnoreSplitBucket = IIgnoreSplitEmittedBucket | 'other';
66
61
  /**
67
62
  * 組合目標:分類與對應的 ignore 檔名,為「分類 ↔ 檔名」的單一事實來源
68
- * Composition targets: the bucket and its ignore file name — the single source
69
- * of truth for the bucket ↔ file-name mapping
70
63
  */
71
64
  export declare const IGNORE_SPLIT_TARGETS: readonly [{
72
- readonly bucket: "git";
65
+ readonly bucket: EnumIgnoreSplitTargetBucket.git;
73
66
  readonly fileName: "gitignore";
74
67
  }, {
75
- readonly bucket: "npm";
68
+ readonly bucket: EnumIgnoreSplitTargetBucket.npm;
76
69
  readonly fileName: "npmignore";
77
70
  }];
78
71
  /**
79
72
  * 可作為組合目標的分類,由 {@link IGNORE_SPLIT_TARGETS} 派生
80
- * Buckets usable as composition targets, derived from {@link IGNORE_SPLIT_TARGETS}
81
73
  */
82
74
  export type IIgnoreSplitTargetBucket = typeof IGNORE_SPLIT_TARGETS[number]['bucket'];
83
75
  /**
84
- * 分類片段的根目錄 / Root directory of the classified fragments
76
+ * 分類片段的根目錄
85
77
  */
86
78
  export declare const SPLIT_ROOT: string;
87
79
  /**
88
80
  * 取得片段檔案路徑,命名慣例為 `<分類>/<主題>.txt`
89
- * Get a fragment file path, following the `<bucket>/<topic>.txt` naming convention
90
81
  *
91
82
  * 分割腳本與組合腳本共用此函式,避免各自拼出不同的存放位置。
92
- * Shared by the split and compose scripts so neither builds its own location.
93
83
  *
94
- * @param bucket - 分類 / Bucket
95
- * @param topic - 主題編號 / Topic id
96
- * @returns 片段檔案的絕對路徑 / The absolute path of the fragment file
84
+ * @param bucket - 分類
85
+ * @param topic - 主題編號
86
+ * @returns 片段檔案的絕對路徑
97
87
  */
98
- export declare function getSplitFragmentPath(bucket: string, topic: string): string;
88
+ export declare function getSplitFragmentPath(bucket: EnumIgnoreSplitTargetBucket, topic: IIgnoreSplitTopicId): string;
99
89
  /**
100
90
  * git:測試建置產物矩陣
101
- * git: test build artifact matrix
102
91
  *
103
92
  * 覆蓋 temp 產物、source map,以及 js/d.ts、mjs/d.mts、cjs/d.cts 三個族系
104
93
  * 在 test、tests、packages/* 等目錄下的組合。
105
94
  *
106
- * Covers temp artifacts, source maps, and the js/d.ts, mjs/d.mts, cjs/d.cts
107
- * families across the test, tests, and packages/* directories.
108
- *
109
- * @returns 片段內容行(含分類說明註解與組內空行)/ Fragment lines (including its description comment and intra-group blanks)
95
+ * @returns 片段內容行(含分類說明註解與組內空行)
110
96
  */
111
97
  export declare function genTestBuildArtifacts(): string[];
112
98
  /**
113
99
  * git:*.map 對應檔規則
114
- * git: *.map source file rules
115
100
  *
116
101
  * 六種模組副檔名的對應檔,一行一個族系無法由其他規則取代,故集中產生。
117
- * The mapping files of six module extensions; centralized here since no single
118
- * rule can cover them.
119
102
  *
120
- * @returns 片段內容行 / Fragment lines
103
+ * @returns 片段內容行
121
104
  */
122
105
  export declare function genSourceMaps(): string[];
123
106
  /**
124
107
  * npm:spec / test 副檔名矩陣
125
- * npm: spec & test filename matrix
126
108
  *
127
109
  * 四種前綴(spec、test、node-spec、node-test)× 四組副檔名族系
128
110
  * (d.ts+js/ts、d.cts+cjs/cts、d.mts+mjs/mts、d.tsx+tsx)的笛卡兒積。
129
111
  *
130
- * The cartesian product of four prefixes (spec, test, node-spec, node-test)
131
- * and four extension families (d.ts+js/ts, d.cts+cjs/cts, d.mts+mjs/mts,
132
- * d.tsx+tsx).
133
- *
134
112
  * @returns 片段內容行 / Fragment lines
135
113
  */
136
114
  export declare function genSpecFiles(): string[];
137
115
  /**
138
116
  * npm:來源與聲明檔規則群
139
- * npm: source & declaration rule groups
140
117
  *
141
118
  * 三種聲明副檔名(d.ts、d.mts、d.cts)各自的白名單與 /bin 目錄規則,
142
119
  * 必須維持在相鄰行才能與前後的排除規則正確互動。
143
120
  *
144
- * The whitelist and /bin rules for the three declaration extensions
145
- * (d.ts, d.mts, d.cts); they must stay on adjacent lines to interact correctly
146
- * with the surrounding exclusion rules.
147
- *
148
- * @returns 片段內容行 / Fragment lines
121
+ * @returns 片段內容行
149
122
  */
150
123
  export declare function genNpmSourceDeclarations(): string[];
151
124
  /**
152
125
  * 共用輔助區塊的註冊資料:產生函式、所屬主題與所屬分類都登记在此,
153
126
  * 分割腳本據此決定佔位行寫入哪個片段,組合腳本據此展開佔位內容
154
- * Registration of a shared generator: the generate function, its topic, and its
155
- * bucket all live here, so the split script knows which fragment receives the
156
- * placeholder line and the compose script knows what to expand it into
157
127
  */
158
128
  export interface IIgnoreSplitGenerator {
159
129
  /**
160
130
  * 產生區塊內容(含說明註解與組內空行)
161
- * Produce the block content (including its description comment and intra-group blanks)
162
131
  */
163
132
  generate: () => string[];
164
133
  /**
165
- * 區塊所屬主題 / The topic this block belongs to
134
+ * 區塊所屬主題
166
135
  */
167
136
  topic: IIgnoreSplitTopicId;
168
137
  /**
169
138
  * 區塊所屬分類;只有目標分類(git / npm)會以輔助產生
170
- * Bucket of the block; only target buckets (git / npm) are produced by helpers
171
139
  */
172
140
  bucket: IIgnoreSplitTargetBucket;
173
141
  }
174
142
  /**
175
143
  * 產生器註冊表:鍵名對應片段中的 `# %gen:NAME%` 佔位名稱
176
- * Generator registry: keys match the `# %gen:NAME%` placeholder names in fragments
177
144
  */
178
145
  export declare const IGNORE_SPLIT_GENERATORS: Record<string, IIgnoreSplitGenerator>;
179
146
  /**
180
147
  * 讀取單一分類片段的所有行
181
- * Read every line of a single classified fragment
182
148
  *
183
149
  * 片段首行是分類標頭(主題 × 分類),組合時保留為輸出檔的區段標記;
184
150
  * 檔案不存在(該分類 × 主題沒有片段)時回傳空陣列。
185
- * The first line is the classification header (topic × bucket), kept as the
186
- * section marker of the composed output; a missing file (no fragment for that
187
- * bucket × topic combination) yields an empty array.
188
151
  *
189
- * @param bucket - 分類:git、npm 或 shared / Bucket: git, npm, or shared
190
- * @param topic - 主題編號({@link TOPICS} 的 id)/ Topic id (see {@link TOPICS})
191
- * @returns 片段行陣列(已去除結尾空行)/ Fragment lines (trailing blanks removed)
152
+ * @param bucket - 分類:git、npm 或 shared
153
+ * @param topic - 主題編號({@link TOPICS} 的 id)
154
+ * @returns 片段行陣列(已去除結尾空行)
192
155
  */
193
- export declare function readSplitFragment(bucket: string, topic: string): string[];
156
+ export declare function readSplitFragment(bucket: EnumIgnoreSplitTargetBucket, topic: IIgnoreSplitTopicId): string[];
194
157
  /**
195
158
  * 將 `# %gen:NAME%` 佔位行展開為對應產生器的輸出
196
- * Expand `# %gen:NAME%` placeholder lines into the matching generator output
197
159
  *
198
160
  * 其餘行原樣保留;遇到未註冊的佔位名稱時拋錯,避免靜默產出不完整的檔案。
199
- * All other lines pass through unchanged; an unregistered placeholder name
200
- * throws instead of silently producing an incomplete file.
201
161
  *
202
- * @param lines - 組合後的行陣列 / The assembled line array
203
- * @returns 展開後的行陣列 / The expanded line array
162
+ * @param lines - 組合後的行陣列
163
+ * @returns 展開後的行陣列
204
164
  */
205
165
  export declare function expandGenPlaceholders(lines: readonly string[]): string[];