@evjs/cli 0.2.15 → 0.3.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
@@ -8,15 +8,23 @@
8
8
  npm install -g @evjs/cli
9
9
  ```
10
10
 
11
- ## Convention over Configuration
11
+ ## Canonical Conventions
12
12
 
13
- No configuration file is needed. `ev dev` and `ev build` delegate to `@evjs/ev` and inject the default utoopack adapter:
13
+ `ev dev` and `ev build` delegate to `@evjs/ev` and inject the default
14
+ Utoopack adapter. Framework-managed applications declare whether the canonical
15
+ Page tree is materialized as an SPA or MPA:
14
16
 
15
- - Entry: `./src/main.tsx`
16
- - HTML: `./index.html`
17
+ - Page and client-route anchors: `./src/pages/**/page.*`
18
+ - Page scope and URL: the complete containing directory
19
+ - Optional build-time Page config: adjacent `page.config.ts`
20
+ - Shared HTML template: `./index.html`
17
21
  - Client dev server: port 3000
18
22
  - API server (dev): port 3001
19
23
  - Server functions auto-discovered via `"use server"` directive
24
+ - Server request-route anchors auto-discovered from `./src/apis/**/api.*`
25
+
26
+ `routing.mode` selects SPA or MPA materialization for the same semantic
27
+ Page-and-Route tree. It does not select a different file convention.
20
28
 
21
29
  ## Commands
22
30
 
@@ -40,15 +48,14 @@ Uses the default bundler adapter directly (no temp config files):
40
48
  Runs the production build through `@evjs/ev` with `NODE_ENV=production`:
41
49
  - `dist/client/` — optimized client assets with content hashes.
42
50
  - `dist/server/main.[hash].js` — server bundle.
43
- - `dist/client/manifest.json` — lightweight client deployment metadata.
44
- - `dist/server/manifest.json` — lightweight server entry and route metadata.
45
- - `dist/build-output.json` — canonical deployment metadata for tooling and adapters.
51
+ - `dist/deployment-metadata.json` — canonical deployment metadata for tooling
52
+ and adapters.
46
53
 
47
54
  ### `ev prepare`
48
55
 
49
56
  Runs config resolution, file-convention discovery, generated contributions, and
50
57
  entry facade generation without invoking the bundler. It writes `.ev/` so tools
51
- and agents can inspect `.ev/manifest.json`, `.ev/framework/app-graph.json`,
58
+ and agents can inspect `.ev/manifest.json`, `.ev/framework/core-graph.json`,
52
59
  `.ev/framework/build-plan.json`, generated entries, and plugin generated
53
60
  modules.
54
61
 
@@ -61,14 +68,15 @@ functions, server routes, render metadata, runtime paths, planned entries, and d
61
68
 
62
69
  ## Configuration
63
70
 
64
- Create `ev.config.ts` in the project root (optional):
71
+ Create `ev.config.ts` in the project root and select the materialization mode:
65
72
 
66
73
  ```ts
67
74
  import { defineConfig } from "@evjs/ev";
68
75
 
