@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
@@ -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":";;AAIA,gEAkBC;AApBD,oCAAkF;AAElF,SAAgB,0BAA0B,CAAC,QAA6D;IAEvG,IAAI,QAAQ,GAAiC;QAC5C,GAAG,8BAAsB;KACzB,CAAC;IAEF,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":["import { IFindRootReturnType } from '@yarn-tool/find-root';\nimport { IStaticFilesMapArray } from '../types';\nimport { defaultCopyStaticFiles, defaultCopyStaticFilesRootOnly } from '../const';\n\nexport function getRootCopyStaticFilesAuto(rootData: Pick<IFindRootReturnType, 'isRoot'| 'hasWorkspace'>)\n{\n\tlet file_map: IStaticFilesMapArray<string> = [\n\t\t...defaultCopyStaticFiles,\n\t];\n\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"]}
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"]}
package/lib/types.d.ts CHANGED
@@ -1,26 +1,99 @@
1
+ /**
2
+ * Static file ID type / 靜態檔案 ID 類型
3
+ *
4
+ * Extracts the union type of all possible file IDs from the static files map array.
5
+ * 從靜態檔案映射陣列中提取所有可能的檔案 ID 聯合類型。
6
+ */
1
7
  import { defaultCopyStaticFiles, defaultCopyStaticFilesRootOnly } from './const';
2
8
  export type IStaticFilesID<T = typeof defaultCopyStaticFiles & typeof defaultCopyStaticFilesRootOnly> = T extends ({
3
9
  [n: number]: IStaticFilesMapArrayEntry<infer U>;
4
10
  } | {
5
11
  readonly [n: number]: IStaticFilesMapArrayEntry<infer U>;
6
12
  }) ? U : never;
13
+ /**
14
+ * Static files map array entry type / 靜態檔案映射陣列條目類型
15
+ *
16
+ * Represents a single entry in the static files map array.
17
+ * 表示靜態檔案映射陣列中的單個條目。
18
+ *
19
+ * @template K - The target file path type / 目標檔案路徑類型
20
+ *
21
+ * @param targetFile - Target file path to copy to / 要複製到的目標檔案路徑
22
+ * @param staticFile - Source static file path / 來源靜態檔案路徑
23
+ * @param detectFile - Optional file path to detect if target already exists / 可選的檢測檔案路徑,用於判斷目標是否已存在
24
+ */
7
25
  export type IStaticFilesMapArrayEntry<K extends string> = [
8
26
  targetFile: K,
9
27
  staticFile: string,
10
28
  detectFile?: string
11
29
  ];
30
+ /**
31
+ * Static files map record type / 靜態檔案映射記錄類型
32
+ *
33
+ * A record mapping target file paths to source file paths.
34
+ * 將目標檔案路徑映射到來源檔案路徑的記錄類型。
35
+ *
36
+ * @template K - The target file path type / 目標檔案路徑類型
37
+ */
12
38
  export type IStaticFilesMapRecord<K extends string> = {
13
39
  [P in K]: string;
14
40
  };
41
+ /**
42
+ * Static files map array type / 靜態檔案映射陣列類型
43
+ *
44
+ * An array of static file mapping entries.
45
+ * 靜態檔案映射條目的陣列。
46
+ *
47
+ * @template K - The target file path type / 目標檔案路徑類型
48
+ */
15
49
  export type IStaticFilesMapArray<K extends string> = IStaticFilesMapArrayEntry<K>[];
50
+ /**
51
+ * Static files map type / 靜態檔案映射類型
52
+ *
53
+ * Can be either an array of entries or a record mapping.
54
+ * 可以是條目陣列或記錄映射。
55
+ *
56
+ * @template K - The target file path type / 目標檔案路徑類型
57
+ */
16
58
  export type IStaticFiles<K extends string> = IStaticFilesMapArray<K> | IStaticFilesMapRecord<K>;
59
+ /**
60
+ * Base options for copying static files / 複製靜態檔案的基本選項
61
+ *
62
+ * @template K - The target file path type / 目標檔案路徑類型
63
+ *
64
+ * @property cwd - Current working directory / 當前工作目錄
65
+ * @property staticRoot - Root directory of static files / 靜態檔案的根目錄
66
+ * @property overwrite - Whether to overwrite existing files / 是否覆蓋已存在的檔案
67
+ */
17
68
  export interface ICopyStaticFilesOptionsBase<K extends string = string> {
18
69
  cwd: string;
19
70
  staticRoot?: string;
20
71
  overwrite?: boolean;
21
72
  }
73
+ /**
74
+ * Options for copying static files / 複製靜態檔案的選項
75
+ *
76
+ * Extends the base options with file map configuration.
77
+ * 擴展基本選項,加入檔案映射配置。
78
+ *
79
+ * @template K - The target file path type / 目標檔案路徑類型
80
+ *
81
+ * @property file_map - Custom file mapping configuration / 自訂檔案映射配置
82
+ */
22
83
  export interface ICopyStaticFilesOptions<K extends string = string> extends ICopyStaticFilesOptionsBase<K> {
23
84
  file_map?: IStaticFiles<K>;
24
85
  }
86
+ /**
87
+ * Extracts the key type from static files map / 從靜態檔案映射中提取鍵類型
88
+ *
89
+ * Utility type to extract the union type of target file paths from various static file map formats.
90
+ * 工具類型,用於從各種靜態檔案映射格式中提取目標檔案路徑的聯合類型。
91
+ *
92
+ * @template T - The static files map type / 靜態檔案映射類型
93
+ */
25
94
  export type IStaticFilesKey<T extends IStaticFiles<string> | readonly any[]> = T extends IStaticFilesMapArray<infer K> ? K : T extends readonly IStaticFilesMapArrayEntry<infer K>[] ? K : T extends IStaticFilesMapRecord<infer K> ? K : _Key<T>;
95
+ /**
96
+ * Internal key extraction type / 內部鍵提取類型
97
+ * @internal
98
+ */
26
99
  export type _Key<T> = T extends readonly (infer U)[] | (infer U)[] ? (U extends [infer K, string, string] | readonly [infer K, string, string] ? K : never) : never;
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import { defaultCopyStaticFiles, defaultCopyStaticFilesRootOnly } from './const';\n\nexport type IStaticFilesID<T = typeof defaultCopyStaticFiles & typeof defaultCopyStaticFilesRootOnly> =\n\tT extends ({\n\t\t\t[n: number]: IStaticFilesMapArrayEntry<infer U>\n\t\t} | {\n\t\t\treadonly [n: number]: IStaticFilesMapArrayEntry<infer U>;\n\t\t})\n\t\t? U\n\t\t: never\n\t;\n\nexport type IStaticFilesMapArrayEntry<K extends string> =\n\t[targetFile: K, staticFile: string, detectFile?: string]\n\ntype IStaticFilesMap01<K extends string> = {\n\t[P in K]: IStaticFilesMapArrayEntry<P>\n}\n\nexport type IStaticFilesMapRecord<K extends string> = {\n\t[P in K]: string\n}\n\nexport type IStaticFilesMapArray<K extends string> =\n\tIStaticFilesMapArrayEntry<K>[]\n\nexport type IStaticFiles<K extends string> = IStaticFilesMapArray<K> | IStaticFilesMapRecord<K>\n\nexport interface ICopyStaticFilesOptionsBase<K extends string = string>\n{\n\tcwd: string,\n\tstaticRoot?: string,\n\toverwrite?: boolean,\n}\n\nexport interface ICopyStaticFilesOptions<K extends string = string> extends ICopyStaticFilesOptionsBase<K>\n{\n\tfile_map?: IStaticFiles<K>,\n}\n\nexport type IStaticFilesKey<T extends IStaticFiles<string> | readonly any[]> = T extends IStaticFilesMapArray<infer K>\n\t? K\n\t: T extends readonly IStaticFilesMapArrayEntry<infer K>[]\n\t\t? K\n\t\t: T extends IStaticFilesMapRecord<infer K> ? K\n\t\t\t: _Key<T>\n\t;\n\nexport type _Key<T> = T extends readonly (infer U)[] | (infer U)[]\n\t? (U extends [infer K, string, string] | readonly [infer K, string, string] ? K : never)\n\t: never\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Static file ID type / 靜態檔案 ID 類型\n *\n * Extracts the union type of all possible file IDs from the static files map array.\n * 從靜態檔案映射陣列中提取所有可能的檔案 ID 聯合類型。\n */\nimport { defaultCopyStaticFiles, defaultCopyStaticFilesRootOnly } from './const';\n\nexport type IStaticFilesID<T = typeof defaultCopyStaticFiles & typeof defaultCopyStaticFilesRootOnly> =\n\tT extends ({\n\t\t\t[n: number]: IStaticFilesMapArrayEntry<infer U>\n\t\t} | {\n\t\t\treadonly [n: number]: IStaticFilesMapArrayEntry<infer U>;\n\t\t})\n\t\t? U\n\t\t: never\n\t;\n\n/**\n * Static files map array entry type / 靜態檔案映射陣列條目類型\n *\n * Represents a single entry in the static files map array.\n * 表示靜態檔案映射陣列中的單個條目。\n *\n * @template K - The target file path type / 目標檔案路徑類型\n *\n * @param targetFile - Target file path to copy to / 要複製到的目標檔案路徑\n * @param staticFile - Source static file path / 來源靜態檔案路徑\n * @param detectFile - Optional file path to detect if target already exists / 可選的檢測檔案路徑,用於判斷目標是否已存在\n */\nexport type IStaticFilesMapArrayEntry<K extends string> =\n\t[targetFile: K, staticFile: string, detectFile?: string]\n\n/**\n * Static files map object type (internal) / 靜態檔案映射物件類型(內部使用)\n * @internal\n */\ntype IStaticFilesMap01<K extends string> = {\n\t[P in K]: IStaticFilesMapArrayEntry<P>\n}\n\n/**\n * Static files map record type / 靜態檔案映射記錄類型\n *\n * A record mapping target file paths to source file paths.\n * 將目標檔案路徑映射到來源檔案路徑的記錄類型。\n *\n * @template K - The target file path type / 目標檔案路徑類型\n */\nexport type IStaticFilesMapRecord<K extends string> = {\n\t[P in K]: string\n}\n\n/**\n * Static files map array type / 靜態檔案映射陣列類型\n *\n * An array of static file mapping entries.\n * 靜態檔案映射條目的陣列。\n *\n * @template K - The target file path type / 目標檔案路徑類型\n */\nexport type IStaticFilesMapArray<K extends string> =\n\tIStaticFilesMapArrayEntry<K>[]\n\n/**\n * Static files map type / 靜態檔案映射類型\n *\n * Can be either an array of entries or a record mapping.\n * 可以是條目陣列或記錄映射。\n *\n * @template K - The target file path type / 目標檔案路徑類型\n */\nexport type IStaticFiles<K extends string> = IStaticFilesMapArray<K> | IStaticFilesMapRecord<K>\n\n/**\n * Base options for copying static files / 複製靜態檔案的基本選項\n *\n * @template K - The target file path type / 目標檔案路徑類型\n *\n * @property cwd - Current working directory / 當前工作目錄\n * @property staticRoot - Root directory of static files / 靜態檔案的根目錄\n * @property overwrite - Whether to overwrite existing files / 是否覆蓋已存在的檔案\n */\nexport interface ICopyStaticFilesOptionsBase<K extends string = string>\n{\n\tcwd: string,\n\tstaticRoot?: string,\n\toverwrite?: boolean,\n}\n\n/**\n * Options for copying static files / 複製靜態檔案的選項\n *\n * Extends the base options with file map configuration.\n * 擴展基本選項,加入檔案映射配置。\n *\n * @template K - The target file path type / 目標檔案路徑類型\n *\n * @property file_map - Custom file mapping configuration / 自訂檔案映射配置\n */\nexport interface ICopyStaticFilesOptions<K extends string = string> extends ICopyStaticFilesOptionsBase<K>\n{\n\tfile_map?: IStaticFiles<K>,\n}\n\n/**\n * Extracts the key type from static files map / 從靜態檔案映射中提取鍵類型\n *\n * Utility type to extract the union type of target file paths from various static file map formats.\n * 工具類型,用於從各種靜態檔案映射格式中提取目標檔案路徑的聯合類型。\n *\n * @template T - The static files map type / 靜態檔案映射類型\n */\nexport type IStaticFilesKey<T extends IStaticFiles<string> | readonly any[]> = T extends IStaticFilesMapArray<infer K>\n\t? K\n\t: T extends readonly IStaticFilesMapArrayEntry<infer K>[]\n\t\t? K\n\t\t: T extends IStaticFilesMapRecord<infer K> ? K\n\t\t\t: _Key<T>\n\t;\n\n/**\n * Internal key extraction type / 內部鍵提取類型\n * @internal\n */\nexport type _Key<T> = T extends readonly (infer U)[] | (infer U)[]\n\t? (U extends [infer K, string, string] | readonly [infer K, string, string] ? K : never)\n\t: never\n"]}
@@ -1,9 +1,59 @@
1
+ /**
2
+ * Get workspace copy static files configuration / 獲取工作區複製靜態檔案配置
3
+ *
4
+ * This module provides a function to get the combined static files map
5
+ * for workspace-level operations.
6
+ * 此模組提供獲取工作區層級操作的合併靜態檔案映射的函數。
7
+ *
8
+ * @module wsCopyStaticFiles
9
+ */
1
10
  import { defaultCopyStaticFiles, defaultCopyStaticFilesRootOnly } from '../const';
2
11
  import { IStaticFiles, IStaticFilesKey } from '../types';
12
+ /**
13
+ * Remapping configuration for workspace files / 工作區檔案的重新映射配置
14
+ *
15
+ * Maps target file names to their template counterparts.
16
+ * 將目標檔案名稱映射到其模板對應項。
17
+ *
18
+ * This allows copying template files directly to their final names.
19
+ * 這允許將模板檔案直接複製到其最終名稱。
20
+ */
3
21
  declare const remap: {
4
22
  readonly 'tsconfig.json': "tsconfig.json.tpl";
5
23
  readonly 'lerna.json': "lerna.json.tpl";
6
24
  readonly 'pnpm-workspace.yaml': "pnpm-workspace.yaml.tpl";
7
25
  };
26
+ /**
27
+ * Get the combined static files map for workspace operations / 獲取工作區操作的合併靜態檔案映射
28
+ *
29
+ * Combines all static file maps (default, root-only, and workspace-root-only)
30
+ * and applies remapping for template files.
31
+ * 合併所有靜態檔案映射(預設、僅根目錄和僅工作區根目錄)並應用模板檔案的重新映射。
32
+ *
33
+ * This function is useful for setting up a complete workspace with all
34
+ * necessary configuration files.
35
+ * 此函數對於設置包含所有必要配置檔案的完整工作區非常有用。
36
+ *
37
+ * @returns A combined static files map with remapped entries / 具有重新映射條目的合併靜態檔案映射
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import { getWsCopyStaticFiles } from '@yarn-tool/static-file';
42
+ *
43
+ * // Get all static files for workspace setup
44
+ * // 獲取工作區設置的所有靜態檔案
45
+ * const files = getWsCopyStaticFiles();
46
+ *
47
+ * // The returned map includes:
48
+ * // - Package-level files (.gitignore, .npmignore, etc.)
49
+ * // - Root-level files (lerna.json, pnpm-workspace.yaml, etc.)
50
+ * // - Workspace-root files (__root_ws.ts, jest-preset.js, etc.)
51
+ * //
52
+ * // 返回的映射包括:
53
+ * // - 套件層級檔案(.gitignore、.npmignore 等)
54
+ * // - 根目錄層級檔案(lerna.json、pnpm-workspace.yaml 等)
55
+ * // - 工作區根目錄檔案(__root_ws.ts、jest-preset.js 等)
56
+ * ```
57
+ */
8
58
  export declare function getWsCopyStaticFiles(): IStaticFiles<IStaticFilesKey<typeof defaultCopyStaticFiles | typeof defaultCopyStaticFilesRootOnly> | keyof typeof remap>;
9
59
  export default getWsCopyStaticFiles;
@@ -1,13 +1,63 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWsCopyStaticFiles = getWsCopyStaticFiles;
4
+ /**
5
+ * Get workspace copy static files configuration / 獲取工作區複製靜態檔案配置
6
+ *
7
+ * This module provides a function to get the combined static files map
8
+ * for workspace-level operations.
9
+ * 此模組提供獲取工作區層級操作的合併靜態檔案映射的函數。
10
+ *
11
+ * @module wsCopyStaticFiles
12
+ */
4
13
  const const_1 = require("../const");
5
14
  const reMapStaticFilesMapArray_1 = require("../reMapStaticFilesMapArray");
15
+ /**
16
+ * Remapping configuration for workspace files / 工作區檔案的重新映射配置
17
+ *
18
+ * Maps target file names to their template counterparts.
19
+ * 將目標檔案名稱映射到其模板對應項。
20
+ *
21
+ * This allows copying template files directly to their final names.
22
+ * 這允許將模板檔案直接複製到其最終名稱。
23
+ */
6
24
  const remap = {
7
25
  'tsconfig.json': 'tsconfig.json.tpl',
8
26
  'lerna.json': 'lerna.json.tpl',
9
27
  'pnpm-workspace.yaml': 'pnpm-workspace.yaml.tpl',
10
28
  };
29
+ /**
30
+ * Get the combined static files map for workspace operations / 獲取工作區操作的合併靜態檔案映射
31
+ *
32
+ * Combines all static file maps (default, root-only, and workspace-root-only)
33
+ * and applies remapping for template files.
34
+ * 合併所有靜態檔案映射(預設、僅根目錄和僅工作區根目錄)並應用模板檔案的重新映射。
35
+ *
36
+ * This function is useful for setting up a complete workspace with all
37
+ * necessary configuration files.
38
+ * 此函數對於設置包含所有必要配置檔案的完整工作區非常有用。
39
+ *
40
+ * @returns A combined static files map with remapped entries / 具有重新映射條目的合併靜態檔案映射
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * import { getWsCopyStaticFiles } from '@yarn-tool/static-file';
45
+ *
46
+ * // Get all static files for workspace setup
47
+ * // 獲取工作區設置的所有靜態檔案
48
+ * const files = getWsCopyStaticFiles();
49
+ *
50
+ * // The returned map includes:
51
+ * // - Package-level files (.gitignore, .npmignore, etc.)
52
+ * // - Root-level files (lerna.json, pnpm-workspace.yaml, etc.)
53
+ * // - Workspace-root files (__root_ws.ts, jest-preset.js, etc.)
54
+ * //
55
+ * // 返回的映射包括:
56
+ * // - 套件層級檔案(.gitignore、.npmignore 等)
57
+ * // - 根目錄層級檔案(lerna.json、pnpm-workspace.yaml 等)
58
+ * // - 工作區根目錄檔案(__root_ws.ts、jest-preset.js 等)
59
+ * ```
60
+ */
11
61
  function getWsCopyStaticFiles() {
12
62
  return (0, reMapStaticFilesMapArray_1.reMapStaticFilesMapArray)([
13
63
  ...const_1.defaultCopyStaticFiles,
@@ -1 +1 @@
1
- {"version":3,"file":"wsCopyStaticFiles.js","sourceRoot":"","sources":["wsCopyStaticFiles.ts"],"names":[],"mappings":";;AAcA,oDAOC;AArBD,oCAIkB;AAElB,0EAAuE;AAEvE,MAAM,KAAK,GAAG;IACb,eAAe,EAAE,mBAAmB;IACpC,YAAY,EAAE,gBAAgB;IAC9B,qBAAqB,EAAE,yBAAyB;CACvC,CAAA;AAEV,SAAgB,oBAAoB;IAEnC,OAAO,IAAA,mDAAwB,EAAC;QAC/B,GAAG,8BAAsB;QACzB,GAAG,sCAA8B;QACjC,GAAG,wCAAgC;KACnC,EAAE,KAAK,CAAC,CAAC;AACX,CAAC;AAED,kBAAe,oBAAoB,CAAC","sourcesContent":["import {\n\tdefaultCopyStaticFiles,\n\tdefaultCopyStaticFilesRootOnly,\n\tdefaultCopyStaticFilesWsRootOnly,\n} from '../const';\nimport { IStaticFiles, IStaticFilesKey, IStaticFilesMapArray } from '../types';\nimport { reMapStaticFilesMapArray } from '../reMapStaticFilesMapArray';\n\nconst remap = {\n\t'tsconfig.json': 'tsconfig.json.tpl',\n\t'lerna.json': 'lerna.json.tpl',\n\t'pnpm-workspace.yaml': 'pnpm-workspace.yaml.tpl',\n} as const\n\nexport function getWsCopyStaticFiles(): IStaticFiles<IStaticFilesKey<typeof defaultCopyStaticFiles | typeof defaultCopyStaticFilesRootOnly> | keyof typeof remap>\n{\n\treturn reMapStaticFilesMapArray([\n\t\t...defaultCopyStaticFiles,\n\t\t...defaultCopyStaticFilesRootOnly,\n\t\t...defaultCopyStaticFilesWsRootOnly,\n\t], remap);\n}\n\nexport default getWsCopyStaticFiles;\n"]}
1
+ {"version":3,"file":"wsCopyStaticFiles.js","sourceRoot":"","sources":["wsCopyStaticFiles.ts"],"names":[],"mappings":";;AAgEA,oDAOC;AAvED;;;;;;;;GAQG;AACH,oCAIkB;AAElB,0EAAuE;AAEvE;;;;;;;;GAQG;AACH,MAAM,KAAK,GAAG;IACb,eAAe,EAAE,mBAAmB;IACpC,YAAY,EAAE,gBAAgB;IAC9B,qBAAqB,EAAE,yBAAyB;CACvC,CAAA;AAEV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,oBAAoB;IAEnC,OAAO,IAAA,mDAAwB,EAAC;QAC/B,GAAG,8BAAsB;QACzB,GAAG,sCAA8B;QACjC,GAAG,wCAAgC;KACnC,EAAE,KAAK,CAAC,CAAC;AACX,CAAC;AAED,kBAAe,oBAAoB,CAAC","sourcesContent":["/**\n * Get workspace copy static files configuration / 獲取工作區複製靜態檔案配置\n *\n * This module provides a function to get the combined static files map\n * for workspace-level operations.\n * 此模組提供獲取工作區層級操作的合併靜態檔案映射的函數。\n *\n * @module wsCopyStaticFiles\n */\nimport {\n\tdefaultCopyStaticFiles,\n\tdefaultCopyStaticFilesRootOnly,\n\tdefaultCopyStaticFilesWsRootOnly,\n} from '../const';\nimport { IStaticFiles, IStaticFilesKey, IStaticFilesMapArray } from '../types';\nimport { reMapStaticFilesMapArray } from '../reMapStaticFilesMapArray';\n\n/**\n * Remapping configuration for workspace files / 工作區檔案的重新映射配置\n *\n * Maps target file names to their template counterparts.\n * 將目標檔案名稱映射到其模板對應項。\n *\n * This allows copying template files directly to their final names.\n * 這允許將模板檔案直接複製到其最終名稱。\n */\nconst remap = {\n\t'tsconfig.json': 'tsconfig.json.tpl',\n\t'lerna.json': 'lerna.json.tpl',\n\t'pnpm-workspace.yaml': 'pnpm-workspace.yaml.tpl',\n} as const\n\n/**\n * Get the combined static files map for workspace operations / 獲取工作區操作的合併靜態檔案映射\n *\n * Combines all static file maps (default, root-only, and workspace-root-only)\n * and applies remapping for template files.\n * 合併所有靜態檔案映射(預設、僅根目錄和僅工作區根目錄)並應用模板檔案的重新映射。\n *\n * This function is useful for setting up a complete workspace with all\n * necessary configuration files.\n * 此函數對於設置包含所有必要配置檔案的完整工作區非常有用。\n *\n * @returns A combined static files map with remapped entries / 具有重新映射條目的合併靜態檔案映射\n *\n * @example\n * ```typescript\n * import { getWsCopyStaticFiles } from '@yarn-tool/static-file';\n *\n * // Get all static files for workspace setup\n * // 獲取工作區設置的所有靜態檔案\n * const files = getWsCopyStaticFiles();\n *\n * // The returned map includes:\n * // - Package-level files (.gitignore, .npmignore, etc.)\n * // - Root-level files (lerna.json, pnpm-workspace.yaml, etc.)\n * // - Workspace-root files (__root_ws.ts, jest-preset.js, etc.)\n * //\n * // 返回的映射包括:\n * // - 套件層級檔案(.gitignore、.npmignore 等)\n * // - 根目錄層級檔案(lerna.json、pnpm-workspace.yaml 等)\n * // - 工作區根目錄檔案(__root_ws.ts、jest-preset.js 等)\n * ```\n */\nexport function getWsCopyStaticFiles(): IStaticFiles<IStaticFilesKey<typeof defaultCopyStaticFiles | typeof defaultCopyStaticFilesRootOnly> | keyof typeof remap>\n{\n\treturn reMapStaticFilesMapArray([\n\t\t...defaultCopyStaticFiles,\n\t\t...defaultCopyStaticFilesRootOnly,\n\t\t...defaultCopyStaticFilesWsRootOnly,\n\t], remap);\n}\n\nexport default getWsCopyStaticFiles;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yarn-tool/static-file",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/bluelovers/ws-yarn-workspaces/tree/master/packages/@yarn-tool/static-file#readme",
6
6
  "bugs": {
@@ -32,11 +32,11 @@
32
32
  "tsc:showConfig": "ynpx get-current-tsconfig -p"
33
33
  },
34
34
  "dependencies": {
35
- "fs-extra": "^11.2.0",
35
+ "fs-extra": "^11.3.3",
36
36
  "tslib": ">=2"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "ab9a6ddd2269cc9eb3167266928b01d42596176d"
41
+ "gitHead": "ae9b0817b25b1019ba68c88e541bbffc7d84047c"
42
42
  }
@@ -1,2 +0,0 @@
1
- export declare const __ROOT: string;
2
- export declare const isWin: boolean;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isWin = exports.__ROOT = void 0;
4
- const path_1 = require("path");
5
- exports.__ROOT = (0, path_1.join)(__dirname, '..');
6
- exports.isWin = process.platform === "win32";
7
- //# sourceMappingURL=__root.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"__root.js","sourceRoot":"","sources":["__root.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAEf,QAAA,MAAM,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAE/B,QAAA,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC","sourcesContent":["import { join } from \"path\";\n\nexport const __ROOT = join(__dirname, '..');\n\nexport const isWin = process.platform === \"win32\";\n"]}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- const tslib_1 = require("tslib");
3
- const index_1 = tslib_1.__importDefault(require("./index"));
4
- module.exports = index_1.default;
5
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["index.cts"],"names":[],"mappings":";;AAAA,4DAAwB;AAGxB,iBAAS,eAAC,CAAA","sourcesContent":["import _ from './index';\n\n// @ts-ignore\nexport = _\n"]}
@@ -1,2 +0,0 @@
1
- import _ from './index';
2
- export = _;
@@ -1,2 +0,0 @@
1
- export declare const __ROOT_WS: string;
2
- export declare const isWin: boolean;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isWin = exports.__ROOT_WS = void 0;
4
- const path_1 = require("path");
5
- exports.__ROOT_WS = (0, path_1.join)(__dirname);
6
- exports.isWin = process.platform === "win32";
7
- //# sourceMappingURL=__root_ws.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"__root_ws.js","sourceRoot":"","sources":["__root_ws.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAEf,QAAA,SAAS,GAAG,IAAA,WAAI,EAAC,SAAS,CAAC,CAAC;AAE5B,QAAA,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC","sourcesContent":["import { join } from \"path\";\n\nexport const __ROOT_WS = join(__dirname);\n\nexport const isWin = process.platform === \"win32\";\n"]}
File without changes