create-disposabl-app 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -9
- package/dist/templates/default/.github/workflows/pipeline.yml +100 -0
- package/dist/templates/default/bun.lock +767 -38
- package/dist/templates/default/packages/backend/package.json +1 -0
- package/dist/templates/default/packages/disposabl-kit/server/dev-setup.mjs +39 -0
- package/dist/templates/default/turbo.json +9 -1
- package/package.json +51 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { $ } from "bun";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { parseEnv } from "node:util";
|
|
4
|
+
|
|
5
|
+
const root = resolve(import.meta.dir, "../../..");
|
|
6
|
+
const backend = `${root}/packages/backend`;
|
|
7
|
+
const read = async (path) => (await Bun.file(path).exists()) ? parseEnv(await Bun.file(path).text()) : {};
|
|
8
|
+
const save = async (path, values) => {
|
|
9
|
+
const previous = await read(path);
|
|
10
|
+
if (Object.entries(values).every(([key, value]) => previous[key] === value)) return;
|
|
11
|
+
process.umask(0o077);
|
|
12
|
+
await Bun.write(path, Object.entries({ ...previous, ...values }).filter(([, value]) => value !== undefined).map(([key, value]) => `${key}=${JSON.stringify(value)}\n`).join(""));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
$.cwd(root);
|
|
16
|
+
if ((await $`git rev-parse --git-dir`.quiet().nothrow()).exitCode !== 0) await $`git init --initial-branch=main`.quiet();
|
|
17
|
+
const branch = (await $`git branch --show-current`.text()).trim();
|
|
18
|
+
if (!branch) throw new Error("Create a named Git branch before running dev.");
|
|
19
|
+
const original = dirname((await $`git rev-parse --path-format=absolute --git-common-dir`.text()).trim());
|
|
20
|
+
const key = process.env.CONVEX_DEPLOY_KEY ?? (await read(`${root}/.env.local`)).CONVEX_DEPLOY_KEY ?? (await read(`${original}/.env.local`)).CONVEX_DEPLOY_KEY;
|
|
21
|
+
const match = key?.match(/^preview:([\w-]+):([\w-]+)\|[A-Za-z0-9_+/=-]+$/);
|
|
22
|
+
if (!match) throw new Error("Set CONVEX_DEPLOY_KEY to the project preview key in root .env.local.");
|
|
23
|
+
let saved = await read(`${backend}/.env.local`);
|
|
24
|
+
if (saved.DISPOSABL_PREVIEW_BRANCH !== branch || saved.CONVEX_SELF_HOSTED_ADMIN_KEY !== key || !saved.CONVEX_SELF_HOSTED_URL) {
|
|
25
|
+
// Convex CLI's create-or-reuse API. Explicit URL/key config lets native `convex dev` use the preview.
|
|
26
|
+
const response = await fetch("https://api.convex.dev/api/claim_preview_deployment", {
|
|
27
|
+
method: "POST", redirect: "error", headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
|
|
28
|
+
body: JSON.stringify({ projectSelection: { kind: "teamAndProjectSlugs", teamSlug: match[1], projectSlug: match[2] }, identifier: branch, reuse: true }),
|
|
29
|
+
});
|
|
30
|
+
if (!response.ok) throw new Error(`Preview setup failed (${response.status}).`);
|
|
31
|
+
const { instanceUrl, adminKey } = await response.json();
|
|
32
|
+
if (!/^https:\/\/[a-z0-9-]+\.convex\.cloud$/.test(instanceUrl) || !adminKey) throw new Error("Invalid preview credentials returned by Convex.");
|
|
33
|
+
await $`bun --no-env-file node_modules/@convex-dev/auth/dist/cli/init.js --keys-only --preview-name ${branch}`.cwd(backend).env({ ...process.env, CONVEX_DEPLOY_KEY: key });
|
|
34
|
+
saved = { DISPOSABL_PREVIEW_BRANCH: branch, CONVEX_SELF_HOSTED_URL: instanceUrl, CONVEX_SELF_HOSTED_ADMIN_KEY: adminKey };
|
|
35
|
+
await save(`${backend}/.env.local`, { ...saved, CONVEX_DEPLOY_KEY: undefined, CONVEX_DEPLOYMENT_TOKEN: undefined, CONVEX_DEPLOYMENT: undefined });
|
|
36
|
+
}
|
|
37
|
+
for await (const manifest of new Bun.Glob("apps/*/package.json").scan({ cwd: root, absolute: true }))
|
|
38
|
+
await save(`${dirname(manifest)}/.env.local`, { VITE_CONVEX_URL: saved.CONVEX_SELF_HOSTED_URL, VITE_CONVEX_SITE_URL: saved.CONVEX_SELF_HOSTED_URL.replace(/\.cloud$/, ".site") });
|
|
39
|
+
console.log(`Using preview ${branch}.`);
|
|
@@ -36,11 +36,19 @@
|
|
|
36
36
|
"^typecheck"
|
|
37
37
|
]
|
|
38
38
|
},
|
|
39
|
+
"@disposabl/backend#dev:setup": {
|
|
40
|
+
"cache": false,
|
|
41
|
+
"passThroughEnv": [
|
|
42
|
+
"CONVEX_DEPLOY_KEY"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
39
45
|
"dev": {
|
|
46
|
+
"dependsOn": [
|
|
47
|
+
"@disposabl/backend#dev:setup"
|
|
48
|
+
],
|
|
40
49
|
"cache": false,
|
|
41
50
|
"persistent": true,
|
|
42
51
|
"passThroughEnv": [
|
|
43
|
-
"CONVEX_*",
|
|
44
52
|
"VITE_*"
|
|
45
53
|
]
|
|
46
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-disposabl-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Create a Disposabl app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,12 +37,60 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@eslint/js": "10.0.1",
|
|
40
|
+
"@semantic-release/exec": "7.1.0",
|
|
40
41
|
"@types/bun": "1.4.4",
|
|
41
|
-
"
|
|
42
|
+
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
42
43
|
"eslint": "10.13.0",
|
|
43
44
|
"jiti": "2.7.0",
|
|
44
|
-
"
|
|
45
|
+
"semantic-release": "25.0.9",
|
|
45
46
|
"typescript": "6.0.3",
|
|
46
47
|
"typescript-eslint": "8.72.1"
|
|
48
|
+
},
|
|
49
|
+
"release": {
|
|
50
|
+
"branches": [
|
|
51
|
+
"main"
|
|
52
|
+
],
|
|
53
|
+
"plugins": [
|
|
54
|
+
[
|
|
55
|
+
"@semantic-release/commit-analyzer",
|
|
56
|
+
{
|
|
57
|
+
"preset": "conventionalcommits",
|
|
58
|
+
"releaseRules": [
|
|
59
|
+
{
|
|
60
|
+
"breaking": true,
|
|
61
|
+
"release": "major"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "feat",
|
|
65
|
+
"release": "minor"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"release": "patch"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
"@semantic-release/release-notes-generator",
|
|
75
|
+
{
|
|
76
|
+
"preset": "conventionalcommits"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"@semantic-release/npm",
|
|
80
|
+
[
|
|
81
|
+
"@semantic-release/exec",
|
|
82
|
+
{
|
|
83
|
+
"prepareCmd": "bun run build"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
"@semantic-release/github",
|
|
88
|
+
{
|
|
89
|
+
"successComment": false,
|
|
90
|
+
"failComment": false,
|
|
91
|
+
"releasedLabels": false
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
]
|
|
47
95
|
}
|
|
48
96
|
}
|