init
This commit is contained in:
47
scripts/deploy-up.mjs
Normal file
47
scripts/deploy-up.mjs
Normal file
@@ -0,0 +1,47 @@
|
||||
import path from "node:path";
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
const root = process.cwd();
|
||||
|
||||
function parseArg(name) {
|
||||
const raw = process.argv.find((arg) => arg.startsWith(`--${name}=`));
|
||||
if (!raw) return "";
|
||||
return raw.slice(name.length + 3).trim();
|
||||
}
|
||||
|
||||
function runNodeScript(scriptPath, args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(process.execPath, [scriptPath, ...args], {
|
||||
cwd: root,
|
||||
stdio: "inherit"
|
||||
});
|
||||
child.on("error", reject);
|
||||
child.on("close", (code) => {
|
||||
if (code !== 0) {
|
||||
reject(new Error(`Deploy failed with exit code ${code}`));
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const walletArg = parseArg("wallet");
|
||||
const gatewayArg = parseArg("gateway");
|
||||
const appName = parseArg("app-name");
|
||||
const appVersion = parseArg("app-version");
|
||||
|
||||
await runNodeScript(path.join(root, "scripts", "deploy.mjs"), [
|
||||
"--upload-mode=up",
|
||||
...(walletArg ? [`--wallet=${walletArg}`] : []),
|
||||
...(gatewayArg ? [`--gateway=${gatewayArg}`] : []),
|
||||
...(appName ? [`--app-name=${appName}`] : []),
|
||||
...(appVersion ? [`--app-version=${appVersion}`] : [])
|
||||
]);
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error?.message || String(error));
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user