@diafunc/cli 0.17.0 → 0.19.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 +3 -0
- package/dist/bin/diafunc.js +15 -3
- package/dist/bin/diafunc.js.map +1 -1
- package/dist/{chunk-ZT25YY7J.js → chunk-A5D45VXJ.js} +2 -2
- package/dist/{chunk-ZT25YY7J.js.map → chunk-A5D45VXJ.js.map} +1 -1
- package/dist/{chunk-6ZOIOHSW.js → chunk-OCZSFCU6.js} +297 -86
- package/dist/chunk-OCZSFCU6.js.map +1 -0
- package/dist/{chunk-QWSCORJH.js → chunk-SYNS3L7N.js} +2 -2
- package/dist/src/index.js +2 -2
- package/dist/update-check-TTXILAMD.js +8 -0
- package/package.json +1 -1
- package/dist/chunk-6ZOIOHSW.js.map +0 -1
- package/dist/update-check-5CPEMV2M.js +0 -8
- /package/dist/{chunk-QWSCORJH.js.map → chunk-SYNS3L7N.js.map} +0 -0
- /package/dist/{update-check-5CPEMV2M.js.map → update-check-TTXILAMD.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-A5D45VXJ.js";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
import chalk36 from "chalk";
|
|
@@ -124,8 +124,8 @@ var REQUEST_TIMEOUT_MS = 6e4;
|
|
|
124
124
|
var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
|
|
125
125
|
var MAX_ATTEMPTS = 3;
|
|
126
126
|
var RETRYABLE_METHODS = /* @__PURE__ */ new Set(["GET"]);
|
|
127
|
-
function buildUrl(endpoint, service,
|
|
128
|
-
const base = `${endpoint}/api/v1/${service}${
|
|
127
|
+
function buildUrl(endpoint, service, path12, query) {
|
|
128
|
+
const base = `${endpoint}/api/v1/${service}${path12}`;
|
|
129
129
|
const params = new URLSearchParams();
|
|
130
130
|
if (query) {
|
|
131
131
|
for (const [key, value] of Object.entries(query)) {
|
|
@@ -224,6 +224,9 @@ var _verbose = false;
|
|
|
224
224
|
function setDryRun(enabled) {
|
|
225
225
|
_dryRun = enabled;
|
|
226
226
|
}
|
|
227
|
+
function isDryRun() {
|
|
228
|
+
return _dryRun;
|
|
229
|
+
}
|
|
227
230
|
function setVerbose(enabled) {
|
|
228
231
|
_verbose = enabled;
|
|
229
232
|
}
|
|
@@ -1653,6 +1656,46 @@ function createAnalysisService(client) {
|
|
|
1653
1656
|
rawBody: formData
|
|
1654
1657
|
});
|
|
1655
1658
|
},
|
|
1659
|
+
// ----- Several files: sources ------------------------------------------------------
|
|
1660
|
+
async addSource(analysisId, formData) {
|
|
1661
|
+
return client.request({
|
|
1662
|
+
method: "POST",
|
|
1663
|
+
service: SERVICE2,
|
|
1664
|
+
path: `/${encodeURIComponent(analysisId)}/sources`,
|
|
1665
|
+
rawBody: formData
|
|
1666
|
+
});
|
|
1667
|
+
},
|
|
1668
|
+
async listSources(analysisId) {
|
|
1669
|
+
return client.request({
|
|
1670
|
+
method: "GET",
|
|
1671
|
+
service: SERVICE2,
|
|
1672
|
+
path: `/${encodeURIComponent(analysisId)}/sources`
|
|
1673
|
+
});
|
|
1674
|
+
},
|
|
1675
|
+
async removeSource(analysisId, sourceId) {
|
|
1676
|
+
return client.request({
|
|
1677
|
+
method: "DELETE",
|
|
1678
|
+
service: SERVICE2,
|
|
1679
|
+
path: `/${encodeURIComponent(analysisId)}/sources/${encodeURIComponent(sourceId)}`
|
|
1680
|
+
});
|
|
1681
|
+
},
|
|
1682
|
+
/** What building from the sources would yield: for `recipe`, or for the platform's proposal when it is null. */
|
|
1683
|
+
async planSources(analysisId, recipe) {
|
|
1684
|
+
return client.request({
|
|
1685
|
+
method: "POST",
|
|
1686
|
+
service: SERVICE2,
|
|
1687
|
+
path: `/${encodeURIComponent(analysisId)}/sources/plan`,
|
|
1688
|
+
body: recipe
|
|
1689
|
+
});
|
|
1690
|
+
},
|
|
1691
|
+
async buildSources(analysisId, recipe) {
|
|
1692
|
+
return client.request({
|
|
1693
|
+
method: "POST",
|
|
1694
|
+
service: SERVICE2,
|
|
1695
|
+
path: `/${encodeURIComponent(analysisId)}/sources/build`,
|
|
1696
|
+
body: recipe
|
|
1697
|
+
});
|
|
1698
|
+
},
|
|
1656
1699
|
async uploadDataUrl(analysisId, request) {
|
|
1657
1700
|
return client.request({
|
|
1658
1701
|
method: "POST",
|
|
@@ -1948,14 +1991,14 @@ function createStorageService(client) {
|
|
|
1948
1991
|
});
|
|
1949
1992
|
},
|
|
1950
1993
|
async deleteLink(projectId, projectBranch, sourceEntityId, sourceEntityBranch, linkId, targetEntityId, targetEntityBranch) {
|
|
1951
|
-
let
|
|
1994
|
+
let path12 = `/links/actual/${enc(projectId)}/${enc(projectBranch)}/${enc(sourceEntityId)}/${enc(sourceEntityBranch)}/${enc(linkId)}`;
|
|
1952
1995
|
if (targetEntityId && targetEntityBranch) {
|
|
1953
|
-
|
|
1996
|
+
path12 += `/${enc(targetEntityId)}/${enc(targetEntityBranch)}`;
|
|
1954
1997
|
}
|
|
1955
1998
|
return client.request({
|
|
1956
1999
|
method: "DELETE",
|
|
1957
2000
|
service: SERVICE3,
|
|
1958
|
-
path:
|
|
2001
|
+
path: path12
|
|
1959
2002
|
});
|
|
1960
2003
|
},
|
|
1961
2004
|
// --- Events ---
|
|
@@ -2991,8 +3034,8 @@ Examples:
|
|
|
2991
3034
|
success(`Profile "${name}" removed.`);
|
|
2992
3035
|
});
|
|
2993
3036
|
}
|
|
2994
|
-
function setNestedValue(obj,
|
|
2995
|
-
const keys =
|
|
3037
|
+
function setNestedValue(obj, path12, value) {
|
|
3038
|
+
const keys = path12.split(".");
|
|
2996
3039
|
let current = obj;
|
|
2997
3040
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
2998
3041
|
const key = keys[i];
|
|
@@ -3003,8 +3046,8 @@ function setNestedValue(obj, path11, value) {
|
|
|
3003
3046
|
}
|
|
3004
3047
|
current[keys[keys.length - 1]] = value;
|
|
3005
3048
|
}
|
|
3006
|
-
function getNestedValue(obj,
|
|
3007
|
-
const keys =
|
|
3049
|
+
function getNestedValue(obj, path12) {
|
|
3050
|
+
const keys = path12.split(".");
|
|
3008
3051
|
let current = obj;
|
|
3009
3052
|
for (const key of keys) {
|
|
3010
3053
|
if (current === null || current === void 0 || typeof current !== "object") {
|
|
@@ -4388,8 +4431,8 @@ function registerEventCommands(program) {
|
|
|
4388
4431
|
});
|
|
4389
4432
|
event.command("create").description("Create one or more events (body from JSON file or stdin)").argument("[file]", "JSON file containing a BareEvent array; defaults to stdin").action(async (file) => {
|
|
4390
4433
|
try {
|
|
4391
|
-
const
|
|
4392
|
-
const body = file ?
|
|
4434
|
+
const fs16 = await import("fs");
|
|
4435
|
+
const body = file ? fs16.readFileSync(file, "utf-8") : await new Promise((resolve, reject) => {
|
|
4393
4436
|
let data = "";
|
|
4394
4437
|
process.stdin.setEncoding("utf-8");
|
|
4395
4438
|
process.stdin.on("data", (chunk) => {
|
|
@@ -4581,6 +4624,22 @@ function parseRange(text2, size, label) {
|
|
|
4581
4624
|
}
|
|
4582
4625
|
return { from, to };
|
|
4583
4626
|
}
|
|
4627
|
+
var SNAPSHOT_MAX_CELLS = 65536;
|
|
4628
|
+
function windowParts(window, maxCells = SNAPSHOT_MAX_CELLS) {
|
|
4629
|
+
const columns = window.columns.to - window.columns.from;
|
|
4630
|
+
const columnsPerPart = Math.max(1, Math.min(columns, maxCells));
|
|
4631
|
+
const rowsPerPart = Math.max(1, Math.floor(maxCells / columnsPerPart));
|
|
4632
|
+
const parts = [];
|
|
4633
|
+
for (let row = window.rows.from; row < window.rows.to; row += rowsPerPart) {
|
|
4634
|
+
for (let column = window.columns.from; column < window.columns.to; column += columnsPerPart) {
|
|
4635
|
+
parts.push({
|
|
4636
|
+
rows: { from: row, to: Math.min(row + rowsPerPart, window.rows.to) },
|
|
4637
|
+
columns: { from: column, to: Math.min(column + columnsPerPart, window.columns.to) }
|
|
4638
|
+
});
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4641
|
+
return parts;
|
|
4642
|
+
}
|
|
4584
4643
|
function cellRange(window) {
|
|
4585
4644
|
return {
|
|
4586
4645
|
fromRowIndex: window.rows.from,
|
|
@@ -4589,6 +4648,18 @@ function cellRange(window) {
|
|
|
4589
4648
|
toColumnIndex: window.columns.to - 1
|
|
4590
4649
|
};
|
|
4591
4650
|
}
|
|
4651
|
+
async function fetchWindow(fetchPart, window, maxCells = SNAPSHOT_MAX_CELLS) {
|
|
4652
|
+
const rows = /* @__PURE__ */ new Map();
|
|
4653
|
+
const columns = /* @__PURE__ */ new Map();
|
|
4654
|
+
const cells = [];
|
|
4655
|
+
for (const part of windowParts(window, maxCells)) {
|
|
4656
|
+
const snapshot = await fetchPart(cellRange(part));
|
|
4657
|
+
for (const row of snapshot.rows) rows.set(row.index, row);
|
|
4658
|
+
for (const column of snapshot.columns) columns.set(column.index, column);
|
|
4659
|
+
for (const cell2 of snapshot.cells) cells.push(cell2);
|
|
4660
|
+
}
|
|
4661
|
+
return { rows: [...rows.values()], columns: [...columns.values()], cells };
|
|
4662
|
+
}
|
|
4592
4663
|
function describeWindow(window, rows, columns) {
|
|
4593
4664
|
const whole = window.rows.from === 0 && window.rows.to === rows && window.columns.from === 0 && window.columns.to === columns;
|
|
4594
4665
|
const line = `Rows ${window.rows.from}\u2013${window.rows.to - 1} of ${rows} \xB7 columns ${window.columns.from}\u2013${window.columns.to - 1} of ${columns}`;
|
|
@@ -4746,7 +4817,10 @@ Examples:
|
|
|
4746
4817
|
rows: options.rows ? parseRange(options.rows, totalRows, "Row") : initial.rows,
|
|
4747
4818
|
columns: options.cols ? parseRange(options.cols, totalColumns, "Column") : initial.columns
|
|
4748
4819
|
};
|
|
4749
|
-
const snapshot = await
|
|
4820
|
+
const snapshot = await fetchWindow(
|
|
4821
|
+
(range) => api.storage.getTableSnapshot(resolved, { cellRanges: [range] }),
|
|
4822
|
+
window
|
|
4823
|
+
);
|
|
4750
4824
|
if (outputFormat === "json") {
|
|
4751
4825
|
const cells = snapshot.cells.map((cell3) => ({ ...cell3, text: decodeCellValue(cell3.value, cell3.type) }));
|
|
4752
4826
|
format({ ...snapshot, cells, totalRows, totalColumns, window }, { format: outputFormat });
|
|
@@ -6185,7 +6259,7 @@ var HELP = [
|
|
|
6185
6259
|
];
|
|
6186
6260
|
async function runChatRepl(options) {
|
|
6187
6261
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
6188
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
6262
|
+
const { getUpdateNotice } = await import("./update-check-TTXILAMD.js");
|
|
6189
6263
|
let sessionId = options.session;
|
|
6190
6264
|
let lastReportedSession;
|
|
6191
6265
|
console.log(chalk19.bold("Diafunc chat") + chalk19.dim(" \xB7 /help for commands, /quit to exit"));
|
|
@@ -6777,8 +6851,8 @@ import chalk21 from "chalk";
|
|
|
6777
6851
|
function createStatusService() {
|
|
6778
6852
|
const config = loadConfig();
|
|
6779
6853
|
const endpoint = resolveEndpoint(config);
|
|
6780
|
-
async function fetchJson(
|
|
6781
|
-
const url = `${endpoint}/status/v1${
|
|
6854
|
+
async function fetchJson(path12) {
|
|
6855
|
+
const url = `${endpoint}/status/v1${path12}`;
|
|
6782
6856
|
const response = await fetch(url, {
|
|
6783
6857
|
headers: { "Accept": "application/json" }
|
|
6784
6858
|
});
|
|
@@ -6976,8 +7050,8 @@ Examples:
|
|
|
6976
7050
|
}
|
|
6977
7051
|
|
|
6978
7052
|
// src/commands/analyze/index.ts
|
|
6979
|
-
import * as
|
|
6980
|
-
import * as
|
|
7053
|
+
import * as fs9 from "fs";
|
|
7054
|
+
import * as path8 from "path";
|
|
6981
7055
|
import { spawn as spawn2 } from "child_process";
|
|
6982
7056
|
|
|
6983
7057
|
// src/commands/analyze/watch-view.ts
|
|
@@ -6997,12 +7071,25 @@ var RUN_PHASE_LABELS = {
|
|
|
6997
7071
|
var RUN_STEPS = ["PREPARING", "PROFILING", "DISCOVERING", "EXPLAINING", "WRITING"];
|
|
6998
7072
|
var STARTING = "Starting";
|
|
6999
7073
|
function phaseLabel(run) {
|
|
7000
|
-
if (run.state === "QUEUED") return
|
|
7074
|
+
if (run.state === "QUEUED") return waitLabel(run);
|
|
7001
7075
|
if (run.state === "DISPATCHING") return STARTING;
|
|
7002
7076
|
if (run.phase && RUN_PHASE_LABELS[run.phase]) return RUN_PHASE_LABELS[run.phase];
|
|
7003
7077
|
if (run.state === "RUNNING" && !((run.progressTotal ?? 0) > 0)) return RUN_PHASE_LABELS.PREPARING;
|
|
7004
7078
|
return run.state.charAt(0) + run.state.slice(1).toLowerCase();
|
|
7005
7079
|
}
|
|
7080
|
+
function waitLabel(run) {
|
|
7081
|
+
switch (run.waitReason) {
|
|
7082
|
+
case "OWN_RUNS":
|
|
7083
|
+
return "Waiting for one of your analyses to finish";
|
|
7084
|
+
case "PLATFORM_BUSY":
|
|
7085
|
+
return "Waiting for a free slot";
|
|
7086
|
+
default:
|
|
7087
|
+
return RUN_PHASE_LABELS.QUEUED;
|
|
7088
|
+
}
|
|
7089
|
+
}
|
|
7090
|
+
function waitCell(run) {
|
|
7091
|
+
return run.waitReason === "OWN_RUNS" ? "Waiting for your runs" : RUN_PHASE_LABELS.QUEUED;
|
|
7092
|
+
}
|
|
7006
7093
|
function stepCounter(run) {
|
|
7007
7094
|
if (!run.phase) return null;
|
|
7008
7095
|
const index = RUN_STEPS.indexOf(run.phase);
|
|
@@ -7011,7 +7098,8 @@ function stepCounter(run) {
|
|
|
7011
7098
|
}
|
|
7012
7099
|
function runPhaseCell(run) {
|
|
7013
7100
|
if (run.state === "COMPLETED") return null;
|
|
7014
|
-
if (run.state === "QUEUED"
|
|
7101
|
+
if (run.state === "QUEUED") return waitCell(run);
|
|
7102
|
+
if (run.state === "DISPATCHING") return phaseLabel(run);
|
|
7015
7103
|
if (run.phase && RUN_PHASE_LABELS[run.phase]) return RUN_PHASE_LABELS[run.phase];
|
|
7016
7104
|
return null;
|
|
7017
7105
|
}
|
|
@@ -7516,8 +7604,64 @@ function constraintsText(analysis) {
|
|
|
7516
7604
|
return parts.length > 0 ? parts.join(", ") : "none";
|
|
7517
7605
|
}
|
|
7518
7606
|
|
|
7607
|
+
// src/commands/analyze/sources.ts
|
|
7608
|
+
import * as fs8 from "fs";
|
|
7609
|
+
import * as path7 from "path";
|
|
7610
|
+
var CAUTIONS = /* @__PURE__ */ new Set(["UNEVEN_COLUMNS", "TYPE_CONFLICT", "SOURCE_WARNING", "LEFT_OUT"]);
|
|
7611
|
+
function recipeWithChoices(proposal, choices) {
|
|
7612
|
+
if (proposal.parts.length < 2) return null;
|
|
7613
|
+
const originColumn = choices.fileColumn ? proposal.originColumn : null;
|
|
7614
|
+
const dropDuplicates = !choices.keepDuplicates;
|
|
7615
|
+
if (originColumn === proposal.originColumn && dropDuplicates === proposal.dropDuplicates) return null;
|
|
7616
|
+
return { parts: proposal.parts, originColumn, dropDuplicates };
|
|
7617
|
+
}
|
|
7618
|
+
function planLines(plan) {
|
|
7619
|
+
const lines = [{
|
|
7620
|
+
text: `One table of ${plan.rows.toLocaleString("en-US")} rows and ${plan.columns.toLocaleString("en-US")} columns.`,
|
|
7621
|
+
caution: false
|
|
7622
|
+
}];
|
|
7623
|
+
for (const finding of plan.findings) {
|
|
7624
|
+
lines.push({ text: finding.message, caution: CAUTIONS.has(finding.kind) });
|
|
7625
|
+
}
|
|
7626
|
+
return lines;
|
|
7627
|
+
}
|
|
7628
|
+
function multipart(file) {
|
|
7629
|
+
const formData = new FormData();
|
|
7630
|
+
formData.append("content", new Blob([fs8.readFileSync(file)]), path7.basename(file));
|
|
7631
|
+
return formData;
|
|
7632
|
+
}
|
|
7633
|
+
async function uploadSeveral(api, analysisId, files, choices, human) {
|
|
7634
|
+
for (const file of files) {
|
|
7635
|
+
if (!fs8.existsSync(file)) {
|
|
7636
|
+
throw new CliError(`File not found: ${file}`, { exitCode: EXIT_USAGE });
|
|
7637
|
+
}
|
|
7638
|
+
}
|
|
7639
|
+
for (const earlier of await api.analysis.listSources(analysisId)) {
|
|
7640
|
+
await api.analysis.removeSource(analysisId, earlier.sourceId);
|
|
7641
|
+
}
|
|
7642
|
+
for (const file of files) {
|
|
7643
|
+
await withStatus(`Uploading ${path7.basename(file)}`, () => api.analysis.addSource(analysisId, multipart(file)));
|
|
7644
|
+
}
|
|
7645
|
+
const plan = await withStatus("Reading the files together", async () => {
|
|
7646
|
+
const proposal = await api.analysis.planSources(analysisId, null);
|
|
7647
|
+
const chosen = recipeWithChoices(proposal.recipe, choices);
|
|
7648
|
+
return chosen ? api.analysis.planSources(analysisId, chosen) : proposal;
|
|
7649
|
+
});
|
|
7650
|
+
if (human) {
|
|
7651
|
+
for (const line of planLines(plan)) {
|
|
7652
|
+
if (line.caution) warn(line.text);
|
|
7653
|
+
else detail(line.text);
|
|
7654
|
+
}
|
|
7655
|
+
}
|
|
7656
|
+
return withStatus(
|
|
7657
|
+
`Building one table from ${plan.recipe.parts.length} file${plan.recipe.parts.length === 1 ? "" : "s"}`,
|
|
7658
|
+
() => api.analysis.buildSources(analysisId, plan.recipe)
|
|
7659
|
+
);
|
|
7660
|
+
}
|
|
7661
|
+
|
|
7519
7662
|
// src/commands/analyze/index.ts
|
|
7520
7663
|
var POLL_INTERVAL_MS = 2e3;
|
|
7664
|
+
var MISSING_RUN_POLLS = 5;
|
|
7521
7665
|
var COLUMN_READ_ATTEMPTS = 3;
|
|
7522
7666
|
var COLUMN_READ_INTERVAL_MS = 1e3;
|
|
7523
7667
|
function openUrl(url) {
|
|
@@ -7537,6 +7681,13 @@ function parseCsv(value) {
|
|
|
7537
7681
|
if (value === void 0) return null;
|
|
7538
7682
|
return value.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
7539
7683
|
}
|
|
7684
|
+
function collectQuestion(value, previous = []) {
|
|
7685
|
+
return previous.concat([value]);
|
|
7686
|
+
}
|
|
7687
|
+
function questionsOf(given) {
|
|
7688
|
+
if (given === void 0) return null;
|
|
7689
|
+
return given.map((question2) => question2.trim()).filter((question2) => question2.length > 0);
|
|
7690
|
+
}
|
|
7540
7691
|
function parseVisibility(value) {
|
|
7541
7692
|
const upper = value.toUpperCase();
|
|
7542
7693
|
if (upper !== "PRIVATE" && upper !== "PUBLIC") {
|
|
@@ -7553,21 +7704,24 @@ function budgetHoursOf(hours) {
|
|
|
7553
7704
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
7554
7705
|
}
|
|
7555
7706
|
function multipartFromFile(file) {
|
|
7556
|
-
const buffer =
|
|
7707
|
+
const buffer = fs9.readFileSync(file);
|
|
7557
7708
|
const blob = new Blob([buffer]);
|
|
7558
7709
|
const formData = new FormData();
|
|
7559
|
-
formData.append("content", blob,
|
|
7710
|
+
formData.append("content", blob, path8.basename(file));
|
|
7560
7711
|
return formData;
|
|
7561
7712
|
}
|
|
7562
7713
|
function reportCommandError(error) {
|
|
7563
7714
|
if (error instanceof PromptCancelled) throw error;
|
|
7564
7715
|
handleError(error);
|
|
7565
7716
|
}
|
|
7566
|
-
async function runAnalysis(
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7717
|
+
async function runAnalysis(files, options, cmd) {
|
|
7718
|
+
for (const candidate of files) {
|
|
7719
|
+
if (!fs9.existsSync(candidate)) {
|
|
7720
|
+
failure(`File not found: ${candidate}`);
|
|
7721
|
+
process.exit(EXIT_FAILURE);
|
|
7722
|
+
}
|
|
7570
7723
|
}
|
|
7724
|
+
const file = files[0];
|
|
7571
7725
|
const outputFormat = getOutputFormat15(cmd);
|
|
7572
7726
|
const noInteractive = noInteractiveFlag(cmd);
|
|
7573
7727
|
const interactive = canPrompt(outputFormat, noInteractive);
|
|
@@ -7581,7 +7735,7 @@ async function runAnalysis(file, options, cmd) {
|
|
|
7581
7735
|
}
|
|
7582
7736
|
const p = opt.preset;
|
|
7583
7737
|
if (options.targets === void 0 && p.targetKeys.length > 0) options.targets = p.targetKeys.join(",");
|
|
7584
|
-
if (options.
|
|
7738
|
+
if (options.question === void 0 && p.questions.length > 0) options.question = [...p.questions];
|
|
7585
7739
|
if (options.segment === void 0 && p.segmentKey) options.segment = p.segmentKey;
|
|
7586
7740
|
if (options.hours === void 0) options.hours = p.time;
|
|
7587
7741
|
if (options.budget === void 0) options.budget = p.budget;
|
|
@@ -7590,11 +7744,11 @@ async function runAnalysis(file, options, cmd) {
|
|
|
7590
7744
|
if (!interactive && (flagTargets === null || flagTargets.length === 0)) {
|
|
7591
7745
|
usageError(
|
|
7592
7746
|
`Target columns are required, and ${whyNoPrompt(outputFormat, noInteractive)}.`,
|
|
7593
|
-
`Pass --targets <csv> or --preset <id>. The names are the column headers of ${
|
|
7747
|
+
`Pass --targets <csv> or --preset <id>. The names are the column headers of ${files.length > 1 ? "the files" : path8.basename(file)}.`
|
|
7594
7748
|
);
|
|
7595
7749
|
}
|
|
7596
7750
|
const prompter = createInquirerPrompter();
|
|
7597
|
-
const fallbackName =
|
|
7751
|
+
const fallbackName = path8.basename(file, path8.extname(file));
|
|
7598
7752
|
const creation = interactive ? await promptCreationFields(prompter, {
|
|
7599
7753
|
name: options.name,
|
|
7600
7754
|
description: options.description,
|
|
@@ -7612,21 +7766,29 @@ async function runAnalysis(file, options, cmd) {
|
|
|
7612
7766
|
hours: options.hours ?? DEFAULT_HOURS,
|
|
7613
7767
|
budget: options.budget ?? DEFAULT_BUDGET,
|
|
7614
7768
|
targets: flagTargets,
|
|
7615
|
-
questions:
|
|
7769
|
+
questions: questionsOf(options.question),
|
|
7616
7770
|
segment: options.segment ?? null
|
|
7617
7771
|
};
|
|
7618
7772
|
const created = await withStatus(`Creating analysis "${creation.name}"`, () => api.analysis.create(request));
|
|
7773
|
+
if (isDryRun()) {
|
|
7774
|
+
hint(`Dry run: nothing was created. A real run would upload ${path8.basename(file)}, queue the analysis and follow it.`);
|
|
7775
|
+
return;
|
|
7776
|
+
}
|
|
7619
7777
|
detail(`analysisId: ${created.analysisId}`);
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7778
|
+
if (files.length > 1) {
|
|
7779
|
+
await uploadSeveral(api, created.analysisId, files, stackChoices(options), outputFormat === "human");
|
|
7780
|
+
} else {
|
|
7781
|
+
await withStatus(
|
|
7782
|
+
`Uploading ${path8.basename(file)}`,
|
|
7783
|
+
() => api.analysis.uploadDataMultipart(created.analysisId, multipartFromFile(file))
|
|
7784
|
+
);
|
|
7785
|
+
}
|
|
7624
7786
|
let runHours = request.hours;
|
|
7625
7787
|
if (interactive) {
|
|
7626
7788
|
const configuredHours = await configureInteractively(api, prompter, created.analysisId, request, {
|
|
7627
7789
|
targets: options.targets === void 0 ? void 0 : parseCsv(options.targets),
|
|
7628
7790
|
segment: options.segment,
|
|
7629
|
-
questions: options.
|
|
7791
|
+
questions: options.question === void 0 ? void 0 : questionsOf(options.question),
|
|
7630
7792
|
hours: options.hours,
|
|
7631
7793
|
budget: options.budget
|
|
7632
7794
|
});
|
|
@@ -7695,16 +7857,30 @@ async function monitorRun(api, analysisId, runId, budgetHours, cmd) {
|
|
|
7695
7857
|
const seenOutputs = /* @__PURE__ */ new Set();
|
|
7696
7858
|
let caption = null;
|
|
7697
7859
|
let lastReported = "";
|
|
7860
|
+
let missingPolls = 0;
|
|
7698
7861
|
if (human) status.start();
|
|
7699
7862
|
try {
|
|
7700
7863
|
for (; ; ) {
|
|
7701
7864
|
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
7702
7865
|
let run = null;
|
|
7866
|
+
let absent = false;
|
|
7703
7867
|
try {
|
|
7704
7868
|
run = (await api.analysis.getRun(runId)).run;
|
|
7705
|
-
|
|
7869
|
+
absent = run === null;
|
|
7870
|
+
} catch (error) {
|
|
7871
|
+
absent = error instanceof ApiError && error.status === 404;
|
|
7872
|
+
}
|
|
7873
|
+
if (!run) {
|
|
7874
|
+
missingPolls = absent ? missingPolls + 1 : 0;
|
|
7875
|
+
if (missingPolls >= MISSING_RUN_POLLS) {
|
|
7876
|
+
status.stop();
|
|
7877
|
+
failure(`Run ${runId} was not found.`);
|
|
7878
|
+
hint(`List the runs with 'diafunc analyze runs ${analysisId}'.`);
|
|
7879
|
+
process.exit(EXIT_FAILURE);
|
|
7880
|
+
}
|
|
7881
|
+
continue;
|
|
7706
7882
|
}
|
|
7707
|
-
|
|
7883
|
+
missingPolls = 0;
|
|
7708
7884
|
try {
|
|
7709
7885
|
for (const out of await api.analysis.getRunOutputs(analysisId, runId)) {
|
|
7710
7886
|
const key = `${out.outputId}:${out.output}`;
|
|
@@ -7923,6 +8099,10 @@ async function rerunAnalysis(analysisId, cmd) {
|
|
|
7923
8099
|
if (configuredHours === null) return;
|
|
7924
8100
|
}
|
|
7925
8101
|
const run = await api.analysis.runAnalysis(analysisId);
|
|
8102
|
+
if (isDryRun()) {
|
|
8103
|
+
hint("Dry run: no run was queued.");
|
|
8104
|
+
return;
|
|
8105
|
+
}
|
|
7926
8106
|
success(`Queued run ${run.runId} for analysis ${analysisId}.`);
|
|
7927
8107
|
hint(`Follow it with 'diafunc analyze watch ${analysisId}'.`);
|
|
7928
8108
|
}
|
|
@@ -7956,29 +8136,56 @@ async function createAnalysis(options, cmd) {
|
|
|
7956
8136
|
hours: options.hours ?? null,
|
|
7957
8137
|
budget: options.budget ?? null,
|
|
7958
8138
|
targets: parseCsv(options.targets),
|
|
7959
|
-
questions:
|
|
8139
|
+
questions: questionsOf(options.question),
|
|
7960
8140
|
segment: options.segment ?? null
|
|
7961
8141
|
};
|
|
7962
8142
|
const created = await api.analysis.create(request);
|
|
8143
|
+
if (isDryRun()) {
|
|
8144
|
+
hint("Dry run: nothing was created.");
|
|
8145
|
+
return;
|
|
8146
|
+
}
|
|
7963
8147
|
format(created, { format: outputFormat });
|
|
7964
8148
|
}
|
|
7965
8149
|
async function deleteAnalysis(analysisId) {
|
|
7966
8150
|
const api = createApiClient();
|
|
7967
8151
|
await api.analysis.delete(analysisId);
|
|
8152
|
+
if (isDryRun()) {
|
|
8153
|
+
hint("Dry run: nothing was deleted.");
|
|
8154
|
+
return;
|
|
8155
|
+
}
|
|
7968
8156
|
success(`Deleted analysis ${analysisId}.`);
|
|
7969
8157
|
}
|
|
7970
8158
|
async function patchAndPrint(analysisId, value, handler, successLabel, cmd) {
|
|
7971
8159
|
const outputFormat = getOutputFormat15(cmd);
|
|
7972
8160
|
const api = createApiClient();
|
|
7973
8161
|
const updated = await handler(api, analysisId, value);
|
|
8162
|
+
if (isDryRun()) {
|
|
8163
|
+
hint("Dry run: nothing was changed.");
|
|
8164
|
+
return;
|
|
8165
|
+
}
|
|
7974
8166
|
if (outputFormat === "human") {
|
|
7975
8167
|
success(`${successLabel} updated for analysis ${analysisId}.`);
|
|
7976
8168
|
} else {
|
|
7977
8169
|
format(updated, { format: outputFormat });
|
|
7978
8170
|
}
|
|
7979
8171
|
}
|
|
7980
|
-
|
|
8172
|
+
function stackChoices(options) {
|
|
8173
|
+
return { fileColumn: options.fileColumn !== false, keepDuplicates: options.keepDuplicates === true };
|
|
8174
|
+
}
|
|
8175
|
+
async function uploadData(analysisId, files, options, cmd) {
|
|
7981
8176
|
const api = createApiClient();
|
|
8177
|
+
const file = files[0];
|
|
8178
|
+
if (files.length > 1) {
|
|
8179
|
+
if (options.url) {
|
|
8180
|
+
usageError("Provide either files or --url, not both.", "Drop one of the two and run it again.");
|
|
8181
|
+
}
|
|
8182
|
+
const outputFormat = getOutputFormat15(cmd);
|
|
8183
|
+
const build = await uploadSeveral(api, analysisId, files, stackChoices(options), outputFormat === "human");
|
|
8184
|
+
if (outputFormat !== "human") {
|
|
8185
|
+
format(build, { format: outputFormat });
|
|
8186
|
+
}
|
|
8187
|
+
return;
|
|
8188
|
+
}
|
|
7982
8189
|
const dataUrl = options.url;
|
|
7983
8190
|
if (dataUrl) {
|
|
7984
8191
|
if (file) {
|
|
@@ -7993,11 +8200,11 @@ async function uploadData(analysisId, file, options) {
|
|
|
7993
8200
|
`For example: diafunc analyze upload ${analysisId} data.csv`
|
|
7994
8201
|
);
|
|
7995
8202
|
}
|
|
7996
|
-
if (!
|
|
8203
|
+
if (!fs9.existsSync(file)) {
|
|
7997
8204
|
throw new CliError(`File not found: ${file}`, { exitCode: EXIT_USAGE });
|
|
7998
8205
|
}
|
|
7999
8206
|
await withStatus(
|
|
8000
|
-
`Uploading ${
|
|
8207
|
+
`Uploading ${path8.basename(file)}`,
|
|
8001
8208
|
() => api.analysis.uploadDataMultipart(analysisId, multipartFromFile(file))
|
|
8002
8209
|
);
|
|
8003
8210
|
}
|
|
@@ -8091,12 +8298,16 @@ async function savePreset(options, cmd) {
|
|
|
8091
8298
|
presetId: options.id ?? null,
|
|
8092
8299
|
name: options.name,
|
|
8093
8300
|
targetKeys: parseCsv(options.targets) ?? [],
|
|
8094
|
-
questions:
|
|
8301
|
+
questions: questionsOf(options.question) ?? [],
|
|
8095
8302
|
segmentKey: options.segment ?? null,
|
|
8096
8303
|
time: options.hours,
|
|
8097
8304
|
budget: options.budget
|
|
8098
8305
|
};
|
|
8099
8306
|
const saved = await api.analysis.savePreset(preset);
|
|
8307
|
+
if (isDryRun()) {
|
|
8308
|
+
hint("Dry run: nothing was saved.");
|
|
8309
|
+
return;
|
|
8310
|
+
}
|
|
8100
8311
|
format(saved, { format: outputFormat });
|
|
8101
8312
|
}
|
|
8102
8313
|
async function deletePreset(presetId) {
|
|
@@ -8168,13 +8379,13 @@ async function updateTriggerCmd(triggerId, options, cmd) {
|
|
|
8168
8379
|
}
|
|
8169
8380
|
function registerAnalyzeCommand(program) {
|
|
8170
8381
|
const analyze = program.command("analyze").description("Run and manage automatic analyses");
|
|
8171
|
-
analyze.command("run", { isDefault: true }).description("Create an analysis from a data file, configure it and run it (the default: `analyze <file>`)").argument("[
|
|
8382
|
+
analyze.command("run", { isDefault: true }).description("Create an analysis from a data file, configure it and run it (the default: `analyze <file>`)").argument("[files...]", "Data file to analyze (CSV, Excel and more than 45 file formats; see `table import-formats`). Several files with the same columns are stacked into one table").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 (hours). Default ${DEFAULT_HOURS}, the Standard preset; a saved preset applies when omitted`).option("--budget <credits>", `Credit budget. Default ${Number(DEFAULT_BUDGET).toLocaleString("en-US")}, the Standard preset; a saved preset applies when omitted`).option("--targets <csv>", "Comma-separated target column names (required when not interactive)").option("--question <text>", "A question for the analysis to answer; repeat the flag for several", collectQuestion).option("--segment <name>", "Column to segment the analysis by").option("--introduction <markdown>", "Markdown introduction shown at the top of the notebook").option("--preset <id>", "Apply a saved preset as defaults (explicit flags override it)").option("--no-file-column", "With several files: do not add the column that records the file each row came from").option("--keep-duplicates", "With several files: keep rows that occur in more than one file").action(async (files, options, cmd) => {
|
|
8172
8383
|
try {
|
|
8173
|
-
if (
|
|
8384
|
+
if (files.length === 0) {
|
|
8174
8385
|
analyze.help();
|
|
8175
8386
|
return;
|
|
8176
8387
|
}
|
|
8177
|
-
await runAnalysis(
|
|
8388
|
+
await runAnalysis(files, options, cmd);
|
|
8178
8389
|
} catch (error) {
|
|
8179
8390
|
reportCommandError(error);
|
|
8180
8391
|
}
|
|
@@ -8214,7 +8425,7 @@ function registerAnalyzeCommand(program) {
|
|
|
8214
8425
|
reportCommandError(error);
|
|
8215
8426
|
}
|
|
8216
8427
|
});
|
|
8217
|
-
analyze.command("create").description("Create an analysis without uploading data or running it").option("--name <name>", "Analysis name").option("--description <text>", "Analysis description").option("--visibility <vis>", "PRIVATE or PUBLIC", "PRIVATE").option("--hours <hours>", "Computation time (hours)").option("--budget <credits>", "Credit budget").option("--targets <csv>", "Comma-separated target column names").option("--
|
|
8428
|
+
analyze.command("create").description("Create an analysis without uploading data or running it").option("--name <name>", "Analysis name").option("--description <text>", "Analysis description").option("--visibility <vis>", "PRIVATE or PUBLIC", "PRIVATE").option("--hours <hours>", "Computation time (hours)").option("--budget <credits>", "Credit budget").option("--targets <csv>", "Comma-separated target column names").option("--question <text>", "A question for the analysis to answer; repeat the flag for several", collectQuestion).option("--segment <name>", "Column to segment the analysis by").option("--introduction <markdown>", "Markdown introduction shown at the top of the notebook").action(async (options, cmd) => {
|
|
8218
8429
|
try {
|
|
8219
8430
|
await createAnalysis(options, cmd);
|
|
8220
8431
|
} catch (error) {
|
|
@@ -8350,12 +8561,12 @@ function registerAnalyzeCommand(program) {
|
|
|
8350
8561
|
handleError(error);
|
|
8351
8562
|
}
|
|
8352
8563
|
});
|
|
8353
|
-
analyze.command("questions").description("Set the questions
|
|
8564
|
+
analyze.command("questions").description("Set the questions the analysis answers, one argument per question").argument("<id>", "Analysis ID").argument("<question...>", "The questions, each quoted as one argument (a single empty string clears them)").action(async (id, given, _options, cmd) => {
|
|
8354
8565
|
try {
|
|
8355
|
-
const questions =
|
|
8566
|
+
const questions = questionsOf(Array.isArray(given) ? given : [given]) ?? [];
|
|
8356
8567
|
await patchAndPrint(
|
|
8357
8568
|
id,
|
|
8358
|
-
|
|
8569
|
+
questions.join(" | "),
|
|
8359
8570
|
(api, aid) => api.analysis.patchQuestions(aid, { questions }),
|
|
8360
8571
|
"Questions",
|
|
8361
8572
|
cmd
|
|
@@ -8377,9 +8588,9 @@ function registerAnalyzeCommand(program) {
|
|
|
8377
8588
|
handleError(error);
|
|
8378
8589
|
}
|
|
8379
8590
|
});
|
|
8380
|
-
analyze.command("upload").description("Replace the analysis data with a new file (any supported format; see `table import-formats`)").argument("<id>", "Analysis ID").argument("[
|
|
8591
|
+
analyze.command("upload").description("Replace the analysis data with a new file (any supported format; see `table import-formats`)").argument("<id>", "Analysis ID").argument("[files...]", "Data file to upload (CSV, Excel and more than 45 file formats; see `table import-formats`). Several files with the same columns are stacked into one table").option("--url <url>", "HTTPS URL to fetch the data file from, instead of a file path").option("--no-file-column", "With several files: do not add the column that records the file each row came from").option("--keep-duplicates", "With several files: keep rows that occur in more than one file").action(async (id, files, options, cmd) => {
|
|
8381
8592
|
try {
|
|
8382
|
-
await uploadData(id,
|
|
8593
|
+
await uploadData(id, files, options, cmd);
|
|
8383
8594
|
} catch (error) {
|
|
8384
8595
|
handleError(error);
|
|
8385
8596
|
}
|
|
@@ -8420,7 +8631,7 @@ function registerAnalyzeCommand(program) {
|
|
|
8420
8631
|
handleError(error);
|
|
8421
8632
|
}
|
|
8422
8633
|
});
|
|
8423
|
-
presets.command("save").description("Create a new preset (omit --id) or update an existing one (with --id)").requiredOption("--name <name>", "Preset name").requiredOption("--targets <csv>", "Comma-separated target column names").requiredOption("--hours <hours>", "Computation time (hours)").requiredOption("--budget <credits>", "Credit budget").option("--
|
|
8634
|
+
presets.command("save").description("Create a new preset (omit --id) or update an existing one (with --id)").requiredOption("--name <name>", "Preset name").requiredOption("--targets <csv>", "Comma-separated target column names").requiredOption("--hours <hours>", "Computation time (hours)").requiredOption("--budget <credits>", "Credit budget").option("--question <text>", "A question for the analysis to answer; repeat the flag for several", collectQuestion).option("--segment <name>", "Column to segment the analysis by").option("--id <id>", "Existing preset ID (update mode)").action(async (options, cmd) => {
|
|
8424
8635
|
try {
|
|
8425
8636
|
await savePreset(options, cmd);
|
|
8426
8637
|
} catch (error) {
|
|
@@ -8906,7 +9117,7 @@ function registerTableExportersCommands(program) {
|
|
|
8906
9117
|
|
|
8907
9118
|
// src/commands/skeleton/index.ts
|
|
8908
9119
|
import chalk28 from "chalk";
|
|
8909
|
-
import * as
|
|
9120
|
+
import * as fs10 from "fs";
|
|
8910
9121
|
function getOutputFormat18(cmd) {
|
|
8911
9122
|
const config = loadConfig();
|
|
8912
9123
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -8930,10 +9141,10 @@ function resolveTemplate(raw) {
|
|
|
8930
9141
|
if (!file) {
|
|
8931
9142
|
throw new Error("--template @ requires a filename after the @, e.g. --template @template.txt");
|
|
8932
9143
|
}
|
|
8933
|
-
if (!
|
|
9144
|
+
if (!fs10.existsSync(file)) {
|
|
8934
9145
|
throw new Error(`Template file not found: ${file}`);
|
|
8935
9146
|
}
|
|
8936
|
-
return
|
|
9147
|
+
return fs10.readFileSync(file, "utf-8").trim();
|
|
8937
9148
|
}
|
|
8938
9149
|
return raw;
|
|
8939
9150
|
}
|
|
@@ -9568,7 +9779,7 @@ Examples:
|
|
|
9568
9779
|
}
|
|
9569
9780
|
|
|
9570
9781
|
// src/commands/invoice/index.ts
|
|
9571
|
-
import * as
|
|
9782
|
+
import * as fs11 from "fs";
|
|
9572
9783
|
function getOutputFormat22(cmd) {
|
|
9573
9784
|
const config = loadConfig();
|
|
9574
9785
|
const globalOpts = cmd.optsWithGlobals();
|
|
@@ -9606,7 +9817,7 @@ Examples:
|
|
|
9606
9817
|
const response = await api.admin.downloadInvoice(invoiceNumber, fileName);
|
|
9607
9818
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
9608
9819
|
const outPath = options.out ?? fileName;
|
|
9609
|
-
|
|
9820
|
+
fs11.writeFileSync(outPath, buffer);
|
|
9610
9821
|
success(`Invoice saved to ${outPath}`);
|
|
9611
9822
|
} catch (error) {
|
|
9612
9823
|
handleError(error);
|
|
@@ -9616,9 +9827,9 @@ Examples:
|
|
|
9616
9827
|
|
|
9617
9828
|
// src/commands/shell/index.ts
|
|
9618
9829
|
import chalk31 from "chalk";
|
|
9619
|
-
import * as
|
|
9830
|
+
import * as fs12 from "fs";
|
|
9620
9831
|
import * as os3 from "os";
|
|
9621
|
-
import * as
|
|
9832
|
+
import * as path9 from "path";
|
|
9622
9833
|
import { spawn as spawn3 } from "child_process";
|
|
9623
9834
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
9624
9835
|
function extensionFor2(language) {
|
|
@@ -9631,16 +9842,16 @@ function extensionFor2(language) {
|
|
|
9631
9842
|
return "txt";
|
|
9632
9843
|
}
|
|
9633
9844
|
async function openInEditor(initial, ext) {
|
|
9634
|
-
const tmpFile =
|
|
9635
|
-
|
|
9845
|
+
const tmpFile = path9.join(os3.tmpdir(), `diafunc-shell-${randomUUID3()}.${ext}`);
|
|
9846
|
+
fs12.writeFileSync(tmpFile, initial);
|
|
9636
9847
|
const editor = process.env.VISUAL ?? process.env.EDITOR ?? "vi";
|
|
9637
9848
|
await new Promise((resolve, reject) => {
|
|
9638
9849
|
const child = spawn3(editor, [tmpFile], { stdio: "inherit" });
|
|
9639
9850
|
child.on("exit", (code) => code === 0 ? resolve() : reject(new Error(`Editor exited with ${code}`)));
|
|
9640
9851
|
child.on("error", reject);
|
|
9641
9852
|
});
|
|
9642
|
-
const content =
|
|
9643
|
-
|
|
9853
|
+
const content = fs12.readFileSync(tmpFile, "utf-8");
|
|
9854
|
+
fs12.unlinkSync(tmpFile);
|
|
9644
9855
|
return content;
|
|
9645
9856
|
}
|
|
9646
9857
|
function utcNowParts() {
|
|
@@ -9716,7 +9927,7 @@ function registerShellCommand(program) {
|
|
|
9716
9927
|
});
|
|
9717
9928
|
const api = createApiClient();
|
|
9718
9929
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
9719
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
9930
|
+
const { getUpdateNotice } = await import("./update-check-TTXILAMD.js");
|
|
9720
9931
|
const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
|
|
9721
9932
|
console.log(chalk31.bold("Diafunc shell") + chalk31.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
|
|
9722
9933
|
console.log(chalk31.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
|
|
@@ -9773,11 +9984,11 @@ function registerShellCommand(program) {
|
|
|
9773
9984
|
console.log(chalk31.dim("usage: /file <path>"));
|
|
9774
9985
|
continue;
|
|
9775
9986
|
}
|
|
9776
|
-
if (!
|
|
9987
|
+
if (!fs12.existsSync(arg)) {
|
|
9777
9988
|
console.log(chalk31.red(`file not found: ${arg}`));
|
|
9778
9989
|
continue;
|
|
9779
9990
|
}
|
|
9780
|
-
const sourceCode =
|
|
9991
|
+
const sourceCode = fs12.readFileSync(arg, "utf-8");
|
|
9781
9992
|
try {
|
|
9782
9993
|
await evaluate(api, fnRef, language, sourceCode);
|
|
9783
9994
|
} catch (e) {
|
|
@@ -9804,18 +10015,18 @@ function registerShellCommand(program) {
|
|
|
9804
10015
|
|
|
9805
10016
|
// src/commands/update/index.ts
|
|
9806
10017
|
import chalk32 from "chalk";
|
|
9807
|
-
import * as
|
|
10018
|
+
import * as path10 from "path";
|
|
9808
10019
|
import { spawn as spawn4 } from "child_process";
|
|
9809
10020
|
|
|
9810
10021
|
// src/util/install-method.ts
|
|
9811
|
-
import * as
|
|
10022
|
+
import * as fs13 from "fs";
|
|
9812
10023
|
function detectInstall() {
|
|
9813
10024
|
const exec = process.execPath;
|
|
9814
10025
|
const exe = exec.replace(/\\/g, "/").toLowerCase();
|
|
9815
10026
|
const isNode = exe.endsWith("/node") || exe.endsWith("/node.exe");
|
|
9816
10027
|
return {
|
|
9817
10028
|
method: isNode ? "npm" : "binary",
|
|
9818
|
-
binaryPath: isNode ? exec :
|
|
10029
|
+
binaryPath: isNode ? exec : fs13.realpathSync(exec)
|
|
9819
10030
|
};
|
|
9820
10031
|
}
|
|
9821
10032
|
|
|
@@ -9859,7 +10070,7 @@ function registerUpdateCommand(program) {
|
|
|
9859
10070
|
console.log(chalk32.bold(` npm install -g @diafunc/cli@${latest}`));
|
|
9860
10071
|
return;
|
|
9861
10072
|
}
|
|
9862
|
-
const installDir =
|
|
10073
|
+
const installDir = path10.dirname(install.binaryPath);
|
|
9863
10074
|
console.log(`Installing diafunc ${latest} to ${installDir}...`);
|
|
9864
10075
|
console.log();
|
|
9865
10076
|
await runInstaller(installDir);
|
|
@@ -9872,18 +10083,18 @@ function registerUpdateCommand(program) {
|
|
|
9872
10083
|
// src/commands/uninstall/index.ts
|
|
9873
10084
|
import chalk33 from "chalk";
|
|
9874
10085
|
import { spawn as spawn5 } from "child_process";
|
|
9875
|
-
import * as
|
|
10086
|
+
import * as fs14 from "fs";
|
|
9876
10087
|
import * as os4 from "os";
|
|
9877
|
-
import * as
|
|
10088
|
+
import * as path11 from "path";
|
|
9878
10089
|
function registerUninstallCommand(program) {
|
|
9879
10090
|
program.command("uninstall").description("Remove the CLI binary and (optionally) its config from this machine").option("-y, --yes", "Skip confirmation prompts").option("--purge", "Also remove ~/.diafunc/ (config + credentials) without prompting").action(async (options) => {
|
|
9880
10091
|
try {
|
|
9881
10092
|
const install = detectInstall();
|
|
9882
|
-
const configDir =
|
|
10093
|
+
const configDir = path11.join(os4.homedir(), ".diafunc");
|
|
9883
10094
|
if (install.method === "npm") {
|
|
9884
10095
|
console.log("Installed via npm. Remove with:");
|
|
9885
10096
|
console.log(chalk33.bold(" npm uninstall -g @diafunc/cli"));
|
|
9886
|
-
if (
|
|
10097
|
+
if (fs14.existsSync(configDir)) {
|
|
9887
10098
|
console.log();
|
|
9888
10099
|
console.log(`Config and credentials live at ${configDir}. Remove them manually with:`);
|
|
9889
10100
|
console.log(chalk33.bold(` rm -rf ${configDir}`));
|
|
@@ -9900,14 +10111,14 @@ function registerUninstallCommand(program) {
|
|
|
9900
10111
|
return;
|
|
9901
10112
|
}
|
|
9902
10113
|
let removeConfig = options.purge ?? false;
|
|
9903
|
-
if (!options.purge && !options.yes &&
|
|
10114
|
+
if (!options.purge && !options.yes && fs14.existsSync(configDir)) {
|
|
9904
10115
|
removeConfig = await confirm({
|
|
9905
10116
|
message: `Also remove ${configDir} (config + credentials)?`,
|
|
9906
10117
|
default: false
|
|
9907
10118
|
});
|
|
9908
10119
|
}
|
|
9909
|
-
if (removeConfig &&
|
|
9910
|
-
|
|
10120
|
+
if (removeConfig && fs14.existsSync(configDir)) {
|
|
10121
|
+
fs14.rmSync(configDir, { recursive: true, force: true });
|
|
9911
10122
|
console.log(chalk33.dim(`Removed ${configDir}`));
|
|
9912
10123
|
}
|
|
9913
10124
|
if (process.platform === "win32") {
|
|
@@ -9923,7 +10134,7 @@ function registerUninstallCommand(program) {
|
|
|
9923
10134
|
console.log("diafunc uninstalled.");
|
|
9924
10135
|
return;
|
|
9925
10136
|
}
|
|
9926
|
-
|
|
10137
|
+
fs14.rmSync(install.binaryPath, { force: true });
|
|
9927
10138
|
console.log(chalk33.dim(`Removed ${install.binaryPath}`));
|
|
9928
10139
|
console.log();
|
|
9929
10140
|
console.log("diafunc uninstalled.");
|
|
@@ -10012,7 +10223,7 @@ var BY_COMMAND = {
|
|
|
10012
10223
|
"analyze targets": { "<csv>": { kind: "analysisColumns", multiple: true, allowEmpty: false } },
|
|
10013
10224
|
"analyze feature-exclusions": { "<csv>": { kind: "analysisColumns", multiple: true, allowEmpty: true } },
|
|
10014
10225
|
"analyze confirmed-inputs": { "<csv>": { kind: "analysisColumns", multiple: true, allowEmpty: true } },
|
|
10015
|
-
"analyze questions": { "<
|
|
10226
|
+
"analyze questions": { "<question>": TEXT_OR_EMPTY },
|
|
10016
10227
|
"analyze description": { "<text>": TEXT_OR_EMPTY },
|
|
10017
10228
|
"analyze introduction": { "<markdown>": TEXT_OR_EMPTY },
|
|
10018
10229
|
"analyze presets save": { "--targets": TEXT, "--hours": POSITIVE, "--budget": POSITIVE },
|
|
@@ -10111,11 +10322,11 @@ var BY_NAME = {
|
|
|
10111
10322
|
function tokenOf(input) {
|
|
10112
10323
|
return input.kind === "option" ? input.flag ?? `--${input.name}` : `<${input.name}>`;
|
|
10113
10324
|
}
|
|
10114
|
-
function specFor(
|
|
10115
|
-
const exact = BY_COMMAND[
|
|
10325
|
+
function specFor(path12, input) {
|
|
10326
|
+
const exact = BY_COMMAND[path12]?.[tokenOf(input)];
|
|
10116
10327
|
if (exact) return exact;
|
|
10117
|
-
const group =
|
|
10118
|
-
const sub =
|
|
10328
|
+
const group = path12.split(" ")[0];
|
|
10329
|
+
const sub = path12.split(" ").slice(0, 2).join(" ");
|
|
10119
10330
|
switch (input.name) {
|
|
10120
10331
|
case "ref":
|
|
10121
10332
|
case "sourceRef":
|
|
@@ -10182,7 +10393,7 @@ function dependencies(spec) {
|
|
|
10182
10393
|
}
|
|
10183
10394
|
|
|
10184
10395
|
// src/prompting/pickers.ts
|
|
10185
|
-
import * as
|
|
10396
|
+
import * as fs15 from "fs";
|
|
10186
10397
|
import chalk34 from "chalk";
|
|
10187
10398
|
var SEARCH_THRESHOLD = 10;
|
|
10188
10399
|
var TYPE_IT = "\0type-it";
|
|
@@ -10317,7 +10528,7 @@ async function askFor(spec, input, ctx) {
|
|
|
10317
10528
|
}
|
|
10318
10529
|
case "file":
|
|
10319
10530
|
return typed(ctx, question(input), {
|
|
10320
|
-
validate: (value) =>
|
|
10531
|
+
validate: (value) => fs15.existsSync(value.trim()) || `No file at ${value.trim()}.`
|
|
10321
10532
|
});
|
|
10322
10533
|
case "number":
|
|
10323
10534
|
return typed(ctx, question(input), { validate: numberRule(spec) });
|
|
@@ -10763,4 +10974,4 @@ export {
|
|
|
10763
10974
|
PromptCancelled,
|
|
10764
10975
|
createProgram
|
|
10765
10976
|
};
|
|
10766
|
-
//# sourceMappingURL=chunk-
|
|
10977
|
+
//# sourceMappingURL=chunk-OCZSFCU6.js.map
|