@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
@@ -1,8 +1,37 @@
1
- const { mixinJestConfig } = require('@bluelovers/jest-config');
1
+ /**
2
+ * 嘗試使用 `@yarn-tool/require-resolve` 載入模組的工具函數
3
+ * Utility function for lazy loading modules
4
+ *
5
+ * @param {string} name - 模組名稱 Module name
6
+ * @param {string[]} [paths] - 搜尋路徑 Search paths
7
+ * @private
8
+ */
9
+ function _lazyRequire(name, paths)
10
+ {
11
+ let m;
12
+ try
13
+ {
14
+ // 嘗試使用 require-resolve 工具載入模組
15
+ // Try to load module using require-resolve tool
16
+ m = require('@yarn-tool/require-resolve').requireExtra(name, {
17
+ includeCurrentDirectory: true,
18
+ includeGlobal: true,
19
+ paths,
20
+ });
21
+ }
22
+ catch (e) {}
23
+
24
+ // 如果失敗則使用標準 require
25
+ // If failed, use standard require
26
+ return typeof m === 'undefined' ? require(name) : m;
27
+ }
28
+
29
+ /** @type {import('@bluelovers/jest-config')} */
30
+ const { mixinJestConfig } = _lazyRequire('@bluelovers/jest-config');
2
31
 
3
32
  /**
4
- * // @type { import('@jest/types').Config.InitialOptions }
5
- * // @type { import('ts-jest').InitialOptionsTsJest }
33
+ * @_type { import('@jest/types').Config.InitialOptions }
34
+ * @_type { import('ts-jest').InitialOptionsTsJest }
6
35
  * @type { import('ts-jest').JestConfigWithTsJest }
7
36
  */
