astro 2.9.5 → 2.9.7

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.
Files changed (57) hide show
  1. package/dist/@types/astro.d.ts +14 -2
  2. package/dist/cli/add/index.d.ts +1 -3
  3. package/dist/cli/add/index.js +11 -4
  4. package/dist/cli/build/index.d.ts +1 -3
  5. package/dist/cli/build/index.js +19 -9
  6. package/dist/cli/check/index.d.ts +4 -9
  7. package/dist/cli/check/index.js +23 -11
  8. package/dist/cli/dev/index.d.ts +1 -3
  9. package/dist/cli/dev/index.js +24 -20
  10. package/dist/cli/flags.d.ts +9 -0
  11. package/dist/cli/flags.js +40 -0
  12. package/dist/cli/index.js +7 -14
  13. package/dist/cli/info/index.js +4 -6
  14. package/dist/cli/preview/index.d.ts +1 -3
  15. package/dist/cli/preview/index.js +21 -5
  16. package/dist/cli/sync/index.d.ts +1 -3
  17. package/dist/cli/sync/index.js +17 -8
  18. package/dist/cli/throw-and-exit.js +3 -0
  19. package/dist/config/index.js +2 -2
  20. package/dist/core/app/index.d.ts +6 -1
  21. package/dist/core/app/index.js +81 -61
  22. package/dist/core/build/index.d.ts +2 -7
  23. package/dist/core/build/index.js +18 -20
  24. package/dist/core/config/config.d.ts +6 -22
  25. package/dist/core/config/config.js +55 -54
  26. package/dist/core/config/index.d.ts +3 -2
  27. package/dist/core/config/index.js +6 -14
  28. package/dist/core/config/logging.d.ts +3 -0
  29. package/dist/core/config/logging.js +12 -0
  30. package/dist/core/config/settings.d.ts +1 -2
  31. package/dist/core/config/settings.js +0 -9
  32. package/dist/core/constants.js +1 -1
  33. package/dist/core/dev/container.d.ts +6 -16
  34. package/dist/core/dev/container.js +8 -27
  35. package/dist/core/dev/dev.d.ts +2 -12
  36. package/dist/core/dev/dev.js +12 -43
  37. package/dist/core/dev/index.d.ts +1 -1
  38. package/dist/core/dev/index.js +1 -2
  39. package/dist/core/dev/restart.d.ts +9 -15
  40. package/dist/core/dev/restart.js +36 -56
  41. package/dist/core/errors/errors.d.ts +10 -0
  42. package/dist/core/errors/errors.js +10 -1
  43. package/dist/core/messages.js +2 -2
  44. package/dist/core/preview/index.d.ts +2 -9
  45. package/dist/core/preview/index.js +12 -21
  46. package/dist/core/routing/manifest/serialization.js +4 -1
  47. package/dist/core/sync/index.d.ts +14 -10
  48. package/dist/core/sync/index.js +19 -20
  49. package/dist/core/util.js +2 -2
  50. package/dist/runtime/server/astro-island.js +16 -1
  51. package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
  52. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  53. package/dist/runtime/server/render/component.js +11 -8
  54. package/dist/vite-plugin-scanner/index.js +4 -1
  55. package/package.json +1 -1
  56. package/dist/cli/load-settings.d.ts +0 -15
  57. package/dist/cli/load-settings.js +0 -39
@@ -14,7 +14,7 @@ import type { PageBuildData } from '../core/build/types';
14
14
  import type { AstroConfigSchema } from '../core/config';
15
15
  import type { AstroTimer } from '../core/config/timer';
16
16
  import type { AstroCookies } from '../core/cookies';
17
- import type { LogOptions } from '../core/logger/core';
17
+ import type { LogOptions, LoggerLevel } from '../core/logger/core';
18
18
  import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
19
19
  import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
20
20
  export type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig, } from '@astrojs/markdown-remark';
