astro 2.9.6 → 2.10.0
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/components/ViewTransitions.astro +65 -12
- package/dist/@types/astro.d.ts +13 -1
- package/dist/assets/vite-plugin-assets.js +1 -1
- package/dist/cli/add/index.d.ts +1 -3
- package/dist/cli/add/index.js +11 -4
- package/dist/cli/build/index.d.ts +1 -3
- package/dist/cli/build/index.js +19 -9
- package/dist/cli/check/index.d.ts +4 -9
- package/dist/cli/check/index.js +23 -11
- package/dist/cli/dev/index.d.ts +1 -3
- package/dist/cli/dev/index.js +24 -20
- package/dist/cli/flags.d.ts +9 -0
- package/dist/cli/flags.js +40 -0
- package/dist/cli/index.js +7 -14
- package/dist/cli/info/index.js +4 -6
- package/dist/cli/preview/index.d.ts +1 -3
- package/dist/cli/preview/index.js +21 -5
- package/dist/cli/sync/index.d.ts +1 -3
- package/dist/cli/sync/index.js +17 -8
- package/dist/cli/throw-and-exit.js +3 -0
- package/dist/config/index.js +2 -2
- package/dist/content/vite-plugin-content-virtual-mod.js +1 -1
- package/dist/core/app/index.d.ts +6 -1
- package/dist/core/app/index.js +84 -62
- package/dist/core/build/index.d.ts +2 -7
- package/dist/core/build/index.js +18 -20
- package/dist/core/compile/compile.js +1 -0
- package/dist/core/config/config.d.ts +6 -22
- package/dist/core/config/config.js +55 -54
- package/dist/core/config/index.d.ts +3 -2
- package/dist/core/config/index.js +6 -14
- package/dist/core/config/logging.d.ts +3 -0
- package/dist/core/config/logging.js +12 -0
- package/dist/core/config/settings.d.ts +1 -2
- package/dist/core/config/settings.js +0 -9
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/container.d.ts +6 -17
- package/dist/core/dev/container.js +8 -32
- package/dist/core/dev/dev.d.ts +2 -12
- package/dist/core/dev/dev.js +12 -43
- package/dist/core/dev/index.d.ts +1 -1
- package/dist/core/dev/index.js +1 -3
- package/dist/core/dev/restart.d.ts +9 -18
- package/dist/core/dev/restart.js +49 -74
- package/dist/core/errors/errors.d.ts +10 -0
- package/dist/core/errors/errors.js +10 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/preview/index.d.ts +2 -9
- package/dist/core/preview/index.js +12 -21
- package/dist/core/sync/index.d.ts +14 -10
- package/dist/core/sync/index.js +19 -20
- package/dist/core/util.js +2 -2
- package/dist/runtime/server/astro-island.js +16 -1
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/hydration.js +9 -0
- package/dist/runtime/server/render/component.js +11 -8
- package/dist/runtime/server/transition.d.ts +1 -0
- package/dist/runtime/server/transition.js +1 -0
- package/dist/vite-plugin-astro-postprocess/index.js +1 -1
- package/dist/vite-plugin-env/index.js +1 -1
- package/dist/vite-plugin-html/transform/index.js +1 -1
- package/dist/vite-plugin-scanner/index.js +4 -1
- package/dist/vite-plugin-scripts/page-ssr.js +1 -1
- package/package.json +3 -3
- package/dist/cli/load-settings.d.ts +0 -15
- package/dist/cli/load-settings.js +0 -39
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AstroConfig, AstroSettings
|
|
1
|
+
import type { AstroConfig, AstroSettings } from '../../@types/astro';
|
|
2
2
|
export declare function createBaseSettings(config: AstroConfig): AstroSettings;
|
|
3
3
|
export declare function createSettings(config: AstroConfig, cwd?: string): AstroSettings;
|
|
4
|
-
export declare function createDefaultDevSettings(userConfig?: AstroUserConfig, root?: string | URL): Promise<AstroSettings>;
|
|
@@ -8,7 +8,6 @@ import { getDefaultClientDirectives } from "../client-directive/index.js";
|
|
|
8
8
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
9
9
|
import { formatYAMLException, isYAMLException } from "../errors/utils.js";
|
|
10
10
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./../constants.js";
|
|
11
|
-
import { createDefaultDevConfig } from "./config.js";
|
|
12
11
|
import { AstroTimer } from "./timer.js";
|
|
13
12
|
import { loadTSConfig } from "./tsconfig.js";
|
|
14
13
|
function createBaseSettings(config) {
|
|
@@ -103,15 +102,7 @@ function createSettings(config, cwd) {
|
|
|
103
102
|
settings.watchFiles = watchFiles;
|
|
104
103
|
return settings;
|
|
105
104
|
}
|
|
106
|
-
async function createDefaultDevSettings(userConfig = {}, root) {
|
|
107
|
-
if (root && typeof root !== "string") {
|
|
108
|
-
root = fileURLToPath(root);
|
|
109
|
-
}
|
|
110
|
-
const config = await createDefaultDevConfig(userConfig, root);
|
|
111
|
-
return createBaseSettings(config);
|
|
112
|
-
}
|
|
113
105
|
export {
|
|
114
106
|
createBaseSettings,
|
|
115
|
-
createDefaultDevSettings,
|
|
116
107
|
createSettings
|
|
117
108
|
};
|
package/dist/core/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
import type * as http from 'node:http';
|
|
5
5
|
import type { AddressInfo } from 'node:net';
|
|
6
|
-
import type {
|
|
6
|
+
import type { AstroInlineConfig, AstroSettings } from '../../@types/astro';
|
|
7
7
|
import nodeFs from 'node:fs';
|
|
8
8
|
import * as vite from 'vite';
|
|
9
9
|
import type { LogOptions } from '../logger/core.js';
|
|
@@ -11,29 +11,18 @@ export interface Container {
|
|
|
11
11
|
fs: typeof nodeFs;
|
|
12
12
|
logging: LogOptions;
|
|
13
13
|
settings: AstroSettings;
|
|
14
|
-
viteConfig: vite.InlineConfig;
|
|
15
14
|
viteServer: vite.ViteDevServer;
|
|
16
|
-
|
|
17
|
-
configFlag: string | undefined;
|
|
18
|
-
configFlagPath: string | undefined;
|
|
15
|
+
inlineConfig: AstroInlineConfig;
|
|
19
16
|
restartInFlight: boolean;
|
|
20
17
|
handle: (req: http.IncomingMessage, res: http.ServerResponse) => void;
|
|
21
18
|
close: () => Promise<void>;
|
|
22
19
|
}
|
|
23
20
|
export interface CreateContainerParams {
|
|
21
|
+
logging: LogOptions;
|
|
22
|
+
settings: AstroSettings;
|
|
23
|
+
inlineConfig?: AstroInlineConfig;
|
|
24
24
|
isRestart?: boolean;
|
|
25
|
-
logging?: LogOptions;
|
|
26
|
-
userConfig?: AstroUserConfig;
|
|
27
|
-
settings?: AstroSettings;
|
|
28
25
|
fs?: typeof nodeFs;
|
|
29
|
-
root?: string | URL;
|
|
30
|
-
configFlag?: string;
|
|
31
|
-
configFlagPath?: string;
|
|
32
26
|
}
|
|
33
|
-
export declare function createContainer(
|
|
27
|
+
export declare function createContainer({ isRestart, logging, inlineConfig, settings, fs, }: CreateContainerParams): Promise<Container>;
|
|
34
28
|
export declare function startContainer({ settings, viteServer, logging, }: Container): Promise<AddressInfo>;
|
|
35
|
-
export declare function isStarted(container: Container): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Only used in tests
|
|
38
|
-
*/
|
|
39
|
-
export declare function runInContainer(params: CreateContainerParams, callback: (container: Container) => Promise<void> | void): Promise<void>;
|
|
@@ -7,22 +7,15 @@ import {
|
|
|
7
7
|
runHookServerDone,
|
|
8
8
|
runHookServerStart
|
|
9
9
|
} from "../../integrations/index.js";
|
|
10
|
-
import { createDefaultDevSettings, resolveRoot } from "../config/index.js";
|
|
11
10
|
import { createVite } from "../create-vite.js";
|
|
12
|
-
import { nodeLogDestination } from "../logger/node.js";
|
|
13
|
-
import { appendForwardSlash } from "../path.js";
|
|
14
11
|
import { apply as applyPolyfill } from "../polyfill.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
logging = defaultLogging,
|
|
23
|
-
settings = await createDefaultDevSettings(params.userConfig, params.root),
|
|
24
|
-
fs = nodeFs
|
|
25
|
-
} = params;
|
|
12
|
+
async function createContainer({
|
|
13
|
+
isRestart = false,
|
|
14
|
+
logging,
|
|
15
|
+
inlineConfig,
|
|
16
|
+
settings,
|
|
17
|
+
fs = nodeFs
|
|
18
|
+
}) {
|
|
26
19
|
applyPolyfill();
|
|
27
20
|
settings = await runHookConfigSetup({
|
|
28
21
|
settings,
|
|
@@ -48,14 +41,11 @@ async function createContainer(params = {}) {
|
|
|
48
41
|
await runHookConfigDone({ settings, logging });
|
|
49
42
|
const viteServer = await vite.createServer(viteConfig);
|
|
50
43
|
const container = {
|
|
51
|
-
|
|
52
|
-
configFlagPath: params.configFlagPath,
|
|
44
|
+
inlineConfig: inlineConfig ?? {},
|
|
53
45
|
fs,
|
|
54
46
|
logging,
|
|
55
|
-
resolvedRoot: appendForwardSlash(resolveRoot(params.root)),
|
|
56
47
|
restartInFlight: false,
|
|
57
48
|
settings,
|
|
58
|
-
viteConfig,
|
|
59
49
|
viteServer,
|
|
60
50
|
handle(req, res) {
|
|
61
51
|
viteServer.middlewares.handle(req, res, Function.prototype);
|
|
@@ -89,21 +79,7 @@ async function startContainer({
|
|
|
89
79
|
});
|
|
90
80
|
return devServerAddressInfo;
|
|
91
81
|
}
|
|
92
|
-
function isStarted(container) {
|
|
93
|
-
var _a;
|
|
94
|
-
return !!((_a = container.viteServer.httpServer) == null ? void 0 : _a.listening);
|
|
95
|
-
}
|
|
96
|
-
async function runInContainer(params, callback) {
|
|
97
|
-
const container = await createContainer(params);
|
|
98
|
-
try {
|
|
99
|
-
await callback(container);
|
|
100
|
-
} finally {
|
|
101
|
-
await container.close();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
82
|
export {
|
|
105
83
|
createContainer,
|
|
106
|
-
isStarted,
|
|
107
|
-
runInContainer,
|
|
108
84
|
startContainer
|
|
109
85
|
};
|
package/dist/core/dev/dev.d.ts
CHANGED
|
@@ -3,17 +3,7 @@
|
|
|
3
3
|
import type http from 'node:http';
|
|
4
4
|
import type { AddressInfo } from 'node:net';
|
|
5
5
|
import type * as vite from 'vite';
|
|
6
|
-
import type
|
|
7
|
-
import type { AstroSettings } from '../../@types/astro';
|
|
8
|
-
import { type LogOptions } from '../logger/core.js';
|
|
9
|
-
export interface DevOptions {
|
|
10
|
-
configFlag: string | undefined;
|
|
11
|
-
configFlagPath: string | undefined;
|
|
12
|
-
flags?: yargs.Arguments;
|
|
13
|
-
logging: LogOptions;
|
|
14
|
-
handleConfigError: (error: Error) => void;
|
|
15
|
-
isRestart?: boolean;
|
|
16
|
-
}
|
|
6
|
+
import type { AstroInlineConfig } from '../../@types/astro';
|
|
17
7
|
export interface DevServer {
|
|
18
8
|
address: AddressInfo;
|
|
19
9
|
handle: (req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage>) => void;
|
|
@@ -21,4 +11,4 @@ export interface DevServer {
|
|
|
21
11
|
stop(): Promise<void>;
|
|
22
12
|
}
|
|
23
13
|
/** `astro dev` */
|
|
24
|
-
export default function dev(
|
|
14
|
+
export default function dev(inlineConfig: AstroInlineConfig): Promise<DevServer>;
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -1,65 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
2
|
import { performance } from "perf_hooks";
|
|
3
3
|
import { attachContentServerListeners } from "../../content/index.js";
|
|
4
4
|
import { telemetry } from "../../events/index.js";
|
|
5
5
|
import { info, warn } from "../logger/core.js";
|
|
6
6
|
import * as msg from "../messages.js";
|
|
7
|
-
import { printHelp } from "../messages.js";
|
|
8
7
|
import { startContainer } from "./container.js";
|
|
9
8
|
import { createContainerWithAutomaticRestart } from "./restart.js";
|
|
10
|
-
async function dev(
|
|
11
|
-
var _a, _b
|
|
12
|
-
if (((_a = options.flags) == null ? void 0 : _a.help) || ((_b = options.flags) == null ? void 0 : _b.h)) {
|
|
13
|
-
printHelp({
|
|
14
|
-
commandName: "astro dev",
|
|
15
|
-
usage: "[...flags]",
|
|
16
|
-
tables: {
|
|
17
|
-
Flags: [
|
|
18
|
-
["--port", `Specify which port to run on. Defaults to 3000.`],
|
|
19
|
-
["--host", `Listen on all addresses, including LAN and public addresses.`],
|
|
20
|
-
["--host <custom-address>", `Expose on a network IP address at <custom-address>`],
|
|
21
|
-
["--open", "Automatically open the app in the browser on server start"],
|
|
22
|
-
["--help (-h)", "See all available flags."]
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
description: `Check ${cyan(
|
|
26
|
-
"https://docs.astro.build/en/reference/cli-reference/#astro-dev"
|
|
27
|
-
)} for more information.`
|
|
28
|
-
});
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
9
|
+
async function dev(inlineConfig) {
|
|
10
|
+
var _a, _b;
|
|
31
11
|
const devStart = performance.now();
|
|
32
12
|
await telemetry.record([]);
|
|
33
|
-
const restart = await createContainerWithAutomaticRestart({
|
|
34
|
-
|
|
35
|
-
handleConfigError: options.handleConfigError,
|
|
36
|
-
// eslint-disable-next-line no-console
|
|
37
|
-
beforeRestart: () => console.clear(),
|
|
38
|
-
params: {
|
|
39
|
-
settings,
|
|
40
|
-
root: (_c = options.flags) == null ? void 0 : _c.root,
|
|
41
|
-
logging: options.logging,
|
|
42
|
-
isRestart: options.isRestart
|
|
43
|
-
}
|
|
44
|
-
});
|
|
13
|
+
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
14
|
+
const logging = restart.container.logging;
|
|
45
15
|
const devServerAddressInfo = await startContainer(restart.container);
|
|
46
16
|
info(
|
|
47
|
-
|
|
17
|
+
logging,
|
|
48
18
|
null,
|
|
49
19
|
msg.serverStart({
|
|
50
20
|
startupTime: performance.now() - devStart,
|
|
51
21
|
resolvedUrls: restart.container.viteServer.resolvedUrls || { local: [], network: [] },
|
|
52
|
-
host: settings.config.server.host,
|
|
53
|
-
base: settings.config.base
|
|
54
|
-
isRestart: options.isRestart
|
|
22
|
+
host: restart.container.settings.config.server.host,
|
|
23
|
+
base: restart.container.settings.config.base
|
|
55
24
|
})
|
|
56
25
|
);
|
|
57
|
-
const currentVersion = "2.
|
|
26
|
+
const currentVersion = "2.10.0";
|
|
58
27
|
if (currentVersion.includes("-")) {
|
|
59
|
-
warn(
|
|
28
|
+
warn(logging, null, msg.prerelease({ currentVersion }));
|
|
60
29
|
}
|
|
61
|
-
if (((
|
|
62
|
-
warn(
|
|
30
|
+
if (((_b = (_a = restart.container.viteServer.config.server) == null ? void 0 : _a.fs) == null ? void 0 : _b.strict) === false) {
|
|
31
|
+
warn(logging, null, msg.fsStrictWarning());
|
|
63
32
|
}
|
|
64
33
|
await attachContentServerListeners(restart.container);
|
|
65
34
|
return {
|
package/dist/core/dev/index.d.ts
CHANGED
package/dist/core/dev/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { createContainer,
|
|
1
|
+
import { createContainer, startContainer } from "./container.js";
|
|
2
2
|
import { default as default2 } from "./dev.js";
|
|
3
3
|
import { createContainerWithAutomaticRestart } from "./restart.js";
|
|
4
4
|
export {
|
|
5
5
|
createContainer,
|
|
6
6
|
createContainerWithAutomaticRestart,
|
|
7
7
|
default2 as default,
|
|
8
|
-
isStarted,
|
|
9
|
-
runInContainer,
|
|
10
8
|
startContainer
|
|
11
9
|
};
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
handleConfigError: (err: Error) => Promise<void> | void;
|
|
8
|
-
beforeRestart?: () => void;
|
|
9
|
-
}
|
|
10
|
-
export declare function restartContainer({ container, flags, logMsg, handleConfigError, beforeRestart, }: RestartContainerParams): Promise<{
|
|
11
|
-
container: Container;
|
|
12
|
-
error: Error | null;
|
|
13
|
-
}>;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import nodeFs from 'node:fs';
|
|
3
|
+
import type { AstroInlineConfig } from '../../@types/astro';
|
|
4
|
+
import type { Container } from './container';
|
|
5
|
+
export declare function shouldRestartContainer({ settings, inlineConfig, restartInFlight }: Container, changedFile: string): boolean;
|
|
6
|
+
export declare function restartContainer(container: Container): Promise<Container | Error>;
|
|
14
7
|
export interface CreateContainerWithAutomaticRestart {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
handleConfigError?: (error: Error) => void | Promise<void>;
|
|
18
|
-
beforeRestart?: () => void;
|
|
8
|
+
inlineConfig?: AstroInlineConfig;
|
|
9
|
+
fs: typeof nodeFs;
|
|
19
10
|
}
|
|
20
11
|
interface Restart {
|
|
21
12
|
container: Container;
|
|
22
13
|
restarted: () => Promise<Error | null>;
|
|
23
14
|
}
|
|
24
|
-
export declare function createContainerWithAutomaticRestart({
|
|
15
|
+
export declare function createContainerWithAutomaticRestart({ inlineConfig, fs, }: CreateContainerWithAutomaticRestart): Promise<Restart>;
|
|
25
16
|
export {};
|
package/dist/core/dev/restart.js
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
1
2
|
import * as vite from "vite";
|
|
2
|
-
import {
|
|
3
|
+
import { eventCliSession, telemetry } from "../../events/index.js";
|
|
4
|
+
import { createNodeLogging, createSettings, resolveConfig } from "../config/index.js";
|
|
5
|
+
import { collectErrorMetadata } from "../errors/dev/utils.js";
|
|
6
|
+
import { isAstroConfigZodError } from "../errors/errors.js";
|
|
3
7
|
import { createSafeError } from "../errors/index.js";
|
|
4
|
-
import { info } from "../logger/core.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
import { info, error as logError } from "../logger/core.js";
|
|
9
|
+
import { formatErrorMessage } from "../messages.js";
|
|
10
|
+
import { createContainer, startContainer } from "./container.js";
|
|
11
|
+
async function createRestartedContainer(container, settings) {
|
|
12
|
+
const { logging, fs, inlineConfig } = container;
|
|
8
13
|
const newContainer = await createContainer({
|
|
9
14
|
isRestart: true,
|
|
10
15
|
logging,
|
|
11
16
|
settings,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
configFlag,
|
|
15
|
-
configFlagPath
|
|
17
|
+
inlineConfig,
|
|
18
|
+
fs
|
|
16
19
|
});
|
|
17
|
-
|
|
18
|
-
await startContainer(newContainer);
|
|
19
|
-
}
|
|
20
|
+
await startContainer(newContainer);
|
|
20
21
|
return newContainer;
|
|
21
22
|
}
|
|
22
|
-
function shouldRestartContainer({ settings,
|
|
23
|
+
function shouldRestartContainer({ settings, inlineConfig, restartInFlight }, changedFile) {
|
|
23
24
|
if (restartInFlight)
|
|
24
25
|
return false;
|
|
25
26
|
let shouldRestart = false;
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
shouldRestart = vite.normalizePath(configFlagPath) === vite.normalizePath(changedFile);
|
|
29
|
-
}
|
|
27
|
+
if (inlineConfig.configFile) {
|
|
28
|
+
shouldRestart = vite.normalizePath(inlineConfig.configFile) === vite.normalizePath(changedFile);
|
|
30
29
|
} else {
|
|
31
30
|
const exp = new RegExp(`.*astro.config.((mjs)|(cjs)|(js)|(ts))$`);
|
|
32
31
|
const normalizedChangedFile = vite.normalizePath(changedFile);
|
|
@@ -39,54 +38,40 @@ function shouldRestartContainer({ settings, configFlag, configFlagPath, restartI
|
|
|
39
38
|
}
|
|
40
39
|
return shouldRestart;
|
|
41
40
|
}
|
|
42
|
-
async function restartContainer({
|
|
43
|
-
container
|
|
44
|
-
flags,
|
|
45
|
-
logMsg,
|
|
46
|
-
handleConfigError,
|
|
47
|
-
beforeRestart
|
|
48
|
-
}) {
|
|
49
|
-
const { logging, close, resolvedRoot, settings: existingSettings } = container;
|
|
41
|
+
async function restartContainer(container) {
|
|
42
|
+
const { logging, close, settings: existingSettings } = container;
|
|
50
43
|
container.restartInFlight = true;
|
|
51
|
-
if (beforeRestart) {
|
|
52
|
-
beforeRestart();
|
|
53
|
-
}
|
|
54
|
-
const needsStart = isStarted(container);
|
|
55
44
|
try {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
flags,
|
|
59
|
-
cmd: "dev",
|
|
60
|
-
isRestart: true,
|
|
61
|
-
fsMod: container.fs
|
|
62
|
-
});
|
|
63
|
-
info(logging, "astro", logMsg + "\n");
|
|
64
|
-
let astroConfig = newConfig.astroConfig;
|
|
65
|
-
const settings = createSettings(astroConfig, resolvedRoot);
|
|
45
|
+
const { astroConfig } = await resolveConfig(container.inlineConfig, "dev", container.fs);
|
|
46
|
+
const settings = createSettings(astroConfig, fileURLToPath(existingSettings.config.root));
|
|
66
47
|
await close();
|
|
67
|
-
return
|
|
68
|
-
container: await createRestartedContainer(container, settings, needsStart),
|
|
69
|
-
error: null
|
|
70
|
-
};
|
|
48
|
+
return await createRestartedContainer(container, settings);
|
|
71
49
|
} catch (_err) {
|
|
72
50
|
const error = createSafeError(_err);
|
|
73
|
-
|
|
74
|
-
|
|
51
|
+
if (!isAstroConfigZodError(_err)) {
|
|
52
|
+
logError(logging, "config", formatErrorMessage(collectErrorMetadata(error)) + "\n");
|
|
53
|
+
}
|
|
54
|
+
container.viteServer.ws.send({
|
|
55
|
+
type: "error",
|
|
56
|
+
err: {
|
|
57
|
+
message: error.message,
|
|
58
|
+
stack: error.stack || ""
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
container.restartInFlight = false;
|
|
75
62
|
info(logging, "astro", "Continuing with previous valid configuration\n");
|
|
76
|
-
return
|
|
77
|
-
container: await createRestartedContainer(container, existingSettings, needsStart),
|
|
78
|
-
error
|
|
79
|
-
};
|
|
63
|
+
return error;
|
|
80
64
|
}
|
|
81
65
|
}
|
|
82
66
|
async function createContainerWithAutomaticRestart({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
beforeRestart,
|
|
87
|
-
params
|
|
67
|
+
inlineConfig,
|
|
68
|
+
fs
|
|
88
69
|
}) {
|
|
89
|
-
const
|
|
70
|
+
const logging = createNodeLogging(inlineConfig ?? {});
|
|
71
|
+
const { userConfig, astroConfig } = await resolveConfig(inlineConfig ?? {}, "dev", fs);
|
|
72
|
+
telemetry.record(eventCliSession("dev", userConfig));
|
|
73
|
+
const settings = createSettings(astroConfig, fileURLToPath(astroConfig.root));
|
|
74
|
+
const initialContainer = await createContainer({ settings, logging, inlineConfig, fs });
|
|
90
75
|
let resolveRestart;
|
|
91
76
|
let restartComplete = new Promise((resolve) => {
|
|
92
77
|
resolveRestart = resolve;
|
|
@@ -98,26 +83,16 @@ async function createContainerWithAutomaticRestart({
|
|
|
98
83
|
}
|
|
99
84
|
};
|
|
100
85
|
async function handleServerRestart(logMsg) {
|
|
86
|
+
info(logging, "astro", logMsg + "\n");
|
|
101
87
|
const container = restart.container;
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
type: "error",
|
|
111
|
-
err: {
|
|
112
|
-
message: err.message,
|
|
113
|
-
stack: err.stack || ""
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
restart.container = newContainer;
|
|
119
|
-
addWatches();
|
|
120
|
-
resolveRestart(error);
|
|
88
|
+
const result = await restartContainer(container);
|
|
89
|
+
if (result instanceof Error) {
|
|
90
|
+
resolveRestart(result);
|
|
91
|
+
} else {
|
|
92
|
+
restart.container = result;
|
|
93
|
+
addWatches();
|
|
94
|
+
resolveRestart(null);
|
|
95
|
+
}
|
|
121
96
|
restartComplete = new Promise((resolve) => {
|
|
122
97
|
resolveRestart = resolve;
|
|
123
98
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ZodError } from 'zod';
|
|
1
2
|
interface ErrorProperties {
|
|
2
3
|
title?: string;
|
|
3
4
|
name?: string;
|
|
@@ -53,6 +54,15 @@ export declare class AggregateError extends AstroError {
|
|
|
53
54
|
}, ...params: any);
|
|
54
55
|
static is(err: unknown): err is AggregateError;
|
|
55
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Check if an error is a ZodError from an AstroConfig validation.
|
|
59
|
+
* Used to suppress formatting a ZodError if needed.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isAstroConfigZodError(error: unknown): error is ZodError;
|
|
62
|
+
/**
|
|
63
|
+
* Track that a ZodError comes from an AstroConfig validation.
|
|
64
|
+
*/
|
|
65
|
+
export declare function trackAstroConfigZodError(error: ZodError): void;
|
|
56
66
|
/**
|
|
57
67
|
* Generic object representing an error with all possible data
|
|
58
68
|
* Compatible with both Astro's and Vite's errors
|
|
@@ -93,6 +93,13 @@ class AggregateError extends AstroError {
|
|
|
93
93
|
return err.type === "AggregateError";
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
const astroConfigZodErrors = /* @__PURE__ */ new WeakSet();
|
|
97
|
+
function isAstroConfigZodError(error) {
|
|
98
|
+
return astroConfigZodErrors.has(error);
|
|
99
|
+
}
|
|
100
|
+
function trackAstroConfigZodError(error) {
|
|
101
|
+
astroConfigZodErrors.add(error);
|
|
102
|
+
}
|
|
96
103
|
export {
|
|
97
104
|
AggregateError,
|
|
98
105
|
AstroError,
|
|
@@ -100,5 +107,7 @@ export {
|
|
|
100
107
|
CompilerError,
|
|
101
108
|
InternalError,
|
|
102
109
|
MarkdownError,
|
|
103
|
-
|
|
110
|
+
isAstroConfigZodError,
|
|
111
|
+
isAstroError,
|
|
112
|
+
trackAstroConfigZodError
|
|
104
113
|
};
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.
|
|
50
|
+
const version = "2.10.0";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
53
53
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -233,7 +233,7 @@ function printHelp({
|
|
|
233
233
|
message.push(
|
|
234
234
|
linebreak(),
|
|
235
235
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
236
|
-
`v${"2.
|
|
236
|
+
`v${"2.10.0"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AstroSettings, PreviewServer } from '../../@types/astro';
|
|
3
|
-
import type { LogOptions } from '../logger/core';
|
|
4
|
-
interface PreviewOptions {
|
|
5
|
-
logging: LogOptions;
|
|
6
|
-
flags?: Arguments;
|
|
7
|
-
}
|
|
1
|
+
import type { AstroInlineConfig, PreviewServer } from '../../@types/astro';
|
|
8
2
|
/** The primary dev action */
|
|
9
|
-
export default function preview(
|
|
10
|
-
export {};
|
|
3
|
+
export default function preview(inlineConfig: AstroInlineConfig): Promise<PreviewServer | undefined>;
|
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
+
import { telemetry } from "../../events/index.js";
|
|
4
|
+
import { eventCliSession } from "../../events/session.js";
|
|
4
5
|
import { runHookConfigDone, runHookConfigSetup } from "../../integrations/index.js";
|
|
5
|
-
import {
|
|
6
|
+
import { resolveConfig } from "../config/config.js";
|
|
7
|
+
import { createNodeLogging } from "../config/logging.js";
|
|
8
|
+
import { createSettings } from "../config/settings.js";
|
|
6
9
|
import createStaticPreviewServer from "./static-preview-server.js";
|
|
7
10
|
import { getResolvedHostForHttpServer } from "./util.js";
|
|
8
|
-
async function preview(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
tables: {
|
|
14
|
-
Flags: [
|
|
15
|
-
["--open", "Automatically open the app in the browser on server start"],
|
|
16
|
-
["--help (-h)", "See all available flags."]
|
|
17
|
-
]
|
|
18
|
-
},
|
|
19
|
-
description: `Starts a local server to serve your static dist/ directory. Check ${cyan(
|
|
20
|
-
"https://docs.astro.build/en/reference/cli-reference/#astro-preview"
|
|
21
|
-
)} for more information.`
|
|
22
|
-
});
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
11
|
+
async function preview(inlineConfig) {
|
|
12
|
+
const logging = createNodeLogging(inlineConfig);
|
|
13
|
+
const { userConfig, astroConfig } = await resolveConfig(inlineConfig ?? {}, "preview");
|
|
14
|
+
telemetry.record(eventCliSession("preview", userConfig));
|
|
15
|
+
const _settings = createSettings(astroConfig, fileURLToPath(astroConfig.root));
|
|
25
16
|
const settings = await runHookConfigSetup({
|
|
26
17
|
settings: _settings,
|
|
27
18
|
command: "preview",
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
import type { AstroSettings } from '../../@types/astro';
|
|
2
|
+
import fsMod from 'node:fs';
|
|
3
|
+
import type { AstroInlineConfig, AstroSettings } from '../../@types/astro';
|
|
5
4
|
import { type LogOptions } from '../logger/core.js';
|
|
6
5
|
export type ProcessExit = 0 | 1;
|
|
7
6
|
export type SyncOptions = {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Only used for testing
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
fs?: typeof fsMod;
|
|
10
12
|
};
|
|
11
|
-
export
|
|
13
|
+
export type SyncInternalOptions = SyncOptions & {
|
|
12
14
|
logging: LogOptions;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}): Promise<ProcessExit>;
|
|
15
|
+
};
|
|
16
|
+
export declare function sync(inlineConfig: AstroInlineConfig, options?: SyncOptions): Promise<ProcessExit>;
|
|
16
17
|
/**
|
|
17
18
|
* Generate content collection types, and then returns the process exit signal.
|
|
18
19
|
*
|
|
19
20
|
* A non-zero process signal is emitted in case there's an error while generating content collection types.
|
|
20
21
|
*
|
|
22
|
+
* This should only be used when the callee already has an `AstroSetting`, otherwise use `sync()` instead.
|
|
23
|
+
* @internal
|
|
24
|
+
*
|
|
21
25
|
* @param {SyncOptions} options
|
|
22
26
|
* @param {AstroSettings} settings Astro settings
|
|
23
27
|
* @param {typeof fsMod} options.fs The file system
|
|
24
28
|
* @param {LogOptions} options.logging Logging options
|
|
25
29
|
* @return {Promise<ProcessExit>}
|
|
26
30
|
*/
|
|
27
|
-
export declare function
|
|
31
|
+
export declare function syncInternal(settings: AstroSettings, { logging, fs }: SyncInternalOptions): Promise<ProcessExit>;
|