summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/itchy-monkeys-fail.md5
-rw-r--r--packages/astro/src/cli/add/index.ts2
-rw-r--r--packages/astro/src/cli/db/index.ts2
-rw-r--r--packages/astro/src/cli/info/index.ts2
-rw-r--r--packages/astro/src/cli/preferences/index.ts2
-rw-r--r--packages/astro/src/core/preview/index.ts2
6 files changed, 14 insertions, 1 deletions
diff --git a/.changeset/itchy-monkeys-fail.md b/.changeset/itchy-monkeys-fail.md
new file mode 100644
index 000000000..5e638e5da
--- /dev/null
+++ b/.changeset/itchy-monkeys-fail.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Fixes an issue where some astro commands failed if the astro config file or an integration used the global `crypto` object.
diff --git a/packages/astro/src/cli/add/index.ts b/packages/astro/src/cli/add/index.ts
index cd8ffd2a8..13782aaf1 100644
--- a/packages/astro/src/cli/add/index.ts
+++ b/packages/astro/src/cli/add/index.ts
@@ -99,10 +99,10 @@ async function getRegistry(): Promise<string> {
export async function add(names: string[], { flags }: AddOptions) {
ensureProcessNodeEnv('production');
+ applyPolyfill();
const inlineConfig = flagsToAstroInlineConfig(flags);
const { userConfig } = await resolveConfig(inlineConfig, 'add');
telemetry.record(eventCliSession('add', userConfig));
- applyPolyfill();
if (flags.help || names.length === 0) {
printHelp({
commandName: 'astro add',
diff --git a/packages/astro/src/cli/db/index.ts b/packages/astro/src/cli/db/index.ts
index 8b45e88e0..95d6f4045 100644
--- a/packages/astro/src/cli/db/index.ts
+++ b/packages/astro/src/cli/db/index.ts
@@ -3,12 +3,14 @@ import { createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js';
import { getPackage } from '../install-package.js';
import { resolveConfig } from '../../core/config/config.js';
import type { AstroConfig } from '../../@types/astro.js';
+import { apply as applyPolyfill } from '../../core/polyfill.js';
type DBPackage = {
cli: (args: { flags: Arguments; config: AstroConfig }) => unknown;
};
export async function db({ flags }: { flags: Arguments }) {
+ applyPolyfill();
const logger = createLoggerFromFlags(flags);
const getPackageOpts = { skipAsk: flags.yes || flags.y, cwd: flags.root };
const dbPackage = await getPackage<DBPackage>('@astrojs/db', logger, getPackageOpts, []);
diff --git a/packages/astro/src/cli/info/index.ts b/packages/astro/src/cli/info/index.ts
index c6586b28d..8275d409c 100644
--- a/packages/astro/src/cli/info/index.ts
+++ b/packages/astro/src/cli/info/index.ts
@@ -8,6 +8,7 @@ import type { AstroConfig, AstroUserConfig } from '../../@types/astro.js';
import { resolveConfig } from '../../core/config/index.js';
import { ASTRO_VERSION } from '../../core/constants.js';
import { flagsToAstroInlineConfig } from '../flags.js';
+import { apply as applyPolyfill } from '../../core/polyfill.js';
interface InfoOptions {
flags: yargs.Arguments;
@@ -47,6 +48,7 @@ export async function getInfoOutput({
}
export async function printInfo({ flags }: InfoOptions) {
+ applyPolyfill();
const { userConfig } = await resolveConfig(flagsToAstroInlineConfig(flags), 'info');
const output = await getInfoOutput({ userConfig, print: true });
diff --git a/packages/astro/src/cli/preferences/index.ts b/packages/astro/src/cli/preferences/index.ts
index e66f9083a..686e0854e 100644
--- a/packages/astro/src/cli/preferences/index.ts
+++ b/packages/astro/src/cli/preferences/index.ts
@@ -16,6 +16,7 @@ import { createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js';
import { flattie } from 'flattie';
import { formatWithOptions } from 'node:util';
import { collectErrorMetadata } from '../../core/errors/dev/utils.js';
+import { apply as applyPolyfill } from '../../core/polyfill.js';
interface PreferencesOptions {
flags: yargs.Arguments;
@@ -45,6 +46,7 @@ export async function preferences(
value: string | undefined,
{ flags }: PreferencesOptions
): Promise<number> {
+ applyPolyfill();
if (!isValidSubcommand(subcommand) || flags?.help || flags?.h) {
msg.printHelp({
commandName: 'astro preferences',
diff --git a/packages/astro/src/core/preview/index.ts b/packages/astro/src/core/preview/index.ts
index 5d6adc0c6..d34faf3a2 100644
--- a/packages/astro/src/core/preview/index.ts
+++ b/packages/astro/src/core/preview/index.ts
@@ -12,6 +12,7 @@ import { createSettings } from '../config/settings.js';
import createStaticPreviewServer from './static-preview-server.js';
import { getResolvedHostForHttpServer } from './util.js';
import { ensureProcessNodeEnv } from '../util.js';
+import { apply as applyPolyfills } from '../polyfill.js';
/**
* Starts a local server to serve your static dist/ directory. This command is useful for previewing
@@ -20,6 +21,7 @@ import { ensureProcessNodeEnv } from '../util.js';
* @experimental The JavaScript API is experimental
*/
export default async function preview(inlineConfig: AstroInlineConfig): Promise<PreviewServer> {
+ applyPolyfills();
ensureProcessNodeEnv('production');
const logger = createNodeLogger(inlineConfig);
const { userConfig, astroConfig } = await resolveConfig(inlineConfig ?? {}, 'preview');