Skip to content

Commit

Permalink
Continuous deployment. (#52)
Browse files Browse the repository at this point in the history
Continuous deployment.
  • Loading branch information
aboodman authored Feb 2, 2024
1 parent 057e386 commit 14299e5
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 20 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
publish-reflect.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ dist
next-env.d.ts
.reflect/
**/*.tgz
.DS_Store
2 changes: 1 addition & 1 deletion examples/codemirror/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@codemirror/lang-javascript": "^6.2.1",
"@rocicorp/eslint-config": "^0.5.1",
"@rocicorp/prettier-config": "^0.2.0",
"@rocicorp/reflect": "0.39.202402020122",
"@rocicorp/reflect": "^0.39.202402020122",
"@types/react-dom": "^18.2.17",
"@types/react": "^18.2.38",
"@vitejs/plugin-react": "^4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/monaco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"devDependencies": {
"@rocicorp/eslint-config": "^0.5.1",
"@rocicorp/prettier-config": "^0.2.0",
"@rocicorp/reflect": "0.39.202402020122",
"@rocicorp/reflect": "^0.39.202402020122",
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.17",
"@vitejs/plugin-react": "^4.2.0",
Expand Down
1 change: 0 additions & 1 deletion examples/tiptap/.env.local

This file was deleted.

1 change: 0 additions & 1 deletion examples/tiptap/.env.template

This file was deleted.

2 changes: 1 addition & 1 deletion examples/tiptap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"next": "^13.5.4"
},
"dependencies": {
"@rocicorp/reflect": "0.39.202402020122",
"@rocicorp/reflect": "^0.39.202402020122",
"@tiptap/core": "^2.0.4",
"@tiptap/extension-code-block-lowlight": "^2.1.13",
"@tiptap/extension-collaboration": "^2.0.4",
Expand Down
65 changes: 65 additions & 0 deletions examples/tiptap/publish-reflect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const { spawn } = require("child_process");
const fs = require("fs");

const appBaseName = "reflect-type";
const refName = getEnv(
process.env.VERCEL_GIT_COMMIT_REF,
"VERCEL_GIT_COMMIT_REF"
);

const appName = `${appBaseName}-${refName}`
.toLowerCase()
.replace(/^[^a-z]/, "")
.replace(/[^a-z0-9-]/g, "-");

publish();

async function publish() {
const output = await runCommand("npx", [
"reflect",
"publish",
"--server-path=./src/reflect/index.ts",
"--reflect-channel=canary",
`--app=${appName}`,
"--auth-key-from-env=REFLECT_AUTH_KEY",
]);
const lines = output.toString().split("\n");
const success = lines.findIndex((line) =>
line.includes("🎁 Published successfully to:")
);
const url = lines[success + 1];

fs.writeFileSync("./.env", `NEXT_PUBLIC_REFLECT_SERVER=${url}`);
}

function runCommand(command, args) {
console.log("running command: " + command + " " + args.join(" "));
return new Promise((resolve, reject) => {
const child = spawn(command, args);

let output = "";
child.stdout.on("data", (data) => {
output += data;
process.stdout.write(data);
});

child.stderr.on("data", (data) => {
process.stderr.write(data);
});

child.on("close", (code) => {
if (code !== 0) {
reject(new Error(`Command failed with exit code ${code}`));
} else {
resolve(output);
}
});
});
}

function getEnv(v, name) {
if (!v) {
throw new Error("Missing required env var: " + name);
}
return v;
}
7 changes: 0 additions & 7 deletions examples/tiptap/reflect.config.json

This file was deleted.

4 changes: 4 additions & 0 deletions examples/tiptap/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"buildCommand": "turbo run build --force && node publish-reflect.js",
"installCommand": "npm install"
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/reflect-yjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test:watch": "vitest watch --browser.provider=playwright --browser.name=chromium --browser.headless"
},
"peerDependencies": {
"@rocicorp/reflect": "0.39.202402020122",
"@rocicorp/reflect": "^0.39.202402020122",
"y-protocols": "^1.0.6",
"yjs": "^13.6.10"
},
Expand Down

0 comments on commit 14299e5

Please sign in to comment.