@codiac.io/codiac-cli 1.3.180 → 1.3.182
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 -1
- package/dist/apis/codiac-api/gen/client.d.ts +5 -1
- package/dist/apis/codiac-api/gen/client.js +12 -0
- package/dist/apis/codiac-api/gen/client.js.map +1 -1
- package/dist/apis/codiac-api/gen/contracts/types.gen.d.ts +25 -0
- package/dist/apis/codiac-api/gen/contracts/types.gen.js.map +1 -1
- package/dist/apis/codiac-api/i-client.d.ts +4 -0
- package/dist/apis/codiac-api-nats/gen/client.d.ts +4 -0
- package/dist/apis/codiac-api-nats/gen/client.js +17 -1
- package/dist/apis/codiac-api-nats/gen/client.js.map +1 -1
- package/dist/apis/codiac-api-nats/gen/contracts/types.gen.d.ts +25 -0
- package/dist/apis/codiac-api-nats/gen/contracts/types.gen.js.map +1 -1
- package/dist/apis/codiac-relay/gen/client.d.ts +16 -3
- package/dist/apis/codiac-relay/gen/client.js +58 -1
- package/dist/apis/codiac-relay/gen/client.js.map +1 -1
- package/dist/apis/codiac-relay/gen/contracts/types.gen.d.ts +173 -7
- package/dist/apis/codiac-relay/gen/contracts/types.gen.js.map +1 -1
- package/dist/apis/codiac-relay/i-client.d.ts +8 -0
- package/dist/apis/codiac-relay-nats/gen/client.d.ts +15 -7
- package/dist/apis/codiac-relay-nats/gen/client.js +86 -19
- package/dist/apis/codiac-relay-nats/gen/client.js.map +1 -1
- package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.d.ts +151 -15
- package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.js +4 -4
- package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.js.map +1 -1
- package/dist/apis/codiac-relay-nats/gen/contracts.ng.d.ts +6 -0
- package/dist/apis/codiac-relay-nats/gen/contracts.ng.js +1 -0
- package/dist/apis/codiac-relay-nats/gen/contracts.ng.js.map +1 -1
- package/dist/bootstrapper-for-api-clients.js +14 -2
- package/dist/bootstrapper-for-api-clients.js.map +1 -1
- package/dist/cli-common/built-in-cli-user-input.d.ts +2 -1
- package/dist/cli-common/built-in-cli-user-input.js +52 -1
- package/dist/cli-common/built-in-cli-user-input.js.map +1 -1
- package/dist/cli-common/entities/prompt-choice.d.ts +2 -7
- package/dist/cli-common/mock-ui.d.ts +2 -1
- package/dist/cli-common/mock-ui.js +3 -0
- package/dist/cli-common/mock-ui.js.map +1 -1
- package/dist/codiac-constants.d.ts +3 -0
- package/dist/codiac-constants.js +3 -0
- package/dist/codiac-constants.js.map +1 -1
- package/dist/command-base-enterprise.d.ts +23 -2
- package/dist/command-base-enterprise.js +82 -26
- package/dist/command-base-enterprise.js.map +1 -1
- package/dist/command-base-exec.js +4 -2
- package/dist/command-base-exec.js.map +1 -1
- package/dist/commands/asset/deploy.d.ts +2 -1
- package/dist/commands/asset/deploy.js +3 -2
- package/dist/commands/asset/deploy.js.map +1 -1
- package/dist/commands/asset/list.d.ts +26 -7
- package/dist/commands/asset/list.js +127 -112
- package/dist/commands/asset/list.js.map +1 -1
- package/dist/commands/asset/probe/create.d.ts +26 -5
- package/dist/commands/asset/probe/create.js +182 -164
- package/dist/commands/asset/probe/create.js.map +1 -1
- package/dist/commands/asset/recycle.js +3 -4
- package/dist/commands/asset/recycle.js.map +1 -1
- package/dist/commands/asset/undeploy.d.ts +24 -9
- package/dist/commands/asset/undeploy.js +162 -161
- package/dist/commands/asset/undeploy.js.map +1 -1
- package/dist/commands/asset/view.js +1 -1
- package/dist/commands/asset/view.js.map +1 -1
- package/dist/commands/asset/volume/create.d.ts +25 -13
- package/dist/commands/asset/volume/create.js +177 -156
- package/dist/commands/asset/volume/create.js.map +1 -1
- package/dist/commands/asset/volume/delete.d.ts +23 -7
- package/dist/commands/asset/volume/delete.js +131 -98
- package/dist/commands/asset/volume/delete.js.map +1 -1
- package/dist/commands/asset/volume/list.d.ts +24 -8
- package/dist/commands/asset/volume/list.js +101 -54
- package/dist/commands/asset/volume/list.js.map +1 -1
- package/dist/commands/cabinet/cluster/attach.d.ts +32 -0
- package/dist/commands/cabinet/cluster/attach.js +144 -0
- package/dist/commands/cabinet/cluster/attach.js.map +1 -0
- package/dist/commands/cabinet/create.d.ts +1 -0
- package/dist/commands/cabinet/create.js +5 -1
- package/dist/commands/cabinet/create.js.map +1 -1
- package/dist/commands/cabinet/list.d.ts +27 -6
- package/dist/commands/cabinet/list.js +130 -121
- package/dist/commands/cabinet/list.js.map +1 -1
- package/dist/commands/cabinet/obliterate.d.ts +1 -0
- package/dist/commands/cabinet/obliterate.js +5 -1
- package/dist/commands/cabinet/obliterate.js.map +1 -1
- package/dist/commands/cabinet/restore.d.ts +36 -0
- package/dist/commands/cabinet/restore.js +186 -0
- package/dist/commands/cabinet/restore.js.map +1 -0
- package/dist/commands/cluster/agent/configure.d.ts +47 -0
- package/dist/commands/cluster/agent/configure.js +320 -0
- package/dist/commands/cluster/agent/configure.js.map +1 -0
- package/dist/commands/cluster/agent/install.d.ts +32 -0
- package/dist/commands/cluster/agent/install.js +152 -0
- package/dist/commands/cluster/agent/install.js.map +1 -0
- package/dist/commands/cluster/agent/uninstall.d.ts +29 -0
- package/dist/commands/cluster/agent/uninstall.js +130 -0
- package/dist/commands/cluster/agent/uninstall.js.map +1 -0
- package/dist/commands/cluster/bootstrap.d.ts +50 -0
- package/dist/commands/cluster/bootstrap.js +310 -0
- package/dist/commands/cluster/bootstrap.js.map +1 -0
- package/dist/commands/cluster/connect.d.ts +0 -5
- package/dist/commands/cluster/connect.js +1 -26
- package/dist/commands/cluster/connect.js.map +1 -1
- package/dist/commands/cluster/install.d.ts +45 -0
- package/dist/commands/cluster/install.js +224 -0
- package/dist/commands/cluster/install.js.map +1 -0
- package/dist/commands/cluster/stack/capture.js +0 -2
- package/dist/commands/cluster/stack/capture.js.map +1 -1
- package/dist/commands/cluster/stack/install.d.ts +40 -0
- package/dist/commands/cluster/stack/install.js +196 -0
- package/dist/commands/cluster/stack/install.js.map +1 -0
- package/dist/commands/cluster/start.d.ts +0 -5
- package/dist/commands/cluster/start.js +1 -27
- package/dist/commands/cluster/start.js.map +1 -1
- package/dist/commands/cluster/stop.d.ts +0 -5
- package/dist/commands/cluster/stop.js +1 -27
- package/dist/commands/cluster/stop.js.map +1 -1
- package/dist/commands/config/add.d.ts +9 -11
- package/dist/commands/config/add.js +59 -125
- package/dist/commands/config/add.js.map +1 -1
- package/dist/commands/config/delete.d.ts +22 -11
- package/dist/commands/config/delete.js +28 -83
- package/dist/commands/config/delete.js.map +1 -1
- package/dist/commands/config/deploy.d.ts +26 -8
- package/dist/commands/config/deploy.js +169 -198
- package/dist/commands/config/deploy.js.map +1 -1
- package/dist/commands/config/import.d.ts +27 -22
- package/dist/commands/config/import.js +222 -253
- package/dist/commands/config/import.js.map +1 -1
- package/dist/commands/config/settings/get.d.ts +25 -14
- package/dist/commands/config/settings/get.js +30 -123
- package/dist/commands/config/settings/get.js.map +1 -1
- package/dist/commands/config/view.d.ts +26 -6
- package/dist/commands/config/view.js +112 -95
- package/dist/commands/config/view.js.map +1 -1
- package/dist/commands/csp/logout.d.ts +23 -6
- package/dist/commands/csp/logout.js +86 -63
- package/dist/commands/csp/logout.js.map +1 -1
- package/dist/commands/deploy.d.ts +31 -14
- package/dist/commands/deploy.js +264 -385
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/enterprise/list.d.ts +22 -4
- package/dist/commands/enterprise/list.js +97 -67
- package/dist/commands/enterprise/list.js.map +1 -1
- package/dist/commands/env/add.d.ts +26 -7
- package/dist/commands/env/add.js +182 -179
- package/dist/commands/env/add.js.map +1 -1
- package/dist/commands/environment/cluster/attach.d.ts +1 -0
- package/dist/commands/environment/cluster/attach.js +5 -1
- package/dist/commands/environment/cluster/attach.js.map +1 -1
- package/dist/commands/environment/cluster/detach.d.ts +1 -0
- package/dist/commands/environment/cluster/detach.js +5 -1
- package/dist/commands/environment/cluster/detach.js.map +1 -1
- package/dist/commands/environment/create.d.ts +1 -0
- package/dist/commands/environment/create.js +5 -1
- package/dist/commands/environment/create.js.map +1 -1
- package/dist/commands/environment/delete.d.ts +39 -0
- package/dist/commands/environment/delete.js +135 -0
- package/dist/commands/environment/delete.js.map +1 -0
- package/dist/commands/environment/list.d.ts +28 -9
- package/dist/commands/environment/list.js +128 -167
- package/dist/commands/environment/list.js.map +1 -1
- package/dist/commands/host/map.d.ts +29 -19
- package/dist/commands/host/map.js +263 -324
- package/dist/commands/host/map.js.map +1 -1
- package/dist/commands/imageRegistry/capture.d.ts +12 -11
- package/dist/commands/imageRegistry/capture.js +49 -113
- package/dist/commands/imageRegistry/capture.js.map +1 -1
- package/dist/commands/imageRegistry/forget.d.ts +12 -11
- package/dist/commands/imageRegistry/forget.js +53 -114
- package/dist/commands/imageRegistry/forget.js.map +1 -1
- package/dist/commands/imageRegistry/pullSecret/set.d.ts +21 -11
- package/dist/commands/imageRegistry/pullSecret/set.js +184 -278
- package/dist/commands/imageRegistry/pullSecret/set.js.map +1 -1
- package/dist/commands/imageRegistry/pullSecret/unset.d.ts +19 -11
- package/dist/commands/imageRegistry/pullSecret/unset.js +117 -190
- package/dist/commands/imageRegistry/pullSecret/unset.js.map +1 -1
- package/dist/commands/images/add.d.ts +19 -6
- package/dist/commands/images/add.js +63 -53
- package/dist/commands/images/add.js.map +1 -1
- package/dist/commands/kit/create.d.ts +22 -10
- package/dist/commands/kit/create.js +119 -121
- package/dist/commands/kit/create.js.map +1 -1
- package/dist/commands/logout.d.ts +21 -5
- package/dist/commands/logout.js +44 -25
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/noc/cluster/create.js +22 -10
- package/dist/commands/noc/cluster/create.js.map +1 -1
- package/dist/commands/noc/cluster/credentials-set.d.ts +38 -0
- package/dist/commands/noc/cluster/credentials-set.js +174 -0
- package/dist/commands/noc/cluster/credentials-set.js.map +1 -0
- package/dist/commands/noc/cluster/define.d.ts +46 -0
- package/dist/commands/noc/cluster/define.js +305 -0
- package/dist/commands/noc/cluster/define.js.map +1 -0
- package/dist/commands/noc/cluster/deinit.d.ts +22 -5
- package/dist/commands/noc/cluster/deinit.js +99 -106
- package/dist/commands/noc/cluster/deinit.js.map +1 -1
- package/dist/commands/noc/cluster/forget.js +2 -4
- package/dist/commands/noc/cluster/forget.js.map +1 -1
- package/dist/commands/noc/cluster/grant.d.ts +20 -11
- package/dist/commands/noc/cluster/grant.js +94 -132
- package/dist/commands/noc/cluster/grant.js.map +1 -1
- package/dist/commands/noc/cluster/init.d.ts +25 -7
- package/dist/commands/noc/cluster/init.js +121 -133
- package/dist/commands/noc/cluster/init.js.map +1 -1
- package/dist/commands/noc/cluster/journal.d.ts +0 -5
- package/dist/commands/noc/cluster/journal.js +1 -26
- package/dist/commands/noc/cluster/journal.js.map +1 -1
- package/dist/commands/noc/cluster/list.d.ts +23 -5
- package/dist/commands/noc/cluster/list.js +107 -111
- package/dist/commands/noc/cluster/list.js.map +1 -1
- package/dist/commands/noc/cluster/restore.d.ts +36 -0
- package/dist/commands/noc/cluster/restore.js +196 -0
- package/dist/commands/noc/cluster/restore.js.map +1 -0
- package/dist/commands/portal.d.ts +21 -5
- package/dist/commands/portal.js +37 -36
- package/dist/commands/portal.js.map +1 -1
- package/dist/commands/secretStore/capture.d.ts +13 -11
- package/dist/commands/secretStore/capture.js +63 -123
- package/dist/commands/secretStore/capture.js.map +1 -1
- package/dist/commands/secretStore/forget.d.ts +13 -11
- package/dist/commands/secretStore/forget.js +55 -111
- package/dist/commands/secretStore/forget.js.map +1 -1
- package/dist/commands/shell/init.d.ts +15 -0
- package/dist/commands/shell/init.js +96 -0
- package/dist/commands/shell/init.js.map +1 -0
- package/dist/commands/snapshot/deploy.d.ts +22 -42
- package/dist/commands/snapshot/deploy.js +173 -269
- package/dist/commands/snapshot/deploy.js.map +1 -1
- package/dist/commands/snapshot/list.d.ts +26 -5
- package/dist/commands/snapshot/list.js +116 -109
- package/dist/commands/snapshot/list.js.map +1 -1
- package/dist/commands/tenant/create.d.ts +18 -13
- package/dist/commands/tenant/create.js +69 -69
- package/dist/commands/tenant/create.js.map +1 -1
- package/dist/commands/tenant/switch.d.ts +18 -12
- package/dist/commands/tenant/switch.js +65 -59
- package/dist/commands/tenant/switch.js.map +1 -1
- package/dist/commands/whereami.d.ts +18 -8
- package/dist/commands/whereami.js +67 -102
- package/dist/commands/whereami.js.map +1 -1
- package/dist/commands/whoami.d.ts +19 -3
- package/dist/commands/whoami.js +44 -13
- package/dist/commands/whoami.js.map +1 -1
- package/dist/ops/i-user-input-provider.d.ts +20 -1
- package/dist/ops/i-user-input-provider.js.map +1 -1
- package/dist/ops/test/mock-ui.d.ts +2 -1
- package/dist/ops/test/mock-ui.js +3 -0
- package/dist/ops/test/mock-ui.js.map +1 -1
- package/dist/ops/throwing-user-input-provider.d.ts +2 -1
- package/dist/ops/throwing-user-input-provider.js +3 -0
- package/dist/ops/throwing-user-input-provider.js.map +1 -1
- package/dist/relay/relay-container.js +1 -1
- package/dist/uilogic/lrp-watcher-predef.d.ts +2 -1
- package/dist/uilogic/lrp-watcher-predef.js +31 -17
- package/dist/uilogic/lrp-watcher-predef.js.map +1 -1
- package/dist/uilogic/lrp-watcher-utils.d.ts +2 -0
- package/dist/uilogic/lrp-watcher-utils.js +2 -0
- package/dist/uilogic/lrp-watcher-utils.js.map +1 -1
- package/dist/uilogic/rootmap-ui-utils.d.ts +18 -1
- package/dist/uilogic/rootmap-ui-utils.js +30 -0
- package/dist/uilogic/rootmap-ui-utils.js.map +1 -1
- package/dist/uilogic/tenant-contextualizer.js +11 -1
- package/dist/uilogic/tenant-contextualizer.js.map +1 -1
- package/dist/user-context-loader.d.ts +12 -7
- package/dist/user-context-loader.js +89 -43
- package/dist/user-context-loader.js.map +1 -1
- package/oclif.manifest.json +3991 -1444
- package/package.json +2 -2
- package/dist/commands/noc/cluster/recreate.d.ts +0 -28
- package/dist/commands/noc/cluster/recreate.js +0 -197
- package/dist/commands/noc/cluster/recreate.js.map +0 -1
|
@@ -3,76 +3,82 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
require("reflect-metadata");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
|
-
const
|
|
7
|
-
const command_base_enterprise_1 = require("../../command-base-enterprise");
|
|
6
|
+
const command_base_exec_tenant_1 = require("../../command-base-exec-tenant");
|
|
8
7
|
const uilogic_1 = require("../../uilogic");
|
|
9
8
|
const ops_1 = require("../../ops");
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const config_ui_utils_1 = require("../../uilogic/config-ui-utils");
|
|
10
|
+
class TenantSwitch extends command_base_exec_tenant_1.CommandBaseExecTenant {
|
|
11
|
+
captureArgs() {
|
|
12
|
+
var _a, _b;
|
|
12
13
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (this._projCfg && this._projCfg.tenantCode !== undefined && this._projCfg.tenantCode !== ops_1.DxConstants.UNREGISTERED_TENANT_CODE) {
|
|
17
|
-
// this._ui.userMessage(`Cannot switch tenant from within a project folder.`)
|
|
18
|
-
throw new Error(`Current tenant [${this._styler.hilite(this._projCfg.tenantCode)}]; cannot switch tenant from this folder; it exists within a workspace declared for that tenant (see the nearest codiac.json file).`);
|
|
19
|
-
}
|
|
20
|
-
// this._userCntx = await this.promptForNewTenant(this._userCntx, contextor);
|
|
21
|
-
let contextor = new uilogic_1.TenantContextualizer(this.cliEnviro, this._projCfg, this.authClient, this.projCfgRepo, this._ui, this._styler, this.logger);
|
|
22
|
-
this._userCntx = yield this.establishTenantContext(this._userCntx, contextor);
|
|
23
|
-
let newCntx;
|
|
24
|
-
if (args.code) {
|
|
25
|
-
newCntx = yield contextor.trySwitchTenant(this._userCntx, args.code);
|
|
26
|
-
}
|
|
27
|
-
newCntx = newCntx !== null && newCntx !== void 0 ? newCntx : yield contextor.trySelectFromMyTenants(this._userCntx, false);
|
|
28
|
-
if (newCntx !== undefined) {
|
|
29
|
-
this._userCntx = newCntx;
|
|
30
|
-
this.bindUserInIoc(this._userCntx);
|
|
31
|
-
if (this._userCntx.currentTenantCode) {
|
|
32
|
-
this._ui.userMessage(`Switched to tenant [${this._styler.hilite(this._userCntx.currentTenantCode)}]`);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this._ui.userMessage(`Current user context is tenant-less.`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
14
|
+
const { flags } = yield this.parse(TenantSwitch);
|
|
15
|
+
if (this._projCfg && this._projCfg.tenantCode !== undefined && this._projCfg.tenantCode !== ops_1.DxConstants.UNREGISTERED_TENANT_CODE) {
|
|
16
|
+
throw new Error(`Current tenant [${this._styler.hilite(this._projCfg.tenantCode)}]; cannot switch tenant from this folder; it exists within a workspace declared for that tenant (see the nearest codiac.json file).`);
|
|
38
17
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
18
|
+
const interactionMode = (this.pipedInput) ? config_ui_utils_1.InteractionModes.silent : (_b = (_a = undefined !== null && undefined !== void 0 ? undefined : (flags.echo ? config_ui_utils_1.InteractionModes.echo : undefined)) !== null && _a !== void 0 ? _a : (flags["to-script"] ? config_ui_utils_1.InteractionModes.toscript : undefined)) !== null && _b !== void 0 ? _b : (flags.silent ? config_ui_utils_1.InteractionModes.silent : undefined);
|
|
19
|
+
return [{}, interactionMode, false];
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
buildCandidate_silently(_partial, _rootMap) {
|
|
23
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const { args } = yield this.parse(TenantSwitch);
|
|
25
|
+
if (!args.code)
|
|
26
|
+
throw new Error(`Tenant code argument is required in silent mode.`);
|
|
27
|
+
const contextor = new uilogic_1.TenantContextualizer(this.cliEnviro, this._projCfg, this.authClient, this.projCfgRepo, this._ui, this._styler, this.logger);
|
|
28
|
+
const newContext = yield contextor.trySwitchTenant(this._userCntx, args.code);
|
|
29
|
+
if (!newContext)
|
|
30
|
+
throw new Error(`Failed to switch to tenant [${args.code}].`);
|
|
31
|
+
return { newContext };
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
buildCandidate_interactively(_partial, _takeDefaults, _rootMap) {
|
|
35
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const { args } = yield this.parse(TenantSwitch);
|
|
37
|
+
const contextor = new uilogic_1.TenantContextualizer(this.cliEnviro, this._projCfg, this.authClient, this.projCfgRepo, this._ui, this._styler, this.logger);
|
|
38
|
+
let newContext;
|
|
39
|
+
if (args.code) {
|
|
40
|
+
newContext = yield contextor.trySwitchTenant(this._userCntx, args.code);
|
|
45
41
|
}
|
|
42
|
+
newContext = newContext !== null && newContext !== void 0 ? newContext : yield contextor.trySelectFromMyTenants(this._userCntx, false);
|
|
43
|
+
if (!newContext)
|
|
44
|
+
return undefined;
|
|
45
|
+
return { newContext };
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
buildCommandString(candidate, cmd) {
|
|
49
|
+
if (candidate.newContext.currentTenantCode)
|
|
50
|
+
cmd.push(candidate.newContext.currentTenantCode);
|
|
51
|
+
cmd.push("--silent");
|
|
52
|
+
return cmd;
|
|
53
|
+
}
|
|
54
|
+
executeTask(candidate) {
|
|
50
55
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (cntx.currentToken)
|
|
60
|
-
this._codiacApi.setUserToken(cntx.currentToken); // why isnt this being done by the contextualizer?
|
|
61
|
-
this.bindUserInIoc(cntx);
|
|
62
|
-
}
|
|
63
|
-
resolve(cntx);
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
reject(err);
|
|
67
|
-
}
|
|
68
|
-
}));
|
|
56
|
+
this._userCntx = candidate.newContext;
|
|
57
|
+
this.bindUserInIoc(this._userCntx);
|
|
58
|
+
if (this._userCntx.currentTenantCode) {
|
|
59
|
+
this._ui.userMessage(`Switched to tenant [${this._styler.hilite(this._userCntx.currentTenantCode)}]`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this._ui.userMessage(`Current user context is tenant-less.`);
|
|
63
|
+
}
|
|
69
64
|
});
|
|
70
65
|
}
|
|
71
66
|
}
|
|
72
|
-
exports.default =
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
exports.default = TenantSwitch;
|
|
68
|
+
TenantSwitch.description = "Sets a different tenant context from the current user's list of tenants.";
|
|
69
|
+
TenantSwitch.args = {
|
|
75
70
|
code: core_1.Args.string({ required: false, description: 'The unique string identifying the tenant to switch to.' })
|
|
76
71
|
};
|
|
77
|
-
|
|
72
|
+
TenantSwitch.flags = {
|
|
73
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
74
|
+
silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Executes without any user interaction; fails on missing or invalid arguments.' }),
|
|
75
|
+
echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Renders the equivalent non-interactive command for future use before executing.' }),
|
|
76
|
+
"to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Renders the equivalent non-interactive command without executing it.' }),
|
|
77
|
+
};
|
|
78
|
+
TenantSwitch.examples = [
|
|
79
|
+
{ description: "Switch tenant interactively.", command: "<%= config.bin %> <%= command.id %>" },
|
|
80
|
+
{ description: "Switch to a specific tenant.", command: "<%= config.bin %> <%= command.id %> my-tenant-code" },
|
|
81
|
+
{ description: "Non-interactive invocation.", command: "<%= config.bin %> <%= command.id %> my-tenant-code --silent" },
|
|
82
|
+
{ description: "Renders the equivalent silent command without executing.", command: "<%= config.bin %> <%= command.id %> my-tenant-code --to-script" },
|
|
83
|
+
];
|
|
78
84
|
//# sourceMappingURL=switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/commands/tenant/switch.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/commands/tenant/switch.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAC1B,sCAAmD;AACnD,6EAAuE;AAEvE,2CAAqD;AACrD,mCAAwC;AAExC,mEAAiE;AAMjE,MAAqB,YAAa,SAAQ,gDAA0C;IAqBrE,WAAW;;;YACtB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YACjD,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,KAAK,iBAAW,CAAC,wBAAwB,EAAE;gBAChI,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,qIAAqI,CAAC,CAAC;aACxN;YACD,MAAM,eAAe,GACnB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,kCAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,MAAA,MAAA,SAAS,aAAT,SAAS,cAAT,SAAS,GAClD,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,kCAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,mCAChD,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,kCAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,mCAC5D,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,kCAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAC5D,OAAO,CAAC,EAAE,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC;;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OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,+EAA+E,EAAE,CAAC;IACzJ,IAAI,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,iFAAiF,EAAE,CAAC;IAC3J,WAAW,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,sEAAsE,EAAE,CAAC;CACnJ,CAAA;AAEM,qBAAQ,GAAsB;IACnC,EAAE,WAAW,EAAE,8BAA8B,EAAE,OAAO,EAAE,qCAAqC,EAAE;IAC/F,EAAE,WAAW,EAAE,8BAA8B,EAAE,OAAO,EAAE,oDAAoD,EAAE;IAC9G,EAAE,WAAW,EAAE,6BAA6B,EAAE,OAAO,EAAE,6DAA6D,EAAE;IACtH,EAAE,WAAW,EAAE,0DAA0D,EAAE,OAAO,EAAE,gEAAgE,EAAE;CACvJ,CAAC"}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { RootMap } from '../apis/codiac-api/contracts';
|
|
3
|
+
import { CommandBaseExecTenant } from '../command-base-exec-tenant';
|
|
4
|
+
import { InteractionModes } from '../uilogic/config-ui-utils';
|
|
5
|
+
type WhereAmIRequest = {
|
|
6
|
+
_?: never;
|
|
7
|
+
};
|
|
8
|
+
export default class Whereami extends CommandBaseExecTenant<WhereAmIRequest> {
|
|
3
9
|
static description: string;
|
|
4
10
|
static flags: {
|
|
5
11
|
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
echo: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
"to-script": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
15
|
};
|
|
9
16
|
static args: {};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
static examples: Command.Example[];
|
|
18
|
+
captureArgs(): Promise<[Partial<WhereAmIRequest>, InteractionModes | undefined, boolean]>;
|
|
19
|
+
buildCandidate_silently(partial: Partial<WhereAmIRequest>, rootMap: RootMap): Promise<WhereAmIRequest | undefined>;
|
|
20
|
+
buildCandidate_interactively(partial: Partial<WhereAmIRequest>, takeDefaults: boolean, rootMap: RootMap): Promise<WhereAmIRequest | undefined>;
|
|
21
|
+
buildCommandString(candidate: WhereAmIRequest, cmd: string[]): string[];
|
|
22
|
+
executeTask(candidate: WhereAmIRequest): Promise<void>;
|
|
14
23
|
private getEnvironmentFor;
|
|
15
24
|
}
|
|
25
|
+
export {};
|
|
@@ -2,114 +2,75 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
-
const
|
|
5
|
+
const command_base_exec_tenant_1 = require("../command-base-exec-tenant");
|
|
6
6
|
const codiac_constants_1 = require("../codiac-constants");
|
|
7
7
|
const prettify_1 = require("../prettify");
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const config_ui_utils_1 = require("../uilogic/config-ui-utils");
|
|
9
|
+
class Whereami extends command_base_exec_tenant_1.CommandBaseExecTenant {
|
|
10
|
+
captureArgs() {
|
|
11
|
+
var _a, _b;
|
|
10
12
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Ben 11:17 AM
|
|
43
|
-
i need to know which enviroment im in
|
|
44
|
-
or at least, which environment you built against
|
|
45
|
-
|
|
46
|
-
Mark Freydl 11:18 AM
|
|
47
|
-
there’s an enterprise context that gets stored in the project-user config file (edited)
|
|
48
|
-
that states the current enterprise, cabinet and asset bindings that the user is pointing the project to (all that is based on gthe branch and cabinet-to-bramch binding, so it’s not source code 0- it’s local state)
|
|
49
|
-
|
|
50
|
-
Ben 11:20 AM
|
|
51
|
-
yeah, that works
|
|
52
|
-
forgot we have in the domain
|
|
53
|
-
that'd be a fun whoami
|
|
54
|
-
|
|
55
|
-
Mark Freydl 11:21 AM
|
|
56
|
-
Every time I work with Environment, I keep thinking that it doesnt have any real purpose other than being a tag
|
|
57
|
-
good idea
|
|
58
|
-
maybe a “whereami”
|
|
59
|
-
|
|
60
|
-
Ben 11:21 AM
|
|
61
|
-
fuck yes dude
|
|
62
|
-
|
|
63
|
-
Mark Freydl 11:21 AM
|
|
64
|
-
returns your enteprise context
|
|
65
|
-
and branch maybe
|
|
66
|
-
|
|
67
|
-
Ben 11:22 AM
|
|
68
|
-
always right, easy to access, i like it
|
|
69
|
-
|
|
70
|
-
Mark Freydl 11:27 AM
|
|
71
|
-
You should write that one.
|
|
72
|
-
it shd be easy - just need to use the cfgRepo to load the projectUser config and prob localOps to get the current branch info
|
|
73
|
-
|
|
74
|
-
Ben 11:30 AM
|
|
75
|
-
i'd be happy to.
|
|
76
|
-
|
|
77
|
-
*/
|
|
78
|
-
resolve();
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
reject(err);
|
|
13
|
+
const { flags } = yield this.parse(Whereami);
|
|
14
|
+
const interactionMode = (this.pipedInput) ? config_ui_utils_1.InteractionModes.silent : (_b = (_a = undefined !== null && undefined !== void 0 ? undefined : (flags.echo ? config_ui_utils_1.InteractionModes.echo : undefined)) !== null && _a !== void 0 ? _a : (flags["to-script"] ? config_ui_utils_1.InteractionModes.toscript : undefined)) !== null && _b !== void 0 ? _b : (flags.silent ? config_ui_utils_1.InteractionModes.silent : undefined);
|
|
15
|
+
return [{}, interactionMode, false];
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
buildCandidate_silently(partial, rootMap) {
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return {};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
buildCandidate_interactively(partial, takeDefaults, rootMap) {
|
|
24
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return {};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
buildCommandString(candidate, cmd) {
|
|
29
|
+
cmd.push("--silent");
|
|
30
|
+
return cmd;
|
|
31
|
+
}
|
|
32
|
+
executeTask(candidate) {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
let bindings = {
|
|
36
|
+
tenant: (_b = (_a = this._projCfg) === null || _a === void 0 ? void 0 : _a.tenantCode) !== null && _b !== void 0 ? _b : this._userCntx.currentTenantCode
|
|
37
|
+
};
|
|
38
|
+
if ((_c = this._projUserCfg) === null || _c === void 0 ? void 0 : _c.enterprise) {
|
|
39
|
+
bindings.enterprise = this._projUserCfg.enterprise.enterpriseCode;
|
|
40
|
+
if (this._projUserCfg.enterprise.cabinet) {
|
|
41
|
+
let environment = yield this.getEnvironmentFor(this._projUserCfg.enterprise.cabinet.cabinet);
|
|
42
|
+
bindings.environment = environment || "[unassigned]";
|
|
43
|
+
bindings.cabinet = this._projUserCfg.enterprise.cabinet.cabinet;
|
|
82
44
|
}
|
|
83
|
-
|
|
84
|
-
|
|
45
|
+
if (this._projUserCfg.enterprise.assetBindings && this._projUserCfg.enterprise.assetBindings.length > 0) {
|
|
46
|
+
bindings.assets = [];
|
|
47
|
+
for (let assetBinding of this._projUserCfg.enterprise.assetBindings) {
|
|
48
|
+
bindings.assets.push({
|
|
49
|
+
asset: assetBinding.incarnation.assetName,
|
|
50
|
+
image: assetBinding.image.name
|
|
51
|
+
});
|
|
52
|
+
}
|
|
85
53
|
}
|
|
86
|
-
}
|
|
54
|
+
}
|
|
55
|
+
this._ui.userMessage((0, prettify_1.prettify)(bindings));
|
|
87
56
|
});
|
|
88
57
|
}
|
|
89
|
-
/** Returns undefined if the cabinet has no environment
|
|
90
|
-
* (undefined should never happen but if such a data issue existed, it would be VERY helpful to know about it here).
|
|
91
|
-
* On error, this method logs the error and returns ERROR_INDICATOR as output. */
|
|
92
58
|
getEnvironmentFor(cabinet) {
|
|
93
59
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
environment = result.output[0].environment;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch (err) {
|
|
105
|
-
this.logger.debug(`Error retrieving environment for cabinet [${cabinet}, tenant: ${this._userCntx.currentTenantCode}]: ${err.name || ""} ${err.message || ""}`, err);
|
|
106
|
-
environment = codiac_constants_1.ERROR_INDICATOR;
|
|
107
|
-
}
|
|
108
|
-
finally {
|
|
109
|
-
// HACK: idkwtf we have to bam this from one TS version to another
|
|
110
|
-
resolve(environment);
|
|
60
|
+
let environment;
|
|
61
|
+
try {
|
|
62
|
+
let result = yield this._codiacApi.Cabinet.tryReadMany({ name: { $eq: cabinet } });
|
|
63
|
+
if (result.error)
|
|
64
|
+
throw result.error;
|
|
65
|
+
else if (result.output && result.output.length > 0) {
|
|
66
|
+
environment = result.output[0].environment;
|
|
111
67
|
}
|
|
112
|
-
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
this.logger.debug(`Error retrieving environment for cabinet [${cabinet}, tenant: ${this._userCntx.currentTenantCode}]: ${err.name || ""} ${err.message || ""}`, err);
|
|
71
|
+
environment = codiac_constants_1.ERROR_INDICATOR;
|
|
72
|
+
}
|
|
73
|
+
return environment;
|
|
113
74
|
});
|
|
114
75
|
}
|
|
115
76
|
}
|
|
@@ -117,10 +78,14 @@ exports.default = Whereami;
|
|
|
117
78
|
Whereami.description = 'Renders the current cabinet context the image project is pointed to. ie: Tenant, Enterprise, Environment, Cabinet.';
|
|
118
79
|
Whereami.flags = {
|
|
119
80
|
help: core_1.Flags.help({ char: 'h' }),
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
force: core_1.Flags.boolean({ char: 'f' }),
|
|
81
|
+
silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Executes without any user interaction; fails on missing or invalid arguments.' }),
|
|
82
|
+
echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Renders the equivalent non-interactive command for future use before executing.' }),
|
|
83
|
+
"to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Renders the equivalent non-interactive command without executing it.' }),
|
|
124
84
|
};
|
|
125
85
|
Whereami.args = {};
|
|
86
|
+
Whereami.examples = [
|
|
87
|
+
{ description: "Show current project context.", command: "<%= config.bin %> <%= command.id %>" },
|
|
88
|
+
{ description: "Non-interactive invocation.", command: "<%= config.bin %> <%= command.id %> --silent" },
|
|
89
|
+
{ description: "Renders the equivalent silent command without executing.", command: "<%= config.bin %> <%= command.id %> --to-script" },
|
|
90
|
+
];
|
|
126
91
|
//# sourceMappingURL=whereami.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whereami.js","sourceRoot":"","sources":["../../src/commands/whereami.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"whereami.js","sourceRoot":"","sources":["../../src/commands/whereami.ts"],"names":[],"mappings":";;;AAAA,s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,8CAA8C,EAAE;IACvG,EAAE,WAAW,EAAE,0DAA0D,EAAE,OAAO,EAAE,iDAAiD,EAAE;CAC1I,CAAC"}
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { RootMap } from '../apis/codiac-api/contracts';
|
|
3
|
+
import { CommandBaseExecTenant } from '../command-base-exec-tenant';
|
|
4
|
+
import { InteractionModes } from '../uilogic/config-ui-utils';
|
|
5
|
+
type WhoamiRequest = {
|
|
6
|
+
output: string;
|
|
7
|
+
};
|
|
8
|
+
export default class Whoami extends CommandBaseExecTenant<WhoamiRequest> {
|
|
3
9
|
static description: string;
|
|
4
10
|
static aliases: string[];
|
|
5
11
|
static flags: {
|
|
12
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
6
13
|
output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
|
+
silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
echo: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
"to-script": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
17
|
};
|
|
8
18
|
static args: {};
|
|
9
|
-
|
|
19
|
+
static examples: Command.Example[];
|
|
20
|
+
captureArgs(): Promise<[Partial<WhoamiRequest>, InteractionModes | undefined, boolean]>;
|
|
21
|
+
buildCandidate_silently(partial: Partial<WhoamiRequest>, rootMap: RootMap): Promise<WhoamiRequest | undefined>;
|
|
22
|
+
buildCandidate_interactively(partial: Partial<WhoamiRequest>, takeDefaults: boolean, rootMap: RootMap): Promise<WhoamiRequest | undefined>;
|
|
23
|
+
buildCommandString(candidate: WhoamiRequest, cmd: string[]): string[];
|
|
24
|
+
executeTask(candidate: WhoamiRequest): Promise<void>;
|
|
10
25
|
}
|
|
26
|
+
export {};
|
package/dist/commands/whoami.js
CHANGED
|
@@ -3,20 +3,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const stringify = require("json-stringify-safe");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const command_base_exec_tenant_1 = require("../command-base-exec-tenant");
|
|
7
|
+
const config_ui_utils_1 = require("../uilogic/config-ui-utils");
|
|
8
|
+
class Whoami extends command_base_exec_tenant_1.CommandBaseExecTenant {
|
|
9
|
+
captureArgs() {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const { flags } = yield this.parse(Whoami);
|
|
13
|
+
const interactionMode = (this.pipedInput) ? config_ui_utils_1.InteractionModes.silent : (_b = (_a = undefined !== null && undefined !== void 0 ? undefined : (flags.echo ? config_ui_utils_1.InteractionModes.echo : undefined)) !== null && _a !== void 0 ? _a : (flags["to-script"] ? config_ui_utils_1.InteractionModes.toscript : undefined)) !== null && _b !== void 0 ? _b : (flags.silent ? config_ui_utils_1.InteractionModes.silent : undefined);
|
|
14
|
+
return [{ output: (_c = flags.output) !== null && _c !== void 0 ? _c : "text" }, interactionMode, false];
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
buildCandidate_silently(partial, rootMap) {
|
|
18
|
+
var _a;
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return { output: (_a = partial.output) !== null && _a !== void 0 ? _a : "text" };
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
buildCandidate_interactively(partial, takeDefaults, rootMap) {
|
|
24
|
+
var _a;
|
|
25
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return { output: (_a = partial.output) !== null && _a !== void 0 ? _a : "text" };
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
buildCommandString(candidate, cmd) {
|
|
30
|
+
if (candidate.output !== "text")
|
|
31
|
+
cmd.push("-o", candidate.output);
|
|
32
|
+
cmd.push("--silent");
|
|
33
|
+
return cmd;
|
|
34
|
+
}
|
|
35
|
+
executeTask(candidate) {
|
|
9
36
|
var _a;
|
|
10
37
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
-
this.bootstrap();
|
|
12
|
-
const { args, flags } = yield this.parse(Whoami);
|
|
13
|
-
// let userContextRepo = new UserContextLoader(this.logger);
|
|
14
|
-
// let cachedUserContext = userContextRepo.loadUserContext(this._projCfg.tenantCode);
|
|
15
38
|
if (this._userCntx) {
|
|
16
|
-
if (
|
|
39
|
+
if (candidate.output === "json") {
|
|
17
40
|
process.stdout.write(stringify(this._userCntx, undefined, 2));
|
|
18
41
|
}
|
|
19
|
-
else {
|
|
42
|
+
else {
|
|
20
43
|
this._ui.userMessage(`${this._styler.hilite(this._userCntx.userName)} (tenant: ${this._styler.hilite(this._userCntx.currentTenantCode || "none")})`);
|
|
21
44
|
if (this._userCntx.roles && (this._userCntx.roles.length > 0)) {
|
|
22
45
|
this._ui.userMessage(this._styler.dim("└─ roles: ").concat((_a = this._userCntx.roles) === null || _a === void 0 ? void 0 : _a.join(", ")));
|
|
@@ -24,10 +47,10 @@ class Whoami extends command_base_enterprise_1.CommandBaseEnterprise {
|
|
|
24
47
|
}
|
|
25
48
|
}
|
|
26
49
|
else {
|
|
27
|
-
if (
|
|
50
|
+
if (candidate.output === "json") {
|
|
28
51
|
process.stdout.write("");
|
|
29
52
|
}
|
|
30
|
-
else {
|
|
53
|
+
else {
|
|
31
54
|
this._ui.userMessage(`You are not currently logged in.`);
|
|
32
55
|
}
|
|
33
56
|
}
|
|
@@ -38,9 +61,17 @@ exports.default = Whoami;
|
|
|
38
61
|
Whoami.description = 'Renders the codiac username and its current tenant.';
|
|
39
62
|
Whoami.aliases = ["user:show"];
|
|
40
63
|
Whoami.flags = {
|
|
41
|
-
|
|
42
|
-
// output: Flags.custom({ char: 'o', options: ['text', 'json'], default: 'text', description: "Format for the response data." })
|
|
64
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
43
65
|
output: core_1.Flags.string({ char: 'o', options: ['text', 'json'], default: 'text', description: 'Format for the response data.' }),
|
|
66
|
+
silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Executes without any user interaction; fails on missing or invalid arguments.' }),
|
|
67
|
+
echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Renders the equivalent non-interactive command for future use before executing.' }),
|
|
68
|
+
"to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Renders the equivalent non-interactive command without executing it.' }),
|
|
44
69
|
};
|
|
45
70
|
Whoami.args = {};
|
|
71
|
+
Whoami.examples = [
|
|
72
|
+
{ description: "Show current user.", command: "<%= config.bin %> <%= command.id %>" },
|
|
73
|
+
{ description: "Show current user as JSON.", command: "<%= config.bin %> <%= command.id %> -o json" },
|
|
74
|
+
{ description: "Non-interactive invocation.", command: "<%= config.bin %> <%= command.id %> --silent" },
|
|
75
|
+
{ description: "Renders the equivalent silent command without executing.", command: "<%= config.bin %> <%= command.id %> --to-script" },
|
|
76
|
+
];
|
|
46
77
|
//# sourceMappingURL=whoami.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";;;AAAA,sCAA6C;AAC7C,iDAAiD;AAEjD,0EAAoE;AACpE,gEAA8D;AAI9D,MAAqB,MAAO,SAAQ,gDAAoC;IAqBvD,WAAW;;;YACpB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC3C,MAAM,eAAe,GACjB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,kCAAgB,CAAC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AAE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,+EAA+E,EAAE,CAAC;IACzJ,IAAI,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,iFAAiF,EAAE,CAAC;IAC3J,WAAW,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,sEAAsE,EAAE,CAAC;CACrJ,CAAC;AAEK,WAAI,GAAG,EAAE,CAAC;AAEV,eAAQ,GAAsB;IACjC,EAAE,WAAW,EAAE,oBAAoB,EAAE,OAAO,EAAE,qCAAqC,EAAE;IACrF,EAAE,WAAW,EAAE,4BAA4B,EAAE,OAAO,EAAE,6CAA6C,EAAE;IACrG,EAAE,WAAW,EAAE,6BAA6B,EAAE,OAAO,EAAE,8CAA8C,EAAE;IACvG,EAAE,WAAW,EAAE,0DAA0D,EAAE,OAAO,EAAE,iDAAiD,EAAE;CAC1I,CAAC"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import * as inquirer from "inquirer";
|
|
2
|
-
import { IEntryValidator } from "../ops/i-entry-validator";
|
|
2
|
+
import { IEntryValidator, ValidationResult } from "../ops/i-entry-validator";
|
|
3
3
|
export type EntryValue = string | number | boolean;
|
|
4
|
+
/** Input object for the available options in a CLI select list.
|
|
5
|
+
* The `name` is what renders in the list,
|
|
6
|
+
* and the `value` is what actually gets returned from the selection. */
|
|
7
|
+
export type SelectOption<T> = {
|
|
8
|
+
value: T;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
/** Return type for fuzzy-select validation callbacks. */
|
|
12
|
+
export type BooleanValidationResult = boolean | ValidationResult;
|
|
4
13
|
export type choice<T extends EntryValue> = T | {
|
|
5
14
|
name: string;
|
|
6
15
|
value?: T;
|
|
@@ -40,6 +49,16 @@ export interface IUserInputProvider {
|
|
|
40
49
|
*/
|
|
41
50
|
promptSelectMulti<T extends EntryValue>(id: string, prompt: string, choices: choice<T>[], loop?: boolean | undefined): Promise<T[] | undefined>;
|
|
42
51
|
promptSelectMulti<T extends EntryValue>(id: string, prompt: string, choices: choice<T>[], loop?: boolean | undefined, validator?: (input: T, answers?: inquirer.Answers | undefined) => boolean | string): Promise<T[] | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Prompts for a value using fuzzy (autocomplete) search over the available choices.
|
|
54
|
+
* @param id Identifies the prompt for internal use, esp in mocking. This value never renders to the user.
|
|
55
|
+
* @param fetchChoices Async function that returns the list of choices, optionally filtered by the user's search string (for remote search). For client-side filtering pass the full list regardless of the input.
|
|
56
|
+
* @param suggestOnly When true the user may type a free-form value not present in the list (optional, defaults to false).
|
|
57
|
+
* @param defaultValue Pre-selected value shown at the top of the list (optional).
|
|
58
|
+
* @param searchOnRemote When true, `fetchChoices` is called on every keystroke; when false the list is fetched once and filtered client-side (optional, defaults to false).
|
|
59
|
+
* @param validate Optional callback to validate the selected value; return `true` / `false` or a `ValidationResult`.
|
|
60
|
+
*/
|
|
61
|
+
promptSelectFuzzy<T>(id: string, prompt: string, fetchChoices: (searchString?: string) => Promise<SelectOption<T>[]>, suggestOnly?: boolean, defaultValue?: T, searchOnRemote?: boolean, validate?: (candidate: T) => BooleanValidationResult): Promise<T | undefined>;
|
|
43
62
|
/** Enables the user to retrieves a reference to a single existing file on the local machine.
|
|
44
63
|
* @param id Identifies the prompt for internal use, esp in mocking. This value never renders to the user. */
|
|
45
64
|
promptSelectFile(id: string, prompt: string, fileOptions: FileSelectionOptions): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i-user-input-provider.js","sourceRoot":"","sources":["../../src/ops/i-user-input-provider.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"i-user-input-provider.js","sourceRoot":"","sources":["../../src/ops/i-user-input-provider.ts"],"names":[],"mappings":";;;AAeA,kFAAkF;AAClF,MAAa,sBAAsB;CAQlC;AARD,wDAQC;AAED,gFAAgF;AAChF,MAAa,oBAAqB,SAAQ,sBAAsB;CAG/D;AAHD,oDAGC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntryValue, IUserInputProvider, choice, IOutputStyler, FileSelectionOptions, FolderSelectionOptions } from '../';
|
|
1
|
+
import { EntryValue, IUserInputProvider, choice, IOutputStyler, FileSelectionOptions, FolderSelectionOptions, SelectOption, BooleanValidationResult } from '../';
|
|
2
2
|
export declare class MockUi implements IUserInputProvider, IOutputStyler {
|
|
3
3
|
constructor();
|
|
4
4
|
private values;
|
|
@@ -13,6 +13,7 @@ export declare class MockUi implements IUserInputProvider, IOutputStyler {
|
|
|
13
13
|
promptPassword(id: string, prompt: string): Promise<string>;
|
|
14
14
|
promptSelect<T extends EntryValue>(id: string, prompt: string, choices: choice<T>[], multiSelect?: boolean | undefined): Promise<T | undefined>;
|
|
15
15
|
promptSelectMulti<T extends EntryValue>(id: string, prompt: string, choices: choice<T>[], loop?: boolean): Promise<T[] | undefined>;
|
|
16
|
+
promptSelectFuzzy<T>(id: string, prompt: string, fetchChoices: (searchString?: string) => Promise<SelectOption<T>[]>, suggestOnly?: boolean, defaultValue?: T, searchOnRemote?: boolean, validate?: (candidate: T) => BooleanValidationResult): Promise<T | undefined>;
|
|
16
17
|
promptSelectFile(id: string, prompt: string, fileOptions: FileSelectionOptions): Promise<string>;
|
|
17
18
|
promptSelectFolder(id: string, prompt: string, folderOptions: FolderSelectionOptions): Promise<string>;
|
|
18
19
|
promptConfirm(id: string, prompt: string, defaultValue?: boolean): Promise<boolean>;
|