mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
[ci] format
This commit is contained in:
parent
bd1d4aaf82
commit
c0c96452a2
3 changed files with 26 additions and 22 deletions
|
@ -15,7 +15,7 @@ for (let i = 0; i < testFiles.length; i++) {
|
||||||
const file = testFiles[i];
|
const file = testFiles[i];
|
||||||
if (file.endsWith('.test.js')) {
|
if (file.endsWith('.test.js')) {
|
||||||
// Port 4045 is an unsafe port in Chrome, so skip it.
|
// Port 4045 is an unsafe port in Chrome, so skip it.
|
||||||
if((4000 + i) === 4045) {
|
if (4000 + i === 4045) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
testFileToPort.set(file, 4000 + i);
|
testFileToPort.set(file, 4000 + i);
|
||||||
|
|
|
@ -1,31 +1,33 @@
|
||||||
import { type Flags, flagsToAstroInlineConfig } from '../flags.js';
|
|
||||||
import { createNodeLogger } from '../../core/config/logging.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 {
|
interface CreateKeyOptions {
|
||||||
flags: Flags;
|
flags: Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createKey({ flags }: CreateKeyOptions): Promise<0 | 1> {
|
export async function createKey({ flags }: CreateKeyOptions): Promise<0 | 1> {
|
||||||
try {
|
try {
|
||||||
const inlineConfig = flagsToAstroInlineConfig(flags);
|
const inlineConfig = flagsToAstroInlineConfig(flags);
|
||||||
const logger = createNodeLogger(inlineConfig);
|
const logger = createNodeLogger(inlineConfig);
|
||||||
|
|
||||||
const keyPromise = createCryptoKey();
|
const keyPromise = createCryptoKey();
|
||||||
const key = await keyPromise;
|
const key = await keyPromise;
|
||||||
const encoded = await encodeKey(key);
|
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}`);
|
ASTRO_KEY=${encoded}`,
|
||||||
} catch(err: unknown) {
|
);
|
||||||
if(err != null) {
|
} catch (err: unknown) {
|
||||||
// eslint-disable-next-line no-console
|
if (err != null) {
|
||||||
console.error(err.toString());
|
// eslint-disable-next-line no-console
|
||||||
}
|
console.error(err.toString());
|
||||||
return 1;
|
}
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,10 @@ export function hasEnvironmentKey(): boolean {
|
||||||
*/
|
*/
|
||||||
export async function getEnvironmentKey(): Promise<CryptoKey> {
|
export async function getEnvironmentKey(): Promise<CryptoKey> {
|
||||||
// This should never happen, because we always check `hasEnvironmentKey` before this is called.
|
// This should never happen, because we always check `hasEnvironmentKey` before this is called.
|
||||||
if(!hasEnvironmentKey()) {
|
if (!hasEnvironmentKey()) {
|
||||||
throw new Error(`There is no environment key defined. If you see this error there is a bug in Astro.`)
|
throw new Error(
|
||||||
|
`There is no environment key defined. If you see this error there is a bug in Astro.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const encodedKey = getEncodedEnvironmentKey();
|
const encodedKey = getEncodedEnvironmentKey();
|
||||||
return decodeKey(encodedKey);
|
return decodeKey(encodedKey);
|
||||||
|
|
Loading…
Add table
Reference in a new issue