@diafunc/cli 0.3.1 → 0.4.1
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 +9 -5
- package/dist/bin/diafunc.js +24 -4
- package/dist/bin/diafunc.js.map +1 -1
- package/dist/{chunk-PDVC2LAL.js → chunk-7TYSZ6GC.js} +565 -354
- package/dist/chunk-7TYSZ6GC.js.map +1 -0
- package/dist/chunk-C2KAWAWW.js +75 -0
- package/dist/chunk-C2KAWAWW.js.map +1 -0
- package/dist/chunk-FCWSWCFN.js +65 -0
- package/dist/chunk-FCWSWCFN.js.map +1 -0
- package/dist/src/index.js +2 -1
- package/dist/update-check-4DNIH3LQ.js +8 -0
- package/dist/update-check-4DNIH3LQ.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-PDVC2LAL.js.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
package_default
|
|
3
|
+
} from "./chunk-FCWSWCFN.js";
|
|
4
|
+
|
|
5
|
+
// src/util/update-check.ts
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
import * as os from "os";
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
10
|
+
var FETCH_TIMEOUT_MS = 2e3;
|
|
11
|
+
var MANIFEST_URL = "https://diafunc.com/cli/latest.json";
|
|
12
|
+
function cachePath() {
|
|
13
|
+
return path.join(os.homedir(), ".diafunc", "update-check.json");
|
|
14
|
+
}
|
|
15
|
+
function readCache() {
|
|
16
|
+
try {
|
|
17
|
+
const raw = fs.readFileSync(cachePath(), "utf8");
|
|
18
|
+
const parsed = JSON.parse(raw);
|
|
19
|
+
if (Date.now() - parsed.checkedAt < CACHE_TTL_MS) return parsed;
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function writeCache(c) {
|
|
25
|
+
try {
|
|
26
|
+
fs.mkdirSync(path.dirname(cachePath()), { recursive: true });
|
|
27
|
+
fs.writeFileSync(cachePath(), JSON.stringify(c), { mode: 384 });
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function fetchLatestVersion() {
|
|
32
|
+
const controller = new AbortController();
|
|
33
|
+
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
34
|
+
try {
|
|
35
|
+
const res = await fetch(MANIFEST_URL, { signal: controller.signal });
|
|
36
|
+
if (!res.ok) return null;
|
|
37
|
+
const manifest = await res.json();
|
|
38
|
+
return manifest.version ?? null;
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
} finally {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function isNewer(available, current) {
|
|
46
|
+
const a = available.split(".").map((n) => parseInt(n, 10));
|
|
47
|
+
const c = current.split(".").map((n) => parseInt(n, 10));
|
|
48
|
+
for (let i = 0; i < 3; i++) {
|
|
49
|
+
const av = a[i] ?? 0;
|
|
50
|
+
const cv = c[i] ?? 0;
|
|
51
|
+
if (av > cv) return true;
|
|
52
|
+
if (av < cv) return false;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
async function getUpdateNotice() {
|
|
57
|
+
if (process.env.DIAFUNC_NO_UPDATE_CHECK) return null;
|
|
58
|
+
if (!process.stdout.isTTY) return null;
|
|
59
|
+
const cached = readCache();
|
|
60
|
+
let available;
|
|
61
|
+
if (cached) {
|
|
62
|
+
available = cached.available;
|
|
63
|
+
} else {
|
|
64
|
+
available = await fetchLatestVersion();
|
|
65
|
+
writeCache({ checkedAt: Date.now(), available });
|
|
66
|
+
}
|
|
67
|
+
if (!available) return null;
|
|
68
|
+
if (!isNewer(available, package_default.version)) return null;
|
|
69
|
+
return `diafunc ${available} is available \u2014 run \`diafunc update\` to upgrade (current: ${package_default.version}).`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
getUpdateNotice
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=chunk-C2KAWAWW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util/update-check.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport pkg from '../../package.json' with { type: 'json' };\n\nconst CACHE_TTL_MS = 24 * 60 * 60 * 1000;\nconst FETCH_TIMEOUT_MS = 2000;\nconst MANIFEST_URL = 'https://diafunc.com/cli/latest.json';\n\ninterface Cache {\n checkedAt: number;\n available: string | null;\n}\n\nfunction cachePath(): string {\n return path.join(os.homedir(), '.diafunc', 'update-check.json');\n}\n\nfunction readCache(): Cache | null {\n try {\n const raw = fs.readFileSync(cachePath(), 'utf8');\n const parsed = JSON.parse(raw) as Cache;\n if (Date.now() - parsed.checkedAt < CACHE_TTL_MS) return parsed;\n } catch {}\n return null;\n}\n\nfunction writeCache(c: Cache): void {\n try {\n fs.mkdirSync(path.dirname(cachePath()), { recursive: true });\n fs.writeFileSync(cachePath(), JSON.stringify(c), { mode: 0o600 });\n } catch {}\n}\n\nasync function fetchLatestVersion(): Promise<string | null> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n try {\n const res = await fetch(MANIFEST_URL, { signal: controller.signal });\n if (!res.ok) return null;\n const manifest = await res.json() as { version?: string };\n return manifest.version ?? null;\n } catch {\n return null;\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction isNewer(available: string, current: string): boolean {\n const a = available.split('.').map((n) => parseInt(n, 10));\n const c = current.split('.').map((n) => parseInt(n, 10));\n for (let i = 0; i < 3; i++) {\n const av = a[i] ?? 0;\n const cv = c[i] ?? 0;\n if (av > cv) return true;\n if (av < cv) return false;\n }\n return false;\n}\n\nexport async function getUpdateNotice(): Promise<string | null> {\n if (process.env.DIAFUNC_NO_UPDATE_CHECK) return null;\n if (!process.stdout.isTTY) return null;\n\n const cached = readCache();\n let available: string | null;\n if (cached) {\n available = cached.available;\n } else {\n available = await fetchLatestVersion();\n writeCache({ checkedAt: Date.now(), available });\n }\n if (!available) return null;\n if (!isNewer(available, pkg.version)) return null;\n return `diafunc ${available} is available — run \\`diafunc update\\` to upgrade (current: ${pkg.version}).`;\n}\n"],"mappings":";;;;;AAAA,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,YAAY,UAAU;AAGtB,IAAM,eAAe,KAAK,KAAK,KAAK;AACpC,IAAM,mBAAmB;AACzB,IAAM,eAAe;AAOrB,SAAS,YAAoB;AAC3B,SAAY,UAAQ,WAAQ,GAAG,YAAY,mBAAmB;AAChE;AAEA,SAAS,YAA0B;AACjC,MAAI;AACF,UAAM,MAAS,gBAAa,UAAU,GAAG,MAAM;AAC/C,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,QAAI,KAAK,IAAI,IAAI,OAAO,YAAY,aAAc,QAAO;AAAA,EAC3D,QAAQ;AAAA,EAAC;AACT,SAAO;AACT;AAEA,SAAS,WAAW,GAAgB;AAClC,MAAI;AACF,IAAG,aAAe,aAAQ,UAAU,CAAC,GAAG,EAAE,WAAW,KAAK,CAAC;AAC3D,IAAG,iBAAc,UAAU,GAAG,KAAK,UAAU,CAAC,GAAG,EAAE,MAAM,IAAM,CAAC;AAAA,EAClE,QAAQ;AAAA,EAAC;AACX;AAEA,eAAe,qBAA6C;AAC1D,QAAM,aAAa,IAAI,gBAAgB;AACvC,QAAM,QAAQ,WAAW,MAAM,WAAW,MAAM,GAAG,gBAAgB;AACnE,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,cAAc,EAAE,QAAQ,WAAW,OAAO,CAAC;AACnE,QAAI,CAAC,IAAI,GAAI,QAAO;AACpB,UAAM,WAAW,MAAM,IAAI,KAAK;AAChC,WAAO,SAAS,WAAW;AAAA,EAC7B,QAAQ;AACN,WAAO;AAAA,EACT,UAAE;AACA,iBAAa,KAAK;AAAA,EACpB;AACF;AAEA,SAAS,QAAQ,WAAmB,SAA0B;AAC5D,QAAM,IAAI,UAAU,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AACzD,QAAM,IAAI,QAAQ,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AACvD,WAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,UAAM,KAAK,EAAE,CAAC,KAAK;AACnB,UAAM,KAAK,EAAE,CAAC,KAAK;AACnB,QAAI,KAAK,GAAI,QAAO;AACpB,QAAI,KAAK,GAAI,QAAO;AAAA,EACtB;AACA,SAAO;AACT;AAEA,eAAsB,kBAA0C;AAC9D,MAAI,QAAQ,IAAI,wBAAyB,QAAO;AAChD,MAAI,CAAC,QAAQ,OAAO,MAAO,QAAO;AAElC,QAAM,SAAS,UAAU;AACzB,MAAI;AACJ,MAAI,QAAQ;AACV,gBAAY,OAAO;AAAA,EACrB,OAAO;AACL,gBAAY,MAAM,mBAAmB;AACrC,eAAW,EAAE,WAAW,KAAK,IAAI,GAAG,UAAU,CAAC;AAAA,EACjD;AACA,MAAI,CAAC,UAAW,QAAO;AACvB,MAAI,CAAC,QAAQ,WAAW,gBAAI,OAAO,EAAG,QAAO;AAC7C,SAAO,WAAW,SAAS,oEAA+D,gBAAI,OAAO;AACvG;","names":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// package.json
|
|
2
|
+
var package_default = {
|
|
3
|
+
name: "@diafunc/cli",
|
|
4
|
+
version: "0.4.1",
|
|
5
|
+
description: "Diafunc CLI \u2014 command-line interface for the Diafunc platform",
|
|
6
|
+
type: "module",
|
|
7
|
+
bin: {
|
|
8
|
+
diafunc: "./dist/bin/diafunc.js"
|
|
9
|
+
},
|
|
10
|
+
homepage: "https://diafunc.com",
|
|
11
|
+
repository: {
|
|
12
|
+
type: "git",
|
|
13
|
+
url: "git+https://gitlab.com/diafunc/cli.git"
|
|
14
|
+
},
|
|
15
|
+
bugs: {
|
|
16
|
+
url: "https://gitlab.com/diafunc/cli/-/issues"
|
|
17
|
+
},
|
|
18
|
+
author: "Markus Pollak <markus.pollak@diafunc.com>",
|
|
19
|
+
scripts: {
|
|
20
|
+
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'))"`,
|
|
21
|
+
dev: "tsup --watch",
|
|
22
|
+
test: "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
24
|
+
lint: "tsc --noEmit",
|
|
25
|
+
start: "node dist/bin/diafunc.js",
|
|
26
|
+
prepublishOnly: "npm run lint && npm test && npm run build"
|
|
27
|
+
},
|
|
28
|
+
files: [
|
|
29
|
+
"dist",
|
|
30
|
+
"LICENSE",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
keywords: [
|
|
34
|
+
"diafunc",
|
|
35
|
+
"cli",
|
|
36
|
+
"data-science",
|
|
37
|
+
"symbolic-regression"
|
|
38
|
+
],
|
|
39
|
+
license: "Apache-2.0",
|
|
40
|
+
publishConfig: {
|
|
41
|
+
access: "public",
|
|
42
|
+
registry: "https://registry.npmjs.org/"
|
|
43
|
+
},
|
|
44
|
+
engines: {
|
|
45
|
+
node: ">=20.0.0"
|
|
46
|
+
},
|
|
47
|
+
dependencies: {
|
|
48
|
+
"@inquirer/prompts": "^7.0.0",
|
|
49
|
+
chalk: "^5.4.0",
|
|
50
|
+
"cli-table3": "^0.6.5",
|
|
51
|
+
commander: "^12.1.0",
|
|
52
|
+
ora: "^8.1.0"
|
|
53
|
+
},
|
|
54
|
+
devDependencies: {
|
|
55
|
+
"@types/node": "^22.0.0",
|
|
56
|
+
tsup: "^8.3.0",
|
|
57
|
+
typescript: "^5.6.0",
|
|
58
|
+
vitest: "^2.1.0"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
package_default
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=chunk-FCWSWCFN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@diafunc/cli\",\n \"version\": \"0.4.1\",\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":[]}
|
package/dist/src/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|