create-yarn-workspaces 3.0.21 → 3.0.23

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 CHANGED
@@ -3,6 +3,64 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.0.23](https://github.com/bluelovers/ws-yarn-workspaces/compare/create-yarn-workspaces@3.0.22...create-yarn-workspaces@3.0.23) (2026-10-12)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * **fix-all:** 引入共用靜態檔案控制邏輯並優化多套件支援
12
+
13
+
14
+
15
+ ### ✨ Features
16
+
17
+ * **fix-all:** 引入共用靜態檔案控制邏輯並優化多套件支援 ([e447590](https://github.com/bluelovers/ws-yarn-workspaces/commit/e447590f2dfd34a83f028db773a2f4c60e30dec2))
18
+
19
+
20
+ ### 📦 Code Refactoring
21
+
22
+ * **core:** 統一靜態檔案控制邏輯並更新 package.json 腳本規範 ([12f5a56](https://github.com/bluelovers/ws-yarn-workspaces/commit/12f5a5623a6f19e33616a326c86a094c548a0436))
23
+ * **create-yarn-workspaces:** 整合靜態檔案控制介面至 INpmAutoFixAll ([ff11830](https://github.com/bluelovers/ws-yarn-workspaces/commit/ff11830ed88492c8bd6624a5e14af5f78a33b504))
24
+
25
+
26
+ ### 📚 Documentation
27
+
28
+ * add jsdoc ([9cb9b13](https://github.com/bluelovers/ws-yarn-workspaces/commit/9cb9b13eda8c357221ad1b754458aa9916eada22))
29
+
30
+
31
+ ### 🚨 Tests
32
+
33
+ * **all:** 完善 node:test 遷移與測試案例優化 ([e38f263](https://github.com/bluelovers/ws-yarn-workspaces/commit/e38f26376a03520b39a54fea5794f27aecc4f424))
34
+ * **test-helper:** 引入路徑正規化機制以解決快照測試的環境依賴問題 ([af390aa](https://github.com/bluelovers/ws-yarn-workspaces/commit/af390aac58733dd93d69cd47bab8034090641b2e))
35
+
36
+
37
+ ### 🛠 Build System
38
+
39
+ * update build ([3186340](https://github.com/bluelovers/ws-yarn-workspaces/commit/3186340758172427cb1e9b8955f6fd677abac625))
40
+ * **deps:** 更新測試腳本與依賴以支援 node:test ([f9c71c7](https://github.com/bluelovers/ws-yarn-workspaces/commit/f9c71c795c792c5c7ed9d613ce7e9c3c726c39d5))
41
+
42
+
43
+ ### ♻️ Chores
44
+
45
+ * **deps:** 更新依賴版本並清理 npm-init2 腳本 ([82bf1e5](https://github.com/bluelovers/ws-yarn-workspaces/commit/82bf1e5d229759aa285205d81cf0651e4d3d9792))
46
+ * **deps:** 更新各套件依賴版本 ([569f075](https://github.com/bluelovers/ws-yarn-workspaces/commit/569f0756189cdadf69955d8e388ac0a6a8988056))
47
+ * **workspace:** 更新測試指令路徑與新增工作區搜尋選項 ([a80039d](https://github.com/bluelovers/ws-yarn-workspaces/commit/a80039dd8c691e047466966ffc8f8a4e2e31c03f))
48
+
49
+
50
+ ### 🔖 Miscellaneous
51
+
52
+ * . ([e5788f8](https://github.com/bluelovers/ws-yarn-workspaces/commit/e5788f84551b870490a96d0a5d67d8d542481373))
53
+
54
+
55
+
56
+ ## [3.0.22](https://github.com/bluelovers/ws-yarn-workspaces/compare/create-yarn-workspaces@3.0.21...create-yarn-workspaces@3.0.22) (2026-09-10)
57
+
58
+ **Note:** Version bump only for package create-yarn-workspaces
59
+
60
+
61
+
62
+
63
+
6
64
  ## [3.0.21](https://github.com/bluelovers/ws-yarn-workspaces/compare/create-yarn-workspaces@3.0.20...create-yarn-workspaces@3.0.21) (2026-09-08)
7
65
 
8
66
 
package/README.md CHANGED
@@ -2,7 +2,19 @@
2
2
 
3
3
  > 快速初始化 Yarn Workspaces 專案結構 / Quickly initialize Yarn Workspaces project structure
4
4
 
5
- ## 安裝與使用 / Installation & Usage
5
+ 一鍵建立 Yarn Workspaces(工作區)專案骨架,自動處理 package.json、Lerna 設定與 packages 目錄。
6
+
7
+ ## 功能特性 / Features
8
+
9
+ - 🚀 **快速初始化** - 一鍵創建完整的 Yarn Workspaces 專案結構
10
+ - 📦 **Lerna 整合** - 自動檢測並更新現有的 Lerna 配置
11
+ - 📝 **智能設定** - 自動配置 package.json、tsconfig 等開發環境檔案
12
+ - 🔧 **靈活選項** - 支援自定義初始化回呼與多種配置選項
13
+ - 🗂️ **目錄管理** - 根據 workspaces 配置自動創建 packages 目錄
14
+
15
+ ## 安裝 / Installation
16
+
17
+ 此為 CLI 工具,不需另外安裝,直接透過下列任一方式執行:
6
18
 
7
19
  ```bash
8
20
  # 使用 Yarn
@@ -15,15 +27,20 @@ npx create-yarn-workspaces
15
27
  pnpm create yarn-workspaces
16
28
  ```
17
29
 
18
- ## 功能特性 / Features
30
+ ## 使用方式 / Usage
19
31
 
20
- - 🚀 **快速初始化** - 一鍵創建完整的 Yarn Workspaces 專案結構
21
- - 📦 **Lerna 整合** - 自動檢測並更新現有的 Lerna 配置
22
- - 📝 **智能設定** - 自動配置 package.json、tsconfig 等開發環境檔案
23
- - 🔧 **靈活選項** - 支援自定義初始化回呼與多種配置選項
24
- - 🗂️ **目錄管理** - 根據 workspaces 配置自動創建 packages 目錄
32
+ ```bash
33
+ # 在目前目錄初始化
34
+ yarn create yarn-workspaces
35
+
36
+ # 指定目標目錄(作為 package 名稱)
37
+ yarn create yarn-workspaces my-project
25
38
 
26
- ## 命令列選項 / CLI Options
39
+ # 忽略已存在的 Package 並覆寫
40
+ yarn create yarn-workspaces --ignoreExistsPackage
41
+ ```
42
+
43
+ 命令列選項 / CLI Options:
27
44
 
28
45
  | 選項 / Option | 別名 / Alias | 說明 / Description |
29
46
  |--------------|-------------|-------------------|
@@ -32,7 +49,20 @@ pnpm create yarn-workspaces
32
49
  | `--ignoreParentWorkspaces` | | 忽略父層 Workspaces / Ignore parent workspaces |
33
50
  | `--debug` | | 啟用除錯模式 / Enable debug mode |
34
51
 
35
- ## API 使用 / API Usage
52
+ 初始化後的專案結構 / Project structure after initialization:
53
+
54
+ ```
55
+ my-project/
56
+ ├── package.json # Workspaces 配置 / Workspaces config
57
+ ├── lerna.json # Lerna 配置(如果存在)/ Lerna config (if exists)
58
+ ├── tsconfig.json # TypeScript 配置 / TypeScript config
59
+ ├── .gitignore # Git 忽略規則 / Git ignore rules
60
+ ├── .eslintrc.json # ESLint 配置 / ESLint config
61
+ └── packages/ # 套件目錄 / Packages directory
62
+ └── .gitkeep
63
+ ```
64
+
65
+ ## API 文件 / API Documentation
36
66
 
37
67
  ```typescript
38
68
  import { createYarnWorkspaces, IOptions } from 'create-yarn-workspaces';
@@ -53,20 +83,31 @@ const options: IOptions = {
53
83
  createYarnWorkspaces('./my-project', options);
54
84
  ```
55
85
 
56
- ## 目錄結構 / Directory Structure
86
+ ### `createYarnWorkspaces(cwd?, options?)`
57
87
 
58
- 初始化後的專案結構 / Project structure after initialization:
88
+ 建立 Workspaces 專案結構的主要函式 / Main function that creates the workspace project structure.
59
89
 
60
- ```
61
- my-project/
62
- ├── package.json # Workspaces 配置 / Workspaces config
63
- ├── lerna.json # Lerna 配置(如果存在)/ Lerna config (if exists)
64
- ├── tsconfig.json # TypeScript 配置 / TypeScript config
65
- ├── .gitignore # Git 忽略規則 / Git ignore rules
66
- ├── .eslintrc.json # ESLint 配置 / ESLint config
67
- └── packages/ # 套件目錄 / Packages directory
68
- └── .gitkeep
69
- ```
90
+ - `cwd?: string | IOptions` — 目標目錄;也可直接傳入選項物件 / Target directory; an options object may be passed directly as the first argument.
91
+ - `options?: IOptions` — 配置選項 / Configuration options.
92
+ - 回傳 `boolean` — 是否成功建立 / Whether creation succeeded.
93
+
94
+ 其他匯出 / Also exported: `createDirByPackages(cwd, packages)`、`getDefaultPackageJson(name?)`、`getDefaultTsconfig()`、`setupWorkspacesInitToYargs(yargs)`。
95
+
96
+ ## 組態設定 / Configuration
97
+
98
+ `IOptions` 支援下列欄位 / The `IOptions` interface supports:
99
+
100
+ | 欄位 / Field | 型別 / Type | 預設 / Default | 說明 / Description |
101
+ | --- | --- | --- | --- |
102
+ | `cwd` | `string` | `process.cwd()` | 工作目錄路徑 / Working directory path |
103
+ | `ignoreExistsPackage` | `boolean` | `false` | 忽略已存在的 Package / Ignore existing package |
104
+ | `ignoreParentWorkspaces` | `boolean` | `false` | 忽略父層 Workspaces / Ignore parent workspaces |
105
+ | `initPackageJson` | `(pkg) => pkg` | — | 自定義 package.json 初始化回呼 / Custom package.json init callback |
106
+ | `debug` | `boolean` | `false` | 啟用除錯輸出 / Enable debug output |
107
+ | `addStaticFiles` | `boolean` | `true` | 自動加入靜態範本檔案 / Auto-add static template files |
108
+ | `noStaticFiles` | `boolean` | `false` | 略過靜態檔案(優先於 `addStaticFiles`)/ Skip static files (takes precedence over `addStaticFiles`) |
109
+
110
+ 靜態檔案(Static Files)的複製行為由 `@yarn-tool/static-file` 提供,可透過 `addStaticFiles`/`noStaticFiles` 開關控制。
70
111
 
71
112
  ## 相關專案 / Related Projects
72
113
 
@@ -7,12 +7,24 @@ const logger_1 = tslib_1.__importDefault(require("debug-color2/logger"));
7
7
  const yargs_1 = tslib_1.__importDefault(require("yargs"));
8
8
  const path_1 = require("path");
9
9
  const yargs_setting_1 = tslib_1.__importDefault(require("../yargs-setting"));
10
+ /**
11
+ * CLI 一律以呼叫當下的 shell 目錄作為基準路徑。
12
+ * The CLI always uses the invoking shell's directory as the base path.
13
+ */
10
14
  const CWD = process.cwd();
15
+ /**
16
+ * CLI 入口:解析參數後呼叫 createYarnWorkspaces,失敗時印出說明。
17
+ * CLI entry: parse arguments, call `createYarnWorkspaces`, and print help on failure.
18
+ */
11
19
  let cli = (0, yargs_setting_1.default)(yargs_1.default)
12
20
  // @ts-ignore
13
21
  .command('$0', '', function (yargs) {
14
22
  // @ts-ignore
23
+ // 優先採用 --name,否則取第一個位置參數作為目標資料夾名稱。
24
+ // Prefer `--name`; otherwise take the first positional argument as the target folder name.
15
25
  let name = (yargs.argv.name || yargs.argv._[0]);
26
+ // 未指定名稱時就地初始化(以 CWD 為目標)。
27
+ // When no name is given, initialize in place (target = `CWD`).
16
28
  if (name) {
17
29
  name = (0, path_1.join)(CWD, name);
18
30
  }
@@ -22,6 +34,8 @@ let cli = (0, yargs_setting_1.default)(yargs_1.default)
22
34
  //console.log(CWD, yargs.argv);
23
35
  // @ts-ignore
24
36
  yargs.argv.debug && logger_1.default.debug(yargs.argv);
37
+ // 布林參數以 !! 強制轉型;靜態檔案相關選項刻意保留原始值,讓 addStaticFiles 維持預設 true。
38
+ // Coerce booleans with `!!`; static-file options are intentionally passed through untouched so `addStaticFiles` keeps its default of `true`.
25
39
  let bool = (0, __1.default)(name, {
26
40
  // @ts-ignore
27
41
  ignoreExistsPackage: !!yargs.argv.ignoreExistsPackage,
@@ -29,8 +43,19 @@ let cli = (0, yargs_setting_1.default)(yargs_1.default)
29
43
  ignoreParentWorkspaces: !!yargs.argv.ignoreParentWorkspaces,
30
44
  // @ts-ignore
31
45
  debug: !!yargs.argv.debug,
46
+ /*
47
+ * 保留 undefined,讓 addStaticFiles 維持預設 true / Keep undefined so addStaticFiles keeps its default of true
48
+ * */
49
+ // @ts-ignore
50
+ addStaticFiles: yargs.argv.addStaticFiles,
51
+ // @ts-ignore
52
+ noStaticFiles: yargs.argv.noStaticFiles,
53
+ // @ts-ignore
54
+ resetStaticFiles: yargs.argv.resetStaticFiles,
32
55
  });
33
56
  //console.log(77777777777, bool);
57
+ // 回傳 false 代表前置檢查失敗(如已存在 Package),此時顯示說明協助使用者修正參數。
58
+ // A `false` return means a pre-check failed (e.g. package already exists), so show help to guide the user.
34
59
  if (!bool) {
35
60
  console.log('\n');
36
61
  yargs.showHelp();
@@ -1 +1 @@
1
- {"version":3,"file":"yarn-ws-init.js","sourceRoot":"","sources":["yarn-ws-init.ts"],"names":[],"mappings":";;;;AAEA,mDAAsC;AACtC,yEAAwC;AACxC,0DAA0B;AAC1B,+BAA4B;AAC5B,6EAA0D;AAE1D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAE1B,IAAI,GAAG,GAAG,IAAA,uBAA0B,EAAC,eAAK,CAAC;IAC1C,aAAa;KACZ,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,UAAU,KAAK;IAEjC,aAAa;IACb,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAW,CAAC;IAE1D,IAAI,IAAI,EACR,CAAC;QACA,IAAI,GAAG,IAAA,WAAI,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;SAED,CAAC;QACA,IAAI,GAAG,GAAG,CAAC;IACZ,CAAC;IAED,+BAA+B;IAE/B,aAAa;IACb,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,gBAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE5C,IAAI,IAAI,GAAG,IAAA,WAAoB,EAAC,IAAI,EAAE;QACrC,aAAa;QACb,mBAAmB,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAmB;QACrD,aAAa;QACb,sBAAsB,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB;QAC3D,aAAa;QACb,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK;KACzB,CAAC,CAAC;IAEH,iCAAiC;IAEjC,IAAI,CAAC,IAAI,EACT,CAAC;QACA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,KAAK,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;SAED,CAAC;QACA,gBAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;AACF,CAAC,CAAC;KACD,OAAO,EAAE;KACT,IAAI,EAAE;KACN,IAAI,CACL","sourcesContent":["#!/usr/bin/env node\n\nimport createYarnWorkspaces from '..';\nimport debug from 'debug-color2/logger';\nimport yargs from 'yargs';\nimport { join } from 'path';\nimport setupWorkspacesInitToYargs from '../yargs-setting';\n\nconst CWD = process.cwd();\n\nlet cli = setupWorkspacesInitToYargs(yargs)\n\t// @ts-ignore\n\t.command('$0', '', function (yargs)\n\t{\n\t\t// @ts-ignore\n\t\tlet name = (yargs.argv.name || yargs.argv._[0]) as string;\n\n\t\tif (name)\n\t\t{\n\t\t\tname = join(CWD, name);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tname = CWD;\n\t\t}\n\n\t\t//console.log(CWD, yargs.argv);\n\n\t\t// @ts-ignore\n\t\tyargs.argv.debug && debug.debug(yargs.argv);\n\n\t\tlet bool = createYarnWorkspaces(name, {\n\t\t\t// @ts-ignore\n\t\t\tignoreExistsPackage: !!yargs.argv.ignoreExistsPackage,\n\t\t\t// @ts-ignore\n\t\t\tignoreParentWorkspaces: !!yargs.argv.ignoreParentWorkspaces,\n\t\t\t// @ts-ignore\n\t\t\tdebug: !!yargs.argv.debug,\n\t\t});\n\n\t\t//console.log(77777777777, bool);\n\n\t\tif (!bool)\n\t\t{\n\t\t\tconsole.log('\\n');\n\t\t\tyargs.showHelp();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdebug.success(`done`);\n\t\t}\n\t})\n\t.version()\n\t.help()\n\t.argv\n;\n"]}
1
+ {"version":3,"file":"yarn-ws-init.js","sourceRoot":"","sources":["yarn-ws-init.ts"],"names":[],"mappings":";;;;AAEA,mDAAsC;AACtC,yEAAwC;AACxC,0DAA0B;AAC1B,+BAA4B;AAC5B,6EAA0D;AAE1D;;;GAGG;AACH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAE1B;;;GAGG;AACH,IAAI,GAAG,GAAG,IAAA,uBAA0B,EAAC,eAAK,CAAC;IAC1C,aAAa;KACZ,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,UAAU,KAAK;IAEjC,aAAa;IACb,mCAAmC;IACnC,2FAA2F;IAC3F,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC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'..';\nimport debug from 'debug-color2/logger';\nimport yargs from 'yargs';\nimport { join } from 'path';\nimport setupWorkspacesInitToYargs from '../yargs-setting';\n\n/**\n * CLI 一律以呼叫當下的 shell 目錄作為基準路徑。\n * The CLI always uses the invoking shell's directory as the base path.\n */\nconst CWD = process.cwd();\n\n/**\n * CLI 入口:解析參數後呼叫 createYarnWorkspaces,失敗時印出說明。\n * CLI entry: parse arguments, call `createYarnWorkspaces`, and print help on failure.\n */\nlet cli = setupWorkspacesInitToYargs(yargs)\n\t// @ts-ignore\n\t.command('$0', '', function (yargs)\n\t{\n\t\t// @ts-ignore\n\t\t// 優先採用 --name,否則取第一個位置參數作為目標資料夾名稱。\n\t\t// Prefer `--name`; otherwise take the first positional argument as the target folder name.\n\t\tlet name = (yargs.argv.name || yargs.argv._[0]) as string;\n\n\t\t// 未指定名稱時就地初始化(以 CWD 為目標)。\n\t\t// When no name is given, initialize in place (target = `CWD`).\n\t\tif (name)\n\t\t{\n\t\t\tname = join(CWD, name);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tname = CWD;\n\t\t}\n\n\t\t//console.log(CWD, yargs.argv);\n\n\t\t// @ts-ignore\n\t\tyargs.argv.debug && debug.debug(yargs.argv);\n\n\t\t// 布林參數以 !! 強制轉型;靜態檔案相關選項刻意保留原始值,讓 addStaticFiles 維持預設 true。\n\t\t// Coerce booleans with `!!`; static-file options are intentionally passed through untouched so `addStaticFiles` keeps its default of `true`.\n\t\tlet bool = createYarnWorkspaces(name, {\n\t\t\t// @ts-ignore\n\t\t\tignoreExistsPackage: !!yargs.argv.ignoreExistsPackage,\n\t\t\t// @ts-ignore\n\t\t\tignoreParentWorkspaces: !!yargs.argv.ignoreParentWorkspaces,\n\t\t\t// @ts-ignore\n\t\t\tdebug: !!yargs.argv.debug,\n\t\t\t/*\n\t\t\t * 保留 undefined,讓 addStaticFiles 維持預設 true / Keep undefined so addStaticFiles keeps its default of true\n\t\t\t * */\n\t\t\t// @ts-ignore\n\t\t\taddStaticFiles: yargs.argv.addStaticFiles,\n\t\t\t// @ts-ignore\n\t\t\tnoStaticFiles: yargs.argv.noStaticFiles,\n\t\t\t// @ts-ignore\n\t\t\tresetStaticFiles: yargs.argv.resetStaticFiles,\n\t\t});\n\n\t\t//console.log(77777777777, bool);\n\n\t\t// 回傳 false 代表前置檢查失敗(如已存在 Package),此時顯示說明協助使用者修正參數。\n\t\t// A `false` return means a pre-check failed (e.g. package already exists), so show help to guide the user.\n\t\tif (!bool)\n\t\t{\n\t\t\tconsole.log('\\n');\n\t\t\tyargs.showHelp();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdebug.success(`done`);\n\t\t}\n\t})\n\t.version()\n\t.help()\n\t.argv\n;\n"]}
package/index.d.ts CHANGED
@@ -12,13 +12,14 @@
12
12
  * @since 2018/5/13/013
13
13
  */
14
14
  import { IPackageJson } from '@ts-type/package-dts/package-json';
15
+ import { INpmAutoFixAll } from '@yarn-tool/fix-all';
15
16
  export * from './lib/index';
16
17
  export * from './lib/util';
17
18
  /**
18
19
  * 創建 Workspaces 的選項介面
19
20
  * Interface for creating workspaces options
20
21
  */
21
- export interface IOptions {
22
+ export interface IOptions extends Pick<INpmAutoFixAll, 'addStaticFiles' | 'noStaticFiles'> {
22
23
  /**
23
24
  * 工作目錄路徑 / Working directory path
24
25
  */
package/index.js CHANGED
@@ -27,6 +27,7 @@ const util_1 = require("./lib/util");
27
27
  const wsCopyStaticFiles_1 = require("@yarn-tool/static-file/lib/ws/wsCopyStaticFiles");
28
28
  const find_root_1 = require("@yarn-tool/find-root");
29
29
  const upath2_2 = require("upath2");
30
+ const staticFiles_1 = require("@yarn-tool/fix-all/lib/file/staticFiles");
30
31
  tslib_1.__exportStar(require("./lib/index"), exports);
31
32
  tslib_1.__exportStar(require("./lib/util"), exports);
32
33
  /**
@@ -61,6 +62,8 @@ function createYarnWorkspaces(cwd, options = {}) {
61
62
  // Get package root directory and workspace path
62
63
  let root = rootData === null || rootData === void 0 ? void 0 : rootData.pkg;
63
64
  let ws = rootData === null || rootData === void 0 ? void 0 : rootData.ws;
65
+ // 實際要初始化的目標路徑:優先採用既有 package 根目錄,否則退回 cwd。
66
+ // The actual init target: prefer an existing package root, otherwise fall back to `cwd`.
64
67
  let targetPath = (0, upath2_1.resolve)(root || cwd);
65
68
  // 除錯輸出 / Debug output
66
69
  options.debug && logger_1.consoleLogger.debug({
@@ -104,7 +107,7 @@ function createYarnWorkspaces(cwd, options = {}) {
104
107
  return false;
105
108
  }
106
109
  }
107
- return _createYarnWorkspaces(targetPath);
110
+ return _createYarnWorkspaces(targetPath, options);
108
111
  }
109
112
  /**
110
113
  * 內部創建 Workspaces 實作函式
@@ -272,10 +275,19 @@ function _createYarnWorkspaces(targetPath, options = {}) {
272
275
  * Copy static template files
273
276
  */
274
277
  const file_map = (0, wsCopyStaticFiles_1.getWsCopyStaticFiles)();
275
- (0, static_file_1.copyStaticFiles)({
276
- cwd: targetPath,
277
- file_map,
278
- });
278
+ /**
279
+ * 複製靜態範本檔案
280
+ * Copy static template files
281
+ *
282
+ * 此呼叫點 addStaticFiles 預設為 true,可用 noStaticFiles 關閉
283
+ * addStaticFiles defaults to true at this call site; disable it with noStaticFiles
284
+ */
285
+ if ((0, staticFiles_1._isAddStaticFilesWithReset)(options, true)) {
286
+ (0, static_file_1.copyStaticFiles)({
287
+ cwd: targetPath,
288
+ file_map,
289
+ });
290
+ }
279
291
  /**
280
292
  * 根據 packages 模式創建目錄
281
293
  * Create directories based on packages pattern
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAoEH,oDAqFC;AAsBD,sDAuMC;AAeD,kDA6BC;;AA/ZD,mCAAiD;AAEjD,gDAA+D;AAC/D,wDAAyD;AACzD,uCAA8E;AAC9E,2DAAqD;AACrD,+BAA8C;AAC9C,qCAAwC;AAGxC,uFAAuF;AACvF,oDAAoD;AACpD,mCAAoD;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,GAAG,EAAE,CAAC,CAAC,CAAC;YAEvB,kDAAkD;YAClD,IAAI,CAAC,IAAA,qBAAU,EAAC,GAAG,CAAC,EACpB,CAAC;gBACA,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAC;YAChB,CAAC;YAED,OAAO,IAAI,CAAC;QACb,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,kBAAe,oBAAoB,CAAC","sourcesContent":["/**\n * 創建 Yarn Workspaces 工具模組\n * Yarn Workspaces Creation Tool Module\n *\n * 提供初始化 Yarn Workspaces 專案結構的功能,包含 package.json 設定、\n * Lerna 整合、目錄創建與靜態檔案複製等功能。\n * Provides functionality to initialize Yarn Workspaces project structure,\n * including package.json configuration, Lerna integration, directory creation,\n * and static file copying.\n *\n * @author user\n * @since 2018/5/13/013\n */\n\nimport findYarnWorkspaceRoot from 'find-yarn-workspace-root2/core';\nimport { resolve, join, basename } from 'upath2';\nimport pkgDir from 'pkg-dir';\nimport { consoleLogger as console } from 'debug-color2/logger';\nimport { copyStaticFiles } from '@yarn-tool/static-file';\nimport { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs-extra';\nimport { sortPackageJson } from 'sort-package-json3';\nimport { getDefaultPackageJson } from './lib';\nimport { isSamePath } from './lib/util';\nimport { ILernaJson } from '@ts-type/package-dts/lerna-json';\nimport { IPackageJson } from '@ts-type/package-dts/package-json';\nimport { getWsCopyStaticFiles } from '@yarn-tool/static-file/lib/ws/wsCopyStaticFiles';\nimport { findRootLazy } from '@yarn-tool/find-root';\nimport { normalize as pathNormalize } from 'upath2';\n\nexport * from './lib/index';\nexport * from './lib/util';\n\n/**\n * 創建 Workspaces 的選項介面\n * Interface for creating workspaces options\n */\nexport interface IOptions\n{\n\t/**\n\t * 工作目錄路徑 / Working directory path\n\t */\n\tcwd?: string,\n\n\t/**\n\t * 忽略父層 Workspaces / Ignore parent workspaces\n\t */\n\tignoreParentWorkspaces?: boolean,\n\n\t/**\n\t * 忽略已存在的 Package / Ignore existing package\n\t */\n\tignoreExistsPackage?: boolean,\n\n\t/**\n\t * 初始化 Package.json 的回呼函式\n\t * Callback function to initialize package.json\n\t * @template T - 擴展屬性類型 / Extended property type\n\t * @param current - 當前的 package.json / Current package.json\n\t * @returns 修改後的 package.json / Modified package.json\n\t */\n\tinitPackageJson?<T extends Record<string, any> = {}>(current: IPackageJson): IPackageJson & T,\n\n\t/**\n\t * 啟用除錯模式 / Enable debug mode\n\t */\n\tdebug?: boolean,\n}\n\n/**\n * 創建 Yarn Workspaces 主函式\n * Main function to create Yarn Workspaces\n *\n * 檢查並創建 Workspaces 專案結構,處理已存在 Package 與父層 Workspaces 的情況\n * Checks and creates workspace project structure, handling existing packages\n * and parent workspaces\n *\n * @param cwd - 工作目錄路徑 / Working directory path\n * @param options - 配置選項 / Configuration options\n * @returns 是否成功創建 / Whether creation was successful\n */\nexport function createYarnWorkspaces(cwd?: string, options: IOptions = {})\n{\n\t// 處理第一個參數可能是選項物件的情況\n\t// Handle case where first argument might be options object\n\tif (cwd && typeof cwd != 'string')\n\t{\n\t\toptions = cwd;\n\t\tcwd = options.cwd;\n\t}\n\n\t// 預設使用當前工作目錄 / Default to current working directory\n\tcwd ??= process.cwd();\n\n\t// 尋找專案根目錄資訊 / Find project root information\n\tconst rootData = findRootLazy({\n\t\tcwd,\n\t});\n\n\t// 標準化路徑 / Normalize path\n\tcwd = pathNormalize(rootData?.cwd ?? cwd);\n\n\t// 取得 Package 根目錄與 Workspaces 路徑\n\t// Get package root directory and workspace path\n\tlet root: string = rootData?.pkg;\n\tlet ws: string = rootData?.ws;\n\n\tlet targetPath = resolve(root || cwd);\n\n\t// 除錯輸出 / Debug output\n\toptions.debug && console.debug({\n\t\ttargetPath,\n\t\tws,\n\t\toptions,\n\t});\n\n\t/**\n\t * 檢查是否已存在 Package\n\t * Check if package already exists\n\t */\n\tif (!options.ignoreExistsPackage && root)\n\t{\n\t\tconsole.error(`already have package at \"${root}\", or use ignoreExistsPackage for overwrite it`);\n\n\t\treturn false;\n\t}\n\telse if (root)\n\t{\n\t\t// 忽略已存在的 Package / Ignore existing package\n\t\tconsole.warn(`ignore exists package \"${root}\"`);\n\t}\n\n\t/**\n\t * 檢查是否已存在 Workspaces\n\t * Check if workspace already exists\n\t */\n\tif (ws)\n\t{\n\t\t// 檢查目標路徑是否與現有 Workspace 相同\n\t\t// Check if target path is same as existing workspace\n\t\tlet bool: boolean = !isSamePath(targetPath, ws);\n\n\t\tconsole.warn(`detect exists workspace \"${ws}\"`);\n\n\t\tif (bool)\n\t\t{\n\t\t\t// 根據選項決定是否忽略父層 Workspaces\n\t\t\t// Decide whether to ignore parent workspaces based on options\n\t\t\tif (options.ignoreParentWorkspaces)\n\t\t\t{\n\t\t\t\tconsole.warn(`ignoreParentWorkspaces = true`);\n\t\t\t\tbool = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tconsole.error(`target path already is workspace`);\n\t\t\t}\n\t\t}\n\n\t\tif (bool)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn _createYarnWorkspaces(targetPath);\n}\n\n/**\n * 內部創建 Workspaces 實作函式\n * Internal implementation function for creating workspaces\n *\n * 執行實際的 Workspaces 初始化工作,包含:\n * - 讀取並更新 Lerna 配置\n * - 創建或更新 package.json\n * - 複製靜態範本檔案\n * - 創建 packages 目錄\n *\n * Performs actual workspace initialization including:\n * - Reading and updating Lerna configuration\n * - Creating or updating package.json\n * - Copying static template files\n * - Creating packages directory\n *\n * @param targetPath - 目標路徑 / Target path\n * @param options - 配置選項 / Configuration options\n * @returns 是否成功 / Whether successful\n */\nexport function _createYarnWorkspaces(targetPath: string, options: IOptions = {})\n{\n\tconsole.info(`create in target path \"${targetPath}\"`);\n\n\tlet pkg: IPackageJson;\n\n\tlet lerna: ILernaJson;\n\n\t/**\n\t * 嘗試讀取現有的 lerna.json 配置\n\t * Try to read existing lerna.json configuration\n\t */\n\t{\n\t\tlet file = join(targetPath, 'lerna.json');\n\n\t\tif (existsSync(file))\n\t\t{\n\t\t\tlet json: ILernaJson = JSON.parse(readFileSync(file).toString());\n\n\t\t\t/**\n\t\t\t * 清理空的 packages 陣列\n\t\t\t * Clean up empty packages array\n\t\t\t */\n\t\t\tif (json.packages && !Object.keys(json.packages).length)\n\t\t\t{\n\t\t\t\tjson.packages = undefined;\n\t\t\t}\n\n\t\t\tlerna = json;\n\t\t}\n\t}\n\n\t/**\n\t * 預設 packages 目錄模式\n\t * Default packages directory pattern\n\t */\n\tlet packages = lerna && lerna.packages || [\n\t\t\"packages/*\",\n\t];\n\n\tlet file = join(targetPath, 'package.json');\n\n\t/**\n\t * 處理 package.json 不存在的情況\n\t * Handle case when package.json does not exist\n\t */\n\tif (!existsSync(file))\n\t{\n\t\t// 使用目錄名作為預設 Package 名稱\n\t\t// Use directory name as default package name\n\t\tlet name = basename(targetPath);\n\n\t\t// 創建目標目錄(如果不存在)\n\t\t// Create target directory if it doesn't exist\n\t\tif (!existsSync(targetPath))\n\t\t{\n\t\t\tmkdirSync(targetPath);\n\t\t}\n\n\t\t// 合併預設配置與基本資訊\n\t\t// Merge default configuration with basic info\n\t\tpkg = Object.assign(getDefaultPackageJson(name), {\n\t\t\tname,\n\t\t\tworkspaces: packages,\n\t\t});\n\n\t\t/**\n\t\t * 執行自定義初始化回呼\n\t\t * Execute custom initialization callback\n\t\t */\n\t\tif (options.initPackageJson)\n\t\t{\n\t\t\tlet ret = options.initPackageJson(pkg);\n\n\t\t\tif (ret)\n\t\t\t{\n\t\t\t\tpkg = ret;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\t/**\n\t\t * 處理已存在的 package.json\n\t\t * Handle existing package.json\n\t\t */\n\t\tlet json: IPackageJson = JSON.parse(readFileSync(file).toString());\n\n\t\tlet workspaces: ILernaJson['packages'];\n\n\t\t/**\n\t\t * 解析現有的 workspaces 配置\n\t\t * Parse existing workspaces configuration\n\t\t */\n\t\tif (json.workspaces && Object.keys(json.workspaces).length)\n\t\t{\n\t\t\tworkspaces = json.workspaces;\n\n\t\t\t/**\n\t\t\t * 支援 nohoist 配置格式\n\t\t\t * Support nohoist configuration format\n\t\t\t * @see https://yarnpkg.com/blog/2018/02/15/nohoist/\n\t\t\t */\n\t\t\t// @ts-ignore\n\t\t\tpackages = workspaces.packages || workspaces;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tworkspaces = packages;\n\t\t}\n\n\t\t/**\n\t\t * 更新 Package.json 內容\n\t\t * Update package.json content\n\t\t */\n\t\tpkg = Object.assign(json, {\n\t\t\t\"private\": true,\n\t\t\t\"workspaces\": workspaces,\n\t\t});\n\n\t\t/**\n\t\t * 合併預設腳本與欄位\n\t\t * Merge default scripts and fields\n\t\t */\n\t\tObject.entries(getDefaultPackageJson(json.name))\n\t\t\t.forEach(([field, value]) => {\n\n\t\t\t\t/**\n\t\t\t\t * 特殊處理 scripts 欄位:合併而非覆蓋\n\t\t\t\t * Special handling for scripts field: merge instead of overwrite\n\t\t\t\t */\n\t\t\t\tif (field === 'scripts')\n\t\t\t\t{\n\t\t\t\t\tpkg.scripts ??= {};\n\t\t\t\t\tpkg.scripts = {\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t...value,\n\t\t\t\t\t\t...pkg.scripts,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t// 使用空值合併運算子設置預設值\n\t\t\t\t\t// Use nullish coalescing operator for default values\n\t\t\t\t\tpkg[field] ??= value\n\t\t\t\t}\n\n\t\t\t})\n\t\t;\n\n\t}\n\n\t/**\n\t * 寫入格式化後的 package.json\n\t * Write formatted package.json\n\t */\n\tlet s = JSON.stringify(sortPackageJson(pkg), null, 2);\n\twriteFileSync(file, s);\n\n\tconsole.success(`create workspace package.json`);\n\n\t/**\n\t * 更新 Lerna 配置(如果存在且需要更新)\n\t * Update Lerna configuration if exists and needs updating\n\t */\n\tif (lerna && (packages != lerna.packages || lerna.npmClient !== 'yarn' || lerna['useWorkspaces'] !== true))\n\t{\n\t\tlet file = join(targetPath, 'lerna.json');\n\n\t\t// 更新為 Yarn Workspaces 模式\n\t\t// Update to Yarn Workspaces mode\n\t\tlerna.packages = packages;\n\t\tlerna.npmClient ??= 'pnpm';\n\t\t// lerna['useWorkspaces'] = true;\n\n\t\tlet s = JSON.stringify(sortPackageJson(lerna), null, 2);\n\t\twriteFileSync(file, s);\n\n\t\tconsole.info(`update lerna.json`);\n\t}\n\n\t/**\n\t * 複製靜態範本檔案\n\t * Copy static template files\n\t */\n\tconst file_map = getWsCopyStaticFiles();\n\n\tcopyStaticFiles({\n\t\tcwd: targetPath,\n\t\tfile_map,\n\t});\n\n\t/**\n\t * 根據 packages 模式創建目錄\n\t * Create directories based on packages pattern\n\t */\n\tcreateDirByPackages(targetPath, packages);\n\n\treturn true;\n}\n\n/**\n * 根據 packages 模式創建目錄\n * Create directories based on packages pattern\n *\n * 解析 packages 陣列中的目錄模式(如 \"packages/*\"),\n * 並創建對應的實體目錄。\n * Parses directory patterns from packages array (e.g., \"packages/*\")\n * and creates corresponding physical directories.\n *\n * @param cwd - 當前工作目錄 / Current working directory\n * @param packages - packages 模式陣列 / Array of package patterns\n * @returns 是否有創建任何目錄 / Whether any directories were created\n */\nexport function createDirByPackages(cwd: string, packages: string[])\n{\n\treturn packages.some(function (value)\n\t{\n\t\tlet bool: boolean;\n\n\t\t// 提取路徑的第一個部分(目錄名稱)\n\t\t// Extract first part of path (directory name)\n\t\tlet s = value.split(/[\\/\\\\]/)[0];\n\n\t\t/**\n\t\t * 只處理不包含 glob 模式的純目錄路徑\n\t\t * Only handle pure directory paths without glob patterns\n\t\t */\n\t\tif (!/[!?\\*{}\\[\\]]/.test(s))\n\t\t{\n\t\t\tlet dir = join(cwd, s);\n\n\t\t\t// 目錄不存在時創建 / Create directory if it doesn't exist\n\t\t\tif (!existsSync(dir))\n\t\t\t{\n\t\t\t\tmkdirSync(dir);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn bool;\n\t})\n}\n\n/**\n * 預設導出創建函式\n * Default export of creation function\n */\nexport default createYarnWorkspaces;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAsEH,oDAuFC;AAsBD,sDAiNC;AAeD,kDA6BC;;AA7aD,mCAAiD;AAEjD,gDAA+D;AAC/D,wDAAyD;AACzD,uCAA8E;AAC9E,2DAAqD;AACrD,+BAA8C;AAC9C,qCAAwC;AAGxC,uFAAuF;AACvF,oDAAoD;AACpD,mCAAoD;AACpD,yEAAqF;AAGrF,sDAA4B;AAC5B,qDAA2B;AAsC3B;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CAAC,GAAY,EAAE,UAAoB,EAAE;;IAExE,oBAAoB;IACpB,2DAA2D;IAC3D,IAAI,GAAG,IAAI,OAAO,GAAG,IAAI,QAAQ,EACjC,CAAC;QACA,OAAO,GAAG,GAAG,CAAC;QACd,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IACnB,CAAC;IAED,oDAAoD;IACpD,GAAG,aAAH,GAAG,cAAH,GAAG,IAAH,GAAG,GAAK,OAAO,CAAC,GAAG,EAAE,EAAC;IAEtB,4CAA4C;IAC5C,MAAM,QAAQ,GAAG,IAAA,wBAAY,EAAC;QAC7B,GAAG;KACH,CAAC,CAAC;IAEH,yBAAyB;IACzB,GAAG,GAAG,IAAA,kBAAa,EAAC,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,mCAAI,GAAG,CAAC,CAAC;IAE1C,gCAAgC;IAChC,gDAAgD;IAChD,IAAI,IAAI,GAAW,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,CAAC;IACjC,IAAI,EAAE,GAAW,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,EAAE,CAAC;IAE9B,2CAA2C;IAC3C,yFAAyF;IACz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C;YACf,GAAG,EAAE,UAAU;YACf,QAAQ;SACR,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,mBAAmB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE1C,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,mBAAmB,CAAC,GAAW,EAAE,QAAkB;IAElE,OAAO,QAAQ,CAAC,IAAI,CAAC,UAAU,KAAK;QAEnC,IAAI,IAAa,CAAC;QAElB,mBAAmB;QACnB,8CAA8C;QAC9C,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjC;;;WAGG;QACH,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAC3B,CAAC;YACA,IAAI,GAAG,GAAG,IAAA,aAAI,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAEvB,kDAAkD;YAClD,IAAI,CAAC,IAAA,qBAAU,EAAC,GAAG,CAAC,EACpB,CAAC;gBACA,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAC;YAChB,CAAC;YAED,OAAO,IAAI,CAAC;QACb,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,kBAAe,oBAAoB,CAAC","sourcesContent":["/**\n * 創建 Yarn Workspaces 工具模組\n * Yarn Workspaces Creation Tool Module\n *\n * 提供初始化 Yarn Workspaces 專案結構的功能,包含 package.json 設定、\n * Lerna 整合、目錄創建與靜態檔案複製等功能。\n * Provides functionality to initialize Yarn Workspaces project structure,\n * including package.json configuration, Lerna integration, directory creation,\n * and static file copying.\n *\n * @author user\n * @since 2018/5/13/013\n */\n\nimport findYarnWorkspaceRoot from 'find-yarn-workspace-root2/core';\nimport { resolve, join, basename } from 'upath2';\nimport pkgDir from 'pkg-dir';\nimport { consoleLogger as console } from 'debug-color2/logger';\nimport { copyStaticFiles } from '@yarn-tool/static-file';\nimport { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs-extra';\nimport { sortPackageJson } from 'sort-package-json3';\nimport { getDefaultPackageJson } from './lib';\nimport { isSamePath } from './lib/util';\nimport { ILernaJson } from '@ts-type/package-dts/lerna-json';\nimport { IPackageJson } from '@ts-type/package-dts/package-json';\nimport { getWsCopyStaticFiles } from '@yarn-tool/static-file/lib/ws/wsCopyStaticFiles';\nimport { findRootLazy } from '@yarn-tool/find-root';\nimport { normalize as pathNormalize } from 'upath2';\nimport { _isAddStaticFilesWithReset } from '@yarn-tool/fix-all/lib/file/staticFiles';\nimport { INpmAutoFixAll } from '@yarn-tool/fix-all';\n\nexport * from './lib/index';\nexport * from './lib/util';\n\n/**\n * 創建 Workspaces 的選項介面\n * Interface for creating workspaces options\n */\nexport interface IOptions extends Pick<INpmAutoFixAll, 'addStaticFiles' | 'noStaticFiles'>\n{\n\t/**\n\t * 工作目錄路徑 / Working directory path\n\t */\n\tcwd?: string,\n\n\t/**\n\t * 忽略父層 Workspaces / Ignore parent workspaces\n\t */\n\tignoreParentWorkspaces?: boolean,\n\n\t/**\n\t * 忽略已存在的 Package / Ignore existing package\n\t */\n\tignoreExistsPackage?: boolean,\n\n\t/**\n\t * 初始化 Package.json 的回呼函式\n\t * Callback function to initialize package.json\n\t * @template T - 擴展屬性類型 / Extended property type\n\t * @param current - 當前的 package.json / Current package.json\n\t * @returns 修改後的 package.json / Modified package.json\n\t */\n\tinitPackageJson?<T extends Record<string, any> = {}>(current: IPackageJson): IPackageJson & T,\n\n\t/**\n\t * 啟用除錯模式 / Enable debug mode\n\t */\n\tdebug?: boolean,\n}\n\n/**\n * 創建 Yarn Workspaces 主函式\n * Main function to create Yarn Workspaces\n *\n * 檢查並創建 Workspaces 專案結構,處理已存在 Package 與父層 Workspaces 的情況\n * Checks and creates workspace project structure, handling existing packages\n * and parent workspaces\n *\n * @param cwd - 工作目錄路徑 / Working directory path\n * @param options - 配置選項 / Configuration options\n * @returns 是否成功創建 / Whether creation was successful\n */\nexport function createYarnWorkspaces(cwd?: string, options: IOptions = {})\n{\n\t// 處理第一個參數可能是選項物件的情況\n\t// Handle case where first argument might be options object\n\tif (cwd && typeof cwd != 'string')\n\t{\n\t\toptions = cwd;\n\t\tcwd = options.cwd;\n\t}\n\n\t// 預設使用當前工作目錄 / Default to current working directory\n\tcwd ??= process.cwd();\n\n\t// 尋找專案根目錄資訊 / Find project root information\n\tconst rootData = findRootLazy({\n\t\tcwd,\n\t});\n\n\t// 標準化路徑 / Normalize path\n\tcwd = pathNormalize(rootData?.cwd ?? cwd);\n\n\t// 取得 Package 根目錄與 Workspaces 路徑\n\t// Get package root directory and workspace path\n\tlet root: string = rootData?.pkg;\n\tlet ws: string = rootData?.ws;\n\n\t// 實際要初始化的目標路徑:優先採用既有 package 根目錄,否則退回 cwd。\n\t// The actual init target: prefer an existing package root, otherwise fall back to `cwd`.\n\tlet targetPath = resolve(root || cwd);\n\n\t// 除錯輸出 / Debug output\n\toptions.debug && console.debug({\n\t\ttargetPath,\n\t\tws,\n\t\toptions,\n\t});\n\n\t/**\n\t * 檢查是否已存在 Package\n\t * Check if package already exists\n\t */\n\tif (!options.ignoreExistsPackage && root)\n\t{\n\t\tconsole.error(`already have package at \"${root}\", or use ignoreExistsPackage for overwrite it`);\n\n\t\treturn false;\n\t}\n\telse if (root)\n\t{\n\t\t// 忽略已存在的 Package / Ignore existing package\n\t\tconsole.warn(`ignore exists package \"${root}\"`);\n\t}\n\n\t/**\n\t * 檢查是否已存在 Workspaces\n\t * Check if workspace already exists\n\t */\n\tif (ws)\n\t{\n\t\t// 檢查目標路徑是否與現有 Workspace 相同\n\t\t// Check if target path is same as existing workspace\n\t\tlet bool: boolean = !isSamePath(targetPath, ws);\n\n\t\tconsole.warn(`detect exists workspace \"${ws}\"`);\n\n\t\tif (bool)\n\t\t{\n\t\t\t// 根據選項決定是否忽略父層 Workspaces\n\t\t\t// Decide whether to ignore parent workspaces based on options\n\t\t\tif (options.ignoreParentWorkspaces)\n\t\t\t{\n\t\t\t\tconsole.warn(`ignoreParentWorkspaces = true`);\n\t\t\t\tbool = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tconsole.error(`target path already is workspace`);\n\t\t\t}\n\t\t}\n\n\t\tif (bool)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn _createYarnWorkspaces(targetPath, options);\n}\n\n/**\n * 內部創建 Workspaces 實作函式\n * Internal implementation function for creating workspaces\n *\n * 執行實際的 Workspaces 初始化工作,包含:\n * - 讀取並更新 Lerna 配置\n * - 創建或更新 package.json\n * - 複製靜態範本檔案\n * - 創建 packages 目錄\n *\n * Performs actual workspace initialization including:\n * - Reading and updating Lerna configuration\n * - Creating or updating package.json\n * - Copying static template files\n * - Creating packages directory\n *\n * @param targetPath - 目標路徑 / Target path\n * @param options - 配置選項 / Configuration options\n * @returns 是否成功 / Whether successful\n */\nexport function _createYarnWorkspaces(targetPath: string, options: IOptions = {})\n{\n\tconsole.info(`create in target path \"${targetPath}\"`);\n\n\tlet pkg: IPackageJson;\n\n\tlet lerna: ILernaJson;\n\n\t/**\n\t * 嘗試讀取現有的 lerna.json 配置\n\t * Try to read existing lerna.json configuration\n\t */\n\t{\n\t\tlet file = join(targetPath, 'lerna.json');\n\n\t\tif (existsSync(file))\n\t\t{\n\t\t\tlet json: ILernaJson = JSON.parse(readFileSync(file).toString());\n\n\t\t\t/**\n\t\t\t * 清理空的 packages 陣列\n\t\t\t * Clean up empty packages array\n\t\t\t */\n\t\t\tif (json.packages && !Object.keys(json.packages).length)\n\t\t\t{\n\t\t\t\tjson.packages = undefined;\n\t\t\t}\n\n\t\t\tlerna = json;\n\t\t}\n\t}\n\n\t/**\n\t * 預設 packages 目錄模式\n\t * Default packages directory pattern\n\t */\n\tlet packages = lerna && lerna.packages || [\n\t\t\"packages/*\",\n\t];\n\n\tlet file = join(targetPath, 'package.json');\n\n\t/**\n\t * 處理 package.json 不存在的情況\n\t * Handle case when package.json does not exist\n\t */\n\tif (!existsSync(file))\n\t{\n\t\t// 使用目錄名作為預設 Package 名稱\n\t\t// Use directory name as default package name\n\t\tlet name = basename(targetPath);\n\n\t\t// 創建目標目錄(如果不存在)\n\t\t// Create target directory if it doesn't exist\n\t\tif (!existsSync(targetPath))\n\t\t{\n\t\t\tmkdirSync(targetPath);\n\t\t}\n\n\t\t// 合併預設配置與基本資訊\n\t\t// Merge default configuration with basic info\n\t\tpkg = Object.assign(getDefaultPackageJson(name), {\n\t\t\tname,\n\t\t\tworkspaces: packages,\n\t\t});\n\n\t\t/**\n\t\t * 執行自定義初始化回呼\n\t\t * Execute custom initialization callback\n\t\t */\n\t\tif (options.initPackageJson)\n\t\t{\n\t\t\tlet ret = options.initPackageJson(pkg);\n\n\t\t\tif (ret)\n\t\t\t{\n\t\t\t\tpkg = ret;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\t/**\n\t\t * 處理已存在的 package.json\n\t\t * Handle existing package.json\n\t\t */\n\t\tlet json: IPackageJson = JSON.parse(readFileSync(file).toString());\n\n\t\tlet workspaces: ILernaJson['packages'];\n\n\t\t/**\n\t\t * 解析現有的 workspaces 配置\n\t\t * Parse existing workspaces configuration\n\t\t */\n\t\tif (json.workspaces && Object.keys(json.workspaces).length)\n\t\t{\n\t\t\tworkspaces = json.workspaces;\n\n\t\t\t/**\n\t\t\t * 支援 nohoist 配置格式\n\t\t\t * Support nohoist configuration format\n\t\t\t * @see https://yarnpkg.com/blog/2018/02/15/nohoist/\n\t\t\t */\n\t\t\t// @ts-ignore\n\t\t\tpackages = workspaces.packages || workspaces;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tworkspaces = packages;\n\t\t}\n\n\t\t/**\n\t\t * 更新 Package.json 內容\n\t\t * Update package.json content\n\t\t */\n\t\tpkg = Object.assign(json, {\n\t\t\t\"private\": true,\n\t\t\t\"workspaces\": workspaces,\n\t\t});\n\n\t\t/**\n\t\t * 合併預設腳本與欄位\n\t\t * Merge default scripts and fields\n\t\t */\n\t\tObject.entries(getDefaultPackageJson(json.name))\n\t\t\t.forEach(([field, value]) => {\n\n\t\t\t\t/**\n\t\t\t\t * 特殊處理 scripts 欄位:合併而非覆蓋\n\t\t\t\t * Special handling for scripts field: merge instead of overwrite\n\t\t\t\t */\n\t\t\t\tif (field === 'scripts')\n\t\t\t\t{\n\t\t\t\t\tpkg.scripts ??= {};\n\t\t\t\t\tpkg.scripts = {\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t...value,\n\t\t\t\t\t\t...pkg.scripts,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t// 使用空值合併運算子設置預設值\n\t\t\t\t\t// Use nullish coalescing operator for default values\n\t\t\t\t\tpkg[field] ??= value\n\t\t\t\t}\n\n\t\t\t})\n\t\t;\n\n\t}\n\n\t/**\n\t * 寫入格式化後的 package.json\n\t * Write formatted package.json\n\t */\n\tlet s = JSON.stringify(sortPackageJson(pkg), null, 2);\n\twriteFileSync(file, s);\n\n\tconsole.success(`create workspace package.json`);\n\n\t/**\n\t * 更新 Lerna 配置(如果存在且需要更新)\n\t * Update Lerna configuration if exists and needs updating\n\t */\n\tif (lerna && (packages != lerna.packages || lerna.npmClient !== 'yarn' || lerna['useWorkspaces'] !== true))\n\t{\n\t\tlet file = join(targetPath, 'lerna.json');\n\n\t\t// 更新為 Yarn Workspaces 模式\n\t\t// Update to Yarn Workspaces mode\n\t\tlerna.packages = packages;\n\t\tlerna.npmClient ??= 'pnpm';\n\t\t// lerna['useWorkspaces'] = true;\n\n\t\tlet s = JSON.stringify(sortPackageJson(lerna), null, 2);\n\t\twriteFileSync(file, s);\n\n\t\tconsole.info(`update lerna.json`);\n\t}\n\n\t/**\n\t * 複製靜態範本檔案\n\t * Copy static template files\n\t */\n\tconst file_map = getWsCopyStaticFiles();\n\n\t/**\n\t * 複製靜態範本檔案\n\t * Copy static template files\n\t *\n\t * 此呼叫點 addStaticFiles 預設為 true,可用 noStaticFiles 關閉\n\t * addStaticFiles defaults to true at this call site; disable it with noStaticFiles\n\t */\n\tif (_isAddStaticFilesWithReset(options, true))\n\t{\n\t\tcopyStaticFiles({\n\t\t\tcwd: targetPath,\n\t\t\tfile_map,\n\t\t});\n\t}\n\n\t/**\n\t * 根據 packages 模式創建目錄\n\t * Create directories based on packages pattern\n\t */\n\tcreateDirByPackages(targetPath, packages);\n\n\treturn true;\n}\n\n/**\n * 根據 packages 模式創建目錄\n * Create directories based on packages pattern\n *\n * 解析 packages 陣列中的目錄模式(如 \"packages/*\"),\n * 並創建對應的實體目錄。\n * Parses directory patterns from packages array (e.g., \"packages/*\")\n * and creates corresponding physical directories.\n *\n * @param cwd - 當前工作目錄 / Current working directory\n * @param packages - packages 模式陣列 / Array of package patterns\n * @returns 是否有創建任何目錄 / Whether any directories were created\n */\nexport function createDirByPackages(cwd: string, packages: string[])\n{\n\treturn packages.some(function (value)\n\t{\n\t\tlet bool: boolean;\n\n\t\t// 提取路徑的第一個部分(目錄名稱)\n\t\t// Extract first part of path (directory name)\n\t\tlet s = value.split(/[\\/\\\\]/)[0];\n\n\t\t/**\n\t\t * 只處理不包含 glob 模式的純目錄路徑\n\t\t * Only handle pure directory paths without glob patterns\n\t\t */\n\t\tif (!/[!?\\*{}\\[\\]]/.test(s))\n\t\t{\n\t\t\tlet dir = join(cwd, s);\n\n\t\t\t// 目錄不存在時創建 / Create directory if it doesn't exist\n\t\t\tif (!existsSync(dir))\n\t\t\t{\n\t\t\t\tmkdirSync(dir);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn bool;\n\t})\n}\n\n/**\n * 預設導出創建函式\n * Default export of creation function\n */\nexport default createYarnWorkspaces;\n"]}
package/lib/index.d.ts CHANGED
@@ -1,5 +1,18 @@
1
1
  import { IPackageJson } from '@ts-type/package-dts/package-json';
2
+ /**
3
+ * 取得新專案根目錄的預設 package.json 內容。
4
+ * Build the default root `package.json` content for a new project.
5
+ *
6
+ * @param name 套件名稱;未提供時保留 undefined 交由呼叫端補上。Package name; left `undefined` when absent for the caller to fill in.
7
+ * @returns 含預設 scripts 與依賴的 package.json 物件。A `package.json` object with default scripts and dependencies.
8
+ */
2
9
  export declare function getDefaultPackageJson(name?: string): IPackageJson;
10
+ /**
11
+ * 取得新專案根目錄的預設 tsconfig 內容。
12
+ * Build the default root `tsconfig` content for a new project.
13
+ *
14
+ * @returns 繼承 @bluelovers/tsconfig 的 tsconfig 物件。A `tsconfig` object extending `@bluelovers/tsconfig`.
15
+ */
3
16
  export declare function getDefaultTsconfig(): {
4
17
  extends: string;
5
18
  };
package/lib/index.js CHANGED
@@ -7,6 +7,13 @@ const ws_root_scripts_1 = require("@yarn-tool/pkg-entry-util/lib/preset/scripts/
7
7
  const dummy_1 = require("@yarn-tool/pkg-entry-util/lib/preset/scripts/dummy");
8
8
  const package_demo_json_1 = require("./package.demo.json");
9
9
  const package_json_1 = tslib_1.__importDefault(require("../package.json"));
10
+ /**
11
+ * 取得新專案根目錄的預設 package.json 內容。
12
+ * Build the default root `package.json` content for a new project.
13
+ *
14
+ * @param name 套件名稱;未提供時保留 undefined 交由呼叫端補上。Package name; left `undefined` when absent for the caller to fill in.
15
+ * @returns 含預設 scripts 與依賴的 package.json 物件。A `package.json` object with default scripts and dependencies.
16
+ */
10
17
  function getDefaultPackageJson(name) {
11
18
  let json = {
12
19
  "name": name,
@@ -16,6 +23,8 @@ function getDefaultPackageJson(name) {
16
23
  "workspaces": [
17
24
  "packages/*",
18
25
  ],
26
+ // 預設標記建立來源,方便日後辨識此專案由 yarn-tool 產生。
27
+ // Mark the origin by default so the project can later be recognized as created by yarn-tool.
19
28
  keywords: [
20
29
  "create-by-yarn-tool",
21
30
  ],
@@ -25,24 +34,40 @@ function getDefaultPackageJson(name) {
25
34
  peerDependencies: package_demo_json_1.peerDependencies,
26
35
  // "resolutions": {},
27
36
  };
37
+ // 以本套件自身的依賴版本覆寫範本版本,確保產生的專案與工具列版本一致。
38
+ // Override the template versions with this package's own dependency versions so the generated project matches the toolchain.
28
39
  for (const deps of ['dependencies', 'devDependencies', 'peerDependencies']) {
29
40
  let keys = Object.keys(json[deps]);
41
+ // 範本沒有該依賴欄位、或本套件也未宣告時略過,避免憑空新增空的依賴區塊。
42
+ // Skip when the template lacks the field or this package does not declare it, avoiding empty dependency blocks out of nowhere.
30
43
  if (!keys.length || !package_json_1.default[deps]) {
31
44
  continue;
32
45
  }
46
+ // 複製一份再改寫,避免直接動到匯入的範本物件(其為模組快取中的共享實例)。
47
+ // Copy before mutating so we do not edit the imported template object (a shared instance in the module cache).
33
48
  json[deps] = {
34
49
  ...json[deps],
35
50
  };
36
51
  keys
37
52
  .forEach(function (key) {
53
+ // 只覆寫本套件也宣告了的鍵,其餘保留範本預設版本。
54
+ // Only overwrite keys also declared by this package; keep template defaults for the rest.
38
55
  if (package_json_1.default[deps][key]) {
39
56
  json[deps][key] = package_json_1.default[deps][key];
40
57
  }
41
58
  });
42
59
  }
60
+ // 補上 workspaces 專用的預設腳本(已存在的腳本不會被覆蓋)。
61
+ // Fill in workspace-specific default scripts (existing scripts are not overwritten).
43
62
  (0, dummy_1.fillDummyScripts)(json.scripts, 'workspaces');
44
63
  return json;
45
64
  }
65
+ /**
66
+ * 取得新專案根目錄的預設 tsconfig 內容。
67
+ * Build the default root `tsconfig` content for a new project.
68
+ *
69
+ * @returns 繼承 @bluelovers/tsconfig 的 tsconfig 物件。A `tsconfig` object extending `@bluelovers/tsconfig`.
70
+ */
46
71
  function getDefaultTsconfig() {
47
72
  return {
48
73
  extends: "@bluelovers/tsconfig/esm/mapfile.json",
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAMA,sDA+CC;AAED,gDAKC;;AA3DD,kGAA2G;AAC3G,8EAAsF;AACtF,2DAAsF;AACtF,2EAAmC;AAEnC,SAAgB,qBAAqB,CAAC,IAAa;IAElD,IAAI,IAAI,GAAiB;QACxB,MAAM,EAAE,IAAI;QACZ,SAAS,EAAE,OAAO;QAClB,SAAS,EAAE,IAAI;QACf,oCAAoC;QACpC,YAAY,EAAE;YACb,YAAY;SACZ;QACD,QAAQ,EAAE;YACT,qBAAqB;SACrB;QACD,SAAS,EAAE,IAAA,6CAA2B,GAAE;QACxC,YAAY,EAAZ,gCAAY;QACZ,eAAe,EAAf,mCAAe;QACf,gBAAgB,EAAhB,oCAAgB;QAChB,qBAAqB;KACd,CAAC;IAET,KAAK,MAAM,IAAI,IAAI,CAAC,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,CAAU,EACnF,CAAC;QACA,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEnC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,sBAAI,CAAC,IAAI,CAAC,EAC/B,CAAC;YACA,SAAS;QACV,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,GAAG;YACZ,GAAG,IAAI,CAAC,IAAI,CAAC;SACb,CAAC;QAEF,IAAI;aACF,OAAO,CAAC,UAAU,GAAG;YAErB,IAAI,sBAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EACnB,CAAC;gBACA,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,sBAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACnC,CAAC;QACF,CAAC,CAAC,CACF;IACF,CAAC;IAED,IAAA,wBAAgB,EAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAE7C,OAAO,IAAI,CAAC;AACb,CAAC;AAED,SAAgB,kBAAkB;IAEjC,OAAO;QACN,OAAO,EAAE,uCAAuC;KAChD,CAAA;AACF,CAAC","sourcesContent":["import { IPackageJson } from '@ts-type/package-dts/package-json';\nimport { defaultWorkspaceRootScripts } from '@yarn-tool/pkg-entry-util/lib/preset/scripts/ws-root-scripts';\nimport { fillDummyScripts } from '@yarn-tool/pkg-entry-util/lib/preset/scripts/dummy';\nimport { dependencies, devDependencies, peerDependencies } from './package.demo.json';\nimport _pkg from '../package.json';\n\nexport function getDefaultPackageJson(name?: string): IPackageJson\n{\n\tlet json: IPackageJson = {\n\t\t\"name\": name,\n\t\t\"version\": \"1.0.0\",\n\t\t\"private\": true,\n\t\t// \"packageManager\": \"yarn@1.22.19\",\n\t\t\"workspaces\": [\n\t\t\t\"packages/*\",\n\t\t],\n\t\tkeywords: [\n\t\t\t\"create-by-yarn-tool\",\n\t\t],\n\t\t\"scripts\": defaultWorkspaceRootScripts(),\n\t\tdependencies,\n\t\tdevDependencies,\n\t\tpeerDependencies,\n\t\t// \"resolutions\": {},\n\t} as any;\n\n\tfor (const deps of ['dependencies', 'devDependencies', 'peerDependencies'] as const)\n\t{\n\t\tlet keys = Object.keys(json[deps]);\n\n\t\tif (!keys.length || !_pkg[deps])\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\tjson[deps] = {\n\t\t\t...json[deps],\n\t\t};\n\n\t\tkeys\n\t\t\t.forEach(function (key)\n\t\t\t{\n\t\t\t\tif (_pkg[deps][key])\n\t\t\t\t{\n\t\t\t\t\tjson[deps][key] = _pkg[deps][key];\n\t\t\t\t}\n\t\t\t})\n\t\t;\n\t}\n\n\tfillDummyScripts(json.scripts, 'workspaces');\n\n\treturn json;\n}\n\nexport function getDefaultTsconfig()\n{\n\treturn {\n\t\textends: \"@bluelovers/tsconfig/esm/mapfile.json\",\n\t}\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAaA,sDA2DC;AAQD,gDAKC;;AApFD,kGAA2G;AAC3G,8EAAsF;AACtF,2DAAsF;AACtF,2EAAmC;AAEnC;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,IAAa;IAElD,IAAI,IAAI,GAAiB;QACxB,MAAM,EAAE,IAAI;QACZ,SAAS,EAAE,OAAO;QA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,CAAA;AACF,CAAC","sourcesContent":["import { IPackageJson } from '@ts-type/package-dts/package-json';\nimport { defaultWorkspaceRootScripts } from '@yarn-tool/pkg-entry-util/lib/preset/scripts/ws-root-scripts';\nimport { fillDummyScripts } from '@yarn-tool/pkg-entry-util/lib/preset/scripts/dummy';\nimport { dependencies, devDependencies, peerDependencies } from './package.demo.json';\nimport _pkg from '../package.json';\n\n/**\n * 取得新專案根目錄的預設 package.json 內容。\n * Build the default root `package.json` content for a new project.\n *\n * @param name 套件名稱;未提供時保留 undefined 交由呼叫端補上。Package name; left `undefined` when absent for the caller to fill in.\n * @returns 含預設 scripts 與依賴的 package.json 物件。A `package.json` object with default scripts and dependencies.\n */\nexport function getDefaultPackageJson(name?: string): IPackageJson\n{\n\tlet json: IPackageJson = {\n\t\t\"name\": name,\n\t\t\"version\": \"1.0.0\",\n\t\t\"private\": true,\n\t\t// \"packageManager\": \"yarn@1.22.19\",\n\t\t\"workspaces\": [\n\t\t\t\"packages/*\",\n\t\t],\n\t\t// 預設標記建立來源,方便日後辨識此專案由 yarn-tool 產生。\n\t\t// Mark the origin by default so the project can later be recognized as created by yarn-tool.\n\t\tkeywords: [\n\t\t\t\"create-by-yarn-tool\",\n\t\t],\n\t\t\"scripts\": defaultWorkspaceRootScripts(),\n\t\tdependencies,\n\t\tdevDependencies,\n\t\tpeerDependencies,\n\t\t// \"resolutions\": {},\n\t} as any;\n\n\t// 以本套件自身的依賴版本覆寫範本版本,確保產生的專案與工具列版本一致。\n\t// Override the template versions with this package's own dependency versions so the generated project matches the toolchain.\n\tfor (const deps of ['dependencies', 'devDependencies', 'peerDependencies'] as const)\n\t{\n\t\tlet keys = Object.keys(json[deps]);\n\n\t\t// 範本沒有該依賴欄位、或本套件也未宣告時略過,避免憑空新增空的依賴區塊。\n\t\t// Skip when the template lacks the field or this package does not declare it, avoiding empty dependency blocks out of nowhere.\n\t\tif (!keys.length || !_pkg[deps])\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\t// 複製一份再改寫,避免直接動到匯入的範本物件(其為模組快取中的共享實例)。\n\t\t// Copy before mutating so we do not edit the imported template object (a shared instance in the module cache).\n\t\tjson[deps] = {\n\t\t\t...json[deps],\n\t\t};\n\n\t\tkeys\n\t\t\t.forEach(function (key)\n\t\t\t{\n\t\t\t\t// 只覆寫本套件也宣告了的鍵,其餘保留範本預設版本。\n\t\t\t\t// Only overwrite keys also declared by this package; keep template defaults for the rest.\n\t\t\t\tif (_pkg[deps][key])\n\t\t\t\t{\n\t\t\t\t\tjson[deps][key] = _pkg[deps][key];\n\t\t\t\t}\n\t\t\t})\n\t\t;\n\t}\n\n\t// 補上 workspaces 專用的預設腳本(已存在的腳本不會被覆蓋)。\n\t// Fill in workspace-specific default scripts (existing scripts are not overwritten).\n\tfillDummyScripts(json.scripts, 'workspaces');\n\n\treturn json;\n}\n\n/**\n * 取得新專案根目錄的預設 tsconfig 內容。\n * Build the default root `tsconfig` content for a new project.\n *\n * @returns 繼承 @bluelovers/tsconfig 的 tsconfig 物件。A `tsconfig` object extending `@bluelovers/tsconfig`.\n */\nexport function getDefaultTsconfig()\n{\n\treturn {\n\t\textends: \"@bluelovers/tsconfig/esm/mapfile.json\",\n\t}\n}\n"]}
@@ -6,7 +6,7 @@
6
6
  "devDependencies": {
7
7
  "@bluelovers/tsconfig": "^2.0.3",
8
8
  "@types/jest": "^30.0.0",
9
- "@types/node": "^26.5.0",
9
+ "@types/node": "^26.6.5",
10
10
  "@yarn-tool/require-resolve": "^4.0.9",
11
11
  "@yarn-tool/ws-find-up-paths": "^1.0.22"
12
12
  },
package/lib/util.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  /**
2
- * @deprecated
2
+ * 判斷兩個路徑是否為同一位置(已標記 @deprecated,請改用 path-is-same)。
3
+ * Check whether two paths point to the same location (marked `@deprecated`; use `path-is-same` instead).
4
+ *
5
+ * @param p1 第一個路徑。The first path.
6
+ * @param p2 第二個路徑。The second path.
7
+ * @returns 兩路徑相同時為 true;任一為空則直接 false。`true` when they match; `false` when either input is empty.
3
8
  */
4
9
  export declare function isSamePath(p1: string, p2: string): boolean;
package/lib/util.js CHANGED
@@ -4,15 +4,24 @@ exports.isSamePath = isSamePath;
4
4
  const path_1 = require("path");
5
5
  const path_is_same_1 = require("path-is-same");
6
6
  /**
7
- * @deprecated
7
+ * 判斷兩個路徑是否為同一位置(已標記 @deprecated,請改用 path-is-same)。
8
+ * Check whether two paths point to the same location (marked `@deprecated`; use `path-is-same` instead).
9
+ *
10
+ * @param p1 第一個路徑。The first path.
11
+ * @param p2 第二個路徑。The second path.
12
+ * @returns 兩路徑相同時為 true;任一為空則直接 false。`true` when they match; `false` when either input is empty.
8
13
  */
9
14
  function isSamePath(p1, p2) {
15
+ // 任一輸入為空時無法比較,直接回傳 false 以免 relative() 產生誤判。
16
+ // Bail out with `false` when either input is empty so `relative()` cannot produce a misleading result.
10
17
  if (!p1 || !p2) {
11
18
  return false;
12
19
  }
13
20
  else if ((0, path_is_same_1.pathIsSame)(p1, p2)) {
14
21
  return true;
15
22
  }
23
+ // 字面不相同時再以 relative 判斷,涵蓋結尾斜線或 '.' 等等價寫法。
24
+ // When the literals differ, fall back to `relative()` to cover equivalent spellings such as trailing slashes or `.`.
16
25
  let s = (0, path_1.relative)(p1, p2);
17
26
  return (s === '.' || s === '');
18
27
  }
package/lib/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":";;AAMA,gCAaC;AAnBD,+BAAgC;AAChC,+CAA0C;AAE1C;;GAEG;AACH,SAAgB,UAAU,CAAC,EAAU,EAAE,EAAU;IAEhD,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,EACd,CAAC;QACA,OAAO,KAAK,CAAC;IACd,CAAC;SACI,IAAI,IAAA,yBAAU,EAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,CAAC;QACA,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,CAAC,GAAG,IAAA,eAAQ,EAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACzB,OAAO,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import { relative } from \"path\";\nimport { pathIsSame } from 'path-is-same';\n\n/**\n * @deprecated\n */\nexport function isSamePath(p1: string, p2: string)\n{\n\tif (!p1 || !p2)\n\t{\n\t\treturn false;\n\t}\n\telse if (pathIsSame(p1, p2))\n\t{\n\t\treturn true;\n\t}\n\n\tlet s = relative(p1, p2);\n\treturn (s === '.' || s === '');\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":";;AAWA,gCAiBC;AA5BD,+BAAgC;AAChC,+CAA0C;AAE1C;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAC,EAAU,EAAE,EAAU;IAEhD,6CAA6C;IAC7C,uGAAuG;IACvG,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,EACd,CAAC;QACA,OAAO,KAAK,CAAC;IACd,CAAC;SACI,IAAI,IAAA,yBAAU,EAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,CAAC;QACA,OAAO,IAAI,CAAC;IACb,CAAC;IAED,0CAA0C;IAC1C,qHAAqH;IACrH,IAAI,CAAC,GAAG,IAAA,eAAQ,EAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACzB,OAAO,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import { relative } from \"path\";\nimport { pathIsSame } from 'path-is-same';\n\n/**\n * 判斷兩個路徑是否為同一位置(已標記 @deprecated,請改用 path-is-same)。\n * Check whether two paths point to the same location (marked `@deprecated`; use `path-is-same` instead).\n *\n * @param p1 第一個路徑。The first path.\n * @param p2 第二個路徑。The second path.\n * @returns 兩路徑相同時為 true;任一為空則直接 false。`true` when they match; `false` when either input is empty.\n */\nexport function isSamePath(p1: string, p2: string)\n{\n\t// 任一輸入為空時無法比較,直接回傳 false 以免 relative() 產生誤判。\n\t// Bail out with `false` when either input is empty so `relative()` cannot produce a misleading result.\n\tif (!p1 || !p2)\n\t{\n\t\treturn false;\n\t}\n\telse if (pathIsSame(p1, p2))\n\t{\n\t\treturn true;\n\t}\n\n\t// 字面不相同時再以 relative 判斷,涵蓋結尾斜線或 '.' 等等價寫法。\n\t// When the literals differ, fall back to `relative()` to cover equivalent spellings such as trailing slashes or `.`.\n\tlet s = relative(p1, p2);\n\treturn (s === '.' || s === '');\n}\n"]}
package/package.json CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "create-yarn-workspaces",
3
- "version": "3.0.21",
4
- "description": "yarn create yarn-workspaces npx create-yarn-workspaces",
3
+ "version": "3.0.23",
4
+ "description": "Quickly initialize Yarn Workspaces project structure",
5
5
  "keywords": [
6
+ "create",
7
+ "yarn-workspaces",
6
8
  "cli",
7
9
  "init",
8
10
  "npm",
@@ -35,11 +37,13 @@
35
37
  "scripts": {
36
38
  "coverage": "pnpm run test --coverage",
37
39
  "pretest": "tsx ./test/scripts/cache-versions.ts",
38
- "test": "echo test",
40
+ "test": "node --run test:node",
39
41
  "test:jest": "jest --passWithNoTests",
40
42
  "test:jest:coverage": "node --run test:jest -- --coverage",
41
43
  "test:jest:snapshot": "node --run test:jest -- -u",
44
+ "test:node": "tsx --test --test-update-snapshots **/*.node-spec.ts **/*.node-test.ts **/*.spec.ts **/*.test.ts",
42
45
  "test:snapshot": "pnpm run test -u",
46
+ "test:tsc": "tsc --noEmit & echo typescript check done",
43
47
  "test:tsd": "ynpx tsd",
44
48
  "npm:publish": "npm publish",
45
49
  "preversion": "pnpm run test",
@@ -52,28 +56,28 @@
52
56
  },
53
57
  "dependencies": {
54
58
  "@bluelovers/tsconfig": "^2.0.3",
55
- "@ts-type/package-dts": "^3.0.9",
59
+ "@ts-type/package-dts": "^3.0.14",
56
60
  "@types/jest": "^30.0.0",
57
- "@types/node": "^26.4.1",
58
- "@yarn-tool/find-root": "^2.0.25",
59
- "@yarn-tool/pkg-entry-util": "^3.0.14",
60
- "@yarn-tool/require-resolve": "^4.0.9",
61
- "@yarn-tool/static-file": "^3.0.18",
62
- "@yarn-tool/ws-find-up-paths": "^1.0.22",
61
+ "@types/node": "^26.6.5",
62
+ "@yarn-tool/find-root": "^2.0.26",
63
+ "@yarn-tool/pkg-entry-util": "^3.0.15",
64
+ "@yarn-tool/require-resolve": "^4.0.10",
65
+ "@yarn-tool/static-file": "^3.0.20",
66
+ "@yarn-tool/ws-find-up-paths": "^1.0.23",
63
67
  "debug-color2": "^1.3.2",
64
- "find-yarn-workspace-root2": "^1.2.55",
65
- "fs-extra": "^11.4.0",
68
+ "find-yarn-workspace-root2": "^1.2.56",
69
+ "fs-extra": "^11.4.1",
66
70
  "path-is-same": "^1.0.29",
67
71
  "pkg-dir": "<6 >=5",
68
- "sort-package-json3": "^3.0.12",
69
- "ts-type": "^3.0.13",
72
+ "sort-package-json3": "^3.0.13",
73
+ "ts-type": "^3.0.18",
70
74
  "tslib": "^2.8.1",
71
75
  "upath2": "^3.1.25",
72
76
  "yargs": "<18 >=17.7.2"
73
77
  },
74
78
  "devDependencies": {
75
- "@yarn-tool/ncu": "^3.0.10",
76
- "@yarn-tool/write-package-json": "^1.0.17"
79
+ "@yarn-tool/ncu": "^3.0.11",
80
+ "@yarn-tool/write-package-json": "^1.0.18"
77
81
  },
78
- "gitHead": "09796d3635918d489d656c7571e8fa31b5ebc32c"
82
+ "gitHead": "471c63ee11851f0ac3487f23d1c472936f99b460"
79
83
  }
@@ -31,7 +31,17 @@ import { Argv } from 'yargs';
31
31
  * @param yargs - Yargs 實例 / Yargs instance
32
32
  * @returns 配置後的 Yargs 實例 / Configured Yargs instance
33
33
  */
34
- export declare function setupWorkspacesInitToYargs<T extends any>(yargs: Argv<T>): yargs.Argv<yargs.Omit<T, never> & {
34
+ export declare function setupWorkspacesInitToYargs<T extends any>(yargs: Argv<T>): yargs.Argv<yargs.Omit<T & {
35
+ overwriteHostedGitInfo: boolean;
36
+ } & {
37
+ branch: string;
38
+ } & {
39
+ resetStaticFiles: boolean;
40
+ } & {
41
+ addStaticFiles: boolean;
42
+ } & {
43
+ noStaticFiles: boolean;
44
+ }, never> & {
35
45
  name: string;
36
46
  } & {
37
47
  ignoreExistsPackage: boolean;
package/yargs-setting.js CHANGED
@@ -12,6 +12,7 @@
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.setupWorkspacesInitToYargs = setupWorkspacesInitToYargs;
15
+ const yargs_setting_1 = require("@yarn-tool/fix-all/lib/util/yargs-setting");
15
16
  /**
16
17
  * 設定 Workspaces 初始化相關的 Yargs 選項
17
18
  * Setup Yargs options for workspaces initialization
@@ -33,7 +34,7 @@ exports.setupWorkspacesInitToYargs = setupWorkspacesInitToYargs;
33
34
  * @returns 配置後的 Yargs 實例 / Configured Yargs instance
34
35
  */
35
36
  function setupWorkspacesInitToYargs(yargs) {
36
- return yargs
37
+ const _return = (0, yargs_setting_1.setupToYargs)(yargs)
37
38
  .default({
38
39
  //input: process.cwd(),
39
40
  })
@@ -69,6 +70,7 @@ function setupWorkspacesInitToYargs(yargs) {
69
70
  .option('debug', {
70
71
  boolean: true,
71
72
  });
73
+ return _return;
72
74
  }
73
75
  /**
74
76
  * 預設導出設定函式
@@ -1 +1 @@
1
- {"version":3,"file":"yargs-setting.js","sourceRoot":"","sources":["yargs-setting.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAyBH,gEAuCC;AA3DD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,0BAA0B,CAAgB,KAAc;IAEvE,OAAO,KAAK;SACV,OAAO,CAAC;IACR,uBAAuB;KACvB,CAAC;QACF;;;WAGG;SACF,MAAM,CAAC,MAAM,EAAE;QACf,KAAK,EAAE,CAAC,GAAG,CAAC;QACZ,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,QAAQ;KACd,CAAC;QACF;;;WAGG;SACF,MAAM,CAAC,qBAAqB,EAAE;QAC9B,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,CAAC,GAAG,CAAC;KACZ,CAAC;QACF;;;WAGG;SACF,MAAM,CAAC,wBAAwB,EAAE;QACjC,OAAO,EAAE,IAAI;KACb,CAAC;QACF;;;WAGG;SACF,MAAM,CAAC,OAAO,EAAE;QAChB,OAAO,EAAE,IAAI;KACb,CAAC,CACF;AACF,CAAC;AAED;;;GAGG;AACH,kBAAe,0BAA0B,CAAA","sourcesContent":["/**\n * Yargs 命令列參數設定模組\n * Yargs Command Line Arguments Configuration Module\n * \n * 提供 Workspaces 初始化相關的命令列參數設定與驗證\n * Provides command line argument configuration and validation for\n * workspace initialization\n * \n * @author user\n * @since 2019/5/16\n */\n\nimport yargs from 'yargs';\nimport { Argv, Omit } from 'yargs';\n\n/**\n * 設定 Workspaces 初始化相關的 Yargs 選項\n * Setup Yargs options for workspaces initialization\n * \n * 配置命令列參數,包含:\n * - name: Package 名稱\n * - ignoreExistsPackage: 忽略已存在的 Package\n * - ignoreParentWorkspaces: 忽略父層 Workspaces\n * - debug: 啟用除錯模式\n * \n * Configures command line arguments including:\n * - name: Package name\n * - ignoreExistsPackage: Ignore existing package\n * - ignoreParentWorkspaces: Ignore parent workspaces\n * - debug: Enable debug mode\n * \n * @template T - Yargs 參數類型 / Yargs argument type\n * @param yargs - Yargs 實例 / Yargs instance\n * @returns 配置後的 Yargs 實例 / Configured Yargs instance\n */\nexport function setupWorkspacesInitToYargs<T extends any>(yargs: Argv<T>)\n{\n\treturn yargs\n\t\t.default({\n\t\t\t//input: process.cwd(),\n\t\t})\n\t\t/**\n\t\t * Package 名稱選項\n\t\t * Package name option\n\t\t */\n\t\t.option('name', {\n\t\t\talias: ['n'],\n\t\t\trequiresArg: true,\n\t\t\tnormalize: true,\n\t\t\ttype: 'string',\n\t\t})\n\t\t/**\n\t\t * 忽略已存在 Package 選項\n\t\t * Ignore existing package option\n\t\t */\n\t\t.option('ignoreExistsPackage', {\n\t\t\tboolean: true,\n\t\t\talias: ['i'],\n\t\t})\n\t\t/**\n\t\t * 忽略父層 Workspaces 選項\n\t\t * Ignore parent workspaces option\n\t\t */\n\t\t.option('ignoreParentWorkspaces', {\n\t\t\tboolean: true,\n\t\t})\n\t\t/**\n\t\t * 除錯模式選項\n\t\t * Debug mode option\n\t\t */\n\t\t.option('debug', {\n\t\t\tboolean: true,\n\t\t})\n\t;\n}\n\n/**\n * 預設導出設定函式\n * Default export of setup function\n */\nexport default setupWorkspacesInitToYargs\n"]}
1
+ {"version":3,"file":"yargs-setting.js","sourceRoot":"","sources":["yargs-setting.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA0BH,gEAyCC;AA/DD,6EAA+F;AAE/F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,0BAA0B,CAAgB,KAAc;IAEvE,MAAM,OAAO,GAAG,IAAA,4BAAkB,EAAC,KAAK,CAAC;SACvC,OAAO,CAAC;IACR,uBAAuB;KACvB,CAAC;QACF;;;WAGG;SACF,MAAM,CAAC,MAAM,EAAE;QACf,KAAK,EAAE,CAAC,GAAG,CAAC;QACZ,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,QAAQ;KACd,CAAC;QACF;;;WAGG;SACF,MAAM,CAAC,qBAAqB,EAAE;QAC9B,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,CAAC,GAAG,CAAC;KACZ,CAAC;QACF;;;WAGG;SACF,MAAM,CAAC,wBAAwB,EAAE;QACjC,OAAO,EAAE,IAAI;KACb,CAAC;QACF;;;WAGG;SACF,MAAM,CAAC,OAAO,EAAE;QAChB,OAAO,EAAE,IAAI;KACb,CAAC,CACF;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,kBAAe,0BAA0B,CAAA","sourcesContent":["/**\n * Yargs 命令列參數設定模組\n * Yargs Command Line Arguments Configuration Module\n *\n * 提供 Workspaces 初始化相關的命令列參數設定與驗證\n * Provides command line argument configuration and validation for\n * workspace initialization\n *\n * @author user\n * @since 2019/5/16\n */\n\nimport yargs from 'yargs';\nimport { Argv, Omit } from 'yargs';\nimport { setupToYargs as setupFixAllToYargs } from '@yarn-tool/fix-all/lib/util/yargs-setting';\n\n/**\n * 設定 Workspaces 初始化相關的 Yargs 選項\n * Setup Yargs options for workspaces initialization\n *\n * 配置命令列參數,包含:\n * - name: Package 名稱\n * - ignoreExistsPackage: 忽略已存在的 Package\n * - ignoreParentWorkspaces: 忽略父層 Workspaces\n * - debug: 啟用除錯模式\n *\n * Configures command line arguments including:\n * - name: Package name\n * - ignoreExistsPackage: Ignore existing package\n * - ignoreParentWorkspaces: Ignore parent workspaces\n * - debug: Enable debug mode\n *\n * @template T - Yargs 參數類型 / Yargs argument type\n * @param yargs - Yargs 實例 / Yargs instance\n * @returns 配置後的 Yargs 實例 / Configured Yargs instance\n */\nexport function setupWorkspacesInitToYargs<T extends any>(yargs: Argv<T>)\n{\n\tconst _return = setupFixAllToYargs(yargs)\n\t\t.default({\n\t\t\t//input: process.cwd(),\n\t\t})\n\t\t/**\n\t\t * Package 名稱選項\n\t\t * Package name option\n\t\t */\n\t\t.option('name', {\n\t\t\talias: ['n'],\n\t\t\trequiresArg: true,\n\t\t\tnormalize: true,\n\t\t\ttype: 'string',\n\t\t})\n\t\t/**\n\t\t * 忽略已存在 Package 選項\n\t\t * Ignore existing package option\n\t\t */\n\t\t.option('ignoreExistsPackage', {\n\t\t\tboolean: true,\n\t\t\talias: ['i'],\n\t\t})\n\t\t/**\n\t\t * 忽略父層 Workspaces 選項\n\t\t * Ignore parent workspaces option\n\t\t */\n\t\t.option('ignoreParentWorkspaces', {\n\t\t\tboolean: true,\n\t\t})\n\t\t/**\n\t\t * 除錯模式選項\n\t\t * Debug mode option\n\t\t */\n\t\t.option('debug', {\n\t\t\tboolean: true,\n\t\t})\n\t;\n\n\treturn _return;\n}\n\n/**\n * 預設導出設定函式\n * Default export of setup function\n */\nexport default setupWorkspacesInitToYargs\n"]}