create-marcapony-app 0.1.0 → 0.1.1

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
@@ -1,39 +1,37 @@
1
1
  # create-marcapony-app
2
2
 
3
- Scaffolds a Marcapony app: a Cloudflare Worker that talks to the Marcapony API
4
- through the SDK, plus a React UI served as static assets.
3
+ Creates a new Marcapony app — a small web app with its own backend, already
4
+ connected to your Marcapony account.
5
5
 
6
6
  ```sh
7
- bunx create-marcapony-app my-app
7
+ npx create-marcapony-app my-app
8
8
  cd my-app
9
9
  bun install
10
- bunx marcapony app link
10
+ npx marcapony app link
11
11
  bun run dev
12
12
  ```
13
13
 
14
14
  When it is ready:
15
15
 
16
16
  ```sh
17
- bunx marcapony app deploy
17
+ npx marcapony app deploy
18
18
  ```
19
19
 
20
- No wrangler, no Cloudflare account, no git. The platform builds nothing for you
21
- locally and hosts the result.
20
+ Marcapony hosts it. There is nothing to set up and no other account to sign up
21
+ for.
22
22
 
23
23
  ## What you get
24
24
 
25
- | Path | What it is |
26
- | ------------------------- | ------------------------------------------------ |
27
- | `src/server/index.ts` | The Worker. Only `/api/*` reaches it |
28
- | `src/server/marcapony.ts` | The only place that builds the Marcapony client |
29
- | `src/ui/` | React app, built to `dist/client` |
30
- | `marcapony.json` | How the platform builds and uploads the project |
31
- | `.gitignore` | Already ignores `.dev.vars`, before a key exists |
25
+ | Path | What it is |
26
+ | ------------------------- | ------------------------------------------- |
27
+ | `src/server/index.ts` | Your backend. Handles `/api/*` |
28
+ | `src/server/marcapony.ts` | The only place that talks to Marcapony |
29
+ | `src/ui/` | Your interface |
30
+ | `marcapony.json` | How Marcapony builds and publishes your app |
32
31
 
33
- The generated project has no `wrangler` dependency and no wrangler config. Local
34
- dev runs the server under Bun; the deployed app runs on the Workers runtime. They
35
- are close but not identical, so the generated README says to prefer plain web
36
- APIs in `src/server` and to check the app after deploying a server change.
32
+ `npx marcapony app link` puts your app key in place and writes an `AGENTS.md`
33
+ listing exactly what this app is allowed to do — so an AI assistant can pick the
34
+ project up and start building on it.
37
35
 
38
36
  ## Options
39
37
 
@@ -42,11 +40,11 @@ APIs in `src/server` and to check the app after deploying a server change.
42
40
  | `--force` | Write into the directory even if it already has files |
43
41
  | `-h` | Help |
44
42
 
45
- Run without a directory argument and it asks for one.
43
+ Run without a directory name and it asks for one.
46
44
 
47
- Requires Node ≥ 20 (or Bun). Zero runtime dependencies.
45
+ Requires Node 20 or newer, or Bun. No runtime dependencies.
48
46
 
49
47
  ## License
50
48
 
51
- Proprietary tool, unrestricted output — the project it generates is yours to
52
- license and ship however you like. See [LICENSE.md](./LICENSE.md).
49
+ Proprietary tool, unrestricted output — the app it creates is yours to license
50
+ and ship however you like. See [LICENSE.md](./LICENSE.md).
package/dist/index.d.ts CHANGED
@@ -12,10 +12,19 @@ export interface ParsedArgs {
12
12
  help: boolean;
13
13
  }
14
14
  export declare function parseArgs(argv: string[]): ParsedArgs;
15
- export declare const HELP = "create-marcapony-app \u2014 scaffold a Marcapony app\n\nUsage\n bunx create-marcapony-app [directory] [--force]\n\nOptions\n --force Write into the directory even if it already has files\n -h Show this help\n\nNext, in the new directory:\n bunx marcapony app link get this app's key\n bun run dev run it locally\n bunx marcapony app deploy put it live\n";
15
+ export declare const HELP = "create-marcapony-app \u2014 scaffold a Marcapony app\n\nUsage\n npx create-marcapony-app [directory] [--force]\n\nOptions\n --force Write into the directory even if it already has files\n -h Show this help\n\nNext, in the new directory:\n npx marcapony app link get this app's key\n bun run dev run it locally\n npx marcapony app deploy put it live\n";
16
16
  export declare function nextSteps(dir: string): string;
17
17
  /** Resolve `template/` relative to the compiled entry, not the cwd. */
18
18
  export declare function templateRoot(moduleUrl: string): string;
