@kaupang/cli 0.1.2 → 0.2.0
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/cli.js +46 -14
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import { defineCommand as
|
|
4
|
+
import { defineCommand as defineCommand8, runMain } from "citty";
|
|
5
5
|
|
|
6
6
|
// src/commands/build.ts
|
|
7
7
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
@@ -426,10 +426,41 @@ var runCommand = defineCommand5({
|
|
|
426
426
|
}
|
|
427
427
|
});
|
|
428
428
|
|
|
429
|
-
// src/commands/
|
|
430
|
-
import { join as join2, resolve as resolvePath } from "node:path";
|
|
429
|
+
// src/commands/studio.ts
|
|
431
430
|
import { defineCommand as defineCommand6 } from "citty";
|
|
432
431
|
import { consola as consola5 } from "consola";
|
|
432
|
+
var studioCommand = defineCommand6({
|
|
433
|
+
meta: {
|
|
434
|
+
name: "studio",
|
|
435
|
+
description: "Launch the kaupang studio web UI \u2014 browse a catalog, assemble environments + a solution, and export a config."
|
|
436
|
+
},
|
|
437
|
+
args: {
|
|
438
|
+
port: { type: "string", description: "Port to listen on (default 8080)." },
|
|
439
|
+
catalog: {
|
|
440
|
+
type: "string",
|
|
441
|
+
description: "Catalog source to preload: a file path, http(s) URL, or oci://ref."
|
|
442
|
+
},
|
|
443
|
+
"no-open": { type: "boolean", description: "Don't open a browser automatically." },
|
|
444
|
+
cwd: { type: "string", description: "Directory to resolve `file` catalog sources from." }
|
|
445
|
+
},
|
|
446
|
+
async run({ args }) {
|
|
447
|
+
const { startStudio } = await import("@kaupang/studio");
|
|
448
|
+
const { url } = await startStudio({
|
|
449
|
+
port: args.port ? Number(args.port) : void 0,
|
|
450
|
+
catalog: args.catalog,
|
|
451
|
+
rootDir: args.cwd,
|
|
452
|
+
open: !args["no-open"]
|
|
453
|
+
});
|
|
454
|
+
consola5.success(`\u2693 kaupang studio \u2192 ${url} (Ctrl-C to stop)`);
|
|
455
|
+
await new Promise(() => {
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
// src/commands/up.ts
|
|
461
|
+
import { join as join2, resolve as resolvePath } from "node:path";
|
|
462
|
+
import { defineCommand as defineCommand7 } from "citty";
|
|
463
|
+
import { consola as consola6 } from "consola";
|
|
433
464
|
import { backendNames as backendNames3 } from "@kaupang/core/internal";
|
|
434
465
|
import { loadConfig as loadConfig6 } from "@kaupang/core/internal";
|
|
435
466
|
import { makeContext as makeContext4 } from "@kaupang/core/internal";
|
|
@@ -443,7 +474,7 @@ import { applyTarget as applyTarget3, resolveTarget as resolveTarget4 } from "@k
|
|
|
443
474
|
import { mergeEnv as mergeEnv2 } from "@kaupang/core/internal";
|
|
444
475
|
import { run as run5 } from "@kaupang/core/internal";
|
|
445
476
|
var PULL_POLICIES = ["always", "missing", "never"];
|
|
446
|
-
var upCommand =
|
|
477
|
+
var upCommand = defineCommand7({
|
|
447
478
|
meta: {
|
|
448
479
|
name: "up",
|
|
449
480
|
description: "Deploy an environment, a solution, or a pre-built bundle to a target."
|
|
@@ -468,7 +499,7 @@ var upCommand = defineCommand6({
|
|
|
468
499
|
async run({ args }) {
|
|
469
500
|
applyVerbose(args);
|
|
470
501
|
const json = parseOutput(args.output);
|
|
471
|
-
if (json)
|
|
502
|
+
if (json) consola6.level = -999;
|
|
472
503
|
const loaded = await loadConfig6(args.cwd);
|
|
473
504
|
if (args.bundle) {
|
|
474
505
|
await deployBundle(loaded, args.bundle, {
|
|
@@ -517,7 +548,7 @@ var upCommand = defineCommand6({
|
|
|
517
548
|
}
|
|
518
549
|
renderPlan(plan, ctx, rt);
|
|
519
550
|
if (args.resolve) {
|
|
520
|
-
|
|
551
|
+
consola6.info("Images will be resolved to digests at deploy time (--no-resolve to skip).");
|
|
521
552
|
}
|
|
522
553
|
return;
|
|
523
554
|
}
|
|
@@ -560,16 +591,16 @@ function emitJson(value) {
|
|
|
560
591
|
async function deployBundle(loaded, bundleArg, opts) {
|
|
561
592
|
let dir;
|
|
562
593
|
if (isOciRef(bundleArg)) {
|
|
563
|
-
|
|
594
|
+
consola6.start(`\u26F5 ferrying cargo \u2190 ${bundleArg}`);
|
|
564
595
|
dir = await pullBundle(bundleArg, join2(loaded.cacheDir, "pulled"));
|
|
565
|
-
|
|
596
|
+
consola6.success(`cargo ashore at ${dir}`);
|
|
566
597
|
} else {
|
|
567
598
|
dir = resolvePath(loaded.rootDir, bundleArg);
|
|
568
599
|
}
|
|
569
600
|
const manifest = readBundle(dir);
|
|
570
601
|
const targetName = opts.target ?? manifest.target ?? "local";
|
|
571
602
|
const rt = resolveTarget4(loaded.config, targetName, loaded.rootDir);
|
|
572
|
-
|
|
603
|
+
consola6.info(
|
|
573
604
|
`\u{1F4E6} Unpacking cargo "${manifest.solution}"${manifest.version ? `@${manifest.version}` : ""} \u2192 ${targetName} (${manifest.environments.map((e) => e.name).join(" \u2192 ")})`
|
|
574
605
|
);
|
|
575
606
|
if (manifest.images.included && manifest.images.tars.length) {
|
|
@@ -579,7 +610,7 @@ async function deployBundle(loaded, bundleArg, opts) {
|
|
|
579
610
|
}
|
|
580
611
|
const deployed = [];
|
|
581
612
|
for (const env of manifest.environments) {
|
|
582
|
-
|
|
613
|
+
consola6.start(`\u{1FA93} raising ${env.name}`);
|
|
583
614
|
const absArtifact = join2(dir, env.artifact.relPath);
|
|
584
615
|
for (const action of env.up) {
|
|
585
616
|
const abs = {
|
|
@@ -609,7 +640,7 @@ async function deployBundle(loaded, bundleArg, opts) {
|
|
|
609
640
|
});
|
|
610
641
|
deployed.push({ environment: env.name, deploymentId: id, ranAt, images: env.images });
|
|
611
642
|
}
|
|
612
|
-
|
|
643
|
+
consola6.success(env.name);
|
|
613
644
|
}
|
|
614
645
|
if (opts.json) {
|
|
615
646
|
emitJson({
|
|
@@ -632,7 +663,7 @@ async function deployBundle(loaded, bundleArg, opts) {
|
|
|
632
663
|
});
|
|
633
664
|
return;
|
|
634
665
|
}
|
|
635
|
-
|
|
666
|
+
consola6.success(`\u{1F6D6} Cargo "${manifest.solution}" landed on ${targetName}.`);
|
|
636
667
|
}
|
|
637
668
|
function resolveBackend(flag, fromTarget, fallback) {
|
|
638
669
|
const name = flag ?? fromTarget ?? fallback ?? "compose";
|
|
@@ -650,7 +681,7 @@ function resolvePull(flag) {
|
|
|
650
681
|
}
|
|
651
682
|
|
|
652
683
|
// src/cli.ts
|
|
653
|
-
var main =
|
|
684
|
+
var main = defineCommand8({
|
|
654
685
|
meta: {
|
|
655
686
|
name: "kaupang",
|
|
656
687
|
version: "0.1.0",
|
|
@@ -662,7 +693,8 @@ var main = defineCommand7({
|
|
|
662
693
|
build: buildCommand,
|
|
663
694
|
bundle: bundleCommand,
|
|
664
695
|
rollback: rollbackCommand,
|
|
665
|
-
run: runCommand
|
|
696
|
+
run: runCommand,
|
|
697
|
+
studio: studioCommand
|
|
666
698
|
}
|
|
667
699
|
});
|
|
668
700
|
runMain(main);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaupang/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "The kaupang CLI — the `kaupang` binary. Deploy the same definitions to Docker Compose, Swarm, or Kubernetes from one config.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Andreas Quist Batista",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"prepublishOnly": "npm run build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@kaupang/core": "^0.
|
|
32
|
+
"@kaupang/core": "^0.2.0",
|
|
33
|
+
"@kaupang/studio": "^0.2.0",
|
|
33
34
|
"citty": "0.1.6",
|
|
34
35
|
"consola": "3.4.0"
|
|
35
36
|
},
|