powersync 0.3.0 → 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 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
- * [PowerSync CLI](#powersync-cli)
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
- $ npm install -g powersync
13
- $ powersync COMMAND
16
+ $ npx powersync
17
+ $ npx powersync COMMAND
14
18
  running command...
15
- $ powersync (--version)
16
- powersync/0.3.0 linux-x64 node-v20.11.1
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.3.0/src/commands/init.ts)_
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.3.0/src/commands/instance/config.ts)_
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.3.0/src/commands/instance/create.ts)_
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.3.0/src/commands/instance/deploy.ts)_
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.3.0/src/commands/instance/destroy.ts)_
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.3.0/src/commands/instance/schema.ts)_
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.3.0/src/commands/instance/set.ts)_
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 [-a <value>] [-t <value>] [-i <value>] [-o <value>]
229
+ $ npx powersync instance status [-t <value>] [-i <value>] [-o <value>] [-p <value>]
214
230
 
215
231
  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
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 --appId=1234 --instanceId=1234 --authToken=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.3.0/src/commands/instance/status.ts)_
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.3.0/src/commands/instance/stop.ts)_
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.3.0/src/commands/instance/sync-rules/deploy.ts)_
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.3.0/src/commands/instance/sync-rules/generate-schema.ts)_
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.3.0/src/commands/instance/sync-rules/validate.ts)_
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.3.0/src/commands/instances.ts)_
358
+ _See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.4.0/src/commands/instances.ts)_
343
359
  <!-- commandsstop -->
