@kinotic-ai/kinotic-cli 2.2.0 → 2.3.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 +1 -393
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.js +21 -0
- package/dist/commands/synchronize.d.ts +0 -1
- package/dist/commands/synchronize.js +38 -37
- package/dist/internal/CliAuthenticator.d.ts +46 -0
- package/dist/internal/CliAuthenticator.js +217 -0
- package/dist/internal/Utils.d.ts +0 -16
- package/dist/internal/Utils.js +0 -141
- package/dist/templates/entity/BaseRepository.liquid +2 -2
- package/package.json +9 -29
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -6
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -6
- package/oclif.manifest.json +0 -213
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Kinotic CLI
|
|
2
2
|
=================
|
|
3
3
|
|
|
4
4
|
<!-- toc -->
|
|
@@ -21,57 +21,13 @@ USAGE
|
|
|
21
21
|
<!-- usagestop -->
|
|
22
22
|
# Commands
|
|
23
23
|
<!-- commands -->
|
|
24
|
-
* [`kinotic autocomplete [SHELL]`](#kinotic-autocomplete-shell)
|
|
25
24
|
* [`kinotic create project NAME`](#kinotic-create-project-name)
|
|
26
25
|
* [`kinotic gen`](#kinotic-gen)
|
|
27
26
|
* [`kinotic generate`](#kinotic-generate)
|
|
28
|
-
* [`kinotic help [COMMAND]`](#kinotic-help-command)
|
|
29
27
|
* [`kinotic init`](#kinotic-init)
|
|
30
28
|
* [`kinotic initialize`](#kinotic-initialize)
|
|
31
|
-
* [`kinotic plugins`](#kinotic-plugins)
|
|
32
|
-
* [`kinotic plugins add PLUGIN`](#kinotic-plugins-add-plugin)
|
|
33
|
-
* [`kinotic plugins:inspect PLUGIN...`](#kinotic-pluginsinspect-plugin)
|
|
34
|
-
* [`kinotic plugins install PLUGIN`](#kinotic-plugins-install-plugin)
|
|
35
|
-
* [`kinotic plugins link PATH`](#kinotic-plugins-link-path)
|
|
36
|
-
* [`kinotic plugins remove [PLUGIN]`](#kinotic-plugins-remove-plugin)
|
|
37
|
-
* [`kinotic plugins reset`](#kinotic-plugins-reset)
|
|
38
|
-
* [`kinotic plugins uninstall [PLUGIN]`](#kinotic-plugins-uninstall-plugin)
|
|
39
|
-
* [`kinotic plugins unlink [PLUGIN]`](#kinotic-plugins-unlink-plugin)
|
|
40
|
-
* [`kinotic plugins update`](#kinotic-plugins-update)
|
|
41
29
|
* [`kinotic sync`](#kinotic-sync)
|
|
42
30
|
* [`kinotic synchronize`](#kinotic-synchronize)
|
|
43
|
-
* [`kinotic update [CHANNEL]`](#kinotic-update-channel)
|
|
44
|
-
|
|
45
|
-
## `kinotic autocomplete [SHELL]`
|
|
46
|
-
|
|
47
|
-
Display autocomplete installation instructions.
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
USAGE
|
|
51
|
-
$ kinotic autocomplete [SHELL] [-r]
|
|
52
|
-
|
|
53
|
-
ARGUMENTS
|
|
54
|
-
[SHELL] (zsh|bash|powershell) Shell type
|
|
55
|
-
|
|
56
|
-
FLAGS
|
|
57
|
-
-r, --refresh-cache Refresh cache (ignores displaying instructions)
|
|
58
|
-
|
|
59
|
-
DESCRIPTION
|
|
60
|
-
Display autocomplete installation instructions.
|
|
61
|
-
|
|
62
|
-
EXAMPLES
|
|
63
|
-
$ kinotic autocomplete
|
|
64
|
-
|
|
65
|
-
$ kinotic autocomplete bash
|
|
66
|
-
|
|
67
|
-
$ kinotic autocomplete zsh
|
|
68
|
-
|
|
69
|
-
$ kinotic autocomplete powershell
|
|
70
|
-
|
|
71
|
-
$ kinotic autocomplete --refresh-cache
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.41/src/commands/autocomplete/index.ts)_
|
|
75
31
|
|
|
76
32
|
## `kinotic create project NAME`
|
|
77
33
|
|
|
@@ -151,26 +107,6 @@ EXAMPLES
|
|
|
151
107
|
|
|
152
108
|
_See code: [src/commands/generate.ts](https://github.com/kinotic-ai/kinotic/blob/v2.2.0/src/commands/generate.ts)_
|
|
153
109
|
|
|
154
|
-
## `kinotic help [COMMAND]`
|
|
155
|
-
|
|
156
|
-
Display help for kinotic.
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
USAGE
|
|
160
|
-
$ kinotic help [COMMAND...] [-n]
|
|
161
|
-
|
|
162
|
-
ARGUMENTS
|
|
163
|
-
[COMMAND...] Command to show help for.
|
|
164
|
-
|
|
165
|
-
FLAGS
|
|
166
|
-
-n, --nested-commands Include all nested commands in the output.
|
|
167
|
-
|
|
168
|
-
DESCRIPTION
|
|
169
|
-
Display help for kinotic.
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/6.2.38/src/commands/help.ts)_
|
|
173
|
-
|
|
174
110
|
## `kinotic init`
|
|
175
111
|
|
|
176
112
|
This will initialize a new Kinotic Project for use with the Kinotic CLI.
|
|
@@ -233,296 +169,6 @@ EXAMPLES
|
|
|
233
169
|
|
|
234
170
|
_See code: [src/commands/initialize.ts](https://github.com/kinotic-ai/kinotic/blob/v2.2.0/src/commands/initialize.ts)_
|
|
235
171
|
|
|
236
|
-
## `kinotic plugins`
|
|
237
|
-
|
|
238
|
-
List installed plugins.
|
|
239
|
-
|
|
240
|
-
```
|
|
241
|
-
USAGE
|
|
242
|
-
$ kinotic plugins [--json] [--core]
|
|
243
|
-
|
|
244
|
-
FLAGS
|
|
245
|
-
--core Show core plugins.
|
|
246
|
-
|
|
247
|
-
GLOBAL FLAGS
|
|
248
|
-
--json Format output as json.
|
|
249
|
-
|
|
250
|
-
DESCRIPTION
|
|
251
|
-
List installed plugins.
|
|
252
|
-
|
|
253
|
-
EXAMPLES
|
|
254
|
-
$ kinotic plugins
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/5.4.58/src/commands/plugins/index.ts)_
|
|
258
|
-
|
|
259
|
-
## `kinotic plugins add PLUGIN`
|
|
260
|
-
|
|
261
|
-
Installs a plugin into kinotic.
|
|
262
|
-
|
|
263
|
-
```
|
|
264
|
-
USAGE
|
|
265
|
-
$ kinotic plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
|
|
266
|
-
|
|
267
|
-
ARGUMENTS
|
|
268
|
-
PLUGIN... Plugin to install.
|
|
269
|
-
|
|
270
|
-
FLAGS
|
|
271
|
-
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
|
272
|
-
-h, --help Show CLI help.
|
|
273
|
-
-s, --silent Silences npm output.
|
|
274
|
-
-v, --verbose Show verbose npm output.
|
|
275
|
-
|
|
276
|
-
GLOBAL FLAGS
|
|
277
|
-
--json Format output as json.
|
|
278
|
-
|
|
279
|
-
DESCRIPTION
|
|
280
|
-
Installs a plugin into kinotic.
|
|
281
|
-
|
|
282
|
-
Uses npm to install plugins.
|
|
283
|
-
|
|
284
|
-
Installation of a user-installed plugin will override a core plugin.
|
|
285
|
-
|
|
286
|
-
Use the KINOTIC_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
|
287
|
-
Use the KINOTIC_NPM_REGISTRY environment variable to set the npm registry.
|
|
288
|
-
|
|
289
|
-
ALIASES
|
|
290
|
-
$ kinotic plugins add
|
|
291
|
-
|
|
292
|
-
EXAMPLES
|
|
293
|
-
Install a plugin from npm registry.
|
|
294
|
-
|
|
295
|
-
$ kinotic plugins add myplugin
|
|
296
|
-
|
|
297
|
-
Install a plugin from a github url.
|
|
298
|
-
|
|
299
|
-
$ kinotic plugins add https://github.com/someuser/someplugin
|
|
300
|
-
|
|
301
|
-
Install a plugin from a github slug.
|
|
302
|
-
|
|
303
|
-
$ kinotic plugins add someuser/someplugin
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
## `kinotic plugins:inspect PLUGIN...`
|
|
307
|
-
|
|
308
|
-
Displays installation properties of a plugin.
|
|
309
|
-
|
|
310
|
-
```
|
|
311
|
-
USAGE
|
|
312
|
-
$ kinotic plugins inspect PLUGIN...
|
|
313
|
-
|
|
314
|
-
ARGUMENTS
|
|
315
|
-
PLUGIN... [default: .] Plugin to inspect.
|
|
316
|
-
|
|
317
|
-
FLAGS
|
|
318
|
-
-h, --help Show CLI help.
|
|
319
|
-
-v, --verbose
|
|
320
|
-
|
|
321
|
-
GLOBAL FLAGS
|
|
322
|
-
--json Format output as json.
|
|
323
|
-
|
|
324
|
-
DESCRIPTION
|
|
325
|
-
Displays installation properties of a plugin.
|
|
326
|
-
|
|
327
|
-
EXAMPLES
|
|
328
|
-
$ kinotic plugins inspect myplugin
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/5.4.58/src/commands/plugins/inspect.ts)_
|
|
332
|
-
|
|
333
|
-
## `kinotic plugins install PLUGIN`
|
|
334
|
-
|
|
335
|
-
Installs a plugin into kinotic.
|
|
336
|
-
|
|
337
|
-
```
|
|
338
|
-
USAGE
|
|
339
|
-
$ kinotic plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
|
|
340
|
-
|
|
341
|
-
ARGUMENTS
|
|
342
|
-
PLUGIN... Plugin to install.
|
|
343
|
-
|
|
344
|
-
FLAGS
|
|
345
|
-
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
|
346
|
-
-h, --help Show CLI help.
|
|
347
|
-
-s, --silent Silences npm output.
|
|
348
|
-
-v, --verbose Show verbose npm output.
|
|
349
|
-
|
|
350
|
-
GLOBAL FLAGS
|
|
351
|
-
--json Format output as json.
|
|
352
|
-
|
|
353
|
-
DESCRIPTION
|
|
354
|
-
Installs a plugin into kinotic.
|
|
355
|
-
|
|
356
|
-
Uses npm to install plugins.
|
|
357
|
-
|
|
358
|
-
Installation of a user-installed plugin will override a core plugin.
|
|
359
|
-
|
|
360
|
-
Use the KINOTIC_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
|
361
|
-
Use the KINOTIC_NPM_REGISTRY environment variable to set the npm registry.
|
|
362
|
-
|
|
363
|
-
ALIASES
|
|
364
|
-
$ kinotic plugins add
|
|
365
|
-
|
|
366
|
-
EXAMPLES
|
|
367
|
-
Install a plugin from npm registry.
|
|
368
|
-
|
|
369
|
-
$ kinotic plugins install myplugin
|
|
370
|
-
|
|
371
|
-
Install a plugin from a github url.
|
|
372
|
-
|
|
373
|
-
$ kinotic plugins install https://github.com/someuser/someplugin
|
|
374
|
-
|
|
375
|
-
Install a plugin from a github slug.
|
|
376
|
-
|
|
377
|
-
$ kinotic plugins install someuser/someplugin
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/5.4.58/src/commands/plugins/install.ts)_
|
|
381
|
-
|
|
382
|
-
## `kinotic plugins link PATH`
|
|
383
|
-
|
|
384
|
-
Links a plugin into the CLI for development.
|
|
385
|
-
|
|
386
|
-
```
|
|
387
|
-
USAGE
|
|
388
|
-
$ kinotic plugins link PATH [-h] [--install] [-v]
|
|
389
|
-
|
|
390
|
-
ARGUMENTS
|
|
391
|
-
PATH [default: .] path to plugin
|
|
392
|
-
|
|
393
|
-
FLAGS
|
|
394
|
-
-h, --help Show CLI help.
|
|
395
|
-
-v, --verbose
|
|
396
|
-
--[no-]install Install dependencies after linking the plugin.
|
|
397
|
-
|
|
398
|
-
DESCRIPTION
|
|
399
|
-
Links a plugin into the CLI for development.
|
|
400
|
-
|
|
401
|
-
Installation of a linked plugin will override a user-installed or core plugin.
|
|
402
|
-
|
|
403
|
-
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
404
|
-
command will override the user-installed or core plugin implementation. This is useful for development work.
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
EXAMPLES
|
|
408
|
-
$ kinotic plugins link myplugin
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/5.4.58/src/commands/plugins/link.ts)_
|
|
412
|
-
|
|
413
|
-
## `kinotic plugins remove [PLUGIN]`
|
|
414
|
-
|
|
415
|
-
Removes a plugin from the CLI.
|
|
416
|
-
|
|
417
|
-
```
|
|
418
|
-
USAGE
|
|
419
|
-
$ kinotic plugins remove [PLUGIN...] [-h] [-v]
|
|
420
|
-
|
|
421
|
-
ARGUMENTS
|
|
422
|
-
[PLUGIN...] plugin to uninstall
|
|
423
|
-
|
|
424
|
-
FLAGS
|
|
425
|
-
-h, --help Show CLI help.
|
|
426
|
-
-v, --verbose
|
|
427
|
-
|
|
428
|
-
DESCRIPTION
|
|
429
|
-
Removes a plugin from the CLI.
|
|
430
|
-
|
|
431
|
-
ALIASES
|
|
432
|
-
$ kinotic plugins unlink
|
|
433
|
-
$ kinotic plugins remove
|
|
434
|
-
|
|
435
|
-
EXAMPLES
|
|
436
|
-
$ kinotic plugins remove myplugin
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
## `kinotic plugins reset`
|
|
440
|
-
|
|
441
|
-
Remove all user-installed and linked plugins.
|
|
442
|
-
|
|
443
|
-
```
|
|
444
|
-
USAGE
|
|
445
|
-
$ kinotic plugins reset [--hard] [--reinstall]
|
|
446
|
-
|
|
447
|
-
FLAGS
|
|
448
|
-
--hard Delete node_modules and package manager related files in addition to uninstalling plugins.
|
|
449
|
-
--reinstall Reinstall all plugins after uninstalling.
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/5.4.58/src/commands/plugins/reset.ts)_
|
|
453
|
-
|
|
454
|
-
## `kinotic plugins uninstall [PLUGIN]`
|
|
455
|
-
|
|
456
|
-
Removes a plugin from the CLI.
|
|
457
|
-
|
|
458
|
-
```
|
|
459
|
-
USAGE
|
|
460
|
-
$ kinotic plugins uninstall [PLUGIN...] [-h] [-v]
|
|
461
|
-
|
|
462
|
-
ARGUMENTS
|
|
463
|
-
[PLUGIN...] plugin to uninstall
|
|
464
|
-
|
|
465
|
-
FLAGS
|
|
466
|
-
-h, --help Show CLI help.
|
|
467
|
-
-v, --verbose
|
|
468
|
-
|
|
469
|
-
DESCRIPTION
|
|
470
|
-
Removes a plugin from the CLI.
|
|
471
|
-
|
|
472
|
-
ALIASES
|
|
473
|
-
$ kinotic plugins unlink
|
|
474
|
-
$ kinotic plugins remove
|
|
475
|
-
|
|
476
|
-
EXAMPLES
|
|
477
|
-
$ kinotic plugins uninstall myplugin
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/5.4.58/src/commands/plugins/uninstall.ts)_
|
|
481
|
-
|
|
482
|
-
## `kinotic plugins unlink [PLUGIN]`
|
|
483
|
-
|
|
484
|
-
Removes a plugin from the CLI.
|
|
485
|
-
|
|
486
|
-
```
|
|
487
|
-
USAGE
|
|
488
|
-
$ kinotic plugins unlink [PLUGIN...] [-h] [-v]
|
|
489
|
-
|
|
490
|
-
ARGUMENTS
|
|
491
|
-
[PLUGIN...] plugin to uninstall
|
|
492
|
-
|
|
493
|
-
FLAGS
|
|
494
|
-
-h, --help Show CLI help.
|
|
495
|
-
-v, --verbose
|
|
496
|
-
|
|
497
|
-
DESCRIPTION
|
|
498
|
-
Removes a plugin from the CLI.
|
|
499
|
-
|
|
500
|
-
ALIASES
|
|
501
|
-
$ kinotic plugins unlink
|
|
502
|
-
$ kinotic plugins remove
|
|
503
|
-
|
|
504
|
-
EXAMPLES
|
|
505
|
-
$ kinotic plugins unlink myplugin
|
|
506
|
-
```
|
|
507
|
-
|
|
508
|
-
## `kinotic plugins update`
|
|
509
|
-
|
|
510
|
-
Update installed plugins.
|
|
511
|
-
|
|
512
|
-
```
|
|
513
|
-
USAGE
|
|
514
|
-
$ kinotic plugins update [-h] [-v]
|
|
515
|
-
|
|
516
|
-
FLAGS
|
|
517
|
-
-h, --help Show CLI help.
|
|
518
|
-
-v, --verbose
|
|
519
|
-
|
|
520
|
-
DESCRIPTION
|
|
521
|
-
Update installed plugins.
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/5.4.58/src/commands/plugins/update.ts)_
|
|
525
|
-
|
|
526
172
|
## `kinotic sync`
|
|
527
173
|
|
|
528
174
|
Synchronize the local Entity definitions with the Kinotic Server
|
|
@@ -588,42 +234,4 @@ EXAMPLES
|
|
|
588
234
|
```
|
|
589
235
|
|
|
590
236
|
_See code: [src/commands/synchronize.ts](https://github.com/kinotic-ai/kinotic/blob/v2.2.0/src/commands/synchronize.ts)_
|
|
591
|
-
|
|
592
|
-
## `kinotic update [CHANNEL]`
|
|
593
|
-
|
|
594
|
-
update the kinotic CLI
|
|
595
|
-
|
|
596
|
-
```
|
|
597
|
-
USAGE
|
|
598
|
-
$ kinotic update [CHANNEL] [--force | | [-a | -v <value> | -i]] [-b ]
|
|
599
|
-
|
|
600
|
-
FLAGS
|
|
601
|
-
-a, --available See available versions.
|
|
602
|
-
-b, --verbose Show more details about the available versions.
|
|
603
|
-
-i, --interactive Interactively select version to install. This is ignored if a channel is provided.
|
|
604
|
-
-v, --version=<value> Install a specific version.
|
|
605
|
-
--force Force a re-download of the requested version.
|
|
606
|
-
|
|
607
|
-
DESCRIPTION
|
|
608
|
-
update the kinotic CLI
|
|
609
|
-
|
|
610
|
-
EXAMPLES
|
|
611
|
-
Update to the stable channel:
|
|
612
|
-
|
|
613
|
-
$ kinotic update stable
|
|
614
|
-
|
|
615
|
-
Update to a specific version:
|
|
616
|
-
|
|
617
|
-
$ kinotic update --version 1.0.0
|
|
618
|
-
|
|
619
|
-
Interactively select version:
|
|
620
|
-
|
|
621
|
-
$ kinotic update --interactive
|
|
622
|
-
|
|
623
|
-
See available versions:
|
|
624
|
-
|
|
625
|
-
$ kinotic update --available
|
|
626
|
-
```
|
|
627
|
-
|
|
628
|
-
_See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/4.7.23/src/commands/update.ts)_
|
|
629
237
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export declare class Login extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
server: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { resolveServer } from '../internal/state/Environment.js';
|
|
3
|
+
import { CliAuthenticator } from '../internal/CliAuthenticator.js';
|
|
4
|
+
export class Login extends Command {
|
|
5
|
+
static description = 'Log in to a Kinotic Server and store credentials for subsequent commands';
|
|
6
|
+
static examples = [
|
|
7
|
+
'$ kinotic login',
|
|
8
|
+
'$ kinotic login --server http://localhost:9090'
|
|
9
|
+
];
|
|
10
|
+
static flags = {
|
|
11
|
+
server: Flags.string({ char: 's', description: 'The Kinotic server to log in to' })
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { flags } = await this.parse(Login);
|
|
15
|
+
const serverConfig = await resolveServer(this.config.configDir, flags.server);
|
|
16
|
+
if (!(await new CliAuthenticator(serverConfig.url, this.config.configDir, this).login())) {
|
|
17
|
+
this.error('Login failed');
|
|
18
|
+
}
|
|
19
|
+
this.log(`Logged in to ${serverConfig.url}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -7,7 +7,6 @@ export declare class Synchronize extends Command {
|
|
|
7
7
|
server: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
8
|
publish: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
9
|
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
authHeaderFile: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
10
|
dryRun: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
11
|
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
12
|
};
|
|
@@ -7,7 +7,7 @@ import { WebSocket } from 'ws';
|
|
|
7
7
|
import { EntityCodeGenerationService } from '../internal/EntityCodeGenerationService.js';
|
|
8
8
|
import { ProjectMigrationService } from '../internal/ProjectMigrationService.js';
|
|
9
9
|
import { resolveServer } from '../internal/state/Environment.js';
|
|
10
|
-
import {
|
|
10
|
+
import { CliAuthenticator } from '../internal/CliAuthenticator.js';
|
|
11
11
|
// This is required when running Kinotic from node
|
|
12
12
|
Object.assign(global, { WebSocket });
|
|
13
13
|
Kinotic.use(OsApiPlugin);
|
|
@@ -24,7 +24,6 @@ export class Synchronize extends Command {
|
|
|
24
24
|
server: Flags.string({ char: 's', description: 'The Kinotic server to connect to' }),
|
|
25
25
|
publish: Flags.boolean({ char: 'p', description: 'Publish each Entity after save/update' }),
|
|
26
26
|
verbose: Flags.boolean({ char: 'v', description: 'Enable verbose logging' }),
|
|
27
|
-
authHeaderFile: Flags.string({ char: 'f', description: 'JSON File containing authentication headers', required: false }),
|
|
28
27
|
dryRun: Flags.boolean({ description: 'Dry run enables verbose logging and does not save any changes to the server' }),
|
|
29
28
|
force: Flags.boolean({ description: 'Force full regeneration, ignoring incremental change detection', default: false })
|
|
30
29
|
};
|
|
@@ -40,45 +39,47 @@ export class Synchronize extends Command {
|
|
|
40
39
|
const serverConfig = await resolveServer(this.config.configDir, flags.server);
|
|
41
40
|
serverUrl = serverConfig.url;
|
|
42
41
|
}
|
|
43
|
-
if (flags.dryRun
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
if (!flags.dryRun && !(await new CliAuthenticator(serverUrl, this.config.configDir, this).connect())) {
|
|
43
|
+
this.error('Could not connect to the Kinotic Server');
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
let project = null;
|
|
47
|
+
if (!flags.dryRun) {
|
|
48
|
+
await Kinotic.applications.createApplicationIfNotExist(kinoticProjectConfig.application, '');
|
|
49
|
+
project = new Project(null, kinoticProjectConfig.application, kinoticProjectConfig.name, kinoticProjectConfig.description);
|
|
50
|
+
project.organizationId = kinoticProjectConfig.organization;
|
|
51
|
+
project.sourceOfTruth = ProjectType.TYPESCRIPT;
|
|
52
|
+
project = await Kinotic.projects.createProjectIfNotExist(project);
|
|
53
|
+
}
|
|
54
|
+
const codeGenerationService = new EntityCodeGenerationService(kinoticProjectConfig.application, kinoticProjectConfig.fileExtensionForImports, this);
|
|
55
|
+
await codeGenerationService
|
|
56
|
+
.generateAllEntities(kinoticProjectConfig, flags.verbose || flags.dryRun, async (entityInfo, services) => {
|
|
57
|
+
// combine named queries from generated services
|
|
58
|
+
const namedQueries = [];
|
|
59
|
+
for (let serviceInfo of services) {
|
|
60
|
+
namedQueries.push(...serviceInfo.namedQueries);
|
|
61
|
+
}
|
|
62
|
+
// We sync named queries first since currently the backend cache eviction logic is a little dumb
|
|
63
|
+
// i.e. The cache eviction for the EntityDefinition deletes the GraphQL schema
|
|
64
|
+
// This will evict the named query execution plan cache
|
|
65
|
+
// We want to make sure the GraphQL schema is updated after both these are updated and the EntityDefinition below
|
|
66
|
+
if (!flags.dryRun && namedQueries.length > 0) {
|
|
67
|
+
await this.synchronizeNamedQueries(kinoticProjectConfig.organization, project.id, entityInfo.entity, namedQueries);
|
|
51
68
|
}
|
|
52
|
-
const codeGenerationService = new EntityCodeGenerationService(kinoticProjectConfig.application, kinoticProjectConfig.fileExtensionForImports, this);
|
|
53
|
-
await codeGenerationService
|
|
54
|
-
.generateAllEntities(kinoticProjectConfig, flags.verbose || flags.dryRun, async (entityInfo, services) => {
|
|
55
|
-
// combine named queries from generated services
|
|
56
|
-
const namedQueries = [];
|
|
57
|
-
for (let serviceInfo of services) {
|
|
58
|
-
namedQueries.push(...serviceInfo.namedQueries);
|
|
59
|
-
}
|
|
60
|
-
// We sync named queries first since currently the backend cache eviction logic is a little dumb
|
|
61
|
-
// i.e. The cache eviction for the EntityDefinition deletes the GraphQL schema
|
|
62
|
-
// This will evict the named query execution plan cache
|
|
63
|
-
// We want to make sure the GraphQL schema is updated after both these are updated and the EntityDefinition below
|
|
64
|
-
if (!flags.dryRun && namedQueries.length > 0) {
|
|
65
|
-
await this.synchronizeNamedQueries(kinoticProjectConfig.organization, project.id, entityInfo.entity, namedQueries);
|
|
66
|
-
}
|
|
67
|
-
if (!flags.dryRun) {
|
|
68
|
-
await this.synchronizeEntity(kinoticProjectConfig.organization, project.id, entityInfo.entity, flags.publish, flags.verbose);
|
|
69
|
-
}
|
|
70
|
-
}, flags.force);
|
|
71
|
-
// Apply migrations after entity synchronization
|
|
72
69
|
if (!flags.dryRun) {
|
|
73
|
-
|
|
74
|
-
await migrationService.applyMigrations(project.id, './migrations', flags.verbose);
|
|
70
|
+
await this.synchronizeEntity(kinoticProjectConfig.organization, project.id, entityInfo.entity, flags.publish, flags.verbose);
|
|
75
71
|
}
|
|
76
|
-
|
|
72
|
+
}, flags.force);
|
|
73
|
+
// Apply migrations after entity synchronization
|
|
74
|
+
if (!flags.dryRun) {
|
|
75
|
+
const migrationService = new ProjectMigrationService(this);
|
|
76
|
+
await migrationService.applyMigrations(project.id, './migrations', flags.verbose);
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
this.log(`Synchronization Complete For application: ${kinoticProjectConfig.application}`);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
if (e instanceof Error) {
|
|
82
|
+
this.error(e.message);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
await Kinotic.disconnect();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Logger } from './Logger.js';
|
|
2
|
+
/**
|
|
3
|
+
* CLI authentication against a Kinotic server using the OAuth 2.0 Device Authorization Grant
|
|
4
|
+
* (RFC 8628). {@link login} runs the interactive browser flow once and stores the refresh
|
|
5
|
+
* token; {@link connect} uses that stored token to open an authenticated {@link Kinotic}
|
|
6
|
+
* connection, refreshing the short-lived access token before every (re)connect.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CliAuthenticator {
|
|
9
|
+
private readonly server;
|
|
10
|
+
private readonly configDir;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
private refreshToken;
|
|
13
|
+
private accessToken;
|
|
14
|
+
private accessTokenExpiresAt;
|
|
15
|
+
/**
|
|
16
|
+
* @param server the server url to authenticate against
|
|
17
|
+
* @param configDir directory the rotating refresh token is persisted in
|
|
18
|
+
* @param logger sink for user-facing progress messages
|
|
19
|
+
*/
|
|
20
|
+
constructor(server: string, configDir: string, logger: Pick<Logger, 'log'>);
|
|
21
|
+
/**
|
|
22
|
+
* Runs the interactive device-authorization login and persists the refresh token, so
|
|
23
|
+
* later {@link connect} calls — this run or a future one — are non-interactive.
|
|
24
|
+
*
|
|
25
|
+
* @return true if login succeeded
|
|
26
|
+
*/
|
|
27
|
+
login(): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Opens an authenticated {@link Kinotic} connection using the stored refresh token. Fails
|
|
30
|
+
* fast — with no interactive prompt — when there are no stored credentials.
|
|
31
|
+
*
|
|
32
|
+
* @return true if the connection was established
|
|
33
|
+
*/
|
|
34
|
+
connect(): Promise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Returns a valid access token, refreshing it — and persisting the rotated refresh token —
|
|
37
|
+
* when it is absent or within 10s of expiry.
|
|
38
|
+
*/
|
|
39
|
+
private freshAccessToken;
|
|
40
|
+
/** Parses the server url into the host/port the gateway serves both REST and STOMP on. */
|
|
41
|
+
private parseServer;
|
|
42
|
+
/** Runs the RFC 8628 device flow: start, browser approval, then poll for tokens. */
|
|
43
|
+
private deviceLogin;
|
|
44
|
+
private loadRefreshToken;
|
|
45
|
+
private saveRefreshToken;
|
|
46
|
+
}
|