@pubinfo/cli 2.0.0-beta.9 → 2.0.0-rc.2
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/bin/pubinfo.mjs +1 -1
- package/dist/build-IhQTnwHT.js +45 -0
- package/dist/commit-BT18KgTK.js +77 -0
- package/dist/dev-CxmFmMRs.js +50 -0
- package/dist/{chunks/generate.mjs → generate-B8E8h4SV.js} +30 -20
- package/dist/generate-De0efY0o.js +3 -0
- package/dist/icon-DEFBRPY4.js +6345 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +77 -0
- package/dist/preview-IG8wXay6.js +43 -0
- package/package.json +10 -10
- package/dist/chunks/build.mjs +0 -47
- package/dist/chunks/dev.mjs +0 -54
- package/dist/chunks/preview.mjs +0 -46
- package/dist/index.d.mts +0 -7
- package/dist/index.mjs +0 -41
package/bin/pubinfo.mjs
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { generate_default } from "./generate-B8E8h4SV.js";
|
|
2
|
+
import { defineCommand, runMain } from "citty";
|
|
3
|
+
import { build, mergeConfig } from "@pubinfo/vite";
|
|
4
|
+
import { loadConfig } from "unconfig";
|
|
5
|
+
|
|
6
|
+
//#region src/commands/build.ts
|
|
7
|
+
const command = defineCommand({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "build",
|
|
10
|
+
description: "Build the application for production"
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
watch: {
|
|
14
|
+
type: "boolean",
|
|
15
|
+
alias: "w"
|
|
16
|
+
},
|
|
17
|
+
mode: {
|
|
18
|
+
type: "string",
|
|
19
|
+
alias: "m"
|
|
20
|
+
},
|
|
21
|
+
config: {
|
|
22
|
+
type: "string",
|
|
23
|
+
alias: "c"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
async run({ args }) {
|
|
27
|
+
await runMain(generate_default);
|
|
28
|
+
const { config } = await loadConfig({
|
|
29
|
+
sources: [{ files: args.config || "pubinfo.config" }],
|
|
30
|
+
merge: false
|
|
31
|
+
});
|
|
32
|
+
const inlineConfig = typeof config.vite === "function" ? config.vite({
|
|
33
|
+
mode: "production",
|
|
34
|
+
command: "build"
|
|
35
|
+
}) : config.vite;
|
|
36
|
+
await build(mergeConfig(inlineConfig ?? {}, {
|
|
37
|
+
mode: args.mode,
|
|
38
|
+
build: { watch: args.watch ? {} : null }
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var build_default = command;
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { build_default as default };
|
|
@@ -0,0 +1,77 @@
|
|
|
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 };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { generate_default } from "./generate-B8E8h4SV.js";
|
|
2
|
+
import { defineCommand, runMain } from "citty";
|
|
3
|
+
import { createServer, mergeConfig } from "@pubinfo/vite";
|
|
4
|
+
import { loadConfig } from "unconfig";
|
|
5
|
+
|
|
6
|
+
//#region src/commands/dev.ts
|
|
7
|
+
const command = defineCommand({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "dev",
|
|
10
|
+
description: "Run Pubinfo development server"
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
host: { type: "string" },
|
|
14
|
+
port: { type: "string" },
|
|
15
|
+
mode: {
|
|
16
|
+
type: "string",
|
|
17
|
+
alias: "m"
|
|
18
|
+
},
|
|
19
|
+
config: {
|
|
20
|
+
type: "string",
|
|
21
|
+
alias: "c"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
async run({ args }) {
|
|
25
|
+
await runMain(generate_default);
|
|
26
|
+
const { config } = await loadConfig({
|
|
27
|
+
sources: [{ files: args.config || "pubinfo.config" }],
|
|
28
|
+
merge: false
|
|
29
|
+
});
|
|
30
|
+
const inlineConfig = typeof config.vite === "function" ? config.vite({
|
|
31
|
+
mode: "development",
|
|
32
|
+
command: "serve"
|
|
33
|
+
}) : config.vite;
|
|
34
|
+
const server = await createServer(mergeConfig(inlineConfig ?? {}, {
|
|
35
|
+
server: {
|
|
36
|
+
host: args.host,
|
|
37
|
+
port: args.port ? Number(args.port) : void 0
|
|
38
|
+
},
|
|
39
|
+
mode: args.mode,
|
|
40
|
+
configFile: false
|
|
41
|
+
}));
|
|
42
|
+
await server.listen();
|
|
43
|
+
server.printUrls();
|
|
44
|
+
server.bindCLIShortcuts({ print: true });
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
var dev_default = command;
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { dev_default as default };
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defineCommand } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { join } from
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { defineCommand } from "citty";
|
|
3
|
+
import { mkdir, rm } from "node:fs/promises";
|
|
4
|
+
import { resolve } from "pathe";
|
|
5
|
+
import { writeFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
7
|
|
|
8
|
+
//#region src/utils/tsconfig.ts
|
|
8
9
|
function writeTsconfig(filePath) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const resolveDeps = (name, path$1) => {
|
|
12
|
+
return join(require.resolve(name), path$1).replace(/\\/g, "/");
|
|
13
|
+
};
|
|
14
|
+
writeFileSync(filePath, `/* eslint-disable */
|
|
12
15
|
/* prettier-ignore */
|
|
13
16
|
// Generated by pubinfo
|
|
14
17
|
{
|
|
@@ -71,17 +74,24 @@ function writeTsconfig(filePath) {
|
|
|
71
74
|
}`);
|
|
72
75
|
}
|
|
73
76
|
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/commands/generate.ts
|
|
74
79
|
const command = defineCommand({
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
meta: {
|
|
81
|
+
name: "generate",
|
|
82
|
+
description: "Generate Pubinfo static site"
|
|
83
|
+
},
|
|
84
|
+
async run() {
|
|
85
|
+
const cwd = resolve(".");
|
|
86
|
+
await rm(resolve(cwd, ".pubinfo"), {
|
|
87
|
+
recursive: true,
|
|
88
|
+
force: true
|
|
89
|
+
});
|
|
90
|
+
await mkdir(resolve(cwd, ".pubinfo"), { recursive: true });
|
|
91
|
+
writeTsconfig(resolve(cwd, ".pubinfo/tsconfig.app.json"));
|
|
92
|
+
}
|
|
85
93
|
});
|
|
94
|
+
var generate_default = command;
|
|
86
95
|
|
|
87
|
-
|
|
96
|
+
//#endregion
|
|
97
|
+
export { generate_default };
|