znode-plugin 0.1.1 → 0.1.2
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 +54 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,11 +4,53 @@ The SDK for Znode runtime plugins and themes: the `znode` command behind every p
|
|
|
4
4
|
`create-znode-plugin`. A package is built on its own and runs in the webstore for the stores it is enabled for, with no
|
|
5
5
|
fork of the store and no webstore rebuild.
|
|
6
6
|
|
|
7
|
+
## Getting started
|
|
8
|
+
|
|
9
|
+
Start a new project with the recipe (any one of these, they are the same):
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm create znode-plugin@latest my-theme
|
|
13
|
+
npx create-znode-plugin@latest my-theme
|
|
14
|
+
npm init znode-plugin@latest my-theme
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
It then asks two things, so have them ready:
|
|
18
|
+
|
|
19
|
+
1. **The store path to connect**: the store repo, the folder with `tsconfig.base.json` at its root. The project gets
|
|
20
|
+
the store's real types from it (`znode link-store`).
|
|
21
|
+
2. **The store's plugin folder**: where the webstore loads runtime packages from (its `RUNTIME_PLUGINS_DIR`, the folder
|
|
22
|
+
with `plugins.json`). Usually found for you in the store's `apps/webstore/.env.local` (or `.env`); asked only when
|
|
23
|
+
the store does not set it. `npm run dev` and `npm run deploy` copy your package there.
|
|
24
|
+
|
|
25
|
+
Then:
|
|
26
|
+
|
|
7
27
|
```bash
|
|
8
|
-
|
|
9
|
-
npm
|
|
28
|
+
cd my-theme
|
|
29
|
+
npm run dev
|
|
10
30
|
```
|
|
11
31
|
|
|
32
|
+
and, with the webstore running in development mode, preview the theme in your browser only:
|
|
33
|
+
`http://localhost:3000/api/extensions/preview?theme=my-theme`. The full walkthrough (every question, what to enter,
|
|
34
|
+
skipping, scripts and CI, troubleshooting): [`create-znode-plugin`](https://www.npmjs.com/package/create-znode-plugin).
|
|
35
|
+
|
|
36
|
+
To add the SDK to an existing package instead:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install -D znode-plugin
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Connecting a project to a store
|
|
43
|
+
|
|
44
|
+
| What | How | Saved in |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| The store's types | `npm run link-store -- <store repo>` (`znode link-store <storeRepo> [dir]`) | `tsconfig.store.json` (git-ignored) |
|
|
47
|
+
| The store's plugin folder | Answer the recipe's question, or write it yourself: `{ "pluginsDir": "D:\\znode\\runtime-plugins-store" }` | `znode.local.json` (git-ignored) |
|
|
48
|
+
|
|
49
|
+
Both are per machine: each developer connects their own checkout. Run `link-store` again after the store adds or moves
|
|
50
|
+
modules.
|
|
51
|
+
|
|
52
|
+
## Commands
|
|
53
|
+
|
|
12
54
|
| Command | What it does |
|
|
13
55
|
| --- | --- |
|
|
14
56
|
| `znode build <dir>` | Type-check (with a `tsconfig.json`), then build the server and browser bundles into `dist/` |
|
|
@@ -21,7 +63,16 @@ npm install -D znode-plugin # or add the SDK to an existing pac
|
|
|
21
63
|
| `znode create <kind> <name> [dir]` | A minimal starter of a kind (theme, plugin, widget, content) |
|
|
22
64
|
|
|
23
65
|
`storeDir` (the store's `RUNTIME_PLUGINS_DIR`): the argument, else the `RUNTIME_PLUGINS_DIR` environment variable, else
|
|
24
|
-
`znode.local.json` (`{ "pluginsDir": "…" }`) in the folder the command runs in.
|
|
66
|
+
`znode.local.json` (`{ "pluginsDir": "…" }`) in the folder the command runs in. With none of them, `deploy`, `install`
|
|
67
|
+
and `dev` stop with `needs the store's plugin folder`.
|
|
68
|
+
|
|
69
|
+
## After deploying
|
|
70
|
+
|
|
71
|
+
- **Preview** (your browser only, webstore in development mode):
|
|
72
|
+
`/api/extensions/preview?theme=<name>`, `…&to=/<path>` to open a page, `/api/extensions/preview` to stop.
|
|
73
|
+
`/api/extensions/preview?list` lists the themes the store can see.
|
|
74
|
+
- **Live for a store**: in the plugin folder's `plugins.json`, set the package's `"enabled": true` and add the store
|
|
75
|
+
codes to `"stores"`. Deploying again keeps those settings.
|
|
25
76
|
|
|
26
77
|
## Imports in a package
|
|
27
78
|
|
package/package.json
CHANGED