@yarn-tool/static-file 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +9 -4
  3. package/__root.d.ts +28 -0
  4. package/__root.js +28 -0
  5. package/__root.js.map +1 -1
  6. package/file/.gitignore +10 -0
  7. package/file/README.md +11 -1
  8. package/file/github/dependabot.yml +39 -0
  9. package/file/github/workflows/action-yarnlock-dedupe.yml +3 -5
  10. package/file/github/workflows/build.yml +1 -0
  11. package/file/github/workflows/cmd-rebase.yml +28 -0
  12. package/file/github/workflows/codeql-analysis.yml +52 -0
  13. package/file/github/workflows/coverage.yml +2 -0
  14. package/file/github/workflows/yarn-lock-changes.yml +3 -0
  15. package/file/gitignore +15 -0
  16. package/file/jest.config.auto.js +81 -15
  17. package/file/jest.config.js +3 -1
  18. package/file/npmrc +3 -0
  19. package/file/nvmrc +1 -1
  20. package/file/pnpm-workspace.yaml +19 -0
  21. package/file/test/__root.ts +3 -0
  22. package/file/test/temp.ts +4 -0
  23. package/file/tsconfig.json +5 -0
  24. package/file/tsdx/tsconfig.json.tpl +7 -0
  25. package/file/ws-root/jest-preset.js +32 -3
  26. package/file/ws-root/jest.config.js +3 -2
  27. package/index.d.ts +25 -0
  28. package/index.js +25 -0
  29. package/index.js.map +1 -1
  30. package/lib/const.d.ts +57 -3
  31. package/lib/const.js +92 -7
  32. package/lib/const.js.map +1 -1
  33. package/lib/copyStaticFiles.d.ts +50 -0
  34. package/lib/copyStaticFiles.js +48 -0
  35. package/lib/copyStaticFiles.js.map +1 -1
  36. package/lib/copyStaticFilesEntry.d.ts +50 -0
  37. package/lib/copyStaticFilesEntry.js +48 -0
  38. package/lib/copyStaticFilesEntry.js.map +1 -1
  39. package/lib/getRowOfStaticFilesMapArray.d.ts +40 -0
  40. package/lib/getRowOfStaticFilesMapArray.js +32 -0
  41. package/lib/getRowOfStaticFilesMapArray.js.map +1 -1
  42. package/lib/getStaticFile.d.ts +42 -0
  43. package/lib/getStaticFile.js +34 -0
  44. package/lib/getStaticFile.js.map +1 -1
  45. package/lib/parseStaticMap.d.ts +39 -0
  46. package/lib/parseStaticMap.js +7 -0
  47. package/lib/parseStaticMap.js.map +1 -1
  48. package/lib/reMapStaticFilesMapArray.d.ts +39 -0
  49. package/lib/reMapStaticFilesMapArray.js +36 -0
  50. package/lib/reMapStaticFilesMapArray.js.map +1 -1
  51. package/lib/replaceTargetOfStaticFilesMapArrayEntry.d.ts +33 -0
  52. package/lib/replaceTargetOfStaticFilesMapArrayEntry.js +25 -0
  53. package/lib/replaceTargetOfStaticFilesMapArrayEntry.js.map +1 -1
  54. package/lib/root/getRootCopyStaticFiles.d.ts +54 -0
  55. package/lib/root/getRootCopyStaticFiles.js +47 -0
  56. package/lib/root/getRootCopyStaticFiles.js.map +1 -1
  57. package/lib/types.d.ts +73 -0
  58. package/lib/types.js.map +1 -1
  59. package/lib/ws/wsCopyStaticFiles.d.ts +50 -0
  60. package/lib/ws/wsCopyStaticFiles.js +50 -0
  61. package/lib/ws/wsCopyStaticFiles.js.map +1 -1
  62. package/package.json +3 -3
  63. package/file/test/__root.d.ts +0 -2
  64. package/file/test/__root.js +0 -7
  65. package/file/test/__root.js.map +0 -1
  66. package/file/tsdx/index.cjs +0 -5
  67. package/file/tsdx/index.cjs.map +0 -1
  68. package/file/tsdx/index.d.cts +0 -2
  69. package/file/ws-root/__root_ws.d.ts +0 -2
  70. package/file/ws-root/__root_ws.js +0 -7
  71. package/file/ws-root/__root_ws.js.map +0 -1
  72. /package/file/{browserslistrc → ws-root/browserslistrc} +0 -0
