@stndrds/cli 1.0.0-alpha.138 → 1.0.0-alpha.140
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.mjs +24 -3
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -336,6 +336,7 @@ import { mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
|
336
336
|
import { homedir } from "os";
|
|
337
337
|
import { dirname, join } from "path";
|
|
338
338
|
var DEFAULT_API_URL = "http://localhost:4100/v1";
|
|
339
|
+
var ENV_PROFILE_NAME = "sandbox";
|
|
339
340
|
function getDefaultApiUrl() {
|
|
340
341
|
return DEFAULT_API_URL;
|
|
341
342
|
}
|
|
@@ -393,19 +394,39 @@ async function removeProfile(name) {
|
|
|
393
394
|
}
|
|
394
395
|
async function listProfiles() {
|
|
395
396
|
const config = await readConfig();
|
|
396
|
-
|
|
397
|
+
const profiles = Object.entries(config.profiles).sort(([a], [b]) => a.localeCompare(b)).map(([name, profile]) => ({
|
|
397
398
|
name,
|
|
398
399
|
apiUrl: profile.apiUrl,
|
|
399
400
|
current: config.currentProfile === name
|
|
400
401
|
}));
|
|
402
|
+
const envProfile = getEnvProfile();
|
|
403
|
+
if (envProfile) {
|
|
404
|
+
profiles.push({
|
|
405
|
+
name: ENV_PROFILE_NAME,
|
|
406
|
+
apiUrl: envProfile.apiUrl,
|
|
407
|
+
current: !config.currentProfile,
|
|
408
|
+
source: "env"
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
return profiles;
|
|
401
412
|
}
|
|
402
413
|
async function getActiveProfile() {
|
|
403
414
|
const config = await readConfig();
|
|
404
|
-
if (!config.currentProfile)
|
|
415
|
+
if (!config.currentProfile) {
|
|
416
|
+
const envProfile = getEnvProfile();
|
|
417
|
+
return envProfile ? { name: ENV_PROFILE_NAME, ...envProfile } : null;
|
|
418
|
+
}
|
|
405
419
|
const profile = config.profiles[config.currentProfile];
|
|
406
420
|
if (!profile) return null;
|
|
407
421
|
return { name: config.currentProfile, ...profile };
|
|
408
422
|
}
|
|
423
|
+
function getEnvProfile() {
|
|
424
|
+
if (!process.env.STANDARDS_API_KEY) return null;
|
|
425
|
+
return {
|
|
426
|
+
apiUrl: process.env.STANDARDS_API_URL ?? DEFAULT_API_URL,
|
|
427
|
+
apiKey: process.env.STANDARDS_API_KEY
|
|
428
|
+
};
|
|
429
|
+
}
|
|
409
430
|
async function resolveCliConfig(options) {
|
|
410
431
|
if (options.apiUrl || options.apiKey) {
|
|
411
432
|
return {
|
|
@@ -507,7 +528,7 @@ function isPublicCommand(actionCommand) {
|
|
|
507
528
|
}
|
|
508
529
|
function createProgram() {
|
|
509
530
|
const program = new Command();
|
|
510
|
-
program.name("standards").description("CLI to interact with Standards API").version("1.0.0-alpha.
|
|
531
|
+
program.name("standards").description("CLI to interact with Standards API").version("1.0.0-alpha.139").option("--format <format>", "output format (json, table, csv)", "json").option("--api-url <url>", "API base URL").option("--api-key <key>", "API key for authentication").option("--instance <name>", "Standards instance profile to use");
|
|
511
532
|
registerRootCommands(program);
|
|
512
533
|
registerRecordsCommand(program);
|
|
513
534
|
registerSchemaCommand(program);
|