@icebreakers/monorepo 2.1.5 → 2.2.0
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/assets/package.json +5 -5
- package/assets/vitest.config.ts +68 -12
- package/dist/{chunk-X2BQKWYW.js → chunk-Y4HUH2J5.js} +3 -3
- package/dist/cli.cjs +4 -4
- package/dist/cli.js +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +240 -121
- package/dist/index.d.ts +240 -121
- package/dist/index.js +1 -1
- package/package.json +7 -7
- package/templates/apps/client/package.json +4 -4
- package/templates/apps/server/package.json +2 -2
- package/templates/packages/vue-lib-template/package.json +1 -1
package/assets/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"private": true,
|
|
6
|
-
"packageManager": "pnpm@10.
|
|
6
|
+
"packageManager": "pnpm@10.22.0",
|
|
7
7
|
"author": "ice breaker <1324318532@qq.com>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@icebreakers/monorepo": "workspace:*",
|
|
49
49
|
"@icebreakers/stylelint-config": "^1.2.3",
|
|
50
50
|
"@types/fs-extra": "^11.0.4",
|
|
51
|
-
"@types/node": "^24.10.
|
|
51
|
+
"@types/node": "^24.10.1",
|
|
52
52
|
"@types/semver": "^7.7.1",
|
|
53
53
|
"@vitest/coverage-v8": "~4.0.8",
|
|
54
54
|
"ci-info": "^4.3.1",
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
"pkg-types": "^2.3.0",
|
|
66
66
|
"rimraf": "^6.1.0",
|
|
67
67
|
"stylelint": "^16.25.0",
|
|
68
|
-
"tsdown": "^0.16.
|
|
68
|
+
"tsdown": "^0.16.4",
|
|
69
69
|
"tslib": "^2.8.1",
|
|
70
|
-
"tsup": "^8.5.
|
|
70
|
+
"tsup": "^8.5.1",
|
|
71
71
|
"tsx": "^4.20.6",
|
|
72
|
-
"turbo": "^2.6.
|
|
72
|
+
"turbo": "^2.6.1",
|
|
73
73
|
"type-fest": "^5.2.0",
|
|
74
74
|
"typescript": "^5.9.3",
|
|
75
75
|
"unbuild": "^3.6.1",
|
package/assets/vitest.config.ts
CHANGED
|
@@ -2,20 +2,74 @@ import fs from 'node:fs'
|
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
4
|
import { defineConfig } from 'vitest/config'
|
|
5
|
+
import YAML from 'yaml'
|
|
5
6
|
|
|
6
7
|
const ROOT_DIR = path.dirname(fileURLToPath(new URL(import.meta.url)))
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
'apps',
|
|
10
|
-
]
|
|
11
|
-
const CONFIG_CANDIDATES = [
|
|
8
|
+
const WORKSPACE_FILE = path.resolve(ROOT_DIR, 'pnpm-workspace.yaml')
|
|
9
|
+
const CONFIG_FILENAMES = [
|
|
12
10
|
'vitest.config.ts',
|
|
13
11
|
'vitest.config.mts',
|
|
12
|
+
'vitest.config.cts',
|
|
14
13
|
'vitest.config.js',
|
|
15
14
|
'vitest.config.cjs',
|
|
16
|
-
'vitest.
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
'vitest.config.mjs',
|
|
16
|
+
] as const
|
|
17
|
+
|
|
18
|
+
function extractBaseDirFromGlob(pattern: string): string | null {
|
|
19
|
+
if (!pattern) {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const normalized = pattern
|
|
24
|
+
.replace(/\\/g, '/')
|
|
25
|
+
.replace(/^\.\//, '')
|
|
26
|
+
const globIndex = normalized.search(/[*?[{]/)
|
|
27
|
+
const base = globIndex === -1
|
|
28
|
+
? normalized
|
|
29
|
+
: normalized.slice(0, globIndex)
|
|
30
|
+
|
|
31
|
+
const cleaned = base.replace(/\/+$/, '')
|
|
32
|
+
return cleaned || null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function loadProjectRootsFromWorkspace(): string[] {
|
|
36
|
+
if (!fs.existsSync(WORKSPACE_FILE)) {
|
|
37
|
+
return []
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const workspaceContent = fs.readFileSync(WORKSPACE_FILE, 'utf8')
|
|
42
|
+
const workspace = YAML.parse(workspaceContent) ?? {}
|
|
43
|
+
const packages: unknown[] = Array.isArray(workspace.packages) ? workspace.packages : []
|
|
44
|
+
const roots = packages
|
|
45
|
+
.map(entry => typeof entry === 'string' ? entry.trim() : '')
|
|
46
|
+
.filter(entry => entry && !entry.startsWith('!'))
|
|
47
|
+
.map(extractBaseDirFromGlob)
|
|
48
|
+
.filter((entry): entry is string => Boolean(entry))
|
|
49
|
+
|
|
50
|
+
return roots.length ? Array.from(new Set(roots)) : []
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.warn('[vitest] Failed to parse pnpm-workspace.yaml, no project roots will be used.', error)
|
|
54
|
+
return []
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const PROJECT_ROOTS = loadProjectRootsFromWorkspace()
|
|
59
|
+
|
|
60
|
+
if (!PROJECT_ROOTS.length) {
|
|
61
|
+
console.warn('[vitest] No project roots detected. Check pnpm-workspace.yaml to define workspace packages.')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function findConfig(basePath: string): string | null {
|
|
65
|
+
for (const filename of CONFIG_FILENAMES) {
|
|
66
|
+
const candidate = path.join(basePath, filename)
|
|
67
|
+
if (fs.existsSync(candidate)) {
|
|
68
|
+
return candidate
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null
|
|
72
|
+
}
|
|
19
73
|
|
|
20
74
|
function resolveProjects(): string[] {
|
|
21
75
|
const projects: string[] = []
|
|
@@ -26,6 +80,11 @@ function resolveProjects(): string[] {
|
|
|
26
80
|
continue
|
|
27
81
|
}
|
|
28
82
|
|
|
83
|
+
const rootConfig = findConfig(rootPath)
|
|
84
|
+
if (rootConfig) {
|
|
85
|
+
projects.push(path.relative(ROOT_DIR, rootConfig))
|
|
86
|
+
}
|
|
87
|
+
|
|
29
88
|
const entries = fs.readdirSync(rootPath, { withFileTypes: true })
|
|
30
89
|
for (const entry of entries) {
|
|
31
90
|
if (!entry.isDirectory()) {
|
|
@@ -33,10 +92,7 @@ function resolveProjects(): string[] {
|
|
|
33
92
|
}
|
|
34
93
|
|
|
35
94
|
const projectDir = path.join(rootPath, entry.name)
|
|
36
|
-
const configPath =
|
|
37
|
-
.map(candidate => path.join(projectDir, candidate))
|
|
38
|
-
.find(fs.existsSync)
|
|
39
|
-
|
|
95
|
+
const configPath = findConfig(projectDir)
|
|
40
96
|
if (configPath) {
|
|
41
97
|
projects.push(path.relative(ROOT_DIR, configPath))
|
|
42
98
|
}
|
|
@@ -27,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
|
|
30
|
-
// ../../node_modules/.pnpm/tsup@8.5.
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.52.12_@types+node@24.10.1__jiti@2.6.1_postcss@8.5_f48fe4e18fc17d0faecb4c10461dc770/node_modules/tsup/assets/esm_shims.js
|
|
31
31
|
import path from "path";
|
|
32
32
|
import { fileURLToPath } from "url";
|
|
33
33
|
var init_esm_shims = __esm({
|
|
34
|
-
"../../node_modules/.pnpm/tsup@8.5.
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.52.12_@types+node@24.10.1__jiti@2.6.1_postcss@8.5_f48fe4e18fc17d0faecb4c10461dc770/node_modules/tsup/assets/esm_shims.js"() {
|
|
35
35
|
"use strict";
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -589,7 +589,7 @@ async function cleanProjects(cwd) {
|
|
|
589
589
|
|
|
590
590
|
// package.json
|
|
591
591
|
var name = "@icebreakers/monorepo";
|
|
592
|
-
var version = "2.
|
|
592
|
+
var version = "2.2.0";
|
|
593
593
|
|
|
594
594
|
// src/constants.ts
|
|
595
595
|
init_esm_shims();
|
package/dist/cli.cjs
CHANGED
|
@@ -28,12 +28,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
mod
|
|
29
29
|
));
|
|
30
30
|
|
|
31
|
-
// ../../node_modules/.pnpm/tsup@8.5.
|
|
31
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.52.12_@types+node@24.10.1__jiti@2.6.1_postcss@8.5_f48fe4e18fc17d0faecb4c10461dc770/node_modules/tsup/assets/cjs_shims.js
|
|
32
32
|
var getImportMetaUrl, importMetaUrl;
|
|
33
33
|
var init_cjs_shims = __esm({
|
|
34
|
-
"../../node_modules/.pnpm/tsup@8.5.
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.52.12_@types+node@24.10.1__jiti@2.6.1_postcss@8.5_f48fe4e18fc17d0faecb4c10461dc770/node_modules/tsup/assets/cjs_shims.js"() {
|
|
35
35
|
"use strict";
|
|
36
|
-
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src
|
|
36
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
37
37
|
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
38
38
|
}
|
|
39
39
|
});
|
|
@@ -616,7 +616,7 @@ var import_node_url = require("url");
|
|
|
616
616
|
|
|
617
617
|
// package.json
|
|
618
618
|
var name = "@icebreakers/monorepo";
|
|
619
|
-
var version = "2.
|
|
619
|
+
var version = "2.2.0";
|
|
620
620
|
|
|
621
621
|
// src/constants.ts
|
|
622
622
|
var packageJsonPath = (0, import_node_url.fileURLToPath)(new URL("../package.json", importMetaUrl));
|
package/dist/cli.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -33,12 +33,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
// ../../node_modules/.pnpm/tsup@8.5.
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.52.12_@types+node@24.10.1__jiti@2.6.1_postcss@8.5_f48fe4e18fc17d0faecb4c10461dc770/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var getImportMetaUrl, importMetaUrl;
|
|
38
38
|
var init_cjs_shims = __esm({
|
|
39
|
-
"../../node_modules/.pnpm/tsup@8.5.
|
|
39
|
+
"../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.52.12_@types+node@24.10.1__jiti@2.6.1_postcss@8.5_f48fe4e18fc17d0faecb4c10461dc770/node_modules/tsup/assets/cjs_shims.js"() {
|
|
40
40
|
"use strict";
|
|
41
|
-
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src
|
|
41
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
42
42
|
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
43
43
|
}
|
|
44
44
|
});
|
|
@@ -652,7 +652,7 @@ var import_node_url = require("url");
|
|
|
652
652
|
|
|
653
653
|
// package.json
|
|
654
654
|
var name = "@icebreakers/monorepo";
|
|
655
|
-
var version = "2.
|
|
655
|
+
var version = "2.2.0";
|
|
656
656
|
|
|
657
657
|
// src/constants.ts
|
|
658
658
|
var packageJsonPath = (0, import_node_url.fileURLToPath)(new URL("../package.json", importMetaUrl));
|
package/dist/index.d.cts
CHANGED
|
@@ -1,137 +1,285 @@
|
|
|
1
|
-
|
|
1
|
+
export { PackageJson } from 'pkg-types';
|
|
2
2
|
import * as simple_git from 'simple-git';
|
|
3
3
|
import { SimpleGitOptions, ConfigValues } from 'simple-git';
|
|
4
4
|
export { ConfigValues, SimpleGit, SimpleGitOptions } from 'simple-git';
|
|
5
5
|
import * as gitUrlParse from 'git-url-parse';
|
|
6
6
|
import gitUrlParse__default from 'git-url-parse';
|
|
7
|
+
import * as _pnpm_types from '@pnpm/types';
|
|
7
8
|
import * as consola from 'consola';
|
|
8
9
|
import crypto from 'node:crypto';
|
|
9
|
-
export { PackageJson } from 'pkg-types';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* CLI 公用参数,保证各命令对外暴露一致的行为。
|
|
13
13
|
*/
|
|
14
|
-
interface
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
interface CliOpts {
|
|
15
|
+
/**
|
|
16
|
+
* 是否开启交互模式,开启后每一步都会提示用户确认。
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
interactive?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 是否使用 core 版资产,只同步最精简的文件集合。
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
core?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 输出目录(相对 `cwd`),用于放置生成或拷贝出来的文件。
|
|
27
|
+
* @default ''
|
|
28
|
+
*/
|
|
29
|
+
outDir?: string;
|
|
30
|
+
/**
|
|
31
|
+
* 命令执行的工作目录。
|
|
32
|
+
* @default process.cwd()
|
|
33
|
+
*/
|
|
34
|
+
cwd?: string;
|
|
35
|
+
/**
|
|
36
|
+
* 是否跳过已有文件的覆写;开启后保留旧文件不做对比。
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
skipOverwrite?: boolean;
|
|
18
40
|
}
|
|
41
|
+
|
|
19
42
|
/**
|
|
20
|
-
*
|
|
43
|
+
* 内置模板映射表,value 指向仓库中对应模板所在路径。
|
|
21
44
|
*/
|
|
22
|
-
declare
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
45
|
+
declare const templateMap: {
|
|
46
|
+
readonly tsup: "packages/tsup-template";
|
|
47
|
+
readonly tsdown: "packages/tsdown-template";
|
|
48
|
+
readonly unbuild: "packages/unbuild-template";
|
|
49
|
+
readonly 'vue-lib': "packages/vue-lib-template";
|
|
50
|
+
readonly 'hono-server': "apps/server";
|
|
51
|
+
readonly 'vue-hono': "apps/client";
|
|
52
|
+
readonly vitepress: "apps/website";
|
|
53
|
+
readonly cli: "apps/cli";
|
|
54
|
+
};
|
|
55
|
+
type CreateNewProjectType = keyof typeof templateMap;
|
|
56
|
+
interface CreateNewProjectOptions {
|
|
57
|
+
name?: string;
|
|
58
|
+
cwd?: string;
|
|
59
|
+
renameJson?: boolean;
|
|
60
|
+
type?: CreateNewProjectType | string;
|
|
61
|
+
}
|
|
30
62
|
/**
|
|
31
|
-
*
|
|
63
|
+
* 若配置中提供 choices 则优先使用,否则退回默认预设。
|
|
32
64
|
*/
|
|
33
|
-
declare function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[] | ({
|
|
66
|
+
readonly name: "unbuild 打包";
|
|
67
|
+
readonly value: "unbuild";
|
|
68
|
+
} | {
|
|
69
|
+
readonly name: "tsup 打包";
|
|
70
|
+
readonly value: "tsup";
|
|
71
|
+
} | {
|
|
72
|
+
readonly name: "tsdown 打包";
|
|
73
|
+
readonly value: "tsdown";
|
|
74
|
+
} | {
|
|
75
|
+
readonly name: "vue 组件";
|
|
76
|
+
readonly value: "vue-lib";
|
|
77
|
+
} | {
|
|
78
|
+
readonly name: "vue hono 全栈";
|
|
79
|
+
readonly value: "vue-hono";
|
|
80
|
+
} | {
|
|
81
|
+
readonly name: "hono 模板";
|
|
82
|
+
readonly value: "hono-server";
|
|
83
|
+
} | {
|
|
84
|
+
readonly name: "vitepress 文档";
|
|
85
|
+
readonly value: "vitepress";
|
|
86
|
+
} | {
|
|
87
|
+
readonly name: "cli 模板";
|
|
88
|
+
readonly value: "cli";
|
|
89
|
+
})[];
|
|
90
|
+
/**
|
|
91
|
+
* 合并内置与自定义模板映射,允许扩展新的模板类型。
|
|
92
|
+
*/
|
|
93
|
+
declare function getTemplateMap(extra?: Record<string, string>): Record<string, string>;
|
|
94
|
+
/**
|
|
95
|
+
* 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
|
|
96
|
+
*/
|
|
97
|
+
declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
|
|
45
98
|
|
|
46
99
|
/**
|
|
47
|
-
*
|
|
100
|
+
* 工作区工具可接收的筛选选项。
|
|
48
101
|
*/
|
|
49
|
-
interface
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
102
|
+
interface GetWorkspacePackagesOptions {
|
|
103
|
+
/**
|
|
104
|
+
* 是否在结果中排除 workspace 根包。
|
|
105
|
+
* @default true
|
|
106
|
+
*/
|
|
107
|
+
ignoreRootPackage?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* 是否过滤掉标记为 `private` 的包。
|
|
110
|
+
* @default true
|
|
111
|
+
*/
|
|
112
|
+
ignorePrivatePackage?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* 自定义 glob,覆盖 `pnpm-workspace.yaml` 的 `packages` 配置。
|
|
115
|
+
* @default workspace manifest `packages`
|
|
116
|
+
*/
|
|
117
|
+
patterns?: string[];
|
|
55
118
|
}
|
|
56
119
|
|
|
57
120
|
/**
|
|
58
121
|
* `monorepo new` 命令的配置项,允许外部覆写模板目录、模板清单等。
|
|
59
122
|
*/
|
|
60
123
|
interface CreateCommandConfig extends Partial<Omit<CreateNewProjectOptions, 'cwd'>> {
|
|
61
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* 自定义模板根目录。
|
|
126
|
+
* @default 内置模板所在的 `packages/monorepo/templates`
|
|
127
|
+
*/
|
|
62
128
|
templatesDir?: string;
|
|
63
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* 扩展模板映射表,key 为类型,value 为模板相对路径。
|
|
131
|
+
* @default 内置 `templateMap`
|
|
132
|
+
*/
|
|
64
133
|
templateMap?: Record<string, string>;
|
|
65
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* 自定义交互提示的选项列表。
|
|
136
|
+
* @default 内置 `baseChoices`
|
|
137
|
+
*/
|
|
66
138
|
choices?: CreateChoiceOption[];
|
|
67
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* 当未选择模板时使用的默认模板。
|
|
141
|
+
* @default 'unbuild'
|
|
142
|
+
*/
|
|
68
143
|
defaultTemplate?: CreateNewProjectOptions['type'];
|
|
69
144
|
}
|
|
70
145
|
/**
|
|
71
146
|
* CLI 交互式选择框的选项结构。
|
|
72
147
|
*/
|
|
73
148
|
interface CreateChoiceOption {
|
|
149
|
+
/**
|
|
150
|
+
* 唯一值,将回传给命令逻辑使用。
|
|
151
|
+
* @default undefined
|
|
152
|
+
*/
|
|
74
153
|
value: string;
|
|
154
|
+
/**
|
|
155
|
+
* 选项展示名称。
|
|
156
|
+
* @default value
|
|
157
|
+
*/
|
|
75
158
|
name?: string;
|
|
159
|
+
/**
|
|
160
|
+
* 选项描述信息。
|
|
161
|
+
* @default undefined
|
|
162
|
+
*/
|
|
76
163
|
description?: string;
|
|
164
|
+
/**
|
|
165
|
+
* 短名称,用于命令行紧凑展示。
|
|
166
|
+
* @default undefined
|
|
167
|
+
*/
|
|
77
168
|
short?: string;
|
|
169
|
+
/**
|
|
170
|
+
* 设置为 true 或字符串即可禁用该选项并显示原因。
|
|
171
|
+
* @default false
|
|
172
|
+
*/
|
|
78
173
|
disabled?: boolean | string;
|
|
79
174
|
}
|
|
80
175
|
/**
|
|
81
176
|
* `monorepo clean` 命令配置,可控制自动选择、排除包等行为。
|
|
82
177
|
*/
|
|
83
178
|
interface CleanCommandConfig {
|
|
84
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* 是否跳过交互直接清理全部。
|
|
181
|
+
* @default false
|
|
182
|
+
*/
|
|
85
183
|
autoConfirm?: boolean;
|
|
86
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* 不允许被清理的包名列表。
|
|
186
|
+
* @default []
|
|
187
|
+
*/
|
|
87
188
|
ignorePackages?: string[];
|
|
88
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* 是否包含 private 包。
|
|
191
|
+
* @default false
|
|
192
|
+
*/
|
|
89
193
|
includePrivate?: boolean;
|
|
90
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* 强制写回的 @icebreakers/monorepo 版本。
|
|
196
|
+
* @default 当前依赖版本
|
|
197
|
+
*/
|
|
91
198
|
pinnedVersion?: string;
|
|
92
199
|
}
|
|
93
200
|
/**
|
|
94
201
|
* `monorepo sync` 命令配置,可覆盖 workspace 过滤规则或同步命令模板。
|
|
95
202
|
*/
|
|
96
203
|
interface SyncCommandConfig extends Partial<GetWorkspacePackagesOptions> {
|
|
97
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* 并发执行同步命令的最大数量。
|
|
206
|
+
* @default os.cpus().length
|
|
207
|
+
*/
|
|
98
208
|
concurrency?: number;
|
|
99
|
-
/**
|
|
209
|
+
/**
|
|
210
|
+
* 自定义执行的同步命令模板,使用 {name} 占位。
|
|
211
|
+
* @default 'cnpm sync {name}'
|
|
212
|
+
*/
|
|
100
213
|
command?: string;
|
|
101
|
-
/**
|
|
214
|
+
/**
|
|
215
|
+
* 仅同步指定的包(按名称过滤)。
|
|
216
|
+
* @default 同步全部可见包
|
|
217
|
+
*/
|
|
102
218
|
packages?: string[];
|
|
103
219
|
}
|
|
104
220
|
/**
|
|
105
221
|
* `monorepo upgrade` 命令配置,覆盖脚本、目标文件等能力。
|
|
106
222
|
*/
|
|
107
223
|
interface UpgradeCommandConfig extends Partial<CliOpts> {
|
|
108
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* 额外需要写入的目标文件列表。
|
|
226
|
+
* @default []
|
|
227
|
+
*/
|
|
109
228
|
targets?: string[];
|
|
110
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* 是否与默认目标合并,false 表示完全覆盖。
|
|
231
|
+
* @default true
|
|
232
|
+
*/
|
|
111
233
|
mergeTargets?: boolean;
|
|
112
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* 需要写入 package.json 的脚本集合。
|
|
236
|
+
* @default {}
|
|
237
|
+
*/
|
|
113
238
|
scripts?: Record<string, string>;
|
|
114
|
-
/**
|
|
239
|
+
/**
|
|
240
|
+
* 是否跳过生成 changeset markdown。
|
|
241
|
+
* @default true
|
|
242
|
+
*/
|
|
115
243
|
skipChangesetMarkdown?: boolean;
|
|
116
244
|
}
|
|
117
245
|
/**
|
|
118
246
|
* `monorepo init` 命令配置,用于跳过部分初始化步骤。
|
|
119
247
|
*/
|
|
120
248
|
interface InitCommandConfig {
|
|
249
|
+
/**
|
|
250
|
+
* 是否跳过 README 生成。
|
|
251
|
+
* @default false
|
|
252
|
+
*/
|
|
121
253
|
skipReadme?: boolean;
|
|
254
|
+
/**
|
|
255
|
+
* 是否跳过 package.json 写入。
|
|
256
|
+
* @default false
|
|
257
|
+
*/
|
|
122
258
|
skipPkgJson?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* 是否跳过 changeset 的更新。
|
|
261
|
+
* @default false
|
|
262
|
+
*/
|
|
123
263
|
skipChangeset?: boolean;
|
|
124
264
|
}
|
|
125
265
|
/**
|
|
126
266
|
* `monorepo mirror` 命令配置,可增加额外的环境变量镜像。
|
|
127
267
|
*/
|
|
128
268
|
interface MirrorCommandConfig {
|
|
269
|
+
/**
|
|
270
|
+
* 需要注入的环境变量键值对。
|
|
271
|
+
* @default {}
|
|
272
|
+
*/
|
|
129
273
|
env?: Record<string, string>;
|
|
130
274
|
}
|
|
131
275
|
/**
|
|
132
276
|
* 项目级配置入口,按命令划分可插拔的配置块。
|
|
133
277
|
*/
|
|
134
278
|
interface MonorepoConfig {
|
|
279
|
+
/**
|
|
280
|
+
* 按命令分类的可选配置。
|
|
281
|
+
* @default {}
|
|
282
|
+
*/
|
|
135
283
|
commands?: {
|
|
136
284
|
create?: CreateCommandConfig;
|
|
137
285
|
clean?: CleanCommandConfig;
|
|
@@ -141,75 +289,6 @@ interface MonorepoConfig {
|
|
|
141
289
|
mirror?: MirrorCommandConfig;
|
|
142
290
|
};
|
|
143
291
|
}
|
|
144
|
-
/**
|
|
145
|
-
* 提供类型提示的辅助函数,供外部定义配置时使用。
|
|
146
|
-
*/
|
|
147
|
-
declare function defineMonorepoConfig(config: MonorepoConfig): MonorepoConfig;
|
|
148
|
-
/**
|
|
149
|
-
* 加载指定目录的 monorepo 配置,并利用缓存提升性能。
|
|
150
|
-
*/
|
|
151
|
-
declare function loadMonorepoConfig(cwd: string): Promise<MonorepoConfig>;
|
|
152
|
-
/**
|
|
153
|
-
* 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
|
|
154
|
-
*/
|
|
155
|
-
declare function resolveCommandConfig<Name extends keyof NonNullable<MonorepoConfig['commands']>>(name: Name, cwd: string): Promise<NonNullable<MonorepoConfig['commands']>[Name]>;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* 内置模板映射表,value 指向仓库中对应模板所在路径。
|
|
159
|
-
*/
|
|
160
|
-
declare const templateMap: {
|
|
161
|
-
readonly tsup: "packages/tsup-template";
|
|
162
|
-
readonly tsdown: "packages/tsdown-template";
|
|
163
|
-
readonly unbuild: "packages/unbuild-template";
|
|
164
|
-
readonly 'vue-lib': "packages/vue-lib-template";
|
|
165
|
-
readonly 'hono-server': "apps/server";
|
|
166
|
-
readonly 'vue-hono': "apps/client";
|
|
167
|
-
readonly vitepress: "apps/website";
|
|
168
|
-
readonly cli: "apps/cli";
|
|
169
|
-
};
|
|
170
|
-
type CreateNewProjectType = keyof typeof templateMap;
|
|
171
|
-
interface CreateNewProjectOptions {
|
|
172
|
-
name?: string;
|
|
173
|
-
cwd?: string;
|
|
174
|
-
renameJson?: boolean;
|
|
175
|
-
type?: CreateNewProjectType | string;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* 若配置中提供 choices 则优先使用,否则退回默认预设。
|
|
179
|
-
*/
|
|
180
|
-
declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[] | ({
|
|
181
|
-
readonly name: "unbuild 打包";
|
|
182
|
-
readonly value: "unbuild";
|
|
183
|
-
} | {
|
|
184
|
-
readonly name: "tsup 打包";
|
|
185
|
-
readonly value: "tsup";
|
|
186
|
-
} | {
|
|
187
|
-
readonly name: "tsdown 打包";
|
|
188
|
-
readonly value: "tsdown";
|
|
189
|
-
} | {
|
|
190
|
-
readonly name: "vue 组件";
|
|
191
|
-
readonly value: "vue-lib";
|
|
192
|
-
} | {
|
|
193
|
-
readonly name: "vue hono 全栈";
|
|
194
|
-
readonly value: "vue-hono";
|
|
195
|
-
} | {
|
|
196
|
-
readonly name: "hono 模板";
|
|
197
|
-
readonly value: "hono-server";
|
|
198
|
-
} | {
|
|
199
|
-
readonly name: "vitepress 文档";
|
|
200
|
-
readonly value: "vitepress";
|
|
201
|
-
} | {
|
|
202
|
-
readonly name: "cli 模板";
|
|
203
|
-
readonly value: "cli";
|
|
204
|
-
})[];
|
|
205
|
-
/**
|
|
206
|
-
* 合并内置与自定义模板映射,允许扩展新的模板类型。
|
|
207
|
-
*/
|
|
208
|
-
declare function getTemplateMap(extra?: Record<string, string>): Record<string, string>;
|
|
209
|
-
/**
|
|
210
|
-
* 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
|
|
211
|
-
*/
|
|
212
|
-
declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
|
|
213
292
|
|
|
214
293
|
/**
|
|
215
294
|
* 对 simple-git 的轻量封装,集中处理配置缓存与常用查询。
|
|
@@ -251,6 +330,33 @@ declare class GitClient {
|
|
|
251
330
|
getRepoRoot(): Promise<string | undefined>;
|
|
252
331
|
}
|
|
253
332
|
|
|
333
|
+
/**
|
|
334
|
+
* 读取 pnpm workspace 下的所有包,并根据配置过滤与补充字段。
|
|
335
|
+
*/
|
|
336
|
+
declare function getWorkspacePackages(workspaceDir: string, options?: GetWorkspacePackagesOptions): Promise<{
|
|
337
|
+
pkgJsonPath: string;
|
|
338
|
+
rootDir: _pnpm_types.ProjectRootDir;
|
|
339
|
+
rootDirRealPath: _pnpm_types.ProjectRootDirRealPath;
|
|
340
|
+
modulesDir?: string;
|
|
341
|
+
manifest: _pnpm_types.ProjectManifest;
|
|
342
|
+
writeProjectManifest: (manifest: _pnpm_types.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
343
|
+
}[]>;
|
|
344
|
+
/**
|
|
345
|
+
* 将工作区绝对路径、包列表与当前 cwd 打包返回,方便调用方一次获取所有信息。
|
|
346
|
+
*/
|
|
347
|
+
declare function getWorkspaceData(cwd: string, options?: GetWorkspacePackagesOptions): Promise<{
|
|
348
|
+
cwd: string;
|
|
349
|
+
workspaceDir: string;
|
|
350
|
+
packages: {
|
|
351
|
+
pkgJsonPath: string;
|
|
352
|
+
rootDir: _pnpm_types.ProjectRootDir;
|
|
353
|
+
rootDirRealPath: _pnpm_types.ProjectRootDirRealPath;
|
|
354
|
+
modulesDir?: string;
|
|
355
|
+
manifest: _pnpm_types.ProjectManifest;
|
|
356
|
+
writeProjectManifest: (manifest: _pnpm_types.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
357
|
+
}[];
|
|
358
|
+
}>;
|
|
359
|
+
|
|
254
360
|
/**
|
|
255
361
|
* 交互式清理被选中的包目录,同时重写根 package.json 中的 @icebreakers/monorepo 版本。
|
|
256
362
|
*/
|
|
@@ -277,7 +383,7 @@ declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOption
|
|
|
277
383
|
declare function upgradeMonorepo(opts: CliOpts): Promise<void>;
|
|
278
384
|
|
|
279
385
|
var name = "@icebreakers/monorepo";
|
|
280
|
-
var version = "2.
|
|
386
|
+
var version = "2.2.0";
|
|
281
387
|
|
|
282
388
|
/**
|
|
283
389
|
* @icebreakers/monorepo 包的根目录,所有模板与资产目录都以此为基准。
|
|
@@ -296,6 +402,19 @@ declare const assetsDir: string;
|
|
|
296
402
|
*/
|
|
297
403
|
declare const rootDir: string;
|
|
298
404
|
|
|
405
|
+
/**
|
|
406
|
+
* 提供类型提示的辅助函数,供外部定义配置时使用。
|
|
407
|
+
*/
|
|
408
|
+
declare function defineMonorepoConfig(config: MonorepoConfig): MonorepoConfig;
|
|
409
|
+
/**
|
|
410
|
+
* 加载指定目录的 monorepo 配置,并利用缓存提升性能。
|
|
411
|
+
*/
|
|
412
|
+
declare function loadMonorepoConfig(cwd: string): Promise<MonorepoConfig>;
|
|
413
|
+
/**
|
|
414
|
+
* 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
|
|
415
|
+
*/
|
|
416
|
+
declare function resolveCommandConfig<Name extends keyof NonNullable<MonorepoConfig['commands']>>(name: Name, cwd: string): Promise<NonNullable<MonorepoConfig['commands']>[Name]>;
|
|
417
|
+
|
|
299
418
|
/**
|
|
300
419
|
* 构建命令执行上下文,封装常用的工作区、Git、配置等信息。
|
|
301
420
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,137 +1,285 @@
|
|
|
1
|
-
|
|
1
|
+
export { PackageJson } from 'pkg-types';
|
|
2
2
|
import * as simple_git from 'simple-git';
|
|
3
3
|
import { SimpleGitOptions, ConfigValues } from 'simple-git';
|
|
4
4
|
export { ConfigValues, SimpleGit, SimpleGitOptions } from 'simple-git';
|
|
5
5
|
import * as gitUrlParse from 'git-url-parse';
|
|
6
6
|
import gitUrlParse__default from 'git-url-parse';
|
|
7
|
+
import * as _pnpm_types from '@pnpm/types';
|
|
7
8
|
import * as consola from 'consola';
|
|
8
9
|
import crypto from 'node:crypto';
|
|
9
|
-
export { PackageJson } from 'pkg-types';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* CLI 公用参数,保证各命令对外暴露一致的行为。
|
|
13
13
|
*/
|
|
14
|
-
interface
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
interface CliOpts {
|
|
15
|
+
/**
|
|
16
|
+
* 是否开启交互模式,开启后每一步都会提示用户确认。
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
interactive?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 是否使用 core 版资产,只同步最精简的文件集合。
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
core?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 输出目录(相对 `cwd`),用于放置生成或拷贝出来的文件。
|
|
27
|
+
* @default ''
|
|
28
|
+
*/
|
|
29
|
+
outDir?: string;
|
|
30
|
+
/**
|
|
31
|
+
* 命令执行的工作目录。
|
|
32
|
+
* @default process.cwd()
|
|
33
|
+
*/
|
|
34
|
+
cwd?: string;
|
|
35
|
+
/**
|
|
36
|
+
* 是否跳过已有文件的覆写;开启后保留旧文件不做对比。
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
skipOverwrite?: boolean;
|
|
18
40
|
}
|
|
41
|
+
|
|
19
42
|
/**
|
|
20
|
-
*
|
|
43
|
+
* 内置模板映射表,value 指向仓库中对应模板所在路径。
|
|
21
44
|
*/
|
|
22
|
-
declare
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
45
|
+
declare const templateMap: {
|
|
46
|
+
readonly tsup: "packages/tsup-template";
|
|
47
|
+
readonly tsdown: "packages/tsdown-template";
|
|
48
|
+
readonly unbuild: "packages/unbuild-template";
|
|
49
|
+
readonly 'vue-lib': "packages/vue-lib-template";
|
|
50
|
+
readonly 'hono-server': "apps/server";
|
|
51
|
+
readonly 'vue-hono': "apps/client";
|
|
52
|
+
readonly vitepress: "apps/website";
|
|
53
|
+
readonly cli: "apps/cli";
|
|
54
|
+
};
|
|
55
|
+
type CreateNewProjectType = keyof typeof templateMap;
|
|
56
|
+
interface CreateNewProjectOptions {
|
|
57
|
+
name?: string;
|
|
58
|
+
cwd?: string;
|
|
59
|
+
renameJson?: boolean;
|
|
60
|
+
type?: CreateNewProjectType | string;
|
|
61
|
+
}
|
|
30
62
|
/**
|
|
31
|
-
*
|
|
63
|
+
* 若配置中提供 choices 则优先使用,否则退回默认预设。
|
|
32
64
|
*/
|
|
33
|
-
declare function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[] | ({
|
|
66
|
+
readonly name: "unbuild 打包";
|
|
67
|
+
readonly value: "unbuild";
|
|
68
|
+
} | {
|
|
69
|
+
readonly name: "tsup 打包";
|
|
70
|
+
readonly value: "tsup";
|
|
71
|
+
} | {
|
|
72
|
+
readonly name: "tsdown 打包";
|
|
73
|
+
readonly value: "tsdown";
|
|
74
|
+
} | {
|
|
75
|
+
readonly name: "vue 组件";
|
|
76
|
+
readonly value: "vue-lib";
|
|
77
|
+
} | {
|
|
78
|
+
readonly name: "vue hono 全栈";
|
|
79
|
+
readonly value: "vue-hono";
|
|
80
|
+
} | {
|
|
81
|
+
readonly name: "hono 模板";
|
|
82
|
+
readonly value: "hono-server";
|
|
83
|
+
} | {
|
|
84
|
+
readonly name: "vitepress 文档";
|
|
85
|
+
readonly value: "vitepress";
|
|
86
|
+
} | {
|
|
87
|
+
readonly name: "cli 模板";
|
|
88
|
+
readonly value: "cli";
|
|
89
|
+
})[];
|
|
90
|
+
/**
|
|
91
|
+
* 合并内置与自定义模板映射,允许扩展新的模板类型。
|
|
92
|
+
*/
|
|
93
|
+
declare function getTemplateMap(extra?: Record<string, string>): Record<string, string>;
|
|
94
|
+
/**
|
|
95
|
+
* 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
|
|
96
|
+
*/
|
|
97
|
+
declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
|
|
45
98
|
|
|
46
99
|
/**
|
|
47
|
-
*
|
|
100
|
+
* 工作区工具可接收的筛选选项。
|
|
48
101
|
*/
|
|
49
|
-
interface
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
102
|
+
interface GetWorkspacePackagesOptions {
|
|
103
|
+
/**
|
|
104
|
+
* 是否在结果中排除 workspace 根包。
|
|
105
|
+
* @default true
|
|
106
|
+
*/
|
|
107
|
+
ignoreRootPackage?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* 是否过滤掉标记为 `private` 的包。
|
|
110
|
+
* @default true
|
|
111
|
+
*/
|
|
112
|
+
ignorePrivatePackage?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* 自定义 glob,覆盖 `pnpm-workspace.yaml` 的 `packages` 配置。
|
|
115
|
+
* @default workspace manifest `packages`
|
|
116
|
+
*/
|
|
117
|
+
patterns?: string[];
|
|
55
118
|
}
|
|
56
119
|
|
|
57
120
|
/**
|
|
58
121
|
* `monorepo new` 命令的配置项,允许外部覆写模板目录、模板清单等。
|
|
59
122
|
*/
|
|
60
123
|
interface CreateCommandConfig extends Partial<Omit<CreateNewProjectOptions, 'cwd'>> {
|
|
61
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* 自定义模板根目录。
|
|
126
|
+
* @default 内置模板所在的 `packages/monorepo/templates`
|
|
127
|
+
*/
|
|
62
128
|
templatesDir?: string;
|
|
63
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* 扩展模板映射表,key 为类型,value 为模板相对路径。
|
|
131
|
+
* @default 内置 `templateMap`
|
|
132
|
+
*/
|
|
64
133
|
templateMap?: Record<string, string>;
|
|
65
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* 自定义交互提示的选项列表。
|
|
136
|
+
* @default 内置 `baseChoices`
|
|
137
|
+
*/
|
|
66
138
|
choices?: CreateChoiceOption[];
|
|
67
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* 当未选择模板时使用的默认模板。
|
|
141
|
+
* @default 'unbuild'
|
|
142
|
+
*/
|
|
68
143
|
defaultTemplate?: CreateNewProjectOptions['type'];
|
|
69
144
|
}
|
|
70
145
|
/**
|
|
71
146
|
* CLI 交互式选择框的选项结构。
|
|
72
147
|
*/
|
|
73
148
|
interface CreateChoiceOption {
|
|
149
|
+
/**
|
|
150
|
+
* 唯一值,将回传给命令逻辑使用。
|
|
151
|
+
* @default undefined
|
|
152
|
+
*/
|
|
74
153
|
value: string;
|
|
154
|
+
/**
|
|
155
|
+
* 选项展示名称。
|
|
156
|
+
* @default value
|
|
157
|
+
*/
|
|
75
158
|
name?: string;
|
|
159
|
+
/**
|
|
160
|
+
* 选项描述信息。
|
|
161
|
+
* @default undefined
|
|
162
|
+
*/
|
|
76
163
|
description?: string;
|
|
164
|
+
/**
|
|
165
|
+
* 短名称,用于命令行紧凑展示。
|
|
166
|
+
* @default undefined
|
|
167
|
+
*/
|
|
77
168
|
short?: string;
|
|
169
|
+
/**
|
|
170
|
+
* 设置为 true 或字符串即可禁用该选项并显示原因。
|
|
171
|
+
* @default false
|
|
172
|
+
*/
|
|
78
173
|
disabled?: boolean | string;
|
|
79
174
|
}
|
|
80
175
|
/**
|
|
81
176
|
* `monorepo clean` 命令配置,可控制自动选择、排除包等行为。
|
|
82
177
|
*/
|
|
83
178
|
interface CleanCommandConfig {
|
|
84
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* 是否跳过交互直接清理全部。
|
|
181
|
+
* @default false
|
|
182
|
+
*/
|
|
85
183
|
autoConfirm?: boolean;
|
|
86
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* 不允许被清理的包名列表。
|
|
186
|
+
* @default []
|
|
187
|
+
*/
|
|
87
188
|
ignorePackages?: string[];
|
|
88
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* 是否包含 private 包。
|
|
191
|
+
* @default false
|
|
192
|
+
*/
|
|
89
193
|
includePrivate?: boolean;
|
|
90
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* 强制写回的 @icebreakers/monorepo 版本。
|
|
196
|
+
* @default 当前依赖版本
|
|
197
|
+
*/
|
|
91
198
|
pinnedVersion?: string;
|
|
92
199
|
}
|
|
93
200
|
/**
|
|
94
201
|
* `monorepo sync` 命令配置,可覆盖 workspace 过滤规则或同步命令模板。
|
|
95
202
|
*/
|
|
96
203
|
interface SyncCommandConfig extends Partial<GetWorkspacePackagesOptions> {
|
|
97
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* 并发执行同步命令的最大数量。
|
|
206
|
+
* @default os.cpus().length
|
|
207
|
+
*/
|
|
98
208
|
concurrency?: number;
|
|
99
|
-
/**
|
|
209
|
+
/**
|
|
210
|
+
* 自定义执行的同步命令模板,使用 {name} 占位。
|
|
211
|
+
* @default 'cnpm sync {name}'
|
|
212
|
+
*/
|
|
100
213
|
command?: string;
|
|
101
|
-
/**
|
|
214
|
+
/**
|
|
215
|
+
* 仅同步指定的包(按名称过滤)。
|
|
216
|
+
* @default 同步全部可见包
|
|
217
|
+
*/
|
|
102
218
|
packages?: string[];
|
|
103
219
|
}
|
|
104
220
|
/**
|
|
105
221
|
* `monorepo upgrade` 命令配置,覆盖脚本、目标文件等能力。
|
|
106
222
|
*/
|
|
107
223
|
interface UpgradeCommandConfig extends Partial<CliOpts> {
|
|
108
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* 额外需要写入的目标文件列表。
|
|
226
|
+
* @default []
|
|
227
|
+
*/
|
|
109
228
|
targets?: string[];
|
|
110
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* 是否与默认目标合并,false 表示完全覆盖。
|
|
231
|
+
* @default true
|
|
232
|
+
*/
|
|
111
233
|
mergeTargets?: boolean;
|
|
112
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* 需要写入 package.json 的脚本集合。
|
|
236
|
+
* @default {}
|
|
237
|
+
*/
|
|
113
238
|
scripts?: Record<string, string>;
|
|
114
|
-
/**
|
|
239
|
+
/**
|
|
240
|
+
* 是否跳过生成 changeset markdown。
|
|
241
|
+
* @default true
|
|
242
|
+
*/
|
|
115
243
|
skipChangesetMarkdown?: boolean;
|
|
116
244
|
}
|
|
117
245
|
/**
|
|
118
246
|
* `monorepo init` 命令配置,用于跳过部分初始化步骤。
|
|
119
247
|
*/
|
|
120
248
|
interface InitCommandConfig {
|
|
249
|
+
/**
|
|
250
|
+
* 是否跳过 README 生成。
|
|
251
|
+
* @default false
|
|
252
|
+
*/
|
|
121
253
|
skipReadme?: boolean;
|
|
254
|
+
/**
|
|
255
|
+
* 是否跳过 package.json 写入。
|
|
256
|
+
* @default false
|
|
257
|
+
*/
|
|
122
258
|
skipPkgJson?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* 是否跳过 changeset 的更新。
|
|
261
|
+
* @default false
|
|
262
|
+
*/
|
|
123
263
|
skipChangeset?: boolean;
|
|
124
264
|
}
|
|
125
265
|
/**
|
|
126
266
|
* `monorepo mirror` 命令配置,可增加额外的环境变量镜像。
|
|
127
267
|
*/
|
|
128
268
|
interface MirrorCommandConfig {
|
|
269
|
+
/**
|
|
270
|
+
* 需要注入的环境变量键值对。
|
|
271
|
+
* @default {}
|
|
272
|
+
*/
|
|
129
273
|
env?: Record<string, string>;
|
|
130
274
|
}
|
|
131
275
|
/**
|
|
132
276
|
* 项目级配置入口,按命令划分可插拔的配置块。
|
|
133
277
|
*/
|
|
134
278
|
interface MonorepoConfig {
|
|
279
|
+
/**
|
|
280
|
+
* 按命令分类的可选配置。
|
|
281
|
+
* @default {}
|
|
282
|
+
*/
|
|
135
283
|
commands?: {
|
|
136
284
|
create?: CreateCommandConfig;
|
|
137
285
|
clean?: CleanCommandConfig;
|
|
@@ -141,75 +289,6 @@ interface MonorepoConfig {
|
|
|
141
289
|
mirror?: MirrorCommandConfig;
|
|
142
290
|
};
|
|
143
291
|
}
|
|
144
|
-
/**
|
|
145
|
-
* 提供类型提示的辅助函数,供外部定义配置时使用。
|
|
146
|
-
*/
|
|
147
|
-
declare function defineMonorepoConfig(config: MonorepoConfig): MonorepoConfig;
|
|
148
|
-
/**
|
|
149
|
-
* 加载指定目录的 monorepo 配置,并利用缓存提升性能。
|
|
150
|
-
*/
|
|
151
|
-
declare function loadMonorepoConfig(cwd: string): Promise<MonorepoConfig>;
|
|
152
|
-
/**
|
|
153
|
-
* 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
|
|
154
|
-
*/
|
|
155
|
-
declare function resolveCommandConfig<Name extends keyof NonNullable<MonorepoConfig['commands']>>(name: Name, cwd: string): Promise<NonNullable<MonorepoConfig['commands']>[Name]>;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* 内置模板映射表,value 指向仓库中对应模板所在路径。
|
|
159
|
-
*/
|
|
160
|
-
declare const templateMap: {
|
|
161
|
-
readonly tsup: "packages/tsup-template";
|
|
162
|
-
readonly tsdown: "packages/tsdown-template";
|
|
163
|
-
readonly unbuild: "packages/unbuild-template";
|
|
164
|
-
readonly 'vue-lib': "packages/vue-lib-template";
|
|
165
|
-
readonly 'hono-server': "apps/server";
|
|
166
|
-
readonly 'vue-hono': "apps/client";
|
|
167
|
-
readonly vitepress: "apps/website";
|
|
168
|
-
readonly cli: "apps/cli";
|
|
169
|
-
};
|
|
170
|
-
type CreateNewProjectType = keyof typeof templateMap;
|
|
171
|
-
interface CreateNewProjectOptions {
|
|
172
|
-
name?: string;
|
|
173
|
-
cwd?: string;
|
|
174
|
-
renameJson?: boolean;
|
|
175
|
-
type?: CreateNewProjectType | string;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* 若配置中提供 choices 则优先使用,否则退回默认预设。
|
|
179
|
-
*/
|
|
180
|
-
declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[] | ({
|
|
181
|
-
readonly name: "unbuild 打包";
|
|
182
|
-
readonly value: "unbuild";
|
|
183
|
-
} | {
|
|
184
|
-
readonly name: "tsup 打包";
|
|
185
|
-
readonly value: "tsup";
|
|
186
|
-
} | {
|
|
187
|
-
readonly name: "tsdown 打包";
|
|
188
|
-
readonly value: "tsdown";
|
|
189
|
-
} | {
|
|
190
|
-
readonly name: "vue 组件";
|
|
191
|
-
readonly value: "vue-lib";
|
|
192
|
-
} | {
|
|
193
|
-
readonly name: "vue hono 全栈";
|
|
194
|
-
readonly value: "vue-hono";
|
|
195
|
-
} | {
|
|
196
|
-
readonly name: "hono 模板";
|
|
197
|
-
readonly value: "hono-server";
|
|
198
|
-
} | {
|
|
199
|
-
readonly name: "vitepress 文档";
|
|
200
|
-
readonly value: "vitepress";
|
|
201
|
-
} | {
|
|
202
|
-
readonly name: "cli 模板";
|
|
203
|
-
readonly value: "cli";
|
|
204
|
-
})[];
|
|
205
|
-
/**
|
|
206
|
-
* 合并内置与自定义模板映射,允许扩展新的模板类型。
|
|
207
|
-
*/
|
|
208
|
-
declare function getTemplateMap(extra?: Record<string, string>): Record<string, string>;
|
|
209
|
-
/**
|
|
210
|
-
* 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
|
|
211
|
-
*/
|
|
212
|
-
declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
|
|
213
292
|
|
|
214
293
|
/**
|
|
215
294
|
* 对 simple-git 的轻量封装,集中处理配置缓存与常用查询。
|
|
@@ -251,6 +330,33 @@ declare class GitClient {
|
|
|
251
330
|
getRepoRoot(): Promise<string | undefined>;
|
|
252
331
|
}
|
|
253
332
|
|
|
333
|
+
/**
|
|
334
|
+
* 读取 pnpm workspace 下的所有包,并根据配置过滤与补充字段。
|
|
335
|
+
*/
|
|
336
|
+
declare function getWorkspacePackages(workspaceDir: string, options?: GetWorkspacePackagesOptions): Promise<{
|
|
337
|
+
pkgJsonPath: string;
|
|
338
|
+
rootDir: _pnpm_types.ProjectRootDir;
|
|
339
|
+
rootDirRealPath: _pnpm_types.ProjectRootDirRealPath;
|
|
340
|
+
modulesDir?: string;
|
|
341
|
+
manifest: _pnpm_types.ProjectManifest;
|
|
342
|
+
writeProjectManifest: (manifest: _pnpm_types.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
343
|
+
}[]>;
|
|
344
|
+
/**
|
|
345
|
+
* 将工作区绝对路径、包列表与当前 cwd 打包返回,方便调用方一次获取所有信息。
|
|
346
|
+
*/
|
|
347
|
+
declare function getWorkspaceData(cwd: string, options?: GetWorkspacePackagesOptions): Promise<{
|
|
348
|
+
cwd: string;
|
|
349
|
+
workspaceDir: string;
|
|
350
|
+
packages: {
|
|
351
|
+
pkgJsonPath: string;
|
|
352
|
+
rootDir: _pnpm_types.ProjectRootDir;
|
|
353
|
+
rootDirRealPath: _pnpm_types.ProjectRootDirRealPath;
|
|
354
|
+
modulesDir?: string;
|
|
355
|
+
manifest: _pnpm_types.ProjectManifest;
|
|
356
|
+
writeProjectManifest: (manifest: _pnpm_types.ProjectManifest, force?: boolean | undefined) => Promise<void>;
|
|
357
|
+
}[];
|
|
358
|
+
}>;
|
|
359
|
+
|
|
254
360
|
/**
|
|
255
361
|
* 交互式清理被选中的包目录,同时重写根 package.json 中的 @icebreakers/monorepo 版本。
|
|
256
362
|
*/
|
|
@@ -277,7 +383,7 @@ declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOption
|
|
|
277
383
|
declare function upgradeMonorepo(opts: CliOpts): Promise<void>;
|
|
278
384
|
|
|
279
385
|
var name = "@icebreakers/monorepo";
|
|
280
|
-
var version = "2.
|
|
386
|
+
var version = "2.2.0";
|
|
281
387
|
|
|
282
388
|
/**
|
|
283
389
|
* @icebreakers/monorepo 包的根目录,所有模板与资产目录都以此为基准。
|
|
@@ -296,6 +402,19 @@ declare const assetsDir: string;
|
|
|
296
402
|
*/
|
|
297
403
|
declare const rootDir: string;
|
|
298
404
|
|
|
405
|
+
/**
|
|
406
|
+
* 提供类型提示的辅助函数,供外部定义配置时使用。
|
|
407
|
+
*/
|
|
408
|
+
declare function defineMonorepoConfig(config: MonorepoConfig): MonorepoConfig;
|
|
409
|
+
/**
|
|
410
|
+
* 加载指定目录的 monorepo 配置,并利用缓存提升性能。
|
|
411
|
+
*/
|
|
412
|
+
declare function loadMonorepoConfig(cwd: string): Promise<MonorepoConfig>;
|
|
413
|
+
/**
|
|
414
|
+
* 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
|
|
415
|
+
*/
|
|
416
|
+
declare function resolveCommandConfig<Name extends keyof NonNullable<MonorepoConfig['commands']>>(name: Name, cwd: string): Promise<NonNullable<MonorepoConfig['commands']>[Name]>;
|
|
417
|
+
|
|
299
418
|
/**
|
|
300
419
|
* 构建命令执行上下文,封装常用的工作区、Git、配置等信息。
|
|
301
420
|
*/
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/monorepo",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"description": "The icebreaker's monorepo manager",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"templates"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@inquirer/checkbox": "^4.3.
|
|
38
|
-
"@inquirer/input": "^4.3.
|
|
39
|
-
"@inquirer/select": "^4.4.
|
|
37
|
+
"@inquirer/checkbox": "^4.3.2",
|
|
38
|
+
"@inquirer/input": "^4.3.1",
|
|
39
|
+
"@inquirer/select": "^4.4.2",
|
|
40
40
|
"@pnpm/find-workspace-dir": "^1000.1.3",
|
|
41
41
|
"@pnpm/logger": "^1001.0.1",
|
|
42
42
|
"@pnpm/types": "^1001.0.0",
|
|
43
|
-
"@pnpm/worker": "^1000.3.
|
|
44
|
-
"@pnpm/workspace.find-packages": "^1000.0.
|
|
43
|
+
"@pnpm/worker": "^1000.3.2",
|
|
44
|
+
"@pnpm/workspace.find-packages": "^1000.0.45",
|
|
45
45
|
"@pnpm/workspace.read-manifest": "^1000.2.6",
|
|
46
|
-
"c12": "^3.3.
|
|
46
|
+
"c12": "^3.3.2",
|
|
47
47
|
"commander": "^14.0.2",
|
|
48
48
|
"comment-json": "^4.4.1",
|
|
49
49
|
"consola": "^3.4.2",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@faker-js/faker": "^10.1.0",
|
|
18
|
-
"@tanstack/vue-query": "^5.
|
|
18
|
+
"@tanstack/vue-query": "^5.91.0",
|
|
19
19
|
"@tanstack/vue-table": "^8.21.3",
|
|
20
20
|
"@tanstack/vue-virtual": "^3.13.12",
|
|
21
21
|
"@trpc/client": "^11.7.1",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"vue-router": "^4.6.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@cloudflare/vite-plugin": "^1.14.
|
|
28
|
+
"@cloudflare/vite-plugin": "^1.14.2",
|
|
29
29
|
"@hono/node-server": "^1.19.6",
|
|
30
30
|
"@hono/trpc-server": "^0.4.0",
|
|
31
31
|
"@tailwindcss/vite": "^4.1.17",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
34
34
|
"@vitejs/plugin-vue-jsx": "^5.1.1",
|
|
35
35
|
"@vue/tsconfig": "^0.8.1",
|
|
36
|
-
"hono": "^4.10.
|
|
36
|
+
"hono": "^4.10.5",
|
|
37
37
|
"tailwindcss": "^4.1.17",
|
|
38
38
|
"typescript": "~5.9.3",
|
|
39
39
|
"unplugin-vue-router": "^0.16.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"vite-plugin-vue-devtools": "^8.0.3",
|
|
42
42
|
"vite-tsconfig-paths": "^5.1.4",
|
|
43
43
|
"vue-tsc": "3.1.3",
|
|
44
|
-
"wrangler": "^4.
|
|
44
|
+
"wrangler": "^4.48.0",
|
|
45
45
|
"zod": "^4.1.12"
|
|
46
46
|
}
|
|
47
47
|
}
|