astro 3.6.2 → 4.0.0-beta.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/client.d.ts +19 -20
- package/components/Code.astro +0 -20
- package/components/ViewTransitions.astro +2 -2
- package/dist/@types/astro.d.ts +19 -81
- package/dist/assets/build/generate.js +2 -2
- package/dist/assets/internal.js +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +3 -3
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +3 -3
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +3 -3
- package/dist/cli/add/babel.d.ts +1 -1
- package/dist/cli/build/index.js +0 -1
- package/dist/cli/flags.js +0 -3
- package/dist/cli/info/index.d.ts +5 -0
- package/dist/cli/info/index.js +16 -7
- package/dist/cli/install-package.js +1 -1
- package/dist/cli/telemetry/index.js +6 -6
- package/dist/content/server-listeners.js +7 -7
- package/dist/content/types-generator.d.ts +1 -4
- package/dist/content/types-generator.js +31 -51
- package/dist/core/app/index.js +2 -4
- package/dist/core/build/buildPipeline.js +3 -3
- package/dist/core/build/generate.js +18 -39
- package/dist/core/build/index.js +10 -32
- package/dist/core/build/internal.js +3 -3
- package/dist/core/build/plugin.d.ts +2 -2
- package/dist/core/build/plugins/plugin-manifest.js +1 -4
- package/dist/core/build/plugins/plugin-pages.js +0 -3
- package/dist/core/build/plugins/plugin-renderers.d.ts +1 -1
- package/dist/core/build/plugins/plugin-ssr.js +5 -6
- package/dist/core/build/static-build.js +4 -7
- package/dist/core/build/types.d.ts +1 -1
- package/dist/core/build/util.js +1 -1
- package/dist/core/config/config.js +1 -2
- package/dist/core/config/schema.d.ts +209 -277
- package/dist/core/config/schema.js +5 -38
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.d.ts +2 -2
- package/dist/core/create-vite.js +12 -1
- package/dist/core/dev/dev.js +6 -4
- package/dist/core/dev/restart.js +7 -7
- package/dist/core/endpoint/index.d.ts +2 -7
- package/dist/core/endpoint/index.js +3 -87
- package/dist/core/errors/dev/vite.js +0 -1
- package/dist/core/logger/console.d.ts +2 -4
- package/dist/core/logger/console.js +4 -28
- package/dist/core/logger/core.d.ts +17 -5
- package/dist/core/logger/core.js +27 -2
- package/dist/core/logger/node.d.ts +2 -32
- package/dist/core/logger/node.js +8 -69
- package/dist/core/messages.d.ts +4 -11
- package/dist/core/messages.js +43 -59
- package/dist/core/middleware/callMiddleware.d.ts +1 -2
- package/dist/core/middleware/callMiddleware.js +1 -12
- package/dist/core/middleware/index.d.ts +2 -2
- package/dist/core/middleware/sequence.d.ts +2 -2
- package/dist/core/pipeline.d.ts +2 -2
- package/dist/core/pipeline.js +8 -13
- package/dist/core/preview/static-preview-server.js +2 -4
- package/dist/core/preview/vite-plugin-astro-preview.js +31 -21
- package/dist/core/render/core.js +0 -6
- package/dist/core/render/index.d.ts +1 -1
- package/dist/core/render/result.js +1 -1
- package/dist/core/render/route-cache.js +2 -5
- package/dist/core/request.js +3 -3
- package/dist/core/routing/manifest/create.js +14 -12
- package/dist/core/routing/validation.js +4 -4
- package/dist/core/sync/index.js +2 -2
- package/dist/i18n/middleware.d.ts +2 -2
- package/dist/i18n/vite-plugin-i18n.js +1 -1
- package/dist/integrations/astroFeaturesValidation.d.ts +1 -1
- package/dist/integrations/astroFeaturesValidation.js +12 -18
- package/dist/integrations/index.js +28 -6
- package/dist/prefetch/vite-plugin-prefetch.js +3 -3
- package/dist/runtime/client/dev-overlay/entrypoint.js +14 -10
- package/dist/runtime/client/dev-overlay/overlay.js +1 -1
- package/dist/runtime/client/dev-overlay/plugins/astro.d.ts +14 -1
- package/dist/runtime/client/dev-overlay/plugins/astro.js +326 -15
- package/dist/runtime/client/dev-overlay/plugins/settings.js +26 -2
- package/dist/runtime/client/dev-overlay/plugins/utils/icons.d.ts +3 -0
- package/dist/runtime/client/dev-overlay/plugins/utils/icons.js +37 -0
- package/dist/runtime/client/dev-overlay/plugins/utils/window.d.ts +1 -2
- package/dist/runtime/client/dev-overlay/plugins/utils/window.js +25 -29
- package/dist/runtime/client/dev-overlay/ui-library/badge.d.ts +9 -0
- package/dist/runtime/client/dev-overlay/ui-library/badge.js +67 -0
- package/dist/runtime/client/dev-overlay/ui-library/button.d.ts +9 -0
- package/dist/runtime/client/dev-overlay/ui-library/button.js +83 -0
- package/dist/runtime/client/dev-overlay/ui-library/card.d.ts +1 -3
- package/dist/runtime/client/dev-overlay/ui-library/card.js +17 -25
- package/dist/runtime/client/dev-overlay/ui-library/highlight.js +1 -0
- package/dist/runtime/client/dev-overlay/ui-library/icon.d.ts +10 -0
- package/dist/runtime/client/dev-overlay/ui-library/icon.js +36 -0
- package/dist/runtime/client/dev-overlay/ui-library/icons.d.ts +21 -6
- package/dist/runtime/client/dev-overlay/ui-library/icons.js +22 -7
- package/dist/runtime/client/dev-overlay/ui-library/index.d.ts +8 -0
- package/dist/runtime/client/dev-overlay/ui-library/index.js +18 -0
- package/dist/runtime/client/dev-overlay/ui-library/window.d.ts +0 -4
- package/dist/runtime/client/dev-overlay/ui-library/window.js +0 -33
- package/dist/runtime/server/endpoint.d.ts +1 -1
- package/dist/runtime/server/endpoint.js +11 -22
- package/dist/transitions/vite-plugin-transitions.js +4 -4
- package/dist/virtual-modules/i18n.d.ts +1 -0
- package/dist/virtual-modules/i18n.js +1 -0
- package/dist/virtual-modules/middleware.d.ts +1 -0
- package/dist/virtual-modules/middleware.js +5 -0
- package/dist/virtual-modules/prefetch.d.ts +1 -0
- package/dist/virtual-modules/prefetch.js +1 -0
- package/dist/virtual-modules/transitions-events.d.ts +1 -0
- package/dist/virtual-modules/transitions-events.js +1 -0
- package/dist/virtual-modules/transitions-router.d.ts +1 -0
- package/dist/virtual-modules/transitions-router.js +1 -0
- package/dist/virtual-modules/transitions-types.d.ts +1 -0
- package/dist/virtual-modules/transitions-types.js +1 -0
- package/dist/virtual-modules/transitions.d.ts +1 -0
- package/dist/virtual-modules/transitions.js +1 -0
- package/dist/vite-plugin-astro/hmr.js +8 -14
- package/dist/vite-plugin-astro/index.js +28 -6
- package/dist/vite-plugin-astro-server/base.js +5 -5
- package/dist/vite-plugin-astro-server/response.js +1 -1
- package/dist/vite-plugin-astro-server/route.js +30 -6
- package/dist/vite-plugin-inject-env-ts/index.js +3 -3
- package/dist/vite-plugin-integrations-container/index.js +1 -1
- package/dist/vite-plugin-load-fallback/index.js +1 -3
- package/dist/vite-plugin-scanner/index.js +3 -6
- package/dist/vite-plugin-scripts/index.js +1 -1
- package/dist/vite-plugin-utils/index.d.ts +1 -0
- package/dist/vite-plugin-utils/index.js +5 -0
- package/package.json +56 -68
- package/dist/core/middleware/namespace.d.ts +0 -1
- package/dist/core/middleware/namespace.js +0 -5
- package/dist/vite-plugin-astro-server/common.d.ts +0 -2
- package/dist/vite-plugin-astro-server/common.js +0 -7
- package/import-meta.d.ts +0 -30
package/dist/cli/info/index.js
CHANGED
|
@@ -5,16 +5,17 @@ import prompts from "prompts";
|
|
|
5
5
|
import { resolveConfig } from "../../core/config/index.js";
|
|
6
6
|
import { ASTRO_VERSION } from "../../core/constants.js";
|
|
7
7
|
import { flagsToAstroInlineConfig } from "../flags.js";
|
|
8
|
-
async function
|
|
8
|
+
async function getInfoOutput({
|
|
9
|
+
userConfig,
|
|
10
|
+
print
|
|
11
|
+
}) {
|
|
9
12
|
const rows = [
|
|
10
13
|
["Astro", `v${ASTRO_VERSION}`],
|
|
11
14
|
["Node", process.version],
|
|
12
15
|
["System", getSystem()],
|
|
13
16
|
["Package Manager", getPackageManager()]
|
|
14
17
|
];
|
|
15
|
-
const inlineConfig = flagsToAstroInlineConfig(flags);
|
|
16
18
|
try {
|
|
17
|
-
const { userConfig } = await resolveConfig(inlineConfig, "info");
|
|
18
19
|
rows.push(["Output", userConfig.output ?? "static"]);
|
|
19
20
|
rows.push(["Adapter", userConfig.adapter?.name ?? "none"]);
|
|
20
21
|
const integrations = (userConfig?.integrations ?? []).filter(Boolean).flat().map((i) => i?.name).filter(Boolean);
|
|
@@ -23,9 +24,14 @@ async function printInfo({ flags }) {
|
|
|
23
24
|
}
|
|
24
25
|
let output = "";
|
|
25
26
|
for (const [label, value] of rows) {
|
|
26
|
-
output += printRow(label, value);
|
|
27
|
+
output += printRow(label, value, print);
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
return output.trim();
|
|
30
|
+
}
|
|
31
|
+
async function printInfo({ flags }) {
|
|
32
|
+
const { userConfig } = await resolveConfig(flagsToAstroInlineConfig(flags), "info");
|
|
33
|
+
const output = await getInfoOutput({ userConfig, print: true });
|
|
34
|
+
await copyToClipboard(output);
|
|
29
35
|
}
|
|
30
36
|
async function copyToClipboard(text) {
|
|
31
37
|
const system = platform();
|
|
@@ -84,7 +90,7 @@ function getPackageManager() {
|
|
|
84
90
|
return name === "npminstall" ? "cnpm" : name;
|
|
85
91
|
}
|
|
86
92
|
const MAX_PADDING = 25;
|
|
87
|
-
function printRow(label, value) {
|
|
93
|
+
function printRow(label, value, print) {
|
|
88
94
|
const padding = MAX_PADDING - label.length;
|
|
89
95
|
const [first, ...rest] = Array.isArray(value) ? value : [value];
|
|
90
96
|
let plaintext = `${label}${" ".repeat(padding)}${first}`;
|
|
@@ -98,9 +104,12 @@ ${" ".repeat(MAX_PADDING)}${colors.green(entry)}`;
|
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
106
|
plaintext += "\n";
|
|
101
|
-
|
|
107
|
+
if (print) {
|
|
108
|
+
console.log(richtext);
|
|
109
|
+
}
|
|
102
110
|
return plaintext;
|
|
103
111
|
}
|
|
104
112
|
export {
|
|
113
|
+
getInfoOutput,
|
|
105
114
|
printInfo
|
|
106
115
|
};
|
|
@@ -13,7 +13,7 @@ async function getPackage(packageName, logger, options, otherDeps = []) {
|
|
|
13
13
|
packageImport = await import(packageName);
|
|
14
14
|
} catch (e) {
|
|
15
15
|
logger.info(
|
|
16
|
-
|
|
16
|
+
null,
|
|
17
17
|
`To continue, Astro requires the following dependency to be installed: ${bold(packageName)}.`
|
|
18
18
|
);
|
|
19
19
|
const result = await installPackage([packageName, ...otherDeps], options, logger);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import whichPm from "which-pm";
|
|
2
1
|
import * as msg from "../../core/messages.js";
|
|
3
2
|
import { telemetry } from "../../events/index.js";
|
|
3
|
+
import { createLoggerFromFlags } from "../flags.js";
|
|
4
4
|
async function notify() {
|
|
5
|
-
const packageManager = (await whichPm(process.cwd()))?.name ?? "npm";
|
|
6
5
|
await telemetry.notify(() => {
|
|
7
|
-
console.log(msg.telemetryNotice(
|
|
6
|
+
console.log(msg.telemetryNotice() + "\n");
|
|
8
7
|
return true;
|
|
9
8
|
});
|
|
10
9
|
}
|
|
11
10
|
async function update(subcommand, { flags }) {
|
|
12
11
|
const isValid = ["enable", "disable", "reset"].includes(subcommand);
|
|
12
|
+
const logger = createLoggerFromFlags(flags);
|
|
13
13
|
if (flags.help || flags.h || !isValid) {
|
|
14
14
|
msg.printHelp({
|
|
15
15
|
commandName: "astro telemetry",
|
|
@@ -27,17 +27,17 @@ async function update(subcommand, { flags }) {
|
|
|
27
27
|
switch (subcommand) {
|
|
28
28
|
case "enable": {
|
|
29
29
|
telemetry.setEnabled(true);
|
|
30
|
-
|
|
30
|
+
logger.info("SKIP_FORMAT", msg.telemetryEnabled());
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
case "disable": {
|
|
34
34
|
telemetry.setEnabled(false);
|
|
35
|
-
|
|
35
|
+
logger.info("SKIP_FORMAT", msg.telemetryDisabled());
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
case "reset": {
|
|
39
39
|
telemetry.clear();
|
|
40
|
-
|
|
40
|
+
logger.info("SKIP_FORMAT", msg.telemetryReset());
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bold, cyan } from "kleur/colors";
|
|
1
|
+
import { bold, cyan, underline } from "kleur/colors";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { loadTSConfig } from "../core/config/tsconfig.js";
|
|
@@ -13,7 +13,7 @@ async function attachContentServerListeners({
|
|
|
13
13
|
}) {
|
|
14
14
|
const contentPaths = getContentPaths(settings.config, fs);
|
|
15
15
|
if (fs.existsSync(contentPaths.contentDir)) {
|
|
16
|
-
logger.
|
|
16
|
+
logger.debug(
|
|
17
17
|
"content",
|
|
18
18
|
`Watching ${cyan(
|
|
19
19
|
contentPaths.contentDir.href.replace(settings.config.root.href, "")
|
|
@@ -27,7 +27,7 @@ async function attachContentServerListeners({
|
|
|
27
27
|
viteServer.watcher.on("addDir", contentDirListener);
|
|
28
28
|
async function contentDirListener(dir) {
|
|
29
29
|
if (appendForwardSlash(pathToFileURL(dir).href) === contentPaths.contentDir.href) {
|
|
30
|
-
logger.
|
|
30
|
+
logger.debug("content", `Content directory found. Watching for changes`);
|
|
31
31
|
await attachListeners();
|
|
32
32
|
viteServer.watcher.removeListener("addDir", contentDirListener);
|
|
33
33
|
}
|
|
@@ -42,7 +42,7 @@ async function attachContentServerListeners({
|
|
|
42
42
|
contentConfigObserver: globalContentConfigObserver
|
|
43
43
|
});
|
|
44
44
|
await contentGenerator.init();
|
|
45
|
-
logger.
|
|
45
|
+
logger.debug("content", "Types generated");
|
|
46
46
|
viteServer.watcher.on("add", (entry) => {
|
|
47
47
|
contentGenerator.queueEvent({ name: "add", entry });
|
|
48
48
|
});
|
|
@@ -74,9 +74,9 @@ function warnAllowJsIsFalse({
|
|
|
74
74
|
"true"
|
|
75
75
|
)} in your ${bold(tsConfigFileName)} file to have autocompletion in your ${bold(
|
|
76
76
|
contentConfigFileName
|
|
77
|
-
)} file.
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
)} file. See ${underline(
|
|
78
|
+
cyan("https://www.typescriptlang.org/tsconfig#allowJs")
|
|
79
|
+
)} for more information.`
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
82
|
async function getTSConfigStatsWhenAllowJsFalse({
|
|
@@ -17,9 +17,6 @@ type CreateContentGeneratorParams = {
|
|
|
17
17
|
viteServer: ViteDevServer;
|
|
18
18
|
fs: typeof fsMod;
|
|
19
19
|
};
|
|
20
|
-
type EventOpts = {
|
|
21
|
-
logLevel: 'info' | 'warn';
|
|
22
|
-
};
|
|
23
20
|
export declare function createContentTypesGenerator({ contentConfigObserver, fs, logger, settings, viteServer, }: CreateContentGeneratorParams): Promise<{
|
|
24
21
|
init: () => Promise<{
|
|
25
22
|
typesGenerated: true;
|
|
@@ -27,6 +24,6 @@ export declare function createContentTypesGenerator({ contentConfigObserver, fs,
|
|
|
27
24
|
typesGenerated: false;
|
|
28
25
|
reason: 'no-content-dir';
|
|
29
26
|
}>;
|
|
30
|
-
queueEvent: (rawEvent: RawContentEvent
|
|
27
|
+
queueEvent: (rawEvent: RawContentEvent) => void;
|
|
31
28
|
}>;
|
|
32
29
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import glob from "fast-glob";
|
|
2
|
-
import { cyan } from "kleur/colors";
|
|
2
|
+
import { bold, cyan } from "kleur/colors";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import { normalizePath } from "vite";
|
|
@@ -39,10 +39,7 @@ async function createContentTypesGenerator({
|
|
|
39
39
|
if (!fs.existsSync(contentPaths.contentDir)) {
|
|
40
40
|
return { typesGenerated: false, reason: "no-content-dir" };
|
|
41
41
|
}
|
|
42
|
-
events.push({
|
|
43
|
-
type: { name: "add", entry: contentPaths.config.url },
|
|
44
|
-
opts: { logLevel: "warn" }
|
|
45
|
-
});
|
|
42
|
+
events.push({ name: "add", entry: contentPaths.config.url });
|
|
46
43
|
const globResult = await glob("**", {
|
|
47
44
|
cwd: fileURLToPath(contentPaths.contentDir),
|
|
48
45
|
fs: {
|
|
@@ -58,19 +55,15 @@ async function createContentTypesGenerator({
|
|
|
58
55
|
if (entryURL.href.startsWith(contentPaths.config.url.href))
|
|
59
56
|
continue;
|
|
60
57
|
if (entry.dirent.isFile()) {
|
|
61
|
-
events.push({
|
|
62
|
-
type: { name: "add", entry: entryURL },
|
|
63
|
-
opts: { logLevel: "warn" }
|
|
64
|
-
});
|
|
58
|
+
events.push({ name: "add", entry: entryURL });
|
|
65
59
|
} else if (entry.dirent.isDirectory()) {
|
|
66
|
-
events.push({
|
|
60
|
+
events.push({ name: "addDir", entry: entryURL });
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
63
|
await runEvents();
|
|
70
64
|
return { typesGenerated: true };
|
|
71
65
|
}
|
|
72
|
-
async function handleEvent(event
|
|
73
|
-
const logLevel = opts?.logLevel ?? "info";
|
|
66
|
+
async function handleEvent(event) {
|
|
74
67
|
if (event.name === "addDir" || event.name === "unlinkDir") {
|
|
75
68
|
const collection2 = normalizePath(
|
|
76
69
|
path.relative(fileURLToPath(contentPaths.contentDir), fileURLToPath(event.entry))
|
|
@@ -82,9 +75,7 @@ async function createContentTypesGenerator({
|
|
|
82
75
|
switch (event.name) {
|
|
83
76
|
case "addDir":
|
|
84
77
|
collectionEntryMap[JSON.stringify(collection2)] = { type: "unknown", entries: {} };
|
|
85
|
-
|
|
86
|
-
logger.info("content", `${cyan(collection2)} collection added`);
|
|
87
|
-
}
|
|
78
|
+
logger.debug("content", `${cyan(collection2)} collection added`);
|
|
88
79
|
break;
|
|
89
80
|
case "unlinkDir":
|
|
90
81
|
if (collectionKey2 in collectionEntryMap) {
|
|
@@ -125,16 +116,14 @@ async function createContentTypesGenerator({
|
|
|
125
116
|
const { contentDir } = contentPaths;
|
|
126
117
|
const collection = getEntryCollectionName({ entry, contentDir });
|
|
127
118
|
if (collection === void 0) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
);
|
|
137
|
-
}
|
|
119
|
+
logger.warn(
|
|
120
|
+
"content",
|
|
121
|
+
`${bold(
|
|
122
|
+
normalizePath(
|
|
123
|
+
path.relative(fileURLToPath(contentPaths.contentDir), fileURLToPath(event.entry))
|
|
124
|
+
)
|
|
125
|
+
)} must live in a ${bold("content/...")} collection subdirectory.`
|
|
126
|
+
);
|
|
138
127
|
return { shouldGenerateTypes: false };
|
|
139
128
|
}
|
|
140
129
|
if (fileType === "data") {
|
|
@@ -234,21 +223,18 @@ async function createContentTypesGenerator({
|
|
|
234
223
|
return { shouldGenerateTypes: false };
|
|
235
224
|
}
|
|
236
225
|
}
|
|
237
|
-
function queueEvent(rawEvent
|
|
226
|
+
function queueEvent(rawEvent) {
|
|
238
227
|
const event = {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
name: rawEvent.name
|
|
242
|
-
},
|
|
243
|
-
opts
|
|
228
|
+
entry: pathToFileURL(rawEvent.entry),
|
|
229
|
+
name: rawEvent.name
|
|
244
230
|
};
|
|
245
|
-
if (!event.
|
|
231
|
+
if (!event.entry.pathname.startsWith(contentPaths.contentDir.pathname))
|
|
246
232
|
return;
|
|
247
233
|
events.push(event);
|
|
248
234
|
debounceTimeout && clearTimeout(debounceTimeout);
|
|
249
235
|
const runEventsSafe = async () => {
|
|
250
236
|
try {
|
|
251
|
-
await runEvents(
|
|
237
|
+
await runEvents();
|
|
252
238
|
} catch {
|
|
253
239
|
}
|
|
254
240
|
};
|
|
@@ -258,29 +244,23 @@ async function createContentTypesGenerator({
|
|
|
258
244
|
/* debounce to batch chokidar events */
|
|
259
245
|
);
|
|
260
246
|
}
|
|
261
|
-
async function runEvents(
|
|
262
|
-
const logLevel = opts?.logLevel ?? "info";
|
|
247
|
+
async function runEvents() {
|
|
263
248
|
const eventResponses = [];
|
|
264
249
|
for (const event of events) {
|
|
265
|
-
const response = await handleEvent(event
|
|
250
|
+
const response = await handleEvent(event);
|
|
266
251
|
eventResponses.push(response);
|
|
267
252
|
}
|
|
268
253
|
events = [];
|
|
269
|
-
let unsupportedFiles = [];
|
|
270
254
|
for (const response of eventResponses) {
|
|
271
255
|
if (response.error instanceof UnsupportedFileTypeError) {
|
|
272
|
-
|
|
256
|
+
logger.warn(
|
|
257
|
+
"content",
|
|
258
|
+
`Unsupported file type ${bold(
|
|
259
|
+
response.error.message
|
|
260
|
+
)} found. Prefix filename with an underscore (\`_\`) to ignore.`
|
|
261
|
+
);
|
|
273
262
|
}
|
|
274
263
|
}
|
|
275
|
-
if (unsupportedFiles.length > 0 && ["info", "warn"].includes(logLevel)) {
|
|
276
|
-
logger.warn(
|
|
277
|
-
"content",
|
|
278
|
-
`Unsupported file types found. Prefix with an underscore (\`_\`) to ignore:
|
|
279
|
-
- ${unsupportedFiles.join(
|
|
280
|
-
"\n"
|
|
281
|
-
)}`
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
264
|
const observable = contentConfigObserver.get();
|
|
285
265
|
if (eventResponses.some((r) => r.shouldGenerateTypes)) {
|
|
286
266
|
await writeContentFiles({
|
|
@@ -293,7 +273,7 @@ async function createContentTypesGenerator({
|
|
|
293
273
|
viteServer
|
|
294
274
|
});
|
|
295
275
|
invalidateVirtualMod(viteServer);
|
|
296
|
-
if (observable.status === "loaded"
|
|
276
|
+
if (observable.status === "loaded") {
|
|
297
277
|
warnNonexistentCollections({
|
|
298
278
|
logger,
|
|
299
279
|
contentConfig: observable.config,
|
|
@@ -424,9 +404,9 @@ function warnNonexistentCollections({
|
|
|
424
404
|
if (!collectionEntryMap[JSON.stringify(configuredCollection)]) {
|
|
425
405
|
logger.warn(
|
|
426
406
|
"content",
|
|
427
|
-
`The ${
|
|
428
|
-
configuredCollection
|
|
429
|
-
)}
|
|
407
|
+
`The ${bold(configuredCollection)} collection is defined but no ${bold(
|
|
408
|
+
"content/" + configuredCollection
|
|
409
|
+
)} folder exists in the content directory. Create a new folder for the collection, or check your content configuration file for typos.`
|
|
430
410
|
);
|
|
431
411
|
}
|
|
432
412
|
}
|
package/dist/core/app/index.js
CHANGED
|
@@ -143,9 +143,7 @@ class App {
|
|
|
143
143
|
);
|
|
144
144
|
if (i18nMiddleware) {
|
|
145
145
|
if (mod.onRequest) {
|
|
146
|
-
this.#pipeline.setMiddlewareFunction(
|
|
147
|
-
sequence(i18nMiddleware, mod.onRequest)
|
|
148
|
-
);
|
|
146
|
+
this.#pipeline.setMiddlewareFunction(sequence(i18nMiddleware, mod.onRequest));
|
|
149
147
|
} else {
|
|
150
148
|
this.#pipeline.setMiddlewareFunction(i18nMiddleware);
|
|
151
149
|
}
|
|
@@ -160,7 +158,7 @@ class App {
|
|
|
160
158
|
if (err instanceof EndpointNotFoundError) {
|
|
161
159
|
return this.#renderError(request, { status: 404, response: err.originalResponse });
|
|
162
160
|
} else {
|
|
163
|
-
this.#logger.error(
|
|
161
|
+
this.#logger.error(null, err.stack || err.message || String(err));
|
|
164
162
|
return this.#renderError(request, { status: 500 });
|
|
165
163
|
}
|
|
166
164
|
}
|
|
@@ -114,9 +114,9 @@ class BuildPipeline extends Pipeline {
|
|
|
114
114
|
*/
|
|
115
115
|
retrieveRoutesToGenerate() {
|
|
116
116
|
const pages = /* @__PURE__ */ new Map();
|
|
117
|
-
for (const [
|
|
118
|
-
if (
|
|
119
|
-
const [, pageName] =
|
|
117
|
+
for (const [entrypoint, filePath] of this.#internals.entrySpecifierToBundleMap) {
|
|
118
|
+
if (entrypoint.includes(ASTRO_PAGE_RESOLVED_MODULE_ID) || entrypoint.includes(RESOLVED_SPLIT_MODULE_ID)) {
|
|
119
|
+
const [, pageName] = entrypoint.split(":");
|
|
120
120
|
const pageData = this.#internals.pagesByComponent.get(
|
|
121
121
|
`${pageName.replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, ".")}`
|
|
122
122
|
);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { bgGreen, black, cyan, dim, green, magenta } from "kleur/colors";
|
|
1
|
+
import { bgGreen, black, blue, bold, dim, green, magenta, red } from "kleur/colors";
|
|
3
2
|
import fs from "node:fs";
|
|
4
3
|
import os from "node:os";
|
|
5
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -79,13 +78,6 @@ async function getEntryForFallbackRoute(route, internals, outFolder) {
|
|
|
79
78
|
}
|
|
80
79
|
return RedirectSinglePageBuiltModule;
|
|
81
80
|
}
|
|
82
|
-
function shouldSkipDraft(pageModule, settings) {
|
|
83
|
-
return (
|
|
84
|
-
// Drafts are disabled
|
|
85
|
-
!settings.config.markdown.drafts && // This is a draft post
|
|
86
|
-
"frontmatter" in pageModule && pageModule.frontmatter?.draft === true
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
81
|
function rootRelativeFacadeId(facadeId, settings) {
|
|
90
82
|
return facadeId.slice(fileURLToPath(settings.config.root).length);
|
|
91
83
|
}
|
|
@@ -103,7 +95,7 @@ function chunkIsPage(settings, output, internals) {
|
|
|
103
95
|
return false;
|
|
104
96
|
}
|
|
105
97
|
async function generatePages(opts, internals) {
|
|
106
|
-
const
|
|
98
|
+
const generatePagesTimer = performance.now();
|
|
107
99
|
const ssr = isServerLikeOutput(opts.settings.config);
|
|
108
100
|
let manifest;
|
|
109
101
|
if (ssr) {
|
|
@@ -126,7 +118,7 @@ async function generatePages(opts, internals) {
|
|
|
126
118
|
return;
|
|
127
119
|
}
|
|
128
120
|
const verb = ssr ? "prerendering" : "generating";
|
|
129
|
-
logger.info(
|
|
121
|
+
logger.info("SKIP_FORMAT", `
|
|
130
122
|
${bgGreen(black(` ${verb} static routes `))}`);
|
|
131
123
|
const builtPaths = /* @__PURE__ */ new Set();
|
|
132
124
|
const pagesToGenerate = pipeline.retrieveRoutesToGenerate();
|
|
@@ -135,10 +127,7 @@ ${bgGreen(black(` ${verb} static routes `))}`);
|
|
|
135
127
|
if (pageData.route.prerender) {
|
|
136
128
|
const ssrEntryURLPage = createEntryURL(filePath, outFolder);
|
|
137
129
|
const ssrEntryPage = await import(ssrEntryURLPage.toString());
|
|
138
|
-
if (
|
|
139
|
-
// TODO: remove in Astro 4.0
|
|
140
|
-
opts.settings.config.build.split || opts.settings.adapter?.adapterFeatures?.functionPerRoute
|
|
141
|
-
) {
|
|
130
|
+
if (opts.settings.adapter?.adapterFeatures?.functionPerRoute) {
|
|
142
131
|
const ssrEntry = ssrEntryPage?.pageModule;
|
|
143
132
|
if (ssrEntry) {
|
|
144
133
|
await generatePage(pageData, ssrEntry, builtPaths, pipeline);
|
|
@@ -168,12 +157,14 @@ ${bgGreen(black(` ${verb} static routes `))}`);
|
|
|
168
157
|
}
|
|
169
158
|
}
|
|
170
159
|
}
|
|
171
|
-
logger.info(
|
|
172
|
-
|
|
160
|
+
logger.info(
|
|
161
|
+
null,
|
|
162
|
+
green(`\u2713 Completed in ${getTimeStat(generatePagesTimer, performance.now())}.
|
|
163
|
+
`)
|
|
164
|
+
);
|
|
173
165
|
const staticImageList = getStaticImageList();
|
|
174
166
|
if (staticImageList.size) {
|
|
175
|
-
logger.info(
|
|
176
|
-
${bgGreen(black(` generating optimized images `))}`);
|
|
167
|
+
logger.info("SKIP_FORMAT", `${bgGreen(black(` generating optimized images `))}`);
|
|
177
168
|
const totalCount = Array.from(staticImageList.values()).map((x) => x.transforms.size).reduce((a, b) => a + b, 0);
|
|
178
169
|
const cpuCount = os.cpus().length;
|
|
179
170
|
const assetsCreationEnvironment = await prepareAssetsGenerationEnv(pipeline, totalCount);
|
|
@@ -184,7 +175,7 @@ ${bgGreen(black(` generating optimized images `))}`);
|
|
|
184
175
|
}
|
|
185
176
|
await queue.onIdle();
|
|
186
177
|
const assetsTimeEnd = performance.now();
|
|
187
|
-
logger.info(null,
|
|
178
|
+
logger.info(null, green(`\u2713 Completed in ${getTimeStat(assetsTimer, assetsTimeEnd)}.
|
|
188
179
|
`));
|
|
189
180
|
delete globalThis?.astroAsset?.addStaticImage;
|
|
190
181
|
}
|
|
@@ -210,9 +201,7 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
|
|
|
210
201
|
);
|
|
211
202
|
if (config.experimental.i18n && i18nMiddleware) {
|
|
212
203
|
if (onRequest) {
|
|
213
|
-
pipeline.setMiddlewareFunction(
|
|
214
|
-
sequence(i18nMiddleware, onRequest)
|
|
215
|
-
);
|
|
204
|
+
pipeline.setMiddlewareFunction(sequence(i18nMiddleware, onRequest));
|
|
216
205
|
} else {
|
|
217
206
|
pipeline.setMiddlewareFunction(i18nMiddleware);
|
|
218
207
|
}
|
|
@@ -226,14 +215,6 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
|
|
|
226
215
|
);
|
|
227
216
|
}
|
|
228
217
|
const pageModule = await pageModulePromise();
|
|
229
|
-
if (shouldSkipDraft(pageModule, pipeline.getSettings())) {
|
|
230
|
-
logger.info(null, `${magenta("\u26A0\uFE0F")} Skipping draft ${pageData.route.component}`);
|
|
231
|
-
logger.warn(
|
|
232
|
-
"astro",
|
|
233
|
-
`The drafts feature is deprecated. You should migrate to content collections instead. See https://docs.astro.build/en/guides/content-collections/#filtering-collection-queries for more information.`
|
|
234
|
-
);
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
218
|
const generationOptions = {
|
|
238
219
|
pageData,
|
|
239
220
|
linkIds,
|
|
@@ -241,7 +222,7 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
|
|
|
241
222
|
styles,
|
|
242
223
|
mod: pageModule
|
|
243
224
|
};
|
|
244
|
-
const icon = pageData.route.type === "page" || pageData.route.type === "redirect" || pageData.route.type === "fallback" ?
|
|
225
|
+
const icon = pageData.route.type === "page" || pageData.route.type === "redirect" || pageData.route.type === "fallback" ? blue("\u25B6") : magenta("\u03BB");
|
|
245
226
|
if (isRelativePath(pageData.route.component)) {
|
|
246
227
|
logger.info(null, `${icon} ${pageData.route.route}`);
|
|
247
228
|
for (const fallbackRoute of pageData.route.fallbackRoutes) {
|
|
@@ -257,10 +238,10 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
|
|
|
257
238
|
await generatePath(path, generationOptions, pipeline);
|
|
258
239
|
const timeEnd = performance.now();
|
|
259
240
|
const timeChange = getTimeStat(prevTimeEnd, timeEnd);
|
|
260
|
-
const timeIncrease = `(
|
|
241
|
+
const timeIncrease = `(${timeChange})`;
|
|
261
242
|
const filePath = getOutputFilename(pipeline.getConfig(), path, pageData.route.type);
|
|
262
243
|
const lineIcon = i === paths.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
263
|
-
logger.info(null, ` ${
|
|
244
|
+
logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`);
|
|
264
245
|
prevTimeEnd = timeEnd;
|
|
265
246
|
}
|
|
266
247
|
}
|
|
@@ -292,13 +273,13 @@ async function getPathsForRoute(pageData, mod, pipeline, builtPaths) {
|
|
|
292
273
|
logger,
|
|
293
274
|
ssr: isServerLikeOutput(opts.settings.config)
|
|
294
275
|
}).catch((err) => {
|
|
295
|
-
logger.debug("build", `\u251C\u2500\u2500 ${
|
|
276
|
+
logger.debug("build", `\u251C\u2500\u2500 ${bold(red("\u2717"))} ${route.component}`);
|
|
296
277
|
throw err;
|
|
297
278
|
});
|
|
298
279
|
const label = staticPaths.length === 1 ? "page" : "pages";
|
|
299
280
|
logger.debug(
|
|
300
281
|
"build",
|
|
301
|
-
`\u251C\u2500\u2500 ${
|
|
282
|
+
`\u251C\u2500\u2500 ${bold(green("\u2714"))} ${route.component} \u2192 ${magenta(
|
|
302
283
|
`[${staticPaths.length} ${label}]`
|
|
303
284
|
)}`
|
|
304
285
|
);
|
|
@@ -435,7 +416,6 @@ async function generatePath(pathname, gopts, pipeline) {
|
|
|
435
416
|
defaultLocale: i18n?.defaultLocale
|
|
436
417
|
});
|
|
437
418
|
let body;
|
|
438
|
-
let encoding;
|
|
439
419
|
let response;
|
|
440
420
|
try {
|
|
441
421
|
response = await pipeline.renderRoute(renderContext, mod);
|
|
@@ -472,13 +452,12 @@ async function generatePath(pathname, gopts, pipeline) {
|
|
|
472
452
|
if (!response.body)
|
|
473
453
|
return;
|
|
474
454
|
body = Buffer.from(await response.arrayBuffer());
|
|
475
|
-
encoding = response.headers.get("X-Astro-Encoding") ?? "utf-8";
|
|
476
455
|
}
|
|
477
456
|
const outFolder = getOutFolder(pipeline.getConfig(), pathname, route.type);
|
|
478
457
|
const outFile = getOutFile(pipeline.getConfig(), outFolder, pathname, route.type);
|
|
479
458
|
route.distURL = outFile;
|
|
480
459
|
await fs.promises.mkdir(outFolder, { recursive: true });
|
|
481
|
-
await fs.promises.writeFile(outFile, body
|
|
460
|
+
await fs.promises.writeFile(outFile, body);
|
|
482
461
|
}
|
|
483
462
|
}
|
|
484
463
|
function createBuildManifest(settings, internals, renderers) {
|
package/dist/core/build/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { blue, bold, green } from "kleur/colors";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { performance } from "node:perf_hooks";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -31,8 +31,9 @@ async function build(inlineConfig, options = {}) {
|
|
|
31
31
|
if (astroConfig.experimental.contentCollectionCache && options.force) {
|
|
32
32
|
const contentCacheDir = new URL("./content/", astroConfig.cacheDir);
|
|
33
33
|
if (fs.existsSync(contentCacheDir)) {
|
|
34
|
-
logger.
|
|
34
|
+
logger.debug("content", "clearing content cache");
|
|
35
35
|
await fs.promises.rm(contentCacheDir, { force: true, recursive: true });
|
|
36
|
+
logger.warn("content", "content cache cleared (force)");
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
const settings = await createSettings(astroConfig, fileURLToPath(astroConfig.root));
|
|
@@ -100,9 +101,10 @@ class AstroBuilder {
|
|
|
100
101
|
async build({ viteConfig }) {
|
|
101
102
|
await runHookBuildStart({ config: this.settings.config, logging: this.logger });
|
|
102
103
|
this.validateConfig();
|
|
103
|
-
this.logger.info("build", `output
|
|
104
|
+
this.logger.info("build", `output: ${blue('"' + this.settings.config.output + '"')}`);
|
|
105
|
+
this.logger.info("build", `directory: ${blue(fileURLToPath(this.settings.config.outDir))}`);
|
|
104
106
|
if (this.settings.adapter) {
|
|
105
|
-
this.logger.info("build", `
|
|
107
|
+
this.logger.info("build", `adapter: ${green(this.settings.adapter.name)}`);
|
|
106
108
|
}
|
|
107
109
|
this.logger.info("build", "Collecting build info...");
|
|
108
110
|
this.timer.loadStart = performance.now();
|
|
@@ -116,7 +118,7 @@ class AstroBuilder {
|
|
|
116
118
|
this.timer.buildStart = performance.now();
|
|
117
119
|
this.logger.info(
|
|
118
120
|
"build",
|
|
119
|
-
|
|
121
|
+
green(`\u2713 Completed in ${getTimeStat(this.timer.init, performance.now())}.`)
|
|
120
122
|
);
|
|
121
123
|
const opts = {
|
|
122
124
|
allPages,
|
|
@@ -174,30 +176,6 @@ class AstroBuilder {
|
|
|
174
176
|
`the outDir cannot be the root folder. Please build to a folder such as dist.`
|
|
175
177
|
);
|
|
176
178
|
}
|
|
177
|
-
if (config.build.split === true) {
|
|
178
|
-
if (config.output === "static") {
|
|
179
|
-
this.logger.warn(
|
|
180
|
-
"configuration",
|
|
181
|
-
'The option `build.split` won\'t take effect, because `output` is not `"server"` or `"hybrid"`.'
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
this.logger.warn(
|
|
185
|
-
"configuration",
|
|
186
|
-
"The option `build.split` is deprecated. Use the adapter options."
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
if (config.build.excludeMiddleware === true) {
|
|
190
|
-
if (config.output === "static") {
|
|
191
|
-
this.logger.warn(
|
|
192
|
-
"configuration",
|
|
193
|
-
'The option `build.excludeMiddleware` won\'t take effect, because `output` is not `"server"` or `"hybrid"`.'
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
this.logger.warn(
|
|
197
|
-
"configuration",
|
|
198
|
-
"The option `build.excludeMiddleware` is deprecated. Use the adapter options."
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
179
|
}
|
|
202
180
|
/** Stats */
|
|
203
181
|
async printStats({
|
|
@@ -209,12 +187,12 @@ class AstroBuilder {
|
|
|
209
187
|
const total = getTimeStat(timeStart, performance.now());
|
|
210
188
|
let messages = [];
|
|
211
189
|
if (buildMode === "static") {
|
|
212
|
-
messages = [`${pageCount} page(s) built in`,
|
|
190
|
+
messages = [`${pageCount} page(s) built in`, bold(total)];
|
|
213
191
|
} else {
|
|
214
|
-
messages = ["Server built in",
|
|
192
|
+
messages = ["Server built in", bold(total)];
|
|
215
193
|
}
|
|
216
194
|
logger.info("build", messages.join(" "));
|
|
217
|
-
logger.info("build", `${
|
|
195
|
+
logger.info("build", `${bold("Complete!")}`);
|
|
218
196
|
}
|
|
219
197
|
}
|
|
220
198
|
export {
|
|
@@ -99,9 +99,9 @@ function* eachPageFromAllPages(allPages) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
function* eachPageDataFromEntryPoint(internals) {
|
|
102
|
-
for (const [
|
|
103
|
-
if (
|
|
104
|
-
const [, pageName] =
|
|
102
|
+
for (const [entrypoint, filePath] of internals.entrySpecifierToBundleMap) {
|
|
103
|
+
if (entrypoint.includes(ASTRO_PAGE_RESOLVED_MODULE_ID) || entrypoint.includes(RESOLVED_SPLIT_MODULE_ID)) {
|
|
104
|
+
const [, pageName] = entrypoint.split(":");
|
|
105
105
|
const pageData = internals.pagesByComponent.get(
|
|
106
106
|
`${pageName.replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, ".")}`
|
|
107
107
|
);
|
|
@@ -31,8 +31,8 @@ export declare function createPluginContainer(options: StaticBuildOptions, inter
|
|
|
31
31
|
internals: BuildInternals;
|
|
32
32
|
register(plugin: AstroBuildPlugin): void;
|
|
33
33
|
runBeforeHook(target: BuildTarget, input: Set<string>): Promise<{
|
|
34
|
-
vitePlugins: (VitePlugin | VitePlugin[])[];
|
|
35
|
-
lastVitePlugins: (VitePlugin | VitePlugin[])[];
|
|
34
|
+
vitePlugins: (VitePlugin<any> | VitePlugin<any>[])[];
|
|
35
|
+
lastVitePlugins: (VitePlugin<any> | VitePlugin<any>[])[];
|
|
36
36
|
}>;
|
|
37
37
|
runPostHook(ssrReturn: ViteBuildReturn, clientReturn: ViteBuildReturn | null): Promise<Map<string, {
|
|
38
38
|
targets: BuildTarget[];
|
|
@@ -76,10 +76,7 @@ function pluginManifest(options, internals) {
|
|
|
76
76
|
throw new Error(`Did not generate an entry chunk for SSR`);
|
|
77
77
|
}
|
|
78
78
|
const manifest = await createManifest(options, internals);
|
|
79
|
-
const shouldPassMiddlewareEntryPoint =
|
|
80
|
-
// TODO: remove in Astro 4.0
|
|
81
|
-
options.settings.config.build.excludeMiddleware || options.settings.adapter?.adapterFeatures?.edgeMiddleware
|
|
82
|
-
);
|
|
79
|
+
const shouldPassMiddlewareEntryPoint = options.settings.adapter?.adapterFeatures?.edgeMiddleware;
|
|
83
80
|
await runHookBuildSsr({
|
|
84
81
|
config: options.settings.config,
|
|
85
82
|
manifest,
|