@@ -1227,6 +1227,17 @@ export interface InjectedRoute {
1227
1227
  export interface AstroConfig extends z.output<typeof AstroConfigSchema> {
1228
1228
  integrations: AstroIntegration[];
1229
1229
  }
1230
+ export interface AstroInlineConfig extends AstroUserConfig, AstroInlineOnlyConfig {
1231
+ }
1232
+ export interface AstroInlineOnlyConfig {
1233
+ configFile?: string | false;
1234
+ mode?: RuntimeMode;
1235
+ logLevel?: LoggerLevel;
1236
+ /**
1237
+ * @internal for testing only
1238
+ */
1239
+ logging?: LogOptions;
1240
+ }
1230
1241
  export type ContentEntryModule = {
1231
1242
  id: string;
1232
1243
  collection: string;
@@ -1766,9 +1777,10 @@ export interface RouteData {
1766
1777
  export type RedirectRouteData = RouteData & {
1767
1778
  redirect: string;
1768
1779
  };
1769
- export type SerializedRouteData = Omit<RouteData, 'generate' | 'pattern'> & {
1780
+ export type SerializedRouteData = Omit<RouteData, 'generate' | 'pattern' | 'redirectRoute'> & {
1770
1781
  generate: undefined;
1771
1782
  pattern: string;
1783
+ redirectRoute: SerializedRouteData | undefined;
1772
1784
  _meta: {
1773
1785
  trailingSlash: AstroConfig['trailingSlash'];
1774
1786
  };
@@ -1,7 +1,5 @@
1
1
  import type yargs from 'yargs-parser';
2
- import { type LogOptions } from '../../core/logger/core.js';
3
2
  interface AddOptions {
4
- logging: LogOptions;
5
3
  flags: yargs.Arguments;
6
4
  }
7
5
  interface IntegrationInfo {
@@ -10,6 +8,6 @@ interface IntegrationInfo {
10
8
  dependencies: [name: string, version: string][];
11
9
  type: 'integration' | 'adapter';
12
10
  }
13
- export declare function add(names: string[], { flags, logging }: AddOptions): Promise<void>;
11
+ export declare function add(names: string[], { flags }: AddOptions): Promise<void>;
14
12
  export declare function validateIntegrations(integrations: string[]): Promise<IntegrationInfo[]>;
15
13
  export {};
@@ -8,7 +8,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
8
8
  import ora from "ora";
9
9
  import preferredPM from "preferred-pm";
10
10
  import prompts from "prompts";
11
- import { loadTSConfig, resolveConfigPath } from "../../core/config/index.js";
11
+ import { loadTSConfig, resolveConfigPath, resolveRoot } from "../../core/config/index.js";
12
12
  import {
13
13
  defaultTSConfig,
14
14
  presets,
@@ -21,6 +21,7 @@ import { appendForwardSlash } from "../../core/path.js";
21
21
  import { apply as applyPolyfill } from "../../core/polyfill.js";
22
22
  import { parseNpmName } from "../../core/util.js";
23
23
  import { eventCliSession, telemetry } from "../../events/index.js";
24
+ import { createLoggingFromFlags } from "../flags.js";
24
25
  import { generate, parse, t, visit } from "./babel.js";
25
26
  import { ensureImport } from "./imports.js";
26
27
  import { wrapDefaultExport } from "./wrapper.js";
@@ -66,7 +67,7 @@ async function getRegistry() {
66
67
  return "https://registry.npmjs.org";
67
68
  }
68
69
  }
69
- async function add(names, { flags, logging }) {
70
+ async function add(names, { flags }) {
70
71
  var _a;
71
72
  telemetry.record(eventCliSession("add"));
72
73
  applyPolyfill();
@@ -109,10 +110,12 @@ async function add(names, { flags, logging }) {
109
110
  return;
110
111
  }
111
112
  const cwd = flags.root;
113
+ const logging = createLoggingFromFlags(flags);
112
114
  const integrationNames = names.map((name) => ALIASES.has(name) ? ALIASES.get(name) : name);
113
115
  const integrations = await validateIntegrations(integrationNames);
114
116
  let installResult = await tryToInstallIntegrations({ integrations, cwd, flags, logging });
115
- const root = pathToFileURL(cwd ? path.resolve(cwd) : process.cwd());
117
+ const rootPath = resolveRoot(cwd);
118
+ const root = pathToFileURL(rootPath);
116
119
  root.href = appendForwardSlash(root.href);
117
120
  switch (installResult) {
118
121
  case 1 /* updated */: {
@@ -170,7 +173,11 @@ async function add(names, { flags, logging }) {
170
173
  throw createPrettyError(new Error(`Unable to install dependencies`));
171
174
  }
172
175
  }
173
- const rawConfigPath = await resolveConfigPath({ cwd, flags, fs: fsMod });
176
+ const rawConfigPath = await resolveConfigPath({
177
+ root: rootPath,
178
+ configFile: flags.config,
179
+ fs: fsMod
180
+ });
174
181
  let configURL = rawConfigPath ? pathToFileURL(rawConfigPath) : void 0;
175
182
  if (configURL) {
176
183
  debug("add", `Found config at ${configURL}`);
@@ -1,8 +1,6 @@
1
1
  import type yargs from 'yargs-parser';
2
- import type { LogOptions } from '../../core/logger/core.js';
3
2
  interface BuildOptions {
4
3
  flags: yargs.Arguments;
5
- logging: LogOptions;
6
4
  }
7
- export declare function build({ flags, logging }: BuildOptions): Promise<void>;
5
+ export declare function build({ flags }: BuildOptions): Promise<void>;
8
6
  export {};
@@ -1,14 +1,24 @@
1
1
  import _build from "../../core/build/index.js";
2
- import { loadSettings } from "../load-settings.js";
3
- async function build({ flags, logging }) {
4
- const settings = await loadSettings({ cmd: "build", flags, logging });
5
- if (!settings)
2
+ import { printHelp } from "../../core/messages.js";
3
+ import { flagsToAstroInlineConfig } from "../flags.js";
4
+ async function build({ flags }) {
5
+ if ((flags == null ? void 0 : flags.help) || (flags == null ? void 0 : flags.h)) {
6
+ printHelp({
7
+ commandName: "astro build",
8
+ usage: "[...flags]",
9
+ tables: {
10
+ Flags: [
11
+ ["--drafts", `Include Markdown draft pages in the build.`],
12
+ ["--help (-h)", "See all available flags."]
13
+ ]
14
+ },
15
+ description: `Builds your site for deployment.`
16
+ });
6
17
  return;
7
- await _build(settings, {
8
- flags,
9
- logging,
10
- teardownCompiler: true,
11
- mode: flags.mode
18
+ }
19
+ const inlineConfig = flagsToAstroInlineConfig(flags);
20
+ await _build(inlineConfig, {
21
+ teardownCompiler: true
12
22
  });
13
23
  }
14
24
  export {
@@ -4,16 +4,12 @@ import fs from 'node:fs';
4
4
  import type { Arguments as Flags } from 'yargs-parser';
5
5
  import type { AstroSettings } from '../../@types/astro';
6
6
  import type { LogOptions } from '../../core/logger/core.js';
7
- import type { ProcessExit, SyncOptions } from '../../core/sync';
7
+ import type { syncInternal } from '../../core/sync';
8
8
  export type CheckPayload = {
9
9
  /**
10
10
  * Flags passed via CLI
11
11
  */
12
12
  flags: Flags;
13
- /**
14
- * Logging options
15
- */
16
- logging: LogOptions;
17
13
  };
18
14
  /**
19
15
  *
@@ -43,13 +39,12 @@ export declare enum CheckResult {
43
39
  *
44
40
  * @param {CheckPayload} options Options passed {@link AstroChecker}
45
41
  * @param {Flags} options.flags Flags coming from the CLI
46
- * @param {LogOptions} options.logging Logging options
47
42
  */
48
- export declare function check({ logging, flags }: CheckPayload): Promise<AstroChecker | undefined>;
43
+ export declare function check({ flags }: CheckPayload): Promise<AstroChecker | undefined>;
49
44
  type CheckerConstructor = {
50
45
  diagnosticChecker: AstroCheck;
51
46
  isWatchMode: boolean;
52
- syncCli: (settings: AstroSettings, options: SyncOptions) => Promise<ProcessExit>;
47
+ syncInternal: typeof syncInternal;
53
48
  settings: Readonly<AstroSettings>;
54
49
  logging: Readonly<LogOptions>;
55
50
  fileSystem: typeof fs;
@@ -62,7 +57,7 @@ type CheckerConstructor = {
62
57
  */
63
58
  export declare class AstroChecker {
64
59
  #private;
65
- constructor({ diagnosticChecker, isWatchMode, syncCli, settings, fileSystem, logging, }: CheckerConstructor);
60
+ constructor({ diagnosticChecker, isWatchMode, syncInternal, settings, fileSystem, logging, }: CheckerConstructor);
66
61
  /**
67
62
  * Check all `.astro` files once and then finishes the operation.
68
63
  */
@@ -9,9 +9,14 @@ import fs from "node:fs";
9
9
  import { join } from "node:path";
10
10
  import { fileURLToPath, pathToFileURL } from "node:url";
11
11
  import ora from "ora";
12
+ import { resolveConfig } from "../../core/config/config.js";
13
+ import { createNodeLogging } from "../../core/config/logging.js";
14
+ import { createSettings } from "../../core/config/settings.js";
12
15
  import { debug, info } from "../../core/logger/core.js";
13
16
  import { printHelp } from "../../core/messages.js";
14
- import { loadSettings } from "../load-settings.js";
17
+ import { eventCliSession, telemetry } from "../../events/index.js";
18
+ import { runHookConfigSetup } from "../../integrations/index.js";
19
+ import { flagsToAstroInlineConfig } from "../flags.js";
15
20
  import { printDiagnostic } from "./print.js";
16
21
  var CheckResult = /* @__PURE__ */ ((CheckResult2) => {
17
22
  CheckResult2[CheckResult2["ExitWithSuccess"] = 0] = "ExitWithSuccess";
@@ -20,7 +25,7 @@ var CheckResult = /* @__PURE__ */ ((CheckResult2) => {
20
25
  return CheckResult2;
21
26
  })(CheckResult || {});
22
27
  const ASTRO_GLOB_PATTERN = "**/*.astro";
23
- async function check({ logging, flags }) {
28
+ async function check({ flags }) {
24
29
  if (flags.help || flags.h) {
25
30
  printHelp({
26
31
  commandName: "astro check",
@@ -35,16 +40,18 @@ async function check({ logging, flags }) {
35
40
  });
36
41
  return;
37
42
  }
38
- const settings = await loadSettings({ cmd: "check", flags, logging });
39
- if (!settings)
40
- return;
43
+ const inlineConfig = flagsToAstroInlineConfig(flags);
44
+ const logging = createNodeLogging(inlineConfig);
45
+ const { userConfig, astroConfig } = await resolveConfig(inlineConfig, "check");
46
+ telemetry.record(eventCliSession("check", userConfig, flags));
47
+ const settings = createSettings(astroConfig, fileURLToPath(astroConfig.root));
41
48
  const checkFlags = parseFlags(flags);
42
49
  if (checkFlags.watch) {
43
50
  info(logging, "check", "Checking files in watch mode");
44
51
  } else {
45
52
  info(logging, "check", "Checking files");
46
53
  }
47
- const { syncCli } = await import("../../core/sync/index.js");
54
+ const { syncInternal } = await import("../../core/sync/index.js");
48
55
  const root = settings.config.root;
49
56
  const require2 = createRequire(import.meta.url);
50
57
  const diagnosticChecker = new AstroCheck(
@@ -54,7 +61,7 @@ async function check({ logging, flags }) {
54
61
  })
55
62
  );
56
63
  return new AstroChecker({
57
- syncCli,
64
+ syncInternal,
58
65
  settings,
59
66
  fileSystem: fs,
60
67
  logging,
@@ -65,7 +72,7 @@ async function check({ logging, flags }) {
65
72
  class AstroChecker {
66
73
  #diagnosticsChecker;
67
74
  #shouldWatch;
68
- #syncCli;
75
+ #syncInternal;
69
76
  #settings;
70
77
  #logging;
71
78
  #fs;
@@ -75,14 +82,14 @@ class AstroChecker {
75
82
  constructor({
76
83
  diagnosticChecker,
77
84
  isWatchMode,
78
- syncCli,
85
+ syncInternal,
79
86
  settings,
80
87
  fileSystem,
81
88
  logging
82
89
  }) {
83
90
  this.#diagnosticsChecker = diagnosticChecker;
84
91
  this.#shouldWatch = isWatchMode;
85
- this.#syncCli = syncCli;
92
+ this.#syncInternal = syncInternal;
86
93
  this.#logging = logging;
87
94
  this.#settings = settings;
88
95
  this.#fs = fileSystem;
@@ -131,7 +138,12 @@ class AstroChecker {
131
138
  * @param openDocuments Whether the operation should open all `.astro` files
132
139
  */
133
140
  async #checkAllFiles(openDocuments) {
134
- const processExit = await this.#syncCli(this.#settings, {
141
+ const syncSettings = await runHookConfigSetup({
142
+ settings: this.#settings,
143
+ logging: this.#logging,
144
+ command: "build"
145
+ });
146
+ const processExit = await this.#syncInternal(syncSettings, {
135
147
  logging: this.#logging,
136
148
  fs: this.#fs
137
149
  });
@@ -1,8 +1,6 @@
1
1
  import type yargs from 'yargs-parser';
2
- import { type LogOptions } from '../../core/logger/core.js';
3
2
  interface DevOptions {
4
3
  flags: yargs.Arguments;
5
- logging: LogOptions;
6
4
  }
7
- export declare function dev({ flags, logging }: DevOptions): Promise<import("../../core/dev/dev.js").DevServer | undefined>;
5
+ export declare function dev({ flags }: DevOptions): Promise<import("../../core/dev/dev.js").DevServer | undefined>;
8
6
  export {};
@@ -1,25 +1,29 @@
1
- import fs from "node:fs";
2
- import { resolveConfigPath, resolveFlags } from "../../core/config/index.js";
1
+ import { cyan } from "kleur/colors";
3
2
  import devServer from "../../core/dev/index.js";
4
- import { info } from "../../core/logger/core.js";
5
- import { handleConfigError, loadSettings } from "../load-settings.js";
6
- async function dev({ flags, logging }) {
7
- const settings = await loadSettings({ cmd: "dev", flags, logging });
8
- if (!settings)
3
+ import { printHelp } from "../../core/messages.js";
4
+ import { flagsToAstroInlineConfig } from "../flags.js";
5
+ async function dev({ flags }) {
6
+ if (flags.help || flags.h) {
7
+ printHelp({
8
+ commandName: "astro dev",
9
+ usage: "[...flags]",
10
+ tables: {
11
+ Flags: [
12
+ ["--port", `Specify which port to run on. Defaults to 3000.`],
13
+ ["--host", `Listen on all addresses, including LAN and public addresses.`],
14
+ ["--host <custom-address>", `Expose on a network IP address at <custom-address>`],
15
+ ["--open", "Automatically open the app in the browser on server start"],
16
+ ["--help (-h)", "See all available flags."]
17
+ ]
18
+ },
19
+ description: `Check ${cyan(
20
+ "https://docs.astro.build/en/reference/cli-reference/#astro-dev"
21
+ )} for more information.`
22
+ });
9
23
  return;
10
- const root = flags.root;
11
- const configFlag = resolveFlags(flags).config;
12
- const configFlagPath = configFlag ? await resolveConfigPath({ cwd: root, flags, fs }) : void 0;
13
- return await devServer(settings, {
14
- configFlag,
15
- configFlagPath,
16
- flags,
17
- logging,
18
- handleConfigError(e) {
19
- handleConfigError(e, { cmd: "dev", cwd: root, flags, logging });
20
- info(logging, "astro", "Continuing with previous valid configuration\n");
21
- }
22
- });
24
+ }
25
+ const inlineConfig = flagsToAstroInlineConfig(flags);
26
+ return await devServer(inlineConfig);
23
27
  }
24
28
  export {
25
29
  dev
@@ -0,0 +1,9 @@
1
+ import type { Arguments as Flags } from 'yargs-parser';
2
+ import type { AstroInlineConfig } from '../@types/astro.js';
3
+ import type { LogOptions } from '../core/logger/core.js';
4
+ export declare function flagsToAstroInlineConfig(flags: Flags): AstroInlineConfig;
5
+ /**
6
+ * The `logging` is usually created from an `AstroInlineConfig`, but some flows like `add`
7
+ * doesn't read the AstroConfig directly, so we create a `logging` object from the CLI flags instead.
8
+ */
9
+ export declare function createLoggingFromFlags(flags: Flags): LogOptions;
@@ -0,0 +1,40 @@
1
+ import { nodeLogDestination } from "../core/logger/node.js";
2
+ function flagsToAstroInlineConfig(flags) {
3
+ return {
4
+ // Inline-only configs
5
+ configFile: typeof flags.config === "string" ? flags.config : void 0,
6
+ mode: typeof flags.mode === "string" ? flags.mode : void 0,
7
+ logLevel: flags.verbose ? "debug" : flags.silent ? "silent" : void 0,
8
+ // Astro user configs
9
+ root: typeof flags.root === "string" ? flags.root : void 0,
10
+ site: typeof flags.site === "string" ? flags.site : void 0,
11
+ base: typeof flags.base === "string" ? flags.base : void 0,
12
+ markdown: {
13
+ drafts: typeof flags.drafts === "boolean" ? flags.drafts : void 0
14
+ },
15
+ server: {
16
+ port: typeof flags.port === "number" ? flags.port : void 0,
17
+ host: typeof flags.host === "string" || typeof flags.host === "boolean" ? flags.host : void 0,
18
+ open: typeof flags.open === "boolean" ? flags.open : void 0
19
+ },
20
+ experimental: {
21
+ assets: typeof flags.experimentalAssets === "boolean" ? flags.experimentalAssets : void 0
22
+ }
23
+ };
24
+ }
25
+ function createLoggingFromFlags(flags) {
26
+ const logging = {
27
+ dest: nodeLogDestination,
28
+ level: "info"
29
+ };
30
+ if (flags.verbose) {
31
+ logging.level = "debug";
32
+ } else if (flags.silent) {
33
+ logging.level = "silent";
34
+ }
35
+ return logging;
36
+ }
37
+ export {
38
+ createLoggingFromFlags,
39
+ flagsToAstroInlineConfig
40
+ };
package/dist/cli/index.js CHANGED
@@ -82,16 +82,9 @@ async function runCommand(cmd, flags) {
82
82
  return;
83
83
  }
84
84
  }
85
- const { enableVerboseLogging, nodeLogDestination } = await import("../core/logger/node.js");
86
- const logging = {
87
- dest: nodeLogDestination,
88
- level: "info"
89
- };
90
85
  if (flags.verbose) {
91
- logging.level = "debug";
86
+ const { enableVerboseLogging } = await import("../core/logger/node.js");
92
87
  enableVerboseLogging();
93
- } else if (flags.silent) {
94
- logging.level = "silent";
95
88
  }
96
89
  if (!process.env.NODE_ENV) {
97
90
  process.env.NODE_ENV = cmd === "dev" ? "development" : "production";
@@ -100,12 +93,12 @@ async function runCommand(cmd, flags) {
100
93
  case "add": {
101
94
  const { add } = await import("./add/index.js");
102
95
  const packages = flags._.slice(3);
103
- await add(packages, { flags, logging });
96
+ await add(packages, { flags });
104
97
  return;
105
98
  }
106
99
  case "dev": {
107
100
  const { dev } = await import("./dev/index.js");
108
- const server = await dev({ flags, logging });
101
+ const server = await dev({ flags });
109
102
  if (server) {
110
103
  return await new Promise(() => {
111
104
  });
@@ -114,12 +107,12 @@ async function runCommand(cmd, flags) {
114
107
  }
115
108
  case "build": {
116
109
  const { build } = await import("./build/index.js");
117
- await build({ flags, logging });
110
+ await build({ flags });
118
111
  return;
119
112
  }
120
113
  case "preview": {
121
114
  const { preview } = await import("./preview/index.js");
122
- const server = await preview({ flags, logging });
115
+ const server = await preview({ flags });
123
116
  if (server) {
124
117
  return await server.closed();
125
118
  }
@@ -127,7 +120,7 @@ async function runCommand(cmd, flags) {
127
120
  }
128
121
  case "check": {
129
122
  const { check } = await import("./check/index.js");
130
- const checkServer = await check({ flags, logging });
123
+ const checkServer = await check({ flags });
131
124
  if (checkServer) {
132
125
  if (checkServer.isWatchMode) {
133
126
  await checkServer.watch();
@@ -142,7 +135,7 @@ async function runCommand(cmd, flags) {
142
135
  }
143
136
  case "sync": {
144
137
  const { sync } = await import("./sync/index.js");
145
- const exitCode = await sync({ flags, logging });
138
+ const exitCode = await sync({ flags });
146
139
  return process.exit(exitCode);
147
140
  }
148
141
  }
@@ -1,10 +1,12 @@
1
1
  import * as colors from "kleur/colors";
2
2
  import { arch, platform } from "node:os";
3
3
  import whichPm from "which-pm";
4
- import { openConfig } from "../../core/config/index.js";
4
+ import { resolveConfig } from "../../core/config/index.js";
5
5
  import { ASTRO_VERSION } from "../../core/constants.js";
6
+ import { flagsToAstroInlineConfig } from "../flags.js";
6
7
  async function printInfo({ flags }) {
7
8
  var _a;
9
+ const inlineConfig = flagsToAstroInlineConfig(flags);
8
10
  const packageManager = await whichPm(process.cwd());
9
11
  let adapter = "Couldn't determine.";
10
12
  let integrations = [];
@@ -14,11 +16,7 @@ async function printInfo({ flags }) {
14
16
  console.log(`${colors.bold(label)}` + " ".repeat(padding) + `${colors.green(value)}`);
15
17
  }
16
18
  try {
17
- const { userConfig } = await openConfig({
18
- cwd: flags.root,
19
- flags,
20
- cmd: "info"
21
- });
19
+ const { userConfig } = await resolveConfig(inlineConfig, "info");
22
20
  if ((_a = userConfig.adapter) == null ? void 0 : _a.name) {
23
21
  adapter = userConfig.adapter.name;
24
22
  }
@@ -1,8 +1,6 @@
1
1
  import type yargs from 'yargs-parser';
2
- import type { LogOptions } from '../../core/logger/core.js';
3
2
  interface PreviewOptions {
4
3
  flags: yargs.Arguments;
5
- logging: LogOptions;
6
4
  }
7
- export declare function preview({ flags, logging }: PreviewOptions): Promise<import("../../@types/astro.js").PreviewServer | undefined>;
5
+ export declare function preview({ flags }: PreviewOptions): Promise<import("../../@types/astro.js").PreviewServer | undefined>;
8
6
  export {};
@@ -1,10 +1,26 @@
1
+ import { cyan } from "kleur/colors";
2
+ import { printHelp } from "../../core/messages.js";
1
3
  import previewServer from "../../core/preview/index.js";
2
- import { loadSettings } from "../load-settings.js";
3
- async function preview({ flags, logging }) {
4
- const settings = await loadSettings({ cmd: "preview", flags, logging });
5
- if (!settings)
4
+ import { flagsToAstroInlineConfig } from "../flags.js";
5
+ async function preview({ flags }) {
6
+ if ((flags == null ? void 0 : flags.help) || (flags == null ? void 0 : flags.h)) {
7
+ printHelp({
8
+ commandName: "astro preview",
9
+ usage: "[...flags]",
10
+ tables: {
11
+ Flags: [
12
+ ["--open", "Automatically open the app in the browser on server start"],
13
+ ["--help (-h)", "See all available flags."]
14
+ ]
15
+ },
16
+ description: `Starts a local server to serve your static dist/ directory. Check ${cyan(
17
+ "https://docs.astro.build/en/reference/cli-reference/#astro-preview"
18
+ )} for more information.`
19
+ });
6
20
  return;
7
- return await previewServer(settings, { flags, logging });
21
+ }
22
+ const inlineConfig = flagsToAstroInlineConfig(flags);
23
+ return await previewServer(inlineConfig);
8
24
  }
9
25
  export {
10
26
  preview
@@ -1,8 +1,6 @@
1
1
  import type yargs from 'yargs-parser';
2
- import type { LogOptions } from '../../core/logger/core.js';
3
2
  interface SyncOptions {
4
3
  flags: yargs.Arguments;
5
- logging: LogOptions;
6
4
  }
7
- export declare function sync({ flags, logging }: SyncOptions): Promise<import("../../core/sync/index.js").ProcessExit | undefined>;
5
+ export declare function sync({ flags }: SyncOptions): Promise<import("../../core/sync/index.js").ProcessExit>;
8
6
  export {};
@@ -1,11 +1,20 @@
1
- import fs from "node:fs";
2
- import { syncCli } from "../../core/sync/index.js";
3
- import { loadSettings } from "../load-settings.js";
4
- async function sync({ flags, logging }) {
5
- const settings = await loadSettings({ cmd: "sync", flags, logging });
6
- if (!settings)
7
- return;
8
- const exitCode = await syncCli(settings, { logging, fs, flags });
1
+ import { printHelp } from "../../core/messages.js";
2
+ import { sync as _sync } from "../../core/sync/index.js";
3
+ import { flagsToAstroInlineConfig } from "../flags.js";
4
+ async function sync({ flags }) {
5
+ if ((flags == null ? void 0 : flags.help) || (flags == null ? void 0 : flags.h)) {
6
+ printHelp({
7
+ commandName: "astro sync",
8
+ usage: "[...flags]",
9
+ tables: {
10
+ Flags: [["--help (-h)", "See all available flags."]]
11
+ },
12
+ description: `Generates TypeScript types for all Astro modules.`
13
+ });
14
+ return 0;
15
+ }
16
+ const inlineConfig = flagsToAstroInlineConfig(flags);
17
+ const exitCode = await _sync(inlineConfig);
9
18
  return exitCode;
10
19
  }
11
20
  export {
@@ -1,9 +1,12 @@
1
1
  import { collectErrorMetadata } from "../core/errors/dev/index.js";
2
+ import { isAstroConfigZodError } from "../core/errors/errors.js";
2
3
  import { createSafeError } from "../core/errors/index.js";
3
4
  import { debug } from "../core/logger/core.js";
4
5
  import { formatErrorMessage } from "../core/messages.js";
5
6
  import { eventError, telemetry } from "../events/index.js";
6
7
  async function throwAndExit(cmd, err) {
8
+ if (isAstroConfigZodError(err))
9
+ return;
7
10
  let telemetryPromise;
8
11
  let errorMessage;
9
12
  function exitWithErrorMessage() {
@@ -8,7 +8,7 @@ function getViteConfig(inlineConfig) {
8
8
  fs,
9
9
  { mergeConfig },
10
10
  { nodeLogDestination },
11
- { openConfig, createSettings },
11
+ { resolveConfig, createSettings },
12
12
  { createVite },
13
13
  { runHookConfigSetup, runHookConfigDone },
14
14
  { astroContentListenPlugin }
@@ -25,7 +25,7 @@ function getViteConfig(inlineConfig) {
25
25
  dest: nodeLogDestination,
26
26
  level: "info"
27
27
  };
28
- const { astroConfig: config } = await openConfig({ cmd });
28
+ const { astroConfig: config } = await resolveConfig({}, cmd);
29
29
  const settings = createSettings(config, inlineConfig.root);
30
30
  await runHookConfigSetup({ settings, command: cmd, logging });
31
31
  const viteConfig = await createVite(
@@ -3,13 +3,18 @@ export { deserializeManifest } from './common.js';
3
3
  export interface MatchOptions {
4
4
  matchNotFound?: boolean | undefined;
5
5
  }
6
+ export interface RenderErrorOptions {
7
+ routeData?: RouteData;
8
+ response?: Response;
9
+ status: 404 | 500;
10
+ }
6
11
  export declare class App {
7
12
  #private;
8
13
  constructor(manifest: SSRManifest, streaming?: boolean);
9
14
  set setManifest(newManifest: SSRManifest);
10
15
  set setManifestData(newManifestData: ManifestData);
11
16
  removeBase(pathname: string): string;
12
- match(request: Request, { matchNotFound }?: MatchOptions): RouteData | undefined;
17
+ match(request: Request, _opts?: MatchOptions): RouteData | undefined;
13
18
  render(request: Request, routeData?: RouteData, locals?: object): Promise<Response>;
14
19
  setCookieHeaders(response: Response): Generator<string, string[], unknown>;
15
20
  }