@evjs/cli 0.2.16 → 0.3.1
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 +62 -32
- package/bin/ev.js +8 -1
- package/dist/cli-program.d.ts +22 -0
- package/dist/cli-program.js +98 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +56 -115
- package/dist/index.d.ts +2 -2
- package/dist/inspect.js +129 -36
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -8,15 +8,23 @@
|
|
|
8
8
|
npm install -g @evjs/cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Canonical Conventions
|
|
12
12
|
|
|
13
|
-
|
|
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
|
-
-
|
|
16
|
-
-
|
|
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
|
+
- Reachable server functions discovered via the `"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
|
|
|
@@ -31,24 +39,25 @@ No configuration file is needed. `ev dev` and `ev build` delegate to `@evjs/ev`
|
|
|
31
39
|
|
|
32
40
|
### `ev dev`
|
|
33
41
|
|
|
34
|
-
Uses the default bundler adapter directly
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
Uses the default bundler adapter directly:
|
|
43
|
+
|
|
44
|
+
1. **browser dev server** (preferred port 3000) — client bundle with HMR;
|
|
45
|
+
2. **framework server** (preferred port 3001) — starts when the active
|
|
46
|
+
BuildPlan emits a server runtime.
|
|
37
47
|
|
|
38
48
|
### `ev build`
|
|
39
49
|
|
|
40
50
|
Runs the production build through `@evjs/ev` with `NODE_ENV=production`:
|
|
41
51
|
- `dist/client/` — optimized client assets with content hashes.
|
|
42
|
-
- `dist/server
|
|
43
|
-
- `dist/
|
|
44
|
-
|
|
45
|
-
- `dist/build-output.json` — canonical deployment metadata for tooling and adapters.
|
|
52
|
+
- `dist/server/` — server artifacts when the BuildPlan requires them.
|
|
53
|
+
- `dist/deployment-metadata.json` — canonical deployment metadata for tooling
|
|
54
|
+
and adapters.
|
|
46
55
|
|
|
47
56
|
### `ev prepare`
|
|
48
57
|
|
|
49
58
|
Runs config resolution, file-convention discovery, generated contributions, and
|
|
50
59
|
entry facade generation without invoking the bundler. It writes `.ev/` so tools
|
|
51
|
-
and agents can inspect `.ev/manifest.json`, `.ev/framework/
|
|
60
|
+
and agents can inspect `.ev/manifest.json`, `.ev/framework/core-graph.json`,
|
|
52
61
|
`.ev/framework/build-plan.json`, generated entries, and plugin generated
|
|
53
62
|
modules.
|
|
54
63
|
|
|
@@ -61,14 +70,15 @@ functions, server routes, render metadata, runtime paths, planned entries, and d
|
|
|
61
70
|
|
|
62
71
|
## Configuration
|
|
63
72
|
|
|
64
|
-
Create `ev.config.ts` in the project root
|
|
73
|
+
Create `ev.config.ts` in the project root and select the materialization mode:
|
|
65
74
|
|
|
66
75
|
```ts
|
|
67
76
|
import { defineConfig } from "@evjs/ev";
|
|
68
77
|
|
|
69
78
|
export default defineConfig({
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
routing: {
|
|
80
|
+
mode: "spa",
|
|
81
|
+
},
|
|
72
82
|
dev: { port: 3000 },
|
|
73
83
|
server: {
|
|
74
84
|
dev: { port: 3001 },
|
|
@@ -76,32 +86,52 @@ export default defineConfig({
|
|
|
76
86
|
});
|
|
77
87
|
```
|
|
78
88
|
|
|
79
|
-
The `dev` and `server.dev` fields accept extra options that are merged with
|
|
89
|
+
The `dev` and `server.dev` fields accept extra options that are merged with
|
|
90
|
+
defaults. Change only `routing.mode` to `"mpa"` to materialize the same Page
|
|
91
|
+
tree as Page-owned Documents. MPA accepts static Page paths and rejects
|
|
92
|
+
dynamic/catch-all paths and router-only boundary facets.
|
|
80
93
|
|
|
81
94
|
## Project Structure
|
|
82
95
|
|
|
83
|
-
```
|
|
96
|
+
```text
|
|
84
97
|
my-app/
|
|
85
|
-
├── ev.config.ts
|
|
86
|
-
├── index.html
|
|
98
|
+
├── ev.config.ts
|
|
99
|
+
├── index.html # shared HTML template
|
|
87
100
|
├── package.json
|
|
88
101
|
├── tsconfig.json
|
|
89
102
|
└── src/
|
|
90
|
-
├── pages/
|
|
91
|
-
│ ├──
|
|
92
|
-
│
|
|
93
|
-
├──
|
|
94
|
-
│
|
|
95
|
-
│ └──
|
|
96
|
-
└──
|
|
103
|
+
├── pages/
|
|
104
|
+
│ ├── page.tsx # /
|
|
105
|
+
│ ├── page.config.ts # optional build-time Page config
|
|
106
|
+
│ ├── components/
|
|
107
|
+
│ │ └── index.tsx # private source, not a Page
|
|
108
|
+
│ └── users/
|
|
109
|
+
│ └── $userId/
|
|
110
|
+
│ └── page.tsx # /users/:userId
|
|
111
|
+
├── api/
|
|
112
|
+
│ └── users.server.ts # reachable server functions
|
|
113
|
+
├── apis/
|
|
114
|
+
│ └── api/
|
|
115
|
+
│ └── health/
|
|
116
|
+
│ └── api.ts # /api/health server request route
|
|
117
|
+
└── middleware.ts # optional server middleware
|
|
97
118
|
```
|
|
98
119
|
|
|
99
|
-
|
|
120
|
+
Only `page.*` creates a canonical client Page and Route. Other files below a
|
|
121
|
+
Page directory, including `index.*`, are ordinary Page-private source and need
|
|
122
|
+
no `_` prefix. The Page directory determines the URL in both SPA and MPA mode.
|
|
123
|
+
|
|
124
|
+
## Authoring Boundaries
|
|
125
|
+
|
|
126
|
+
1. Canonical apps publish Pages through `src/pages/**/page.*` and declare
|
|
127
|
+
`routing.mode`; colocated `index.*` files remain ordinary source.
|
|
128
|
+
2. Configure the framework in `ev.config.ts`; the CLI supplies the default
|
|
129
|
+
bundler adapter.
|
|
130
|
+
3. Import `defineConfig` and `definePageConfig` from `@evjs/ev`.
|
|
100
131
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
4. **Import `defineConfig` from `@evjs/ev`** — not from `@evjs/server`
|
|
132
|
+
Explicit `application.routes` and `component`/`routes` config are SPA-only
|
|
133
|
+
route-tree inputs in `@evjs/ev`; they normalize into the same CoreGraph and
|
|
134
|
+
cannot be combined with canonical `routing` discovery.
|
|
105
135
|
|
|
106
136
|
## Bundled Dependencies
|
|
107
137
|
|
package/bin/ev.js
CHANGED
|
@@ -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 {
|
|
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 {
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
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
|
|
6
|
-
export type { BuildResult, BundlerCtx,
|
|
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(`
|
|
16
|
-
lines.push(`
|
|
17
|
-
lines.push(`
|
|
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 =
|
|
34
|
+
const target = formatRouteFileTarget(file);
|
|
39
35
|
return `${file.status}: ${file.file}${target}${diagnostics ?? ""}`;
|
|
40
36
|
});
|
|
41
|
-
appendList(lines, "
|
|
42
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
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
|
|
114
|
-
|
|
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
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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.
|
|
3
|
+
"version": "0.3.1",
|
|
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.
|
|
32
|
-
"@evjs/ev": "0.
|
|
31
|
+
"@evjs/bundler-utoopack": "0.3.1",
|
|
32
|
+
"@evjs/ev": "0.3.1",
|
|
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
|
},
|