@wjwjq/release-helper 0.1.5 → 0.1.7
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/.release/release.conf.yaml +2 -0
- package/dist/cli.js +1 -1
- package/dist/deploy/script/common.sh +36 -29
- package/dist/deploy/script/prompt.sh +6 -0
- package/dist/pack.js +22 -21
- package/dist/prepare.js +20 -10
- package/dist/publish.js +7 -9
- package/dist/release.js +4 -5
- package/dist/start_prepare.js +3 -3
- package/package.json +1 -1
- package/pnpm-lock.yaml +0 -2443
- package/src/.release/README.md +0 -73
- package/src/.release/doc//351/203/250/347/275/262/346/211/213/345/206/214.md +0 -418
- package/src/.release/nginx/ca/ca.crt +0 -32
- package/src/.release/nginx/ca/ca.key +0 -54
- package/src/.release/nginx/ca/client.crt +0 -100
- package/src/.release/nginx/ca/client.csr +0 -16
- package/src/.release/nginx/ca/client.p12 +0 -0
- package/src/.release/nginx/ca/client.pem +0 -30
- package/src/.release/nginx/ca/server.crt +0 -101
- package/src/.release/nginx/ca/server.csr +0 -17
- package/src/.release/nginx/ca/server.key +0 -27
- package/src/.release/nginx/ca/server.pem +0 -30
- package/src/.release/nginx/nginx.conf +0 -179
- package/src/.release/release.conf.yaml +0 -15
- package/src/cli.ts +0 -99
- package/src/deploy/pkg/nginx/nginx.logrotate.tpl +0 -14
- package/src/deploy/pkg/nginx/nginx.service.tpl +0 -32
- package/src/deploy/pkg/nginx_binary/compile.sh +0 -39
- package/src/deploy/pkg/nginx_binary/nginx-arm-ssl1.1.1.tar.gz +0 -0
- package/src/deploy/pkg/nginx_binary/nginx-x86_64-ssl1.0.2.tar.gz +0 -0
- package/src/deploy/pkg/nginx_binary/nginx-x86_64-ssl1.1.1.tar.gz +0 -0
- package/src/deploy/pkg/nginx_binary/nginx-x86_64-ssl3.0.7.tar.gz +0 -0
- package/src/deploy/script/common.sh +0 -196
- package/src/deploy/script/install.sh +0 -7
- package/src/deploy/script/nginx.sh +0 -265
- package/src/deploy/script/prompt.sh +0 -110
- package/src/deploy/script/readme.md +0 -10
- package/src/deploy/script/upgrade.sh +0 -7
- package/src/logger.ts +0 -18
- package/src/pack.ts +0 -152
- package/src/prepare.ts +0 -120
- package/src/publish.ts +0 -308
- package/src/release.ts +0 -292
- package/src/start_prepare.ts +0 -13
package/dist/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ cli.command("init", "generate release configuration").action(async (options) =>
|
|
|
16
16
|
try {
|
|
17
17
|
logger.info("start to generate .release configuration ");
|
|
18
18
|
const { prepare } = await import('./prepare.js');
|
|
19
|
-
await prepare();
|
|
19
|
+
await prepare({ callBy: "init" });
|
|
20
20
|
logger.info("done");
|
|
21
21
|
} catch (e) {
|
|
22
22
|
console.error(`release-helper error: `, e);
|
|
@@ -133,34 +133,37 @@ install_assets() {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
start() {
|
|
136
|
-
#
|
|
137
|
-
if
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
# 仅静态文件
|
|
137
|
+
if [[ "${mode}" != 3 ]]; then
|
|
138
|
+
# 未安装
|
|
139
|
+
if ((has_nginx_installed == 0)); then
|
|
140
|
+
install_nginx_binary
|
|
141
|
+
|
|
142
|
+
if [[ $? != 0 ]]; then
|
|
143
|
+
echo "$(tput setaf 1)"failed to install!"$(tput sgr0)"
|
|
144
|
+
exit 1
|
|
145
|
+
fi
|
|
143
146
|
fi
|
|
144
|
-
fi
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
148
|
+
# 已安装 询问是否更新nginx
|
|
149
|
+
if ((has_nginx_installed == 1)); then
|
|
150
|
+
while true; do
|
|
151
|
+
read -r -p "Nginx has been installed, re-install it?[Y/N]" yn
|
|
152
|
+
case $yn in
|
|
153
|
+
[Yy]*)
|
|
154
|
+
install_nginx_binary
|
|
155
|
+
|
|
156
|
+
if [[ $? != 0 ]]; then
|
|
157
|
+
echo "$(tput setaf 1)"failed to install!"$(tput sgr0)"
|
|
158
|
+
exit 1
|
|
159
|
+
fi
|
|
160
|
+
break
|
|
161
|
+
;;
|
|
162
|
+
[Nn]*) break ;;
|
|
163
|
+
*) echo "Please answer yes or no." ;;
|
|
164
|
+
esac
|
|
165
|
+
done
|
|
166
|
+
fi
|
|
164
167
|
fi
|
|
165
168
|
|
|
166
169
|
# 创建用户
|
|
@@ -179,9 +182,13 @@ start() {
|
|
|
179
182
|
|
|
180
183
|
mkdir -p "$install_path"
|
|
181
184
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
# 仅静态文件
|
|
186
|
+
if [[ "${mode}" != 3 ]]; then
|
|
187
|
+
copy_nginx_conf_and_write_verison
|
|
188
|
+
add_nginx_service
|
|
189
|
+
add_log_rotate
|
|
190
|
+
fi
|
|
191
|
+
|
|
185
192
|
install_assets
|
|
186
193
|
|
|
187
194
|
# 修改所属用户
|
|
@@ -12,6 +12,8 @@ if [[ "${mode}" == "standalone" ]]; then
|
|
|
12
12
|
mode=1
|
|
13
13
|
elif [[ "${mode}" == "cluster" ]]; then
|
|
14
14
|
mode=2
|
|
15
|
+
elif [[ "${mode}" == "static" ]]; then
|
|
16
|
+
mode=3
|
|
15
17
|
else
|
|
16
18
|
mode=''
|
|
17
19
|
fi
|
|
@@ -28,6 +30,10 @@ while [ $# -gt 0 ]; do
|
|
|
28
30
|
mode=2
|
|
29
31
|
shift
|
|
30
32
|
;;
|
|
33
|
+
-SS | -static)
|
|
34
|
+
mode=3
|
|
35
|
+
shift
|
|
36
|
+
;;
|
|
31
37
|
-h | --help)
|
|
32
38
|
echo "supported parameters: "
|
|
33
39
|
echo "-S, -standalone install for supervisord startup mode, conflict with -C"
|
package/dist/pack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
3
|
import * as inquirer from '@inquirer/prompts';
|
|
4
4
|
import pc from 'picocolors';
|
|
5
5
|
import * as tar from 'tar';
|
|
@@ -23,7 +23,7 @@ async function pack(version) {
|
|
|
23
23
|
logger.error("\u7248\u672C\u53F7\u4E0D\u80FD\u4E3A\u7A7A\uFF01");
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const packageJson = JSON.parse(fs.readFileSync(
|
|
26
|
+
const packageJson = JSON.parse(fs.readFileSync(resolve(__work_dir, "package.json"), { "encoding": "utf-8" }));
|
|
27
27
|
const projectName = packageJson.name;
|
|
28
28
|
if (!projectName) {
|
|
29
29
|
logger.error("\u672A\u5728package.json\u627E\u5230name\u5B9A\u4E49\uFF01");
|
|
@@ -31,19 +31,20 @@ async function pack(version) {
|
|
|
31
31
|
}
|
|
32
32
|
const zipFileName = `${projectName}_${version}.tar.gz`;
|
|
33
33
|
logger.tip(`start to pack`);
|
|
34
|
-
const projectDir =
|
|
35
|
-
const assetsDir =
|
|
36
|
-
const nginxDir =
|
|
37
|
-
fs.cpSync(
|
|
38
|
-
fs.cpSync(
|
|
39
|
-
fs.writeFileSync(
|
|
40
|
-
fs.writeFileSync(
|
|
41
|
-
fs.writeFileSync(
|
|
34
|
+
const projectDir = resolve(__releaseDir, projectName);
|
|
35
|
+
const assetsDir = resolve(projectDir, "pkg/assets");
|
|
36
|
+
const nginxDir = resolve(projectDir, "pkg/nginx");
|
|
37
|
+
fs.cpSync(resolve(__dirname, "deploy"), projectDir, { recursive: true });
|
|
38
|
+
fs.cpSync(resolve(__work_dir, releaseConf.assetsDir), assetsDir, { recursive: true });
|
|
39
|
+
fs.writeFileSync(resolve(projectDir, "pkg", "version"), version, { encoding: "utf-8" });
|
|
40
|
+
fs.writeFileSync(resolve(assetsDir, "version"), version, { encoding: "utf-8" });
|
|
41
|
+
fs.writeFileSync(resolve(nginxDir, "version"), version, { encoding: "utf-8" });
|
|
42
42
|
logger.info(pc.green(`version: ${version} added`));
|
|
43
|
-
const
|
|
43
|
+
const installDir = releaseConf.installDir.endsWith("/") ? releaseConf.installDir.replace(/\/$/, "") : releaseConf.installDir;
|
|
44
|
+
const assetInstallPath = `${installDir}/${projectName}/`;
|
|
44
45
|
logger.info(pc.green(`start to replace variants in common.sh`));
|
|
45
46
|
replaceFileContent({
|
|
46
|
-
filePath:
|
|
47
|
+
filePath: resolve(projectDir, "script", "common.sh"),
|
|
47
48
|
replaced: [
|
|
48
49
|
["__APP_NAME__", `"${projectName}"`],
|
|
49
50
|
["__INSTALL_PATH__", assetInstallPath],
|
|
@@ -52,25 +53,25 @@ async function pack(version) {
|
|
|
52
53
|
]
|
|
53
54
|
});
|
|
54
55
|
replaceFileContent({
|
|
55
|
-
filePath:
|
|
56
|
+
filePath: resolve(projectDir, "script", "prompt.sh"),
|
|
56
57
|
replaced: [
|
|
57
58
|
["__INSTALL_MODE__", releaseConf.installMode]
|
|
58
59
|
]
|
|
59
60
|
});
|
|
60
61
|
logger.info(pc.green(`start to replace version: ${version} in index.html`));
|
|
61
62
|
replaceFileContent({
|
|
62
|
-
filePath:
|
|
63
|
+
filePath: resolve(assetsDir, "index.html"),
|
|
63
64
|
replaced: [["__version__", version]]
|
|
64
65
|
});
|
|
65
66
|
logger.info(pc.green(`start to generate nginx.conf`));
|
|
66
|
-
fs.cpSync(
|
|
67
|
+
fs.cpSync(resolve(__releaseDir, "nginx"), nginxDir, { recursive: true, force: true });
|
|
67
68
|
replaceFileContent({
|
|
68
|
-
filePath:
|
|
69
|
+
filePath: resolve(nginxDir, "nginx.conf"),
|
|
69
70
|
replaced: [["__root__", `${assetInstallPath}assets/`]]
|
|
70
|
-
// writeToNewFilePath:
|
|
71
|
+
// writeToNewFilePath: resolve(nginxDir, `${projectName}.conf`)
|
|
71
72
|
});
|
|
72
73
|
logger.info(pc.green(`start to generate ${zipFileName}`));
|
|
73
|
-
const zipFilePath =
|
|
74
|
+
const zipFilePath = resolve(__releaseDir, zipFileName);
|
|
74
75
|
await genTarPkg(__releaseDir, projectName, zipFilePath);
|
|
75
76
|
logger.success(`done to pack ${pc.green(`${zipFileName} at: ${__releaseDir}`)}`);
|
|
76
77
|
if (fs.existsSync(projectDir)) {
|
|
@@ -88,10 +89,10 @@ async function pack(version) {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
function genTarPkg(releaseDir, projectName, zipFileName) {
|
|
91
|
-
return new Promise((
|
|
92
|
+
return new Promise((resolve2, reject) => {
|
|
92
93
|
const zipStream = fs.createWriteStream(zipFileName);
|
|
93
94
|
zipStream.on("close", () => {
|
|
94
|
-
|
|
95
|
+
resolve2(true);
|
|
95
96
|
});
|
|
96
97
|
try {
|
|
97
98
|
tar.create(
|
package/dist/prepare.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fs from 'fs';
|
|
1
|
+
import { resolve, dirname } from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
3
|
import YAML from 'yaml';
|
|
4
4
|
import * as inquirer from '@inquirer/prompts';
|
|
5
5
|
import { execa } from 'execa';
|
|
@@ -7,13 +7,13 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
import { logger } from './logger.js';
|
|
8
8
|
import 'picocolors';
|
|
9
9
|
|
|
10
|
-
const installMode = ["standalone", "cluster", "
|
|
10
|
+
const installMode = ["standalone", "cluster", "static", "all"];
|
|
11
11
|
const __work_dir = process.env.INIT_CWD || process.cwd();
|
|
12
|
-
const __releaseDir =
|
|
12
|
+
const __releaseDir = resolve(__work_dir, ".release");
|
|
13
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
14
|
const __dirname = dirname(__filename);
|
|
15
15
|
const releaseConfFileName = "release.conf.yaml";
|
|
16
|
-
const __releaseConfPath =
|
|
16
|
+
const __releaseConfPath = resolve(__releaseDir, releaseConfFileName);
|
|
17
17
|
function parseConf(file) {
|
|
18
18
|
try {
|
|
19
19
|
const conf = fs.readFileSync(file, "utf-8");
|
|
@@ -22,6 +22,11 @@ function parseConf(file) {
|
|
|
22
22
|
return {};
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
function isValidLinuxPath(path) {
|
|
26
|
+
const absolutePathPattern = /^\//;
|
|
27
|
+
const relativePathPattern = /^(\.\/|\.\.\/)/;
|
|
28
|
+
return absolutePathPattern.test(path) || relativePathPattern.test(path);
|
|
29
|
+
}
|
|
25
30
|
const releaseConf = Object.assign({
|
|
26
31
|
host: "",
|
|
27
32
|
token: "",
|
|
@@ -31,19 +36,20 @@ const releaseConf = Object.assign({
|
|
|
31
36
|
assetsDir: "dist",
|
|
32
37
|
user: "root",
|
|
33
38
|
userGroup: "root",
|
|
34
|
-
installMode: "both"
|
|
39
|
+
installMode: "both",
|
|
40
|
+
installDir: "/opt"
|
|
35
41
|
}, parseConf(__releaseConfPath));
|
|
36
42
|
const $ = execa({ encoding: "utf8" });
|
|
37
|
-
async function prepare() {
|
|
43
|
+
async function prepare({ callBy } = { callBy: "postinstall" }) {
|
|
38
44
|
const copyFiles = () => {
|
|
39
|
-
fs.cpSync(
|
|
45
|
+
fs.cpSync(resolve(__dirname, ".release"), __releaseDir, { recursive: true });
|
|
40
46
|
};
|
|
41
47
|
if (!fs.existsSync(__releaseDir)) {
|
|
42
48
|
fs.mkdirSync(__releaseDir);
|
|
43
49
|
copyFiles();
|
|
44
50
|
logger.tip(`\u8BF7\u6CE8\u610F\u4FEE\u6539.release/${releaseConfFileName} \u914D\u7F6E\u4FE1\u606F`);
|
|
45
51
|
} else {
|
|
46
|
-
if (
|
|
52
|
+
if (callBy === "init") {
|
|
47
53
|
const shouldRegenerate = await inquirer.confirm(
|
|
48
54
|
{
|
|
49
55
|
message: ".release\u914D\u7F6E\u5DF2\u5B58\u5728\uFF0C\u662F\u5426\u91CD\u65B0\u751F\u6210\uFF1F"
|
|
@@ -61,7 +67,7 @@ async function checkEnvInfo() {
|
|
|
61
67
|
logger.error("\u5F53\u524D\u9879\u76EE\u4E0D\u662Fgit\u4ED3\u5E93");
|
|
62
68
|
process.exit(1);
|
|
63
69
|
}
|
|
64
|
-
if (!fs.existsSync(
|
|
70
|
+
if (!fs.existsSync(resolve(__releaseDir, "nginx/nginx.conf"))) {
|
|
65
71
|
logger.error(".release\u76EE\u5F55\u4E0B\u4E0D\u5B58\u5728nginx/nginx.conf \u6587\u4EF6\uFF0C \u8BF7\u4F7F\u7528 release-helper init \u521D\u59CB\u5316\u751F\u6210");
|
|
66
72
|
process.exit(1);
|
|
67
73
|
}
|
|
@@ -78,6 +84,10 @@ async function checkEnvInfo() {
|
|
|
78
84
|
logger.error(`The field: [${field}]'s value should be one of ${installMode.join(" | ")}`);
|
|
79
85
|
process.exit(1);
|
|
80
86
|
}
|
|
87
|
+
if (field === "installDir" && !isValidLinuxPath(value)) {
|
|
88
|
+
logger.error(`The field: [${field}]'s value is not a legal path`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
81
91
|
}
|
|
82
92
|
}
|
|
83
93
|
|
package/dist/publish.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import
|
|
3
|
-
import { URL } from 'url';
|
|
4
|
-
import crypto from 'crypto';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { resolve, join } from 'node:path';
|
|
3
|
+
import { URL } from 'node:url';
|
|
4
|
+
import crypto from 'node:crypto';
|
|
5
5
|
import mime from 'mime';
|
|
6
6
|
import * as inquirer from '@inquirer/prompts';
|
|
7
7
|
import { setTimeout } from 'node:timers/promises';
|
|
@@ -10,7 +10,6 @@ import { $, releaseConf, __releaseDir } from './prepare.js';
|
|
|
10
10
|
import { logger } from './logger.js';
|
|
11
11
|
import 'yaml';
|
|
12
12
|
import 'execa';
|
|
13
|
-
import 'node:url';
|
|
14
13
|
import 'picocolors';
|
|
15
14
|
|
|
16
15
|
async function isGitFlowRepo() {
|
|
@@ -112,7 +111,6 @@ async function getChangeLog(host, newVersion, userSelectedLatestTag, markdownUrl
|
|
|
112
111
|
});
|
|
113
112
|
newChangelog += "\n";
|
|
114
113
|
}
|
|
115
|
-
console.log("\u{1F680} ~ getChangeLog ~features & Bugfixes:", features, Bugfixes);
|
|
116
114
|
newChangelog += `# Artifacts
|
|
117
115
|
`;
|
|
118
116
|
newChangelog += `## tar\u5305
|
|
@@ -180,16 +178,16 @@ async function publish(params) {
|
|
|
180
178
|
throw Error(`The target repo not founded!`);
|
|
181
179
|
}
|
|
182
180
|
const id = proj.id;
|
|
183
|
-
const assetFile =
|
|
181
|
+
const assetFile = resolve(__releaseDir, pkgName);
|
|
184
182
|
const file = fs.readFileSync(assetFile);
|
|
185
183
|
const hash = crypto.createHash("md5");
|
|
186
184
|
hash.update(file);
|
|
187
185
|
const md5 = hash.digest("hex");
|
|
188
186
|
const md5FileName = `${appName}_${version}.md5.txt`;
|
|
189
|
-
const docPath =
|
|
187
|
+
const docPath = join(__releaseDir, "doc");
|
|
190
188
|
const replacedConstants = [["\\$APP_NAME\\$", appName], ["\\$VERSION\\$", version], ["\\$TAR_PKG\\$", pkgName]];
|
|
191
189
|
const docUploadsPromises = fs.readdirSync(docPath).map((docFIleName) => {
|
|
192
|
-
const docFilePath =
|
|
190
|
+
const docFilePath = resolve(docPath, docFIleName);
|
|
193
191
|
const stats = fs.statSync(docFilePath);
|
|
194
192
|
if (stats.isFile()) {
|
|
195
193
|
let content = fs.readFileSync(docFilePath).toString();
|
package/dist/release.js
CHANGED
|
@@ -5,17 +5,16 @@ import { pack } from './pack.js';
|
|
|
5
5
|
import { getGitTags, selectLatestTag, publish, isGitFlowRepo } from './publish.js';
|
|
6
6
|
import { checkEnvInfo, $, releaseConf } from './prepare.js';
|
|
7
7
|
import { logger } from './logger.js';
|
|
8
|
-
import 'fs';
|
|
9
|
-
import 'path';
|
|
8
|
+
import 'node:fs';
|
|
9
|
+
import 'node:path';
|
|
10
10
|
import 'tar';
|
|
11
|
-
import 'url';
|
|
12
|
-
import 'crypto';
|
|
11
|
+
import 'node:url';
|
|
12
|
+
import 'node:crypto';
|
|
13
13
|
import 'mime';
|
|
14
14
|
import 'node:timers/promises';
|
|
15
15
|
import '@gitbeaker/rest';
|
|
16
16
|
import 'yaml';
|
|
17
17
|
import 'execa';
|
|
18
|
-
import 'node:url';
|
|
19
18
|
|
|
20
19
|
async function release(fromPublishCmd = false) {
|
|
21
20
|
try {
|
package/dist/start_prepare.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { logger } from './logger.js';
|
|
2
2
|
import { prepare } from './prepare.js';
|
|
3
3
|
import 'picocolors';
|
|
4
|
-
import 'path';
|
|
5
|
-
import 'fs';
|
|
4
|
+
import 'node:path';
|
|
5
|
+
import 'node:fs';
|
|
6
6
|
import 'yaml';
|
|
7
7
|
import '@inquirer/prompts';
|
|
8
8
|
import 'execa';
|
|
@@ -11,7 +11,7 @@ import 'node:url';
|
|
|
11
11
|
(async function startPrepare() {
|
|
12
12
|
try {
|
|
13
13
|
logger.info("start to generate .release configuration ");
|
|
14
|
-
await prepare();
|
|
14
|
+
await prepare({ callBy: "postinstall" });
|
|
15
15
|
logger.info("done");
|
|
16
16
|
} catch (error) {
|
|
17
17
|
console.error(`release-helper error: `, error);
|