@memfork/cli 0.1.59 → 0.1.61
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
CHANGED
|
@@ -25,7 +25,7 @@ const { version } = createRequire(import.meta.url)("../package.json");
|
|
|
25
25
|
import { cmdInit } from "./commands/init.js";
|
|
26
26
|
import { cmdDoctor, cmdDoctorEnv } from "./commands/doctor.js";
|
|
27
27
|
import { cmdInstall } from "./commands/install.js";
|
|
28
|
-
import { cmdStatus, cmdLog, cmdRecall, cmdCommit, cmdCat, cmdMerge, cmdProposals, cmdResolverCreate, cmdPrComment, cmdUi, cmdShow, cmdDiff, cmdDelegates, cmdGrant, cmdGrantMemwal, cmdRevoke, cmdBranch, cmdCheckout, } from "./commands/ops.js";
|
|
28
|
+
import { cmdStatus, cmdLog, cmdRecall, cmdCommit, cmdCat, cmdMerge, cmdProposals, cmdResolverCreate, cmdPrComment, cmdUi, cmdShow, cmdDiff, cmdDelegates, cmdGrant, cmdGrantMemwal, cmdRevoke, cmdBranch, cmdCheckout, cmdConfigSet, cmdConfigGet, } from "./commands/ops.js";
|
|
29
29
|
import { cmdJoin } from "./commands/join.js";
|
|
30
30
|
const program = new Command();
|
|
31
31
|
program
|
|
@@ -131,6 +131,16 @@ resolverCmd
|
|
|
131
131
|
.option("-k, --k <n>", "approval threshold (default: majority)", parseInt)
|
|
132
132
|
.action(wrap((opts) => cmdResolverCreate({ jury: opts.jury, k: opts.k ?? 2 })));
|
|
133
133
|
program.addCommand(resolverCmd);
|
|
134
|
+
const configCmd = new Command("config").description("read and write local project config (.memfork/config.json)");
|
|
135
|
+
configCmd
|
|
136
|
+
.command("set <key> <value>")
|
|
137
|
+
.description("set a config value (keys: author, defaultBranch)")
|
|
138
|
+
.action(wrap((key, value) => cmdConfigSet(key, value)));
|
|
139
|
+
configCmd
|
|
140
|
+
.command("get [key]")
|
|
141
|
+
.description("print config values and their sources (omit key to print all)")
|
|
142
|
+
.action(wrap((key) => cmdConfigGet(key)));
|
|
143
|
+
program.addCommand(configCmd);
|
|
134
144
|
program
|
|
135
145
|
.command("pr-comment")
|
|
136
146
|
.description("post a MemForks decision summary to a GitHub PR")
|
package/dist/commands/ops.d.ts
CHANGED
|
@@ -89,3 +89,14 @@ export declare function cmdBranch(name: string, opts?: {
|
|
|
89
89
|
export declare function cmdCheckout(name: string, opts?: {
|
|
90
90
|
at?: string;
|
|
91
91
|
}): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* memfork config set <key> <value>
|
|
94
|
+
* Writes a value into .memfork/config.json.
|
|
95
|
+
* Settable keys: author, defaultBranch
|
|
96
|
+
*/
|
|
97
|
+
export declare function cmdConfigSet(key: string, value: string): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* memfork config get [key]
|
|
100
|
+
* Prints one config value or all of them, showing where each comes from.
|
|
101
|
+
*/
|
|
102
|
+
export declare function cmdConfigGet(key?: string): Promise<void>;
|
package/dist/commands/ops.js
CHANGED
|
@@ -797,8 +797,6 @@ function findAppDir() {
|
|
|
797
797
|
];
|
|
798
798
|
for (const c of candidates) {
|
|
799
799
|
try {
|
|
800
|
-
// Bundled path: presence of index.html is the signal (no package.json shipped).
|
|
801
|
-
// Monorepo path: package.json marks the source root.
|
|
802
800
|
if (fs.existsSync(path.join(c, "index.html")) || fs.existsSync(path.join(c, "package.json"))) {
|
|
803
801
|
return c;
|
|
804
802
|
}
|
|
@@ -809,3 +807,59 @@ function findAppDir() {
|
|
|
809
807
|
}
|
|
810
808
|
return null;
|
|
811
809
|
}
|
|
810
|
+
// ─── config ───────────────────────────────────────────────────────────────────
|
|
811
|
+
const SETTABLE_KEYS = ["author", "defaultBranch"];
|
|
812
|
+
/**
|
|
813
|
+
* memfork config set <key> <value>
|
|
814
|
+
* Writes a value into .memfork/config.json.
|
|
815
|
+
* Settable keys: author, defaultBranch
|
|
816
|
+
*/
|
|
817
|
+
export async function cmdConfigSet(key, value) {
|
|
818
|
+
if (!SETTABLE_KEYS.includes(key)) {
|
|
819
|
+
console.error(chalk.red(`Unknown config key "${key}". Settable keys: ${SETTABLE_KEYS.join(", ")}`));
|
|
820
|
+
process.exitCode = 1;
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
const existing = readProjectConfig() ?? {};
|
|
824
|
+
const updated = { ...existing, [key]: value };
|
|
825
|
+
writeProjectConfig(updated);
|
|
826
|
+
console.log(chalk.green(`✓ config.${key} = ${JSON.stringify(value)}`));
|
|
827
|
+
console.log(chalk.dim(" saved to .memfork/config.json"));
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* memfork config get [key]
|
|
831
|
+
* Prints one config value or all of them, showing where each comes from.
|
|
832
|
+
*/
|
|
833
|
+
export async function cmdConfigGet(key) {
|
|
834
|
+
const file = readProjectConfig() ?? {};
|
|
835
|
+
const env = process.env;
|
|
836
|
+
const sources = [
|
|
837
|
+
{
|
|
838
|
+
key: "author",
|
|
839
|
+
value: env["MEMFORK_AUTHOR"] ?? file.author,
|
|
840
|
+
source: env["MEMFORK_AUTHOR"]
|
|
841
|
+
? "env MEMFORK_AUTHOR"
|
|
842
|
+
: file.author
|
|
843
|
+
? ".memfork/config.json"
|
|
844
|
+
: "git config user.name (fallback)",
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
key: "defaultBranch",
|
|
848
|
+
value: env["MEMFORK_DEFAULT_BRANCH"] ?? file.defaultBranch ?? "main",
|
|
849
|
+
source: env["MEMFORK_DEFAULT_BRANCH"]
|
|
850
|
+
? "env MEMFORK_DEFAULT_BRANCH"
|
|
851
|
+
: file.defaultBranch
|
|
852
|
+
? ".memfork/config.json"
|
|
853
|
+
: "built-in default",
|
|
854
|
+
},
|
|
855
|
+
];
|
|
856
|
+
const rows = key ? sources.filter((s) => s.key === key) : sources;
|
|
857
|
+
if (key && rows.length === 0) {
|
|
858
|
+
console.error(chalk.red(`Unknown config key "${key}". Known keys: ${sources.map((s) => s.key).join(", ")}`));
|
|
859
|
+
process.exitCode = 1;
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
for (const row of rows) {
|
|
863
|
+
console.log(`${chalk.bold(row.key.padEnd(16))}${chalk.cyan(row.value ?? "(unset)")} ${chalk.dim(`← ${row.source}`)}`);
|
|
864
|
+
}
|
|
865
|
+
}
|