@pubinfo/cli 2.0.0-rc.3 → 2.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-IhQTnwHT.js → build-CE20dL_r.js} +3 -3
- package/dist/commit-Dae8BYp0.js +76 -0
- package/dist/{dev-CxmFmMRs.js → dev-Dyuh6pCj.js} +3 -3
- package/dist/{icon-BPS--AyP.js → icon-DWczAqmo.js} +1 -1
- package/dist/index.js +11 -8
- package/dist/{preview-IG8wXay6.js → preview-W9XnXXss.js} +1 -1
- package/dist/setup-CYXOtkPr.js +3 -0
- package/dist/{generate-B8E8h4SV.js → setup-DivXUi8w.js} +11 -14
- package/dist/upgrade-CIZMqC7-.js +32 -0
- package/package.json +8 -5
- package/dist/commit-BT18KgTK.js +0 -77
- package/dist/generate-De0efY0o.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setup_default } from "./setup-DivXUi8w.js";
|
|
2
2
|
import { defineCommand, runMain } from "citty";
|
|
3
3
|
import { build, mergeConfig } from "@pubinfo/vite";
|
|
4
4
|
import { loadConfig } from "unconfig";
|
|
@@ -7,7 +7,7 @@ import { loadConfig } from "unconfig";
|
|
|
7
7
|
const command = defineCommand({
|
|
8
8
|
meta: {
|
|
9
9
|
name: "build",
|
|
10
|
-
description: "
|
|
10
|
+
description: "构建应用"
|
|
11
11
|
},
|
|
12
12
|
args: {
|
|
13
13
|
watch: {
|
|
@@ -24,7 +24,7 @@ const command = defineCommand({
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
async run({ args }) {
|
|
27
|
-
await runMain(
|
|
27
|
+
await runMain(setup_default);
|
|
28
28
|
const { config } = await loadConfig({
|
|
29
29
|
sources: [{ files: args.config || "pubinfo.config" }],
|
|
30
30
|
merge: false
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
|
|
4
|
+
//#region src/commands/commit.ts
|
|
5
|
+
/**
|
|
6
|
+
* `pubinfo commit` 子命令:
|
|
7
|
+
* 统一封装项目级提交体验,复用 @pubinfo/commitlint 的核心能力。
|
|
8
|
+
* 功能概述:
|
|
9
|
+
* 1. 交互式生成符合规范的提交信息(中文 + 可选 emoji)。
|
|
10
|
+
* 2. 支持 `--edit` 供 commit-msg 钩子调用,读取临时文件并执行 lint。
|
|
11
|
+
* 4. 支持 `--init` 一键初始化(cz 配置 / 模板 / git hooks)。
|
|
12
|
+
* 5. 不直接执行 `git commit`,保持透明,调用者自行决定是否提交。
|
|
13
|
+
*/
|
|
14
|
+
var commit_default = {
|
|
15
|
+
meta: {
|
|
16
|
+
name: "commit",
|
|
17
|
+
description: "交互式规范 Commit Lint 提交"
|
|
18
|
+
},
|
|
19
|
+
args: {
|
|
20
|
+
edit: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "从 commit-msg 钩子传入的临时文件路径 (--edit $1)"
|
|
23
|
+
},
|
|
24
|
+
init: {
|
|
25
|
+
type: "boolean",
|
|
26
|
+
description: "初始化提交环境 (cz 配置 / 模板 / git hooks)"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
run: async ({ args }) => {
|
|
30
|
+
const { createCzConfig, createGitMessage, runCzConfig, runNpx, runSimpleGitHooks, runGitMessage, lintMessage, runPrompt, isInsideGitRepo } = await import("@pubinfo/commitlint");
|
|
31
|
+
if (!isInsideGitRepo()) {
|
|
32
|
+
console.error("[pubinfo commit] 未检测到 Git 仓库。请在已初始化的 Git 项目中运行,或执行 `git init` 后重试。");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (args.init) {
|
|
36
|
+
const pubinfoDir = `${process.cwd()}/.pubinfo`;
|
|
37
|
+
if (!fs.existsSync(pubinfoDir)) fs.mkdirSync(pubinfoDir);
|
|
38
|
+
const gitMessageStatus = createGitMessage();
|
|
39
|
+
const czConfigStatus = createCzConfig(pubinfoDir);
|
|
40
|
+
const gitHookStatus = runGitMessage();
|
|
41
|
+
const simpleGitHooks = runSimpleGitHooks("pubinfo commit");
|
|
42
|
+
const czConfig = runCzConfig(".pubinfo/cz.config.cjs");
|
|
43
|
+
const npxStatus = runNpx();
|
|
44
|
+
console.log("[pubinfo-commit] 初始化结果:");
|
|
45
|
+
console.log(`- cz.config.cjs: ${czConfigStatus ? "已创建" : "已存在"}`);
|
|
46
|
+
console.log(`- .gitmessage: ${gitMessageStatus ? "已创建" : "已存在"}`);
|
|
47
|
+
console.log(`- Git hooks: ${gitHookStatus ? "已写入" : "已存在"}`);
|
|
48
|
+
console.log(`- package.json 配置 cz-git: ${czConfig ? "已写入" : "已存在"}`);
|
|
49
|
+
console.log(`- package.json 配置 simple-git-hooks: ${simpleGitHooks ? "已写入" : "已存在"}`);
|
|
50
|
+
console.log(`- npx simple-git-hooks 安装: ${npxStatus ? "成功" : "失败,请手动安装"}`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (args.edit) {
|
|
54
|
+
try {
|
|
55
|
+
const raw = fs.readFileSync(String(args.edit), "utf8").trim();
|
|
56
|
+
if (!raw) {
|
|
57
|
+
console.error("[pubinfo commit] 空的 commit message");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
await lintMessage(raw);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error("[pubinfo commit] 读取 --edit 文件失败", e);
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const result = await runPrompt();
|
|
67
|
+
if (!result) {
|
|
68
|
+
console.error("[pubinfo-commit] 未找到 cz-git 或交互被中断");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
await lintMessage(result.raw);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { commit_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setup_default } from "./setup-DivXUi8w.js";
|
|
2
2
|
import { defineCommand, runMain } from "citty";
|
|
3
3
|
import { createServer, mergeConfig } from "@pubinfo/vite";
|
|
4
4
|
import { loadConfig } from "unconfig";
|
|
@@ -7,7 +7,7 @@ import { loadConfig } from "unconfig";
|
|
|
7
7
|
const command = defineCommand({
|
|
8
8
|
meta: {
|
|
9
9
|
name: "dev",
|
|
10
|
-
description: "
|
|
10
|
+
description: "启动应用"
|
|
11
11
|
},
|
|
12
12
|
args: {
|
|
13
13
|
host: { type: "string" },
|
|
@@ -22,7 +22,7 @@ const command = defineCommand({
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
async run({ args }) {
|
|
25
|
-
await runMain(
|
|
25
|
+
await runMain(setup_default);
|
|
26
26
|
const { config } = await loadConfig({
|
|
27
27
|
sources: [{ files: args.config || "pubinfo.config" }],
|
|
28
28
|
merge: false
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,13 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
//#region package.json
|
|
5
5
|
var name = "@pubinfo/cli";
|
|
6
6
|
var type = "module";
|
|
7
|
-
var version = "2.0.0-rc.
|
|
7
|
+
var version = "2.0.0-rc.5";
|
|
8
8
|
var description = "CLI for Pubinfo";
|
|
9
9
|
var exports = { ".": "./bin/pubinfo.mjs" };
|
|
10
10
|
var types = "./dist/index.d.ts";
|
|
11
11
|
var bin = { "pubinfo": "./bin/pubinfo.mjs" };
|
|
12
12
|
var files = ["bin", "dist"];
|
|
13
|
+
var engines = { "node": "^20.19.0 || >=22.12.0" };
|
|
13
14
|
var scripts = {
|
|
14
15
|
"dev": "tsdown --watch",
|
|
15
16
|
"build": "tsdown",
|
|
@@ -21,7 +22,7 @@ var dependencies = {
|
|
|
21
22
|
"cheerio": "catalog:node",
|
|
22
23
|
"citty": "catalog:node",
|
|
23
24
|
"globby": "catalog:node",
|
|
24
|
-
"
|
|
25
|
+
"pkg-types": "catalog:node",
|
|
25
26
|
"unconfig": "catalog:node"
|
|
26
27
|
};
|
|
27
28
|
var devDependencies = {
|
|
@@ -37,6 +38,7 @@ var package_default = {
|
|
|
37
38
|
types,
|
|
38
39
|
bin,
|
|
39
40
|
files,
|
|
41
|
+
engines,
|
|
40
42
|
scripts,
|
|
41
43
|
peerDependencies,
|
|
42
44
|
dependencies,
|
|
@@ -47,12 +49,13 @@ var package_default = {
|
|
|
47
49
|
//#region src/commands/index.ts
|
|
48
50
|
const _rDefault = (r) => r.default || r;
|
|
49
51
|
const commands = {
|
|
50
|
-
dev: () => import("./dev-
|
|
51
|
-
build: () => import("./build-
|
|
52
|
-
preview: () => import("./preview-
|
|
53
|
-
|
|
54
|
-
commit: () => import("./commit-
|
|
55
|
-
icon: () => import("./icon-
|
|
52
|
+
dev: () => import("./dev-Dyuh6pCj.js").then(_rDefault),
|
|
53
|
+
build: () => import("./build-CE20dL_r.js").then(_rDefault),
|
|
54
|
+
preview: () => import("./preview-W9XnXXss.js").then(_rDefault),
|
|
55
|
+
setup: () => import("./setup-CYXOtkPr.js").then(_rDefault),
|
|
56
|
+
commit: () => import("./commit-Dae8BYp0.js").then(_rDefault),
|
|
57
|
+
icon: () => import("./icon-DWczAqmo.js").then(_rDefault),
|
|
58
|
+
upgrade: () => import("./upgrade-CIZMqC7-.js").then(_rDefault)
|
|
56
59
|
};
|
|
57
60
|
|
|
58
61
|
//#endregion
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { defineCommand } from "citty";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { join } from "node:path";
|
|
3
|
+
import { existsSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { mkdir } from "node:fs/promises";
|
|
5
|
+
import { join, resolve } from "node:path";
|
|
7
6
|
|
|
8
7
|
//#region src/utils/tsconfig.ts
|
|
9
8
|
function writeTsconfig(filePath) {
|
|
@@ -11,6 +10,7 @@ function writeTsconfig(filePath) {
|
|
|
11
10
|
const resolveDeps = (name, path$1) => {
|
|
12
11
|
return join(require.resolve(name), path$1).replace(/\\/g, "/");
|
|
13
12
|
};
|
|
13
|
+
if (existsSync(filePath)) unlinkSync(filePath);
|
|
14
14
|
writeFileSync(filePath, `/* eslint-disable */
|
|
15
15
|
/* prettier-ignore */
|
|
16
16
|
// Generated by pubinfo
|
|
@@ -75,23 +75,20 @@ function writeTsconfig(filePath) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
//#endregion
|
|
78
|
-
//#region src/commands/
|
|
78
|
+
//#region src/commands/setup.ts
|
|
79
79
|
const command = defineCommand({
|
|
80
80
|
meta: {
|
|
81
|
-
name: "
|
|
82
|
-
description: "
|
|
81
|
+
name: "setup",
|
|
82
|
+
description: "初始化配置"
|
|
83
83
|
},
|
|
84
84
|
async run() {
|
|
85
85
|
const cwd = resolve(".");
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
force: true
|
|
89
|
-
});
|
|
90
|
-
await mkdir(resolve(cwd, ".pubinfo"), { recursive: true });
|
|
86
|
+
const pubinfoDir = resolve(cwd, ".pubinfo");
|
|
87
|
+
if (!existsSync(pubinfoDir)) await mkdir(pubinfoDir, { recursive: true });
|
|
91
88
|
writeTsconfig(resolve(cwd, ".pubinfo/tsconfig.app.json"));
|
|
92
89
|
}
|
|
93
90
|
});
|
|
94
|
-
var
|
|
91
|
+
var setup_default = command;
|
|
95
92
|
|
|
96
93
|
//#endregion
|
|
97
|
-
export {
|
|
94
|
+
export { setup_default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
|
+
import { readPackageJSON } from "pkg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/commands/upgrade.ts
|
|
6
|
+
const command = defineCommand({
|
|
7
|
+
meta: {
|
|
8
|
+
name: "upgrade",
|
|
9
|
+
description: "升级依赖版本"
|
|
10
|
+
},
|
|
11
|
+
async run() {
|
|
12
|
+
const pkg = await readPackageJSON();
|
|
13
|
+
const deps = {
|
|
14
|
+
...pkg.dependencies,
|
|
15
|
+
...pkg.devDependencies,
|
|
16
|
+
...pkg.peerDependencies
|
|
17
|
+
};
|
|
18
|
+
const pubinfoDeps = Object.keys(deps).filter((name) => name === "pubinfo" || name.startsWith("@pubinfo/module-"));
|
|
19
|
+
if (!pubinfoDeps.length) {
|
|
20
|
+
console.log("No pubinfo-related dependencies found.");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log(`Upgrading: ${pubinfoDeps.join(", ")}`);
|
|
24
|
+
const cmd = `pnpm up ${pubinfoDeps.join(" ")} --latest`;
|
|
25
|
+
console.log(`Running: ${cmd}`);
|
|
26
|
+
execSync(cmd, { stdio: "inherit" });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var upgrade_default = command;
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { upgrade_default as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubinfo/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.5",
|
|
5
5
|
"description": "CLI for Pubinfo",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./bin/pubinfo.mjs"
|
|
@@ -14,20 +14,23 @@
|
|
|
14
14
|
"bin",
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
19
|
+
},
|
|
17
20
|
"peerDependencies": {
|
|
18
|
-
"@pubinfo/vite": "2.0.0-rc.
|
|
21
|
+
"@pubinfo/vite": "2.0.0-rc.5"
|
|
19
22
|
},
|
|
20
23
|
"dependencies": {
|
|
21
24
|
"cheerio": "^1.1.2",
|
|
22
25
|
"citty": "^0.1.6",
|
|
23
26
|
"globby": "^14.1.0",
|
|
24
|
-
"
|
|
27
|
+
"pkg-types": "^2.3.0",
|
|
25
28
|
"unconfig": "^7.3.2",
|
|
26
|
-
"@pubinfo/commitlint": "2.0.0-rc.
|
|
29
|
+
"@pubinfo/commitlint": "2.0.0-rc.5"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
32
|
"@types/node": "^24.0.10",
|
|
30
|
-
"@pubinfo/vite": "2.0.0-rc.
|
|
33
|
+
"@pubinfo/vite": "2.0.0-rc.5"
|
|
31
34
|
},
|
|
32
35
|
"scripts": {
|
|
33
36
|
"dev": "tsdown --watch",
|
package/dist/commit-BT18KgTK.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
|
|
3
|
-
//#region src/commands/commit.ts
|
|
4
|
-
/**
|
|
5
|
-
* `pubinfo commit` 子命令:
|
|
6
|
-
* 统一封装项目级提交体验,复用 @pubinfo/commitlint 的核心能力。
|
|
7
|
-
* 功能概述:
|
|
8
|
-
* 1. 交互式生成符合规范的提交信息(中文 + 可选 emoji)。
|
|
9
|
-
* 2. 支持 `--edit` 供 commit-msg 钩子调用,读取临时文件并执行 lint。
|
|
10
|
-
* 3. 支持 `--message/-m` 直接传入字符串校验。
|
|
11
|
-
* 4. 支持 `--init` 一键初始化(cz 配置 / 模板 / git hooks)。
|
|
12
|
-
* 5. 不直接执行 `git commit`,保持透明,调用者自行决定是否提交。
|
|
13
|
-
*/
|
|
14
|
-
var commit_default = {
|
|
15
|
-
meta: {
|
|
16
|
-
name: "commit",
|
|
17
|
-
description: "交互式规范 Commit Lint 提交"
|
|
18
|
-
},
|
|
19
|
-
args: {
|
|
20
|
-
message: {
|
|
21
|
-
type: "string",
|
|
22
|
-
alias: "m",
|
|
23
|
-
description: "直接提交 message (跳过交互)"
|
|
24
|
-
},
|
|
25
|
-
edit: {
|
|
26
|
-
type: "string",
|
|
27
|
-
description: "从 commit-msg 钩子传入的临时文件路径 (--edit $1)"
|
|
28
|
-
},
|
|
29
|
-
init: {
|
|
30
|
-
type: "boolean",
|
|
31
|
-
description: "初始化提交环境 (cz 配置 / 模板 / git hooks)"
|
|
32
|
-
},
|
|
33
|
-
emoji: {
|
|
34
|
-
type: "boolean",
|
|
35
|
-
description: "交互模式使用 emoji 类型"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
run: async ({ args }) => {
|
|
39
|
-
const { runPrompt, loadCommitConfig, lintMessage, createCzConfigFile, initCommitEnvironment } = await import("@pubinfo/commitlint");
|
|
40
|
-
if (args.init) {
|
|
41
|
-
const r = initCommitEnvironment();
|
|
42
|
-
console.log("[pubinfo commit:init]", r);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (args.edit) {
|
|
46
|
-
try {
|
|
47
|
-
const raw = fs.readFileSync(String(args.edit), "utf8").trim();
|
|
48
|
-
if (!raw) {
|
|
49
|
-
console.error("[pubinfo commit] 空的 commit message");
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
await lintMessage(raw);
|
|
53
|
-
} catch (e) {
|
|
54
|
-
console.error("[pubinfo commit] 读取 --edit 文件失败", e);
|
|
55
|
-
}
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
createCzConfigFile();
|
|
59
|
-
const cfg = loadCommitConfig();
|
|
60
|
-
if (args.message) {
|
|
61
|
-
await lintMessage(String(args.message));
|
|
62
|
-
console.log("\n✔ 已通过 lint,可执行: git commit -m %s");
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const result = await runPrompt(cfg, { emoji: !!args.emoji });
|
|
66
|
-
if (!result) {
|
|
67
|
-
console.error("[pubinfo commit] 未能获取提交信息 (可能已取消)");
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
await lintMessage(result.raw);
|
|
71
|
-
console.log("\nCommit message:");
|
|
72
|
-
console.log(result.raw);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
|
-
export { commit_default as default };
|