create-disposabl-app 1.1.4 → 1.3.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/README.md CHANGED
@@ -3,20 +3,29 @@
3
3
  Run the Exact starter generator with Node.js 22.12 or newer, Git, and Bun.
4
4
 
5
5
  ```sh
6
- npx create-disposabl-app my-app
6
+ bunx create-disposabl-app@latest my-app
7
+ cd my-app
8
+ bun run dev
7
9
  ```
8
10
 
9
- npm installs `@disposabl/cli` with the generator. Sign in to Disposabl and connect GitHub and Convex when prompted. The CLI provisions a repository, a Convex project with a development deployment, and the GitHub Actions Convex deploy key. The generated checkout has that repository as its `origin` and local Convex settings for its backend and Exact app.
11
+ The generator installs `@disposabl/cli` as a development dependency in the new app root. Sign in to Disposabl and connect GitHub and Convex when prompted. The CLI provisions a repository, a Convex project with a development deployment, and the GitHub Actions Convex deploy key. The generated checkout has that repository as its `origin` and local Convex settings for its backend and Exact app.
10
12
 
11
13
  The default project enables web and authentication. Choose platforms and features at the prompts or pass comma-separated lists for unattended setup.
12
14
 
13
15
  ```sh
14
- npx create-disposabl-app my-app --platforms web,ios --features authentication,payments
16
+ bunx create-disposabl-app@latest my-app --platforms web,ios --features authentication,payments
15
17
  ```
16
18
 
17
19
  The generator saves your selections in `disposabl.json`. The provisioning API uses web to create the repository and Convex project. Deployment uses the platforms and features in the generated file. Use `--features ""` for an app without sign-in or billing.
18
20
 
19
- Run the same command with `--resume` and the app name if setup stops partway. Edit `disposabl.json` to change selections before resuming. Use `--skip-setup` to create the files without provisioning a repository or deployment. To run the shared CLI directly, use `npx --package @disposabl/cli disposabl --help`.
21
+ Run the same command with `--resume` and the app name if setup stops partway. Edit `disposabl.json` to change selections before resuming. Use `--skip-setup` to create the files without provisioning a repository or deployment. Run the project CLI with `bun run disposabl --help`.
22
+
23
+ ## Project skills
24
+
25
+ New projects start with empty skill folders at `.agents/skills` for Codex and `.claude/skills` for Claude Code.
26
+
27
+ 1. To ship a skill with future projects, add `packages/skills/<skill-name>/SKILL.md` in this repository.
28
+ 2. Stage the file and run `bun run test` from this package. The generator copies tracked skill files into both folders.
20
29
 
21
30
  ## Reset to the clean starter
22
31
 
package/index.mjs CHANGED
@@ -2,13 +2,18 @@
2
2
  import { randomBytes } from "node:crypto";
3
3
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
4
  import { join, resolve } from "node:path";
5
- import { createInterface } from "node:readline/promises";
6
5
  import { parseArgs } from "node:util";
7
6
  import { extract } from "tar";
8
7
  import lockfile from "proper-lockfile";
9
8
  import { features, platforms, readProjectConfig } from "./platform-config.mjs";
10
9
  import { git, readJson, setup, writeJson } from "./setup.mjs";
11
10
 
11
+ import { createTerminal } from "./terminal.mjs";
12
+
13
+ const terminal = createTerminal();
14
+ const nameError = "Provide an app name of up to 55 lowercase letters, numbers and hyphens.";
15
+ const validName = name => typeof name === "string" && name.length <= 55 && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name);
16
+
12
17
  const help = `Usage: create-disposabl-app [app-name] [options]
13
18
 
14
19
  Create an Exact and Convex project. Web and authentication are the defaults.
@@ -22,18 +27,11 @@ Setup uses @disposabl/cli to provision GitHub and Convex.
22
27
  --help Show this message.`;
23
28
 
