From c0c96452a26a2fb56acbc99cc67fd1e808e66d0e Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 6 Sep 2024 16:42:29 +0000 Subject: [PATCH] [ci] format --- packages/astro/e2e/test-utils.js | 2 +- packages/astro/src/cli/create-key/index.ts | 40 ++++++++++++---------- packages/astro/src/core/encryption.ts | 6 ++-- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/packages/astro/e2e/test-utils.js b/packages/astro/e2e/test-utils.js index 7ae2e552a5..a2728f9627 100644 --- a/packages/astro/e2e/test-utils.js +++ b/packages/astro/e2e/test-utils.js @@ -15,7 +15,7 @@ for (let i = 0; i < testFiles.length; i++) { const file = testFiles[i]; if (file.endsWith('.test.js')) { // Port 4045 is an unsafe port in Chrome, so skip it. - if((4000 + i) === 4045) { + if (4000 + i === 4045) { i++; } testFileToPort.set(file, 4000 + i); diff --git a/packages/astro/src/cli/create-key/index.ts b/packages/astro/src/cli/create-key/index.ts index 55091d5059..d9b9f08ffd 100644 --- a/packages/astro/src/cli/create-key/index.ts +++ b/packages/astro/src/cli/create-key/index.ts @@ -1,31 +1,33 @@ -import { type Flags, flagsToAstroInlineConfig } from '../flags.js'; import { createNodeLogger } from '../../core/config/logging.js'; -import { createKey as createCryptoKey,encodeKey } from '../../core/encryption.js'; +import { createKey as createCryptoKey, encodeKey } from '../../core/encryption.js'; +import { type Flags, flagsToAstroInlineConfig } from '../flags.js'; interface CreateKeyOptions { flags: Flags; } export async function createKey({ flags }: CreateKeyOptions): Promise<0 | 1> { - try { - const inlineConfig = flagsToAstroInlineConfig(flags); - const logger = createNodeLogger(inlineConfig); + try { + const inlineConfig = flagsToAstroInlineConfig(flags); + const logger = createNodeLogger(inlineConfig); - const keyPromise = createCryptoKey(); - const key = await keyPromise; - const encoded = await encodeKey(key); + const keyPromise = createCryptoKey(); + const key = await keyPromise; + const encoded = await encodeKey(key); - logger.info('crypto', `Generated a key to encrypt props passed to Server islands. To reuse the same key across builds, set this value as ASTRO_KEY in an environment variable on your build server. + logger.info( + 'crypto', + `Generated a key to encrypt props passed to Server islands. To reuse the same key across builds, set this value as ASTRO_KEY in an environment variable on your build server. -ASTRO_KEY=${encoded}`); - } catch(err: unknown) { - if(err != null) { - // eslint-disable-next-line no-console - console.error(err.toString()); - } - return 1; - } - +ASTRO_KEY=${encoded}`, + ); + } catch (err: unknown) { + if (err != null) { + // eslint-disable-next-line no-console + console.error(err.toString()); + } + return 1; + } - return 0; + return 0; } diff --git a/packages/astro/src/core/encryption.ts b/packages/astro/src/core/encryption.ts index 7cfba99d94..253e5f3c97 100644 --- a/packages/astro/src/core/encryption.ts +++ b/packages/astro/src/core/encryption.ts @@ -42,8 +42,10 @@ export function hasEnvironmentKey(): boolean { */ export async function getEnvironmentKey(): Promise { // This should never happen, because we always check `hasEnvironmentKey` before this is called. - if(!hasEnvironmentKey()) { - throw new Error(`There is no environment key defined. If you see this error there is a bug in Astro.`) + if (!hasEnvironmentKey()) { + throw new Error( + `There is no environment key defined. If you see this error there is a bug in Astro.`, + ); } const encodedKey = getEncodedEnvironmentKey(); return decodeKey(encodedKey);