@diafunc/cli 0.3.1 → 0.4.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 CHANGED
@@ -14,7 +14,7 @@ Drops a single self-contained binary into `~/.local/bin/diafunc`. No Node.js req
14
14
 
15
15
  Environment variables:
16
16
 
17
- - `DIAFUNC_CLI_VERSION` — pin to a specific version (e.g. `v0.3.0`). Defaults to the latest release.
17
+ - `DIAFUNC_CLI_VERSION` — pin to a specific version (must match the latest release; older versions are available via npm only).
18
18
  - `DIAFUNC_CLI_INSTALL_DIR` — override the install directory (default `$HOME/.local/bin`).
19
19
 
20
20
  ### npm (if you already have Node.js 20+)
@@ -25,12 +25,16 @@ npm install -g @diafunc/cli
25
25
 
26
26
  ### Manual download
27
27
 
28
- Pre-built binaries for Linux, macOS, and Windows are attached to each release:
28
+ Pre-built binaries for the latest release are at `https://diafunc.com/cli/diafunc-<os>-<arch>.tar.gz` (and `diafunc-windows-x64.zip`). Verify the SHA-256 against `https://diafunc.com/cli/SHA256SUMS`, then place the binary on your `PATH`.
29
29
 
30
- - Latest from `diafunc.com`: `https://diafunc.com/cli/diafunc-<os>-<arch>.tar.gz` (and `diafunc-windows-x64.zip`)
31
- - Any version: <https://gitlab.com/diafunc/cli/-/releases>
30
+ ### Update or uninstall
32
31
 
33
- Verify the SHA-256 checksum against `SHA256SUMS` in the same release, then place the binary on your `PATH`.
32
+ ```bash
33
+ diafunc update # upgrade to the latest release
34
+ diafunc uninstall # remove the binary (and optionally ~/.diafunc/)
35
+ ```
36
+
37
+ `diafunc update` uses the same install path as the original install — shell installer in place, npm-installed CLIs are pointed at `npm install -g @diafunc/cli@latest`.
34
38
 
35
39
  ## Quick Start
36
40
 
@@ -1,8 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- createProgram,
3
+ createProgram
4
+ } from "../chunk-ECAKWLCR.js";
5
+ import {
6
+ getUpdateNotice
7
+ } from "../chunk-F5FBH7UD.js";
8
+ import {
4
9
  package_default
5
- } from "../chunk-PDVC2LAL.js";
10
+ } from "../chunk-H5CNMAQX.js";
11
+
12
+ // bin/diafunc.ts
13
+ import chalk2 from "chalk";
6
14
 
7
15
  // src/splash.ts
8
16
  import chalk from "chalk";
@@ -109,6 +117,18 @@ if (process.argv.length <= 2 && process.stdout.isTTY) {
109
117
  showSplash();
110
118
  process.exit(0);
111
119
  }
