feat: 更新上传文件功能,增强目录路径处理逻辑
This commit is contained in:
@@ -46,7 +46,7 @@ const command = new Command('deploy')
|
|||||||
.option('-u, --update', 'load current app. set current version in product。 redis 缓存更新')
|
.option('-u, --update', 'load current app. set current version in product。 redis 缓存更新')
|
||||||
.option('-s, --showBackend', 'show backend url, 部署的后端应用,显示执行的cli命令')
|
.option('-s, --showBackend', 'show backend url, 部署的后端应用,显示执行的cli命令')
|
||||||
.option('-d, --dot', '是否上传隐藏文件')
|
.option('-d, --dot', '是否上传隐藏文件')
|
||||||
.option('--dir, --directory <directory>', '上传的默认路径')
|
.option('--dir, --directory <directory>', '上传的prefix路径,默认为空,例如设置为static,则会上传到/${username}/resources/${key}/${version}/static/路径下')
|
||||||
.action(async (filePath, options) => {
|
.action(async (filePath, options) => {
|
||||||
try {
|
try {
|
||||||
let { version, key, yes, update, org, showBackend } = options;
|
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> => {
|
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++) {
|
for (let i = 0; i < files.length; i++) {
|
||||||
const file = files[i];
|
const file = files[i];
|
||||||
@@ -184,7 +184,7 @@ export const uploadFilesV2 = async (files: string[], directory: string, opts: Up
|
|||||||
filepath: file,
|
filepath: file,
|
||||||
});
|
});
|
||||||
const _baseURL = getBaseURL();
|
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);
|
// console.log('upload file', file, filePath);
|
||||||
const token = await storage.getItem('token');
|
const token = await storage.getItem('token');
|
||||||
const check = () => {
|
const check = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user