19
+ /**
20
+ * Copy the template, never overwriting a file that is already there.
21
+ *
22
+ * That matters most with `--force`, which is how someone lands here with a
23
+ * directory that already has content. Clobbering would destroy exactly the files
24
+ * you cannot get back: `.dev.vars` holds a key the platform will not show again,
25
+ * and `marcapony.json` holds the app slug `marcapony app link` wrote. Filling in
26
+ * only what is missing is both safer and the more useful meaning of --force.
27
+ */
19
28
  export declare function copyTemplate(from: string, to: string): void;
20
29
  export declare function applyPackageName(dir: string, name: string): void;
21
30
  export declare function run(argv: string[], moduleUrl: string): Promise<number>;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, writeFileSync, } from 'node:fs';
2
+ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
3
3
  import { basename, dirname, join, resolve } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { createInterface } from 'node:readline/promises';
@@ -54,16 +54,16 @@ export function parseArgs(argv) {
54
54
  export const HELP = `create-marcapony-app — scaffold a Marcapony app
55
55
 
56
56
  Usage
57
- bunx create-marcapony-app [directory] [--force]
57
+ npx create-marcapony-app [directory] [--force]
58
58
 
59
59
  Options
60
60
  --force Write into the directory even if it already has files
61
61
  -h Show this help
62
62
 
63
63
  Next, in the new directory:
64
- bunx marcapony app link get this app's key
64
+ npx marcapony app link get this app's key
65
65
  bun run dev run it locally
66
- bunx marcapony app deploy put it live
66
+ npx marcapony app deploy put it live
67
67
  `;
68
68
  export function nextSteps(dir) {
69
69
  return [
@@ -73,11 +73,11 @@ export function nextSteps(dir) {
73
73
  'Next:',
74
74
  ` cd ${dir}`,
75
75
  ' bun install',
76
- ' bunx marcapony app link # writes your app key into .dev.vars',
76
+ ' npx marcapony app link # writes your app key into .dev.vars',
77
77
  ' bun run dev',
78
78
  '',
79
79
  'When it is ready:',
80
- ' bunx marcapony app deploy',
80
+ ' npx marcapony app deploy',
81
81
  '',
82
82
  ].join('\n');
83
83
  }
@@ -85,13 +85,46 @@ export function nextSteps(dir) {
85
85
  export function templateRoot(moduleUrl) {
86
86
  return resolve(dirname(fileURLToPath(moduleUrl)), '..', 'template');
87
87
  }
88
+ /**
89
+ * Copy the template, never overwriting a file that is already there.
90
+ *
91
+ * That matters most with `--force`, which is how someone lands here with a
92
+ * directory that already has content. Clobbering would destroy exactly the files
93
+ * you cannot get back: `.dev.vars` holds a key the platform will not show again,
94
+ * and `marcapony.json` holds the app slug `marcapony app link` wrote. Filling in
95
+ * only what is missing is both safer and the more useful meaning of --force.
96
+ */
88
97
  export function copyTemplate(from, to) {
89
98
  mkdirSync(to, { recursive: true });
90
- cpSync(from, to, { recursive: true });
99
+ cpSync(from, to, {
100
+ recursive: true,
101
+ force: false,
102
+ errorOnExist: false,
103
+ // Skip a template file when its destination — under the name it will
104
+ // actually land as — already exists.
105
+ filter: (source) => {
106
+ const relative = source.slice(from.length).replace(/^[/\\]/, '');
107
+ if (relative.length === 0)
108
+ return true;
109
+ const segments = relative.split(/[/\\]/);
110
+ const last = segments[segments.length - 1];
111
+ if (last === undefined)
112
+ return true;
113
+ segments[segments.length - 1] = templateTargetName(last);
114
+ return !existsSync(join(to, ...segments));
115
+ },
116
+ });
91
117
  for (const [source, target] of Object.entries(TEMPLATE_RENAMES)) {
92
118
  const sourcePath = join(to, source);
93
- if (existsSync(sourcePath))
94
- renameSync(sourcePath, join(to, target));
119
+ if (!existsSync(sourcePath))
120
+ continue;
121
+ const targetPath = join(to, target);
122
+ if (existsSync(targetPath)) {
123
+ // The real name was already present, so the underscore copy is redundant.
124
+ rmSync(sourcePath);
125
+ continue;
126
+ }
127
+ renameSync(sourcePath, targetPath);
95
128
  }
96
129
  }
97
130
  export function applyPackageName(dir, name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-marcapony-app",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Scaffold a Marcapony app — a Worker backed by the Marcapony API, ready for `marcapony app link` and `marcapony app deploy`",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -1,19 +1,18 @@
1
1
  # Marcapony app
2
2
 
3
- A Worker that serves this app's API and talks to Marcapony, plus a React UI
4
- served as static assets.
3
+ A small web app with its own backend, connected to your Marcapony account.
5
4
 
6
5
  ## Get a key
7
6
 
8
7
  ```sh
9
- bunx marcapony app link
8
+ npx marcapony app link
10
9
  ```
11
10
 
12
- Create the app under **My Apps** in your Marcapony dashboard, generate a pairing
13
- code there, and paste it when asked. The CLI writes `MARCAPONY_API_KEY` into
14
- `.dev.vars` itself — the key is never shown and never goes through a clipboard.
15
- It also fills in `AGENTS.md` with the exact operations your key can perform, so
16
- your AI assistant knows what this app is allowed to do.
11
+ Create the app under **My Apps** in your Marcapony dashboard, generate a
12
+ connection code there, and paste it when asked. The key is written into
13
+ `.dev.vars` for you — it is never shown and never goes through your clipboard.
14
+ An `AGENTS.md` is written too, listing exactly what this app is allowed to do, so
15
+ your AI assistant knows what it can build.
17
16
 
18
17
  ## Develop
19
18
 
@@ -22,38 +21,37 @@ bun install
22
21
  bun run dev
23
22
  ```
24
23
 
25
- Vite serves the UI and proxies `/api` to the Hono app in `src/server`.
24
+ Your interface and your `/api` routes both run locally.
26
25
 
27
- One thing to know: `bun run dev` runs the server under Bun, while the deployed
28
- app runs on the Workers runtime. They are close but not identical, so prefer
29
- plain web APIs (`fetch`, `Request`, `Response`, `crypto`) over Node built-ins in
30
- `src/server`, and check the deployed app after shipping a server change.
26
+ One thing to know: local development and the published app run in slightly
27
+ different environments. Stick to standard web APIs in `src/server` — `fetch`,
28
+ `Request`, `Response`, `crypto` — since those behave identically in both, and
29
+ check the published app after you change something on the backend.
31
30
 
32
- ## Deploy
31
+ ## Publish
33
32
 
34
33
  ```sh
35
- bunx marcapony app deploy
34
+ npx marcapony app deploy
36
35
  ```
37
36
 
38
- That builds the project, uploads it, and prints the hostname when it is live.
39
- There is no wrangler and no Cloudflare account involved — the platform runs it
40
- for you, injecting the key as a secret.
37
+ That builds your app, publishes it, and prints its address. Marcapony hosts it
38
+ and supplies the key at runtime; there is nothing for you to configure.
41
39
 
42
40
  ## Layout
43
41
 
44
- | Path | What it is |
45
- | ------------------------- | ------------------------------------------------ |
46
- | `src/server/index.ts` | The Worker. Only `/api/*` reaches it |
47
- | `src/server/marcapony.ts` | The only place that builds the Marcapony client |
48
- | `src/ui/` | React app, built to `dist/client` |
49
- | `marcapony.json` | How the platform builds and uploads this project |
50
- | `.dev.vars` | Your key. Gitignored — never commit it |
42
+ | Path | What it is |
43
+ | ------------------------- | ------------------------------------------- |
44
+ | `src/server/index.ts` | Your backend. Handles `/api/*` |
45
+ | `src/server/marcapony.ts` | The only place that talks to Marcapony |
46
+ | `src/ui/` | Your interface |
47
+ | `marcapony.json` | How Marcapony builds and publishes your app |
48
+ | `.dev.vars` | Your key. Never commit it |
51
49
 
52
50
  ## Rules that matter
53
51
 
54
- - **The app key stays on the server.** The browser calls your `/api` routes;
55
- those routes call Marcapony. A key in a client bundle is a public key.
52
+ - **The key stays on the backend.** Your interface calls your own `/api` routes,
53
+ and those routes call Marcapony. A key sent to the browser is a public key.
56
54
  - **Pass an `idempotencyKey` to every create call.** Retries then cannot create
57
55
  the same order, reservation, or payment link twice.
58
- - **Deployed apps are stateless.** No KV, Durable Objects, D1 or R2 — durable
59
- state lives behind the Marcapony API, which your key already reaches.
56
+ - **Apps keep no storage of their own.** Anything that has to persist lives in
57
+ Marcapony, which your key already reaches.
@@ -17,6 +17,7 @@
17
17
  "react-dom": "^19.0.0"
18
18
  },
19
19
  "devDependencies": {
20
+ "@types/bun": "^1.3.14",
20
21
  "@types/react": "^19.0.0",
21
22
  "@types/react-dom": "^19.0.0",
22
23
  "@vitejs/plugin-react": "^5.0.0",