update
This commit is contained in:
parent
65f3f2b019
commit
302af0f7b6
|
@ -1,26 +1,31 @@
|
||||||
|
// Node Modules
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
|
import fse from "fs-extra";
|
||||||
|
|
||||||
|
// Utils
|
||||||
import { createResolver, defineIntegration } from "astro-integration-kit";
|
import { createResolver, defineIntegration } from "astro-integration-kit";
|
||||||
import { corePlugins } from "astro-integration-kit/plugins";
|
import { corePlugins } from "astro-integration-kit/plugins";
|
||||||
import { AstroError } from "astro/errors";
|
import { AstroError } from "astro/errors";
|
||||||
import fse from "fs-extra";
|
|
||||||
import c from "picocolors";
|
|
||||||
import { loadEnv } from "vite";
|
import { loadEnv } from "vite";
|
||||||
import { GhostUserConfigSchema } from "./schemas/userconfig";
|
|
||||||
import latestVersion from "./utils/latestVersion";
|
import latestVersion from "./utils/latestVersion";
|
||||||
|
import c from "picocolors";
|
||||||
|
|
||||||
// Import External Integrations
|
// External Integrations
|
||||||
import sitemap from "@astrojs/sitemap";
|
import sitemap from "@astrojs/sitemap";
|
||||||
import robotsTxt from "astro-robots-txt";
|
import robotsTxt from "astro-robots-txt";
|
||||||
|
|
||||||
import ghostRSS from "./integrations/rssfeed";
|
// Internal Integrations
|
||||||
// Import Internal Integrations
|
|
||||||
import ghostOGImages from "./integrations/satoriog";
|
import ghostOGImages from "./integrations/satoriog";
|
||||||
|
import ghostRSS from "./integrations/rssfeed";
|
||||||
import ghostThemeProvider from "./integrations/themeprovider";
|
import ghostThemeProvider from "./integrations/themeprovider";
|
||||||
|
|
||||||
// Load environment variables
|
// Load environment variables
|
||||||
const ENV = loadEnv("all", process.cwd(), "CONTENT_API");
|
const ENV = loadEnv("all", process.cwd(), "CONTENT_API");
|
||||||
|
|
||||||
|
// Import User Configuration Zod Schema
|
||||||
|
import { GhostUserConfigSchema } from "./schemas/userconfig";
|
||||||
|
|
||||||
/** Astro-GhostCMS Integration
|
/** Astro-GhostCMS Integration
|
||||||
* @description This integration allows you to use GhostCMS as a headless CMS for your Astro project
|
* @description This integration allows you to use GhostCMS as a headless CMS for your Astro project
|
||||||
* @see https://astro-ghostcms.xyz for the most up-to-date documentation!
|
* @see https://astro-ghostcms.xyz for the most up-to-date documentation!
|
||||||
|
@ -34,14 +39,11 @@ export default defineIntegration({
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"astro:config:setup": ({
|
"astro:config:setup": ({
|
||||||
watchIntegration,
|
watchIntegration, hasIntegration, addIntegration,
|
||||||
hasIntegration,
|
addVirtualImports, addDts,
|
||||||
addIntegration,
|
injectRoute, logger,
|
||||||
addVirtualImports,
|
|
||||||
addDts,
|
|
||||||
injectRoute,
|
|
||||||
logger,
|
|
||||||
}) => {
|
}) => {
|
||||||
|
// Configure Loggers
|
||||||
const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS")));
|
const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS")));
|
||||||
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(
|
||||||
|
@ -59,9 +61,11 @@ export default defineIntegration({
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Setup Watch Integration for Hot Reload during DEV
|
||||||
watchIntegration(resolve());
|
watchIntegration(resolve());
|
||||||
GhostLogger.info("Initializing @matthiesenxyz/astro-ghostcms...");
|
GhostLogger.info("Initializing @matthiesenxyz/astro-ghostcms...");
|
||||||
|
|
||||||
|
// Set up verbose logging
|
||||||
const verbose = options.fullConsoleLogs;
|
const verbose = options.fullConsoleLogs;
|
||||||
|
|
||||||
// Check for GhostCMS environment variables
|
// Check for GhostCMS environment variables
|
||||||
|
@ -72,6 +76,7 @@ export default defineIntegration({
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ENV.CONTENT_API_KEY === undefined) {
|
if (ENV.CONTENT_API_KEY === undefined) {
|
||||||
GhostENVLogger.error(
|
GhostENVLogger.error(
|
||||||
c.bgRed(
|
c.bgRed(
|
||||||
|
@ -229,16 +234,20 @@ export default defineIntegration({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
"astro:config:done": ({ logger }) => {
|
"astro:config:done": ({ logger }) => {
|
||||||
|
// Configure Loggers
|
||||||
const GhostLogger = logger.fork(
|
const GhostLogger = logger.fork(
|
||||||
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.green(
|
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.green(
|
||||||
"CONFIG",
|
"CONFIG",
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Log Configuration Complete
|
||||||
GhostLogger.info(
|
GhostLogger.info(
|
||||||
c.bold(c.green("Integration Setup & Configuration Complete")),
|
c.bold(c.green("Integration Setup & Configuration Complete")),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
"astro:server:start": async ({ logger }) => {
|
"astro:server:start": async ({ logger }) => {
|
||||||
|
// Configure Loggers
|
||||||
const GhostLogger = logger.fork(
|
const GhostLogger = logger.fork(
|
||||||
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold(
|
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold(
|
||||||
c.green("DEV"),
|
c.green("DEV"),
|
||||||
|
@ -256,14 +265,19 @@ export default defineIntegration({
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check for updates
|
// Check for updates
|
||||||
|
|
||||||
|
// Get the latest version of Astro-GhostCMS
|
||||||
const currentNPMVersion = await latestVersion(
|
const currentNPMVersion = await latestVersion(
|
||||||
"@matthiesenxyz/astro-ghostcms",
|
"@matthiesenxyz/astro-ghostcms",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Get the local version of Astro-GhostCMS
|
||||||
const packageJson = await fse.readJson(
|
const packageJson = await fse.readJson(
|
||||||
path.resolve(fileURLToPath(import.meta.url), "../../package.json"),
|
path.resolve(fileURLToPath(import.meta.url), "../../package.json"),
|
||||||
);
|
);
|
||||||
const localVersion = packageJson.version;
|
const localVersion = packageJson.version;
|
||||||
|
|
||||||
|
// Log the version check
|
||||||
if (currentNPMVersion !== localVersion) {
|
if (currentNPMVersion !== localVersion) {
|
||||||
GhostUpdateLogger.warn(
|
GhostUpdateLogger.warn(
|
||||||
`\n${c.bgYellow(
|
`\n${c.bgYellow(
|
||||||
|
@ -292,11 +306,14 @@ export default defineIntegration({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"astro:build:done": ({ logger }) => {
|
"astro:build:done": ({ logger }) => {
|
||||||
|
// Configure Loggers
|
||||||
const GhostLogger = logger.fork(
|
const GhostLogger = logger.fork(
|
||||||
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold(
|
`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold(
|
||||||
c.green("BUILD"),
|
c.green("BUILD"),
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Log Build Complete
|
||||||
GhostLogger.info(
|
GhostLogger.info(
|
||||||
c.bold(c.magenta("Running Astro-GhostCMS in Production mode 🚀")),
|
c.bold(c.magenta("Running Astro-GhostCMS in Production mode 🚀")),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
import astroghostcms from "./astro-ghostcms.js";
|
import astroghostcms from "./astro-ghostcms";
|
||||||
|
|
||||||
export default astroghostcms;
|
export default astroghostcms;
|
||||||
|
|
Loading…
Reference in New Issue