Skip to content

Commit f8c9de1

Browse files
committed
perf(cli_plugin): ✨ Enhance monorepo handling and improve validation logic
1 parent acf38b0 commit f8c9de1

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/create-vitnode-app/src/create/create-vitnode.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,20 @@ export const createVitNode = async ({
125125
}
126126
}
127127

128-
if (mode === "apiMonorepo" || monorepo) {
128+
if (mode === "apiMonorepo" || (monorepo && mode !== "singleApp")) {
129129
await cp(join(templatePath, "monorepo"), root, {
130130
recursive: true,
131131
});
132+
} else if (monorepo && mode === "singleApp") {
133+
// Copy only the necessary monorepo files, excluding the api folder
134+
await copyFile(
135+
join(templatePath, "monorepo", "turbo.json"),
136+
join(root, "turbo.json"),
137+
);
138+
await copyFile(
139+
join(templatePath, "monorepo", ".gitignore_template"),
140+
join(root, ".gitignore_template"),
141+
);
132142
}
133143

134144
if (eslint) {

packages/create-vitnode-app/src/plugin/validation.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { program } from "commander";
2-
import { existsSync, readFileSync } from "node:fs";
2+
import { existsSync } from "node:fs";
3+
import { mkdir, readFile } from "node:fs/promises";
34
import { basename, join, resolve } from "node:path";
45
import color from "picocolors";
56

@@ -54,7 +55,7 @@ export const validationProjectForPlugin = async (projectPath: string) => {
5455

5556
try {
5657
const packageJson: PackageJSON = JSON.parse(
57-
readFileSync(packageJsonPath, "utf-8"),
58+
await readFile(packageJsonPath, "utf-8"),
5859
);
5960

6061
if (!packageJson.packageManager) {
@@ -107,6 +108,11 @@ export const validationProjectForPlugin = async (projectPath: string) => {
107108
process.exit(1);
108109
}
109110

111+
// Check that plugins directory exists
112+
if (!existsSync(pluginsDir)) {
113+
await mkdir(pluginsDir, { recursive: true });
114+
}
115+
110116
// Verify the plugins dir is writeable
111117
if (!(await isWriteable(pluginsDir))) {
112118
console.error(

0 commit comments

Comments
 (0)