@deepraxis/cli 0.1.1-dev.378725e → 0.1.1-dev.61eb886
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/praxis.js +19 -83
- package/package.json +1 -1
package/dist/praxis.js
CHANGED
|
@@ -26104,31 +26104,15 @@ var workflows = [
|
|
|
26104
26104
|
{ words: ["whoami"], usage: "whoami", summary: "Show the signed-in identity and credential storage location." },
|
|
26105
26105
|
{ words: ["org", "list"], usage: "org list", summary: "List organizations available to the login." },
|
|
26106
26106
|
{ words: ["org", "switch"], usage: "org switch <organization_id>", summary: "Switch the login organization." },
|
|
26107
|
-
{ words: ["app", "create"], usage: "app create <name> [--dir <path>] [--template <dir>] [--no-install]", summary: "Create an application project from the standard template and install its dependencies."
|
|
26108
|
-
{ words: ["app", "deploy"], usage: "app deploy [--dir <path>] [--no-build]", summary: "Build the project, publish it, create declared secrets, run the health check and print the URL."
|
|
26109
|
-
{ words: ["app", "rollback"], usage: "app rollback [--dir <path>] [--to <version_id>]", summary: "Deploy the previous version again (or --to a given version) and wait until it is active."
|
|
26107
|
+
{ words: ["app", "create"], usage: "app create <name> [--dir <path>] [--template <dir>] [--no-install]", summary: "Create an application project from the standard template and install its dependencies." },
|
|
26108
|
+
{ words: ["app", "deploy"], usage: "app deploy [--dir <path>] [--no-build]", summary: "Build the project, publish it, create declared secrets, run the health check and print the URL." },
|
|
26109
|
+
{ words: ["app", "rollback"], usage: "app rollback [--dir <path>] [--to <version_id>]", summary: "Deploy the previous version again (or --to a given version) and wait until it is active." },
|
|
26110
26110
|
{ words: ["skill"], usage: "skill [--install <dir>]", summary: "Print the AI skill, or write <dir>/praxis-cli/SKILL.md." }
|
|
26111
26111
|
];
|
|
26112
26112
|
var workflowNouns = [...new Set(workflows.filter((w) => w.words.length > 1).map((w) => w.words[0]))];
|
|
26113
26113
|
function nounHelp(noun) {
|
|
26114
26114
|
const mine = workflows.filter((w) => w.words[0] === noun);
|
|
26115
|
-
|
|
26116
|
-
return [...mine.map((w) => ` praxis ${w.usage.padEnd(width)} ${w.summary}`), "", `Run \`praxis ${noun} <command> --help\` for a command's options.`, "", "Examples:", ...mine.map((w) => ` ${w.example ?? `praxis ${w.usage}`}`)].join(`
|
|
26117
|
-
`);
|
|
26118
|
-
}
|
|
26119
|
-
function workflowHelp(workflow, options) {
|
|
26120
|
-
return [
|
|
26121
|
-
`praxis ${workflow.usage}`,
|
|
26122
|
-
workflow.summary,
|
|
26123
|
-
"",
|
|
26124
|
-
"Options:",
|
|
26125
|
-
...[...options, ...globalOptions].map((s) => ` ${describeOption(s)}`),
|
|
26126
|
-
" -h is an alias of --help",
|
|
26127
|
-
"PRAXIS_ENV=develop|production (default: develop); no --env option.",
|
|
26128
|
-
"",
|
|
26129
|
-
"Examples:",
|
|
26130
|
-
` ${workflow.example ?? `praxis ${workflow.usage}`}`
|
|
26131
|
-
].join(`
|
|
26115
|
+
return [...mine.map((w) => `praxis ${w.usage}`), "", "Examples:", ` praxis ${mine[0].usage}`].join(`
|
|
26132
26116
|
`);
|
|
26133
26117
|
}
|
|
26134
26118
|
|
|
@@ -26870,17 +26854,6 @@ var templateTag = (env) => env === "develop" ? "dev" : "latest";
|
|
|
26870
26854
|
function randomSecret(bytes = 32) {
|
|
26871
26855
|
return Buffer.from(crypto.getRandomValues(new Uint8Array(bytes))).toString("base64url");
|
|
26872
26856
|
}
|
|
26873
|
-
function decideBuildOutput(mode) {
|
|
26874
|
-
return mode === "human" ? "stream" : "capture";
|
|
26875
|
-
}
|
|
26876
|
-
function tailLines(text, count3) {
|
|
26877
|
-
return text.replace(/\s+$/, "").split(`
|
|
26878
|
-
`).slice(-count3).join(`
|
|
26879
|
-
`);
|
|
26880
|
-
}
|
|
26881
|
-
function nextSteps(dir, bunAvailable) {
|
|
26882
|
-
return [`cd ${dir}`, bunAvailable ? "bun run dev" : "npm run dev", "praxis app deploy"];
|
|
26883
|
-
}
|
|
26884
26857
|
|
|
26885
26858
|
// src/commands/app.ts
|
|
26886
26859
|
var REGISTRY = "https://registry.npmjs.org/@deepraxis%2fapp-template";
|
|
@@ -26948,13 +26921,13 @@ async function appCreate(args, env, ports) {
|
|
|
26948
26921
|
if (code !== 0)
|
|
26949
26922
|
throw new PraxisError({ code: "INSTALL_FAILED", message: `${pm} install failed (exit ${code}); the project was created in ${dir}. Run it again there.` });
|
|
26950
26923
|
}
|
|
26951
|
-
const next_steps = nextSteps(dir, ports.has("bun"));
|
|
26952
26924
|
ports.human(`Created ${dir}
|
|
26953
26925
|
|
|
26954
26926
|
Next steps:
|
|
26955
|
-
|
|
26956
|
-
|
|
26957
|
-
|
|
26927
|
+
cd ${dir}
|
|
26928
|
+
${ports.has("bun") ? "bun run dev" : "npm run dev"}
|
|
26929
|
+
praxis app deploy`);
|
|
26930
|
+
ports.emit({ kind: "object", data: { dir, name, template_version: version } });
|
|
26958
26931
|
}
|
|
26959
26932
|
function findProjectDir(dir, cwd) {
|
|
26960
26933
|
if (dir) {
|
|
@@ -27030,21 +27003,12 @@ async function healthCheck2(url, path, ports, timeoutMs = 60000) {
|
|
|
27030
27003
|
await ports.wait(2000);
|
|
27031
27004
|
}
|
|
27032
27005
|
}
|
|
27033
|
-
async function runBuild(pm, dir, ports) {
|
|
27034
|
-
if (decideBuildOutput(ports.mode) === "stream")
|
|
27035
|
-
return ports.spawn(pm, ["run", "build"], { cwd: dir });
|
|
27036
|
-
const started = ports.now();
|
|
27037
|
-
const { code, output } = await ports.spawnCapture(pm, ["run", "build"], { cwd: dir });
|
|
27038
|
-
const text = code === 0 ? `build ok in ${Math.round((ports.now() - started) / 100) / 10}s` : tailLines(output, 60);
|
|
27039
|
-
ports.emit({ kind: "message", channel: "stderr", text });
|
|
27040
|
-
return code;
|
|
27041
|
-
}
|
|
27042
27006
|
async function appDeploy(args, client2, ports) {
|
|
27043
27007
|
const dir = findProjectDir(args.dir, ports.cwd);
|
|
27044
27008
|
const project = loadProject(dir);
|
|
27045
27009
|
if (args.build) {
|
|
27046
27010
|
const pm = ports.has("bun") ? "bun" : "npm";
|
|
27047
|
-
const code = await
|
|
27011
|
+
const code = await ports.spawn(pm, ["run", "build"], { cwd: dir });
|
|
27048
27012
|
if (code !== 0)
|
|
27049
27013
|
throw new PraxisError({ code: "BUILD_FAILED", message: `${pm} run build failed (exit ${code})` });
|
|
27050
27014
|
}
|
|
@@ -27260,21 +27224,6 @@ function plain(value) {
|
|
|
27260
27224
|
` || c === "\r" || c === "\t" ? " " : "");
|
|
27261
27225
|
}
|
|
27262
27226
|
|
|
27263
|
-
// src/output/list-columns.ts
|
|
27264
|
-
function workerStatus(item) {
|
|
27265
|
-
const row = record(item), status = record(row.praxis).status;
|
|
27266
|
-
if (typeof status !== "string")
|
|
27267
|
-
return item;
|
|
27268
|
-
return { ...row, status };
|
|
27269
|
-
}
|
|
27270
|
-
var listProjections = {
|
|
27271
|
-
"application.workers.list": workerStatus
|
|
27272
|
-
};
|
|
27273
|
-
function projectList(items, op) {
|
|
27274
|
-
const project = op ? listProjections[op] : undefined;
|
|
27275
|
-
return project ? items.map(project) : items;
|
|
27276
|
-
}
|
|
27277
|
-
|
|
27278
27227
|
// src/output/human.ts
|
|
27279
27228
|
var count3 = (n, noun) => `${n} ${noun}${n === 1 ? "" : "s"}`;
|
|
27280
27229
|
function identity(result, ctx) {
|
|
@@ -27343,7 +27292,7 @@ function table(items, ctx, paint) {
|
|
|
27343
27292
|
const text = truncate(v, sizes[i]);
|
|
27344
27293
|
let styled = header ? paint.dim(text) : text;
|
|
27345
27294
|
if (!header && ["status", "state"].includes(columns[i])) {
|
|
27346
|
-
const color = /^(running|active|ready|succeeded|completed|enabled)$/i.test(v) ? paint.green : /^(pending|queued|starting|creating|paused)$/i.test(v) ? paint.yellow : /^(failed|error|cancelled|expired|disabled
|
|
27295
|
+
const color = /^(running|active|ready|succeeded|completed|enabled)$/i.test(v) ? paint.green : /^(pending|queued|starting|creating|paused)$/i.test(v) ? paint.yellow : /^(failed|error|cancelled|expired|disabled)$/i.test(v) ? paint.red : (s) => s;
|
|
27347
27296
|
styled = color(text);
|
|
27348
27297
|
}
|
|
27349
27298
|
return styled + (i === row.length - 1 ? "" : " ".repeat(Math.max(0, sizes[i] - width(text))));
|
|
@@ -27403,7 +27352,7 @@ function renderHuman(result, ctx) {
|
|
|
27403
27352
|
` : "") };
|
|
27404
27353
|
case "list":
|
|
27405
27354
|
return {
|
|
27406
|
-
stdout: result.items.length ? table(
|
|
27355
|
+
stdout: result.items.length ? table(result.items, ctx, out) : out.dim(`No ${plain(resource)}${/(s|x|ch|sh)$/.test(resource) ? "es" : "s"}.`) + `
|
|
27407
27356
|
`,
|
|
27408
27357
|
stderr: err.dim(`${result.total !== undefined ? `${result.items.length} of ${result.total} items` : count3(result.items.length, "item")}${result.nextCursor ? ` · next: ${ctx.nextCommand ?? "praxis --help"}` : ""}`) + `
|
|
27409
27358
|
`
|
|
@@ -27475,8 +27424,8 @@ ${usage ? `usage: ${JSON.stringify(usage)}
|
|
|
27475
27424
|
return { stdout, stderr };
|
|
27476
27425
|
}
|
|
27477
27426
|
case "list": {
|
|
27478
|
-
const
|
|
27479
|
-
const lines = columns.length ? ["|" + columns.map(cell).join("|") + "|", "|" + columns.map(() => "---").join("|") + "|", ...items.map((item) => "|" + columns.map((key) => cell(timestamp(key, record(item)[key]) ?? scalar(record(item)[key]))).join("|") + "|")] : [];
|
|
27427
|
+
const columns = columnsFor(result.items);
|
|
27428
|
+
const lines = columns.length ? ["|" + columns.map(cell).join("|") + "|", "|" + columns.map(() => "---").join("|") + "|", ...result.items.map((item) => "|" + columns.map((key) => cell(timestamp(key, record(item)[key]) ?? scalar(record(item)[key]))).join("|") + "|")] : [];
|
|
27480
27429
|
lines.push(result.total !== undefined ? `${result.items.length} of ${result.total} rows; more: \`${ctx.moreCommand ?? "praxis --help"}\`` : `${result.items.length} rows; ${result.nextCursor ? `more: \`${ctx.nextCommand ?? "praxis --help"}\`` : "end"}`);
|
|
27481
27430
|
return { stdout: lines.join(`
|
|
27482
27431
|
`) + `
|
|
@@ -27685,7 +27634,7 @@ function startProgress(ctx, write = (text) => writeOutput({ stderr: text })) {
|
|
|
27685
27634
|
}
|
|
27686
27635
|
|
|
27687
27636
|
// src/main.ts
|
|
27688
|
-
var version = "0.1.1-dev.
|
|
27637
|
+
var version = "0.1.1-dev.61eb886";
|
|
27689
27638
|
var commands = commandTree(operations);
|
|
27690
27639
|
var manual = [...workflows.map((w) => w.words), [API_WORD]];
|
|
27691
27640
|
function route(argv) {
|
|
@@ -27756,21 +27705,13 @@ var defaults = {
|
|
|
27756
27705
|
child.once("error", reject);
|
|
27757
27706
|
child.once("close", (code) => resolve2(code ?? 1));
|
|
27758
27707
|
}),
|
|
27759
|
-
spawnCapture: (cmd, args, options) => new Promise((resolve2, reject) => {
|
|
27760
|
-
const child = spawn2(cmd, args, { cwd: options.cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
27761
|
-
const chunks = [];
|
|
27762
|
-
child.stdout.on("data", (c) => chunks.push(c));
|
|
27763
|
-
child.stderr.on("data", (c) => chunks.push(c));
|
|
27764
|
-
child.once("error", reject);
|
|
27765
|
-
child.once("close", (code) => resolve2({ code: code ?? 1, output: Buffer.concat(chunks).toString("utf8") }));
|
|
27766
|
-
}),
|
|
27767
27708
|
has: (bin) => spawnSync(process.platform === "win32" ? "where" : "which", [bin], { stdio: "ignore" }).status === 0,
|
|
27768
27709
|
cwd: process.cwd()
|
|
27769
27710
|
};
|
|
27770
27711
|
var appOptions = {
|
|
27771
|
-
"app create": [{ name: "dir", type: "string"
|
|
27772
|
-
"app deploy": [{ name: "dir", type: "string"
|
|
27773
|
-
"app rollback": [{ name: "dir", type: "string"
|
|
27712
|
+
"app create": [{ name: "dir", type: "string" }, { name: "template", type: "string" }, { name: "no-install", type: "boolean" }],
|
|
27713
|
+
"app deploy": [{ name: "dir", type: "string" }, { name: "no-build", type: "boolean" }],
|
|
27714
|
+
"app rollback": [{ name: "dir", type: "string" }, { name: "to", type: "string" }]
|
|
27774
27715
|
};
|
|
27775
27716
|
async function main(argv, injected = {}) {
|
|
27776
27717
|
const ports = { ...defaults, ...injected };
|
|
@@ -27839,11 +27780,6 @@ async function main(argv, injected = {}) {
|
|
|
27839
27780
|
Print the AI skill or write <dir>/praxis-cli/SKILL.md.` });
|
|
27840
27781
|
return 0;
|
|
27841
27782
|
}
|
|
27842
|
-
const workflow = workflows.find((w) => w.example && w.words.join(" ") === selected.words.join(" "));
|
|
27843
|
-
if (flags.help && workflow) {
|
|
27844
|
-
emit({ kind: "message", channel: "stdout", text: workflowHelp(workflow, appOptions[workflow.words.join(" ")] ?? []) });
|
|
27845
|
-
return 0;
|
|
27846
|
-
}
|
|
27847
27783
|
if (flags.help) {
|
|
27848
27784
|
emit({ kind: "message", channel: "stdout", text: selected.command ? help(commands, selected.words, selected.command) : `praxis ${selected.words.join(" ")}${selected.words[0] === "api" ? " <METHOD> <path> [--data JSON|@file|-]" : selected.words[1] === "switch" ? " <organization_id>" : ""}
|
|
27849
27785
|
${globalOptions.map((s) => "--" + s.name).join(" ")}
|
|
@@ -27970,7 +27906,7 @@ Examples:
|
|
|
27970
27906
|
emit({ kind: "object", data: await auth.switchOrganization(parsed.positional[0]) });
|
|
27971
27907
|
break;
|
|
27972
27908
|
case "app create": {
|
|
27973
|
-
const appPorts = { ...ports,
|
|
27909
|
+
const appPorts = { ...ports, emit, human: (text) => {
|
|
27974
27910
|
if (ctx.mode === "human")
|
|
27975
27911
|
emit({ kind: "message", channel: "stdout", text });
|
|
27976
27912
|
}, random: randomSecret };
|
|
@@ -27979,7 +27915,7 @@ Examples:
|
|
|
27979
27915
|
}
|
|
27980
27916
|
case "app deploy":
|
|
27981
27917
|
case "app rollback": {
|
|
27982
|
-
const appPorts = { ...ports,
|
|
27918
|
+
const appPorts = { ...ports, emit, human: () => {}, random: randomSecret };
|
|
27983
27919
|
const client2 = await auth.client(org);
|
|
27984
27920
|
const dir = parsed.flags.dir?.[0];
|
|
27985
27921
|
if (name === "app deploy")
|