create-cartbase 0.1.6 → 0.1.8
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 +13 -8
- package/dist/index.js +28 -20
- package/package.json +21 -21
- package/template/app/AGENTS.md +35 -0
- package/template/app/CLAUDE.md +24 -7
- package/template/app/docs/BUILD-A-STOREFRONT.md +233 -226
- package/template/app/docs/README.md +1 -0
- package/template/app/docs/components.md +8 -7
- package/template/app/docs/deploy.md +15 -10
- package/template/app/docs/platform.md +1 -1
- package/template/app/docs/store.md +47 -0
- package/template/app/docs/variables.md +3 -3
- package/template/app/next.config.ts +10 -14
- package/template/app/package.json +4 -3
- package/template/app/src/app/checkout/checkout-page-client.tsx +0 -20
- package/template/app/src/app/globals.css +1 -1
- package/template/app/src/app/layout.tsx +59 -18
- package/template/app/src/lib/config.ts +30 -21
- package/template/app/next-env.d.ts +0 -6
- package/template/app/smoke.mjs +0 -158
- package/template/app/src/app/checkout/mypos-demo-tab.tsx +0 -101
- package/template/app/src/app/gallery/[slug]/page.tsx +0 -172
- package/template/app/src/app/gallery/_components/specimens.tsx +0 -254
- package/template/app/src/app/gallery/_components/status.tsx +0 -47
- package/template/app/src/app/gallery/_lib/catalog.ts +0 -59
- package/template/app/src/app/gallery/_lib/registry.ts +0 -401
- package/template/app/src/app/gallery/design-system/page.tsx +0 -353
- package/template/app/src/app/gallery/layout.tsx +0 -83
- package/template/app/src/app/gallery/page.tsx +0 -81
- package/template/app/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
# create-cartbase
|
|
2
2
|
|
|
3
3
|
Scaffold a storefront on the [Cartbase](https://cartbase.net) commerce
|
|
4
|
-
platform:
|
|
4
|
+
platform. One input: your store's publishable key, handed out on the
|
|
5
|
+
**Storefront** page of your Cartbase admin.
|
|
5
6
|
|
|
6
7
|
```bash
|
|
7
|
-
|
|
8
|
-
# or
|
|
9
|
-
npm create cartbase my-store -- --
|
|
8
|
+
npx create-cartbase@latest my-store --key pk_…
|
|
9
|
+
# or
|
|
10
|
+
npm create cartbase my-store -- --key pk_…
|
|
11
|
+
bun create cartbase my-store --key pk_…
|
|
10
12
|
```
|
|
11
13
|
|
|
12
14
|
You get a working Next.js storefront wired to your store through
|
|
13
|
-
`@cartbase/storefront`, with the **complete platform docs
|
|
14
|
-
`docs/`** and a `CLAUDE.md` brief
|
|
15
|
-
and it has everything it needs offline.
|
|
16
|
-
|
|
15
|
+
`@cartbase/storefront`, styled, with the **complete platform docs
|
|
16
|
+
included in `docs/`** and a `CLAUDE.md` brief. Hand the folder to a
|
|
17
|
+
coding agent and it has everything it needs offline. `--url` points the
|
|
18
|
+
app at a local or staging platform; without it the app talks to the
|
|
19
|
+
platform. Deploy with the
|
|
20
|
+
[`cartbase`](https://www.npmjs.com/package/cartbase) CLI: `cartbase login`,
|
|
21
|
+
then `cartbase deploy`.
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,8 @@ function parseArgs(argv) {
|
|
|
7
7
|
let dir;
|
|
8
8
|
for (let i = 0; i < argv.length; i++) {
|
|
9
9
|
const arg = argv[i];
|
|
10
|
+
if (arg === "--")
|
|
11
|
+
continue;
|
|
10
12
|
if (arg.startsWith("--")) {
|
|
11
13
|
const name = arg.slice(2);
|
|
12
14
|
const next = argv[i + 1];
|
|
@@ -33,16 +35,31 @@ function copyDir(from, to) {
|
|
|
33
35
|
fs.copyFileSync(src, dest);
|
|
34
36
|
}
|
|
35
37
|
}
|
|
38
|
+
function flag(flags, name) {
|
|
39
|
+
const v = flags.get(name);
|
|
40
|
+
return typeof v === "string" ? v.trim() : "";
|
|
41
|
+
}
|
|
42
|
+
/** The .env.local the scaffold writes: the key, plus overrides only when given. */
|
|
43
|
+
function envFile(input) {
|
|
44
|
+
return [
|
|
45
|
+
"# Your store's publishable key — Cartbase admin, Storefront page.",
|
|
46
|
+
`NEXT_PUBLIC_CARTBASE_PUBLISHABLE_KEY=${input.key}`,
|
|
47
|
+
...(input.url ? [`NEXT_PUBLIC_CARTBASE_URL=${input.url}`] : []),
|
|
48
|
+
...(input.clientId ? [`NEXT_PUBLIC_CARTBASE_CLIENT_ID=${input.clientId}`] : []),
|
|
49
|
+
"",
|
|
50
|
+
].join("\n");
|
|
51
|
+
}
|
|
36
52
|
function main() {
|
|
37
53
|
const { dir, flags } = parseArgs(process.argv.slice(2));
|
|
38
54
|
if (!dir || flags.get("help") === true) {
|
|
39
55
|
console.log(`create-cartbase — scaffold a Cartbase storefront
|
|
40
56
|
|
|
41
57
|
Usage:
|
|
42
|
-
|
|
58
|
+
npx create-cartbase@latest <directory> --key <pk_…>
|
|
43
59
|
|
|
44
|
-
The
|
|
45
|
-
as
|
|
60
|
+
The key is your store's publishable key (Cartbase admin, Storefront page).
|
|
61
|
+
Given as a flag it is written into .env.local; otherwise a placeholder is.
|
|
62
|
+
--url points at a local or staging platform; the default is the platform.`);
|
|
46
63
|
process.exitCode = dir ? 0 : 1;
|
|
47
64
|
return;
|
|
48
65
|
}
|
|
@@ -63,32 +80,23 @@ as flags they are written into .env.local, otherwise placeholders are.`);
|
|
|
63
80
|
.replace(/[^a-z0-9-]+/g, "-")
|
|
64
81
|
.replace(/^-+|-+$/g, "") || "cartbase-storefront";
|
|
65
82
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
const key = typeof flags.get("key") === "string" ? flags.get("key") : "";
|
|
69
|
-
fs.writeFileSync(path.join(target, ".env.local"), [
|
|
70
|
-
"# Your store's inputs — Cartbase admin, Settings.",
|
|
71
|
-
`NEXT_PUBLIC_CARTBASE_URL=${url}`,
|
|
72
|
-
`NEXT_PUBLIC_CARTBASE_CLIENT_ID=${clientId}`,
|
|
73
|
-
`NEXT_PUBLIC_CARTBASE_PUBLISHABLE_KEY=${key}`,
|
|
74
|
-
"",
|
|
75
|
-
].join("\n"));
|
|
76
|
-
const filled = url && clientId;
|
|
83
|
+
const key = flag(flags, "key");
|
|
84
|
+
fs.writeFileSync(path.join(target, ".env.local"), envFile({ key, url: flag(flags, "url"), clientId: flag(flags, "client-id") }));
|
|
77
85
|
console.log(`
|
|
78
86
|
Created ${path.basename(target)}/
|
|
79
87
|
|
|
80
88
|
Next steps:
|
|
81
89
|
cd ${dir}
|
|
82
|
-
bun install (or npm install)${
|
|
90
|
+
bun install (or npm install)${key
|
|
83
91
|
? ""
|
|
84
92
|
: `
|
|
85
|
-
|
|
86
|
-
|
|
93
|
+
open .env.local and paste your store's publishable key
|
|
94
|
+
(Cartbase admin, Storefront page)`}
|
|
87
95
|
bun run dev
|
|
88
96
|
|
|
89
|
-
The complete storefront reference is in docs/ — hand CLAUDE.md
|
|
90
|
-
coding agent and it has everything. Deploy with the
|
|
91
|
-
cartbase login, then cartbase deploy.
|
|
97
|
+
The complete storefront reference is in docs/ — hand CLAUDE.md (or
|
|
98
|
+
AGENTS.md) to your coding agent and it has everything. Deploy with the
|
|
99
|
+
Cartbase CLI: cartbase login, then cartbase deploy.
|
|
92
100
|
`);
|
|
93
101
|
}
|
|
94
102
|
main();
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "create-cartbase",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Scaffold a Cartbase storefront: npm create cartbase my-store",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"bin": {
|
|
8
|
-
"create-cartbase": "./dist/index.js"
|
|
9
|
-
},
|
|
10
|
-
"files": ["dist", "template"],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "
|
|
13
|
-
"prepack": "
|
|
14
|
-
},
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": ">=20"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"typescript": "^5"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "create-cartbase",
|
|
3
|
+
"version": "0.1.8",
|
|
4
|
+
"description": "Scaffold a Cartbase storefront: npm create cartbase my-store",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-cartbase": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": ["dist", "template"],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "bun scripts/build-template.mjs && tsc -p tsconfig.json",
|
|
13
|
+
"prepack": "bun scripts/build-template.mjs && tsc -p tsconfig.json"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# This is a Cartbase storefront
|
|
2
|
+
|
|
3
|
+
A Next.js app wired to a Cartbase store through `@cartbase/storefront`
|
|
4
|
+
(typed API client + UI components). It is the store's own starting point:
|
|
5
|
+
the same files are already running on the store's permanent preview link,
|
|
6
|
+
and the store's live address shows an "opening soon" page until the
|
|
7
|
+
merchant publishes from their admin (Storefront in the sidebar).
|
|
8
|
+
|
|
9
|
+
Everything you need is local:
|
|
10
|
+
|
|
11
|
+
- **docs/** — the complete storefront reference (also at the store's docs
|
|
12
|
+
site): endpoints, shapes, auth, checkout orchestration, components.
|
|
13
|
+
Start with docs/BUILD-A-STOREFRONT.md.
|
|
14
|
+
- **.env.local** — ONE input: the store's publishable key
|
|
15
|
+
(`NEXT_PUBLIC_CARTBASE_PUBLISHABLE_KEY`). It names the store and scopes
|
|
16
|
+
the catalog; the merchant's Cartbase admin hands it out on the
|
|
17
|
+
Storefront page. The API origin is the platform's (a constant); the
|
|
18
|
+
store's id is not an input (`GET /api/store/store` answers it).
|
|
19
|
+
- **Deploy** with the Cartbase CLI: `cartbase login` then
|
|
20
|
+
`cartbase deploy`. Every deploy lands on the same preview link; the
|
|
21
|
+
merchant publishes from their admin. `cartbase pull` fetches the
|
|
22
|
+
hosted source. Never commit .env.local.
|
|
23
|
+
|
|
24
|
+
House rules: totals and prices are SERVER truth (render them verbatim);
|
|
25
|
+
always pass a pricing context; consent before tracking; the store API is
|
|
26
|
+
proxied same-origin via next.config rewrites.
|
|
27
|
+
|
|
28
|
+
What you may change: **everything except payments.** Payments are the one
|
|
29
|
+
thing that cannot be ejected. The cart and the checkout are yours to
|
|
30
|
+
shape, and you should rarely need to eject them: both are built to be
|
|
31
|
+
restyled through the theme tokens and their slots, which is the intended
|
|
32
|
+
route and keeps you on our updates. Eject when tokens genuinely are not
|
|
33
|
+
enough, and know what it means, because we say so at the moment you do
|
|
34
|
+
it: that file leaves our support, stops receiving our fixes, and its
|
|
35
|
+
safety is yours from then on.
|
package/template/app/CLAUDE.md
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
# This is a Cartbase storefront
|
|
2
2
|
|
|
3
3
|
A Next.js app wired to a Cartbase store through `@cartbase/storefront`
|
|
4
|
-
(typed API client + UI components).
|
|
4
|
+
(typed API client + UI components). It is the store's own starting point:
|
|
5
|
+
the same files are already running on the store's permanent preview link,
|
|
6
|
+
and the store's live address shows an "opening soon" page until the
|
|
7
|
+
merchant publishes from their admin (Storefront in the sidebar).
|
|
8
|
+
|
|
9
|
+
Everything you need is local:
|
|
5
10
|
|
|
6
11
|
- **docs/** — the complete storefront reference (also at the store's docs
|
|
7
12
|
site): endpoints, shapes, auth, checkout orchestration, components.
|
|
8
13
|
Start with docs/BUILD-A-STOREFRONT.md.
|
|
9
|
-
- **.env.local** — the
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
- **.env.local** — ONE input: the store's publishable key
|
|
15
|
+
(`NEXT_PUBLIC_CARTBASE_PUBLISHABLE_KEY`). It names the store and scopes
|
|
16
|
+
the catalog; the merchant's Cartbase admin hands it out on the
|
|
17
|
+
Storefront page. The API origin is the platform's (a constant); the
|
|
18
|
+
store's id is not an input (`GET /api/store/store` answers it).
|
|
19
|
+
- **Deploy** with the Cartbase CLI: `cartbase login` then
|
|
20
|
+
`cartbase deploy`. Every deploy lands on the same preview link; the
|
|
21
|
+
merchant publishes from their admin. `cartbase pull` fetches the
|
|
22
|
+
hosted source. Never commit .env.local.
|
|
15
23
|
|
|
16
24
|
House rules: totals and prices are SERVER truth (render them verbatim);
|
|
17
25
|
always pass a pricing context; consent before tracking; the store API is
|
|
18
26
|
proxied same-origin via next.config rewrites.
|
|
27
|
+
|
|
28
|
+
What you may change: **everything except payments.** Payments are the one
|
|
29
|
+
thing that cannot be ejected. The cart and the checkout are yours to
|
|
30
|
+
shape, and you should rarely need to eject them: both are built to be
|
|
31
|
+
restyled through the theme tokens and their slots, which is the intended
|
|
32
|
+
route and keeps you on our updates. Eject when tokens genuinely are not
|
|
33
|
+
enough, and know what it means, because we say so at the moment you do
|
|
34
|
+
it: that file leaves our support, stops receiving our fixes, and its
|
|
35
|
+
safety is yours from then on.
|