powersync 0.2.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -67
- package/dist/commands/init.js +12 -12
- package/dist/commands/instance/create.js +1 -1
- package/dist/commands/instance/deploy.js +1 -3
- package/dist/commands/instance/destroy.js +1 -1
- 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 +1 -0
- package/dist/constants.js +1 -0
- package/dist/service/accounts.client.js +126 -268
- package/dist/service/powersync.client.js +167 -309
- package/dist/service/utils.js +16 -155
- package/dist/utils.js +1 -1
- package/oclif.manifest.json +17 -17
- package/package.json +3 -4
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,17 +13,28 @@
|
|
|
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
|
-
|
|
16
|
-
powersync
|
|
17
|
-
$ powersync --help [COMMAND]
|
|
19
|
+
powersync/0.4.0 linux-x64 node-v20.11.1
|
|
20
|
+
$ npx powersync --help [COMMAND]
|
|
18
21
|
USAGE
|
|
19
|
-
$ powersync COMMAND
|
|
22
|
+
$ npx powersync COMMAND
|
|
20
23
|
...
|
|
21
24
|
```
|
|
22
25
|
<!-- usagestop -->
|
|
26
|
+
## Inject ENV variables
|
|
27
|
+
|
|
28
|
+
The following environment variables can be injected:
|
|
29
|
+
|
|
30
|
+
* `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).
|
|
31
|
+
* `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`.
|
|
32
|
+
* `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`.
|
|
33
|
+
* `INSTANCE_ID` - The PowerSync instance ID. Get this by running `npx powersync instances`.
|
|
34
|
+
|
|
35
|
+
Example:
|
|
36
|
+
|
|
37
|
+
`ORG_ID=123 PROJECT_ID=456 INSTANCE_ID=789 npx powersync instance status`
|
|
23
38
|
|
|
24
39
|
# Commands
|
|
25
40
|
|
|
@@ -45,7 +60,7 @@ Display help for powersync.
|
|
|
45
60
|
|
|
46
61
|
```
|
|
47
62
|
USAGE
|
|
48
|
-
$ powersync help [COMMANDS] [-n]
|
|
63
|
+
$ npx powersync help [COMMANDS] [-n]
|
|
49
64
|
|
|
50
65
|
ARGUMENTS
|
|
51
66
|
COMMANDS Command to show help for.
|
|
@@ -62,19 +77,20 @@ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.1
|
|
|
62
77
|
## `powersync init`
|
|
63
78
|
|
|
64
79
|
Initialize the CLI.
|
|
80
|
+
Requires an access token. Learn how to generate these [here](https://docs.powersync.com/usage/tools/cli-beta#personal-access-token).
|
|
65
81
|
|
|
66
82
|
```
|
|
67
83
|
USAGE
|
|
68
|
-
$ powersync init
|
|
84
|
+
$ npx powersync init
|
|
69
85
|
|
|
70
86
|
DESCRIPTION
|
|
71
87
|
Initialize the CLI.
|
|
72
88
|
|
|
73
89
|
EXAMPLES
|
|
74
|
-
$ powersync init
|
|
90
|
+
$ npx powersync init
|
|
75
91
|
```
|
|
76
92
|
|
|
77
|
-
_See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
93
|
+
_See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/init.ts)_
|
|
78
94
|
|
|
79
95
|
## `powersync instance config`
|
|
80
96
|
|
|
@@ -82,16 +98,16 @@ Display the instance config.
|
|
|
82
98
|
|
|
83
99
|
```
|
|
84
100
|
USAGE
|
|
85
|
-
$ powersync instance config
|
|
101
|
+
$ npx powersync instance config
|
|
86
102
|
|
|
87
103
|
DESCRIPTION
|
|
88
104
|
Display the instance config.
|
|
89
105
|
|
|
90
106
|
EXAMPLES
|
|
91
|
-
$ powersync instance config
|
|
107
|
+
$ npx powersync instance config
|
|
92
108
|
```
|
|
93
109
|
|
|
94
|
-
_See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
110
|
+
_See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/config.ts)_
|
|
95
111
|
|
|
96
112
|
## `powersync instance create`
|
|
97
113
|
|
|
@@ -99,7 +115,7 @@ Create a new instance.
|
|
|
99
115
|
|
|
100
116
|
```
|
|
101
117
|
USAGE
|
|
102
|
-
$ powersync instance create [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
|
|
118
|
+
$ npx powersync instance create [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
|
|
103
119
|
[--region US|EU] [--useSupabaseAuth]
|
|
104
120
|
|
|
105
121
|
FLAGS
|
|
@@ -115,10 +131,10 @@ DESCRIPTION
|
|
|
115
131
|
Create a new instance.
|
|
116
132
|
|
|
117
133
|
EXAMPLES
|
|
118
|
-
$ powersync instance create
|
|
134
|
+
$ npx powersync instance create
|
|
119
135
|
```
|
|
120
136
|
|
|
121
|
-
_See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
137
|
+
_See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/create.ts)_
|
|
122
138
|
|
|
123
139
|
## `powersync instance deploy`
|
|
124
140
|
|
|
@@ -126,7 +142,7 @@ Deploy changes to an existing instance.
|
|
|
126
142
|
|
|
127
143
|
```
|
|
128
144
|
USAGE
|
|
129
|
-
$ powersync instance deploy [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
|
|
145
|
+
$ npx powersync instance deploy [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
|
|
130
146
|
[--useSupabaseAuth]
|
|
131
147
|
|
|
132
148
|
FLAGS
|
|
@@ -140,10 +156,10 @@ DESCRIPTION
|
|
|
140
156
|
Deploy changes to an existing instance.
|
|
141
157
|
|
|
142
158
|
EXAMPLES
|
|
143
|
-
$ powersync instance deploy
|
|
159
|
+
$ npx powersync instance deploy
|
|
144
160
|
```
|
|
145
161
|
|
|
146
|
-
_See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
162
|
+
_See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/deploy.ts)_
|
|
147
163
|
|
|
148
164
|
## `powersync instance destroy`
|
|
149
165
|
|
|
@@ -151,7 +167,7 @@ Destroy the current instance - THIS CANNOT BE UNDONE.
|
|
|
151
167
|
|
|
152
168
|
```
|
|
153
169
|
USAGE
|
|
154
|
-
$ powersync instance destroy [-s]
|
|
170
|
+
$ npx powersync instance destroy [-s]
|
|
155
171
|
|
|
156
172
|
FLAGS
|
|
157
173
|
-s, --skipConfirmation Ignore confirmation question.
|
|
@@ -160,10 +176,10 @@ DESCRIPTION
|
|
|
160
176
|
Destroy the current instance - THIS CANNOT BE UNDONE.
|
|
161
177
|
|
|
162
178
|
EXAMPLES
|
|
163
|
-
$ powersync instance destroy
|
|
179
|
+
$ npx powersync instance destroy
|
|
164
180
|
```
|
|
165
181
|
|
|
166
|
-
_See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
182
|
+
_See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/destroy.ts)_
|
|
167
183
|
|
|
168
184
|
## `powersync instance schema`
|
|
169
185
|
|
|
@@ -171,16 +187,16 @@ View the schema of the current instance.
|
|
|
171
187
|
|
|
172
188
|
```
|
|
173
189
|
USAGE
|
|
174
|
-
$ powersync instance schema
|
|
190
|
+
$ npx powersync instance schema
|
|
175
191
|
|
|
176
192
|
DESCRIPTION
|
|
177
193
|
View the schema of the current instance.
|
|
178
194
|
|
|
179
195
|
EXAMPLES
|
|
180
|
-
$ powersync instance schema
|
|
196
|
+
$ npx powersync instance schema
|
|
181
197
|
```
|
|
182
198
|
|
|
183
|
-
_See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
199
|
+
_See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/schema.ts)_
|
|
184
200
|
|
|
185
201
|
## `powersync instance set`
|
|
186
202
|
|
|
@@ -188,7 +204,7 @@ Set the current instance.
|
|
|
188
204
|
|
|
189
205
|
```
|
|
190
206
|
USAGE
|
|
191
|
-
$ powersync instance set [-i <value>]
|
|
207
|
+
$ npx powersync instance set [-i <value>]
|
|
192
208
|
|
|
193
209
|
FLAGS
|
|
194
210
|
-i, --instanceId=<value> Instance ID to change to.
|
|
@@ -197,37 +213,37 @@ DESCRIPTION
|
|
|
197
213
|
Set the current instance.
|
|
198
214
|
|
|
199
215
|
EXAMPLES
|
|
200
|
-
$ powersync instance set
|
|
216
|
+
$ npx powersync instance set
|
|
201
217
|
|
|
202
|
-
$ powersync instance set --instanceId=1234
|
|
218
|
+
$ npx powersync instance set --instanceId=1234
|
|
203
219
|
```
|
|
204
220
|
|
|
205
|
-
_See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
221
|
+
_See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/set.ts)_
|
|
206
222
|
|
|
207
223
|
## `powersync instance status`
|
|
208
224
|
|
|
209
|
-
View the status of the current instance.
|
|
225
|
+
View the status of the current instance. View the status of a different instance by using flags.
|
|
210
226
|
|
|
211
227
|
```
|
|
212
228
|
USAGE
|
|
213
|
-
$ powersync instance status [-
|
|
229
|
+
$ npx powersync instance status [-t <value>] [-i <value>] [-o <value>] [-p <value>]
|
|
214
230
|
|
|
215
231
|
FLAGS
|
|
216
|
-
-
|
|
217
|
-
-
|
|
218
|
-
-
|
|
219
|
-
-t, --authToken=<value> auth token
|
|
232
|
+
-i, --instanceId=<value> Override current instance by providing the ID of a different instance.
|
|
233
|
+
-o, --orgId=<value> Override current organization by providing the ID of a different organization.
|
|
234
|
+
-p, --projectId=<value> Override current project by providing the ID of a different project.
|
|
235
|
+
-t, --authToken=<value> Override current auth token.
|
|
220
236
|
|
|
221
237
|
DESCRIPTION
|
|
222
|
-
View the status of the current instance.
|
|
238
|
+
View the status of the current instance. View the status of a different instance by using flags.
|
|
223
239
|
|
|
224
240
|
EXAMPLES
|
|
225
|
-
$ powersync instance status
|
|
241
|
+
$ npx powersync instance status
|
|
226
242
|
|
|
227
|
-
$ powersync instance status --orgId=1234 --
|
|
243
|
+
$ npx powersync instance status --orgId=1234 --projectId=1234 --instanceId=1234 --authToken=1234
|
|
228
244
|
```
|
|
229
245
|
|
|
230
|
-
_See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
246
|
+
_See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/status.ts)_
|
|
231
247
|
|
|
232
248
|
## `powersync instance stop`
|
|
233
249
|
|
|
@@ -235,7 +251,7 @@ Stop the current instance.
|
|
|
235
251
|
|
|
236
252
|
```
|
|
237
253
|
USAGE
|
|
238
|
-
$ powersync instance stop [-s]
|
|
254
|
+
$ npx powersync instance stop [-s]
|
|
239
255
|
|
|
240
256
|
FLAGS
|
|
241
257
|
-s, --skipConfirmation Ignore confirmation question.
|
|
@@ -244,43 +260,43 @@ DESCRIPTION
|
|
|
244
260
|
Stop the current instance.
|
|
245
261
|
|
|
246
262
|
EXAMPLES
|
|
247
|
-
$ powersync instance stop
|
|
263
|
+
$ npx powersync instance stop
|
|
248
264
|
```
|
|
249
265
|
|
|
250
|
-
_See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
266
|
+
_See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/stop.ts)_
|
|
251
267
|
|
|
252
268
|
## `powersync instance sync-rules deploy`
|
|
253
269
|
|
|
254
|
-
Deploy sync rules from a local sync rules file to the current instance.
|
|
270
|
+
Deploy sync rules from a local sync rules config file to the current instance.
|
|
255
271
|
|
|
256
272
|
```
|
|
257
273
|
USAGE
|
|
258
|
-
$ powersync instance sync-rules deploy -f <value> [-s]
|
|
274
|
+
$ npx powersync instance sync-rules deploy -f <value> [-s]
|
|
259
275
|
|
|
260
276
|
FLAGS
|
|
261
277
|
-f, --filePath=<value> (required) Path to the sync rules config file.
|
|
262
278
|
-s, --skipConfirmation Ignore confirmation question.
|
|
263
279
|
|
|
264
280
|
DESCRIPTION
|
|
265
|
-
Deploy sync rules from a local sync rules file to the current instance.
|
|
281
|
+
Deploy sync rules from a local sync rules config file to the current instance.
|
|
266
282
|
|
|
267
283
|
EXAMPLES
|
|
268
|
-
$ powersync instance sync-rules deploy
|
|
284
|
+
$ npx powersync instance sync-rules deploy
|
|
269
285
|
|
|
270
|
-
$ powersync instance sync-rules deploy --filePath path/to/file
|
|
286
|
+
$ npx powersync instance sync-rules deploy --filePath path/to/file
|
|
271
287
|
|
|
272
|
-
$ powersync instance sync-rules deploy -f path/to/file
|
|
288
|
+
$ npx powersync instance sync-rules deploy -f path/to/file
|
|
273
289
|
```
|
|
274
290
|
|
|
275
|
-
_See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
291
|
+
_See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/sync-rules/deploy.ts)_
|
|
276
292
|
|
|
277
293
|
## `powersync instance sync-rules generate-schema`
|
|
278
294
|
|
|
279
|
-
Generate schema in your language from your sync rules file.
|
|
295
|
+
Generate schema in your language from your sync rules config file.
|
|
280
296
|
|
|
281
297
|
```
|
|
282
298
|
USAGE
|
|
283
|
-
$ powersync instance sync-rules generate-schema -f <value> [-l js|dart]
|
|
299
|
+
$ npx powersync instance sync-rules generate-schema -f <value> [-l js|dart]
|
|
284
300
|
|
|
285
301
|
FLAGS
|
|
286
302
|
-f, --filePath=<value> (required) Path to the sync rules config file.
|
|
@@ -288,41 +304,41 @@ FLAGS
|
|
|
288
304
|
<options: js|dart>
|
|
289
305
|
|
|
290
306
|
DESCRIPTION
|
|
291
|
-
Generate schema in your language from your sync rules file.
|
|
307
|
+
Generate schema in your language from your sync rules config file.
|
|
292
308
|
|
|
293
309
|
EXAMPLES
|
|
294
|
-
$ powersync instance sync-rules generate-schema
|
|
310
|
+
$ npx powersync instance sync-rules generate-schema
|
|
295
311
|
|
|
296
|
-
$ powersync instance sync-rules generate-schema --filePath path/to/file
|
|
312
|
+
$ npx powersync instance sync-rules generate-schema --filePath path/to/file
|
|
297
313
|
|
|
298
|
-
$ powersync instance sync-rules generate-schema -f path/to/file
|
|
314
|
+
$ npx powersync instance sync-rules generate-schema -f path/to/file
|
|
299
315
|
```
|
|
300
316
|
|
|
301
|
-
_See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
317
|
+
_See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/sync-rules/generate-schema.ts)_
|
|
302
318
|
|
|
303
319
|
## `powersync instance sync-rules validate`
|
|
304
320
|
|
|
305
|
-
Validate sync rules from a local sync rules file.
|
|
321
|
+
Validate sync rules from a local sync rules config file.
|
|
306
322
|
|
|
307
323
|
```
|
|
308
324
|
USAGE
|
|
309
|
-
$ powersync instance sync-rules validate -f <value>
|
|
325
|
+
$ npx powersync instance sync-rules validate -f <value>
|
|
310
326
|
|
|
311
327
|
FLAGS
|
|
312
328
|
-f, --filePath=<value> (required) Path to the sync rules config file.
|
|
313
329
|
|
|
314
330
|
DESCRIPTION
|
|
315
|
-
Validate sync rules from a local sync rules file.
|
|
331
|
+
Validate sync rules from a local sync rules config file.
|
|
316
332
|
|
|
317
333
|
EXAMPLES
|
|
318
|
-
$ powersync instance sync-rules validate
|
|
334
|
+
$ npx powersync instance sync-rules validate
|
|
319
335
|
|
|
320
|
-
$ powersync instance sync-rules validate --filePath path/to/file
|
|
336
|
+
$ npx powersync instance sync-rules validate --filePath path/to/file
|
|
321
337
|
|
|
322
|
-
$ powersync instance sync-rules validate -f path/to/file
|
|
338
|
+
$ npx powersync instance sync-rules validate -f path/to/file
|
|
323
339
|
```
|
|
324
340
|
|
|
325
|
-
_See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
341
|
+
_See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instance/sync-rules/validate.ts)_
|
|
326
342
|
|
|
327
343
|
## `powersync instances`
|
|
328
344
|
|
|
@@ -330,14 +346,14 @@ View list of instances.
|
|
|
330
346
|
|
|
331
347
|
```
|
|
332
348
|
USAGE
|
|
333
|
-
$ powersync instances
|
|
349
|
+
$ npx powersync instances
|
|
334
350
|
|
|
335
351
|
DESCRIPTION
|
|
336
352
|
View list of instances.
|
|
337
353
|
|
|
338
354
|
EXAMPLES
|
|
339
|
-
$ powersync instances
|
|
355
|
+
$ npx powersync instances
|
|
340
356
|
```
|
|
341
357
|
|
|
342
|
-
_See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
358
|
+
_See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instances.ts)_
|
|
343
359
|
<!-- 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
|
}
|
|
@@ -152,7 +152,7 @@ export default class InstanceCreate extends Command {
|
|
|
152
152
|
});
|
|
153
153
|
spinner.start();
|
|
154
154
|
const instance = await PowerSyncClient.createInstance(instanceName);
|
|
155
|
-
await PowerSyncClient.deployInstance(config, instance.id
|
|
155
|
+
await PowerSyncClient.deployInstance(config, instance.id);
|
|
156
156
|
let status = 'pending';
|
|
157
157
|
status = await PowerSyncClient.waitForStatusChange(instance.id);
|
|
158
158
|
spinner.stop();
|
|
@@ -97,9 +97,7 @@ export default class InstanceDeploy extends Command {
|
|
|
97
97
|
const databaseName = flags.databaseName || answers.databaseName;
|
|
98
98
|
const databaseUsername = flags.databaseUsername || answers.databaseUsername;
|
|
99
99
|
const useSupabaseAuth = flags.useSupabaseAuth || answers.useSupabaseAuth;
|
|
100
|
-
const instanceConfig = await PowerSyncClient.getInstanceConfig(
|
|
101
|
-
options: { shouldApplyAdditionalHeaders: false }
|
|
102
|
-
});
|
|
100
|
+
const instanceConfig = await PowerSyncClient.getInstanceConfig();
|
|
103
101
|
const { region } = instanceConfig.config;
|
|
104
102
|
const config = {
|
|
105
103
|
client_auth: {
|
|
@@ -12,7 +12,7 @@ export default class InstanceDestroy extends Command {
|
|
|
12
12
|
async run() {
|
|
13
13
|
checkForValidEnvFile(this.config.bin, true);
|
|
14
14
|
const { flags } = await this.parse(InstanceDestroy);
|
|
15
|
-
const config = await PowerSyncClient.getInstanceConfig(
|
|
15
|
+
const config = await PowerSyncClient.getInstanceConfig();
|
|
16
16
|
const questions = [
|
|
17
17
|
{
|
|
18
18
|
message: `Please type ${red(config.name)} to confirm you want to destroy this instance.\n`,
|
|
@@ -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
package/dist/constants.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { homedir } from 'node:os';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
export const APP_NAME = 'POWERSYNC_CLI';
|
|
3
4
|
export const POWERSYNC_DIRECTORY = path.join(homedir(), '/.powersync');
|
|
4
5
|
export const ENV_FILE_PATH = `${POWERSYNC_DIRECTORY}/.env.powersync`;
|
|
5
6
|
export const ENDPOINTS = {
|