112
- var program = createProgram();
113
- program.parseAsync(process.argv);
120
+ async function main() {
121
+ const program = createProgram();
122
+ const noticePromise = getUpdateNotice();
123
+ await program.parseAsync(process.argv);
124
+ try {
125
+ const notice = await Promise.race([
126
+ noticePromise,
127
+ new Promise((resolve) => setTimeout(() => resolve(null), 100))
128
+ ]);
129
+ if (notice) console.error(chalk2.dim(notice));
130
+ } catch {
131
+ }
132
+ }
133
+ main();
114
134
  //# sourceMappingURL=diafunc.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/splash.ts","../../bin/diafunc.ts"],"sourcesContent":["import chalk from 'chalk';\nimport pkg from '../package.json' with { type: 'json' };\n\n// Diafunc gem logo rendered with a pixel mask + vertical gradient.\n//\n// The silhouette approximates app/src/assets/images/logos/icon.svg: flat top at\n// ~60% width, widening to shoulder points, tapering to a bottom tip.\n//\n// Each character cell packs two vertical pixels. By using ▀ with an independent\n// foreground (upper pixel) and background (lower pixel) color, we get 2×\n// vertical color resolution — enough for a smooth gradient across 14 pixel\n// rows in only 7 character rows. The gradient mirrors the SVG's linearGradient\n// stops: lighter at the top and bottom, darker in the middle (polished-gem\n// highlight effect).\n\n// 14 rows × 20 cols pixel mask. true = filled, false = empty.\n// Silhouette: flat top (60% wide), widening to shoulders (row 3, full width),\n// then tapering to a single-pixel tip.\nconst MASK: readonly (readonly boolean[])[] = [\n row(' ████████████ '), // 0 flat top\n row(' ██████████████ '), // 1\n row(' ██████████████████ '), // 2\n row('████████████████████'), // 3 shoulder (max width)\n row('████████████████████'), // 4 shoulder\n row(' ██████████████████ '), // 5\n row(' ████████████████ '), // 6\n row(' ██████████████ '), // 7\n row(' ████████████ '), // 8\n row(' ██████████ '), // 9\n row(' ████████ '), // 10\n row(' ██████ '), // 11\n row(' ████ '), // 12\n row(' ██ '), // 13 tip\n];\n\nfunction row(s: string): boolean[] {\n // Any non-space character counts as filled.\n return Array.from(s).map((c) => c !== ' ');\n}\n\n// Gradient endpoints: light blue from the SVG stops, dark blue in the middle.\nconst LIGHT: readonly [number, number, number] = [0x47, 0x75, 0xb8]; // #4775B8\nconst DARK: readonly [number, number, number] = [0x2d, 0x2d, 0x5d]; // #2D2D5D\n\nfunction gradientHex(pixelRow: number, pixelRows: number): string {\n // t = 0 at vertical center, 1 at top/bottom edges.\n const center = (pixelRows - 1) / 2;\n const t = Math.abs(pixelRow - center) / center;\n const r = Math.round(DARK[0] + (LIGHT[0] - DARK[0]) * t);\n const g = Math.round(DARK[1] + (LIGHT[1] - DARK[1]) * t);\n const b = Math.round(DARK[2] + (LIGHT[2] - DARK[2]) * t);\n return '#' + [r, g, b].map((v) => v.toString(16).padStart(2, '0')).join('');\n}\n\nfunction renderGem(): string[] {\n const pixelRows = MASK.length;\n const cols = MASK[0].length;\n const charRows = pixelRows / 2;\n const lines: string[] = [];\n\n for (let c = 0; c < charRows; c++) {\n let line = '';\n for (let x = 0; x < cols; x++) {\n const top = MASK[2 * c][x];\n const bot = MASK[2 * c + 1][x];\n const topHex = gradientHex(2 * c, pixelRows);\n const botHex = gradientHex(2 * c + 1, pixelRows);\n\n if (top && bot) {\n line += chalk.hex(topHex).bgHex(botHex)('▀');\n } else if (top) {\n line += chalk.hex(topHex)('▀');\n } else if (bot) {\n line += chalk.hex(botHex)('▄');\n } else {\n line += ' ';\n }\n }\n lines.push(line);\n }\n return lines;\n}\n\n// \"Diafunc\" in figlet \"standard\" font, rendered in a single brand color\n// alongside the gem (a gradient on thin text glyphs would look noisy).\nconst WORDMARK: readonly string[] = [\n ' ____ _ __ ',\n '| _ \\\\(_) __ _ / _|_ _ _ __ ___ ',\n \"| | | | |/ _` | |_| | | | '_ \\\\ / __|\",\n '| |_| | | (_| | _| |_| | | | | (__ ',\n '|____/|_|\\\\__,_|_| \\\\__,_|_| |_|\\\\___|',\n];\n\nconst GAP = ' ';\n\nexport function showSplash(): void {\n const brand = chalk.hex('#4775B8');\n const gem = renderGem();\n\n // Center the 5-row wordmark vertically against the 7-row gem.\n const wordmarkOffset = Math.floor((gem.length - WORDMARK.length) / 2);\n\n console.log();\n for (let i = 0; i < gem.length; i++) {\n const w = i - wordmarkOffset;\n const text = w >= 0 && w < WORDMARK.length ? WORDMARK[w] : '';\n console.log(gem[i] + GAP + brand.bold(text));\n }\n console.log();\n console.log(\n ' ' +\n chalk.bold('CLI') +\n chalk.dim(` v${pkg.version}`) +\n chalk.dim(' · https://diafunc.com'),\n );\n console.log();\n console.log(\n chalk.dim(\" Run 'diafunc --help' for usage, or 'diafunc auth login' to get started.\"),\n );\n console.log();\n}\n","import { createProgram } from '../src/index.js';\nimport { showSplash } from '../src/splash.js';\n\nif (process.argv.length <= 2 && process.stdout.isTTY) {\n showSplash();\n process.exit(0);\n}\n\nconst program = createProgram();\nprogram.parseAsync(process.argv);\n"],"mappings":";;;;;;AAAA,OAAO,WAAW;AAkBlB,IAAM,OAAwC;AAAA,EAC5C,IAAI,kFAAsB;AAAA;AAAA,EAC1B,IAAI,4FAAsB;AAAA;AAAA,EAC1B,IAAI,gHAAsB;AAAA;AAAA,EAC1B,IAAI,0HAAsB;AAAA;AAAA,EAC1B,IAAI,0HAAsB;AAAA;AAAA,EAC1B,IAAI,gHAAsB;AAAA;AAAA,EAC1B,IAAI,sGAAsB;AAAA;AAAA,EAC1B,IAAI,4FAAsB;AAAA;AAAA,EAC1B,IAAI,kFAAsB;AAAA;AAAA,EAC1B,IAAI,wEAAsB;AAAA;AAAA,EAC1B,IAAI,8DAAsB;AAAA;AAAA,EAC1B,IAAI,oDAAsB;AAAA;AAAA,EAC1B,IAAI,0CAAsB;AAAA;AAAA,EAC1B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\nimport { createProgram } from '../src/index.js';\nimport { showSplash } from '../src/splash.js';\nimport { getUpdateNotice } from '../src/util/update-check.js';\n\nif (process.argv.length <= 2 && process.stdout.isTTY) {\n showSplash();\n process.exit(0);\n}\n\nasync function main(): Promise<void> {\n const program = createProgram();\n // Kick off the update check in the background so it doesn't block real work.\n // It only does anything for TTY runs and is heavily cached, so the network\n // round-trip is rare; even when it fires, we wait at most a hair after the\n // command completes before printing.\n const noticePromise = getUpdateNotice();\n await program.parseAsync(process.argv);\n try {\n const notice = await Promise.race([\n noticePromise,\n new Promise<null>((resolve) => setTimeout(() => resolve(null), 100)),\n ]);\n if (notice) console.error(chalk.dim(notice));\n } catch {}\n}\n\nmain();\n","import chalk from 'chalk';\nimport pkg from '../package.json' with { type: 'json' };\n\n// Diafunc gem logo rendered with a pixel mask + vertical gradient.\n//\n// The silhouette approximates app/src/assets/images/logos/icon.svg: flat top at\n// ~60% width, widening to shoulder points, tapering to a bottom tip.\n//\n// Each character cell packs two vertical pixels. By using ▀ with an independent\n// foreground (upper pixel) and background (lower pixel) color, we get 2×\n// vertical color resolution — enough for a smooth gradient across 14 pixel\n// rows in only 7 character rows. The gradient mirrors the SVG's linearGradient\n// stops: lighter at the top and bottom, darker in the middle (polished-gem\n// highlight effect).\n\n// 14 rows × 20 cols pixel mask. true = filled, false = empty.\n// Silhouette: flat top (60% wide), widening to shoulders (row 3, full width),\n// then tapering to a single-pixel tip.\nconst MASK: readonly (readonly boolean[])[] = [\n row(' ████████████ '), // 0 flat top\n row(' ██████████████ '), // 1\n row(' ██████████████████ '), // 2\n row('████████████████████'), // 3 shoulder (max width)\n row('████████████████████'), // 4 shoulder\n row(' ██████████████████ '), // 5\n row(' ████████████████ '), // 6\n row(' ██████████████ '), // 7\n row(' ████████████ '), // 8\n row(' ██████████ '), // 9\n row(' ████████ '), // 10\n row(' ██████ '), // 11\n row(' ████ '), // 12\n row(' ██ '), // 13 tip\n];\n\nfunction row(s: string): boolean[] {\n // Any non-space character counts as filled.\n return Array.from(s).map((c) => c !== ' ');\n}\n\n// Gradient endpoints: light blue from the SVG stops, dark blue in the middle.\nconst LIGHT: readonly [number, number, number] = [0x47, 0x75, 0xb8]; // #4775B8\nconst DARK: readonly [number, number, number] = [0x2d, 0x2d, 0x5d]; // #2D2D5D\n\nfunction gradientHex(pixelRow: number, pixelRows: number): string {\n // t = 0 at vertical center, 1 at top/bottom edges.\n const center = (pixelRows - 1) / 2;\n const t = Math.abs(pixelRow - center) / center;\n const r = Math.round(DARK[0] + (LIGHT[0] - DARK[0]) * t);\n const g = Math.round(DARK[1] + (LIGHT[1] - DARK[1]) * t);\n const b = Math.round(DARK[2] + (LIGHT[2] - DARK[2]) * t);\n return '#' + [r, g, b].map((v) => v.toString(16).padStart(2, '0')).join('');\n}\n\nfunction renderGem(): string[] {\n const pixelRows = MASK.length;\n const cols = MASK[0].length;\n const charRows = pixelRows / 2;\n const lines: string[] = [];\n\n for (let c = 0; c < charRows; c++) {\n let line = '';\n for (let x = 0; x < cols; x++) {\n const top = MASK[2 * c][x];\n const bot = MASK[2 * c + 1][x];\n const topHex = gradientHex(2 * c, pixelRows);\n const botHex = gradientHex(2 * c + 1, pixelRows);\n\n if (top && bot) {\n line += chalk.hex(topHex).bgHex(botHex)('▀');\n } else if (top) {\n line += chalk.hex(topHex)('▀');\n } else if (bot) {\n line += chalk.hex(botHex)('▄');\n } else {\n line += ' ';\n }\n }\n lines.push(line);\n }\n return lines;\n}\n\n// \"Diafunc\" in figlet \"standard\" font, rendered in a single brand color\n// alongside the gem (a gradient on thin text glyphs would look noisy).\nconst WORDMARK: readonly string[] = [\n ' ____ _ __ ',\n '| _ \\\\(_) __ _ / _|_ _ _ __ ___ ',\n \"| | | | |/ _` | |_| | | | '_ \\\\ / __|\",\n '| |_| | | (_| | _| |_| | | | | (__ ',\n '|____/|_|\\\\__,_|_| \\\\__,_|_| |_|\\\\___|',\n];\n\nconst GAP = ' ';\n\nexport function showSplash(): void {\n const brand = chalk.hex('#4775B8');\n const gem = renderGem();\n\n // Center the 5-row wordmark vertically against the 7-row gem.\n const wordmarkOffset = Math.floor((gem.length - WORDMARK.length) / 2);\n\n console.log();\n for (let i = 0; i < gem.length; i++) {\n const w = i - wordmarkOffset;\n const text = w >= 0 && w < WORDMARK.length ? WORDMARK[w] : '';\n console.log(gem[i] + GAP + brand.bold(text));\n }\n console.log();\n console.log(\n ' ' +\n chalk.bold('CLI') +\n chalk.dim(` v${pkg.version}`) +\n chalk.dim(' · https://diafunc.com'),\n );\n console.log();\n console.log(\n chalk.dim(\" Run 'diafunc --help' for usage, or 'diafunc auth login' to get started.\"),\n );\n console.log();\n}\n"],"mappings":";;;;;;;;;;;AAAA,OAAOA,YAAW;;;ACAlB,OAAO,WAAW;AAkBlB,IAAM,OAAwC;AAAA,EAC5C,IAAI,kFAAsB;AAAA;AAAA,EAC1B,IAAI,4FAAsB;AAAA;AAAA,EAC1B,IAAI,gHAAsB;AAAA;AAAA,EAC1B,IAAI,0HAAsB;AAAA;AAAA,EAC1B,IAAI,0HAAsB;AAAA;AAAA,EAC1B,IAAI,gHAAsB;AAAA;AAAA,EAC1B,IAAI,sGAAsB;AAAA;AAAA,EAC1B,IAAI,4FAAsB;AAAA;AAAA,EAC1B,IAAI,kFAAsB;AAAA;AAAA,EAC1B,IAAI,wEAAsB;AAAA;AAAA,EAC1B,IAAI,8DAAsB;AAAA;AAAA,EAC1B,IAAI,oDAAsB;AAAA;AAAA,EAC1B,IAAI,0CAAsB;AAAA;AAAA,EAC1B,IAAI,gCAAsB;AAAA;AAC5B;AAEA,SAAS,IAAI,GAAsB;AAEjC,SAAO,MAAM,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,MAAM,GAAG;AAC3C;AAGA,IAAM,QAA2C,CAAC,IAAM,KAAM,GAAI;AAClE,IAAM,OAA0C,CAAC,IAAM,IAAM,EAAI;AAEjE,SAAS,YAAY,UAAkB,WAA2B;AAEhE,QAAM,UAAU,YAAY,KAAK;AACjC,QAAM,IAA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 } from "./chunk-H5CNMAQX.js";
