mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
add cloudflare workers support for all frontends (#366)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
31
apps/cli/src/utils/ts-morph.ts
Normal file
31
apps/cli/src/utils/ts-morph.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user