oneclient 0.1.1 → 0.1.2
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/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -0
- package/dist/index.js +17 -9
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare const DEFAULT_CONTROL_API_URL = "https://control.one-client.com";
|
|
2
2
|
export declare const DEFAULT_CONSOLE_ORIGIN = "https://console.one-client.com";
|
|
3
3
|
export declare function developerAuthOrigin(apiUrl: string): string;
|
|
4
|
+
export declare function inferOrganizationId(explicitId: string | undefined, organizations: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
}>): string;
|
|
4
7
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,mCAAmC,CAAC;AACxE,eAAO,MAAM,sBAAsB,mCAAmC,CAAC;AAEvE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG1D"}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,mCAAmC,CAAC;AACxE,eAAO,MAAM,sBAAsB,mCAAmC,CAAC;AAEvE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GACnC,MAAM,CAMR"}
|
package/dist/config.js
CHANGED
|
@@ -4,3 +4,12 @@ export function developerAuthOrigin(apiUrl) {
|
|
|
4
4
|
const origin = new URL(apiUrl).origin;
|
|
5
5
|
return origin === DEFAULT_CONTROL_API_URL ? DEFAULT_CONSOLE_ORIGIN : origin;
|
|
6
6
|
}
|
|
7
|
+
export function inferOrganizationId(explicitId, organizations) {
|
|
8
|
+
if (explicitId)
|
|
9
|
+
return explicitId;
|
|
10
|
+
if (organizations.length === 1)
|
|
11
|
+
return organizations[0].id;
|
|
12
|
+
if (organizations.length === 0)
|
|
13
|
+
throw new Error("Create an organization with `oneclient organization:create` first");
|
|
14
|
+
throw new Error("This account has multiple organizations; pass --organization <id>");
|
|
15
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -14,12 +14,12 @@ import { deployTokenFromEnvironment, parseServerKeyScopes, serverKeyFromEnvironm
|
|
|
14
14
|
import { secretValueFromOptions } from "./secret-input.js";
|
|
15
15
|
import { brand, formatOutput, statusLine } from "./presenter.js";
|
|
16
16
|
import { slugify } from "./slug.js";
|
|
17
|
-
import { DEFAULT_CONTROL_API_URL } from "./config.js";
|
|
17
|
+
import { DEFAULT_CONTROL_API_URL, inferOrganizationId } from "./config.js";
|
|
18
18
|
const program = new Command();
|
|
19
19
|
program
|
|
20
20
|
.name("oneclient")
|
|
21
21
|
.description("Deploy and manage OneClient projects")
|
|
22
|
-
.version("0.1.
|
|
22
|
+
.version("0.1.2")
|
|
23
23
|
.option("--api-url <url>", "Control or environment API URL", process.env.ONECLIENT_API_URL)
|
|
24
24
|
.option("--organization <id>", "Organization ID", process.env.ONECLIENT_ORGANIZATION_ID)
|
|
25
25
|
.option("--json", "Print stable JSON for scripts and agents", false)
|
|
@@ -115,7 +115,7 @@ program
|
|
|
115
115
|
program
|
|
116
116
|
.command("projects")
|
|
117
117
|
.description("List projects")
|
|
118
|
-
.action(async () => print(await
|
|
118
|
+
.action(async () => print(await organizationSessionClient().then((api) => api.projects.list()), "Projects"));
|
|
119
119
|
program
|
|
120
120
|
.command("project:create")
|
|
121
121
|
.description("Create a project and its development and production environments")
|
|
@@ -155,7 +155,7 @@ program
|
|
|
155
155
|
program
|
|
156
156
|
.command("usage")
|
|
157
157
|
.description("Show the prepaid wallet and retention reserve")
|
|
158
|
-
.action(async () => print(await
|
|
158
|
+
.action(async () => print(await organizationSessionClient().then((api) => api.usage.summary()), "Usage & balance"));
|
|
159
159
|
program
|
|
160
160
|
.command("status")
|
|
161
161
|
.description("Show account, organization, project, and spend status in one view")
|
|
@@ -199,7 +199,7 @@ program
|
|
|
199
199
|
const limit = Number(options.limit);
|
|
200
200
|
if (!Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
201
201
|
throw new Error("limit must be an integer from 1 through 100");
|
|
202
|
-
print(await
|
|
202
|
+
print(await organizationSessionClient().then((api) => api.usage.activity(limit)), "Recent activity");
|
|
203
203
|
});
|
|
204
204
|
program
|
|
205
205
|
.command("deployments")
|
|
@@ -269,11 +269,11 @@ program
|
|
|
269
269
|
program
|
|
270
270
|
.command("billing:portal")
|
|
271
271
|
.description("Create a secure Stripe billing-portal session")
|
|
272
|
-
.action(async () => print(await
|
|
272
|
+
.action(async () => print(await organizationSessionClient().then((api) => api.billing.portal()), "Billing portal"));
|
|
273
273
|
program
|
|
274
274
|
.command("billing:subscribe")
|
|
275
275
|
.description("Create a subscription Checkout session")
|
|
276
|
-
.action(async () => print(await
|
|
276
|
+
.action(async () => print(await organizationSessionClient().then((api) => api.billing.subscriptionCheckout()), "Subscription checkout"));
|
|
277
277
|
program
|
|
278
278
|
.command("billing:topup")
|
|
279
279
|
.description("Create a prepaid credit Checkout session")
|
|
@@ -283,12 +283,12 @@ program
|
|
|
283
283
|
if (!Number.isFinite(dollars) || dollars < 25 || Math.round(dollars * 100) !== dollars * 100)
|
|
284
284
|
throw new Error("usd must be at least 25 with no more than two decimal places");
|
|
285
285
|
const amountMicros = String(Math.round(dollars * 1_000_000));
|
|
286
|
-
print(await
|
|
286
|
+
print(await organizationSessionClient().then((api) => api.billing.topupCheckout(amountMicros)), "Credit checkout");
|
|
287
287
|
});
|
|
288
288
|
program
|
|
289
289
|
.command("domain:list")
|
|
290
290
|
.description("List application, API, and sending domains")
|
|
291
|
-
.action(async () => print(await
|
|
291
|
+
.action(async () => print(await organizationSessionClient().then((api) => api.domains.list()), "Domains"));
|
|
292
292
|
program
|
|
293
293
|
.command("domain:add")
|
|
294
294
|
.description("Attach a custom hostname")
|
|
@@ -572,6 +572,14 @@ async function sessionClient(organizationId) {
|
|
|
572
572
|
: {}),
|
|
573
573
|
});
|
|
574
574
|
}
|
|
575
|
+
async function organizationSessionClient() {
|
|
576
|
+
const explicitId = program.opts().organization;
|
|
577
|
+
if (explicitId)
|
|
578
|
+
return sessionClient(explicitId);
|
|
579
|
+
const base = await sessionClient();
|
|
580
|
+
const organizations = await base.organizations.list();
|
|
581
|
+
return sessionClient(inferOrganizationId(undefined, organizations));
|
|
582
|
+
}
|
|
575
583
|
async function deployClient() {
|
|
576
584
|
const options = program.opts();
|
|
577
585
|
const deployToken = deployTokenFromEnvironment();
|