69
76
  export default defineConfig({
70
- entry: "./src/main.tsx",
71
- html: "./index.html",
77
+ routing: {
78
+ mode: "spa",
79
+ },
72
80
  dev: { port: 3000 },
73
81
  server: {
74
82
  dev: { port: 3001 },
@@ -76,32 +84,60 @@ export default defineConfig({
76
84
  });
77
85
  ```
78
86
 
79
- The `dev` and `server.dev` fields accept extra options that are merged with defaults.
87
+ The `dev` and `server.dev` fields accept extra options that are merged with
88
+ defaults. Change only `routing.mode` to `"mpa"` to materialize the same Page
89
+ tree as Page-owned Documents. Dynamic-route output and React route facets in
90
+ MPA remain staged; `ev inspect` and `ev build` report unsupported combinations.
80
91
 
81
92
  ## Project Structure
82
93
 
83
- ```
94
+ ```text
84
95
  my-app/
85
- ├── ev.config.ts # optional config
86
- ├── index.html # HTML template
96
+ ├── ev.config.ts
97
+ ├── index.html # shared HTML template
87
98
  ├── package.json
88
99
  ├── tsconfig.json
89
100
  └── src/
90
- ├── pages/ # page routes
91
- │ ├── index.tsx
92
- │ └── users/$id.tsx
93
- ├── api/ # server functions
94
- │ ├── users.server.ts
95
- │ └── posts.server.ts
96
- └── server.ts # optional server entry
101
+ ├── pages/
102
+ │ ├── page.tsx # /
103
+ │ ├── page.config.ts # optional build-time Page config
104
+ │ ├── components/
105
+ │ │ └── index.tsx # private source, not a Page
106
+ │ └── users/
107
+ │ └── $userId/
108
+ │ └── page.tsx # /users/:userId
109
+ ├── api/
110
+ │ └── users.server.ts # reachable server functions
111
+ ├── apis/
112
+ │ └── api/
113
+ │ └── health/
114
+ │ └── api.ts # /api/health server request route
115
+ └── middleware.ts # optional server middleware
97
116
  ```
98
117
 
118
+ Only `page.*` creates a canonical client Page and Route. Other files below a
119
+ Page directory, including `index.*`, are ordinary Page-private source and need
120
+ no `_` prefix. The Page directory determines the URL in both SPA and MPA mode.
121
+
99
122
  ## Common Mistakes
100
123
 
101
- 1. **Don't create `custom bundler config file`** — use `ev.config.ts` instead
102
- 2. **Don't install bundler internals manually** — the default adapter is provided by `@evjs/cli`
103
- 3. **Config file must be `ev.config.ts`** — not `evjs.config.ts`
104
- 4. **Import `defineConfig` from `@evjs/ev`** — not from `@evjs/server`
124
+ 1. **Do not create `src/main.tsx` or top-level `entry` for a canonical app** —
125
+ add `src/pages/**/page.tsx` anchors and declare `routing.mode`.
126
+ 2. **Do not use `index.tsx` as a new Page anchor** — it is ordinary private
127
+ source in the canonical model.
128
+ 3. **Do not create a custom bundler config file** — use `ev.config.ts` instead.
129
+ 4. **Do not install bundler internals manually** — the default adapter is
130
+ provided by `@evjs/cli`.
131
+ 5. **Config file must be `ev.config.ts`** — not `evjs.config.ts`.
132
+ 6. **Import `defineConfig` and `definePageConfig` from `@evjs/ev`** — not from
133
+ `@evjs/server`.
134
+
135
+ Explicit `application.routes` and `component`/`routes` config are SPA-only
136
+ route-tree inputs in `@evjs/ev`; their converters normalize into the same Core
137
+ graph, reject MPA materialization, and do not define additional canonical
138
+ routing models. File-convention applications must use `page.tsx` for every
139
+ published Page, keep Page configuration in `page.config.ts`, and select only
140
+ `routing.mode: "spa" | "mpa"`.
105
141
 
106
142
  ## Bundled Dependencies
107
143
 
package/bin/ev.js CHANGED
@@ -1,2 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import "../dist/cli.js";
2
+ import { runCli } from "../dist/cli.js";
3
+
4
+ try {
5
+ process.exitCode = await runCli(process.argv);
6
+ } catch (error) {
7
+ console.error(error);
8
+ process.exitCode = 1;
9
+ }
@@ -0,0 +1,22 @@
1
+ import type { Config } from "@evjs/ev/config";
2
+ import type { CliFlags } from "@evjs/ev/plugin";
3
+ import type { DefaultBundlerConfig } from "./index.js";
4
+ import { type InspectCommandOptions, type InspectCommandResult } from "./inspect-command.js";
5
+ type FrameworkCommand = (config: Config<DefaultBundlerConfig> | undefined, options: {
6
+ cwd: string;
7
+ flags: CliFlags;
8
+ }) => Promise<void>;
9
+ export interface CliProgramDependencies {
10
+ version: string;
11
+ cwd(): string;
12
+ loadConfig(cwd: string): Promise<Config<DefaultBundlerConfig> | undefined>;
13
+ dev: FrameworkCommand;
14
+ build: FrameworkCommand;
15
+ prepare: FrameworkCommand;
16
+ inspect(options: InspectCommandOptions): Promise<InspectCommandResult>;
17
+ writeStdout(output: string): void;
18
+ writeStderr(output: string): void;
19
+ reportError(summary: string, error: unknown): void;
20
+ }
21
+ export declare function runCliProgram(argv: readonly string[], dependencies: CliProgramDependencies): Promise<number>;
22
+ export {};
@@ -0,0 +1,98 @@
1
+ import { Command, CommanderError } from "commander";
2
+ import { parseCliFlags } from "./cli-options.js";
3
+ import { formatInspectCommandErrorJson, } from "./inspect-command.js";
4
+ export async function runCliProgram(argv, dependencies) {
5
+ let exitCode = 0;
6
+ const fail = () => {
7
+ exitCode = 1;
8
+ };
9
+ const runCommand = async (errorSummary, command) => {
10
+ try {
11
+ await command();
12
+ }
13
+ catch (error) {
14
+ dependencies.reportError(errorSummary, error);
15
+ fail();
16
+ }
17
+ };
18
+ const program = new Command()
19
+ .name("ev")
20
+ .description("CLI for the evjs framework")
21
+ .version(dependencies.version)
22
+ .exitOverride()
23
+ .configureOutput({
24
+ writeOut: dependencies.writeStdout,
25
+ writeErr: dependencies.writeStderr,
26
+ });
27
+ program
28
+ .command("dev")
29
+ .description("Start development server")
30
+ .allowUnknownOption(true)
31
+ .action(async (_options, command) => {
32
+ await runCommand("Failed to start dev server", async () => {
33
+ const cwd = dependencies.cwd();
34
+ const flags = parseCliFlags(command.args);
35
+ const config = await dependencies.loadConfig(cwd);
36
+ await dependencies.dev(config, { cwd, flags });
37
+ });
38
+ });
39
+ program
40
+ .command("build")
41
+ .description("Build project for production")
42
+ .allowUnknownOption(true)
43
+ .action(async (_options, command) => {
44
+ await runCommand("Build failed", async () => {
45
+ const cwd = dependencies.cwd();
46
+ const flags = parseCliFlags(command.args);
47
+ const config = await dependencies.loadConfig(cwd);
48
+ await dependencies.build(config, { cwd, flags });
49
+ });
50
+ });
51
+ program
52
+ .command("prepare")
53
+ .description("Generate .ev framework IR without running a bundler")
54
+ .allowUnknownOption(true)
55
+ .action(async (_options, command) => {
56
+ await runCommand("Prepare failed", async () => {
57
+ const cwd = dependencies.cwd();
58
+ const flags = parseCliFlags(command.args);
59
+ const config = await dependencies.loadConfig(cwd);
60
+ await dependencies.prepare(config, { cwd, flags });
61
+ });
62
+ });
63
+ program
64
+ .command("inspect")
65
+ .description("Inspect evjs framework discovery without running a bundler")
66
+ .option("--json", "Print machine-readable JSON")
67
+ .action(async (options) => {
68
+ try {
69
+ const result = await dependencies.inspect({
70
+ cwd: dependencies.cwd(),
71
+ json: Boolean(options.json),
72
+ });
73
+ dependencies.writeStdout(result.output);
74
+ if (result.exitCode !== 0)
75
+ fail();
76
+ }
77
+ catch (error) {
78
+ if (options.json) {
79
+ dependencies.writeStdout(formatInspectCommandErrorJson(error));
80
+ }
81
+ else {
82
+ dependencies.reportError("Inspect failed", error);
83
+ }
84
+ fail();
85
+ }
86
+ });
87
+ try {
88
+ await program.parseAsync([...argv]);
89
+ }
90
+ catch (error) {
91
+ if (error instanceof CommanderError) {
92
+ return error.exitCode;
93
+ }
94
+ dependencies.reportError("CLI failed", error);
95
+ return 1;
96
+ }
97
+ return exitCode;
98
+ }
package/dist/cli.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ export declare function runCli(argv?: readonly string[]): Promise<number>;
package/dist/cli.js CHANGED
@@ -3,121 +3,62 @@ import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { configure, getConsoleSink, getLogger } from "@logtape/logtape";
6
- import { Command } from "commander";
7
- import { parseCliFlags } from "./cli-options.js";
6
+ import { runCliProgram } from "./cli-program.js";
8
7
  import { build, dev, prepare } from "./index.js";
9
- import { formatInspectCommandErrorJson, runInspectCommand, } from "./inspect-command.js";
8
+ import { runInspectCommand } from "./inspect-command.js";
9
+ import { loadConfig } from "./load-config.js";
10
10
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
- await configure({
12
- sinks: {
13
- console: getConsoleSink({
14
- formatter: (record) => {
15
- const time = new Date(record.timestamp).toLocaleTimeString("en-US", {
16
- hour12: false,
17
- });
18
- const levelColor = record.level === "info"
19
- ? "\x1b[36m"
20
- : record.level === "warning"
21
- ? "\x1b[33m"
22
- : record.level === "error" || record.level === "fatal"
23
- ? "\x1b[31m"
24
- : "\x1b[32m";
25
- const reset = "\x1b[0m";
26
- const cat = record.category[1]
27
- ? `\x1b[90m[${record.category[1]}]\x1b[0m `
28
- : "";
29
- const msg = record.message.map(String).join("");
30
- return `${levelColor}${time}${reset} ${cat}${msg}\n`;
31
- },
32
- }),
33
- },
34
- loggers: [
35
- { category: ["logtape", "meta"], lowestLevel: "warning" },
36
- { category: ["evjs"], sinks: ["console"], lowestLevel: "info" },
37
- ],
38
- });
39
11
  const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf-8"));
40
- const program = new Command();
41
- program
42
- .name("ev")
43
- .description("CLI for the evjs framework")
44
- .version(pkg.version);
45
- const logger = getLogger(["evjs", "cli"]);
46
- program
47
- .command("dev")
48
- .description("Start development server")
49
- .allowUnknownOption(true)
50
- .action(async (_options, command) => {
51
- const cwd = process.cwd();
52
- const flags = parseCliFlags(command.args);
53
- const { loadConfig } = await import("./load-config.js");
54
- const config = await loadConfig(cwd);
55
- try {
56
- await dev(config ?? undefined, { cwd, flags });
57
- }
58
- catch (err) {
59
- logger.error `Failed to start dev server: ${err}`;
60
- process.exit(1);
61
- }
62
- });
63
- program
64
- .command("build")
65
- .description("Build project for production")
66
- .allowUnknownOption(true)
67
- .action(async (_options, command) => {
68
- const cwd = process.cwd();
69
- const flags = parseCliFlags(command.args);
70
- const { loadConfig } = await import("./load-config.js");
71
- const config = await loadConfig(cwd);
72
- try {
73
- await build(config ?? undefined, { cwd, flags });
74
- }
75
- catch (err) {
76
- logger.error `Build failed: ${err}`;
77
- process.exit(1);
78
- }
79
- });
80
- program
81
- .command("prepare")
82
- .description("Generate .ev framework IR without running a bundler")
83
- .allowUnknownOption(true)
84
- .action(async (_options, command) => {
85
- const cwd = process.cwd();
86
- const flags = parseCliFlags(command.args);
87
- const { loadConfig } = await import("./load-config.js");
88
- const config = await loadConfig(cwd);
89
- try {
90
- await prepare(config ?? undefined, { cwd, flags });
91
- }
92
- catch (err) {
93
- logger.error `Prepare failed: ${err}`;
94
- process.exit(1);
95
- }
96
- });
97
- program
98
- .command("inspect")
99
- .description("Inspect evjs framework discovery without running a bundler")
100
- .option("--json", "Print machine-readable JSON")
101
- .action(async (options) => {
102
- const cwd = process.cwd();
103
- try {
104
- const result = await runInspectCommand({
105
- cwd,
106
- json: Boolean(options.json),
107
- });
108
- process.stdout.write(result.output);
109
- if (result.exitCode !== 0) {
110
- process.exit(result.exitCode);
111
- }
112
- }
113
- catch (err) {
114
- if (options.json) {
115
- process.stdout.write(formatInspectCommandErrorJson(err));
116
- }
117
- else {
118
- logger.error `Inspect failed: ${err}`;
119
- }
120
- process.exit(1);
121
- }
122
- });
123
- program.parse();
12
+ let configureLoggingPromise;
13
+ function getLevelColor(level) {
14
+ if (level === "info")
15
+ return "\x1b[36m";
16
+ if (level === "warning")
17
+ return "\x1b[33m";
18
+ if (level === "error" || level === "fatal")
19
+ return "\x1b[31m";
20
+ return "\x1b[32m";
21
+ }
22
+ function configureLogging() {
23
+ configureLoggingPromise ??= configure({
24
+ sinks: {
25
+ console: getConsoleSink({
26
+ formatter: (record) => {
27
+ const time = new Date(record.timestamp).toLocaleTimeString("en-US", {
28
+ hour12: false,
29
+ });
30
+ const levelColor = getLevelColor(record.level);
31
+ const reset = "\x1b[0m";
32
+ const cat = record.category[1]
33
+ ? `\x1b[90m[${record.category[1]}]\x1b[0m `
34
+ : "";
35
+ const msg = record.message.map(String).join("");
36
+ return `${levelColor}${time}${reset} ${cat}${msg}\n`;
37
+ },
38
+ }),
39
+ },
40
+ loggers: [
41
+ { category: ["logtape", "meta"], lowestLevel: "warning" },
42
+ { category: ["evjs"], sinks: ["console"], lowestLevel: "info" },
43
+ ],
44
+ });
45
+ return configureLoggingPromise;
46
+ }
47
+ export async function runCli(argv = process.argv) {
48
+ await configureLogging();
49
+ const logger = getLogger(["evjs", "cli"]);
50
+ return runCliProgram(argv, {
51
+ version: pkg.version,
52
+ cwd: () => process.cwd(),
53
+ loadConfig: (cwd) => loadConfig(cwd),
54
+ dev,
55
+ build,
56
+ prepare,
57
+ inspect: runInspectCommand,
58
+ writeStdout: (output) => process.stdout.write(output),
59
+ writeStderr: (output) => process.stderr.write(output),
60
+ reportError(summary, error) {
61
+ logger.error `${summary}: ${error}`;
62
+ },
63
+ });
64
+ }
package/dist/index.d.ts CHANGED
@@ -2,8 +2,8 @@ import { utoopackAdapter } from "@evjs/bundler-utoopack";
2
2
  import { type BuildOptions, type BundlerAdapter, type DevOptions, type PrepareFrameworkBuildOptions } from "@evjs/ev/_internal/build";
3
3
  import type { Config } from "@evjs/ev/config";
4
4
  export type { BuildOptions, BundlerAdapter, DevOptions, PrepareFrameworkBuildOptions, } from "@evjs/ev/_internal/build";
5
- export { CONFIG_DEFAULTS, type Config, defineConfig, type EvConfig, type ResolvedConfig, type ResolvedEvConfig, resolveConfig, } from "@evjs/ev/config";
6
- export type { BuildResult, BundlerCtx, ClientManifest, ContributionContext, EmitApi, EvBuildResult, EvBundlerCtx, EvDocument, EvPlugin, EvPluginConfigContext, EvPluginContext, EvPluginHooks, FrameworkIRView, FrameworkSlot, FrameworkSlotInput, GeneratedModuleRef, Plugin, PluginContext, PluginHooks, ServerManifest, } from "@evjs/ev/plugin";
5
+ export { CONFIG_DEFAULTS, type Config, defineConfig, type ResolvedConfig, resolveConfig, } from "@evjs/ev/config";
6
+ export type { BuildResult, BundlerCtx, ContributionContext, EmitApi, FrameworkIRView, FrameworkSlot, FrameworkSlotInput, GeneratedModuleRef, Plugin, PluginContext, PluginHooks, } from "@evjs/ev/plugin";
7
7
  export { loadConfig } from "./load-config.js";
8
8
  export type DefaultBundlerConfig = typeof utoopackAdapter extends BundlerAdapter<infer TBundlerCfg> ? TBundlerCfg : never;
9
9
  export declare function dev<TBundlerCfg = DefaultBundlerConfig>(userConfig?: Config<TBundlerCfg>, options?: DevOptions<TBundlerCfg>): Promise<void>;
package/dist/inspect.js CHANGED
@@ -12,53 +12,80 @@ export function formatInspectText(result) {
12
12
  lines.push("");
13
13
  lines.push("Routing");
14
14
  if (result.routing) {
15
- lines.push(` mode: ${result.routing.mode}`);
16
- lines.push(` dir: ${result.routing.dir}`);
17
- lines.push(` html: ${result.routing.html}`);
18
- lines.push(` mount: ${result.routing.mount}`);
19
- lines.push(` conventions.layout: ${formatLayoutConvention(result.routing.conventions?.layout)}`);
15
+ lines.push(` routingMode: ${result.routing.routingMode}`);
16
+ lines.push(` pageRoot: ${result.routing.pageRoot}`);
17
+ lines.push(` document.template: ${result.routing.document.template}`);
18
+ lines.push(` document.mount: ${result.routing.document.mount}`);
20
19
  if (result.routing.rootModule) {
21
20
  lines.push(` rootModule: ${result.routing.rootModule}`);
22
21
  }
23
- if (result.routing.routeTypes) {
24
- lines.push(` routeTypes: ${result.routing.routeTypes}`);
25
- }
26
22
  }
27
23
  else {
28
24
  lines.push(" (disabled)");
29
25
  }
30
26
  lines.push("");
31
27
  appendList(lines, "Page Routes", result.pageRoutes, (route) => {
32
- return `${route.path} -> ${route.id} (${route.module})`;
28
+ return `${route.path} -> ${formatCoreIdentifier(route.id)} (${route.module})`;
33
29
  });
34
30
  appendList(lines, "Route Files", result.routeFiles, (file) => {
35
31
  const diagnostics = file.diagnostics
36
32
  ?.map((diagnostic) => ` ${formatDiagnostic(diagnostic)}`)
37
33
  .join("");
38
- const target = file.status === "route" ? ` -> ${file.routePath} (${file.routeId})` : "";
34
+ const target = formatRouteFileTarget(file);
39
35
  return `${file.status}: ${file.file}${target}${diagnostics ?? ""}`;
40
36
  });
41
- appendList(lines, "Pages", result.pages, (page) => {
42
- const model = [
37
+ appendList(lines, "Applications", Object.values(result.graph.applications), (application) => `${application.id}: ${application.routingMode}, pages=${application.pageIds.length}, routes=${application.routeIds.length}, documents=${application.documentIds.length}`);
38
+ appendList(lines, "Pages", Object.values(result.graph.pages), (page) => {
39
+ const extensions = Object.keys(page.extensions);
40
+ const metadata = [
41
+ `application=${page.applicationId}`,
43
42
  `render=${page.render}`,
43
+ `scope=${formatPageScope(page.source.scope)}`,
44
+ page.source.config ? `config=${page.source.config}` : undefined,
45
+ page.metadata ? `metadata=${JSON.stringify(page.metadata)}` : undefined,
44
46
  page.hydrate ? `hydrate=${page.hydrate}` : undefined,
45
- page.rsc ? "rsc=true" : undefined,
46
- page.partialPrerender ? "ppr=true" : undefined,
47
+ page.componentModel === "rsc" ? "rsc=true" : undefined,
48
+ page.ppr ||
49
+ (typeof page.prerender === "object" && page.prerender.partial === true)
50
+ ? "ppr=true"
51
+ : undefined,
52
+ extensions.length > 0 ? `extensions=${extensions.join(",")}` : undefined,
53
+ ]
54
+ .filter(Boolean)
55
+ .join(", ");
56
+ return `${page.id}: ${metadata} (${page.source.module})`;
57
+ });
58
+ appendList(lines, "Routes", result.graph.routes, formatCoreRoute);
59
+ appendList(lines, "Documents", Object.values(result.graph.documents), (document) => `${document.id}: application=${document.applicationId}, owner=${document.owner.kind}, output=${document.output}`);
60
+ appendList(lines, "Extensions", Object.entries(result.graph.extensions.namespaces), ([namespace, registration]) => {
61
+ const metadata = [
62
+ `producer=${formatCoreIdentifier(registration.producer)}`,
63
+ `owners=${registration.owners.join(",")}`,
64
+ registration.schemaVersion
65
+ ? `schema=${registration.schemaVersion}`
66
+ : undefined,
47
67
  ]
48
68
  .filter(Boolean)
49
69
  .join(", ");
50
- const source = page.component ?? page.entry ?? page.app ?? "(generated)";
51
- return `${page.id}: ${model} (${source})`;
70
+ return `${namespace}: ${metadata}`;
52
71
  });
53
- appendList(lines, "Server Functions", result.serverFunctions, (fn) => {
72
+ appendList(lines, "Server Functions", result.graph.serverFunctions, (fn) => {
54
73
  return `${fn.exportName} -> ${fn.id} (${fn.module})`;
55
74
  });
56
- appendList(lines, "Server Routes", result.serverRoutes, (route) => {
75
+ appendList(lines, "Server Routes", result.graph.serverRoutes, (route) => {
57
76
  return `${route.path} [${route.methods.join(", ")}] (${route.module})`;
58
77
  });
59
78
  lines.push("Runtime");
60
79
  lines.push(` output.client: ${result.output.client}`);
61
80
  lines.push(` output.server: ${result.output.server}`);
81
+ if (result.bundler) {
82
+ lines.push(` bundler: ${result.bundler.name}`);
83
+ lines.push(` bundler.build: ${formatCapabilities(result.bundler.capabilities.build)}`);
84
+ lines.push(` bundler.dev: ${formatCapabilities(result.bundler.capabilities.dev)}`);
85
+ for (const gap of result.bundler.gaps) {
86
+ lines.push(` bundler.gap: ${gap.capability} (${gap.reason})`);
87
+ }
88
+ }
62
89
  lines.push(` server.basePath: ${result.runtime.server.basePath}`);
63
90
  lines.push(` server.fn: ${result.runtime.server.fn}`);
64
91
  lines.push(` server.ppr: ${result.runtime.server.ppr}`);
@@ -74,7 +101,10 @@ export function formatInspectText(result) {
74
101
  return `${entry.name}: ${entry.kind}/${entry.environment}`;
75
102
  });
76
103
  appendList(lines, "HTML Documents", result.buildPlan.html, (document) => {
77
- return `${document.id}: ${document.fileName}`;
104
+ const aliases = document.aliases?.length
105
+ ? ` (aliases: ${document.aliases.join(", ")})`
106
+ : "";
107
+ return `${document.id}: ${document.fileName}${aliases}`;
78
108
  });
79
109
  }
80
110
  appendList(lines, "Diagnostics", result.diagnostics, formatDiagnostic);
@@ -82,6 +112,11 @@ export function formatInspectText(result) {
82
112
  lines.push(`Plugin Watch Files: ${result.pluginWatchFiles.length}`);
83
113
  return `${lines.join("\n")}\n`;
84
114
  }
115
+ function formatCapabilities(capabilities) {
116
+ return Object.entries(capabilities)
117
+ .map(([name, supported]) => `${name}=${supported === true ? "yes" : "no"}`)
118
+ .join(", ");
119
+ }
85
120
  function appendList(lines, title, values, format) {
86
121
  lines.push(title);
87
122
  if (values.length === 0) {
@@ -95,28 +130,86 @@ function appendList(lines, title, values, format) {
95
130
  lines.push("");
96
131
  }
97
132
  function formatDiagnostic(diagnostic) {
98
- const location = [
99
- diagnostic.file,
100
- diagnostic.line === undefined
101
- ? undefined
102
- : diagnostic.column === undefined
133
+ let position;
134
+ if (diagnostic.line !== undefined) {
135
+ position =
136
+ diagnostic.column === undefined
103
137
  ? String(diagnostic.line)
104
- : `${diagnostic.line}:${diagnostic.column}`,
105
- ]
106
- .filter(Boolean)
107
- .join(":");
138
+ : `${diagnostic.line}:${diagnostic.column}`;
139
+ }
140
+ const location = [diagnostic.file, position].filter(Boolean).join(":");
108
141
  const prefix = `[${diagnostic.level}] ${diagnostic.source}`;
109
142
  return location
110
143
  ? `${prefix} ${location} - ${diagnostic.message}`
111
144
  : `${prefix} - ${diagnostic.message}`;
112
145
  }
113
- function formatValue(value) {
114
- return typeof value === "string" ? value : JSON.stringify(value);
146
+ function formatRouteFileTarget(file) {
147
+ if (file.status === "route") {
148
+ return ` -> ${file.routePath} (${file.routeId})`;
149
+ }
150
+ if (file.status === "facet") {
151
+ const routePath = file.routePath ? ` ${file.routePath}` : "";
152
+ return ` -> ${file.facetKind}${routePath}`;
153
+ }
154
+ return "";
115
155
  }
116
- function formatLayoutConvention(value) {
117
- if (value === true)
118
- return "auto";
119
- if (value === false || value === undefined)
120
- return "disabled";
121
- return formatValue(value);
156
+ function formatPageScope(scope) {
157
+ return scope.kind === "directory" ? scope.root : scope.file;
158
+ }
159
+ function formatCoreRoute(route) {
160
+ const pattern = formatCoreRoutePattern(route.pattern.segments);
161
+ const parent = route.parentId
162
+ ? `, parent=${formatCoreIdentifier(route.parentId)}`
163
+ : "";
164
+ const facets = formatCoreRouteFacets(route);
165
+ return `client:${formatCoreIdentifier(route.id)}: ${pattern} -> ${formatCoreRouteTarget(route)}${parent}${facets ? `, ${facets}` : ""}`;
166
+ }
167
+ function formatCoreIdentifier(value) {
168
+ const providerPrefix = "@evjs/provider/";
169
+ if (!value.startsWith(providerPrefix))
170
+ return value;
171
+ const identifier = value.slice(providerPrefix.length);
172
+ const separator = identifier.indexOf(":");
173
+ return separator === -1 ? "framework" : identifier.slice(separator + 1);
174
+ }
175
+ function formatCoreRouteFacets(route) {
176
+ const facets = [];
177
+ if (route.facets.layout === false) {
178
+ facets.push("layout=false");
179
+ }
180
+ else if (route.facets.layout) {
181
+ facets.push(`layout=${route.facets.layout}`);
182
+ }
183
+ if (route.facets.error)
184
+ facets.push(`error=${route.facets.error}`);
185
+ if (route.facets.notFound) {
186
+ facets.push(`notFound=${route.facets.notFound}`);
187
+ }
188
+ if (route.facets.wrappers.length > 0) {
189
+ facets.push(`wrappers=${route.facets.wrappers.join(",")}`);
190
+ }
191
+ return facets.join(", ");
192
+ }
193
+ function formatCoreRoutePattern(segments) {
194
+ if (segments.length === 0)
195
+ return "/";
196
+ return `/${segments
197
+ .map((segment) => {
198
+ if (segment.kind === "static")
199
+ return segment.value;
200
+ if (segment.kind === "param")
201
+ return `:${segment.name}`;
202
+ return `*${segment.name}`;
203
+ })
204
+ .join("/")}`;
205
+ }
206
+ function formatCoreRouteTarget(route) {
207
+ if (route.target.kind === "page")
208
+ return `page:${route.target.pageId}`;
209
+ if (route.target.kind === "group")
210
+ return "group";
211
+ if (route.target.to.kind === "url") {
212
+ return `redirect:${route.target.to.href}`;
213
+ }
214
+ return `redirect:${formatCoreRoutePattern(route.target.to.pattern.segments)}`;
122
215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evjs/cli",
3
- "version": "0.2.15",
3
+ "version": "0.3.0",
4
4
  "description": "Command-line wrapper for the evjs framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,12 +28,13 @@
28
28
  "check-types": "tsc --noEmit"
29
29
  },
30
30
  "dependencies": {
31
- "@evjs/bundler-utoopack": "0.2.15",
32
- "@evjs/ev": "0.2.15",
31
+ "@evjs/bundler-utoopack": "0.3.0",
32
+ "@evjs/ev": "0.3.0",
33
33
  "@logtape/logtape": "^2.0.4",
34
34
  "commander": "^12.1.0"
35
35
  },
36
36
  "devDependencies": {
37
+ "@evjs/shared": "*",
37
38
  "@types/node": "^22.19.15",
38
39
  "typescript": "^6.0.2"
39
40
  },