powersync 0.1.2 → 0.2.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 CHANGED
@@ -13,7 +13,7 @@ $ npm install -g powersync
13
13
  $ powersync COMMAND
14
14
  running command...
15
15
  $ powersync (--version)
16
- powersync/0.1.2 linux-x64 node-v20.11.0
16
+ powersync/0.2.0 linux-x64 node-v20.11.0
17
17
  $ powersync --help [COMMAND]
18
18
  USAGE
19
19
  $ powersync COMMAND
@@ -61,41 +61,41 @@ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.1
61
61
 
62
62
  ## `powersync init`
63
63
 
64
- Initialize the CLI
64
+ Initialize the CLI.
65
65
 
66
66
  ```
67
67
  USAGE
68
68
  $ powersync init
69
69
 
70
70
  DESCRIPTION
71
- Initialize the CLI
71
+ Initialize the CLI.
72
72
 
73
73
  EXAMPLES
74
74
  $ powersync init
75
75
  ```
76
76
 
77
- _See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/init.ts)_
77
+ _See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/init.ts)_
78
78
 
79
79
  ## `powersync instance config`
80
80
 
81
- get the instance config
81
+ Display the instance config.
82
82
 
83
83
  ```
84
84
  USAGE
85
85
  $ powersync instance config
86
86
 
87
87
  DESCRIPTION
88
- get the instance config
88
+ Display the instance config.
89
89
 
90
90
  EXAMPLES
91
91
  $ powersync instance config
92
92
  ```
93
93
 
94
- _See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/config.ts)_
94
+ _See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/config.ts)_
95
95
 
96
96
  ## `powersync instance create`
97
97
 
98
- create a new instance
98
+ Create a new instance.
99
99
 
100
100
  ```
101
101
  USAGE
@@ -103,26 +103,26 @@ USAGE
103
103
  [--region US|EU] [--useSupabaseAuth]
104
104
 
105
105
  FLAGS
106
- --databaseName=<value> Name of the DB
107
- --hostname=<value> Hostname to connect to DB
108
- --name=<value> Name of the instance
109
- --port=<value> Port number to connect to DB
110
- --region=<option> Region to deploy instance to
106
+ --databaseName=<value> Name of the database.
107
+ --hostname=<value> Hostname to connect to database.
108
+ --name=<value> Name of the instance.
109
+ --port=<value> Port number to connect to database.
110
+ --region=<option> Region to deploy instance to.
111
111
  <options: US|EU>
112
- --useSupabaseAuth Use Supabase for auth
112
+ --useSupabaseAuth Use Supabase for auth.
113
113
 
114
114
  DESCRIPTION
115
- create a new instance
115
+ Create a new instance.
116
116
 
117
117
  EXAMPLES
118
118
  $ powersync instance create
119
119
  ```
120
120
 
121
- _See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/create.ts)_
121
+ _See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/create.ts)_
122
122
 
123
123
  ## `powersync instance deploy`
124
124
 
125
- deploy changes to an existing instance
125
+ Deploy changes to an existing instance.
126
126
 
127
127
  ```
128
128
  USAGE
@@ -130,73 +130,71 @@ USAGE
130
130
  [--useSupabaseAuth]
131
131
 
132
132
  FLAGS
133
- --databaseName=<value> Name of the DB
134
- --hostname=<value> Hostname to connect to DB
135
- --name=<value> Name of the instance
136
- --port=<value> Port number to connect to DB
137
- --useSupabaseAuth Use Supabase auth
133
+ --databaseName=<value> Name of the database.
134
+ --hostname=<value> Hostname to connect to database.
135
+ --name=<value> Name of the instance.
136
+ --port=<value> Port number to connect to database.
137
+ --useSupabaseAuth Use Supabase auth.
138
138
 
139
139
  DESCRIPTION
140
- deploy changes to an existing instance
140
+ Deploy changes to an existing instance.
141
141
 
142
142
  EXAMPLES
143
143
  $ powersync instance deploy
144
144
  ```
145
145
 
