several bug fixes

This commit is contained in:
Aman Varshney
2025-03-29 18:09:36 +05:30
parent bf0625ce08
commit b0e3432554
12 changed files with 304 additions and 65 deletions

View File

@@ -1,7 +1,7 @@
import path from "node:path";
import fs from "fs-extra";
import { PKG_ROOT } from "../constants";
import type { PackageManager, ProjectAddons } from "../types";
import type { PackageManager, ProjectAddons, ProjectFrontend } from "../types";
import { addPackageDependency } from "../utils/add-package-deps";
import { setupTauri } from "./tauri-setup";
@@ -9,14 +9,17 @@ export async function setupAddons(
projectDir: string,
addons: ProjectAddons[],
packageManager: PackageManager,
frontends: ProjectFrontend[],
) {
const hasWebFrontend = frontends.includes("web");
// if (addons.includes("docker")) {
// await setupDocker(projectDir);
// }
if (addons.includes("pwa")) {
if (addons.includes("pwa") && hasWebFrontend) {
await setupPwa(projectDir);
}
if (addons.includes("tauri")) {
if (addons.includes("tauri") && hasWebFrontend) {
await setupTauri(projectDir, packageManager);
}
if (addons.includes("biome")) {
@@ -89,6 +92,10 @@ async function setupPwa(projectDir: string) {
const clientPackageDir = path.join(projectDir, "apps/web");
if (!(await fs.pathExists(clientPackageDir))) {
return;
}
addPackageDependency({
dependencies: ["vite-plugin-pwa"],
devDependencies: ["@vite-pwa/assets-generator"],

View File

@@ -71,6 +71,7 @@ export async function createProject(options: ProjectConfig): Promise<string> {
options.examples,
options.orm,
options.auth,
options.frontend,
);
await setupEnvironmentVariables(projectDir, options);
@@ -78,7 +79,12 @@ export async function createProject(options: ProjectConfig): Promise<string> {
await initializeGit(projectDir, options.git);
if (options.addons.length > 0) {
await setupAddons(projectDir, options.addons, options.packageManager);
await setupAddons(
projectDir,
options.addons,
options.packageManager,
options.frontend,
);
}
await updatePackageConfigurations(projectDir, options);

View File

@@ -1,15 +1,20 @@
import path from "node:path";
import fs from "fs-extra";
import { PKG_ROOT } from "../constants";
import type { ProjectOrm } from "../types";
import type { ProjectFrontend, ProjectOrm } from "../types";
export async function setupExamples(
projectDir: string,
examples: string[],
orm: ProjectOrm,
auth: boolean,
frontend: ProjectFrontend[] = ["web"],
): Promise<void> {
if (examples.includes("todo")) {
const hasWebFrontend = frontend.includes("web");
const webAppExists = await fs.pathExists(path.join(projectDir, "apps/web"));
if (examples.includes("todo") && hasWebFrontend && webAppExists) {
await setupTodoExample(projectDir, orm, auth);
} else {
await cleanupTodoFiles(projectDir, orm);

View File

@@ -13,6 +13,10 @@ export async function setupTauri(
const s = spinner();
const clientPackageDir = path.join(projectDir, "apps/web");
if (!(await fs.pathExists(clientPackageDir))) {
return;
}
try {
s.start("Setting up Tauri desktop app support...");