astro 5.13.7 → 5.13.8

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.
@@ -44,7 +44,7 @@ const GET = async ({ request }) => {
44
44
  transform,
45
45
  imageConfig
46
46
  );
47
- return new Response(Buffer.from(data), {
47
+ return new Response(data, {
48
48
  status: 200,
49
49
  headers: {
50
50
  "Content-Type": mime.lookup(format) ?? `image/${format}`,
@@ -84,7 +84,7 @@ const GET = async ({ request }) => {
84
84
  return new Response("Internal Server Error", { status: 500 });
85
85
  }
86
86
  const { data, format } = await imageService.transform(inputBuffer, transform, imageConfig);
87
- return new Response(Buffer.from(data), {
87
+ return new Response(data, {
88
88
  status: 200,
89
89
  headers: {
90
90
  "Content-Type": mime.lookup(format) ?? `image/${format}`,
@@ -15,7 +15,7 @@ function keyFor(hash) {
15
15
  return key;
16
16
  }
17
17
  async function handleSvgDeduplication(fileData, filename, fileEmitter) {
18
- const contentHash = await generateContentHash(Uint8Array.from(fileData).buffer);
18
+ const contentHash = await generateContentHash(fileData.buffer);
19
19
  const key = keyFor(contentHash);
20
20
  const existing = svgContentCache.get(key);
21
21
  if (existing) {
@@ -1,4 +1,4 @@
1
- import { spawnSync } from "node:child_process";
1
+ import { spawn, spawnSync } from "node:child_process";
2
2
  import { arch, platform } from "node:os";
3
3
  import * as colors from "kleur/colors";
4
4
  import prompts from "prompts";
@@ -10,23 +10,50 @@ async function getInfoOutput({
10
10
  userConfig,
11
11
  print
12
12
  }) {
13
+ const packageManager = getPackageManager();
13
14
  const rows = [
14
15
  ["Astro", `v${ASTRO_VERSION}`],
15
16
  ["Node", process.version],
16
17
  ["System", getSystem()],
17
- ["Package Manager", getPackageManager()]
18
+ ["Package Manager", packageManager]
18
19
  ];
20
+ if (print) {
21
+ const viteVersion = await getVersion(packageManager, "vite");
22
+ if (viteVersion) {
23
+ rows.splice(1, 0, ["Vite", viteVersion]);
24
+ }
25
+ }
26
+ const hasAdapter = "adapter" in userConfig && userConfig.adapter?.name;
27
+ let adapterVersion = void 0;
28
+ if (print && hasAdapter) {
29
+ adapterVersion = await getVersion(packageManager, userConfig.adapter.name);
30
+ }
31
+ const adatperOutputString = hasAdapter ? `${userConfig.adapter.name}${adapterVersion ? ` (${adapterVersion})` : ""}` : "none";
19
32
  try {
20
- rows.push(["Output", userConfig.output ?? "static"]);
21
- rows.push(["Adapter", userConfig.adapter?.name ?? "none"]);
22
- const integrations = (userConfig?.integrations ?? []).filter(Boolean).flat().map((i) => i?.name).filter(Boolean);
23
- rows.push(["Integrations", integrations.length > 0 ? integrations : "none"]);
33
+ rows.push([
34
+ "Output",
35
+ "adapter" in userConfig && userConfig.output ? userConfig.output : "static"
36
+ ]);
37
+ rows.push(["Adapter", adatperOutputString]);
38
+ const integrations = (userConfig?.integrations ?? []).filter(Boolean).flat().map(async (i) => {
39
+ if (!i.name) return;
40
+ if (!print) return i.name;
41
+ const version = await getVersion(packageManager, i.name);
42
+ return `${i.name}${version ? ` (${version})` : ""}`;
43
+ });
44
+ const awaitedIntegrations = (await Promise.all(integrations)).filter(Boolean);
45
+ rows.push(["Integrations", awaitedIntegrations.length > 0 ? awaitedIntegrations : "none"]);
24
46
  } catch {
25
47
  }
26
48
  let output = "";
27
49
  for (const [label, value] of rows) {
28
50
  output += printRow(label, value, print);
29
51
  }
52
+ if (packageManager === "bun") {
53
+ console.warn(
54
+ "Bun is not officially supported by Astro. Unable to retreive certain version information."
55
+ );
56
+ }
30
57
  return output.trim();
31
58
  }
32
59
  async function printInfo({ flags }) {
@@ -162,6 +189,85 @@ ${" ".repeat(MAX_PADDING)}${colors.green(entry)}`;
162
189
  }
163
190
  return plaintext;
164
191
  }
192
+ function formatPnpmVersionOutput(versionOutput) {
193
+ return versionOutput.startsWith("link:") ? "Local" : `v${versionOutput}`;
194
+ }
195
+ async function spawnAsync(executable, opts) {
196
+ return new Promise((resolve, reject) => {
197
+ const child = spawn(executable, opts, { shell: true });
198
+ let stdout = "";
199
+ let stderr = "";
200
+ child.stdout.on("data", (d) => stdout += d);
201
+ child.stderr.on("data", (d) => stderr += d);
202
+ child.on("error", reject);
203
+ child.on("close", (code) => {
204
+ if (code !== 0) reject(new Error(stderr));
205
+ else resolve(stdout);
206
+ });
207
+ });
208
+ }
209
+ async function getVersionUsingPNPM(dependency) {
210
+ const output = await spawnAsync("pnpm", ["why", dependency, "--json"]);
211
+ const parsedOutput = JSON.parse(output);
212
+ const deps = parsedOutput[0].dependencies;
213
+ if (parsedOutput.length === 0 || !deps) {
214
+ return void 0;
215
+ }
216
+ const userProvidedDependency = deps[dependency];
217
+ if (userProvidedDependency) {
218
+ return userProvidedDependency.version.startsWith("link:") ? "Local" : `v${userProvidedDependency.version}`;
219
+ }
220
+ const astroDependency = deps.astro?.dependencies[dependency];
221
+ return astroDependency ? formatPnpmVersionOutput(astroDependency.version) : void 0;
222
+ }
223
+ async function getVersionUsingNPM(dependency) {
224
+ const output = await spawnAsync("npm", ["ls", dependency, "--json", "--depth=1"]);
225
+ const parsedNpmOutput = JSON.parse(output);
226
+ if (!parsedNpmOutput.dependencies) {
227
+ return void 0;
228
+ }
229
+ if (parsedNpmOutput.dependencies[dependency]) {
230
+ return `v${parsedNpmOutput.dependencies[dependency].version}`;
231
+ }
232
+ const astro = parsedNpmOutput.dependencies.astro;
233
+ return astro ? `v${astro.dependencies[dependency].version}` : void 0;
234
+ }
235
+ function getYarnOutputDepVersion(dependency, outputLine) {
236
+ const parsed = JSON.parse(outputLine);
237
+ for (const [key, value] of Object.entries(parsed.children)) {
238
+ if (key.startsWith(`${dependency}@`)) {
239
+ return `v${value.locator.split(":").pop()}`;
240
+ }
241
+ }
242
+ }
243
+ async function getVersionUsingYarn(dependency) {
244
+ const yarnOutput = await spawnAsync("yarn", ["why", dependency, "--json"]);
245
+ const hasUserDefinition = yarnOutput.includes("workspace:.");
246
+ for (const line of yarnOutput.split("\n")) {
247
+ if (hasUserDefinition && line.includes("workspace:."))
248
+ return getYarnOutputDepVersion(dependency, line);
249
+ if (!hasUserDefinition && line.includes("astro@"))
250
+ return getYarnOutputDepVersion(dependency, line);
251
+ }
252
+ }
253
+ async function getVersion(packageManager, dependency) {
254
+ try {
255
+ switch (packageManager) {
256
+ case "pnpm":
257
+ return await getVersionUsingPNPM(dependency);
258
+ case "npm":
259
+ return getVersionUsingNPM(dependency);
260
+ case "yarn":
261
+ return getVersionUsingYarn(dependency);
262
+ case "bun":
263
+ return void 0;
264
+ }
265
+ return void 0;
266
+ } catch (err) {
267
+ console.error(err);
268
+ return void 0;
269
+ }
270
+ }
165
271
  export {
166
272
  getInfoOutput,
167
273
  printInfo,
@@ -164,7 +164,7 @@ ${contentConfig.error.message}`);
164
164
  logger.info("Content config changed");
165
165
  shouldClear = true;
166
166
  }
167
- if (previousAstroVersion && previousAstroVersion !== "5.13.7") {
167
+ if (previousAstroVersion && previousAstroVersion !== "5.13.8") {
168
168
  logger.info("Astro version changed");
169
169
  shouldClear = true;
170
170
  }
@@ -172,8 +172,8 @@ ${contentConfig.error.message}`);
172
172
  logger.info("Clearing content store");
173
173
  this.#store.clearAll();
174
174
  }
175
- if ("5.13.7") {
176
- await this.#store.metaStore().set("astro-version", "5.13.7");
175
+ if ("5.13.8") {
176
+ await this.#store.metaStore().set("astro-version", "5.13.8");
177
177
  }
178
178
  if (currentConfigDigest) {
179
179
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
4
  import { parseFrontmatter } from "@astrojs/markdown-remark";
5
5
  import { slug as githubSlug } from "github-slugger";
6
- import { green } from "kleur/colors";
6
+ import { green, red } from "kleur/colors";
7
7
  import xxhash from "xxhash-wasm";
8
8
  import { z } from "zod";
9
9
  import { AstroError, AstroErrorData, errorMap, MarkdownError } from "../core/errors/index.js";
@@ -381,6 +381,27 @@ async function loadContentConfig({
381
381
  const digest = await hasher.h64ToString(await fs.promises.readFile(configPathname, "utf-8"));
382
382
  return { ...config.data, digest };
383
383
  } else {
384
+ const message = config.error.issues.map((issue) => ` \u2192 ${green(issue.path.join("."))}: ${red(issue.message)}`).join("\n");
385
+ console.error(
386
+ `${green("[content]")} There was a problem with your content config:
387
+
388
+ ${message}
389
+ `
390
+ );
391
+ if (settings.config.experimental.liveContentCollections) {
392
+ const liveCollections = Object.entries(unparsedConfig.collections ?? {}).filter(
393
+ ([, collection]) => collection?.type === LIVE_CONTENT_TYPE
394
+ );
395
+ if (liveCollections.length > 0) {
396
+ throw new AstroError({
397
+ ...AstroErrorData.LiveContentConfigError,
398
+ message: AstroErrorData.LiveContentConfigError.message(
399
+ "Live collections must be defined in a `src/live.config.ts` file.",
400
+ path.relative(fileURLToPath(settings.config.root), configPathname)
401
+ )
402
+ });
403
+ }
404
+ }
384
405
  return void 0;
385
406
  }
386
407
  }
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.13.7";
1
+ const ASTRO_VERSION = "5.13.8";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
4
4
  const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
22
22
  await telemetry.record([]);
23
23
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
24
24
  const logger = restart.container.logger;
25
- const currentVersion = "5.13.7";
25
+ const currentVersion = "5.13.8";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -35,7 +35,7 @@ async function encodeKey(key) {
35
35
  }
36
36
  async function decodeKey(encoded) {
37
37
  const bytes = decodeBase64(encoded);
38
- return crypto.subtle.importKey("raw", Buffer.from(bytes), ALGORITHM, true, [
38
+ return crypto.subtle.importKey("raw", bytes.buffer, ALGORITHM, true, [
39
39
  "encrypt",
40
40
  "decrypt"
41
41
  ]);
@@ -62,10 +62,10 @@ async function decryptString(key, encoded) {
62
62
  const decryptedBuffer = await crypto.subtle.decrypt(
63
63
  {
64
64
  name: ALGORITHM,
65
- iv: Buffer.from(iv)
65
+ iv
66
66
  },
67
67
  key,
68
- Buffer.from(dataArray)
68
+ dataArray
69
69
  );
70
70
  const decryptedString = decoder.decode(decryptedBuffer);
71
71
  return decryptedString;
@@ -37,7 +37,7 @@ function serverStart({
37
37
  host,
38
38
  base
39
39
  }) {
40
- const version = "5.13.7";
40
+ const version = "5.13.8";
41
41
  const localPrefix = `${dim("\u2503")} Local `;
42
42
  const networkPrefix = `${dim("\u2503")} Network `;
43
43
  const emptyPrefix = " ".repeat(11);
@@ -274,7 +274,7 @@ function printHelp({
274
274
  message.push(
275
275
  linebreak(),
276
276
  ` ${bgGreen(black(` ${commandName} `))} ${green(
277
- `v${"5.13.7"}`
277
+ `v${"5.13.8"}`
278
278
  )} ${headline}`
279
279
  );
280
280
  }
@@ -51,6 +51,19 @@ function swapBodyElement(newElement, oldElement) {
51
51
  }
52
52
  }
53
53
  }
54
+ attachShadowRoots(newElement);
55
+ }
56
+ function attachShadowRoots(root) {
57
+ root.querySelectorAll("template[shadowrootmode]").forEach((template) => {
58
+ const mode = template.getAttribute("shadowrootmode");
59
+ const parent = template.parentNode;
60
+ if ((mode === "closed" || mode === "open") && parent instanceof HTMLElement) {
61
+ const shadowRoot = parent.attachShadow({ mode });
62
+ shadowRoot.appendChild(template.content);
63
+ template.remove();
64
+ attachShadowRoots(shadowRoot);
65
+ }
66
+ });
54
67
  }
55
68
  const saveFocus = () => {
56
69
  const activeElement = document.activeElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.13.7",
3
+ "version": "5.13.8",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -114,7 +114,7 @@
114
114
  "cssesc": "^3.0.0",
115
115
  "debug": "^4.4.1",
116
116
  "deterministic-object-hash": "^2.0.2",
117
- "devalue": "^5.1.1",
117
+ "devalue": "^5.3.2",
118
118
  "diff": "^5.2.0",
119
119
  "dlv": "^1.1.3",
120
120
  "dset": "^3.1.4",
@@ -222,6 +222,7 @@
222
222
  "dev": "astro-scripts dev --copy-wasm --prebuild \"src/runtime/server/astro-island.ts\" --prebuild \"src/runtime/client/{idle,load,media,only,visible}.ts\" \"src/**/*.{ts,js}\"",
223
223
  "test": "pnpm run test:unit && pnpm run test:integration && pnpm run test:types",
224
224
  "test:match": "astro-scripts test \"test/**/*.test.js\" --match",
225
+ "test:cli": "astro-scripts test \"test/**/cli.test.js\"",
225
226
  "test:e2e": "pnpm test:e2e:chrome && pnpm test:e2e:firefox",
226
227
  "test:e2e:match": "playwright test -g",
227
228
  "test:e2e:chrome": "playwright test",