146
- _See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/deploy.ts)_
146
+ _See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/deploy.ts)_
147
147
 
148
148
  ## `powersync instance destroy`
149
149
 
150
- destroy the current instance - THIS CANNOT BE UNDONE
150
+ Destroy the current instance - THIS CANNOT BE UNDONE.
151
151
 
152
152
  ```
153
153
  USAGE
154
154
  $ powersync instance destroy [-s]
155
155
 
156
156
  FLAGS
157
- -s, --skipConfirmation Ignore confirmation question
157
+ -s, --skipConfirmation Ignore confirmation question.
158
158
 
159
159
  DESCRIPTION
160
- destroy the current instance - THIS CANNOT BE UNDONE
160
+ Destroy the current instance - THIS CANNOT BE UNDONE.
161
161
 
162
162
  EXAMPLES
163
163
  $ powersync instance destroy
164
-
165
- $ powersync instance destroy --instanceId=1234
166
164
  ```
167
165
 
168
- _See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/destroy.ts)_
166
+ _See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/destroy.ts)_
169
167
 
170
168
  ## `powersync instance schema`
171
169
 
172
- view the schema of the current instance
170
+ View the schema of the current instance.
173
171
 
174
172
  ```
175
173
  USAGE
176
174
  $ powersync instance schema
177
175
 
178
176
  DESCRIPTION
179
- view the schema of the current instance
177
+ View the schema of the current instance.
180
178
 
181
179
  EXAMPLES
182
180
  $ powersync instance schema
183
181
  ```
184
182
 
185
- _See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/schema.ts)_
183
+ _See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/schema.ts)_
186
184
 
187
185
  ## `powersync instance set`
188
186
 
189
- set the current instance
187
+ Set the current instance.
190
188
 
191
189
  ```
192
190
  USAGE
193
- $ powersync instance set [-n <value>]
191
+ $ powersync instance set [-i <value>]
194
192
 
195
193
  FLAGS
196
- -n, --instanceId=<value> instance id to change to
194
+ -i, --instanceId=<value> Instance ID to change to.
197
195
 
198
196
  DESCRIPTION
199
- set the current instance
197
+ Set the current instance.
200
198
 
201
199
  EXAMPLES
202
200
  $ powersync instance set
@@ -204,61 +202,67 @@ EXAMPLES
204
202
  $ powersync instance set --instanceId=1234
205
203
  ```
206
204
 
207
- _See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/set.ts)_
205
+ _See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/set.ts)_
208
206
 
209
207
  ## `powersync instance status`
210
208
 
211
- view the status of the current instance
209
+ View the status of the current instance.
212
210
 
213
211
  ```
214
212
  USAGE
215
- $ powersync instance status
213
+ $ powersync instance status [-a <value>] [-t <value>] [-i <value>] [-o <value>]
214
+
215
+ FLAGS
216
+ -a, --appId=<value> app id to use
217
+ -i, --instanceId=<value> instance id to use
218
+ -o, --orgId=<value> org id to use
219
+ -t, --authToken=<value> auth token to use
216
220
 
217
221
  DESCRIPTION
218
- view the status of the current instance
222
+ View the status of the current instance.
219
223
 
220
224
  EXAMPLES
221
225
  $ powersync instance status
226
+
227
+ $ powersync instance status --orgId=1234 --appId=1234 --instanceId=1234 --authToken=1234
222
228
  ```
223
229
 
224
- _See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/status.ts)_
230
+ _See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/status.ts)_
225
231
 
226
232
  ## `powersync instance stop`
227
233
 
228
- stop the current instance
234
+ Stop the current instance.
229
235
 
230
236
  ```
231
237
  USAGE
232
238
  $ powersync instance stop [-s]
233
239
 
234
240
  FLAGS
235
- -s, --skipConfirmation Ignore confirmation question
241
+ -s, --skipConfirmation Ignore confirmation question.
236
242
 
237
243
  DESCRIPTION
238
- stop the current instance
244
+ Stop the current instance.
239
245
 
240
246
  EXAMPLES
241
247
  $ powersync instance stop
242
-
243
- $ powersync instance stop --instanceId=1234
244
248
  ```
