@tavily/cli 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +322 -2
- package/dist/auth-EQZRRVIV.js +213 -0
- package/dist/chunk-5JXZZSLS.js +30 -0
- package/dist/chunk-AERAIFZU.js +691 -0
- package/dist/chunk-E4N27QWM.js +53 -0
- package/dist/chunk-HQ7QBZ5H.js +8 -0
- package/dist/chunk-IRCF6F3S.js +45 -0
- package/dist/chunk-K76OUMXM.js +43 -0
- package/dist/chunk-KQFC5TMG.js +380 -0
- package/dist/chunk-PZGMUDV2.js +427 -0
- package/dist/chunk-QHWWSCVM.js +85 -0
- package/dist/chunk-SPBOEASO.js +9 -0
- package/dist/chunk-U3B7BNFI.js +40 -0
- package/dist/chunk-ULNXDG4Q.js +147 -0
- package/dist/chunk-V3OJFHHD.js +191 -0
- package/dist/cli.js +132 -0
- package/dist/client-factory-LWJMZVKT.js +338 -0
- package/dist/defaults-344GEHCS.js +204 -0
- package/dist/extract-Q5VLDRON.js +90 -0
- package/dist/init-6PKQ6UES.js +348 -0
- package/dist/repl-IHHLWI3L.js +259 -0
- package/dist/research-PU3YJMQM.js +262 -0
- package/dist/search-XTAH2SDD.js +191 -0
- package/dist/setup-JNKIKMOX.js +52 -0
- package/dist/site-ZG42IEW7.js +151 -0
- package/dist/status-UAAZ7CBV.js +36 -0
- package/dist/update-CWPZZE4P.js +129 -0
- package/package.json +55 -4
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
compareVersions,
|
|
4
|
+
detectInstall,
|
|
5
|
+
fetchLatestVersion,
|
|
6
|
+
isNewer,
|
|
7
|
+
safeRealpath
|
|
8
|
+
} from "./chunk-V3OJFHHD.js";
|
|
9
|
+
import {
|
|
10
|
+
VERSION
|
|
11
|
+
} from "./chunk-SPBOEASO.js";
|
|
12
|
+
import {
|
|
13
|
+
sanitizeControl
|
|
14
|
+
} from "./chunk-QHWWSCVM.js";
|
|
15
|
+
import {
|
|
16
|
+
resolveJson
|
|
17
|
+
} from "./chunk-IRCF6F3S.js";
|
|
18
|
+
import {
|
|
19
|
+
colors,
|
|
20
|
+
err,
|
|
21
|
+
out
|
|
22
|
+
} from "./chunk-E4N27QWM.js";
|
|
23
|
+
import {
|
|
24
|
+
ExitError,
|
|
25
|
+
messageOf
|
|
26
|
+
} from "./chunk-5JXZZSLS.js";
|
|
27
|
+
|
|
28
|
+
// src/commands/update.ts
|
|
29
|
+
async function run(opts, cmd, host) {
|
|
30
|
+
const json = resolveJson(cmd);
|
|
31
|
+
const current = VERSION;
|
|
32
|
+
let latest;
|
|
33
|
+
let updateAvailable;
|
|
34
|
+
try {
|
|
35
|
+
latest = await fetchLatestVersion(host.fetch);
|
|
36
|
+
updateAvailable = isNewer(latest, current);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
return fail("check", messageOf(e), 4, json);
|
|
39
|
+
}
|
|
40
|
+
let install;
|
|
41
|
+
try {
|
|
42
|
+
install = detectInstall(host);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
return fail("install_method", messageOf(e), 1, json);
|
|
45
|
+
}
|
|
46
|
+
if (opts.check || !updateAvailable) {
|
|
47
|
+
printResult(result(current, latest, install, false), current, json, opts.check === true);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (install.command === null) {
|
|
51
|
+
return fail("install_method", install.blockedReason ?? "", 1, json);
|
|
52
|
+
}
|
|
53
|
+
if (!json) out(`Updating Tavily CLI via ${install.method}...`);
|
|
54
|
+
const [file = "", ...args] = install.command;
|
|
55
|
+
const completed = host.exec.run(file, args, { timeoutMs: 3e5 });
|
|
56
|
+
if (completed.failure) return fail("update", completed.failure, 1, json);
|
|
57
|
+
let installed;
|
|
58
|
+
try {
|
|
59
|
+
installed = installedVersion(host);
|
|
60
|
+
if (isNewer(latest, installed)) {
|
|
61
|
+
let message = `The package manager completed, but Tavily CLI is still ${installed}; latest is ${latest}. The installation may be pinned.`;
|
|
62
|
+
const hint = managerHint(completed);
|
|
63
|
+
if (hint) message += ` Package manager reported: ${hint}`;
|
|
64
|
+
throw new Error(message);
|
|
65
|
+
}
|
|
66
|
+
} catch (e) {
|
|
67
|
+
return fail("verify", messageOf(e), 1, json);
|
|
68
|
+
}
|
|
69
|
+
printResult(
|
|
70
|
+
result(installed, latest, install, compareVersions(installed, current) !== 0),
|
|
71
|
+
current,
|
|
72
|
+
json,
|
|
73
|
+
false
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
function installedVersion(host) {
|
|
77
|
+
const entry = safeRealpath(host.argv[1] ?? "");
|
|
78
|
+
const r = host.exec.run(process.execPath, [entry, "--version"], { timeoutMs: 3e4 });
|
|
79
|
+
if (!r.ok) throw new Error(`Could not read the installed Tavily CLI version: ${r.failure}`);
|
|
80
|
+
const token = sanitizeControl(r.stdout).trim().split(/\s+/).pop();
|
|
81
|
+
if (!token) throw new Error("Could not read the installed Tavily CLI version.");
|
|
82
|
+
return token;
|
|
83
|
+
}
|
|
84
|
+
function managerHint(completed) {
|
|
85
|
+
for (const output of [completed.stderr, completed.stdout]) {
|
|
86
|
+
const lines = output.split(/\r?\n/);
|
|
87
|
+
for (const line of lines.reverse()) {
|
|
88
|
+
const candidate = sanitizeControl(line).trim();
|
|
89
|
+
if (candidate.toLowerCase().startsWith("hint:")) return candidate.slice(0, 1e3);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
function result(current, latest, install, updated) {
|
|
95
|
+
return {
|
|
96
|
+
ok: true,
|
|
97
|
+
current_version: current,
|
|
98
|
+
latest_version: latest,
|
|
99
|
+
update_available: isNewer(latest, current),
|
|
100
|
+
install_method: install.method,
|
|
101
|
+
can_update: install.command !== null,
|
|
102
|
+
blocked_reason: install.command === null ? install.blockedReason : null,
|
|
103
|
+
updated
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function fail(stage, message, code, json) {
|
|
107
|
+
const safe = sanitizeControl(message);
|
|
108
|
+
if (json) out(JSON.stringify({ ok: false, error: { stage, message: safe } }));
|
|
109
|
+
else err(` ${colors.pink("> Update failed:")} ${safe}`);
|
|
110
|
+
throw new ExitError(code);
|
|
111
|
+
}
|
|
112
|
+
function printResult(r, started, json, checkOnly) {
|
|
113
|
+
if (json) {
|
|
114
|
+
out(JSON.stringify(r));
|
|
115
|
+
} else if (r.updated) {
|
|
116
|
+
out(`Updated Tavily CLI: ${started} -> ${r.current_version}`);
|
|
117
|
+
} else if (r.update_available) {
|
|
118
|
+
out(`Tavily CLI update available: ${r.current_version} -> ${r.latest_version}`);
|
|
119
|
+
if (checkOnly) {
|
|
120
|
+
if (r.can_update) out("Run `tvly update` to install it.");
|
|
121
|
+
else out(`Self-update unavailable: ${sanitizeControl(r.blocked_reason)}`);
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
out(`Tavily CLI ${r.current_version} is up to date.`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
run
|
|
129
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tavily/cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Tavily CLI",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"tvly": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20.1.0"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsup",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"lint": "biome check",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"check:publishable": "node -e \"const s=require('./package.json').dependencies['@tavily/core'];if(!/^[~^0-9]/.test(s)){console.error('@tavily/core is '+s+'; switch it to a registry semver range before publishing (a file: dependency makes the package uninstallable).');process.exit(1)}\"",
|
|
22
|
+
"prepublishOnly": "npm run check:publishable && npm run lint && npm run typecheck && npm test && npm run build"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@clack/prompts": "^1.9.0",
|
|
26
|
+
"@tavily/core": "^1.1.0",
|
|
27
|
+
"commander": "15.1.0",
|
|
28
|
+
"marked": "18.1.3",
|
|
29
|
+
"marked-terminal": "8.0.0",
|
|
30
|
+
"picocolors": "1.1.1",
|
|
31
|
+
"proper-lockfile": "4.1.2"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@biomejs/biome": "2.6.6",
|
|
35
|
+
"@types/node": "26.6.6",
|
|
36
|
+
"@types/proper-lockfile": "4.1.4",
|
|
37
|
+
"tsup": "9.0.0",
|
|
38
|
+
"tsx": "4.23.15",
|
|
39
|
+
"typescript": "7.0.2",
|
|
40
|
+
"vitest": "5.1.0"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://tavily.com",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/tavily-ai/cli.git"
|
|
46
|
+
},
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/tavily-ai/cli/issues"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"provenance": true
|
|
53
|
+
},
|
|
54
|
+
"overrides": {
|
|
55
|
+
"zod": "^4.6.6"
|
|
56
|
+
}
|
|
57
|
+
}
|