4
+
1
5
  // src/index.ts
2
6
  import { Command } from "commander";
3
7
 
4
- // package.json
5
- var package_default = {
6
- name: "@diafunc/cli",
7
- version: "0.3.1",
8
- description: "Diafunc CLI \u2014 command-line interface for the Diafunc platform",
9
- type: "module",
10
- bin: {
11
- diafunc: "./dist/bin/diafunc.js"
12
- },
13
- homepage: "https://diafunc.com",
14
- repository: {
15
- type: "git",
16
- url: "git+https://gitlab.com/diafunc/cli.git"
17
- },
18
- bugs: {
19
- url: "https://gitlab.com/diafunc/cli/-/issues"
20
- },
21
- author: "Markus Pollak <markus.pollak@diafunc.com>",
22
- scripts: {
23
- 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'))"`,
24
- dev: "tsup --watch",
25
- test: "vitest run",
26
- "test:watch": "vitest",
27
- lint: "tsc --noEmit",
28
- start: "node dist/bin/diafunc.js",
29
- prepublishOnly: "npm run lint && npm test && npm run build"
30
- },
31
- files: [
32
- "dist",
33
- "LICENSE",
34
- "README.md"
35
- ],
36
- keywords: [
37
- "diafunc",
38
- "cli",
39
- "data-science",
40
- "symbolic-regression"
41
- ],
42
- license: "Apache-2.0",
43
- publishConfig: {
44
- access: "public",
45
- registry: "https://registry.npmjs.org/"
46
- },
47
- engines: {
48
- node: ">=20.0.0"
49
- },
50
- dependencies: {
51
- "@inquirer/prompts": "^7.0.0",
52
- chalk: "^5.4.0",
53
- "cli-table3": "^0.6.5",
54
- commander: "^12.1.0",
55
- ora: "^8.1.0"
56
- },
57
- devDependencies: {
58
- "@types/node": "^22.0.0",
59
- tsup: "^8.3.0",
60
- typescript: "^5.6.0",
61
- vitest: "^2.1.0"
62
- }
63
- };
64
-
65
8
  // src/commands/auth/login.ts
