@embeddables/cli 0.4.1 → 0.4.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.
- package/README.md +148 -45
- package/dist/cli.js +0 -9
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -1,68 +1,171 @@
|
|
|
1
|
-
# Embeddables CLI
|
|
1
|
+
# Embeddables CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A CLI for authoring and managing Embeddables locally using TypeScript/TSX.
|
|
4
4
|
|
|
5
|
-
##
|
|
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
|
-
##
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Install the CLI globally:
|
|
10
20
|
|
|
11
21
|
```bash
|
|
12
|
-
|
|
13
|
-
cd embeddables-cli
|
|
14
|
-
npm install
|
|
22
|
+
npm install -g @embeddables/cli
|
|
15
23
|
```
|
|
16
24
|
|
|
17
|
-
##
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Initialize a new project (will ask for your Embeddables project ID if not skipped)
|
|
29
|
+
embeddables init
|
|
18
30
|
|
|
19
|
-
|
|
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) |
|
|
31
|
+
# Install dependencies
|
|
32
|
+
npm install
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
# Login to your Embeddables account
|
|
35
|
+
embeddables login
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
# Pull an embeddable (shows a list to choose from when logged in)
|
|
38
|
+
embeddables pull
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
npm link
|
|
40
|
+
# Start dev server with hot reload (proxies to production engine by default)
|
|
41
|
+
embeddables dev
|
|
37
42
|
```
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
You can also run the CLI without installing, from this repo:
|
|
44
|
+
This creates the following structure in your repo:
|
|
42
45
|
|
|
43
|
-
```bash
|
|
44
|
-
npx tsx src/cli.ts dev
|
|
45
|
-
# or
|
|
46
|
-
npx tsx src/cli.ts build -i <embeddable-id>
|
|
47
46
|
```
|
|
47
|
+
embeddables/
|
|
48
|
+
<embeddable-id>/
|
|
49
|
+
pages/ # TSX page files
|
|
50
|
+
styles/ # CSS styles
|
|
51
|
+
computed-fields/ # Custom computed field logic
|
|
52
|
+
actions/ # Data output actions
|
|
53
|
+
config.json # Embeddable configuration
|
|
54
|
+
.generated/ # Compiled JSON output
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Commands
|
|
58
|
+
|
|
59
|
+
### `embeddables init`
|
|
60
|
+
|
|
61
|
+
Initialize a new Embeddables project. Creates `package.json`, `embeddables.json`, `.gitignore`, `.types/` (type stubs), and an `embeddables/` directory.
|
|
62
|
+
|
|
63
|
+
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.
|
|
64
|
+
|
|
65
|
+
Options:
|
|
66
|
+
|
|
67
|
+
- `-p, --project-id <id>`: Embeddables project ID (shows list if logged in and not using `--yes`)
|
|
68
|
+
- `-y, --yes`: Skip prompts and use defaults
|
|
69
|
+
|
|
70
|
+
The project ID is stored in `embeddables.json` and enables interactive embeddable selection when running `embeddables pull` and `embeddables save`.
|
|
71
|
+
|
|
72
|
+
### `embeddables login`
|
|
73
|
+
|
|
74
|
+
Authenticate with your Embeddables account.
|
|
75
|
+
|
|
76
|
+
### `embeddables logout`
|
|
77
|
+
|
|
78
|
+
Clear stored authentication.
|
|
79
|
+
|
|
80
|
+
### `embeddables pull`
|
|
48
81
|
|
|
49
|
-
|
|
82
|
+
Fetch an embeddable from the cloud and reverse-compile it into local TSX files.
|
|
50
83
|
|
|
51
|
-
|
|
52
|
-
- **`src/commands/`** — Implementations for `init`, `login`, `logout`, `pull`, `branch`, `build`, `save`, `dev`, `build-workbench`
|
|
53
|
-
- **`src/compiler/`** — TSX → JSON compile and JSON → TSX reverse-compile
|
|
54
|
-
- **`src/config/`** — `embeddables.json` and project config
|
|
55
|
-
- **`src/auth/`** — Login/logout and token storage
|
|
56
|
-
- **`src/prompts/`** — Interactive prompts (projects, embeddables, branches)
|
|
57
|
-
- **`src/proxy/`** — Dev server and engine proxy
|
|
58
|
-
- **`src/components/`** — React primitives exported as `@embeddables/cli/components`
|
|
59
|
-
- **`bin/embeddables.mjs`** — Entry script that runs `dist/cli.js`
|
|
60
|
-
- **`tests/`** — Unit and integration tests (Vitest)
|
|
84
|
+
If you're logged in and run `embeddables pull` without `--id`:
|
|
61
85
|
|
|
62
|
-
|
|
86
|
+
1. If no project is configured, you'll be prompted to select one (saved to `embeddables.json`)
|
|
87
|
+
2. Then you'll see an interactive list of embeddables to choose from
|
|
63
88
|
|
|
64
|
-
|
|
89
|
+
Options:
|
|
90
|
+
|
|
91
|
+
- `-i, --id <id>`: Embeddable ID to pull (skips interactive selection)
|
|
92
|
+
- `-o, --out <path>`: Output path for the compiled JSON (default: `embeddables/<id>/.generated/embeddable.json`)
|
|
93
|
+
- `-b, --branch <branch_id>`: Pull a specific branch version
|
|
94
|
+
- `-f, --fix`: Remove components with missing required props instead of erroring
|
|
95
|
+
|
|
96
|
+
### `embeddables branch`
|
|
97
|
+
|
|
98
|
+
Switch to a different branch of a local embeddable. Shows an interactive list of branches to choose from, then pulls that branch. Requires login.
|
|
99
|
+
|
|
100
|
+
Options:
|
|
101
|
+
|
|
102
|
+
- `-i, --id <id>`: Embeddable ID (will prompt from local embeddables if not provided)
|
|
103
|
+
|
|
104
|
+
### `embeddables build`
|
|
105
|
+
|
|
106
|
+
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`).
|
|
107
|
+
|
|
108
|
+
Options:
|
|
109
|
+
|
|
110
|
+
- `-i, --id <id>` (required): Embeddable ID
|
|
111
|
+
- `-p, --pages <glob>`: Custom pages glob pattern (default: `embeddables/<id>/pages/**/*.page.tsx`)
|
|
112
|
+
- `-o, --out <path>`: Custom output path (default: `embeddables/<id>/.generated/embeddable.json`)
|
|
113
|
+
- `--pageKeyFrom <mode>`: How to derive page keys: `filename` or `export` (default: `filename`)
|
|
114
|
+
|
|
115
|
+
### `embeddables save`
|
|
116
|
+
|
|
117
|
+
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.
|
|
118
|
+
|
|
119
|
+
Options:
|
|
120
|
+
|
|
121
|
+
- `-i, --id <id>`: Embeddable ID (will prompt from local embeddables if not provided)
|
|
122
|
+
- `-l, --label <label>`: Human-readable label for this version
|
|
123
|
+
- `-b, --branch <branch_id>`: Branch ID to save to
|
|
124
|
+
- `-s, --skip-build`: Skip the build step and use existing compiled JSON from `.generated/embeddable.json`
|
|
125
|
+
- `--from-version <number>`: Base version number (auto-detected from local config/files if not provided)
|
|
126
|
+
|
|
127
|
+
### `embeddables dev`
|
|
128
|
+
|
|
129
|
+
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.
|
|
130
|
+
|
|
131
|
+
Options:
|
|
132
|
+
|
|
133
|
+
- `-i, --id <id>`: Embeddable ID (will prompt if not provided)
|
|
134
|
+
- `-p, --pages <glob>`: Custom pages glob
|
|
135
|
+
- `-o, --out <path>`: Output path for compiled JSON
|
|
136
|
+
- `-L, --local`: Use local engine (`http://localhost:8787`) instead of production
|
|
137
|
+
- `-e, --engine <url>`: Engine origin (default: `https://engine.embeddables.com`; overridden by `--local`)
|
|
138
|
+
- `--port <n>`: Dev proxy port (default: `3000`)
|
|
139
|
+
- `--overrideRoute <path>`: Route to override in proxy, exact match (default: `/init`)
|
|
140
|
+
- `--pageKeyFrom <mode>`: `filename` or `export` (default: `filename`)
|
|
141
|
+
|
|
142
|
+
## Authoring with TypeScript
|
|
143
|
+
|
|
144
|
+
Import component primitives for full autocomplete:
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { Container, InputBox, PlainText, CustomButton } from '@embeddables/cli/components'
|
|
148
|
+
|
|
149
|
+
export default function MyPage() {
|
|
150
|
+
return (
|
|
151
|
+
<Container id="main" key="main">
|
|
152
|
+
<PlainText id="title" key="title" text="Welcome!" />
|
|
153
|
+
<InputBox
|
|
154
|
+
id="email"
|
|
155
|
+
key="email"
|
|
156
|
+
input_type="email"
|
|
157
|
+
label="Email"
|
|
158
|
+
placeholder="you@example.com"
|
|
159
|
+
isRequired
|
|
160
|
+
/>
|
|
161
|
+
<CustomButton id="submit" key="submit" text="Continue" action="next-page" />
|
|
162
|
+
</Container>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
```
|
|
65
166
|
|
|
66
|
-
|
|
167
|
+
Package exports:
|
|
67
168
|
|
|
68
|
-
|
|
169
|
+
- `@embeddables/cli` — CLI entry (binary)
|
|
170
|
+
- `@embeddables/cli/components` — React component primitives for authoring
|
|
171
|
+
- `@embeddables/cli/types` — Type definitions for embeddable JSON
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Command } from 'commander';
|
|
|
2
2
|
import pc from 'picocolors';
|
|
3
3
|
import { runBranch } from './commands/branch.js';
|
|
4
4
|
import { runBuild } from './commands/build.js';
|
|
5
|
-
import { runBuildWorkbench } from './commands/build-workbench.js';
|
|
6
5
|
import { runDev } from './commands/dev.js';
|
|
7
6
|
import { runInit } from './commands/init.js';
|
|
8
7
|
import { runLogin } from './commands/login.js';
|
|
@@ -100,12 +99,4 @@ program
|
|
|
100
99
|
.action(async (opts) => {
|
|
101
100
|
await runBranch(opts);
|
|
102
101
|
});
|
|
103
|
-
program
|
|
104
|
-
.command('build-workbench')
|
|
105
|
-
.description('Build Workbench for CDN deployment')
|
|
106
|
-
.option('-o, --out <path>', 'Output directory', 'dist/workbench')
|
|
107
|
-
.option('--no-minify', 'Disable minification (for debugging)')
|
|
108
|
-
.action(async (opts) => {
|
|
109
|
-
await runBuildWorkbench(opts);
|
|
110
|
-
});
|
|
111
102
|
await program.parseAsync(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embeddables/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"embeddables": "./bin/embeddables.mjs"
|
|
@@ -35,13 +35,16 @@
|
|
|
35
35
|
"build:watch": "tsc -p tsconfig.json --watch",
|
|
36
36
|
"dev": "tsx src/cli.ts dev",
|
|
37
37
|
"dev:watch": "tsx src/cli.ts dev",
|
|
38
|
+
"build-workbench": "tsx scripts/run-build-workbench.ts",
|
|
38
39
|
"format": "prettier --write .",
|
|
39
40
|
"format:check": "prettier --check .",
|
|
40
41
|
"lint": "eslint .",
|
|
41
42
|
"test": "vitest",
|
|
42
43
|
"test:watch": "vitest --watch",
|
|
43
44
|
"test:coverage": "vitest --coverage",
|
|
44
|
-
"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"
|
|
45
48
|
},
|
|
46
49
|
"dependencies": {
|
|
47
50
|
"@babel/generator": "^7.28.6",
|