omnara 1.0.6 → 1.0.7
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/dist/bin.js +18 -10
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -7109,10 +7109,12 @@ async function selectFrom(message, choices) {
|
|
|
7109
7109
|
if (isCancel(picked)) throw new CliInputError("selection cancelled");
|
|
7110
7110
|
return picked;
|
|
7111
7111
|
}
|
|
7112
|
-
async function promptOrgSelection(client2) {
|
|
7112
|
+
async function promptOrgSelection(client2, issuerUrl) {
|
|
7113
7113
|
const { data } = await sdk_gen_exports.getCurrentUser({ client: client2 });
|
|
7114
7114
|
if (data.orgs.length === 0) {
|
|
7115
|
-
throw new CliInputError(
|
|
7115
|
+
throw new CliInputError(
|
|
7116
|
+
`this account has no organizations; create one at ${new URL("/onboarding", issuerUrl).toString()}`
|
|
7117
|
+
);
|
|
7116
7118
|
}
|
|
7117
7119
|
return selectFrom(
|
|
7118
7120
|
"Select an organization",
|
|
@@ -7257,11 +7259,13 @@ async function loginWithDevice(options) {
|
|
|
7257
7259
|
const client2 = createOmnaraClient({ baseUrl: options.apiUrl, auth: bearerToken(token) });
|
|
7258
7260
|
let orgId = saved.org_id;
|
|
7259
7261
|
let projectId = saved.project_id;
|
|
7262
|
+
let hasOrganizations;
|
|
7260
7263
|
let loginMessage = "Logged in";
|
|
7261
7264
|
let validationWarning;
|
|
7262
7265
|
try {
|
|
7263
7266
|
const { data: me } = await sdk_gen_exports.getCurrentUser({ client: client2 });
|
|
7264
7267
|
loginMessage = `Logged in as ${me.user.email || me.user.display_name}`;
|
|
7268
|
+
hasOrganizations = me.orgs.length > 0;
|
|
7265
7269
|
if (orgId !== void 0 && !me.orgs.some((org) => org.id === orgId)) {
|
|
7266
7270
|
updateConfigFile({ org_id: void 0, project_id: void 0 });
|
|
7267
7271
|
orgId = void 0;
|
|
@@ -7283,7 +7287,7 @@ async function loginWithDevice(options) {
|
|
|
7283
7287
|
if (process.env.OMNARA_API_KEY !== void 0) {
|
|
7284
7288
|
report.warn("OMNARA_API_KEY is set and takes precedence over the saved token");
|
|
7285
7289
|
}
|
|
7286
|
-
return { token, orgId, projectId };
|
|
7290
|
+
return { token, orgId, projectId, hasOrganizations };
|
|
7287
7291
|
}
|
|
7288
7292
|
|
|
7289
7293
|
// src/config.ts
|
|
@@ -7397,7 +7401,7 @@ function registerConfigCommand(program2, cli) {
|
|
|
7397
7401
|
throw new CliInputError("interactive selection needs a terminal");
|
|
7398
7402
|
}
|
|
7399
7403
|
await cli.ensureLoggedIn();
|
|
7400
|
-
const orgId = await promptOrgSelection(cli.client);
|
|
7404
|
+
const orgId = await promptOrgSelection(cli.client, cli.issuerUrl);
|
|
7401
7405
|
const projectId = await promptProjectSelection(cli.client, orgId);
|
|
7402
7406
|
updateConfigFile({ org_id: orgId, project_id: projectId });
|
|
7403
7407
|
printConfig();
|
|
@@ -7623,7 +7627,7 @@ var CONFIG_PARAMS = [
|
|
|
7623
7627
|
configKey: "org_id",
|
|
7624
7628
|
describe: "pass --org or set OMNARA_ORG_ID",
|
|
7625
7629
|
resolve: (config2) => config2.defaultOrgId,
|
|
7626
|
-
prompt: (
|
|
7630
|
+
prompt: (config2) => promptOrgSelection(config2.client, config2.issuerUrl)
|
|
7627
7631
|
},
|
|
7628
7632
|
{
|
|
7629
7633
|
key: "projectID",
|
|
@@ -7632,12 +7636,12 @@ var CONFIG_PARAMS = [
|
|
|
7632
7636
|
configKey: "project_id",
|
|
7633
7637
|
describe: "pass --project or set OMNARA_PROJECT_ID",
|
|
7634
7638
|
resolve: (config2, path) => path.orgID === void 0 || path.orgID === config2.defaultOrgId ? config2.defaultProjectId : void 0,
|
|
7635
|
-
prompt: (
|
|
7639
|
+
prompt: (config2, path) => {
|
|
7636
7640
|
const orgId = path.orgID;
|
|
7637
7641
|
if (typeof orgId !== "string") {
|
|
7638
7642
|
throw new CliInputError("cannot select a project before an organization is set");
|
|
7639
7643
|
}
|
|
7640
|
-
return promptProjectSelection(
|
|
7644
|
+
return promptProjectSelection(config2.client, orgId);
|
|
7641
7645
|
}
|
|
7642
7646
|
}
|
|
7643
7647
|
];
|
|
@@ -7767,7 +7771,7 @@ async function resolvePathValues(plan, args, options, config2) {
|
|
|
7767
7771
|
usedExplicitOverride = usedExplicitOverride || explicit !== void 0;
|
|
7768
7772
|
let value = explicit ?? param.resolve(config2, path);
|
|
7769
7773
|
if (value === void 0 && canPromptInteractively()) {
|
|
7770
|
-
value = await param.prompt(config2
|
|
7774
|
+
value = await param.prompt(config2, path);
|
|
7771
7775
|
if (!usedExplicitOverride) saveConfigDefault(param.configKey, value);
|
|
7772
7776
|
}
|
|
7773
7777
|
if (value === void 0) {
|
|
@@ -7859,14 +7863,18 @@ function registerLoginCommand(program2, cli) {
|
|
|
7859
7863
|
program2.command("login").description("Log in via the browser and save an API token").option("--no-browser", "print the approval URL instead of opening a browser").option("--token-name <name>", "name for the created API token").action(async (options) => {
|
|
7860
7864
|
await runCliAction(async () => {
|
|
7861
7865
|
const report = createLoginReporter(`Log in to ${cli.issuerUrl}`);
|
|
7862
|
-
const { orgId } = await loginWithDevice({
|
|
7866
|
+
const { orgId, hasOrganizations } = await loginWithDevice({
|
|
7863
7867
|
apiUrl: cli.apiUrl,
|
|
7864
7868
|
issuerUrl: cli.issuerUrl,
|
|
7865
7869
|
browser: options.browser,
|
|
7866
7870
|
tokenName: options.tokenName,
|
|
7867
7871
|
report
|
|
7868
7872
|
});
|
|
7869
|
-
if (
|
|
7873
|
+
if (hasOrganizations === false) {
|
|
7874
|
+
report.finish(
|
|
7875
|
+
`This account has no organization yet. Create one at ${new URL("/onboarding", cli.issuerUrl).toString()}, then run 'omnara config select'.`
|
|
7876
|
+
);
|
|
7877
|
+
} else if ((process.env.OMNARA_ORG_ID ?? orgId) === void 0) {
|
|
7870
7878
|
report.finish("Run 'omnara config select' to choose a default organization and project.");
|
|
7871
7879
|
} else {
|
|
7872
7880
|
report.finish();
|
package/package.json
CHANGED