astro 7.0.0 → 7.0.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/dist/assets/utils/generateImageStylesCSS.js +4 -1
- package/dist/cli/dev/background.d.ts +9 -0
- package/dist/cli/dev/background.js +19 -17
- package/dist/cli/dev/index.js +3 -2
- package/dist/cli/dev/status.js +9 -3
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/lockfile.d.ts +2 -0
- package/dist/core/dev/lockfile.js +13 -0
- package/dist/core/messages/runtime.js +1 -1
- package/dist/vite-plugin-config-alias/index.js +10 -3
- package/package.json +2 -2
|
@@ -37,7 +37,7 @@ function generateImageStylesCSS(defaultObjectFit, defaultObjectPosition) {
|
|
|
37
37
|
:where([data-astro-image]:not([data-astro-image-pos])) {
|
|
38
38
|
object-position: ${defaultObjectPosition};
|
|
39
39
|
}` : "";
|
|
40
|
-
|
|
40
|
+
const rules = `
|
|
41
41
|
:where([data-astro-image]) {
|
|
42
42
|
height: auto;
|
|
43
43
|
}
|
|
@@ -52,6 +52,9 @@ ${defaultFitStyle}
|
|
|
52
52
|
${positionStyles}
|
|
53
53
|
${defaultPositionStyle}
|
|
54
54
|
`.trim();
|
|
55
|
+
return `@layer astro.images {
|
|
56
|
+
${rules}
|
|
57
|
+
}`;
|
|
55
58
|
}
|
|
56
59
|
export {
|
|
57
60
|
generateImageStylesCSS
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AstroLogger } from '../../core/logger/core.js';
|
|
2
2
|
import type { Flags } from '../flags.js';
|
|
3
|
+
import { type LockFileData } from '../../core/dev/lockfile.js';
|
|
3
4
|
export interface BackgroundResult {
|
|
4
5
|
pid: number;
|
|
5
6
|
url: string;
|
|
@@ -10,6 +11,14 @@ export interface BackgroundErrorResult {
|
|
|
10
11
|
message: string;
|
|
11
12
|
}
|
|
12
13
|
export declare function formatBackgroundOutput(result: BackgroundResult | BackgroundErrorResult): string;
|
|
14
|
+
/**
|
|
15
|
+
* Build the human-readable message shown when a background dev server is running.
|
|
16
|
+
* Lists every network address (when `--host` exposed any) so the output matches
|
|
17
|
+
* the foreground dev server, then appends the management command hints.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatServerRunningMessage(data: LockFileData, { existing }?: {
|
|
20
|
+
existing?: boolean;
|
|
21
|
+
}): string;
|
|
13
22
|
export declare function background({ flags, logger, }: {
|
|
14
23
|
flags: Flags;
|
|
15
24
|
logger: AstroLogger;
|
|
@@ -14,6 +14,19 @@ import { resolveRoot } from "../../core/config/config.js";
|
|
|
14
14
|
function formatBackgroundOutput(result) {
|
|
15
15
|
return JSON.stringify(result);
|
|
16
16
|
}
|
|
17
|
+
function formatServerRunningMessage(data, { existing = false } = {}) {
|
|
18
|
+
const lines = [
|
|
19
|
+
`Dev server ${existing ? "already running" : "running"} at ${data.url} (pid ${data.pid})`
|
|
20
|
+
];
|
|
21
|
+
if (data.urls && data.urls.network.length > 0) {
|
|
22
|
+
lines.push(" Network:");
|
|
23
|
+
for (const url of data.urls.network) {
|
|
24
|
+
lines.push(` ${url}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
lines.push(" Stop: astro dev stop", " Status: astro dev status", " Logs: astro dev logs");
|
|
28
|
+
return lines.join("\n");
|
|
29
|
+
}
|
|
17
30
|
async function background({
|
|
18
31
|
flags,
|
|
19
32
|
logger
|
|
@@ -21,13 +34,7 @@ async function background({
|
|
|
21
34
|
const root = pathToFileURL(resolveRoot(flags.root) + "/");
|
|
22
35
|
const existing = checkExistingServer(root);
|
|
23
36
|
if (existing && !flags.force) {
|
|
24
|
-
logger.info(
|
|
25
|
-
"SKIP_FORMAT",
|
|
26
|
-
`Dev server already running at ${existing.url} (pid ${existing.pid})
|
|
27
|
-
Stop: astro dev stop
|
|
28
|
-
Status: astro dev status
|
|
29
|
-
Logs: astro dev logs`
|
|
30
|
-
);
|
|
37
|
+
logger.info("SKIP_FORMAT", formatServerRunningMessage(existing, { existing: true }));
|
|
31
38
|
return;
|
|
32
39
|
}
|
|
33
40
|
if (existing && flags.force) {
|
|
@@ -69,8 +76,8 @@ async function background({
|
|
|
69
76
|
}
|
|
70
77
|
const logFd = openSync(logFilePath, "w");
|
|
71
78
|
const rootPath = fileURLToPath(root);
|
|
72
|
-
const astroBin = resolve(rootPath, "node_modules", "
|
|
73
|
-
const child = spawn(astroBin, args, {
|
|
79
|
+
const astroBin = resolve(rootPath, "node_modules", "astro", "bin", "astro.mjs");
|
|
80
|
+
const child = spawn(process.execPath, [astroBin, ...args], {
|
|
74
81
|
detached: true,
|
|
75
82
|
stdio: ["ignore", logFd, logFd],
|
|
76
83
|
cwd: rootPath,
|
|
@@ -91,13 +98,7 @@ async function background({
|
|
|
91
98
|
}
|
|
92
99
|
const lockData = readLockFile(root);
|
|
93
100
|
if (lockData && lockData.pid === childPid) {
|
|
94
|
-
logger.info(
|
|
95
|
-
"SKIP_FORMAT",
|
|
96
|
-
`Dev server running at ${lockData.url} (pid ${lockData.pid})
|
|
97
|
-
Stop: astro dev stop
|
|
98
|
-
Status: astro dev status
|
|
99
|
-
Logs: astro dev logs`
|
|
100
|
-
);
|
|
101
|
+
logger.info("SKIP_FORMAT", formatServerRunningMessage(lockData));
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
104
|
await new Promise((r) => setTimeout(r, 200));
|
|
@@ -112,5 +113,6 @@ async function background({
|
|
|
112
113
|
}
|
|
113
114
|
export {
|
|
114
115
|
background,
|
|
115
|
-
formatBackgroundOutput
|
|
116
|
+
formatBackgroundOutput,
|
|
117
|
+
formatServerRunningMessage
|
|
116
118
|
};
|
package/dist/cli/dev/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { detectAgenticEnvironment } from "am-i-vibing";
|
|
2
2
|
import colors from "piccolore";
|
|
3
3
|
import devServer from "../../core/dev/index.js";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
@@ -8,7 +8,7 @@ import { printHelp } from "../../core/messages/runtime.js";
|
|
|
8
8
|
import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
|
|
9
9
|
function isRunByAgent() {
|
|
10
10
|
try {
|
|
11
|
-
return
|
|
11
|
+
return detectAgenticEnvironment().type === "agent";
|
|
12
12
|
} catch {
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
@@ -100,6 +100,7 @@ Run \`astro dev --help\` to see available commands.`
|
|
|
100
100
|
pid: process.pid,
|
|
101
101
|
port: server.address.port,
|
|
102
102
|
url: serverUrl,
|
|
103
|
+
urls: server.resolvedUrls,
|
|
103
104
|
background: !!process.env.ASTRO_DEV_BACKGROUND,
|
|
104
105
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
105
106
|
});
|
package/dist/cli/dev/status.js
CHANGED
|
@@ -16,10 +16,16 @@ async function status({
|
|
|
16
16
|
}
|
|
17
17
|
const startedAt = new Date(existing.startedAt).getTime();
|
|
18
18
|
const uptime = Math.floor((Date.now() - startedAt) / 1e3);
|
|
19
|
-
|
|
20
|
-
"SKIP_FORMAT",
|
|
19
|
+
const lines = [
|
|
21
20
|
`Dev server running at ${existing.url} (pid ${existing.pid}, uptime ${uptime}s${existing.background ? ", background" : ""})`
|
|
22
|
-
|
|
21
|
+
];
|
|
22
|
+
if (existing.urls && existing.urls.network.length > 0) {
|
|
23
|
+
lines.push(" Network:");
|
|
24
|
+
for (const url of existing.urls.network) {
|
|
25
|
+
lines.push(` ${url}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
logger.info("SKIP_FORMAT", lines.join("\n"));
|
|
23
29
|
}
|
|
24
30
|
export {
|
|
25
31
|
formatStatusOutput,
|
|
@@ -197,7 +197,7 @@ ${contentConfig.error.message}`
|
|
|
197
197
|
logger.info("Content config changed");
|
|
198
198
|
shouldClear = true;
|
|
199
199
|
}
|
|
200
|
-
if (previousAstroVersion && previousAstroVersion !== "7.0.
|
|
200
|
+
if (previousAstroVersion && previousAstroVersion !== "7.0.1") {
|
|
201
201
|
logger.info("Astro version changed");
|
|
202
202
|
shouldClear = true;
|
|
203
203
|
}
|
|
@@ -205,8 +205,8 @@ ${contentConfig.error.message}`
|
|
|
205
205
|
logger.info("Clearing content store");
|
|
206
206
|
this.#store.clearAll();
|
|
207
207
|
}
|
|
208
|
-
if ("7.0.
|
|
209
|
-
this.#store.metaStore().set("astro-version", "7.0.
|
|
208
|
+
if ("7.0.1") {
|
|
209
|
+
this.#store.metaStore().set("astro-version", "7.0.1");
|
|
210
210
|
}
|
|
211
211
|
if (currentConfigDigest) {
|
|
212
212
|
this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -26,7 +26,7 @@ async function dev(inlineConfig) {
|
|
|
26
26
|
await telemetry.record([]);
|
|
27
27
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
28
28
|
const logger = restart.container.logger;
|
|
29
|
-
const currentVersion = "7.0.
|
|
29
|
+
const currentVersion = "7.0.1";
|
|
30
30
|
const isPrerelease = currentVersion.includes("-");
|
|
31
31
|
if (!isPrerelease) {
|
|
32
32
|
try {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { ResolvedServerUrls } from 'vite';
|
|
1
2
|
/** Maximum time (ms) to wait for a process to exit after SIGTERM before escalating to SIGKILL. */
|
|
2
3
|
export declare const GRACEFUL_SHUTDOWN_TIMEOUT = 5000;
|
|
3
4
|
export interface LockFileData {
|
|
4
5
|
pid: number;
|
|
5
6
|
port: number;
|
|
6
7
|
url: string;
|
|
8
|
+
urls?: ResolvedServerUrls;
|
|
7
9
|
background: boolean;
|
|
8
10
|
startedAt: string;
|
|
9
11
|
}
|
|
@@ -7,12 +7,25 @@ function getLockFileURL(root) {
|
|
|
7
7
|
function getLogFileURL(root) {
|
|
8
8
|
return new URL(".astro/dev.log", root);
|
|
9
9
|
}
|
|
10
|
+
function isStringArray(value) {
|
|
11
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
12
|
+
}
|
|
13
|
+
function isResolvedServerUrls(value) {
|
|
14
|
+
if (typeof value !== "object" || value === null) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const { local, network } = value;
|
|
18
|
+
return isStringArray(local) && isStringArray(network);
|
|
19
|
+
}
|
|
10
20
|
function parseLockFile(content) {
|
|
11
21
|
try {
|
|
12
22
|
const data = JSON.parse(content);
|
|
13
23
|
if (typeof data.pid !== "number" || typeof data.port !== "number" || typeof data.url !== "string" || typeof data.background !== "boolean" || typeof data.startedAt !== "string") {
|
|
14
24
|
return null;
|
|
15
25
|
}
|
|
26
|
+
if (data.urls !== void 0 && !isResolvedServerUrls(data.urls)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
16
29
|
return data;
|
|
17
30
|
} catch {
|
|
18
31
|
return null;
|
|
@@ -44,6 +44,7 @@ function resolveWithAlias(id, configAlias) {
|
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
const cssImportRE = /@import\s+(?:url\(\s*)?['"]([^'"]+)['"]\s*\)?/g;
|
|
47
|
+
const cssUrlRE = /(?<!@import\s+)url\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
47
48
|
function configAliasVitePlugin({
|
|
48
49
|
settings
|
|
49
50
|
}) {
|
|
@@ -64,9 +65,8 @@ function configAliasVitePlugin({
|
|
|
64
65
|
}
|
|
65
66
|
},
|
|
66
67
|
handler(code) {
|
|
67
|
-
if (!code.includes("@import")) return;
|
|
68
68
|
let hasReplacement = false;
|
|
69
|
-
const
|
|
69
|
+
const replaceAliases = (match, importId) => {
|
|
70
70
|
if (!importId) return match;
|
|
71
71
|
const resolved = resolveWithAlias(importId, configAlias);
|
|
72
72
|
if (resolved) {
|
|
@@ -74,7 +74,14 @@ function configAliasVitePlugin({
|
|
|
74
74
|
return match.replace(importId, resolved);
|
|
75
75
|
}
|
|
76
76
|
return match;
|
|
77
|
-
}
|
|
77
|
+
};
|
|
78
|
+
let result = code;
|
|
79
|
+
if (result.includes("@import")) {
|
|
80
|
+
result = result.replace(cssImportRE, replaceAliases);
|
|
81
|
+
}
|
|
82
|
+
if (result.includes("url(")) {
|
|
83
|
+
result = result.replace(cssUrlRE, replaceAliases);
|
|
84
|
+
}
|
|
78
85
|
if (hasReplacement) {
|
|
79
86
|
return { code: result, map: null };
|
|
80
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
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",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@clack/prompts": "^1.1.0",
|
|
119
119
|
"@oslojs/encoding": "^1.1.0",
|
|
120
120
|
"@rollup/pluginutils": "^5.3.0",
|
|
121
|
-
"am-i-vibing": "^0.
|
|
121
|
+
"am-i-vibing": "^0.4.0",
|
|
122
122
|
"aria-query": "^5.3.2",
|
|
123
123
|
"axobject-query": "^4.1.0",
|
|
124
124
|
"ci-info": "^4.4.0",
|