66
9
  import chalk2 from "chalk";
67
10
 
@@ -149,8 +92,8 @@ var NetworkError = class extends Error {
149
92
  };
150
93
 
151
94
  // src/client/http.ts
152
- function buildUrl(endpoint, service, path7, query) {
153
- const base = `${endpoint}/api/v1/${service}${path7}`;
95
+ function buildUrl(endpoint, service, path9, query) {
96
+ const base = `${endpoint}/api/v1/${service}${path9}`;
154
97
  const params = new URLSearchParams();
155
98
  if (query) {
156
99
  for (const [key, value] of Object.entries(query)) {
@@ -1337,14 +1280,14 @@ function createStorageService(client) {
1337
1280
  });
1338
1281
  },
1339
1282
  async deleteLink(projectId, projectBranch, sourceEntityId, sourceEntityBranch, linkId, targetEntityId, targetEntityBranch) {
1340
- let path7 = `/links/actual/${enc(projectId)}/${enc(projectBranch)}/${enc(sourceEntityId)}/${enc(sourceEntityBranch)}/${enc(linkId)}`;
1283
+ let path9 = `/links/actual/${enc(projectId)}/${enc(projectBranch)}/${enc(sourceEntityId)}/${enc(sourceEntityBranch)}/${enc(linkId)}`;
1341
1284
  if (targetEntityId && targetEntityBranch) {
1342
- path7 += `/${enc(targetEntityId)}/${enc(targetEntityBranch)}`;
1285
+ path9 += `/${enc(targetEntityId)}/${enc(targetEntityBranch)}`;
1343
1286
  }
1344
1287
  return client.request({
1345
1288
  method: "DELETE",
1346
1289
  service: SERVICE3,
1347
- path: path7
1290
+ path: path9
1348
1291
  });
1349
1292
  },
1350
1293
  // --- Events ---
@@ -2033,8 +1976,8 @@ function registerConfigCommands(program) {
2033
1976
  console.log(chalk7.green(`Profile "${name}" removed.`));
2034
1977
  });
2035
1978
  }
