Skip to content

Commit 93b60c7

Browse files
author
Shaun Persad
authored
Deploy live demos in isolation (#714)
1 parent aa1d19d commit 93b60c7

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- run: pnpm -w test
2424

2525
- name: Deploy live demos
26-
run: pnpm run deploy # pnpm deploy is a whole other thing apparently
26+
run: pnpm -w deploy-live-demos
2727

2828
- name: Validate live demo links
2929
run: pnpm -w validate-live-demo-links

cli/src/deployLiveDemos.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import "zx/globals";
2+
import subprocess from "node:child_process";
3+
import { getTemplates } from "./util";
4+
5+
export type DeployLiveDemosConfig = {
6+
templateDirectory: string;
7+
};
8+
9+
export default async function deployLiveDemos({
10+
templateDirectory,
11+
}: DeployLiveDemosConfig) {
12+
const templates = getTemplates(templateDirectory);
13+
await Promise.all(
14+
templates.map(({ path: templatePath }) => {
15+
subprocess.execSync("npm install", {
16+
cwd: templatePath,
17+
});
18+
subprocess.execSync("npm run build --if-present", {
19+
cwd: templatePath,
20+
});
21+
subprocess.execSync("npm run deploy", {
22+
cwd: templatePath,
23+
});
24+
}),
25+
);
26+
}

cli/src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { validateD2CButtons } from "./validateD2CButtons";
1111
import { setupHooks } from "./setupHooks";
1212
import { depsInfo } from "./depsInfo";
1313
import { depsUpdate } from "./depsUpdate";
14+
import deployLiveDemos from "./deployLiveDemos";
1415

1516
const program = new Command();
1617

@@ -100,6 +101,20 @@ program
100101
);
101102
});
102103

104+
program
105+
.command("deploy-live-demos")
106+
.description("Builds and deploys each template in isolataion")
107+
.argument(
108+
"[path-to-template(s)]",
109+
"path to directory containing template(s)",
110+
".",
111+
)
112+
.action((templateDirectory) => {
113+
return actionWithSummary("Deploy live demos", () =>
114+
deployLiveDemos({ templateDirectory }),
115+
);
116+
});
117+
103118
program
104119
.command("validate-live-demo-links")
105120
.description("Ensures every template has a live demo that returns a 200")

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"check:templates": "templates lint .",
2727
"check:turbo": "turbo run check cf-typegen --force",
2828
"deploy": "turbo run deploy",
29+
"deploy-live-demos": "templates deploy-live-demos .",
2930
"fix": "pnpm run fix:templates && pnpm run fix:lockfiles && pnpm run fix:turbo && pnpm run fix:prettier",
3031
"fix:deps": "syncpack format && syncpack fix-mismatches",
3132
"fix:lockfiles": "templates generate-npm-lockfiles .",

0 commit comments

Comments
 (0)