add cloudflare workers support for all frontends (#366)

This commit is contained in:
Aman Varshney
2025-07-05 15:51:26 +05:30
committed by GitHub
parent 6499f8cf04
commit d2674270a4
53 changed files with 1213 additions and 159 deletions

View File

@@ -23,6 +23,7 @@ export async function writeBtsConfig(
packageManager: projectConfig.packageManager,
dbSetup: projectConfig.dbSetup,
api: projectConfig.api,
webDeploy: projectConfig.webDeploy,
};
const baseContent = {
@@ -40,6 +41,7 @@ export async function writeBtsConfig(
packageManager: btsConfig.packageManager,
dbSetup: btsConfig.dbSetup,
api: btsConfig.api,
webDeploy: btsConfig.webDeploy,
};
let configContent = JSON.stringify(baseContent);
@@ -91,7 +93,7 @@ export async function readBtsConfig(
export async function updateBtsConfig(
projectDir: string,
updates: Partial<Pick<BetterTStackConfig, "addons">>,
updates: Partial<Pick<BetterTStackConfig, "addons" | "webDeploy">>,
): Promise<void> {
try {
const configPath = path.join(projectDir, BTS_CONFIG_FILE);

View File

@@ -101,6 +101,12 @@ export function displayConfig(config: Partial<ProjectConfig>) {
);
}
if (config.webDeploy !== undefined) {
configDisplay.push(
`${pc.blue("Web Deployment:")} ${String(config.webDeploy)}`,
);
}
if (configDisplay.length === 0) {
return pc.yellow("No configuration selected.");
}

View File

@@ -29,6 +29,7 @@ export function generateReproducibleCommand(config: ProjectConfig): string {
}
flags.push(`--db-setup ${config.dbSetup}`);
flags.push(`--web-deploy ${config.webDeploy}`);
flags.push(config.git ? "--git" : "--no-git");
flags.push(`--package-manager ${config.packageManager}`);
flags.push(config.install ? "--install" : "--no-install");

View File

@@ -0,0 +1,31 @@
import {
type ArrayLiteralExpression,
IndentationText,
type ObjectLiteralExpression,
Project,
QuoteKind,
SyntaxKind,
} from "ts-morph";
export const tsProject = new Project({
useInMemoryFileSystem: false,
skipAddingFilesFromTsConfig: true,
manipulationSettings: {
quoteKind: QuoteKind.Single,
indentationText: IndentationText.TwoSpaces,
},
});
export function ensureArrayProperty(
obj: ObjectLiteralExpression,
name: string,
): ArrayLiteralExpression {
return (obj
.getProperty(name)
?.getFirstDescendantByKind(SyntaxKind.ArrayLiteralExpression) ??
obj
.addPropertyAssignment({ name, initializer: "[]" })
.getFirstDescendantByKindOrThrow(
SyntaxKind.ArrayLiteralExpression,
)) as ArrayLiteralExpression;
}