buildx-cli 1.0.10 → 1.0.12
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 +10 -1
- package/dist/README.md +555 -0
- package/dist/index.cjs +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -0
- package/dist/package.json +64 -0
- package/package.json +7 -2
- package/.github/workflows/auto-publish.yml +0 -254
- package/.github/workflows/create-pr.yml +0 -182
- package/.prettierrc +0 -8
- package/eslint.config.mjs +0 -115
- package/jest.config.cjs +0 -16
- package/rollup.config.mjs +0 -64
- package/scripts/prepare-publish.js +0 -12
- package/src/__tests__/config.test.ts +0 -102
- package/src/__tests__/schema-types-convert.test.ts +0 -147
- package/src/commands/auth/login.ts +0 -148
- package/src/commands/auth/logout.ts +0 -16
- package/src/commands/auth/status.ts +0 -52
- package/src/commands/config/clear.ts +0 -16
- package/src/commands/config/index.ts +0 -14
- package/src/commands/config/setup.ts +0 -108
- package/src/commands/config/show.ts +0 -96
- package/src/commands/functions.ts +0 -703
- package/src/commands/projects/current.ts +0 -36
- package/src/commands/projects/list.ts +0 -61
- package/src/commands/projects/set-default.ts +0 -59
- package/src/commands/sync.ts +0 -778
- package/src/config/index.ts +0 -169
- package/src/index.ts +0 -62
- package/src/services/api.ts +0 -198
- package/src/services/schema-generator.ts +0 -132
- package/src/services/schema-types-convert.ts +0 -361
- package/src/types/index.ts +0 -91
- package/src/utils/env.ts +0 -117
- package/src/utils/logger.ts +0 -29
- package/src/utils/sync.ts +0 -70
- package/test.env +0 -2
- package/tsconfig.json +0 -29
package/README.md
CHANGED
|
@@ -170,6 +170,11 @@ Writes:
|
|
|
170
170
|
- `collections.json` (unless `--skip-collections-code`)
|
|
171
171
|
- `collections.manifest.json`
|
|
172
172
|
|
|
173
|
+
System-managed fields:
|
|
174
|
+
- `createdAt`, `updatedAt`, `createdBy`, `updatedBy` are ensured in pulled `types.ts`
|
|
175
|
+
- injected type mapping: `createdAt/updatedAt => BxDateTime`, `createdBy/updatedBy => BxAuth`
|
|
176
|
+
- these fields are excluded from collections sync payloads (won't be pushed back)
|
|
177
|
+
|
|
173
178
|
Key options:
|
|
174
179
|
- `-p, --project-id <id>`: project to sync from
|
|
175
180
|
- `-t, --target-dir <path>`: base output directory (recommended)
|
|
@@ -200,6 +205,7 @@ Behavior:
|
|
|
200
205
|
- validates minimum shape (`collection_id`, `form_schema`)
|
|
201
206
|
- compares local checksum vs remote checksum
|
|
202
207
|
- skips remote-drift conflicts unless `--force`
|
|
208
|
+
- excludes system-managed fields (`createdAt`, `updatedAt`, `createdBy`, `updatedBy`) from push
|
|
203
209
|
|
|
204
210
|
Key options:
|
|
205
211
|
- `-p, --project-id <id>`
|
|
@@ -218,7 +224,7 @@ Converts a local `types.ts` file into collections JSON first, so you can review
|
|
|
218
224
|
|
|
219
225
|
Reads:
|
|
220
226
|
- `types.ts` (or `--types-file`)
|
|
221
|
-
- base `collections.json` to preserve metadata (
|
|
227
|
+
- optional base `collections.json` to preserve metadata (used when present)
|
|
222
228
|
|
|
223
229
|
Writes:
|
|
224
230
|
- `collections.json` (or `--collections-file`)
|
|
@@ -239,6 +245,9 @@ Field annotations (JSDoc in `types.ts`) are supported:
|
|
|
239
245
|
- `@bx.ref <collection_id_or_enum_key>`
|
|
240
246
|
- `@bx.choices value1:Label 1|value2:Label 2` (for `Choices`/`MultipleChoices`)
|
|
241
247
|
|
|
248
|
+
System-managed fields:
|
|
249
|
+
- `createdAt`, `updatedAt`, `createdBy`, `updatedBy` in `types.ts` are ignored by convert output and never synced back
|
|
250
|
+
|
|
242
251
|
Example:
|
|
243
252
|
```ts
|
|
244
253
|
export type Employees = {
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
# BuildX CLI
|
|
2
|
+
|
|
3
|
+
A command-line interface tool for BuildX API with authentication, project management, and schema synchronization capabilities.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **🔐 Authentication Management**: Secure login/logout with token validation
|
|
8
|
+
- **📁 Project Management**: List, set default, and manage multiple projects
|
|
9
|
+
- **🔄 Schema Synchronization**: Pull and push collections/types as code
|
|
10
|
+
- **⚡ Function Synchronization**: Pull and push function source files as code
|
|
11
|
+
- **⚙️ Configuration Management**: Store settings or use environment variables
|
|
12
|
+
- **🎯 Interactive CLI**: User-friendly command-line interface with prompts
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### Using npx (Recommended)
|
|
17
|
+
```bash
|
|
18
|
+
npx buildx-cli --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Global Installation
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g buildx-cli
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Local Development
|
|
27
|
+
```bash
|
|
28
|
+
git clone <repository-url>
|
|
29
|
+
cd buildx-cli
|
|
30
|
+
yarn install
|
|
31
|
+
yarn build
|
|
32
|
+
yarn start --help
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
1. **Configure API settings:**
|
|
38
|
+
```bash
|
|
39
|
+
npx buildx-cli config:setup
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
2. **Authenticate:**
|
|
43
|
+
```bash
|
|
44
|
+
npx buildx-cli auth:login
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
3. **List projects:**
|
|
48
|
+
```bash
|
|
49
|
+
npx buildx-cli projects:list
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
4. **Pull schema:**
|
|
53
|
+
```bash
|
|
54
|
+
npx buildx-cli schema:pull --project-id <project-id>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
5. **Pull function code:**
|
|
58
|
+
```bash
|
|
59
|
+
npx buildx-cli function:pull --project-id <project-id>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
### Method 1: Interactive Setup
|
|
65
|
+
```bash
|
|
66
|
+
npx buildx-cli config:setup
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Method 2: Environment Variables
|
|
70
|
+
Set these environment variables or add them to a `.env` file:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
BUILDX_API_ENDPOINT=https://api.example.com
|
|
74
|
+
BUILDX_API_KEY=your-api-key
|
|
75
|
+
BUILDX_PROJECT_ID=your-default-project-id
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Supported aliases (auto-resolved):
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
NEXT_PUBLIC_API_ENDPOINT=
|
|
82
|
+
NEXT_PUBLIC_API_KEY=
|
|
83
|
+
NEXT_PUBLIC_BUILDX_PROJECT_ID=
|
|
84
|
+
|
|
85
|
+
NEXT_PUBLIC_BUILDX_API_ENDPOINT=
|
|
86
|
+
NEXT_PUBLIC_BUILDX_API_KEY=
|
|
87
|
+
|
|
88
|
+
BUILDX_API_ENDPOINT=
|
|
89
|
+
BUILDX_API_KEY=
|
|
90
|
+
BUILDX_PROJECT_ID=
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Resolution priority is strict-first:
|
|
94
|
+
- Endpoint: `BUILDX_API_ENDPOINT` -> `NEXT_PUBLIC_BUILDX_API_ENDPOINT` -> `NEXT_PUBLIC_API_ENDPOINT`
|
|
95
|
+
- API key: `BUILDX_API_KEY` -> `NEXT_PUBLIC_BUILDX_API_KEY` -> `NEXT_PUBLIC_API_KEY`
|
|
96
|
+
- Project ID: `BUILDX_PROJECT_ID` -> `NEXT_PUBLIC_BUILDX_PROJECT_ID`
|
|
97
|
+
|
|
98
|
+
When running `config:setup`, CLI auto-detects these values and asks for confirmation before using them.
|
|
99
|
+
|
|
100
|
+
### Method 3: Command Line Options
|
|
101
|
+
```bash
|
|
102
|
+
npx buildx-cli config:setup --endpoint https://api.example.com --api-key your-api-key
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### View Current Configuration
|
|
106
|
+
```bash
|
|
107
|
+
npx buildx-cli config:show
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Clear Configuration
|
|
111
|
+
```bash
|
|
112
|
+
npx buildx-cli config:clear
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Commands
|
|
116
|
+
|
|
117
|
+
### Authentication
|
|
118
|
+
|
|
119
|
+
#### `auth:login`
|
|
120
|
+
Logs in with token or username/password interactively.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx buildx-cli auth:login
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### `auth:logout`
|
|
127
|
+
Clears stored authentication.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npx buildx-cli auth:logout
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### `auth:status`
|
|
134
|
+
Shows current auth state and user details (if available).
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npx buildx-cli auth:status
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Projects
|
|
141
|
+
|
|
142
|
+
#### `projects:list`
|
|
143
|
+
Lists available projects for the authenticated account.
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npx buildx-cli projects:list
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### `projects:set-default <project-id>`
|
|
150
|
+
Sets default project used by commands when `--project-id` is not provided.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npx buildx-cli projects:set-default hello-world
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### `projects:current`
|
|
157
|
+
Shows currently selected default project.
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
npx buildx-cli projects:current
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Schema Commands
|
|
164
|
+
|
|
165
|
+
#### `schema:pull`
|
|
166
|
+
Pulls schema artifacts from remote and writes local files.
|
|
167
|
+
|
|
168
|
+
Writes:
|
|
169
|
+
- `types.ts`
|
|
170
|
+
- `collections.json` (unless `--skip-collections-code`)
|
|
171
|
+
- `collections.manifest.json`
|
|
172
|
+
|
|
173
|
+
System-managed fields:
|
|
174
|
+
- `createdAt`, `updatedAt`, `createdBy`, `updatedBy` are ensured in pulled `types.ts`
|
|
175
|
+
- injected type mapping: `createdAt/updatedAt => BxDateTime`, `createdBy/updatedBy => BxAuth`
|
|
176
|
+
- these fields are excluded from collections sync payloads (won't be pushed back)
|
|
177
|
+
|
|
178
|
+
Key options:
|
|
179
|
+
- `-p, --project-id <id>`: project to sync from
|
|
180
|
+
- `-t, --target-dir <path>`: base output directory (recommended)
|
|
181
|
+
- `-o, --output <path>`: custom types path (when no `--target-dir`)
|
|
182
|
+
- `--collections-file <path>`: custom collections JSON path (when no `--target-dir`)
|
|
183
|
+
- `--filter <pattern...>`: include only matching collection IDs
|
|
184
|
+
- `--include-buildx`: include `buildx_*` collections
|
|
185
|
+
- `--skip-collections-code`: skip collections JSON/manifest output
|
|
186
|
+
- `--no-annotate-types`: disable `@bx.*` annotations injection into pulled `types.ts`
|
|
187
|
+
- `--dry-run`: print full file content previews without writing files
|
|
188
|
+
- `-f, --force`: overwrite even if local file drift is detected
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npx buildx-cli schema:pull --project-id hello-world --target-dir ./.sandbox/buildx-cli
|
|
192
|
+
npx buildx-cli schema:pull --project-id hello-world --dry-run
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
`schema:sync` is still available as a compatibility alias (deprecated).
|
|
196
|
+
|
|
197
|
+
#### `schema:push`
|
|
198
|
+
Pushes local `collections.json` back to remote project.
|
|
199
|
+
|
|
200
|
+
Reads:
|
|
201
|
+
- `collections.json`
|
|
202
|
+
- `collections.manifest.json` (for drift checks)
|
|
203
|
+
|
|
204
|
+
Behavior:
|
|
205
|
+
- validates minimum shape (`collection_id`, `form_schema`)
|
|
206
|
+
- compares local checksum vs remote checksum
|
|
207
|
+
- skips remote-drift conflicts unless `--force`
|
|
208
|
+
- excludes system-managed fields (`createdAt`, `updatedAt`, `createdBy`, `updatedBy`) from push
|
|
209
|
+
|
|
210
|
+
Key options:
|
|
211
|
+
- `-p, --project-id <id>`
|
|
212
|
+
- `-t, --target-dir <path>`
|
|
213
|
+
- `--collections-file <path>` (when no `--target-dir`)
|
|
214
|
+
- `--filter <pattern...>`
|
|
215
|
+
- `--dry-run`
|
|
216
|
+
- `-f, --force`
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npx buildx-cli schema:push --project-id hello-world --target-dir ./.sandbox/buildx-cli --dry-run
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
#### `schema:types:convert`
|
|
223
|
+
Converts a local `types.ts` file into collections JSON first, so you can review before push.
|
|
224
|
+
|
|
225
|
+
Reads:
|
|
226
|
+
- `types.ts` (or `--types-file`)
|
|
227
|
+
- optional base `collections.json` to preserve metadata (used when present)
|
|
228
|
+
|
|
229
|
+
Writes:
|
|
230
|
+
- `collections.json` (or `--collections-file`)
|
|
231
|
+
|
|
232
|
+
Key options:
|
|
233
|
+
- `-t, --target-dir <path>`
|
|
234
|
+
- `--types-file <path>`
|
|
235
|
+
- `--collections-file <path>`
|
|
236
|
+
- `--base-collections-file <path>`
|
|
237
|
+
- `--no-allow-lossy` (strict mode: require base metadata file)
|
|
238
|
+
- `--filter <pattern...>`
|
|
239
|
+
- `--dry-run`
|
|
240
|
+
|
|
241
|
+
Field annotations (JSDoc in `types.ts`) are supported:
|
|
242
|
+
- `@bx.title <text>`
|
|
243
|
+
- `@bx.description <text>`
|
|
244
|
+
- `@bx.required` or `@bx.required false`
|
|
245
|
+
- `@bx.ref <collection_id_or_enum_key>`
|
|
246
|
+
- `@bx.choices value1:Label 1|value2:Label 2` (for `Choices`/`MultipleChoices`)
|
|
247
|
+
|
|
248
|
+
System-managed fields:
|
|
249
|
+
- `createdAt`, `updatedAt`, `createdBy`, `updatedBy` in `types.ts` are ignored by convert output and never synced back
|
|
250
|
+
|
|
251
|
+
Example:
|
|
252
|
+
```ts
|
|
253
|
+
export type Employees = {
|
|
254
|
+
/** @bx.title Employment status @bx.choices active:Active|on_leave:On Leave */
|
|
255
|
+
status?: BxChoices;
|
|
256
|
+
/** @bx.required */
|
|
257
|
+
employee_id?: BxText;
|
|
258
|
+
/** @bx.ref departments @bx.title Department */
|
|
259
|
+
department?: Partial<Departments> | BxDataObject;
|
|
260
|
+
};
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
npx buildx-cli schema:types:convert --target-dir ./.sandbox/buildx-cli --dry-run
|
|
265
|
+
npx buildx-cli schema:types:convert --target-dir ./.sandbox/buildx-cli
|
|
266
|
+
npx buildx-cli schema:push --collections-file ./.sandbox/buildx-cli/collections.json --project-id hello-world --dry-run
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
#### `schema:list`
|
|
270
|
+
Lists remote collections.
|
|
271
|
+
|
|
272
|
+
Key options:
|
|
273
|
+
- `-p, --project-id <id>`
|
|
274
|
+
- `--filter <pattern...>`
|
|
275
|
+
- `--include-buildx`
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
npx buildx-cli schema:list --project-id hello-world --filter "user*"
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
#### `schema:diff`
|
|
282
|
+
Diffs local collections against remote by `collection_id`.
|
|
283
|
+
|
|
284
|
+
Reads:
|
|
285
|
+
- local `collections.json`
|
|
286
|
+
|
|
287
|
+
Output markers:
|
|
288
|
+
- `= same`
|
|
289
|
+
- `~ changed`
|
|
290
|
+
- `+ local-only`
|
|
291
|
+
- `- remote-only`
|
|
292
|
+
|
|
293
|
+
Key options:
|
|
294
|
+
- `-p, --project-id <id>`
|
|
295
|
+
- `-t, --target-dir <path>`
|
|
296
|
+
- `--collections-file <path>` (when no `--target-dir`)
|
|
297
|
+
- `--filter <pattern...>`
|
|
298
|
+
- `--include-buildx`
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
npx buildx-cli schema:diff --project-id hello-world --target-dir ./.sandbox/buildx-cli
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Function Commands
|
|
305
|
+
|
|
306
|
+
#### `function:pull`
|
|
307
|
+
Pulls function context schema and function source code from remote.
|
|
308
|
+
|
|
309
|
+
Writes:
|
|
310
|
+
- `function-context.d.ts`
|
|
311
|
+
- `functions/*.ts`
|
|
312
|
+
- `functions/functions.manifest.json`
|
|
313
|
+
|
|
314
|
+
Behavior:
|
|
315
|
+
- writes a compact `function-context.d.ts` by default (use `--full-context` to keep full remote schema)
|
|
316
|
+
- preserves remote function code as-is by default (safe with existing runtime)
|
|
317
|
+
- optional `--module-wrap` can normalize arrow-function code into module format (`export default`) for local tooling
|
|
318
|
+
- skips overwriting local edited files unless `--force`
|
|
319
|
+
- supports dry-run file content previews
|
|
320
|
+
|
|
321
|
+
Key options:
|
|
322
|
+
- `-p, --project-id <id>`
|
|
323
|
+
- `-t, --target-dir <path>`
|
|
324
|
+
- `--context-output <path>` (when no `--target-dir`)
|
|
325
|
+
- `--functions-dir <path>` (when no `--target-dir`)
|
|
326
|
+
- `--filter <pattern...>`
|
|
327
|
+
- `--full-context`
|
|
328
|
+
- `--module-wrap`
|
|
329
|
+
- `--no-validate-code`
|
|
330
|
+
- `--no-lint`
|
|
331
|
+
- `--dry-run`
|
|
332
|
+
- `-f, --force`
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
npx buildx-cli function:pull --project-id hello-world --target-dir ./.sandbox/buildx-cli
|
|
336
|
+
npx buildx-cli function:pull --project-id hello-world --dry-run
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
`function:sync` is still available as a compatibility alias (deprecated).
|
|
340
|
+
|
|
341
|
+
#### `function:push`
|
|
342
|
+
Pushes local function source files back to remote.
|
|
343
|
+
|
|
344
|
+
Reads:
|
|
345
|
+
- `functions/*.ts`
|
|
346
|
+
- `functions/functions.manifest.json`
|
|
347
|
+
|
|
348
|
+
Behavior:
|
|
349
|
+
- checks remote drift against manifest baseline
|
|
350
|
+
- validates local function code compatibility before push (can bypass via `--no-validate-code`)
|
|
351
|
+
- runs basic syntax lint before push (can bypass via `--no-lint`)
|
|
352
|
+
- skips conflicts unless `--force`
|
|
353
|
+
|
|
354
|
+
Key options:
|
|
355
|
+
- `-p, --project-id <id>`
|
|
356
|
+
- `-t, --target-dir <path>`
|
|
357
|
+
- `--functions-dir <path>` (when no `--target-dir`)
|
|
358
|
+
- `-n, --name <function-name>` for a single function
|
|
359
|
+
- `--filter <pattern...>`
|
|
360
|
+
- `--no-validate-code`
|
|
361
|
+
- `--no-lint`
|
|
362
|
+
- `--dry-run`
|
|
363
|
+
- `-f, --force`
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
npx buildx-cli function:push --project-id hello-world --target-dir ./.sandbox/buildx-cli --dry-run
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
#### `function:list`
|
|
370
|
+
Lists remote function names.
|
|
371
|
+
|
|
372
|
+
Key options:
|
|
373
|
+
- `-p, --project-id <id>`
|
|
374
|
+
- `--filter <pattern...>`
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
npx buildx-cli function:list --project-id hello-world --filter "send*"
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
#### `function:diff`
|
|
381
|
+
Diffs local function sources against remote.
|
|
382
|
+
|
|
383
|
+
Reads:
|
|
384
|
+
- local `functions/*.ts`
|
|
385
|
+
- `functions/functions.manifest.json`
|
|
386
|
+
|
|
387
|
+
Output markers:
|
|
388
|
+
- `= same`
|
|
389
|
+
- `~ changed`
|
|
390
|
+
- `+ local-missing`
|
|
391
|
+
- `- remote-missing`
|
|
392
|
+
- `! remote-drift`
|
|
393
|
+
|
|
394
|
+
Key options:
|
|
395
|
+
- `-p, --project-id <id>`
|
|
396
|
+
- `-t, --target-dir <path>`
|
|
397
|
+
- `--functions-dir <path>` (when no `--target-dir`)
|
|
398
|
+
- `-n, --name <function-name>`
|
|
399
|
+
- `--filter <pattern...>`
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
npx buildx-cli function:diff --project-id hello-world --target-dir ./.sandbox/buildx-cli
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Configuration Commands
|
|
406
|
+
|
|
407
|
+
#### `config:setup`
|
|
408
|
+
Interactive API configuration (`endpoint`, `api key`).
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
npx buildx-cli config:setup
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
#### `config:show`
|
|
415
|
+
Displays current resolved configuration (use this to inspect configured API endpoint).
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
npx buildx-cli config:show
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
#### `config:clear`
|
|
422
|
+
Clears all saved CLI configuration.
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
npx buildx-cli config:clear
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
## Configuration Sources
|
|
429
|
+
|
|
430
|
+
The CLI checks for configuration in this order:
|
|
431
|
+
|
|
432
|
+
1. **Stored Configuration** (via `config:setup`)
|
|
433
|
+
2. **Environment Variables** (`BUILDX_API_ENDPOINT`, `BUILDX_API_KEY`)
|
|
434
|
+
3. **`.env` File** (in current directory)
|
|
435
|
+
|
|
436
|
+
### Configuration File Location
|
|
437
|
+
- **Global config**: `~/.config/buildx-cli-nodejs/config.json`
|
|
438
|
+
|
|
439
|
+
### Environment Variables
|
|
440
|
+
- `BUILDX_API_ENDPOINT` - Your API endpoint URL
|
|
441
|
+
- `BUILDX_API_KEY` - Your API key
|
|
442
|
+
- `BUILDX_PROJECT_ID` - Default project ID (optional)
|
|
443
|
+
- `NEXT_PUBLIC_BUILDX_API_ENDPOINT` - Alias for API endpoint
|
|
444
|
+
- `NEXT_PUBLIC_API_ENDPOINT` - Alias for API endpoint
|
|
445
|
+
- `NEXT_PUBLIC_BUILDX_API_KEY` - Alias for API key
|
|
446
|
+
- `NEXT_PUBLIC_API_KEY` - Alias for API key
|
|
447
|
+
- `NEXT_PUBLIC_BUILDX_PROJECT_ID` - Alias for default project ID
|
|
448
|
+
|
|
449
|
+
## API Endpoints
|
|
450
|
+
|
|
451
|
+
The CLI interacts with the following API endpoints:
|
|
452
|
+
|
|
453
|
+
- `POST /auth/login` - User authentication
|
|
454
|
+
- `GET /auth/me` - Get current user info
|
|
455
|
+
- `GET /projects` - List user projects
|
|
456
|
+
- `GET /project/:project_id/collections/schema` - Fetch project schema types
|
|
457
|
+
- `GET /project/:project_id/collections` - Fetch collections as code
|
|
458
|
+
- `POST /project/:project_id/collections` - Upsert collection
|
|
459
|
+
- `GET /project/:project_id/functions/context/schema/info` - Fetch function context schema info
|
|
460
|
+
- `GET /project/:project_id/functions` - List functions
|
|
461
|
+
- `GET /project/:project_id/functions/:function_name` - Fetch function source
|
|
462
|
+
- `POST /project/:project_id/functions/:function_name` - Upsert function source
|
|
463
|
+
|
|
464
|
+
## Development
|
|
465
|
+
|
|
466
|
+
### Project Structure
|
|
467
|
+
|
|
468
|
+
```
|
|
469
|
+
src/
|
|
470
|
+
├── commands/ # CLI commands
|
|
471
|
+
│ ├── auth/ # Authentication commands
|
|
472
|
+
│ ├── config/ # Configuration commands
|
|
473
|
+
│ ├── projects/ # Project management commands
|
|
474
|
+
│ └── sync.ts # Schema synchronization
|
|
475
|
+
├── services/ # Business logic services
|
|
476
|
+
├── types/ # TypeScript type definitions
|
|
477
|
+
├── utils/ # Utility functions
|
|
478
|
+
├── config/ # Configuration management
|
|
479
|
+
└── index.ts # Main entry point
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### Available Scripts
|
|
483
|
+
|
|
484
|
+
```bash
|
|
485
|
+
yarn build # Build the project
|
|
486
|
+
yarn dev # Run in development mode
|
|
487
|
+
yarn start # Run built version
|
|
488
|
+
yarn test # Run tests
|
|
489
|
+
yarn lint # Run linter
|
|
490
|
+
yarn format # Format code
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### Building
|
|
494
|
+
|
|
495
|
+
```bash
|
|
496
|
+
yarn build
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### Development Mode
|
|
500
|
+
|
|
501
|
+
```bash
|
|
502
|
+
yarn dev
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
## Examples
|
|
506
|
+
|
|
507
|
+
### CI/CD Pipeline
|
|
508
|
+
```bash
|
|
509
|
+
# Set environment variables
|
|
510
|
+
export BUILDX_API_ENDPOINT=https://api.example.com
|
|
511
|
+
export BUILDX_API_KEY=$CI_API_KEY
|
|
512
|
+
export BUILDX_PROJECT_ID=$CI_PROJECT_ID
|
|
513
|
+
|
|
514
|
+
# Run schema pull
|
|
515
|
+
npx buildx-cli schema:pull --project-id $BUILDX_PROJECT_ID --output ./src/types/api.ts
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### Local Development
|
|
519
|
+
```bash
|
|
520
|
+
# Setup once
|
|
521
|
+
npx buildx-cli config:setup
|
|
522
|
+
|
|
523
|
+
# Use regularly
|
|
524
|
+
npx buildx-cli projects:list
|
|
525
|
+
npx buildx-cli schema:pull --project-id my-project
|
|
526
|
+
npx buildx-cli function:pull --project-id my-project
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
### Monorepo Local Shortcuts (No Publish)
|
|
530
|
+
From monorepo root:
|
|
531
|
+
|
|
532
|
+
```bash
|
|
533
|
+
yarn cli:build
|
|
534
|
+
yarn cli --help
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
Isolated test output:
|
|
538
|
+
|
|
539
|
+
```bash
|
|
540
|
+
yarn cli -- schema:pull --project-id my-project --target-dir ./.sandbox/buildx-cli
|
|
541
|
+
yarn cli -- function:pull --project-id my-project --target-dir ./.sandbox/buildx-cli
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
## Contributing
|
|
545
|
+
|
|
546
|
+
1. Fork the repository
|
|
547
|
+
2. Create a feature branch
|
|
548
|
+
3. Make your changes
|
|
549
|
+
4. Add tests for new functionality
|
|
550
|
+
5. Run the test suite
|
|
551
|
+
6. Submit a pull request
|
|
552
|
+
|
|
553
|
+
## License
|
|
554
|
+
|
|
555
|
+
MIT License - see LICENSE file for details.
|