@@ -4,20 +4,68 @@ exports.copyStaticFilesEntry = copyStaticFilesEntry;
4
4
  const path_1 = require("path");
5
5
  const fs_extra_1 = require("fs-extra");
6
6
  const __root_1 = require("../__root");
7
+ /**
8
+ * Copy a single static file entry / 複製單個靜態檔案條目
9
+ *
10
+ * Copies a single static file from the static root to the target directory.
11
+ * 從靜態根目錄複製單個靜態檔案到目標目錄。
12
+ *
13
+ * @param entry - The static file entry / 靜態檔案條目
14
+ * @param entry.0 - targetFile: Target file path / 目標檔案路徑
15
+ * @param entry.1 - staticFile: Source static file path / 來源靜態檔案路徑
16
+ * @param entry.2 - detectFile: Optional file to check for existence / 可選的檢測檔案
17
+ *
18
+ * @param cwd - Current working directory / 當前工作目錄
19
+ * @param staticRoot - Root directory of static files (defaults to package root) / 靜態檔案根目錄(預設為套件根目錄)
20
+ * @param overwrite - Whether to overwrite existing files (defaults to false) / 是否覆蓋已存在的檔案(預設為 false)
21
+ *
22
+ * @returns true if file was copied, undefined if skipped (detect file exists) / 如果檔案已複製則返回 true,如果跳過(檢測檔案存在)則返回 undefined
23
+ *
24
+ * @throws {Error} When the source static file does not exist / 當來源靜態檔案不存在時
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * import { copyStaticFilesEntry } from '@yarn-tool/static-file';
29
+ *
30
+ * // Copy a single file
31
+ * // 複製單個檔案
32
+ * const result = copyStaticFilesEntry(
33
+ * ['.gitignore', 'file/gitignore'],
34
+ * '/path/to/project',
35
+ * '/path/to/static/root',
36
+ * false
37
+ * );
38
+ *
39
+ * // With detect file - skips if detect file exists
40
+ * // 使用檢測檔案 - 如果檢測檔案存在則跳過
41
+ * const result = copyStaticFilesEntry(
42
+ * ['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json'],
43
+ * '/path/to/project'
44
+ * );
45
+ * // Skips copy if tsconfig.json already exists in the project
46
+ * // 如果 tsconfig.json 已存在於專案中則跳過複製
47
+ * ```
48
+ */
7
49
  function copyStaticFilesEntry(entry, cwd, staticRoot = __root_1.__STATIC_ROOT, overwrite) {
8
50
  const [targetFile, staticFile, detectFile] = entry;
51
+ // Check if detect file exists - skip copy if it does / 檢查檢測檔案是否存在 - 如果存在則跳過複製
9
52
  if (detectFile === null || detectFile === void 0 ? void 0 : detectFile.length) {
10
53
  const fc = (0, path_1.resolve)(cwd, detectFile);
11
54
  if ((0, fs_extra_1.existsSync)(fc)) {
12
55
  return;
13
56
  }
14
57
  }
58
+ // Resolve source file path / 解析來源檔案路徑
15
59
  const fb = (0, path_1.resolve)(staticRoot, staticFile);
60
+ // Verify source file exists / 驗證來源檔案是否存在
16
61
  if (!(0, fs_extra_1.existsSync)(fb)) {
17
62
  throw new Error(`file not exists. ${fb}`);
18
63
  }
64
+ // Resolve target file path / 解析目標檔案路徑
19
65
  const fa = (0, path_1.resolve)(cwd, targetFile);
66
+ // Ensure target directory exists / 確保目標目錄存在
20
67
  (0, fs_extra_1.ensureDirSync)((0, path_1.dirname)(fa));
68
+ // Copy the file / 複製檔案
21
69
  (0, fs_extra_1.copySync)(fb, fa, {
22
70
  overwrite: overwrite || false,
23
71
  preserveTimestamps: true,
@@ -1 +1 @@
1
- {"version":3,"file":"copyStaticFilesEntry.js","sourceRoot":"","sources":["copyStaticFilesEntry.ts"],"names":[],"mappings":";;AAKA,oDAmCC;AAvCD,+BAAwC;AACxC,uCAA+D;AAC/D,sCAA0C;AAE1C,SAAgB,oBAAoB,CAAC,KAAwC,EAC5E,GAAW,EACX,aAAqB,sBAAa,EAClC,SAAmB;IAGnB,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC;IAEnD,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,EACtB,CAAC;QACA,MAAM,EAAE,GAAG,IAAA,cAAO,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAEpC,IAAI,IAAA,qBAAU,EAAC,EAAE,CAAC,EAClB,CAAC;YACA,OAAO;QACR,CAAC;IACF,CAAC;IAED,MAAM,EAAE,GAAG,IAAA,cAAO,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAE3C,IAAI,CAAC,IAAA,qBAAU,EAAC,EAAE,CAAC,EACnB,CAAC;QACA,MAAM,IAAI,KAAK,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED,MAAM,EAAE,GAAG,IAAA,cAAO,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAEpC,IAAA,wBAAa,EAAC,IAAA,cAAO,EAAC,EAAE,CAAC,CAAC,CAAA;IAC1B,IAAA,mBAAQ,EAAC,EAAE,EAAE,EAAE,EAAE;QAChB,SAAS,EAAE,SAAS,IAAI,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,YAAY,EAAE,KAAK;KACnB,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import { IStaticFilesMapArrayEntry } from './types';\nimport { dirname, resolve } from 'path';\nimport { copySync, ensureDirSync, existsSync } from 'fs-extra';\nimport { __STATIC_ROOT } from '../__root';\n\nexport function copyStaticFilesEntry(entry: IStaticFilesMapArrayEntry<string>,\n\tcwd: string,\n\tstaticRoot: string = __STATIC_ROOT,\n\toverwrite?: boolean,\n)\n{\n\tconst [targetFile, staticFile, detectFile] = entry;\n\n\tif (detectFile?.length)\n\t{\n\t\tconst fc = resolve(cwd, detectFile);\n\n\t\tif (existsSync(fc))\n\t\t{\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst fb = resolve(staticRoot, staticFile);\n\n\tif (!existsSync(fb))\n\t{\n\t\tthrow new Error(`file not exists. ${fb}`)\n\t}\n\n\tconst fa = resolve(cwd, targetFile);\n\n\tensureDirSync(dirname(fa))\n\tcopySync(fb, fa, {\n\t\toverwrite: overwrite || false,\n\t\tpreserveTimestamps: true,\n\t\terrorOnExist: false,\n\t});\n\n\treturn true;\n}\n"]}
1
+ {"version":3,"file":"copyStaticFilesEntry.js","sourceRoot":"","sources":["copyStaticFilesEntry.ts"],"names":[],"mappings":";;AAuDA,oDA0CC;AAxFD,+BAAwC;AACxC,uCAA+D;AAC/D,sCAA0C;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,SAAgB,oBAAoB,CAAC,KAAwC,EAC5E,GAAW,EACX,aAAqB,sBAAa,EAClC,SAAmB;IAGnB,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC;IAEnD,8EAA8E;IAC9E,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,EACtB,CAAC;QACA,MAAM,EAAE,GAAG,IAAA,cAAO,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAEpC,IAAI,IAAA,qBAAU,EAAC,EAAE,CAAC,EAClB,CAAC;YACA,OAAO;QACR,CAAC;IACF,CAAC;IAED,sCAAsC;IACtC,MAAM,EAAE,GAAG,IAAA,cAAO,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAE3C,yCAAyC;IACzC,IAAI,CAAC,IAAA,qBAAU,EAAC,EAAE,CAAC,EACnB,CAAC;QACA,MAAM,IAAI,KAAK,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED,sCAAsC;IACtC,MAAM,EAAE,GAAG,IAAA,cAAO,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAEpC,4CAA4C;IAC5C,IAAA,wBAAa,EAAC,IAAA,cAAO,EAAC,EAAE,CAAC,CAAC,CAAA;IAE1B,uBAAuB;IACvB,IAAA,mBAAQ,EAAC,EAAE,EAAE,EAAE,EAAE;QAChB,SAAS,EAAE,SAAS,IAAI,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,YAAY,EAAE,KAAK;KACnB,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * Copy single static file entry / 複製單個靜態檔案條目\n *\n * This module provides the function for copying a single static file entry.\n * 此模組提供複製單個靜態檔案條目的函數。\n *\n * @module copyStaticFilesEntry\n */\nimport { IStaticFilesMapArrayEntry } from './types';\nimport { dirname, resolve } from 'path';\nimport { copySync, ensureDirSync, existsSync } from 'fs-extra';\nimport { __STATIC_ROOT } from '../__root';\n\n/**\n * Copy a single static file entry / 複製單個靜態檔案條目\n *\n * Copies a single static file from the static root to the target directory.\n * 從靜態根目錄複製單個靜態檔案到目標目錄。\n *\n * @param entry - The static file entry / 靜態檔案條目\n * @param entry.0 - targetFile: Target file path / 目標檔案路徑\n * @param entry.1 - staticFile: Source static file path / 來源靜態檔案路徑\n * @param entry.2 - detectFile: Optional file to check for existence / 可選的檢測檔案\n *\n * @param cwd - Current working directory / 當前工作目錄\n * @param staticRoot - Root directory of static files (defaults to package root) / 靜態檔案根目錄(預設為套件根目錄)\n * @param overwrite - Whether to overwrite existing files (defaults to false) / 是否覆蓋已存在的檔案(預設為 false)\n *\n * @returns true if file was copied, undefined if skipped (detect file exists) / 如果檔案已複製則返回 true,如果跳過(檢測檔案存在)則返回 undefined\n *\n * @throws {Error} When the source static file does not exist / 當來源靜態檔案不存在時\n *\n * @example\n * ```typescript\n * import { copyStaticFilesEntry } from '@yarn-tool/static-file';\n *\n * // Copy a single file\n * // 複製單個檔案\n * const result = copyStaticFilesEntry(\n * ['.gitignore', 'file/gitignore'],\n * '/path/to/project',\n * '/path/to/static/root',\n * false\n * );\n *\n * // With detect file - skips if detect file exists\n * // 使用檢測檔案 - 如果檢測檔案存在則跳過\n * const result = copyStaticFilesEntry(\n * ['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json'],\n * '/path/to/project'\n * );\n * // Skips copy if tsconfig.json already exists in the project\n * // 如果 tsconfig.json 已存在於專案中則跳過複製\n * ```\n */\nexport function copyStaticFilesEntry(entry: IStaticFilesMapArrayEntry<string>,\n\tcwd: string,\n\tstaticRoot: string = __STATIC_ROOT,\n\toverwrite?: boolean,\n)\n{\n\tconst [targetFile, staticFile, detectFile] = entry;\n\n\t// Check if detect file exists - skip copy if it does / 檢查檢測檔案是否存在 - 如果存在則跳過複製\n\tif (detectFile?.length)\n\t{\n\t\tconst fc = resolve(cwd, detectFile);\n\n\t\tif (existsSync(fc))\n\t\t{\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// Resolve source file path / 解析來源檔案路徑\n\tconst fb = resolve(staticRoot, staticFile);\n\n\t// Verify source file exists / 驗證來源檔案是否存在\n\tif (!existsSync(fb))\n\t{\n\t\tthrow new Error(`file not exists. ${fb}`)\n\t}\n\n\t// Resolve target file path / 解析目標檔案路徑\n\tconst fa = resolve(cwd, targetFile);\n\n\t// Ensure target directory exists / 確保目標目錄存在\n\tensureDirSync(dirname(fa))\n\n\t// Copy the file / 複製檔案\n\tcopySync(fb, fa, {\n\t\toverwrite: overwrite || false,\n\t\tpreserveTimestamps: true,\n\t\terrorOnExist: false,\n\t});\n\n\treturn true;\n}\n"]}
@@ -1,2 +1,42 @@
1
+ /**
2
+ * Get row from static files map array / 從靜態檔案映射陣列獲取行
3
+ *
4
+ * This module provides a function to retrieve a specific entry from a static files map.
5
+ * 此模組提供從靜態檔案映射中檢索特定條目的函數。
6
+ *
7
+ * @module getRowOfStaticFilesMapArray
8
+ */
1
9
  import { IStaticFiles, IStaticFilesKey, IStaticFilesMapArrayEntry } from './types';
10
+ /**
11
+ * Get a specific row from static files map array / 從靜態檔案映射陣列獲取特定行
12
+ *
13
+ * Retrieves a specific entry from the static files map based on the target file key.
14
+ * 根據目標檔案鍵從靜態檔案映射中檢索特定條目。
15
+ *
16
+ * @template T - The static files map type / 靜態檔案映射類型
17
+ * @template K - The target file key type / 目標檔案鍵類型
18
+ *
19
+ * @param file_map - The static files map (array or record format) / 靜態檔案映射(陣列或記錄格式)
20
+ * @param key - The target file key to search for / 要搜尋的目標檔案鍵
21
+ *
22
+ * @returns The matching entry or undefined if not found / 匹配的條目,如果未找到則返回 undefined
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * import { getRowOfStaticFilesMapArray } from '@yarn-tool/static-file';
27
+ * import { defaultCopyStaticFiles } from '@yarn-tool/static-file/lib/const';
28
+ *
29
+ * // Get the entry for .gitignore
30
+ * // 獲取 .gitignore 的條目
31
+ * const entry = getRowOfStaticFilesMapArray(defaultCopyStaticFiles, '.gitignore');
32
+ * // Returns: ['.gitignore', 'file/gitignore']
33
+ * // 返回:['.gitignore', 'file/gitignore']
34
+ *
35
+ * // Get the entry for tsconfig.json.tpl
36
+ * // 獲取 tsconfig.json.tpl 的條目
37
+ * const tsconfigEntry = getRowOfStaticFilesMapArray(defaultCopyStaticFiles, 'tsconfig.json.tpl');
38
+ * // Returns: ['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json']
39
+ * // 返回:['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json']
40
+ * ```
41
+ */
2
42
  export declare function getRowOfStaticFilesMapArray<T extends IStaticFiles<string>, K extends IStaticFilesKey<T>>(file_map: T, key: K): IStaticFilesMapArrayEntry<K>;
@@ -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":";;AAUA,kEAGC;AALD,qDAAkD;AAElD,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":["import {\n\tIStaticFiles,\n\tIStaticFilesID,\n\tIStaticFilesKey,\n\tIStaticFilesMapArray,\n\tIStaticFilesMapArrayEntry,\n\tIStaticFilesMapRecord,\n} from './types';\nimport { parseStaticMap } from './parseStaticMap';\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"]}
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"]}
@@ -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>;
@@ -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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getStaticFile.js","sourceRoot":"","sources":["getStaticFile.ts"],"names":[],"mappings":";;AAKA,sCAKC;AARD,mCAAiD;AACjD,+EAA4E;AAE5E,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":["import { ICopyStaticFilesOptions, IStaticFilesMapArray } from './types';\nimport { parseStaticMap } from './parseStaticMap';\nimport { defaultCopyStaticFiles } from './const';\nimport { getRowOfStaticFilesMapArray } from './getRowOfStaticFilesMapArray';\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"]}
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"]}
@@ -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>;
@@ -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":";;AAWA,wCAeC;AAfD,SAAgB,cAAc,CAAmB,QAAyB;IAEzE,IAAI,EAA2B,CAAC;IAEhC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAC3B,CAAC;QACA,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC7B,CAAC;SAED,CAAC;QACA,aAAa;QACb,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC9B,CAAC;IAED,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":["import {\n\tIStaticFiles,\n\tIStaticFilesID,\n\tIStaticFilesMapArray,\n\tIStaticFilesMapRecord,\n\tIStaticFilesMapArrayEntry,\n} from './types';\n\nexport function parseStaticMap<K extends string>(file_map: IStaticFilesMapArray<K>): IStaticFilesMapArray<K | IStaticFilesID>\nexport function parseStaticMap<K extends string>(file_map: IStaticFilesMapRecord<K>): IStaticFilesMapArray<K | IStaticFilesID>\nexport function parseStaticMap<K extends string>(file_map: IStaticFiles<K>): IStaticFilesMapArray<K | IStaticFilesID>\nexport function parseStaticMap<K extends string>(file_map: IStaticFiles<K>): IStaticFilesMapArray<K | IStaticFilesID>\n{\n\tlet ls: IStaticFilesMapArray<K>;\n\n\tif (Array.isArray(file_map))\n\t{\n\t\tls = Object.values(file_map)\n\t}\n\telse\n\t{\n\t\t// @ts-ignore\n\t\tls = Object.entries(file_map)\n\t}\n\n\treturn ls.filter(v => v && Array.isArray(v) && v.length > 1);\n}\n"]}
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":";;AAMA,4DAqBC;AA1BD,qDAAkD;AAClD,+EAA4E;AAC5E,uGAAoG;AACpG,2DAA4D;AAE5D,SAAgB,wBAAwB,CAAmD,QAAW,EACrG,UAAyC;IAGzC,MAAM,EAAE,GAAG,IAAA,+BAAc,EAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,GAAG,GAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAA+B;SACnE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,EAAE;QAGvC,IAAI,GAAG,GAAG,IAAA,yDAA2B,EAAC,EAAE,EAAE,SAAS,CAAC,CAAA;QAEpD,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,OAAO,IAAA,2CAAsB,EAAC,GAAG,CAAC,MAAM,CAAC,EAAS,CAAC,CAAiD,CAAA;AACrG,CAAC","sourcesContent":["import { 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\nexport function reMapStaticFilesMapArray<T extends IStaticFiles<string>, N extends string>(file_map: T,\n\treplaceMap: Record<N, IStaticFilesKey<T>>,\n)\n{\n\tconst ls = parseStaticMap(file_map);\n\tconst arr = (Object.entries(replaceMap) as [N, IStaticFilesKey<T>][])\n\t\t.reduce((arr, [targetNew, targetOld]) =>\n\t\t{\n\n\t\t\tlet old = getRowOfStaticFilesMapArray(ls, targetOld)\n\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\treturn array_unique_overwrite(arr.concat(ls as any)) as IStaticFilesMapArray<IStaticFilesKey<T> | N>\n}\n"]}
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":";;AAEA,0FAGC;AAHD,SAAgB,uCAAuC,CAAmB,KAAwC,EAAE,UAAa;IAEhI,OAAO,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAiC,CAAA;AACvE,CAAC","sourcesContent":["import { IStaticFilesMapArrayEntry } from './types';\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
+ {"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>;