Skip to content

Commit

Permalink
feat: work on todos
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lefebvre committed Aug 12, 2024
1 parent 31a3b3a commit da6b613
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/astro/src/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function createManifest(
i18n: manifest?.i18n,
checkOrigin: false,
middleware: manifest?.middleware ?? middleware ?? defaultMiddleware,
experimentalEnvGetSecretEnabled: false,
envGetSecretEnabled: false,
};
}

Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/core/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ export type SSRManifest = {
i18n: SSRManifestI18n | undefined;
middleware: MiddlewareHandler;
checkOrigin: boolean;
// TODO: remove experimental prefix
experimentalEnvGetSecretEnabled: boolean;
envGetSecretEnabled: boolean;
};

export type SSRManifestI18n = {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/base-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export abstract class Pipeline {
}
// In SSR, getSecret should fail by default. Setting it here will run before the
// adapter override.
if (callSetGetEnv && manifest.experimentalEnvGetSecretEnabled) {
if (callSetGetEnv && manifest.envGetSecretEnabled) {
setGetEnv(() => {
throw new AstroError(AstroErrorData.EnvUnsupportedGetSecret);
}, true);
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,6 @@ function createBuildManifest(
buildFormat: settings.config.build.format,
middleware,
checkOrigin: settings.config.security?.checkOrigin ?? false,
experimentalEnvGetSecretEnabled: false,
envGetSecretEnabled: false,
};
}
3 changes: 1 addition & 2 deletions packages/astro/src/core/build/plugins/plugin-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ function buildManifest(
buildFormat: settings.config.build.format,
checkOrigin: settings.config.security?.checkOrigin ?? false,
serverIslandNameMap: Array.from(settings.serverIslandNameMap),
experimentalEnvGetSecretEnabled:
settings.config.experimental.env !== undefined &&
envGetSecretEnabled:
(settings.adapter?.supportedAstroFeatures.envGetSecret ?? 'unsupported') !== 'unsupported',
};
}
8 changes: 3 additions & 5 deletions packages/astro/src/core/sync/setup-env-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ export async function setUpEnvTs({
filename: ACTIONS_TYPES_FILE,
meetsCondition: () => fs.existsSync(new URL(ACTIONS_TYPES_FILE, settings.dotAstroDir)),
},
];
if (settings.config.experimental.env) {
injectedTypes.push({
{
filename: ENV_TYPES_FILE,
});
}
},
];

if (fs.existsSync(envTsPath)) {
const initialEnvContents = await fs.promises.readFile(envTsPath, 'utf-8');
Expand Down
4 changes: 0 additions & 4 deletions packages/astro/src/env/vite-plugin-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import { type InvalidVariable, invalidVariablesToError } from './errors.js';
import type { EnvSchema } from './schema.js';
import { getEnvFieldType, validateEnvVariable } from './validators.js';

// TODO: rename experimentalWhatever in ssr manifest
// TODO: update integrations compat
// TODO: update adapters

interface AstroEnvPluginParams {
settings: AstroSettings;
mode: 'dev' | 'build' | string;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/integrations/features-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function validateSupportedFeatures(
adapterName,
logger,
'astro:env getSecret',
() => config?.experimental?.env !== undefined,
() => Object.keys(config?.env.schema ?? {}).length !== 0,
);

return validationResult;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-astro-server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function createDevelopmentManifest(settings: AstroSettings): SSRManifest
inlinedScripts: new Map(),
i18n: i18nManifest,
checkOrigin: settings.config.security?.checkOrigin ?? false,
experimentalEnvGetSecretEnabled: false,
envGetSecretEnabled: false,
middleware(_, next) {
return next();
},
Expand Down

0 comments on commit da6b613

Please sign in to comment.