create-znode-plugin 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/README.md +151 -19
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,36 +1,168 @@
1
1
  # create-znode-plugin
2
2
 
3
- Creates a Znode runtime theme project, the way `create-next-app` creates a Next.js app.
3
+ Creates a Znode runtime theme project, the way `create-next-app` creates a Next.js app. The project builds on its own
4
+ and runs inside your Znode store: no fork of the store, no webstore rebuild.
5
+
6
+ ## Before you start
7
+
8
+ | You need | Where to find it |
9
+ | --- | --- |
10
+ | Node.js 20 or newer | `node -v` |
11
+ | **The store repo**, checked out on this machine | The folder that has `tsconfig.base.json` at its root (the webstore and page builder repo), e.g. `D:\znode\my-store` |
12
+ | **The store's plugin folder** | The folder the webstore loads runtime packages from: the `RUNTIME_PLUGINS_DIR` line in the store's `apps/webstore/.env.local` (or `.env`), e.g. `D:\znode\runtime-plugins-store` |
13
+
14
+ You will be asked for the store repo. The plugin folder is usually found for you (step 3 below).
15
+
16
+ ## 1. Run one of these
17
+
18
+ All three run this package; use the one you like.
4
19
 
5
20
  ```bash
6
21
  npm create znode-plugin@latest my-theme
7
- cd my-theme
8
- npm run dev
9
22
  ```
10
23
 
11
- It then asks for the store to connect:
24
+ ```bash
25
+ npx create-znode-plugin@latest my-theme
26
+ ```
12
27
 
28
+ ```bash
29
+ npm init znode-plugin@latest my-theme
13
30
  ```
14
- Store path to connect (the store repo, with tsconfig.base.json), Enter to skip: D:\stores\my-store
15
- Store: D:\stores\my-store
16
- Plugin folder: D:\stores\runtime-plugins-store
31
+
32
+ `my-theme` is your project's name and folder: lowercase letters, digits and dashes (2 to 49 characters). Leave it out
33
+ and you are asked for it.
34
+
35
+ > `npx create znode-plugin` (with a space) does **not** work: npx would look for a package called `create`. With `npx`,
36
+ > type the full name `create-znode-plugin`.
37
+
38
+ ## 2. What happens next, step by step
39
+
40
+ ```
41
+ > npm create znode-plugin@latest my-theme
42
+
43
+ Store path to connect (the store repo, with tsconfig.base.json), Enter to skip: D:\znode\my-store
44
+ Store: D:\znode\my-store
45
+ Plugin folder: D:\znode\runtime-plugins-store
46
+ Created My Theme in D:\themes\my-theme
47
+ Installing dependencies…
48
+ added 32 packages in 30s
49
+ linked D:\themes\my-theme\tsconfig.store.json to D:\znode\my-store\tsconfig.base.json (69 store aliases)
50
+
51
+ Next:
52
+ cd my-theme
53
+ npm run dev (build, deploy, and again on every save)
54
+ Then enable the theme for your stores in the plugin folder's plugins.json, and open /my-theme-welcome.
17
55
  ```
18
56
 
