@yarn-tool/static-file 3.0.4 → 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.
- package/CHANGELOG.md +48 -0
- package/README.md +9 -4
- package/__root.d.ts +28 -0
- package/__root.js +28 -0
- package/__root.js.map +1 -1
- package/file/.gitignore +10 -0
- package/file/README.md +11 -1
- package/file/gitignore +15 -0
- package/file/jest.config.auto.js +81 -15
- package/file/jest.config.js +3 -1
- package/file/npmrc +2 -1
- package/file/nvmrc +1 -1
- package/file/pnpm-workspace.yaml +19 -0
- package/file/test/__root.ts +3 -0
- package/file/tsconfig.json +5 -0
- package/file/tsdx/tsconfig.json.tpl +7 -0
- package/file/ws-root/jest-preset.js +32 -3
- package/file/ws-root/jest.config.js +3 -2
- package/index.d.ts +25 -0
- package/index.js +25 -0
- package/index.js.map +1 -1
- package/lib/const.d.ts +57 -3
- package/lib/const.js +81 -8
- package/lib/const.js.map +1 -1
- package/lib/copyStaticFiles.d.ts +50 -0
- package/lib/copyStaticFiles.js +48 -0
- package/lib/copyStaticFiles.js.map +1 -1
- package/lib/copyStaticFilesEntry.d.ts +50 -0
- package/lib/copyStaticFilesEntry.js +48 -0
- package/lib/copyStaticFilesEntry.js.map +1 -1
- package/lib/getRowOfStaticFilesMapArray.d.ts +40 -0
- package/lib/getRowOfStaticFilesMapArray.js +32 -0
- package/lib/getRowOfStaticFilesMapArray.js.map +1 -1
- package/lib/getStaticFile.d.ts +42 -0
- package/lib/getStaticFile.js +34 -0
- package/lib/getStaticFile.js.map +1 -1
- package/lib/parseStaticMap.d.ts +39 -0
- package/lib/parseStaticMap.js +7 -0
- package/lib/parseStaticMap.js.map +1 -1
- package/lib/reMapStaticFilesMapArray.d.ts +39 -0
- package/lib/reMapStaticFilesMapArray.js +36 -0
- package/lib/reMapStaticFilesMapArray.js.map +1 -1
- package/lib/replaceTargetOfStaticFilesMapArrayEntry.d.ts +33 -0
- package/lib/replaceTargetOfStaticFilesMapArrayEntry.js +25 -0
- package/lib/replaceTargetOfStaticFilesMapArrayEntry.js.map +1 -1
- package/lib/root/getRootCopyStaticFiles.d.ts +54 -0
- package/lib/root/getRootCopyStaticFiles.js +47 -0
- package/lib/root/getRootCopyStaticFiles.js.map +1 -1
- package/lib/types.d.ts +73 -0
- package/lib/types.js.map +1 -1
- package/lib/ws/wsCopyStaticFiles.d.ts +50 -0
- package/lib/ws/wsCopyStaticFiles.js +50 -0
- package/lib/ws/wsCopyStaticFiles.js.map +1 -1
- package/package.json +3 -3
- package/file/github/workflows/linter.yml +0 -57
- package/file/node-version +0 -1
- package/file/tsdx/index.cjs +0 -5
- package/file/tsdx/index.cjs.map +0 -1
- package/file/tsdx/index.d.cts +0 -2
- package/file/ws-root/__root_ws.d.ts +0 -2
- package/file/ws-root/__root_ws.js +0 -7
- package/file/ws-root/__root_ws.js.map +0 -1
- /package/file/{browserslistrc → ws-root/browserslistrc} +0 -0
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRowOfStaticFilesMapArray = getRowOfStaticFilesMapArray;
|
|
4
4
|
const parseStaticMap_1 = require("./parseStaticMap");
|
|
5
|
+
/**
|
|
6
|
+
* Get a specific row from static files map array / 從靜態檔案映射陣列獲取特定行
|
|
7
|
+
*
|
|
8
|
+
* Retrieves a specific entry from the static files map based on the target file key.
|
|
9
|
+
* 根據目標檔案鍵從靜態檔案映射中檢索特定條目。
|
|
10
|
+
*
|
|
11
|
+
* @template T - The static files map type / 靜態檔案映射類型
|
|
12
|
+
* @template K - The target file key type / 目標檔案鍵類型
|
|
13
|
+
*
|
|
14
|
+
* @param file_map - The static files map (array or record format) / 靜態檔案映射(陣列或記錄格式)
|
|
15
|
+
* @param key - The target file key to search for / 要搜尋的目標檔案鍵
|
|
16
|
+
*
|
|
17
|
+
* @returns The matching entry or undefined if not found / 匹配的條目,如果未找到則返回 undefined
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { getRowOfStaticFilesMapArray } from '@yarn-tool/static-file';
|
|
22
|
+
* import { defaultCopyStaticFiles } from '@yarn-tool/static-file/lib/const';
|
|
23
|
+
*
|
|
24
|
+
* // Get the entry for .gitignore
|
|
25
|
+
* // 獲取 .gitignore 的條目
|
|
26
|
+
* const entry = getRowOfStaticFilesMapArray(defaultCopyStaticFiles, '.gitignore');
|
|
27
|
+
* // Returns: ['.gitignore', 'file/gitignore']
|
|
28
|
+
* // 返回:['.gitignore', 'file/gitignore']
|
|
29
|
+
*
|
|
30
|
+
* // Get the entry for tsconfig.json.tpl
|
|
31
|
+
* // 獲取 tsconfig.json.tpl 的條目
|
|
32
|
+
* const tsconfigEntry = getRowOfStaticFilesMapArray(defaultCopyStaticFiles, 'tsconfig.json.tpl');
|
|
33
|
+
* // Returns: ['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json']
|
|
34
|
+
* // 返回:['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json']
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
5
37
|
function getRowOfStaticFilesMapArray(file_map, key) {
|
|
6
38
|
return (0, parseStaticMap_1.parseStaticMap)(file_map).find(a => a[0] === key);
|
|
7
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRowOfStaticFilesMapArray.js","sourceRoot":"","sources":["getRowOfStaticFilesMapArray.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"getRowOfStaticFilesMapArray.js","sourceRoot":"","sources":["getRowOfStaticFilesMapArray.ts"],"names":[],"mappings":";;AAkDA,kEAGC;AArCD,qDAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,2BAA2B,CAA+D,QAAW,EAAE,GAAM;IAE5H,OAAO,IAAA,+BAAc,EAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAiC,CAAA;AACxF,CAAC","sourcesContent":["/**\n * Get row from static files map array / 從靜態檔案映射陣列獲取行\n *\n * This module provides a function to retrieve a specific entry from a static files map.\n * 此模組提供從靜態檔案映射中檢索特定條目的函數。\n *\n * @module getRowOfStaticFilesMapArray\n */\nimport {\n\tIStaticFiles,\n\tIStaticFilesID,\n\tIStaticFilesKey,\n\tIStaticFilesMapArray,\n\tIStaticFilesMapArrayEntry,\n\tIStaticFilesMapRecord,\n} from './types';\nimport { parseStaticMap } from './parseStaticMap';\n\n/**\n * Get a specific row from static files map array / 從靜態檔案映射陣列獲取特定行\n *\n * Retrieves a specific entry from the static files map based on the target file key.\n * 根據目標檔案鍵從靜態檔案映射中檢索特定條目。\n *\n * @template T - The static files map type / 靜態檔案映射類型\n * @template K - The target file key type / 目標檔案鍵類型\n *\n * @param file_map - The static files map (array or record format) / 靜態檔案映射(陣列或記錄格式)\n * @param key - The target file key to search for / 要搜尋的目標檔案鍵\n *\n * @returns The matching entry or undefined if not found / 匹配的條目,如果未找到則返回 undefined\n *\n * @example\n * ```typescript\n * import { getRowOfStaticFilesMapArray } from '@yarn-tool/static-file';\n * import { defaultCopyStaticFiles } from '@yarn-tool/static-file/lib/const';\n *\n * // Get the entry for .gitignore\n * // 獲取 .gitignore 的條目\n * const entry = getRowOfStaticFilesMapArray(defaultCopyStaticFiles, '.gitignore');\n * // Returns: ['.gitignore', 'file/gitignore']\n * // 返回:['.gitignore', 'file/gitignore']\n *\n * // Get the entry for tsconfig.json.tpl\n * // 獲取 tsconfig.json.tpl 的條目\n * const tsconfigEntry = getRowOfStaticFilesMapArray(defaultCopyStaticFiles, 'tsconfig.json.tpl');\n * // Returns: ['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json']\n * // 返回:['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json']\n * ```\n */\nexport function getRowOfStaticFilesMapArray<T extends IStaticFiles<string>, K extends IStaticFilesKey<T>>(file_map: T, key: K)\n{\n\treturn parseStaticMap(file_map).find(a => a[0] === key) as IStaticFilesMapArrayEntry<K>\n}\n"]}
|
package/lib/getStaticFile.d.ts
CHANGED
|
@@ -1,2 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get static file entry / 獲取靜態檔案條目
|
|
3
|
+
*
|
|
4
|
+
* This module provides a convenience function to retrieve a static file entry.
|
|
5
|
+
* 此模組提供獲取靜態檔案條目的便利函數。
|
|
6
|
+
*
|
|
7
|
+
* @module getStaticFile
|
|
8
|
+
*/
|
|
1
9
|
import { ICopyStaticFilesOptions } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Get a static file entry by file ID / 根據檔案 ID 獲取靜態檔案條目
|
|
12
|
+
*
|
|
13
|
+
* Retrieves the static file entry for a given file ID from the file map.
|
|
14
|
+
* 從檔案映射中根據給定的檔案 ID 檢索靜態檔案條目。
|
|
15
|
+
*
|
|
16
|
+
* @template K - The file ID type / 檔案 ID 類型
|
|
17
|
+
*
|
|
18
|
+
* @param file_id - The file ID to look up / 要查找的檔案 ID
|
|
19
|
+
* @param options - Optional configuration / 可選配置
|
|
20
|
+
* @param options.file_map - Custom file map (defaults to defaultCopyStaticFiles) / 自訂檔案映射(預設為 defaultCopyStaticFiles)
|
|
21
|
+
*
|
|
22
|
+
* @returns The static file entry or undefined if not found / 靜態檔案條目,如果未找到則返回 undefined
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { getStaticFile } from '@yarn-tool/static-file';
|
|
27
|
+
*
|
|
28
|
+
* // Get the .gitignore entry from default file map
|
|
29
|
+
* // 從預設檔案映射獲取 .gitignore 條目
|
|
30
|
+
* const entry = getStaticFile('.gitignore');
|
|
31
|
+
* // Returns: ['.gitignore', 'file/gitignore']
|
|
32
|
+
* // 返回:['.gitignore', 'file/gitignore']
|
|
33
|
+
*
|
|
34
|
+
* // Get entry from custom file map
|
|
35
|
+
* // 從自訂檔案映射獲取條目
|
|
36
|
+
* const customEntry = getStaticFile('README.md', {
|
|
37
|
+
* file_map: [
|
|
38
|
+
* ['README.md', 'file/README.md'],
|
|
39
|
+
* ['.gitignore', 'file/gitignore']
|
|
40
|
+
* ]
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
2
44
|
export declare function getStaticFile<K extends string>(file_id: K, options?: Pick<ICopyStaticFilesOptions<K>, 'file_map'>): import("./types").IStaticFilesMapArrayEntry<K>;
|
package/lib/getStaticFile.js
CHANGED
|
@@ -3,6 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getStaticFile = getStaticFile;
|
|
4
4
|
const const_1 = require("./const");
|
|
5
5
|
const getRowOfStaticFilesMapArray_1 = require("./getRowOfStaticFilesMapArray");
|
|
6
|
+
/**
|
|
7
|
+
* Get a static file entry by file ID / 根據檔案 ID 獲取靜態檔案條目
|
|
8
|
+
*
|
|
9
|
+
* Retrieves the static file entry for a given file ID from the file map.
|
|
10
|
+
* 從檔案映射中根據給定的檔案 ID 檢索靜態檔案條目。
|
|
11
|
+
*
|
|
12
|
+
* @template K - The file ID type / 檔案 ID 類型
|
|
13
|
+
*
|
|
14
|
+
* @param file_id - The file ID to look up / 要查找的檔案 ID
|
|
15
|
+
* @param options - Optional configuration / 可選配置
|
|
16
|
+
* @param options.file_map - Custom file map (defaults to defaultCopyStaticFiles) / 自訂檔案映射(預設為 defaultCopyStaticFiles)
|
|
17
|
+
*
|
|
18
|
+
* @returns The static file entry or undefined if not found / 靜態檔案條目,如果未找到則返回 undefined
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { getStaticFile } from '@yarn-tool/static-file';
|
|
23
|
+
*
|
|
24
|
+
* // Get the .gitignore entry from default file map
|
|
25
|
+
* // 從預設檔案映射獲取 .gitignore 條目
|
|
26
|
+
* const entry = getStaticFile('.gitignore');
|
|
27
|
+
* // Returns: ['.gitignore', 'file/gitignore']
|
|
28
|
+
* // 返回:['.gitignore', 'file/gitignore']
|
|
29
|
+
*
|
|
30
|
+
* // Get entry from custom file map
|
|
31
|
+
* // 從自訂檔案映射獲取條目
|
|
32
|
+
* const customEntry = getStaticFile('README.md', {
|
|
33
|
+
* file_map: [
|
|
34
|
+
* ['README.md', 'file/README.md'],
|
|
35
|
+
* ['.gitignore', 'file/gitignore']
|
|
36
|
+
* ]
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
6
40
|
function getStaticFile(file_id, options) {
|
|
7
41
|
return (0, getRowOfStaticFilesMapArray_1.getRowOfStaticFilesMapArray)((options === null || options === void 0 ? void 0 : options.file_map) || const_1.defaultCopyStaticFiles, file_id);
|
|
8
42
|
}
|
package/lib/getStaticFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStaticFile.js","sourceRoot":"","sources":["getStaticFile.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"getStaticFile.js","sourceRoot":"","sources":["getStaticFile.ts"],"names":[],"mappings":";;AA+CA,sCAKC;AA1CD,mCAAiD;AACjD,+EAA4E;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,aAAa,CAAmB,OAAU,EACzD,OAAsD;IAGtD,OAAO,IAAA,yDAA2B,EAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,8BAAsB,EAAE,OAAO,CAAC,CAAA;AACzF,CAAC","sourcesContent":["/**\n * Get static file entry / 獲取靜態檔案條目\n *\n * This module provides a convenience function to retrieve a static file entry.\n * 此模組提供獲取靜態檔案條目的便利函數。\n *\n * @module getStaticFile\n */\nimport { ICopyStaticFilesOptions, IStaticFilesMapArray } from './types';\nimport { parseStaticMap } from './parseStaticMap';\nimport { defaultCopyStaticFiles } from './const';\nimport { getRowOfStaticFilesMapArray } from './getRowOfStaticFilesMapArray';\n\n/**\n * Get a static file entry by file ID / 根據檔案 ID 獲取靜態檔案條目\n *\n * Retrieves the static file entry for a given file ID from the file map.\n * 從檔案映射中根據給定的檔案 ID 檢索靜態檔案條目。\n *\n * @template K - The file ID type / 檔案 ID 類型\n *\n * @param file_id - The file ID to look up / 要查找的檔案 ID\n * @param options - Optional configuration / 可選配置\n * @param options.file_map - Custom file map (defaults to defaultCopyStaticFiles) / 自訂檔案映射(預設為 defaultCopyStaticFiles)\n *\n * @returns The static file entry or undefined if not found / 靜態檔案條目,如果未找到則返回 undefined\n *\n * @example\n * ```typescript\n * import { getStaticFile } from '@yarn-tool/static-file';\n *\n * // Get the .gitignore entry from default file map\n * // 從預設檔案映射獲取 .gitignore 條目\n * const entry = getStaticFile('.gitignore');\n * // Returns: ['.gitignore', 'file/gitignore']\n * // 返回:['.gitignore', 'file/gitignore']\n *\n * // Get entry from custom file map\n * // 從自訂檔案映射獲取條目\n * const customEntry = getStaticFile('README.md', {\n * file_map: [\n * ['README.md', 'file/README.md'],\n * ['.gitignore', 'file/gitignore']\n * ]\n * });\n * ```\n */\nexport function getStaticFile<K extends string>(file_id: K,\n\toptions?: Pick<ICopyStaticFilesOptions<K>, 'file_map'>,\n)\n{\n\treturn getRowOfStaticFilesMapArray(options?.file_map || defaultCopyStaticFiles, file_id)\n}\n"]}
|
package/lib/parseStaticMap.d.ts
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse static file map / 解析靜態檔案映射
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to parse different static file map formats
|
|
5
|
+
* into a unified array format.
|
|
6
|
+
* 此模組提供將不同靜態檔案映射格式解析為統一陣列格式的函數。
|
|
7
|
+
*
|
|
8
|
+
* @module parseStaticMap
|
|
9
|
+
*/
|
|
1
10
|
import { IStaticFiles, IStaticFilesID, IStaticFilesMapArray, IStaticFilesMapRecord } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Parse static file map from array format / 從陣列格式解析靜態檔案映射
|
|
13
|
+
*
|
|
14
|
+
* Converts an array-based file map to a normalized array format.
|
|
15
|
+
* 將基於陣列的檔案映射轉換為標準化陣列格式。
|
|
16
|
+
*
|
|
17
|
+
* @template K - The target file path type / 目標檔案路徑類型
|
|
18
|
+
* @param file_map - The array-based file map / 基於陣列的檔案映射
|
|
19
|
+
* @returns Normalized array of file map entries / 標準化的檔案映射條目陣列
|
|
20
|
+
*/
|
|
2
21
|
export declare function parseStaticMap<K extends string>(file_map: IStaticFilesMapArray<K>): IStaticFilesMapArray<K | IStaticFilesID>;
|
|
22
|
+
/**
|
|
23
|
+
* Parse static file map from record format / 從記錄格式解析靜態檔案映射
|
|
24
|
+
*
|
|
25
|
+
* Converts a record-based file map to a normalized array format.
|
|
26
|
+
* 將基於記錄的檔案映射轉換為標準化陣列格式。
|
|
27
|
+
*
|
|
28
|
+
* @template K - The target file path type / 目標檔案路徑類型
|
|
29
|
+
* @param file_map - The record-based file map / 基於記錄的檔案映射
|
|
30
|
+
* @returns Normalized array of file map entries / 標準化的檔案映射條目陣列
|
|
31
|
+
*/
|
|
3
32
|
export declare function parseStaticMap<K extends string>(file_map: IStaticFilesMapRecord<K>): IStaticFilesMapArray<K | IStaticFilesID>;
|
|
33
|
+
/**
|
|
34
|
+
* Parse static file map from any supported format / 從任何支援的格式解析靜態檔案映射
|
|
35
|
+
*
|
|
36
|
+
* Unified function that handles both array and record formats.
|
|
37
|
+
* 處理陣列和記錄格式的統一函數。
|
|
38
|
+
*
|
|
39
|
+
* @template K - The target file path type / 目標檔案路徑類型
|
|
40
|
+
* @param file_map - The file map in any supported format / 任何支援格式的檔案映射
|
|
41
|
+
* @returns Normalized array of file map entries / 標準化的檔案映射條目陣列
|
|
42
|
+
*/
|
|
4
43
|
export declare function parseStaticMap<K extends string>(file_map: IStaticFiles<K>): IStaticFilesMapArray<K | IStaticFilesID>;
|
package/lib/parseStaticMap.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseStaticMap = parseStaticMap;
|
|
4
|
+
/**
|
|
5
|
+
* Implementation of parseStaticMap / parseStaticMap 的實現
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
4
8
|
function parseStaticMap(file_map) {
|
|
5
9
|
let ls;
|
|
10
|
+
// Handle array format / 處理陣列格式
|
|
6
11
|
if (Array.isArray(file_map)) {
|
|
7
12
|
ls = Object.values(file_map);
|
|
8
13
|
}
|
|
14
|
+
// Handle record format / 處理記錄格式
|
|
9
15
|
else {
|
|
10
16
|
// @ts-ignore
|
|
11
17
|
ls = Object.entries(file_map);
|
|
12
18
|
}
|
|
19
|
+
// Filter out invalid entries / 過濾無效條目
|
|
13
20
|
return ls.filter(v => v && Array.isArray(v) && v.length > 1);
|
|
14
21
|
}
|
|
15
22
|
//# sourceMappingURL=parseStaticMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseStaticMap.js","sourceRoot":"","sources":["parseStaticMap.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"parseStaticMap.js","sourceRoot":"","sources":["parseStaticMap.ts"],"names":[],"mappings":";;AAyDA,wCAkBC;AAtBD;;;GAGG;AACH,SAAgB,cAAc,CAAmB,QAAyB;IAEzE,IAAI,EAA2B,CAAC;IAEhC,+BAA+B;IAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAC3B,CAAC;QACA,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC7B,CAAC;IACD,gCAAgC;SAEhC,CAAC;QACA,aAAa;QACb,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC9B,CAAC;IAED,sCAAsC;IACtC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["/**\n * Parse static file map / 解析靜態檔案映射\n *\n * This module provides functions to parse different static file map formats\n * into a unified array format.\n * 此模組提供將不同靜態檔案映射格式解析為統一陣列格式的函數。\n *\n * @module parseStaticMap\n */\nimport {\n\tIStaticFiles,\n\tIStaticFilesID,\n\tIStaticFilesMapArray,\n\tIStaticFilesMapRecord,\n\tIStaticFilesMapArrayEntry,\n} from './types';\n\n/**\n * Parse static file map from array format / 從陣列格式解析靜態檔案映射\n *\n * Converts an array-based file map to a normalized array format.\n * 將基於陣列的檔案映射轉換為標準化陣列格式。\n *\n * @template K - The target file path type / 目標檔案路徑類型\n * @param file_map - The array-based file map / 基於陣列的檔案映射\n * @returns Normalized array of file map entries / 標準化的檔案映射條目陣列\n */\nexport function parseStaticMap<K extends string>(file_map: IStaticFilesMapArray<K>): IStaticFilesMapArray<K | IStaticFilesID>\n\n/**\n * Parse static file map from record format / 從記錄格式解析靜態檔案映射\n *\n * Converts a record-based file map to a normalized array format.\n * 將基於記錄的檔案映射轉換為標準化陣列格式。\n *\n * @template K - The target file path type / 目標檔案路徑類型\n * @param file_map - The record-based file map / 基於記錄的檔案映射\n * @returns Normalized array of file map entries / 標準化的檔案映射條目陣列\n */\nexport function parseStaticMap<K extends string>(file_map: IStaticFilesMapRecord<K>): IStaticFilesMapArray<K | IStaticFilesID>\n\n/**\n * Parse static file map from any supported format / 從任何支援的格式解析靜態檔案映射\n *\n * Unified function that handles both array and record formats.\n * 處理陣列和記錄格式的統一函數。\n *\n * @template K - The target file path type / 目標檔案路徑類型\n * @param file_map - The file map in any supported format / 任何支援格式的檔案映射\n * @returns Normalized array of file map entries / 標準化的檔案映射條目陣列\n */\nexport function parseStaticMap<K extends string>(file_map: IStaticFiles<K>): IStaticFilesMapArray<K | IStaticFilesID>\n\n/**\n * Implementation of parseStaticMap / parseStaticMap 的實現\n * @internal\n */\nexport function parseStaticMap<K extends string>(file_map: IStaticFiles<K>): IStaticFilesMapArray<K | IStaticFilesID>\n{\n\tlet ls: IStaticFilesMapArray<K>;\n\n\t// Handle array format / 處理陣列格式\n\tif (Array.isArray(file_map))\n\t{\n\t\tls = Object.values(file_map)\n\t}\n\t// Handle record format / 處理記錄格式\n\telse\n\t{\n\t\t// @ts-ignore\n\t\tls = Object.entries(file_map)\n\t}\n\n\t// Filter out invalid entries / 過濾無效條目\n\treturn ls.filter(v => v && Array.isArray(v) && v.length > 1);\n}\n"]}
|
|
@@ -1,2 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remap static files map array / 重新映射靜態檔案映射陣列
|
|
3
|
+
*
|
|
4
|
+
* This module provides a function to remap target file paths in a static files map.
|
|
5
|
+
* 此模組提供重新映射靜態檔案映射中目標檔案路徑的函數。
|
|
6
|
+
*
|
|
7
|
+
* @module reMapStaticFilesMapArray
|
|
8
|
+
*/
|
|
1
9
|
import { IStaticFiles, IStaticFilesKey, IStaticFilesMapArray } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Remap static files map array with new target paths / 使用新目標路徑重新映射靜態檔案映射陣列
|
|
12
|
+
*
|
|
13
|
+
* Creates a new static files map array by replacing target file paths according to the provided mapping.
|
|
14
|
+
* 根據提供的映射關係,通過替換目標檔案路徑來創建新的靜態檔案映射陣列。
|
|
15
|
+
*
|
|
16
|
+
* This is useful when you want to copy the same static file to different target locations.
|
|
17
|
+
* 當您想將同一個靜態檔案複製到不同的目標位置時,這非常有用。
|
|
18
|
+
*
|
|
19
|
+
* @template T - The source static files map type / 來源靜態檔案映射類型
|
|
20
|
+
* @template N - The new target file path type / 新目標檔案路徑類型
|
|
21
|
+
*
|
|
22
|
+
* @param file_map - The source static files map / 來源靜態檔案映射
|
|
23
|
+
* @param replaceMap - A record mapping new target paths to old target paths / 將新路徑映射到舊路徑的記錄
|
|
24
|
+
*
|
|
25
|
+
* @returns A new static files map array with remapped entries / 重新映射條目的新靜態檔案映射陣列
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { reMapStaticFilesMapArray } from '@yarn-tool/static-file';
|
|
30
|
+
* import { defaultCopyStaticFiles } from '@yarn-tool/static-file/lib/const';
|
|
31
|
+
*
|
|
32
|
+
* // Remap tsconfig.json.tpl to tsconfig.json
|
|
33
|
+
* // 將 tsconfig.json.tpl 重新映射為 tsconfig.json
|
|
34
|
+
* const remapped = reMapStaticFilesMapArray(defaultCopyStaticFiles, {
|
|
35
|
+
* 'tsconfig.json': 'tsconfig.json.tpl'
|
|
36
|
+
* });
|
|
37
|
+
* // The result will have an entry for 'tsconfig.json' instead of 'tsconfig.json.tpl'
|
|
38
|
+
* // 結果將包含 'tsconfig.json' 的條目,而不是 'tsconfig.json.tpl'
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
2
41
|
export declare function reMapStaticFilesMapArray<T extends IStaticFiles<string>, N extends string>(file_map: T, replaceMap: Record<N, IStaticFilesKey<T>>): IStaticFilesMapArray<IStaticFilesKey<T> | N>;
|
|
@@ -5,16 +5,52 @@ const parseStaticMap_1 = require("./parseStaticMap");
|
|
|
5
5
|
const getRowOfStaticFilesMapArray_1 = require("./getRowOfStaticFilesMapArray");
|
|
6
6
|
const replaceTargetOfStaticFilesMapArrayEntry_1 = require("./replaceTargetOfStaticFilesMapArrayEntry");
|
|
7
7
|
const array_hyper_unique_1 = require("array-hyper-unique");
|
|
8
|
+
/**
|
|
9
|
+
* Remap static files map array with new target paths / 使用新目標路徑重新映射靜態檔案映射陣列
|
|
10
|
+
*
|
|
11
|
+
* Creates a new static files map array by replacing target file paths according to the provided mapping.
|
|
12
|
+
* 根據提供的映射關係,通過替換目標檔案路徑來創建新的靜態檔案映射陣列。
|
|
13
|
+
*
|
|
14
|
+
* This is useful when you want to copy the same static file to different target locations.
|
|
15
|
+
* 當您想將同一個靜態檔案複製到不同的目標位置時,這非常有用。
|
|
16
|
+
*
|
|
17
|
+
* @template T - The source static files map type / 來源靜態檔案映射類型
|
|
18
|
+
* @template N - The new target file path type / 新目標檔案路徑類型
|
|
19
|
+
*
|
|
20
|
+
* @param file_map - The source static files map / 來源靜態檔案映射
|
|
21
|
+
* @param replaceMap - A record mapping new target paths to old target paths / 將新路徑映射到舊路徑的記錄
|
|
22
|
+
*
|
|
23
|
+
* @returns A new static files map array with remapped entries / 重新映射條目的新靜態檔案映射陣列
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { reMapStaticFilesMapArray } from '@yarn-tool/static-file';
|
|
28
|
+
* import { defaultCopyStaticFiles } from '@yarn-tool/static-file/lib/const';
|
|
29
|
+
*
|
|
30
|
+
* // Remap tsconfig.json.tpl to tsconfig.json
|
|
31
|
+
* // 將 tsconfig.json.tpl 重新映射為 tsconfig.json
|
|
32
|
+
* const remapped = reMapStaticFilesMapArray(defaultCopyStaticFiles, {
|
|
33
|
+
* 'tsconfig.json': 'tsconfig.json.tpl'
|
|
34
|
+
* });
|
|
35
|
+
* // The result will have an entry for 'tsconfig.json' instead of 'tsconfig.json.tpl'
|
|
36
|
+
* // 結果將包含 'tsconfig.json' 的條目,而不是 'tsconfig.json.tpl'
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
8
39
|
function reMapStaticFilesMapArray(file_map, replaceMap) {
|
|
40
|
+
// Parse the source file map / 解析來源檔案映射
|
|
9
41
|
const ls = (0, parseStaticMap_1.parseStaticMap)(file_map);
|
|
42
|
+
// Process each replacement mapping / 處理每個替換映射
|
|
10
43
|
const arr = Object.entries(replaceMap)
|
|
11
44
|
.reduce((arr, [targetNew, targetOld]) => {
|
|
45
|
+
// Find the original entry / 查找原始條目
|
|
12
46
|
let old = (0, getRowOfStaticFilesMapArray_1.getRowOfStaticFilesMapArray)(ls, targetOld);
|
|
47
|
+
// If entry exists, create a new entry with the new target path / 如果條目存在,使用新目標路徑創建新條目
|
|
13
48
|
if (old === null || old === void 0 ? void 0 : old.length) {
|
|
14
49
|
arr.push((0, replaceTargetOfStaticFilesMapArrayEntry_1.replaceTargetOfStaticFilesMapArrayEntry)(old, targetNew));
|
|
15
50
|
}
|
|
16
51
|
return arr;
|
|
17
52
|
}, []);
|
|
53
|
+
// Combine remapped entries with original entries and remove duplicates / 合併重新映射的條目與原始條目並移除重複項
|
|
18
54
|
return (0, array_hyper_unique_1.array_unique_overwrite)(arr.concat(ls));
|
|
19
55
|
}
|
|
20
56
|
//# sourceMappingURL=reMapStaticFilesMapArray.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reMapStaticFilesMapArray.js","sourceRoot":"","sources":["reMapStaticFilesMapArray.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"reMapStaticFilesMapArray.js","sourceRoot":"","sources":["reMapStaticFilesMapArray.ts"],"names":[],"mappings":";;AA6CA,4DA2BC;AA/DD,qDAAkD;AAClD,+EAA4E;AAC5E,uGAAoG;AACpG,2DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,SAAgB,wBAAwB,CAAmD,QAAW,EACrG,UAAyC;IAGzC,uCAAuC;IACvC,MAAM,EAAE,GAAG,IAAA,+BAAc,EAAC,QAAQ,CAAC,CAAC;IAEpC,8CAA8C;IAC9C,MAAM,GAAG,GAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAA+B;SACnE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,EAAE;QAGvC,mCAAmC;QACnC,IAAI,GAAG,GAAG,IAAA,yDAA2B,EAAC,EAAE,EAAE,SAAS,CAAC,CAAA;QAEpD,qFAAqF;QACrF,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,EACf,CAAC;YACA,GAAG,CAAC,IAAI,CAAC,IAAA,iFAAuC,EAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAA;QAClE,CAAC;QAED,OAAO,GAAG,CAAA;IACX,CAAC,EAAE,EAA6B,CAAC,CACjC;IAED,8FAA8F;IAC9F,OAAO,IAAA,2CAAsB,EAAC,GAAG,CAAC,MAAM,CAAC,EAAS,CAAC,CAAiD,CAAA;AACrG,CAAC","sourcesContent":["/**\n * Remap static files map array / 重新映射靜態檔案映射陣列\n *\n * This module provides a function to remap target file paths in a static files map.\n * 此模組提供重新映射靜態檔案映射中目標檔案路徑的函數。\n *\n * @module reMapStaticFilesMapArray\n */\nimport { IStaticFiles, IStaticFilesKey, IStaticFilesMapArray, IStaticFilesMapArrayEntry } from './types';\nimport { parseStaticMap } from './parseStaticMap';\nimport { getRowOfStaticFilesMapArray } from './getRowOfStaticFilesMapArray';\nimport { replaceTargetOfStaticFilesMapArrayEntry } from './replaceTargetOfStaticFilesMapArrayEntry';\nimport { array_unique_overwrite } from 'array-hyper-unique';\n\n/**\n * Remap static files map array with new target paths / 使用新目標路徑重新映射靜態檔案映射陣列\n *\n * Creates a new static files map array by replacing target file paths according to the provided mapping.\n * 根據提供的映射關係,通過替換目標檔案路徑來創建新的靜態檔案映射陣列。\n *\n * This is useful when you want to copy the same static file to different target locations.\n * 當您想將同一個靜態檔案複製到不同的目標位置時,這非常有用。\n *\n * @template T - The source static files map type / 來源靜態檔案映射類型\n * @template N - The new target file path type / 新目標檔案路徑類型\n *\n * @param file_map - The source static files map / 來源靜態檔案映射\n * @param replaceMap - A record mapping new target paths to old target paths / 將新路徑映射到舊路徑的記錄\n *\n * @returns A new static files map array with remapped entries / 重新映射條目的新靜態檔案映射陣列\n *\n * @example\n * ```typescript\n * import { reMapStaticFilesMapArray } from '@yarn-tool/static-file';\n * import { defaultCopyStaticFiles } from '@yarn-tool/static-file/lib/const';\n *\n * // Remap tsconfig.json.tpl to tsconfig.json\n * // 將 tsconfig.json.tpl 重新映射為 tsconfig.json\n * const remapped = reMapStaticFilesMapArray(defaultCopyStaticFiles, {\n * 'tsconfig.json': 'tsconfig.json.tpl'\n * });\n * // The result will have an entry for 'tsconfig.json' instead of 'tsconfig.json.tpl'\n * // 結果將包含 'tsconfig.json' 的條目,而不是 'tsconfig.json.tpl'\n * ```\n */\nexport function reMapStaticFilesMapArray<T extends IStaticFiles<string>, N extends string>(file_map: T,\n\treplaceMap: Record<N, IStaticFilesKey<T>>,\n)\n{\n\t// Parse the source file map / 解析來源檔案映射\n\tconst ls = parseStaticMap(file_map);\n\n\t// Process each replacement mapping / 處理每個替換映射\n\tconst arr = (Object.entries(replaceMap) as [N, IStaticFilesKey<T>][])\n\t\t.reduce((arr, [targetNew, targetOld]) =>\n\t\t{\n\n\t\t\t// Find the original entry / 查找原始條目\n\t\t\tlet old = getRowOfStaticFilesMapArray(ls, targetOld)\n\n\t\t\t// If entry exists, create a new entry with the new target path / 如果條目存在,使用新目標路徑創建新條目\n\t\t\tif (old?.length)\n\t\t\t{\n\t\t\t\tarr.push(replaceTargetOfStaticFilesMapArrayEntry(old, targetNew))\n\t\t\t}\n\n\t\t\treturn arr\n\t\t}, [] as IStaticFilesMapArray<N>)\n\t;\n\n\t// Combine remapped entries with original entries and remove duplicates / 合併重新映射的條目與原始條目並移除重複項\n\treturn array_unique_overwrite(arr.concat(ls as any)) as IStaticFilesMapArray<IStaticFilesKey<T> | N>\n}\n"]}
|
|
@@ -1,2 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace target of static files map array entry / 替換靜態檔案映射陣列條目的目標
|
|
3
|
+
*
|
|
4
|
+
* This module provides a function to replace the target file path in an entry.
|
|
5
|
+
* 此模組提供替換條目中目標檔案路徑的函數。
|
|
6
|
+
*
|
|
7
|
+
* @module replaceTargetOfStaticFilesMapArrayEntry
|
|
8
|
+
*/
|
|
1
9
|
import { IStaticFilesMapArrayEntry } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Replace the target file path in a static files map entry / 替換靜態檔案映射條目中的目標檔案路徑
|
|
12
|
+
*
|
|
13
|
+
* Creates a new entry with the same source file but a different target file path.
|
|
14
|
+
* 創建一個具有相同來源檔案但不同目標檔案路徑的新條目。
|
|
15
|
+
*
|
|
16
|
+
* @template K - The new target file path type / 新目標檔案路徑類型
|
|
17
|
+
*
|
|
18
|
+
* @param entry - The original entry / 原始條目
|
|
19
|
+
* @param targetFile - The new target file path / 新目標檔案路徑
|
|
20
|
+
*
|
|
21
|
+
* @returns A new entry with the replaced target file path / 替換目標檔案路徑後的新條目
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { replaceTargetOfStaticFilesMapArrayEntry } from '@yarn-tool/static-file';
|
|
26
|
+
*
|
|
27
|
+
* // Replace target file path
|
|
28
|
+
* // 替換目標檔案路徑
|
|
29
|
+
* const original = ['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json'];
|
|
30
|
+
* const newEntry = replaceTargetOfStaticFilesMapArrayEntry(original, 'tsconfig.json');
|
|
31
|
+
* // Returns: ['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json']
|
|
32
|
+
* // 返回:['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json']
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
2
35
|
export declare function replaceTargetOfStaticFilesMapArrayEntry<K extends string>(entry: IStaticFilesMapArrayEntry<string>, targetFile: K): IStaticFilesMapArrayEntry<K>;
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replaceTargetOfStaticFilesMapArrayEntry = replaceTargetOfStaticFilesMapArrayEntry;
|
|
4
|
+
/**
|
|
5
|
+
* Replace the target file path in a static files map entry / 替換靜態檔案映射條目中的目標檔案路徑
|
|
6
|
+
*
|
|
7
|
+
* Creates a new entry with the same source file but a different target file path.
|
|
8
|
+
* 創建一個具有相同來源檔案但不同目標檔案路徑的新條目。
|
|
9
|
+
*
|
|
10
|
+
* @template K - The new target file path type / 新目標檔案路徑類型
|
|
11
|
+
*
|
|
12
|
+
* @param entry - The original entry / 原始條目
|
|
13
|
+
* @param targetFile - The new target file path / 新目標檔案路徑
|
|
14
|
+
*
|
|
15
|
+
* @returns A new entry with the replaced target file path / 替換目標檔案路徑後的新條目
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { replaceTargetOfStaticFilesMapArrayEntry } from '@yarn-tool/static-file';
|
|
20
|
+
*
|
|
21
|
+
* // Replace target file path
|
|
22
|
+
* // 替換目標檔案路徑
|
|
23
|
+
* const original = ['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json'];
|
|
24
|
+
* const newEntry = replaceTargetOfStaticFilesMapArrayEntry(original, 'tsconfig.json');
|
|
25
|
+
* // Returns: ['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json']
|
|
26
|
+
* // 返回:['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json']
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
4
29
|
function replaceTargetOfStaticFilesMapArrayEntry(entry, targetFile) {
|
|
5
30
|
return [targetFile, ...entry.slice(1)];
|
|
6
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replaceTargetOfStaticFilesMapArrayEntry.js","sourceRoot":"","sources":["replaceTargetOfStaticFilesMapArrayEntry.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"replaceTargetOfStaticFilesMapArrayEntry.js","sourceRoot":"","sources":["replaceTargetOfStaticFilesMapArrayEntry.ts"],"names":[],"mappings":";;AAmCA,0FAGC;AA5BD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,uCAAuC,CAAmB,KAAwC,EAAE,UAAa;IAEhI,OAAO,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAiC,CAAA;AACvE,CAAC","sourcesContent":["/**\n * Replace target of static files map array entry / 替換靜態檔案映射陣列條目的目標\n *\n * This module provides a function to replace the target file path in an entry.\n * 此模組提供替換條目中目標檔案路徑的函數。\n *\n * @module replaceTargetOfStaticFilesMapArrayEntry\n */\nimport { IStaticFilesMapArrayEntry } from './types';\n\n/**\n * Replace the target file path in a static files map entry / 替換靜態檔案映射條目中的目標檔案路徑\n *\n * Creates a new entry with the same source file but a different target file path.\n * 創建一個具有相同來源檔案但不同目標檔案路徑的新條目。\n *\n * @template K - The new target file path type / 新目標檔案路徑類型\n *\n * @param entry - The original entry / 原始條目\n * @param targetFile - The new target file path / 新目標檔案路徑\n *\n * @returns A new entry with the replaced target file path / 替換目標檔案路徑後的新條目\n *\n * @example\n * ```typescript\n * import { replaceTargetOfStaticFilesMapArrayEntry } from '@yarn-tool/static-file';\n *\n * // Replace target file path\n * // 替換目標檔案路徑\n * const original = ['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json'];\n * const newEntry = replaceTargetOfStaticFilesMapArrayEntry(original, 'tsconfig.json');\n * // Returns: ['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json']\n * // 返回:['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json']\n * ```\n */\nexport function replaceTargetOfStaticFilesMapArrayEntry<K extends string>(entry: IStaticFilesMapArrayEntry<string>, targetFile: K)\n{\n\treturn [targetFile, ...entry.slice(1)] as IStaticFilesMapArrayEntry<K>\n}\n"]}
|
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get root copy static files configuration / 獲取根目錄複製靜態檔案配置
|
|
3
|
+
*
|
|
4
|
+
* This module provides a function to determine the appropriate static files
|
|
5
|
+
* to copy based on the project root structure.
|
|
6
|
+
* 此模組提供根據專案根目錄結構確定要複製的適當靜態檔案的函數。
|
|
7
|
+
*
|
|
8
|
+
* @module getRootCopyStaticFiles
|
|
9
|
+
*/
|
|
1
10
|
import { IFindRootReturnType } from '@yarn-tool/find-root';
|
|
2
11
|
import { IStaticFilesMapArray } from '../types';
|
|
12
|
+
/**
|
|
13
|
+
* Get the appropriate static files map based on root data / 根據根目錄數據獲取適當的靜態檔案映射
|
|
14
|
+
*
|
|
15
|
+
* Determines which static files should be copied based on whether the current
|
|
16
|
+
* directory is the workspace root and whether it has workspaces.
|
|
17
|
+
* 根據當前目錄是否為工作區根目錄以及是否具有工作區,確定應複製哪些靜態檔案。
|
|
18
|
+
*
|
|
19
|
+
* @param rootData - Information about the project root / 關於專案根目錄的資訊
|
|
20
|
+
* @param rootData.isRoot - Whether the current directory is the workspace root / 當前目錄是否為工作區根目錄
|
|
21
|
+
* @param rootData.hasWorkspace - Whether the project has workspaces / 專案是否具有工作區
|
|
22
|
+
*
|
|
23
|
+
* @returns An array of static file entries to copy / 要複製的靜態檔案條目陣列
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { getRootCopyStaticFilesAuto } from '@yarn-tool/static-file';
|
|
28
|
+
*
|
|
29
|
+
* // For a workspace root with workspaces
|
|
30
|
+
* // 對於具有工作區的工作區根目錄
|
|
31
|
+
* const files1 = getRootCopyStaticFilesAuto({
|
|
32
|
+
* isRoot: true,
|
|
33
|
+
* hasWorkspace: true
|
|
34
|
+
* });
|
|
35
|
+
* // Returns only defaultCopyStaticFiles (not root-only files)
|
|
36
|
+
* // 僅返回 defaultCopyStaticFiles(不包含僅根目錄的檔案)
|
|
37
|
+
*
|
|
38
|
+
* // For a standalone project root
|
|
39
|
+
* // 對於獨立專案根目錄
|
|
40
|
+
* const files2 = getRootCopyStaticFilesAuto({
|
|
41
|
+
* isRoot: true,
|
|
42
|
+
* hasWorkspace: false
|
|
43
|
+
* });
|
|
44
|
+
* // Returns defaultCopyStaticFiles + defaultCopyStaticFilesRootOnly
|
|
45
|
+
* // 返回 defaultCopyStaticFiles + defaultCopyStaticFilesRootOnly
|
|
46
|
+
*
|
|
47
|
+
* // For a package within a workspace
|
|
48
|
+
* // 對於工作區內的套件
|
|
49
|
+
* const files3 = getRootCopyStaticFilesAuto({
|
|
50
|
+
* isRoot: false,
|
|
51
|
+
* hasWorkspace: true
|
|
52
|
+
* });
|
|
53
|
+
* // Returns only defaultCopyStaticFiles
|
|
54
|
+
* // 僅返回 defaultCopyStaticFiles
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
3
57
|
export declare function getRootCopyStaticFilesAuto(rootData: Pick<IFindRootReturnType, 'isRoot' | 'hasWorkspace'>): IStaticFilesMapArray<string>;
|
|
@@ -2,10 +2,57 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRootCopyStaticFilesAuto = getRootCopyStaticFilesAuto;
|
|
4
4
|
const const_1 = require("../const");
|
|
5
|
+
/**
|
|
6
|
+
* Get the appropriate static files map based on root data / 根據根目錄數據獲取適當的靜態檔案映射
|
|
7
|
+
*
|
|
8
|
+
* Determines which static files should be copied based on whether the current
|
|
9
|
+
* directory is the workspace root and whether it has workspaces.
|
|
10
|
+
* 根據當前目錄是否為工作區根目錄以及是否具有工作區,確定應複製哪些靜態檔案。
|
|
11
|
+
*
|
|
12
|
+
* @param rootData - Information about the project root / 關於專案根目錄的資訊
|
|
13
|
+
* @param rootData.isRoot - Whether the current directory is the workspace root / 當前目錄是否為工作區根目錄
|
|
14
|
+
* @param rootData.hasWorkspace - Whether the project has workspaces / 專案是否具有工作區
|
|
15
|
+
*
|
|
16
|
+
* @returns An array of static file entries to copy / 要複製的靜態檔案條目陣列
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { getRootCopyStaticFilesAuto } from '@yarn-tool/static-file';
|
|
21
|
+
*
|
|
22
|
+
* // For a workspace root with workspaces
|
|
23
|
+
* // 對於具有工作區的工作區根目錄
|
|
24
|
+
* const files1 = getRootCopyStaticFilesAuto({
|
|
25
|
+
* isRoot: true,
|
|
26
|
+
* hasWorkspace: true
|
|
27
|
+
* });
|
|
28
|
+
* // Returns only defaultCopyStaticFiles (not root-only files)
|
|
29
|
+
* // 僅返回 defaultCopyStaticFiles(不包含僅根目錄的檔案)
|
|
30
|
+
*
|
|
31
|
+
* // For a standalone project root
|
|
32
|
+
* // 對於獨立專案根目錄
|
|
33
|
+
* const files2 = getRootCopyStaticFilesAuto({
|
|
34
|
+
* isRoot: true,
|
|
35
|
+
* hasWorkspace: false
|
|
36
|
+
* });
|
|
37
|
+
* // Returns defaultCopyStaticFiles + defaultCopyStaticFilesRootOnly
|
|
38
|
+
* // 返回 defaultCopyStaticFiles + defaultCopyStaticFilesRootOnly
|
|
39
|
+
*
|
|
40
|
+
* // For a package within a workspace
|
|
41
|
+
* // 對於工作區內的套件
|
|
42
|
+
* const files3 = getRootCopyStaticFilesAuto({
|
|
43
|
+
* isRoot: false,
|
|
44
|
+
* hasWorkspace: true
|
|
45
|
+
* });
|
|
46
|
+
* // Returns only defaultCopyStaticFiles
|
|
47
|
+
* // 僅返回 defaultCopyStaticFiles
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
5
50
|
function getRootCopyStaticFilesAuto(rootData) {
|
|
51
|
+
// Start with default package-level files / 從預設套件層級檔案開始
|
|
6
52
|
let file_map = [
|
|
7
53
|
...const_1.defaultCopyStaticFiles,
|
|
8
54
|
];
|
|
55
|
+
// Add root-only files if this is the root and has no workspaces / 如果這是根目錄且沒有工作區,則添加僅根目錄的檔案
|
|
9
56
|
if (rootData.isRoot) {
|
|
10
57
|
if (!rootData.hasWorkspace) {
|
|
11
58
|
file_map = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRootCopyStaticFiles.js","sourceRoot":"","sources":["getRootCopyStaticFiles.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"getRootCopyStaticFiles.js","sourceRoot":"","sources":["getRootCopyStaticFiles.ts"],"names":[],"mappings":";;AA0DA,gEAoBC;AAnED,oCAAkF;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,SAAgB,0BAA0B,CAAC,QAA6D;IAEvG,uDAAuD;IACvD,IAAI,QAAQ,GAAiC;QAC5C,GAAG,8BAAsB;KACzB,CAAC;IAEF,2FAA2F;IAC3F,IAAI,QAAQ,CAAC,MAAM,EACnB,CAAC;QACA,IAAI,CAAC,QAAQ,CAAC,YAAY,EAC1B,CAAC;YACA,QAAQ,GAAG;gBACV,GAAG,QAAQ;gBACX,GAAG,sCAA8B;aACjC,CAAC;QACH,CAAC;IACF,CAAC;IAED,OAAO,QAAQ,CAAA;AAChB,CAAC","sourcesContent":["/**\n * Get root copy static files configuration / 獲取根目錄複製靜態檔案配置\n *\n * This module provides a function to determine the appropriate static files\n * to copy based on the project root structure.\n * 此模組提供根據專案根目錄結構確定要複製的適當靜態檔案的函數。\n *\n * @module getRootCopyStaticFiles\n */\nimport { IFindRootReturnType } from '@yarn-tool/find-root';\nimport { IStaticFilesMapArray } from '../types';\nimport { defaultCopyStaticFiles, defaultCopyStaticFilesRootOnly } from '../const';\n\n/**\n * Get the appropriate static files map based on root data / 根據根目錄數據獲取適當的靜態檔案映射\n *\n * Determines which static files should be copied based on whether the current\n * directory is the workspace root and whether it has workspaces.\n * 根據當前目錄是否為工作區根目錄以及是否具有工作區,確定應複製哪些靜態檔案。\n *\n * @param rootData - Information about the project root / 關於專案根目錄的資訊\n * @param rootData.isRoot - Whether the current directory is the workspace root / 當前目錄是否為工作區根目錄\n * @param rootData.hasWorkspace - Whether the project has workspaces / 專案是否具有工作區\n *\n * @returns An array of static file entries to copy / 要複製的靜態檔案條目陣列\n *\n * @example\n * ```typescript\n * import { getRootCopyStaticFilesAuto } from '@yarn-tool/static-file';\n *\n * // For a workspace root with workspaces\n * // 對於具有工作區的工作區根目錄\n * const files1 = getRootCopyStaticFilesAuto({\n * isRoot: true,\n * hasWorkspace: true\n * });\n * // Returns only defaultCopyStaticFiles (not root-only files)\n * // 僅返回 defaultCopyStaticFiles(不包含僅根目錄的檔案)\n *\n * // For a standalone project root\n * // 對於獨立專案根目錄\n * const files2 = getRootCopyStaticFilesAuto({\n * isRoot: true,\n * hasWorkspace: false\n * });\n * // Returns defaultCopyStaticFiles + defaultCopyStaticFilesRootOnly\n * // 返回 defaultCopyStaticFiles + defaultCopyStaticFilesRootOnly\n *\n * // For a package within a workspace\n * // 對於工作區內的套件\n * const files3 = getRootCopyStaticFilesAuto({\n * isRoot: false,\n * hasWorkspace: true\n * });\n * // Returns only defaultCopyStaticFiles\n * // 僅返回 defaultCopyStaticFiles\n * ```\n */\nexport function getRootCopyStaticFilesAuto(rootData: Pick<IFindRootReturnType, 'isRoot'| 'hasWorkspace'>)\n{\n\t// Start with default package-level files / 從預設套件層級檔案開始\n\tlet file_map: IStaticFilesMapArray<string> = [\n\t\t...defaultCopyStaticFiles,\n\t];\n\n\t// Add root-only files if this is the root and has no workspaces / 如果這是根目錄且沒有工作區,則添加僅根目錄的檔案\n\tif (rootData.isRoot)\n\t{\n\t\tif (!rootData.hasWorkspace)\n\t\t{\n\t\t\tfile_map = [\n\t\t\t\t...file_map,\n\t\t\t\t...defaultCopyStaticFilesRootOnly,\n\t\t\t];\n\t\t}\n\t}\n\n\treturn file_map\n}\n"]}
|