@yarn-tool/setup-module-env 3.0.11 → 3.0.12
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 +10 -0
- package/lib/preset/tsdx/index.js +4 -4
- package/lib/preset/tsdx/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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.12](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/setup-module-env@3.0.11...@yarn-tool/setup-module-env@3.0.12) (2026-04-26)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### ♻️ Chores
|
|
11
|
+
|
|
12
|
+
* 大範圍更新依賴版本並優化腳本執行與路徑解析 ([221eb35](https://github.com/bluelovers/ws-yarn-workspaces/commit/221eb352b31a00d5ffea5e2c8323b50863508f2c))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
## [3.0.11](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/setup-module-env@3.0.10...@yarn-tool/setup-module-env@3.0.11) (2026-03-12)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @yarn-tool/setup-module-env
|
package/lib/preset/tsdx/index.js
CHANGED
|
@@ -60,7 +60,7 @@ function updatePackageJson(pkg, config) {
|
|
|
60
60
|
// 如果 build 腳本不包含 tsdx build,則設定新的 build 腳本
|
|
61
61
|
// If build script doesn't include tsdx build, set new build script
|
|
62
62
|
if (!((_d = pkg.scripts["build"]) === null || _d === void 0 ? void 0 : _d.includes('run build:tsdx'))) {
|
|
63
|
-
pkg.scripts["build"] = "
|
|
63
|
+
pkg.scripts["build"] = "node --run build:tsdx && node --run build:dts:bundle";
|
|
64
64
|
}
|
|
65
65
|
// 設定 TypeScript 宣告檔案打包腳本
|
|
66
66
|
// Set TypeScript declaration file bundling script
|
|
@@ -77,9 +77,9 @@ function updatePackageJson(pkg, config) {
|
|
|
77
77
|
// 組合完整的 dts 建置腳本
|
|
78
78
|
// Compose complete dts build script
|
|
79
79
|
(_j = (_w = pkg.scripts)["build:dts:tsc"]) !== null && _j !== void 0 ? _j : (_w["build:dts:tsc"] = [
|
|
80
|
-
'
|
|
81
|
-
'
|
|
82
|
-
'
|
|
80
|
+
'node --run build:dts:copy',
|
|
81
|
+
'node --run build:dts:tsc:emit',
|
|
82
|
+
'node --run build:dts:copy',
|
|
83
83
|
].join(' && '));
|
|
84
84
|
// 設定模組入口點
|
|
85
85
|
// Set module entry points
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAmCH,8CA8FC;AAsFD,sBA4BC;AA9OD,yEAA8G;AAG9G,+BAAuC;AACvC,uCAAyC;AACzC,+BAA+B;AAE/B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,iBAAiB,CAAyB,GAAM,EAAE,MAA6B;;;IAE9F,kBAAkB;IAClB,8BAA8B;IAC9B,MAAA,GAAG,CAAC,OAAO,oCAAX,GAAG,CAAC,OAAO,GAAK,EAAE,EAAC;IAEnB,4BAA4B;IAC5B,kEAAkE;IAClE,IAAI,IAAA,uCAA6B,EAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EACtD,CAAC;QACA,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,sBAAsB;IACtB,kCAAkC;IAClC,YAAA,GAAG,CAAC,OAAO,EAAC,MAAM,wCAAN,MAAM,+DAAiC;IAEnD,8BAA8B;IAC9B,+CAA+C;IAC/C,YAAA,GAAG,CAAC,OAAO,EAAC,UAAU,wCAAV,UAAU,IAAM,gBAAgB,EAAC;IAE7C,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;GAGG;AACU,QAAA,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAA0E,CAAC;AAgC9J;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,KAAK,CAAyB,MAA4B;IAEzE,IAAI,EACH,GAAG,EACH,QAAQ,EACR,SAAS,GACT,GAAG,MAAM,CAAC;IAEX,kBAAkB;IAClB,sBAAsB;IACtB,GAAG,GAAG,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAErC,iBAAiB;IACjB,gDAAgD;IAChD,QAAQ,GAAG;QACR,GAAG,kCAA0B;QAC/B,GAAG,QAAQ;KACX,CAAC;IAEF,cAAc;IACd,8BAA8B;IAC9B,IAAA,wBAAa,EAAC,IAAA,cAAO,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEzC,OAAO;QACN,GAAG,MAAM;QACT,GAAG;QACH,QAAQ;KACR,CAAA;AACF,CAAC","sourcesContent":["/**\n * tsdx 專案設定模組\n * tsdx project setup module\n *\n * 此模組提供設定 tsdx 專案的核心功能,包括更新 package.json、\n * 設定靜態檔案映射以及主要設定函式。\n * This module provides core functionality for setting up tsdx projects,\n * including updating package.json, configuring static file mappings,\n * and the main setup function.\n */\n\nimport { IPackageJson } from '@ts-type/package-dts/package-json';\nimport { IFindRootReturnType } from '@yarn-tool/find-root';\nimport { _Key, IStaticFilesMapArray } from '@yarn-tool/static-file/lib/types';\nimport { EnumScriptsEntry, scriptsEntryIsNoTestSpecified } from '@yarn-tool/pkg-entry-util/lib/field/scripts';\nimport { deleteValue } from 'dot-values2';\nimport { EnumTsdx } from './const';\nimport { fixTsdxPackage } from './fix';\nimport { ensureDirSync } from 'fs-extra';\nimport { resolve } from 'path';\n\n/**\n * 更新 package.json 以符合 tsdx 專案標準\n * Update package.json to conform to tsdx project standards\n *\n * 此函式會設定以下內容:\n * This function configures the following:\n *\n * - scripts: test, posttest, build, build:dts:bundle, build:tsdx 等\n * scripts: test, posttest, build, build:dts:bundle, build:tsdx, etc.\n *\n * - main/module/types: 設定輸出檔案路徑\n * main/module/types: configure output file paths\n *\n * - exports: 設定模組匯出映射\n * exports: configure module export mappings\n *\n * - keywords: 添加 tsdx 標識關鍵字\n * keywords: add tsdx identifier keyword\n *\n * @param pkg - 要更新的 package.json 物件 / package.json object to update\n * @param config - 設定選項 (可選) / configuration options (optional)\n * @returns 更新後的 package.json 物件 / Updated package.json object\n */\nexport function updatePackageJson<P extends IPackageJson>(pkg: P, config?: ISetupTsdxOptions<P>)\n{\n\t// 確保 scripts 欄位存在\n\t// Ensure scripts field exists\n\tpkg.scripts ??= {};\n\n\t// 如果 test 腳本未指定或為空,清除並設定預設值\n\t// If test script is not specified or empty, clear and set default\n\tif (scriptsEntryIsNoTestSpecified(pkg.scripts[\"test\"]))\n\t{\n\t\tpkg.scripts[\"test\"] = void 0;\n\t}\n\n\t// 設定預設的 test 腳本為 jest\n\t// Set default test script to jest\n\tpkg.scripts[\"test\"] ??= EnumScriptsEntry.JEST_TEST;\n\n\t// 設定 posttest 腳本,在測試後執行 build\n\t// Set posttest script to run build after tests\n\tpkg.scripts[\"posttest\"] ??= \"yarn run build\";\n\n\t// 如果 build 腳本不包含 tsdx build,則設定新的 build 腳本\n\t// If build script doesn't include tsdx build, set new build script\n\tif (!pkg.scripts[\"build\"]?.includes('run build:tsdx'))\n\t{\n\t\tpkg.scripts[\"build\"] = \"yarn run build:tsdx && yarn run build:dts:bundle\";\n\t}\n\n\t// 設定 TypeScript 宣告檔案打包腳本\n\t// Set TypeScript declaration file bundling script\n\tpkg.scripts[\"build:dts:bundle\"] ??= EnumScriptsEntry.BUILD_DTS_BUNDLE;\n\n\t// 設定 tsdx build 腳本,目標為 node 環境\n\t// Set tsdx build script targeting node environment\n\tpkg.scripts[\"build:tsdx\"] ??= \"ynpx @bluelovers/tsdx build --target node\";\n\n\t// 設定複製宣告檔案的腳本 (Windows 語法)\n\t// Set declaration file copy script (Windows syntax)\n\tpkg.scripts[\"build:dts:copy\"] ??= \"copy .\\\\src\\\\index.d.ts .\\\\dist\\\\index.d.ts & echo build:dts\";\n\n\t// 設定 TypeScript 宣告檔案輸出腳本\n\t// Set TypeScript declaration file emit script\n\tpkg.scripts[\"build:dts:tsc:emit\"] ??= \"tsc --emitDeclarationOnly --declaration --noEmit false\";\n\n\t// 組合完整的 dts 建置腳本\n\t// Compose complete dts build script\n\tpkg.scripts[\"build:dts:tsc\"] ??= [\n 'yarn run build:dts:copy',\n 'yarn run build:dts:tsc:emit',\n 'yarn run build:dts:copy',\n ].join(' && ');\n\n\t// 設定模組入口點\n\t// Set module entry points\n\tpkg.main = \"dist/index.cjs\";\n\tpkg.module = \"dist/index.esm.mjs\";\n\tpkg.types = pkg.typings = \"dist/index.d.ts\";\n\n\t// 設定 unpkg CDN 入口點\n\t// Set unpkg CDN entry point\n\tpkg.unpkg ??= \"dist/index.umd.production.min.cjs\";\n\n\t// 設定 exports 欄位,定義模組匯出映射\n\t// Set exports field, defining module export mappings\n\tpkg.exports ??= {};\n\tpkg.exports['.'] ??= {};\n\tpkg.exports['.'].types = \"./dist/index.d.ts\";\n\tpkg.exports['.'].import = \"./dist/index.esm.mjs\";\n\tpkg.exports['.'].require = \"./dist/index.cjs\";\n\n\t// 允許直接存取 src 目錄下的檔案\n\t// Allow direct access to files under src directory\n\tpkg.exports['./src/*'] = './src/*';\n\n\t// 匯出 package.json 本身\n\t// Export package.json itself\n\tpkg.exports['./package.json'] ??= './package.json';\n\n\t// 確保 keywords 欄位存在\n\t// Ensure keywords field exists\n\tpkg.keywords ??= [];\n\n\t// 添加 tsdx 標識關鍵字(如果尚未存在)\n\t// Add tsdx identifier keyword if not already present\n\tif (!pkg.keywords.includes(EnumTsdx.keyword))\n\t{\n\t\tpkg.keywords.push(EnumTsdx.keyword);\n\t}\n\n\t// 呼叫 fixTsdxPackage 進行額外的修復\n\t// Call fixTsdxPackage for additional fixes\n\tfixTsdxPackage(pkg, config);\n\n\treturn pkg\n}\n\n/**\n * 預設的靜態檔案複製映射表\n * Default static file copy mapping table\n *\n * 定義需要複製到目標專案的靜態檔案,每個項目為 [目標路徑, 來源路徑, ?來源檔名] 的格式。\n * Defines static files that need to be copied to the target project,\n * each entry follows [targetPath, sourcePath, ?sourceFileName] format.\n */\nconst _defaultCopyStaticFilesTsdx = [\n\n\t// 根目錄的 tsconfig.json 設定檔\n\t// Root tsconfig.json configuration file\n\t['tsconfig.json', 'file/tsconfig.tsdx.json.tpl'],\n\n\t// 測試目錄的 tsconfig.json 設定檔\n\t// Test directory tsconfig.json configuration file\n\t['test/tsconfig.json', 'file/test/tsconfig.json.tpl'],\n\n\t// src 目錄下的 index.cts 檔案\n\t// index.cts file under src directory\n\t['src/index.cts', 'file/tsdx/index.cts'],\n\n\t// src 目錄的 tsconfig.json 設定檔\n\t// src directory tsconfig.json configuration file\n\t['src/tsconfig.json', 'file/tsdx/tsconfig.json.tpl'],\n\n] as const;\n\n/**\n * 凍結的預設靜態檔案映射表\n * Frozen default static file mapping table\n */\nexport const defaultCopyStaticFilesTsdx = Object.freeze(_defaultCopyStaticFilesTsdx) as any as IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFilesTsdx>>;\n\n/**\n * tsdx 設定選項介面\n * tsdx setup options interface\n *\n * @template P - package.json 類型 / package.json type\n */\nexport interface ISetupTsdxOptions<P extends IPackageJson>\n{\n\t/** 目標目錄路徑 / Target directory path */\n\ttargetDir: string,\n\n\t/** package.json 物件 / package.json object */\n\tpkg: P,\n\n\t/** 工作區根目錄資訊 / Workspace root directory information */\n\trootData: IFindRootReturnType,\n\n\t/** 靜態檔案映射表 / Static file mapping table */\n\tfile_map: IStaticFilesMapArray<string>,\n\n\t/** README 檔案名稱 / README file name */\n\tmdFile: string,\n\n\t/** 是否存在 README 檔案 / Whether README file exists */\n\texistsReadme: boolean,\n\n\t/** 是否為已存在的專案 / Whether it's an existing project */\n\toldExists: boolean,\n}\n\n/**\n * 設定 tsdx 專案的主要函式\n * Main function for setting up tsdx project\n *\n * 此函式執行以下操作:\n * This function performs the following operations:\n *\n * 1. 更新 package.json 設定\n * Update package.json configuration\n *\n * 2. 合併預設與自訂的靜態檔案映射\n * Merge default and custom static file mappings\n *\n * 3. 確保 src 目錄存在\n * Ensure src directory exists\n *\n * @template P - package.json 類型 / package.json type\n * @param config - 設定選項 / Configuration options\n * @returns 包含更新後設定的物件 / Object containing updated configuration\n */\nexport function setup<P extends IPackageJson>(config: ISetupTsdxOptions<P>)\n{\n\tlet {\n\t\tpkg,\n\t\tfile_map,\n\t\ttargetDir,\n\t} = config;\n\n\t// 更新 package.json\n\t// Update package.json\n\tpkg = updatePackageJson(pkg, config);\n\n\t// 合併預設與自訂的靜態檔案映射\n\t// Merge default and custom static file mappings\n\tfile_map = [\n ...defaultCopyStaticFilesTsdx,\n\t\t...file_map,\n\t];\n\n\t// 確保 src 目錄存在\n\t// Ensure src directory exists\n\tensureDirSync(resolve(targetDir, 'src'));\n\n\treturn {\n\t\t...config,\n\t\tpkg,\n\t\tfile_map,\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAmCH,8CA8FC;AAsFD,sBA4BC;AA9OD,yEAA8G;AAG9G,+BAAuC;AACvC,uCAAyC;AACzC,+BAA+B;AAE/B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,iBAAiB,CAAyB,GAAM,EAAE,MAA6B;;;IAE9F,kBAAkB;IAClB,8BAA8B;IAC9B,MAAA,GAAG,CAAC,OAAO,oCAAX,GAAG,CAAC,OAAO,GAAK,EAAE,EAAC;IAEnB,4BAA4B;IAC5B,kEAAkE;IAClE,IAAI,IAAA,uCAA6B,EAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EACtD,CAAC;QACA,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,sBAAsB;IACtB,kC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BAAoB,EAAE,6BAA6B,CAAC;IAErD,wBAAwB;IACxB,qCAAqC;IACrC,CAAC,eAAe,EAAE,qBAAqB,CAAC;IAExC,4BAA4B;IAC5B,iDAAiD;IACjD,CAAC,mBAAmB,EAAE,6BAA6B,CAAC;CAE3C,CAAC;AAEX;;;GAGG;AACU,QAAA,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAA0E,CAAC;AAgC9J;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,KAAK,CAAyB,MAA4B;IAEzE,IAAI,EACH,GAAG,EACH,QAAQ,EACR,SAAS,GACT,GAAG,MAAM,CAAC;IAEX,kBAAkB;IAClB,sBAAsB;IACtB,GAAG,GAAG,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAErC,iBAAiB;IACjB,gDAAgD;IAChD,QAAQ,GAAG;QACR,GAAG,kCAA0B;QAC/B,GAAG,QAAQ;KACX,CAAC;IAEF,cAAc;IACd,8BAA8B;IAC9B,IAAA,wBAAa,EAAC,IAAA,cAAO,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEzC,OAAO;QACN,GAAG,MAAM;QACT,GAAG;QACH,QAAQ;KACR,CAAA;AACF,CAAC","sourcesContent":["/**\n * tsdx 專案設定模組\n * tsdx project setup module\n *\n * 此模組提供設定 tsdx 專案的核心功能,包括更新 package.json、\n * 設定靜態檔案映射以及主要設定函式。\n * This module provides core functionality for setting up tsdx projects,\n * including updating package.json, configuring static file mappings,\n * and the main setup function.\n */\n\nimport { IPackageJson } from '@ts-type/package-dts/package-json';\nimport { IFindRootReturnType } from '@yarn-tool/find-root';\nimport { _Key, IStaticFilesMapArray } from '@yarn-tool/static-file/lib/types';\nimport { EnumScriptsEntry, scriptsEntryIsNoTestSpecified } from '@yarn-tool/pkg-entry-util/lib/field/scripts';\nimport { deleteValue } from 'dot-values2';\nimport { EnumTsdx } from './const';\nimport { fixTsdxPackage } from './fix';\nimport { ensureDirSync } from 'fs-extra';\nimport { resolve } from 'path';\n\n/**\n * 更新 package.json 以符合 tsdx 專案標準\n * Update package.json to conform to tsdx project standards\n *\n * 此函式會設定以下內容:\n * This function configures the following:\n *\n * - scripts: test, posttest, build, build:dts:bundle, build:tsdx 等\n * scripts: test, posttest, build, build:dts:bundle, build:tsdx, etc.\n *\n * - main/module/types: 設定輸出檔案路徑\n * main/module/types: configure output file paths\n *\n * - exports: 設定模組匯出映射\n * exports: configure module export mappings\n *\n * - keywords: 添加 tsdx 標識關鍵字\n * keywords: add tsdx identifier keyword\n *\n * @param pkg - 要更新的 package.json 物件 / package.json object to update\n * @param config - 設定選項 (可選) / configuration options (optional)\n * @returns 更新後的 package.json 物件 / Updated package.json object\n */\nexport function updatePackageJson<P extends IPackageJson>(pkg: P, config?: ISetupTsdxOptions<P>)\n{\n\t// 確保 scripts 欄位存在\n\t// Ensure scripts field exists\n\tpkg.scripts ??= {};\n\n\t// 如果 test 腳本未指定或為空,清除並設定預設值\n\t// If test script is not specified or empty, clear and set default\n\tif (scriptsEntryIsNoTestSpecified(pkg.scripts[\"test\"]))\n\t{\n\t\tpkg.scripts[\"test\"] = void 0;\n\t}\n\n\t// 設定預設的 test 腳本為 jest\n\t// Set default test script to jest\n\tpkg.scripts[\"test\"] ??= EnumScriptsEntry.JEST_TEST;\n\n\t// 設定 posttest 腳本,在測試後執行 build\n\t// Set posttest script to run build after tests\n\tpkg.scripts[\"posttest\"] ??= \"yarn run build\";\n\n\t// 如果 build 腳本不包含 tsdx build,則設定新的 build 腳本\n\t// If build script doesn't include tsdx build, set new build script\n\tif (!pkg.scripts[\"build\"]?.includes('run build:tsdx'))\n\t{\n\t\tpkg.scripts[\"build\"] = \"node --run build:tsdx && node --run build:dts:bundle\";\n\t}\n\n\t// 設定 TypeScript 宣告檔案打包腳本\n\t// Set TypeScript declaration file bundling script\n\tpkg.scripts[\"build:dts:bundle\"] ??= EnumScriptsEntry.BUILD_DTS_BUNDLE;\n\n\t// 設定 tsdx build 腳本,目標為 node 環境\n\t// Set tsdx build script targeting node environment\n\tpkg.scripts[\"build:tsdx\"] ??= \"ynpx @bluelovers/tsdx build --target node\";\n\n\t// 設定複製宣告檔案的腳本 (Windows 語法)\n\t// Set declaration file copy script (Windows syntax)\n\tpkg.scripts[\"build:dts:copy\"] ??= \"copy .\\\\src\\\\index.d.ts .\\\\dist\\\\index.d.ts & echo build:dts\";\n\n\t// 設定 TypeScript 宣告檔案輸出腳本\n\t// Set TypeScript declaration file emit script\n\tpkg.scripts[\"build:dts:tsc:emit\"] ??= \"tsc --emitDeclarationOnly --declaration --noEmit false\";\n\n\t// 組合完整的 dts 建置腳本\n\t// Compose complete dts build script\n\tpkg.scripts[\"build:dts:tsc\"] ??= [\n 'node --run build:dts:copy',\n 'node --run build:dts:tsc:emit',\n 'node --run build:dts:copy',\n ].join(' && ');\n\n\t// 設定模組入口點\n\t// Set module entry points\n\tpkg.main = \"dist/index.cjs\";\n\tpkg.module = \"dist/index.esm.mjs\";\n\tpkg.types = pkg.typings = \"dist/index.d.ts\";\n\n\t// 設定 unpkg CDN 入口點\n\t// Set unpkg CDN entry point\n\tpkg.unpkg ??= \"dist/index.umd.production.min.cjs\";\n\n\t// 設定 exports 欄位,定義模組匯出映射\n\t// Set exports field, defining module export mappings\n\tpkg.exports ??= {};\n\tpkg.exports['.'] ??= {};\n\tpkg.exports['.'].types = \"./dist/index.d.ts\";\n\tpkg.exports['.'].import = \"./dist/index.esm.mjs\";\n\tpkg.exports['.'].require = \"./dist/index.cjs\";\n\n\t// 允許直接存取 src 目錄下的檔案\n\t// Allow direct access to files under src directory\n\tpkg.exports['./src/*'] = './src/*';\n\n\t// 匯出 package.json 本身\n\t// Export package.json itself\n\tpkg.exports['./package.json'] ??= './package.json';\n\n\t// 確保 keywords 欄位存在\n\t// Ensure keywords field exists\n\tpkg.keywords ??= [];\n\n\t// 添加 tsdx 標識關鍵字(如果尚未存在)\n\t// Add tsdx identifier keyword if not already present\n\tif (!pkg.keywords.includes(EnumTsdx.keyword))\n\t{\n\t\tpkg.keywords.push(EnumTsdx.keyword);\n\t}\n\n\t// 呼叫 fixTsdxPackage 進行額外的修復\n\t// Call fixTsdxPackage for additional fixes\n\tfixTsdxPackage(pkg, config);\n\n\treturn pkg\n}\n\n/**\n * 預設的靜態檔案複製映射表\n * Default static file copy mapping table\n *\n * 定義需要複製到目標專案的靜態檔案,每個項目為 [目標路徑, 來源路徑, ?來源檔名] 的格式。\n * Defines static files that need to be copied to the target project,\n * each entry follows [targetPath, sourcePath, ?sourceFileName] format.\n */\nconst _defaultCopyStaticFilesTsdx = [\n\n\t// 根目錄的 tsconfig.json 設定檔\n\t// Root tsconfig.json configuration file\n\t['tsconfig.json', 'file/tsconfig.tsdx.json.tpl'],\n\n\t// 測試目錄的 tsconfig.json 設定檔\n\t// Test directory tsconfig.json configuration file\n\t['test/tsconfig.json', 'file/test/tsconfig.json.tpl'],\n\n\t// src 目錄下的 index.cts 檔案\n\t// index.cts file under src directory\n\t['src/index.cts', 'file/tsdx/index.cts'],\n\n\t// src 目錄的 tsconfig.json 設定檔\n\t// src directory tsconfig.json configuration file\n\t['src/tsconfig.json', 'file/tsdx/tsconfig.json.tpl'],\n\n] as const;\n\n/**\n * 凍結的預設靜態檔案映射表\n * Frozen default static file mapping table\n */\nexport const defaultCopyStaticFilesTsdx = Object.freeze(_defaultCopyStaticFilesTsdx) as any as IStaticFilesMapArray<_Key<typeof _defaultCopyStaticFilesTsdx>>;\n\n/**\n * tsdx 設定選項介面\n * tsdx setup options interface\n *\n * @template P - package.json 類型 / package.json type\n */\nexport interface ISetupTsdxOptions<P extends IPackageJson>\n{\n\t/** 目標目錄路徑 / Target directory path */\n\ttargetDir: string,\n\n\t/** package.json 物件 / package.json object */\n\tpkg: P,\n\n\t/** 工作區根目錄資訊 / Workspace root directory information */\n\trootData: IFindRootReturnType,\n\n\t/** 靜態檔案映射表 / Static file mapping table */\n\tfile_map: IStaticFilesMapArray<string>,\n\n\t/** README 檔案名稱 / README file name */\n\tmdFile: string,\n\n\t/** 是否存在 README 檔案 / Whether README file exists */\n\texistsReadme: boolean,\n\n\t/** 是否為已存在的專案 / Whether it's an existing project */\n\toldExists: boolean,\n}\n\n/**\n * 設定 tsdx 專案的主要函式\n * Main function for setting up tsdx project\n *\n * 此函式執行以下操作:\n * This function performs the following operations:\n *\n * 1. 更新 package.json 設定\n * Update package.json configuration\n *\n * 2. 合併預設與自訂的靜態檔案映射\n * Merge default and custom static file mappings\n *\n * 3. 確保 src 目錄存在\n * Ensure src directory exists\n *\n * @template P - package.json 類型 / package.json type\n * @param config - 設定選項 / Configuration options\n * @returns 包含更新後設定的物件 / Object containing updated configuration\n */\nexport function setup<P extends IPackageJson>(config: ISetupTsdxOptions<P>)\n{\n\tlet {\n\t\tpkg,\n\t\tfile_map,\n\t\ttargetDir,\n\t} = config;\n\n\t// 更新 package.json\n\t// Update package.json\n\tpkg = updatePackageJson(pkg, config);\n\n\t// 合併預設與自訂的靜態檔案映射\n\t// Merge default and custom static file mappings\n\tfile_map = [\n ...defaultCopyStaticFilesTsdx,\n\t\t...file_map,\n\t];\n\n\t// 確保 src 目錄存在\n\t// Ensure src directory exists\n\tensureDirSync(resolve(targetDir, 'src'));\n\n\treturn {\n\t\t...config,\n\t\tpkg,\n\t\tfile_map,\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarn-tool/setup-module-env",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.12",
|
|
4
4
|
"description": "用於設定 tsdx 專案環境的工具,自動配置 package.json 與靜態檔案 (Tool for setting up tsdx project environment, auto-configuring package.json and static files)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yarn",
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
"tsc:showConfig": "ynpx get-current-tsconfig -p"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@yarn-tool/pkg-entry-util": "^3.0.
|
|
58
|
+
"@yarn-tool/pkg-entry-util": "^3.0.12",
|
|
59
59
|
"dot-values2": "^2.0.7",
|
|
60
60
|
"tslib": ">=2"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "2cbfd8a3dfa6944bba8e6c55742790fed32dd680"
|
|
66
66
|
}
|