@done-coding/cli-publish 0.3.0 → 0.3.3
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/es/handler.mjs +13 -13
- package/es/index.mjs +4 -2
- package/es/injectInfo.json.mjs +6 -2
- package/es/main.mjs +14 -14
- package/package.json +5 -4
- package/types/handler.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/injectInfo.json.d.ts +6 -2
package/es/handler.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { PublishModeEnum as h } from "./utils/types.mjs";
|
|
3
|
-
import { inc as p, prerelease as
|
|
3
|
+
import { inc as p, prerelease as S } from "semver";
|
|
4
4
|
import { join as u } from "node:path";
|
|
5
5
|
import { execSync as o } from "node:child_process";
|
|
6
6
|
import f from "pinyin";
|
|
7
|
-
import { readFileSync as y, existsSync as
|
|
7
|
+
import { readFileSync as y, existsSync as d } from "node:fs";
|
|
8
8
|
import c from "chalk";
|
|
9
|
-
const
|
|
9
|
+
const w = "/.dc/publish.json", $ = "/package.json", b = ({ gitOriginName: r = "origin" }) => {
|
|
10
10
|
try {
|
|
11
11
|
const i = o("git rev-parse HEAD").toString().trim(), s = o('git log -1 --pretty=format:"%an"').toString().trim(), a = o('git log -1 --pretty=format:"%ae"').toString().trim(), t = o('git log -1 --pretty=format:"%s"').toString().trim(), n = o("git config user.name").toString().trim(), e = o("git config user.email").toString().trim(), g = o("git rev-parse --abbrev-ref HEAD").toString().trim();
|
|
12
12
|
let l = "";
|
|
@@ -36,14 +36,14 @@ const S = process.cwd(), $ = "/.dc/publish.json", b = "/package.json", v = ({ gi
|
|
|
36
36
|
} catch (i) {
|
|
37
37
|
throw console.error("Error fetching git information:", i), i;
|
|
38
38
|
}
|
|
39
|
-
},
|
|
40
|
-
const i = y(u(
|
|
39
|
+
}, v = async (r) => {
|
|
40
|
+
const i = y(u(process.cwd(), $), "utf-8"), s = JSON.parse(i);
|
|
41
41
|
let a = s.name, t = "", n;
|
|
42
42
|
const { version: e } = s;
|
|
43
43
|
if (["major", "minor", "patch"].includes(r))
|
|
44
44
|
t = p(e, r), n = "latest";
|
|
45
45
|
else if (["premajor", "preminor", "prepatch"].includes(r)) {
|
|
46
|
-
const g =
|
|
46
|
+
const g = S(e);
|
|
47
47
|
g ? (console.log(
|
|
48
48
|
c.yellow("当前版本已经是预发布版本,将会在当前版本基础上进行发布")
|
|
49
49
|
), g.length === 1 && typeof g[0] == "number" ? t = p(e, "prerelease") : t = e.split("-")[0] + "-0") : t = p(e, r), n = "next";
|
|
@@ -56,10 +56,10 @@ const S = process.cwd(), $ = "/.dc/publish.json", b = "/package.json", v = ({ gi
|
|
|
56
56
|
version: t,
|
|
57
57
|
tag: n
|
|
58
58
|
};
|
|
59
|
-
},
|
|
59
|
+
}, N = () => {
|
|
60
60
|
let r;
|
|
61
|
-
const i = u(
|
|
62
|
-
if (
|
|
61
|
+
const i = u(process.cwd(), w);
|
|
62
|
+
if (d(i)) {
|
|
63
63
|
const s = y(i, "utf-8");
|
|
64
64
|
r = JSON.parse(s);
|
|
65
65
|
} else
|
|
@@ -72,11 +72,11 @@ const S = process.cwd(), $ = "/.dc/publish.json", b = "/package.json", v = ({ gi
|
|
|
72
72
|
gitOriginName: "origin",
|
|
73
73
|
...r || {}
|
|
74
74
|
};
|
|
75
|
-
},
|
|
75
|
+
}, C = async (r) => {
|
|
76
76
|
console.log(r);
|
|
77
|
-
const { mode: i, type: s, push: a } = r, t =
|
|
77
|
+
const { mode: i, type: s, push: a } = r, t = N(), n = b(t);
|
|
78
78
|
console.log("type:", s), console.log("gitInfo:", n);
|
|
79
|
-
const e = await
|
|
79
|
+
const e = await v(s), { version: g } = e;
|
|
80
80
|
console.log("npmInfo:", e), o(`npm version ${g} 1>&2`);
|
|
81
81
|
try {
|
|
82
82
|
if (i === h.NPM) {
|
|
@@ -103,5 +103,5 @@ const S = process.cwd(), $ = "/.dc/publish.json", b = "/package.json", v = ({ gi
|
|
|
103
103
|
a && (o(`git push ${t.gitOriginName} v${e.version} 1>&2`), o(`git push ${t.gitOriginName} ${n.branchName} 1>&2`)), console.log(c.green("发布成功"));
|
|
104
104
|
};
|
|
105
105
|
export {
|
|
106
|
-
|
|
106
|
+
C as handler
|
|
107
107
|
};
|
package/es/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { handler as e } from "./handler.mjs";
|
|
3
|
-
import { command as
|
|
3
|
+
import { command as n } from "./main.mjs";
|
|
4
|
+
import { PublishModeEnum as f } from "./utils/types.mjs";
|
|
4
5
|
export {
|
|
5
|
-
|
|
6
|
+
f as PublishModeEnum,
|
|
7
|
+
n as command,
|
|
6
8
|
e as handler
|
|
7
9
|
};
|
package/es/injectInfo.json.mjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const n = {
|
|
3
|
+
version: "0.3.3",
|
|
3
4
|
name: "@done-coding/cli-publish",
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
description: "项目发布命令行工具",
|
|
6
|
+
cliConfig: {
|
|
7
|
+
namespaceDir: ".done-coding",
|
|
8
|
+
commandName: "publish"
|
|
9
|
+
}
|
|
6
10
|
};
|
|
7
11
|
export {
|
|
8
12
|
n as default
|
package/es/main.mjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import m from "yargs";
|
|
3
3
|
import { hideBin as l } from "yargs/helpers";
|
|
4
4
|
import { PublishModeEnum as s } from "./utils/types.mjs";
|
|
5
|
-
import { handler as
|
|
5
|
+
import { handler as t } from "./handler.mjs";
|
|
6
6
|
import i from "chalk";
|
|
7
|
-
import
|
|
8
|
-
const
|
|
7
|
+
import n from "./injectInfo.json.mjs";
|
|
8
|
+
const d = () => ({
|
|
9
9
|
mode: {
|
|
10
10
|
alias: "m",
|
|
11
11
|
describe: "发布模式",
|
|
@@ -24,21 +24,21 @@ const p = () => ({
|
|
|
24
24
|
type: "boolean",
|
|
25
25
|
default: !0
|
|
26
26
|
}
|
|
27
|
-
}), r =
|
|
27
|
+
}), r = n.cliConfig.commandName, p = (o, e) => {
|
|
28
28
|
console.log(o ? i.red(o) : i.red(e.message)), process.exit(1);
|
|
29
|
-
},
|
|
30
|
-
const c =
|
|
31
|
-
return o.strict().usage(e).help("help").version(
|
|
32
|
-
},
|
|
29
|
+
}, f = n.description, g = `Usage: $0 ${r} [options]`, h = "Usage: $0 [options]", a = (o, e) => {
|
|
30
|
+
const c = d();
|
|
31
|
+
return o.strict().usage(e).help("help").version(n.version).alias("v", "version").alias("h", "help").options(c).fail(p).argv;
|
|
32
|
+
}, u = (o) => a(o, g), M = {
|
|
33
33
|
command: r,
|
|
34
|
-
describe:
|
|
35
|
-
builder:
|
|
36
|
-
handler:
|
|
34
|
+
describe: f,
|
|
35
|
+
builder: u,
|
|
36
|
+
handler: t
|
|
37
37
|
}, P = async () => {
|
|
38
|
-
const o = m(l(process.argv)), e = await a(o,
|
|
39
|
-
return
|
|
38
|
+
const o = m(l(process.argv)), e = await a(o, h);
|
|
39
|
+
return t(e);
|
|
40
40
|
};
|
|
41
41
|
export {
|
|
42
|
-
|
|
42
|
+
M as command,
|
|
43
43
|
P as createCli
|
|
44
44
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-publish",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "项目发布命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -34,13 +34,14 @@
|
|
|
34
34
|
"directory": "packages/publish"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
|
-
"access": "public"
|
|
37
|
+
"access": "public",
|
|
38
|
+
"registry": "https://registry.npmjs.org/"
|
|
38
39
|
},
|
|
39
40
|
"author": "JustSoSu",
|
|
40
41
|
"license": "MIT",
|
|
41
42
|
"sideEffects": false,
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@done-coding/cli-inject": "^0.
|
|
44
|
+
"@done-coding/cli-inject": "^0.3.0",
|
|
44
45
|
"@types/node": "^20.0.0",
|
|
45
46
|
"@types/pinyin": "^2.10.0",
|
|
46
47
|
"@types/prompts": "^2.4.6",
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
"semver": "^7.5.4",
|
|
62
63
|
"yargs": "^17.7.2"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "0e9dcf532b8abf7608d07f738348538fa9a9864d"
|
|
65
66
|
}
|
package/types/handler.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ArgumentsCamelCase } from "yargs";
|
|
2
2
|
import { type Options } from './utils';
|
|
3
3
|
export type ChildCmd = "npm" | "web";
|
|
4
|
-
export declare const handler: (argv: ArgumentsCamelCase<Options>) => Promise<undefined>;
|
|
4
|
+
export declare const handler: (argv: ArgumentsCamelCase<Options> | Options) => Promise<undefined>;
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
+
"version": "0.3.3",
|
|
2
3
|
"name": "@done-coding/cli-publish",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
4
|
+
"description": "项目发布命令行工具",
|
|
5
|
+
"cliConfig": {
|
|
6
|
+
"namespaceDir": ".done-coding",
|
|
7
|
+
"commandName": "publish"
|
|
8
|
+
}
|
|
5
9
|
};
|
|
6
10
|
|
|
7
11
|
export default _default;
|