@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.
- package/CHANGELOG.md +64 -0
- package/README.md +9 -4
- package/__root.d.ts +28 -0
- package/__root.js +28 -0
- package/__root.js.map +1 -1
- package/file/.gitignore +10 -0
- package/file/README.md +11 -1
- package/file/github/dependabot.yml +39 -0
- package/file/github/workflows/action-yarnlock-dedupe.yml +3 -5
- package/file/github/workflows/build.yml +1 -0
- package/file/github/workflows/cmd-rebase.yml +28 -0
- package/file/github/workflows/codeql-analysis.yml +52 -0
- package/file/github/workflows/coverage.yml +2 -0
- package/file/github/workflows/yarn-lock-changes.yml +3 -0
- package/file/gitignore +15 -0
- package/file/jest.config.auto.js +81 -15
- package/file/jest.config.js +3 -1
- package/file/npmrc +3 -0
- package/file/nvmrc +1 -1
- package/file/pnpm-workspace.yaml +19 -0
- package/file/test/__root.ts +3 -0
- package/file/test/temp.ts +4 -0
- package/file/tsconfig.json +5 -0
- package/file/tsdx/tsconfig.json.tpl +7 -0
- package/file/ws-root/jest-preset.js +32 -3
- package/file/ws-root/jest.config.js +3 -2
- package/index.d.ts +25 -0
- package/index.js +25 -0
- package/index.js.map +1 -1
- package/lib/const.d.ts +57 -3
- package/lib/const.js +92 -7
- package/lib/const.js.map +1 -1
- package/lib/copyStaticFiles.d.ts +50 -0
- package/lib/copyStaticFiles.js +48 -0
- package/lib/copyStaticFiles.js.map +1 -1
- package/lib/copyStaticFilesEntry.d.ts +50 -0
- package/lib/copyStaticFilesEntry.js +48 -0
- package/lib/copyStaticFilesEntry.js.map +1 -1
- package/lib/getRowOfStaticFilesMapArray.d.ts +40 -0
- package/lib/getRowOfStaticFilesMapArray.js +32 -0
- package/lib/getRowOfStaticFilesMapArray.js.map +1 -1
- package/lib/getStaticFile.d.ts +42 -0
- package/lib/getStaticFile.js +34 -0
- package/lib/getStaticFile.js.map +1 -1
- package/lib/parseStaticMap.d.ts +39 -0
- package/lib/parseStaticMap.js +7 -0
- package/lib/parseStaticMap.js.map +1 -1
- package/lib/reMapStaticFilesMapArray.d.ts +39 -0
- package/lib/reMapStaticFilesMapArray.js +36 -0
- package/lib/reMapStaticFilesMapArray.js.map +1 -1
- package/lib/replaceTargetOfStaticFilesMapArrayEntry.d.ts +33 -0
- package/lib/replaceTargetOfStaticFilesMapArrayEntry.js +25 -0
- package/lib/replaceTargetOfStaticFilesMapArrayEntry.js.map +1 -1
- package/lib/root/getRootCopyStaticFiles.d.ts +54 -0
- package/lib/root/getRootCopyStaticFiles.js +47 -0
- package/lib/root/getRootCopyStaticFiles.js.map +1 -1
- package/lib/types.d.ts +73 -0
- package/lib/types.js.map +1 -1
- package/lib/ws/wsCopyStaticFiles.d.ts +50 -0
- package/lib/ws/wsCopyStaticFiles.js +50 -0
- package/lib/ws/wsCopyStaticFiles.js.map +1 -1
- package/package.json +3 -3
- package/file/test/__root.d.ts +0 -2
- package/file/test/__root.js +0 -7
- package/file/test/__root.js.map +0 -1
- package/file/tsdx/index.cjs +0 -5
- package/file/tsdx/index.cjs.map +0 -1
- package/file/tsdx/index.d.cts +0 -2
- package/file/ws-root/__root_ws.d.ts +0 -2
- package/file/ws-root/__root_ws.js +0 -7
- package/file/ws-root/__root_ws.js.map +0 -1
- /package/file/{browserslistrc → ws-root/browserslistrc} +0 -0
|
@@ -1,8 +1,37 @@
|
|
|
1
|
-
|
|
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
|
-
*
|
|
5
|
-
*
|
|
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
|
-
*
|
|
6
|
-
* @
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
40
|
+
// TSDX configuration / TSDX 配置
|
|
23
41
|
['tsdx.config.js.tpl', 'file/tsdx.config.js', 'tsdx.config.js'],
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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":";;;
|
|
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"]}
|
package/lib/copyStaticFiles.d.ts
CHANGED
|
@@ -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>[];
|
package/lib/copyStaticFiles.js
CHANGED
|
@@ -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":";;
|
|
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;
|