Skip to content

Commit

Permalink
feat(create-turbo): apply official-starter transform
Browse files Browse the repository at this point in the history
  • Loading branch information
turbobot-temp authored and maneike committed Oct 9, 2024
1 parent cd3a930 commit e8df28e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 38 deletions.
26 changes: 7 additions & 19 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,11 @@ export async function createProject(options: ProjectOptions) {

createEnvFile(currentDir);

try {
if (usePayload) {
console.log("🍸 Preparing Payload...");
await preparePayload();
console.log("🍸 Payload prepared.");
}

console.log("🍸 Installing Supabase...");
await installSupabase(currentDir);
console.log("🍸 Supabase installed.");

console.log("🍸 Prettifying files...");
await prettify();
console.log("🍸 Prettifying completed.");

prepareDrink(name);
} catch (error) {
console.error("An error occurred:", error);
}
if (usePayload) await preparePayload();

await installSupabase(currentDir);

await prettify();

prepareDrink(name);
}
2 changes: 1 addition & 1 deletion packages/core/utils/bar/prepareDrink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const prepareDrink = (name: string) => {
setTimeout(() => {
console.log("🍸 Adding gin and lime juice...");
setTimeout(() => {
console.log("🍸 Topping with", "\x1b[34mTonik\x1b[0m", "...");
console.log("🍸 Topping with", "\x1b[34mTonik\x1b[0m...");
setTimeout(() => {
console.log("🍸 Garnishing with lime wedge...");
setTimeout(() => {
Expand Down
26 changes: 10 additions & 16 deletions packages/core/utils/payload/preparePayloadConfig.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import fs from "fs";
import type { PathLike } from "fs";
import fs from "fs/promises";

export const preparePayloadConfig = async (configPath: fs.PathOrFileDescriptor) => {
export const preparePayloadConfig = async (configPath: PathLike) => {
console.log("🍸 Preparing payload.config.ts...");

// Read the payload.config.ts file
fs.readFile(configPath, "utf8", (err, data) => {
if (err) {
console.error("🍸 Error reading payload.config.ts", err);
return;
}
try {
// Read the payload.config.ts file
const data = await fs.readFile(configPath, "utf8");

// Use regex to find the "pool" object and append "schemaName: 'payload'" to the pool configuration
const updatedConfig = data.replace(
Expand All @@ -26,12 +24,8 @@ export const preparePayloadConfig = async (configPath: fs.PathOrFileDescriptor)
);

// Write the updated payload.config.ts back to the file
fs.writeFile(configPath, updatedConfig, (err) => {
if (err) {
console.error("🍸 Error writing to payload.config.ts", err);
} else {
console.log("🍸 payload.config.ts updated successfully!");
}
});
});
await fs.writeFile(configPath, updatedConfig);
} catch (err) {
console.error("🍸 Error during processing payload.config.ts", err);
}
};
4 changes: 2 additions & 2 deletions packages/core/utils/supabase/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import path from "path";
import fs from "fs";

export const installSupabase = async (destinationDirectory: string) => {
console.log("🍸 Installing supabase-js..."); // create supabase
console.log("🍸 Installing supabase-js...");
execSync(`supabase init`, { stdio: "inherit" });

console.log("🍸 Adding Supabase Files...");
const templateDirectory = path.join(__dirname, "../templates/supabase/files");

templateGenerator(supabaseFiles, templateDirectory, destinationDirectory);
// add ` - "supabase/**"` to pnpm-workspace.yaml
// add "supabase/**" to pnpm-workspace.yaml
const workspacePath = path.join(destinationDirectory, "pnpm-workspace.yaml");
const addSupabaseToWorkspace = ` - "supabase/**"`;
fs.appendFileSync(workspacePath, addSupabaseToWorkspace);
Expand Down

0 comments on commit e8df28e

Please sign in to comment.