create-shopnex 0.16.0 → 0.16.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 +18 -3
- package/dist/main.mjs +36 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
Try ShopNex on your machine with one command. It starts the admin (with the API and hosted checkout) and the
|
|
4
4
|
storefront on an embedded database ([PGlite](https://pglite.dev)): no PostgreSQL, no Docker, no clone.
|
|
5
5
|
|
|
6
|
+
New here? Read [Getting started](getting-started/README.md) first: a short walk-through from the first command to a
|
|
7
|
+
running shop. This page is the full reference.
|
|
8
|
+
|
|
6
9
|
## Run it
|
|
7
10
|
|
|
8
11
|
```sh
|
|
@@ -23,6 +26,18 @@ The first run downloads ShopNex (one file, about 15 MB) into `~/.shopnex/app/<ve
|
|
|
23
26
|
runs start straight away. It prints where to open the shop and the admin and opens the admin's setup wizard (use
|
|
24
27
|
`--no-open` to skip that). Ctrl+C stops everything. Nothing is installed globally.
|
|
25
28
|
|
|
29
|
+
## Run it again
|
|
30
|
+
|
|
31
|
+
The shop folder has a `package.json`, so from inside it:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
cd shopnex
|
|
35
|
+
npm start # or: npm run dev
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
No `npm install` first: both scripts run `npx --yes create-shopnex@<version> .`, the version that made the folder, and
|
|
39
|
+
npx fetches it into its cache the first time. The same works from the folder above: `npx create-shopnex@latest shopnex`.
|
|
40
|
+
|
|
26
41
|
## What it does, and why you can trust it
|
|
27
42
|
|
|
28
43
|
- **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).
|
|
@@ -73,13 +88,13 @@ SHOPNEX_SECRET=<generated once> # encrypts the provider keys saved in the admi
|
|
|
73
88
|
```
|
|
74
89
|
|
|
75
90
|
- **PostgreSQL:** set `DATABASE_URL=postgres://user:password@host:5432/shopnex` and start again. The migrations are applied
|
|
76
|
-
on start (`SHOPNEX_AUTO_MIGRATE`).
|
|
91
|
+
on start (`SHOPNEX_AUTO_MIGRATE`). To move the data from `.pglite/`, run `npx shopnex migrate-db` (see [Getting started](getting-started/README.md)).
|
|
77
92
|
- **Other settings** in the file (SMTP, and so on) are passed to the admin. The address, the ports and the build's own
|
|
78
93
|
files are set by the CLI and its flags and win over the file.
|
|
79
94
|
- Do not commit or share it. Without `SHOPNEX_SECRET` the saved provider keys cannot be read: a lost one means a new
|
|
80
95
|
shop.
|
|
81
96
|
|
|
82
|
-
The first run also writes a `.gitignore` (keeps `.env`, `.pglite/` and the apps' keys out of git) and the
|
|
97
|
+
The first run also writes a `README.md` (how to run the shop again), a `package.json` (for `npm start`), a `.gitignore` (keeps `.env`, `.pglite/` and the apps' keys out of git) and the
|
|
83
98
|
`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
99
|
app and PostgreSQL from prebuilt images), for when the shop should run in Docker instead. Existing files are never
|
|
85
100
|
overwritten.
|
|
@@ -89,7 +104,7 @@ To start over, delete the shop folder.
|
|
|
89
104
|
## Not for production
|
|
90
105
|
|
|
91
106
|
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
|
|
107
|
+
Docker or PostgreSQL for a real shop, and move the data with `npx shopnex migrate-db`.
|
|
93
108
|
|
|
94
109
|
## Where the build comes from
|
|
95
110
|
|
package/dist/main.mjs
CHANGED
|
@@ -40,7 +40,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
40
40
|
var define_PKG_default;
|
|
41
41
|
var init_define_PKG = __esm({
|
|
42
42
|
"<define:__PKG__>"() {
|
|
43
|
-
define_PKG_default = { version: "0.16.
|
|
43
|
+
define_PKG_default = { version: "0.16.1", engines: { node: ">=22.22.0" } };
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -879,7 +879,16 @@ var extras = [
|
|
|
879
879
|
keyEnv: "CJ_DROPSHIPPING_APP_KEY",
|
|
880
880
|
database: true
|
|
881
881
|
},
|
|
882
|
-
{ name: "shippo", label: "Shippo", dir: "shippo", port: 4900, urlEnv: "SHIPPO_APP_URL", keyEnv: "SHIPPO_APP_KEY" }
|
|
882
|
+
{ name: "shippo", label: "Shippo", dir: "shippo", port: 4900, urlEnv: "SHIPPO_APP_URL", keyEnv: "SHIPPO_APP_KEY" },
|
|
883
|
+
{
|
|
884
|
+
name: "reviews",
|
|
885
|
+
label: "Reviews",
|
|
886
|
+
dir: "reviews",
|
|
887
|
+
port: 5100,
|
|
888
|
+
urlEnv: "REVIEWS_APP_URL",
|
|
889
|
+
keyEnv: "REVIEWS_APP_KEY",
|
|
890
|
+
database: true
|
|
891
|
+
}
|
|
883
892
|
];
|
|
884
893
|
function pickExtras(values, list = extras) {
|
|
885
894
|
const names = (values ?? []).flatMap((value) => value.split(",")).map((name) => name.trim().toLowerCase());
|
|
@@ -1095,18 +1104,42 @@ function loadShopEnv(shopDir, { write }) {
|
|
|
1095
1104
|
// src/scaffold.ts
|
|
1096
1105
|
init_define_PKG();
|
|
1097
1106
|
import { existsSync as existsSync4, mkdirSync as mkdirSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
1098
|
-
import { join as join6 } from "node:path";
|
|
1107
|
+
import { basename, join as join6 } from "node:path";
|
|
1108
|
+
|
|
1109
|
+
// src/readme.ts
|
|
1110
|
+
init_define_PKG();
|
|
1111
|
+
var template2 = true ? "# Getting started with ShopNex\n\nRun a ShopNex shop on your machine in a few minutes. No PostgreSQL, no Docker, no clone.\n\nWhen it is running you have:\n\n- the **admin** at http://localhost:3000/admin\n- the **storefront** at http://localhost:4321\n- a **database** in the shop folder (embedded, for trying things out)\n\n## You need\n\n- Node.js 22.22 or newer\n- Free ports `3000` (admin, API, checkout) and `4321` (storefront). Other ports: `--port` and `--storefront-port`.\n\n## 1. Start the shop\n\n```sh\nnpx create-shopnex@latest my-shop\n```\n\nThis creates the folder `my-shop`, downloads ShopNex once (about 15 MB, kept in `~/.shopnex/app` and shared by all\nyour shops), starts the admin and the storefront, and opens the admin in your browser. The first start takes a minute.\nLeave the terminal open: Ctrl+C stops the shop.\n\n## 2. Create the owner account\n\nThe admin opens the setup wizard on the first run. Create the owner account right away: until you do, whoever reaches\nthe admin can. Both servers listen on your machine only (`127.0.0.1`).\n\nThen open the storefront at http://localhost:4321 and the admin at http://localhost:3000/admin.\n\n## 3. Run it again\n\n```sh\ncd my-shop\nnpm start\n```\n\n`npm run dev` does the same. Nothing to install first: the script runs `npx --yes create-shopnex@<version> .` with the\nversion that made the folder. The shop's data stays in the folder, so the same folder is the same shop.\n\n## 4. Add your first product\n\nIn the admin, add a product (a name and a price are enough), then reload the storefront: it shows up there. That is the\nwhole loop: you change things in the admin, customers see them in the storefront.\n\nTo try a card payment, start the Stripe app next to the shop (`--with stripe`, see below), install it from the admin and\nenter your Stripe **test** keys; the test card is `4242 4242 4242 4242`. Stripe cannot reach a `localhost` address, so\npayments need a public address for the app or `stripe listen`: the Stripe app's settings page explains it.\n\n## Update\n\n`npm start` runs the version written in the shop's `package.json` (`create-shopnex@<version>`), so it never changes by\nitself. To move to a newer version:\n\n1. Stop the shop and copy the folder somewhere as a backup.\n2. Change the version in the two scripts of `package.json` (or run `npx create-shopnex@latest my-shop` once).\n3. Start it again. The database changes the new version needs are applied on start.\n\n## What is in the folder\n\n| File | What it is |\n| -------------------- | ---------------------------------------------------------------------------------------------------------------- |\n| `.env` | The shop's settings and secrets. Keep it out of git; a lost `SHOPNEX_SECRET` means a new shop |\n| `.pglite/` | The embedded trial database |\n| `docker-compose.yml` | For running the shop in Docker instead: see the [self-hosting docs](https://shopnex.ai/docs/self-hosting/docker) |\n| `README.md` | How to run this shop again |\n\n## Next\n\n- **Payments and shipping:** start the optional apps next to the shop with\n `npx create-shopnex@latest my-shop --with stripe,cj,shippo`, then install them from the admin and enter your keys.\n- **From trying it to a real shop:** the embedded database is for trying ShopNex out (one process owns it), so move to\n PostgreSQL before you rely on the shop. With the shop stopped, run this in its folder with an empty PostgreSQL database:\n\n ```sh\n TARGET=postgres://user:password@host:5432/shopnex npx shopnex migrate-db --to-env TARGET\n ```\n\n It copies the data, keeps a copy of the old data next to it and points the `.env` at PostgreSQL. Then run the shop in\n Docker with the `docker-compose.yml` ([self-hosting docs](https://shopnex.ai/docs/self-hosting/docker)).\n\n- **Every option and how the download is checked:** the [package README](https://github.com/shopnex-ai/shopnex/tree/main/packages/create-shopnex#readme).\n\n## If something goes wrong\n\n- **A port is taken:** the command stops before downloading anything and names the flag to change (`--port`,\n `--storefront-port`).\n- **No connection:** the first run needs the network for the download; later runs do not.\n- **Servers will not start:** run again with `--verbose` to see their output.\n- **Start over:** delete the shop folder.\n" : readFileSync(new URL("../getting-started/README.md", import.meta.url), "utf8");
|
|
1112
|
+
var EXAMPLE_NAME = "my-shop";
|
|
1113
|
+
var readme = (name) => template2.replaceAll(EXAMPLE_NAME, name);
|
|
1114
|
+
|
|
1115
|
+
// src/scaffold.ts
|
|
1099
1116
|
var GITIGNORE = `# ShopNex: secrets and local data stay out of git
|
|
1100
1117
|
.env
|
|
1101
1118
|
.pglite/
|
|
1102
1119
|
apps/*/.pglite/
|
|
1103
1120
|
apps/*/app-key
|
|
1104
1121
|
`;
|
|
1122
|
+
var packageJson = (name, version) => {
|
|
1123
|
+
const run2 = `npx --yes create-shopnex@${version} .`;
|
|
1124
|
+
return JSON.stringify(
|
|
1125
|
+
{
|
|
1126
|
+
name: name.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "") || "shopnex-shop",
|
|
1127
|
+
private: true,
|
|
1128
|
+
scripts: { start: run2, dev: run2 }
|
|
1129
|
+
},
|
|
1130
|
+
null,
|
|
1131
|
+
2
|
|
1132
|
+
) + "\n";
|
|
1133
|
+
};
|
|
1105
1134
|
var composeUrl = (version) => `https://raw.githubusercontent.com/shopnex-ai/shopnex/${isEdge(version) ? "main" : `v${version}`}/deploy/docker-compose.yml`;
|
|
1106
1135
|
async function writeScaffold(shopDir, version, fetcher = fetch) {
|
|
1107
1136
|
mkdirSync4(shopDir, { recursive: true });
|
|
1108
1137
|
const gitignore = join6(shopDir, ".gitignore");
|
|
1109
1138
|
if (!existsSync4(gitignore)) writeFileSync3(gitignore, GITIGNORE);
|
|
1139
|
+
const pkgFile = join6(shopDir, "package.json");
|
|
1140
|
+
if (!existsSync4(pkgFile)) writeFileSync3(pkgFile, packageJson(basename(shopDir), version));
|
|
1141
|
+
const readmeFile = join6(shopDir, "README.md");
|
|
1142
|
+
if (!existsSync4(readmeFile)) writeFileSync3(readmeFile, readme(basename(shopDir)));
|
|
1110
1143
|
const compose = join6(shopDir, "docker-compose.yml");
|
|
1111
1144
|
if (existsSync4(compose)) return;
|
|
1112
1145
|
const url = composeUrl(version);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-shopnex",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "Try ShopNex with one command: npx create-shopnex starts the admin and the storefront on an embedded database, nothing else to install",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://shopnex.ai",
|