create-shopnex 0.0.0-stage → 0.15.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 +114 -2
- package/bin/create-shopnex.mjs +10 -0
- package/dist/main.mjs +1346 -0
- package/package.json +44 -4
package/README.md
CHANGED
|
@@ -1,3 +1,115 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-shopnex
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Try ShopNex on your machine with one command. It starts the admin (with the API and hosted checkout) and the
|
|
4
|
+
storefront on an embedded database ([PGlite](https://pglite.dev)): no PostgreSQL, no Docker, no clone.
|
|
5
|
+
|
|
6
|
+
## Run it
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npx create-shopnex@latest
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This creates the folder `shopnex` in the current folder and keeps the shop's database in it. Want another name?
|
|
13
|
+
Add it: `npx create-shopnex@latest my-shop`.
|
|
14
|
+
|
|
15
|
+
npm asks once whether to install the package: answer `y`. `@latest` makes npx fetch the newest version instead of
|
|
16
|
+
reusing an older copy from its cache. With pnpm, which does not ask:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pnpm create shopnex@latest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The first run downloads ShopNex (one file, about 15 MB) into `~/.shopnex/app/<version>` (shared by all your shops) and checks its SHA-256; later
|
|
23
|
+
runs start straight away. It prints where to open the shop and the admin and opens the admin's setup wizard (use
|
|
24
|
+
`--no-open` to skip that). Ctrl+C stops everything. Nothing is installed globally.
|
|
25
|
+
|
|
26
|
+
## What it does, and why you can trust it
|
|
27
|
+
|
|
28
|
+
- **It runs on your machine only.** Both servers listen on `127.0.0.1`, and the data stays in the shop folder (`shopnex/data` by default).
|
|
29
|
+
- **It downloads one file.** `create-shopnex` itself fetches only the ShopNex build from this repository's GitHub
|
|
30
|
+
releases, and checks its SHA-256 before it unpacks anything. The checksum comes from the same place as the file, so it
|
|
31
|
+
catches a damaged or half-finished download, not a tampered release: the release itself is what you trust.
|
|
32
|
+
- **The source is here.** The package is
|
|
33
|
+
[`packages/create-shopnex`](https://github.com/shopnex-ai/shopnex/tree/main/packages/create-shopnex) in this
|
|
34
|
+
repository, and has no runtime dependencies: what you run is one bundled file built from that source.
|
|
35
|
+
- **It is built in the open.** Releases and edge builds are published from GitHub Actions
|
|
36
|
+
([release](https://github.com/shopnex-ai/shopnex/blob/main/.github/workflows/release.yaml),
|
|
37
|
+
[edge](https://github.com/shopnex-ai/shopnex/blob/main/.github/workflows/edge.yaml)) with npm provenance, so a
|
|
38
|
+
version's page on npmjs.com shows which commit and workflow run built it. The one exception is `0.0.0-edge.init`, the
|
|
39
|
+
first publish, made by hand to create the package. Publishing uses npm trusted publishing, so there is no long-lived
|
|
40
|
+
npm token.
|
|
41
|
+
|
|
42
|
+
## Options
|
|
43
|
+
|
|
44
|
+
| Option | What it does |
|
|
45
|
+
| ----------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
46
|
+
| `[name]` | The shop's folder, created if needed. `shopnex` when left out; the same folder is the same shop |
|
|
47
|
+
| `--port <n>` | Admin, API and checkout. Default `3000` |
|
|
48
|
+
| `--storefront-port <n>` | Storefront. Default `4321` |
|
|
49
|
+
| `--no-open` | Do not open the browser |
|
|
50
|
+
| `--with <apps>` | Also start optional apps next to the shop: `stripe`, `cj`, `shippo` (comma separated, or repeat the flag) |
|
|
51
|
+
| `--app <name>` | What to start. Only `shop` today; a picker appears once there is more than one |
|
|
52
|
+
| `--verbose` | Show the servers' output while they start (otherwise only if one fails) |
|
|
53
|
+
| `--dry-run` | Show what would run, and exit |
|
|
54
|
+
|
|
55
|
+
## Apps: Stripe, CJ Dropshipping and Shippo
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
npx create-shopnex@latest --with stripe,cj,shippo
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Each app runs as its own small server on this machine only (Stripe on port 4600, CJ Dropshipping on 4700, Shippo on 4900) and keeps
|
|
62
|
+
its data in `<shop folder>/apps/`. The admin finds them by itself; install them from the admin like any app and enter
|
|
63
|
+
your keys there. Stripe cannot reach a `localhost` address, so card payments need a public address for the app or
|
|
64
|
+
`stripe listen`: see the Stripe app's settings page.
|
|
65
|
+
|
|
66
|
+
## The shop's `.env`
|
|
67
|
+
|
|
68
|
+
The first run writes `<name>/.env` (readable by you only) with the two settings a shop needs, and every run reads it:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
DATABASE_URL=pglite:./.pglite # embedded database in the shop folder (a relative path is relative to it)
|
|
72
|
+
SHOPNEX_SECRET=<generated once> # encrypts the provider keys saved in the admin and signs sessions: keep it
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- **PostgreSQL:** set `DATABASE_URL=postgres://user:password@host:5432/shopnex` and start again. The migrations are applied
|
|
76
|
+
on start (`SHOPNEX_AUTO_MIGRATE`). The data in `.pglite/` is not moved (there is no tool for that yet).
|
|
77
|
+
- **Other settings** in the file (SMTP, and so on) are passed to the admin. The address, the ports and the build's own
|
|
78
|
+
files are set by the CLI and its flags and win over the file.
|
|
79
|
+
- Do not commit or share it. Without `SHOPNEX_SECRET` the saved provider keys cannot be read: a lost one means a new
|
|
80
|
+
shop.
|
|
81
|
+
|
|
82
|
+
The first run also writes a `.gitignore` (keeps `.env`, `.pglite/` and the apps' keys out of git) and the
|
|
83
|
+
`docker-compose.yml` (fetched from the repository, the file the [self-hosting docs](https://shopnex.ai/docs/self-hosting/docker) describe: ShopNex, the Stripe
|
|
84
|
+
app and PostgreSQL from prebuilt images), for when the shop should run in Docker instead. Existing files are never
|
|
85
|
+
overwritten.
|
|
86
|
+
|
|
87
|
+
To start over, delete the shop folder.
|
|
88
|
+
|
|
89
|
+
## Not for production
|
|
90
|
+
|
|
91
|
+
One process owns the data, so nothing else can open the folder, and the servers listen on `127.0.0.1` only. Use
|
|
92
|
+
Docker or PostgreSQL for a real shop. There is no tool yet to move the data from the embedded database to PostgreSQL.
|
|
93
|
+
|
|
94
|
+
## Where the build comes from
|
|
95
|
+
|
|
96
|
+
Each release attaches `shopnex-v<version>-node.tgz` and its `.sha256` (`scripts/build-node-bundle.mjs`, run by the
|
|
97
|
+
release workflow). It holds the admin (bundled into a few files), the built storefront with its themes and the database
|
|
98
|
+
migrations: JavaScript and WebAssembly, so one file serves every OS and CPU. `create-shopnex` asks for the build of its
|
|
99
|
+
own version, so a version without a release says so. The checksum comes from the same place as the file: it catches a
|
|
100
|
+
damaged download, not a tampered release.
|
|
101
|
+
|
|
102
|
+
`SHOPNEX_BUNDLE_URL` downloads from somewhere else (a mirror; the `.sha256` sits next to it) and `SHOPNEX_APP_DIR`
|
|
103
|
+
changes where builds are unpacked.
|
|
104
|
+
|
|
105
|
+
**Edge:** `npx create-shopnex@edge` (or `pnpm create shopnex@edge`) runs the latest build of `main` (`.github/workflows/edge.yaml` replaces the file of
|
|
106
|
+
the `edge` pre-release on every push). It downloads again only when `main` moved. It can be broken: use a release for
|
|
107
|
+
anything you want to keep.
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
pnpm --filter create-shopnex dev # runs src/main.ts (needs a release of this version, or SHOPNEX_BUNDLE_URL)
|
|
113
|
+
pnpm --filter create-shopnex test
|
|
114
|
+
pnpm build && pnpm --dir templates/storefront build && node scripts/build-node-bundle.mjs 0.14.0 /tmp/bundle
|
|
115
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The compiled CLI (pnpm --filter create-shopnex build; it is built before the package is packed). From a checkout,
|
|
3
|
+
// `pnpm --filter create-shopnex dev -- <options>` runs the TypeScript directly.
|
|
4
|
+
try {
|
|
5
|
+
await import('../dist/main.mjs')
|
|
6
|
+
} catch (error) {
|
|
7
|
+
if (error?.code !== 'ERR_MODULE_NOT_FOUND' || !String(error.message).includes('dist/main.mjs')) throw error
|
|
8
|
+
console.error('create-shopnex is not built. Run: pnpm --filter create-shopnex build')
|
|
9
|
+
process.exitCode = 1
|
|
10
|
+
}
|