8
37
  const jestConfig = mixinJestConfig({}, true, {
@@ -2,8 +2,9 @@
2
2
  const { resolve } = require('path');
3
3
 
4
4
  /**
5
- * // @type { import('@jest/types').Config.InitialOptions }
6
- * @type { import('ts-jest').InitialOptionsTsJest }
5
+ * @_type { import('@jest/types').Config.InitialOptions }
6
+ * @_type { import('ts-jest').InitialOptionsTsJest }
7
+ * @type { import('ts-jest').JestConfigWithTsJest }
7
8
  */
8
9
  const jestConfig = {
9
10
  preset: __dirname,
package/index.d.ts CHANGED
@@ -1,3 +1,28 @@
1
+ /**
2
+ * @yarn-tool/static-file
3
+ *
4
+ * A utility for copying static configuration files to yarn workspace projects.
5
+ * 用於將靜態配置檔案複製到 yarn 工作區專案的工具。
6
+ *
7
+ * This package provides functionality to copy predefined static files
8
+ * (such as .gitignore, tsconfig.json, etc.) to target directories.
9
+ * 此套件提供將預定義的靜態檔案(如 .gitignore、tsconfig.json 等)
10
+ * 複製到目標目錄的功能。
11
+ *
12
+ * @packageDocumentation
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { copyStaticFiles } from '@yarn-tool/static-file';
17
+ *
18
+ * // Copy default static files to current directory
19
+ * // 將預設靜態檔案複製到當前目錄
20
+ * copyStaticFiles({
21
+ * cwd: process.cwd(),
22
+ * overwrite: true
23
+ * });
24
+ * ```
25
+ */
1
26
  import { copyStaticFiles } from './lib/copyStaticFiles';
2
27
  export { copyStaticFiles };
3
28
  export default copyStaticFiles;
package/index.js CHANGED
@@ -1,6 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.copyStaticFiles = void 0;
4
+ /**
5
+ * @yarn-tool/static-file
6
+ *
7
+ * A utility for copying static configuration files to yarn workspace projects.
8
+ * 用於將靜態配置檔案複製到 yarn 工作區專案的工具。
9
+ *
10
+ * This package provides functionality to copy predefined static files
11
+ * (such as .gitignore, tsconfig.json, etc.) to target directories.
12
+ * 此套件提供將預定義的靜態檔案(如 .gitignore、tsconfig.json 等)
13
+ * 複製到目標目錄的功能。
14
+ *
15
+ * @packageDocumentation
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { copyStaticFiles } from '@yarn-tool/static-file';
20
+ *
21
+ * // Copy default static files to current directory
22
+ * // 將預設靜態檔案複製到當前目錄
23
+ * copyStaticFiles({
24
+ * cwd: process.cwd(),
25
+ * overwrite: true
26
+ * });
27
+ * ```
28
+ */
4
29
  const copyStaticFiles_1 = require("./lib/copyStaticFiles");
5
30
  Object.defineProperty(exports, "copyStaticFiles", { enumerable: true, get: function () { return copyStaticFiles_1.copyStaticFiles; } });
6
31
  exports.default = copyStaticFiles_1.copyStaticFiles;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AAE/C,gGAFA,iCAAe,OAEA;AAExB,kBAAe,iCAAe,CAAC","sourcesContent":["import { copyStaticFiles } from './lib/copyStaticFiles';\n\nexport { copyStaticFiles }\n\nexport default copyStaticFiles;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,2DAAwD;AAE/C,gGAFA,iCAAe,OAEA;AAExB,kBAAe,iCAAe,CAAC","sourcesContent":["/**\n * @yarn-tool/static-file\n *\n * A utility for copying static configuration files to yarn workspace projects.\n * 用於將靜態配置檔案複製到 yarn 工作區專案的工具。\n *\n * This package provides functionality to copy predefined static files\n * (such as .gitignore, tsconfig.json, etc.) to target directories.\n * 此套件提供將預定義的靜態檔案(如 .gitignore、tsconfig.json 等)\n * 複製到目標目錄的功能。\n *\n * @packageDocumentation\n *\n * @example\n * ```typescript\n * import { copyStaticFiles } from '@yarn-tool/static-file';\n *\n * // Copy default static files to current directory\n * // 將預設靜態檔案複製到當前目錄\n * copyStaticFiles({\n * cwd: process.cwd(),\n * overwrite: true\n * });\n * ```\n */\nimport { copyStaticFiles } from './lib/copyStaticFiles';\n\nexport { copyStaticFiles }\n\nexport default copyStaticFiles;\n"]}
package/lib/const.d.ts CHANGED
@@ -1,8 +1,62 @@
1
+ /**
2
+ * Static file mapping constants / 靜態檔案映射常量
3
+ *
4
+ * This module defines the default static file mappings for different project scenarios.
5
+ * 此模組定義了不同專案情境的預設靜態檔案映射。
6
+ *
7
+ * @module const
8
+ */
1
9
  import { _Key, IStaticFilesMapArray } from './types';
2
- declare const _defaultCopyStaticFiles: readonly [readonly [".npmignore", "file/npmignore"], readonly [".gitignore", "file/gitignore"], readonly [".eslintignore", "file/eslintignore"], readonly [".nvmrc", "file/nvmrc"], readonly [".browserslistrc", "file/browserslistrc"], readonly ["tsconfig.json.tpl", "file/tsconfig.json.tpl", "tsconfig.json"], readonly ["test/tsconfig.json.tpl", "file/test/tsconfig.json.tpl", "test/tsconfig.json"], readonly ["tsconfig.esm.json.tpl", "file/tsconfig.esm.json.tpl", "tsconfig.esm.json"], readonly ["tsconfig.tsdx.json.tpl", "file/tsconfig.tsdx.json.tpl", "tsconfig.tsdx.json"], readonly [".eslintrc.json.tpl", "file/eslintrc.json.tpl", ".eslintrc.json"], readonly ["README.md", "file/README.md"], readonly [".nycrc.tpl", "file/nycrc"], readonly [".mocharc.yml.tpl", "file/mocharc.yml"], readonly ["jest.config.js", "file/jest.config.auto.js"], readonly [".nowignore", "file/nowignore"], readonly ["now.json.tpl", "file/now.json.tpl", "now.json"], readonly [".npmrc.tpl", "file/npmrc", ".npmrc"], readonly ["tsdx.config.js.tpl", "file/tsdx.config.js", "tsdx.config.js"], readonly ["tsc-multi.json.tpl", "file/tsc-multi.json.tpl", "tsc-multi.json"], readonly ["test/__root.ts", "file/test/__root.ts"], readonly ["test/fixtures/.gitkeep", "file/test/fixtures/.gitkeep"]];
3
- declare const _defaultCopyStaticFilesRootOnly: readonly [readonly ["lerna.json.tpl", "file/lerna.json.tpl", "lerna.json"], readonly ["pnpm-workspace.yaml.tpl", "file/pnpm-workspace.yaml", "pnpm-workspace.yaml"], readonly [".github/workflows/coverage.yml", "file/github/workflows/coverage.yml"], readonly [".github/workflows/action-yarnlock-dedupe.yml", "file/github/workflows/action-yarnlock-dedupe.yml"], readonly [".github/workflows/build.yml", "file/github/workflows/build.yml"], readonly [".github/workflows/yarn-lock-changes.yml", "file/github/workflows/yarn-lock-changes.yml"], readonly [".github/commit-convention.md", "file/github/commit-convention.md"], readonly ["tsconfig.json", "file/tsconfig.json.tpl", "tsconfig.json"], readonly [".eslintrc.json", "file/eslintrc.json.tpl", ".eslintrc.json"], readonly [".yarnrc.yml.tpl", "file/root/yarnrc.yml", ".yarnrc.yml"], readonly ["jest.config.js", "file/jest.config.js"], readonly ["jest.config.js.tpl", "file/jest.config.js"], readonly ["jest.config.auto.js.tpl", "file/jest.config.auto.js"], readonly [".editorconfig.tpl", "file/tpl.editorconfig"], readonly [".editorconfig", "file/tpl.editorconfig"], readonly ["global.tsdx.d.ts", "file/root/global.tsdx.d.ts"]];
4
- declare const _defaultCopyStaticFilesWsRootOnly: readonly [readonly ["lerna.json.tpl", "file/lerna.json.tpl"], readonly ["pnpm-workspace.yaml", "file/pnpm-workspace.yaml"], readonly ["tsconfig.json", "file/tsconfig.json.tpl"], readonly ["tsc-multi.json.tpl", "file/tsc-multi.json.tpl", "tsc-multi.json"], readonly ["__root_ws.ts", "file/ws-root/__root_ws.ts"], readonly ["jest.config.js", "file/ws-root/jest.config.js"], readonly ["jest-preset.js", "file/ws-root/jest-preset.js"], readonly [".run/lerna_publish_yes.run.xml", "file/ws-root/.run/lerna_publish_yes.run.xml"]];
10
+ /**
11
+ * Default static files for package-level copying / 套件層級複製的預設靜態檔案
12
+ *
13
+ * Contains common configuration files that should be copied to each package.
14
+ * 包含應複製到每個套件的常用配置檔案。
15
+ *
16
+ * Each entry follows the format: [targetFile, staticFile, detectFile?]
17
+ * 每個條目遵循格式:[目標檔案, 靜態檔案, 檢測檔案?]
18
+ *
19
+ * - targetFile: The destination file path / 目標檔案路徑
20
+ * - staticFile: The source static file path (relative to static root) / 來源靜態檔案路徑(相對於靜態根目錄)
21
+ * - detectFile: Optional file to check for existence before copying / 可選的檢測檔案,複製前檢查是否存在
22
+ */
23
+ declare const _defaultCopyStaticFiles: [[".npmignore", "file/npmignore"], [".gitignore", "file/gitignore"], [".eslintignore", "file/eslintignore"], ["tsconfig.json.tpl", "file/tsconfig.json.tpl", "tsconfig.json"], ["test/tsconfig.json.tpl", "file/test/tsconfig.json.tpl", "test/tsconfig.json"], ["test/tsconfig.json", "file/test/tsconfig.json.tpl"], ["tsconfig.esm.json.tpl", "file/tsconfig.esm.json.tpl", "tsconfig.esm.json"], ["tsconfig.tsdx.json.tpl", "file/tsconfig.tsdx.json.tpl", "tsconfig.tsdx.json"], ["tsconfig.json", "file/tsconfig.json.tpl"], [".eslintrc.json.tpl", "file/eslintrc.json.tpl", ".eslintrc.json"], ["README.md", "file/README.md"], [".mocharc.yml.tpl", "file/mocharc.yml"], ["jest.config.js", "file/jest.config.auto.js"], [".nowignore", "file/nowignore"], ["now.json.tpl", "file/now.json.tpl", "now.json"], ["tsdx.config.js.tpl", "file/tsdx.config.js", "tsdx.config.js"], ["test/__root.ts", "file/test/__root.ts"], ["test/fixtures/.gitkeep", "file/test/fixtures/.gitkeep"], ...["test/temp.ts", "file/test/temp.ts"][]];
24
+ /**
25
+ * Default static files for root-level only copying / 僅根目錄層級複製的預設靜態檔案
26
+ *
27
+ * Contains configuration files that should only be copied to the workspace root.
28
+ * 包含僅應複製到工作區根目錄的配置檔案。
29
+ *
30
+ * These files are typically shared across all packages in a monorepo.
31
+ * 這些檔案通常在 monorepo 中的所有套件之間共享。
32
+ */
33
+ declare const _defaultCopyStaticFilesRootOnly: [["lerna.json.tpl", "file/lerna.json.tpl", "lerna.json"], ["pnpm-workspace.yaml.tpl", "file/pnpm-workspace.yaml", "pnpm-workspace.yaml"], [".github/workflows/coverage.yml", "file/github/workflows/coverage.yml"], [".github/workflows/action-yarnlock-dedupe.yml", "file/github/workflows/action-yarnlock-dedupe.yml"], [".github/workflows/build.yml", "file/github/workflows/build.yml"], [".github/workflows/yarn-lock-changes.yml", "file/github/workflows/yarn-lock-changes.yml"], [".github/commit-convention.md", "file/github/commit-convention.md"], ...[".github/dependabot.yml" | ".github/workflows/codeql-analysis.yml" | ".github/workflows/cmd-rebase.yml", "file/github/dependabot.yml" | "file/github/workflows/codeql-analysis.yml" | "file/github/workflows/cmd-rebase.yml"][], [".node-version", "file/nvmrc"], [".nvmrc", "file/nvmrc"], [".eslintrc.json", "file/eslintrc.json.tpl", ".eslintrc.json"], [".yarnrc.yml.tpl", "file/root/yarnrc.yml", ".yarnrc.yml"], [".npmrc.tpl", "file/npmrc", ".npmrc"], ["jest.config.js", "file/jest.config.js"], ["jest.config.js.tpl", "file/jest.config.js"], ["jest.config.auto.js.tpl", "file/jest.config.auto.js"], [".editorconfig.tpl", "file/tpl.editorconfig"], [".editorconfig", "file/tpl.editorconfig"], ["global.tsdx.d.ts", "file/root/global.tsdx.d.ts"], [".browserslistrc", "file/ws-root/browserslistrc"], ["tsc-multi.json.tpl", "file/tsc-multi.json.tpl", "tsc-multi.json"], [".nycrc.tpl", "file/nycrc"]];
34
+ /**
35
+ * Default static files for workspace root only / 僅工作區根目錄的預設靜態檔案
36
+ *
37
+ * Contains files specific to workspace root management.
38
+ * 包含特定於工作區根目錄管理的檔案。
39
+ */
40
+ declare const _defaultCopyStaticFilesWsRootOnly: [["lerna.json.tpl", "file/lerna.json.tpl"], ["pnpm-workspace.yaml", "file/pnpm-workspace.yaml"], ["tsc-multi.json.tpl", "file/tsc-multi.json.tpl", "tsc-multi.json"], ["__root_ws.ts", "file/ws-root/__root_ws.ts"], ["jest.config.js", "file/ws-root/jest.config.js"], ["jest-preset.js", "file/ws-root/jest-preset.js"], [".run/lerna_publish_yes.run.xml", "file/ws-root/.run/lerna_publish_yes.run.xml"]];
41
+ /**
42
+ * Frozen default static files for package-level / 凍結的套件層級預設靜態檔案
43
+ *
44
+ * Use this for copying static files to individual packages.
45
+ * 用於將靜態檔案複製到各個套件。
46
+ */
5
47
  export declare const defaultCopyStaticFiles: IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFiles>>;
48
+ /**
49
+ * Frozen default static files for root-level only / 凍結的僅根目錄層級預設靜態檔案
50
+ *
51
+ * Use this for copying static files to the workspace root only.
52
+ * 用於將靜態檔案僅複製到工作區根目錄。
53
+ */
6
54
  export declare const defaultCopyStaticFilesRootOnly: IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFilesRootOnly>>;
55
+ /**
56
+ * Frozen default static files for workspace root / 凍結的工作區根目錄預設靜態檔案
57
+ *
58
+ * Use this for workspace root specific file management.
59
+ * 用於工作區根目錄特定的檔案管理。
60
+ */
7
61
  export declare const defaultCopyStaticFilesWsRootOnly: IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFilesWsRootOnly>>;
8
62
  export {};
package/lib/const.js CHANGED
@@ -1,61 +1,146 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultCopyStaticFilesWsRootOnly = exports.defaultCopyStaticFilesRootOnly = exports.defaultCopyStaticFiles = void 0;
4
+ /**
5
+ * Default static files for package-level copying / 套件層級複製的預設靜態檔案
6
+ *
7
+ * Contains common configuration files that should be copied to each package.
8
+ * 包含應複製到每個套件的常用配置檔案。
9
+ *
10
+ * Each entry follows the format: [targetFile, staticFile, detectFile?]
11
+ * 每個條目遵循格式:[目標檔案, 靜態檔案, 檢測檔案?]
12
+ *
13
+ * - targetFile: The destination file path / 目標檔案路徑
14
+ * - staticFile: The source static file path (relative to static root) / 來源靜態檔案路徑(相對於靜態根目錄)
15
+ * - detectFile: Optional file to check for existence before copying / 可選的檢測檔案,複製前檢查是否存在
16
+ */
4
17
  const _defaultCopyStaticFiles = [
18
+ // Ignore files / 忽略檔案
5
19
  ['.npmignore', 'file/npmignore'],
6
20
  ['.gitignore', 'file/gitignore'],
7
21
  ['.eslintignore', 'file/eslintignore'],
8
- ['.nvmrc', 'file/nvmrc'],
9
- ['.browserslistrc', 'file/browserslistrc'],
22
+ // TypeScript configuration / TypeScript 配置
10
23
  ['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json'],
11
24
  ['test/tsconfig.json.tpl', 'file/test/tsconfig.json.tpl', 'test/tsconfig.json'],
25
+ ['test/tsconfig.json', 'file/test/tsconfig.json.tpl'],
12
26
  ['tsconfig.esm.json.tpl', 'file/tsconfig.esm.json.tpl', 'tsconfig.esm.json'],
13
27
  ['tsconfig.tsdx.json.tpl', 'file/tsconfig.tsdx.json.tpl', 'tsconfig.tsdx.json'],
28
+ ['tsconfig.json', 'file/tsconfig.json.tpl'],
29
+ // ESLint configuration / ESLint 配置
14
30
  ['.eslintrc.json.tpl', 'file/eslintrc.json.tpl', '.eslintrc.json'],
31
+ // Documentation / 文檔
15
32
  ['README.md', 'file/README.md'],
16
- ['.nycrc.tpl', 'file/nycrc'],
33
+ // Test configuration / 測試配置
17
34
  ['.mocharc.yml.tpl', 'file/mocharc.yml'],
18
35
  //['jest.config.js', 'file/jest.config.js'],
19
36
  ['jest.config.js', 'file/jest.config.auto.js'],
37
+ // Now/Zeit deployment / Now/Zeit 部署配置
20
38
  ['.nowignore', 'file/nowignore'],
21
39
  ['now.json.tpl', 'file/now.json.tpl', 'now.json'],
22
- ['.npmrc.tpl', 'file/npmrc', '.npmrc'],
40
+ // TSDX configuration / TSDX 配置
23
41
  ['tsdx.config.js.tpl', 'file/tsdx.config.js', 'tsdx.config.js'],
24
- ['tsc-multi.json.tpl', 'file/tsc-multi.json.tpl', 'tsc-multi.json'],
42
+ // Test fixtures / 測試固定檔案
25
43
  ['test/__root.ts', 'file/test/__root.ts'],
26
44
  ['test/fixtures/.gitkeep', 'file/test/fixtures/.gitkeep'],
45
+ // Temporary test files / 臨時測試檔案
46
+ ...([
47
+ 'temp.ts',
48
+ ].map(file => [
49
+ `test/${file}`,
50
+ `file/test/${file}`
51
+ ])),
27
52
  //['changelog-option.js.tpl', 'file/changelog-option.js', 'changelog-option.js'],
28
53
  ];
54
+ /**
55
+ * Default static files for root-level only copying / 僅根目錄層級複製的預設靜態檔案
56
+ *
57
+ * Contains configuration files that should only be copied to the workspace root.
58
+ * 包含僅應複製到工作區根目錄的配置檔案。
59
+ *
60
+ * These files are typically shared across all packages in a monorepo.
61
+ * 這些檔案通常在 monorepo 中的所有套件之間共享。
62
+ */
29
63
  const _defaultCopyStaticFilesRootOnly = [
64
+ // Monorepo configuration / Monorepo 配置
30
65
  ['lerna.json.tpl', 'file/lerna.json.tpl', 'lerna.json'],
31
66
  ['pnpm-workspace.yaml.tpl', 'file/pnpm-workspace.yaml', 'pnpm-workspace.yaml'],
67
+ // GitHub Actions workflows / GitHub Actions 工作流程
32
68
  ['.github/workflows/coverage.yml', 'file/github/workflows/coverage.yml'],
33
69
  ['.github/workflows/action-yarnlock-dedupe.yml', 'file/github/workflows/action-yarnlock-dedupe.yml'],
34
70
  ['.github/workflows/build.yml', 'file/github/workflows/build.yml'],
35
71
  ['.github/workflows/yarn-lock-changes.yml', 'file/github/workflows/yarn-lock-changes.yml'],
36
72
  ['.github/commit-convention.md', 'file/github/commit-convention.md'],
37
- ['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json'],
73
+ // Additional GitHub configuration / 額外的 GitHub 配置
74
+ ...([
75
+ 'dependabot.yml',
76
+ 'workflows/codeql-analysis.yml',
77
+ 'workflows/cmd-rebase.yml',
78
+ ].map(file => [`.github/${file}`, `file/github/${file}`])),
79
+ // Node version files / Node 版本檔案
80
+ ['.node-version', 'file/nvmrc'],
81
+ ['.nvmrc', 'file/nvmrc'],
82
+ // Root TypeScript configuration / 根目錄 TypeScript 配置
38
83
  ['.eslintrc.json', 'file/eslintrc.json.tpl', '.eslintrc.json'],
39
84
  //['changelog-option.js', 'file/changelog-option.js', 'changelog-option.js.tpl'],
85
+ // Package manager configuration / 套件管理器配置
40
86
  ['.yarnrc.yml.tpl', 'file/root/yarnrc.yml', '.yarnrc.yml'],
87
+ ['.npmrc.tpl', 'file/npmrc', '.npmrc'],
88
+ // Jest configuration / Jest 配置
41
89
  ['jest.config.js', 'file/jest.config.js'],
42
90
  ['jest.config.js.tpl', 'file/jest.config.js'],
43
91
  ['jest.config.auto.js.tpl', 'file/jest.config.auto.js'],
92
+ // Editor configuration / 編輯器配置
44
93
  ['.editorconfig.tpl', 'file/tpl.editorconfig'],
45
94
  ['.editorconfig', 'file/tpl.editorconfig'],
95
+ // Global type declarations / 全局類型聲明
46
96
  ['global.tsdx.d.ts', 'file/root/global.tsdx.d.ts'],
97
+ // Browserslist configuration / Browserslist 配置
98
+ ['.browserslistrc', 'file/ws-root/browserslistrc'],
99
+ // TSC multi configuration / TSC 多配置
100
+ ['tsc-multi.json.tpl', 'file/tsc-multi.json.tpl', 'tsc-multi.json'],
101
+ // NYC coverage configuration / NYC 覆蓋率配置
102
+ ['.nycrc.tpl', 'file/nycrc'],
47
103
  ];
104
+ /**
105
+ * Default static files for workspace root only / 僅工作區根目錄的預設靜態檔案
106
+ *
107
+ * Contains files specific to workspace root management.
108
+ * 包含特定於工作區根目錄管理的檔案。
109
+ */
48
110
  const _defaultCopyStaticFilesWsRootOnly = [
111
+ // Lerna configuration / Lerna 配置
49
112
  ['lerna.json.tpl', 'file/lerna.json.tpl'],
113
+ // pnpm workspace configuration / pnpm 工作區配置
50
114
  ['pnpm-workspace.yaml', 'file/pnpm-workspace.yaml'],
51
- ['tsconfig.json', 'file/tsconfig.json.tpl'],
115
+ // TSC multi configuration / TSC 多配置
52
116
  ['tsc-multi.json.tpl', 'file/tsc-multi.json.tpl', 'tsc-multi.json'],
117
+ // Workspace root file / 工作區根目錄檔案
53
118
  ['__root_ws.ts', 'file/ws-root/__root_ws.ts'],
119
+ // Jest configuration / Jest 配置
54
120
  ['jest.config.js', 'file/ws-root/jest.config.js'],
55
121
  ['jest-preset.js', 'file/ws-root/jest-preset.js'],
122
+ // Run configurations / 執行配置
56
123
  ['.run/lerna_publish_yes.run.xml', 'file/ws-root/.run/lerna_publish_yes.run.xml'],
57
124
  ];
125
+ /**
126
+ * Frozen default static files for package-level / 凍結的套件層級預設靜態檔案
127
+ *
128
+ * Use this for copying static files to individual packages.
129
+ * 用於將靜態檔案複製到各個套件。
130
+ */
58
131
  exports.defaultCopyStaticFiles = Object.freeze(_defaultCopyStaticFiles);
132
+ /**
133
+ * Frozen default static files for root-level only / 凍結的僅根目錄層級預設靜態檔案
134
+ *
135
+ * Use this for copying static files to the workspace root only.
136
+ * 用於將靜態檔案僅複製到工作區根目錄。
137
+ */
59
138
  exports.defaultCopyStaticFilesRootOnly = Object.freeze(_defaultCopyStaticFilesRootOnly);
139
+ /**
140
+ * Frozen default static files for workspace root / 凍結的工作區根目錄預設靜態檔案
141
+ *
142
+ * Use this for workspace root specific file management.
143
+ * 用於工作區根目錄特定的檔案管理。
144
+ */
60
145
  exports.defaultCopyStaticFilesWsRootOnly = Object.freeze(_defaultCopyStaticFilesWsRootOnly);
61
146
  //# sourceMappingURL=const.js.map
package/lib/const.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"","sources":["const.ts"],"names":[],"mappings":"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","sourcesContent":["import { _Key, IStaticFilesKey, IStaticFilesMapArray } from './types';\n\nconst _defaultCopyStaticFiles = [\n\n\t['.npmignore', 'file/npmignore'],\n\t['.gitignore', 'file/gitignore'],\n\n\t['.eslintignore', 'file/eslintignore'],\n\n\t['.nvmrc', 'file/nvmrc'],\n\t['.browserslistrc', 'file/browserslistrc'],\n\n\t['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json'],\n\n\t['test/tsconfig.json.tpl', 'file/test/tsconfig.json.tpl', 'test/tsconfig.json'],\n\n\t['tsconfig.esm.json.tpl', 'file/tsconfig.esm.json.tpl', 'tsconfig.esm.json'],\n\n\t['tsconfig.tsdx.json.tpl', 'file/tsconfig.tsdx.json.tpl', 'tsconfig.tsdx.json'],\n\n\t['.eslintrc.json.tpl', 'file/eslintrc.json.tpl', '.eslintrc.json'],\n\n\t['README.md', 'file/README.md'],\n\n\t['.nycrc.tpl', 'file/nycrc'],\n\n\t['.mocharc.yml.tpl', 'file/mocharc.yml'],\n\t//['jest.config.js', 'file/jest.config.js'],\n\t['jest.config.js', 'file/jest.config.auto.js'],\n\n\t['.nowignore', 'file/nowignore'],\n\n\t['now.json.tpl', 'file/now.json.tpl', 'now.json'],\n\n\t['.npmrc.tpl', 'file/npmrc', '.npmrc'],\n\n\t['tsdx.config.js.tpl', 'file/tsdx.config.js', 'tsdx.config.js'],\n\n\t['tsc-multi.json.tpl', 'file/tsc-multi.json.tpl', 'tsc-multi.json'],\n\n\t['test/__root.ts', 'file/test/__root.ts'],\n\t['test/fixtures/.gitkeep', 'file/test/fixtures/.gitkeep'],\n\n\t//['changelog-option.js.tpl', 'file/changelog-option.js', 'changelog-option.js'],\n\n] as const;\n\nconst _defaultCopyStaticFilesRootOnly = [\n\n\t['lerna.json.tpl', 'file/lerna.json.tpl', 'lerna.json'],\n\n\t['pnpm-workspace.yaml.tpl', 'file/pnpm-workspace.yaml', 'pnpm-workspace.yaml'],\n\n\t['.github/workflows/coverage.yml', 'file/github/workflows/coverage.yml'],\n\n\t['.github/workflows/action-yarnlock-dedupe.yml', 'file/github/workflows/action-yarnlock-dedupe.yml'],\n\n\t['.github/workflows/build.yml', 'file/github/workflows/build.yml'],\n\n\t['.github/workflows/yarn-lock-changes.yml', 'file/github/workflows/yarn-lock-changes.yml'],\n\n\t['.github/commit-convention.md', 'file/github/commit-convention.md'],\n\n\t['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json'],\n\n\t['.eslintrc.json', 'file/eslintrc.json.tpl', '.eslintrc.json'],\n\n\t//['changelog-option.js', 'file/changelog-option.js', 'changelog-option.js.tpl'],\n\n\t['.yarnrc.yml.tpl', 'file/root/yarnrc.yml', '.yarnrc.yml'],\n\n\t['jest.config.js', 'file/jest.config.js'],\n\n\t['jest.config.js.tpl', 'file/jest.config.js'],\n\t['jest.config.auto.js.tpl', 'file/jest.config.auto.js'],\n\n\t['.editorconfig.tpl', 'file/tpl.editorconfig'],\n\t['.editorconfig', 'file/tpl.editorconfig'],\n\n\t['global.tsdx.d.ts', 'file/root/global.tsdx.d.ts'],\n\n] as const;\n\nconst _defaultCopyStaticFilesWsRootOnly = [\n\n\t['lerna.json.tpl', 'file/lerna.json.tpl'],\n\n\t['pnpm-workspace.yaml', 'file/pnpm-workspace.yaml'],\n\n\t['tsconfig.json', 'file/tsconfig.json.tpl'],\n\n\t['tsc-multi.json.tpl', 'file/tsc-multi.json.tpl', 'tsc-multi.json'],\n\n\t['__root_ws.ts', 'file/ws-root/__root_ws.ts'],\n\n\t['jest.config.js', 'file/ws-root/jest.config.js'],\n\t['jest-preset.js', 'file/ws-root/jest-preset.js'],\n\n\t['.run/lerna_publish_yes.run.xml', 'file/ws-root/.run/lerna_publish_yes.run.xml'],\n\n] as const;\n\nexport const defaultCopyStaticFiles = Object.freeze(_defaultCopyStaticFiles) as any as IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFiles>>;\n\nexport const defaultCopyStaticFilesRootOnly = Object.freeze(_defaultCopyStaticFilesRootOnly) as any as IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFilesRootOnly>>;\n\nexport const defaultCopyStaticFilesWsRootOnly = Object.freeze(_defaultCopyStaticFilesWsRootOnly) as any as IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFilesWsRootOnly>>;\n"]}
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["const.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Static file mapping constants / 靜態檔案映射常量\n *\n * This module defines the default static file mappings for different project scenarios.\n * 此模組定義了不同專案情境的預設靜態檔案映射。\n *\n * @module const\n */\nimport { _Key, IStaticFilesKey, IStaticFilesMapArray, IStaticFilesMapArrayEntry } from './types';\n\n/**\n * Default static files for package-level copying / 套件層級複製的預設靜態檔案\n *\n * Contains common configuration files that should be copied to each package.\n * 包含應複製到每個套件的常用配置檔案。\n *\n * Each entry follows the format: [targetFile, staticFile, detectFile?]\n * 每個條目遵循格式:[目標檔案, 靜態檔案, 檢測檔案?]\n *\n * - targetFile: The destination file path / 目標檔案路徑\n * - staticFile: The source static file path (relative to static root) / 來源靜態檔案路徑(相對於靜態根目錄)\n * - detectFile: Optional file to check for existence before copying / 可選的檢測檔案,複製前檢查是否存在\n */\nconst _defaultCopyStaticFiles = [\n\n\t// Ignore files / 忽略檔案\n\t['.npmignore', 'file/npmignore'],\n\t['.gitignore', 'file/gitignore'],\n\t['.eslintignore', 'file/eslintignore'],\n\n\t// TypeScript configuration / TypeScript 配置\n\t['tsconfig.json.tpl', 'file/tsconfig.json.tpl', 'tsconfig.json'],\n\n\t['test/tsconfig.json.tpl', 'file/test/tsconfig.json.tpl', 'test/tsconfig.json'],\n\t['test/tsconfig.json', 'file/test/tsconfig.json.tpl'],\n\n\t['tsconfig.esm.json.tpl', 'file/tsconfig.esm.json.tpl', 'tsconfig.esm.json'],\n\t['tsconfig.tsdx.json.tpl', 'file/tsconfig.tsdx.json.tpl', 'tsconfig.tsdx.json'],\n\n\t['tsconfig.json', 'file/tsconfig.json.tpl'],\n\n\t// ESLint configuration / ESLint 配置\n\t['.eslintrc.json.tpl', 'file/eslintrc.json.tpl', '.eslintrc.json'],\n\n\t// Documentation / 文檔\n\t['README.md', 'file/README.md'],\n\n\t// Test configuration / 測試配置\n\t['.mocharc.yml.tpl', 'file/mocharc.yml'],\n\t//['jest.config.js', 'file/jest.config.js'],\n\t['jest.config.js', 'file/jest.config.auto.js'],\n\n\t// Now/Zeit deployment / Now/Zeit 部署配置\n\t['.nowignore', 'file/nowignore'],\n\t['now.json.tpl', 'file/now.json.tpl', 'now.json'],\n\n\t// TSDX configuration / TSDX 配置\n\t['tsdx.config.js.tpl', 'file/tsdx.config.js', 'tsdx.config.js'],\n\n\t// Test fixtures / 測試固定檔案\n\t['test/__root.ts', 'file/test/__root.ts'],\n\t['test/fixtures/.gitkeep', 'file/test/fixtures/.gitkeep'],\n\n\t// Temporary test files / 臨時測試檔案\n\t...(([\n\t\t'temp.ts',\n\t] as const).map(file => [\n\t\t`test/${file}`,\n\t\t`file/test/${file}`\n\t] as const satisfies IStaticFilesMapArrayEntry<string>)),\n\n\t//['changelog-option.js.tpl', 'file/changelog-option.js', 'changelog-option.js'],\n\n] as const satisfies IStaticFilesMapArray<string>;\n\n/**\n * Default static files for root-level only copying / 僅根目錄層級複製的預設靜態檔案\n *\n * Contains configuration files that should only be copied to the workspace root.\n * 包含僅應複製到工作區根目錄的配置檔案。\n *\n * These files are typically shared across all packages in a monorepo.\n * 這些檔案通常在 monorepo 中的所有套件之間共享。\n */\nconst _defaultCopyStaticFilesRootOnly = [\n\n\t// Monorepo configuration / Monorepo 配置\n\t['lerna.json.tpl', 'file/lerna.json.tpl', 'lerna.json'],\n\t['pnpm-workspace.yaml.tpl', 'file/pnpm-workspace.yaml', 'pnpm-workspace.yaml'],\n\n\t// GitHub Actions workflows / GitHub Actions 工作流程\n\t['.github/workflows/coverage.yml', 'file/github/workflows/coverage.yml'],\n\t['.github/workflows/action-yarnlock-dedupe.yml', 'file/github/workflows/action-yarnlock-dedupe.yml'],\n\t['.github/workflows/build.yml', 'file/github/workflows/build.yml'],\n\t['.github/workflows/yarn-lock-changes.yml', 'file/github/workflows/yarn-lock-changes.yml'],\n\t['.github/commit-convention.md', 'file/github/commit-convention.md'],\n\n\t// Additional GitHub configuration / 額外的 GitHub 配置\n\t...(([\n\t\t'dependabot.yml',\n\t\t'workflows/codeql-analysis.yml',\n\t\t'workflows/cmd-rebase.yml',\n\t] as const).map(file => [`.github/${file}`, `file/github/${file}`] as const satisfies IStaticFilesMapArrayEntry<string>)),\n\n\t// Node version files / Node 版本檔案\n\t['.node-version', 'file/nvmrc'],\n\t['.nvmrc', 'file/nvmrc'],\n\n\t// Root TypeScript configuration / 根目錄 TypeScript 配置\n\t['.eslintrc.json', 'file/eslintrc.json.tpl', '.eslintrc.json'],\n\n\t//['changelog-option.js', 'file/changelog-option.js', 'changelog-option.js.tpl'],\n\n\t// Package manager configuration / 套件管理器配置\n\t['.yarnrc.yml.tpl', 'file/root/yarnrc.yml', '.yarnrc.yml'],\n\t['.npmrc.tpl', 'file/npmrc', '.npmrc'],\n\n\t// Jest configuration / Jest 配置\n\t['jest.config.js', 'file/jest.config.js'],\n\t['jest.config.js.tpl', 'file/jest.config.js'],\n\t['jest.config.auto.js.tpl', 'file/jest.config.auto.js'],\n\n\t// Editor configuration / 編輯器配置\n\t['.editorconfig.tpl', 'file/tpl.editorconfig'],\n\t['.editorconfig', 'file/tpl.editorconfig'],\n\n\t// Global type declarations / 全局類型聲明\n\t['global.tsdx.d.ts', 'file/root/global.tsdx.d.ts'],\n\n\t// Browserslist configuration / Browserslist 配置\n\t['.browserslistrc', 'file/ws-root/browserslistrc'],\n\n\t// TSC multi configuration / TSC 多配置\n\t['tsc-multi.json.tpl', 'file/tsc-multi.json.tpl', 'tsc-multi.json'],\n\n\t// NYC coverage configuration / NYC 覆蓋率配置\n\t['.nycrc.tpl', 'file/nycrc'],\n\n] as const satisfies IStaticFilesMapArray<string>;\n\n/**\n * Default static files for workspace root only / 僅工作區根目錄的預設靜態檔案\n *\n * Contains files specific to workspace root management.\n * 包含特定於工作區根目錄管理的檔案。\n */\nconst _defaultCopyStaticFilesWsRootOnly = [\n\n\t// Lerna configuration / Lerna 配置\n\t['lerna.json.tpl', 'file/lerna.json.tpl'],\n\n\t// pnpm workspace configuration / pnpm 工作區配置\n\t['pnpm-workspace.yaml', 'file/pnpm-workspace.yaml'],\n\n\t// TSC multi configuration / TSC 多配置\n\t['tsc-multi.json.tpl', 'file/tsc-multi.json.tpl', 'tsc-multi.json'],\n\n\t// Workspace root file / 工作區根目錄檔案\n\t['__root_ws.ts', 'file/ws-root/__root_ws.ts'],\n\n\t// Jest configuration / Jest 配置\n\t['jest.config.js', 'file/ws-root/jest.config.js'],\n\t['jest-preset.js', 'file/ws-root/jest-preset.js'],\n\n\t// Run configurations / 執行配置\n\t['.run/lerna_publish_yes.run.xml', 'file/ws-root/.run/lerna_publish_yes.run.xml'],\n\n] as const satisfies IStaticFilesMapArray<string>;\n\n/**\n * Frozen default static files for package-level / 凍結的套件層級預設靜態檔案\n *\n * Use this for copying static files to individual packages.\n * 用於將靜態檔案複製到各個套件。\n */\nexport const defaultCopyStaticFiles = Object.freeze(_defaultCopyStaticFiles) as any as IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFiles>>;\n\n/**\n * Frozen default static files for root-level only / 凍結的僅根目錄層級預設靜態檔案\n *\n * Use this for copying static files to the workspace root only.\n * 用於將靜態檔案僅複製到工作區根目錄。\n */\nexport const defaultCopyStaticFilesRootOnly = Object.freeze(_defaultCopyStaticFilesRootOnly) as any as IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFilesRootOnly>>;\n\n/**\n * Frozen default static files for workspace root / 凍結的工作區根目錄預設靜態檔案\n *\n * Use this for workspace root specific file management.\n * 用於工作區根目錄特定的檔案管理。\n */\nexport const defaultCopyStaticFilesWsRootOnly = Object.freeze(_defaultCopyStaticFilesWsRootOnly) as any as IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFilesWsRootOnly>>;\n"]}
@@ -1,2 +1,52 @@
1
+ /**
2
+ * Copy static files main function / 複製靜態檔案主函數
3
+ *
4
+ * This module provides the main function for copying static files to a target directory.
5
+ * 此模組提供將靜態檔案複製到目標目錄的主函數。
6
+ *
7
+ * @module copyStaticFiles
8
+ */
1
9
  import { ICopyStaticFilesOptions, IStaticFilesMapArrayEntry } from './types';
10
+ /**
11
+ * Copy static files to a target directory / 將靜態檔案複製到目標目錄
12
+ *
13
+ * Copies static files based on the provided file map configuration.
14
+ * 根據提供的檔案映射配置複製靜態檔案。
15
+ *
16
+ * @template K - The target file path type / 目標檔案路徑類型
17
+ *
18
+ * @param options - Copy options / 複製選項
19
+ * @param options.cwd - Current working directory (required) / 當前工作目錄(必填)
20
+ * @param options.staticRoot - Root directory of static files (defaults to package root) / 靜態檔案根目錄(預設為套件根目錄)
21
+ * @param options.overwrite - Whether to overwrite existing files / 是否覆蓋已存在的檔案
22
+ * @param options.file_map - Custom file mapping configuration / 自訂檔案映射配置
23
+ *
24
+ * @returns Array of entries that were successfully copied / 成功複製的條目陣列
25
+ *
26
+ * @throws {TypeError} When options.cwd is not a valid string / 當 options.cwd 不是有效的字串時
27
+ * @throws {TypeError} When options.cwd directory does not exist / 當 options.cwd 目錄不存在時
28
+ * @throws {TypeError} When file_map is invalid / 當 file_map 無效時
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { copyStaticFiles } from '@yarn-tool/static-file';
33
+ *
34
+ * // Copy default static files to current directory
35
+ * // 複製預設靜態檔案到當前目錄
36
+ * copyStaticFiles({
37
+ * cwd: process.cwd(),
38
+ * overwrite: true
39
+ * });
40
+ *
41
+ * // Copy with custom file map
42
+ * // 使用自訂檔案映射複製
43
+ * copyStaticFiles({
44
+ * cwd: '/path/to/project',
45
+ * file_map: [
46
+ * ['.gitignore', 'file/gitignore'],
47
+ * ['README.md', 'file/README.md']
48
+ * ]
49
+ * });
50
+ * ```
51
+ */
2
52
  export declare function copyStaticFiles<K extends string>(options: ICopyStaticFilesOptions<K>): IStaticFilesMapArrayEntry<string | K>[];
@@ -6,20 +6,68 @@ const const_1 = require("./const");
6
6
  const parseStaticMap_1 = require("./parseStaticMap");
7
7
  const copyStaticFilesEntry_1 = require("./copyStaticFilesEntry");
8
8
  const __root_1 = require("../__root");
9
+ /**
10
+ * Copy static files to a target directory / 將靜態檔案複製到目標目錄
11
+ *
12
+ * Copies static files based on the provided file map configuration.
13
+ * 根據提供的檔案映射配置複製靜態檔案。
14
+ *
15
+ * @template K - The target file path type / 目標檔案路徑類型
16
+ *
17
+ * @param options - Copy options / 複製選項
18
+ * @param options.cwd - Current working directory (required) / 當前工作目錄(必填)
19
+ * @param options.staticRoot - Root directory of static files (defaults to package root) / 靜態檔案根目錄(預設為套件根目錄)
20
+ * @param options.overwrite - Whether to overwrite existing files / 是否覆蓋已存在的檔案
21
+ * @param options.file_map - Custom file mapping configuration / 自訂檔案映射配置
22
+ *
23
+ * @returns Array of entries that were successfully copied / 成功複製的條目陣列
24
+ *
25
+ * @throws {TypeError} When options.cwd is not a valid string / 當 options.cwd 不是有效的字串時
26
+ * @throws {TypeError} When options.cwd directory does not exist / 當 options.cwd 目錄不存在時
27
+ * @throws {TypeError} When file_map is invalid / 當 file_map 無效時
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { copyStaticFiles } from '@yarn-tool/static-file';
32
+ *
33
+ * // Copy default static files to current directory
34
+ * // 複製預設靜態檔案到當前目錄
35
+ * copyStaticFiles({
36
+ * cwd: process.cwd(),
37
+ * overwrite: true
38
+ * });
39
+ *
40
+ * // Copy with custom file map
41
+ * // 使用自訂檔案映射複製
42
+ * copyStaticFiles({
43
+ * cwd: '/path/to/project',
44
+ * file_map: [
45
+ * ['.gitignore', 'file/gitignore'],
46
+ * ['README.md', 'file/README.md']
47
+ * ]
48
+ * });
49
+ * ```
50
+ */
9
51
  function copyStaticFiles(options) {
10
52
  var _a, _b;
53
+ // Validate cwd parameter / 驗證 cwd 參數
11
54
  if (typeof options.cwd !== 'string' || !((_a = options.cwd) === null || _a === void 0 ? void 0 : _a.length) || !options.cwd) {
12
55
  throw new TypeError(`options.cwd must is string`);
13
56
  }
57
+ // Check if cwd directory exists / 檢查 cwd 目錄是否存在
14
58
  if (!(0, fs_extra_1.pathExistsSync)(options.cwd)) {
15
59
  throw new TypeError(`options.cwd not exists`);
16
60
  }
61
+ // Parse the file map / 解析檔案映射
17
62
  let ls = (0, parseStaticMap_1.parseStaticMap)((_b = options.file_map) !== null && _b !== void 0 ? _b : const_1.defaultCopyStaticFiles);
63
+ // Validate parsed file map / 驗證解析後的檔案映射
18
64
  if (!ls.length) {
19
65
  throw new TypeError(`Invalid file map: ${options.file_map}`);
20
66
  }
67
+ // Determine static root directory / 確定靜態檔案根目錄
21
68
  const staticRoot = options.staticRoot || __root_1.__STATIC_ROOT;
22
69
  const { cwd, overwrite } = options;
70
+ // Filter and copy files / 過濾並複製檔案
23
71
  return ls.filter((entry) => {
24
72
  return (0, copyStaticFilesEntry_1.copyStaticFilesEntry)(entry, cwd, staticRoot, overwrite);
25
73
  });
@@ -1 +1 @@
1
- {"version":3,"file":"copyStaticFiles.js","sourceRoot":"","sources":["copyStaticFiles.ts"],"names":[],"mappings":";;AAQA,0CA2BC;AAlCD,uCAAgG;AAEhG,mCAAiD;AACjD,qDAAkD;AAClD,iEAA8D;AAC9D,sCAA0C;AAE1C,SAAgB,eAAe,CAAmB,OAAmC;;IAEpF,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,GAAG,0CAAE,MAAM,CAAA,IAAI,CAAC,OAAO,CAAC,GAAG,EAC3E,CAAC;QACA,MAAM,IAAI,SAAS,CAAC,4BAA4B,CAAC,CAAA;IAClD,CAAC;IAED,IAAI,CAAC,IAAA,yBAAc,EAAC,OAAO,CAAC,GAAG,CAAC,EAChC,CAAC;QACA,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,EAAE,GAAG,IAAA,+BAAc,EAAI,MAAA,OAAO,CAAC,QAAQ,mCAAI,8BAAiD,CAAC,CAAC;IAElG,IAAI,CAAC,EAAE,CAAC,MAAM,EACd,CAAC;QACA,MAAM,IAAI,SAAS,CAAC,qBAAqB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC7D,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,sBAAa,CAAC;IACvD,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEnC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAEzB,OAAO,IAAA,2CAAoB,EAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;IAC/D,CAAC,CAAC,CACD;AACH,CAAC","sourcesContent":["import { ICopyStaticFilesOptions, IStaticFilesMapArray, IStaticFilesMapArrayEntry } from './types';\nimport { CopyOptionsSync, copySync, ensureDirSync, existsSync, pathExistsSync } from 'fs-extra';\nimport { dirname, resolve } from 'path';\nimport { defaultCopyStaticFiles } from './const';\nimport { parseStaticMap } from './parseStaticMap';\nimport { copyStaticFilesEntry } from './copyStaticFilesEntry';\nimport { __STATIC_ROOT } from '../__root';\n\nexport function copyStaticFiles<K extends string>(options: ICopyStaticFilesOptions<K>)\n{\n\tif (typeof options.cwd !== 'string' || !options.cwd?.length || !options.cwd)\n\t{\n\t\tthrow new TypeError(`options.cwd must is string`)\n\t}\n\n\tif (!pathExistsSync(options.cwd))\n\t{\n\t\tthrow new TypeError(`options.cwd not exists`)\n\t}\n\n\tlet ls = parseStaticMap<K>(options.file_map ?? defaultCopyStaticFiles as IStaticFilesMapArray<K>);\n\n\tif (!ls.length)\n\t{\n\t\tthrow new TypeError(`Invalid file map: ${options.file_map}`)\n\t}\n\n\tconst staticRoot = options.staticRoot || __STATIC_ROOT;\n\tconst { cwd, overwrite } = options;\n\n\treturn ls.filter((entry) =>\n\t\t{\n\t\t\treturn copyStaticFilesEntry(entry, cwd, staticRoot, overwrite)\n\t\t})\n\t\t;\n}\n"]}
1
+ {"version":3,"file":"copyStaticFiles.js","sourceRoot":"","sources":["copyStaticFiles.ts"],"names":[],"mappings":";;AA0DA,0CAiCC;AAlFD,uCAAgG;AAEhG,mCAAiD;AACjD,qDAAkD;AAClD,iEAA8D;AAC9D,sCAA0C;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,SAAgB,eAAe,CAAmB,OAAmC;;IAEpF,qCAAqC;IACrC,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,GAAG,0CAAE,MAAM,CAAA,IAAI,CAAC,OAAO,CAAC,GAAG,EAC3E,CAAC;QACA,MAAM,IAAI,SAAS,CAAC,4BAA4B,CAAC,CAAA;IAClD,CAAC;IAED,gDAAgD;IAChD,IAAI,CAAC,IAAA,yBAAc,EAAC,OAAO,CAAC,GAAG,CAAC,EAChC,CAAC;QACA,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC,CAAA;IAC9C,CAAC;IAED,8BAA8B;IAC9B,IAAI,EAAE,GAAG,IAAA,+BAAc,EAAI,MAAA,OAAO,CAAC,QAAQ,mCAAI,8BAAiD,CAAC,CAAC;IAElG,wCAAwC;IACxC,IAAI,CAAC,EAAE,CAAC,MAAM,EACd,CAAC;QACA,MAAM,IAAI,SAAS,CAAC,qBAAqB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC7D,CAAC;IAED,8CAA8C;IAC9C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,sBAAa,CAAC;IACvD,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEnC,kCAAkC;IAClC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAEzB,OAAO,IAAA,2CAAoB,EAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;IAC/D,CAAC,CAAC,CACD;AACH,CAAC","sourcesContent":["/**\n * Copy static files main function / 複製靜態檔案主函數\n *\n * This module provides the main function for copying static files to a target directory.\n * 此模組提供將靜態檔案複製到目標目錄的主函數。\n *\n * @module copyStaticFiles\n */\nimport { ICopyStaticFilesOptions, IStaticFilesMapArray, IStaticFilesMapArrayEntry } from './types';\nimport { CopyOptionsSync, copySync, ensureDirSync, existsSync, pathExistsSync } from 'fs-extra';\nimport { dirname, resolve } from 'path';\nimport { defaultCopyStaticFiles } from './const';\nimport { parseStaticMap } from './parseStaticMap';\nimport { copyStaticFilesEntry } from './copyStaticFilesEntry';\nimport { __STATIC_ROOT } from '../__root';\n\n/**\n * Copy static files to a target directory / 將靜態檔案複製到目標目錄\n *\n * Copies static files based on the provided file map configuration.\n * 根據提供的檔案映射配置複製靜態檔案。\n *\n * @template K - The target file path type / 目標檔案路徑類型\n *\n * @param options - Copy options / 複製選項\n * @param options.cwd - Current working directory (required) / 當前工作目錄(必填)\n * @param options.staticRoot - Root directory of static files (defaults to package root) / 靜態檔案根目錄(預設為套件根目錄)\n * @param options.overwrite - Whether to overwrite existing files / 是否覆蓋已存在的檔案\n * @param options.file_map - Custom file mapping configuration / 自訂檔案映射配置\n *\n * @returns Array of entries that were successfully copied / 成功複製的條目陣列\n *\n * @throws {TypeError} When options.cwd is not a valid string / 當 options.cwd 不是有效的字串時\n * @throws {TypeError} When options.cwd directory does not exist / 當 options.cwd 目錄不存在時\n * @throws {TypeError} When file_map is invalid / 當 file_map 無效時\n *\n * @example\n * ```typescript\n * import { copyStaticFiles } from '@yarn-tool/static-file';\n *\n * // Copy default static files to current directory\n * // 複製預設靜態檔案到當前目錄\n * copyStaticFiles({\n * cwd: process.cwd(),\n * overwrite: true\n * });\n *\n * // Copy with custom file map\n * // 使用自訂檔案映射複製\n * copyStaticFiles({\n * cwd: '/path/to/project',\n * file_map: [\n * ['.gitignore', 'file/gitignore'],\n * ['README.md', 'file/README.md']\n * ]\n * });\n * ```\n */\nexport function copyStaticFiles<K extends string>(options: ICopyStaticFilesOptions<K>)\n{\n\t// Validate cwd parameter / 驗證 cwd 參數\n\tif (typeof options.cwd !== 'string' || !options.cwd?.length || !options.cwd)\n\t{\n\t\tthrow new TypeError(`options.cwd must is string`)\n\t}\n\n\t// Check if cwd directory exists / 檢查 cwd 目錄是否存在\n\tif (!pathExistsSync(options.cwd))\n\t{\n\t\tthrow new TypeError(`options.cwd not exists`)\n\t}\n\n\t// Parse the file map / 解析檔案映射\n\tlet ls = parseStaticMap<K>(options.file_map ?? defaultCopyStaticFiles as IStaticFilesMapArray<K>);\n\n\t// Validate parsed file map / 驗證解析後的檔案映射\n\tif (!ls.length)\n\t{\n\t\tthrow new TypeError(`Invalid file map: ${options.file_map}`)\n\t}\n\n\t// Determine static root directory / 確定靜態檔案根目錄\n\tconst staticRoot = options.staticRoot || __STATIC_ROOT;\n\tconst { cwd, overwrite } = options;\n\n\t// Filter and copy files / 過濾並複製檔案\n\treturn ls.filter((entry) =>\n\t\t{\n\t\t\treturn copyStaticFilesEntry(entry, cwd, staticRoot, overwrite)\n\t\t})\n\t\t;\n}\n"]}
@@ -1,2 +1,52 @@
1
+ /**
2
+ * Copy single static file entry / 複製單個靜態檔案條目
3
+ *
4
+ * This module provides the function for copying a single static file entry.
5
+ * 此模組提供複製單個靜態檔案條目的函數。
6
+ *
7
+ * @module copyStaticFilesEntry
8
+ */
1
9
  import { IStaticFilesMapArrayEntry } from './types';
10
+ /**
11
+ * Copy a single static file entry / 複製單個靜態檔案條目
12
+ *
13
+ * Copies a single static file from the static root to the target directory.
14
+ * 從靜態根目錄複製單個靜態檔案到目標目錄。
15
+ *
16
+ * @param entry - The static file entry / 靜態檔案條目
17
+ * @param entry.0 - targetFile: Target file path / 目標檔案路徑
18
+ * @param entry.1 - staticFile: Source static file path / 來源靜態檔案路徑
19
+ * @param entry.2 - detectFile: Optional file to check for existence / 可選的檢測檔案
20
+ *
21
+ * @param cwd - Current working directory / 當前工作目錄
22
+ * @param staticRoot - Root directory of static files (defaults to package root) / 靜態檔案根目錄(預設為套件根目錄)
23
+ * @param overwrite - Whether to overwrite existing files (defaults to false) / 是否覆蓋已存在的檔案(預設為 false)
24
+ *
25
+ * @returns true if file was copied, undefined if skipped (detect file exists) / 如果檔案已複製則返回 true,如果跳過(檢測檔案存在)則返回 undefined
26
+ *
27
+ * @throws {Error} When the source static file does not exist / 當來源靜態檔案不存在時
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { copyStaticFilesEntry } from '@yarn-tool/static-file';
32
+ *
33
+ * // Copy a single file
34
+ * // 複製單個檔案
35
+ * const result = copyStaticFilesEntry(
36
+ * ['.gitignore', 'file/gitignore'],
37
+ * '/path/to/project',
38
+ * '/path/to/static/root',
39
+ * false
40
+ * );
41
+ *
42
+ * // With detect file - skips if detect file exists
43
+ * // 使用檢測檔案 - 如果檢測檔案存在則跳過
44
+ * const result = copyStaticFilesEntry(
45
+ * ['tsconfig.json', 'file/tsconfig.json.tpl', 'tsconfig.json'],
46
+ * '/path/to/project'
47
+ * );
48
+ * // Skips copy if tsconfig.json already exists in the project
49
+ * // 如果 tsconfig.json 已存在於專案中則跳過複製
50
+ * ```
51
+ */
2
52
  export declare function copyStaticFilesEntry(entry: IStaticFilesMapArrayEntry<string>, cwd: string, staticRoot?: string, overwrite?: boolean): boolean;