@quonfig/cli 0.0.14 → 0.0.15
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 +40 -35
- package/dist/commands/workspace/switch.d.ts +3 -0
- package/dist/commands/workspace/switch.js +25 -3
- package/dist/commands/workspace.d.ts +1 -0
- package/dist/commands/workspace.js +55 -0
- package/dist/util/get-client.js +1 -1
- package/oclif.manifest.json +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ $ npm install -g @quonfig/cli
|
|
|
14
14
|
$ qfg COMMAND
|
|
15
15
|
running command...
|
|
16
16
|
$ qfg (--version)
|
|
17
|
-
@quonfig/cli/0.0.
|
|
17
|
+
@quonfig/cli/0.0.15 linux-x64 node-v24.4.1
|
|
18
18
|
$ qfg --help [COMMAND]
|
|
19
19
|
USAGE
|
|
20
20
|
$ qfg COMMAND
|
|
@@ -59,7 +59,7 @@ USAGE
|
|
|
59
59
|
* [`qfg whoami`](#qfg-whoami)
|
|
60
60
|
* [`qfg workspace`](#qfg-workspace)
|
|
61
61
|
* [`qfg workspace bootstrap`](#qfg-workspace-bootstrap)
|
|
62
|
-
* [`qfg workspace switch`](#qfg-workspace-switch)
|
|
62
|
+
* [`qfg workspace switch [SLUG]`](#qfg-workspace-switch-slug)
|
|
63
63
|
|
|
64
64
|
## `qfg config-schema`
|
|
65
65
|
|
|
@@ -88,7 +88,7 @@ EXAMPLES
|
|
|
88
88
|
$ qfg config-schema --json-schema # full JSON Schema document (copy into your editor)
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
_See code: [src/commands/config-schema.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
91
|
+
_See code: [src/commands/config-schema.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/config-schema.ts)_
|
|
92
92
|
|
|
93
93
|
## `qfg create NAME`
|
|
94
94
|
|
|
@@ -160,7 +160,7 @@ EXAMPLES
|
|
|
160
160
|
$ qfg set-rollout my.new.flag --environment production --true-percent 20
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
-
_See code: [src/commands/create.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
163
|
+
_See code: [src/commands/create.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/create.ts)_
|
|
164
164
|
|
|
165
165
|
## `qfg flag info [NAME]`
|
|
166
166
|
|
|
@@ -360,7 +360,7 @@ EXAMPLES
|
|
|
360
360
|
$ qfg generate --targets node-ts -o ./dist # combine with targets
|
|
361
361
|
```
|
|
362
362
|
|
|
363
|
-
_See code: [src/commands/generate.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
363
|
+
_See code: [src/commands/generate.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/generate.ts)_
|
|
364
364
|
|
|
365
365
|
## `qfg generate-new-hex-key`
|
|
366
366
|
|
|
@@ -383,7 +383,7 @@ EXAMPLES
|
|
|
383
383
|
$ qfg generate-new-hex-key
|
|
384
384
|
```
|
|
385
385
|
|
|
386
|
-
_See code: [src/commands/generate-new-hex-key.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
386
|
+
_See code: [src/commands/generate-new-hex-key.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/generate-new-hex-key.ts)_
|
|
387
387
|
|
|
388
388
|
## `qfg get [NAME]`
|
|
389
389
|
|
|
@@ -415,7 +415,7 @@ EXAMPLES
|
|
|
415
415
|
$ qfg get my.config.name --environment=production
|
|
416
416
|
```
|
|
417
417
|
|
|
418
|
-
_See code: [src/commands/get.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
418
|
+
_See code: [src/commands/get.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/get.ts)_
|
|
419
419
|
|
|
420
420
|
## `qfg info [NAME]`
|
|
421
421
|
|
|
@@ -463,7 +463,7 @@ EXAMPLES
|
|
|
463
463
|
$ qfg info my.config.name --exclude-evaluations # skip 24h stats
|
|
464
464
|
```
|
|
465
465
|
|
|
466
|
-
_See code: [src/commands/info.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
466
|
+
_See code: [src/commands/info.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/info.ts)_
|
|
467
467
|
|
|
468
468
|
## `qfg init [DIRECTORY]`
|
|
469
469
|
|
|
@@ -501,7 +501,7 @@ EXAMPLES
|
|
|
501
501
|
$ qfg init --dry-run
|
|
502
502
|
```
|
|
503
503
|
|
|
504
|
-
_See code: [src/commands/init.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
504
|
+
_See code: [src/commands/init.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/init.ts)_
|
|
505
505
|
|
|
506
506
|
## `qfg interactive`
|
|
507
507
|
|
|
@@ -531,7 +531,7 @@ EXAMPLES
|
|
|
531
531
|
$ qfg
|
|
532
532
|
```
|
|
533
533
|
|
|
534
|
-
_See code: [src/commands/interactive.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
534
|
+
_See code: [src/commands/interactive.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/interactive.ts)_
|
|
535
535
|
|
|
536
536
|
## `qfg list`
|
|
537
537
|
|
|
@@ -571,7 +571,7 @@ EXAMPLES
|
|
|
571
571
|
$ qfg list --feature-flags
|
|
572
572
|
```
|
|
573
573
|
|
|
574
|
-
_See code: [src/commands/list.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
574
|
+
_See code: [src/commands/list.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/list.ts)_
|
|
575
575
|
|
|
576
576
|
## `qfg login`
|
|
577
577
|
|
|
@@ -596,7 +596,7 @@ EXAMPLES
|
|
|
596
596
|
$ qfg login --profile myprofile
|
|
597
597
|
```
|
|
598
598
|
|
|
599
|
-
_See code: [src/commands/login.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
599
|
+
_See code: [src/commands/login.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/login.ts)_
|
|
600
600
|
|
|
601
601
|
## `qfg logout`
|
|
602
602
|
|
|
@@ -619,7 +619,7 @@ EXAMPLES
|
|
|
619
619
|
$ qfg logout
|
|
620
620
|
```
|
|
621
621
|
|
|
622
|
-
_See code: [src/commands/logout.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
622
|
+
_See code: [src/commands/logout.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/logout.ts)_
|
|
623
623
|
|
|
624
624
|
## `qfg mcp`
|
|
625
625
|
|
|
@@ -652,7 +652,7 @@ EXAMPLES
|
|
|
652
652
|
$ qfg mcp --url http://local-app.quonfig-staging.com:3003/api/v1/mcp
|
|
653
653
|
```
|
|
654
654
|
|
|
655
|
-
_See code: [src/commands/mcp.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
655
|
+
_See code: [src/commands/mcp.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/mcp.ts)_
|
|
656
656
|
|
|
657
657
|
## `qfg migrate`
|
|
658
658
|
|
|
@@ -706,7 +706,7 @@ EXAMPLES
|
|
|
706
706
|
$ qfg migrate --from launch --api-key $LAUNCH_API_KEY --dir ./quonfig-config --staging
|
|
707
707
|
```
|
|
708
708
|
|
|
709
|
-
_See code: [src/commands/migrate.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
709
|
+
_See code: [src/commands/migrate.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/migrate.ts)_
|
|
710
710
|
|
|
711
711
|
## `qfg migrate doctor`
|
|
712
712
|
|
|
@@ -744,7 +744,7 @@ EXAMPLES
|
|
|
744
744
|
$ qfg migrate doctor --json
|
|
745
745
|
```
|
|
746
746
|
|
|
747
|
-
_See code: [src/commands/migrate/doctor.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
747
|
+
_See code: [src/commands/migrate/doctor.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/migrate/doctor.ts)_
|
|
748
748
|
|
|
749
749
|
## `qfg migrate my-code`
|
|
750
750
|
|
|
@@ -776,7 +776,7 @@ EXAMPLES
|
|
|
776
776
|
$ qfg migrate my-code --dry-run
|
|
777
777
|
```
|
|
778
778
|
|
|
779
|
-
_See code: [src/commands/migrate/my-code.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
779
|
+
_See code: [src/commands/migrate/my-code.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/migrate/my-code.ts)_
|
|
780
780
|
|
|
781
781
|
## `qfg migrate status`
|
|
782
782
|
|
|
@@ -807,7 +807,7 @@ EXAMPLES
|
|
|
807
807
|
$ qfg migrate status --json
|
|
808
808
|
```
|
|
809
809
|
|
|
810
|
-
_See code: [src/commands/migrate/status.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
810
|
+
_See code: [src/commands/migrate/status.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/migrate/status.ts)_
|
|
811
811
|
|
|
812
812
|
## `qfg override [NAME]`
|
|
813
813
|
|
|
@@ -851,7 +851,7 @@ EXAMPLES
|
|
|
851
851
|
$ qfg override my.double.config --value=3.14159
|
|
852
852
|
```
|
|
853
853
|
|
|
854
|
-
_See code: [src/commands/override.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
854
|
+
_See code: [src/commands/override.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/override.ts)_
|
|
855
855
|
|
|
856
856
|
## `qfg pull`
|
|
857
857
|
|
|
@@ -895,7 +895,7 @@ EXAMPLES
|
|
|
895
895
|
$ qfg pull # uses QUONFIG_DIR env var
|
|
896
896
|
```
|
|
897
897
|
|
|
898
|
-
_See code: [src/commands/pull.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
898
|
+
_See code: [src/commands/pull.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/pull.ts)_
|
|
899
899
|
|
|
900
900
|
## `qfg schema NAME`
|
|
901
901
|
|
|
@@ -933,7 +933,7 @@ EXAMPLES
|
|
|
933
933
|
$ qfg schema my-schema --set-json-schema=@schemas/my-schema.json --protected
|
|
934
934
|
```
|
|
935
935
|
|
|
936
|
-
_See code: [src/commands/schema.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
936
|
+
_See code: [src/commands/schema.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/schema.ts)_
|
|
937
937
|
|
|
938
938
|
## `qfg sdk-key`
|
|
939
939
|
|
|
@@ -960,7 +960,7 @@ EXAMPLES
|
|
|
960
960
|
$ qfg sdk-key revoke <key-id>
|
|
961
961
|
```
|
|
962
962
|
|
|
963
|
-
_See code: [src/commands/sdk-key.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
963
|
+
_See code: [src/commands/sdk-key.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/sdk-key.ts)_
|
|
964
964
|
|
|
965
965
|
## `qfg sdk-key create`
|
|
966
966
|
|
|
@@ -992,7 +992,7 @@ EXAMPLES
|
|
|
992
992
|
$ qfg sdk-key create --environment staging --type browser
|
|
993
993
|
```
|
|
994
994
|
|
|
995
|
-
_See code: [src/commands/sdk-key/create.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
995
|
+
_See code: [src/commands/sdk-key/create.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/sdk-key/create.ts)_
|
|
996
996
|
|
|
997
997
|
## `qfg sdk-key list`
|
|
998
998
|
|
|
@@ -1021,7 +1021,7 @@ EXAMPLES
|
|
|
1021
1021
|
$ qfg sdk-key list --environment production
|
|
1022
1022
|
```
|
|
1023
1023
|
|
|
1024
|
-
_See code: [src/commands/sdk-key/list.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
1024
|
+
_See code: [src/commands/sdk-key/list.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/sdk-key/list.ts)_
|
|
1025
1025
|
|
|
1026
1026
|
## `qfg sdk-key revoke KEYID`
|
|
1027
1027
|
|
|
@@ -1048,7 +1048,7 @@ EXAMPLES
|
|
|
1048
1048
|
$ qfg sdk-key revoke a1b2c3d4-e5f6-7890-abcd-ef1234567890
|
|
1049
1049
|
```
|
|
1050
1050
|
|
|
1051
|
-
_See code: [src/commands/sdk-key/revoke.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
1051
|
+
_See code: [src/commands/sdk-key/revoke.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/sdk-key/revoke.ts)_
|
|
1052
1052
|
|
|
1053
1053
|
## `qfg set-default [NAME]`
|
|
1054
1054
|
|
|
@@ -1119,7 +1119,7 @@ EXAMPLES
|
|
|
1119
1119
|
$ qfg pull && qfg config-schema
|
|
1120
1120
|
```
|
|
1121
1121
|
|
|
1122
|
-
_See code: [src/commands/set-default.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
1122
|
+
_See code: [src/commands/set-default.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/set-default.ts)_
|
|
1123
1123
|
|
|
1124
1124
|
## `qfg set-rollout [NAME]`
|
|
1125
1125
|
|
|
@@ -1196,7 +1196,7 @@ EXAMPLES
|
|
|
1196
1196
|
$ qfg set-rollout my.variant.flag --environment production --weights "a:33,b:33,c:34" --hash-by user.id
|
|
1197
1197
|
```
|
|
1198
1198
|
|
|
1199
|
-
_See code: [src/commands/set-rollout.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
1199
|
+
_See code: [src/commands/set-rollout.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/set-rollout.ts)_
|
|
1200
1200
|
|
|
1201
1201
|
## `qfg sync`
|
|
1202
1202
|
|
|
@@ -1228,7 +1228,7 @@ EXAMPLES
|
|
|
1228
1228
|
$ qfg sync --watch --dir ./our-config --interval 30
|
|
1229
1229
|
```
|
|
1230
1230
|
|
|
1231
|
-
_See code: [src/commands/sync.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
1231
|
+
_See code: [src/commands/sync.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/sync.ts)_
|
|
1232
1232
|
|
|
1233
1233
|
## `qfg toggle [NAME]`
|
|
1234
1234
|
|
|
@@ -1330,7 +1330,7 @@ EXAMPLES
|
|
|
1330
1330
|
$ qfg verify --json
|
|
1331
1331
|
```
|
|
1332
1332
|
|
|
1333
|
-
_See code: [src/commands/verify.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
1333
|
+
_See code: [src/commands/verify.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/verify.ts)_
|
|
1334
1334
|
|
|
1335
1335
|
## `qfg whoami`
|
|
1336
1336
|
|
|
@@ -1353,7 +1353,7 @@ EXAMPLES
|
|
|
1353
1353
|
$ qfg whoami
|
|
1354
1354
|
```
|
|
1355
1355
|
|
|
1356
|
-
_See code: [src/commands/whoami.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
1356
|
+
_See code: [src/commands/whoami.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/whoami.ts)_
|
|
1357
1357
|
|
|
1358
1358
|
## `qfg workspace`
|
|
1359
1359
|
|
|
@@ -1376,7 +1376,7 @@ EXAMPLES
|
|
|
1376
1376
|
$ qfg workspace
|
|
1377
1377
|
```
|
|
1378
1378
|
|
|
1379
|
-
_See code: [src/commands/workspace.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
1379
|
+
_See code: [src/commands/workspace.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/workspace.ts)_
|
|
1380
1380
|
|
|
1381
1381
|
## `qfg workspace bootstrap`
|
|
1382
1382
|
|
|
@@ -1409,15 +1409,18 @@ EXAMPLES
|
|
|
1409
1409
|
$ qfg workspace bootstrap --dir ./our-config --skip-validate
|
|
1410
1410
|
```
|
|
1411
1411
|
|
|
1412
|
-
_See code: [src/commands/workspace/bootstrap.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
1412
|
+
_See code: [src/commands/workspace/bootstrap.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/workspace/bootstrap.ts)_
|
|
1413
1413
|
|
|
1414
|
-
## `qfg workspace switch`
|
|
1414
|
+
## `qfg workspace switch [SLUG]`
|
|
1415
1415
|
|
|
1416
1416
|
Switch to a different workspace
|
|
1417
1417
|
|
|
1418
1418
|
```
|
|
1419
1419
|
USAGE
|
|
1420
|
-
$ qfg workspace switch [--json] [--interactive] [--no-color] [--verbose]
|
|
1420
|
+
$ qfg workspace switch [SLUG] [--json] [--interactive] [--no-color] [--verbose]
|
|
1421
|
+
|
|
1422
|
+
ARGUMENTS
|
|
1423
|
+
SLUG Workspace slug (or UUID) to switch to. Omit for an interactive picker.
|
|
1421
1424
|
|
|
1422
1425
|
GLOBAL FLAGS
|
|
1423
1426
|
--[no-]interactive Force interactive mode
|
|
@@ -1430,9 +1433,11 @@ DESCRIPTION
|
|
|
1430
1433
|
|
|
1431
1434
|
EXAMPLES
|
|
1432
1435
|
$ qfg workspace switch
|
|
1436
|
+
|
|
1437
|
+
$ qfg workspace switch my-workspace-slug
|
|
1433
1438
|
```
|
|
1434
1439
|
|
|
1435
|
-
_See code: [src/commands/workspace/switch.ts](https://github.com/quonfig/cli/blob/v0.0.
|
|
1440
|
+
_See code: [src/commands/workspace/switch.ts](https://github.com/quonfig/cli/blob/v0.0.15/src/commands/workspace/switch.ts)_
|
|
1436
1441
|
<!-- commandsstop -->
|
|
1437
1442
|
|
|
1438
1443
|
## Local Development
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { JsonObj } from '../../result.js';
|
|
2
2
|
import { BaseCommand } from '../../index.js';
|
|
3
3
|
export default class WorkspaceSwitch extends BaseCommand {
|
|
4
|
+
static args: {
|
|
5
|
+
slug: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
6
|
+
};
|
|
4
7
|
static description: string;
|
|
5
8
|
static examples: string[];
|
|
6
9
|
run(): Promise<JsonObj | void>;
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
1
2
|
import { select } from '@inquirer/prompts';
|
|
2
3
|
import { BaseCommand } from '../../index.js';
|
|
3
4
|
import { getApiUrl } from '../../util/domain-urls.js';
|
|
4
5
|
import { getValidAccessToken } from '../../util/get-valid-token.js';
|
|
5
6
|
import { loadAuthConfig, saveAuthConfig } from '../../util/token-storage.js';
|
|
7
|
+
const UUID_PATTERN = /^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/i;
|
|
6
8
|
export default class WorkspaceSwitch extends BaseCommand {
|
|
9
|
+
static args = {
|
|
10
|
+
slug: Args.string({
|
|
11
|
+
description: 'Workspace slug (or UUID) to switch to. Omit for an interactive picker.',
|
|
12
|
+
required: false,
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
7
15
|
static description = 'Switch to a different workspace';
|
|
8
|
-
static examples = [
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> <%= command.id %>',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> my-workspace-slug',
|
|
19
|
+
];
|
|
9
20
|
async run() {
|
|
21
|
+
const { args } = await this.parse(WorkspaceSwitch);
|
|
10
22
|
// Get a valid token — refresh silently if needed, error if not logged in
|
|
11
23
|
let accessToken;
|
|
12
24
|
try {
|
|
@@ -44,9 +56,19 @@ export default class WorkspaceSwitch extends BaseCommand {
|
|
|
44
56
|
if (candidates.length === 0) {
|
|
45
57
|
return this.err('No workspaces found for your account.');
|
|
46
58
|
}
|
|
47
|
-
// Pick workspace
|
|
59
|
+
// Pick workspace: positional arg → interactive picker → auto-select if only one
|
|
48
60
|
let match;
|
|
49
|
-
if (
|
|
61
|
+
if (args.slug) {
|
|
62
|
+
const found = UUID_PATTERN.test(args.slug)
|
|
63
|
+
? candidates.find((w) => w.workspaceId === args.slug)
|
|
64
|
+
: candidates.find((w) => w.workspaceSlug === args.slug);
|
|
65
|
+
if (!found) {
|
|
66
|
+
const available = candidates.map((w) => w.workspaceSlug).join(', ') || '(none)';
|
|
67
|
+
return this.err(`Workspace "${args.slug}" not found. Available: ${available}.`);
|
|
68
|
+
}
|
|
69
|
+
match = found;
|
|
70
|
+
}
|
|
71
|
+
else if (candidates.length === 1) {
|
|
50
72
|
match = candidates[0];
|
|
51
73
|
this.log(`Only one workspace available: ${match.organizationName} / ${match.workspaceSlug}`);
|
|
52
74
|
}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { BaseCommand } from '../index.js';
|
|
2
|
+
import { getApiUrl } from '../util/domain-urls.js';
|
|
3
|
+
import { getValidAccessToken } from '../util/get-valid-token.js';
|
|
2
4
|
import { getActiveProfile, loadAuthConfig } from '../util/token-storage.js';
|
|
5
|
+
const UUID_PATTERN = /^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/i;
|
|
3
6
|
export default class Workspace extends BaseCommand {
|
|
4
7
|
static description = 'Show the current workspace';
|
|
5
8
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
6
9
|
async run() {
|
|
10
|
+
// API-key mode: resolve the workspace from QUONFIG_WORKSPACE via the server
|
|
11
|
+
// so we show the workspace the key is actually scoped to, not whatever
|
|
12
|
+
// the local OAuth config happens to point at.
|
|
13
|
+
if (process.env.QUONFIG_API_KEY) {
|
|
14
|
+
return this.runApiKeyMode();
|
|
15
|
+
}
|
|
7
16
|
const authConfig = await loadAuthConfig();
|
|
8
17
|
if (!authConfig || Object.keys(authConfig.profiles).length === 0) {
|
|
9
18
|
return this.err('Not logged in. Run `qfg login` first.');
|
|
@@ -26,4 +35,50 @@ export default class Workspace extends BaseCommand {
|
|
|
26
35
|
workspaceSlug,
|
|
27
36
|
};
|
|
28
37
|
}
|
|
38
|
+
async runApiKeyMode() {
|
|
39
|
+
const override = process.env.QUONFIG_WORKSPACE;
|
|
40
|
+
if (!override) {
|
|
41
|
+
return this.err('QUONFIG_API_KEY is set but QUONFIG_WORKSPACE is not. Set QUONFIG_WORKSPACE=<workspace-slug> (UUIDs also work).');
|
|
42
|
+
}
|
|
43
|
+
// getValidAccessToken short-circuits when QUONFIG_API_KEY is set.
|
|
44
|
+
let jwt;
|
|
45
|
+
try {
|
|
46
|
+
jwt = await getValidAccessToken();
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return this.err(error instanceof Error ? error.message : String(error));
|
|
50
|
+
}
|
|
51
|
+
let entries = [];
|
|
52
|
+
try {
|
|
53
|
+
const res = await fetch(`${getApiUrl()}/api/v1/userWorkspaces/list`, {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: { Authorization: `Bearer ${jwt}`, 'Content-Type': 'application/json' },
|
|
56
|
+
body: JSON.stringify({ json: {} }),
|
|
57
|
+
});
|
|
58
|
+
if (!res.ok) {
|
|
59
|
+
return this.err(`Failed to resolve workspace (HTTP ${res.status}). Check that QUONFIG_API_KEY is valid.`);
|
|
60
|
+
}
|
|
61
|
+
const body = (await res.json());
|
|
62
|
+
entries = body.json ?? body ?? [];
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return this.err(`Failed to resolve workspace "${override}": ${error instanceof Error ? error.message : String(error)}`);
|
|
66
|
+
}
|
|
67
|
+
const match = UUID_PATTERN.test(override)
|
|
68
|
+
? entries.find((w) => w.workspaceId === override)
|
|
69
|
+
: entries.find((w) => w.workspaceSlug === override);
|
|
70
|
+
if (!match) {
|
|
71
|
+
const available = entries.map((w) => w.workspaceSlug).join(', ') || '(none)';
|
|
72
|
+
return this.err(`Workspace "${override}" not accessible with this API key. Available: ${available}.`);
|
|
73
|
+
}
|
|
74
|
+
const orgLine = match.organizationName ? `${match.organizationName} / ` : '';
|
|
75
|
+
this.log(`Workspace: ${orgLine}${match.workspaceSlug} (API key mode)`);
|
|
76
|
+
this.log(`ID: ${match.workspaceId}`);
|
|
77
|
+
this.log(`Source: QUONFIG_API_KEY + QUONFIG_WORKSPACE=${override}`);
|
|
78
|
+
return {
|
|
79
|
+
organizationName: match.organizationName,
|
|
80
|
+
workspace: match.workspaceId,
|
|
81
|
+
workspaceSlug: match.workspaceSlug,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
29
84
|
}
|
package/dist/util/get-client.js
CHANGED
|
@@ -36,7 +36,7 @@ const getClient = async (command, sdkKey, profile) => {
|
|
|
36
36
|
}
|
|
37
37
|
const workspaceOverride = profile ?? process.env.QUONFIG_WORKSPACE;
|
|
38
38
|
if (!workspaceOverride) {
|
|
39
|
-
command.error('QUONFIG_API_KEY is set but
|
|
39
|
+
command.error('QUONFIG_API_KEY is set but QUONFIG_WORKSPACE is not. Set QUONFIG_WORKSPACE=<workspace-slug> (UUIDs also work).', { exit: 1 });
|
|
40
40
|
}
|
|
41
41
|
const uuidPattern = /^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/i;
|
|
42
42
|
if (uuidPattern.test(workspaceOverride)) {
|
package/oclif.manifest.json
CHANGED
|
@@ -2526,10 +2526,17 @@
|
|
|
2526
2526
|
},
|
|
2527
2527
|
"workspace:switch": {
|
|
2528
2528
|
"aliases": [],
|
|
2529
|
-
"args": {
|
|
2529
|
+
"args": {
|
|
2530
|
+
"slug": {
|
|
2531
|
+
"description": "Workspace slug (or UUID) to switch to. Omit for an interactive picker.",
|
|
2532
|
+
"name": "slug",
|
|
2533
|
+
"required": false
|
|
2534
|
+
}
|
|
2535
|
+
},
|
|
2530
2536
|
"description": "Switch to a different workspace",
|
|
2531
2537
|
"examples": [
|
|
2532
|
-
"<%= config.bin %> <%= command.id %>"
|
|
2538
|
+
"<%= config.bin %> <%= command.id %>",
|
|
2539
|
+
"<%= config.bin %> <%= command.id %> my-workspace-slug"
|
|
2533
2540
|
],
|
|
2534
2541
|
"flags": {
|
|
2535
2542
|
"json": {
|
|
@@ -2579,5 +2586,5 @@
|
|
|
2579
2586
|
]
|
|
2580
2587
|
}
|
|
2581
2588
|
},
|
|
2582
|
-
"version": "0.0.
|
|
2589
|
+
"version": "0.0.15"
|
|
2583
2590
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageManager": "yarn@4.11.0+sha512.4e54aeace9141df2f0177c266b05ec50dc044638157dae128c471ba65994ac802122d7ab35bcd9e81641228b7dcf24867d28e750e0bcae8a05277d600008ad54",
|
|
3
3
|
"name": "@quonfig/cli",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/quonfig/cli/issues"
|
|
7
7
|
},
|