diff options
author | 2024-09-06 16:42:29 +0000 | |
---|---|---|
committer | 2024-09-06 16:42:29 +0000 | |
commit | c0c96452a26a2fb56acbc99cc67fd1e808e66d0e (patch) | |
tree | 0950afb6e9dd4cd45c99a423ce433edbcd2fcb88 | |
parent | bd1d4aaf8262187b4f132d7fe0365902131ddf1a (diff) | |
download | astro-c0c96452a26a2fb56acbc99cc67fd1e808e66d0e.tar.gz astro-c0c96452a26a2fb56acbc99cc67fd1e808e66d0e.tar.zst astro-c0c96452a26a2fb56acbc99cc67fd1e808e66d0e.zip |
[ci] format
-rw-r--r-- | packages/astro/e2e/test-utils.js | 2 | ||||
-rw-r--r-- | packages/astro/src/cli/create-key/index.ts | 40 | ||||
-rw-r--r-- | 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 7ae2e552a..a2728f962 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 55091d505..d9b9f08ff 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 7cfba99d9..253e5f3c9 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<CryptoKey> { // 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); |