19
- - The store repo gives the project the store's real types (`npm run link-store` runs for you).
20
- - The plugin folder is read from the store's own `RUNTIME_PLUGINS_DIR` (`apps/webstore/.env.local`, else `.env`).
21
- Only that line is read. When the store does not set it, you are asked for it.
22
- - A path without `tsconfig.base.json` is asked again; Enter skips (link later with `npm run link-store -- <store repo>`).
23
- - `ZNODE_STORE_DIR` set in your environment becomes the suggested answer.
24
- - In scripts and CI (no terminal) nothing is asked: pass the options below.
57
+ | Step | What you see | What you do |
58
+ | --- | --- | --- |
59
+ | 1. Name | `Project name …` (only when you did not type one) | Type a name such as `my-theme` |
60
+ | 2. **Store path** | `Store path to connect (the store repo, with tsconfig.base.json), Enter to skip:` | Type or paste the **store repo folder** (the one with `tsconfig.base.json`), then Enter |
61
+ | 3. **Plugin folder** | `Plugin folder: …` printed for you, or the question `The store's plugin folder (its RUNTIME_PLUGINS_DIR), Enter to skip:` | Nothing when it is printed. When asked: the folder the store's `RUNTIME_PLUGINS_DIR` points to |
62
+ | 4. Files | `Created My Theme in …` | Nothing: the starter theme is copied and named |
63
+ | 5. Install | `Installing dependencies…` | Nothing: `npm install` runs (`znode-plugin`, React and Next.js types) |
64
+ | 6. Link | `linked … (69 store aliases)` | Nothing: the project now sees the store's real components and types |
65
+ | 7. Next | `Next:` | Run the commands it prints (section 3) |
66
+
67
+ ### The store path question (step 2)
68
+
69
+ - **What to enter:** the root of the store repo, the folder with `tsconfig.base.json` in it. Not `apps/webstore`, not
70
+ the plugin folder.
71
+ - **Why:** the project gets the store's real types, so imports such as `@znode/base-components/...` are checked against
72
+ the store's own code while you write your theme.
73
+ - **A wrong folder** is not accepted: you see `… has no tsconfig.base.json` and the question again.
74
+ - **A default answer:** set `ZNODE_STORE_DIR` in your environment and it is shown in `[ ]`; press Enter to take it.
75
+ - **Enter on an empty answer skips it.** The project is still created; connect it later with
76
+ `npm run link-store -- <store repo>`.
77
+
78
+ ### The plugin folder (step 3)
79
+
80
+ - **Found for you** when the store sets `RUNTIME_PLUGINS_DIR` in `apps/webstore/.env.local` (or `.env`). Only that one
81
+ line is read from the file, nothing else.
82
+ - **Asked** when the store does not set it: enter the folder the webstore loads runtime packages from (it holds
83
+ `plugins.json`).
84
+ - **Why:** `npm run dev` and `npm run deploy` copy your built theme there.
85
+ - It is saved in the project's `znode.local.json` (`{ "pluginsDir": "…" }`), which is git-ignored: each developer keeps
86
+ their own.
87
+ - **Skipped:** create `znode.local.json` yourself later, or pass the folder to the command
88
+ (`npm run deploy -- <plugin folder>`).
89
+
90
+ ## 3. After it is created
91
+
92
+ 1. Build and deploy, again on every save:
93
+
94
+ ```bash
95
+ cd my-theme
96
+ npm run dev
97
+ ```
98
+
99
+ 2. Start the store's webstore in development mode (in the store repo).
100
+
101
+ 3. Look at your theme in your browser only, without changing anything for shoppers (development mode only):
102
+
103
+ ```
104
+ http://localhost:3000/api/extensions/preview?theme=my-theme
105
+ http://localhost:3000/api/extensions/preview?theme=my-theme&to=/my-theme-welcome
106
+ http://localhost:3000/api/extensions/preview (back to the store's own theme)
107
+ ```
108
+
109
+ 4. To make it live for a store: in the plugin folder's `plugins.json`, set your theme's `"enabled": true` and add the
110
+ store codes to `"stores"`.
111
+
112
+ | Command | What it does |
113
+ | --- | --- |
114
+ | `npm run dev` | Build, deploy to the plugin folder, and again on every save |
115
+ | `npm run build` | Type-check and build into `dist/` |
116
+ | `npm run check` | Marketplace checks (metadata, permissions, settings, sizes) |
117
+ | `npm run pack` | Build and zip into `releases/` |
118
+ | `npm run deploy` | Pack and install into the plugin folder once |
119
+ | `npm run link-store -- <store repo>` | Connect (or reconnect) the store's types |
120
+
121
+ ## What is in the project
122
+
123
+ ```
124
+ my-theme/
125
+ znode-package.json name, version, kind "theme", settings, server pages
126
+ src/browser.tsx slots (wrap or replace parts of the store) and page-builder widgets
127
+ src/server.tsx layouts around pages, whole pages at new URLs, API routes
128
+ src/slots/ AnnouncementBar (layout.header), ProductBadge (product.card)
129
+ src/widgets/ a Hero widget for the page builder
130
+ src/server/ ThemeLayout (layout.root), WelcomePage (/my-theme-welcome)
131
+ src/styles/theme.css the theme's styles
132
+ src/i18n/labels.json the theme's labels
133
+ tsconfig.store.json this machine's link to the store's types (git-ignored)
134
+ znode.local.json this machine's plugin folder (git-ignored)
135
+ ```
136
+
137
+ Where each kind of customization goes (styles, layouts, slots, widgets, pages, routes, settings, labels): see
138
+ [`znode-plugin`](https://www.npmjs.com/package/znode-plugin).
139
+
140
+ ## Without questions (scripts and CI)
141
+
142
+ When there is no terminal to answer, nothing is asked: pass the answers as options. With `npm create` and `npm init`
143
+ the options go after `--`; with `npx` they follow the name directly.
144
+
145
+ ```bash
146
+ npm create znode-plugin@latest my-theme -- --store D:\znode\my-store
147
+ npx create-znode-plugin@latest my-theme --store D:\znode\my-store --plugins-dir D:\znode\runtime-plugins-store
148
+ ```
25
149
 
26
150
  | Option | Meaning |
27
151
  | --- | --- |
28
- | `--store <dir>` | The store repo (with `tsconfig.base.json`): links the store's real types; skips the question |
29
- | `--plugins-dir <dir>` | The store's plugin folder, when the store does not set `RUNTIME_PLUGINS_DIR`; saved in the project's git-ignored `znode.local.json` |
152
+ | `--store <dir>` | The store repo (with `tsconfig.base.json`); skips the store question |
153
+ | `--plugins-dir <dir>` | The store's plugin folder, when the store does not set `RUNTIME_PLUGINS_DIR` |
30
154
  | `--publisher <name>` | Publisher shown in the marketplace |
31
155
  | `--registry <url>` | npm registry for the project's dependencies (written to its `.npmrc`) |
32
- | `--no-install` | Skip `npm install` |
156
+ | `--no-install` | Skip `npm install` (and the store link, which needs it) |
33
157
 
34
- The project depends on [`znode-plugin`](../znode-plugin), the SDK behind its `npm run` commands. Its README lists
35
- where each customization goes: styles, layouts, slots, page-builder widgets, pages at new URLs, API routes, settings,
36
- labels and the store's own components.
158
+ ## Troubleshooting
159
+
160
+ | You see | Do this |
161
+ | --- | --- |
162
+ | `npm error 404 … create` | You typed `npx create znode-plugin`: use `npx create-znode-plugin@latest` or `npm create znode-plugin@latest` |
163
+ | No store question | Not a terminal (scripts, CI, some IDE consoles): pass `--store`. Or an old cached version: keep `@latest` |
164
+ | `… has no tsconfig.base.json` | You gave a subfolder (`apps/webstore`) or the plugin folder: give the store repo's root |
165
+ | `… exists and is not empty` | Choose another name, or empty that folder |
166
+ | `needs the store's plugin folder` | Add `znode.local.json` with `{ "pluginsDir": "<the store's RUNTIME_PLUGINS_DIR>" }` |
167
+ | Preview link returns 404 | The webstore is not in development mode, or the theme is not deployed yet (`npm run dev`) |
168
+ | `@znode/...` imports are red in the editor | Run `npm run link-store -- <store repo>` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-znode-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Create a Znode runtime theme project: npm create znode-plugin@latest <name>.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",