From aa4b74444bad21dacfa0e26300c614c9f4552bc3 Mon Sep 17 00:00:00 2001 From: Derek Anderson Date: Thu, 1 Sep 2022 09:25:29 -0500 Subject: [PATCH] correct publish with build (#35) --- src/commands/function/publish.ts | 16 ++++++++++------ src/commands/function/shared.ts | 2 +- src/index.ts | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/commands/function/publish.ts b/src/commands/function/publish.ts index 7857c2a..150237c 100644 --- a/src/commands/function/publish.ts +++ b/src/commands/function/publish.ts @@ -29,7 +29,7 @@ export const publishFunction = async ( axios .post(`${server}/api/submit`, formData, { headers: { - "Authorization": `Bearer ${token}`, + Authorization: `Bearer ${token}`, "Content-Type": "multipart/form-data", }, }) @@ -48,7 +48,13 @@ const logResult = (data: any) => { console.log(`function successfully published with id ${cid}`); }; export const run = (options: any) => { - const { debug, name, path, publishCallback = logResult, rebuild } = options; + const { + debug, + name, + path = process.cwd(), + publishCallback = logResult, + rebuild, + } = options; const buildDir = getBuildDir(path); const wasmName = `${name}${debug ? "-debug" : ""}.wasm`; const wasmArchive = `${name}.tar.gz`; @@ -59,16 +65,14 @@ export const run = (options: any) => { //TODO: this is absolutely monstrous and needssanity appplied deploymentOptions.userFunctionId = userFunctionId; - if (rebuild) { - runBuild({ debug, name, path, rebuild }); - } + runBuild({ debug, name, path, rebuild }); console.log(Chalk.yellow(`Creating tarball...`)); createWasmArchive(buildDir, wasmArchive, wasmName); console.log(Chalk.yellow(`Deploying function located in ${buildDir}`)); publishFunction( - readFileSync(`${buildDir}/manifest.json}`), + readFileSync(`${buildDir}/manifest.json`), readFileSync(`${buildDir}/${wasmArchive}`), publishCallback ); diff --git a/src/commands/function/shared.ts b/src/commands/function/shared.ts index 6249495..d53ae69 100644 --- a/src/commands/function/shared.ts +++ b/src/commands/function/shared.ts @@ -8,7 +8,7 @@ export const createWasmArchive = ( wasmArchive: string, wasmName: string ) => { - execSync(`tar zcf ${wasmArchive} ${wasmName}`, { + execSync(`tar zcf ${path}/${wasmArchive} ${path}/${wasmName}`, { cwd: path, stdio: "inherit", }); diff --git a/src/index.ts b/src/index.ts index 55022aa..fefa3f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -114,8 +114,8 @@ args } const requiredOptions: RequiredOptions = { init: ["name"], - deploy: ["name", "path"], - publish: ["name", "path"], + deploy: ["name"], + publish: ["name"], }; const index: keyof RequiredOptions = "init"; didRun = true;