@deepraxis/cli 0.1.1-dev.61eb886 → 0.1.1-dev.660f2cc
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 +83 -19
- package/package.json +1 -1
package/dist/praxis.js
CHANGED
|
@@ -26104,15 +26104,31 @@ 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.", example: "praxis app create my-app" },
|
|
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.", example: "praxis app deploy --dir ./my-app" },
|
|
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.", example: "praxis app rollback --to <version_id>" },
|
|
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
|
-
|
|
26115
|
+
const width = Math.max(...mine.map((w) => w.usage.length));
|
|
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(`
|
|
26116
26132
|
`);
|
|
26117
26133
|
}
|
|
26118
26134
|
|
|
@@ -26854,6 +26870,17 @@ var templateTag = (env) => env === "develop" ? "dev" : "latest";
|
|
|
26854
26870
|
function randomSecret(bytes = 32) {
|
|
26855
26871
|
return Buffer.from(crypto.getRandomValues(new Uint8Array(bytes))).toString("base64url");
|
|
26856
26872
|
}
|
|
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
|
+
}
|
|
26857
26884
|
|
|
26858
26885
|
// src/commands/app.ts
|
|
26859
26886
|
var REGISTRY = "https://registry.npmjs.org/@deepraxis%2fapp-template";
|
|
@@ -26921,13 +26948,13 @@ async function appCreate(args, env, ports) {
|
|
|
26921
26948
|
if (code !== 0)
|
|
26922
26949
|
throw new PraxisError({ code: "INSTALL_FAILED", message: `${pm} install failed (exit ${code}); the project was created in ${dir}. Run it again there.` });
|
|
26923
26950
|
}
|
|
26951
|
+
const next_steps = nextSteps(dir, ports.has("bun"));
|
|
26924
26952
|
ports.human(`Created ${dir}
|
|
26925
26953
|
|
|
26926
26954
|
Next steps:
|
|
26927
|
-
|
|
26928
|
-
|
|
26929
|
-
|
|
26930
|
-
ports.emit({ kind: "object", data: { dir, name, template_version: version } });
|
|
26955
|
+
${next_steps.map((step) => ` ${step}`).join(`
|
|
26956
|
+
`)}`);
|
|
26957
|
+
ports.emit({ kind: "object", data: { dir, name, template_version: version, next_steps } });
|
|
26931
26958
|
}
|
|
26932
26959
|
function findProjectDir(dir, cwd) {
|
|
26933
26960
|
if (dir) {
|
|
@@ -27003,12 +27030,21 @@ async function healthCheck2(url, path, ports, timeoutMs = 60000) {
|
|
|
27003
27030
|
await ports.wait(2000);
|
|
27004
27031
|
}
|
|
27005
27032
|
}
|
|
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
|
+
}
|
|
27006
27042
|
async function appDeploy(args, client2, ports) {
|
|
27007
27043
|
const dir = findProjectDir(args.dir, ports.cwd);
|
|
27008
27044
|
const project = loadProject(dir);
|
|
27009
27045
|
if (args.build) {
|
|
27010
27046
|
const pm = ports.has("bun") ? "bun" : "npm";
|
|
27011
|
-
const code = await
|
|
27047
|
+
const code = await runBuild(pm, dir, ports);
|
|
27012
27048
|
if (code !== 0)
|
|
27013
27049
|
throw new PraxisError({ code: "BUILD_FAILED", message: `${pm} run build failed (exit ${code})` });
|
|
27014
27050
|
}
|
|
@@ -27224,6 +27260,21 @@ function plain(value) {
|
|
|
27224
27260
|
` || c === "\r" || c === "\t" ? " " : "");
|
|
27225
27261
|
}
|
|
27226
27262
|
|
|
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
|
+
|
|
27227
27278
|
// src/output/human.ts
|
|
27228
27279
|
var count3 = (n, noun) => `${n} ${noun}${n === 1 ? "" : "s"}`;
|
|
27229
27280
|
function identity(result, ctx) {
|
|
@@ -27292,7 +27343,7 @@ function table(items, ctx, paint) {
|
|
|
27292
27343
|
const text = truncate(v, sizes[i]);
|
|
27293
27344
|
let styled = header ? paint.dim(text) : text;
|
|
27294
27345
|
if (!header && ["status", "state"].includes(columns[i])) {
|
|
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;
|
|
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|deleted|purging|purged|suspended)$/i.test(v) ? paint.red : (s) => s;
|
|
27296
27347
|
styled = color(text);
|
|
27297
27348
|
}
|
|
27298
27349
|
return styled + (i === row.length - 1 ? "" : " ".repeat(Math.max(0, sizes[i] - width(text))));
|
|
@@ -27352,7 +27403,7 @@ function renderHuman(result, ctx) {
|
|
|
27352
27403
|
` : "") };
|
|
27353
27404
|
case "list":
|
|
27354
27405
|
return {
|
|
27355
|
-
stdout: result.items.length ? table(result.items, ctx, out) : out.dim(`No ${plain(resource)}${/(s|x|ch|sh)$/.test(resource) ? "es" : "s"}.`) + `
|
|
27406
|
+
stdout: result.items.length ? table(projectList(result.items, result.op), ctx, out) : out.dim(`No ${plain(resource)}${/(s|x|ch|sh)$/.test(resource) ? "es" : "s"}.`) + `
|
|
27356
27407
|
`,
|
|
27357
27408
|
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"}` : ""}`) + `
|
|
27358
27409
|
`
|
|
@@ -27424,8 +27475,8 @@ ${usage ? `usage: ${JSON.stringify(usage)}
|
|
|
27424
27475
|
return { stdout, stderr };
|
|
27425
27476
|
}
|
|
27426
27477
|
case "list": {
|
|
27427
|
-
const
|
|
27428
|
-
const lines = columns.length ? ["|" + columns.map(cell).join("|") + "|", "|" + columns.map(() => "---").join("|") + "|", ...
|
|
27478
|
+
const items = projectList(result.items, result.op), columns = columnsFor(items);
|
|
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("|") + "|")] : [];
|
|
27429
27480
|
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"}`);
|
|
27430
27481
|
return { stdout: lines.join(`
|
|
27431
27482
|
`) + `
|
|
@@ -27634,7 +27685,7 @@ function startProgress(ctx, write = (text) => writeOutput({ stderr: text })) {
|
|
|
27634
27685
|
}
|
|
27635
27686
|
|
|
27636
27687
|
// src/main.ts
|
|
27637
|
-
var version = "0.1.1-dev.
|
|
27688
|
+
var version = "0.1.1-dev.660f2cc";
|
|
27638
27689
|
var commands = commandTree(operations);
|
|
27639
27690
|
var manual = [...workflows.map((w) => w.words), [API_WORD]];
|
|
27640
27691
|
function route(argv) {
|
|
@@ -27705,13 +27756,21 @@ var defaults = {
|
|
|
27705
27756
|
child.once("error", reject);
|
|
27706
27757
|
child.once("close", (code) => resolve2(code ?? 1));
|
|
27707
27758
|
}),
|
|
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
|
+
}),
|
|
27708
27767
|
has: (bin) => spawnSync(process.platform === "win32" ? "where" : "which", [bin], { stdio: "ignore" }).status === 0,
|
|
27709
27768
|
cwd: process.cwd()
|
|
27710
27769
|
};
|
|
27711
27770
|
var appOptions = {
|
|
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" }]
|
|
27771
|
+
"app create": [{ name: "dir", type: "string", description: "Directory to create the project in (default: ./<name>)." }, { name: "template", type: "string", description: "Copy a local template directory instead of downloading the standard template." }, { name: "no-install", type: "boolean", description: "Skip installing dependencies." }],
|
|
27772
|
+
"app deploy": [{ name: "dir", type: "string", description: "Project directory (default: the nearest parent containing praxis.jsonc)." }, { name: "no-build", type: "boolean", description: "Publish the existing dist/ output without building." }],
|
|
27773
|
+
"app rollback": [{ name: "dir", type: "string", description: "Project directory (default: the nearest parent containing praxis.jsonc)." }, { name: "to", type: "string", description: "Version id to deploy (default: the previous version)." }]
|
|
27715
27774
|
};
|
|
27716
27775
|
async function main(argv, injected = {}) {
|
|
27717
27776
|
const ports = { ...defaults, ...injected };
|
|
@@ -27780,6 +27839,11 @@ async function main(argv, injected = {}) {
|
|
|
27780
27839
|
Print the AI skill or write <dir>/praxis-cli/SKILL.md.` });
|
|
27781
27840
|
return 0;
|
|
27782
27841
|
}
|
|
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
|
+
}
|
|
27783
27847
|
if (flags.help) {
|
|
27784
27848
|
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>" : ""}
|
|
27785
27849
|
${globalOptions.map((s) => "--" + s.name).join(" ")}
|
|
@@ -27906,7 +27970,7 @@ Examples:
|
|
|
27906
27970
|
emit({ kind: "object", data: await auth.switchOrganization(parsed.positional[0]) });
|
|
27907
27971
|
break;
|
|
27908
27972
|
case "app create": {
|
|
27909
|
-
const appPorts = { ...ports, emit, human: (text) => {
|
|
27973
|
+
const appPorts = { ...ports, mode: ctx.mode, emit, human: (text) => {
|
|
27910
27974
|
if (ctx.mode === "human")
|
|
27911
27975
|
emit({ kind: "message", channel: "stdout", text });
|
|
27912
27976
|
}, random: randomSecret };
|
|
@@ -27915,7 +27979,7 @@ Examples:
|
|
|
27915
27979
|
}
|
|
27916
27980
|
case "app deploy":
|
|
27917
27981
|
case "app rollback": {
|
|
27918
|
-
const appPorts = { ...ports, emit, human: () => {}, random: randomSecret };
|
|
27982
|
+
const appPorts = { ...ports, mode: ctx.mode, emit, human: () => {}, random: randomSecret };
|
|
27919
27983
|
const client2 = await auth.client(org);
|
|
27920
27984
|
const dir = parsed.flags.dir?.[0];
|
|
27921
27985
|
if (name === "app deploy")
|