@codemarc/blt 1.4.2 → 1.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 +400 -156
- package/dist/commands/deploy/functions.d.ts +6 -0
- package/dist/commands/deploy/functions.d.ts.map +1 -0
- package/dist/commands/deploy/functions.js +197 -0
- package/dist/commands/deploy/functions.js.map +1 -0
- package/dist/commands/deploy/secrets.d.ts +3 -0
- package/dist/commands/deploy/secrets.d.ts.map +1 -0
- package/dist/commands/deploy/secrets.js +111 -0
- package/dist/commands/deploy/secrets.js.map +1 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +37 -0
- package/dist/commands/deploy.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
# @codemarc/blt
|
|
2
2
|
|
|
3
|
-
> BLT CLI
|
|
3
|
+
> BLT CLI — Command-line tools for image processing, PDF manipulation, storage, schema/data build and deploy, and version management.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **Version
|
|
7
|
+
- **Image**: WebP conversion, sharpening, color manipulation, and enhancement
|
|
8
|
+
- **PDF**: Combine PDFs (binder), create folios with page numbers and table of contents
|
|
9
|
+
- **Version**: Update and manage `version.json`, format version strings, generate version SQL
|
|
10
|
+
- **Build**: Build schema from DDL files, build data from instance directory
|
|
11
|
+
- **Deploy**: Deploy schema/data from SQL files, run a single SQL file
|
|
12
|
+
- **Bucket**: Supabase storage — list buckets, list/upload/download files, get URLs
|
|
13
|
+
- **Show**: Schema info, row counts, env vars, DB version, repo list
|
|
14
|
+
- **Cleanup**: Remove generated SQL/instance files, clean infrequently used YAML tags
|
|
10
15
|
|
|
11
16
|
## Installation
|
|
12
17
|
|
|
@@ -22,73 +27,48 @@ pnpm add -g @codemarc/blt
|
|
|
22
27
|
|
|
23
28
|
## Quick Start
|
|
24
29
|
|
|
25
|
-
### Check Environment
|
|
26
|
-
|
|
27
|
-
Verify your environment setup:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
blt check
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
This command checks for:
|
|
34
|
-
- `.env` file existence
|
|
35
|
-
- `SMASH_KEY` environment variable
|
|
36
|
-
- Other environment configuration
|
|
37
|
-
|
|
38
|
-
### Process Images
|
|
39
|
-
|
|
40
|
-
Convert an image to WebP:
|
|
41
|
-
|
|
42
30
|
```bash
|
|
31
|
+
# Convert an image to WebP
|
|
43
32
|
blt image convert ./photo.jpg
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Sharpen an image:
|
|
47
33
|
|
|
48
|
-
|
|
49
|
-
blt
|
|
50
|
-
```
|
|
34
|
+
# Combine PDFs into one file
|
|
35
|
+
blt pdf binder output.pdf file1.pdf file2.pdf
|
|
51
36
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Update version.json with current build information:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
37
|
+
# Update version.json in current directory
|
|
57
38
|
blt version update
|
|
58
|
-
```
|
|
59
39
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
- Component name (detected from `package.json`)
|
|
63
|
-
- Component version from `package.json`
|
|
64
|
-
- Runtime information (Bun/Node version)
|
|
65
|
-
- Git commit hash and branch
|
|
66
|
-
- Build timestamp
|
|
67
|
-
- Package manager information
|
|
40
|
+
# List Supabase storage buckets
|
|
41
|
+
blt bucket names
|
|
68
42
|
|
|
69
|
-
|
|
43
|
+
# Show schema info
|
|
44
|
+
blt show schema
|
|
70
45
|
|
|
71
|
-
|
|
46
|
+
# Deploy schema from .sql files
|
|
47
|
+
blt deploy schema
|
|
48
|
+
```
|
|
72
49
|
|
|
73
|
-
|
|
50
|
+
## Commands Overview
|
|
74
51
|
|
|
75
|
-
|
|
52
|
+
| Command | Description |
|
|
53
|
+
|---------------|--------------------------------------|
|
|
54
|
+
| `blt image` | Convert, sharpen, enhance, recolor |
|
|
55
|
+
| `blt pdf` | Binder (combine), folio (TOC + pages)|
|
|
56
|
+
| `blt version` | Update, string, sql |
|
|
57
|
+
| `blt build` | Schema (DDL), data (instance) |
|
|
58
|
+
| `blt deploy` | Schema, data, sql file |
|
|
59
|
+
| `blt bucket` | names, list, upload, download, url |
|
|
60
|
+
| `blt show` | schema, counts, env, db, repo |
|
|
61
|
+
| `blt cleanup` | generated, tags |
|
|
76
62
|
|
|
77
|
-
|
|
78
|
-
blt check
|
|
79
|
-
blt check all
|
|
80
|
-
```
|
|
63
|
+
Run `blt <command>` with no subcommand for help (e.g. `blt image`, `blt pdf`).
|
|
81
64
|
|
|
82
|
-
|
|
83
|
-
- Presence of `.env` file
|
|
84
|
-
- `SMASH_KEY` environment variable
|
|
85
|
-
- Other environment configuration
|
|
65
|
+
---
|
|
86
66
|
|
|
87
|
-
|
|
67
|
+
## Image Commands
|
|
88
68
|
|
|
89
|
-
|
|
69
|
+
### `blt image convert <input>`
|
|
90
70
|
|
|
91
|
-
Convert images to WebP format
|
|
71
|
+
Convert images to WebP format.
|
|
92
72
|
|
|
93
73
|
```bash
|
|
94
74
|
blt image convert ./photo.jpg
|
|
@@ -97,14 +77,15 @@ blt image convert ./photo.jpg --quality 90 --output ./photo.webp
|
|
|
97
77
|
```
|
|
98
78
|
|
|
99
79
|
**Options:**
|
|
100
|
-
- `-o, --output <path>`: Output file or directory (default: same location as input)
|
|
101
|
-
- `-q, --quality <quality>`: WebP quality 0-100 (default: 80)
|
|
102
|
-
- `-r, --recursive`: Process directories recursively
|
|
103
|
-
- `--overwrite`: Overwrite existing files
|
|
104
80
|
|
|
105
|
-
|
|
81
|
+
- `-o, --output <path>` — Output file or directory (default: same as input)
|
|
82
|
+
- `-q, --quality <quality>` — WebP quality 0–100 (default: 80)
|
|
83
|
+
- `-r, --recursive` — Process directories recursively
|
|
84
|
+
- `--overwrite` — Overwrite existing files
|
|
85
|
+
|
|
86
|
+
### `blt image sharpen <input>`
|
|
106
87
|
|
|
107
|
-
Sharpen image edges
|
|
88
|
+
Sharpen image edges.
|
|
108
89
|
|
|
109
90
|
```bash
|
|
110
91
|
blt image sharpen ./photo.jpg
|
|
@@ -112,16 +93,17 @@ blt image sharpen ./images/ --recursive
|
|
|
112
93
|
```
|
|
113
94
|
|
|
114
95
|
**Options:**
|
|
115
|
-
- `-o, --output <path>`: Output file or directory (default: same location as input)
|
|
116
|
-
- `-s, --sigma <sigma>`: Sigma value for sharpening 0.3-1000 (default: 1.0)
|
|
117
|
-
- `-f, --flat <flat>`: Flat threshold 0-10000 (default: 1.0)
|
|
118
|
-
- `-j, --jagged <jagged>`: Jagged threshold 0-10000 (default: 2.0)
|
|
119
|
-
- `-r, --recursive`: Process directories recursively
|
|
120
|
-
- `--overwrite`: Overwrite existing files
|
|
121
96
|
|
|
122
|
-
|
|
97
|
+
- `-o, --output <path>` — Output file or directory
|
|
98
|
+
- `-s, --sigma <sigma>` — Sigma for sharpening 0.3–1000 (default: 1.0)
|
|
99
|
+
- `-f, --flat <flat>` — Flat threshold 0–10000 (default: 1.0)
|
|
100
|
+
- `-j, --jagged <jagged>` — Jagged threshold 0–10000 (default: 2.0)
|
|
101
|
+
- `-r, --recursive` — Process directories recursively
|
|
102
|
+
- `--overwrite` — Overwrite existing files
|
|
103
|
+
|
|
104
|
+
### `blt image enhance <input>`
|
|
123
105
|
|
|
124
|
-
Enhance avatar images for dark or light mode
|
|
106
|
+
Enhance avatar images for dark or light mode.
|
|
125
107
|
|
|
126
108
|
```bash
|
|
127
109
|
blt image enhance ./avatar.jpg --mode dark
|
|
@@ -129,13 +111,14 @@ blt image enhance ./avatar.jpg --mode light --quality 95
|
|
|
129
111
|
```
|
|
130
112
|
|
|
131
113
|
**Options:**
|
|
132
|
-
- `-m, --mode <mode>`: Enhancement mode: `dark` or `light` (default: dark)
|
|
133
|
-
- `-o, --output <path>`: Output file path (default: overwrites input)
|
|
134
|
-
- `-q, --quality <quality>`: WebP quality 0-100 (default: 90)
|
|
135
114
|
|
|
136
|
-
|
|
115
|
+
- `-m, --mode <mode>` — `dark` or `light` (default: dark)
|
|
116
|
+
- `-o, --output <path>` — Output path (default: overwrites input)
|
|
117
|
+
- `-q, --quality <quality>` — WebP quality 0–100 (default: 90)
|
|
137
118
|
|
|
138
|
-
|
|
119
|
+
### `blt image color <input>`
|
|
120
|
+
|
|
121
|
+
Change the base color of an image.
|
|
139
122
|
|
|
140
123
|
```bash
|
|
141
124
|
blt image color ./logo.png --to blue
|
|
@@ -143,50 +126,107 @@ blt image color ./logo.png --from red --to blue --tolerance 30
|
|
|
143
126
|
```
|
|
144
127
|
|
|
145
128
|
**Options:**
|
|
146
|
-
- `-t, --to <color>`: Target color (hex, rgb, or color name)
|
|
147
|
-
- `-f, --from <color>`: Source color to replace (hex, rgb, or color name). If not specified, detects dominant color
|
|
148
|
-
- `-o, --output <path>`: Output file path (default: overwrites input)
|
|
149
|
-
- `-q, --quality <quality>`: WebP quality 0-100 (default: 90)
|
|
150
|
-
- `-z, --tolerance <tolerance>`: Color matching tolerance 0-100 (default: 30)
|
|
151
129
|
|
|
152
|
-
|
|
130
|
+
- `-t, --to <color>` — Target color (hex, rgb, or name)
|
|
131
|
+
- `-f, --from <color>` — Source color to replace; if omitted, dominant color is used
|
|
132
|
+
- `-o, --output <path>` — Output path (default: overwrites input)
|
|
133
|
+
- `-q, --quality <quality>` — WebP quality 0–100 (default: 90)
|
|
134
|
+
- `-z, --tolerance <tolerance>` — Color matching tolerance 0–100 (default: 30)
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## PDF Commands
|
|
139
|
+
|
|
140
|
+
PDF manipulation uses the `blt pdf` namespace. Inputs can be files and/or directories (optionally recursive). Non-PDF files are skipped with a warning. Files are processed in alphabetical order.
|
|
141
|
+
|
|
142
|
+
**Dependency:** `pdf-lib`. If needed: `bun install` (or `npm install`).
|
|
143
|
+
|
|
144
|
+
### `blt pdf binder <output> <inputs...>`
|
|
145
|
+
|
|
146
|
+
Combine multiple PDFs into a single document.
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Two files
|
|
150
|
+
blt pdf binder output.pdf file1.pdf file2.pdf
|
|
151
|
+
|
|
152
|
+
# All PDFs in a directory
|
|
153
|
+
blt pdf binder output.pdf /path/to/pdfs/
|
|
154
|
+
|
|
155
|
+
# Mix files and directories (recursive)
|
|
156
|
+
blt pdf binder output.pdf file1.pdf /path/to/pdfs/ file2.pdf -r
|
|
157
|
+
|
|
158
|
+
# Overwrite existing output
|
|
159
|
+
blt pdf binder output.pdf *.pdf --overwrite
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Arguments:**
|
|
163
|
+
|
|
164
|
+
- `<output>` — Output PDF path
|
|
165
|
+
- `<inputs...>` — Input files and/or directories (can be mixed)
|
|
166
|
+
|
|
167
|
+
**Options:**
|
|
168
|
+
|
|
169
|
+
- `-r, --recursive` — Process directories recursively
|
|
170
|
+
- `--overwrite` — Overwrite existing output file
|
|
171
|
+
|
|
172
|
+
**Behavior:** Mix files and directories; non-PDFs skipped with a warning; progress and total page/file count are shown.
|
|
153
173
|
|
|
154
|
-
|
|
174
|
+
### `blt pdf folio <output> <inputs...>`
|
|
155
175
|
|
|
156
|
-
|
|
176
|
+
Create a folio with automatic page numbers and an optional table of contents.
|
|
157
177
|
|
|
158
178
|
```bash
|
|
159
|
-
|
|
179
|
+
# Folio with TOC and page numbers
|
|
180
|
+
blt pdf folio report.pdf *.pdf
|
|
181
|
+
|
|
182
|
+
# Start page number at 10
|
|
183
|
+
blt pdf folio report.pdf chapter1.pdf chapter2.pdf --start-page 10
|
|
184
|
+
|
|
185
|
+
# No table of contents
|
|
186
|
+
blt pdf folio report.pdf /path/to/pdfs/ --no-toc
|
|
187
|
+
|
|
188
|
+
# Recursive directories
|
|
189
|
+
blt pdf folio complete.pdf /docs/ /appendices/ -r
|
|
160
190
|
```
|
|
161
191
|
|
|
162
|
-
|
|
192
|
+
**Arguments:**
|
|
193
|
+
|
|
194
|
+
- `<output>` — Output PDF path
|
|
195
|
+
- `<inputs...>` — Input files and/or directories (can be mixed)
|
|
196
|
+
|
|
197
|
+
**Options:**
|
|
198
|
+
|
|
199
|
+
- `-r, --recursive` — Process directories recursively
|
|
200
|
+
- `--overwrite` — Overwrite existing output file
|
|
201
|
+
- `--no-toc` — Skip table of contents
|
|
202
|
+
- `--start-page <number>` — First page number (default: 1)
|
|
203
|
+
|
|
204
|
+
**Behavior:** Page numbers at bottom center; TOC at start (unless `--no-toc`) with document names and starting pages; professional formatting. Page numbers use light gray (50% opacity). TOC auto-sized (~40 entries per page). `.DS_Store` and hidden files are skipped.
|
|
205
|
+
|
|
206
|
+
**Technical:** Uses `pdf-lib` (^1.17.1). Shell wildcards (e.g. `*.pdf`) and special characters in filenames are supported.
|
|
163
207
|
|
|
164
|
-
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Version Commands
|
|
211
|
+
|
|
212
|
+
### `blt version update`
|
|
213
|
+
|
|
214
|
+
Create or update `version.json` in the current directory with build information.
|
|
165
215
|
|
|
166
216
|
```bash
|
|
167
217
|
blt version update
|
|
168
218
|
```
|
|
169
219
|
|
|
170
|
-
|
|
171
|
-
- Creates `version.json` if it doesn't exist
|
|
172
|
-
- Updates existing `version.json` with current information
|
|
173
|
-
- Works from any directory (uses current working directory)
|
|
174
|
-
- Detects component name from `package.json`
|
|
175
|
-
- Generates a unique build number for each update
|
|
176
|
-
- Includes git commit, branch, and build timestamp
|
|
177
|
-
- Captures runtime and package manager versions
|
|
220
|
+
Fills in: build number (from build-number-generator), component name (from `package.json`), component version, runtime (Bun/Node), git commit and branch, build timestamp, package manager info.
|
|
178
221
|
|
|
179
|
-
**Example `version.json
|
|
222
|
+
**Example `version.json`:**
|
|
180
223
|
|
|
181
224
|
```json
|
|
182
225
|
{
|
|
183
226
|
"buildnum": "260115212",
|
|
184
227
|
"component": "cli",
|
|
185
228
|
"version": "1.1.0",
|
|
186
|
-
"runtime": {
|
|
187
|
-
"type": "bun",
|
|
188
|
-
"version": "1.3.4"
|
|
189
|
-
},
|
|
229
|
+
"runtime": { "type": "bun", "version": "1.3.4" },
|
|
190
230
|
"build": {
|
|
191
231
|
"commit": "c79d284f8d2a3df00af85740cc64010587d12b08",
|
|
192
232
|
"branch": "main",
|
|
@@ -199,40 +239,260 @@ This command:
|
|
|
199
239
|
}
|
|
200
240
|
```
|
|
201
241
|
|
|
202
|
-
**
|
|
242
|
+
**Component mapping:** `@codemarc/blt` / `blt-cli` → `cli`; `blt-core-pos` → `pos`; `blt-core-devops` → `devops`; `data` → `data`; `deploy` → `deploy`; `gateway` → `gateway`.
|
|
203
243
|
|
|
204
|
-
|
|
205
|
-
- `component`: Component name (cli, data, pos, devops, deploy, gateway)
|
|
206
|
-
- `version`: Semantic version from `package.json`
|
|
207
|
-
- `runtime.type`: Runtime type ("bun" or "node")
|
|
208
|
-
- `runtime.version`: Runtime version (e.g., "1.3.4" for Bun, "v25.2.1" for Node)
|
|
209
|
-
- `build.commit`: Full git commit hash
|
|
210
|
-
- `build.branch`: Current git branch name
|
|
211
|
-
- `build.time`: ISO 8601 timestamp of when version.json was updated
|
|
212
|
-
- `metadata.packageManager`: Package manager name ("bun" or "npm")
|
|
213
|
-
- `metadata.packageManagerVersion`: Package manager version
|
|
244
|
+
### `blt version string`
|
|
214
245
|
|
|
215
|
-
|
|
216
|
-
- `@codemarc/blt` or `blt-cli` → `cli`
|
|
217
|
-
- `blt-core-pos` → `pos`
|
|
218
|
-
- `blt-core-devops` → `devops`
|
|
219
|
-
- `data` → `data`
|
|
220
|
-
- `deploy` → `deploy`
|
|
221
|
-
- `gateway` → `gateway`
|
|
246
|
+
Print version as a formatted string.
|
|
222
247
|
|
|
223
|
-
|
|
248
|
+
```bash
|
|
249
|
+
blt version string
|
|
250
|
+
blt version string --short
|
|
251
|
+
blt version string --full --date
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Options:** `-d, --date`, `-o, --only`, `-s, --short`, `-f, --full`.
|
|
255
|
+
|
|
256
|
+
### `blt version sql`
|
|
257
|
+
|
|
258
|
+
Generate SQL to upsert `version.json` into the settings table.
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
blt version sql
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Build Commands
|
|
267
|
+
|
|
268
|
+
### `blt build schema [name]`
|
|
269
|
+
|
|
270
|
+
Build schema from DDL files.
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
blt build schema
|
|
274
|
+
blt build schema my_schema
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### `blt build data [name]`
|
|
278
|
+
|
|
279
|
+
Build data from instance directory.
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
blt build data
|
|
283
|
+
blt build data my_instance
|
|
284
|
+
```
|
|
224
285
|
|
|
225
|
-
|
|
286
|
+
---
|
|
226
287
|
|
|
227
|
-
|
|
288
|
+
## Deploy Commands
|
|
228
289
|
|
|
229
|
-
|
|
290
|
+
### `blt deploy schema [name]`
|
|
291
|
+
|
|
292
|
+
Deploy schema from .sql files.
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
blt deploy schema
|
|
296
|
+
blt deploy schema my_schema
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### `blt deploy data [name]`
|
|
300
|
+
|
|
301
|
+
Deploy data instance from .sql files.
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
blt deploy data
|
|
305
|
+
blt deploy data my_instance
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### `blt deploy sql <file>`
|
|
309
|
+
|
|
310
|
+
Run a single SQL file against the database.
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
blt deploy sql ./migrations/001_init.sql
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Bucket Commands (Supabase Storage)
|
|
319
|
+
|
|
320
|
+
### `blt bucket names`
|
|
321
|
+
|
|
322
|
+
List all bucket names.
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
blt bucket names
|
|
326
|
+
blt bucket names --format json
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Options:** `-f, --format <format>` — `table` or `json` (default: table).
|
|
330
|
+
|
|
331
|
+
### `blt bucket list <bucket-name>`
|
|
332
|
+
|
|
333
|
+
List files in a bucket.
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
blt bucket list my-bucket
|
|
337
|
+
blt bucket list my-bucket --prefix path/ --limit 50
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
**Options:**
|
|
341
|
+
|
|
342
|
+
- `-p, --prefix <prefix>` — Path/prefix filter (default: "")
|
|
343
|
+
- `-l, --limit <limit>` — Max results (default: 100)
|
|
344
|
+
- `-f, --format <format>` — `table` or `json` (default: table).
|
|
345
|
+
|
|
346
|
+
### `blt bucket upload <bucket-name> <local-path> <remote-path>`
|
|
347
|
+
|
|
348
|
+
Upload a file.
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
blt bucket upload my-bucket ./local.pdf docs/file.pdf
|
|
352
|
+
blt bucket upload my-bucket ./local.pdf docs/file.pdf --upsert
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Options:** `--upsert` — Overwrite if exists (default: false).
|
|
356
|
+
|
|
357
|
+
### `blt bucket upload-folder <bucket-name> <local-folder>`
|
|
358
|
+
|
|
359
|
+
Upload all files in a folder.
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
blt bucket upload-folder my-bucket ./public/
|
|
363
|
+
blt bucket upload-folder my-bucket ./public/ -r prefix/
|
|
364
|
+
blt bucket upload-folder my-bucket ./public/ --dry-run
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Options:**
|
|
368
|
+
|
|
369
|
+
- `-r, --remote-prefix <prefix>` — Remote path prefix (default: "")
|
|
370
|
+
- `--upsert` — Overwrite existing files (default: true)
|
|
371
|
+
- `--dry-run` — Show what would be uploaded without uploading.
|
|
372
|
+
|
|
373
|
+
### `blt bucket download <bucket-name> <remote-path> <local-path>`
|
|
374
|
+
|
|
375
|
+
Download a file.
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
blt bucket download my-bucket docs/file.pdf ./local.pdf
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### `blt bucket url <bucket-name> <remote-path>`
|
|
382
|
+
|
|
383
|
+
Get public or signed URL for a file.
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
blt bucket url my-bucket docs/file.pdf
|
|
387
|
+
blt bucket url my-bucket docs/file.pdf --signed --expires-in 7200
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
**Options:**
|
|
391
|
+
|
|
392
|
+
- `--signed` — Generate signed URL (default: false)
|
|
393
|
+
- `--expires-in <seconds>` — Signed URL expiry (default: 3600).
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## Show Commands
|
|
398
|
+
|
|
399
|
+
### `blt show schema [schema-name]`
|
|
400
|
+
|
|
401
|
+
Schema information.
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
blt show schema
|
|
405
|
+
blt show schema core
|
|
406
|
+
blt show schema --format json
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Options:** `-f, --format <format>` — `table` or `json` (default: table).
|
|
410
|
+
|
|
411
|
+
### `blt show counts`
|
|
412
|
+
|
|
413
|
+
Row counts for all tables.
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
blt show counts
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### `blt show env`
|
|
420
|
+
|
|
421
|
+
Display BLT core environment variables.
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
blt show env
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### `blt show db`
|
|
428
|
+
|
|
429
|
+
Display version from database (same format as version string).
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
blt show db
|
|
433
|
+
blt show db --short
|
|
434
|
+
blt show db --full --date
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
**Options:** `-d, --date`, `-o, --only`, `-s, --short`, `-f, --full`.
|
|
438
|
+
|
|
439
|
+
### `blt show repo`
|
|
440
|
+
|
|
441
|
+
List valid repositories in the current working set.
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
blt show repo
|
|
445
|
+
blt show repo --ssh
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
**Options:** `-s, --ssh` — Show SSH URLs instead of HTTPS.
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
## Cleanup Commands
|
|
453
|
+
|
|
454
|
+
### `blt cleanup generated`
|
|
455
|
+
|
|
456
|
+
Remove generated SQL files and instance SQL directories.
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
blt cleanup generated
|
|
460
|
+
blt cleanup generated -i instance1 -i instance2
|
|
461
|
+
blt cleanup generated --all
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
**Options:**
|
|
465
|
+
|
|
466
|
+
- `-i, --instance <instance>` — Instance to clean (repeatable)
|
|
467
|
+
- `-a, --all` — Clean all instances.
|
|
468
|
+
|
|
469
|
+
### `blt cleanup tags <instance>`
|
|
470
|
+
|
|
471
|
+
Clean infrequently used tags in YAML files.
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
blt cleanup tags default
|
|
475
|
+
blt cleanup tags joanne --min-count 2 --dry-run
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
**Options:**
|
|
479
|
+
|
|
480
|
+
- `-m, --min-count <count>` — Minimum tag count to keep (default: 4)
|
|
481
|
+
- `-d, --dry-run` — Show changes without modifying files.
|
|
482
|
+
|
|
483
|
+
---
|
|
484
|
+
|
|
485
|
+
## Environment Variables
|
|
486
|
+
|
|
487
|
+
Bucket and database operations typically use Supabase configuration (e.g. from `.env`). The `blt show env` command displays BLT core environment variables.
|
|
488
|
+
|
|
489
|
+
---
|
|
230
490
|
|
|
231
491
|
## Troubleshooting
|
|
232
492
|
|
|
233
|
-
###
|
|
493
|
+
### Image commands (Sharp)
|
|
234
494
|
|
|
235
|
-
Sharp is an optional dependency.
|
|
495
|
+
Sharp is an optional dependency. If image commands fail, install it:
|
|
236
496
|
|
|
237
497
|
```bash
|
|
238
498
|
bun add sharp
|
|
@@ -240,11 +500,17 @@ bun add sharp
|
|
|
240
500
|
npm install sharp
|
|
241
501
|
```
|
|
242
502
|
|
|
503
|
+
### PDF commands
|
|
504
|
+
|
|
505
|
+
Ensure `pdf-lib` is installed: `bun install` (or `npm install`). The CLI uses `pdf-lib` ^1.17.1 and works with the Bun runtime.
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
243
509
|
## Development
|
|
244
510
|
|
|
245
|
-
|
|
511
|
+
Built with TypeScript and Bun.
|
|
246
512
|
|
|
247
|
-
###
|
|
513
|
+
### Build from source
|
|
248
514
|
|
|
249
515
|
```bash
|
|
250
516
|
git clone https://github.com/codemarc/blt-cli.git
|
|
@@ -254,48 +520,26 @@ bun run build
|
|
|
254
520
|
bun link
|
|
255
521
|
```
|
|
256
522
|
|
|
257
|
-
|
|
258
|
-
- Compiles TypeScript to JavaScript
|
|
259
|
-
- Updates `version.json` with current build information
|
|
260
|
-
- Sets execute permissions on the built binary
|
|
261
|
-
|
|
262
|
-
### Running in Development
|
|
263
|
-
|
|
264
|
-
You can run the CLI directly from source using Bun:
|
|
265
|
-
|
|
266
|
-
```bash
|
|
267
|
-
bun run src/blt.ts check
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
### Version Management
|
|
271
|
-
|
|
272
|
-
The CLI includes a postbuild script that automatically updates `version.json` after each build. The build number is automatically generated and incremented on each update.
|
|
523
|
+
Build compiles TypeScript, updates `version.json`, and sets execute permissions on the binary.
|
|
273
524
|
|
|
274
|
-
|
|
525
|
+
### Run from source
|
|
275
526
|
|
|
276
527
|
```bash
|
|
277
|
-
|
|
278
|
-
blt
|
|
279
|
-
|
|
280
|
-
# Or from the CLI project directory, run the script directly
|
|
281
|
-
bun run src/commands/version/update.ts
|
|
528
|
+
bun run src/blt.ts image convert ./photo.jpg
|
|
529
|
+
bun run src/blt.ts pdf binder output.pdf a.pdf b.pdf
|
|
282
530
|
```
|
|
283
531
|
|
|
284
|
-
|
|
285
|
-
- Read `package.json` from the current directory
|
|
286
|
-
- Create or update `version.json` in the current directory
|
|
287
|
-
- Use git information from the current directory's repository
|
|
288
|
-
- Generate a new build number for each update
|
|
289
|
-
|
|
290
|
-
### Testing
|
|
532
|
+
### Tests
|
|
291
533
|
|
|
292
534
|
```bash
|
|
293
535
|
bun test
|
|
294
536
|
```
|
|
295
537
|
|
|
538
|
+
---
|
|
539
|
+
|
|
296
540
|
## License
|
|
297
541
|
|
|
298
|
-
MIT License
|
|
542
|
+
MIT License — see [LICENSE](LICENSE).
|
|
299
543
|
|
|
300
544
|
## Author
|
|
301
545
|
|
|
@@ -307,4 +551,4 @@ https://github.com/codemarc/blt-cli
|
|
|
307
551
|
|
|
308
552
|
## Support
|
|
309
553
|
|
|
310
|
-
|
|
554
|
+
https://github.com/codemarc/blt-cli/issues
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAwK5C,wBAAsB,eAAe,CACpC,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EACjD,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAiEf"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
const DEFAULT_FUNCTIONS_DIR = "./supabase/functions";
|
|
5
|
+
function exec(command, options = {}) {
|
|
6
|
+
try {
|
|
7
|
+
return execSync(command, {
|
|
8
|
+
encoding: "utf8",
|
|
9
|
+
stdio: options.silent ? "pipe" : "inherit",
|
|
10
|
+
cwd: options.cwd,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (options.ignoreError) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function resolveFunctionsDir(functionsDir) {
|
|
21
|
+
return resolve(process.cwd(), functionsDir ?? DEFAULT_FUNCTIONS_DIR);
|
|
22
|
+
}
|
|
23
|
+
function resolveProjectRoot(functionsDir) {
|
|
24
|
+
const parent = dirname(functionsDir);
|
|
25
|
+
if (basename(functionsDir) === "functions" && basename(parent) === "supabase") {
|
|
26
|
+
return dirname(parent);
|
|
27
|
+
}
|
|
28
|
+
return process.cwd();
|
|
29
|
+
}
|
|
30
|
+
function checkSupabaseCli(logger, cwd) {
|
|
31
|
+
logger.info("Checking Supabase CLI installation...");
|
|
32
|
+
try {
|
|
33
|
+
const version = exec("bunx supabase --version", { silent: true, cwd });
|
|
34
|
+
logger.info(`Supabase CLI found: ${version?.trim() ?? "unknown"}`);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
logger.error("Supabase CLI not found.");
|
|
39
|
+
console.log("Install with: bun install -g supabase");
|
|
40
|
+
console.log("Or use: bunx supabase <command>");
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function checkSupabaseLogin(logger, cwd) {
|
|
45
|
+
logger.info("Checking Supabase authentication...");
|
|
46
|
+
const accessToken = process.env.SUPABASE_ACCESS_TOKEN?.trim();
|
|
47
|
+
if (accessToken) {
|
|
48
|
+
logger.info("Using SUPABASE_ACCESS_TOKEN from environment");
|
|
49
|
+
if (process.env.CI) {
|
|
50
|
+
console.log(`Token length: ${accessToken.length}`);
|
|
51
|
+
console.log(`Token starts with: ${accessToken.substring(0, 10)}...`);
|
|
52
|
+
console.log(`Token ends with: ...${accessToken.substring(accessToken.length - 10)}`);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
exec("bunx supabase projects list", { silent: true, cwd });
|
|
56
|
+
logger.info("Authenticated with Supabase (via token)");
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
logger.error("SUPABASE_ACCESS_TOKEN is invalid or expired.");
|
|
61
|
+
console.log("Get a new token from: https://supabase.com/dashboard/account/tokens");
|
|
62
|
+
console.log("Make sure the token has Functions permissions.");
|
|
63
|
+
if (process.env.CI && error instanceof Error) {
|
|
64
|
+
console.log("Debug info:");
|
|
65
|
+
console.log(`Error: ${error.message}`);
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
exec("bunx supabase projects list", { silent: true, cwd });
|
|
72
|
+
logger.info("Authenticated with Supabase (via CLI)");
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
logger.warn("Not logged in to Supabase.");
|
|
77
|
+
console.log("Options:");
|
|
78
|
+
console.log("1. Login with: bunx supabase login");
|
|
79
|
+
console.log(" Then link project: bunx supabase link --project-ref $" + "{SUPABASE_PROJECT_REF}");
|
|
80
|
+
console.log("2. Set SUPABASE_ACCESS_TOKEN in your environment");
|
|
81
|
+
console.log(" Get token from: https://supabase.com/dashboard/account/tokens");
|
|
82
|
+
console.log(" Make sure token has Functions scope/permissions");
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function getFunctions(functionsDir, logger) {
|
|
87
|
+
if (!existsSync(functionsDir)) {
|
|
88
|
+
logger.error(`Functions directory not found: ${functionsDir}`);
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
return readdirSync(functionsDir)
|
|
92
|
+
.filter((item) => {
|
|
93
|
+
const itemPath = join(functionsDir, item);
|
|
94
|
+
return statSync(itemPath).isDirectory();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function deployFunction(functionName, projectRef, projectRoot, logger) {
|
|
98
|
+
logger.info(`Deploying function: ${functionName}`);
|
|
99
|
+
try {
|
|
100
|
+
const projectFlag = projectRef ? ` --project-ref "${projectRef}"` : "";
|
|
101
|
+
if (projectRef && !process.env.SUPABASE_ACCESS_TOKEN?.trim()) {
|
|
102
|
+
try {
|
|
103
|
+
logger.info("Checking project link...");
|
|
104
|
+
exec(`bunx supabase link --project-ref "${projectRef}"`, {
|
|
105
|
+
silent: true,
|
|
106
|
+
ignoreError: true,
|
|
107
|
+
cwd: projectRoot,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// Ignore link errors (likely already linked)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exec(`bunx supabase functions deploy ${functionName}${projectFlag}`, { cwd: projectRoot });
|
|
115
|
+
logger.info(`Function '${functionName}' deployed successfully`);
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
logger.error(`Failed to deploy function '${functionName}'`);
|
|
120
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
121
|
+
if (message.includes("403") || message.includes("privileges")) {
|
|
122
|
+
console.error("Authentication/Permission Error:");
|
|
123
|
+
console.error("Your account may not have the necessary privileges.");
|
|
124
|
+
console.error("Try one of these solutions:");
|
|
125
|
+
console.error("1. Login with: bunx supabase login");
|
|
126
|
+
if (projectRef) {
|
|
127
|
+
console.error(`2. Link project: bunx supabase link --project-ref ${projectRef}`);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
console.error("2. Link project: bunx supabase link --project-ref <project_ref>");
|
|
131
|
+
}
|
|
132
|
+
console.error("3. Use an access token with Functions permissions:");
|
|
133
|
+
console.error(" Get token: https://supabase.com/dashboard/account/tokens");
|
|
134
|
+
console.error(" Set in your environment: SUPABASE_ACCESS_TOKEN=your_token_here");
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
console.error(message);
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export async function deployFunctions(options, logger) {
|
|
143
|
+
const functionsDir = resolveFunctionsDir(options.functionsDir);
|
|
144
|
+
const projectRoot = resolveProjectRoot(functionsDir);
|
|
145
|
+
if (!checkSupabaseCli(logger, projectRoot) || !checkSupabaseLogin(logger, projectRoot)) {
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
const functions = getFunctions(functionsDir, logger);
|
|
149
|
+
if (functions.length === 0) {
|
|
150
|
+
logger.warn("No functions found to deploy.");
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const projectRef = process.env.SUPABASE_PROJECT_REF?.trim();
|
|
154
|
+
if (options.name) {
|
|
155
|
+
if (!functions.includes(options.name)) {
|
|
156
|
+
logger.error(`Function '${options.name}' not found.`);
|
|
157
|
+
console.log("Available functions:");
|
|
158
|
+
functions.forEach((name) => {
|
|
159
|
+
console.log(` - ${name}`);
|
|
160
|
+
});
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
deployFunction(options.name, projectRef, projectRoot, logger);
|
|
164
|
+
logger.info("Tip: Set secrets with: blt deploy secrets");
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
logger.info(`Found ${functions.length} function(s): ${functions.join(", ")}`);
|
|
168
|
+
const results = {
|
|
169
|
+
success: [],
|
|
170
|
+
failed: [],
|
|
171
|
+
};
|
|
172
|
+
for (const name of functions) {
|
|
173
|
+
if (deployFunction(name, projectRef, projectRoot, logger)) {
|
|
174
|
+
results.success.push(name);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
results.failed.push(name);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
console.log("");
|
|
181
|
+
console.log("Deployment Summary");
|
|
182
|
+
console.log("==================");
|
|
183
|
+
if (results.success.length > 0) {
|
|
184
|
+
logger.info(`${results.success.length} function(s) deployed successfully:`);
|
|
185
|
+
results.success.forEach((name) => {
|
|
186
|
+
console.log(` - ${name}`);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
if (results.failed.length > 0) {
|
|
190
|
+
logger.error(`${results.failed.length} function(s) failed:`);
|
|
191
|
+
results.failed.forEach((name) => {
|
|
192
|
+
console.log(` - ${name}`);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
logger.info("Tip: Set secrets with: blt deploy secrets");
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/commands/deploy/functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAQrD,SAAS,IAAI,CAAC,OAAe,EAAE,UAAuB,EAAE;IACvD,IAAI,CAAC;QACJ,OAAO,QAAQ,CAAC,OAAO,EAAE;YACxB,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YAC1C,GAAG,EAAE,OAAO,CAAC,GAAG;SAChB,CAAC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACzB,OAAO,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AC;IAED,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,sBAAsB,CAAC,CAAC;QAC7D,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC/B,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAyF5C,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyC9D"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
const DEFAULT_PROJECT_REF = "erpofhdbqnvltzggpnrn";
|
|
3
|
+
function exec(command, options = {}) {
|
|
4
|
+
try {
|
|
5
|
+
return execSync(command, {
|
|
6
|
+
encoding: "utf8",
|
|
7
|
+
stdio: options.silent ? "pipe" : "inherit",
|
|
8
|
+
cwd: options.cwd,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (options.ignoreError) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function checkSupabaseCli(logger, cwd) {
|
|
19
|
+
logger.info("Checking Supabase CLI installation...");
|
|
20
|
+
try {
|
|
21
|
+
const version = exec("bunx supabase --version", { silent: true, cwd });
|
|
22
|
+
logger.info(`Supabase CLI found: ${version?.trim() ?? "unknown"}`);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
logger.error("Supabase CLI not found.");
|
|
27
|
+
console.log("Install with: bun install -g supabase");
|
|
28
|
+
console.log("Or use: bunx supabase <command>");
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function checkSupabaseLogin(logger, cwd) {
|
|
33
|
+
logger.info("Checking Supabase authentication...");
|
|
34
|
+
const accessToken = process.env.SUPABASE_ACCESS_TOKEN?.trim();
|
|
35
|
+
if (accessToken) {
|
|
36
|
+
logger.info("Using SUPABASE_ACCESS_TOKEN from environment");
|
|
37
|
+
if (process.env.CI) {
|
|
38
|
+
console.log(`Token length: ${accessToken.length}`);
|
|
39
|
+
console.log(`Token starts with: ${accessToken.substring(0, 10)}...`);
|
|
40
|
+
console.log(`Token ends with: ...${accessToken.substring(accessToken.length - 10)}`);
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
exec("bunx supabase projects list", { silent: true, cwd });
|
|
44
|
+
logger.info("Authenticated with Supabase (via token)");
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
logger.error("SUPABASE_ACCESS_TOKEN is invalid or expired.");
|
|
49
|
+
console.log("Get a new token from: https://supabase.com/dashboard/account/tokens");
|
|
50
|
+
console.log("Make sure the token has Functions permissions.");
|
|
51
|
+
if (process.env.CI && error instanceof Error) {
|
|
52
|
+
console.log("Debug info:");
|
|
53
|
+
console.log(`Error: ${error.message}`);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
exec("bunx supabase projects list", { silent: true, cwd });
|
|
60
|
+
logger.info("Authenticated with Supabase (via CLI)");
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
logger.warn("Not logged in to Supabase.");
|
|
65
|
+
console.log("Options:");
|
|
66
|
+
console.log("1. Login with: bunx supabase login");
|
|
67
|
+
console.log(" Then link project: bunx supabase link --project-ref $" + "{SUPABASE_PROJECT_REF}");
|
|
68
|
+
console.log("2. Set SUPABASE_ACCESS_TOKEN in your environment");
|
|
69
|
+
console.log(" Get token from: https://supabase.com/dashboard/account/tokens");
|
|
70
|
+
console.log(" Make sure token has Functions scope/permissions");
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export async function setSecrets(logger) {
|
|
75
|
+
if (!checkSupabaseCli(logger) || !checkSupabaseLogin(logger)) {
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
const stripeKey = process.env.STRIPE_SECRET_KEY;
|
|
79
|
+
const squareToken = process.env.SQUARE_ACCESS_TOKEN;
|
|
80
|
+
if (!stripeKey && !squareToken) {
|
|
81
|
+
logger.error("No payment provider secrets found in environment variables.");
|
|
82
|
+
console.log("Make sure you have a .env file with one or more of:");
|
|
83
|
+
console.log("STRIPE_SECRET_KEY=sk_test_...");
|
|
84
|
+
console.log("SQUARE_ACCESS_TOKEN=EAAAl...");
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
const projectRef = (process.env.SUPABASE_PROJECT_REF || DEFAULT_PROJECT_REF).trim();
|
|
88
|
+
const projectFlag = ` --project-ref "${projectRef}"`;
|
|
89
|
+
let secretsSet = 0;
|
|
90
|
+
if (stripeKey) {
|
|
91
|
+
logger.info("Setting STRIPE_SECRET_KEY...");
|
|
92
|
+
exec(`bunx supabase secrets set STRIPE_SECRET_KEY="${stripeKey}"${projectFlag}`);
|
|
93
|
+
logger.info("STRIPE_SECRET_KEY set successfully");
|
|
94
|
+
secretsSet++;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
logger.warn("STRIPE_SECRET_KEY not found, skipping...");
|
|
98
|
+
}
|
|
99
|
+
if (squareToken) {
|
|
100
|
+
logger.info("Setting SQUARE_ACCESS_TOKEN...");
|
|
101
|
+
exec(`bunx supabase secrets set SQUARE_ACCESS_TOKEN="${squareToken}"${projectFlag}`);
|
|
102
|
+
logger.info("SQUARE_ACCESS_TOKEN set successfully");
|
|
103
|
+
secretsSet++;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
logger.warn("SQUARE_ACCESS_TOKEN not found, skipping...");
|
|
107
|
+
}
|
|
108
|
+
logger.info(`${secretsSet} secret(s) set successfully`);
|
|
109
|
+
logger.info("You can verify secrets with: bunx supabase secrets list");
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../../src/commands/deploy/secrets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAQnD,SAAS,IAAI,CAAC,OAAe,EAAE,UAAuB,EAAE;IACvD,IAAI,CAAC;QACJ,OAAO,QAAQ,CAAC,OAAO,EAAE;YACxB,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YAC1C,GAAG,EAAE,OAAO,CAAC,GAAG;SAChB,CAAC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACb,CAAC;QACD,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc,EAAE,GAAY;IACrD,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IAErD,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,yBAAyB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;QACvE,MAAM,CAAC,IAAI,C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AC;IACxD,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,eAAe,CAAC;AAO5E;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAO,EAAE,OAAO,QAwGrD"}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { deploySchema } from "./deploy/schema";
|
|
2
2
|
import { deployData } from "./deploy/data";
|
|
3
|
+
import { deployFunctions } from "./deploy/functions";
|
|
4
|
+
import { setSecrets } from "./deploy/secrets";
|
|
3
5
|
import { runSqlFile } from "../lib/database-runner";
|
|
4
6
|
/**
|
|
5
7
|
* Register deploy commands with the CLI program
|
|
@@ -15,6 +17,8 @@ Available operations:
|
|
|
15
17
|
schema Deploy schema from .sql files
|
|
16
18
|
data Deploy data instance from .sql files
|
|
17
19
|
sql Deploy a named SQL file to database
|
|
20
|
+
functions Deploy Supabase Edge Functions
|
|
21
|
+
secrets Set Supabase secrets from environment
|
|
18
22
|
|
|
19
23
|
Run 'blt deploy <operation> --help' for more information on a specific command.
|
|
20
24
|
`;
|
|
@@ -69,5 +73,38 @@ Run 'blt deploy <operation> --help' for more information on a specific command.
|
|
|
69
73
|
process.exit(1);
|
|
70
74
|
}
|
|
71
75
|
});
|
|
76
|
+
program
|
|
77
|
+
.command("deploy functions", "Deploy Supabase Edge Functions")
|
|
78
|
+
.hide()
|
|
79
|
+
.argument("[name]", "Function name")
|
|
80
|
+
.option("--functions-dir <path>", "Path to supabase/functions directory", {
|
|
81
|
+
default: "./supabase/functions",
|
|
82
|
+
})
|
|
83
|
+
.action(async ({ args, options, logger }) => {
|
|
84
|
+
try {
|
|
85
|
+
await deployFunctions({
|
|
86
|
+
name: args.name,
|
|
87
|
+
functionsDir: options.functionsDir,
|
|
88
|
+
}, logger);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
92
|
+
logger.error(`Failed to deploy functions: ${message}`);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
program
|
|
97
|
+
.command("deploy secrets", "Set Supabase secrets from environment")
|
|
98
|
+
.hide()
|
|
99
|
+
.action(async ({ logger }) => {
|
|
100
|
+
try {
|
|
101
|
+
await setSecrets(logger);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
105
|
+
logger.error(`Failed to set secrets: ${message}`);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
72
109
|
}
|
|
73
110
|
//# sourceMappingURL=deploy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAgB;IACrD,MAAM,cAAc,GAAG
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,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