@shipdit/cli 0.1.0 → 0.1.1
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/index.mjs +8 -7
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Command, CommanderError } from "commander";
|
|
2
|
+
import { Command, CommanderError, Option } from "commander";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
@@ -51,7 +51,7 @@ function findProjectRoot(start = process.cwd()) {
|
|
|
51
51
|
function loadProjectConfig(projectRoot, configPath) {
|
|
52
52
|
return readJsonFile(configPath ?? path.join(projectRoot, ".shipd", "config.json")) ?? {};
|
|
53
53
|
}
|
|
54
|
-
function resolveRuntimeConfig(flags) {
|
|
54
|
+
function resolveRuntimeConfig(flags, options) {
|
|
55
55
|
const cwd = process.cwd();
|
|
56
56
|
const projectRoot = findProjectRoot(cwd);
|
|
57
57
|
const projectConfig = loadProjectConfig(projectRoot, flags.config);
|
|
@@ -60,7 +60,7 @@ function resolveRuntimeConfig(flags) {
|
|
|
60
60
|
const ci = flags.ci === true || flags.yes === true || process.env.CI === "1" || process.env.CI === "true" || process.env.SHIPD_CI === "1";
|
|
61
61
|
const defaultConfigFile = fs.existsSync(path.join(projectRoot, "shipd.config.ts")) ? path.join(projectRoot, "shipd.config.ts") : path.join(cwd, "shipd.config.ts");
|
|
62
62
|
return {
|
|
63
|
-
apiUrl: flags.apiUrl ?? process.env.SHIPD_API_URL ?? projectConfig.apiUrl ?? globalConfig.apiUrl ?? credentials.apiUrl ?? "http://localhost:8000",
|
|
63
|
+
apiUrl: flags.apiUrl ?? process.env.SHIPD_API_URL ?? projectConfig.apiUrl ?? globalConfig.apiUrl ?? credentials.apiUrl ?? options?.defaultApiUrl ?? "http://localhost:8000",
|
|
64
64
|
appUrl: process.env.SHIPD_APP_URL ?? projectConfig.appUrl ?? globalConfig.appUrl ?? "http://localhost:5173",
|
|
65
65
|
apiKey: process.env.SHIPD_API_KEY ?? credentials.apiKey,
|
|
66
66
|
org: flags.org ?? process.env.SHIPD_ORG ?? projectConfig.org ?? globalConfig.org,
|
|
@@ -3935,9 +3935,9 @@ async function resolveIds(client, runtime) {
|
|
|
3935
3935
|
|
|
3936
3936
|
//#endregion
|
|
3937
3937
|
//#region src/lib/output.ts
|
|
3938
|
-
function getRuntime(command) {
|
|
3938
|
+
function getRuntime(command, options) {
|
|
3939
3939
|
const opts = command.optsWithGlobals();
|
|
3940
|
-
return resolveRuntimeConfig(opts);
|
|
3940
|
+
return resolveRuntimeConfig(opts, options);
|
|
3941
3941
|
}
|
|
3942
3942
|
function printResult(runtime, data, human) {
|
|
3943
3943
|
if (runtime.json) {
|
|
@@ -3973,9 +3973,10 @@ function e(e) {
|
|
|
3973
3973
|
//#region src/commands/auth.ts
|
|
3974
3974
|
const CLIENT_ID = "shipd-cli";
|
|
3975
3975
|
const MANAGEMENT_KEY_PREFIX = "shipd_mgmt_";
|
|
3976
|
+
const DEFAULT_API_URL = "https://api.useshipd.com";
|
|
3976
3977
|
function registerAuthCommands(program) {
|
|
3977
|
-
program.command("login").description("Authenticate via browser device authorization").action(async (_opts, command) => {
|
|
3978
|
-
const runtime = getRuntime(command);
|
|
3978
|
+
program.command("login").description("Authenticate via browser device authorization").addOption(new Option("--api-url <url>", `API origin (default: ${DEFAULT_API_URL})`).env("SHIPD_API_URL")).action(async (_opts, command) => {
|
|
3979
|
+
const runtime = getRuntime(command, { defaultApiUrl: DEFAULT_API_URL });
|
|
3979
3980
|
const auth = e(createCliAuthClient(runtime.apiUrl));
|
|
3980
3981
|
const codeResult = await auth.device.code({ client_id: CLIENT_ID });
|
|
3981
3982
|
if (codeResult.error) throw new CliError("unauthenticated", codeResult.error.error_description ?? "Failed to start device authorization");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipdit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "shipd's command-line interface",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"commander": "^14.0.0",
|
|
21
21
|
"jiti": "^2.5.1",
|
|
22
22
|
"zod": "^4",
|
|
23
|
-
"shipdit": "0.2.
|
|
23
|
+
"shipdit": "0.2.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^24.13.3",
|