powersync 0.3.0 → 0.4.1
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 +88 -74
- package/dist/commands/init.js +12 -12
- package/dist/commands/instance/create.js +3 -3
- package/dist/commands/instance/status.d.ts +1 -1
- package/dist/commands/instance/status.js +9 -9
- package/dist/commands/instance/sync-rules/deploy.js +1 -1
- package/dist/commands/instance/sync-rules/generate-schema.js +1 -1
- package/dist/commands/instance/sync-rules/validate.js +1 -1
- package/dist/commands/instances.js +4 -4
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -1
- package/dist/service/accounts.client.js +72 -68
- package/dist/service/powersync.client.js +102 -90
- package/dist/service/utils.js +27 -27
- package/dist/utils.js +1 -1
- package/oclif.manifest.json +17 -21
- package/package.json +23 -23
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# PowerSync CLI
|
|
2
2
|
|
|
3
|
+
Programmatically manage your [PowerSync](https://www.powersync.com/) environment.
|
|
4
|
+
|
|
5
|
+
For an overview, see the docs [here](https://docs.powersync.com/usage/tools/cli-beta).
|
|
6
|
+
|
|
3
7
|
<!-- toc -->
|
|
4
|
-
|
|
8
|
+
### Table of contents:
|
|
5
9
|
* [Usage](#usage)
|
|
6
10
|
* [Commands](#commands)
|
|
7
11
|
<!-- tocstop -->
|
|
@@ -9,22 +13,32 @@
|
|
|
9
13
|
# Usage
|
|
10
14
|
<!-- usage -->
|
|
11
15
|
```sh-session
|
|
12
|
-
$
|
|
13
|
-
$ powersync COMMAND
|
|
16
|
+
$ npx powersync
|
|
17
|
+
$ npx powersync COMMAND
|
|
14
18
|
running command...
|
|
15
|
-
$ powersync
|
|
16
|
-
powersync/0.3.0 linux-x64 node-v20.11.1
|
|
17
|
-
$ powersync --help [COMMAND]
|
|
19
|
+
$ npx powersync --help [COMMAND]
|
|
18
20
|
USAGE
|
|
19
|
-
$ powersync COMMAND
|
|
21
|
+
$ npx powersync COMMAND
|
|
20
22
|
...
|
|
21
23
|
```
|
|
22
24
|
<!-- usagestop -->
|
|
25
|
+
## Inject ENV variables
|
|
26
|
+
|
|
27
|
+
The following environment variables can be injected:
|
|
28
|
+
|
|
29
|
+
* `AUTH_TOKEN` - The access token used to authenticate with the PowerSync service. [Learn more](https://docs.powersync.com/usage/tools/cli-beta#personal-access-token).
|
|
30
|
+
* `ORG_ID` - The PowerSync organization ID. This is the first UUID in your project's dashboard URL. `123` in this example: `https://powersync.journeyapps.com/org/123/app/456`.
|
|
31
|
+
* `PROJECT_ID` - The PowerSync project ID. This is the second UUID in your project's dashboard URL. `456` in this example: `https://powersync.journeyapps.com/org/123/app/456`.
|
|
32
|
+
* `INSTANCE_ID` - The PowerSync instance ID. Get this by running `npx powersync instances`.
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
|
|
36
|
+
`ORG_ID=123 PROJECT_ID=456 INSTANCE_ID=789 npx powersync instance status`
|
|
23
37
|
|
|
24
38
|
# Commands
|
|
25
39
|
|
|
26
40
|
<!-- commands -->
|
|
27
|
-
* [`powersync help [
|
|
41
|
+
* [`powersync help [COMMAND]`](#powersync-help-command)
|
|
28
42
|
* [`powersync init`](#powersync-init)
|
|
29
43
|
* [`powersync instance config`](#powersync-instance-config)
|
|
30
44
|
* [`powersync instance create`](#powersync-instance-create)
|
|
@@ -39,16 +53,16 @@ USAGE
|
|
|
39
53
|
* [`powersync instance sync-rules validate`](#powersync-instance-sync-rules-validate)
|
|
40
54
|
* [`powersync instances`](#powersync-instances)
|
|
41
55
|
|
|
42
|
-
## `powersync help [
|
|
56
|
+
## `powersync help [COMMAND]`
|
|
43
57
|
|
|
44
58
|
Display help for powersync.
|
|
45
59
|
|
|
46
60
|
```
|
|
47
61
|
USAGE
|
|
48
|
-
$ powersync help [
|
|
62
|
+
$ npx powersync help [COMMAND...] [-n]
|
|
49
63
|
|
|
50
64
|
ARGUMENTS
|
|
51
|
-
|
|
65
|
+
COMMAND... Command to show help for.
|
|
52
66
|
|
|
53
67
|
FLAGS
|
|
54
68
|
-n, --nested-commands Include all nested commands in the output.
|
|
@@ -57,24 +71,25 @@ DESCRIPTION
|
|
|
57
71
|
Display help for powersync.
|
|
58
72
|
```
|
|
59
73
|
|
|
60
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.
|
|
74
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.21/src/commands/help.ts)_
|
|
61
75
|
|
|
62
76
|
## `powersync init`
|
|
63
77
|
|
|
64
78
|
Initialize the CLI.
|
|
79
|
+
Requires an access token. Learn how to generate these [here](https://docs.powersync.com/usage/tools/cli-beta#personal-access-token).
|
|
65
80
|
|
|
66
81
|
```
|
|
67
82
|
USAGE
|
|
68
|
-
$ powersync init
|
|
83
|
+
$ npx powersync init
|
|
69
84
|
|
|
70
85
|
DESCRIPTION
|
|
71
86
|
Initialize the CLI.
|
|
72
87
|
|
|
73
88
|
EXAMPLES
|
|
74
|
-
$ powersync init
|
|
89
|
+
$ npx powersync init
|
|
75
90
|
```
|
|
76
91
|
|
|
77
|
-
_See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
92
|
+
_See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/init.ts)_
|
|
78
93
|
|
|
79
94
|
## `powersync instance config`
|
|
80
95
|
|
|
@@ -82,16 +97,16 @@ Display the instance config.
|
|
|
82
97
|
|
|
83
98
|
```
|
|
84
99
|
USAGE
|
|
85
|
-
$ powersync instance config
|
|
100
|
+
$ npx powersync instance config
|
|
86
101
|
|
|
87
102
|
DESCRIPTION
|
|
88
103
|
Display the instance config.
|
|
89
104
|
|
|
90
105
|
EXAMPLES
|
|
91
|
-
$ powersync instance config
|
|
106
|
+
$ npx powersync instance config
|
|
92
107
|
```
|
|
93
108
|
|
|
94
|
-
_See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
109
|
+
_See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/config.ts)_
|
|
95
110
|
|
|
96
111
|
## `powersync instance create`
|
|
97
112
|
|
|
@@ -99,26 +114,25 @@ Create a new instance.
|
|
|
99
114
|
|
|
100
115
|
```
|
|
101
116
|
USAGE
|
|
102
|
-
$ powersync instance create [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
|
|
103
|
-
[--region
|
|
117
|
+
$ npx powersync instance create [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
|
|
118
|
+
[--region <value>] [--useSupabaseAuth]
|
|
104
119
|
|
|
105
120
|
FLAGS
|
|
106
121
|
--databaseName=<value> Name of the database.
|
|
107
122
|
--hostname=<value> Hostname to connect to database.
|
|
108
123
|
--name=<value> Name of the instance.
|
|
109
124
|
--port=<value> Port number to connect to database.
|
|
110
|
-
--region=<
|
|
111
|
-
<options: US|EU>
|
|
125
|
+
--region=<value> Region to deploy instance to.
|
|
112
126
|
--useSupabaseAuth Use Supabase for auth.
|
|
113
127
|
|
|
114
128
|
DESCRIPTION
|
|
115
129
|
Create a new instance.
|
|
116
130
|
|
|
117
131
|
EXAMPLES
|
|
118
|
-
$ powersync instance create
|
|
132
|
+
$ npx powersync instance create
|
|
119
133
|
```
|
|
120
134
|
|
|
121
|
-
_See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
135
|
+
_See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/create.ts)_
|
|
122
136
|
|
|
123
137
|
## `powersync instance deploy`
|
|
124
138
|
|
|
@@ -126,7 +140,7 @@ Deploy changes to an existing instance.
|
|
|
126
140
|
|
|
127
141
|
```
|
|
128
142
|
USAGE
|
|
129
|
-
$ powersync instance deploy [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
|
|
143
|
+
$ npx powersync instance deploy [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
|
|
130
144
|
[--useSupabaseAuth]
|
|
131
145
|
|
|
132
146
|
FLAGS
|
|
@@ -140,10 +154,10 @@ DESCRIPTION
|
|
|
140
154
|
Deploy changes to an existing instance.
|
|
141
155
|
|
|
142
156
|
EXAMPLES
|
|
143
|
-
$ powersync instance deploy
|
|
157
|
+
$ npx powersync instance deploy
|
|
144
158
|
```
|
|
145
159
|
|
|
146
|
-
_See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
160
|
+
_See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/deploy.ts)_
|
|
147
161
|
|
|
148
162
|
## `powersync instance destroy`
|
|
149
163
|
|
|
@@ -151,7 +165,7 @@ Destroy the current instance - THIS CANNOT BE UNDONE.
|
|
|
151
165
|
|
|
152
166
|
```
|
|
153
167
|
USAGE
|
|
154
|
-
$ powersync instance destroy [-s]
|
|
168
|
+
$ npx powersync instance destroy [-s]
|
|
155
169
|
|
|
156
170
|
FLAGS
|
|
157
171
|
-s, --skipConfirmation Ignore confirmation question.
|
|
@@ -160,10 +174,10 @@ DESCRIPTION
|
|
|
160
174
|
Destroy the current instance - THIS CANNOT BE UNDONE.
|
|
161
175
|
|
|
162
176
|
EXAMPLES
|
|
163
|
-
$ powersync instance destroy
|
|
177
|
+
$ npx powersync instance destroy
|
|
164
178
|
```
|
|
165
179
|
|
|
166
|
-
_See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
180
|
+
_See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/destroy.ts)_
|
|
167
181
|
|
|
168
182
|
## `powersync instance schema`
|
|
169
183
|
|
|
@@ -171,16 +185,16 @@ View the schema of the current instance.
|
|
|
171
185
|
|
|
172
186
|
```
|
|
173
187
|
USAGE
|
|
174
|
-
$ powersync instance schema
|
|
188
|
+
$ npx powersync instance schema
|
|
175
189
|
|
|
176
190
|
DESCRIPTION
|
|
177
191
|
View the schema of the current instance.
|
|
178
192
|
|
|
179
193
|
EXAMPLES
|
|
180
|
-
$ powersync instance schema
|
|
194
|
+
$ npx powersync instance schema
|
|
181
195
|
```
|
|
182
196
|
|
|
183
|
-
_See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
197
|
+
_See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/schema.ts)_
|
|
184
198
|
|
|
185
199
|
## `powersync instance set`
|
|
186
200
|
|
|
@@ -188,7 +202,7 @@ Set the current instance.
|
|
|
188
202
|
|
|
189
203
|
```
|
|
190
204
|
USAGE
|
|
191
|
-
$ powersync instance set [-i <value>]
|
|
205
|
+
$ npx powersync instance set [-i <value>]
|
|
192
206
|
|
|
193
207
|
FLAGS
|
|
194
208
|
-i, --instanceId=<value> Instance ID to change to.
|
|
@@ -197,37 +211,37 @@ DESCRIPTION
|
|
|
197
211
|
Set the current instance.
|
|
198
212
|
|
|
199
213
|
EXAMPLES
|
|
200
|
-
$ powersync instance set
|
|
214
|
+
$ npx powersync instance set
|
|
201
215
|
|
|
202
|
-
$ powersync instance set --instanceId=1234
|
|
216
|
+
$ npx powersync instance set --instanceId=1234
|
|
203
217
|
```
|
|
204
218
|
|
|
205
|
-
_See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
219
|
+
_See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/set.ts)_
|
|
206
220
|
|
|
207
221
|
## `powersync instance status`
|
|
208
222
|
|
|
209
|
-
View the status of the current instance.
|
|
223
|
+
View the status of the current instance. View the status of a different instance by using flags.
|
|
210
224
|
|
|
211
225
|
```
|
|
212
226
|
USAGE
|
|
213
|
-
$ powersync instance status [-
|
|
227
|
+
$ npx powersync instance status [-t <value>] [-i <value>] [-o <value>] [-p <value>]
|
|
214
228
|
|
|
215
229
|
FLAGS
|
|
216
|
-
-
|
|
217
|
-
-
|
|
218
|
-
-
|
|
219
|
-
-t, --authToken=<value> auth token
|
|
230
|
+
-i, --instanceId=<value> Override current instance by providing the ID of a different instance.
|
|
231
|
+
-o, --orgId=<value> Override current organization by providing the ID of a different organization.
|
|
232
|
+
-p, --projectId=<value> Override current project by providing the ID of a different project.
|
|
233
|
+
-t, --authToken=<value> Override current auth token.
|
|
220
234
|
|
|
221
235
|
DESCRIPTION
|
|
222
|
-
View the status of the current instance.
|
|
236
|
+
View the status of the current instance. View the status of a different instance by using flags.
|
|
223
237
|
|
|
224
238
|
EXAMPLES
|
|
225
|
-
$ powersync instance status
|
|
239
|
+
$ npx powersync instance status
|
|
226
240
|
|
|
227
|
-
$ powersync instance status --orgId=1234 --
|
|
241
|
+
$ npx powersync instance status --orgId=1234 --projectId=1234 --instanceId=1234 --authToken=1234
|
|
228
242
|
```
|
|
229
243
|
|
|
230
|
-
_See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
244
|
+
_See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/status.ts)_
|
|
231
245
|
|
|
232
246
|
## `powersync instance stop`
|
|
233
247
|
|
|
@@ -235,7 +249,7 @@ Stop the current instance.
|
|
|
235
249
|
|
|
236
250
|
```
|
|
237
251
|
USAGE
|
|
238
|
-
$ powersync instance stop [-s]
|
|
252
|
+
$ npx powersync instance stop [-s]
|
|
239
253
|
|
|
240
254
|
FLAGS
|
|
241
255
|
-s, --skipConfirmation Ignore confirmation question.
|
|
@@ -244,43 +258,43 @@ DESCRIPTION
|
|
|
244
258
|
Stop the current instance.
|
|
245
259
|
|
|
246
260
|
EXAMPLES
|
|
247
|
-
$ powersync instance stop
|
|
261
|
+
$ npx powersync instance stop
|
|
248
262
|
```
|
|
249
263
|
|
|
250
|
-
_See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
264
|
+
_See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/stop.ts)_
|
|
251
265
|
|
|
252
266
|
## `powersync instance sync-rules deploy`
|
|
253
267
|
|
|
254
|
-
Deploy sync rules from a local sync rules file to the current instance.
|
|
268
|
+
Deploy sync rules from a local sync rules config file to the current instance.
|
|
255
269
|
|
|
256
270
|
```
|
|
257
271
|
USAGE
|
|
258
|
-
$ powersync instance sync-rules deploy -f <value> [-s]
|
|
272
|
+
$ npx powersync instance sync-rules deploy -f <value> [-s]
|
|
259
273
|
|
|
260
274
|
FLAGS
|
|
261
275
|
-f, --filePath=<value> (required) Path to the sync rules config file.
|
|
262
276
|
-s, --skipConfirmation Ignore confirmation question.
|
|
263
277
|
|
|
264
278
|
DESCRIPTION
|
|
265
|
-
Deploy sync rules from a local sync rules file to the current instance.
|
|
279
|
+
Deploy sync rules from a local sync rules config file to the current instance.
|
|
266
280
|
|
|
267
281
|
EXAMPLES
|
|
268
|
-
$ powersync instance sync-rules deploy
|
|
282
|
+
$ npx powersync instance sync-rules deploy
|
|
269
283
|
|
|
270
|
-
$ powersync instance sync-rules deploy --filePath path/to/file
|
|
284
|
+
$ npx powersync instance sync-rules deploy --filePath path/to/file
|
|
271
285
|
|
|
272
|
-
$ powersync instance sync-rules deploy -f path/to/file
|
|
286
|
+
$ npx powersync instance sync-rules deploy -f path/to/file
|
|
273
287
|
```
|
|
274
288
|
|
|
275
|
-
_See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
289
|
+
_See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/sync-rules/deploy.ts)_
|
|
276
290
|
|
|
277
291
|
## `powersync instance sync-rules generate-schema`
|
|
278
292
|
|
|
279
|
-
Generate schema in your language from your sync rules file.
|
|
293
|
+
Generate schema in your language from your sync rules config file.
|
|
280
294
|
|
|
281
295
|
```
|
|
282
296
|
USAGE
|
|
283
|
-
$ powersync instance sync-rules generate-schema -f <value> [-l js|dart]
|
|
297
|
+
$ npx powersync instance sync-rules generate-schema -f <value> [-l js|dart]
|
|
284
298
|
|
|
285
299
|
FLAGS
|
|
286
300
|
-f, --filePath=<value> (required) Path to the sync rules config file.
|
|
@@ -288,41 +302,41 @@ FLAGS
|
|
|
288
302
|
<options: js|dart>
|
|
289
303
|
|
|
290
304
|
DESCRIPTION
|
|
291
|
-
Generate schema in your language from your sync rules file.
|
|
305
|
+
Generate schema in your language from your sync rules config file.
|
|
292
306
|
|
|
293
307
|
EXAMPLES
|
|
294
|
-
$ powersync instance sync-rules generate-schema
|
|
308
|
+
$ npx powersync instance sync-rules generate-schema
|
|
295
309
|
|
|
296
|
-
$ powersync instance sync-rules generate-schema --filePath path/to/file
|
|
310
|
+
$ npx powersync instance sync-rules generate-schema --filePath path/to/file
|
|
297
311
|
|
|
298
|
-
$ powersync instance sync-rules generate-schema -f path/to/file
|
|
312
|
+
$ npx powersync instance sync-rules generate-schema -f path/to/file
|
|
299
313
|
```
|
|
300
314
|
|
|
301
|
-
_See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
315
|
+
_See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/sync-rules/generate-schema.ts)_
|
|
302
316
|
|
|
303
317
|
## `powersync instance sync-rules validate`
|
|
304
318
|
|
|
305
|
-
Validate sync rules from a local sync rules file.
|
|
319
|
+
Validate sync rules from a local sync rules config file.
|
|
306
320
|
|
|
307
321
|
```
|
|
308
322
|
USAGE
|
|
309
|
-
$ powersync instance sync-rules validate -f <value>
|
|
323
|
+
$ npx powersync instance sync-rules validate -f <value>
|
|
310
324
|
|
|
311
325
|
FLAGS
|
|
312
326
|
-f, --filePath=<value> (required) Path to the sync rules config file.
|
|
313
327
|
|
|
314
328
|
DESCRIPTION
|
|
315
|
-
Validate sync rules from a local sync rules file.
|
|
329
|
+
Validate sync rules from a local sync rules config file.
|
|
316
330
|
|
|
317
331
|
EXAMPLES
|
|
318
|
-
$ powersync instance sync-rules validate
|
|
332
|
+
$ npx powersync instance sync-rules validate
|
|
319
333
|
|
|
320
|
-
$ powersync instance sync-rules validate --filePath path/to/file
|
|
334
|
+
$ npx powersync instance sync-rules validate --filePath path/to/file
|
|
321
335
|
|
|
322
|
-
$ powersync instance sync-rules validate -f path/to/file
|
|
336
|
+
$ npx powersync instance sync-rules validate -f path/to/file
|
|
323
337
|
```
|
|
324
338
|
|
|
325
|
-
_See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
339
|
+
_See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instance/sync-rules/validate.ts)_
|
|
326
340
|
|
|
327
341
|
## `powersync instances`
|
|
328
342
|
|
|
@@ -330,14 +344,14 @@ View list of instances.
|
|
|
330
344
|
|
|
331
345
|
```
|
|
332
346
|
USAGE
|
|
333
|
-
$ powersync instances
|
|
347
|
+
$ npx powersync instances
|
|
334
348
|
|
|
335
349
|
DESCRIPTION
|
|
336
350
|
View list of instances.
|
|
337
351
|
|
|
338
352
|
EXAMPLES
|
|
339
|
-
$ powersync instances
|
|
353
|
+
$ npx powersync instances
|
|
340
354
|
```
|
|
341
355
|
|
|
342
|
-
_See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
356
|
+
_See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.4.1/src/commands/instances.ts)_
|
|
343
357
|
<!-- commandsstop -->
|
package/dist/commands/init.js
CHANGED
|
@@ -30,19 +30,19 @@ export default class Init extends Command {
|
|
|
30
30
|
if (numberOfOrganizations > 1) {
|
|
31
31
|
return ux.error(red(`Multiple organizations found. ${SUPPORT_MESSAGE}`), { exit: 1 });
|
|
32
32
|
}
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
return ux.error(red(`No
|
|
33
|
+
const projects = await AccountsClient.getPowerSyncProjects(authTokenAnswers.authToken);
|
|
34
|
+
if (projects.length === 0) {
|
|
35
|
+
return ux.error(red(`No projects found. ${SUPPORT_MESSAGE}`), { exit: 1 });
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const projectQuestions = [
|
|
38
38
|
{
|
|
39
|
-
choices:
|
|
40
|
-
message: 'Which
|
|
41
|
-
name: '
|
|
39
|
+
choices: projects,
|
|
40
|
+
message: 'Which project would you like to use?',
|
|
41
|
+
name: 'projectId',
|
|
42
42
|
type: 'list'
|
|
43
43
|
}
|
|
44
44
|
];
|
|
45
|
-
const
|
|
45
|
+
const projectAnswers = await inquirer.prompt(projectQuestions);
|
|
46
46
|
const orgId = organizations.objects[0].id;
|
|
47
47
|
if (!fs.existsSync(POWERSYNC_DIRECTORY)) {
|
|
48
48
|
fs.mkdirSync(POWERSYNC_DIRECTORY);
|
|
@@ -50,10 +50,10 @@ export default class Init extends Command {
|
|
|
50
50
|
if (fs.existsSync(ENV_FILE_PATH)) {
|
|
51
51
|
fs.unlinkSync(ENV_FILE_PATH);
|
|
52
52
|
}
|
|
53
|
-
fs.writeFileSync(ENV_FILE_PATH, `ORG_ID=${orgId}\
|
|
53
|
+
fs.writeFileSync(ENV_FILE_PATH, `ORG_ID=${orgId}\nPROJECT_ID=${projectAnswers.projectId}\nAUTH_TOKEN=${authTokenAnswers.authToken}\n`);
|
|
54
54
|
ux.log(green('CLI has been initialized'));
|
|
55
|
-
ux.log(`Run ${green(`"${this.config.bin} instances"`)} to view your instances or`);
|
|
56
|
-
ux.log(`run ${green(`"${this.config.bin} instance create"`)} to create an instance or`);
|
|
57
|
-
ux.log(`run ${green(`"${this.config.bin} instance set"`)} to use an already created instance.`);
|
|
55
|
+
ux.log(`Run ${green(`"npx ${this.config.bin} instances"`)} to view your instances or`);
|
|
56
|
+
ux.log(`run ${green(`"npx ${this.config.bin} instance create"`)} to create an instance or`);
|
|
57
|
+
ux.log(`run ${green(`"npx ${this.config.bin} instance set"`)} to use an already created instance.`);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { Command, Flags, ux } from '@oclif/core';
|
|
3
3
|
import inquirer from 'inquirer';
|
|
4
4
|
import ora from 'ora';
|
|
5
|
-
import { REGIONS } from '../../constants.js';
|
|
6
5
|
import * as PowerSyncClient from '../../service/powersync.client.js';
|
|
7
6
|
import { bold, checkForValidEnvFile, green, red, updateEnvFileVariableValue } from '../../utils.js';
|
|
8
7
|
export default class InstanceCreate extends Command {
|
|
@@ -15,12 +14,13 @@ export default class InstanceCreate extends Command {
|
|
|
15
14
|
hostname: Flags.string({ description: 'Hostname to connect to database.' }),
|
|
16
15
|
name: Flags.string({ description: 'Name of the instance.' }),
|
|
17
16
|
port: Flags.integer({ description: 'Port number to connect to database.' }),
|
|
18
|
-
region: Flags.string({ description: 'Region to deploy instance to.'
|
|
17
|
+
region: Flags.string({ description: 'Region to deploy instance to.' }),
|
|
19
18
|
useSupabaseAuth: Flags.boolean({ description: 'Use Supabase for auth.' })
|
|
20
19
|
};
|
|
21
20
|
async run() {
|
|
22
21
|
checkForValidEnvFile(this.config.bin);
|
|
23
22
|
const { flags } = await this.parse(InstanceCreate);
|
|
23
|
+
const regions = await PowerSyncClient.getRegions();
|
|
24
24
|
const questions = [
|
|
25
25
|
{
|
|
26
26
|
message: 'What do you want to name your instance?',
|
|
@@ -32,7 +32,7 @@ export default class InstanceCreate extends Command {
|
|
|
32
32
|
when: !flags.name
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
choices:
|
|
35
|
+
choices: regions.map((region) => region.toUpperCase()),
|
|
36
36
|
message: 'What region do you want to use?',
|
|
37
37
|
name: 'region',
|
|
38
38
|
type: 'list',
|
|
@@ -3,10 +3,10 @@ export default class InstanceStatus extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
appId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
7
6
|
authToken: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
7
|
instanceId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
8
|
orgId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
+
projectId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
10
|
};
|
|
11
11
|
run(): Promise<void>;
|
|
12
12
|
}
|
|
@@ -2,27 +2,27 @@ import { Command, Flags, ux } from '@oclif/core';
|
|
|
2
2
|
import * as PowerSyncClient from '../../service/powersync.client.js';
|
|
3
3
|
import { checkForValidEnvFile, green, red } from '../../utils.js';
|
|
4
4
|
export default class InstanceStatus extends Command {
|
|
5
|
-
static description = 'View the status of the current instance.';
|
|
5
|
+
static description = 'View the status of the current instance. View the status of a different instance by using flags.';
|
|
6
6
|
static examples = [
|
|
7
7
|
'<%= config.bin %> <%= command.id %>',
|
|
8
|
-
'<%= config.bin %> <%= command.id %> --orgId=1234 --
|
|
8
|
+
'<%= config.bin %> <%= command.id %> --orgId=1234 --projectId=1234 --instanceId=1234 --authToken=1234'
|
|
9
9
|
];
|
|
10
10
|
static flags = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
authToken: Flags.string({ char: 't', description: 'Override current auth token.' }),
|
|
12
|
+
instanceId: Flags.string({ char: 'i', description: 'Override current instance by providing the ID of a different instance.' }),
|
|
13
|
+
orgId: Flags.string({ char: 'o', description: 'Override current organization by providing the ID of a different organization.' }),
|
|
14
|
+
projectId: Flags.string({ char: 'p', description: 'Override current project by providing the ID of a different project.' })
|
|
15
15
|
};
|
|
16
16
|
async run() {
|
|
17
17
|
const { flags } = await this.parse(InstanceStatus);
|
|
18
|
-
if (!flags.authToken || !flags.instanceId || !flags.orgId || !flags.
|
|
18
|
+
if (!flags.authToken || !flags.instanceId || !flags.orgId || !flags.projectId) {
|
|
19
19
|
checkForValidEnvFile(this.config.bin, true);
|
|
20
20
|
}
|
|
21
21
|
const diagnostics = await PowerSyncClient.getInstanceDiagnostics({
|
|
22
|
-
appId: flags.appId,
|
|
23
22
|
authToken: flags.authToken,
|
|
24
23
|
instanceId: flags.instanceId,
|
|
25
|
-
orgId: flags.orgId
|
|
24
|
+
orgId: flags.orgId,
|
|
25
|
+
projectId: flags.projectId
|
|
26
26
|
});
|
|
27
27
|
const { errors } = diagnostics.connections[0];
|
|
28
28
|
if (errors.length > 0) {
|
|
@@ -5,7 +5,7 @@ import ora from 'ora';
|
|
|
5
5
|
import * as PowerSyncClient from '../../../service/powersync.client.js';
|
|
6
6
|
import { bold, checkForValidEnvFile, green, red } from '../../../utils.js';
|
|
7
7
|
export default class SyncRulesDeploy extends Command {
|
|
8
|
-
static description = 'Deploy sync rules from a local sync rules file to the current instance.';
|
|
8
|
+
static description = 'Deploy sync rules from a local sync rules config file to the current instance.';
|
|
9
9
|
static examples = [
|
|
10
10
|
'<%= config.bin %> <%= command.id %>',
|
|
11
11
|
'<%= config.bin %> <%= command.id %> --filePath path/to/file',
|
|
@@ -5,7 +5,7 @@ import { LANGUAGES } from '../../../constants.js';
|
|
|
5
5
|
import * as PowerSyncClient from '../../../service/powersync.client.js';
|
|
6
6
|
import { checkForValidEnvFile, green, red } from '../../../utils.js';
|
|
7
7
|
export default class SyncRulesGenerateSchema extends Command {
|
|
8
|
-
static description = 'Generate schema in your language from your sync rules file.';
|
|
8
|
+
static description = 'Generate schema in your language from your sync rules config file.';
|
|
9
9
|
static examples = [
|
|
10
10
|
'<%= config.bin %> <%= command.id %>',
|
|
11
11
|
'<%= config.bin %> <%= command.id %> --filePath path/to/file',
|
|
@@ -3,7 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import * as PowerSyncClient from '../../../service/powersync.client.js';
|
|
4
4
|
import { checkForValidEnvFile, green, red } from '../../../utils.js';
|
|
5
5
|
export default class SyncRulesValidate extends Command {
|
|
6
|
-
static description = 'Validate sync rules from a local sync rules file.';
|
|
6
|
+
static description = 'Validate sync rules from a local sync rules config file.';
|
|
7
7
|
static examples = [
|
|
8
8
|
'<%= config.bin %> <%= command.id %>',
|
|
9
9
|
'<%= config.bin %> <%= command.id %> --filePath path/to/file',
|
|
@@ -7,13 +7,13 @@ export default class InstancesList extends Command {
|
|
|
7
7
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
8
8
|
async run() {
|
|
9
9
|
checkForValidEnvFile(this.config.bin, false);
|
|
10
|
-
const
|
|
10
|
+
const project = await AccountsClient.getCurrentPowerSyncProject();
|
|
11
11
|
const list = await PowerSyncClient.getInstancesList();
|
|
12
12
|
const { instances } = list;
|
|
13
13
|
if (instances.length === 0) {
|
|
14
|
-
return ux.log(`It seems like you have ${red('no')} instances. Run ${green(
|
|
14
|
+
return ux.log(`It seems like you have ${red('no')} instances. Run ${green(`"npx ${this.config.bin} instance create"`)} to create your first instance.`);
|
|
15
15
|
}
|
|
16
|
-
ux.log(`Your ${bold('
|
|
16
|
+
ux.log(`Your ${bold('project')} is currently set to ${green(project.name)}.`);
|
|
17
17
|
if (process.env.INSTANCE_ID) {
|
|
18
18
|
const currentInstance = instances.find((instance) => instance.id === process.env.INSTANCE_ID);
|
|
19
19
|
if (currentInstance) {
|
|
@@ -24,6 +24,6 @@ export default class InstancesList extends Command {
|
|
|
24
24
|
id: { header: 'ID' },
|
|
25
25
|
name: { minWidth: 7 }
|
|
26
26
|
}, { printLine: this.log.bind(this) });
|
|
27
|
-
ux.log(`\nRun ${green(`"${this.config.bin} instance set"`)} to use one of the instances.`);
|
|
27
|
+
ux.log(`\nRun ${green(`"npx ${this.config.bin} instance set"`)} to use one of the instances.`);
|
|
28
28
|
}
|
|
29
29
|
}
|
package/dist/constants.d.ts
CHANGED