veryfront 0.1.927 → 0.1.928
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/esm/cli/commands/routes/command.d.ts.map +1 -1
- package/esm/cli/commands/routes/command.js +42 -42
- package/esm/deno.js +1 -1
- package/esm/src/build/production-build/build/output-generator.d.ts.map +1 -1
- package/esm/src/build/production-build/build/output-generator.js +11 -7
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/routes/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/routes/command.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GAC/B,OAAO,CAAC,IAAI,CAAC,CA4Df"}
|
|
@@ -1,38 +1,51 @@
|
|
|
1
|
-
import { join } from "../../../deps/jsr.io/@std/path/1.1.4/mod.js";
|
|
1
|
+
import { join, relative } from "../../../deps/jsr.io/@std/path/1.1.4/mod.js";
|
|
2
2
|
import { runtime } from "../../../src/platform/index.js";
|
|
3
|
-
import { APIRouteHandler } from "../../../src/routing/index.js";
|
|
4
3
|
import { getConfig } from "../../../src/config/index.js";
|
|
5
4
|
import { cliLogger } from "../../utils/index.js";
|
|
6
|
-
import {
|
|
5
|
+
import { ApiRouteMatcher } from "../../../src/routing/api/api-route-matcher.js";
|
|
6
|
+
import { discoverAppRoutes, discoverPagesRoutes } from "../../../src/routing/api/route-discovery.js";
|
|
7
|
+
import { RouteDiscovery } from "../../../src/server/dev-server/route-discovery.js";
|
|
7
8
|
export async function routesCommand(projectDir, options = {}) {
|
|
8
|
-
const fs = createFileSystem();
|
|
9
9
|
const adapter = await runtime.get();
|
|
10
|
-
await getConfig(projectDir, adapter);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const pages = [];
|
|
14
|
-
const pagesDir = join(projectDir, "pages");
|
|
10
|
+
const config = await getConfig(projectDir, adapter);
|
|
11
|
+
const pageRouter = new ApiRouteMatcher();
|
|
12
|
+
let pageRoutes = [];
|
|
15
13
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!entry.isFile)
|
|
19
|
-
continue;
|
|
20
|
-
if (!entry.name.endsWith(".mdx") && !entry.name.endsWith(".tsx"))
|
|
21
|
-
continue;
|
|
22
|
-
const slug = entry.name.replace(/\.(mdx|tsx)$/i, "");
|
|
23
|
-
const path = slug === "index" ? "/" : `/${slug}`;
|
|
24
|
-
pages.push({ pattern: path, file: `pages/${entry.name}` });
|
|
25
|
-
}
|
|
14
|
+
await new RouteDiscovery(projectDir, adapter, pageRouter, config).discoverRoutes();
|
|
15
|
+
pageRoutes = pageRouter.listRoutes();
|
|
26
16
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
cliLogger.debug("Could not read pages directory:", error);
|
|
17
|
+
finally {
|
|
18
|
+
pageRouter.destroy();
|
|
30
19
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
const pages = pageRoutes
|
|
21
|
+
.map((route) => ({
|
|
22
|
+
pattern: route.pattern,
|
|
23
|
+
file: toProjectRelativePath(projectDir, route.page),
|
|
24
|
+
}))
|
|
25
|
+
.sort((a, b) => a.pattern.localeCompare(b.pattern));
|
|
26
|
+
const apiRouter = new ApiRouteMatcher();
|
|
27
|
+
let apiRoutes = [];
|
|
28
|
+
try {
|
|
29
|
+
const pagesDir = config.directories?.pages ?? "pages";
|
|
30
|
+
const apiDir = join(projectDir, pagesDir, "api");
|
|
31
|
+
if (await adapter.fs.exists(apiDir)) {
|
|
32
|
+
await discoverPagesRoutes(apiRouter, apiDir, "/api", adapter);
|
|
33
|
+
}
|
|
34
|
+
const appDir = join(projectDir, config.directories?.app ?? "app");
|
|
35
|
+
if (await adapter.fs.exists(appDir)) {
|
|
36
|
+
await discoverAppRoutes(apiRouter, appDir, "", adapter);
|
|
37
|
+
}
|
|
38
|
+
apiRoutes = apiRouter.listRoutes();
|
|
35
39
|
}
|
|
40
|
+
finally {
|
|
41
|
+
apiRouter.destroy();
|
|
42
|
+
}
|
|
43
|
+
const apis = apiRoutes
|
|
44
|
+
.map((route) => ({
|
|
45
|
+
pattern: route.pattern,
|
|
46
|
+
file: toProjectRelativePath(projectDir, route.page),
|
|
47
|
+
}))
|
|
48
|
+
.sort((a, b) => a.pattern.localeCompare(b.pattern));
|
|
36
49
|
if (options.json) {
|
|
37
50
|
console.log(JSON.stringify({ pages, apis }, null, 2));
|
|
38
51
|
return;
|
|
@@ -43,22 +56,9 @@ export async function routesCommand(projectDir, options = {}) {
|
|
|
43
56
|
}
|
|
44
57
|
cliLogger.info("\nAPI:");
|
|
45
58
|
for (const a of apis) {
|
|
46
|
-
cliLogger.info(` ${a}`);
|
|
59
|
+
cliLogger.info(` ${a.pattern} -> ${a.file}`);
|
|
47
60
|
}
|
|
48
61
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
for await (const entry of entries) {
|
|
52
|
-
const fullPath = join(dir, entry.name);
|
|
53
|
-
if (entry.isDirectory) {
|
|
54
|
-
await collectApiPatterns(fs, fullPath, `${prefix}/${entry.name}`, out);
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (!entry.isFile || !/\.(ts|js|tsx|jsx)$/i.test(entry.name))
|
|
58
|
-
continue;
|
|
59
|
-
const nameWithoutExt = entry.name.replace(/\.(ts|js|tsx|jsx)$/i, "");
|
|
60
|
-
const routePath = `${prefix}/${nameWithoutExt}`;
|
|
61
|
-
const pattern = routePath.replace(/\/index$/, "");
|
|
62
|
-
out.push(pattern);
|
|
63
|
-
}
|
|
62
|
+
function toProjectRelativePath(projectDir, path) {
|
|
63
|
+
return path.startsWith(projectDir) ? relative(projectDir, path) : path;
|
|
64
64
|
}
|
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/build/production-build/build/output-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAe1F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,KAAK,EAAE,UAAU,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACpD;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"output-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/build/production-build/build/output-generator.ts"],"names":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AE,OAAO,GACd,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAEhD;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBvF"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - Static asset copying
|
|
10
10
|
*/
|
|
11
11
|
import { serverLogger as logger } from "../../../utils/index.js";
|
|
12
|
-
import { join } from "../../../platform/compat/path/index.js";
|
|
12
|
+
import { dirname, join } from "../../../platform/compat/path/index.js";
|
|
13
13
|
import { generateServiceWorker } from "../../../server/build-service-worker.js";
|
|
14
14
|
import { generateProdHydrationModule, getProdHydrationModulePath, } from "../../../html/hydration-script-builder/prod-scripts.js";
|
|
15
15
|
import { copyStaticAssets } from "../asset-generation.js";
|
|
@@ -23,13 +23,17 @@ export async function generateClientScripts(adapter, outputDir, dryRun) {
|
|
|
23
23
|
logger.info("Copying client scripts...");
|
|
24
24
|
if (dryRun)
|
|
25
25
|
return;
|
|
26
|
-
await adapter
|
|
27
|
-
await adapter
|
|
28
|
-
await adapter
|
|
29
|
-
await adapter
|
|
26
|
+
await writeOutputFile(adapter, join(outputDir, "_veryfront/app.js"), generateAppModule());
|
|
27
|
+
await writeOutputFile(adapter, join(outputDir, "_veryfront/client.js"), await generateClientModule());
|
|
28
|
+
await writeOutputFile(adapter, join(outputDir, "_veryfront/router.js"), await generateRouterScript(adapter));
|
|
29
|
+
await writeOutputFile(adapter, join(outputDir, "_veryfront/prefetch.js"), await generatePrefetchScript(adapter));
|
|
30
30
|
const hydrationRuntime = generateProdHydrationModule();
|
|
31
|
-
await adapter
|
|
32
|
-
await adapter
|
|
31
|
+
await writeOutputFile(adapter, join(outputDir, "_veryfront/hydration-runtime.js"), hydrationRuntime);
|
|
32
|
+
await writeOutputFile(adapter, join(outputDir, getProdHydrationModulePath().slice(1)), hydrationRuntime);
|
|
33
|
+
}
|
|
34
|
+
async function writeOutputFile(adapter, path, content) {
|
|
35
|
+
await adapter.fs.mkdir(dirname(path), { recursive: true });
|
|
36
|
+
await adapter.fs.writeFile(path, content);
|
|
33
37
|
}
|
|
34
38
|
/**
|
|
35
39
|
* Generate manifest and service worker
|