|
@@ -9,7 +9,7 @@ import { writeFile, readFile, access, unlink, readdir, stat, constants } from 'n
|
|
|
import { exec } from 'node:child_process';
|
|
|
import fs from 'fs';
|
|
|
import archiver from 'archiver';
|
|
|
-import path from 'node:path';
|
|
|
+import path, { resolve } from 'node:path';
|
|
|
import OSS from 'ali-oss';
|
|
|
import cliProgress from 'cli-progress';
|
|
|
import { selectVersion } from './index.mjs';
|
|
@@ -78,13 +78,31 @@ async function saveConfig(postConfig) {
|
|
|
await writeFile(path.resolve(__dirname, './_config.json'), JSON.stringify(postConfig));
|
|
|
}
|
|
|
|
|
|
+async function getUpdateInfo(postConfig) {
|
|
|
+ let updateInfo = await input({ message: '输入更新信息', default: postConfig.lastUpdateInfo });
|
|
|
+ if (updateInfo === 'git') {
|
|
|
+ console.log('开始获取git提交信息');
|
|
|
+ updateInfo = await new Promise((resolve, reject) => {
|
|
|
+ exec('git log -1 --pretty=format:"%h %s"', (error, stdout, stderr) => {
|
|
|
+ if (error) {
|
|
|
+ reject(error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ resolve(stdout);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ console.log('使用git提交信息作为更新信息');
|
|
|
+ }
|
|
|
+ return updateInfo;
|
|
|
+}
|
|
|
+
|
|
|
//App更新与提交
|
|
|
//========================================
|
|
|
|
|
|
export async function postAppUpdate(axiosInstance, param) {
|
|
|
const postConfig = await getConfig();
|
|
|
const versionId = await selectVersion(false, postConfig.lastVersion);
|
|
|
- const updateInfo = await input({ message: '输入更新信息', default: postConfig.lastUpdateInfo });
|
|
|
+ const updateInfo = await getUpdateInfo(postConfig);
|
|
|
|
|
|
await axiosInstance.post('/update-post', { config: { type: 2, test: true, versionId, uploadWebConfig: config.uploadWebConfig, submitKey: config.submitKey } });
|
|
|
|
|
@@ -251,7 +269,7 @@ export async function postWebUpdate(axiosInstance, param) {
|
|
|
|
|
|
const postConfig = await getConfig();
|
|
|
const versionId = await selectVersion(false, postConfig.lastVersion);
|
|
|
- const updateInfo = await input({ message: '输入更新信息', default: postConfig.lastUpdateInfo });
|
|
|
+ const updateInfo = await getUpdateInfo(postConfig);
|
|
|
|
|
|
postConfig.lastVersion = versionId;
|
|
|
postConfig.lastUpdateInfo = updateInfo;
|