2036
- function setNestedValue(obj, path7, value) {
2037
- const keys = path7.split(".");
1979
+ function setNestedValue(obj, path9, value) {
1980
+ const keys = path9.split(".");
2038
1981
  let current = obj;
2039
1982
  for (let i = 0; i < keys.length - 1; i++) {
2040
1983
  const key = keys[i];
@@ -2045,8 +1988,8 @@ function setNestedValue(obj, path7, value) {
2045
1988
  }
2046
1989
  current[keys[keys.length - 1]] = value;
2047
1990
  }
2048
- function getNestedValue(obj, path7) {
2049
- const keys = path7.split(".");
1991
+ function getNestedValue(obj, path9) {
1992
+ const keys = path9.split(".");
2050
1993
  let current = obj;
2051
1994
  for (const key of keys) {
2052
1995
  if (current === null || current === void 0 || typeof current !== "object") {
@@ -2596,8 +2539,8 @@ function registerEventCommands(program) {
2596
2539
  });
2597
2540
  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) => {
2598
2541
  try {
2599
- const fs9 = await import("fs");
2600
- const body = file ? fs9.readFileSync(file, "utf-8") : await new Promise((resolve, reject) => {
2542
+ const fs11 = await import("fs");
2543
+ const body = file ? fs11.readFileSync(file, "utf-8") : await new Promise((resolve, reject) => {
2601
2544
  let data = "";
2602
2545
  process.stdin.setEncoding("utf-8");
2603
2546
  process.stdin.on("data", (chunk) => {
@@ -3633,11 +3576,14 @@ Error: ${event.content}`));
3633
3576
  }
3634
3577
  async function runChatRepl(options) {
3635
3578
  const { input: promptInput } = await import("@inquirer/prompts");
3579
+ const { getUpdateNotice } = await import("./update-check-5JBBCRL3.js");
3636
3580
  let sessionId = options.session;
3637
3581
  console.log(chalk17.bold("Diafunc chat") + chalk17.dim(" \xB7 /help for commands, /quit to exit"));
3638
3582
  if (sessionId) {
3639
3583
  console.log(chalk17.dim(`Continuing session ${sessionId}`));
3640
3584
  }
3585
+ const notice = await getUpdateNotice();
3586
+ if (notice) console.log(chalk17.dim(notice));
3641
3587
  console.log();
3642
3588
  for (; ; ) {
3643
3589
  let line;
@@ -4183,8 +4129,8 @@ import chalk20 from "chalk";
4183
4129
  function createStatusService() {
4184
4130
  const config = loadConfig();
4185
4131
  const endpoint = resolveEndpoint(config);
4186
- async function fetchJson(path7) {
4187
- const url = `${endpoint}/status/v1${path7}`;
4132
+ async function fetchJson(path9) {
4133
+ const url = `${endpoint}/status/v1${path9}`;
4188
4134
  const response = await fetch(url, {
4189
4135
  headers: { "Accept": "application/json" }
4190
4136
  });
@@ -5597,9 +5543,12 @@ function registerShellCommand(program) {
5597
5543
  });
5598
5544
  const api = createApiClient();
5599
5545
  const { input: promptInput } = await import("@inquirer/prompts");
5546
+ const { getUpdateNotice } = await import("./update-check-5JBBCRL3.js");
5600
5547
  console.log(chalk28.bold("Diafunc shell") + chalk28.dim(` \xB7 function ${fnRef.entityId} \xB7 ${options.language}`));
5601
5548
  console.log(chalk28.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
5602
5549
  console.log(chalk28.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
5550
+ const notice = await getUpdateNotice();
5551
+ if (notice) console.log(chalk28.dim(notice));
5603
5552
  console.log();
5604
5553
  let language = options.language;
5605
5554
  for (; ; ) {
@@ -5679,6 +5628,130 @@ function registerShellCommand(program) {
5679
5628
  });
5680
5629
  }
5681
5630
 
5631
+ // src/commands/update/index.ts
5632
+ import chalk29 from "chalk";
5633
+ import * as path7 from "path";
5634
+ import { spawn as spawn4 } from "child_process";
5635
+
5636
+ // src/util/install-method.ts
5637
+ import * as fs9 from "fs";
5638
+ function detectInstall() {
5639
+ const exec = process.execPath;
5640
+ const exe = exec.replace(/\\/g, "/").toLowerCase();
5641
+ const isNode = exe.endsWith("/node") || exe.endsWith("/node.exe");
5642
+ return {
5643
+ method: isNode ? "npm" : "binary",
5644
+ binaryPath: isNode ? exec : fs9.realpathSync(exec)
5645
+ };
5646
+ }
5647
+
5648
+ // src/commands/update/index.ts
5649
+ var MANIFEST_URL = "https://diafunc.com/cli/latest.json";
5650
+ var INSTALLER_URL = "https://diafunc.com/cli/install.sh";
5651
+ async function fetchLatestVersion() {
5652
+ const res = await fetch(MANIFEST_URL);
5653
+ if (!res.ok) throw new Error(`Failed to fetch ${MANIFEST_URL}: HTTP ${res.status}`);
5654
+ const manifest = await res.json();
5655
+ if (!manifest.version) throw new Error("Manifest missing version field.");
5656
+ return manifest.version;
5657
+ }
5658
+ function runInstaller(installDir) {
5659
+ return new Promise((resolve, reject) => {
5660
+ const child = spawn4("sh", ["-c", `curl -fsSL ${INSTALLER_URL} | sh`], {
5661
+ stdio: "inherit",
5662
+ env: { ...process.env, DIAFUNC_CLI_INSTALL_DIR: installDir }
5663
+ });
5664
+ child.on("exit", (code) => code === 0 ? resolve() : reject(new Error(`Installer exited with code ${code}`)));
5665
+ child.on("error", reject);
5666
+ });
5667
+ }
5668
+ function registerUpdateCommand(program) {
5669
+ program.command("update").description("Update the CLI to the latest released version").action(async () => {
5670
+ try {
5671
+ const install = detectInstall();
5672
+ const latest = await fetchLatestVersion();
5673
+ if (latest === package_default.version) {
5674
+ console.log(chalk29.dim(`diafunc is already at the latest version (${package_default.version}).`));
5675
+ return;
5676
+ }
5677
+ console.log(chalk29.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
5678
+ if (install.method === "npm") {
5679
+ console.log();
5680
+ console.log("Installed via npm. Upgrade with:");
5681
+ console.log(chalk29.bold(` npm install -g @diafunc/cli@${latest}`));
5682
+ return;
5683
+ }
5684
+ if (process.platform === "win32") {
5685
+ console.log();
5686
+ console.log("In-place update is not supported on Windows. Re-download from:");
5687
+ console.log(chalk29.bold(" https://diafunc.com/cli/diafunc-windows-x64.zip"));
5688
+ return;
5689
+ }
5690
+ const installDir = path7.dirname(install.binaryPath);
5691
+ console.log(`Installing diafunc ${latest} to ${installDir}...`);
5692
+ console.log();
5693
+ await runInstaller(installDir);
5694
+ } catch (error) {
5695
+ handleError(error);
5696
+ }
5697
+ });
5698
+ }
5699
+
5700
+ // src/commands/uninstall/index.ts
5701
+ import chalk30 from "chalk";
5702
+ import * as fs10 from "fs";
5703
+ import * as os4 from "os";
5704
+ import * as path8 from "path";
5705
+ function registerUninstallCommand(program) {
5706
+ 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) => {
5707
+ try {
5708
+ const install = detectInstall();
5709
+ const configDir = path8.join(os4.homedir(), ".diafunc");
5710
+ if (install.method === "npm") {
5711
+ console.log("Installed via npm. Remove with:");
5712
+ console.log(chalk30.bold(" npm uninstall -g @diafunc/cli"));
5713
+ if (fs10.existsSync(configDir)) {
5714
+ console.log();
5715
+ console.log(`Config + credentials live at ${configDir} \u2014 remove manually with:`);
5716
+ console.log(chalk30.bold(` rm -rf ${configDir}`));
5717
+ }
5718
+ return;
5719
+ }
5720
+ if (process.platform === "win32") {
5721
+ console.log("Self-uninstall is not supported on Windows (the running .exe is locked).");
5722
+ console.log(`Delete the binary manually: ${install.binaryPath}`);
5723
+ return;
5724
+ }
5725
+ const { confirm } = await import("@inquirer/prompts");
5726
+ const removeBinary = options.yes ? true : await confirm({
5727
+ message: `Remove binary at ${install.binaryPath}?`,
5728
+ default: false
5729
+ });
5730
+ if (!removeBinary) {
5731
+ console.log(chalk30.dim("Aborted."));
5732
+ return;
5733
+ }
5734
+ let removeConfig = options.purge ?? false;
5735
+ if (!options.purge && !options.yes && fs10.existsSync(configDir)) {
5736
+ removeConfig = await confirm({
5737
+ message: `Also remove ${configDir} (config + credentials)?`,
5738
+ default: false
5739
+ });
5740
+ }
5741
+ if (removeConfig && fs10.existsSync(configDir)) {
5742
+ fs10.rmSync(configDir, { recursive: true, force: true });
5743
+ console.log(chalk30.dim(`Removed ${configDir}`));
5744
+ }
5745
+ fs10.rmSync(install.binaryPath, { force: true });
5746
+ console.log(chalk30.dim(`Removed ${install.binaryPath}`));
5747
+ console.log();
5748
+ console.log("diafunc uninstalled.");
5749
+ } catch (error) {
5750
+ handleError(error);
5751
+ }
5752
+ });
5753
+ }
5754
+
5682
5755
  // src/index.ts
5683
5756
  function createProgram() {
5684
5757
  const program = new Command();
@@ -5712,11 +5785,12 @@ function createProgram() {
5712
5785
  registerSubscriptionCommand(program);
5713
5786
  registerInvoiceCommand(program);
5714
5787
  registerShellCommand(program);
5788
+ registerUpdateCommand(program);
5789
+ registerUninstallCommand(program);
5715
5790
  return program;
5716
5791
  }
5717
5792
 
5718
5793
  export {
5719
- package_default,
5720
5794
  createProgram
5721
5795
  };
5722
- //# sourceMappingURL=chunk-PDVC2LAL.js.map
5796
+ //# sourceMappingURL=chunk-ECAKWLCR.js.map