@supacontrol/cli 0.1.3 → 0.1.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.
package/README.md CHANGED
@@ -1,19 +1,23 @@
1
- # @supacontrol/cli
2
-
3
- > Safety-first CLI wrapper for Supabase with environment guards and confirmation prompts
4
-
1
+ # @supacontrol/cli
2
+
3
+ > Safety-first CLI wrapper for Supabase with environment guards and confirmation prompts
4
+
5
5
  [![CI](https://github.com/haal-laah/supacontrol/actions/workflows/ci.yml/badge.svg)](https://github.com/haal-laah/supacontrol/actions/workflows/ci.yml)
6
- [![npm version](https://badge.fury.io/js/%40supacontrol%2Fcli.svg)](https://www.npmjs.com/package/@supacontrol/cli)
7
-
8
- ## Why SupaControl?
9
-
10
- The Supabase CLI is powerful but dangerous. One wrong command on the wrong branch can wipe your production database. **SupaControl adds safety guards:**
11
-
12
- - **Environment locking** - Production locked by default
13
- - **Confirmation prompts** - Type environment name to confirm destructive operations
14
- - **Branch-based auto-detection** - Automatically targets the right environment
15
- - **Project ref validation** - Prevents operating on wrong database
16
- - **Clean git checks** - Requires clean working directory for safety
6
+
7
+ ## Why SupaControl?
8
+
9
+ The Supabase CLI is powerful but dangerous. One wrong command on the wrong branch can wipe your production database. **SupaControl adds safety guards:**
10
+
11
+ - **Environment locking** - Production locked by default
12
+ - **Confirmation prompts** - Type environment name to confirm destructive operations
13
+ - **Branch-based auto-detection** - Automatically targets the right environment
14
+ - **Project ref validation** - Prevents operating on wrong database
15
+ - **Clean git checks** - Requires clean working directory for safety
16
+
17
+ ## Prerequisites
18
+
19
+ - **Node.js 20+** - [Download](https://nodejs.org/)
20
+ - **Supabase CLI** - [Installation Guide](https://supabase.com/docs/guides/cli/getting-started)
17
21
 
18
22
  ## Installation
19
23
 
@@ -27,274 +31,274 @@ pnpm add -g @supacontrol/cli
27
31
  # yarn
28
32
  yarn global add @supacontrol/cli
29
33
  ```
30
-
31
- ## Quick Start
32
-
33
- ```bash
34
- # Initialize in your Supabase project (requires supabase init first)
35
- supacontrol init
36
-
37
- # Check current status
38
- supacontrol status
39
-
40
- # Push migrations (with safety guards)
41
- supacontrol push
42
-
43
- # Reset database (requires confirmation)
44
- supacontrol reset
45
- ```
46
-
47
- ## Configuration
48
-
49
- SupaControl uses a `supacontrol.toml` file in your project root:
50
-
51
- ```toml
52
- [settings]
53
- # Fail on any guard warning (default: false)
54
- strict_mode = false
55
-
56
- # Require clean git working tree (default: true)
57
- require_clean_git = true
58
-
59
- # Show migration diff before push (default: true)
60
- show_migration_diff = true
61
-
62
- [environments.staging]
63
- # Supabase project reference
64
- project_ref = "your-staging-project-ref"
65
-
66
- # Git branches that map to this environment
67
- git_branches = ["develop", "staging"]
68
-
69
- # Operations that require confirmation
70
- protected_operations = ["reset"]
71
-
72
- [environments.production]
73
- project_ref = "your-production-project-ref"
74
- git_branches = ["main", "master"]
75
- protected_operations = ["push", "reset", "seed"]
76
-
77
- # Custom confirmation word (default: environment name)
78
- confirm_word = "production"
79
-
80
- # Lock environment (blocks ALL destructive operations)
81
- locked = true
82
- ```
83
-
84
- ### Configuration Options
85
-
86
- #### Settings
87
-
88
- | Option | Type | Default | Description |
89
- |--------|------|---------|-------------|
90
- | `strict_mode` | boolean | `false` | Fail on warnings, not just errors |
91
- | `require_clean_git` | boolean | `true` | Require clean git working directory |
92
- | `show_migration_diff` | boolean | `true` | Show diff before push |
93
-
94
- #### Environment Options
95
-
96
- | Option | Type | Default | Description |
97
- |--------|------|---------|-------------|
98
- | `project_ref` | string | - | Supabase project reference |
99
- | `git_branches` | string[] | `[]` | Branches mapping to this environment |
100
- | `protected_operations` | string[] | `[]` | Operations requiring confirmation |
101
- | `confirm_word` | string | env name | Word to type for confirmation |
102
- | `locked` | boolean | `true` for production | Block all destructive operations |
103
-
104
- #### Protected Operations
105
-
106
- - `push` - Push migrations
107
- - `reset` - Reset database
108
- - `pull` - Pull schema changes
109
- - `seed` - Run seed files
110
- - `link` - Link to project
111
- - `unlink` - Unlink project
112
-
113
- #### Branch Patterns
114
-
115
- Use wildcards to match multiple branches:
116
-
117
- ```toml
118
- [environments.preview]
119
- git_branches = ["feature/*", "pr/*", "preview/*"]
120
- ```
121
-
122
- ## Commands
123
-
124
- ### `supacontrol init`
125
-
126
- Interactive setup wizard to create `supacontrol.toml`.
127
-
128
- ```bash
129
- supacontrol init
130
- ```
131
-
132
- ### `supacontrol status`
133
-
134
- Show current environment, linked project, and configuration.
135
-
136
- ```bash
137
- supacontrol status
138
- ```
139
-
140
- ### `supacontrol push`
141
-
142
- Push local migrations to remote database.
143
-
144
- ```bash
145
- # Auto-detect environment from git branch
146
- supacontrol push
147
-
148
- # Target specific environment
149
- supacontrol push -e staging
150
-
151
- # Dry run (show what would be pushed)
152
- supacontrol push --dry-run
153
-
154
- # Force (bypass guards - use with caution!)
155
- supacontrol push --force
156
- ```
157
-
158
- ### `supacontrol reset`
159
-
160
- Reset remote database (destructive!).
161
-
162
- ```bash
163
- supacontrol reset
164
- ```
165
-
166
- ### `supacontrol pull`
167
-
168
- Pull schema changes from remote database.
169
-
170
- ```bash
171
- supacontrol pull
172
- ```
173
-
174
- ### `supacontrol switch`
175
-
176
- Switch to a different environment (relinks Supabase project).
177
-
178
- ```bash
179
- supacontrol switch staging
180
- supacontrol switch production
181
- ```
182
-
183
- ### `supacontrol lock/unlock`
184
-
185
- Lock or unlock an environment.
186
-
187
- ```bash
188
- supacontrol lock production
189
- supacontrol unlock staging
190
- ```
191
-
192
- ### `supacontrol doctor`
193
-
194
- Health check for your setup.
195
-
196
- ```bash
197
- supacontrol doctor
198
- ```
199
-
200
- ## CI/CD Usage
201
-
202
- ### GitHub Actions
203
-
204
- ```yaml
205
- - name: Install Supabase CLI
206
- uses: supabase/setup-cli@v1
207
- with:
208
- version: latest
209
-
210
- - name: Push migrations
211
- run: supacontrol push -e production --ci
212
- env:
213
- SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
214
- ```
215
-
216
- ### CI Mode Flags
217
-
218
- | Flag | Description |
219
- |------|-------------|
220
- | `--ci` | Non-interactive mode |
221
- | `-e, --env <name>` | Explicit environment target |
222
-
223
- ### Environment Variables
224
-
225
- | Variable | Description |
226
- |----------|-------------|
227
- | `SUPABASE_ACCESS_TOKEN` | Supabase access token for API operations |
228
-
229
- ## Safety Features
230
-
231
- ### Lock Guard
232
-
233
- Production environments are locked by default. Locked environments block ALL destructive operations:
234
-
235
- ```
236
- x Environment 'production' is locked
237
- Suggestions:
238
- - Set 'locked = false' in supacontrol.toml for [environments.production]
239
- - Or use --force flag to override (not recommended for production)
240
- ```
241
-
242
- ### Operation Guard
243
-
244
- Protected operations require typing a confirmation word:
245
-
246
- ```
247
- ! This will reset the staging database
248
- Type 'staging' to confirm:
249
- ```
250
-
251
- ### Project Guard
252
-
253
- Validates that the linked Supabase project matches the expected environment:
254
-
255
- ```
256
- x Project mismatch: linked to 'wrong-project' but 'production' expects 'prod-project'
257
- Suggestions:
258
- - Run 'supabase link --project-ref prod-project' to switch
259
- ```
260
-
261
- ### Git Guard
262
-
263
- Requires clean git working directory for destructive operations:
264
-
265
- ```
266
- x Uncommitted changes detected
267
- Suggestions:
268
- - Commit or stash your changes before running this command
269
- ```
270
-
271
- ## Aliases
272
-
273
- The CLI is available under three names:
274
-
275
- - `supacontrol` - Full name
276
- - `supac` - Short name
277
- - `spc` - Very short name
278
-
279
- ## Contributing
280
-
281
- See [CONTRIBUTING.md](https://github.com/haal-laah/supacontrol/blob/develop/CONTRIBUTING.md) for guidelines.
282
-
283
- ```bash
284
- # Clone the repo
285
- git clone https://github.com/haal-laah/supacontrol.git
286
- cd supacontrol
287
-
288
- # Install dependencies
289
- pnpm install
290
-
291
- # Run tests
292
- pnpm test
293
-
294
- # Build
295
- pnpm build
296
- ```
297
-
298
- ## License
299
-
300
- MIT - see [LICENSE](https://github.com/haal-laah/supacontrol/blob/main/LICENSE) for details.
34
+
35
+ ## Quick Start
36
+
37
+ ```bash
38
+ # Initialize in your Supabase project (requires supabase init first)
39
+ supacontrol init
40
+
41
+ # Check current status
42
+ supacontrol status
43
+
44
+ # Push migrations (with safety guards)
45
+ supacontrol push
46
+
47
+ # Reset database (requires confirmation)
48
+ supacontrol reset
49
+ ```
50
+
51
+ ## Configuration
52
+
53
+ SupaControl uses a `supacontrol.toml` file in your project root:
54
+
55
+ ```toml
56
+ [settings]
57
+ # Fail on any guard warning (default: false)
58
+ strict_mode = false
59
+
60
+ # Require clean git working tree (default: true)
61
+ require_clean_git = true
62
+
63
+ # Show migration diff before push (default: true)
64
+ show_migration_diff = true
65
+
66
+ [environments.staging]
67
+ # Supabase project reference
68
+ project_ref = "your-staging-project-ref"
69
+
70
+ # Git branches that map to this environment
71
+ git_branches = ["develop", "staging"]
72
+
73
+ # Operations that require confirmation
74
+ protected_operations = ["reset"]
75
+
76
+ [environments.production]
77
+ project_ref = "your-production-project-ref"
78
+ git_branches = ["main", "master"]
79
+ protected_operations = ["push", "reset", "seed"]
80
+
81
+ # Custom confirmation word (default: environment name)
82
+ confirm_word = "production"
83
+
84
+ # Lock environment (blocks ALL destructive operations)
85
+ locked = true
86
+ ```
87
+
88
+ ### Configuration Options
89
+
90
+ #### Settings
91
+
92
+ | Option | Type | Default | Description |
93
+ |--------|------|---------|-------------|
94
+ | `strict_mode` | boolean | `false` | Fail on warnings, not just errors |
95
+ | `require_clean_git` | boolean | `true` | Require clean git working directory |
96
+ | `show_migration_diff` | boolean | `true` | Show diff before push |
97
+
98
+ #### Environment Options
99
+
100
+ | Option | Type | Default | Description |
101
+ |--------|------|---------|-------------|
102
+ | `project_ref` | string | - | Supabase project reference |
103
+ | `git_branches` | string[] | `[]` | Branches mapping to this environment |
104
+ | `protected_operations` | string[] | `[]` | Operations requiring confirmation |
105
+ | `confirm_word` | string | env name | Word to type for confirmation |
106
+ | `locked` | boolean | `true` for production | Block all destructive operations |
107
+
108
+ #### Protected Operations
109
+
110
+ - `push` - Push migrations
111
+ - `reset` - Reset database
112
+ - `pull` - Pull schema changes
113
+ - `seed` - Run seed files
114
+ - `link` - Link to project
115
+ - `unlink` - Unlink project
116
+
117
+ #### Branch Patterns
118
+
119
+ Use wildcards to match multiple branches:
120
+
121
+ ```toml
122
+ [environments.preview]
123
+ git_branches = ["feature/*", "pr/*", "preview/*"]
124
+ ```
125
+
126
+ ## Commands
127
+
128
+ ### `supacontrol init`
129
+
130
+ Interactive setup wizard to create `supacontrol.toml`.
131
+
132
+ ```bash
133
+ supacontrol init
134
+ ```
135
+
136
+ ### `supacontrol status`
137
+
138
+ Show current environment, linked project, and configuration.
139
+
140
+ ```bash
141
+ supacontrol status
142
+ ```
143
+
144
+ ### `supacontrol push`
145
+
146
+ Push local migrations to remote database.
147
+
148
+ ```bash
149
+ # Auto-detect environment from git branch
150
+ supacontrol push
151
+
152
+ # Target specific environment
153
+ supacontrol push -e staging
154
+
155
+ # Dry run (show what would be pushed)
156
+ supacontrol push --dry-run
157
+
158
+ # Force (bypass guards - use with caution!)
159
+ supacontrol push --force
160
+ ```
161
+
162
+ ### `supacontrol reset`
163
+
164
+ Reset remote database (destructive!).
165
+
166
+ ```bash
167
+ supacontrol reset
168
+ ```
169
+
170
+ ### `supacontrol pull`
171
+
172
+ Pull schema changes from remote database.
173
+
174
+ ```bash
175
+ supacontrol pull
176
+ ```
177
+
178
+ ### `supacontrol switch`
179
+
180
+ Switch to a different environment (relinks Supabase project).
181
+
182
+ ```bash
183
+ supacontrol switch staging
184
+ supacontrol switch production
185
+ ```
186
+
187
+ ### `supacontrol lock/unlock`
188
+
189
+ Lock or unlock an environment.
190
+
191
+ ```bash
192
+ supacontrol lock production
193
+ supacontrol unlock staging
194
+ ```
195
+
196
+ ### `supacontrol doctor`
197
+
198
+ Health check for your setup.
199
+
200
+ ```bash
201
+ supacontrol doctor
202
+ ```
203
+
204
+ ## CI/CD Usage
205
+
206
+ ### GitHub Actions
207
+
208
+ ```yaml
209
+ - name: Install Supabase CLI
210
+ uses: supabase/setup-cli@v1
211
+ with:
212
+ version: latest
213
+
214
+ - name: Push migrations
215
+ run: supacontrol push -e production --ci
216
+ env:
217
+ SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
218
+ ```
219
+
220
+ ### CI Mode Flags
221
+
222
+ | Flag | Description |
223
+ |------|-------------|
224
+ | `--ci` | Non-interactive mode |
225
+ | `-e, --env <name>` | Explicit environment target |
226
+
227
+ ### Environment Variables
228
+
229
+ | Variable | Description |
230
+ |----------|-------------|
231
+ | `SUPABASE_ACCESS_TOKEN` | Supabase access token for API operations |
232
+
233
+ ## Safety Features
234
+
235
+ ### Lock Guard
236
+
237
+ Production environments are locked by default. Locked environments block ALL destructive operations:
238
+
239
+ ```
240
+ x Environment 'production' is locked
241
+ Suggestions:
242
+ - Set 'locked = false' in supacontrol.toml for [environments.production]
243
+ - Or use --force flag to override (not recommended for production)
244
+ ```
245
+
246
+ ### Operation Guard
247
+
248
+ Protected operations require typing a confirmation word:
249
+
250
+ ```
251
+ ! This will reset the staging database
252
+ Type 'staging' to confirm:
253
+ ```
254
+
255
+ ### Project Guard
256
+
257
+ Validates that the linked Supabase project matches the expected environment:
258
+
259
+ ```
260
+ x Project mismatch: linked to 'wrong-project' but 'production' expects 'prod-project'
261
+ Suggestions:
262
+ - Run 'supabase link --project-ref prod-project' to switch
263
+ ```
264
+
265
+ ### Git Guard
266
+
267
+ Requires clean git working directory for destructive operations:
268
+
269
+ ```
270
+ x Uncommitted changes detected
271
+ Suggestions:
272
+ - Commit or stash your changes before running this command
273
+ ```
274
+
275
+ ## Aliases
276
+
277
+ The CLI is available under three names:
278
+
279
+ - `supacontrol` - Full name
280
+ - `supac` - Short name
281
+ - `spc` - Very short name
282
+
283
+ ## Contributing
284
+
285
+ See [CONTRIBUTING.md](https://github.com/haal-laah/supacontrol/blob/develop/CONTRIBUTING.md) for guidelines.
286
+
287
+ ```bash
288
+ # Clone the repo
289
+ git clone https://github.com/haal-laah/supacontrol.git
290
+ cd supacontrol
291
+
292
+ # Install dependencies
293
+ pnpm install
294
+
295
+ # Run tests
296
+ pnpm test
297
+
298
+ # Build
299
+ pnpm build
300
+ ```
301
+
302
+ ## License
303
+
304
+ MIT - see [LICENSE](https://github.com/haal-laah/supacontrol/blob/main/LICENSE) for details.