@evjs/cli 0.1.11 → 0.2.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 +15 -6
- package/dist/cli.js +27 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +11 -2
- package/dist/inspect-command.d.ts +10 -0
- package/dist/inspect-command.js +28 -0
- package/dist/inspect.d.ts +4 -0
- package/dist/inspect.js +116 -0
- package/dist/load-config.d.ts +4 -2
- package/dist/load-config.js +10 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ No configuration file is needed. `ev dev` and `ev build` delegate to `@evjs/ev`
|
|
|
24
24
|
|---------|-------------|
|
|
25
25
|
| `ev dev` | Start dev server (client HMR + API watch) |
|
|
26
26
|
| `ev build` | Production build (client + server) |
|
|
27
|
+
| `ev inspect` | Explain framework discovery without running a bundler or writing `dist` |
|
|
27
28
|
|
|
28
29
|
> **Scaffolding:** Use `npx @evjs/create-app` to scaffold a new project.
|
|
29
30
|
|
|
@@ -37,7 +38,15 @@ Uses the default bundler adapter directly (no temp config files):
|
|
|
37
38
|
|
|
38
39
|
Runs the production build through `@evjs/ev` with `NODE_ENV=production`:
|
|
39
40
|
- `dist/client/` — optimized client assets with content hashes.
|
|
40
|
-
- `dist/server/main.[hash].js` — server bundle
|
|
41
|
+
- `dist/server/main.[hash].js` — server bundle.
|
|
42
|
+
- `dist/manifest.json` — single framework manifest with client, server, route, and function metadata.
|
|
43
|
+
|
|
44
|
+
### `ev inspect`
|
|
45
|
+
|
|
46
|
+
Runs the framework preflight path without bundling. Use it to inspect page
|
|
47
|
+
routes, ignored/rejected route files, server functions, server routes, render
|
|
48
|
+
metadata, runtime paths, planned entries, and diagnostics. Add
|
|
49
|
+
`--json` for machine-readable output.
|
|
41
50
|
|
|
42
51
|
## Configuration
|
|
43
52
|
|
|
@@ -67,13 +76,13 @@ my-app/
|
|
|
67
76
|
├── package.json
|
|
68
77
|
├── tsconfig.json
|
|
69
78
|
└── src/
|
|
70
|
-
├──
|
|
71
|
-
├──
|
|
79
|
+
├── pages/ # page routes
|
|
80
|
+
│ ├── index.tsx
|
|
81
|
+
│ └── users/$id.tsx
|
|
72
82
|
├── api/ # server functions
|
|
73
83
|
│ ├── users.server.ts
|
|
74
84
|
│ └── posts.server.ts
|
|
75
|
-
|
|
76
|
-
└── auth.ts
|
|
85
|
+
└── server.ts # optional server entry
|
|
77
86
|
```
|
|
78
87
|
|
|
79
88
|
## Common Mistakes
|
|
@@ -87,5 +96,5 @@ my-app/
|
|
|
87
96
|
|
|
88
97
|
Users do NOT need to install these — they're included through `@evjs/cli`:
|
|
89
98
|
- `@evjs/bundler-utoopack`
|
|
90
|
-
- `@evjs/
|
|
99
|
+
- build tools under `@evjs/ev`
|
|
91
100
|
- the bundler's underlying compiler dependencies
|
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import { configure, getConsoleSink, getLogger } from "@logtape/logtape";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
import { build, dev } from "./index.js";
|
|
8
|
+
import { formatInspectCommandErrorJson, runInspectCommand, } from "./inspect-command.js";
|
|
8
9
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
10
|
await configure({
|
|
10
11
|
sinks: {
|
|
@@ -71,4 +72,30 @@ program
|
|
|
71
72
|
process.exit(1);
|
|
72
73
|
}
|
|
73
74
|
});
|
|
75
|
+
program
|
|
76
|
+
.command("inspect")
|
|
77
|
+
.description("Inspect evjs framework discovery without running a bundler")
|
|
78
|
+
.option("--json", "Print machine-readable JSON")
|
|
79
|
+
.action(async (options) => {
|
|
80
|
+
const cwd = process.cwd();
|
|
81
|
+
try {
|
|
82
|
+
const result = await runInspectCommand({
|
|
83
|
+
cwd,
|
|
84
|
+
json: Boolean(options.json),
|
|
85
|
+
});
|
|
86
|
+
process.stdout.write(result.output);
|
|
87
|
+
if (result.exitCode !== 0) {
|
|
88
|
+
process.exit(result.exitCode);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
if (options.json) {
|
|
93
|
+
process.stdout.write(formatInspectCommandErrorJson(err));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
logger.error `Inspect failed: ${err}`;
|
|
97
|
+
}
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
74
101
|
program.parse();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { utoopackAdapter } from "@evjs/bundler-utoopack";
|
|
2
|
+
import { type BuildOptions, type BundlerAdapter, type Config, type DevOptions } from "@evjs/ev";
|
|
3
|
+
export { type BuildOptions, type BuildResult, type BundlerAdapter, type BundlerCtx, type ClientManifest, CONFIG_DEFAULTS, type Config, type DevOptions, defineConfig, type EvBuildResult, type EvBundlerCtx, type EvConfig, type EvDocument, type EvPlugin, type EvPluginConfigContext, type EvPluginContext, type EvPluginHooks, type Plugin, type PluginContext, type PluginHooks, type ResolvedConfig, type ResolvedEvConfig, resolveConfig, type ServerManifest, } from "@evjs/ev";
|
|
3
4
|
export { loadConfig } from "./load-config.js";
|
|
4
|
-
export
|
|
5
|
-
export declare function
|
|
5
|
+
export type DefaultBundlerConfig = typeof utoopackAdapter extends BundlerAdapter<infer TBundlerCfg> ? TBundlerCfg : never;
|
|
6
|
+
export declare function dev<TBundlerCfg = DefaultBundlerConfig>(userConfig?: Config<TBundlerCfg>, options?: DevOptions<TBundlerCfg>): Promise<void>;
|
|
7
|
+
export declare function build<TBundlerCfg = DefaultBundlerConfig>(userConfig?: Config<TBundlerCfg>, options?: BuildOptions<TBundlerCfg>): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -4,14 +4,23 @@ export { CONFIG_DEFAULTS, defineConfig, resolveConfig, } from "@evjs/ev";
|
|
|
4
4
|
export { loadConfig } from "./load-config.js";
|
|
5
5
|
const defaultBundler = utoopackAdapter;
|
|
6
6
|
export async function dev(userConfig, options) {
|
|
7
|
+
const { loadConfig } = await import("./load-config.js");
|
|
8
|
+
const defaultLoadConfig = (loadConfig);
|
|
9
|
+
const bundler = options?.bundler ??
|
|
10
|
+
userConfig?.bundler ??
|
|
11
|
+
defaultBundler;
|
|
7
12
|
await frameworkDev(userConfig, {
|
|
8
13
|
...options,
|
|
9
|
-
bundler
|
|
14
|
+
bundler,
|
|
15
|
+
loadConfig: options?.loadConfig ?? defaultLoadConfig,
|
|
10
16
|
});
|
|
11
17
|
}
|
|
12
18
|
export async function build(userConfig, options) {
|
|
19
|
+
const bundler = options?.bundler ??
|
|
20
|
+
userConfig?.bundler ??
|
|
21
|
+
defaultBundler;
|
|
13
22
|
await frameworkBuild(userConfig, {
|
|
14
23
|
...options,
|
|
15
|
-
bundler
|
|
24
|
+
bundler,
|
|
16
25
|
});
|
|
17
26
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface InspectCommandOptions {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
json?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface InspectCommandResult {
|
|
6
|
+
exitCode: 0 | 1;
|
|
7
|
+
output: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function runInspectCommand(options?: InspectCommandOptions): Promise<InspectCommandResult>;
|
|
10
|
+
export declare function formatInspectCommandErrorJson(error: unknown): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { inspectFrameworkBuild } from "@evjs/ev";
|
|
2
|
+
import { formatInspectJson, formatInspectText, hasInspectErrors, } from "./inspect.js";
|
|
3
|
+
import { loadConfig } from "./load-config.js";
|
|
4
|
+
export async function runInspectCommand(options = {}) {
|
|
5
|
+
const cwd = options.cwd ?? process.cwd();
|
|
6
|
+
const config = await loadConfig(cwd);
|
|
7
|
+
const result = await inspectFrameworkBuild(config ?? undefined, {
|
|
8
|
+
cwd,
|
|
9
|
+
runLifecycleHooks: false,
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
exitCode: hasInspectErrors(result) ? 1 : 0,
|
|
13
|
+
output: options.json
|
|
14
|
+
? formatInspectJson(result)
|
|
15
|
+
: formatInspectText(result),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function formatInspectCommandErrorJson(error) {
|
|
19
|
+
return `${JSON.stringify({
|
|
20
|
+
diagnostics: [
|
|
21
|
+
{
|
|
22
|
+
level: "error",
|
|
23
|
+
source: "config",
|
|
24
|
+
message: error instanceof Error ? error.message : String(error),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
}, null, 2)}\n`;
|
|
28
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InspectFrameworkBuildResult } from "@evjs/ev";
|
|
2
|
+
export declare function hasInspectErrors(result: InspectFrameworkBuildResult): boolean;
|
|
3
|
+
export declare function formatInspectJson(result: InspectFrameworkBuildResult): string;
|
|
4
|
+
export declare function formatInspectText(result: InspectFrameworkBuildResult): string;
|
package/dist/inspect.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export function hasInspectErrors(result) {
|
|
2
|
+
return result.diagnostics.some((diagnostic) => diagnostic.level === "error");
|
|
3
|
+
}
|
|
4
|
+
export function formatInspectJson(result) {
|
|
5
|
+
return `${JSON.stringify(result, null, 2)}\n`;
|
|
6
|
+
}
|
|
7
|
+
export function formatInspectText(result) {
|
|
8
|
+
const lines = [];
|
|
9
|
+
lines.push("ev inspect");
|
|
10
|
+
lines.push(`Project: ${result.cwd}`);
|
|
11
|
+
lines.push(`Mode: ${result.command} (${result.mode})`);
|
|
12
|
+
lines.push("");
|
|
13
|
+
lines.push("Routing");
|
|
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(` layout: ${formatValue(result.routing.layout ?? "auto")}`);
|
|
20
|
+
if (result.routing.rootModule) {
|
|
21
|
+
lines.push(` rootModule: ${result.routing.rootModule}`);
|
|
22
|
+
}
|
|
23
|
+
if (result.routing.routeTypes) {
|
|
24
|
+
lines.push(` routeTypes: ${result.routing.routeTypes}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
lines.push(" (disabled)");
|
|
29
|
+
}
|
|
30
|
+
lines.push("");
|
|
31
|
+
appendList(lines, "Page Routes", result.pageRoutes, (route) => {
|
|
32
|
+
return `${route.path} -> ${route.id} (${route.module})`;
|
|
33
|
+
});
|
|
34
|
+
appendList(lines, "Route Files", result.routeFiles, (file) => {
|
|
35
|
+
const diagnostics = file.diagnostics
|
|
36
|
+
?.map((diagnostic) => ` ${formatDiagnostic(diagnostic)}`)
|
|
37
|
+
.join("");
|
|
38
|
+
const target = file.status === "route" ? ` -> ${file.routePath} (${file.routeId})` : "";
|
|
39
|
+
return `${file.status}: ${file.file}${target}${diagnostics ?? ""}`;
|
|
40
|
+
});
|
|
41
|
+
appendList(lines, "Pages", result.pages, (page) => {
|
|
42
|
+
const model = [
|
|
43
|
+
`render=${page.render}`,
|
|
44
|
+
page.hydrate ? `hydrate=${page.hydrate}` : undefined,
|
|
45
|
+
page.rsc ? "rsc=true" : undefined,
|
|
46
|
+
page.partialPrerender ? "ppr=true" : undefined,
|
|
47
|
+
]
|
|
48
|
+
.filter(Boolean)
|
|
49
|
+
.join(", ");
|
|
50
|
+
const source = page.component ?? page.entry ?? page.app ?? "(generated)";
|
|
51
|
+
return `${page.id}: ${model} (${source})`;
|
|
52
|
+
});
|
|
53
|
+
appendList(lines, "Server Functions", result.serverFunctions, (fn) => {
|
|
54
|
+
return `${fn.exportName} -> ${fn.id} (${fn.module})`;
|
|
55
|
+
});
|
|
56
|
+
appendList(lines, "Server Routes", result.serverRoutes, (route) => {
|
|
57
|
+
return `${route.path} [${route.methods.join(", ")}] (${route.module})`;
|
|
58
|
+
});
|
|
59
|
+
lines.push("Runtime");
|
|
60
|
+
lines.push(` serverEnabled: ${String(result.runtime.serverEnabled)}`);
|
|
61
|
+
if (result.runtime.server) {
|
|
62
|
+
lines.push(` server.basePath: ${result.runtime.server.basePath}`);
|
|
63
|
+
lines.push(` server.fn: ${result.runtime.server.fn}`);
|
|
64
|
+
lines.push(` server.ppr: ${result.runtime.server.ppr}`);
|
|
65
|
+
if (result.runtime.server.rsc) {
|
|
66
|
+
lines.push(` server.rsc: ${result.runtime.server.rsc}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (result.runtime.transport?.baseUrl) {
|
|
70
|
+
lines.push(` transport.baseUrl: ${result.runtime.transport.baseUrl}`);
|
|
71
|
+
}
|
|
72
|
+
lines.push("");
|
|
73
|
+
if (result.buildPlan) {
|
|
74
|
+
appendList(lines, "Build Entries", result.buildPlan.entries, (entry) => {
|
|
75
|
+
return `${entry.name}: ${entry.kind}/${entry.environment}`;
|
|
76
|
+
});
|
|
77
|
+
appendList(lines, "HTML Documents", result.buildPlan.html, (document) => {
|
|
78
|
+
return `${document.id}: ${document.fileName}`;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
appendList(lines, "Diagnostics", result.diagnostics, formatDiagnostic);
|
|
82
|
+
lines.push(`File Dependencies: ${result.fileDependencies.length}`);
|
|
83
|
+
lines.push(`Plugin Watch Files: ${result.pluginWatchFiles.length}`);
|
|
84
|
+
return `${lines.join("\n")}\n`;
|
|
85
|
+
}
|
|
86
|
+
function appendList(lines, title, values, format) {
|
|
87
|
+
lines.push(title);
|
|
88
|
+
if (values.length === 0) {
|
|
89
|
+
lines.push(" (none)");
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
for (const value of values) {
|
|
93
|
+
lines.push(` ${format(value)}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
lines.push("");
|
|
97
|
+
}
|
|
98
|
+
function formatDiagnostic(diagnostic) {
|
|
99
|
+
const location = [
|
|
100
|
+
diagnostic.file,
|
|
101
|
+
diagnostic.line === undefined
|
|
102
|
+
? undefined
|
|
103
|
+
: diagnostic.column === undefined
|
|
104
|
+
? String(diagnostic.line)
|
|
105
|
+
: `${diagnostic.line}:${diagnostic.column}`,
|
|
106
|
+
]
|
|
107
|
+
.filter(Boolean)
|
|
108
|
+
.join(":");
|
|
109
|
+
const prefix = `[${diagnostic.level}] ${diagnostic.source}`;
|
|
110
|
+
return location
|
|
111
|
+
? `${prefix} ${location} - ${diagnostic.message}`
|
|
112
|
+
: `${prefix} - ${diagnostic.message}`;
|
|
113
|
+
}
|
|
114
|
+
function formatValue(value) {
|
|
115
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
116
|
+
}
|
package/dist/load-config.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config, DefaultBundlerConfig } from "@evjs/ev";
|
|
2
|
+
export declare const CONFIG_FILES: string[];
|
|
2
3
|
/**
|
|
3
4
|
* Load evjs config from the project root.
|
|
4
5
|
*
|
|
5
6
|
* Looks for `ev.config.ts`, `.js`, or `.mjs` in the given directory.
|
|
6
7
|
* Returns undefined if no config file is found.
|
|
7
8
|
*/
|
|
8
|
-
export declare function loadConfig(cwd: string): Promise<
|
|
9
|
+
export declare function loadConfig<TBundlerCfg = DefaultBundlerConfig>(cwd: string): Promise<Config<TBundlerCfg> | undefined>;
|
|
10
|
+
export declare function resolveConfigPath(cwd: string): string | undefined;
|
package/dist/load-config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
|
|
3
|
+
import { loadConfigFile } from "@evjs/ev/build-tools";
|
|
4
|
+
export const CONFIG_FILES = ["ev.config.ts", "ev.config.js", "ev.config.mjs"];
|
|
4
5
|
/**
|
|
5
6
|
* Load evjs config from the project root.
|
|
6
7
|
*
|
|
@@ -8,12 +9,16 @@ const CONFIG_FILES = ["ev.config.ts", "ev.config.js", "ev.config.mjs"];
|
|
|
8
9
|
* Returns undefined if no config file is found.
|
|
9
10
|
*/
|
|
10
11
|
export async function loadConfig(cwd) {
|
|
12
|
+
const configPath = resolveConfigPath(cwd);
|
|
13
|
+
if (!configPath)
|
|
14
|
+
return undefined;
|
|
15
|
+
return loadConfigFile(configPath);
|
|
16
|
+
}
|
|
17
|
+
export function resolveConfigPath(cwd) {
|
|
11
18
|
for (const filename of CONFIG_FILES) {
|
|
12
19
|
const configPath = path.resolve(cwd, filename);
|
|
13
|
-
if (fs.existsSync(configPath))
|
|
14
|
-
|
|
15
|
-
return mod.default ?? mod;
|
|
16
|
-
}
|
|
20
|
+
if (fs.existsSync(configPath))
|
|
21
|
+
return configPath;
|
|
17
22
|
}
|
|
18
23
|
return undefined;
|
|
19
24
|
}
|