@diafunc/cli 0.31.0 → 0.31.2
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 +11 -1
- package/dist/bin/diafunc.js +3 -3
- package/dist/{chunk-QX7F5YXI.js → chunk-2BL23GQZ.js} +2 -2
- package/dist/{chunk-QX7F5YXI.js.map → chunk-2BL23GQZ.js.map} +1 -1
- package/dist/{chunk-AH6DCAHU.js → chunk-FP3ZMLXZ.js} +36 -25
- package/dist/chunk-FP3ZMLXZ.js.map +1 -0
- package/dist/{chunk-PUTTVRZA.js → chunk-U554YXJR.js} +2 -2
- package/dist/src/index.js +2 -2
- package/dist/update-check-WNT76O6I.js +8 -0
- package/package.json +1 -1
- package/dist/chunk-AH6DCAHU.js.map +0 -1
- package/dist/update-check-JWT4C4O5.js +0 -8
- /package/dist/{chunk-PUTTVRZA.js.map → chunk-U554YXJR.js.map} +0 -0
- /package/dist/{update-check-JWT4C4O5.js.map → update-check-WNT76O6I.js.map} +0 -0
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ Config is stored at `~/.diafunc/config.json` with 0600 permissions.
|
|
|
109
109
|
|
|
110
110
|
### Profiles
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
A profile is one endpoint with one sign-in. Use several for different environments or different accounts:
|
|
113
113
|
|
|
114
114
|
```bash
|
|
115
115
|
diafunc config profile add staging --endpoint https://staging.diafunc.com
|
|
@@ -117,6 +117,16 @@ diafunc config profile use staging
|
|
|
117
117
|
diafunc config profile list
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
`-p, --profile <name>` runs one command on another profile without changing the active one. It applies to
|
|
121
|
+
every command, sign-in included: `diafunc -p staging auth login` signs in on `staging` and leaves the
|
|
122
|
+
sign-in of the active profile as it was.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
diafunc config profile add examples --endpoint https://diafunc.com
|
|
126
|
+
diafunc -p examples auth login
|
|
127
|
+
diafunc -p examples whoami
|
|
128
|
+
```
|
|
129
|
+
|
|
120
130
|
### Defaults
|
|
121
131
|
|
|
122
132
|
Reduce repetition by setting default project and branch:
|
package/dist/bin/diafunc.js
CHANGED
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
PromptCanceled,
|
|
5
5
|
createProgram,
|
|
6
6
|
handleError
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-FP3ZMLXZ.js";
|
|
8
8
|
import {
|
|
9
9
|
getUpdateNotice
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-U554YXJR.js";
|
|
11
11
|
import {
|
|
12
12
|
package_default
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-2BL23GQZ.js";
|
|
14
14
|
|
|
15
15
|
// bin/diafunc.ts
|
|
16
16
|
import chalk2 from "chalk";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@diafunc/cli",
|
|
4
|
-
version: "0.31.
|
|
4
|
+
version: "0.31.2",
|
|
5
5
|
description: "Diafunc CLI: the command-line interface for the Diafunc platform",
|
|
6
6
|
type: "module",
|
|
7
7
|
bin: {
|
|
@@ -62,4 +62,4 @@ var package_default = {
|
|
|
62
62
|
export {
|
|
63
63
|
package_default
|
|
64
64
|
};
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-2BL23GQZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@diafunc/cli\",\n \"version\": \"0.31.
|
|
1
|
+
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@diafunc/cli\",\n \"version\": \"0.31.2\",\n \"description\": \"Diafunc CLI: the command-line interface for the Diafunc platform\",\n \"type\": \"module\",\n \"bin\": {\n \"diafunc\": \"./dist/bin/diafunc.js\"\n },\n \"homepage\": \"https://diafunc.com\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://gitlab.com/diafunc/cli.git\"\n },\n \"bugs\": {\n \"url\": \"https://gitlab.com/diafunc/cli/-/issues\"\n },\n \"author\": \"Markus Pollak <markus.pollak@diafunc.com>\",\n \"scripts\": {\n \"build\": \"tsup && node -e \\\"const fs=require('fs');const f='dist/bin/diafunc.js';fs.writeFileSync(f,'#!/usr/bin/env node\\\\n'+fs.readFileSync(f,'utf8'))\\\"\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"lint\": \"tsc --noEmit\",\n \"start\": \"node dist/bin/diafunc.js\",\n \"prepublishOnly\": \"npm run lint && npm test && npm run build\"\n },\n \"files\": [\n \"dist\",\n \"LICENSE\",\n \"README.md\"\n ],\n \"keywords\": [\n \"diafunc\",\n \"cli\",\n \"data-science\",\n \"symbolic-regression\"\n ],\n \"license\": \"Apache-2.0\",\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"dependencies\": {\n \"@inquirer/prompts\": \"^7.0.0\",\n \"chalk\": \"^5.4.0\",\n \"cli-table3\": \"^0.6.5\",\n \"commander\": \"^12.1.0\",\n \"ora\": \"^8.1.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.0.0\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.6.0\",\n \"vitest\": \"^2.1.0\"\n }\n}\n"],"mappings":";AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,KAAO;AAAA,IACL,SAAW;AAAA,EACb;AAAA,EACA,UAAY;AAAA,EACZ,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,QAAU;AAAA,EACV,SAAW;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,MAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAQ;AAAA,IACR,OAAS;AAAA,IACT,gBAAkB;AAAA,EACpB;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,EACX,eAAiB;AAAA,IACf,QAAU;AAAA,IACV,UAAY;AAAA,EACd;AAAA,EACA,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,cAAgB;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAS;AAAA,IACT,cAAc;AAAA,IACd,WAAa;AAAA,IACb,KAAO;AAAA,EACT;AAAA,EACA,iBAAmB;AAAA,IACjB,eAAe;AAAA,IACf,MAAQ;AAAA,IACR,YAAc;AAAA,IACd,QAAU;AAAA,EACZ;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2BL23GQZ.js";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
import chalk41 from "chalk";
|
|
@@ -245,8 +245,15 @@ function profileSidecarFile(profileName, suffix) {
|
|
|
245
245
|
const digest = crypto2.createHash("sha256").update(profileName).digest("hex").slice(0, 8);
|
|
246
246
|
return `${CONFIG_FILE}.${safe}-${digest}.${suffix}`;
|
|
247
247
|
}
|
|
248
|
+
var selectedProfile;
|
|
249
|
+
function selectProfile(name) {
|
|
250
|
+
selectedProfile = name;
|
|
251
|
+
}
|
|
252
|
+
function getActiveProfileName(config) {
|
|
253
|
+
return selectedProfile ?? config.currentProfile;
|
|
254
|
+
}
|
|
248
255
|
function resolveEndpoint(config, profileOverride) {
|
|
249
|
-
const name = profileOverride ?? config
|
|
256
|
+
const name = profileOverride ?? getActiveProfileName(config);
|
|
250
257
|
const profile = config.profiles[name];
|
|
251
258
|
if (!profile) {
|
|
252
259
|
throw new Error(`Profile "${name}" not found.`);
|
|
@@ -566,7 +573,7 @@ function getAuthHeader(auth) {
|
|
|
566
573
|
return void 0;
|
|
567
574
|
}
|
|
568
575
|
async function ensureValidAuth(config, profileOverride) {
|
|
569
|
-
const profileName = profileOverride ?? config
|
|
576
|
+
const profileName = profileOverride ?? getActiveProfileName(config);
|
|
570
577
|
const profile = config.profiles[profileName];
|
|
571
578
|
if (!profile?.auth) return void 0;
|
|
572
579
|
if (profile.auth.type === "device-code" && isTokenExpired(profile.auth)) {
|
|
@@ -1439,9 +1446,9 @@ function registerLoginCommand(parent) {
|
|
|
1439
1446
|
parent.command("login").description("Authenticate with the Diafunc platform").option("--token <token>", "API token (dfat_...) for non-interactive token-based auth").option("--endpoint <url>", "Override the endpoint URL for this login").action(async (options) => {
|
|
1440
1447
|
try {
|
|
1441
1448
|
const config = loadConfig();
|
|
1442
|
-
const profile = config.profiles[config
|
|
1449
|
+
const profile = config.profiles[getActiveProfileName(config)];
|
|
1443
1450
|
if (!profile) {
|
|
1444
|
-
failure(`Profile "${config
|
|
1451
|
+
failure(`Profile "${getActiveProfileName(config)}" not found. Run 'diafunc config profile add' first.`);
|
|
1445
1452
|
process.exit(1);
|
|
1446
1453
|
}
|
|
1447
1454
|
if (options.endpoint) {
|
|
@@ -1449,14 +1456,14 @@ function registerLoginCommand(parent) {
|
|
|
1449
1456
|
}
|
|
1450
1457
|
if (options.token) {
|
|
1451
1458
|
profile.auth = { type: "api-token", token: options.token };
|
|
1452
|
-
await storeSignIn(config
|
|
1459
|
+
await storeSignIn(getActiveProfileName(config), profile);
|
|
1453
1460
|
const client = createHttpClient();
|
|
1454
1461
|
const admin = createAdminService(client);
|
|
1455
1462
|
const user = await admin.getMyUser();
|
|
1456
1463
|
success("Signed in.");
|
|
1457
1464
|
console.log(` User: ${chalk4.bold(user.name)}`);
|
|
1458
1465
|
console.log(` Email: ${user.email}`);
|
|
1459
|
-
console.log(` Profile: ${config
|
|
1466
|
+
console.log(` Profile: ${getActiveProfileName(config)}`);
|
|
1460
1467
|
console.log(` Endpoint: ${profile.endpoint}`);
|
|
1461
1468
|
return;
|
|
1462
1469
|
}
|
|
@@ -1515,14 +1522,14 @@ async function deviceCodeLogin(config, profile) {
|
|
|
1515
1522
|
refreshToken: tokens.refresh_token,
|
|
1516
1523
|
accessTokenExpiry: Date.now() + (tokens.expires_in || ACCESS_TOKEN_LIFETIME_SECONDS) * 1e3
|
|
1517
1524
|
};
|
|
1518
|
-
await storeSignIn(config
|
|
1525
|
+
await storeSignIn(getActiveProfileName(config), profile);
|
|
1519
1526
|
const client = createHttpClient();
|
|
1520
1527
|
const admin = createAdminService(client);
|
|
1521
1528
|
const user = await admin.getMyUser();
|
|
1522
1529
|
success("Signed in.");
|
|
1523
1530
|
console.log(` User: ${chalk4.bold(user.name)}`);
|
|
1524
1531
|
console.log(` Email: ${user.email}`);
|
|
1525
|
-
console.log(` Profile: ${config
|
|
1532
|
+
console.log(` Profile: ${getActiveProfileName(config)}`);
|
|
1526
1533
|
console.log(` Endpoint: ${profile.endpoint}`);
|
|
1527
1534
|
return;
|
|
1528
1535
|
}
|
|
@@ -1562,9 +1569,9 @@ function deriveAuthUrl3(endpoint) {
|
|
|
1562
1569
|
function registerLogoutCommand(parent) {
|
|
1563
1570
|
parent.command("logout").description("Remove stored credentials for the active profile and revoke refresh token if possible").action(async () => {
|
|
1564
1571
|
const config = loadConfig();
|
|
1565
|
-
const profile = config.profiles[config
|
|
1572
|
+
const profile = config.profiles[getActiveProfileName(config)];
|
|
1566
1573
|
if (!profile) {
|
|
1567
|
-
failure(`Profile "${config
|
|
1574
|
+
failure(`Profile "${getActiveProfileName(config)}" not found.`);
|
|
1568
1575
|
process.exit(1);
|
|
1569
1576
|
}
|
|
1570
1577
|
if (!profile.auth) {
|
|
@@ -1586,10 +1593,10 @@ function registerLogoutCommand(parent) {
|
|
|
1586
1593
|
} catch {
|
|
1587
1594
|
}
|
|
1588
1595
|
}
|
|
1589
|
-
await updateStoredProfile(config
|
|
1596
|
+
await updateStoredProfile(getActiveProfileName(config), (stored) => {
|
|
1590
1597
|
delete stored.auth;
|
|
1591
1598
|
});
|
|
1592
|
-
success(`Logged out from profile "${config
|
|
1599
|
+
success(`Logged out from profile "${getActiveProfileName(config)}".`);
|
|
1593
1600
|
});
|
|
1594
1601
|
}
|
|
1595
1602
|
|
|
@@ -2014,13 +2021,13 @@ function registerStatusCommand(parent) {
|
|
|
2014
2021
|
const config = loadConfig();
|
|
2015
2022
|
const globalOpts = cmd.optsWithGlobals();
|
|
2016
2023
|
const outputFormat = globalOpts.output ?? config.defaults.output ?? "human";
|
|
2017
|
-
const profile = config.profiles[config
|
|
2024
|
+
const profile = config.profiles[getActiveProfileName(config)];
|
|
2018
2025
|
if (!profile?.auth) {
|
|
2019
2026
|
if (outputFormat === "json") {
|
|
2020
|
-
console.log(JSON.stringify({ authenticated: false, profile: config
|
|
2027
|
+
console.log(JSON.stringify({ authenticated: false, profile: getActiveProfileName(config) }));
|
|
2021
2028
|
} else {
|
|
2022
2029
|
console.log(chalk7.yellow("Not authenticated."), `Run 'diafunc auth login' to configure credentials.`);
|
|
2023
|
-
console.log(` Profile: ${config
|
|
2030
|
+
console.log(` Profile: ${getActiveProfileName(config)}`);
|
|
2024
2031
|
console.log(` Endpoint: ${profile?.endpoint ?? "not configured"}`);
|
|
2025
2032
|
}
|
|
2026
2033
|
return;
|
|
@@ -2030,7 +2037,7 @@ function registerStatusCommand(parent) {
|
|
|
2030
2037
|
const user = await admin.getMyUser();
|
|
2031
2038
|
const data = {
|
|
2032
2039
|
authenticated: true,
|
|
2033
|
-
profile: config
|
|
2040
|
+
profile: getActiveProfileName(config),
|
|
2034
2041
|
endpoint: profile.endpoint,
|
|
2035
2042
|
authType: profile.auth.type,
|
|
2036
2043
|
userId: user.id,
|
|
@@ -6843,6 +6850,9 @@ function resultText(result, resultEncoding) {
|
|
|
6843
6850
|
if (result === null || result === void 0) return null;
|
|
6844
6851
|
if (resultEncoding === "json") return typeof result === "string" ? result : JSON.stringify(result);
|
|
6845
6852
|
if (resultEncoding === "text") return String(result);
|
|
6853
|
+
if (resultEncoding !== "base64") {
|
|
6854
|
+
throw new Error(`A function result without a known encoding cannot be read (resultEncoding: ${resultEncoding})`);
|
|
6855
|
+
}
|
|
6846
6856
|
const bytes = Buffer.from(String(result), "base64");
|
|
6847
6857
|
const text2 = bytes.toString("utf-8");
|
|
6848
6858
|
return Buffer.from(text2, "utf-8").equals(bytes) ? text2 : String(result);
|
|
@@ -8469,7 +8479,7 @@ var HELP = [
|
|
|
8469
8479
|
];
|
|
8470
8480
|
async function runChatRepl(options) {
|
|
8471
8481
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
8472
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
8482
|
+
const { getUpdateNotice } = await import("./update-check-WNT76O6I.js");
|
|
8473
8483
|
let sessionId = options.session;
|
|
8474
8484
|
let lastReportedSession;
|
|
8475
8485
|
console.log(chalk21.bold("Diafunc chat") + chalk21.dim(" \xB7 /help for commands, /quit to exit"));
|
|
@@ -11221,7 +11231,7 @@ async function reportTerminalRun(api, config, run, analysisId, runId, outputForm
|
|
|
11221
11231
|
async function printNotebookLink(api, config, analysisId) {
|
|
11222
11232
|
try {
|
|
11223
11233
|
const nav = await api.analysis.getNavigation(analysisId);
|
|
11224
|
-
const endpoint = config.profiles[config
|
|
11234
|
+
const endpoint = config.profiles[getActiveProfileName(config)]?.endpoint ?? "https://diafunc.com";
|
|
11225
11235
|
detail(`${endpoint}${nav.labUrl}`);
|
|
11226
11236
|
} catch {
|
|
11227
11237
|
}
|
|
@@ -11274,7 +11284,7 @@ async function getAnalysisDetails(analysisId, options, cmd) {
|
|
|
11274
11284
|
intent: abbreviate(result.analysis.intent ?? null)
|
|
11275
11285
|
};
|
|
11276
11286
|
const config = loadConfig();
|
|
11277
|
-
const endpoint = config.profiles[config
|
|
11287
|
+
const endpoint = config.profiles[getActiveProfileName(config)]?.endpoint ?? "https://diafunc.com";
|
|
11278
11288
|
const details = analysisDetails(analysis, endpoint, await resultVerdict(api, result.analysis));
|
|
11279
11289
|
format(details.data, { format: outputFormat, columns: details.columns });
|
|
11280
11290
|
if (!options.full && isLong(result.analysis.introduction)) {
|
|
@@ -11391,7 +11401,7 @@ async function openAnalysis(analysisId) {
|
|
|
11391
11401
|
return;
|
|
11392
11402
|
}
|
|
11393
11403
|
const config = loadConfig();
|
|
11394
|
-
const endpoint = config.profiles[config
|
|
11404
|
+
const endpoint = config.profiles[getActiveProfileName(config)]?.endpoint ?? "https://diafunc.com";
|
|
11395
11405
|
try {
|
|
11396
11406
|
const nav = await api.analysis.getNavigation(result.analysis.analysisId);
|
|
11397
11407
|
const url = `${endpoint}${nav.labUrl}`;
|
|
@@ -13783,7 +13793,7 @@ function registerWhoamiCommand(program) {
|
|
|
13783
13793
|
const user = await api.admin.getMyUser();
|
|
13784
13794
|
if (outputFormat === "human") {
|
|
13785
13795
|
console.log(chalk34.bold(user.name) + chalk34.dim(` <${user.email}>`));
|
|
13786
|
-
console.log(chalk34.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config
|
|
13796
|
+
console.log(chalk34.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${getActiveProfileName(config)}`));
|
|
13787
13797
|
} else {
|
|
13788
13798
|
format(user, { format: outputFormat });
|
|
13789
13799
|
}
|
|
@@ -14151,10 +14161,10 @@ function registerShellCommand(program) {
|
|
|
14151
14161
|
});
|
|
14152
14162
|
const api = createApiClient();
|
|
14153
14163
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
14154
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
14164
|
+
const { getUpdateNotice } = await import("./update-check-WNT76O6I.js");
|
|
14155
14165
|
const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
|
|
14156
14166
|
console.log(chalk36.bold("Diafunc shell") + chalk36.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
|
|
14157
|
-
console.log(chalk36.dim(`Endpoint: ${config.profiles[config
|
|
14167
|
+
console.log(chalk36.dim(`Endpoint: ${config.profiles[getActiveProfileName(config)]?.endpoint}`));
|
|
14158
14168
|
console.log(chalk36.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
|
|
14159
14169
|
const notice = await getUpdateNotice();
|
|
14160
14170
|
if (notice) console.log(chalk36.dim(notice));
|
|
@@ -14965,6 +14975,7 @@ function createProgram(environment = {}) {
|
|
|
14965
14975
|
writeErr: (str) => process.stderr.write(str)
|
|
14966
14976
|
}).hook("preAction", (thisCommand) => {
|
|
14967
14977
|
const opts = thisCommand.optsWithGlobals();
|
|
14978
|
+
selectProfile(opts.profile);
|
|
14968
14979
|
if (opts.dryRun) setDryRun(true);
|
|
14969
14980
|
if (opts.verbose) setVerbose(true);
|
|
14970
14981
|
if (opts.color === false) chalk41.level = 0;
|
|
@@ -15012,4 +15023,4 @@ export {
|
|
|
15012
15023
|
PromptCanceled,
|
|
15013
15024
|
createProgram
|
|
15014
15025
|
};
|
|
15015
|
-
//# sourceMappingURL=chunk-
|
|
15026
|
+
//# sourceMappingURL=chunk-FP3ZMLXZ.js.map
|