@avsbhq/cli 1.0.0

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 (4) hide show
  1. package/README.md +240 -0
  2. package/bin/avsb.js +2 -0
  3. package/dist/cli.js +36251 -0
  4. package/package.json +54 -0
package/README.md ADDED
@@ -0,0 +1,240 @@
1
+ # @avsbhq/cli
2
+
3
+ CLI tool for local A/B experiment and project script development with the [A vs B](https://app.avsb.cloud) platform.
4
+
5
+ Clone experiments, edit variation code locally in your preferred editor, manage project-level scripts, and push changes back to the platform.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -g @avsbhq/cli
11
+ ```
12
+
13
+ Verify the installation:
14
+
15
+ ```bash
16
+ avsb --version
17
+ ```
18
+
19
+ ## Authentication
20
+
21
+ Before using the CLI, you need to generate a personal API token from the platform.
22
+
23
+ ### Step 1: Generate a token
24
+
25
+ 1. Log in to the [A vs B platform](https://app.avsb.cloud)
26
+ 2. Go to **Account Settings** (click your avatar in the top bar)
27
+ 3. Open the **Personal Auth Tokens** tab
28
+ 4. Click **Generate Token**, give it a name (e.g. "CLI access"), and click **Generate**
29
+ 5. Copy the token immediately -- it won't be shown again
30
+
31
+ > You need the **Developer** role or higher in your organization to generate tokens.
32
+
33
+ ### Step 2: Log in with the CLI
34
+
35
+ ```bash
36
+ avsb login
37
+ ```
38
+
39
+ You'll be prompted for:
40
+
41
+ - **API token** -- paste the token you copied
42
+ - **Default script language** -- JavaScript or TypeScript
43
+ - **Default style language** -- CSS or SCSS
44
+
45
+ ### Logout
46
+
47
+ To remove stored credentials:
48
+
49
+ ```bash
50
+ avsb logout
51
+ ```
52
+
53
+ ## Quick start
54
+
55
+ ### Experiments
56
+
57
+ ```bash
58
+ # 1. Log in (see Authentication above)
59
+ avsb login
60
+
61
+ # 2. Clone an experiment
62
+ avsb clone EXP-42
63
+
64
+ # 3. Edit the variation code in your editor
65
+ cd exp-42
66
+
67
+ # 4. Start dev server with live reload
68
+ avsb dev
69
+
70
+ # 5. Push changes back to the platform
71
+ avsb push
72
+ ```
73
+
74
+ ### Project scripts
75
+
76
+ ```bash
77
+ # 1. Pull a project script
78
+ avsb project pull PRJ-10
79
+
80
+ # 2. Edit the project script in your editor
81
+ cd project-10
82
+
83
+ # 3. Start dev server with live reload
84
+ avsb project dev
85
+
86
+ # 4. Push changes back to the platform
87
+ avsb project push
88
+ ```
89
+
90
+ ## Commands
91
+
92
+ ### General
93
+
94
+ | Command | Description |
95
+ | -------------- | ----------------------------------------------------- |
96
+ | `avsb login` | Authenticate with the A vs B platform |
97
+ | `avsb logout` | Log out and remove stored credentials |
98
+ | `avsb org` | Show current organization |
99
+ | `avsb org list` | List all organizations accessible with your token |
100
+ | `avsb org switch` | Switch to a different organization |
101
+
102
+ ### Experiments
103
+
104
+ | Command | Description |
105
+ | ------------------------- | ----------------------------------------------------------------- |
106
+ | `avsb clone <experiment>` | Clone an experiment locally (accepts URL, EXP-123, or numeric ID) |
107
+ | `avsb status` | Show the status of the current experiment |
108
+ | `avsb dev` | Start dev server with live reload for the browser extension |
109
+ | `avsb pull` | Pull latest experiment data from the platform |
110
+ | `avsb push` | Compile and push local changes to the platform |
111
+
112
+ ### Project scripts
113
+
114
+ | Command | Description |
115
+ | ---------------------------- | -------------------------------------------------------------- |
116
+ | `avsb project pull <project>` | Pull a project script (accepts PRJ-42 or numeric ID) |
117
+ | `avsb project push` | Compile and push project script to the platform |
118
+ | `avsb project dev` | Watch project script and hot-reload via browser extension |
119
+
120
+ ## Experiment workflow
121
+
122
+ ### Clone
123
+
124
+ Fetches experiment data and scaffolds a local directory with editable files.
125
+
126
+ ```bash
127
+ avsb clone EXP-42 # by experiment ID
128
+ avsb clone 42 # by numeric ID
129
+ avsb clone <platform-url> # by URL
130
+ ```
131
+
132
+ ### Push
133
+
134
+ Compiles your local TypeScript/SCSS and pushes the built output to the platform.
135
+
136
+ Before pushing, the CLI checks if the remote experiment has changed since your last sync. If changes are detected, you'll be prompted before overwriting.
137
+
138
+ ```bash
139
+ avsb push # push with conflict check
140
+ avsb push --force # skip conflict check
141
+ ```
142
+
143
+ After a successful push, if the experiment is running, you'll be offered the option to publish changes immediately.
144
+
145
+ ### Pull
146
+
147
+ Fetches the latest experiment data and updates your local files.
148
+
149
+ If you have local edits that would be overwritten, you'll be prompted before proceeding.
150
+
151
+ ```bash
152
+ avsb pull # pull with local change check
153
+ avsb pull --force # skip local change check
154
+ ```
155
+
156
+ ### Dev
157
+
158
+ Starts a WebSocket dev server that watches your local files for changes and hot-reloads them in the browser via the A vs B Chrome extension.
159
+
160
+ ```bash
161
+ avsb dev
162
+ ```
163
+
164
+ ### Status
165
+
166
+ Shows the current experiment's metadata: name, ID, status, variations, languages, last sync time, and platform URL.
167
+
168
+ ```bash
169
+ avsb status
170
+ ```
171
+
172
+ ## Project script workflow
173
+
174
+ Project scripts run on every page where your snippet is active, independent of any experiment.
175
+
176
+ ### Pull
177
+
178
+ Fetches the project script and scaffolds a local directory. Supports both JavaScript and TypeScript projects.
179
+
180
+ ```bash
181
+ avsb project pull PRJ-10 # by project ID
182
+ avsb project pull 10 # by numeric ID
183
+ ```
184
+
185
+ The CLI creates a `project-<id>/` directory containing:
186
+
187
+ ```
188
+ project-10/
189
+ project.ts # or project.js (based on project language)
190
+ .avsb-project.json # manifest (project metadata, do not delete)
191
+ tsconfig.json # TypeScript config (TS projects only)
192
+ avsb.d.ts # type definitions for avsb APIs (TS projects only)
193
+ ```
194
+
195
+ Re-running `project pull` in an existing directory updates the local file from the platform.
196
+
197
+ ### Push
198
+
199
+ Compiles (if TypeScript) and pushes the project script to the platform. The script is pushed to the correct field based on the project's language setting -- JavaScript code goes to `projectJs`, TypeScript code goes to `projectTs`.
200
+
201
+ ```bash
202
+ avsb project push # push with conflict check
203
+ avsb project push --force # skip conflict check
204
+ ```
205
+
206
+ ### Dev
207
+
208
+ Watches the project script for changes and hot-reloads via the browser extension.
209
+
210
+ ```bash
211
+ avsb project dev
212
+ ```
213
+
214
+ ## Experiment project structure
215
+
216
+ After cloning an experiment, your directory looks like this:
217
+
218
+ ```
219
+ exp-42/
220
+ .avsb.manifest.json # manifest (experiment metadata, do not delete)
221
+ trigger.ts # trigger code (when to activate the experiment)
222
+ control/
223
+ control.ts # control variation script
224
+ control.scss # control variation styles
225
+ my-variant/
226
+ my-variant.ts # variant script
227
+ my-variant.scss # variant styles
228
+ ```
229
+
230
+ File extensions depend on the experiment's script/style language setting (`.js`/`.ts`, `.css`/`.scss`).
231
+
232
+ ## Uninstall
233
+
234
+ ```bash
235
+ npm uninstall -g @avsbhq/cli
236
+ ```
237
+
238
+ ## Requirements
239
+
240
+ - Node.js >= 18
package/bin/avsb.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.js'