cleanup and OCD some code...
This commit is contained in:
parent
e0372288ed
commit
5b4c3e3268
|
@ -56,6 +56,9 @@
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
"test:ci": "vitest run --coverage.enabled --coverage.reporter='text-summary'"
|
"test:ci": "vitest run --coverage.enabled --coverage.reporter='text-summary'"
|
||||||
},
|
},
|
||||||
|
"enginesStrict": {
|
||||||
|
"node": ">=18.19.0"
|
||||||
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"astro": ">=4.4.1"
|
"astro": ">=4.4.1"
|
||||||
},
|
},
|
||||||
|
|
|
@ -50,19 +50,25 @@ export default defineIntegration({
|
||||||
}) => {
|
}) => {
|
||||||
// Set up verbose logging
|
// Set up verbose logging
|
||||||
const verbose = options.verbose;
|
const verbose = options.verbose;
|
||||||
|
|
||||||
// Configure Loggers
|
// Configure Loggers
|
||||||
const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS")));
|
const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS")));
|
||||||
|
|
||||||
|
// Configure ENV Logger
|
||||||
const GhostENVLogger = logger.fork(
|
const GhostENVLogger = logger.fork(
|
||||||
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
|
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
|
||||||
"ENV Check",
|
"ENV Check",
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Configure Integration Loggers & verbose logging
|
// Configure Integration Loggers & verbose logging
|
||||||
const GhostIntegrationLogger = logger.fork(
|
const GhostIntegrationLogger = logger.fork(
|
||||||
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
|
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(
|
||||||
"Integrations",
|
"Integrations",
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Log Info Helper
|
||||||
const intLogInfo = (message:string) => {
|
const intLogInfo = (message:string) => {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
GhostIntegrationLogger.info(message);
|
GhostIntegrationLogger.info(message);
|
||||||
|
@ -75,12 +81,46 @@ export default defineIntegration({
|
||||||
"Router",
|
"Router",
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Log Route Info Helper
|
||||||
const routeLogInfo = (message:string) => {
|
const routeLogInfo = (message:string) => {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
GhostRouteLogger.info(message);
|
GhostRouteLogger.info(message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Local Integration Helper
|
||||||
|
const localIntegration = (enabled: boolean, name: string, integration: AstroIntegration) => {
|
||||||
|
if (enabled) {
|
||||||
|
addIntegration(integration);
|
||||||
|
} else {
|
||||||
|
intLogInfo(c.gray(`${name} integration is disabled`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check External Integration Helper
|
||||||
|
const checkIntegration = (name: string, integration: AstroIntegration) => {
|
||||||
|
if (!hasIntegration(name)) {
|
||||||
|
intLogInfo(c.bold(c.magenta(`Adding ${c.blue(name)} integration`)));
|
||||||
|
addIntegration(integration);
|
||||||
|
} else {
|
||||||
|
intLogInfo(c.gray(`${name} integration already exists, skipping...`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inject Route Helper
|
||||||
|
const routeHelper = (routename: string, enabled: boolean, pattern: string, entrypoint: string) => {
|
||||||
|
if (enabled) {
|
||||||
|
routeLogInfo(c.bold(c.cyan(`Setting up ${routename} route`)));
|
||||||
|
injectRoute({
|
||||||
|
pattern: pattern,
|
||||||
|
entrypoint: `${name}${entrypoint}`,
|
||||||
|
prerender: true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
routeLogInfo(c.gray(`${routename} route is disabled, Skipping...`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Watch Integration for Hot Reload during DEV
|
// Setup Watch Integration for Hot Reload during DEV
|
||||||
watchIntegration(resolve());
|
watchIntegration(resolve());
|
||||||
|
@ -143,39 +183,6 @@ export default defineIntegration({
|
||||||
c.bold(c.magenta("Configuring Enabled Integrations")),
|
c.bold(c.magenta("Configuring Enabled Integrations")),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Local Integration Helper
|
|
||||||
const localIntegration = (enabled: boolean, name: string, integration: AstroIntegration) => {
|
|
||||||
if (enabled) {
|
|
||||||
addIntegration(integration);
|
|
||||||
} else {
|
|
||||||
intLogInfo(c.gray(`${name} integration is disabled`));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check External Integration Helper
|
|
||||||
const checkIntegration = (name: string, integration: AstroIntegration) => {
|
|
||||||
if (!hasIntegration(name)) {
|
|
||||||
intLogInfo(c.bold(c.magenta(`Adding ${c.blue(name)} integration`)));
|
|
||||||
addIntegration(integration);
|
|
||||||
} else {
|
|
||||||
intLogInfo(c.gray(`${name} integration already exists, skipping...`));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inject Route Helper
|
|
||||||
const routeHelper = (routename: string, enabled: boolean, pattern: string, entrypoint: string) => {
|
|
||||||
if (enabled) {
|
|
||||||
routeLogInfo(c.bold(c.cyan(`Setting up ${routename} route`)));
|
|
||||||
injectRoute({
|
|
||||||
pattern: pattern,
|
|
||||||
entrypoint: `${name}${entrypoint}`,
|
|
||||||
prerender: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
routeLogInfo(c.gray(`${routename} route is disabled, Skipping...`));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
localIntegration(
|
localIntegration(
|
||||||
!options.ThemeProvider?.disableThemeProvider,
|
!options.ThemeProvider?.disableThemeProvider,
|
||||||
"Theme Provider",
|
"Theme Provider",
|
||||||
|
|
Loading…
Reference in New Issue