0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-17 22:44:24 -05:00

[ci] format

This commit is contained in:
Matthew Phillips 2024-09-06 16:42:29 +00:00 committed by astrobot-houston
parent bd1d4aaf82
commit c0c96452a2
3 changed files with 26 additions and 22 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -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);