@@ -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 apps = await AccountsClient.getPowerSyncApps(authTokenAnswers.authToken);
34
- if (apps.length === 0) {
35
- return ux.error(red(`No apps found. ${SUPPORT_MESSAGE}`), { exit: 1 });
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 appQuestions = [
37
+ const projectQuestions = [
38
38
  {
39
- choices: apps,
40
- message: 'Which app would you like to use?',
41
- name: 'appId',
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 appAnswers = await inquirer.prompt(appQuestions);
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}\nAPP_ID=${appAnswers.appId}\nAUTH_TOKEN=${authTokenAnswers.authToken}\n`);
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
  }
@@ -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 --appId=1234 --instanceId=1234 --authToken=1234'
8
+ '<%= config.bin %> <%= command.id %> --orgId=1234 --projectId=1234 --instanceId=1234 --authToken=1234'
9
9
  ];
10
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' })
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.appId) {
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 app = await AccountsClient.getCurrentPowerSyncApp();
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('"powersync instance create"')} to create your first instance.`);
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('app')} is currently set to ${green(app.name)}.`);
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
  }
@@ -11130,7 +11130,7 @@ var files = [
11130
11130
  "/dist",
11131
11131
  "/oclif.manifest.json"
11132
11132
  ];
11133
- var version = "0.3.0";
11133
+ var version = "0.4.0";
11134
11134
  var bugs = "https://github.com/powersync-ja/cli/issues";
11135
11135
  var types = "dist/index.d.ts";
11136
11136
  var exports = "./lib/index.js";
@@ -11166,12 +11166,12 @@ var scripts = {
11166
11166
  postpack: "shx rm -f oclif.manifest.json",
11167
11167
  posttest: "pnpm run lint",
11168
11168
  prepack: "pnpm run build && oclif manifest && oclif readme",
11169
- readme: "oclif readme",
11169
+ readme: "oclif readme && ./update-readme.sh",
11170
11170
  prepare: "pnpm run build",
11171
11171
  test: "vitest",
11172
11172
  release: "pnpm build && pnpm changeset publish",
11173
11173
  prettier: "prettier --write .",
11174
- version: "oclif readme && git add README.md",
11174
+ version: "pnpm run readme && git add README.md",
11175
11175
  "pack:tarballs": "oclif pack tarballs --parallel"
11176
11176
  };
11177
11177
  var dependencies = {
@@ -11256,23 +11256,23 @@ const getOrgs = async (bearerToken) => {
11256
11256
  const headers = generateHeader(bearerToken);
11257
11257
  return accountsClient(headers).listOrgs({});
11258
11258
  };
11259
- const getPowerSyncApps = async (bearerToken) => {
11259
+ const getPowerSyncProjects = async (bearerToken) => {
11260
11260
  const headers = generateHeader(bearerToken);
11261
11261
  const response = await accountsClient(headers).listApps({});
11262
11262
  if (response.count === 0) {
11263
11263
  return [];
11264
11264
  }
11265
- const apps = response.objects.filter((obj) => obj.features.includes(dist$4.ProjectFeatureFlags.POWERSYNC)).map((obj) => ({ name: obj.name, value: obj.id }));
11266
- return apps;
11265
+ const projects = response.objects.filter((obj) => obj.features.includes(dist$4.ProjectFeatureFlags.POWERSYNC)).map((obj) => ({ name: obj.name, value: obj.id }));
11266
+ return projects;
11267
11267
  };
11268
- const getCurrentPowerSyncApp = async () => {
11268
+ const getCurrentPowerSyncProject = async () => {
11269
11269
  const headers = generateHeader(process.env.AUTH_TOKEN);
11270
11270
  const response = await accountsClient(headers).listApps({});
11271
- const app = response.objects.find((obj) => obj.id === process.env.APP_ID);
11272
- if (!app) {
11273
- throw new Error("No app found.");
11271
+ const project = response.objects.find((obj) => obj.id === process.env.PROJECT_ID);
11272
+ if (!project) {
11273
+ throw new Error("No project found.");
11274
11274
  }
11275
- return app;
11275
+ return project;
11276
11276
  };
11277
11277
 
11278
- export { accountsClient, getCurrentPowerSyncApp, getOrgs, getPowerSyncApps };
11278
+ export { accountsClient, getCurrentPowerSyncProject, getOrgs, getPowerSyncProjects };
@@ -11519,7 +11519,7 @@ var files = [
11519
11519
  "/dist",
11520
11520
  "/oclif.manifest.json"
11521
11521
  ];
11522
- var version = "0.3.0";
11522
+ var version = "0.4.0";
11523
11523
  var bugs = "https://github.com/powersync-ja/cli/issues";
11524
11524
  var types$2 = "dist/index.d.ts";
11525
11525
  var exports = "./lib/index.js";
@@ -11555,12 +11555,12 @@ var scripts = {
11555
11555
  postpack: "shx rm -f oclif.manifest.json",
11556
11556
  posttest: "pnpm run lint",
11557
11557
  prepack: "pnpm run build && oclif manifest && oclif readme",
11558
- readme: "oclif readme",
11558
+ readme: "oclif readme && ./update-readme.sh",
11559
11559
  prepare: "pnpm run build",
11560
11560
  test: "vitest",
11561
11561
  release: "pnpm build && pnpm changeset publish",
11562
11562
  prettier: "prettier --write .",
11563
- version: "oclif readme && git add README.md",
11563
+ version: "pnpm run readme && git add README.md",
11564
11564
  "pack:tarballs": "oclif pack tarballs --parallel"
11565
11565
  };
11566
11566
  var dependencies$1 = {
@@ -11633,9 +11633,9 @@ const generateHeader = (bearerToken) => {
11633
11633
  "user-agent": `${APP_NAME}/${packageJSON.version}`
11634
11634
  };
11635
11635
  };
11636
- const checkAppId = (appId) => {
11637
- if (!appId)
11638
- throw new Error("No app id found");
11636
+ const checkProjectId = (projectId) => {
11637
+ if (!projectId)
11638
+ throw new Error("No project id found");
11639
11639
  };
11640
11640
  const checkOrgId = (orgId) => {
11641
11641
  if (!orgId)
@@ -37498,13 +37498,13 @@ const schemaGenerators = {
37498
37498
  };
37499
37499
 
37500
37500
  config_1({ path: ENV_FILE_PATH });
37501
- const { APP_ID, AUTH_TOKEN, INSTANCE_ID, ORG_ID } = process.env;
37501
+ const { AUTH_TOKEN, INSTANCE_ID, ORG_ID, PROJECT_ID } = process.env;
37502
37502
  var ENV_VARIABLES;
37503
37503
  (function(ENV_VARIABLES2) {
37504
- ENV_VARIABLES2["APP_ID"] = "APP_ID";
37505
37504
  ENV_VARIABLES2["AUTH_TOKEN"] = "AUTH_TOKEN";
37506
37505
  ENV_VARIABLES2["INSTANCE_ID"] = "INSTANCE_ID";
37507
37506
  ENV_VARIABLES2["ORG_ID"] = "ORG_ID";
37507
+ ENV_VARIABLES2["PROJECT_ID"] = "PROJECT_ID";
37508
37508
  })(ENV_VARIABLES || (ENV_VARIABLES = {}));
37509
37509
  const powerSyncClient = ({ authToken } = {}) => {
37510
37510
  const finalToken = authToken || AUTH_TOKEN;
@@ -37519,41 +37519,41 @@ const powerSyncClient = ({ authToken } = {}) => {
37519
37519
  };
37520
37520
  const getInstancesList = async () => {
37521
37521
  checkOrgId(ORG_ID);
37522
- checkAppId(APP_ID);
37522
+ checkProjectId(PROJECT_ID);
37523
37523
  return powerSyncClient().listInstances({
37524
- app_id: APP_ID,
37524
+ app_id: PROJECT_ID,
37525
37525
  org_id: ORG_ID
37526
37526
  });
37527
37527
  };
37528
37528
  const getInstanceConfig = async () => {
37529
37529
  checkOrgId(ORG_ID);
37530
- checkAppId(APP_ID);
37530
+ checkProjectId(PROJECT_ID);
37531
37531
  checkInstanceId(INSTANCE_ID);
37532
37532
  return powerSyncClient().getInstanceConfig({
37533
- app_id: APP_ID,
37533
+ app_id: PROJECT_ID,
37534
37534
  id: INSTANCE_ID,
37535
37535
  org_id: ORG_ID
37536
37536
  });
37537
37537
  };
37538
- const getInstanceDiagnostics = async ({ appId, authToken, instanceId, orgId }) => {
37539
- const finalAppId = appId || APP_ID;
37538
+ const getInstanceDiagnostics = async ({ authToken, instanceId, orgId, projectId }) => {
37539
+ const finalProjectId = projectId || PROJECT_ID;
37540
37540
  const finalInstanceId = instanceId || INSTANCE_ID;
37541
37541
  const finalOrgId = orgId || ORG_ID;
37542
37542
  checkOrgId(finalOrgId);
37543
- checkAppId(finalAppId);
37543
+ checkProjectId(finalProjectId);
37544
37544
  checkInstanceId(finalInstanceId);
37545
37545
  return powerSyncClient({ authToken }).getInstanceDiagnostics({
37546
- app_id: finalAppId,
37546
+ app_id: finalProjectId,
37547
37547
  id: finalInstanceId,
37548
37548
  org_id: finalOrgId
37549
37549
  });
37550
37550
  };
37551
37551
  const getInstanceSchema = async () => {
37552
37552
  checkOrgId(ORG_ID);
37553
- checkAppId(APP_ID);
37553
+ checkProjectId(PROJECT_ID);
37554
37554
  checkInstanceId(INSTANCE_ID);
37555
37555
  return powerSyncClient().getInstanceSchema({
37556
- app_id: APP_ID,
37556
+ app_id: PROJECT_ID,
37557
37557
  id: INSTANCE_ID,
37558
37558
  org_id: ORG_ID
37559
37559
  });
@@ -37561,57 +37561,57 @@ const getInstanceSchema = async () => {
37561
37561
  const getInstanceStatus = async (instanceId) => {
37562
37562
  const finalInstanceId = instanceId || INSTANCE_ID;
37563
37563
  checkOrgId(ORG_ID);
37564
- checkAppId(APP_ID);
37564
+ checkProjectId(PROJECT_ID);
37565
37565
  checkInstanceId(finalInstanceId);
37566
37566
  return powerSyncClient().getInstanceStatus({
37567
- app_id: APP_ID,
37567
+ app_id: PROJECT_ID,
37568
37568
  id: instanceId ?? INSTANCE_ID,
37569
37569
  org_id: ORG_ID
37570
37570
  });
37571
37571
  };
37572
37572
  const destroyInstance = async () => {
37573
37573
  checkOrgId(ORG_ID);
37574
- checkAppId(APP_ID);
37574
+ checkProjectId(PROJECT_ID);
37575
37575
  checkInstanceId(INSTANCE_ID);
37576
37576
  return powerSyncClient().destroyInstance({
37577
- app_id: APP_ID,
37577
+ app_id: PROJECT_ID,
37578
37578
  id: INSTANCE_ID,
37579
37579
  org_id: ORG_ID
37580
37580
  });
37581
37581
  };
37582
37582
  const deactivateInstance = async () => {
37583
37583
  checkOrgId(ORG_ID);
37584
- checkAppId(APP_ID);
37584
+ checkProjectId(PROJECT_ID);
37585
37585
  checkInstanceId(INSTANCE_ID);
37586
37586
  return powerSyncClient().deactivateInstance({
37587
- app_id: APP_ID,
37587
+ app_id: PROJECT_ID,
37588
37588
  id: INSTANCE_ID,
37589
37589
  org_id: ORG_ID
37590
37590
  });
37591
37591
  };
37592
37592
  const createInstance = async (name) => {
37593
37593
  checkOrgId(ORG_ID);
37594
- checkAppId(APP_ID);
37594
+ checkProjectId(PROJECT_ID);
37595
37595
  return powerSyncClient().createInstance({
37596
- app_id: APP_ID,
37596
+ app_id: PROJECT_ID,
37597
37597
  name,
37598
37598
  org_id: ORG_ID
37599
37599
  });
37600
37600
  };
37601
37601
  const testConnection = async (connection) => {
37602
37602
  checkOrgId(ORG_ID);
37603
- checkAppId(APP_ID);
37603
+ checkProjectId(PROJECT_ID);
37604
37604
  return powerSyncClient().testConnection({
37605
- app_id: APP_ID,
37605
+ app_id: PROJECT_ID,
37606
37606
  connection,
37607
37607
  org_id: ORG_ID
37608
37608
  });
37609
37609
  };
37610
37610
  const deployInstance = async (config, instanceId) => {
37611
37611
  checkOrgId(ORG_ID);
37612
- checkAppId(APP_ID);
37612
+ checkProjectId(PROJECT_ID);
37613
37613
  return powerSyncClient().deployInstance({
37614
- app_id: APP_ID,
37614
+ app_id: PROJECT_ID,
37615
37615
  config,
37616
37616
  id: instanceId,
37617
37617
  org_id: ORG_ID
@@ -37619,10 +37619,10 @@ const deployInstance = async (config, instanceId) => {
37619
37619
  };
37620
37620
  const validateSyncRules = async (syncRules) => {
37621
37621
  checkOrgId(ORG_ID);
37622
- checkAppId(APP_ID);
37622
+ checkProjectId(PROJECT_ID);
37623
37623
  checkInstanceId(INSTANCE_ID);
37624
37624
  return powerSyncClient().validateSyncRules({
37625
- app_id: APP_ID,
37625
+ app_id: PROJECT_ID,
37626
37626
  id: INSTANCE_ID,
37627
37627
  org_id: ORG_ID,
37628
37628
  sync_rules: syncRules
@@ -37630,7 +37630,7 @@ const validateSyncRules = async (syncRules) => {
37630
37630
  };
37631
37631
  const deploySyncRules = async (syncRules) => {
37632
37632
  checkOrgId(ORG_ID);
37633
- checkAppId(APP_ID);
37633
+ checkProjectId(PROJECT_ID);
37634
37634
  checkInstanceId(INSTANCE_ID);
37635
37635
  const config = await getInstanceConfig();
37636
37636
  if (!config.config) {
@@ -37640,7 +37640,7 @@ const deploySyncRules = async (syncRules) => {
37640
37640
  throw new Error("No sync rules found");
37641
37641
  }
37642
37642
  return powerSyncClient().deployInstance({
37643
- app_id: APP_ID,
37643
+ app_id: PROJECT_ID,
37644
37644
  config: config.config,
37645
37645
  id: INSTANCE_ID,
37646
37646
  org_id: ORG_ID,
@@ -37649,10 +37649,10 @@ const deploySyncRules = async (syncRules) => {
37649
37649
  };
37650
37650
  const processSyncRules = async () => {
37651
37651
  checkOrgId(ORG_ID);
37652
- checkAppId(APP_ID);
37652
+ checkProjectId(PROJECT_ID);
37653
37653
  checkInstanceId(INSTANCE_ID);
37654
37654
  powerSyncClient().reprocessSyncRules({
37655
- app_id: APP_ID,
37655
+ app_id: PROJECT_ID,
37656
37656
  id: INSTANCE_ID,
37657
37657
  org_id: ORG_ID
37658
37658
  });
@@ -18,7 +18,7 @@ var files = [
18
18
  "/dist",
19
19
  "/oclif.manifest.json"
20
20
  ];
21
- var version = "0.3.0";
21
+ var version = "0.4.0";
22
22
  var bugs = "https://github.com/powersync-ja/cli/issues";
23
23
  var types = "dist/index.d.ts";
24
24
  var exports = "./lib/index.js";
@@ -54,12 +54,12 @@ var scripts = {
54
54
  postpack: "shx rm -f oclif.manifest.json",
55
55
  posttest: "pnpm run lint",
56
56
  prepack: "pnpm run build && oclif manifest && oclif readme",
57
- readme: "oclif readme",
57
+ readme: "oclif readme && ./update-readme.sh",
58
58
  prepare: "pnpm run build",
59
59
  test: "vitest",
60
60
  release: "pnpm build && pnpm changeset publish",
61
61
  prettier: "prettier --write .",
62
- version: "oclif readme && git add README.md",
62
+ version: "pnpm run readme && git add README.md",
63
63
  "pack:tarballs": "oclif pack tarballs --parallel"
64
64
  };
65
65
  var dependencies = {
@@ -135,9 +135,9 @@ const generateHeader = (bearerToken) => {
135
135
  "user-agent": `${APP_NAME}/${packageJSON.version}`
136
136
  };
137
137
  };
138
- const checkAppId = (appId) => {
139
- if (!appId)
140
- throw new Error("No app id found");
138
+ const checkProjectId = (projectId) => {
139
+ if (!projectId)
140
+ throw new Error("No project id found");
141
141
  };
142
142
  const checkOrgId = (orgId) => {
143
143
  if (!orgId)
@@ -148,4 +148,4 @@ const checkInstanceId = (instanceId) => {
148
148
  throw new Error("No instance id found");
149
149
  };
150
150
 
151
- export { checkAppId, checkInstanceId, checkOrgId, generateHeader };
151
+ export { checkInstanceId, checkOrgId, checkProjectId, generateHeader };
package/dist/utils.js CHANGED
@@ -4,7 +4,7 @@ import { ENV_FILE_PATH } from './constants.js';
4
4
  import { ENV_VARIABLES } from './service/powersync.client.js';
5
5
  // Add cliName as argument because we don't have access to this.config.bin in this file
6
6
  export const checkForValidEnvFile = (cliName, requiresInstanceId = false) => {
7
- const requiredProperties = [ENV_VARIABLES.APP_ID, ENV_VARIABLES.AUTH_TOKEN, ENV_VARIABLES.ORG_ID];
7
+ const requiredProperties = [ENV_VARIABLES.PROJECT_ID, ENV_VARIABLES.AUTH_TOKEN, ENV_VARIABLES.ORG_ID];
8
8
  const missingProperties = requiredProperties.filter((prop) => !process.env[prop]);
9
9
  if (!fs.existsSync(ENV_FILE_PATH) || missingProperties.length > 0) {
10
10
  ux.error(`CLI has not been initialized. Please run ${green(`"${cliName} init"`)}.`, { exit: 1 });
@@ -324,23 +324,15 @@
324
324
  "instance:status": {
325
325
  "aliases": [],
326
326
  "args": {},
327
- "description": "View the status of the current instance.",
327
+ "description": "View the status of the current instance. View the status of a different instance by using flags.",
328
328
  "examples": [
329
329
  "<%= config.bin %> <%= command.id %>",
330
- "<%= config.bin %> <%= command.id %> --orgId=1234 --appId=1234 --instanceId=1234 --authToken=1234"
330
+ "<%= config.bin %> <%= command.id %> --orgId=1234 --projectId=1234 --instanceId=1234 --authToken=1234"
331
331
  ],
332
332
  "flags": {
333
- "appId": {
334
- "char": "a",
335
- "description": "app id to use",
336
- "name": "appId",
337
- "hasDynamicHelp": false,
338
- "multiple": false,
339
- "type": "option"
340
- },
341
333
  "authToken": {
342
334
  "char": "t",
343
- "description": "auth token to use",
335
+ "description": "Override current auth token.",
344
336
  "name": "authToken",
345
337
  "hasDynamicHelp": false,
346
338
  "multiple": false,
@@ -348,7 +340,7 @@
348
340
  },
349
341
  "instanceId": {
350
342
  "char": "i",
351
- "description": "instance id to use",
343
+ "description": "Override current instance by providing the ID of a different instance.",
352
344
  "name": "instanceId",
353
345
  "hasDynamicHelp": false,
354
346
  "multiple": false,
@@ -356,11 +348,19 @@
356
348
  },
357
349
  "orgId": {
358
350
  "char": "o",
359
- "description": "org id to use",
351
+ "description": "Override current organization by providing the ID of a different organization.",
360
352
  "name": "orgId",
361
353
  "hasDynamicHelp": false,
362
354
  "multiple": false,
363
355
  "type": "option"
356
+ },
357
+ "projectId": {
358
+ "char": "p",
359
+ "description": "Override current project by providing the ID of a different project.",
360
+ "name": "projectId",
361
+ "hasDynamicHelp": false,
362
+ "multiple": false,
363
+ "type": "option"
364
364
  }
365
365
  },
366
366
  "hasDynamicHelp": false,
@@ -414,7 +414,7 @@
414
414
  "instance:sync-rules:deploy": {
415
415
  "aliases": [],
416
416
  "args": {},
417
- "description": "Deploy sync rules from a local sync rules file to the current instance.",
417
+ "description": "Deploy sync rules from a local sync rules config file to the current instance.",
418
418
  "examples": [
419
419
  "<%= config.bin %> <%= command.id %>",
420
420
  "<%= config.bin %> <%= command.id %> --filePath path/to/file",
@@ -458,7 +458,7 @@
458
458
  "instance:sync-rules:generate-schema": {
459
459
  "aliases": [],
460
460
  "args": {},
461
- "description": "Generate schema in your language from your sync rules file.",
461
+ "description": "Generate schema in your language from your sync rules config file.",
462
462
  "examples": [
463
463
  "<%= config.bin %> <%= command.id %>",
464
464
  "<%= config.bin %> <%= command.id %> --filePath path/to/file",
@@ -507,7 +507,7 @@
507
507
  "instance:sync-rules:validate": {
508
508
  "aliases": [],
509
509
  "args": {},
510
- "description": "Validate sync rules from a local sync rules file.",
510
+ "description": "Validate sync rules from a local sync rules config file.",
511
511
  "examples": [
512
512
  "<%= config.bin %> <%= command.id %>",
513
513
  "<%= config.bin %> <%= command.id %> --filePath path/to/file",
@@ -542,5 +542,5 @@
542
542
  ]
543
543
  }
544
544
  },
545
- "version": "0.3.0"
545
+ "version": "0.4.0"
546
546
  }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "/dist",
17
17
  "/oclif.manifest.json"
18
18
  ],
19
- "version": "0.3.0",
19
+ "version": "0.4.0",
20
20
  "bugs": "https://github.com/powersync-ja/cli/issues",
21
21
  "types": "dist/index.d.ts",
22
22
  "exports": "./lib/index.js",
@@ -90,11 +90,11 @@
90
90
  "bundle:powersync-deps": "shx rm -rf lib && rollup -c rollup.config.mjs",
91
91
  "lint": "eslint . --ext .ts",
92
92
  "posttest": "pnpm run lint",
93
- "readme": "oclif readme",
93
+ "readme": "oclif readme && ./update-readme.sh",
94
94
  "test": "vitest",
95
95
  "release": "pnpm build && pnpm changeset publish",
96
96
  "prettier": "prettier --write .",
97
- "version": "oclif readme && git add README.md",
97
+ "version": "pnpm run readme && git add README.md",
98
98
  "pack:tarballs": "oclif pack tarballs --parallel"
99
99
  }
100
100
  }