Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make project starting when site is removed via create-app #565

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion admin/src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export function createConfig() {
apiUrl: environmentVariables.API_URL,
adminUrl: environmentVariables.ADMIN_URL,
previewUrl: environmentVariables.PREVIEW_URL,
sitesConfig: JSON.parse(environmentVariables.PUBLIC_SITE_CONFIGS) as PublicSiteConfig[],
sitesConfig: (environmentVariables.PUBLIC_SITE_CONFIGS
? JSON.parse(environmentVariables.PUBLIC_SITE_CONFIGS)
: [{ scope: { domain: "main", languages: ["en"] } }]) as PublicSiteConfig[],
buildDate: environmentVariables.BUILD_DATE,
buildNumber: environmentVariables.BUILD_NUMBER,
commitSha: environmentVariables.COMMIT_SHA,
Expand Down
2 changes: 1 addition & 1 deletion api/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function createConfig(processEnv: NodeJS.ProcessEnv) {
cdn: {
originCheckSecret: envVars.CDN_ORIGIN_CHECK_SECRET,
},
siteConfigs: envVars.PRIVATE_SITE_CONFIGS,
siteConfigs: envVars.PRIVATE_SITE_CONFIGS || [{ scope: { domain: "main", languages: ["en"] } }],
sitePreviewSecret: envVars.SITE_PREVIEW_SECRET,
};
}
Expand Down
1 change: 1 addition & 0 deletions api/src/config/environment-variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export class EnvironmentVariables {

@IsArray()
@Transform(({ value }) => JSON.parse(value))
@IsOptional()
PRIVATE_SITE_CONFIGS: PrivateSiteConfig[];

@IsArray()
Expand Down
17 changes: 17 additions & 0 deletions create-app/site-configs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// This file is meant to be deleted in the process of creating a data-driven application

export type ContentScope = {
domain: string;
language: string;
};

export type PublicSiteConfig = {
url: "";
preloginEnabled: false;
scope: {
domain: string;
languages: string[];
};
};

export type PrivateSiteConfig = PublicSiteConfig;
6 changes: 5 additions & 1 deletion create-app/src/scripts/remove-site/removeSite.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as fs from "fs";

import { deleteFilesAndFolders } from "../../util/deleteFilesAndFolders";
import { removeReferenceInFile } from "../../util/removeReferenceInFile";
import { runEslintFix } from "../../util/runEslintFix";
Expand All @@ -16,7 +18,9 @@ function removeSiteReferences(verbose: boolean) {
}

export function removeSite(verbose: boolean) {
deleteFilesAndFolders(["site"], verbose);
deleteFilesAndFolders(["site", "site-configs", ".env.site-configs.tpl"], verbose);
fs.copyFile("./create-app/site-configs.d.ts", "./admin/src/site-configs.d.ts", (err) => console.log);
fs.copyFile("./create-app/site-configs.d.ts", "./api/src/site-configs.d.ts", (err) => console.log);
removeSiteReferences(verbose);
runEslintFix(verbose);
}
Loading