245
249
 
246
- _See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/stop.ts)_
250
+ _See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/stop.ts)_
247
251
 
248
252
  ## `powersync instance sync-rules deploy`
249
253
 
250
- deploy sync rules from a local file to the current instance
254
+ Deploy sync rules from a local file to the current instance.
251
255
 
252
256
  ```
253
257
  USAGE
254
258
  $ powersync instance sync-rules deploy -f <value> [-s]
255
259
 
256
260
  FLAGS
257
- -f, --filePath=<value> (required) Path to the file
258
- -s, --skipConfirmation Ignore confirmation question
261
+ -f, --filePath=<value> (required) Path to the file.
262
+ -s, --skipConfirmation Ignore confirmation question.
259
263
 
260
264
  DESCRIPTION
261
- deploy sync rules from a local file to the current instance
265
+ Deploy sync rules from a local file to the current instance.
262
266
 
263
267
  EXAMPLES
264
268
  $ powersync instance sync-rules deploy
@@ -268,23 +272,23 @@ EXAMPLES
268
272
  $ powersync instance sync-rules deploy -f path/to/file
269
273
  ```
270
274
 
271
- _See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/sync-rules/deploy.ts)_
275
+ _See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/sync-rules/deploy.ts)_
272
276
 
273
277
  ## `powersync instance sync-rules generate-schema`
274
278
 
275
- generate schema in your language from sync rules
279
+ Generate schema in your language from sync rules.
276
280
 
277
281
  ```
278
282
  USAGE
279
283
  $ powersync instance sync-rules generate-schema -f <value> [-l js|dart]
280
284
 
281
285
  FLAGS
282
- -f, --filePath=<value> (required) Path to the file
283
- -l, --language=<option> Choose language for output
286
+ -f, --filePath=<value> (required) Path to the file.
287
+ -l, --language=<option> Choose language for output.
284
288
  <options: js|dart>
285
289
 
286
290
  DESCRIPTION
287
- generate schema in your language from sync rules
291
+ Generate schema in your language from sync rules.
288
292
 
289
293
  EXAMPLES
290
294
  $ powersync instance sync-rules generate-schema
@@ -294,21 +298,21 @@ EXAMPLES
294
298
  $ powersync instance sync-rules generate-schema -f path/to/file
295
299
  ```
296
300
 
297
- _See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/sync-rules/generate-schema.ts)_
301
+ _See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/sync-rules/generate-schema.ts)_
298
302
 
299
303
  ## `powersync instance sync-rules validate`
300
304
 
301
- validate sync rules from a local file
305
+ Validate sync rules from a local file.
302
306
 
303
307
  ```
304
308
  USAGE
305
309
  $ powersync instance sync-rules validate -f <value>
306
310
 
307
311
  FLAGS
308
- -f, --filePath=<value> (required) Path to the file
312
+ -f, --filePath=<value> (required) Path to the file.
309
313
 
310
314
  DESCRIPTION
311
- validate sync rules from a local file
315
+ Validate sync rules from a local file.
312
316
 
313
317
  EXAMPLES
314
318
  $ powersync instance sync-rules validate
@@ -318,22 +322,22 @@ EXAMPLES
318
322
  $ powersync instance sync-rules validate -f path/to/file
319
323
  ```
320
324
 
321
- _See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instance/sync-rules/validate.ts)_
325
+ _See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instance/sync-rules/validate.ts)_
322
326
 
323
327
  ## `powersync instances`
324
328
 
325
- view list of instances
329
+ View list of instances.
326
330
 
327
331
  ```
328
332
  USAGE
329
333
  $ powersync instances
330
334
 
331
335
  DESCRIPTION
332
- view list of instances
336
+ View list of instances.
333
337
 
334
338
  EXAMPLES
335
339
  $ powersync instances
336
340
  ```
337
341
 
