create-disposabl-app 0.8.9 → 0.8.11
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/README.md +8 -1
- package/dist/disposabl.js +42 -42
- package/dist/index.js +1 -1
- package/dist/templates/default/bun.lock +1 -7
- package/dist/templates/default/packages/backend/README.md +4 -8
- package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +0 -67
- package/dist/templates/default/packages/backend/convex/_generated/server.d.ts +0 -9
- package/dist/templates/default/packages/backend/convex/convex.config.ts +0 -11
- package/dist/templates/default/packages/backend/convex/http.ts +1 -9
- package/dist/templates/default/packages/backend/convex/schema.ts +1 -69
- package/dist/templates/default/packages/backend/generated/openapi.json +1 -1262
- package/dist/templates/default/packages/backend/generated/pages.json +0 -4
- package/dist/templates/default/packages/backend/generated/platforms.ts +2 -20
- package/dist/templates/default/packages/backend/package.json +1 -7
- package/dist/templates/default/packages/cli/README.md +5 -1
- package/dist/templates/default/packages/cli/commands.ts +15 -8
- package/dist/templates/default/packages/cli/delete.ts +40 -31
- package/dist/templates/default/packages/skill/SKILL.md +13 -5
- package/dist/templates/default/packages/skill/references/delivery.md +1 -1
- package/package.json +1 -1
- package/dist/templates/default/packages/backend/convex/apps/actions/cleanup.ts +0 -296
- package/dist/templates/default/packages/backend/convex/apps/actions/create.ts +0 -30
- package/dist/templates/default/packages/backend/convex/apps/actions/delete.ts +0 -15
- package/dist/templates/default/packages/backend/convex/apps/actions/expo.ts +0 -174
- package/dist/templates/default/packages/backend/convex/apps/actions/setup.ts +0 -48
- package/dist/templates/default/packages/backend/convex/apps/internal.ts +0 -211
- package/dist/templates/default/packages/backend/convex/apps/operations/internal.ts +0 -213
- package/dist/templates/default/packages/backend/convex/apps/validator.ts +0 -23
- package/dist/templates/default/packages/backend/convex/connections/actions/credentials.ts +0 -56
- package/dist/templates/default/packages/backend/convex/connections/actions/expo.ts +0 -79
- package/dist/templates/default/packages/backend/convex/connections/actions/github.ts +0 -119
- package/dist/templates/default/packages/backend/convex/connections/actions/oauth.ts +0 -128
- package/dist/templates/default/packages/backend/convex/connections/index.ts +0 -80
- package/dist/templates/default/packages/backend/convex/connections/internal.ts +0 -147
- package/dist/templates/default/packages/backend/convex/connections/validator.ts +0 -35
- package/dist/templates/default/packages/backend/convex/downloads/action.ts +0 -136
- package/dist/templates/default/packages/backend/convex/downloads/http.ts +0 -32
- package/dist/templates/default/packages/backend/convex/downloads/internal.ts +0 -58
- package/dist/templates/default/packages/backend/convex/github/actions/http.ts +0 -69
- package/dist/templates/default/packages/backend/convex/github/actions/internal.ts +0 -196
- package/dist/templates/default/packages/backend/convex/github/actions/oidc.ts +0 -75
- package/dist/templates/default/packages/backend/convex/github/actions/provision.ts +0 -76
- package/dist/templates/default/packages/backend/convex/github/actions/secrets.ts +0 -180
- package/dist/templates/default/packages/backend/convex/github/actions/signing.ts +0 -41
- package/dist/templates/default/packages/backend/convex/github/actions/tokens.ts +0 -145
- package/dist/templates/default/packages/backend/convex/github/identityCache.ts +0 -54
- package/dist/templates/default/packages/backend/convex/github/internal.ts +0 -33
- package/dist/templates/default/packages/backend/convex/previews/internal.ts +0 -257
- package/dist/templates/default/packages/backend/convex/previews/token/actions/create.ts +0 -83
- package/dist/templates/default/packages/backend/convex/previews/token/actions/management.ts +0 -182
- package/dist/templates/default/packages/backend/convex/previews/token/internal.ts +0 -32
- package/dist/templates/default/packages/backend/convex/releases/internal.ts +0 -28
- package/dist/templates/default/packages/backend/convex/validator.ts +0 -87
- package/dist/templates/default/packages/sdk/src/generated/client/client.gen.ts +0 -300
- package/dist/templates/default/packages/sdk/src/generated/client/index.ts +0 -27
- package/dist/templates/default/packages/sdk/src/generated/client/types.gen.ts +0 -238
- package/dist/templates/default/packages/sdk/src/generated/client/utils.gen.ts +0 -337
- package/dist/templates/default/packages/sdk/src/generated/client.gen.ts +0 -28
- package/dist/templates/default/packages/sdk/src/generated/core/auth.gen.ts +0 -49
- package/dist/templates/default/packages/sdk/src/generated/core/bodySerializer.gen.ts +0 -96
- package/dist/templates/default/packages/sdk/src/generated/core/params.gen.ts +0 -188
- package/dist/templates/default/packages/sdk/src/generated/core/pathSerializer.gen.ts +0 -186
- package/dist/templates/default/packages/sdk/src/generated/core/queryKeySerializer.gen.ts +0 -134
- package/dist/templates/default/packages/sdk/src/generated/core/serverSentEvents.gen.ts +0 -265
- package/dist/templates/default/packages/sdk/src/generated/core/types.gen.ts +0 -126
- package/dist/templates/default/packages/sdk/src/generated/core/utils.gen.ts +0 -146
- package/dist/templates/default/packages/sdk/src/generated/index.ts +0 -63
- package/dist/templates/default/packages/sdk/src/generated/sdk.gen.ts +0 -234
- package/dist/templates/default/packages/sdk/src/generated/types.gen.ts +0 -660
|
@@ -1,21 +1,3 @@
|
|
|
1
1
|
// Generated by bun run generate. Do not edit.
|
|
2
|
-
import * as m0 from "../convex/
|
|
3
|
-
|
|
4
|
-
import * as m2 from "../convex/connections/internal";
|
|
5
|
-
import * as m3 from "../convex/downloads/internal";
|
|
6
|
-
import * as m4 from "../convex/github/internal";
|
|
7
|
-
import * as m5 from "../convex/previews/internal";
|
|
8
|
-
import * as m6 from "../convex/previews/token/internal";
|
|
9
|
-
import * as m7 from "../convex/releases/internal";
|
|
10
|
-
import * as m8 from "../convex/users/internal";
|
|
11
|
-
export default {
|
|
12
|
-
"apps/internal": m0,
|
|
13
|
-
"apps/operations/internal": m1,
|
|
14
|
-
"connections/internal": m2,
|
|
15
|
-
"downloads/internal": m3,
|
|
16
|
-
"github/internal": m4,
|
|
17
|
-
"previews/internal": m5,
|
|
18
|
-
"previews/token/internal": m6,
|
|
19
|
-
"releases/internal": m7,
|
|
20
|
-
"users/internal": m8,
|
|
21
|
-
};
|
|
2
|
+
import * as m0 from "../convex/users/internal";
|
|
3
|
+
export default { "users/internal": m0 };
|
|
@@ -16,20 +16,14 @@
|
|
|
16
16
|
"@convex-dev/auth": "catalog:",
|
|
17
17
|
"@convex-dev/mcp": "catalog:",
|
|
18
18
|
"@convex-dev/static-hosting": "catalog:",
|
|
19
|
-
"@convex-dev/workflow": "^0.4.10",
|
|
20
19
|
"@disposabl/disposabl-kit": "workspace:*",
|
|
21
|
-
"
|
|
22
|
-
"@vercel/connect": "^2.5.2",
|
|
23
|
-
"convex": "catalog:",
|
|
24
|
-
"libsodium-wrappers": "^0.8.4",
|
|
25
|
-
"node-forge": "^1.4.2"
|
|
20
|
+
"convex": "catalog:"
|
|
26
21
|
},
|
|
27
22
|
"devDependencies": {
|
|
28
23
|
"@convex-dev/eslint-plugin": "^5.0.1",
|
|
29
24
|
"@eslint/eslintrc": "^3.3.6",
|
|
30
25
|
"@eslint/js": "^10.0.1",
|
|
31
26
|
"@types/node": "^24.13.3",
|
|
32
|
-
"@types/node-forge": "^1.3.14",
|
|
33
27
|
"@typescript-eslint/eslint-plugin": "^8.66.0",
|
|
34
28
|
"@typescript-eslint/parser": "^8.66.0",
|
|
35
29
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
@@ -22,4 +22,8 @@ Credentials live under `~/.config/disposabl` with restricted file permissions. `
|
|
|
22
22
|
|
|
23
23
|
Use `--json` for machine-readable preview output. Other commands return JSON; `--help` lists their arguments.
|
|
24
24
|
|
|
25
|
-
App deletion
|
|
25
|
+
App deletion runs in the Convex action using connected provider credentials. Apps with production releases cannot be deleted. The CLI never launches EAS or asks for an Expo password.
|
|
26
|
+
|
|
27
|
+
When Expo rejects token-based deletion, the action records that Expo cleanup is pending and continues deleting GitHub and Convex. Once both are removed, it returns `expo_manual_delete_required` with the app ID, Expo project ID, and exact `projectUrl` ending in `/settings/advanced`. The CLI opens that URL in the browser and prints it. Sign in directly to Expo if needed, then use Delete project. Pass `--no-browser` to print the link without opening it.
|
|
28
|
+
|
|
29
|
+
The command exits unsuccessfully while manual cleanup is pending. Rerun the same Disposabl deletion command after deleting the Expo project. The action verifies the connected Expo account and project removal, then deletes previews and the app record. Interrupted provider cleanup remains resumable. Keep the owning accounts connected until deletion finishes; Disposabl does not accept Expo passwords or session cookies.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { completeExpoDeletion } from "./delete";
|
|
2
1
|
import { Command } from "commander";
|
|
2
|
+
import { openExpoDeletion } from "./delete";
|
|
3
3
|
import manifest from "./package.json";
|
|
4
4
|
import {
|
|
5
5
|
NotAuthenticated,
|
|
@@ -127,6 +127,11 @@ export async function runCli(
|
|
|
127
127
|
"Open Connections and continue when GitHub and Convex are connected",
|
|
128
128
|
);
|
|
129
129
|
const deleteApp = path === "/api/apps/delete";
|
|
130
|
+
if (deleteApp)
|
|
131
|
+
command.option(
|
|
132
|
+
"--no-browser",
|
|
133
|
+
"Print the Expo cleanup URL without opening a browser",
|
|
134
|
+
);
|
|
130
135
|
const previewGet = path === "/api/previews/get";
|
|
131
136
|
const tokenCreate = path === "/api/previews/token/create";
|
|
132
137
|
if (previewGet)
|
|
@@ -225,13 +230,15 @@ export async function runCli(
|
|
|
225
230
|
let result = await send();
|
|
226
231
|
if (result.status === 401 && !process.env.DISPOSABL_API_KEY)
|
|
227
232
|
result = await send(true);
|
|
228
|
-
if (deleteApp && result.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
if (deleteApp && !result.ok)
|
|
234
|
+
openExpoDeletion(
|
|
235
|
+
await result
|
|
236
|
+
.clone()
|
|
237
|
+
.json()
|
|
238
|
+
.catch(() => null),
|
|
239
|
+
options.appId,
|
|
240
|
+
options.browser !== false,
|
|
241
|
+
);
|
|
235
242
|
if (!result.ok)
|
|
236
243
|
throw new Error(
|
|
237
244
|
`API request failed (${result.status}): ${await result.text()}`,
|
|
@@ -1,39 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { openUrl } from "./auth";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
export
|
|
3
|
+
/** Only open the verified Expo project returned by the deletion action. */
|
|
4
|
+
export function openExpoDeletion(
|
|
5
|
+
body: unknown,
|
|
6
|
+
appId: string,
|
|
7
|
+
browser: boolean,
|
|
8
|
+
) {
|
|
9
|
+
if (!body || typeof body !== "object" || !("error" in body)) return;
|
|
10
|
+
const error = body.error;
|
|
5
11
|
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
!error ||
|
|
13
|
+
typeof error !== "object" ||
|
|
14
|
+
!("code" in error) ||
|
|
15
|
+
error.code !== "expo_manual_delete_required"
|
|
16
|
+
)
|
|
17
|
+
return;
|
|
18
|
+
if (
|
|
19
|
+
!("appId" in error) ||
|
|
20
|
+
error.appId !== appId ||
|
|
21
|
+
!("projectUrl" in error) ||
|
|
22
|
+
typeof error.projectUrl !== "string"
|
|
10
23
|
)
|
|
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
24
|
throw new Error(
|
|
15
|
-
|
|
25
|
+
"Invalid Expo deletion response. The app record has been kept.",
|
|
16
26
|
);
|
|
27
|
+
const url = new URL(error.projectUrl);
|
|
28
|
+
const parts = url.pathname.split("/");
|
|
29
|
+
if (
|
|
30
|
+
url.origin !== "https://expo.dev" ||
|
|
31
|
+
url.username ||
|
|
32
|
+
url.password ||
|
|
33
|
+
url.search ||
|
|
34
|
+
url.hash ||
|
|
35
|
+
parts.length !== 7 ||
|
|
36
|
+
parts[1] !== "accounts" ||
|
|
37
|
+
!parts[2] ||
|
|
38
|
+
parts[3] !== "projects" ||
|
|
39
|
+
parts[4] !== `app-${appId}` ||
|
|
40
|
+
parts[5] !== "settings" ||
|
|
41
|
+
parts[6] !== "advanced"
|
|
42
|
+
)
|
|
43
|
+
throw new Error("Invalid Expo project URL. The app record has been kept.");
|
|
17
44
|
console.error(
|
|
18
|
-
|
|
45
|
+
`GitHub and Convex cleanup is complete. Finish deleting the Expo project here:\n${url.href}\nSign in to Expo if needed and choose Delete project. Then rerun this command to verify cleanup. The Disposabl app record is still pending deletion.`,
|
|
19
46
|
);
|
|
20
|
-
|
|
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
|
-
});
|
|
47
|
+
if (browser) openUrl(url.href);
|
|
39
48
|
}
|
|
@@ -21,12 +21,10 @@ Before designing a new app, locate and read the `frontend-design` skill and use
|
|
|
21
21
|
|
|
22
22
|
Create a separate Git branch and worktree for each change. In that worktree run `disposabl previews token create --configure .`, `bun install`, and `bun dev`. Implement the request and verify the actual behavior on the requested platforms. Commit and push the branch and open a pull request when the task authorizes delivery.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
A newly generated app already has an Initial commit. Publish its scaffold to `main` first so GitHub has the trusted publishing workflow. Setup configures `origin` for the provisioned repository. Then work on the requested features in an isolated branch:
|
|
25
25
|
|
|
26
26
|
```sh
|
|
27
27
|
cd my-app
|
|
28
|
-
git add .
|
|
29
|
-
git commit -m "chore: initialize app"
|
|
30
28
|
git push -u origin main
|
|
31
29
|
git worktree add ../my-app-feature -b feat/first-version
|
|
32
30
|
cd ../my-app-feature
|
|
@@ -35,10 +33,20 @@ bun install
|
|
|
35
33
|
bun run dev
|
|
36
34
|
```
|
|
37
35
|
|
|
38
|
-
The configured token is scoped to this worktree's development backend. Never copy another worktree's environment files or use a production deploy key for development.
|
|
36
|
+
The configured token is scoped to this worktree's development backend. Never copy another worktree's environment files or use a production deploy key for development. Token provisioning or refresh alone does not deploy or require git operations. Keep credentials in ignored environment files. A branch push alone does not trigger deployment: a same-repository PR to `main` triggers the `pr-N` preview, and a push to `main` triggers production. Local development is separate; preview reports are tracked by head branch.
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
For background delivery, hand a subagent a fixed, reviewed commit snapshot in an isolated worktree. Its brief must name the repository, branch, SHA, scope, PR base, required checks, push ownership, and expected result evidence. It pushes that snapshot and opens or updates the same-repository PR while the main agent continues separately. Never sweep concurrent edits or the index, or push later commits without a new handoff. Do not block implementation on push or PR creation.
|
|
39
|
+
|
|
40
|
+
After opening the PR, run `disposabl previews get` in the worktree and check each requested platform's status and available preview, workflow, release, or download URLs. Report the deployed SHA, checks, and each platform URL and status. Readiness requires successful CI and actual endpoint or device behavior; a provisioned development URL is not a hosted preview. For Android, install the preview APK on the target and verify the requested behavior and authentication. Do not run `eas submit`. After an authorized merge, verify production status and actual URLs. If a platform or URL is missing, inspect the relevant workflow and report the gap.
|
|
41
41
|
|
|
42
42
|
Use `disposabl previews get --json` when an agent needs structured status. Query again as builds progress, respecting the host's PR watcher rules, and stop waiting when every requested platform has a terminal status. Inspect and repair failures instead of repeatedly polling an unchanged failure. After merging, run `disposabl releases get --appId <appId-from-disposabl.json>`; production results are separate from the worktree's preview. Install the production Android APK alongside its preview and verify login and saved data against the production backend. Store submission is not required for Android APK delivery. TestFlight is available only after Apple signing and App Store Connect submission credentials are configured.
|
|
43
43
|
|
|
44
44
|
When CI fails, compare the notification SHA with the current branch before editing. Diagnose the exact failed step, collect independent platform failures, and batch related fixes before pushing. A push can cancel an expensive preview build. Use available PR watchers instead of polling unchanged checks. Keep separate evidence for compilation, artifact publication, installation, and login/data persistence.
|
|
45
|
+
|
|
46
|
+
## Delete an app
|
|
47
|
+
|
|
48
|
+
When the user requests deletion, run `disposabl apps delete --appId <uuid> --dangerously-delete-app`. The Convex action deletes linked resources and retains the app record until cleanup is verified. Apps with production releases cannot be deleted.
|
|
49
|
+
|
|
50
|
+
If Expo rejects deletion with its access token, GitHub and Convex cleanup still proceeds. The response `expo_manual_delete_required` includes `projectUrl`, pointing to that exact Expo project's `/settings/advanced` page. The CLI opens it automatically; if your environment cannot show that browser, open the returned URL in the user's available browser. Never send the user to a generic dashboard or another project's settings. Expo preserves the project URL through its login flow. Tell the user to sign in directly to Expo if needed and use Delete project. Never request, collect, or pass an Expo password or session cookie.
|
|
51
|
+
|
|
52
|
+
After the user finishes on Expo, retry the same Disposabl delete command. Report full deletion only after the action verifies Expo removal and deletes the app record. While waiting, report GitHub/Convex cleanup separately from the remaining manual Expo step. `--no-browser` prints the exact URL for headless callers; API and MCP callers should present and open the returned `projectUrl` themselves.
|
|
@@ -15,7 +15,7 @@ Read before a first native build, a toolchain change, or a failed preview/produc
|
|
|
15
15
|
|
|
16
16
|
## Avoid repeating expensive work
|
|
17
17
|
|
|
18
|
-
Diagnose independent platform failures in parallel when available, with separate owners and checkouts. Keep each device and browser session under one owner. Give a delivery delegate an observable success condition, such as an uploaded artifact or a verified login on its assigned device; a commit and local checks alone do not satisfy that condition. Batch related repairs before pushing, because PR concurrency can cancel running native builds. Keep source-commit validation when publishing so an old build cannot become the current release.
|
|
18
|
+
Diagnose independent platform failures in parallel when available, with separate owners and checkouts. Keep each device and browser session under one owner. Give a delivery delegate an observable success condition, such as an uploaded artifact or a verified login on its assigned device; a commit and local checks alone do not satisfy that condition. Batch related repairs before pushing, because PR concurrency can cancel running native builds. Use host PR watchers where applicable; do not busy poll. Hand off a new reviewed SHA before pushing subsequent changes. Keep source-commit validation when publishing so an old build cannot become the current release.
|
|
19
19
|
|
|
20
20
|
Separate an application change from a starter/pipeline defect. Repair a reusable defect in the generator and the generated app. For a new repository, establish its trusted publishing workflow on `main` before the feature preview; later workflow changes must follow the repository's review and merge policy. Do not weaken workflow-source identity checks to bypass a mismatch.
|
|
21
21
|
|
package/package.json
CHANGED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
"use node";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
identityFields,
|
|
5
|
-
internalAction,
|
|
6
|
-
} from "@disposabl/disposabl-kit/server/lib/functions";
|
|
7
|
-
import { ConvexError, v } from "convex/values";
|
|
8
|
-
import { internal } from "../../_generated/api";
|
|
9
|
-
import { credential } from "../../connections/actions/credentials";
|
|
10
|
-
import { validateExpo } from "../../connections/actions/expo";
|
|
11
|
-
import {
|
|
12
|
-
GitHubError,
|
|
13
|
-
githubRequest,
|
|
14
|
-
githubToken,
|
|
15
|
-
} from "../../github/actions/tokens";
|
|
16
|
-
import {
|
|
17
|
-
ManagementError,
|
|
18
|
-
management,
|
|
19
|
-
} from "../../previews/token/actions/management";
|
|
20
|
-
import { deleteArgs } from "../validator";
|
|
21
|
-
import { ExpoLoginRequired, deleteExpo, findExpo, verifyExpo } from "./expo";
|
|
22
|
-
|
|
23
|
-
export const remove = internalAction({
|
|
24
|
-
args: { ...identityFields, ...deleteArgs },
|
|
25
|
-
returns: v.null(),
|
|
26
|
-
handler: async (ctx, { userId, appId }): Promise<null> => {
|
|
27
|
-
const identity = { userId, appId };
|
|
28
|
-
const { until, resuming, pending } = await ctx.runMutation(
|
|
29
|
-
internal.apps.operations.internal.begin,
|
|
30
|
-
{ ...identity, kind: "delete" },
|
|
31
|
-
);
|
|
32
|
-
let started = false;
|
|
33
|
-
const resume = (
|
|
34
|
-
provider: "github" | "convex" | "expo",
|
|
35
|
-
accountId: string,
|
|
36
|
-
) => {
|
|
37
|
-
if (pending?.provider !== provider) return undefined;
|
|
38
|
-
if (pending.accountId !== accountId)
|
|
39
|
-
throw new ConvexError(
|
|
40
|
-
`Reconnect the original ${provider} account to finish deleting this app.`,
|
|
41
|
-
);
|
|
42
|
-
return pending;
|
|
43
|
-
};
|
|
44
|
-
const deleting = (
|
|
45
|
-
provider: "github" | "convex" | "expo",
|
|
46
|
-
accountId: string,
|
|
47
|
-
receipt?: string,
|
|
48
|
-
) =>
|
|
49
|
-
ctx.runMutation(internal.apps.operations.internal.deletingResource, {
|
|
50
|
-
...identity,
|
|
51
|
-
until,
|
|
52
|
-
pending: { provider, accountId, ...(receipt ? { receipt } : {}) },
|
|
53
|
-
});
|
|
54
|
-
const forget = (provider: "github" | "convex" | "expo") =>
|
|
55
|
-
ctx.runMutation(internal.apps.operations.internal.forget, {
|
|
56
|
-
...identity,
|
|
57
|
-
until,
|
|
58
|
-
provider,
|
|
59
|
-
});
|
|
60
|
-
try {
|
|
61
|
-
const linked = await ctx.runQuery(
|
|
62
|
-
internal.apps.operations.internal.linked,
|
|
63
|
-
identity,
|
|
64
|
-
);
|
|
65
|
-
// Preflight every provider before deleting anything. Missing access is never success.
|
|
66
|
-
let github:
|
|
67
|
-
| { token: string; path: string; accountId: string; absent: boolean }
|
|
68
|
-
| undefined;
|
|
69
|
-
if (linked.githubRepo) {
|
|
70
|
-
const app = await ctx.runQuery(internal.apps.internal.githubApp, {
|
|
71
|
-
appId,
|
|
72
|
-
});
|
|
73
|
-
if (!app)
|
|
74
|
-
throw new ConvexError(
|
|
75
|
-
"Reconnect the GitHub account that owns this app before deleting it.",
|
|
76
|
-
);
|
|
77
|
-
const repository = `${app.githubOwner}/${app.githubRepo}`;
|
|
78
|
-
const retry = resume("github", app.githubOwner);
|
|
79
|
-
// An installation-wide token remains usable after this repository is deleted.
|
|
80
|
-
const token = await githubToken(
|
|
81
|
-
ctx,
|
|
82
|
-
app.installationId,
|
|
83
|
-
["administration:write", "contents:read", "actions:read"],
|
|
84
|
-
retry ? undefined : repository,
|
|
85
|
-
);
|
|
86
|
-
const path = `/repos/${repository}`;
|
|
87
|
-
let absent = false;
|
|
88
|
-
try {
|
|
89
|
-
const repo = await githubRequest<{
|
|
90
|
-
full_name: string;
|
|
91
|
-
description: string;
|
|
92
|
-
}>(token, path);
|
|
93
|
-
if (
|
|
94
|
-
repo.full_name.toLowerCase() !== repository.toLowerCase() ||
|
|
95
|
-
repo.description !== `Disposabl app ${appId}`
|
|
96
|
-
)
|
|
97
|
-
throw new ConvexError(
|
|
98
|
-
"The GitHub repository does not match this app. No resources were deleted.",
|
|
99
|
-
);
|
|
100
|
-
} catch (error) {
|
|
101
|
-
if (!retry || !(error instanceof GitHubError) || error.status !== 404)
|
|
102
|
-
throw error;
|
|
103
|
-
await githubRequest(token, "/installation/repositories?per_page=1");
|
|
104
|
-
absent = true;
|
|
105
|
-
}
|
|
106
|
-
if (!absent) {
|
|
107
|
-
for (let page = 1; ; page++) {
|
|
108
|
-
const releases = await githubRequest<
|
|
109
|
-
{ draft: boolean; prerelease: boolean }[]
|
|
110
|
-
>(token, `${path}/releases?per_page=100&page=${page}`);
|
|
111
|
-
if (
|
|
112
|
-
releases.some((release) => !release.draft && !release.prerelease)
|
|
113
|
-
)
|
|
114
|
-
throw new ConvexError(
|
|
115
|
-
"Apps with production releases cannot be deleted.",
|
|
116
|
-
);
|
|
117
|
-
if (releases.length < 100) break;
|
|
118
|
-
}
|
|
119
|
-
for (const status of [
|
|
120
|
-
"queued",
|
|
121
|
-
"in_progress",
|
|
122
|
-
"waiting",
|
|
123
|
-
"pending",
|
|
124
|
-
"requested",
|
|
125
|
-
]) {
|
|
126
|
-
const runs = await githubRequest<{ total_count: number }>(
|
|
127
|
-
token,
|
|
128
|
-
`${path}/actions/runs?status=${status}&per_page=1`,
|
|
129
|
-
);
|
|
130
|
-
if (runs.total_count)
|
|
131
|
-
throw new ConvexError(
|
|
132
|
-
"Wait for this app's GitHub Actions to finish before deleting it.",
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
github = { token, path, accountId: app.githubOwner, absent };
|
|
137
|
-
}
|
|
138
|
-
let convex:
|
|
139
|
-
| {
|
|
140
|
-
token: string;
|
|
141
|
-
projectId: number;
|
|
142
|
-
accountId: string;
|
|
143
|
-
absent: boolean;
|
|
144
|
-
}
|
|
145
|
-
| undefined;
|
|
146
|
-
if (linked.convexProjectId !== undefined) {
|
|
147
|
-
const connection = await credential(ctx, userId, "convex");
|
|
148
|
-
const retry = resume("convex", connection.accountId);
|
|
149
|
-
let absent = false;
|
|
150
|
-
try {
|
|
151
|
-
const project = await management<{
|
|
152
|
-
id: number;
|
|
153
|
-
name: string;
|
|
154
|
-
teamId: number;
|
|
155
|
-
}>(connection.token, `/projects/${linked.convexProjectId}`);
|
|
156
|
-
if (
|
|
157
|
-
project.id !== linked.convexProjectId ||
|
|
158
|
-
String(project.teamId) !== connection.accountId ||
|
|
159
|
-
project.name !== `disposabl-${appId}`
|
|
160
|
-
)
|
|
161
|
-
throw new ConvexError(
|
|
162
|
-
"The Convex project does not match this app and connected team.",
|
|
163
|
-
);
|
|
164
|
-
} catch (error) {
|
|
165
|
-
if (
|
|
166
|
-
!retry ||
|
|
167
|
-
!(error instanceof ManagementError) ||
|
|
168
|
-
error.status !== 404
|
|
169
|
-
)
|
|
170
|
-
throw error;
|
|
171
|
-
await management(
|
|
172
|
-
connection.token,
|
|
173
|
-
`/teams/${connection.accountId}/projects?limit=1`,
|
|
174
|
-
);
|
|
175
|
-
absent = true;
|
|
176
|
-
}
|
|
177
|
-
convex = {
|
|
178
|
-
token: connection.token,
|
|
179
|
-
projectId: linked.convexProjectId,
|
|
180
|
-
accountId: connection.accountId,
|
|
181
|
-
absent,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
if (linked.expoAccountId === undefined && linked.githubRepo) {
|
|
185
|
-
const app = await ctx.runQuery(internal.apps.internal.get, identity);
|
|
186
|
-
if (
|
|
187
|
-
app.platforms.some(
|
|
188
|
-
(platform) => platform === "android" || platform === "ios",
|
|
189
|
-
)
|
|
190
|
-
)
|
|
191
|
-
throw new ConvexError(
|
|
192
|
-
"This older app has no recorded Expo ownership. Link its original Expo project before deleting it.",
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
let expo:
|
|
196
|
-
| {
|
|
197
|
-
token: string;
|
|
198
|
-
projectId?: string;
|
|
199
|
-
accountId: string;
|
|
200
|
-
receipt?: string;
|
|
201
|
-
}
|
|
202
|
-
| undefined;
|
|
203
|
-
if (linked.expoAccountId || linked.expoProjectId) {
|
|
204
|
-
const connection = await credential(ctx, userId, "expo");
|
|
205
|
-
const retry = resume("expo", connection.accountId);
|
|
206
|
-
if (
|
|
207
|
-
linked.expoAccountId !== connection.accountId ||
|
|
208
|
-
!(await validateExpo(connection.token)).some(
|
|
209
|
-
(account) => account.id === connection.accountId,
|
|
210
|
-
)
|
|
211
|
-
)
|
|
212
|
-
throw new ConvexError(
|
|
213
|
-
"Reconnect the Expo account that owns this app.",
|
|
214
|
-
);
|
|
215
|
-
const project = await findExpo(
|
|
216
|
-
connection.token,
|
|
217
|
-
`@${connection.name}/app-${appId}`,
|
|
218
|
-
linked.expoProjectId,
|
|
219
|
-
);
|
|
220
|
-
if (project) verifyExpo(project, connection.accountId, appId);
|
|
221
|
-
if (!project && linked.expoProjectId && !retry)
|
|
222
|
-
throw new ConvexError(
|
|
223
|
-
"The linked Expo project is unavailable. Reconnect its owner before deleting this app.",
|
|
224
|
-
);
|
|
225
|
-
expo = {
|
|
226
|
-
token: connection.token,
|
|
227
|
-
projectId: project?.id,
|
|
228
|
-
accountId: connection.accountId,
|
|
229
|
-
receipt: retry?.receipt,
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
started = true;
|
|
233
|
-
if (expo) {
|
|
234
|
-
// Resume the receipt even if Expo has already removed the project from lookup.
|
|
235
|
-
if (expo.projectId || expo.receipt) {
|
|
236
|
-
await deleting("expo", expo.accountId, expo.receipt);
|
|
237
|
-
try {
|
|
238
|
-
await deleteExpo(
|
|
239
|
-
expo.token,
|
|
240
|
-
expo.projectId ?? linked.expoProjectId!,
|
|
241
|
-
expo.receipt,
|
|
242
|
-
async (receipt) => {
|
|
243
|
-
await deleting("expo", expo.accountId, receipt);
|
|
244
|
-
},
|
|
245
|
-
);
|
|
246
|
-
} catch (error) {
|
|
247
|
-
if (error instanceof ExpoLoginRequired)
|
|
248
|
-
throw new ConvexError({
|
|
249
|
-
code: "expo_delete_requires_login",
|
|
250
|
-
projectId: expo.projectId ?? linked.expoProjectId!,
|
|
251
|
-
message:
|
|
252
|
-
"Expo requires a signed-in user and password confirmation to delete projects. Complete Expo deletion, then retry this command.",
|
|
253
|
-
});
|
|
254
|
-
throw error;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
await forget("expo");
|
|
258
|
-
}
|
|
259
|
-
if (github) {
|
|
260
|
-
await deleting("github", github.accountId);
|
|
261
|
-
if (!github.absent)
|
|
262
|
-
await githubRequest(github.token, github.path, undefined, "DELETE");
|
|
263
|
-
await forget("github");
|
|
264
|
-
}
|
|
265
|
-
if (convex) {
|
|
266
|
-
await deleting("convex", convex.accountId);
|
|
267
|
-
if (!convex.absent)
|
|
268
|
-
await management(
|
|
269
|
-
convex.token,
|
|
270
|
-
`/projects/${convex.projectId}/delete`,
|
|
271
|
-
{},
|
|
272
|
-
);
|
|
273
|
-
await forget("convex");
|
|
274
|
-
}
|
|
275
|
-
while (
|
|
276
|
-
!(await ctx.runMutation(internal.apps.operations.internal.erase, {
|
|
277
|
-
...identity,
|
|
278
|
-
until,
|
|
279
|
-
}))
|
|
280
|
-
) {
|
|
281
|
-
/* Delete previews in bounded batches. */
|
|
282
|
-
}
|
|
283
|
-
return null;
|
|
284
|
-
} catch (error) {
|
|
285
|
-
await ctx.runMutation(internal.apps.operations.internal.finish, {
|
|
286
|
-
...identity,
|
|
287
|
-
until,
|
|
288
|
-
retryDelete: started || resuming,
|
|
289
|
-
});
|
|
290
|
-
if (error instanceof ConvexError) throw error;
|
|
291
|
-
throw new ConvexError(
|
|
292
|
-
"App deletion could not finish. Check your connected accounts, then retry apps delete with --dangerously-delete-app. The app record has been kept.",
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
identityFields,
|
|
3
|
-
internalAction,
|
|
4
|
-
} from "@disposabl/disposabl-kit/server/lib/functions";
|
|
5
|
-
import { internal } from "../../_generated/api";
|
|
6
|
-
import { appArgs, appResult } from "../../validator";
|
|
7
|
-
import { ConvexError } from "convex/values";
|
|
8
|
-
import type { Infer } from "convex/values";
|
|
9
|
-
type AppResult = Infer<typeof appResult>;
|
|
10
|
-
|
|
11
|
-
export const create = internalAction({
|
|
12
|
-
platforms: true,
|
|
13
|
-
args: { ...identityFields, ...appArgs },
|
|
14
|
-
returns: appResult,
|
|
15
|
-
handler: async (ctx, args): Promise<AppResult> => {
|
|
16
|
-
const connections = await ctx.runQuery(
|
|
17
|
-
internal.connections.internal.status,
|
|
18
|
-
{ userId: args.userId },
|
|
19
|
-
);
|
|
20
|
-
if (!connections.ready)
|
|
21
|
-
throw new ConvexError(
|
|
22
|
-
"Connect GitHub and Convex at https://www.disposabl.dev/dashboard/connections, then retry setup. Your login remains active.",
|
|
23
|
-
);
|
|
24
|
-
// Return the UUID before external setup so the CLI can save it and resume safely.
|
|
25
|
-
return ctx.runMutation(internal.apps.internal.insert, {
|
|
26
|
-
...args,
|
|
27
|
-
appId: crypto.randomUUID(),
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
identityFields,
|
|
3
|
-
internalAction,
|
|
4
|
-
} from "@disposabl/disposabl-kit/server/lib/functions";
|
|
5
|
-
import { v } from "convex/values";
|
|
6
|
-
import { internal } from "../../_generated/api";
|
|
7
|
-
import { deleteArgs } from "../validator";
|
|
8
|
-
|
|
9
|
-
export const remove = internalAction({
|
|
10
|
-
platforms: true,
|
|
11
|
-
args: { ...identityFields, ...deleteArgs },
|
|
12
|
-
returns: v.null(),
|
|
13
|
-
handler: async (ctx, args): Promise<null> =>
|
|
14
|
-
ctx.runAction(internal.apps.actions.cleanup.remove, args),
|
|
15
|
-
});
|