This commit is contained in:
2025-03-09 17:49:10 +08:00
parent ce9b43b497
commit 0ee7d9a69a
5 changed files with 483 additions and 395 deletions

View File

@@ -16,10 +16,11 @@ const command = new Command('deploy')
.option('-v, --version <version>', 'verbose')
.option('-k, --key <key>', 'key')
.option('-y, --yes <yes>', 'yes')
.option('-o, --org <org>', 'org')
.option('-u, --update', 'load current app. set current version in product')
.action(async (filePath, options) => {
try {
let { version, key, yes, update } = options;
let { version, key, yes, update, org } = options;
if (!version || !key) {
const answers = await inquirer.prompt([
{
@@ -69,7 +70,7 @@ const command = new Command('deploy')
}
}
const uploadDirectory = isDirectory ? directory : path.dirname(directory);
const res = await uploadFiles(_relativeFiles, uploadDirectory, { key, version });
const res = await uploadFiles(_relativeFiles, uploadDirectory, { key, version, username: org });
if (res?.code === 200) {
console.log('File uploaded successfully!');
res.data?.data?.files?.map?.((d) => {
@@ -92,7 +93,11 @@ const command = new Command('deploy')
}
});
const uploadFiles = async (files: string[], directory: string, { key, version }: { key: string; version: string }): Promise<any> => {
const uploadFiles = async (
files: string[],
directory: string,
{ key, version, username }: { key: string; version: string; username: string },
): Promise<any> => {
const config = await getConfig();
const form = new FormData();
for (const file of files) {
@@ -104,6 +109,9 @@ const uploadFiles = async (files: string[], directory: string, { key, version }:
}
form.append('appKey', key);
form.append('version', version);
if (username) {
form.append('username', username);
}
return new Promise((resolve) => {
const _baseURL = getBaseURL();
const url = new URL(_baseURL);