full site update
This commit is contained in:
181
node_modules/astro/dist/integrations/features-validation.js
generated
vendored
181
node_modules/astro/dist/integrations/features-validation.js
generated
vendored
@@ -1,20 +1,18 @@
|
||||
const STABLE = "stable";
|
||||
const DEPRECATED = "deprecated";
|
||||
const UNSUPPORTED = "unsupported";
|
||||
const EXPERIMENTAL = "experimental";
|
||||
const UNSUPPORTED_ASSETS_FEATURE = {
|
||||
supportKind: UNSUPPORTED,
|
||||
isSquooshCompatible: false,
|
||||
isSharpCompatible: false
|
||||
const AdapterFeatureStability = {
|
||||
STABLE: "stable",
|
||||
DEPRECATED: "deprecated",
|
||||
UNSUPPORTED: "unsupported",
|
||||
EXPERIMENTAL: "experimental",
|
||||
LIMITED: "limited"
|
||||
};
|
||||
function validateSupportedFeatures(adapterName, featureMap, config, adapterFeatures, logger) {
|
||||
function validateSupportedFeatures(adapterName, featureMap, settings, logger) {
|
||||
const {
|
||||
assets = UNSUPPORTED_ASSETS_FEATURE,
|
||||
serverOutput = UNSUPPORTED,
|
||||
staticOutput = UNSUPPORTED,
|
||||
hybridOutput = UNSUPPORTED,
|
||||
i18nDomains = UNSUPPORTED,
|
||||
envGetSecret = UNSUPPORTED
|
||||
serverOutput = AdapterFeatureStability.UNSUPPORTED,
|
||||
staticOutput = AdapterFeatureStability.UNSUPPORTED,
|
||||
hybridOutput = AdapterFeatureStability.UNSUPPORTED,
|
||||
i18nDomains = AdapterFeatureStability.UNSUPPORTED,
|
||||
envGetSecret = AdapterFeatureStability.UNSUPPORTED,
|
||||
sharpImageService = AdapterFeatureStability.UNSUPPORTED
|
||||
} = featureMap;
|
||||
const validationResult = {};
|
||||
validationResult.staticOutput = validateSupportKind(
|
||||
@@ -22,108 +20,117 @@ function validateSupportedFeatures(adapterName, featureMap, config, adapterFeatu
|
||||
adapterName,
|
||||
logger,
|
||||
"staticOutput",
|
||||
() => config?.output === "static"
|
||||
() => settings.buildOutput === "static"
|
||||
);
|
||||
validationResult.hybridOutput = validateSupportKind(
|
||||
hybridOutput,
|
||||
adapterName,
|
||||
logger,
|
||||
"hybridOutput",
|
||||
() => config?.output === "hybrid"
|
||||
() => settings.config.output == "static" && settings.buildOutput === "server"
|
||||
);
|
||||
validationResult.serverOutput = validateSupportKind(
|
||||
serverOutput,
|
||||
adapterName,
|
||||
logger,
|
||||
"serverOutput",
|
||||
() => config?.output === "server"
|
||||
() => settings.config?.output === "server" || settings.buildOutput === "server"
|
||||
);
|
||||
validationResult.assets = validateAssetsFeature(assets, adapterName, config, logger);
|
||||
if (config.i18n?.domains) {
|
||||
if (settings.config.i18n?.domains) {
|
||||
validationResult.i18nDomains = validateSupportKind(
|
||||
i18nDomains,
|
||||
adapterName,
|
||||
logger,
|
||||
"i18nDomains",
|
||||
() => {
|
||||
return config?.output === "server" && !config?.site;
|
||||
return settings.config?.output === "server" && !settings.config?.site;
|
||||
}
|
||||
);
|
||||
if (adapterFeatures?.functionPerRoute) {
|
||||
logger.error(
|
||||
"config",
|
||||
"The Astro feature `i18nDomains` is incompatible with the Adapter feature `functionPerRoute`"
|
||||
);
|
||||
}
|
||||
}
|
||||
if (config.experimental?.env) {
|
||||
validationResult.envGetSecret = validateSupportKind(
|
||||
envGetSecret,
|
||||
adapterName,
|
||||
logger,
|
||||
"astro:env getSecret",
|
||||
() => true
|
||||
);
|
||||
}
|
||||
validationResult.envGetSecret = validateSupportKind(
|
||||
envGetSecret,
|
||||
adapterName,
|
||||
logger,
|
||||
"astro:env getSecret",
|
||||
() => Object.keys(settings.config?.env?.schema ?? {}).length !== 0
|
||||
);
|
||||
validationResult.sharpImageService = validateSupportKind(
|
||||
sharpImageService,
|
||||
adapterName,
|
||||
logger,
|
||||
"sharp",
|
||||
() => settings.config?.image?.service?.entrypoint === "astro/assets/services/sharp"
|
||||
);
|
||||
return validationResult;
|
||||
}
|
||||
function unwrapSupportKind(supportKind) {
|
||||
if (!supportKind) {
|
||||
return void 0;
|
||||
}
|
||||
return typeof supportKind === "object" ? supportKind.support : supportKind;
|
||||
}
|
||||
function getSupportMessage(supportKind) {
|
||||
return typeof supportKind === "object" ? supportKind.message : void 0;
|
||||
}
|
||||
function getSupportMessageSuppression(supportKind) {
|
||||
return typeof supportKind === "object" ? supportKind.suppress : void 0;
|
||||
}
|
||||
function validateSupportKind(supportKind, adapterName, logger, featureName, hasCorrectConfig) {
|
||||
if (supportKind === STABLE) {
|
||||
const supportValue = unwrapSupportKind(supportKind);
|
||||
const message = getSupportMessage(supportKind);
|
||||
const suppress = getSupportMessageSuppression(supportKind);
|
||||
if (!supportValue) {
|
||||
return false;
|
||||
}
|
||||
if (supportValue === AdapterFeatureStability.STABLE) {
|
||||
return true;
|
||||
} else if (supportKind === DEPRECATED) {
|
||||
featureIsDeprecated(adapterName, logger, featureName);
|
||||
} else if (supportKind === EXPERIMENTAL) {
|
||||
featureIsExperimental(adapterName, logger, featureName);
|
||||
} else if (hasCorrectConfig()) {
|
||||
logFeatureSupport(adapterName, logger, featureName, supportValue, message, suppress);
|
||||
}
|
||||
if (hasCorrectConfig() && supportKind === UNSUPPORTED) {
|
||||
featureIsUnsupported(adapterName, logger, featureName);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
function logFeatureSupport(adapterName, logger, featureName, supportKind, adapterMessage, suppress) {
|
||||
if (!suppress) {
|
||||
switch (supportKind) {
|
||||
case AdapterFeatureStability.STABLE:
|
||||
break;
|
||||
case AdapterFeatureStability.DEPRECATED:
|
||||
logger.warn(
|
||||
"config",
|
||||
`The adapter ${adapterName} has deprecated its support for "${featureName}", and future compatibility is not guaranteed. The adapter may completely remove support for this feature without warning.`
|
||||
);
|
||||
break;
|
||||
case AdapterFeatureStability.EXPERIMENTAL:
|
||||
logger.warn(
|
||||
"config",
|
||||
`The adapter ${adapterName} provides experimental support for "${featureName}". You may experience issues or breaking changes until this feature is fully supported by the adapter.`
|
||||
);
|
||||
break;
|
||||
case AdapterFeatureStability.LIMITED:
|
||||
logger.warn(
|
||||
"config",
|
||||
`The adapter ${adapterName} has limited support for "${featureName}". Certain features may not work as expected.`
|
||||
);
|
||||
break;
|
||||
case AdapterFeatureStability.UNSUPPORTED:
|
||||
logger.error(
|
||||
"config",
|
||||
`The adapter ${adapterName} does not currently support the feature "${featureName}". Your project may not build correctly.`
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (adapterMessage && suppress !== "all") {
|
||||
logger.warn("adapter", adapterMessage);
|
||||
}
|
||||
}
|
||||
function featureIsUnsupported(adapterName, logger, featureName) {
|
||||
logger.error(
|
||||
"config",
|
||||
`The adapter ${adapterName} doesn't currently support the feature "${featureName}".`
|
||||
);
|
||||
}
|
||||
function featureIsExperimental(adapterName, logger, featureName) {
|
||||
logger.warn(
|
||||
"config",
|
||||
`The adapter ${adapterName} provides experimental support for "${featureName}". You may experience issues or breaking changes until this feature is fully supported by the adapter.`
|
||||
);
|
||||
}
|
||||
function featureIsDeprecated(adapterName, logger, featureName) {
|
||||
logger.warn(
|
||||
"config",
|
||||
`The adapter ${adapterName} has deprecated its support for "${featureName}", and future compatibility is not guaranteed. The adapter may completely remove support for this feature without warning.`
|
||||
);
|
||||
}
|
||||
const SHARP_SERVICE = "astro/assets/services/sharp";
|
||||
const SQUOOSH_SERVICE = "astro/assets/services/squoosh";
|
||||
function validateAssetsFeature(assets, adapterName, config, logger) {
|
||||
const {
|
||||
supportKind = UNSUPPORTED,
|
||||
isSharpCompatible = false,
|
||||
isSquooshCompatible = false
|
||||
} = assets;
|
||||
if (config?.image?.service?.entrypoint === SHARP_SERVICE && !isSharpCompatible) {
|
||||
logger.warn(
|
||||
null,
|
||||
`The currently selected adapter \`${adapterName}\` is not compatible with the image service "Sharp".`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (config?.image?.service?.entrypoint === SQUOOSH_SERVICE && !isSquooshCompatible) {
|
||||
logger.warn(
|
||||
null,
|
||||
`The currently selected adapter \`${adapterName}\` is not compatible with the image service "Squoosh".`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return validateSupportKind(supportKind, adapterName, logger, "assets", () => true);
|
||||
function getAdapterStaticRecommendation(adapterName) {
|
||||
return {
|
||||
"@astrojs/vercel/static": "Update your configuration to use `@astrojs/vercel/serverless` to unlock server-side rendering capabilities."
|
||||
}[adapterName];
|
||||
}
|
||||
export {
|
||||
AdapterFeatureStability,
|
||||
getAdapterStaticRecommendation,
|
||||
validateSupportedFeatures
|
||||
};
|
||||
|
Reference in New Issue
Block a user