@embeddables/cli 0.4.2 → 0.4.4

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 +145 -47
  2. package/package.json +4 -2
package/README.md CHANGED
@@ -1,70 +1,168 @@
1
- # Embeddables CLI (development)
1
+ # Embeddables CLI
2
2
 
3
- This repo is the source for **@embeddables/cli** — the CLI for authoring and managing Embeddables locally with TypeScript/TSX. If you only want to _use_ the CLI, see the [package on npm](https://www.npmjs.com/package/@embeddables/cli) or the [user-facing README](./package-readme.md) (same content as the npm package page).
3
+ A CLI for authoring and managing Embeddables locally using TypeScript/TSX.
4
4
 
5
- ## Prerequisites
5
+ ## Features
6
+
7
+ - **Pull** existing Embeddables from the cloud and reverse-compile to TSX
8
+ - **Build** TSX pages into the canonical Embeddable JSON format
9
+ - **Save** compiled embeddables back to the cloud (with optional version labels and branches)
10
+ - **Dev** mode with hot reload and proxy to a live Engine instance
11
+ - Full **TypeScript support** with autocomplete for all component primitives
12
+
13
+ ## Requirements
6
14
 
7
15
  - Node.js >= 18.0.0
8
16
 
9
- ## Setup
17
+ ## Installation
18
+
19
+ Install the CLI globally:
10
20
 
11
21
  ```bash
12
- git clone <this-repo>
13
- cd embeddables-cli
14
- npm install
22
+ npm install -g @embeddables/cli
15
23
  ```
16
24
 
17
- ## Scripts
25
+ ## Quick Start
18
26
 
19
- | Script | Description |
20
- | ----------------------- | ----------------------------- |
21
- | `npm run build` | Compile TypeScript to `dist/` |
22
- | `npm run build:watch` | Watch and recompile on change |
23
- | `npm test` | Run tests (Vitest) |
24
- | `npm run test:watch` | Run tests in watch mode |
25
- | `npm run test:coverage` | Coverage report |
26
- | `npm run lint` | ESLint |
27
- | `npm run format` | Prettier (write) |
28
- | `npm run format:check` | Prettier (check only) |
29
- | `npm run build-workbench` | Build Workbench bundle for CDN (e.g. `-- --out workbench-worker`) |
27
+ ```bash
28
+ # Login to your Embeddables account (this applies gobally)
29
+ embeddables login
30
30
 
31
- ## Local testing
31
+ # Initialize a new project, from within a new folder (will ask for your Embeddables project ID if not skipped)
32
+ embeddables init
32
33
 
33
- After building, link the CLI so you can run `embeddables` from another project:
34
+ # Pull an embeddable (shows a list to choose from when logged in)
35
+ embeddables pull
34
36
 
35
- ```bash
36
- npm run build
37
- npm link
37
+ # Start dev server with hot reload (proxies to production engine by default)
38
+ embeddables dev
38
39
  ```
39
40
 
40
- Then in a project that uses the CLI (e.g. an embeddables app), run `embeddables <command>` — it will use your linked build. Unlink with `npm unlink -g @embeddables/cli` when done.
41
-
42
- You can also run the CLI without installing, from this repo:
41
+ This creates the following structure in your repo:
43
42
 
44
- ```bash
45
- npx tsx src/cli.ts dev
46
- # or
47
- npx tsx src/cli.ts build -i <embeddable-id>
48
43
  ```
44
+ embeddables/
45
+ <embeddable-id>/
46
+ pages/ # TSX page files
47
+ styles/ # CSS styles
48
+ computed-fields/ # Custom computed field logic
49
+ actions/ # Data output actions
50
+ config.json # Embeddable configuration
51
+ .generated/ # Compiled JSON output
52
+ ```
53
+
54
+ ## Commands
55
+
56
+ ### `embeddables init`
57
+
58
+ Initialize a new Embeddables project. Creates `embeddables.json`, `.gitignore`, `.types/` (type stubs), `tsconfig.json` (if missing), and an `embeddables/` directory.
59
+
60
+ If you're logged in and don't use `--yes`, you'll see an interactive list of your projects to choose from. Otherwise you can enter a project ID manually or skip.
61
+
62
+ Options:
63
+
64
+ - `-p, --project-id <id>`: Embeddables project ID (shows list if logged in and not using `--yes`)
65
+ - `-y, --yes`: Skip prompts and use defaults
66
+
67
+ The project ID is stored in `embeddables.json` and enables interactive embeddable selection when running `embeddables pull` and `embeddables save`.
68
+
69
+ ### `embeddables login`
70
+
71
+ Authenticate with your Embeddables account.
72
+
73
+ ### `embeddables logout`
74
+
75
+ Clear stored authentication.
76
+
77
+ ### `embeddables pull`
78
+
79
+ Fetch an embeddable from the cloud and reverse-compile it into local TSX files.
49
80
 
50
- ## Project structure
81
+ If you're logged in and run `embeddables pull` without `--id`:
51
82
 
52
- - **`src/cli.ts`** Commander setup and command registration
53
- - **`src/commands/`** Implementations for `init`, `login`, `logout`, `pull`, `branch`, `build`, `save`, `dev`
54
- - **`src/compiler/`** — TSX → JSON compile and JSON → TSX reverse-compile
55
- - **`src/config/`** — `embeddables.json` and project config
56
- - **`src/auth/`** — Login/logout and token storage
57
- - **`src/prompts/`** — Interactive prompts (projects, embeddables, branches)
58
- - **`src/proxy/`** — Dev server and engine proxy
59
- - **`src/components/`** — React primitives exported as `@embeddables/cli/components`
60
- - **`bin/embeddables.mjs`** — Entry script that runs `dist/cli.js`
61
- - **`scripts/run-build-workbench.ts`** — Entry for `npm run build-workbench` (builds Workbench from `src/workbench/` for CDN deploy)
62
- - **`tests/`** — Unit and integration tests (Vitest)
83
+ 1. If no project is configured, you'll be prompted to select one (saved to `embeddables.json`)
84
+ 2. Then you'll see an interactive list of embeddables to choose from
63
85
 
64
- ## Publishing
86
+ Options:
65
87
 
66
- The user-facing README is in **`package-readme.md`**. It is swapped in as `README.md` during `npm pack` / `npm publish` via `prepack`/`postpack` scripts so the npm package shows the right docs. Do not remove those scripts.
88
+ - `-i, --id <id>`: Embeddable ID to pull (skips interactive selection)
89
+ - `-o, --out <path>`: Output path for the compiled JSON (default: `embeddables/<id>/.generated/embeddable.json`)
90
+ - `-b, --branch <branch_id>`: Pull a specific branch version
91
+ - `-f, --fix`: Remove components with missing required props instead of erroring
92
+
93
+ ### `embeddables branch`
94
+
95
+ Switch to a different branch of a local embeddable. Shows an interactive list of branches to choose from, then pulls that branch. Requires login.
96
+
97
+ Options:
98
+
99
+ - `-i, --id <id>`: Embeddable ID (will prompt from local embeddables if not provided)
100
+
101
+ ### `embeddables build`
102
+
103
+ Compile TSX pages into the canonical JSON format. You usually don't need to run this yourself: `embeddables save` builds automatically before uploading (unless you pass `--skip-build`). Use `build` when you only want to compile (e.g. to inspect `.generated/embeddable.json`) or when you run build and save separately (e.g. `build` then `save --skip-build`).
104
+
105
+ Options:
106
+
107
+ - `-i, --id <id>` (required): Embeddable ID
108
+ - `-p, --pages <glob>`: Custom pages glob pattern (default: `embeddables/<id>/pages/**/*.page.tsx`)
109
+ - `-o, --out <path>`: Custom output path (default: `embeddables/<id>/.generated/embeddable.json`)
110
+ - `--pageKeyFrom <mode>`: How to derive page keys: `filename` or `export` (default: `filename`)
111
+
112
+ ### `embeddables save`
113
+
114
+ Build the embeddable (unless `--skip-build` is set) and save it to the cloud. Uses the version in `config.json` or `.generated/` for optimistic concurrency; prompts to force-save if the server has a newer version. Requires login.
115
+
116
+ Options:
117
+
118
+ - `-i, --id <id>`: Embeddable ID (will prompt from local embeddables if not provided)
119
+ - `-l, --label <label>`: Human-readable label for this version
120
+ - `-b, --branch <branch_id>`: Branch ID to save to
121
+ - `-s, --skip-build`: Skip the build step and use existing compiled JSON from `.generated/embeddable.json`
122
+ - `--from-version <number>`: Base version number (auto-detected from local config/files if not provided)
123
+
124
+ ### `embeddables dev`
125
+
126
+ Start a dev server with hot reload. Proxies to the Engine; by default uses production (`https://engine.embeddables.com`). Use `--local` to point to a local engine.
127
+
128
+ Options:
129
+
130
+ - `-i, --id <id>`: Embeddable ID (will prompt if not provided)
131
+ - `-p, --pages <glob>`: Custom pages glob
132
+ - `-o, --out <path>`: Output path for compiled JSON
133
+ - `-L, --local`: Use local engine (`http://localhost:8787`) instead of production
134
+ - `-e, --engine <url>`: Engine origin (default: `https://engine.embeddables.com`; overridden by `--local`)
135
+ - `--port <n>`: Dev proxy port (default: `3000`)
136
+ - `--overrideRoute <path>`: Route to override in proxy, exact match (default: `/init`)
137
+ - `--pageKeyFrom <mode>`: `filename` or `export` (default: `filename`)
138
+
139
+ ## Authoring with TypeScript
140
+
141
+ Import component primitives for full autocomplete:
142
+
143
+ ```tsx
144
+ import { Container, InputBox, PlainText, CustomButton } from '@embeddables/cli/components'
145
+
146
+ export default function MyPage() {
147
+ return (
148
+ <Container id="main" key="main">
149
+ <PlainText id="title" key="title" text="Welcome!" />
150
+ <InputBox
151
+ id="email"
152
+ key="email"
153
+ input_type="email"
154
+ label="Email"
155
+ placeholder="you@example.com"
156
+ isRequired
157
+ />
158
+ <CustomButton id="submit" key="submit" text="Continue" action="next-page" />
159
+ </Container>
160
+ )
161
+ }
162
+ ```
67
163
 
68
- ## User documentation
164
+ Package exports:
69
165
 
70
- Full command reference, installation, and usage for people who install the package: **[package-readme.md](./package-readme.md)**.
166
+ - `@embeddables/cli` CLI entry (binary)
167
+ - `@embeddables/cli/components` — React component primitives for authoring
168
+ - `@embeddables/cli/types` — Type definitions for embeddable JSON
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddables/cli",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "embeddables": "./bin/embeddables.mjs"
@@ -42,7 +42,9 @@
42
42
  "test": "vitest",
43
43
  "test:watch": "vitest --watch",
44
44
  "test:coverage": "vitest --coverage",
45
- "test:verbose": "vitest --reporter verbose"
45
+ "test:verbose": "vitest --reporter verbose",
46
+ "prepack": "node scripts/readme-swap.cjs prepack",
47
+ "postpack": "node scripts/readme-swap.cjs postpack"
46
48
  },
47
49
  "dependencies": {
48
50
  "@babel/generator": "^7.28.6",