@akanjs/cli 3.0.0-alpha.81 → 3.0.0-alpha.82
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/.build-stamp
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
133d9fd6deee4acd90c4506d240dc80a0ae269fc5a4e0e37b76f334390c27745
|
package/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var commandModules = {
|
|
|
24
24
|
page: async () => (await import("./page.command-x4379grq.js")).PageCommand,
|
|
25
25
|
context: async () => (await import("./context.command-dk2m2sjx.js")).ContextCommand,
|
|
26
26
|
cloud: async () => (await import("./cloud.command-wm3mtfve.js")).CloudCommand,
|
|
27
|
-
subspace: async () => (await import("./subspace.command-
|
|
27
|
+
subspace: async () => (await import("./subspace.command-nr32nm35.js")).SubspaceCommand,
|
|
28
28
|
guideline: async () => (await import("./guideline.command-w6ddv13r.js")).GuidelineCommand,
|
|
29
29
|
scalar: async () => (await import("./scalar.command-2emk89eh.js")).ScalarCommand,
|
|
30
30
|
primitive: async () => (await import("./primitive.command-8etmnqhq.js")).PrimitiveCommand,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/cli",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.82",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@langchain/openai": "^1.4.6",
|
|
34
34
|
"@tailwindcss/node": "^4.3.0",
|
|
35
35
|
"@trapezedev/project": "^7.1.4",
|
|
36
|
-
"akanjs": "3.0.0-alpha.
|
|
36
|
+
"akanjs": "3.0.0-alpha.82",
|
|
37
37
|
"chalk": "^5.6.2",
|
|
38
38
|
"commander": "^14.0.3",
|
|
39
39
|
"dayjs": "^1.11.20",
|
|
@@ -607,15 +607,44 @@ class SubspaceConfig {
|
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
// pkgs/@akanjs/cli/subspace/subspace.runner.ts
|
|
610
|
+
var loadPrompts = async () => await import("@inquirer/prompts");
|
|
611
|
+
|
|
610
612
|
class SubspaceRunner extends runner("subspace") {
|
|
611
|
-
|
|
613
|
+
static multiTargetActions = ["status", "push"];
|
|
614
|
+
async config(workspace) {
|
|
612
615
|
const config = await SubspaceConfig.from(workspace);
|
|
613
616
|
if (!config)
|
|
614
617
|
throw new Error(`No ${SubspaceConfig.fileName} at the workspace root. Declare the customer repos there first.`);
|
|
618
|
+
return config;
|
|
619
|
+
}
|
|
620
|
+
async subspaces(workspace, names) {
|
|
621
|
+
const config = await this.config(workspace);
|
|
615
622
|
const subspaces = config.select(names).map((declaration) => new Subspace(workspace, config, declaration));
|
|
616
623
|
const branch = (await workspace.spawn("git", ["rev-parse", "--abbrev-ref", "HEAD"])).trim();
|
|
617
624
|
return { config, subspaces, branch };
|
|
618
625
|
}
|
|
626
|
+
async selectNames(workspace, action) {
|
|
627
|
+
const config = await this.config(workspace);
|
|
628
|
+
const interactive = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
629
|
+
return await SubspaceRunner.chooseNames(config, action, { interactive });
|
|
630
|
+
}
|
|
631
|
+
static async chooseNames(config, action, { interactive, prompts }) {
|
|
632
|
+
const multiple = SubspaceRunner.multiTargetActions.includes(action);
|
|
633
|
+
if (!config.subspaces.length)
|
|
634
|
+
throw new Error(`${SubspaceConfig.fileName} declares no subspaces.`);
|
|
635
|
+
if (!interactive) {
|
|
636
|
+
throw new Error(multiple ? `\`akan subspace ${action}\` needs a subspace name when it cannot prompt. Pass one, or run \`akan subspace ${action}-all\` for every subspace.` : `\`akan subspace ${action}\` needs a subspace name when it cannot prompt \u2014 it is reviewed one repo at a time.`);
|
|
637
|
+
}
|
|
638
|
+
const { checkbox, select } = prompts ?? await loadPrompts();
|
|
639
|
+
const choices = config.subspaces.map((subspace) => ({
|
|
640
|
+
name: subspace.name,
|
|
641
|
+
value: subspace.name,
|
|
642
|
+
description: `${subspace.repo} \xB7 ${subspace.apps.join(", ")}`
|
|
643
|
+
}));
|
|
644
|
+
if (multiple)
|
|
645
|
+
return await checkbox({ message: `Select subspaces to ${action}`, choices, required: true });
|
|
646
|
+
return [await select({ message: `Select a subspace to ${action}`, choices })];
|
|
647
|
+
}
|
|
619
648
|
async status(workspace, names) {
|
|
620
649
|
const { subspaces, branch } = await this.subspaces(workspace, names);
|
|
621
650
|
const statuses = [];
|
|
@@ -649,6 +678,9 @@ class SubspaceRunner extends runner("subspace") {
|
|
|
649
678
|
|
|
650
679
|
// pkgs/@akanjs/cli/subspace/subspace.script.ts
|
|
651
680
|
class SubspaceScript extends script("subspace", [SubspaceRunner]) {
|
|
681
|
+
async select(workspace, action) {
|
|
682
|
+
return await this.subspaceRunner.selectNames(workspace, action);
|
|
683
|
+
}
|
|
652
684
|
async status(workspace, names, format = "text") {
|
|
653
685
|
const spinner = workspace.spinning("Checking subspaces...");
|
|
654
686
|
const statuses = await this.subspaceRunner.status(workspace, names);
|
|
@@ -683,29 +715,38 @@ class SubspaceScript extends script("subspace", [SubspaceRunner]) {
|
|
|
683
715
|
// pkgs/@akanjs/cli/subspace/subspace.command.ts
|
|
684
716
|
class SubspaceCommand extends command("subspace", [SubspaceScript], ({ public: target }) => ({
|
|
685
717
|
subspace: target({ desc: "Mirror apps and libraries between this workspace and the customer repos it serves" }).arg("action", String, {
|
|
686
|
-
desc: "subspace action",
|
|
718
|
+
desc: "subspace action; status-all and push-all take every declared subspace",
|
|
687
719
|
default: "status",
|
|
688
|
-
enum: ["status", "diff", "push", "pull"]
|
|
689
|
-
}).arg("subspace", String, {
|
|
720
|
+
enum: ["status", "status-all", "diff", "push", "push-all", "pull"]
|
|
721
|
+
}).arg("subspace", String, {
|
|
722
|
+
desc: "subspace name; asks which one(s) when omitted, and is refused by status-all / push-all",
|
|
723
|
+
nullable: true
|
|
724
|
+
}).with(Workspace).option("format", String, { desc: "output format", default: "text", enum: ["text", "json"] }).option("verify", Boolean, {
|
|
690
725
|
flag: "y",
|
|
691
726
|
desc: "run bun install + akan sync in the subspace before committing",
|
|
692
727
|
default: true
|
|
693
728
|
}).option("adoptLibs", Boolean, { desc: "pull: also apply the subspace's library edits", default: false }).option("path", String, { desc: "diff: limit to one path", nullable: true }).exec(async function(action, subspace, workspace, format, verify, adoptLibs, filePath) {
|
|
694
|
-
const names = subspace ? [subspace] : [];
|
|
695
729
|
const output = format;
|
|
696
|
-
|
|
730
|
+
const all = action === "status-all" || action === "push-all";
|
|
731
|
+
const base = all ? action.slice(0, -"-all".length) : action;
|
|
732
|
+
if (base !== "status" && base !== "diff" && base !== "push" && base !== "pull")
|
|
733
|
+
throw new Error(`Unknown subspace action: ${action}. Use status, status-all, diff, push, push-all or pull.`);
|
|
734
|
+
if (all && subspace)
|
|
735
|
+
throw new Error(`\`akan subspace ${action}\` takes no name. Run \`akan subspace ${base} ${subspace}\` instead.`);
|
|
736
|
+
const names = subspace ? [subspace] : all ? [] : await this.subspaceScript.select(workspace, base);
|
|
737
|
+
if (base === "status")
|
|
697
738
|
await this.subspaceScript.status(workspace, names, output);
|
|
698
|
-
else if (
|
|
739
|
+
else if (base === "push")
|
|
699
740
|
await this.subspaceScript.push(workspace, names, { verify, format: output });
|
|
700
|
-
else
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
741
|
+
else {
|
|
742
|
+
const [name] = names;
|
|
743
|
+
if (!name)
|
|
744
|
+
throw new Error(`\`akan subspace ${base}\` needs a name \u2014 it is reviewed one repo at a time.`);
|
|
745
|
+
if (base === "diff")
|
|
746
|
+
await this.subspaceScript.diff(workspace, name, filePath, output);
|
|
705
747
|
else
|
|
706
|
-
await this.subspaceScript.pull(workspace,
|
|
707
|
-
}
|
|
708
|
-
throw new Error(`Unknown subspace action: ${action}. Use status, diff, push or pull.`);
|
|
748
|
+
await this.subspaceScript.pull(workspace, name, { adoptLibs, format: output });
|
|
749
|
+
}
|
|
709
750
|
})
|
|
710
751
|
})) {
|
|
711
752
|
}
|