mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
[ci] format
This commit is contained in:
parent
9284a68ecf
commit
18ed0813f6
3 changed files with 10 additions and 7 deletions
|
@ -2179,7 +2179,7 @@ export interface AstroUserConfig {
|
||||||
* Whether or not to validate secrets on the server when starting the dev server or running a build.
|
* Whether or not to validate secrets on the server when starting the dev server or running a build.
|
||||||
*
|
*
|
||||||
* By default, only public variables are validated on the server when starting the dev server or a build, and private variables are validated at runtime only. If enabled, private variables will also be checked on start. This is useful in some continuous integration (CI) pipelines to make sure all your secrets are correctly set before deploying.
|
* By default, only public variables are validated on the server when starting the dev server or a build, and private variables are validated at runtime only. If enabled, private variables will also be checked on start. This is useful in some continuous integration (CI) pipelines to make sure all your secrets are correctly set before deploying.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* // astro.config.mjs
|
* // astro.config.mjs
|
||||||
* import { defineConfig, envField } from "astro/config"
|
* import { defineConfig, envField } from "astro/config"
|
||||||
|
|
|
@ -90,8 +90,8 @@ export const ASTRO_CONFIG_DEFAULTS = {
|
||||||
globalRoutePriority: false,
|
globalRoutePriority: false,
|
||||||
rewriting: false,
|
rewriting: false,
|
||||||
env: {
|
env: {
|
||||||
validateSecrets: false
|
validateSecrets: false,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
} satisfies AstroUserConfig & { server: { open: boolean } };
|
} satisfies AstroUserConfig & { server: { open: boolean } };
|
||||||
|
|
||||||
|
@ -529,7 +529,10 @@ export const AstroConfigSchema = z.object({
|
||||||
env: z
|
env: z
|
||||||
.object({
|
.object({
|
||||||
schema: EnvSchema.optional(),
|
schema: EnvSchema.optional(),
|
||||||
validateSecrets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.env.validateSecrets)
|
validateSecrets: z
|
||||||
|
.boolean()
|
||||||
|
.optional()
|
||||||
|
.default(ASTRO_CONFIG_DEFAULTS.experimental.env.validateSecrets),
|
||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
.optional(),
|
.optional(),
|
||||||
|
|
|
@ -13,12 +13,12 @@ describe('astro:env secret variables', () => {
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await devServer?.stop();
|
await devServer?.stop();
|
||||||
if (process.env.KNOWN_SECRET) {
|
if (process.env.KNOWN_SECRET) {
|
||||||
delete process.env.KNOWN_SECRET
|
delete process.env.KNOWN_SECRET;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works in dev', async () => {
|
it('works in dev', async () => {
|
||||||
process.env.KNOWN_SECRET = '5'
|
process.env.KNOWN_SECRET = '5';
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
root: './fixtures/astro-env-server-secret/',
|
root: './fixtures/astro-env-server-secret/',
|
||||||
});
|
});
|
||||||
|
@ -80,7 +80,7 @@ describe('astro:env secret variables', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
assert.fail()
|
assert.fail();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
assert.equal(error instanceof Error, true);
|
assert.equal(error instanceof Error, true);
|
||||||
assert.equal(error.title, 'Invalid Environment Variables');
|
assert.equal(error.title, 'Invalid Environment Variables');
|
||||||
|
|
Loading…
Add table
Reference in a new issue