338
- _See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.1.2/src/commands/instances.ts)_
342
+ _See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.2.0/src/commands/instances.ts)_
339
343
  <!-- commandsstop -->
@@ -5,27 +5,34 @@ import { ENV_FILE_PATH, POWERSYNC_DIRECTORY } from '../constants.js';
5
5
  import * as AccountsClient from '../service/accounts.client.js';
6
6
  import { green, red } from '../utils.js';
7
7
  export default class Init extends Command {
8
- static description = 'Initialize the CLI';
8
+ static description = 'Initialize the CLI.';
9
9
  static examples = ['<%= config.bin %> <%= command.id %>'];
10
10
  async run() {
11
- const cardinalTokenQuestions = [
11
+ const authTokenQuestions = [
12
12
  {
13
- message: 'Enter your API token:.',
14
- name: 'cardinalToken',
13
+ message: 'Enter your API token:',
14
+ name: 'authToken',
15
15
  type: 'password',
16
16
  validate(value) {
17
17
  return value.length > 0 ? true : 'Please enter your API token.';
18
18
  }
19
19
  }
20
20
  ];
21
- const cardinalTokenAnswers = await inquirer.prompt(cardinalTokenQuestions);
22
- const organizations = await AccountsClient.getOrgs(cardinalTokenAnswers.cardinalToken);
23
- if (organizations.count > 1) {
24
- return ux.error(red('Multiple organizations found. Please contact support for assistance - support@powersync.com'), { exit: 1 });
21
+ const authTokenAnswers = await inquirer.prompt(authTokenQuestions);
22
+ const organizations = await AccountsClient.getOrgs(authTokenAnswers.authToken);
23
+ const numberOfOrganizations = organizations.count;
24
+ const SUPPORT_MESSAGE = 'Please contact support for assistance - support@powersync.com.';
25
+ if (numberOfOrganizations === 0) {
26
+ return ux.error(red(`No organizations found. ${SUPPORT_MESSAGE}`), {
27
+ exit: 1
28
+ });
25
29
  }
26
- const apps = await AccountsClient.getPowerSyncApps(cardinalTokenAnswers.cardinalToken);
30
+ if (numberOfOrganizations > 1) {
31
+ return ux.error(red(`Multiple organizations found. ${SUPPORT_MESSAGE}`), { exit: 1 });
32
+ }
33
+ const apps = await AccountsClient.getPowerSyncApps(authTokenAnswers.authToken);
27
34
  if (apps.length === 0) {
28
- return ux.error(red('No apps found. Please contact support for assistance - support@powersync.com'), { exit: 1 });
35
+ return ux.error(red(`No apps found. ${SUPPORT_MESSAGE}`), { exit: 1 });
29
36
  }
30
37
  const appQuestions = [
31
38
  {
@@ -43,10 +50,10 @@ export default class Init extends Command {
43
50
  if (fs.existsSync(ENV_FILE_PATH)) {
44
51
  fs.unlinkSync(ENV_FILE_PATH);
45
52
  }
46
- fs.writeFileSync(ENV_FILE_PATH, `ORG_ID=${orgId}\nAPP_ID=${appAnswers.appId}\nCARDINAL_TOKEN=${cardinalTokenAnswers.cardinalToken}\n`);
53
+ fs.writeFileSync(ENV_FILE_PATH, `ORG_ID=${orgId}\nAPP_ID=${appAnswers.appId}\nAUTH_TOKEN=${authTokenAnswers.authToken}\n`);
47
54
  ux.log(green('CLI has been initialized'));
48
- ux.log(`run ${green(`"${this.config.bin} instances"`)} to view your instances or`);
55
+ ux.log(`Run ${green(`"${this.config.bin} instances"`)} to view your instances or`);
49
56
  ux.log(`run ${green(`"${this.config.bin} instance create"`)} to create an instance or`);
50
- ux.log(`run ${green(`"${this.config.bin} instance set"`)} to use an already created instance`);
57
+ ux.log(`run ${green(`"${this.config.bin} instance set"`)} to use an already created instance.`);
51
58
  }
52
59
  }
@@ -2,7 +2,7 @@ import { Command, ux } from '@oclif/core';
2
2
  import * as PowerSyncClient from '../../service/powersync.client.js';
3
3
  import { checkForValidEnvFile, red } from '../../utils.js';
4
4
  export default class InstanceConfig extends Command {
5
- static description = 'get the instance config';
5
+ static description = 'Display the instance config.';
6
6
  static examples = ['<%= config.bin %> <%= command.id %>'];
7
7
  async run() {
8
8
  checkForValidEnvFile(this.config.bin, true);
@@ -6,20 +6,20 @@ import { REGIONS } from '../../constants.js';
6
6
  import * as PowerSyncClient from '../../service/powersync.client.js';
7
7
  import { bold, checkForValidEnvFile, green, red, updateEnvFileVariableValue } from '../../utils.js';
8
8
  export default class InstanceCreate extends Command {
9
- static description = 'create a new instance';
9
+ static description = 'Create a new instance.';
10
10
  static examples = ['<%= config.bin %> <%= command.id %>'];
11
11
  static flags = {
12
- databaseName: Flags.string({ description: 'Name of the DB' }),
13
- databasePassword: Flags.string({ description: 'Password of the DB', hidden: true }),
14
- databaseUsername: Flags.string({ description: 'Username of the DB', hidden: true }),
15
- hostname: Flags.string({ description: 'Hostname to connect to DB' }),
16
- name: Flags.string({ description: 'Name of the instance' }),
17
- port: Flags.integer({ description: 'Port number to connect to DB' }),
18
- region: Flags.string({ description: 'Region to deploy instance to', options: REGIONS }),
19
- useSupabaseAuth: Flags.boolean({ description: 'Use Supabase for auth' })
12
+ databaseName: Flags.string({ description: 'Name of the database.' }),
13
+ databasePassword: Flags.string({ description: 'Password of the database.', hidden: true }),
14
+ databaseUsername: Flags.string({ description: 'Username of the database.', hidden: true }),
15
+ hostname: Flags.string({ description: 'Hostname to connect to database.' }),
16
+ name: Flags.string({ description: 'Name of the instance.' }),
17
+ port: Flags.integer({ description: 'Port number to connect to database.' }),
18
+ region: Flags.string({ description: 'Region to deploy instance to.', options: REGIONS }),
19
+ useSupabaseAuth: Flags.boolean({ description: 'Use Supabase for auth.' })
20
20
  };
21
21
  async run() {
22
- checkForValidEnvFile(this.config.bin, true);
22
+ checkForValidEnvFile(this.config.bin);
23
23
  const { flags } = await this.parse(InstanceCreate);
24
24
  const questions = [
25
25
  {
@@ -117,6 +117,20 @@ export default class InstanceCreate extends Command {
117
117
  const databaseUsername = flags.databaseUsername || answers.databaseUsername;
118
118
  const region = flags.region || answers.region;
119
119
  const useSupabaseAuth = flags.useSupabaseAuth || answers.useSupabaseAuth;
120
+ const connection = {
121
+ database: databaseName,
122
+ debug_api: false,
123
+ hostname,
124
+ name: 'Default',
125
+ password: {
126
+ secret: password
127
+ },
128
+ port: Number(port),
129
+ sslmode: 'verify-full',
130
+ tag: 'default',
131
+ type: 'postgresql',
132
+ username: databaseUsername
133
+ };
120
134
  const config = {
121
135
  client_auth: {
122
136
  jwks_uri: answers.jwksUri || undefined,
@@ -124,24 +138,13 @@ export default class InstanceCreate extends Command {
124
138
  },
125
139
  region: region.toLowerCase(),
126
140
  replication: {
127
- connections: [
128
- {
129
- database: databaseName,
130
- debug_api: false,
131
- hostname,
132
- name: 'Default',
133
- password: {
134
- secret: password
135
- },
136
- port: Number(port),
137
- sslmode: 'verify-full',
138
- tag: 'default',
139
- type: 'postgresql',
140
- username: databaseUsername
141
- }
142
- ]
141
+ connections: [connection]
143
142
  }
144
143
  };
144
+ const connectionResponse = await PowerSyncClient.testConnection(connection);
145
+ if (connectionResponse.error) {
146
+ return ux.error(red(`There was an issue testing the connection from the PowerSync service to your database: ${connectionResponse.error}. Please double-check your entered values.`), { exit: 1 });
147
+ }
145
148
  const spinner = ora({
146
149
  prefixText: 'Creating instance.\n',
147
150
  spinner: 'moon',
@@ -158,6 +161,6 @@ export default class InstanceCreate extends Command {
158
161
  }
159
162
  updateEnvFileVariableValue(PowerSyncClient.ENV_VARIABLES.INSTANCE_ID, instance.id);
160
163
  ux.log(green(`Instance with id ${bold(instance.id)} has been created successfully.`));
161
- ux.log(green(`Current instance has been set to ${instance.id}`));
164
+ ux.log(green(`Current instance has been set to ${bold(instance.id)}.`));
162
165
  }
163
166
  }
@@ -5,16 +5,16 @@ 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 InstanceDeploy extends Command {
8
- static description = 'deploy changes to an existing instance';
8
+ static description = 'Deploy changes to an existing instance.';
9
9
  static examples = ['<%= config.bin %> <%= command.id %>'];
10
10
  static flags = {
11
- databaseName: Flags.string({ description: 'Name of the DB' }),
12
- databasePassword: Flags.string({ description: 'Password of the DB', hidden: true }),
13
- databaseUsername: Flags.string({ description: 'Username of the DB', hidden: true }),
14
- hostname: Flags.string({ description: 'Hostname to connect to DB' }),
15
- name: Flags.string({ description: 'Name of the instance' }),
16
- port: Flags.integer({ description: 'Port number to connect to DB' }),
17
- useSupabaseAuth: Flags.boolean({ description: 'Use Supabase auth' })
11
+ databaseName: Flags.string({ description: 'Name of the database.' }),
12
+ databasePassword: Flags.string({ description: 'Password of the database.', hidden: true }),
13
+ databaseUsername: Flags.string({ description: 'Username of the database.', hidden: true }),
14
+ hostname: Flags.string({ description: 'Hostname to connect to database.' }),
15
+ name: Flags.string({ description: 'Name of the instance.' }),
16
+ port: Flags.integer({ description: 'Port number to connect to database.' }),
17
+ useSupabaseAuth: Flags.boolean({ description: 'Use Supabase auth.' })
18
18
  };
19
19
  async run() {
20
20
  checkForValidEnvFile(this.config.bin, true);
@@ -4,26 +4,30 @@ import ora from 'ora';
4
4
  import * as PowerSyncClient from '../../service/powersync.client.js';
5
5
  import { bold, checkForValidEnvFile, green, red } from '../../utils.js';
6
6
  export default class InstanceDestroy extends Command {
7
- static description = 'destroy the current instance - THIS CANNOT BE UNDONE';
8
- static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --instanceId=1234'];
7
+ static description = 'Destroy the current instance - THIS CANNOT BE UNDONE.';
8
+ static examples = ['<%= config.bin %> <%= command.id %>'];
9
9
  static flags = {
10
- skipConfirmation: Flags.boolean({ char: 's', description: 'Ignore confirmation question' })
10
+ skipConfirmation: Flags.boolean({ char: 's', description: 'Ignore confirmation question.' })
11
11
  };
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
16
  const questions = [
16
17
  {
17
- message: 'Are you sure you want to do destroy the instance?',
18
+ message: `Please type ${red(config.name)} to confirm you want to destroy this instance.\n`,
18
19
  name: 'areYouSure',
19
- type: 'confirm',
20
+ type: 'input',
21
+ validate(input) {
22
+ if (input !== config.name) {
23
+ return `Please type ${red(config.name)} to confirm you want to destroy this instance.\n`;
24
+ }
25
+ return true;
26
+ },
20
27
  when: !flags.skipConfirmation
21
28
  }
22
29
  ];
23
- const answers = await inquirer.prompt(questions);
24
- if (!answers.areYouSure) {
25
- return ux.log('Instance will not be destroyed.');
26
- }
30
+ await inquirer.prompt(questions);
27
31
  const spinner = ora({
28
32
  prefixText: 'Destroying instance\n',
29
33
  spinner: 'moon',
@@ -3,7 +3,7 @@ import { Command, ux } from '@oclif/core';
3
3
  import * as PowerSyncClient from '../../service/powersync.client.js';
4
4
  import { checkForValidEnvFile } from '../../utils.js';
5
5
  export default class InstanceSchema extends Command {
6
- static description = 'view the schema of the current instance';
6
+ static description = 'View the schema of the current instance.';
7
7
  static examples = ['<%= config.bin %> <%= command.id %>'];
8
8
  async run() {
9
9
  checkForValidEnvFile(this.config.bin, true);
@@ -4,10 +4,10 @@ import * as PowerSyncClient from '../../service/powersync.client.js';
4
4
  import { ENV_VARIABLES } from '../../service/powersync.client.js';
5
5
  import { bold, checkForValidEnvFile, green, updateEnvFileVariableValue } from '../../utils.js';
6
6
  export default class InstanceSet extends Command {
7
- static description = 'set the current instance';
7
+ static description = 'Set the current instance.';
8
8
  static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --instanceId=1234'];
9
9
  static flags = {
10
- instanceId: Flags.string({ char: 'n', description: 'instance id to change to' })
10
+ instanceId: Flags.string({ char: 'i', description: 'Instance ID to change to.' })
11
11
  };
12
12
  async run() {
13
13
  checkForValidEnvFile(this.config.bin);
@@ -2,5 +2,11 @@ import { Command } from '@oclif/core';
2
2
  export default class InstanceStatus extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
+ static flags: {
6
+ appId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ authToken: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
+ instanceId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
+ orgId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
+ };
5
11
  run(): Promise<void>;
6
12
  }
@@ -1,15 +1,32 @@
1
- import { Command, ux } from '@oclif/core';
1
+ 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';
6
- static examples = ['<%= config.bin %> <%= command.id %>'];
5
+ static description = 'View the status of the current instance.';
6
+ static examples = [
7
+ '<%= config.bin %> <%= command.id %>',
8
+ '<%= config.bin %> <%= command.id %> --orgId=1234 --appId=1234 --instanceId=1234 --authToken=1234'
9
+ ];
10
+ static flags = {
11
+ appId: Flags.string({ char: 'a', description: 'app id to use' }),
12
+ authToken: Flags.string({ char: 't', description: 'auth token to use' }),
13
+ instanceId: Flags.string({ char: 'i', description: 'instance id to use' }),
14
+ orgId: Flags.string({ char: 'o', description: 'org id to use' })
15
+ };
7
16
  async run() {
8
- checkForValidEnvFile(this.config.bin, true);
9
- const diagnostics = await PowerSyncClient.getInstanceDiagnostics();
17
+ const { flags } = await this.parse(InstanceStatus);
18
+ if (!flags.authToken || !flags.instanceId || !flags.orgId || !flags.appId) {
19
+ checkForValidEnvFile(this.config.bin, true);
20
+ }
21
+ const diagnostics = await PowerSyncClient.getInstanceDiagnostics({
22
+ appId: flags.appId,
23
+ authToken: flags.authToken,
24
+ instanceId: flags.instanceId,
25
+ orgId: flags.orgId
26
+ });
10
27
  const { errors } = diagnostics.connections[0];
11
28
  if (errors.length > 0) {
12
- ux.log(red(`❌ errors found:`));
29
+ ux.log(red(`❌ Errors found:`));
13
30
  errors.map((error) => {
14
31
  ux.log(red(`Level: ${error.level}`));
15
32
  return ux.log(red(`Message: ${error.message}\n`));