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 +20 -22
- package/dist/index.d.ts +10 -1
- package/dist/index.js +42 -9
- package/package.json +1 -1
- package/template/README.md +27 -29
- package/template/_package.json +1 -0
package/README.md
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
# create-marcapony-app
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
7
|
+
npx create-marcapony-app my-app
|
|
8
8
|
cd my-app
|
|
9
9
|
bun install
|
|
10
|
-
|
|
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
|
-
|
|
17
|
+
npx marcapony app deploy
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
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` |
|
|
28
|
-
| `src/server/marcapony.ts` | The only place that
|
|
29
|
-
| `src/ui/` |
|
|
30
|
-
| `marcapony.json` | How
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
43
|
+
Run without a directory name and it asks for one.
|
|
46
44
|
|
|
47
|
-
Requires Node
|
|
45
|
+
Requires Node 20 or newer, or Bun. No runtime dependencies.
|
|
48
46
|
|
|
49
47
|
## License
|
|
50
48
|
|
|
51
|
-
Proprietary tool, unrestricted output — the
|
|
52
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
64
|
+
npx marcapony app link get this app's key
|
|
65
65
|
bun run dev run it locally
|
|
66
|
-
|
|
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
|
-
'
|
|
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
|
-
'
|
|
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, {
|
|
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
|
-
|
|
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.
|
|
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",
|
package/template/README.md
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
# Marcapony app
|
|
2
2
|
|
|
3
|
-
A
|
|
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
|
-
|
|
8
|
+
npx marcapony app link
|
|
10
9
|
```
|
|
11
10
|
|
|
12
|
-
Create the app under **My Apps** in your Marcapony dashboard, generate a
|
|
13
|
-
code there, and paste it when asked. The
|
|
14
|
-
`.dev.vars`
|
|
15
|
-
|
|
16
|
-
your AI assistant knows what
|
|
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
|
-
|
|
24
|
+
Your interface and your `/api` routes both run locally.
|
|
26
25
|
|
|
27
|
-
One thing to know:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
##
|
|
31
|
+
## Publish
|
|
33
32
|
|
|
34
33
|
```sh
|
|
35
|
-
|
|
34
|
+
npx marcapony app deploy
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
That builds
|
|
39
|
-
|
|
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` |
|
|
47
|
-
| `src/server/marcapony.ts` | The only place that
|
|
48
|
-
| `src/ui/` |
|
|
49
|
-
| `marcapony.json` | How
|
|
50
|
-
| `.dev.vars` | Your key.
|
|
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
|
|
55
|
-
those routes call Marcapony. A 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
|
-
- **
|
|
59
|
-
|
|
56
|
+
- **Apps keep no storage of their own.** Anything that has to persist lives in
|
|
57
|
+
Marcapony, which your key already reaches.
|