Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: fix download error while use s.yaml model #88

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/common/install-saectl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ const fs = require('fs');
const BASE_DOWNLOAD_URL = "https://sae-component-software.oss-cn-hangzhou.aliyuncs.com/saectl"
const HOME_DIR = os.homedir();
const SAECTL_INSTALLED_PATH = `${HOME_DIR}/.s/components/devsapp.cn/sae/dist`;
const DEVSAPP_SAECTL_INSTALLED_PATH = `${HOME_DIR}/.s/components/devsapp.cn/devsapp/sae/dist`;
let INSTALLED_PATH;

export async function checkAndInstallSaeCtl() {
let os_arch = getMachineOsArch();
let target = `${SAECTL_INSTALLED_PATH}/${os_arch}/saectl`;
if (existsSync(DEVSAPP_SAECTL_INSTALLED_PATH)) {
INSTALLED_PATH = DEVSAPP_SAECTL_INSTALLED_PATH
} else {
INSTALLED_PATH = SAECTL_INSTALLED_PATH
}
let target = `${INSTALLED_PATH}/${os_arch}/saectl`;
let exist = existsSync(target);
if (!exist) {
let target = await installSaeCtl("latest");
Expand All @@ -47,7 +54,7 @@ export async function installSaeCtl(version: string) {
let os_arch = getMachineOsArch();
let tarFileName = `saectl-${version}-${os_arch}.tar.gz`;
let downloadUrl = `${BASE_DOWNLOAD_URL}/${version}/${tarFileName}`;
let downloadFileName = `${SAECTL_INSTALLED_PATH}/${tarFileName}`;
let downloadFileName = `${INSTALLED_PATH}/${tarFileName}`;
let exist = existsSync(downloadFileName);
if (!exist) {
let downloadProgress = spinner("Download saectl plugin");
Expand All @@ -63,10 +70,10 @@ export async function installSaeCtl(version: string) {
downloadProgress.succeed();
}
try {
spawnSync(`tar xf ${downloadFileName} -C ${SAECTL_INSTALLED_PATH}`, { shell: true, stdio: 'inherit' });
spawnSync(`tar xf ${downloadFileName} -C ${INSTALLED_PATH}`, { shell: true, stdio: 'inherit' });
} catch (ex) {
logger.error(`fail to tar plugin ${downloadFileName}`)
process.exit(1);
}
return `${SAECTL_INSTALLED_PATH}/${os_arch}/saectl`
return `${INSTALLED_PATH}/${os_arch}/saectl`
}