diff --git a/.gitignore b/.gitignore index 8a71573..5b5ffa3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,12 @@ node_modules dist dist-ssr *.local +# permaweb deploy output garbage +dist-errors.txt +dist-id.txt +dist-manifest.json +dist-csv.json +dist-manifest.csv # Editor directories and files .idea diff --git a/package.json b/package.json index 50e7343..bc21289 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "storybook": "storybook dev -p 6006", "build-storybook": "yarn build-docs && storybook build", "build-docs": "typedoc", - "publish-docs": "yarn build-storybook && permaweb-deploy --ant-process $DEPLOY_ANT_PROCESS_ID --undername ao-wallet-kit --deploy-folder storybook-static", + "publish-docs": "node tools/deploy-docs.mjs", "serve-docs": "http-server storybook-static --port 8080", "test": "echo \"Warning: no test specified\"", "format": "prettier . --write", diff --git a/tools/deploy-docs.mjs b/tools/deploy-docs.mjs new file mode 100644 index 0000000..1da4acf --- /dev/null +++ b/tools/deploy-docs.mjs @@ -0,0 +1,35 @@ +import { exec } from 'node:child_process'; +import fs from 'node:fs'; +import path from 'node:path'; + +const __dirname = path.dirname(new URL(import.meta.url).pathname); + +const wallet = + process.env.DEPLOY_KEY ?? + fs.readFileSync(path.join(__dirname, 'wallet.json'), 'utf-8').trim(); +const b64EncodedWallet = + process.env.DEPLOY_KEY ?? Buffer.from(wallet).toString('base64'); + +async function main() { + const deployProcess = exec( + `yarn build-storybook && permaweb-deploy --ant-process $DEPLOY_ANT_PROCESS_ID --undername ao-wallet-kit --deploy-folder $DEPLOY_DIR`, + { + env: { + ...process.env, + DEPLOY_KEY: b64EncodedWallet, + DEPLOY_ANT_PROCESS_ID: 'wJVTnZTedI9FIY4r2cB9C4CpAJKImvhu0WjOh0AecjQ', + DEPLOY_DIR: path.join(__dirname, '..', 'storybook-static'), + }, + }, + ); + + deployProcess.stdout.pipe(process.stdout); + deployProcess.stderr.pipe(process.stderr); + deployProcess.on('exit', (code) => { + if (code !== 0) { + process.exit(code); + } + }); +} + +main().catch(console.error);