bavitutor 0.1.1 → 0.1.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 +7 -1
- package/dist/bavitutor.mjs +40 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,13 @@ npx bavitutor
|
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
That's all: it downloads BaviTutor, serves it on <http://localhost:4100> and
|
|
19
|
-
opens your browser. Data stays on your machine in `~/.bavitutor`.
|
|
19
|
+
opens your browser. Data stays on your machine in `~/.bavitutor`. If 4100 is
|
|
20
|
+
taken it moves to the next free port, and if BaviTutor is already running it
|
|
21
|
+
opens that one.
|
|
22
|
+
|
|
23
|
+
npx and vpx reuse a version they downloaded before (pnpm for a day), so when a
|
|
24
|
+
newer one is out BaviTutor says so on start, with the exact command:
|
|
25
|
+
`npx bavitutor@<version>` always fetches that version.
|
|
20
26
|
|
|
21
27
|
Requirements: Node 24+, [Vite+](https://viteplus.dev) (`vp`), and a logged-in
|
|
22
28
|
[Claude Code](https://claude.com/claude-code) install (the Claude Agent SDK
|
package/dist/bavitutor.mjs
CHANGED
|
@@ -46583,7 +46583,8 @@ const codeByLiteral = {
|
|
|
46583
46583
|
const fromLiteral = (literal) => codeByLiteral[literal];
|
|
46584
46584
|
//#endregion
|
|
46585
46585
|
//#region package.json
|
|
46586
|
-
var
|
|
46586
|
+
var name = "bavitutor";
|
|
46587
|
+
var version$1 = "0.1.2";
|
|
46587
46588
|
/**
|
|
46588
46589
|
* Default Server-Sent Events encoder.
|
|
46589
46590
|
*
|
|
@@ -61926,6 +61927,40 @@ const choosePort = async (requested, isExplicit, host) => {
|
|
|
61926
61927
|
}
|
|
61927
61928
|
return fail([`Ports ${requested}-${requested + SPARE_PORTS} are all in use.`, "Pick a free one: bavitutor --port <port>"]);
|
|
61928
61929
|
};
|
|
61930
|
+
/** The version npm calls latest, or undefined when npm doesn't answer quickly. */
|
|
61931
|
+
const latestVersion = async () => {
|
|
61932
|
+
if (process.env["NO_UPDATE_NOTIFIER"]) return;
|
|
61933
|
+
try {
|
|
61934
|
+
const response = await fetch(`https://registry.npmjs.org/${name}/latest`, { signal: AbortSignal.timeout(3e3) });
|
|
61935
|
+
const body = await response.json();
|
|
61936
|
+
return response.ok && body !== null && typeof body === "object" && "version" in body && typeof body.version === "string" ? body.version : void 0;
|
|
61937
|
+
} catch {
|
|
61938
|
+
return;
|
|
61939
|
+
}
|
|
61940
|
+
};
|
|
61941
|
+
const isNewer = (candidate, current) => {
|
|
61942
|
+
const parts = (version) => (version.split("-")[0] ?? "").split(".").map(Number);
|
|
61943
|
+
const [next, now] = [parts(candidate), parts(current)];
|
|
61944
|
+
const difference = [
|
|
61945
|
+
0,
|
|
61946
|
+
1,
|
|
61947
|
+
2
|
|
61948
|
+
].map((i) => (next[i] ?? 0) - (now[i] ?? 0)).find((delta) => delta !== 0);
|
|
61949
|
+
return difference !== void 0 && difference > 0;
|
|
61950
|
+
};
|
|
61951
|
+
/**
|
|
61952
|
+
* npx and vpx (through pnpm dlx) reuse what they downloaded before, so a bare
|
|
61953
|
+
* `npx bavitutor` can keep starting an old version. An exact version is
|
|
61954
|
+
* always fetched, so the notice names one.
|
|
61955
|
+
*/
|
|
61956
|
+
const sayIfOutdated = (latest) => {
|
|
61957
|
+
if (latest !== void 0 && isNewer(latest, version$1)) {
|
|
61958
|
+
say(`BaviTutor ${latest} is out (this is ${version$1}). To update,`);
|
|
61959
|
+
say(`stop this one and run: npx bavitutor@${latest}`);
|
|
61960
|
+
say(` or: vpx bavitutor@${latest}`);
|
|
61961
|
+
say();
|
|
61962
|
+
}
|
|
61963
|
+
};
|
|
61929
61964
|
const openBrowser = (url) => {
|
|
61930
61965
|
const [command, args] = process.platform === "win32" ? ["cmd.exe", [
|
|
61931
61966
|
"/d",
|
|
@@ -61957,6 +61992,7 @@ const main = async () => {
|
|
|
61957
61992
|
say(version$1);
|
|
61958
61993
|
return;
|
|
61959
61994
|
}
|
|
61995
|
+
const latest = latestVersion();
|
|
61960
61996
|
const dataDir = resolve(expandHome(options["data-dir"] ?? join(homedir(), ".bavitutor")));
|
|
61961
61997
|
mkdirSync(dataDir, { recursive: true });
|
|
61962
61998
|
const envFile = join(dataDir, ".env");
|
|
@@ -61997,7 +62033,9 @@ const main = async () => {
|
|
|
61997
62033
|
if (choice.isRunning) {
|
|
61998
62034
|
say();
|
|
61999
62035
|
say(`BaviTutor is already running at ${urlFor(choice.port)}`);
|
|
62036
|
+
say();
|
|
62000
62037
|
if (options.open) openBrowser(urlFor(choice.port));
|
|
62038
|
+
sayIfOutdated(await latest);
|
|
62001
62039
|
return;
|
|
62002
62040
|
}
|
|
62003
62041
|
const port = choice.port;
|
|
@@ -62009,6 +62047,7 @@ const main = async () => {
|
|
|
62009
62047
|
say(`BaviTutor is running at ${url} (Ctrl+C to stop)`);
|
|
62010
62048
|
say();
|
|
62011
62049
|
if (options.open) openBrowser(url);
|
|
62050
|
+
latest.then(sayIfOutdated);
|
|
62012
62051
|
})).pipe(provide(makeServer({
|
|
62013
62052
|
port,
|
|
62014
62053
|
host,
|