create-disposabl-app 0.7.1 → 0.8.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/disposabl.js +35 -4
- package/dist/index.js +1 -1
- package/dist/templates/default/.github/workflows/pipeline.yml +4 -4
- package/dist/templates/default/packages/backend/AGENTS.md +2 -0
- package/dist/templates/default/packages/backend/README.md +2 -2
- package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +10 -0
- package/dist/templates/default/packages/backend/convex/apps/actions/cleanup.ts +295 -0
- package/dist/templates/default/packages/backend/convex/apps/actions/delete.ts +15 -0
- package/dist/templates/default/packages/backend/convex/apps/actions/expo.ts +174 -0
- package/dist/templates/default/packages/backend/convex/apps/internal.ts +4 -21
- package/dist/templates/default/packages/backend/convex/apps/operations/internal.ts +213 -0
- package/dist/templates/default/packages/backend/convex/apps/validator.ts +23 -0
- package/dist/templates/default/packages/backend/convex/connections/actions/github.ts +1 -3
- package/dist/templates/default/packages/backend/convex/connections/index.ts +8 -8
- package/dist/templates/default/packages/backend/convex/connections/internal.ts +1 -2
- package/dist/templates/default/packages/backend/convex/github/actions/internal.ts +6 -0
- package/dist/templates/default/packages/backend/convex/github/actions/secrets.ts +35 -2
- package/dist/templates/default/packages/backend/convex/github/actions/tokens.ts +6 -2
- package/dist/templates/default/packages/backend/convex/github/internal.ts +5 -4
- package/dist/templates/default/packages/backend/convex/previews/internal.ts +5 -5
- package/dist/templates/default/packages/backend/convex/previews/token/actions/create.ts +30 -19
- package/dist/templates/default/packages/backend/convex/previews/token/actions/management.ts +2 -1
- package/dist/templates/default/packages/backend/convex/schema.ts +10 -0
- package/dist/templates/default/packages/backend/generated/openapi.json +5 -2
- package/dist/templates/default/packages/backend/generated/platforms.ts +14 -12
- package/dist/templates/default/packages/cli/README.md +3 -1
- package/dist/templates/default/packages/cli/commands.ts +23 -2
- package/dist/templates/default/packages/cli/delete.ts +39 -0
- package/dist/templates/default/packages/disposabl-kit/server/lib/platform-spec.ts +10 -2
- package/dist/templates/default/packages/sdk/src/generated/types.gen.ts +1 -0
- package/package.json +1 -1
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
// Generated by bun run generate. Do not edit.
|
|
2
2
|
import * as m0 from "../convex/apps/internal";
|
|
3
|
-
import * as m1 from "../convex/
|
|
4
|
-
import * as m2 from "../convex/
|
|
5
|
-
import * as m3 from "../convex/
|
|
6
|
-
import * as m4 from "../convex/previews/
|
|
7
|
-
import * as m5 from "../convex/
|
|
8
|
-
import * as m6 from "../convex/
|
|
3
|
+
import * as m1 from "../convex/apps/operations/internal";
|
|
4
|
+
import * as m2 from "../convex/connections/internal";
|
|
5
|
+
import * as m3 from "../convex/github/internal";
|
|
6
|
+
import * as m4 from "../convex/previews/internal";
|
|
7
|
+
import * as m5 from "../convex/previews/token/internal";
|
|
8
|
+
import * as m6 from "../convex/releases/internal";
|
|
9
|
+
import * as m7 from "../convex/users/internal";
|
|
9
10
|
export default {
|
|
10
11
|
"apps/internal": m0,
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"previews/
|
|
15
|
-
"
|
|
16
|
-
"
|
|
12
|
+
"apps/operations/internal": m1,
|
|
13
|
+
"connections/internal": m2,
|
|
14
|
+
"github/internal": m3,
|
|
15
|
+
"previews/internal": m4,
|
|
16
|
+
"previews/token/internal": m5,
|
|
17
|
+
"releases/internal": m6,
|
|
18
|
+
"users/internal": m7,
|
|
17
19
|
};
|
|
@@ -10,7 +10,7 @@ disposabl apps list --paginationOpts '{"numItems":20,"cursor":null}'
|
|
|
10
10
|
disposabl apps get --appId <uuid>
|
|
11
11
|
disposabl previews token create --configure .
|
|
12
12
|
disposabl previews get
|
|
13
|
-
disposabl apps delete --appId <uuid>
|
|
13
|
+
disposabl apps delete --appId <uuid> --dangerously-delete-app
|
|
14
14
|
disposabl logout
|
|
15
15
|
```
|
|
16
16
|
|
|
@@ -21,3 +21,5 @@ Save the returned app UUID as `appId` in `disposabl.json`. Preview commands read
|
|
|
21
21
|
Credentials live under `~/.config/disposabl` with restricted file permissions. `DISPOSABL_CONFIG_DIR` changes the local credential directory. `DISPOSABL_API_KEY` provides an automation credential. The service origin has no public override.
|
|
22
22
|
|
|
23
23
|
Use `--json` for machine-readable preview output. Other commands return JSON; `--help` lists their arguments.
|
|
24
|
+
|
|
25
|
+
App deletion permanently removes linked GitHub, Convex, and Expo projects, then previews and the app record. Apps with production releases cannot be deleted. Expo requires a signed-in user and password confirmation; the CLI opens the official EAS deletion flow when needed. API/MCP callers receive the project ID and must complete this Expo step before retrying. If cleanup is interrupted, run the same command again; keep the owning accounts connected until it finishes.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { completeExpoDeletion } from "./delete";
|
|
1
2
|
import { Command } from "commander";
|
|
2
3
|
import manifest from "./package.json";
|
|
3
4
|
import {
|
|
@@ -125,6 +126,7 @@ export async function runCli(
|
|
|
125
126
|
"--wait",
|
|
126
127
|
"Open Connections and continue when GitHub and Convex are connected",
|
|
127
128
|
);
|
|
129
|
+
const deleteApp = path === "/api/apps/delete";
|
|
128
130
|
const previewGet = path === "/api/previews/get";
|
|
129
131
|
const tokenCreate = path === "/api/previews/token/create";
|
|
130
132
|
if (previewGet)
|
|
@@ -151,6 +153,13 @@ export async function runCli(
|
|
|
151
153
|
}),
|
|
152
154
|
);
|
|
153
155
|
for (const field of fields) {
|
|
156
|
+
if (deleteApp && field.name === "dangerouslyDeleteApp") {
|
|
157
|
+
command.option(
|
|
158
|
+
"--dangerously-delete-app",
|
|
159
|
+
"Permanently delete this preview app and its GitHub, Convex and Expo projects",
|
|
160
|
+
);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
154
163
|
const flag = `--${field.name} <value>`;
|
|
155
164
|
if (
|
|
156
165
|
field.required &&
|
|
@@ -166,6 +175,10 @@ export async function runCli(
|
|
|
166
175
|
else command.option(flag, field.name);
|
|
167
176
|
}
|
|
168
177
|
command.action(async (options) => {
|
|
178
|
+
if (deleteApp && options.dangerouslyDeleteApp !== true)
|
|
179
|
+
throw new Error(
|
|
180
|
+
"Permanent deletion requires --dangerously-delete-app. Apps with production releases cannot be deleted.",
|
|
181
|
+
);
|
|
169
182
|
if ((previewGet || tokenCreate) && !options.appId) {
|
|
170
183
|
const config = JSON.parse(
|
|
171
184
|
await readFile(
|
|
@@ -186,7 +199,8 @@ export async function runCli(
|
|
|
186
199
|
.filter((field) => options[field.name] !== undefined)
|
|
187
200
|
.map((field) => [
|
|
188
201
|
field.name,
|
|
189
|
-
field.schema.type === "string"
|
|
202
|
+
field.schema.type === "string" ||
|
|
203
|
+
typeof options[field.name] === "boolean"
|
|
190
204
|
? options[field.name]
|
|
191
205
|
: JSON.parse(options[field.name]),
|
|
192
206
|
]),
|
|
@@ -201,7 +215,7 @@ export async function runCli(
|
|
|
201
215
|
fetch(target, {
|
|
202
216
|
method: method.toUpperCase(),
|
|
203
217
|
redirect: "error",
|
|
204
|
-
signal: AbortSignal.timeout(30_000),
|
|
218
|
+
signal: AbortSignal.timeout(deleteApp ? 300_000 : 30_000),
|
|
205
219
|
headers: {
|
|
206
220
|
Authorization: `Bearer ${await accessToken(base, refresh)}`,
|
|
207
221
|
"Content-Type": "application/json",
|
|
@@ -211,6 +225,13 @@ export async function runCli(
|
|
|
211
225
|
let result = await send();
|
|
212
226
|
if (result.status === 401 && !process.env.DISPOSABL_API_KEY)
|
|
213
227
|
result = await send(true);
|
|
228
|
+
if (deleteApp && result.status === 400) {
|
|
229
|
+
const body = await result.clone().json();
|
|
230
|
+
if (body.error?.code === "expo_delete_requires_login") {
|
|
231
|
+
await completeExpoDeletion(body.error.projectId);
|
|
232
|
+
result = await send();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
214
235
|
if (!result.ok)
|
|
215
236
|
throw new Error(
|
|
216
237
|
`API request failed (${result.status}): ${await result.text()}`,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
/** Expo requires a user session in sudo mode; access tokens cannot provide it. */
|
|
4
|
+
export async function completeExpoDeletion(projectId: unknown) {
|
|
5
|
+
if (
|
|
6
|
+
typeof projectId !== "string" ||
|
|
7
|
+
!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
|
|
8
|
+
projectId,
|
|
9
|
+
)
|
|
10
|
+
)
|
|
11
|
+
throw new Error("The service returned an invalid Expo project ID.");
|
|
12
|
+
const command = `bunx eas-cli@27.2.0 project:delete ${projectId}`;
|
|
13
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
14
|
+
throw new Error(
|
|
15
|
+
`Expo needs an interactive login and password confirmation. Run ${command}, then retry apps delete. Your app and remaining resources are retained.`,
|
|
16
|
+
);
|
|
17
|
+
console.error(
|
|
18
|
+
"Expo requires you to confirm deletion in your Expo account. Complete the following EAS prompts to continue.",
|
|
19
|
+
);
|
|
20
|
+
// EAS owns login, password confirmation and MFA. Do not pass the CI robot token.
|
|
21
|
+
const { EXPO_TOKEN: _token, ...env } = process.env;
|
|
22
|
+
await new Promise<void>((resolve, reject) => {
|
|
23
|
+
const child = spawn(
|
|
24
|
+
"bunx",
|
|
25
|
+
["eas-cli@27.2.0", "project:delete", projectId],
|
|
26
|
+
{ stdio: "inherit", env },
|
|
27
|
+
);
|
|
28
|
+
child.on("error", reject);
|
|
29
|
+
child.on("exit", (code) =>
|
|
30
|
+
code === 0
|
|
31
|
+
? resolve()
|
|
32
|
+
: reject(
|
|
33
|
+
new Error(
|
|
34
|
+
"Expo deletion was not completed. Retry apps delete when ready.",
|
|
35
|
+
),
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -56,6 +56,7 @@ export function createPlatforms(
|
|
|
56
56
|
)
|
|
57
57
|
throw new Error(`${id}: expected function kind, args and returns`);
|
|
58
58
|
const { userId, ...args } = fn.args;
|
|
59
|
+
if (!userId) throw new Error(`${id}: platform functions require userId`);
|
|
59
60
|
const type = fn.isQuery ? "query" : fn.isMutation ? "mutation" : "action";
|
|
60
61
|
spec.push({
|
|
61
62
|
name: id,
|
|
@@ -72,7 +73,7 @@ export function createPlatforms(
|
|
|
72
73
|
handler: async (ctx, input, user) => {
|
|
73
74
|
const params = {
|
|
74
75
|
...input,
|
|
75
|
-
|
|
76
|
+
userId: user.userId,
|
|
76
77
|
};
|
|
77
78
|
if (type === "query")
|
|
78
79
|
return ctx.runQuery(reference<"query">(id), params);
|
|
@@ -145,7 +146,14 @@ export function createPlatforms(
|
|
|
145
146
|
{ headers: { "Content-Type": "application/json" } },
|
|
146
147
|
);
|
|
147
148
|
} catch (error) {
|
|
148
|
-
if (error instanceof
|
|
149
|
+
if (error instanceof ConvexError)
|
|
150
|
+
return Response.json(
|
|
151
|
+
{
|
|
152
|
+
error: error.data,
|
|
153
|
+
},
|
|
154
|
+
{ status: 400 },
|
|
155
|
+
);
|
|
156
|
+
if (error instanceof SyntaxError)
|
|
149
157
|
return Response.json({ error: "invalid_request" }, { status: 400 });
|
|
150
158
|
console.error(error);
|
|
151
159
|
return Response.json({ error: "internal_error" }, { status: 500 });
|