@yarn-tool/static-file 3.0.19 → 3.0.20
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 +56 -0
- package/README.md +110 -3
- package/file/npmignore +31 -0
- package/file/test/__root-core.cjs +1 -1
- package/file/test/__root-core.mjs +1 -1
- package/file/test/__root.js.map +1 -0
- package/file/test/__root.ts +9 -2
- package/file/test/temp.js.map +1 -0
- package/file/test/tsconfig.json.tpl +7 -0
- package/file/tsconfig.esm.json.tpl +9 -1
- package/file/tsconfig.json.tpl +9 -1
- package/file/tsconfig.tsdx.json.tpl +4 -0
- package/file/tsdx/index.cjs.map +1 -0
- package/file/ws-root/__root_ws.js.map +1 -0
- package/lib/const.js +120 -27
- package/lib/const.js.map +1 -1
- package/lib/copyStaticFiles.d.ts +62 -2
- package/lib/copyStaticFiles.js +156 -9
- package/lib/copyStaticFiles.js.map +1 -1
- package/lib/copyStaticFilesEntry.d.ts +72 -25
- package/lib/copyStaticFilesEntry.js +133 -34
- package/lib/copyStaticFilesEntry.js.map +1 -1
- package/lib/mergeIgnoreFiles.d.ts +52 -0
- package/lib/mergeIgnoreFiles.js +146 -0
- package/lib/mergeIgnoreFiles.js.map +1 -0
- package/lib/parseStaticMap.js +16 -3
- package/lib/parseStaticMap.js.map +1 -1
- package/lib/reMapStaticFilesMapArray.js +26 -5
- package/lib/reMapStaticFilesMapArray.js.map +1 -1
- package/lib/root/getRootCopyStaticFiles.js +17 -2
- package/lib/root/getRootCopyStaticFiles.js.map +1 -1
- package/lib/types.d.ts +71 -0
- package/lib/types.js.map +1 -1
- package/package.json +22 -5
- package/test/__root-core.cjs +1 -0
- package/test/__root-core.d.cts +1 -0
- package/test/__root-core.d.mts +1 -0
- package/test/__root-core.d.ts +1 -0
- package/test/__root-core.mjs +8 -0
- package/test/__root.d.ts +32 -0
- package/test/__root.js +54 -0
- package/test/__root.js.map +1 -0
- package/test/copyStaticFiles.test.js.map +1 -0
- package/test/copyStaticFiles.test.ts.snapshot +439 -0
- package/test/fixtures/out/gitignore +242 -0
- package/test/fixtures/out/npmignore +216 -0
- package/test/fixtures/split/git/00-header.txt +2 -0
- package/test/fixtures/split/git/10-project.txt +24 -0
- package/test/fixtures/split/git/20-test.txt +9 -0
- package/test/fixtures/split/git/40-env.txt +10 -0
- package/test/fixtures/split/git/90-misc.txt +6 -0
- package/test/fixtures/split/git/99-whitelist.txt +40 -0
- package/test/fixtures/split/npm/01-hidden.txt +2 -0
- package/test/fixtures/split/npm/05-source.txt +7 -0
- package/test/fixtures/split/npm/10-project.txt +31 -0
- package/test/fixtures/split/npm/20-test.txt +20 -0
- package/test/fixtures/split/npm/30-ide.txt +2 -0
- package/test/fixtures/split/npm/40-env.txt +2 -0
- package/test/fixtures/split/npm/90-misc.txt +4 -0
- package/test/fixtures/split/other/90-duplicates.txt +33 -0
- package/test/fixtures/split/shared/10-project.txt +38 -0
- package/test/fixtures/split/shared/20-test.txt +7 -0
- package/test/fixtures/split/shared/30-ide.txt +8 -0
- package/test/fixtures/split/shared/40-env.txt +6 -0
- package/test/fixtures/split/shared/90-misc.txt +10 -0
- package/test/scripts/compose-split-ignore-files.d.ts +1 -0
- package/test/scripts/compose-split-ignore-files.js +80 -0
- package/test/scripts/compose-split-ignore-files.js.map +1 -0
- package/test/scripts/lib/ignore-split.d.ts +205 -0
- package/test/scripts/lib/ignore-split.js +286 -0
- package/test/scripts/lib/ignore-split.js.map +1 -0
- package/test/scripts/split-ignore-files.d.ts +1 -0
- package/test/scripts/split-ignore-files.js +454 -0
- package/test/scripts/split-ignore-files.js.map +1 -0
- package/test/scripts/update-npmignore-static-files.d.ts +1 -0
- package/test/scripts/update-npmignore-static-files.js +121 -0
- package/test/scripts/update-npmignore-static-files.js.map +1 -0
- package/test/temp.d.ts +3 -0
- package/test/temp.js +5 -0
- package/test/temp.js.map +1 -0
- package/test/tsconfig.json.tpl +13 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 二層分類主題,陣列順序即全域組合順序
|
|
3
|
+
* Second-level topics; the array order is the global assembly order
|
|
4
|
+
*
|
|
5
|
+
* 編號前綴刻意留出間隙(05、10、20…),方便日後插入新主題而不需重排。
|
|
6
|
+
* The numeric prefixes leave gaps (05, 10, 20…) so new topics can be inserted
|
|
7
|
+
* without renumbering the rest.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TOPICS: readonly [{
|
|
10
|
+
readonly id: "00-header";
|
|
11
|
+
readonly zh: "檔案頭";
|
|
12
|
+
readonly en: "file header";
|
|
13
|
+
}, {
|
|
14
|
+
readonly id: "01-hidden";
|
|
15
|
+
readonly zh: "根目錄隱藏檔";
|
|
16
|
+
readonly en: "root hidden files";
|
|
17
|
+
}, {
|
|
18
|
+
readonly id: "05-source";
|
|
19
|
+
readonly zh: "npm 來源檔規則";
|
|
20
|
+
readonly en: "npm source rules";
|
|
21
|
+
}, {
|
|
22
|
+
readonly id: "10-project";
|
|
23
|
+
readonly zh: "專案檔";
|
|
24
|
+
readonly en: "project files";
|
|
25
|
+
}, {
|
|
26
|
+
readonly id: "20-test";
|
|
27
|
+
readonly zh: "測試檔";
|
|
28
|
+
readonly en: "test files";
|
|
29
|
+
}, {
|
|
30
|
+
readonly id: "30-ide";
|
|
31
|
+
readonly zh: "IDE 與編輯器設定";
|
|
32
|
+
readonly en: "IDE & editor settings";
|
|
33
|
+
}, {
|
|
34
|
+
readonly id: "40-env";
|
|
35
|
+
readonly zh: "環境設定";
|
|
36
|
+
readonly en: "environment settings";
|
|
37
|
+
}, {
|
|
38
|
+
readonly id: "90-misc";
|
|
39
|
+
readonly zh: "未分類";
|
|
40
|
+
readonly en: "unclassified";
|
|
41
|
+
}, {
|
|
42
|
+
readonly id: "99-whitelist";
|
|
43
|
+
readonly zh: "白名單例外";
|
|
44
|
+
readonly en: "whitelist exceptions";
|
|
45
|
+
}];
|
|
46
|
+
/**
|
|
47
|
+
* 主題 id 的聯合型別,由 {@link TOPICS} 派生
|
|
48
|
+
* Union of topic ids, derived from {@link TOPICS}
|
|
49
|
+
*/
|
|
50
|
+
export type IIgnoreSplitTopicId = typeof TOPICS[number]['id'];
|
|
51
|
+
/**
|
|
52
|
+
* 會輸出到組合結果的分類(other 永不輸出)
|
|
53
|
+
* Buckets emitted into the composed output (other is never emitted)
|
|
54
|
+
*/
|
|
55
|
+
export declare const EMITTED_BUCKETS: readonly ["git", "npm", "shared"];
|
|
56
|
+
/**
|
|
57
|
+
* 輸出分類的聯合型別,由 {@link EMITTED_BUCKETS} 派生
|
|
58
|
+
* Union of emitted buckets, derived from {@link EMITTED_BUCKETS}
|
|
59
|
+
*/
|
|
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
|
+
/**
|
|
67
|
+
* 組合目標:分類與對應的 ignore 檔名,為「分類 ↔ 檔名」的單一事實來源
|
|
68
|
+
* Composition targets: the bucket and its ignore file name — the single source
|
|
69
|
+
* of truth for the bucket ↔ file-name mapping
|
|
70
|
+
*/
|
|
71
|
+
export declare const IGNORE_SPLIT_TARGETS: readonly [{
|
|
72
|
+
readonly bucket: "git";
|
|
73
|
+
readonly fileName: "gitignore";
|
|
74
|
+
}, {
|
|
75
|
+
readonly bucket: "npm";
|
|
76
|
+
readonly fileName: "npmignore";
|
|
77
|
+
}];
|
|
78
|
+
/**
|
|
79
|
+
* 可作為組合目標的分類,由 {@link IGNORE_SPLIT_TARGETS} 派生
|
|
80
|
+
* Buckets usable as composition targets, derived from {@link IGNORE_SPLIT_TARGETS}
|
|
81
|
+
*/
|
|
82
|
+
export type IIgnoreSplitTargetBucket = typeof IGNORE_SPLIT_TARGETS[number]['bucket'];
|
|
83
|
+
/**
|
|
84
|
+
* 分類片段的根目錄 / Root directory of the classified fragments
|
|
85
|
+
*/
|
|
86
|
+
export declare const SPLIT_ROOT: string;
|
|
87
|
+
/**
|
|
88
|
+
* 取得片段檔案路徑,命名慣例為 `<分類>/<主題>.txt`
|
|
89
|
+
* Get a fragment file path, following the `<bucket>/<topic>.txt` naming convention
|
|
90
|
+
*
|
|
91
|
+
* 分割腳本與組合腳本共用此函式,避免各自拼出不同的存放位置。
|
|
92
|
+
* Shared by the split and compose scripts so neither builds its own location.
|
|
93
|
+
*
|
|
94
|
+
* @param bucket - 分類 / Bucket
|
|
95
|
+
* @param topic - 主題編號 / Topic id
|
|
96
|
+
* @returns 片段檔案的絕對路徑 / The absolute path of the fragment file
|
|
97
|
+
*/
|
|
98
|
+
export declare function getSplitFragmentPath(bucket: string, topic: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* git:測試建置產物矩陣
|
|
101
|
+
* git: test build artifact matrix
|
|
102
|
+
*
|
|
103
|
+
* 覆蓋 temp 產物、source map,以及 js/d.ts、mjs/d.mts、cjs/d.cts 三個族系
|
|
104
|
+
* 在 test、tests、packages/* 等目錄下的組合。
|
|
105
|
+
*
|
|
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)
|
|
110
|
+
*/
|
|
111
|
+
export declare function genTestBuildArtifacts(): string[];
|
|
112
|
+
/**
|
|
113
|
+
* git:*.map 對應檔規則
|
|
114
|
+
* git: *.map source file rules
|
|
115
|
+
*
|
|
116
|
+
* 六種模組副檔名的對應檔,一行一個族系無法由其他規則取代,故集中產生。
|
|
117
|
+
* The mapping files of six module extensions; centralized here since no single
|
|
118
|
+
* rule can cover them.
|
|
119
|
+
*
|
|
120
|
+
* @returns 片段內容行 / Fragment lines
|
|
121
|
+
*/
|
|
122
|
+
export declare function genSourceMaps(): string[];
|
|
123
|
+
/**
|
|
124
|
+
* npm:spec / test 副檔名矩陣
|
|
125
|
+
* npm: spec & test filename matrix
|
|
126
|
+
*
|
|
127
|
+
* 四種前綴(spec、test、node-spec、node-test)× 四組副檔名族系
|
|
128
|
+
* (d.ts+js/ts、d.cts+cjs/cts、d.mts+mjs/mts、d.tsx+tsx)的笛卡兒積。
|
|
129
|
+
*
|
|
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
|
+
* @returns 片段內容行 / Fragment lines
|
|
135
|
+
*/
|
|
136
|
+
export declare function genSpecFiles(): string[];
|
|
137
|
+
/**
|
|
138
|
+
* npm:來源與聲明檔規則群
|
|
139
|
+
* npm: source & declaration rule groups
|
|
140
|
+
*
|
|
141
|
+
* 三種聲明副檔名(d.ts、d.mts、d.cts)各自的白名單與 /bin 目錄規則,
|
|
142
|
+
* 必須維持在相鄰行才能與前後的排除規則正確互動。
|
|
143
|
+
*
|
|
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
|
|
149
|
+
*/
|
|
150
|
+
export declare function genNpmSourceDeclarations(): string[];
|
|
151
|
+
/**
|
|
152
|
+
* 共用輔助區塊的註冊資料:產生函式、所屬主題與所屬分類都登记在此,
|
|
153
|
+
* 分割腳本據此決定佔位行寫入哪個片段,組合腳本據此展開佔位內容
|
|
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
|
+
*/
|
|
158
|
+
export interface IIgnoreSplitGenerator {
|
|
159
|
+
/**
|
|
160
|
+
* 產生區塊內容(含說明註解與組內空行)
|
|
161
|
+
* Produce the block content (including its description comment and intra-group blanks)
|
|
162
|
+
*/
|
|
163
|
+
generate: () => string[];
|
|
164
|
+
/**
|
|
165
|
+
* 區塊所屬主題 / The topic this block belongs to
|
|
166
|
+
*/
|
|
167
|
+
topic: IIgnoreSplitTopicId;
|
|
168
|
+
/**
|
|
169
|
+
* 區塊所屬分類;只有目標分類(git / npm)會以輔助產生
|
|
170
|
+
* Bucket of the block; only target buckets (git / npm) are produced by helpers
|
|
171
|
+
*/
|
|
172
|
+
bucket: IIgnoreSplitTargetBucket;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 產生器註冊表:鍵名對應片段中的 `# %gen:NAME%` 佔位名稱
|
|
176
|
+
* Generator registry: keys match the `# %gen:NAME%` placeholder names in fragments
|
|
177
|
+
*/
|
|
178
|
+
export declare const IGNORE_SPLIT_GENERATORS: Record<string, IIgnoreSplitGenerator>;
|
|
179
|
+
/**
|
|
180
|
+
* 讀取單一分類片段的所有行
|
|
181
|
+
* Read every line of a single classified fragment
|
|
182
|
+
*
|
|
183
|
+
* 片段首行是分類標頭(主題 × 分類),組合時保留為輸出檔的區段標記;
|
|
184
|
+
* 檔案不存在(該分類 × 主題沒有片段)時回傳空陣列。
|
|
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
|
+
*
|
|
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)
|
|
192
|
+
*/
|
|
193
|
+
export declare function readSplitFragment(bucket: string, topic: string): string[];
|
|
194
|
+
/**
|
|
195
|
+
* 將 `# %gen:NAME%` 佔位行展開為對應產生器的輸出
|
|
196
|
+
* Expand `# %gen:NAME%` placeholder lines into the matching generator output
|
|
197
|
+
*
|
|
198
|
+
* 其餘行原樣保留;遇到未註冊的佔位名稱時拋錯,避免靜默產出不完整的檔案。
|
|
199
|
+
* All other lines pass through unchanged; an unregistered placeholder name
|
|
200
|
+
* throws instead of silently producing an incomplete file.
|
|
201
|
+
*
|
|
202
|
+
* @param lines - 組合後的行陣列 / The assembled line array
|
|
203
|
+
* @returns 展開後的行陣列 / The expanded line array
|
|
204
|
+
*/
|
|
205
|
+
export declare function expandGenPlaceholders(lines: readonly string[]): string[];
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IGNORE_SPLIT_GENERATORS = exports.SPLIT_ROOT = exports.IGNORE_SPLIT_TARGETS = exports.EMITTED_BUCKETS = exports.TOPICS = void 0;
|
|
4
|
+
exports.getSplitFragmentPath = getSplitFragmentPath;
|
|
5
|
+
exports.genTestBuildArtifacts = genTestBuildArtifacts;
|
|
6
|
+
exports.genSourceMaps = genSourceMaps;
|
|
7
|
+
exports.genSpecFiles = genSpecFiles;
|
|
8
|
+
exports.genNpmSourceDeclarations = genNpmSourceDeclarations;
|
|
9
|
+
exports.readSplitFragment = readSplitFragment;
|
|
10
|
+
exports.expandGenPlaceholders = expandGenPlaceholders;
|
|
11
|
+
/**
|
|
12
|
+
* 忽略規則分割片段的主題定義與共用輔助(分割與組合腳本的單一事實來源)
|
|
13
|
+
* Topic definitions and shared helpers of the split ignore-rule fragments
|
|
14
|
+
* (the single source of truth for the split and compose scripts)
|
|
15
|
+
*
|
|
16
|
+
* 片段檔案位於 test/fixtures/split/{git,npm,shared,other}/NN-topic.txt,
|
|
17
|
+
* 依「第一層 git 專用 / npm 發布專用 / 兩類共用 / 其他、第二層主題分類」保存。
|
|
18
|
+
*
|
|
19
|
+
* Fragments live in test/fixtures/split/{git,npm,shared,other}/NN-topic.txt,
|
|
20
|
+
* sorted by the first-level buckets (git-only / npm-only / shared / other)
|
|
21
|
+
* and the second-level topics below.
|
|
22
|
+
*
|
|
23
|
+
* 重複的語法矩陣(測試建置產物、*.map、spec 副檔名…)不逐行手寫:
|
|
24
|
+
* 片段中只放 `# %gen:NAME%` 佔位行,組合時由本檔的產生器展開,
|
|
25
|
+
* 以單一事實來源避免多份手抄副本漂移。
|
|
26
|
+
*
|
|
27
|
+
* Repetitive matrices (test build artifacts, *.map, spec filenames…) are never
|
|
28
|
+
* hand-copied: fragments only carry a `# %gen:NAME%` placeholder line, which the
|
|
29
|
+
* generators below expand at composition time — a single source of truth instead
|
|
30
|
+
* of drifting manual copies.
|
|
31
|
+
*
|
|
32
|
+
* 本檔是「分割(split-ignore-files.ts)」與「組合(compose-split-ignore-files.ts)」
|
|
33
|
+
* 兩支腳本的共用事實來源:主題、分類 ↔ 檔名、片段路徑慣例與輔助區塊定義都只存在於此。
|
|
34
|
+
* This file is the shared source of truth for both scripts (split-ignore-files.ts
|
|
35
|
+
* and compose-split-ignore-files.ts): topics, the bucket ↔ file name mapping, the
|
|
36
|
+
* fragment path convention, and the generator blocks are all defined here only.
|
|
37
|
+
*/
|
|
38
|
+
const fs_1 = require("fs");
|
|
39
|
+
const path_1 = require("path");
|
|
40
|
+
const __root_1 = require("../../__root");
|
|
41
|
+
/**
|
|
42
|
+
* 二層分類主題,陣列順序即全域組合順序
|
|
43
|
+
* Second-level topics; the array order is the global assembly order
|
|
44
|
+
*
|
|
45
|
+
* 編號前綴刻意留出間隙(05、10、20…),方便日後插入新主題而不需重排。
|
|
46
|
+
* The numeric prefixes leave gaps (05, 10, 20…) so new topics can be inserted
|
|
47
|
+
* without renumbering the rest.
|
|
48
|
+
*/
|
|
49
|
+
exports.TOPICS = [
|
|
50
|
+
{ id: '00-header', zh: '檔案頭', en: 'file header' },
|
|
51
|
+
{ id: '01-hidden', zh: '根目錄隱藏檔', en: 'root hidden files' },
|
|
52
|
+
{ id: '05-source', zh: 'npm 來源檔規則', en: 'npm source rules' },
|
|
53
|
+
{ id: '10-project', zh: '專案檔', en: 'project files' },
|
|
54
|
+
{ id: '20-test', zh: '測試檔', en: 'test files' },
|
|
55
|
+
{ id: '30-ide', zh: 'IDE 與編輯器設定', en: 'IDE & editor settings' },
|
|
56
|
+
{ id: '40-env', zh: '環境設定', en: 'environment settings' },
|
|
57
|
+
{ id: '90-misc', zh: '未分類', en: 'unclassified' },
|
|
58
|
+
{ id: '99-whitelist', zh: '白名單例外', en: 'whitelist exceptions' },
|
|
59
|
+
];
|
|
60
|
+
/**
|
|
61
|
+
* 會輸出到組合結果的分類(other 永不輸出)
|
|
62
|
+
* Buckets emitted into the composed output (other is never emitted)
|
|
63
|
+
*/
|
|
64
|
+
exports.EMITTED_BUCKETS = ['git', 'npm', 'shared'];
|
|
65
|
+
/**
|
|
66
|
+
* 組合目標:分類與對應的 ignore 檔名,為「分類 ↔ 檔名」的單一事實來源
|
|
67
|
+
* Composition targets: the bucket and its ignore file name — the single source
|
|
68
|
+
* of truth for the bucket ↔ file-name mapping
|
|
69
|
+
*/
|
|
70
|
+
exports.IGNORE_SPLIT_TARGETS = [
|
|
71
|
+
{ bucket: 'git', fileName: 'gitignore' },
|
|
72
|
+
{ bucket: 'npm', fileName: 'npmignore' },
|
|
73
|
+
];
|
|
74
|
+
/**
|
|
75
|
+
* 分類片段的根目錄 / Root directory of the classified fragments
|
|
76
|
+
*/
|
|
77
|
+
exports.SPLIT_ROOT = (0, path_1.join)(__root_1.__ROOT, 'test', 'fixtures', 'split');
|
|
78
|
+
/**
|
|
79
|
+
* 取得片段檔案路徑,命名慣例為 `<分類>/<主題>.txt`
|
|
80
|
+
* Get a fragment file path, following the `<bucket>/<topic>.txt` naming convention
|
|
81
|
+
*
|
|
82
|
+
* 分割腳本與組合腳本共用此函式,避免各自拼出不同的存放位置。
|
|
83
|
+
* Shared by the split and compose scripts so neither builds its own location.
|
|
84
|
+
*
|
|
85
|
+
* @param bucket - 分類 / Bucket
|
|
86
|
+
* @param topic - 主題編號 / Topic id
|
|
87
|
+
* @returns 片段檔案的絕對路徑 / The absolute path of the fragment file
|
|
88
|
+
*/
|
|
89
|
+
function getSplitFragmentPath(bucket, topic) {
|
|
90
|
+
return (0, path_1.join)(exports.SPLIT_ROOT, bucket, `${topic}.txt`);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 片段中的佔位行:`# %gen:<名稱>%`
|
|
94
|
+
* Placeholder line inside a fragment: `# %gen:<name>%`
|
|
95
|
+
*/
|
|
96
|
+
const GEN_PLACEHOLDER_RE = /^# %gen:([a-z0-9-]+)%$/;
|
|
97
|
+
/**
|
|
98
|
+
* git:測試建置產物矩陣
|
|
99
|
+
* git: test build artifact matrix
|
|
100
|
+
*
|
|
101
|
+
* 覆蓋 temp 產物、source map,以及 js/d.ts、mjs/d.mts、cjs/d.cts 三個族系
|
|
102
|
+
* 在 test、tests、packages/* 等目錄下的組合。
|
|
103
|
+
*
|
|
104
|
+
* Covers temp artifacts, source maps, and the js/d.ts, mjs/d.mts, cjs/d.cts
|
|
105
|
+
* families across the test, tests, and packages/* directories.
|
|
106
|
+
*
|
|
107
|
+
* @returns 片段內容行(含分類說明註解與組內空行)/ Fragment lines (including its description comment and intra-group blanks)
|
|
108
|
+
*/
|
|
109
|
+
function genTestBuildArtifacts() {
|
|
110
|
+
const lines = [
|
|
111
|
+
'# 測試建置產物(共用輔助產生)/ test build artifacts (generated by shared helper)',
|
|
112
|
+
];
|
|
113
|
+
for (const dir of ['test', 'tests']) {
|
|
114
|
+
lines.push(`${dir}/temp*`, `${dir}/**/*.map`);
|
|
115
|
+
}
|
|
116
|
+
lines.push('/packages/*/test/temp*', '/packages/*/tests/temp*', '');
|
|
117
|
+
/**
|
|
118
|
+
* 每個族系:實作副檔名與其聲明檔配對,重複的目錄組合交給迴圈展開
|
|
119
|
+
* Per family: the implementation extension paired with its declaration file,
|
|
120
|
+
* with the repeated directory combinations expanded by the loop
|
|
121
|
+
*/
|
|
122
|
+
const families = [
|
|
123
|
+
['js', 'd.ts'],
|
|
124
|
+
['mjs', 'd.mts'],
|
|
125
|
+
['cjs', 'd.cts'],
|
|
126
|
+
];
|
|
127
|
+
families.forEach(([ext, decl], index) => {
|
|
128
|
+
if (index) {
|
|
129
|
+
lines.push('');
|
|
130
|
+
}
|
|
131
|
+
for (const dir of ['test', 'tests']) {
|
|
132
|
+
lines.push(`${dir}/**/*.${ext}`, `${dir}/**/*.${decl}`, `${dir}/*.${ext}`, `${dir}/*.${decl}`);
|
|
133
|
+
}
|
|
134
|
+
lines.push(`bin/*.${decl}`, `bin/**/*.${decl}`, `/packages/*/bin/*.${decl}`);
|
|
135
|
+
for (const dir of ['/packages/*/test', '/packages/*/tests']) {
|
|
136
|
+
lines.push(`${dir}/**/*.${ext}`, `${dir}/**/*.${decl}`, `${dir}/*.${ext}`, `${dir}/*.${decl}`);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return lines;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* git:*.map 對應檔規則
|
|
143
|
+
* git: *.map source file rules
|
|
144
|
+
*
|
|
145
|
+
* 六種模組副檔名的對應檔,一行一個族系無法由其他規則取代,故集中產生。
|
|
146
|
+
* The mapping files of six module extensions; centralized here since no single
|
|
147
|
+
* rule can cover them.
|
|
148
|
+
*
|
|
149
|
+
* @returns 片段內容行 / Fragment lines
|
|
150
|
+
*/
|
|
151
|
+
function genSourceMaps() {
|
|
152
|
+
return [
|
|
153
|
+
'# *.map 對應檔(共用輔助產生)/ *.map files (generated by shared helper)',
|
|
154
|
+
'*.js.map',
|
|
155
|
+
'*.cjs.map',
|
|
156
|
+
'*.mjs.map',
|
|
157
|
+
'*.ts.map',
|
|
158
|
+
'*.cts.map',
|
|
159
|
+
'*.mts.map',
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* npm:spec / test 副檔名矩陣
|
|
164
|
+
* npm: spec & test filename matrix
|
|
165
|
+
*
|
|
166
|
+
* 四種前綴(spec、test、node-spec、node-test)× 四組副檔名族系
|
|
167
|
+
* (d.ts+js/ts、d.cts+cjs/cts、d.mts+mjs/mts、d.tsx+tsx)的笛卡兒積。
|
|
168
|
+
*
|
|
169
|
+
* The cartesian product of four prefixes (spec, test, node-spec, node-test)
|
|
170
|
+
* and four extension families (d.ts+js/ts, d.cts+cjs/cts, d.mts+mjs/mts,
|
|
171
|
+
* d.tsx+tsx).
|
|
172
|
+
*
|
|
173
|
+
* @returns 片段內容行 / Fragment lines
|
|
174
|
+
*/
|
|
175
|
+
function genSpecFiles() {
|
|
176
|
+
const lines = [
|
|
177
|
+
'# spec / test 副檔名矩陣(共用輔助產生)/ spec & test filename matrix (generated by shared helper)',
|
|
178
|
+
];
|
|
179
|
+
const prefixes = ['spec', 'test', 'node-spec', 'node-test'];
|
|
180
|
+
const families = [
|
|
181
|
+
{ decl: 'd.ts', impls: ['js', 'ts'] },
|
|
182
|
+
{ decl: 'd.cts', impls: ['cjs', 'cts'] },
|
|
183
|
+
{ decl: 'd.mts', impls: ['mjs', 'mts'] },
|
|
184
|
+
{ decl: 'd.tsx', impls: ['tsx'] },
|
|
185
|
+
];
|
|
186
|
+
prefixes.forEach((prefix, prefixIndex) => {
|
|
187
|
+
if (prefixIndex) {
|
|
188
|
+
lines.push('');
|
|
189
|
+
}
|
|
190
|
+
families.forEach((family, familyIndex) => {
|
|
191
|
+
if (familyIndex) {
|
|
192
|
+
lines.push('');
|
|
193
|
+
}
|
|
194
|
+
lines.push(`*.${prefix}.${family.decl}`);
|
|
195
|
+
for (const impl of family.impls) {
|
|
196
|
+
lines.push(`*.${prefix}.${impl}`);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
return lines;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* npm:來源與聲明檔規則群
|
|
204
|
+
* npm: source & declaration rule groups
|
|
205
|
+
*
|
|
206
|
+
* 三種聲明副檔名(d.ts、d.mts、d.cts)各自的白名單與 /bin 目錄規則,
|
|
207
|
+
* 必須維持在相鄰行才能與前後的排除規則正確互動。
|
|
208
|
+
*
|
|
209
|
+
* The whitelist and /bin rules for the three declaration extensions
|
|
210
|
+
* (d.ts, d.mts, d.cts); they must stay on adjacent lines to interact correctly
|
|
211
|
+
* with the surrounding exclusion rules.
|
|
212
|
+
*
|
|
213
|
+
* @returns 片段內容行 / Fragment lines
|
|
214
|
+
*/
|
|
215
|
+
function genNpmSourceDeclarations() {
|
|
216
|
+
const lines = [
|
|
217
|
+
'# npm 來源與聲明檔規則(共用輔助產生)/ npm source & declaration rules (generated by shared helper)',
|
|
218
|
+
];
|
|
219
|
+
['d.ts', 'd.mts', 'd.cts'].forEach((decl, index) => {
|
|
220
|
+
if (index) {
|
|
221
|
+
lines.push('');
|
|
222
|
+
}
|
|
223
|
+
lines.push(`!*.${decl}`, `/bin/**/*.${decl}`, `/bin/*.${decl}`);
|
|
224
|
+
});
|
|
225
|
+
return lines;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* 產生器註冊表:鍵名對應片段中的 `# %gen:NAME%` 佔位名稱
|
|
229
|
+
* Generator registry: keys match the `# %gen:NAME%` placeholder names in fragments
|
|
230
|
+
*/
|
|
231
|
+
exports.IGNORE_SPLIT_GENERATORS = {
|
|
232
|
+
'test-build-artifacts': { generate: genTestBuildArtifacts, topic: '20-test', bucket: 'git' },
|
|
233
|
+
'source-maps': { generate: genSourceMaps, topic: '10-project', bucket: 'git' },
|
|
234
|
+
'spec-files': { generate: genSpecFiles, topic: '20-test', bucket: 'npm' },
|
|
235
|
+
'npm-source-declarations': { generate: genNpmSourceDeclarations, topic: '05-source', bucket: 'npm' },
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* 讀取單一分類片段的所有行
|
|
239
|
+
* Read every line of a single classified fragment
|
|
240
|
+
*
|
|
241
|
+
* 片段首行是分類標頭(主題 × 分類),組合時保留為輸出檔的區段標記;
|
|
242
|
+
* 檔案不存在(該分類 × 主題沒有片段)時回傳空陣列。
|
|
243
|
+
* The first line is the classification header (topic × bucket), kept as the
|
|
244
|
+
* section marker of the composed output; a missing file (no fragment for that
|
|
245
|
+
* bucket × topic combination) yields an empty array.
|
|
246
|
+
*
|
|
247
|
+
* @param bucket - 分類:git、npm 或 shared / Bucket: git, npm, or shared
|
|
248
|
+
* @param topic - 主題編號({@link TOPICS} 的 id)/ Topic id (see {@link TOPICS})
|
|
249
|
+
* @returns 片段行陣列(已去除結尾空行)/ Fragment lines (trailing blanks removed)
|
|
250
|
+
*/
|
|
251
|
+
function readSplitFragment(bucket, topic) {
|
|
252
|
+
const path = getSplitFragmentPath(bucket, topic);
|
|
253
|
+
if (!(0, fs_1.existsSync)(path)) {
|
|
254
|
+
return [];
|
|
255
|
+
}
|
|
256
|
+
const lines = (0, fs_1.readFileSync)(path, 'utf8').split(/\r?\n/);
|
|
257
|
+
while (lines.length > 0 && lines[lines.length - 1] === '') {
|
|
258
|
+
lines.pop();
|
|
259
|
+
}
|
|
260
|
+
return lines;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* 將 `# %gen:NAME%` 佔位行展開為對應產生器的輸出
|
|
264
|
+
* Expand `# %gen:NAME%` placeholder lines into the matching generator output
|
|
265
|
+
*
|
|
266
|
+
* 其餘行原樣保留;遇到未註冊的佔位名稱時拋錯,避免靜默產出不完整的檔案。
|
|
267
|
+
* All other lines pass through unchanged; an unregistered placeholder name
|
|
268
|
+
* throws instead of silently producing an incomplete file.
|
|
269
|
+
*
|
|
270
|
+
* @param lines - 組合後的行陣列 / The assembled line array
|
|
271
|
+
* @returns 展開後的行陣列 / The expanded line array
|
|
272
|
+
*/
|
|
273
|
+
function expandGenPlaceholders(lines) {
|
|
274
|
+
return lines.flatMap((line) => {
|
|
275
|
+
const matched = GEN_PLACEHOLDER_RE.exec(line);
|
|
276
|
+
if (!matched) {
|
|
277
|
+
return [line];
|
|
278
|
+
}
|
|
279
|
+
const generator = exports.IGNORE_SPLIT_GENERATORS[matched[1]];
|
|
280
|
+
if (!generator) {
|
|
281
|
+
throw new Error(`unknown ignore split generator placeholder: ${line}`);
|
|
282
|
+
}
|
|
283
|
+
return generator.generate();
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=ignore-split.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignore-split.js","sourceRoot":"","sources":["ignore-split.ts"],"names":[],"mappings":";;;AA2GA,oDAGC;AAoBD,sDA6CC;AAYD,sCAWC;AAeD,oCAuCC;AAeD,4DAiBC;AAsDD,8CAiBC;AAaD,sDAoBC;AApYD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,2BAA8C;AAC9C,+BAA4B;AAC5B,yCAAsC;AAEtC;;;;;;;GAOG;AACU,QAAA,MAAM,GAAG;IACrB,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE;IACjD,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,mBAAmB,EAAE;IAC1D,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,kBAAkB,EAAE;IAC5D,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,eAAe,EAAE;IACpD,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE;IAC9C,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,uBAAuB,EAAE;IAC/D,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,sBAAsB,EAAE;IACxD,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE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,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAE7B,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,CAAC,OAAO,EACZ,CAAC;YACA,OAAO,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;QAED,MAAM,SAAS,GAAG,+BAAuB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtD,IAAI,CAAC,SAAS,EACd,CAAC;YACA,MAAM,IAAI,KAAK,CAAC,+CAA+C,IAAI,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * 忽略規則分割片段的主題定義與共用輔助(分割與組合腳本的單一事實來源)\n * Topic definitions and shared helpers of the split ignore-rule fragments\n * (the single source of truth for the split and compose scripts)\n *\n * 片段檔案位於 test/fixtures/split/{git,npm,shared,other}/NN-topic.txt,\n * 依「第一層 git 專用 / npm 發布專用 / 兩類共用 / 其他、第二層主題分類」保存。\n *\n * Fragments live in test/fixtures/split/{git,npm,shared,other}/NN-topic.txt,\n * sorted by the first-level buckets (git-only / npm-only / shared / other)\n * and the second-level topics below.\n *\n * 重複的語法矩陣(測試建置產物、*.map、spec 副檔名…)不逐行手寫:\n * 片段中只放 `# %gen:NAME%` 佔位行,組合時由本檔的產生器展開,\n * 以單一事實來源避免多份手抄副本漂移。\n *\n * Repetitive matrices (test build artifacts, *.map, spec filenames…) are never\n * hand-copied: fragments only carry a `# %gen:NAME%` placeholder line, which the\n * generators below expand at composition time — a single source of truth instead\n * of drifting manual copies.\n *\n * 本檔是「分割(split-ignore-files.ts)」與「組合(compose-split-ignore-files.ts)」\n * 兩支腳本的共用事實來源:主題、分類 ↔ 檔名、片段路徑慣例與輔助區塊定義都只存在於此。\n * This file is the shared source of truth for both scripts (split-ignore-files.ts\n * and compose-split-ignore-files.ts): topics, the bucket ↔ file name mapping, the\n * fragment path convention, and the generator blocks are all defined here only.\n */\nimport { existsSync, readFileSync } from 'fs';\nimport { join } from 'path';\nimport { __ROOT } from '../../__root';\n\n/**\n * 二層分類主題,陣列順序即全域組合順序\n * Second-level topics; the array order is the global assembly order\n *\n * 編號前綴刻意留出間隙(05、10、20…),方便日後插入新主題而不需重排。\n * The numeric prefixes leave gaps (05, 10, 20…) so new topics can be inserted\n * without renumbering the rest.\n */\nexport const TOPICS = [\n\t{ id: '00-header', zh: '檔案頭', en: 'file header' },\n\t{ id: '01-hidden', zh: '根目錄隱藏檔', en: 'root hidden files' },\n\t{ id: '05-source', zh: 'npm 來源檔規則', en: 'npm source rules' },\n\t{ id: '10-project', zh: '專案檔', en: 'project files' },\n\t{ id: '20-test', zh: '測試檔', en: 'test files' },\n\t{ id: '30-ide', zh: 'IDE 與編輯器設定', en: 'IDE & editor settings' },\n\t{ id: '40-env', zh: '環境設定', en: 'environment settings' },\n\t{ id: '90-misc', zh: '未分類', en: 'unclassified' },\n\t{ id: '99-whitelist', zh: '白名單例外', en: 'whitelist exceptions' },\n] as const;\n\n/**\n * 主題 id 的聯合型別,由 {@link TOPICS} 派生\n * Union of topic ids, derived from {@link TOPICS}\n */\nexport type IIgnoreSplitTopicId = typeof TOPICS[number]['id'];\n\n/**\n * 會輸出到組合結果的分類(other 永不輸出)\n * Buckets emitted into the composed output (other is never emitted)\n */\nexport const EMITTED_BUCKETS = ['git', 'npm', 'shared'] as const;\n\n/**\n * 輸出分類的聯合型別,由 {@link EMITTED_BUCKETS} 派生\n * Union of emitted buckets, derived from {@link EMITTED_BUCKETS}\n */\nexport type IIgnoreSplitEmittedBucket = typeof EMITTED_BUCKETS[number];\n\n/**\n * 全部分類的聯合型別(含永不輸出的 other)\n * Union of all buckets (including the never-emitted other)\n */\nexport type IIgnoreSplitBucket = IIgnoreSplitEmittedBucket | 'other';\n\n/**\n * 組合目標:分類與對應的 ignore 檔名,為「分類 ↔ 檔名」的單一事實來源\n * Composition targets: the bucket and its ignore file name — the single source\n * of truth for the bucket ↔ file-name mapping\n */\nexport const IGNORE_SPLIT_TARGETS = [\n\t{ bucket: 'git', fileName: 'gitignore' },\n\t{ bucket: 'npm', fileName: 'npmignore' },\n] as const;\n\n/**\n * 可作為組合目標的分類,由 {@link IGNORE_SPLIT_TARGETS} 派生\n * Buckets usable as composition targets, derived from {@link IGNORE_SPLIT_TARGETS}\n */\nexport type IIgnoreSplitTargetBucket = typeof IGNORE_SPLIT_TARGETS[number]['bucket'];\n\n/**\n * 分類片段的根目錄 / Root directory of the classified fragments\n */\nexport const SPLIT_ROOT = join(__ROOT, 'test', 'fixtures', 'split');\n\n/**\n * 取得片段檔案路徑,命名慣例為 `<分類>/<主題>.txt`\n * Get a fragment file path, following the `<bucket>/<topic>.txt` naming convention\n *\n * 分割腳本與組合腳本共用此函式,避免各自拼出不同的存放位置。\n * Shared by the split and compose scripts so neither builds its own location.\n *\n * @param bucket - 分類 / Bucket\n * @param topic - 主題編號 / Topic id\n * @returns 片段檔案的絕對路徑 / The absolute path of the fragment file\n */\nexport function getSplitFragmentPath(bucket: string, topic: string): string\n{\n\treturn join(SPLIT_ROOT, bucket, `${topic}.txt`);\n}\n\n/**\n * 片段中的佔位行:`# %gen:<名稱>%`\n * Placeholder line inside a fragment: `# %gen:<name>%`\n */\nconst GEN_PLACEHOLDER_RE = /^# %gen:([a-z0-9-]+)%$/;\n\n/**\n * git:測試建置產物矩陣\n * git: test build artifact matrix\n *\n * 覆蓋 temp 產物、source map,以及 js/d.ts、mjs/d.mts、cjs/d.cts 三個族系\n * 在 test、tests、packages/* 等目錄下的組合。\n *\n * Covers temp artifacts, source maps, and the js/d.ts, mjs/d.mts, cjs/d.cts\n * families across the test, tests, and packages/* directories.\n *\n * @returns 片段內容行(含分類說明註解與組內空行)/ Fragment lines (including its description comment and intra-group blanks)\n */\nexport function genTestBuildArtifacts(): string[]\n{\n\tconst lines: string[] = [\n\t\t'# 測試建置產物(共用輔助產生)/ test build artifacts (generated by shared helper)',\n\t];\n\n\tfor (const dir of ['test', 'tests'])\n\t{\n\t\tlines.push(`${dir}/temp*`, `${dir}/**/*.map`);\n\t}\n\n\tlines.push('/packages/*/test/temp*', '/packages/*/tests/temp*', '');\n\n\t/**\n\t * 每個族系:實作副檔名與其聲明檔配對,重複的目錄組合交給迴圈展開\n\t * Per family: the implementation extension paired with its declaration file,\n\t * with the repeated directory combinations expanded by the loop\n\t */\n\tconst families: [string, string][] = [\n\t\t['js', 'd.ts'],\n\t\t['mjs', 'd.mts'],\n\t\t['cjs', 'd.cts'],\n\t];\n\n\tfamilies.forEach(([ext, decl], index) =>\n\t{\n\t\tif (index)\n\t\t{\n\t\t\tlines.push('');\n\t\t}\n\n\t\tfor (const dir of ['test', 'tests'])\n\t\t{\n\t\t\tlines.push(`${dir}/**/*.${ext}`, `${dir}/**/*.${decl}`, `${dir}/*.${ext}`, `${dir}/*.${decl}`);\n\t\t}\n\n\t\tlines.push(`bin/*.${decl}`, `bin/**/*.${decl}`, `/packages/*/bin/*.${decl}`);\n\n\t\tfor (const dir of ['/packages/*/test', '/packages/*/tests'])\n\t\t{\n\t\t\tlines.push(`${dir}/**/*.${ext}`, `${dir}/**/*.${decl}`, `${dir}/*.${ext}`, `${dir}/*.${decl}`);\n\t\t}\n\t});\n\n\treturn lines;\n}\n\n/**\n * git:*.map 對應檔規則\n * git: *.map source file rules\n *\n * 六種模組副檔名的對應檔,一行一個族系無法由其他規則取代,故集中產生。\n * The mapping files of six module extensions; centralized here since no single\n * rule can cover them.\n *\n * @returns 片段內容行 / Fragment lines\n */\nexport function genSourceMaps(): string[]\n{\n\treturn [\n\t\t'# *.map 對應檔(共用輔助產生)/ *.map files (generated by shared helper)',\n\t\t'*.js.map',\n\t\t'*.cjs.map',\n\t\t'*.mjs.map',\n\t\t'*.ts.map',\n\t\t'*.cts.map',\n\t\t'*.mts.map',\n\t];\n}\n\n/**\n * npm:spec / test 副檔名矩陣\n * npm: spec & test filename matrix\n *\n * 四種前綴(spec、test、node-spec、node-test)× 四組副檔名族系\n * (d.ts+js/ts、d.cts+cjs/cts、d.mts+mjs/mts、d.tsx+tsx)的笛卡兒積。\n *\n * The cartesian product of four prefixes (spec, test, node-spec, node-test)\n * and four extension families (d.ts+js/ts, d.cts+cjs/cts, d.mts+mjs/mts,\n * d.tsx+tsx).\n *\n * @returns 片段內容行 / Fragment lines\n */\nexport function genSpecFiles(): string[]\n{\n\tconst lines: string[] = [\n\t\t'# spec / test 副檔名矩陣(共用輔助產生)/ spec & test filename matrix (generated by shared helper)',\n\t];\n\n\tconst prefixes = ['spec', 'test', 'node-spec', 'node-test'];\n\n\tconst families = [\n\t\t{ decl: 'd.ts', impls: ['js', 'ts'] },\n\t\t{ decl: 'd.cts', impls: ['cjs', 'cts'] },\n\t\t{ decl: 'd.mts', impls: ['mjs', 'mts'] },\n\t\t{ decl: 'd.tsx', impls: ['tsx'] },\n\t];\n\n\tprefixes.forEach((prefix, prefixIndex) =>\n\t{\n\t\tif (prefixIndex)\n\t\t{\n\t\t\tlines.push('');\n\t\t}\n\n\t\tfamilies.forEach((family, familyIndex) =>\n\t\t{\n\t\t\tif (familyIndex)\n\t\t\t{\n\t\t\t\tlines.push('');\n\t\t\t}\n\n\t\t\tlines.push(`*.${prefix}.${family.decl}`);\n\n\t\t\tfor (const impl of family.impls)\n\t\t\t{\n\t\t\t\tlines.push(`*.${prefix}.${impl}`);\n\t\t\t}\n\t\t});\n\t});\n\n\treturn lines;\n}\n\n/**\n * npm:來源與聲明檔規則群\n * npm: source & declaration rule groups\n *\n * 三種聲明副檔名(d.ts、d.mts、d.cts)各自的白名單與 /bin 目錄規則,\n * 必須維持在相鄰行才能與前後的排除規則正確互動。\n *\n * The whitelist and /bin rules for the three declaration extensions\n * (d.ts, d.mts, d.cts); they must stay on adjacent lines to interact correctly\n * with the surrounding exclusion rules.\n *\n * @returns 片段內容行 / Fragment lines\n */\nexport function genNpmSourceDeclarations(): string[]\n{\n\tconst lines: string[] = [\n\t\t'# npm 來源與聲明檔規則(共用輔助產生)/ npm source & declaration rules (generated by shared helper)',\n\t];\n\n\t['d.ts', 'd.mts', 'd.cts'].forEach((decl, index) =>\n\t{\n\t\tif (index)\n\t\t{\n\t\t\tlines.push('');\n\t\t}\n\n\t\tlines.push(`!*.${decl}`, `/bin/**/*.${decl}`, `/bin/*.${decl}`);\n\t});\n\n\treturn lines;\n}\n\n/**\n * 共用輔助區塊的註冊資料:產生函式、所屬主題與所屬分類都登记在此,\n * 分割腳本據此決定佔位行寫入哪個片段,組合腳本據此展開佔位內容\n * Registration of a shared generator: the generate function, its topic, and its\n * bucket all live here, so the split script knows which fragment receives the\n * placeholder line and the compose script knows what to expand it into\n */\nexport interface IIgnoreSplitGenerator\n{\n\t/**\n\t * 產生區塊內容(含說明註解與組內空行)\n\t * Produce the block content (including its description comment and intra-group blanks)\n\t */\n\tgenerate: () => string[];\n\n\t/**\n\t * 區塊所屬主題 / The topic this block belongs to\n\t */\n\ttopic: IIgnoreSplitTopicId;\n\n\t/**\n\t * 區塊所屬分類;只有目標分類(git / npm)會以輔助產生\n\t * Bucket of the block; only target buckets (git / npm) are produced by helpers\n\t */\n\tbucket: IIgnoreSplitTargetBucket;\n}\n\n/**\n * 產生器註冊表:鍵名對應片段中的 `# %gen:NAME%` 佔位名稱\n * Generator registry: keys match the `# %gen:NAME%` placeholder names in fragments\n */\nexport const IGNORE_SPLIT_GENERATORS: Record<string, IIgnoreSplitGenerator> = {\n\t'test-build-artifacts': { generate: genTestBuildArtifacts, topic: '20-test', bucket: 'git' },\n\t'source-maps': { generate: genSourceMaps, topic: '10-project', bucket: 'git' },\n\t'spec-files': { generate: genSpecFiles, topic: '20-test', bucket: 'npm' },\n\t'npm-source-declarations': { generate: genNpmSourceDeclarations, topic: '05-source', bucket: 'npm' },\n};\n\n/**\n * 讀取單一分類片段的所有行\n * Read every line of a single classified fragment\n *\n * 片段首行是分類標頭(主題 × 分類),組合時保留為輸出檔的區段標記;\n * 檔案不存在(該分類 × 主題沒有片段)時回傳空陣列。\n * The first line is the classification header (topic × bucket), kept as the\n * section marker of the composed output; a missing file (no fragment for that\n * bucket × topic combination) yields an empty array.\n *\n * @param bucket - 分類:git、npm 或 shared / Bucket: git, npm, or shared\n * @param topic - 主題編號({@link TOPICS} 的 id)/ Topic id (see {@link TOPICS})\n * @returns 片段行陣列(已去除結尾空行)/ Fragment lines (trailing blanks removed)\n */\nexport function readSplitFragment(bucket: string, topic: string): string[]\n{\n\tconst path = getSplitFragmentPath(bucket, topic);\n\n\tif (!existsSync(path))\n\t{\n\t\treturn [];\n\t}\n\n\tconst lines = readFileSync(path, 'utf8').split(/\\r?\\n/);\n\n\twhile (lines.length > 0 && lines[lines.length - 1] === '')\n\t{\n\t\tlines.pop();\n\t}\n\n\treturn lines;\n}\n\n/**\n * 將 `# %gen:NAME%` 佔位行展開為對應產生器的輸出\n * Expand `# %gen:NAME%` placeholder lines into the matching generator output\n *\n * 其餘行原樣保留;遇到未註冊的佔位名稱時拋錯,避免靜默產出不完整的檔案。\n * All other lines pass through unchanged; an unregistered placeholder name\n * throws instead of silently producing an incomplete file.\n *\n * @param lines - 組合後的行陣列 / The assembled line array\n * @returns 展開後的行陣列 / The expanded line array\n */\nexport function expandGenPlaceholders(lines: readonly string[]): string[]\n{\n\treturn lines.flatMap((line) =>\n\t{\n\t\tconst matched = GEN_PLACEHOLDER_RE.exec(line);\n\n\t\tif (!matched)\n\t\t{\n\t\t\treturn [line];\n\t\t}\n\n\t\tconst generator = IGNORE_SPLIT_GENERATORS[matched[1]];\n\n\t\tif (!generator)\n\t\t{\n\t\t\tthrow new Error(`unknown ignore split generator placeholder: ${line}`);\n\t\t}\n\n\t\treturn generator.generate();\n\t});\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|