@diafunc/cli 0.10.1 → 0.11.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/README.md +7 -3
- package/dist/bin/diafunc.js +3 -3
- package/dist/{chunk-RMW4OLRA.js → chunk-77KBGDMM.js} +2 -2
- package/dist/{chunk-XRUDG6ZY.js → chunk-GDW62ZQX.js} +542 -134
- package/dist/chunk-GDW62ZQX.js.map +1 -0
- package/dist/{chunk-4EDLP7DD.js → chunk-Q7HG2CUO.js} +2 -2
- package/dist/{chunk-4EDLP7DD.js.map → chunk-Q7HG2CUO.js.map} +1 -1
- package/dist/src/index.js +2 -2
- package/dist/update-check-ZCS3IYOZ.js +8 -0
- package/package.json +1 -1
- package/dist/chunk-XRUDG6ZY.js.map +0 -1
- package/dist/update-check-XRMWJ753.js +0 -8
- /package/dist/{chunk-RMW4OLRA.js.map → chunk-77KBGDMM.js.map} +0 -0
- /package/dist/{update-check-XRMWJ753.js.map → update-check-ZCS3IYOZ.js.map} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Q7HG2CUO.js";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
import { Command } from "commander";
|
|
7
|
-
import
|
|
7
|
+
import chalk35 from "chalk";
|
|
8
8
|
|
|
9
9
|
// src/commands/auth/login.ts
|
|
10
10
|
import chalk4 from "chalk";
|
|
@@ -812,11 +812,16 @@ function empty(noun, options) {
|
|
|
812
812
|
}
|
|
813
813
|
console.log(chalk2.dim(`No ${noun}.`));
|
|
814
814
|
}
|
|
815
|
+
function heading(text) {
|
|
816
|
+
console.log();
|
|
817
|
+
console.log(chalk2.bold(text));
|
|
818
|
+
}
|
|
815
819
|
|
|
816
820
|
// src/util/errors.ts
|
|
817
821
|
var EXIT_FAILURE = 1;
|
|
818
822
|
var EXIT_USAGE = 2;
|
|
819
823
|
var EXIT_AUTH = 3;
|
|
824
|
+
var EXIT_CANCELLED = 130;
|
|
820
825
|
var CliError = class extends Error {
|
|
821
826
|
exitCode;
|
|
822
827
|
hint;
|
|
@@ -4394,12 +4399,12 @@ Examples:
|
|
|
4394
4399
|
handleError(error);
|
|
4395
4400
|
}
|
|
4396
4401
|
});
|
|
4397
|
-
branch.command("fork").description("Fork a project").argument("<projectId>", "Source project ID").argument("<forkProjectId>", "New forked project ID").option("--
|
|
4402
|
+
branch.command("fork").description("Fork a project (source branch: the global --branch, default main)").argument("<projectId>", "Source project ID").argument("<forkProjectId>", "New forked project ID").option("--name <name>", "Forked project name").option("--description <desc>", "Forked project description", "").action(async (projectId, forkProjectId, options, cmd) => {
|
|
4398
4403
|
try {
|
|
4399
4404
|
const api = createApiClient();
|
|
4400
4405
|
await api.storage.fork({
|
|
4401
4406
|
projectId,
|
|
4402
|
-
projectBranch:
|
|
4407
|
+
projectBranch: getOverrides5(cmd).branch ?? "main",
|
|
4403
4408
|
forkProjectId,
|
|
4404
4409
|
forkProjectName: options.name ?? forkProjectId,
|
|
4405
4410
|
forkProjectDescription: options.description
|
|
@@ -5714,10 +5719,10 @@ var MarkdownRenderer = class {
|
|
|
5714
5719
|
if (this.inFence) {
|
|
5715
5720
|
return [chalk18.cyan(` ${line}`)];
|
|
5716
5721
|
}
|
|
5717
|
-
const
|
|
5718
|
-
if (
|
|
5719
|
-
const text = inline(
|
|
5720
|
-
return ["",
|
|
5722
|
+
const heading2 = line.match(/^(#{1,6})\s+(.*)$/);
|
|
5723
|
+
if (heading2) {
|
|
5724
|
+
const text = inline(heading2[2]);
|
|
5725
|
+
return ["", heading2[1].length <= 2 ? chalk18.bold.underline(text) : chalk18.bold(text)];
|
|
5721
5726
|
}
|
|
5722
5727
|
if (/^\s*([-*_])\1{2,}\s*$/.test(line)) {
|
|
5723
5728
|
return [chalk18.dim("\u2500".repeat(Math.min(this.width, 60)))];
|
|
@@ -5851,7 +5856,7 @@ var HELP = [
|
|
|
5851
5856
|
];
|
|
5852
5857
|
async function runChatRepl(options) {
|
|
5853
5858
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
5854
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
5859
|
+
const { getUpdateNotice } = await import("./update-check-ZCS3IYOZ.js");
|
|
5855
5860
|
let sessionId = options.session;
|
|
5856
5861
|
let lastReportedSession;
|
|
5857
5862
|
console.log(chalk19.bold("Diafunc chat") + chalk19.dim(" \xB7 /help for commands, /quit to exit"));
|
|
@@ -5937,6 +5942,10 @@ async function runChatRepl(options) {
|
|
|
5937
5942
|
}
|
|
5938
5943
|
}
|
|
5939
5944
|
}
|
|
5945
|
+
function chatContext(cmd) {
|
|
5946
|
+
const globals = cmd.optsWithGlobals();
|
|
5947
|
+
return { project: globals.project, branch: globals.branch ?? "main" };
|
|
5948
|
+
}
|
|
5940
5949
|
function registerChatCommands(program) {
|
|
5941
5950
|
const chat = program.command("chat").description("Ask the Diafunc assistant").addHelpText("after", `
|
|
5942
5951
|
Examples:
|
|
@@ -5944,22 +5953,24 @@ Examples:
|
|
|
5944
5953
|
$ diafunc chat --project <id> with a project in context
|
|
5945
5954
|
$ diafunc chat send "how do I add a table?" one question, one answer
|
|
5946
5955
|
`);
|
|
5947
|
-
chat.
|
|
5956
|
+
chat.command("repl", { isDefault: true }).description("Interactive chat session (the default: `diafunc chat`)").option("--session <id>", "Continue an existing session").action(async (options, cmd) => {
|
|
5948
5957
|
try {
|
|
5949
|
-
|
|
5958
|
+
const context = chatContext(cmd);
|
|
5959
|
+
await runChatRepl({ session: options.session, project: context.project, branch: context.branch });
|
|
5950
5960
|
} catch (error) {
|
|
5951
5961
|
handleError(error);
|
|
5952
5962
|
}
|
|
5953
5963
|
});
|
|
5954
|
-
chat.command("send").description("Send a chat message (blocking)
|
|
5964
|
+
chat.command("send").description("Send a chat message (blocking). Project context: the global --project and --branch").argument("<message>", "Message to send").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
|
|
5955
5965
|
try {
|
|
5956
5966
|
const outputFormat = getOutputFormat12(cmd);
|
|
5957
5967
|
const api = createApiClient();
|
|
5968
|
+
const context = chatContext(cmd);
|
|
5958
5969
|
const response = await api.language.chat({
|
|
5959
5970
|
message,
|
|
5960
5971
|
sessionId: options.session,
|
|
5961
|
-
projectId:
|
|
5962
|
-
projectBranch:
|
|
5972
|
+
projectId: context.project,
|
|
5973
|
+
projectBranch: context.branch
|
|
5963
5974
|
});
|
|
5964
5975
|
if (outputFormat === "human") {
|
|
5965
5976
|
console.log(renderMarkdown(response.content));
|
|
@@ -5974,15 +5985,16 @@ Examples:
|
|
|
5974
5985
|
handleError(error);
|
|
5975
5986
|
}
|
|
5976
5987
|
});
|
|
5977
|
-
chat.command("stream").description("Send a chat message (streaming)
|
|
5988
|
+
chat.command("stream").description("Send a chat message (streaming). Project context: the global --project and --branch").argument("<message>", "Message to send").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
|
|
5978
5989
|
try {
|
|
5979
5990
|
const outputFormat = getOutputFormat12(cmd);
|
|
5980
5991
|
const api = createApiClient();
|
|
5992
|
+
const context = chatContext(cmd);
|
|
5981
5993
|
const response = await api.language.chatStream({
|
|
5982
5994
|
message,
|
|
5983
5995
|
sessionId: options.session,
|
|
5984
|
-
projectId:
|
|
5985
|
-
projectBranch:
|
|
5996
|
+
projectId: context.project,
|
|
5997
|
+
projectBranch: context.branch
|
|
5986
5998
|
});
|
|
5987
5999
|
if (outputFormat === "json") {
|
|
5988
6000
|
const events = [];
|
|
@@ -6135,7 +6147,7 @@ function getOutputFormat13(cmd) {
|
|
|
6135
6147
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
6136
6148
|
}
|
|
6137
6149
|
function registerSearchCommands(program) {
|
|
6138
|
-
program.command("search").description("Search across every project you can see").argument("<query>", "Search query").option("--
|
|
6150
|
+
program.command("search").description("Search across every project you can see").argument("<query>", "Search query").option("--type <contentType>", "Limit to one content type, e.g. project, notebook, table, function").option("--limit <n>", "Maximum results", "20").addHelpText("after", `
|
|
6139
6151
|
Examples:
|
|
6140
6152
|
$ diafunc search "housing" everything matching, across projects
|
|
6141
6153
|
$ diafunc search "housing" --type project only projects
|
|
@@ -6147,14 +6159,14 @@ Examples:
|
|
|
6147
6159
|
const overrides = cmd.optsWithGlobals();
|
|
6148
6160
|
const config = loadConfig();
|
|
6149
6161
|
const api = createApiClient();
|
|
6150
|
-
const projectId =
|
|
6162
|
+
const projectId = overrides.project ?? config.defaults.project ?? null;
|
|
6151
6163
|
const limit = Number.parseInt(options.limit, 10);
|
|
6152
6164
|
const page = await api.index.searchPage({
|
|
6153
6165
|
query,
|
|
6154
6166
|
limit: Number.isFinite(limit) && limit > 0 ? limit : 20,
|
|
6155
6167
|
contentType: options.type ?? null,
|
|
6156
6168
|
projectId,
|
|
6157
|
-
projectBranch: projectId ?
|
|
6169
|
+
projectBranch: projectId ? overrides.branch ?? config.defaults.branch ?? "main" : null
|
|
6158
6170
|
});
|
|
6159
6171
|
const items = dedupe(page.items);
|
|
6160
6172
|
if (items.length === 0) {
|
|
@@ -6359,12 +6371,13 @@ function registerAdminCommands(program) {
|
|
|
6359
6371
|
handleError(error);
|
|
6360
6372
|
}
|
|
6361
6373
|
});
|
|
6362
|
-
admin.command("index-rebuild").description("Rebuild all search indexes (or a specific project with --project)").
|
|
6374
|
+
admin.command("index-rebuild").description("Rebuild all search indexes (or a specific project with the global --project)").action(async (_options, cmd) => {
|
|
6363
6375
|
try {
|
|
6364
6376
|
const api = createApiClient();
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6377
|
+
const { project } = cmd.optsWithGlobals();
|
|
6378
|
+
if (project) {
|
|
6379
|
+
await api.index.rebuildProject(project);
|
|
6380
|
+
success(`Index rebuild initiated for project "${project}".`);
|
|
6368
6381
|
} else {
|
|
6369
6382
|
await api.index.rebuildAll();
|
|
6370
6383
|
success("Index rebuild initiated for all projects.");
|
|
@@ -6614,7 +6627,7 @@ Examples:
|
|
|
6614
6627
|
}
|
|
6615
6628
|
|
|
6616
6629
|
// src/commands/analyze/index.ts
|
|
6617
|
-
import
|
|
6630
|
+
import chalk26 from "chalk";
|
|
6618
6631
|
import * as fs8 from "fs";
|
|
6619
6632
|
import * as path7 from "path";
|
|
6620
6633
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -6705,8 +6718,283 @@ function estimateRemaining(fraction, elapsedMs) {
|
|
|
6705
6718
|
return remaining > 0 ? remaining : null;
|
|
6706
6719
|
}
|
|
6707
6720
|
|
|
6721
|
+
// src/commands/analyze/wizard.ts
|
|
6722
|
+
import chalk25 from "chalk";
|
|
6723
|
+
var DEPTH_PRESETS = [
|
|
6724
|
+
{ name: "Express", hours: "1", budget: "500" },
|
|
6725
|
+
{ name: "Quick", hours: "2", budget: "2000" },
|
|
6726
|
+
{ name: "Standard", hours: "4", budget: "10000" },
|
|
6727
|
+
{ name: "Thorough", hours: "8", budget: "40000" },
|
|
6728
|
+
{ name: "Deep", hours: "24", budget: "150000" }
|
|
6729
|
+
];
|
|
6730
|
+
var DEFAULT_HOURS = "4";
|
|
6731
|
+
var DEFAULT_BUDGET = "10000";
|
|
6732
|
+
var PromptCancelled = class extends Error {
|
|
6733
|
+
constructor() {
|
|
6734
|
+
super("Cancelled.");
|
|
6735
|
+
this.name = "PromptCancelled";
|
|
6736
|
+
}
|
|
6737
|
+
};
|
|
6738
|
+
function createInquirerPrompter() {
|
|
6739
|
+
const load = () => import("@inquirer/prompts");
|
|
6740
|
+
const guard = async (work) => {
|
|
6741
|
+
try {
|
|
6742
|
+
return await work();
|
|
6743
|
+
} catch (error) {
|
|
6744
|
+
if (error instanceof Error && error.name === "ExitPromptError") throw new PromptCancelled();
|
|
6745
|
+
throw error;
|
|
6746
|
+
}
|
|
6747
|
+
};
|
|
6748
|
+
return {
|
|
6749
|
+
async input(options) {
|
|
6750
|
+
const { input } = await load();
|
|
6751
|
+
return guard(() => input(options));
|
|
6752
|
+
},
|
|
6753
|
+
async select(options) {
|
|
6754
|
+
const { select } = await load();
|
|
6755
|
+
return guard(() => select(options));
|
|
6756
|
+
},
|
|
6757
|
+
async checkbox(options) {
|
|
6758
|
+
const { checkbox } = await load();
|
|
6759
|
+
return guard(() => checkbox(options));
|
|
6760
|
+
},
|
|
6761
|
+
async confirm(options) {
|
|
6762
|
+
const { confirm } = await load();
|
|
6763
|
+
return guard(() => confirm(options));
|
|
6764
|
+
}
|
|
6765
|
+
};
|
|
6766
|
+
}
|
|
6767
|
+
function canPrompt(outputFormat, noInteractive) {
|
|
6768
|
+
if (noInteractive) return false;
|
|
6769
|
+
if (outputFormat !== "human") return false;
|
|
6770
|
+
return Boolean(process.stdin.isTTY) && isInteractive();
|
|
6771
|
+
}
|
|
6772
|
+
function whyNoPrompt(outputFormat, noInteractive) {
|
|
6773
|
+
if (noInteractive) return "--no-interactive is set";
|
|
6774
|
+
if (outputFormat !== "human") return `--output ${outputFormat} does not prompt`;
|
|
6775
|
+
return "there is no terminal to ask";
|
|
6776
|
+
}
|
|
6777
|
+
async function promptCreationFields(prompter, supplied, fallbackName) {
|
|
6778
|
+
const name = supplied.name ?? await prompter.input({
|
|
6779
|
+
message: "Analysis name",
|
|
6780
|
+
default: fallbackName,
|
|
6781
|
+
validate: (value) => value.trim().length > 0 || "A name is required."
|
|
6782
|
+
});
|
|
6783
|
+
const description = supplied.description ?? await prompter.input({
|
|
6784
|
+
message: "Description (optional)"
|
|
6785
|
+
});
|
|
6786
|
+
const visibility = supplied.visibility ?? await prompter.select({
|
|
6787
|
+
message: "Visibility",
|
|
6788
|
+
default: "PRIVATE",
|
|
6789
|
+
choices: [
|
|
6790
|
+
{ name: "Private", value: "PRIVATE", description: "Only you can open the analysis." },
|
|
6791
|
+
{ name: "Public", value: "PUBLIC", description: "Anyone with the link can read the notebook." }
|
|
6792
|
+
]
|
|
6793
|
+
});
|
|
6794
|
+
return { name: name.trim(), description: description.trim() || null, visibility };
|
|
6795
|
+
}
|
|
6796
|
+
function matchDepthPreset(hours, budget) {
|
|
6797
|
+
if (!hours || !budget) return null;
|
|
6798
|
+
return DEPTH_PRESETS.find((p) => p.hours === hours && p.budget === budget) ?? null;
|
|
6799
|
+
}
|
|
6800
|
+
function defaultTargets(columns) {
|
|
6801
|
+
const named = columns.filter((c) => c.name && c.name.length > 0);
|
|
6802
|
+
return named.length > 0 ? [named[named.length - 1].name] : [];
|
|
6803
|
+
}
|
|
6804
|
+
function positiveNumber(label) {
|
|
6805
|
+
return (value) => {
|
|
6806
|
+
const parsed = Number(value.trim());
|
|
6807
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return `${label} must be a positive number.`;
|
|
6808
|
+
return true;
|
|
6809
|
+
};
|
|
6810
|
+
}
|
|
6811
|
+
async function promptRunFields(prompter, options) {
|
|
6812
|
+
const { columns } = options;
|
|
6813
|
+
const named = columns.filter((c) => c.name && c.name.length > 0);
|
|
6814
|
+
let supplied = { ...options.supplied };
|
|
6815
|
+
const nothingSupplied = supplied.targets === void 0 && supplied.segment === void 0 && supplied.questions === void 0 && supplied.hours === void 0 && supplied.budget === void 0;
|
|
6816
|
+
if (options.presets.length > 0 && nothingSupplied) {
|
|
6817
|
+
const preset = await prompter.select({
|
|
6818
|
+
message: "Start from a saved preset?",
|
|
6819
|
+
default: null,
|
|
6820
|
+
choices: [
|
|
6821
|
+
{ name: "No, set it up now", value: null },
|
|
6822
|
+
...options.presets.map((p) => ({
|
|
6823
|
+
name: p.name,
|
|
6824
|
+
value: p,
|
|
6825
|
+
description: describePreset(p)
|
|
6826
|
+
}))
|
|
6827
|
+
]
|
|
6828
|
+
});
|
|
6829
|
+
if (preset) {
|
|
6830
|
+
supplied = {
|
|
6831
|
+
targets: preset.targetKeys.length > 0 ? preset.targetKeys : void 0,
|
|
6832
|
+
questions: preset.questions.length > 0 ? preset.questions : void 0,
|
|
6833
|
+
segment: preset.segmentKey ?? void 0,
|
|
6834
|
+
hours: preset.time || void 0,
|
|
6835
|
+
budget: preset.budget || void 0
|
|
6836
|
+
};
|
|
6837
|
+
}
|
|
6838
|
+
}
|
|
6839
|
+
let targets = supplied.targets ?? null;
|
|
6840
|
+
if (targets === null || targets.length === 0) {
|
|
6841
|
+
if (named.length > 0) {
|
|
6842
|
+
const preselected = new Set(defaultTargets(named));
|
|
6843
|
+
targets = await prompter.checkbox({
|
|
6844
|
+
message: "Target variables: what should the analysis predict?",
|
|
6845
|
+
choices: named.map((c) => ({
|
|
6846
|
+
name: c.valueType ? `${c.name} ${chalk25.dim(`(${c.valueType})`)}` : c.name,
|
|
6847
|
+
value: c.name,
|
|
6848
|
+
checked: preselected.has(c.name)
|
|
6849
|
+
})),
|
|
6850
|
+
validate: (chosen) => chosen.length > 0 || "Pick at least one target column."
|
|
6851
|
+
});
|
|
6852
|
+
} else {
|
|
6853
|
+
const typed = await prompter.input({
|
|
6854
|
+
message: "Target column names (comma-separated)",
|
|
6855
|
+
validate: (value) => splitCsv(value).length > 0 || "Name at least one target column."
|
|
6856
|
+
});
|
|
6857
|
+
targets = splitCsv(typed);
|
|
6858
|
+
}
|
|
6859
|
+
}
|
|
6860
|
+
const remaining = named.filter((c) => !targets.includes(c.name));
|
|
6861
|
+
let segment = supplied.segment ?? null;
|
|
6862
|
+
if (supplied.segment === void 0 && remaining.length > 0) {
|
|
6863
|
+
segment = await prompter.select({
|
|
6864
|
+
message: "Segment the analysis by a column? (optional)",
|
|
6865
|
+
default: null,
|
|
6866
|
+
choices: [
|
|
6867
|
+
{ name: "No segmentation", value: null },
|
|
6868
|
+
...remaining.map((c) => ({
|
|
6869
|
+
name: c.valueType ? `${c.name} ${chalk25.dim(`(${c.valueType})`)}` : c.name,
|
|
6870
|
+
value: c.name
|
|
6871
|
+
}))
|
|
6872
|
+
]
|
|
6873
|
+
});
|
|
6874
|
+
}
|
|
6875
|
+
let questions = supplied.questions ?? null;
|
|
6876
|
+
if (supplied.questions === void 0) {
|
|
6877
|
+
const wanted = await prompter.confirm({
|
|
6878
|
+
message: "Add questions for the analysis to answer? (optional)",
|
|
6879
|
+
default: false
|
|
6880
|
+
});
|
|
6881
|
+
if (wanted) {
|
|
6882
|
+
const collected = [];
|
|
6883
|
+
for (; ; ) {
|
|
6884
|
+
const question = await prompter.input({
|
|
6885
|
+
message: collected.length === 0 ? "Question" : "Another question (blank to finish)"
|
|
6886
|
+
});
|
|
6887
|
+
const trimmed = question.trim();
|
|
6888
|
+
if (trimmed.length === 0) break;
|
|
6889
|
+
collected.push(trimmed);
|
|
6890
|
+
}
|
|
6891
|
+
questions = collected.length > 0 ? collected : null;
|
|
6892
|
+
}
|
|
6893
|
+
}
|
|
6894
|
+
let hours = supplied.hours;
|
|
6895
|
+
let budget = supplied.budget;
|
|
6896
|
+
if (hours === void 0 && budget === void 0) {
|
|
6897
|
+
const chosen = await prompter.select({
|
|
6898
|
+
message: "Depth: how long may the search run, and what may it spend?",
|
|
6899
|
+
default: DEPTH_PRESETS.find((p) => p.name === "Standard") ?? null,
|
|
6900
|
+
choices: [
|
|
6901
|
+
...DEPTH_PRESETS.map((p) => ({
|
|
6902
|
+
name: p.name,
|
|
6903
|
+
value: p,
|
|
6904
|
+
description: `${p.hours}h \xB7 ${p.budget} credits`
|
|
6905
|
+
})),
|
|
6906
|
+
{ name: "Set your own", value: null }
|
|
6907
|
+
]
|
|
6908
|
+
});
|
|
6909
|
+
if (chosen) {
|
|
6910
|
+
hours = chosen.hours;
|
|
6911
|
+
budget = chosen.budget;
|
|
6912
|
+
}
|
|
6913
|
+
}
|
|
6914
|
+
if (hours === void 0) {
|
|
6915
|
+
hours = await prompter.input({
|
|
6916
|
+
message: "Computation time in hours",
|
|
6917
|
+
default: DEFAULT_HOURS,
|
|
6918
|
+
validate: positiveNumber("Computation time")
|
|
6919
|
+
});
|
|
6920
|
+
}
|
|
6921
|
+
if (budget === void 0) {
|
|
6922
|
+
budget = await prompter.input({
|
|
6923
|
+
message: "Credit budget",
|
|
6924
|
+
default: DEFAULT_BUDGET,
|
|
6925
|
+
validate: positiveNumber("Credit budget")
|
|
6926
|
+
});
|
|
6927
|
+
}
|
|
6928
|
+
return {
|
|
6929
|
+
targets: targets ?? [],
|
|
6930
|
+
segment,
|
|
6931
|
+
questions,
|
|
6932
|
+
hours: hours.trim(),
|
|
6933
|
+
budget: budget.trim()
|
|
6934
|
+
};
|
|
6935
|
+
}
|
|
6936
|
+
function describePreset(preset) {
|
|
6937
|
+
const parts = [`${preset.time || DEFAULT_HOURS}h`, `${preset.budget || DEFAULT_BUDGET} credits`];
|
|
6938
|
+
if (preset.targetKeys.length > 0) parts.push(`targets: ${preset.targetKeys.join(", ")}`);
|
|
6939
|
+
if (preset.segmentKey) parts.push(`segmented by ${preset.segmentKey}`);
|
|
6940
|
+
return parts.join(" \xB7 ");
|
|
6941
|
+
}
|
|
6942
|
+
function summaryLines(creation, run) {
|
|
6943
|
+
const lines = [
|
|
6944
|
+
`Name: ${creation.name}`,
|
|
6945
|
+
`Visibility: ${creation.visibility === "PUBLIC" ? "Public" : "Private"}`,
|
|
6946
|
+
`Targets: ${run.targets.join(", ")}`
|
|
6947
|
+
];
|
|
6948
|
+
if (run.segment) lines.push(`Segment: ${run.segment}`);
|
|
6949
|
+
if (run.questions && run.questions.length > 0) {
|
|
6950
|
+
lines.push(`Questions: ${run.questions.length}`);
|
|
6951
|
+
}
|
|
6952
|
+
const depth = matchDepthPreset(run.hours, run.budget);
|
|
6953
|
+
const named = depth ? `${depth.name}, ` : "";
|
|
6954
|
+
lines.push(`Depth: ${named}${run.hours}h \xB7 ${run.budget} credits`);
|
|
6955
|
+
return lines;
|
|
6956
|
+
}
|
|
6957
|
+
function splitCsv(value) {
|
|
6958
|
+
return value.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
6959
|
+
}
|
|
6960
|
+
function missingRunFields(recipe) {
|
|
6961
|
+
const missing = [];
|
|
6962
|
+
if (!recipe.hours || recipe.hours.trim().length === 0) missing.push("hours");
|
|
6963
|
+
if (!recipe.budget || recipe.budget.trim().length === 0) missing.push("budget");
|
|
6964
|
+
if (!recipe.targets || recipe.targets.length === 0) missing.push("targets");
|
|
6965
|
+
return missing;
|
|
6966
|
+
}
|
|
6967
|
+
function suppliedFromAnalysis(analysis) {
|
|
6968
|
+
return {
|
|
6969
|
+
targets: analysis.targets && analysis.targets.length > 0 ? analysis.targets : void 0,
|
|
6970
|
+
hours: analysis.hours?.trim() ? analysis.hours : void 0,
|
|
6971
|
+
budget: analysis.budget?.trim() ? analysis.budget : void 0,
|
|
6972
|
+
segment: analysis.segment ?? null,
|
|
6973
|
+
questions: analysis.questions ?? null
|
|
6974
|
+
};
|
|
6975
|
+
}
|
|
6976
|
+
var FIELD_COMMANDS = {
|
|
6977
|
+
hours: "hours <id> <hours>",
|
|
6978
|
+
budget: "budget <id> <credits>",
|
|
6979
|
+
targets: "targets <id> <csv>"
|
|
6980
|
+
};
|
|
6981
|
+
function explainMissingRunFields(analysisId, missing, reason) {
|
|
6982
|
+
const commands = missing.map((f) => `'diafunc analyze ${FIELD_COMMANDS[f].replace("<id>", analysisId)}'`);
|
|
6983
|
+
const columns = missing.includes("targets") ? ` Column names: 'diafunc analyze columns ${analysisId}'.` : "";
|
|
6984
|
+
return {
|
|
6985
|
+
message: `Analysis ${analysisId} cannot run yet: it has no ${joinList(missing)}, and ${reason}.`,
|
|
6986
|
+
suggestion: `Set ${missing.length === 1 ? "it" : "them"} with ${commands.join(", ")}, then rerun.${columns}`
|
|
6987
|
+
};
|
|
6988
|
+
}
|
|
6989
|
+
function joinList(items) {
|
|
6990
|
+
if (items.length <= 1) return items.join("");
|
|
6991
|
+
return `${items.slice(0, -1).join(", ")} or ${items[items.length - 1]}`;
|
|
6992
|
+
}
|
|
6993
|
+
|
|
6708
6994
|
// src/commands/analyze/index.ts
|
|
6709
6995
|
var POLL_INTERVAL_MS = 2e3;
|
|
6996
|
+
var COLUMN_READ_ATTEMPTS = 3;
|
|
6997
|
+
var COLUMN_READ_INTERVAL_MS = 1e3;
|
|
6710
6998
|
function openUrl(url) {
|
|
6711
6999
|
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
6712
7000
|
const args = process.platform === "win32" ? ["/c", "start", '""', url] : [url];
|
|
@@ -6738,17 +7026,27 @@ function multipartFromFile(file) {
|
|
|
6738
7026
|
formData.append("content", blob, path7.basename(file));
|
|
6739
7027
|
return formData;
|
|
6740
7028
|
}
|
|
7029
|
+
function reportCommandError(error) {
|
|
7030
|
+
if (error instanceof PromptCancelled) {
|
|
7031
|
+
console.log();
|
|
7032
|
+
console.log(chalk26.dim("Cancelled."));
|
|
7033
|
+
process.exit(EXIT_CANCELLED);
|
|
7034
|
+
}
|
|
7035
|
+
handleError(error);
|
|
7036
|
+
}
|
|
6741
7037
|
async function runAnalysis(file, options, cmd) {
|
|
6742
7038
|
if (!fs8.existsSync(file)) {
|
|
6743
7039
|
failure(`File not found: ${file}`);
|
|
6744
|
-
process.exit(
|
|
7040
|
+
process.exit(EXIT_FAILURE);
|
|
6745
7041
|
}
|
|
7042
|
+
const outputFormat = getOutputFormat15(cmd);
|
|
7043
|
+
const interactive = canPrompt(outputFormat, options.interactive === false);
|
|
7044
|
+
const api = createApiClient();
|
|
6746
7045
|
if (options.preset) {
|
|
6747
|
-
const
|
|
6748
|
-
const opt = await api2.analysis.getPreset(options.preset);
|
|
7046
|
+
const opt = await api.analysis.getPreset(options.preset);
|
|
6749
7047
|
if (!opt.preset) {
|
|
6750
7048
|
failure(`Preset not found: ${options.preset}`);
|
|
6751
|
-
process.exit(
|
|
7049
|
+
process.exit(EXIT_FAILURE);
|
|
6752
7050
|
}
|
|
6753
7051
|
const p = opt.preset;
|
|
6754
7052
|
if (options.targets === void 0 && p.targetKeys.length > 0) options.targets = p.targetKeys.join(",");
|
|
@@ -6757,33 +7055,105 @@ async function runAnalysis(file, options, cmd) {
|
|
|
6757
7055
|
if (options.hours === void 0) options.hours = p.time;
|
|
6758
7056
|
if (options.budget === void 0) options.budget = p.budget;
|
|
6759
7057
|
}
|
|
6760
|
-
const
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
7058
|
+
const flagTargets = parseCsv(options.targets);
|
|
7059
|
+
if (!interactive && (flagTargets === null || flagTargets.length === 0)) {
|
|
7060
|
+
usageError(
|
|
7061
|
+
`Target columns are required, and ${whyNoPrompt(outputFormat, options.interactive === false)}.`,
|
|
7062
|
+
`Pass --targets <csv> or --preset <id>. The names are the column headers of ${path7.basename(file)}.`
|
|
7063
|
+
);
|
|
7064
|
+
}
|
|
7065
|
+
const prompter = createInquirerPrompter();
|
|
7066
|
+
const fallbackName = path7.basename(file, path7.extname(file));
|
|
7067
|
+
const creation = interactive ? await promptCreationFields(prompter, {
|
|
7068
|
+
name: options.name,
|
|
7069
|
+
description: options.description,
|
|
7070
|
+
visibility: options.visibility === void 0 ? void 0 : parseVisibility(options.visibility)
|
|
7071
|
+
}, fallbackName) : {
|
|
7072
|
+
name: options.name ?? fallbackName,
|
|
7073
|
+
description: options.description?.trim() || null,
|
|
7074
|
+
visibility: options.visibility === void 0 ? "PRIVATE" : parseVisibility(options.visibility)
|
|
7075
|
+
};
|
|
6765
7076
|
const request = {
|
|
6766
|
-
name,
|
|
6767
|
-
description:
|
|
6768
|
-
visibility,
|
|
7077
|
+
name: creation.name,
|
|
7078
|
+
description: creation.description,
|
|
7079
|
+
visibility: creation.visibility,
|
|
6769
7080
|
introduction: options.introduction ?? null,
|
|
6770
|
-
hours,
|
|
6771
|
-
budget,
|
|
6772
|
-
targets:
|
|
7081
|
+
hours: options.hours ?? DEFAULT_HOURS,
|
|
7082
|
+
budget: options.budget ?? DEFAULT_BUDGET,
|
|
7083
|
+
targets: flagTargets,
|
|
6773
7084
|
questions: parseCsv(options.questions),
|
|
6774
7085
|
segment: options.segment ?? null
|
|
6775
7086
|
};
|
|
6776
|
-
const created = await withStatus(`Creating analysis "${name}"`, () => api.analysis.create(request));
|
|
6777
|
-
|
|
7087
|
+
const created = await withStatus(`Creating analysis "${creation.name}"`, () => api.analysis.create(request));
|
|
7088
|
+
detail(`analysisId: ${created.analysisId}`);
|
|
6778
7089
|
await withStatus(
|
|
6779
7090
|
`Uploading ${path7.basename(file)}`,
|
|
6780
7091
|
() => api.analysis.uploadDataMultipart(created.analysisId, multipartFromFile(file))
|
|
6781
7092
|
);
|
|
7093
|
+
if (interactive) {
|
|
7094
|
+
const configured = await configureInteractively(api, prompter, created.analysisId, request, {
|
|
7095
|
+
targets: options.targets === void 0 ? void 0 : parseCsv(options.targets),
|
|
7096
|
+
segment: options.segment,
|
|
7097
|
+
questions: options.questions === void 0 ? void 0 : parseCsv(options.questions),
|
|
7098
|
+
hours: options.hours,
|
|
7099
|
+
budget: options.budget
|
|
7100
|
+
});
|
|
7101
|
+
if (!configured) return;
|
|
7102
|
+
}
|
|
6782
7103
|
const run = await withStatus("Queuing analysis run", () => api.analysis.runAnalysis(created.analysisId));
|
|
6783
|
-
|
|
7104
|
+
detail(`runId: ${run.runId}`);
|
|
6784
7105
|
console.log();
|
|
6785
7106
|
await monitorRun(api, created.analysisId, run.runId, cmd);
|
|
6786
7107
|
}
|
|
7108
|
+
async function configureInteractively(api, prompter, analysisId, recipe, supplied) {
|
|
7109
|
+
const columns = await readColumns(api, analysisId);
|
|
7110
|
+
const presets = await readPresets(api);
|
|
7111
|
+
console.log();
|
|
7112
|
+
const answers = await promptRunFields(prompter, { columns, presets, supplied });
|
|
7113
|
+
console.log();
|
|
7114
|
+
await withStatus("Saving the analysis settings", () => api.analysis.update(analysisId, {
|
|
7115
|
+
...recipe,
|
|
7116
|
+
targets: answers.targets,
|
|
7117
|
+
questions: answers.questions,
|
|
7118
|
+
segment: answers.segment,
|
|
7119
|
+
hours: answers.hours,
|
|
7120
|
+
budget: answers.budget
|
|
7121
|
+
}));
|
|
7122
|
+
console.log();
|
|
7123
|
+
heading("Ready to run");
|
|
7124
|
+
const identity = {
|
|
7125
|
+
name: recipe.name,
|
|
7126
|
+
description: recipe.description ?? null,
|
|
7127
|
+
visibility: recipe.visibility ?? "PRIVATE"
|
|
7128
|
+
};
|
|
7129
|
+
for (const line of summaryLines(identity, answers)) detail(line);
|
|
7130
|
+
console.log();
|
|
7131
|
+
if (!await prompter.confirm({ message: "Start the analysis?", default: true })) {
|
|
7132
|
+
warn("Not started. The analysis and these settings are saved.");
|
|
7133
|
+
hint(`Start it later with 'diafunc analyze rerun ${analysisId}'.`);
|
|
7134
|
+
return false;
|
|
7135
|
+
}
|
|
7136
|
+
return true;
|
|
7137
|
+
}
|
|
7138
|
+
async function readColumns(api, analysisId) {
|
|
7139
|
+
for (let attempt = 0; attempt < COLUMN_READ_ATTEMPTS; attempt++) {
|
|
7140
|
+
if (attempt > 0) await new Promise((resolve) => setTimeout(resolve, COLUMN_READ_INTERVAL_MS));
|
|
7141
|
+
try {
|
|
7142
|
+
const columns = await api.analysis.getColumns(analysisId);
|
|
7143
|
+
if (columns.length > 0) return columns;
|
|
7144
|
+
} catch {
|
|
7145
|
+
}
|
|
7146
|
+
}
|
|
7147
|
+
warn("Could not read the column names from the uploaded file.");
|
|
7148
|
+
return [];
|
|
7149
|
+
}
|
|
7150
|
+
async function readPresets(api) {
|
|
7151
|
+
try {
|
|
7152
|
+
return await api.analysis.getPresets();
|
|
7153
|
+
} catch {
|
|
7154
|
+
return [];
|
|
7155
|
+
}
|
|
7156
|
+
}
|
|
6787
7157
|
async function monitorRun(api, analysisId, runId, cmd) {
|
|
6788
7158
|
const config = loadConfig();
|
|
6789
7159
|
const outputFormat = getOutputFormat15(cmd);
|
|
@@ -6974,13 +7344,51 @@ async function watchAnalysis(analysisId, cmd) {
|
|
|
6974
7344
|
console.log(`Watching run ${latest.runId} for analysis ${recipe.analysisId} ...`);
|
|
6975
7345
|
await monitorRun(api, recipe.analysisId, latest.runId, cmd);
|
|
6976
7346
|
}
|
|
6977
|
-
async function rerunAnalysis(analysisId) {
|
|
7347
|
+
async function rerunAnalysis(analysisId, options, cmd) {
|
|
6978
7348
|
const api = createApiClient();
|
|
7349
|
+
const found = await api.analysis.get(analysisId);
|
|
7350
|
+
if (!found.analysis) {
|
|
7351
|
+
failure(`Analysis not found: ${analysisId}`);
|
|
7352
|
+
process.exit(EXIT_FAILURE);
|
|
7353
|
+
}
|
|
7354
|
+
const analysis = found.analysis;
|
|
7355
|
+
const missing = missingRunFields(analysis);
|
|
7356
|
+
if (missing.length > 0) {
|
|
7357
|
+
const outputFormat = getOutputFormat15(cmd);
|
|
7358
|
+
const noInteractive = options.interactive === false;
|
|
7359
|
+
if (!canPrompt(outputFormat, noInteractive)) {
|
|
7360
|
+
const { message, suggestion } = explainMissingRunFields(
|
|
7361
|
+
analysisId,
|
|
7362
|
+
missing,
|
|
7363
|
+
whyNoPrompt(outputFormat, noInteractive)
|
|
7364
|
+
);
|
|
7365
|
+
usageError(message, suggestion);
|
|
7366
|
+
}
|
|
7367
|
+
const recipe = {
|
|
7368
|
+
name: analysis.name,
|
|
7369
|
+
description: analysis.description,
|
|
7370
|
+
visibility: analysis.visibility,
|
|
7371
|
+
introduction: analysis.introduction,
|
|
7372
|
+
hours: analysis.hours,
|
|
7373
|
+
budget: analysis.budget,
|
|
7374
|
+
targets: analysis.targets,
|
|
7375
|
+
questions: analysis.questions,
|
|
7376
|
+
segment: analysis.segment
|
|
7377
|
+
};
|
|
7378
|
+
const configured = await configureInteractively(
|
|
7379
|
+
api,
|
|
7380
|
+
createInquirerPrompter(),
|
|
7381
|
+
analysisId,
|
|
7382
|
+
recipe,
|
|
7383
|
+
suppliedFromAnalysis(analysis)
|
|
7384
|
+
);
|
|
7385
|
+
if (!configured) return;
|
|
7386
|
+
}
|
|
6979
7387
|
const run = await api.analysis.runAnalysis(analysisId);
|
|
6980
7388
|
success(`Queued new run ${run.runId} for analysis ${analysisId}`);
|
|
6981
|
-
console.log(
|
|
7389
|
+
console.log(chalk26.dim(` State: ${run.state}`));
|
|
6982
7390
|
console.log();
|
|
6983
|
-
console.log(
|
|
7391
|
+
console.log(chalk26.dim("Track progress: diafunc analyze watch " + analysisId));
|
|
6984
7392
|
}
|
|
6985
7393
|
async function openAnalysis(analysisId) {
|
|
6986
7394
|
const api = createApiClient();
|
|
@@ -6997,7 +7405,7 @@ async function openAnalysis(analysisId) {
|
|
|
6997
7405
|
console.log(`Opening ${url} ...`);
|
|
6998
7406
|
openUrl(url);
|
|
6999
7407
|
} catch {
|
|
7000
|
-
console.log(
|
|
7408
|
+
console.log(chalk26.dim("Notebook not yet provisioned \u2014 run the analysis first."));
|
|
7001
7409
|
}
|
|
7002
7410
|
}
|
|
7003
7411
|
async function createRecipe(options, cmd) {
|
|
@@ -7121,7 +7529,7 @@ async function getPreset(presetId, cmd) {
|
|
|
7121
7529
|
const api = createApiClient();
|
|
7122
7530
|
const opt = await api.analysis.getPreset(presetId);
|
|
7123
7531
|
if (!opt.preset) {
|
|
7124
|
-
console.log(
|
|
7532
|
+
console.log(chalk26.dim("Preset not found."));
|
|
7125
7533
|
return;
|
|
7126
7534
|
}
|
|
7127
7535
|
format(opt.preset, { format: outputFormat });
|
|
@@ -7204,7 +7612,7 @@ async function updateTriggerCmd(triggerId, options, cmd) {
|
|
|
7204
7612
|
}
|
|
7205
7613
|
function registerAnalyzeCommand(program) {
|
|
7206
7614
|
const analyze = program.command("analyze").description("Run and manage automatic analyses");
|
|
7207
|
-
analyze.argument("[file]", "CSV or Excel file to analyze").option("--name <name>", "Analysis name (derived from filename
|
|
7615
|
+
analyze.command("run", { isDefault: true }).description("Create an analysis from a data file, configure it and run it (the default: `analyze <file>`)").argument("[file]", "CSV or Excel file to analyze").option("--name <name>", "Analysis name (asked for, or derived from the filename)").option("--description <text>", "Analysis description").option("--visibility <vis>", "PRIVATE or PUBLIC (default: PRIVATE)").option("--hours <hours>", `Computation time in hours (default: ${DEFAULT_HOURS}; preset value used when --preset set)`).option("--budget <credits>", `Credit budget (default: ${DEFAULT_BUDGET}; preset value used when --preset set)`).option("--targets <csv>", "Comma-separated target column names (required when not interactive)").option("--questions <csv>", "Comma-separated questions to answer").option("--segment <name>", "Column to segment the analysis by").option("--introduction <markdown>", "Markdown introduction at notebook position 0").option("--preset <id>", "Apply a saved preset as defaults (explicit flags override preset values)").option("--no-interactive", "Never prompt; every value a run needs must come from a flag or a preset").action(async (file, options, cmd) => {
|
|
7208
7616
|
try {
|
|
7209
7617
|
if (!file) {
|
|
7210
7618
|
analyze.help();
|
|
@@ -7212,7 +7620,7 @@ function registerAnalyzeCommand(program) {
|
|
|
7212
7620
|
}
|
|
7213
7621
|
await runAnalysis(file, options, cmd);
|
|
7214
7622
|
} catch (error) {
|
|
7215
|
-
|
|
7623
|
+
reportCommandError(error);
|
|
7216
7624
|
}
|
|
7217
7625
|
});
|
|
7218
7626
|
analyze.command("list").description("List recent analyses").option("--limit <n>", "Number of analyses to list", "20").action(async (options, cmd) => {
|
|
@@ -7243,11 +7651,11 @@ function registerAnalyzeCommand(program) {
|
|
|
7243
7651
|
handleError(error);
|
|
7244
7652
|
}
|
|
7245
7653
|
});
|
|
7246
|
-
analyze.command("rerun").description("Queue a fresh run on an existing analysis").argument("<id>", "Analysis ID to rerun").action(async (id) => {
|
|
7654
|
+
analyze.command("rerun").description("Queue a fresh run on an existing analysis (asks for anything a run still needs)").argument("<id>", "Analysis ID to rerun").option("--no-interactive", "Never prompt; fail if the analysis has no targets, hours or budget").action(async (id, options, cmd) => {
|
|
7247
7655
|
try {
|
|
7248
|
-
await rerunAnalysis(id);
|
|
7656
|
+
await rerunAnalysis(id, options, cmd);
|
|
7249
7657
|
} catch (error) {
|
|
7250
|
-
|
|
7658
|
+
reportCommandError(error);
|
|
7251
7659
|
}
|
|
7252
7660
|
});
|
|
7253
7661
|
analyze.command("create").description("Create an analysis recipe without uploading data or running").option("--name <name>", "Analysis name").option("--description <text>", "Analysis description").option("--visibility <vis>", "PRIVATE or PUBLIC", "PRIVATE").option("--hours <h>", "Computation hours").option("--budget <credits>", "Credit budget").option("--targets <csv>", "Comma-separated target column names").option("--questions <csv>", "Comma-separated questions").option("--segment <name>", "Segmentation column").option("--introduction <markdown>", "Markdown introduction").action(async (options, cmd) => {
|
|
@@ -7476,7 +7884,7 @@ function registerAnalyzeCommand(program) {
|
|
|
7476
7884
|
}
|
|
7477
7885
|
|
|
7478
7886
|
// src/commands/data-sources/index.ts
|
|
7479
|
-
import
|
|
7887
|
+
import chalk27 from "chalk";
|
|
7480
7888
|
function getOutputFormat16(cmd) {
|
|
7481
7889
|
const config = loadConfig();
|
|
7482
7890
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -7565,9 +7973,9 @@ function runTableRow(run) {
|
|
|
7565
7973
|
triggeredBy: run.triggeredBy ?? "\u2014"
|
|
7566
7974
|
};
|
|
7567
7975
|
}
|
|
7568
|
-
function resolveProjectId(
|
|
7976
|
+
function resolveProjectId(cmd) {
|
|
7569
7977
|
const globals = cmd.optsWithGlobals();
|
|
7570
|
-
const resolved =
|
|
7978
|
+
const resolved = globals.project ?? loadConfig().defaults.project;
|
|
7571
7979
|
if (!resolved) {
|
|
7572
7980
|
usageError(
|
|
7573
7981
|
"This command needs a project.",
|
|
@@ -7612,7 +8020,7 @@ async function showDashboard(projectId, cmd) {
|
|
|
7612
8020
|
return;
|
|
7613
8021
|
}
|
|
7614
8022
|
const r = dashboard.rollup;
|
|
7615
|
-
let line =
|
|
8023
|
+
let line = chalk27.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
|
|
7616
8024
|
if (r.lastActivityAt) line += `, last activity ${r.lastActivityAt}`;
|
|
7617
8025
|
console.log(line);
|
|
7618
8026
|
if (dashboard.sources.length === 0) {
|
|
@@ -7650,8 +8058,8 @@ async function createDataSource(options, cmd) {
|
|
|
7650
8058
|
const ds = await api.storage.createDataSource(request);
|
|
7651
8059
|
if (outputFormat === "human") {
|
|
7652
8060
|
success(`Created data source ${ds.id}`);
|
|
7653
|
-
console.log(
|
|
7654
|
-
if (ds.lastRunError) console.log(
|
|
8061
|
+
console.log(chalk27.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
|
|
8062
|
+
if (ds.lastRunError) console.log(chalk27.dim(` Error: ${ds.lastRunError}`));
|
|
7655
8063
|
} else {
|
|
7656
8064
|
format(ds, { format: outputFormat });
|
|
7657
8065
|
}
|
|
@@ -7697,7 +8105,7 @@ async function refreshDataSource(id, cmd) {
|
|
|
7697
8105
|
const run = await api.storage.refreshDataSource(id);
|
|
7698
8106
|
if (outputFormat === "human") {
|
|
7699
8107
|
success(`Refresh queued \u2014 run ${run.runId}, status ${run.status}`);
|
|
7700
|
-
if (run.errorMessage) console.log(
|
|
8108
|
+
if (run.errorMessage) console.log(chalk27.red(` Error: ${run.errorMessage}`));
|
|
7701
8109
|
} else {
|
|
7702
8110
|
format(run, { format: outputFormat });
|
|
7703
8111
|
}
|
|
@@ -7746,13 +8154,13 @@ async function listConnectorTypes(cmd) {
|
|
|
7746
8154
|
}
|
|
7747
8155
|
function registerDataSourcesCommands(program) {
|
|
7748
8156
|
const dataSources = program.command("data-sources").description("Manage scheduled DataSource imports (Google Sheets, S3 URL, JDBC)");
|
|
7749
|
-
dataSources.command("list").description("List the data sources of one project").
|
|
8157
|
+
dataSources.command("list").description("List the data sources of one project").addHelpText("after", `
|
|
7750
8158
|
Examples:
|
|
7751
8159
|
$ diafunc data-sources list --project <id>
|
|
7752
8160
|
$ diafunc config set defaults.project <id> then --project can be omitted
|
|
7753
|
-
`).action(async (
|
|
8161
|
+
`).action(async (_options, cmd) => {
|
|
7754
8162
|
try {
|
|
7755
|
-
await listDataSources(resolveProjectId(
|
|
8163
|
+
await listDataSources(resolveProjectId(cmd), cmd);
|
|
7756
8164
|
} catch (error) {
|
|
7757
8165
|
handleError(error);
|
|
7758
8166
|
}
|
|
@@ -7824,7 +8232,7 @@ Examples:
|
|
|
7824
8232
|
}
|
|
7825
8233
|
|
|
7826
8234
|
// src/commands/table-exporters/index.ts
|
|
7827
|
-
import
|
|
8235
|
+
import chalk28 from "chalk";
|
|
7828
8236
|
function getOutputFormat17(cmd) {
|
|
7829
8237
|
const config = loadConfig();
|
|
7830
8238
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -7855,7 +8263,7 @@ function registerTableExportersCommands(program) {
|
|
|
7855
8263
|
format: outputFormat,
|
|
7856
8264
|
columns: ["id", "name", "format", "extension", "mimeType", "priority", "function", "createdBy"]
|
|
7857
8265
|
});
|
|
7858
|
-
console.log(
|
|
8266
|
+
console.log(chalk28.dim(`${list.length} exporter(s)`));
|
|
7859
8267
|
} catch (error) {
|
|
7860
8268
|
handleError(error);
|
|
7861
8269
|
}
|
|
@@ -7913,15 +8321,14 @@ function registerTableExportersCommands(program) {
|
|
|
7913
8321
|
}
|
|
7914
8322
|
|
|
7915
8323
|
// src/commands/skeleton/index.ts
|
|
7916
|
-
import
|
|
8324
|
+
import chalk29 from "chalk";
|
|
7917
8325
|
import * as fs9 from "fs";
|
|
7918
8326
|
function getOutputFormat18(cmd) {
|
|
7919
8327
|
const config = loadConfig();
|
|
7920
8328
|
const globalOpts = cmd.optsWithGlobals();
|
|
7921
8329
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
7922
8330
|
}
|
|
7923
|
-
function resolveProjectId2(
|
|
7924
|
-
if (localOption) return localOption;
|
|
8331
|
+
function resolveProjectId2(cmd) {
|
|
7925
8332
|
const globalOpts = cmd.optsWithGlobals();
|
|
7926
8333
|
if (globalOpts.project) return globalOpts.project;
|
|
7927
8334
|
const config = loadConfig();
|
|
@@ -7966,12 +8373,13 @@ function skeletonTableRow(s) {
|
|
|
7966
8373
|
}
|
|
7967
8374
|
async function createSkeleton(options, cmd) {
|
|
7968
8375
|
const outputFormat = getOutputFormat18(cmd);
|
|
7969
|
-
const projectId = resolveProjectId2(
|
|
8376
|
+
const projectId = resolveProjectId2(cmd);
|
|
7970
8377
|
const template = resolveTemplate(options.template);
|
|
7971
8378
|
const weight = parseWeight(options.weight);
|
|
8379
|
+
const globals = cmd.optsWithGlobals();
|
|
7972
8380
|
const request = {
|
|
7973
8381
|
projectId,
|
|
7974
|
-
projectBranch:
|
|
8382
|
+
projectBranch: globals.branch ?? loadConfig().defaults.branch ?? "main",
|
|
7975
8383
|
name: options.name,
|
|
7976
8384
|
template,
|
|
7977
8385
|
weight
|
|
@@ -7980,17 +8388,17 @@ async function createSkeleton(options, cmd) {
|
|
|
7980
8388
|
const skeleton = await api.storage.createSkeleton(request);
|
|
7981
8389
|
if (outputFormat === "human") {
|
|
7982
8390
|
success(`Created skeleton ${skeleton.id}`);
|
|
7983
|
-
console.log(
|
|
7984
|
-
console.log(
|
|
7985
|
-
console.log(
|
|
7986
|
-
console.log(
|
|
8391
|
+
console.log(chalk29.dim(` name: ${skeleton.name}`));
|
|
8392
|
+
console.log(chalk29.dim(` template: ${skeleton.template}`));
|
|
8393
|
+
console.log(chalk29.dim(` paramCount: ${skeleton.paramCount}`));
|
|
8394
|
+
console.log(chalk29.dim(` weight: ${skeleton.weight}`));
|
|
7987
8395
|
} else {
|
|
7988
8396
|
format(skeleton, { format: outputFormat });
|
|
7989
8397
|
}
|
|
7990
8398
|
}
|
|
7991
|
-
async function listSkeletons(
|
|
8399
|
+
async function listSkeletons(cmd) {
|
|
7992
8400
|
const outputFormat = getOutputFormat18(cmd);
|
|
7993
|
-
const projectId = resolveProjectId2(
|
|
8401
|
+
const projectId = resolveProjectId2(cmd);
|
|
7994
8402
|
const api = createApiClient();
|
|
7995
8403
|
const skeletons = await api.storage.listSkeletons(projectId);
|
|
7996
8404
|
if (outputFormat === "human" && skeletons.length === 0) {
|
|
@@ -8022,10 +8430,10 @@ async function updateSkeleton(id, options, cmd) {
|
|
|
8022
8430
|
const skeleton = await api.storage.updateSkeleton(id, request);
|
|
8023
8431
|
if (outputFormat === "human") {
|
|
8024
8432
|
success(`Updated skeleton ${skeleton.id}`);
|
|
8025
|
-
console.log(
|
|
8026
|
-
console.log(
|
|
8027
|
-
console.log(
|
|
8028
|
-
console.log(
|
|
8433
|
+
console.log(chalk29.dim(` name: ${skeleton.name}`));
|
|
8434
|
+
console.log(chalk29.dim(` template: ${skeleton.template}`));
|
|
8435
|
+
console.log(chalk29.dim(` paramCount: ${skeleton.paramCount}`));
|
|
8436
|
+
console.log(chalk29.dim(` weight: ${skeleton.weight}`));
|
|
8029
8437
|
} else {
|
|
8030
8438
|
format(skeleton, { format: outputFormat });
|
|
8031
8439
|
}
|
|
@@ -8045,16 +8453,16 @@ Examples:
|
|
|
8045
8453
|
skeleton.command("create").description("Create a skeleton. Parse errors from the engine are surfaced as stderr.").requiredOption("--name <name>", "Display name").requiredOption(
|
|
8046
8454
|
"--template <expr>",
|
|
8047
8455
|
'Skeleton template expression (e.g. "?*x+?"). Use "@file.txt" to read from a file; "@@\u2026" escapes a literal leading @.'
|
|
8048
|
-
).option("--
|
|
8456
|
+
).option("--weight <number>", "Sampling weight (positive; server default applies if omitted)").action(async (options, cmd) => {
|
|
8049
8457
|
try {
|
|
8050
8458
|
await createSkeleton(options, cmd);
|
|
8051
8459
|
} catch (error) {
|
|
8052
8460
|
handleError(error);
|
|
8053
8461
|
}
|
|
8054
8462
|
});
|
|
8055
|
-
skeleton.command("list").description("List skeletons in a project").
|
|
8463
|
+
skeleton.command("list").description("List skeletons in a project").action(async (_options, cmd) => {
|
|
8056
8464
|
try {
|
|
8057
|
-
await listSkeletons(
|
|
8465
|
+
await listSkeletons(cmd);
|
|
8058
8466
|
} catch (error) {
|
|
8059
8467
|
handleError(error);
|
|
8060
8468
|
}
|
|
@@ -8153,7 +8561,7 @@ _diafunc_completions() {
|
|
|
8153
8561
|
COMPREPLY=($(compgen -W "call" -- "\${cur}"))
|
|
8154
8562
|
;;
|
|
8155
8563
|
chat)
|
|
8156
|
-
subcommands="send stream upload session usage"
|
|
8564
|
+
subcommands="repl send stream upload session usage"
|
|
8157
8565
|
if [[ "\${COMP_WORDS[2]}" == "session" ]]; then
|
|
8158
8566
|
COMPREPLY=($(compgen -W "list delete" -- "\${cur}"))
|
|
8159
8567
|
else
|
|
@@ -8250,7 +8658,7 @@ _diafunc_project() { _values 'subcommand' list get create delete lock unlock mem
|
|
|
8250
8658
|
_diafunc_team() { _values 'subcommand' list get use usage create portal cancel leave members invitations seats packs transfer; }
|
|
8251
8659
|
_diafunc_entity() { _values 'subcommand' list get delete history revert rename content; }
|
|
8252
8660
|
_diafunc_table() { _values 'subcommand' view import export row column cell clear; }
|
|
8253
|
-
_diafunc_chat() { _values 'subcommand' send stream upload session usage; }
|
|
8661
|
+
_diafunc_chat() { _values 'subcommand' repl send stream upload session usage; }
|
|
8254
8662
|
_diafunc_admin() { _values 'subcommand' users subscription settings backup; }
|
|
8255
8663
|
|
|
8256
8664
|
_diafunc "$@"`;
|
|
@@ -8309,7 +8717,7 @@ complete -c diafunc -n "__fish_seen_subcommand_from table; and not __fish_seen_s
|
|
|
8309
8717
|
complete -c diafunc -n "__fish_seen_subcommand_from function; and not __fish_seen_subcommand_from call evaluations outputs logs stop engines" -a "call evaluations outputs logs stop engines"
|
|
8310
8718
|
|
|
8311
8719
|
# chat
|
|
8312
|
-
complete -c diafunc -n "__fish_seen_subcommand_from chat; and not __fish_seen_subcommand_from send stream upload session usage" -a "send stream upload session usage"
|
|
8720
|
+
complete -c diafunc -n "__fish_seen_subcommand_from chat; and not __fish_seen_subcommand_from repl send stream upload session usage" -a "repl send stream upload session usage"
|
|
8313
8721
|
|
|
8314
8722
|
# team
|
|
8315
8723
|
complete -c diafunc -n "__fish_seen_subcommand_from team; and not __fish_seen_subcommand_from list get use usage create portal cancel leave members invitations seats packs transfer" -a "list get use usage create portal cancel leave members invitations seats packs transfer"
|
|
@@ -8342,7 +8750,7 @@ function registerCompletionCommand(program) {
|
|
|
8342
8750
|
}
|
|
8343
8751
|
|
|
8344
8752
|
// src/commands/whoami/index.ts
|
|
8345
|
-
import
|
|
8753
|
+
import chalk30 from "chalk";
|
|
8346
8754
|
function registerWhoamiCommand(program) {
|
|
8347
8755
|
program.command("whoami").description("Show the currently authenticated user").action(async (_options, cmd) => {
|
|
8348
8756
|
try {
|
|
@@ -8352,8 +8760,8 @@ function registerWhoamiCommand(program) {
|
|
|
8352
8760
|
const api = createApiClient();
|
|
8353
8761
|
const user = await api.admin.getMyUser();
|
|
8354
8762
|
if (outputFormat === "human") {
|
|
8355
|
-
console.log(
|
|
8356
|
-
console.log(
|
|
8763
|
+
console.log(chalk30.bold(user.name) + chalk30.dim(` <${user.email}>`));
|
|
8764
|
+
console.log(chalk30.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config.currentProfile}`));
|
|
8357
8765
|
} else {
|
|
8358
8766
|
format(user, { format: outputFormat });
|
|
8359
8767
|
}
|
|
@@ -8364,7 +8772,7 @@ function registerWhoamiCommand(program) {
|
|
|
8364
8772
|
}
|
|
8365
8773
|
|
|
8366
8774
|
// src/commands/utilization/index.ts
|
|
8367
|
-
import
|
|
8775
|
+
import chalk31 from "chalk";
|
|
8368
8776
|
function getOutputFormat19(cmd) {
|
|
8369
8777
|
const config = loadConfig();
|
|
8370
8778
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -8381,19 +8789,19 @@ function windowLabel(u) {
|
|
|
8381
8789
|
}
|
|
8382
8790
|
function printUtilizationHuman(u, label) {
|
|
8383
8791
|
const when = windowLabel(u);
|
|
8384
|
-
console.log(label ?
|
|
8792
|
+
console.log(label ? chalk31.bold(label) + " " + chalk31.dim(when) : chalk31.bold(when));
|
|
8385
8793
|
if (u.types.length === 0) {
|
|
8386
|
-
console.log(
|
|
8794
|
+
console.log(chalk31.dim(" (no usage)"));
|
|
8387
8795
|
return;
|
|
8388
8796
|
}
|
|
8389
8797
|
const types = [...u.types].sort((a, b) => b.credits - a.credits);
|
|
8390
8798
|
const width = Math.max(...types.map((t) => t.type.length));
|
|
8391
8799
|
for (const t of types) {
|
|
8392
|
-
const line = ` ${t.type.padEnd(width)} ${formatNumber(t.quantity).padStart(12)} ${
|
|
8393
|
-
console.log(t.credits === 0 ?
|
|
8800
|
+
const line = ` ${t.type.padEnd(width)} ${formatNumber(t.quantity).padStart(12)} ${chalk31.dim("credits")} ${t.credits.toFixed(2).padStart(10)}`;
|
|
8801
|
+
console.log(t.credits === 0 ? chalk31.dim(line) : line);
|
|
8394
8802
|
}
|
|
8395
8803
|
const total = u.totalCredits ?? u.types.reduce((s, t) => s + t.credits, 0);
|
|
8396
|
-
console.log(
|
|
8804
|
+
console.log(chalk31.bold(` ${"Total".padEnd(width)} ${" ".repeat(12)} ${chalk31.dim("credits")} ${total.toFixed(2).padStart(10)}`));
|
|
8397
8805
|
}
|
|
8398
8806
|
function registerUtilizationCommand(program) {
|
|
8399
8807
|
const util = program.command("utilization").description("Show credit utilization for the current billing cycle").addHelpText("after", `
|
|
@@ -8596,7 +9004,7 @@ Examples:
|
|
|
8596
9004
|
}
|
|
8597
9005
|
|
|
8598
9006
|
// src/commands/shell/index.ts
|
|
8599
|
-
import
|
|
9007
|
+
import chalk32 from "chalk";
|
|
8600
9008
|
import * as fs11 from "fs";
|
|
8601
9009
|
import * as os3 from "os";
|
|
8602
9010
|
import * as path8 from "path";
|
|
@@ -8662,21 +9070,21 @@ async function evaluate(api, fnRef, language, sourceCode) {
|
|
|
8662
9070
|
}, false);
|
|
8663
9071
|
if (result.outputs?.length) {
|
|
8664
9072
|
for (const out of result.outputs) {
|
|
8665
|
-
console.log(
|
|
9073
|
+
console.log(chalk32.dim(` [${out.type}]`) + " " + out.output);
|
|
8666
9074
|
}
|
|
8667
9075
|
}
|
|
8668
9076
|
if (result.successful) {
|
|
8669
9077
|
if (result.result) {
|
|
8670
|
-
console.log(
|
|
9078
|
+
console.log(chalk32.green("=>") + " " + result.result);
|
|
8671
9079
|
} else {
|
|
8672
|
-
console.log(
|
|
9080
|
+
console.log(chalk32.dim("=> (no value)"));
|
|
8673
9081
|
}
|
|
8674
9082
|
const duration = result.completed - result.started;
|
|
8675
|
-
console.log(
|
|
9083
|
+
console.log(chalk32.dim(` [${duration}ms \xB7 ${evaluationId}]`));
|
|
8676
9084
|
} else {
|
|
8677
|
-
console.log(
|
|
9085
|
+
console.log(chalk32.red("error: ") + result.error);
|
|
8678
9086
|
if (result.lineNumber > 0) {
|
|
8679
|
-
console.log(
|
|
9087
|
+
console.log(chalk32.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
|
|
8680
9088
|
}
|
|
8681
9089
|
}
|
|
8682
9090
|
}
|
|
@@ -8697,19 +9105,19 @@ function registerShellCommand(program) {
|
|
|
8697
9105
|
});
|
|
8698
9106
|
const api = createApiClient();
|
|
8699
9107
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
8700
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
9108
|
+
const { getUpdateNotice } = await import("./update-check-ZCS3IYOZ.js");
|
|
8701
9109
|
const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
|
|
8702
|
-
console.log(
|
|
8703
|
-
console.log(
|
|
8704
|
-
console.log(
|
|
9110
|
+
console.log(chalk32.bold("Diafunc shell") + chalk32.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
|
|
9111
|
+
console.log(chalk32.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
|
|
9112
|
+
console.log(chalk32.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
|
|
8705
9113
|
const notice = await getUpdateNotice();
|
|
8706
|
-
if (notice) console.log(
|
|
9114
|
+
if (notice) console.log(chalk32.dim(notice));
|
|
8707
9115
|
console.log();
|
|
8708
9116
|
let language = resolvedLanguage;
|
|
8709
9117
|
for (; ; ) {
|
|
8710
9118
|
let line;
|
|
8711
9119
|
try {
|
|
8712
|
-
line = await promptInput({ message:
|
|
9120
|
+
line = await promptInput({ message: chalk32.cyan.bold(`${language} >`) });
|
|
8713
9121
|
} catch {
|
|
8714
9122
|
console.log();
|
|
8715
9123
|
return;
|
|
@@ -8727,54 +9135,54 @@ function registerShellCommand(program) {
|
|
|
8727
9135
|
case "help":
|
|
8728
9136
|
case "h":
|
|
8729
9137
|
case "?":
|
|
8730
|
-
console.log(
|
|
8731
|
-
console.log(
|
|
8732
|
-
console.log(
|
|
8733
|
-
console.log(
|
|
9138
|
+
console.log(chalk32.dim(" /edit open $EDITOR for multi-line code"));
|
|
9139
|
+
console.log(chalk32.dim(" /file <path> evaluate the contents of a file"));
|
|
9140
|
+
console.log(chalk32.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
|
|
9141
|
+
console.log(chalk32.dim(" /quit exit the shell"));
|
|
8734
9142
|
continue;
|
|
8735
9143
|
case "lang":
|
|
8736
9144
|
if (arg) language = arg;
|
|
8737
|
-
console.log(
|
|
9145
|
+
console.log(chalk32.dim(`Language: ${language}`));
|
|
8738
9146
|
continue;
|
|
8739
9147
|
case "edit": {
|
|
8740
9148
|
const sourceCode = await openInEditor("", extensionFor2(language));
|
|
8741
9149
|
if (!sourceCode.trim()) {
|
|
8742
|
-
console.log(
|
|
9150
|
+
console.log(chalk32.dim("(empty \u2014 not evaluated)"));
|
|
8743
9151
|
continue;
|
|
8744
9152
|
}
|
|
8745
9153
|
try {
|
|
8746
9154
|
await evaluate(api, fnRef, language, sourceCode);
|
|
8747
9155
|
} catch (e) {
|
|
8748
|
-
console.error(
|
|
9156
|
+
console.error(chalk32.red(e.message));
|
|
8749
9157
|
}
|
|
8750
9158
|
continue;
|
|
8751
9159
|
}
|
|
8752
9160
|
case "file": {
|
|
8753
9161
|
if (!arg) {
|
|
8754
|
-
console.log(
|
|
9162
|
+
console.log(chalk32.dim("usage: /file <path>"));
|
|
8755
9163
|
continue;
|
|
8756
9164
|
}
|
|
8757
9165
|
if (!fs11.existsSync(arg)) {
|
|
8758
|
-
console.log(
|
|
9166
|
+
console.log(chalk32.red(`file not found: ${arg}`));
|
|
8759
9167
|
continue;
|
|
8760
9168
|
}
|
|
8761
9169
|
const sourceCode = fs11.readFileSync(arg, "utf-8");
|
|
8762
9170
|
try {
|
|
8763
9171
|
await evaluate(api, fnRef, language, sourceCode);
|
|
8764
9172
|
} catch (e) {
|
|
8765
|
-
console.error(
|
|
9173
|
+
console.error(chalk32.red(e.message));
|
|
8766
9174
|
}
|
|
8767
9175
|
continue;
|
|
8768
9176
|
}
|
|
8769
9177
|
default:
|
|
8770
|
-
console.log(
|
|
9178
|
+
console.log(chalk32.dim(`Unknown command: /${cmd2}. Try /help.`));
|
|
8771
9179
|
continue;
|
|
8772
9180
|
}
|
|
8773
9181
|
}
|
|
8774
9182
|
try {
|
|
8775
9183
|
await evaluate(api, fnRef, language, trimmed);
|
|
8776
9184
|
} catch (e) {
|
|
8777
|
-
console.error(
|
|
9185
|
+
console.error(chalk32.red(e.message));
|
|
8778
9186
|
}
|
|
8779
9187
|
}
|
|
8780
9188
|
} catch (error) {
|
|
@@ -8784,7 +9192,7 @@ function registerShellCommand(program) {
|
|
|
8784
9192
|
}
|
|
8785
9193
|
|
|
8786
9194
|
// src/commands/update/index.ts
|
|
8787
|
-
import
|
|
9195
|
+
import chalk33 from "chalk";
|
|
8788
9196
|
import * as path9 from "path";
|
|
8789
9197
|
import { spawn as spawn4 } from "child_process";
|
|
8790
9198
|
|
|
@@ -8830,14 +9238,14 @@ function registerUpdateCommand(program) {
|
|
|
8830
9238
|
const install = detectInstall();
|
|
8831
9239
|
const latest = await fetchLatestVersion();
|
|
8832
9240
|
if (latest === package_default.version) {
|
|
8833
|
-
console.log(
|
|
9241
|
+
console.log(chalk33.dim(`diafunc is already at the latest version (${package_default.version}).`));
|
|
8834
9242
|
return;
|
|
8835
9243
|
}
|
|
8836
|
-
console.log(
|
|
9244
|
+
console.log(chalk33.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
|
|
8837
9245
|
if (install.method === "npm") {
|
|
8838
9246
|
console.log();
|
|
8839
9247
|
console.log("Installed via npm. Upgrade with:");
|
|
8840
|
-
console.log(
|
|
9248
|
+
console.log(chalk33.bold(` npm install -g @diafunc/cli@${latest}`));
|
|
8841
9249
|
return;
|
|
8842
9250
|
}
|
|
8843
9251
|
const installDir = path9.dirname(install.binaryPath);
|
|
@@ -8851,7 +9259,7 @@ function registerUpdateCommand(program) {
|
|
|
8851
9259
|
}
|
|
8852
9260
|
|
|
8853
9261
|
// src/commands/uninstall/index.ts
|
|
8854
|
-
import
|
|
9262
|
+
import chalk34 from "chalk";
|
|
8855
9263
|
import { spawn as spawn5 } from "child_process";
|
|
8856
9264
|
import * as fs13 from "fs";
|
|
8857
9265
|
import * as os4 from "os";
|
|
@@ -8863,11 +9271,11 @@ function registerUninstallCommand(program) {
|
|
|
8863
9271
|
const configDir = path10.join(os4.homedir(), ".diafunc");
|
|
8864
9272
|
if (install.method === "npm") {
|
|
8865
9273
|
console.log("Installed via npm. Remove with:");
|
|
8866
|
-
console.log(
|
|
9274
|
+
console.log(chalk34.bold(" npm uninstall -g @diafunc/cli"));
|
|
8867
9275
|
if (fs13.existsSync(configDir)) {
|
|
8868
9276
|
console.log();
|
|
8869
9277
|
console.log(`Config + credentials live at ${configDir} \u2014 remove manually with:`);
|
|
8870
|
-
console.log(
|
|
9278
|
+
console.log(chalk34.bold(` rm -rf ${configDir}`));
|
|
8871
9279
|
}
|
|
8872
9280
|
return;
|
|
8873
9281
|
}
|
|
@@ -8877,7 +9285,7 @@ function registerUninstallCommand(program) {
|
|
|
8877
9285
|
default: false
|
|
8878
9286
|
});
|
|
8879
9287
|
if (!removeBinary) {
|
|
8880
|
-
console.log(
|
|
9288
|
+
console.log(chalk34.dim("Aborted."));
|
|
8881
9289
|
return;
|
|
8882
9290
|
}
|
|
8883
9291
|
let removeConfig = options.purge ?? false;
|
|
@@ -8889,7 +9297,7 @@ function registerUninstallCommand(program) {
|
|
|
8889
9297
|
}
|
|
8890
9298
|
if (removeConfig && fs13.existsSync(configDir)) {
|
|
8891
9299
|
fs13.rmSync(configDir, { recursive: true, force: true });
|
|
8892
|
-
console.log(
|
|
9300
|
+
console.log(chalk34.dim(`Removed ${configDir}`));
|
|
8893
9301
|
}
|
|
8894
9302
|
if (process.platform === "win32") {
|
|
8895
9303
|
const cmd = `timeout /t 2 /nobreak >nul & del /f /q "${install.binaryPath}"`;
|
|
@@ -8899,13 +9307,13 @@ function registerUninstallCommand(program) {
|
|
|
8899
9307
|
windowsHide: true
|
|
8900
9308
|
});
|
|
8901
9309
|
child.unref();
|
|
8902
|
-
console.log(
|
|
9310
|
+
console.log(chalk34.dim(`Removing ${install.binaryPath} on exit...`));
|
|
8903
9311
|
console.log();
|
|
8904
9312
|
console.log("diafunc uninstalled.");
|
|
8905
9313
|
return;
|
|
8906
9314
|
}
|
|
8907
9315
|
fs13.rmSync(install.binaryPath, { force: true });
|
|
8908
|
-
console.log(
|
|
9316
|
+
console.log(chalk34.dim(`Removed ${install.binaryPath}`));
|
|
8909
9317
|
console.log();
|
|
8910
9318
|
console.log("diafunc uninstalled.");
|
|
8911
9319
|
} catch (error) {
|
|
@@ -8936,7 +9344,7 @@ Docs: https://diafunc.com/documentation
|
|
|
8936
9344
|
`;
|
|
8937
9345
|
function createProgram() {
|
|
8938
9346
|
const program = new Command();
|
|
8939
|
-
program.name("diafunc").description("Diafunc CLI \u2014 command-line interface for the Diafunc platform").version(package_default.version).option("-p, --profile <name>", "Profile to use").option("-o, --output <format>", "Output format: human, json, table (default: human)").option("--project <id>", "
|
|
9347
|
+
program.name("diafunc").description("Diafunc CLI \u2014 command-line interface for the Diafunc platform").version(package_default.version).option("-p, --profile <name>", "Profile to use").option("-o, --output <format>", "Output format: human, json, table (default: human)").option("--project <id>", "Project to work in (overrides defaults.project)").option("--branch <name>", "Project branch (overrides defaults.branch)").option("--dry-run", "Preview mutating operations without executing them").option("--verbose", "Echo every HTTP request to stderr").option("--no-color", "Disable coloured output").showSuggestionAfterError().showHelpAfterError(`(run 'diafunc --help' to see the available commands)`).configureHelp({ showGlobalOptions: true }).configureOutput({
|
|
8940
9348
|
// Commander writes usage errors to stdout by default, which puts a complaint in the middle
|
|
8941
9349
|
// of whatever a caller was capturing.
|
|
8942
9350
|
writeErr: (str) => process.stderr.write(str)
|
|
@@ -8944,7 +9352,7 @@ function createProgram() {
|
|
|
8944
9352
|
const opts = thisCommand.optsWithGlobals();
|
|
8945
9353
|
if (opts.dryRun) setDryRun(true);
|
|
8946
9354
|
if (opts.verbose) setVerbose(true);
|
|
8947
|
-
if (opts.color === false)
|
|
9355
|
+
if (opts.color === false) chalk35.level = 0;
|
|
8948
9356
|
});
|
|
8949
9357
|
program.addHelpText("after", HELP_EPILOGUE);
|
|
8950
9358
|
registerAuthCommands(program);
|
|
@@ -8983,4 +9391,4 @@ function createProgram() {
|
|
|
8983
9391
|
export {
|
|
8984
9392
|
createProgram
|
|
8985
9393
|
};
|
|
8986
|
-
//# sourceMappingURL=chunk-
|
|
9394
|
+
//# sourceMappingURL=chunk-GDW62ZQX.js.map
|