vagejs 0.3.1 → 0.3.3

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
@@ -29,10 +29,10 @@ Requires **Node.js 22.12 or newer**.
29
29
  npm create vagejs@latest my-site
30
30
  cd my-site
31
31
  npm install
32
- npm run dev
32
+ npm start
33
33
  ```
34
34
 
35
- Open the URL it prints. Edit `src/pages/index.md` and the browser reloads.
35
+ `npm start` opens the site in your browser. Edit `src/pages/index.md` and the page reloads. (`npm run dev` does the same without opening a browser, and prints the address.)
36
36
 
37
37
  ## Using vagejs
38
38
 
@@ -103,7 +103,8 @@ export default layout;
103
103
 
104
104
  | Command | What it does |
105
105
  | --- | --- |
106
- | `npm run dev` | Dev server with live reload |
106
+ | `npm start` | Dev server with live reload, opened in your browser |
107
+ | `npm run dev` | The same, without opening a browser; prints the address (and a direct `[::1]` or `127.0.0.1` address to use if the browser shows HTTP 431) |
107
108
  | `npm run check` | Links, SEO, structured data and basic accessibility; writes nothing |
108
109
  | `npm run build` | Static site in `dist/`, plus `robots.txt`, `sitemap.xml`, `llms.txt` |
109
110
  | `npm run audit` | Page-weight budgets and automated accessibility (`-- --lighthouse` adds Lighthouse) |
package/dist/cli/index.js CHANGED
@@ -9,6 +9,7 @@ import { VageError } from "../core/errors.js";
9
9
  import { assertBranchName, assertCloudflareProject, assertVageSpec, assertWorkerName } from "../core/validate.js";
10
10
  import { startDevServer } from "../dev/server.js";
11
11
  import { startPreviewServer } from "../dev/preview.js";
12
+ import { directUrl, printUrls } from "../dev/listen.js";
12
13
  import { createInterface } from "node:readline/promises";
13
14
  import { createProject } from "./create.js";
14
15
  import { frameworkInfo } from "./info.js";
@@ -23,17 +24,21 @@ cli
23
24
  if (opts.json)
24
25
  return print({ ok: true, ...result });
25
26
  const rel = path.relative(process.cwd(), result.dir) || ".";
26
- console.log(`Created ${result.dir}\n\nNext steps:\n cd ${rel}\n npm install\n npm run dev`);
27
+ console.log(`Created ${result.dir}\n\nNext steps:\n cd ${rel}\n npm install\n npm start\n\nnpm start opens the site in your browser. npm run dev starts it without opening one.`);
27
28
  }));
28
29
  cli
29
30
  .command("dev", "Start the dev server with live reload")
30
31
  .option("--root <dir>", "Project root", { default: "." })
31
32
  .option("--port <port>", "Port (fails if taken; default picks a free port from 5173)")
32
33
  .option("--host [host]", "Expose on the network")
34
+ .option("--open", "Open the site in your browser (at the direct address, so localhost cookies can't cause HTTP 431)")
33
35
  .action((opts) => run(opts, async () => {
34
36
  const server = await startDevServer(opts.root, { port: parsePort(opts.port), host: opts.host });
35
- console.log(`vagejs dev server running at ${server.resolvedUrls?.local[0]}`);
36
- server.resolvedUrls?.network.forEach((url) => console.log(` network: ${url}`));
37
+ const direct = directUrl(server.httpServer?.address());
38
+ printUrls("vagejs dev server", server.resolvedUrls?.local[0], direct, server.resolvedUrls?.network);
39
+ const target = direct ?? server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
40
+ if (opts.open && target)
41
+ openBrowser(target);
37
42
  }));
38
43
  cli
39
44
  .command("build", "Build the static site into dist/")
@@ -128,10 +133,14 @@ cli
128
133
  .option("--root <dir>", "Project root", { default: "." })
129
134
  .option("--port <port>", "Port (fails if taken; default picks a free port from 4173)")
130
135
  .option("--host [host]", "Expose on the network")
136
+ .option("--open", "Open the site in your browser")
131
137
  .action((opts) => run(opts, async () => {
132
138
  const server = await startPreviewServer(opts.root, { port: parsePort(opts.port), host: opts.host });
133
- console.log(`vagejs preview running at ${server.resolvedUrls?.local[0]}`);
134
- server.resolvedUrls?.network.forEach((url) => console.log(` network: ${url}`));
139
+ const direct = directUrl(server.httpServer?.address());
140
+ printUrls("vagejs preview", server.resolvedUrls?.local[0], direct, server.resolvedUrls?.network);
141
+ const target = direct ?? server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
142
+ if (opts.open && target)
143
+ openBrowser(target);
135
144
  }));
136
145
  cli
137
146
  .command("info", "Describe commands, config and frontmatter (use --json for agents)")
@@ -493,7 +502,16 @@ try {
493
502
  }
494
503
  }
495
504
  catch (err) {
496
- fail(err, Boolean(cli.options.json));
505
+ fail(usageError(err), Boolean(cli.options.json));
506
+ }
507
+ /** Mistakes in the command line itself (unknown option, extra value) get a clear message, not a stack trace. */
508
+ function usageError(err) {
509
+ if (err?.name !== "CACError")
510
+ return err;
511
+ const name = cli.matchedCommand?.name;
512
+ const help = name ? `vage ${name} --help` : "vage --help";
513
+ const lists = /^Unused args/.test(err.message) ? ' Options that take a list want one comma-separated value, e.g. --urls "/a/,/b/".' : "";
514
+ return new VageError(`${err.message}.${lists} See "${help}".`);
497
515
  }
498
516
  async function run(opts, fn) {
499
517
  try {
@@ -1,6 +1,17 @@
1
+ import type { AddressInfo } from "node:net";
1
2
  export interface ServeOptions {
2
3
  port?: number;
3
4
  host?: string | boolean;
4
5
  }
5
6
  /** Runs a Vite listen() call and turns a port conflict into an actionable message. */
6
7
  export declare function listenOrExplain<T>(listen: () => Promise<T>, port: number | undefined): Promise<T>;
8
+ /**
9
+ * The address the server is really listening on, when it's a loopback address, e.g.
10
+ * http://[::1]:5173/ or http://127.0.0.1:5173/. Browsers keep cookies per host name, so
11
+ * this address doesn't carry the cookies other projects left on "localhost" (the usual
12
+ * cause of HTTP 431). A server on every interface (--host) is reached at 127.0.0.1;
13
+ * a specific network address has no direct loopback address.
14
+ */
15
+ export declare function directUrl(address: AddressInfo | string | null | undefined): string | undefined;
16
+ /** Prints where the server runs: the localhost URL, the direct address, and network URLs. */
17
+ export declare function printUrls(label: string, local: string | undefined, direct: string | undefined, network?: string[]): void;
@@ -11,3 +11,29 @@ export async function listenOrExplain(listen, port) {
11
11
  throw err;
12
12
  }
13
13
  }
14
+ /**
15
+ * The address the server is really listening on, when it's a loopback address, e.g.
16
+ * http://[::1]:5173/ or http://127.0.0.1:5173/. Browsers keep cookies per host name, so
17
+ * this address doesn't carry the cookies other projects left on "localhost" (the usual
18
+ * cause of HTTP 431). A server on every interface (--host) is reached at 127.0.0.1;
19
+ * a specific network address has no direct loopback address.
20
+ */
21
+ export function directUrl(address) {
22
+ if (!address || typeof address === "string")
23
+ return undefined;
24
+ if (address.address === "::1")
25
+ return `http://[::1]:${address.port}/`;
26
+ if (address.address === "0.0.0.0" || address.address === "::")
27
+ return `http://127.0.0.1:${address.port}/`;
28
+ if (address.address.startsWith("127."))
29
+ return `http://${address.address}:${address.port}/`;
30
+ return undefined;
31
+ }
32
+ /** Prints where the server runs: the localhost URL, the direct address, and network URLs. */
33
+ export function printUrls(label, local, direct, network = []) {
34
+ console.log(`${label} running at ${local ?? direct ?? network[0]}`);
35
+ if (direct && direct !== local)
36
+ console.log(` same server: ${direct} (use this if the browser shows HTTP 431)`);
37
+ for (const url of network)
38
+ console.log(` network: ${url}`);
39
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vagejs",
3
- "version": "0.3.1",
4
- "description": "AI-native, static-first web framework: Markdown sites with built-in SEO, llms.txt, audits, security and safe deploys.",
3
+ "version": "0.3.3",
4
+ "description": "A free static site generator for AI website development: Markdown pages with built-in SEO, llms.txt, checks, spam protection and safe deploys.",
5
5
  "keywords": [
6
6
  "static-site-generator",
7
7
  "ssg",
@@ -9,9 +9,9 @@
9
9
  "seo",
10
10
  "llms-txt",
11
11
  "ai-agents",
12
- "vite",
13
- "cli",
14
- "web-framework"
12
+ "agents-md",
13
+ "claude-code",
14
+ "cli"
15
15
  ],
16
16
  "homepage": "https://vagejs.com",
17
17
  "author": "vagejs.com",
@@ -6,7 +6,8 @@ This website uses **vagejs** (pre-release). Only the features listed here exist
6
6
 
7
7
  | Command | What it does |
8
8
  | ----------------- | --------------------------------------------------------- |
9
- | `npm run dev` | Dev server with live reload. Prints the local URL. |
9
+ | `npm run dev` | Dev server with live reload. Prints the local URL and the same server's direct address (e.g. `http://[::1]:5173/`): if a browser shows HTTP 431 on localhost (too many cookies from other projects), use the direct address. Use this one yourself; it doesn't open a browser. |
10
+ | `npm start` | For people: the dev server, opened in the default browser at the direct address. |
10
11
  | `npm run build` | Static build into `dist/`. Exits non-zero on any error. |
11
12
  | `npm run check` | SEO, link, structured-data and basic a11y checks. Writes nothing. Exit 1 on errors (`--strict`: also on warnings). |
12
13
  | `npm run audit` | Builds, then checks page-weight budgets and runs axe accessibility rules. `--lighthouse` adds a local Lighthouse run (install `lighthouse`; needs Chrome). `--url <https://...>` audits a deployed page via PageSpeed Insights (+ CrUX field data with `CRUX_API_KEY`). |
@@ -4,6 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
+ "start": "vage dev --open",
7
8
  "dev": "vage dev",
8
9
  "build": "vage build",
9
10
  "check": "vage check",
@@ -11,6 +12,6 @@
11
12
  "preview": "vage preview"
12
13
  },
13
14
  "devDependencies": {
14
- "vagejs": "^0.3.1"
15
+ "vagejs": "^0.3.3"
15
16
  }
16
17
  }