@wjwjq/release-helper 0.1.6 → 0.1.8
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/pack.js +20 -20
- package/dist/prepare.js +10 -9
- package/dist/publish.js +7 -9
- package/dist/release.js +4 -5
- package/dist/start_prepare.js +2 -2
- package/package.json +1 -1
- package/pnpm-lock.yaml +0 -2443
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,20 +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
43
|
const installDir = releaseConf.installDir.endsWith("/") ? releaseConf.installDir.replace(/\/$/, "") : releaseConf.installDir;
|
|
44
44
|
const assetInstallPath = `${installDir}/${projectName}/`;
|
|
45
45
|
logger.info(pc.green(`start to replace variants in common.sh`));
|
|
46
46
|
replaceFileContent({
|
|
47
|
-
filePath:
|
|
47
|
+
filePath: resolve(projectDir, "script", "common.sh"),
|
|
48
48
|
replaced: [
|
|
49
49
|
["__APP_NAME__", `"${projectName}"`],
|
|
50
50
|
["__INSTALL_PATH__", assetInstallPath],
|
|
@@ -53,25 +53,25 @@ async function pack(version) {
|
|
|
53
53
|
]
|
|
54
54
|
});
|
|
55
55
|
replaceFileContent({
|
|
56
|
-
filePath:
|
|
56
|
+
filePath: resolve(projectDir, "script", "prompt.sh"),
|
|
57
57
|
replaced: [
|
|
58
58
|
["__INSTALL_MODE__", releaseConf.installMode]
|
|
59
59
|
]
|
|
60
60
|
});
|
|
61
61
|
logger.info(pc.green(`start to replace version: ${version} in index.html`));
|
|
62
62
|
replaceFileContent({
|
|
63
|
-
filePath:
|
|
63
|
+
filePath: resolve(assetsDir, "index.html"),
|
|
64
64
|
replaced: [["__version__", version]]
|
|
65
65
|
});
|
|
66
66
|
logger.info(pc.green(`start to generate nginx.conf`));
|
|
67
|
-
fs.cpSync(
|
|
67
|
+
fs.cpSync(resolve(__releaseDir, "nginx"), nginxDir, { recursive: true, force: true });
|
|
68
68
|
replaceFileContent({
|
|
69
|
-
filePath:
|
|
69
|
+
filePath: resolve(nginxDir, "nginx.conf"),
|
|
70
70
|
replaced: [["__root__", `${assetInstallPath}assets/`]]
|
|
71
|
-
// writeToNewFilePath:
|
|
71
|
+
// writeToNewFilePath: resolve(nginxDir, `${projectName}.conf`)
|
|
72
72
|
});
|
|
73
73
|
logger.info(pc.green(`start to generate ${zipFileName}`));
|
|
74
|
-
const zipFilePath =
|
|
74
|
+
const zipFilePath = resolve(__releaseDir, zipFileName);
|
|
75
75
|
await genTarPkg(__releaseDir, projectName, zipFilePath);
|
|
76
76
|
logger.success(`done to pack ${pc.green(`${zipFileName} at: ${__releaseDir}`)}`);
|
|
77
77
|
if (fs.existsSync(projectDir)) {
|
|
@@ -89,10 +89,10 @@ async function pack(version) {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
function genTarPkg(releaseDir, projectName, zipFileName) {
|
|
92
|
-
return new Promise((
|
|
92
|
+
return new Promise((resolve2, reject) => {
|
|
93
93
|
const zipStream = fs.createWriteStream(zipFileName);
|
|
94
94
|
zipStream.on("close", () => {
|
|
95
|
-
|
|
95
|
+
resolve2(true);
|
|
96
96
|
});
|
|
97
97
|
try {
|
|
98
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';
|
|
@@ -8,12 +8,13 @@ import { logger } from './logger.js';
|
|
|
8
8
|
import 'picocolors';
|
|
9
9
|
|
|
10
10
|
const installMode = ["standalone", "cluster", "static", "all"];
|
|
11
|
-
|
|
12
|
-
const
|
|
11
|
+
console.log("\u{1F680} ~ process.env.INIT_CWD:", process.env.INIT_CWD);
|
|
12
|
+
const __work_dir = typeof process.env.INIT_CWD === "string" ? process.env.INIT_CWD : process.cwd();
|
|
13
|
+
const __releaseDir = resolve(__work_dir, ".release");
|
|
13
14
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
15
|
const __dirname = dirname(__filename);
|
|
15
16
|
const releaseConfFileName = "release.conf.yaml";
|
|
16
|
-
const __releaseConfPath =
|
|
17
|
+
const __releaseConfPath = resolve(__releaseDir, releaseConfFileName);
|
|
17
18
|
function parseConf(file) {
|
|
18
19
|
try {
|
|
19
20
|
const conf = fs.readFileSync(file, "utf-8");
|
|
@@ -22,10 +23,10 @@ function parseConf(file) {
|
|
|
22
23
|
return {};
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
function isValidLinuxPath(
|
|
26
|
+
function isValidLinuxPath(path) {
|
|
26
27
|
const absolutePathPattern = /^\//;
|
|
27
28
|
const relativePathPattern = /^(\.\/|\.\.\/)/;
|
|
28
|
-
return absolutePathPattern.test(
|
|
29
|
+
return absolutePathPattern.test(path) || relativePathPattern.test(path);
|
|
29
30
|
}
|
|
30
31
|
const releaseConf = Object.assign({
|
|
31
32
|
host: "",
|
|
@@ -42,7 +43,7 @@ const releaseConf = Object.assign({
|
|
|
42
43
|
const $ = execa({ encoding: "utf8" });
|
|
43
44
|
async function prepare({ callBy } = { callBy: "postinstall" }) {
|
|
44
45
|
const copyFiles = () => {
|
|
45
|
-
fs.cpSync(
|
|
46
|
+
fs.cpSync(resolve(__dirname, ".release"), __releaseDir, { recursive: true });
|
|
46
47
|
};
|
|
47
48
|
if (!fs.existsSync(__releaseDir)) {
|
|
48
49
|
fs.mkdirSync(__releaseDir);
|
|
@@ -67,7 +68,7 @@ async function checkEnvInfo() {
|
|
|
67
68
|
logger.error("\u5F53\u524D\u9879\u76EE\u4E0D\u662Fgit\u4ED3\u5E93");
|
|
68
69
|
process.exit(1);
|
|
69
70
|
}
|
|
70
|
-
if (!fs.existsSync(
|
|
71
|
+
if (!fs.existsSync(resolve(__releaseDir, "nginx/nginx.conf"))) {
|
|
71
72
|
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");
|
|
72
73
|
process.exit(1);
|
|
73
74
|
}
|
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