Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(examples): replace pnpm in readme #6747

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/create-turbo/src/commands/create/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { isDefaultExample } from "../../utils/isDefaultExample";
import * as prompts from "./prompts";
import type { CreateCommandArgument, CreateCommandOptions } from "./types";
import { updateCommandsInREADME } from "./updateCommandsInREADME";
DependerKumarSoni marked this conversation as resolved.
Show resolved Hide resolved

const { turboGradient, turboLoader, info, error, warn } = logger;

Expand Down Expand Up @@ -92,6 +93,16 @@
skipTransforms,
});

const selectedPackageManager = selectedPackageManagerDetails.name;
if (selectedPackageManager !== "pnpm") {
DependerKumarSoni marked this conversation as resolved.
Show resolved Hide resolved
updateCommandsInREADME(selectedPackageManager)
.then(() => {
info(`README updated for ${selectedPackageManager} commands.`);
})
.catch((error) => {

Check failure on line 102 in packages/create-turbo/src/commands/create/index.ts

View workflow job for this annotation

GitHub Actions / Formatting

'error' is already declared in the upper scope on line 25 column 43
console.error("Unable to update README. Error: ", error);

Check failure on line 103 in packages/create-turbo/src/commands/create/index.ts

View workflow job for this annotation

GitHub Actions / Formatting

Unexpected console statement
});
}
if (packageManager && opts.skipTransforms) {
warn(
"--skip-transforms conflicts with <package-manager>. The package manager argument will be ignored."
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const fs = require("fs").promises;

Check warning on line 1 in packages/create-turbo/src/commands/create/updateCommandsInREADME.js

View workflow job for this annotation

GitHub Actions / Formatting

Prefer `node:fs` over `fs`
DependerKumarSoni marked this conversation as resolved.
Show resolved Hide resolved

const filePath = "../../../../../examples/basic/README.md";
DependerKumarSoni marked this conversation as resolved.
Show resolved Hide resolved

async function updateCommandsInREADME(selectedPackageManager) {
try {
// Read the content of the file
let data = await fs.readFile(filePath, "utf8");

// Replace all occurrences of 'pnpm' with selectedPackageManager
data = data.replace(/\bpnpm\b/g, `${selectedPackageManager} run`);
DependerKumarSoni marked this conversation as resolved.
Show resolved Hide resolved

// Write the updated content back to the file
await fs.writeFile(filePath, data, "utf8");

console.log(

Check failure on line 16 in packages/create-turbo/src/commands/create/updateCommandsInREADME.js

View workflow job for this annotation

GitHub Actions / Formatting

Unexpected console statement
DependerKumarSoni marked this conversation as resolved.
Show resolved Hide resolved
`pnpm commands replaced with ${selectedPackageManager} commands successfully.`
);
} catch (err) {
console.error("Error:", err.message);

Check failure on line 20 in packages/create-turbo/src/commands/create/updateCommandsInREADME.js

View workflow job for this annotation

GitHub Actions / Formatting

Unexpected console statement
}
}

module.exports = {
updateCommandsInREADME,
};

// Example usage:
// updateCommandsInREADME("pnpm");
Loading