@diafunc/cli 0.5.0 → 0.6.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 +1 -4
- package/dist/bin/diafunc.js +3 -3
- package/dist/{chunk-WC5HTITC.js → chunk-CXC5AQC3.js} +2 -2
- package/dist/{chunk-BQ453MK3.js → chunk-LXTNUI3L.js} +2 -2
- package/dist/{chunk-BQ453MK3.js.map → chunk-LXTNUI3L.js.map} +1 -1
- package/dist/{chunk-BPJNQJQS.js → chunk-SEX4YGKJ.js} +8 -75
- package/dist/chunk-SEX4YGKJ.js.map +1 -0
- package/dist/src/index.js +2 -2
- package/dist/update-check-M7H4GTM7.js +8 -0
- package/package.json +1 -1
- package/dist/chunk-BPJNQJQS.js.map +0 -1
- package/dist/update-check-BCZ3WECC.js +0 -8
- /package/dist/{chunk-WC5HTITC.js.map → chunk-CXC5AQC3.js.map} +0 -0
- /package/dist/{update-check-BCZ3WECC.js.map → update-check-M7H4GTM7.js.map} +0 -0
package/README.md
CHANGED
|
@@ -77,9 +77,6 @@ diafunc auth login
|
|
|
77
77
|
# Non-interactive, for scripts and CI. Get a token from
|
|
78
78
|
# Settings → API Tokens in the web UI.
|
|
79
79
|
diafunc auth login --token dfat_your_token_here
|
|
80
|
-
|
|
81
|
-
# Legacy username/password, kept for environments without a browser.
|
|
82
|
-
diafunc auth login --password
|
|
83
80
|
```
|
|
84
81
|
|
|
85
82
|
`diafunc auth logout` clears the local credentials and revokes the refresh
|
|
@@ -151,7 +148,7 @@ diafunc project create --visibility PRIVATE --dry-run
|
|
|
151
148
|
|
|
152
149
|
| Command | Description |
|
|
153
150
|
|---------|-------------|
|
|
154
|
-
| `diafunc auth` | Login (OIDC device-code
|
|
151
|
+
| `diafunc auth` | Login (OIDC device-code or API token), logout, status, API token management |
|
|
155
152
|
| `diafunc whoami` | Show the currently authenticated user |
|
|
156
153
|
| `diafunc config` | Configuration and profile management |
|
|
157
154
|
| `diafunc project` | Project CRUD, `recent`, `update`, lock/unlock, member management |
|
package/dist/bin/diafunc.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
createProgram
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-SEX4YGKJ.js";
|
|
5
5
|
import {
|
|
6
6
|
getUpdateNotice
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-CXC5AQC3.js";
|
|
8
8
|
import {
|
|
9
9
|
package_default
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-LXTNUI3L.js";
|
|
11
11
|
|
|
12
12
|
// bin/diafunc.ts
|
|
13
13
|
import chalk2 from "chalk";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LXTNUI3L.js";
|
|
4
4
|
|
|
5
5
|
// src/util/update-check.ts
|
|
6
6
|
import * as fs from "fs";
|
|
@@ -72,4 +72,4 @@ async function getUpdateNotice() {
|
|
|
72
72
|
export {
|
|
73
73
|
getUpdateNotice
|
|
74
74
|
};
|
|
75
|
-
//# sourceMappingURL=chunk-
|
|
75
|
+
//# sourceMappingURL=chunk-CXC5AQC3.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@diafunc/cli",
|
|
4
|
-
version: "0.
|
|
4
|
+
version: "0.6.0",
|
|
5
5
|
description: "Diafunc CLI \u2014 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-LXTNUI3L.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@diafunc/cli\",\n \"version\": \"0.
|
|
1
|
+
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@diafunc/cli\",\n \"version\": \"0.6.0\",\n \"description\": \"Diafunc CLI — 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-LXTNUI3L.js";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
import { Command } from "commander";
|
|
@@ -110,14 +110,14 @@ function getAuthHeader(auth) {
|
|
|
110
110
|
if (auth.type === "api-token") {
|
|
111
111
|
return `Bearer ${auth.token}`;
|
|
112
112
|
}
|
|
113
|
-
if (auth.type === "
|
|
113
|
+
if (auth.type === "device-code") {
|
|
114
114
|
return `Bearer ${auth.accessToken}`;
|
|
115
115
|
}
|
|
116
116
|
return void 0;
|
|
117
117
|
}
|
|
118
118
|
function isTokenExpired(auth) {
|
|
119
119
|
if (!auth) return false;
|
|
120
|
-
if (auth.type === "
|
|
120
|
+
if (auth.type === "device-code") {
|
|
121
121
|
return Date.now() >= auth.accessTokenExpiry - 3e4;
|
|
122
122
|
}
|
|
123
123
|
return false;
|
|
@@ -132,22 +132,6 @@ function deriveAuthUrl(endpoint) {
|
|
|
132
132
|
url.pathname = "";
|
|
133
133
|
return url.toString().replace(/\/+$/, "");
|
|
134
134
|
}
|
|
135
|
-
async function refreshSession(endpoint, refreshToken) {
|
|
136
|
-
const url = `${endpoint}/api/v1/admin/sessions/`;
|
|
137
|
-
const response = await fetch(url, {
|
|
138
|
-
method: "PUT",
|
|
139
|
-
headers: { "Content-Type": "text/plain" },
|
|
140
|
-
body: refreshToken
|
|
141
|
-
});
|
|
142
|
-
if (!response.ok) {
|
|
143
|
-
throw new ApiError(response.status, "Session refresh failed. Please log in again.");
|
|
144
|
-
}
|
|
145
|
-
const session = await response.json();
|
|
146
|
-
return {
|
|
147
|
-
accessToken: session.accessToken.raw,
|
|
148
|
-
accessTokenExpiry: session.accessToken.expiry
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
135
|
async function refreshOAuthTokens(endpoint, clientId, refreshToken) {
|
|
152
136
|
const authUrl = deriveAuthUrl(endpoint);
|
|
153
137
|
const response = await fetch(`${authUrl}/token`, {
|
|
@@ -177,16 +161,7 @@ async function ensureValidAuth(config, profileOverride) {
|
|
|
177
161
|
return profile.auth;
|
|
178
162
|
}
|
|
179
163
|
const endpoint = resolveEndpoint(config, profileOverride);
|
|
180
|
-
if (profile.auth.type === "
|
|
181
|
-
const refreshed = await refreshSession(endpoint, profile.auth.refreshToken);
|
|
182
|
-
profile.auth = {
|
|
183
|
-
type: "session",
|
|
184
|
-
accessToken: refreshed.accessToken,
|
|
185
|
-
refreshToken: profile.auth.refreshToken,
|
|
186
|
-
accessTokenExpiry: refreshed.accessTokenExpiry
|
|
187
|
-
};
|
|
188
|
-
saveConfig(config);
|
|
189
|
-
} else if (profile.auth.type === "device-code") {
|
|
164
|
+
if (profile.auth.type === "device-code") {
|
|
190
165
|
const refreshed = await refreshOAuthTokens(endpoint, profile.auth.clientId, profile.auth.refreshToken);
|
|
191
166
|
profile.auth = {
|
|
192
167
|
type: "device-code",
|
|
@@ -664,7 +639,7 @@ function deriveAuthUrl2(endpoint) {
|
|
|
664
639
|
return url.toString().replace(/\/+$/, "");
|
|
665
640
|
}
|
|
666
641
|
function registerLoginCommand(parent) {
|
|
667
|
-
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").
|
|
642
|
+
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) => {
|
|
668
643
|
try {
|
|
669
644
|
const config = loadConfig();
|
|
670
645
|
const profile = config.profiles[config.currentProfile];
|
|
@@ -688,10 +663,6 @@ function registerLoginCommand(parent) {
|
|
|
688
663
|
console.log(` Endpoint: ${profile.endpoint}`);
|
|
689
664
|
return;
|
|
690
665
|
}
|
|
691
|
-
if (options.password) {
|
|
692
|
-
await legacyPasswordLogin(config, profile);
|
|
693
|
-
return;
|
|
694
|
-
}
|
|
695
666
|
await deviceCodeLogin(config, profile);
|
|
696
667
|
} catch (error) {
|
|
697
668
|
handleError(error);
|
|
@@ -771,38 +742,6 @@ Device-code flow failed: ${errorBody.error}${errorBody.error_description ? " \u2
|
|
|
771
742
|
console.error(chalk2.red("\nTimed out waiting for approval."));
|
|
772
743
|
process.exit(1);
|
|
773
744
|
}
|
|
774
|
-
async function legacyPasswordLogin(config, profile) {
|
|
775
|
-
const { input, password } = await import("@inquirer/prompts");
|
|
776
|
-
const username = await input({ message: "Username or email:" });
|
|
777
|
-
const pwd = await password({ message: "Password:" });
|
|
778
|
-
const endpoint = profile.endpoint.replace(/\/+$/, "");
|
|
779
|
-
const response = await fetch(`${endpoint}/api/v1/admin/sessions/`, {
|
|
780
|
-
method: "POST",
|
|
781
|
-
headers: { "Content-Type": "application/json" },
|
|
782
|
-
body: JSON.stringify({ userNameOrEmail: username, password: pwd })
|
|
783
|
-
});
|
|
784
|
-
if (!response.ok) {
|
|
785
|
-
const text = await response.text();
|
|
786
|
-
console.error(chalk2.red("Login failed:"), text || response.statusText);
|
|
787
|
-
process.exit(1);
|
|
788
|
-
}
|
|
789
|
-
const session = await response.json();
|
|
790
|
-
profile.auth = {
|
|
791
|
-
type: "session",
|
|
792
|
-
accessToken: session.accessToken.raw,
|
|
793
|
-
refreshToken: session.refreshToken.raw,
|
|
794
|
-
accessTokenExpiry: session.accessToken.expiry
|
|
795
|
-
};
|
|
796
|
-
saveConfig(config);
|
|
797
|
-
const client = createHttpClient();
|
|
798
|
-
const admin = createAdminService(client);
|
|
799
|
-
const user = await admin.getMyUser();
|
|
800
|
-
console.log(chalk2.green("Logged in successfully (legacy password path)."));
|
|
801
|
-
console.log(` User: ${chalk2.bold(user.name)}`);
|
|
802
|
-
console.log(` Email: ${user.email}`);
|
|
803
|
-
console.log(` Profile: ${config.currentProfile}`);
|
|
804
|
-
console.log(` Endpoint: ${profile.endpoint}`);
|
|
805
|
-
}
|
|
806
745
|
function sleep(ms) {
|
|
807
746
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
808
747
|
}
|
|
@@ -844,12 +783,6 @@ function registerLogoutCommand(parent) {
|
|
|
844
783
|
});
|
|
845
784
|
} catch {
|
|
846
785
|
}
|
|
847
|
-
} else if (profile.auth.type === "session") {
|
|
848
|
-
try {
|
|
849
|
-
const endpoint = profile.endpoint.replace(/\/+$/, "");
|
|
850
|
-
await fetch(`${endpoint}/api/v1/admin/sessions/`, { method: "DELETE" });
|
|
851
|
-
} catch {
|
|
852
|
-
}
|
|
853
786
|
}
|
|
854
787
|
delete profile.auth;
|
|
855
788
|
saveConfig(config);
|
|
@@ -3693,7 +3626,7 @@ Error: ${event.content}`));
|
|
|
3693
3626
|
}
|
|
3694
3627
|
async function runChatRepl(options) {
|
|
3695
3628
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
3696
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
3629
|
+
const { getUpdateNotice } = await import("./update-check-M7H4GTM7.js");
|
|
3697
3630
|
let sessionId = options.session;
|
|
3698
3631
|
console.log(chalk17.bold("Diafunc chat") + chalk17.dim(" \xB7 /help for commands, /quit to exit"));
|
|
3699
3632
|
if (sessionId) {
|
|
@@ -5680,7 +5613,7 @@ function registerShellCommand(program) {
|
|
|
5680
5613
|
});
|
|
5681
5614
|
const api = createApiClient();
|
|
5682
5615
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
5683
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
5616
|
+
const { getUpdateNotice } = await import("./update-check-M7H4GTM7.js");
|
|
5684
5617
|
console.log(chalk28.bold("Diafunc shell") + chalk28.dim(` \xB7 function ${fnRef.entityId} \xB7 ${options.language}`));
|
|
5685
5618
|
console.log(chalk28.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
|
|
5686
5619
|
console.log(chalk28.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
|
|
@@ -5937,4 +5870,4 @@ function createProgram() {
|
|
|
5937
5870
|
export {
|
|
5938
5871
|
createProgram
|
|
5939
5872
|
};
|
|
5940
|
-
//# sourceMappingURL=chunk-
|
|
5873
|
+
//# sourceMappingURL=chunk-SEX4YGKJ.js.map
|