@yarn-tool/fix-all 3.0.6 → 3.0.9
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 +39 -0
- package/lib/pkg/index.js +7 -3
- package/lib/pkg/index.js.map +1 -1
- package/lib/root/index.js +1 -0
- package/lib/root/index.js.map +1 -1
- package/lib/ws/lerna.d.ts +45 -2
- package/lib/ws/lerna.js +85 -8
- package/lib/ws/lerna.js.map +1 -1
- package/package.json +19 -17
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,45 @@
|
|
|
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.9](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/fix-all@3.0.8...@yarn-tool/fix-all@3.0.9) (2026-03-09)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @yarn-tool/fix-all
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.0.8](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/fix-all@3.0.7...@yarn-tool/fix-all@3.0.8) (2026-03-09)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### ✨ Features
|
|
19
|
+
|
|
20
|
+
* **fix-all:** add Lerna testing utilities and improve `lerna.json` handling ([72ea5ed](https://github.com/bluelovers/ws-yarn-workspaces/commit/72ea5edb51ce911951f76ca312d9d177678fe5e0))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### ♻️ Chores
|
|
24
|
+
|
|
25
|
+
* **deps:** 更新 workspace 依賴版本並新增 CI 安裝腳本 ([fbb5b0b](https://github.com/bluelovers/ws-yarn-workspaces/commit/fbb5b0b32cab8cdd34c1f5b5f9a6f8c54213e738))
|
|
26
|
+
* **deps:** 更新 monorepo 依賴版本 ([e44dff2](https://github.com/bluelovers/ws-yarn-workspaces/commit/e44dff29d5d6b7eb7c77acb8414e73f70feff649))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [3.0.7](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/fix-all@3.0.6...@yarn-tool/fix-all@3.0.7) (2026-03-04)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### BREAKING CHANGES
|
|
34
|
+
|
|
35
|
+
* **fix-all:** 自動移除未指定測試的佔位符腳本
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### 🐛 Bug Fixes
|
|
40
|
+
|
|
41
|
+
* **fix-all:** 自動移除未指定測試的佔位符腳本 ([fb7f8d9](https://github.com/bluelovers/ws-yarn-workspaces/commit/fb7f8d9cc8e725652b4d81a6087d3b71f8265ed2))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
6
45
|
## [3.0.6](https://github.com/bluelovers/ws-yarn-workspaces/compare/@yarn-tool/fix-all@3.0.5...@yarn-tool/fix-all@3.0.6) (2026-03-04)
|
|
7
46
|
|
|
8
47
|
**Note:** Version bump only for package @yarn-tool/fix-all
|
package/lib/pkg/index.js
CHANGED
|
@@ -33,6 +33,7 @@ const getRootCopyStaticFiles_1 = require("@yarn-tool/static-file/lib/root/getRoo
|
|
|
33
33
|
const static_file_1 = require("@yarn-tool/static-file");
|
|
34
34
|
const pkg_scripts_1 = require("@yarn-tool/pkg-entry-util/lib/preset/scripts/pkg-scripts");
|
|
35
35
|
const dummy_1 = require("@yarn-tool/pkg-entry-util/lib/util/scripts/dummy");
|
|
36
|
+
const scripts_1 = require("@yarn-tool/pkg-entry-util/lib/field/scripts");
|
|
36
37
|
const is_tsdx_1 = require("@yarn-tool/setup-module-env/lib/preset/tsdx/is-tsdx");
|
|
37
38
|
const fix_1 = require("@yarn-tool/setup-module-env/lib/preset/tsdx/fix");
|
|
38
39
|
const reset_1 = require("../file/reset");
|
|
@@ -75,7 +76,7 @@ function _handler(cwd, ...argv) {
|
|
|
75
76
|
* @param {AggregateErrorExtra} err - 錯誤聚合器 / Error aggregator
|
|
76
77
|
*/
|
|
77
78
|
function _runFixPackagesCore(row, options, cache, err) {
|
|
78
|
-
var _a, _b;
|
|
79
|
+
var _a, _b, _c;
|
|
79
80
|
const { rootData, overwriteHostedGitInfo, hostedGitInfo, branch, resetStaticFiles, } = options;
|
|
80
81
|
// 為套件建立假的根資料 / Create fake root data for the package
|
|
81
82
|
const _rootDataFake = (0, find_root_1.newFakeRootData)(rootData, {
|
|
@@ -133,6 +134,9 @@ function _runFixPackagesCore(row, options, cache, err) {
|
|
|
133
134
|
hostedGitInfo,
|
|
134
135
|
branch,
|
|
135
136
|
});
|
|
137
|
+
if ((0, scripts_1.scriptsEntryIsNoTestSpecified)((_a = pkg.data.scripts) === null || _a === void 0 ? void 0 : _a.test)) {
|
|
138
|
+
delete pkg.data.scripts.test;
|
|
139
|
+
}
|
|
136
140
|
// 若適用則修復 tsdx 套件 / Fix tsdx package if applicable
|
|
137
141
|
if ((0, is_tsdx_1.isTsdxPackage)(pkg.data)) {
|
|
138
142
|
(0, fix_1.fixTsdxPackage)(pkg.data, {
|
|
@@ -154,7 +158,7 @@ function _runFixPackagesCore(row, options, cache, err) {
|
|
|
154
158
|
// 設定預設腳本 / Set default scripts
|
|
155
159
|
pkg.data.scripts = {
|
|
156
160
|
...(0, pkg_scripts_1.defaultPkgScripts)(),
|
|
157
|
-
...((
|
|
161
|
+
...((_b = pkg.data.scripts) !== null && _b !== void 0 ? _b : {}),
|
|
158
162
|
};
|
|
159
163
|
// 處理根套件與非根套件 / Handle root vs non-root packages
|
|
160
164
|
if (isRoot) {
|
|
@@ -168,7 +172,7 @@ function _runFixPackagesCore(row, options, cache, err) {
|
|
|
168
172
|
else {
|
|
169
173
|
// 非根套件:修復 preversion 腳本並移除 packageManager
|
|
170
174
|
// Non-root package: fix preversion script and remove packageManager
|
|
171
|
-
if (!((
|
|
175
|
+
if (!((_c = pkg.data.scripts['_preversion']) === null || _c === void 0 ? void 0 : _c.length) && (0, dummy_1.isDummyEchoMaybeOrEmpty)(pkg.data.scripts.preversion)) {
|
|
172
176
|
pkg.data.scripts.preversion = "yarn run test" /* EnumScriptsEntry.preversion */;
|
|
173
177
|
}
|
|
174
178
|
// 從非根套件移除 packageManager 欄位
|
package/lib/pkg/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAgDA,4BAMC;AA2CD,kDAoJC;AAoBD,sDAiDC;AAYD,gEA0BC;;AAhWD;;;;;;;;GAQG;AACH,6CAAoH;AACpH,oDAA4E;AAC5E,qEAA4D;AAC5D,8DAA6D;AAC7D,+DAA2D;AAC3D,aAAa;AACb,gEAAgC;AAChC,uDAA+D;AAC/D,gDAAoD;AACpD,+CAAuC;AAEvC,gEAA0F;AAE1F,2DAAqD;AACrD,gEAAyF;AACzF,uEAA4F;AAC5F,0EAAqE;AACrE,mGAAoG;AACpG,wDAAyD;AACzD,0FAA6F;AAE7F,4EAA2F;AAE3F,iFAAoF;AACpF,yEAAiF;AACjF,yCAAkD;AAElD,mCAA8B;AAC9B,uCAAgD;AAChD,2EAAwE;AAExE;;;;;;;GAOG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,GAAG,IAAgD;IAExF,OAAO;QACN,GAAG,IAAA,uCAAyB,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QAC1C,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;KACZ,CAAA;AACF,CAAC;AAsBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,mBAAmB,CAAC,GAAW,EAAE,OAAgC,EAAE,KAA0B,EAAE,GAAwB;;IAEtI,MAAM,EACL,QAAQ,EACR,sBAAsB,EACtB,aAAa,EACb,MAAM,EACN,gBAAgB,GAChB,GAAG,OAAO,CAAC;IAEZ,qDAAqD;IAC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B,EAAC;QAC7B,GAAG;KACH,EAAE,GAAG,EAAE;QACP,OAAO,CAAC,GAAG,IAAI;YAEd,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;QAC9B,CAAC;KACD,CAAC,CAAA;AACH,CAAC","sourcesContent":["/**\n * @yarn-tool/fix-all/lib/pkg\n *\n * package.json 自動修復處理模組\n * package.json auto-fix processing module\n *\n * 處理 workspace 中每個套件的迭代與修復\n * Handles the iteration and fixing of each package in the workspace\n */\nimport { IOptionsPkgListable, normalizeListableRowExtra, wsPkgListable, wsPkgListableFromPaths } from 'ws-pkg-list';\nimport { IFindRootReturnType, newFakeRootData } from '@yarn-tool/find-root';\nimport { PackageJsonLoader } from 'npm-package-json-loader';\nimport { pkgExportsVerify } from '@yarn-tool/pkg-entry-util';\nimport { AggregateErrorExtra } from 'lazy-aggregate-error';\n// @ts-ignore\nimport Bluebird from 'bluebird';\nimport { createProgressEstimator } from '../util/cli-progress';\nimport { consoleLogger } from 'debug-color2/logger';\nimport { console } from 'debug-color2';\nimport { ProgressEstimator } from 'progress-estimator';\nimport { fillPkgHostedInfo, IFillPkgHostedInfoOptions } from '@yarn-tool/pkg-hosted-info';\nimport { ITSRequiredPick } from 'ts-type/lib/type/record';\nimport { sortPackageJson } from 'sort-package-json3';\nimport { fixPkgDepsVersionsCore, ICache, ICacheInput } from '@yarn-tool/fix-ws-versions';\nimport { packageJsonDependenciesFields } from '@ts-type/package-dts/lib/package-json/types';\nimport { normalizeDepsValue } from '@yarn-tool/normalize-deps-value';\nimport { getRootCopyStaticFilesAuto } from '@yarn-tool/static-file/lib/root/getRootCopyStaticFiles';\nimport { copyStaticFiles } from '@yarn-tool/static-file';\nimport { defaultPkgScripts } from '@yarn-tool/pkg-entry-util/lib/preset/scripts/pkg-scripts';\nimport { pathIsSame } from 'path-is-same';\nimport { isDummyEchoMaybeOrEmpty } from '@yarn-tool/pkg-entry-util/lib/util/scripts/dummy';\nimport { EnumScriptsEntry } from '@yarn-tool/pkg-entry-util/lib/field/scripts';\nimport { isTsdxPackage } from '@yarn-tool/setup-module-env/lib/preset/tsdx/is-tsdx';\nimport { fixTsdxPackage } from '@yarn-tool/setup-module-env/lib/preset/tsdx/fix';\nimport { _resetStaticFiles } from '../file/reset';\nimport { INpmAutoFixAll } from '../../index';\nimport { join } from 'upath2';\nimport { existsSync, statSync } from 'fs-extra';\nimport { writeReadme } from '@yarn-tool/pkg-readme-tpl/lib/writeReadme';\n\n/**\n * 處理套件列表項目的 handler 函數\n * Handler function for processing package list entries\n *\n * @param {string} cwd - 當前工作目錄 / Current working directory\n * @param {Parameters<IOptionsPkgListable[\"handler\"]>} argv - Handler 參數 / Handler arguments\n * @returns {object} 處理後的項目物件 / Processed entry object\n */\nexport function _handler(cwd: string, ...argv: Parameters<IOptionsPkgListable[\"handler\"]>)\n{\n\treturn {\n\t\t...normalizeListableRowExtra(argv[0], cwd),\n\t\tpkg: argv[1],\n\t}\n}\n\n/**\n * _handler 返回的項目類型\n * Entry type returned by _handler\n */\nexport type IEntry = ReturnType<typeof _handler>\n\n/**\n * 執行每個套件修復的選項\n * Options for running each package fix\n *\n * 繼承自 IFillPkgHostedInfoOptions 和 INpmAutoFixAll 的必要屬性\n * Inherits required properties from IFillPkgHostedInfoOptions and INpmAutoFixAll\n *\n * @extends {ITSRequiredPick<IFillPkgHostedInfoOptions & INpmAutoFixAll, ...>}\n */\nexport interface IOptionsRunEachPackages extends ITSRequiredPick<IFillPkgHostedInfoOptions & INpmAutoFixAll, 'overwriteHostedGitInfo' | 'branch' | 'rootData' | 'hostedGitInfo' | 'resetStaticFiles'>\n{\n\n}\n\n/**\n * 執行單一套件修復的核心函數\n * Core function for fixing a single package\n *\n * 此函數負責對單一套件執行完整的修復流程,包括:\n * This function performs the complete fix process for a single package, including:\n * 1. 重置靜態檔案(如啟用)/ Reset static files (if enabled)\n * 2. 複製靜態檔案到套件目錄 / Copy static files to package directory\n * 3. 驗證套件匯出 / Verify package exports\n * 4. 填充託管 git 資訊 / Fill hosted git info\n * 5. 修復 tsdx 套件(如適用)/ Fix tsdx package (if applicable)\n * 6. 修復依賴版本 / Fix dependency versions\n * 7. 標準化依賴值 / Normalize dependency values\n * 8. 設定預設腳本 / Set default scripts\n * 9. 排序並寫入 package.json / Sort and write package.json\n *\n * @param {IEntry} row - 套件項目資料 / Package entry data\n * @param {IOptionsRunEachPackages} options - 修復操作的選項 / Options for the fix operation\n * @param {ICacheInput<IEntry>} cache - 依賴版本修復的快取 / Cache for dependency version fixing\n * @param {AggregateErrorExtra} err - 錯誤聚合器 / Error aggregator\n */\nexport function _runFixPackagesCore(row: IEntry, options: IOptionsRunEachPackages, cache: ICacheInput<IEntry>, err: AggregateErrorExtra)\n{\n\tconst {\n\t\trootData,\n\t\toverwriteHostedGitInfo,\n\t\thostedGitInfo,\n\t\tbranch,\n\t\tresetStaticFiles,\n\t} = options;\n\n\t// 為套件建立假的根資料 / Create fake root data for the package\n\tconst _rootDataFake = newFakeRootData(rootData, {\n\t\tpkg: row.location,\n\t});\n\n\tconst { isRoot, isWorkspace } = _rootDataFake;\n\n\t// 載入 package.json / Load package.json\n\tconst pkg = new PackageJsonLoader(row.manifestLocation);\n\n\t// 若選項啟用則重置靜態檔案 / Reset static files if option enabled\n\tif (resetStaticFiles)\n\t{\n\t\t_resetStaticFiles(_rootDataFake.pkg, {\n\t\t\trootData: _rootDataFake,\n\t\t});\n\t}\n\n\t// 檢查 README.md 是否存在或檔案過小,若符合條件則標記需要生成\n\t// Check if README.md exists or file is too small, mark for generation if condition met\n\tconst mdFile = join(row.location, 'README.md');\n\tlet shouldWriteReadme = false;\n\n\tif (!existsSync(mdFile))\n\t{\n\t\t// README.md 不存在,需要生成 / README.md doesn't exist, needs generation\n\t\tshouldWriteReadme = true;\n\t}\n\telse\n\t{\n\t\t// 檢查檔案大小,若小於 1KB 則重新生成 / Check file size, regenerate if smaller than 1KB\n\t\tconst stats = statSync(mdFile);\n\t\tif (stats.size < 1024)\n\t\t{\n\t\t\tshouldWriteReadme = true;\n\t\t}\n\t}\n\n\t// 複製靜態檔案到套件目錄 / Copy static files to package directory\n\tcopyStaticFiles({\n\t\tcwd: row.location,\n\t\tfile_map: getRootCopyStaticFilesAuto(_rootDataFake),\n\t});\n\n\t// 若 README.md 不存在或小於 1KB 則自動生成 / Auto-generate README.md if it doesn't exist or is smaller than 1KB\n\tif (shouldWriteReadme)\n\t{\n\t\twriteReadme({\n\t\t\tfile: mdFile,\n\t\t\tvariable: pkg.data,\n\t\t})\n\t}\n\n\t// 驗證套件匯出 / Verify package exports\n\ttry\n\t{\n\t\tpkgExportsVerify(pkg.data, {\n\t\t\tcwd: row.location,\n\t\t});\n\t}\n\tcatch (e)\n\t{\n\t\terr.push(e);\n\t}\n\n\t// 填充託管 git 資訊(homepage, repository, bugs)/ Fill hosted git info\n\tfillPkgHostedInfo(pkg.data, {\n\t\ttargetDir: row.location,\n\t\toverwriteHostedGitInfo,\n\t\thostedGitInfo,\n\t\tbranch,\n\t});\n\n\t// 若適用則修復 tsdx 套件 / Fix tsdx package if applicable\n\tif (isTsdxPackage(pkg.data))\n\t{\n\t\tfixTsdxPackage(pkg.data, {\n\t\t\trootData: _rootDataFake,\n\t\t});\n\t}\n\n\t// 修復依賴版本 / Fix dependency versions\n\tfixPkgDepsVersionsCore(pkg.data, cache);\n\n\t// 標準化依賴值 / Normalize dependency values\n\tpackageJsonDependenciesFields\n\t\t.forEach(field => {\n\n\t\t\tObject.keys(pkg.data[field] ?? {})\n\t\t\t\t.forEach(name => {\n\t\t\t\t\tconst _value = normalizeDepsValue(pkg.data[field][name]);\n\t\t\t\t\tpkg.data[field][name] = _value;\n\t\t\t\t})\n\t\t\t;\n\n\t\t})\n\t;\n\n\t// 設定預設腳本 / Set default scripts\n\tpkg.data.scripts = {\n\t\t...defaultPkgScripts(),\n\t\t...(pkg.data.scripts ?? {}),\n\t};\n\n\t// 處理根套件與非根套件 / Handle root vs non-root packages\n\tif (isRoot)\n\t{\n\t\tif (isWorkspace)\n\t\t{\n\t\t\t// Workspace 根套件 - 無特殊處理 / Workspace root - no special handling\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// 單一套件根 - 無特殊處理 / Single package root - no special handling\n\t\t}\n\t}\n\telse\n\t{\n\t\t// 非根套件:修復 preversion 腳本並移除 packageManager\n\t\t// Non-root package: fix preversion script and remove packageManager\n\t\tif (!pkg.data.scripts['_preversion']?.length && isDummyEchoMaybeOrEmpty(pkg.data.scripts.preversion))\n\t\t{\n\t\t\tpkg.data.scripts.preversion = EnumScriptsEntry.preversion;\n\t\t}\n\n\t\t// 從非根套件移除 packageManager 欄位\n\t\t// Remove packageManager field from non-root packages\n\t\tif (pkg.data['packageManager'])\n\t\t{\n\t\t\tdelete pkg.data['packageManager'];\n\t\t}\n\t}\n\n\t// 排序並寫入 package.json / Sort and write package.json\n\tpkg.data = sortPackageJson(pkg.data);\n\n\tpkg.autofix();\n\tpkg.write();\n}\n\n/**\n * 非同步執行每個套件的修復操作\n * Run fix operations on each package asynchronously\n *\n * 對每個套件執行以下操作:\n * Performs the following operations on each package:\n * 1. 驗證套件匯出 / Verify package exports\n * 2. 填充託管 git 資訊 / Fill hosted git info\n * 3. 修復 tsdx 套件(如適用)/ Fix tsdx package (if applicable)\n * 4. 修復依賴版本 / Fix dependency versions\n * 5. 標準化依賴值 / Normalize dependency values\n * 6. 設定預設腳本 / Set default scripts\n * 7. 排序並寫入 package.json / Sort and write package.json\n *\n * @param {IEntry[]} list - 套件項目列表 / List of package entries\n * @param {IOptionsRunEachPackages} options - 修復操作的選項 / Options for the fix operation\n * @returns {Bluebird<void>} Promise 物件 / Promise object\n */\nexport function _runEachPackagesAsync(list: IEntry[],\n\toptions: IOptionsRunEachPackages,\n)\n{\n\tlet logger: ProgressEstimator;\n\t// 依賴版本修復的快取 / Cache for dependency version fixing\n\tlet cache: ICacheInput<IEntry> = {} as any;\n\n\treturn Bluebird.resolve(list)\n\t\t.tap((listable) =>\n\t\t{\n\t\t\t// 建立進度估計器 / Create progress estimator\n\t\t\tlogger = createProgressEstimator(options.rootData.root);\n\n\t\t\tconsoleLogger.info(`auto check/fix packages`);\n\n\t\t\tcache.listable = listable;\n\n\t\t})\n\t\t.mapSeries(async (row) =>\n\t\t{\n\t\t\t// 錯誤收集器 / Error aggregator for collecting errors\n\t\t\tconst err = new AggregateErrorExtra();\n\n\t\t\tconst promiseLogger = logger((async () =>\n\t\t\t{\n\n\t\t\t\t_runFixPackagesCore(row, options, cache, err);\n\n\t\t\t})().catch(e => {\n\t\t\t\te.row = row;\n\t\t\t\terr.push(e);\n\t\t\t}), row.name)\n\n\t\t\treturn promiseLogger\n\t\t\t\t.catch(e => {\n\t\t\t\t\te.row = row;\n\t\t\t\t\terr.push(e);\n\t\t\t\t})\n\t\t\t\t.then(() =>\n\t\t\t\t{\n\t\t\t\t\t// 若有錯誤則記錄 / Log errors if any\n\t\t\t\t\tif (err.length)\n\t\t\t\t\t{\n\t\t\t\t\t\tconsole.error(err);\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t})\n\t\t;\n}\n\n/**\n * 從根資料初始化套件列表\n * Initialize package list from root data\n *\n * 根據 workspace 或單一套件模式返回要處理的套件列表\n * Returns list of packages to process based on workspace or single package mode\n *\n * @param {Pick<IFindRootReturnType, 'root' | 'hasWorkspace'>} rootData - 根資料物件 / Root data object\n * @returns {IEntry[]} 套件項目列表 / List of package entries\n */\nexport function _initPkgListableByRootData(rootData: Pick<IFindRootReturnType, 'root' | 'hasWorkspace'>)\n{\n\tlet cwd = rootData.root;\n\n\t// Workspace 模式:取得 workspace 中的所有套件\n\t// Workspace mode: get all packages in workspace\n\tif (rootData.hasWorkspace)\n\t{\n\t\treturn wsPkgListable(cwd, {\n\t\t\thandler(...argv)\n\t\t\t{\n\t\t\t\treturn _handler(cwd, ...argv)\n\t\t\t},\n\t\t})\n\t}\n\n\t// 單一套件模式:僅返回根套件\n\t// Single package mode: return only the root package\n\treturn wsPkgListableFromPaths([\n\t\tcwd,\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AA,oCAAsB,EAAC;QAC7B,GAAG;KACH,EAAE,GAAG,EAAE;QACP,OAAO,CAAC,GAAG,IAAI;YAEd,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;QAC9B,CAAC;KACD,CAAC,CAAA;AACH,CAAC","sourcesContent":["/**\n * @yarn-tool/fix-all/lib/pkg\n *\n * package.json 自動修復處理模組\n * package.json auto-fix processing module\n *\n * 處理 workspace 中每個套件的迭代與修復\n * Handles the iteration and fixing of each package in the workspace\n */\nimport { IOptionsPkgListable, normalizeListableRowExtra, wsPkgListable, wsPkgListableFromPaths } from 'ws-pkg-list';\nimport { IFindRootReturnType, newFakeRootData } from '@yarn-tool/find-root';\nimport { PackageJsonLoader } from 'npm-package-json-loader';\nimport { pkgExportsVerify } from '@yarn-tool/pkg-entry-util';\nimport { AggregateErrorExtra } from 'lazy-aggregate-error';\n// @ts-ignore\nimport Bluebird from 'bluebird';\nimport { createProgressEstimator } from '../util/cli-progress';\nimport { consoleLogger } from 'debug-color2/logger';\nimport { console } from 'debug-color2';\nimport { ProgressEstimator } from 'progress-estimator';\nimport { fillPkgHostedInfo, IFillPkgHostedInfoOptions } from '@yarn-tool/pkg-hosted-info';\nimport { ITSRequiredPick } from 'ts-type/lib/type/record';\nimport { sortPackageJson } from 'sort-package-json3';\nimport { fixPkgDepsVersionsCore, ICache, ICacheInput } from '@yarn-tool/fix-ws-versions';\nimport { packageJsonDependenciesFields } from '@ts-type/package-dts/lib/package-json/types';\nimport { normalizeDepsValue } from '@yarn-tool/normalize-deps-value';\nimport { getRootCopyStaticFilesAuto } from '@yarn-tool/static-file/lib/root/getRootCopyStaticFiles';\nimport { copyStaticFiles } from '@yarn-tool/static-file';\nimport { defaultPkgScripts } from '@yarn-tool/pkg-entry-util/lib/preset/scripts/pkg-scripts';\nimport { pathIsSame } from 'path-is-same';\nimport { isDummyEchoMaybeOrEmpty } from '@yarn-tool/pkg-entry-util/lib/util/scripts/dummy';\nimport { EnumScriptsEntry, scriptsEntryIsNoTestSpecified } from '@yarn-tool/pkg-entry-util/lib/field/scripts';\nimport { isTsdxPackage } from '@yarn-tool/setup-module-env/lib/preset/tsdx/is-tsdx';\nimport { fixTsdxPackage } from '@yarn-tool/setup-module-env/lib/preset/tsdx/fix';\nimport { _resetStaticFiles } from '../file/reset';\nimport { INpmAutoFixAll } from '../../index';\nimport { join } from 'upath2';\nimport { existsSync, statSync } from 'fs-extra';\nimport { writeReadme } from '@yarn-tool/pkg-readme-tpl/lib/writeReadme';\n\n/**\n * 處理套件列表項目的 handler 函數\n * Handler function for processing package list entries\n *\n * @param {string} cwd - 當前工作目錄 / Current working directory\n * @param {Parameters<IOptionsPkgListable[\"handler\"]>} argv - Handler 參數 / Handler arguments\n * @returns {object} 處理後的項目物件 / Processed entry object\n */\nexport function _handler(cwd: string, ...argv: Parameters<IOptionsPkgListable[\"handler\"]>)\n{\n\treturn {\n\t\t...normalizeListableRowExtra(argv[0], cwd),\n\t\tpkg: argv[1],\n\t}\n}\n\n/**\n * _handler 返回的項目類型\n * Entry type returned by _handler\n */\nexport type IEntry = ReturnType<typeof _handler>\n\n/**\n * 執行每個套件修復的選項\n * Options for running each package fix\n *\n * 繼承自 IFillPkgHostedInfoOptions 和 INpmAutoFixAll 的必要屬性\n * Inherits required properties from IFillPkgHostedInfoOptions and INpmAutoFixAll\n *\n * @extends {ITSRequiredPick<IFillPkgHostedInfoOptions & INpmAutoFixAll, ...>}\n */\nexport interface IOptionsRunEachPackages extends ITSRequiredPick<IFillPkgHostedInfoOptions & INpmAutoFixAll, 'overwriteHostedGitInfo' | 'branch' | 'rootData' | 'hostedGitInfo' | 'resetStaticFiles'>\n{\n\n}\n\n/**\n * 執行單一套件修復的核心函數\n * Core function for fixing a single package\n *\n * 此函數負責對單一套件執行完整的修復流程,包括:\n * This function performs the complete fix process for a single package, including:\n * 1. 重置靜態檔案(如啟用)/ Reset static files (if enabled)\n * 2. 複製靜態檔案到套件目錄 / Copy static files to package directory\n * 3. 驗證套件匯出 / Verify package exports\n * 4. 填充託管 git 資訊 / Fill hosted git info\n * 5. 修復 tsdx 套件(如適用)/ Fix tsdx package (if applicable)\n * 6. 修復依賴版本 / Fix dependency versions\n * 7. 標準化依賴值 / Normalize dependency values\n * 8. 設定預設腳本 / Set default scripts\n * 9. 排序並寫入 package.json / Sort and write package.json\n *\n * @param {IEntry} row - 套件項目資料 / Package entry data\n * @param {IOptionsRunEachPackages} options - 修復操作的選項 / Options for the fix operation\n * @param {ICacheInput<IEntry>} cache - 依賴版本修復的快取 / Cache for dependency version fixing\n * @param {AggregateErrorExtra} err - 錯誤聚合器 / Error aggregator\n */\nexport function _runFixPackagesCore(row: IEntry, options: IOptionsRunEachPackages, cache: ICacheInput<IEntry>, err: AggregateErrorExtra)\n{\n\tconst {\n\t\trootData,\n\t\toverwriteHostedGitInfo,\n\t\thostedGitInfo,\n\t\tbranch,\n\t\tresetStaticFiles,\n\t} = options;\n\n\t// 為套件建立假的根資料 / Create fake root data for the package\n\tconst _rootDataFake = newFakeRootData(rootData, {\n\t\tpkg: row.location,\n\t});\n\n\tconst { isRoot, isWorkspace } = _rootDataFake;\n\n\t// 載入 package.json / Load package.json\n\tconst pkg = new PackageJsonLoader(row.manifestLocation);\n\n\t// 若選項啟用則重置靜態檔案 / Reset static files if option enabled\n\tif (resetStaticFiles)\n\t{\n\t\t_resetStaticFiles(_rootDataFake.pkg, {\n\t\t\trootData: _rootDataFake,\n\t\t});\n\t}\n\n\t// 檢查 README.md 是否存在或檔案過小,若符合條件則標記需要生成\n\t// Check if README.md exists or file is too small, mark for generation if condition met\n\tconst mdFile = join(row.location, 'README.md');\n\tlet shouldWriteReadme = false;\n\n\tif (!existsSync(mdFile))\n\t{\n\t\t// README.md 不存在,需要生成 / README.md doesn't exist, needs generation\n\t\tshouldWriteReadme = true;\n\t}\n\telse\n\t{\n\t\t// 檢查檔案大小,若小於 1KB 則重新生成 / Check file size, regenerate if smaller than 1KB\n\t\tconst stats = statSync(mdFile);\n\t\tif (stats.size < 1024)\n\t\t{\n\t\t\tshouldWriteReadme = true;\n\t\t}\n\t}\n\n\t// 複製靜態檔案到套件目錄 / Copy static files to package directory\n\tcopyStaticFiles({\n\t\tcwd: row.location,\n\t\tfile_map: getRootCopyStaticFilesAuto(_rootDataFake),\n\t});\n\n\t// 若 README.md 不存在或小於 1KB 則自動生成 / Auto-generate README.md if it doesn't exist or is smaller than 1KB\n\tif (shouldWriteReadme)\n\t{\n\t\twriteReadme({\n\t\t\tfile: mdFile,\n\t\t\tvariable: pkg.data,\n\t\t})\n\t}\n\n\t// 驗證套件匯出 / Verify package exports\n\ttry\n\t{\n\t\tpkgExportsVerify(pkg.data, {\n\t\t\tcwd: row.location,\n\t\t});\n\t}\n\tcatch (e)\n\t{\n\t\terr.push(e);\n\t}\n\n\t// 填充託管 git 資訊(homepage, repository, bugs)/ Fill hosted git info\n\tfillPkgHostedInfo(pkg.data, {\n\t\ttargetDir: row.location,\n\t\toverwriteHostedGitInfo,\n\t\thostedGitInfo,\n\t\tbranch,\n\t});\n\n\tif (scriptsEntryIsNoTestSpecified(pkg.data.scripts?.test))\n\t{\n\t\tdelete pkg.data.scripts!.test\n\t}\n\n\t// 若適用則修復 tsdx 套件 / Fix tsdx package if applicable\n\tif (isTsdxPackage(pkg.data))\n\t{\n\t\tfixTsdxPackage(pkg.data, {\n\t\t\trootData: _rootDataFake,\n\t\t});\n\t}\n\n\t// 修復依賴版本 / Fix dependency versions\n\tfixPkgDepsVersionsCore(pkg.data, cache);\n\n\t// 標準化依賴值 / Normalize dependency values\n\tpackageJsonDependenciesFields\n\t\t.forEach(field => {\n\n\t\t\tObject.keys(pkg.data[field] ?? {})\n\t\t\t\t.forEach(name => {\n\t\t\t\t\tconst _value = normalizeDepsValue(pkg.data[field][name]);\n\t\t\t\t\tpkg.data[field][name] = _value;\n\t\t\t\t})\n\t\t\t;\n\n\t\t})\n\t;\n\n\t// 設定預設腳本 / Set default scripts\n\tpkg.data.scripts = {\n\t\t...defaultPkgScripts(),\n\t\t...(pkg.data.scripts ?? {}),\n\t};\n\n\t// 處理根套件與非根套件 / Handle root vs non-root packages\n\tif (isRoot)\n\t{\n\t\tif (isWorkspace)\n\t\t{\n\t\t\t// Workspace 根套件 - 無特殊處理 / Workspace root - no special handling\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// 單一套件根 - 無特殊處理 / Single package root - no special handling\n\t\t}\n\t}\n\telse\n\t{\n\t\t// 非根套件:修復 preversion 腳本並移除 packageManager\n\t\t// Non-root package: fix preversion script and remove packageManager\n\t\tif (!pkg.data.scripts['_preversion']?.length && isDummyEchoMaybeOrEmpty(pkg.data.scripts.preversion))\n\t\t{\n\t\t\tpkg.data.scripts.preversion = EnumScriptsEntry.preversion;\n\t\t}\n\n\t\t// 從非根套件移除 packageManager 欄位\n\t\t// Remove packageManager field from non-root packages\n\t\tif (pkg.data['packageManager'])\n\t\t{\n\t\t\tdelete pkg.data['packageManager'];\n\t\t}\n\t}\n\n\t// 排序並寫入 package.json / Sort and write package.json\n\tpkg.data = sortPackageJson(pkg.data);\n\n\tpkg.autofix();\n\tpkg.write();\n}\n\n/**\n * 非同步執行每個套件的修復操作\n * Run fix operations on each package asynchronously\n *\n * 對每個套件執行以下操作:\n * Performs the following operations on each package:\n * 1. 驗證套件匯出 / Verify package exports\n * 2. 填充託管 git 資訊 / Fill hosted git info\n * 3. 修復 tsdx 套件(如適用)/ Fix tsdx package (if applicable)\n * 4. 修復依賴版本 / Fix dependency versions\n * 5. 標準化依賴值 / Normalize dependency values\n * 6. 設定預設腳本 / Set default scripts\n * 7. 排序並寫入 package.json / Sort and write package.json\n *\n * @param {IEntry[]} list - 套件項目列表 / List of package entries\n * @param {IOptionsRunEachPackages} options - 修復操作的選項 / Options for the fix operation\n * @returns {Bluebird<void>} Promise 物件 / Promise object\n */\nexport function _runEachPackagesAsync(list: IEntry[],\n\toptions: IOptionsRunEachPackages,\n)\n{\n\tlet logger: ProgressEstimator;\n\t// 依賴版本修復的快取 / Cache for dependency version fixing\n\tlet cache: ICacheInput<IEntry> = {} as any;\n\n\treturn Bluebird.resolve(list)\n\t\t.tap((listable) =>\n\t\t{\n\t\t\t// 建立進度估計器 / Create progress estimator\n\t\t\tlogger = createProgressEstimator(options.rootData.root);\n\n\t\t\tconsoleLogger.info(`auto check/fix packages`);\n\n\t\t\tcache.listable = listable;\n\n\t\t})\n\t\t.mapSeries(async (row) =>\n\t\t{\n\t\t\t// 錯誤收集器 / Error aggregator for collecting errors\n\t\t\tconst err = new AggregateErrorExtra();\n\n\t\t\tconst promiseLogger = logger((async () =>\n\t\t\t{\n\n\t\t\t\t_runFixPackagesCore(row, options, cache, err);\n\n\t\t\t})().catch(e => {\n\t\t\t\te.row = row;\n\t\t\t\terr.push(e);\n\t\t\t}), row.name)\n\n\t\t\treturn promiseLogger\n\t\t\t\t.catch(e => {\n\t\t\t\t\te.row = row;\n\t\t\t\t\terr.push(e);\n\t\t\t\t})\n\t\t\t\t.then(() =>\n\t\t\t\t{\n\t\t\t\t\t// 若有錯誤則記錄 / Log errors if any\n\t\t\t\t\tif (err.length)\n\t\t\t\t\t{\n\t\t\t\t\t\tconsole.error(err);\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t})\n\t\t;\n}\n\n/**\n * 從根資料初始化套件列表\n * Initialize package list from root data\n *\n * 根據 workspace 或單一套件模式返回要處理的套件列表\n * Returns list of packages to process based on workspace or single package mode\n *\n * @param {Pick<IFindRootReturnType, 'root' | 'hasWorkspace'>} rootData - 根資料物件 / Root data object\n * @returns {IEntry[]} 套件項目列表 / List of package entries\n */\nexport function _initPkgListableByRootData(rootData: Pick<IFindRootReturnType, 'root' | 'hasWorkspace'>)\n{\n\tlet cwd = rootData.root;\n\n\t// Workspace 模式:取得 workspace 中的所有套件\n\t// Workspace mode: get all packages in workspace\n\tif (rootData.hasWorkspace)\n\t{\n\t\treturn wsPkgListable(cwd, {\n\t\t\thandler(...argv)\n\t\t\t{\n\t\t\t\treturn _handler(cwd, ...argv)\n\t\t\t},\n\t\t})\n\t}\n\n\t// 單一套件模式:僅返回根套件\n\t// Single package mode: return only the root package\n\treturn wsPkgListableFromPaths([\n\t\tcwd,\n\t], cwd, {\n\t\thandler(...argv)\n\t\t{\n\t\t\treturn _handler(cwd, ...argv)\n\t\t},\n\t})\n}\n"]}
|
package/lib/root/index.js
CHANGED
package/lib/root/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAWA,4BAkCC;AAED,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAWA,4BAkCC;AAED,gCA4CC;AA1FD,gEAA0F;AAC1F,mCAA8B;AAC9B,0DAA+D;AAC/D,qEAA4D;AAC5D,kDAAsD;AACtD,2DAAqD;AACrD,kGAA2G;AAC3G,8EAAsF;AACtF,0DAAsE;AAEtE,SAAgB,QAAQ,CAAC,OAA4C;IAEpE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,sBAAsB,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAErF,MAAM,sBAAsB,GAAG,IAAA,aAAI,EAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAE/D,IAAI,aAAa,GAAG,IAAI,2CAAiB,CAAC,sBAAsB,CAAC,CAAC;IAElE,aAAa,aAAb,aAAa,cAAb,aAAa,IAAb,aAAa,GAAK,IAAA,mCAAoB,GAAE,EAAC;IAEzC,IAAI,aAAa,EACjB,CAAC;QACA,IAAA,mCAAiB,EAAC,aAAa,CAAC,IAAI,EAAE;YACrC,SAAS;YACT,QAAQ;YACR,aAAa;YACb,MAAM;YACN,sBAAsB;SACtB,CAAC,CAAC;QAEH,aAAa,CAAC,IAAI,GAAG,IAAA,oCAAe,EAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAEzD,aAAa,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IA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IAAA,oCAAe,EAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAEzE,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAE9B,IAAI,GAAG,GAAG,IAAI,0BAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnD,GAAG,CAAC,SAAS,EAAE,CAAC;IAChB,GAAG,CAAC,IAAI,EAAE,CAAC;IAEX,OAAO,OAAO,CAAA;AACf,CAAC","sourcesContent":["import { ITSRequiredPick } from 'ts-type/lib/type/record';\nimport { fillPkgHostedInfo, IFillPkgHostedInfoOptions } from '@yarn-tool/pkg-hosted-info';\nimport { join } from 'upath2';\nimport { npmHostedGitInfoLazy } from '@yarn-tool/pkg-git-info';\nimport { PackageJsonLoader } from 'npm-package-json-loader';\nimport { WorkspacesScope } from '@yarn-tool/ws-scope';\nimport { sortPackageJson } from 'sort-package-json3';\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 { _checkDependenciesExistsAll } from '@yarn-tool/pkg-deps-add';\n\nexport function _fixRoot(options: Required<IFillPkgHostedInfoOptions>)\n{\n\tlet { rootData, branch, overwriteHostedGitInfo, hostedGitInfo, targetDir } = options;\n\n\tconst root_file_package_json = join(targetDir, 'package.json');\n\n\tlet root_pkg_json = new PackageJsonLoader(root_file_package_json);\n\n\thostedGitInfo ??= npmHostedGitInfoLazy();\n\n\tif (hostedGitInfo)\n\t{\n\t\tfillPkgHostedInfo(root_pkg_json.data, {\n\t\t\ttargetDir,\n\t\t\trootData,\n\t\t\thostedGitInfo,\n\t\t\tbranch,\n\t\t\toverwriteHostedGitInfo,\n\t\t});\n\n\t\troot_pkg_json.data = sortPackageJson(root_pkg_json.data);\n\n\t\troot_pkg_json.write();\n\t}\n\n\treturn {\n\t\troot_file_package_json,\n\t\troot_pkg_json,\n\t\ttargetDir,\n\t\trootData,\n\t\thostedGitInfo,\n\t\tbranch,\n\t\toverwriteHostedGitInfo,\n\t}\n}\n\nexport function _fixWsRoot(options: ITSRequiredPick<IFillPkgHostedInfoOptions, 'hostedGitInfo' | 'rootData' | 'overwriteHostedGitInfo' | 'branch'>)\n{\n\tif (!options.rootData.ws?.length)\n\t{\n\t\tthrow new Error(`Invalid workspaces`)\n\t}\n\n\tlet runtime = _fixRoot({\n\t\t...options,\n\t\ttargetDir: options.rootData.ws,\n\t});\n\n\tObject.entries(fillDummyScripts(defaultWorkspaceRootScripts())).forEach(([key, value]) =>\n\t{\n\t\truntime.root_pkg_json.data.scripts[key] ??= value;\n\t});\n\n\t[\n\t\t'@yarn-tool/ws-find-up-paths',\n\t\t'@types/node',\n\t\t'@bluelovers/tsconfig',\n\t\t'@yarn-tool/require-resolve',\n\t].forEach(name => {\n\t\tconst _check = _checkDependenciesExistsAll(runtime.root_pkg_json.data, [\n\t\t\t'devDependencies',\n\t\t\t'dependencies',\n\t\t], name);\n\n\t\tif (!_check._exists)\n\t\t{\n\t\t\truntime.root_pkg_json.data.devDependencies ??= {};\n\t\t\truntime.root_pkg_json.data.devDependencies[name] = '*';\n\t\t}\n\t});\n\n\truntime.root_pkg_json.data = sortPackageJson(runtime.root_pkg_json.data);\n\n\truntime.root_pkg_json.write();\n\n\tlet wss = new WorkspacesScope(runtime.rootData.ws);\n\twss.syncValue();\n\twss.save();\n\n\treturn runtime\n}\n"]}
|
package/lib/ws/lerna.d.ts
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
import { ITSRequiredPick } from 'ts-type/lib/type/record';
|
|
2
2
|
import { IFillPkgHostedInfoOptions } from '@yarn-tool/pkg-hosted-info';
|
|
3
3
|
import { ILernaJson } from '@ts-type/package-dts/lerna-json';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Lerna 修復選項型別
|
|
6
|
+
* Lerna fix options type
|
|
7
|
+
*
|
|
8
|
+
* 從 IFillPkgHostedInfoOptions 中選取必需的 rootData 屬性
|
|
9
|
+
* Picks the required rootData property from IFillPkgHostedInfoOptions
|
|
10
|
+
*/
|
|
11
|
+
export type IOptionsFixLerna = ITSRequiredPick<IFillPkgHostedInfoOptions, 'rootData'>;
|
|
12
|
+
/**
|
|
13
|
+
* 合併 Lerna 設定核心邏輯
|
|
14
|
+
* Core logic for merging Lerna configuration
|
|
15
|
+
*
|
|
16
|
+
* 將模板中的命令設定與現有設定進行深度合併,並處理 publish.ignoreChanges 的清單合併與去重
|
|
17
|
+
* Performs deep merge of command settings from template with existing config, and handles merging and deduplication of publish.ignoreChanges list
|
|
18
|
+
*
|
|
19
|
+
* @param currentLernaJson - 當前的 lerna.json 設定物件 / Current lerna.json configuration object
|
|
20
|
+
* @param tpl - 模板 lerna.json 設定物件 / Template lerna.json configuration object
|
|
21
|
+
* @returns 合併後的 lerna.json 設定物件 / Merged lerna.json configuration object
|
|
22
|
+
*/
|
|
23
|
+
export declare function _fixLernaJsonCore(currentLernaJson: ILernaJson, tpl: ILernaJson): ILernaJson;
|
|
24
|
+
/**
|
|
25
|
+
* 處理 Lerna 已棄用屬性的核心邏輯
|
|
26
|
+
* Core logic for handling deprecated Lerna properties
|
|
27
|
+
*
|
|
28
|
+
* 檢測 Lerna 版本,若為 7.0.0 以上版本則移除 useWorkspaces 屬性
|
|
29
|
+
* Detects Lerna version and removes useWorkspaces property if version is 7.0.0 or higher
|
|
30
|
+
*
|
|
31
|
+
* Lerna 7.0.0 開始強制使用 workspaces,useWorkspaces 屬性已無意義
|
|
32
|
+
* Since Lerna 7.0.0, workspaces are mandatory and useWorkspaces property is no longer meaningful
|
|
33
|
+
*
|
|
34
|
+
* @param options - 修復選項,包含 rootData 資訊 / Fix options containing rootData information
|
|
35
|
+
* @param currentLernaJson - 當前的 lerna.json 設定物件 / Current lerna.json configuration object
|
|
36
|
+
* @returns 處理後的 lerna.json 設定物件 / Processed lerna.json configuration object
|
|
37
|
+
*/
|
|
38
|
+
export declare function _fixLernaDeprecatedCore(options: IOptionsFixLerna, currentLernaJson: ILernaJson): ILernaJson;
|
|
39
|
+
/**
|
|
40
|
+
* 修復專案中的 lerna.json 檔案
|
|
41
|
+
* Fix lerna.json file in the project
|
|
42
|
+
*
|
|
43
|
+
* 讀取專案根目錄的 lerna.json,與模板進行合併,並處理已棄用的屬性
|
|
44
|
+
* Reads lerna.json from project root, merges with template, and handles deprecated properties
|
|
45
|
+
*
|
|
46
|
+
* @param options - 修復選項,必須包含 rootData.root(專案根目錄) / Fix options, must contain rootData.root (project root directory)
|
|
47
|
+
*/
|
|
48
|
+
export declare function _fixLernaJson(options: IOptionsFixLerna): void;
|
package/lib/ws/lerna.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._fixLernaJsonCore = _fixLernaJsonCore;
|
|
4
|
+
exports._fixLernaDeprecatedCore = _fixLernaDeprecatedCore;
|
|
4
5
|
exports._fixLernaJson = _fixLernaJson;
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
const fs_extra_1 = require("fs-extra");
|
|
@@ -8,19 +9,95 @@ const lodash_1 = require("lodash");
|
|
|
8
9
|
const __root_1 = require("@yarn-tool/static-file/__root");
|
|
9
10
|
const write_package_json_1 = require("@yarn-tool/write-package-json");
|
|
10
11
|
const array_hyper_unique_1 = require("array-hyper-unique");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const package_1 = require("@yarn-tool/require-resolve/lib/package");
|
|
13
|
+
const semver_1 = require("semver");
|
|
14
|
+
/**
|
|
15
|
+
* 合併 Lerna 設定核心邏輯
|
|
16
|
+
* Core logic for merging Lerna configuration
|
|
17
|
+
*
|
|
18
|
+
* 將模板中的命令設定與現有設定進行深度合併,並處理 publish.ignoreChanges 的清單合併與去重
|
|
19
|
+
* Performs deep merge of command settings from template with existing config, and handles merging and deduplication of publish.ignoreChanges list
|
|
20
|
+
*
|
|
21
|
+
* @param currentLernaJson - 當前的 lerna.json 設定物件 / Current lerna.json configuration object
|
|
22
|
+
* @param tpl - 模板 lerna.json 設定物件 / Template lerna.json configuration object
|
|
23
|
+
* @returns 合併後的 lerna.json 設定物件 / Merged lerna.json configuration object
|
|
24
|
+
*/
|
|
25
|
+
function _fixLernaJsonCore(currentLernaJson, tpl) {
|
|
26
|
+
// 使用 defaultsDeep 進行命令設定的深度合併,確保現有設定優先,缺失值從模板補充
|
|
27
|
+
// Use defaultsDeep for deep merging command settings, ensuring existing config takes precedence while filling missing values from template
|
|
28
|
+
currentLernaJson.command = (0, lodash_1.defaultsDeep)(currentLernaJson.command, tpl.command);
|
|
29
|
+
// 合併 publish.ignoreChanges 陣列:將模板的忽略規則附加到現有規則之後
|
|
30
|
+
// Merge publish.ignoreChanges arrays: append template ignore rules after existing rules
|
|
31
|
+
currentLernaJson.command.publish['ignoreChanges'] = currentLernaJson.command.publish['ignoreChanges'].concat(tpl.command.publish['ignoreChanges']);
|
|
32
|
+
// 對合併後的 ignoreChanges 進行去重處理,避免重複的忽略規則
|
|
33
|
+
// Deduplicate the merged ignoreChanges to avoid duplicate ignore rules
|
|
34
|
+
(0, array_hyper_unique_1.array_unique_overwrite)(currentLernaJson.command.publish['ignoreChanges']);
|
|
35
|
+
return currentLernaJson;
|
|
16
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* 處理 Lerna 已棄用屬性的核心邏輯
|
|
39
|
+
* Core logic for handling deprecated Lerna properties
|
|
40
|
+
*
|
|
41
|
+
* 檢測 Lerna 版本,若為 7.0.0 以上版本則移除 useWorkspaces 屬性
|
|
42
|
+
* Detects Lerna version and removes useWorkspaces property if version is 7.0.0 or higher
|
|
43
|
+
*
|
|
44
|
+
* Lerna 7.0.0 開始強制使用 workspaces,useWorkspaces 屬性已無意義
|
|
45
|
+
* Since Lerna 7.0.0, workspaces are mandatory and useWorkspaces property is no longer meaningful
|
|
46
|
+
*
|
|
47
|
+
* @param options - 修復選項,包含 rootData 資訊 / Fix options containing rootData information
|
|
48
|
+
* @param currentLernaJson - 當前的 lerna.json 設定物件 / Current lerna.json configuration object
|
|
49
|
+
* @returns 處理後的 lerna.json 設定物件 / Processed lerna.json configuration object
|
|
50
|
+
*/
|
|
51
|
+
function _fixLernaDeprecatedCore(options, currentLernaJson) {
|
|
52
|
+
try {
|
|
53
|
+
// 解析本機或全域安裝的 lerna 套件資訊
|
|
54
|
+
// Resolve locally or globally installed lerna package information
|
|
55
|
+
let result = (0, package_1.resolvePackage)('lerna', {
|
|
56
|
+
includeGlobal: true,
|
|
57
|
+
includeCurrentDirectory: true,
|
|
58
|
+
});
|
|
59
|
+
// 若 Lerna 版本 >= 7.0.0,移除 useWorkspaces 屬性
|
|
60
|
+
// Remove useWorkspaces property if Lerna version >= 7.0.0
|
|
61
|
+
if ((0, semver_1.gte)(result.pkg.version, '7.0.0')) {
|
|
62
|
+
delete currentLernaJson['useWorkspaces'];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// 若無法解析 lerna 套件(未安裝),靜默忽略錯誤
|
|
66
|
+
// Silently ignore error if lerna package cannot be resolved (not installed)
|
|
67
|
+
catch (e) { }
|
|
68
|
+
return currentLernaJson;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 修復專案中的 lerna.json 檔案
|
|
72
|
+
* Fix lerna.json file in the project
|
|
73
|
+
*
|
|
74
|
+
* 讀取專案根目錄的 lerna.json,與模板進行合併,並處理已棄用的屬性
|
|
75
|
+
* Reads lerna.json from project root, merges with template, and handles deprecated properties
|
|
76
|
+
*
|
|
77
|
+
* @param options - 修復選項,必須包含 rootData.root(專案根目錄) / Fix options, must contain rootData.root (project root directory)
|
|
78
|
+
*/
|
|
17
79
|
function _fixLernaJson(options) {
|
|
80
|
+
// 組合 lerna.json 的完整路徑
|
|
81
|
+
// Compose the full path to lerna.json
|
|
18
82
|
const file = (0, path_1.resolve)(options.rootData.root, 'lerna.json');
|
|
83
|
+
// 只有當 lerna.json 存在時才進行處理
|
|
84
|
+
// Only process if lerna.json exists
|
|
19
85
|
if ((0, fs_extra_1.existsSync)(file)) {
|
|
20
|
-
|
|
86
|
+
// 讀取現有的 lerna.json
|
|
87
|
+
// Read existing lerna.json
|
|
88
|
+
let currentLernaJson = (0, fs_extra_1.readJSONSync)(file);
|
|
89
|
+
// 讀取靜態模板檔案作為合併基準
|
|
90
|
+
// Read static template file as merge baseline
|
|
21
91
|
let json2 = (0, fs_extra_1.readJSONSync)((0, path_1.resolve)(__root_1.__STATIC_ROOT, 'file/lerna.json.tpl'));
|
|
22
|
-
|
|
23
|
-
|
|
92
|
+
// 執行核心合併邏輯
|
|
93
|
+
// Execute core merge logic
|
|
94
|
+
currentLernaJson = _fixLernaJsonCore(currentLernaJson, json2);
|
|
95
|
+
// 處理已棄用的屬性
|
|
96
|
+
// Handle deprecated properties
|
|
97
|
+
currentLernaJson = _fixLernaDeprecatedCore(options, currentLernaJson);
|
|
98
|
+
// 將合併後的結果寫回檔案
|
|
99
|
+
// Write merged result back to file
|
|
100
|
+
(0, write_package_json_1.writePackageJSONSync)(file, currentLernaJson);
|
|
24
101
|
}
|
|
25
102
|
}
|
|
26
103
|
//# sourceMappingURL=lerna.js.map
|
package/lib/ws/lerna.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lerna.js","sourceRoot":"","sources":["lerna.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"lerna.js","sourceRoot":"","sources":["lerna.ts"],"names":[],"mappings":";;AAgCA,8CAeC;AAgBD,0DAwBC;AAWD,sCA8BC;AA9HD,+BAA+B;AAC/B,uCAAoD;AACpD,mCAA6C;AAC7C,0DAA8D;AAC9D,sEAAqE;AAErE,2DAA4D;AAC5D,oEAAwE;AACxE,mCAA6B;AAW7B;;;;;;;;;;GAUG;AACH,SAAgB,iBAAiB,CAAC,gBAA4B,EAA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AY,CAAC,CAAC;IAE1D,0BAA0B;IAC1B,oCAAoC;IACpC,IAAI,IAAA,qBAAU,EAAC,IAAI,CAAC,EACpB,CAAC;QACA,mBAAmB;QACnB,2BAA2B;QAC3B,IAAI,gBAAgB,GAAG,IAAA,uBAAY,EAAC,IAAI,CAAC,CAAC;QAE1C,iBAAiB;QACjB,8CAA8C;QAC9C,IAAI,KAAK,GAAG,IAAA,uBAAY,EAAC,IAAA,cAAO,EAAC,sBAAa,EAAE,qBAAqB,CAAC,CAAC,CAAC;QAExE,WAAW;QACX,2BAA2B;QAC3B,gBAAgB,GAAG,iBAAiB,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAE9D,WAAW;QACX,+BAA+B;QAC/B,gBAAgB,GAAG,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAEtE,cAAc;QACd,mCAAmC;QACnC,IAAA,yCAAoB,EAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC9C,CAAC;AACF,CAAC","sourcesContent":["import { ITSRequiredPick } from 'ts-type/lib/type/record';\nimport { IFillPkgHostedInfoOptions } from '@yarn-tool/pkg-hosted-info';\nimport { resolve } from 'path';\nimport { existsSync, readJSONSync } from 'fs-extra';\nimport { defaultsDeep, merge } from 'lodash';\nimport { __STATIC_ROOT } from '@yarn-tool/static-file/__root';\nimport { writePackageJSONSync } from '@yarn-tool/write-package-json';\nimport { ILernaJson } from '@ts-type/package-dts/lerna-json';\nimport { array_unique_overwrite } from 'array-hyper-unique';\nimport { resolvePackage } from '@yarn-tool/require-resolve/lib/package';\nimport { gte } from 'semver';\n\n/**\n * Lerna 修復選項型別\n * Lerna fix options type\n *\n * 從 IFillPkgHostedInfoOptions 中選取必需的 rootData 屬性\n * Picks the required rootData property from IFillPkgHostedInfoOptions\n */\nexport type IOptionsFixLerna = ITSRequiredPick<IFillPkgHostedInfoOptions, 'rootData'>;\n\n/**\n * 合併 Lerna 設定核心邏輯\n * Core logic for merging Lerna configuration\n *\n * 將模板中的命令設定與現有設定進行深度合併,並處理 publish.ignoreChanges 的清單合併與去重\n * Performs deep merge of command settings from template with existing config, and handles merging and deduplication of publish.ignoreChanges list\n *\n * @param currentLernaJson - 當前的 lerna.json 設定物件 / Current lerna.json configuration object\n * @param tpl - 模板 lerna.json 設定物件 / Template lerna.json configuration object\n * @returns 合併後的 lerna.json 設定物件 / Merged lerna.json configuration object\n */\nexport function _fixLernaJsonCore(currentLernaJson: ILernaJson, tpl: ILernaJson)\n{\n\t// 使用 defaultsDeep 進行命令設定的深度合併,確保現有設定優先,缺失值從模板補充\n\t// Use defaultsDeep for deep merging command settings, ensuring existing config takes precedence while filling missing values from template\n\tcurrentLernaJson.command = defaultsDeep(currentLernaJson.command, tpl.command);\n\n\t// 合併 publish.ignoreChanges 陣列:將模板的忽略規則附加到現有規則之後\n\t// Merge publish.ignoreChanges arrays: append template ignore rules after existing rules\n\tcurrentLernaJson.command.publish['ignoreChanges'] = (currentLernaJson.command.publish['ignoreChanges'] as string[]).concat(tpl.command.publish['ignoreChanges'] as string[]);\n\n\t// 對合併後的 ignoreChanges 進行去重處理,避免重複的忽略規則\n\t// Deduplicate the merged ignoreChanges to avoid duplicate ignore rules\n\tarray_unique_overwrite(currentLernaJson.command.publish['ignoreChanges']);\n\n\treturn currentLernaJson\n}\n\n/**\n * 處理 Lerna 已棄用屬性的核心邏輯\n * Core logic for handling deprecated Lerna properties\n *\n * 檢測 Lerna 版本,若為 7.0.0 以上版本則移除 useWorkspaces 屬性\n * Detects Lerna version and removes useWorkspaces property if version is 7.0.0 or higher\n *\n * Lerna 7.0.0 開始強制使用 workspaces,useWorkspaces 屬性已無意義\n * Since Lerna 7.0.0, workspaces are mandatory and useWorkspaces property is no longer meaningful\n *\n * @param options - 修復選項,包含 rootData 資訊 / Fix options containing rootData information\n * @param currentLernaJson - 當前的 lerna.json 設定物件 / Current lerna.json configuration object\n * @returns 處理後的 lerna.json 設定物件 / Processed lerna.json configuration object\n */\nexport function _fixLernaDeprecatedCore(options: IOptionsFixLerna, currentLernaJson: ILernaJson)\n{\n\ttry\n\t{\n\t\t// 解析本機或全域安裝的 lerna 套件資訊\n\t\t// Resolve locally or globally installed lerna package information\n\t\tlet result = resolvePackage('lerna', {\n\t\t\tincludeGlobal: true,\n\t\t\tincludeCurrentDirectory: true,\n\t\t});\n\n\t\t// 若 Lerna 版本 >= 7.0.0,移除 useWorkspaces 屬性\n\t\t// Remove useWorkspaces property if Lerna version >= 7.0.0\n\t\tif (gte(result.pkg.version, '7.0.0'))\n\t\t{\n\t\t\tdelete currentLernaJson['useWorkspaces']\n\t\t}\n\t}\n\t// 若無法解析 lerna 套件(未安裝),靜默忽略錯誤\n\t// Silently ignore error if lerna package cannot be resolved (not installed)\n\tcatch (e)\n\t{}\n\n\treturn currentLernaJson\n}\n\n/**\n * 修復專案中的 lerna.json 檔案\n * Fix lerna.json file in the project\n *\n * 讀取專案根目錄的 lerna.json,與模板進行合併,並處理已棄用的屬性\n * Reads lerna.json from project root, merges with template, and handles deprecated properties\n *\n * @param options - 修復選項,必須包含 rootData.root(專案根目錄) / Fix options, must contain rootData.root (project root directory)\n */\nexport function _fixLernaJson(options: IOptionsFixLerna)\n{\n\t// 組合 lerna.json 的完整路徑\n\t// Compose the full path to lerna.json\n\tconst file = resolve(options.rootData.root, 'lerna.json');\n\n\t// 只有當 lerna.json 存在時才進行處理\n\t// Only process if lerna.json exists\n\tif (existsSync(file))\n\t{\n\t\t// 讀取現有的 lerna.json\n\t\t// Read existing lerna.json\n\t\tlet currentLernaJson = readJSONSync(file);\n\n\t\t// 讀取靜態模板檔案作為合併基準\n\t\t// Read static template file as merge baseline\n\t\tlet json2 = readJSONSync(resolve(__STATIC_ROOT, 'file/lerna.json.tpl'));\n\n\t\t// 執行核心合併邏輯\n\t\t// Execute core merge logic\n\t\tcurrentLernaJson = _fixLernaJsonCore(currentLernaJson, json2);\n\n\t\t// 處理已棄用的屬性\n\t\t// Handle deprecated properties\n\t\tcurrentLernaJson = _fixLernaDeprecatedCore(options, currentLernaJson);\n\n\t\t// 將合併後的結果寫回檔案\n\t\t// Write merged result back to file\n\t\twritePackageJSONSync(file, currentLernaJson);\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarn-tool/fix-all",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.9",
|
|
4
4
|
"description": "一站式自動修復工具,支援 git 資訊更新、靜態檔案同步、版本修正與 workspace 管理 (All-in-one auto-fix tool for git info update, static file sync, version fix, and workspace management)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fix-all",
|
|
@@ -63,34 +63,36 @@
|
|
|
63
63
|
"tsc:showConfig": "ynpx get-current-tsconfig -p"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@ts-type/package-dts": "^
|
|
67
|
-
"@yarn-tool/find-root": "^2.0.
|
|
68
|
-
"@yarn-tool/fix-ws-versions": "^3.0.
|
|
69
|
-
"@yarn-tool/normalize-deps-value": "^2.0.
|
|
70
|
-
"@yarn-tool/pkg-git-info": "^2.0.
|
|
71
|
-
"@yarn-tool/pkg-hosted-info": "^3.0.
|
|
72
|
-
"@yarn-tool/pkg-readme-tpl": "^1.0.
|
|
73
|
-
"@yarn-tool/
|
|
66
|
+
"@ts-type/package-dts": "^3.0.6",
|
|
67
|
+
"@yarn-tool/find-root": "^2.0.20",
|
|
68
|
+
"@yarn-tool/fix-ws-versions": "^3.0.7",
|
|
69
|
+
"@yarn-tool/normalize-deps-value": "^2.0.5",
|
|
70
|
+
"@yarn-tool/pkg-git-info": "^2.0.5",
|
|
71
|
+
"@yarn-tool/pkg-hosted-info": "^3.0.7",
|
|
72
|
+
"@yarn-tool/pkg-readme-tpl": "^1.0.4",
|
|
73
|
+
"@yarn-tool/require-resolve": "^4.0.4",
|
|
74
|
+
"@yarn-tool/static-file": "^3.0.9",
|
|
74
75
|
"@yarn-tool/write-package-json": "^1.0.14",
|
|
75
|
-
"@yarn-tool/ws-scope": "^3.0.
|
|
76
|
+
"@yarn-tool/ws-scope": "^3.0.7",
|
|
76
77
|
"array-hyper-unique": "^2.1.6",
|
|
77
78
|
"bluebird": "^3.7.2",
|
|
78
|
-
"cache-path": "^4.0.
|
|
79
|
+
"cache-path": "^4.0.7",
|
|
79
80
|
"debug-color2": "^1.3.2",
|
|
80
|
-
"fs-extra": "^11.3.
|
|
81
|
+
"fs-extra": "^11.3.4",
|
|
81
82
|
"fs-remove-extra": "^1.0.8",
|
|
82
83
|
"lazy-aggregate-error": "^1.0.21",
|
|
83
84
|
"lodash": "^4.17.23",
|
|
84
|
-
"npm-package-json-loader": "^3.0.
|
|
85
|
+
"npm-package-json-loader": "^3.0.9",
|
|
85
86
|
"progress-estimator": "^0.3.1",
|
|
86
|
-
"
|
|
87
|
-
"
|
|
87
|
+
"semver": "^7.7.4",
|
|
88
|
+
"sort-package-json3": "^3.0.7",
|
|
89
|
+
"ts-type": "^3.0.8",
|
|
88
90
|
"tslib": ">=2",
|
|
89
91
|
"upath2": "^3.1.23",
|
|
90
|
-
"ws-pkg-list": "^3.0.
|
|
92
|
+
"ws-pkg-list": "^3.0.7"
|
|
91
93
|
},
|
|
92
94
|
"publishConfig": {
|
|
93
95
|
"access": "public"
|
|
94
96
|
},
|
|
95
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "1baa583ecae8fa5869962494f8df3761bf527cdf"
|
|
96
98
|
}
|