This commit is contained in:
2025-12-09 13:40:41 +08:00
parent 9127df2600
commit 5b83f7a6d1
9 changed files with 442 additions and 113 deletions

View File

@@ -59,7 +59,7 @@ const command = new Command('deploy')
if (!key && pkgInfo?.appKey) {
key = pkgInfo?.appKey || '';
}
console.log('start deploy');
logger.debug('start deploy');
if (!version || !key) {
const answers = await inquirer.prompt([
{
@@ -124,7 +124,6 @@ const command = new Command('deploy')
const uploadDirectory = isDirectory ? directory : path.dirname(directory);
const res = await uploadFiles(_relativeFiles, uploadDirectory, { key, version, username: org, noCheckAppFiles: !noCheck, directory: options.directory });
if (res?.code === 200) {
console.log('File uploaded successfully!');
res.data?.upload?.map?.((d) => {
console.log(chalk.green('uploaded file', d?.name, d?.path));
});
@@ -139,7 +138,6 @@ const command = new Command('deploy')
// const { id, data, ...rest } = res.data?.app || {};
const { id, data, ...rest } = res2.data || {};
if (id && !update) {
console.log(chalk.green('id: '), id);
if (!org) {
console.log(chalk.green(`更新为最新版本: envision deploy-load ${id}`));
} else {
@@ -153,7 +151,7 @@ const command = new Command('deploy')
logger.debug('deploy success', res2.data);
if (id && showBackend) {
console.log('\n');
console.log(chalk.blue('服务端应用部署: '), 'envision pack-deploy', id);
console.log(chalk.blue('服务端应用部署:\n'), 'envision pack-deploy', id);
console.log('\n');
}
} else {
@@ -180,8 +178,8 @@ const uploadFiles = async (files: string[], directory: string, opts: UploadFileO
const filePath = path.join(directory, file);
const hash = getHash(filePath);
if (!hash) {
console.error('文件', filePath, '不存在');
console.error('请检查文件是否存在');
logger.error('文件', filePath, '不存在');
logger.error('请检查文件是否存在');
}
data.files.push({ path: file, hash: hash });
}
@@ -220,11 +218,11 @@ const uploadFiles = async (files: string[], directory: string, opts: UploadFileO
const filePath = path.join(directory, file);
const check = checkData.find((d) => d.path === file);
if (check?.isUpload) {
console.log('文件已经上传过了', file);
logger.debug('文件已经上传过了', file);
continue;
}
const filename = path.basename(filePath);
console.log('upload file', file, filename);
logger.debug('upload file', file, filename);
form.append('file', fs.createReadStream(filePath), {
filename: filename,
filepath: file,
@@ -232,7 +230,7 @@ const uploadFiles = async (files: string[], directory: string, opts: UploadFileO
needUpload = true;
}
if (!needUpload) {
console.log('所有文件都上传过了,不需要上传文件');
logger.debug('所有文件都上传过了,不需要上传文件');
return {
code: 200,
};
@@ -260,16 +258,16 @@ const deployLoadFn = async (id: string, org?: string) => {
},
});
if (res.code === 200) {
console.log(chalk.green('deploy-load success. current version:', res.data?.version));
logger.info(chalk.green('deploy-load success. current version:', res.data?.version));
// /:username/:appName
try {
const { user, key } = res.data;
const baseURL = getBaseURL();
const deployURL = new URL(`/${user}/${key}/`, baseURL);
console.log(chalk.blue('deployURL', deployURL.href));
logger.info(chalk.blue('deployURL', deployURL.href));
} catch (error) { }
} else {
console.error('deploy-load failed', res.message);
logger.error('deploy-load failed', res.message);
}
};