Skip to content

Commit

Permalink
fix(docs): add tool for deploying docs
Browse files Browse the repository at this point in the history
  • Loading branch information
atticusofsparta committed Oct 25, 2024
1 parent 77ca6b6 commit f8561cd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
35 changes: 35 additions & 0 deletions tools/deploy-docs.mjs
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit f8561cd

Please sign in to comment.