fix: fix unknown deployment error in Linux (#778)
This commit is contained in:
Родитель
b2123b9c93
Коммит
90abd454e1
|
@ -13,7 +13,7 @@ import {
|
|||
updateSwaCliConfigFile,
|
||||
} from "../../../core";
|
||||
import { chooseOrCreateProjectDetails, getStaticSiteDeployment } from "../../../core/account";
|
||||
import { DEFAULT_RUNTIME_LANGUAGE, STATIC_SITE_CLIENT_WORKING_FOLDER } from "../../../core/constants";
|
||||
import { DEFAULT_RUNTIME_LANGUAGE } from "../../../core/constants";
|
||||
import { cleanUp, getDeployClientPath } from "../../../core/deploy-client";
|
||||
import { swaCLIEnv } from "../../../core/env";
|
||||
import { getDefaultVersion } from "../../../core/functions-versions";
|
||||
|
@ -255,11 +255,6 @@ export async function deploy(options: SWACLIConfig) {
|
|||
FUNCTION_LANGUAGE_VERSION: apiVersion,
|
||||
};
|
||||
|
||||
const clientWorkingDir = path.resolve(deployClientEnv.REPOSITORY_BASE ?? "", STATIC_SITE_CLIENT_WORKING_FOLDER);
|
||||
if (!fs.existsSync(clientWorkingDir)) {
|
||||
fs.mkdirSync(clientWorkingDir);
|
||||
}
|
||||
|
||||
// set the DEPLOYMENT_ENVIRONMENT env variable only when the user has provided
|
||||
// a deployment environment which is not "production".
|
||||
if (options.env?.toLowerCase() !== "production" && options.env?.toLowerCase() !== "prod") {
|
||||
|
@ -280,7 +275,6 @@ export async function deploy(options: SWACLIConfig) {
|
|||
logger.silly(`Deploying using ${cliEnv.SWA_CLI_DEPLOY_BINARY}`);
|
||||
logger.silly(`Deploying using the following options:`);
|
||||
logger.silly({ env: { ...cliEnv, ...deployClientEnv } });
|
||||
logger.silly(`StaticSiteClient working directory: ${clientWorkingDir}`);
|
||||
|
||||
spinner.start(`Preparing deployment. Please wait...`);
|
||||
|
||||
|
@ -288,7 +282,6 @@ export async function deploy(options: SWACLIConfig) {
|
|||
env: {
|
||||
...swaCLIEnv(cliEnv, deployClientEnv),
|
||||
},
|
||||
cwd: clientWorkingDir,
|
||||
});
|
||||
|
||||
let projectUrl = "";
|
||||
|
@ -330,7 +323,7 @@ export async function deploy(options: SWACLIConfig) {
|
|||
});
|
||||
|
||||
child.on("close", (code) => {
|
||||
cleanUp(clientWorkingDir);
|
||||
cleanUp();
|
||||
|
||||
if (code === 0) {
|
||||
spinner.succeed(chalk.green(`Project deployed to ${chalk.underline(projectUrl)} 🚀`));
|
||||
|
@ -347,7 +340,7 @@ export async function deploy(options: SWACLIConfig) {
|
|||
);
|
||||
logGitHubIssueMessageAndExit();
|
||||
} finally {
|
||||
cleanUp(clientWorkingDir);
|
||||
cleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ export const DEPLOY_BINARY_NAME = "StaticSitesClient";
|
|||
export const DEPLOY_BINARY_STABLE_TAG = "stable";
|
||||
export const DEPLOY_FOLDER = path.join(os.homedir(), ".swa", "deploy");
|
||||
export const STATIC_SITE_CLIENT_RELEASE_METADATA_URL = "https://swalocaldeploy.azureedge.net/downloads/versions.json";
|
||||
export const STATIC_SITE_CLIENT_WORKING_FOLDER = "staticsites-cli";
|
||||
|
||||
// Data-api-builder related constants
|
||||
export const DATA_API_BUILDER_BINARY_NAME = "DataApiBuilder";
|
||||
|
|
|
@ -109,9 +109,9 @@ export async function fetchClientVersionDefinition(releaseVersion: string): Prom
|
|||
|
||||
// TODO: get StaticSiteClient to remove zip files
|
||||
// TODO: can these ZIPs be created under /tmp?
|
||||
export function cleanUp(clientWorkingDir: string) {
|
||||
export function cleanUp() {
|
||||
const clean = (file: string) => {
|
||||
const filepath = path.join(clientWorkingDir, file);
|
||||
const filepath = path.join(process.cwd(), file);
|
||||
if (fs.existsSync(filepath)) {
|
||||
try {
|
||||
fs.unlinkSync(filepath);
|
||||
|
@ -121,10 +121,4 @@ export function cleanUp(clientWorkingDir: string) {
|
|||
|
||||
clean(".\\app.zip");
|
||||
clean(".\\api.zip");
|
||||
|
||||
if (fs.existsSync(clientWorkingDir)) {
|
||||
try {
|
||||
fs.rmdirSync(clientWorkingDir, { recursive: true });
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче