@ts-max/deploy 0.0.18 → 0.0.20
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/index.cjs +28 -18
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -26,9 +26,12 @@ const defaultConfig = {
|
|
|
26
26
|
RANCHER_URL: void 0,
|
|
27
27
|
RANCHER_BEARER_TOKEN: void 0,
|
|
28
28
|
RANCHER_NAME_SPACE: "front-center",
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// Git information is resolved lazily in val() so explicit configuration can
|
|
30
|
+
// be used even when the command is run outside a Git worktree.
|
|
31
|
+
GIT_URL: "",
|
|
32
|
+
GIT_BRANCH: "",
|
|
31
33
|
NODE_VERSION: "18",
|
|
34
|
+
NOTICE_ENABLED: false,
|
|
32
35
|
NOTICE_USERS: void 0,
|
|
33
36
|
MESSAGE_URL: void 0,
|
|
34
37
|
MESSAGE_TOKEN: void 0
|
|
@@ -46,11 +49,13 @@ function getConfig() {
|
|
|
46
49
|
return fs.existsSync(configPath) ? require(configPath) : {};
|
|
47
50
|
}
|
|
48
51
|
function val(key) {
|
|
49
|
-
let _defaultValue = defaultConfig[key];
|
|
50
|
-
if (_defaultValue === void 0 || _defaultValue === "") _defaultValue = account[key];
|
|
51
52
|
const envValue = getProcessEnv(key);
|
|
52
53
|
if (envValue !== void 0) return envValue;
|
|
53
54
|
if (key in customerConfig) return customerConfig[key];
|
|
55
|
+
if (key === "GIT_URL") return getGitUrl() || account[key];
|
|
56
|
+
if (key === "GIT_BRANCH") return getGitBranch$1();
|
|
57
|
+
let _defaultValue = defaultConfig[key];
|
|
58
|
+
if (_defaultValue === void 0 || _defaultValue === "") _defaultValue = account[key];
|
|
54
59
|
return _defaultValue;
|
|
55
60
|
}
|
|
56
61
|
function getProcessEnv(key) {
|
|
@@ -67,16 +72,15 @@ function getAccount() {
|
|
|
67
72
|
return JSON.parse(res.getBody("utf8"));
|
|
68
73
|
}
|
|
69
74
|
function getGitRoot() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
try {
|
|
76
|
+
return child_process.execSync("git rev-parse --show-toplevel", {
|
|
77
|
+
cwd: __cwd,
|
|
78
|
+
encoding: "utf8",
|
|
79
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
80
|
+
}).trim();
|
|
81
|
+
} catch {
|
|
82
|
+
throw new Error("非git仓库,或 非仓库中子文件夹");
|
|
77
83
|
}
|
|
78
|
-
if (rootPath) return rootPath;
|
|
79
|
-
throw new Error("非git仓库,或 非仓库中子文件夹");
|
|
80
84
|
}
|
|
81
85
|
function httpToSSH(url) {
|
|
82
86
|
if (!url) return url;
|
|
@@ -88,11 +92,16 @@ function httpToSSH(url) {
|
|
|
88
92
|
}
|
|
89
93
|
function getGitUrl() {
|
|
90
94
|
const gitRoot = getGitRoot();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
try {
|
|
96
|
+
const url = child_process.execSync("git config --get remote.origin.url", {
|
|
97
|
+
cwd: gitRoot,
|
|
98
|
+
encoding: "utf8",
|
|
99
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
100
|
+
}).trim();
|
|
101
|
+
return httpToSSH(url);
|
|
102
|
+
} catch {
|
|
103
|
+
return "";
|
|
104
|
+
}
|
|
96
105
|
}
|
|
97
106
|
function getGitBranch$1() {
|
|
98
107
|
return child_process.execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
|
|
@@ -276,6 +285,7 @@ async function showLog(buildNumber) {
|
|
|
276
285
|
config.DOMAIN && console.log(`- web访问域名: ${config.DOMAIN}`);
|
|
277
286
|
}
|
|
278
287
|
async function notice(buildNumber) {
|
|
288
|
+
if (!config.NOTICE_ENABLED) return;
|
|
279
289
|
const jenkinsAddress = getJenkinsAddress(`/${buildNumber}/console`);
|
|
280
290
|
const webAddress = await getWebAddress();
|
|
281
291
|
let users = config.NOTICE_USERS || [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-max/deploy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "部署脚本",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"cli"
|
|
46
46
|
],
|
|
47
47
|
"license": "MIT",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "9e20383e4c4e28f8be62e7953abffb07c204af09"
|
|
49
49
|
}
|