feat: 更新上传文件功能,增强目录路径处理逻辑

This commit is contained in:
2026-03-02 02:06:16 +08:00
parent 73d0fb9730
commit 57bf884360

View File

@@ -46,7 +46,7 @@ const command = new Command('deploy')
.option('-u, --update', 'load current app. set current version in product。 redis 缓存更新')
.option('-s, --showBackend', 'show backend url, 部署的后端应用显示执行的cli命令')
.option('-d, --dot', '是否上传隐藏文件')
.option('--dir, --directory <directory>', '上传的默认路径')
.option('--dir, --directory <directory>', '上传的prefix路径默认为空例如设置为static则会上传到/${username}/resources/${key}/${version}/static/路径')
.action(async (filePath, options) => {
try {
let { version, key, yes, update, org, showBackend } = options;
@@ -169,7 +169,7 @@ type UploadFileOptions = {
};
export const uploadFilesV2 = async (files: string[], directory: string, opts: UploadFileOptions): Promise<any> => {
const { key, version, username } = opts || {};
const { key, version, username, directory: prefix } = opts || {};
for (let i = 0; i < files.length; i++) {
const file = files[i];
@@ -184,7 +184,7 @@ export const uploadFilesV2 = async (files: string[], directory: string, opts: Up
filepath: file,
});
const _baseURL = getBaseURL();
const url = new URL(`/${username}/resources/${key}/${version}/${file}`, _baseURL);
const url = new URL(`/${username}/resources/${key}/${version}/${prefix ? prefix + '/' : ''}${file}`, _baseURL);
// console.log('upload file', file, filePath);
const token = await storage.getItem('token');
const check = () => {