24
29
  async function getName(positionals) {
25
- if (positionals.length === 0 && process.stdin.isTTY) {
26
- const prompt = createInterface({ input: process.stdin, output: process.stdout });
27
- try {
28
- positionals.push((await prompt.question("App name: ")).trim());
29
- } finally {
30
- prompt.close();
31
- }
30
+ if (positionals.length === 0 && terminal.interactive) {
31
+ return terminal.name(name => validName(name) ? undefined : nameError);
32
32
  }
33
33
  const [name] = positionals;
34
- if (positionals.length !== 1 || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name) || name.length > 55) {
35
- throw new Error("Provide an app name of up to 55 lowercase letters, numbers and hyphens.");
36
- }
34
+ if (positionals.length !== 1 || !validName(name)) throw new Error(nameError);
37
35
  return name;
38
36
  }
39
37
 
@@ -54,19 +52,12 @@ function parseSelection(value) {
54
52
 
55
53
  async function selectConfig(path, options) {
56
54
  const config = await readJson(path);
57
- let prompt;
58
- try {
59
- for (const [key, choices] of [["platforms", platforms], ["features", features]]) {
60
- if (options[key] !== undefined) {
61
- config[key] = parseSelection(options[key]);
62
- } else if (process.stdin.isTTY) {
63
- prompt ??= createInterface({ input: process.stdin, output: process.stdout });
64
- const answer = await prompt.question(`Choose ${key} (${choices.join(", ")} or none) [${config[key].join(", ")}]: `);
65
- if (answer.trim()) config[key] = parseSelection(answer);
66
- }
55
+ for (const [key, choices] of [["platforms", platforms], ["features", features]]) {
56
+ if (options[key] !== undefined) {
57
+ config[key] = parseSelection(options[key]);
58
+ } else if (terminal.interactive) {
59
+ config[key] = await terminal.select(key, choices, config[key]);
67
60
  }
68
- } finally {
69
- prompt?.close();
70
61
  }
71
62
  readProjectConfig(config);
72
63
  await writeJson(path, config);
@@ -116,6 +107,7 @@ async function main() {
116
107
  if (values.resume && (values.platforms !== undefined || values.features !== undefined)) {
117
108
  throw new Error("Edit disposabl.json before resuming setup.");
118
109
  }
110
+ terminal.intro(values.resume);
119
111
  const name = await getName(positionals);
120
112
  const directory = resolve(name);
121
113
  if (!values.resume) await createProject(directory, name, values);
@@ -130,18 +122,18 @@ async function main() {
130
122
  try {
131
123
  const config = await readJson(configPath);
132
124
  readProjectConfig(config);
125
+ await terminal.install(directory, config);
133
126
  if (!values["skip-setup"]) await setup(directory, app.name, config);
134
127
  } catch (error) {
135
128
  throw new Error(`${error.message}\nFiles are in ${directory}. Rerun the generator with --resume.`);
136
129
  } finally {
137
130
  await release();
138
131
  }
139
- console.log(`Created ${directory}\nSee README.md for local development and deployment.`);
132
+ terminal.complete(directory);
140
133
  }
141
134
 
142
135
  try {
143
136
  await main();
144
137
  } catch (error) {
145
- console.error(error.message);
146
- process.exitCode = 1;
138
+ process.exitCode = terminal.fail(error);
147
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-disposabl-app",
3
- "version": "1.1.4",
3
+ "version": "1.3.0",
4
4
  "description": "Create a Disposabl app with Exact and Convex",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/disposabl-dev/disposabl-exact/tree/main/packages/create-disposabl-app#readme",
@@ -18,6 +18,7 @@
18
18
  "files": [
19
19
  "index.mjs",
20
20
  "setup.mjs",
21
+ "terminal.mjs",
21
22
  "platform-config.mjs",
22
23
  "template.tar.gz"
23
24
  ],
@@ -25,7 +26,7 @@
25
26
  "node": ">=22.12.0"
26
27
  },
27
28
  "dependencies": {
28
- "@disposabl/cli": "4.1.0",
29
+ "@clack/prompts": "1.8.1",
29
30
  "proper-lockfile": "4.1.2",
30
31
  "tar": "7.5.23"
31
32
  },
package/setup.mjs CHANGED
@@ -4,9 +4,6 @@ import { readFile, rename, rm, writeFile } from "node:fs/promises";
4
4
  import { createRequire } from "node:module";
5
5
  import { dirname, join } from "node:path";
6
6
 
7
- const require = createRequire(import.meta.url);
8
- const cliManifest = require.resolve("@disposabl/cli/package.json");
9
- const cli = join(dirname(cliManifest), require(cliManifest).bin.disposabl);
10
7
  const defaultOrigin = "https://www.disposabl.dev";
11
8
  const web = JSON.stringify(["web"]);
12
9
 
@@ -25,6 +22,9 @@ export async function writeJson(path, value) {
25
22
  }
26
23
 
27
24
  async function runCli(directory, origin, args, interactive = false) {
25
+ const require = createRequire(join(directory, "package.json"));
26
+ const manifest = require.resolve("@disposabl/cli/package.json");
27
+ const cli = join(dirname(manifest), require(manifest).bin.disposabl);
28
28
  const output = await new Promise((resolve, reject) => {
29
29
  const child = spawn(process.execPath, [cli, ...args], {
30
30
  cwd: directory,
package/template.tar.gz CHANGED
Binary file
package/terminal.mjs ADDED
@@ -0,0 +1,80 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { basename } from "node:path";
4
+ import * as prompts from "@clack/prompts";
5
+
6
+ const exec = promisify(execFile);
7
+
8
+ class PromptCancelled extends Error {}
9
+
10
+ function answer(value) {
11
+ if (prompts.isCancel(value)) throw new PromptCancelled("Cancelled.");
12
+ return value;
13
+ }
14
+
15
+ const labels = {
16
+ web: "Web",
17
+ android: "Android",
18
+ ios: "iOS",
19
+ macos: "macOS",
20
+ api: "API",
21
+ mcp: "MCP",
22
+ cli: "CLI",
23
+ "typescript-sdk": "TypeScript SDK",
24
+ authentication: "Authentication",
25
+ payments: "Payments",
26
+ };
27
+
28
+ export function createTerminal() {
29
+ const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
30
+ return {
31
+ interactive,
32
+ intro(resume) {
33
+ if (interactive) prompts.intro(resume ? "Resume Exact setup" : "Create a Disposabl app with Exact");
34
+ },
35
+ async name(validate) {
36
+ return answer(await prompts.text({
37
+ message: "App name",
38
+ placeholder: "my-app",
39
+ validate: value => validate((value ?? "").trim()),
40
+ })).trim();
41
+ },
42
+ async select(key, choices, defaults) {
43
+ return answer(await prompts.multiselect({
44
+ message: `Choose ${key}`,
45
+ options: choices.map(value => ({ value, label: labels[value] ?? value })),
46
+ initialValues: defaults,
47
+ required: false,
48
+ }));
49
+ },
50
+ async install(directory, config) {
51
+ const progress = interactive ? prompts.spinner() : null;
52
+ if (interactive) {
53
+ const names = ids => ids.map(id => labels[id] ?? id).join(", ") || "None";
54
+ prompts.note([
55
+ `App ${basename(directory)}`,
56
+ `Platforms ${names(config.platforms)}`,
57
+ `Features ${names(config.features)}`,
58
+ ].join("\n"), "Project setup");
59
+ }
60
+ progress?.start("Installing project dependencies");
61
+ try {
62
+ await exec("bun", ["install", "--frozen-lockfile"], { cwd: directory });
63
+ progress?.stop("Project dependencies installed");
64
+ } catch (error) {
65
+ progress?.stop("Dependency installation failed");
66
+ throw error;
67
+ }
68
+ },
69
+ complete(directory) {
70
+ const message = `Created ${directory}\n\ncd ${basename(directory)}\nbun run dev`;
71
+ if (interactive) prompts.outro(message);
72
+ else console.log(message);
73
+ },
74
+ fail(error) {
75
+ if (interactive) prompts.cancel(error.message);
76
+ else console.error(error.message);
77
+ return error instanceof PromptCancelled ? 130 : 1;
78
+ },
79
+ };
80
+ }