Fixed custom domain deployment bug

This commit is contained in:
Prozilla 2024-06-13 22:01:01 +02:00
parent ae6b8209b6
commit a396cbaf88
No known key found for this signature in database
GPG key ID: 5858DFE71CAF31EE
3 changed files with 9 additions and 4 deletions

View file

@ -11,9 +11,9 @@
"repository": "https://github.com/Prozilla/ProzillaOS",
"type": "module",
"scripts": {
"start": "vite --port 3000 --host",
"start": "vite",
"build": "tsc && vite build",
"serve": "vite preview --port 8080 --host",
"serve": "vite preview --port 8080",
"stage": "tsx scripts/stage",
"predeploy": "npm run build && npm run stage",
"deploy": "tsx scripts/deploy",

View file

@ -10,7 +10,6 @@ function deploy() {
void ghpages.publish(BUILD_DIR, {
repo: REPO_URL,
cname: DOMAIN,
message: COMMIT_MESSAGE
}, (error) => {
if (error == null)

View file

@ -3,12 +3,13 @@ import { APP_DESCRIPTIONS, APP_NAMES, APPS } from "../src/config/apps.config";
import { ANSI } from "../src/config/apps/terminal.config";
import { NAME, TAG_LINE } from "../src/config/branding.config";
import { WALLPAPERS } from "../src/config/desktop.config";
import { BASE_URL, BUILD_DIR } from "../src/config/deploy.config";
import { BASE_URL, BUILD_DIR, DOMAIN } from "../src/config/deploy.config";
const PATHS = {
sitemapXml: BUILD_DIR + "/sitemap.xml",
robotsTxt: BUILD_DIR + "/robots.txt",
indexHtml: BUILD_DIR + "/index.html",
cname: BUILD_DIR + "/CNAME",
};
function generateSitemapXml() {
@ -53,6 +54,10 @@ Disallow:
Sitemap: ${sitemapUrl}`;
}
function generateCname() {
return DOMAIN;
}
function generateTemplate(html: string) {
const baseUrlRegex = /(?<=")https?:\/\/[a-z0-9-]+(\.)([a-zA-Z0-9-]+(\.))*[a-z]{2,3}\/(?=.*")/gi;
html = html.replaceAll(baseUrlRegex, BASE_URL);
@ -121,6 +126,7 @@ function stage() {
const files: [string, () => string][] = [
[PATHS.sitemapXml, generateSitemapXml],
[PATHS.robotsTxt, generateRobotsTxt],
[PATHS.cname, generateCname],
];
files.forEach(([path, generateContent]) => {