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

Automate package name replacement in package.json #1

Open
sanjaysah101 opened this issue Jan 1, 2024 · 0 comments
Open

Automate package name replacement in package.json #1

sanjaysah101 opened this issue Jan 1, 2024 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@sanjaysah101
Copy link
Owner

Problem

Currently, the name field in the package.json file is static. When a user clones the boilerplate, they have to manually change the name field to their project's name. This can be a bit inconvenient and goes against the principle of a boilerplate, which should be ready to use out of the box.

Proposed Solution

We should automate the process of replacing the name field in the package.json file with the user's input name. This can be achieved by creating a setup script that prompts the user for their project name and automatically replaces the name field in the package.json file.

Here's a basic example of how this could be implemented in Node.js:

const fs = require('fs');
const prompt = require('prompt');

prompt.start();

prompt.get(['name'], function (err, result) {
    if (err) { return onErr(err); }
    let package = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
    package.name = result.name;
    fs.writeFileSync('./package.json', JSON.stringify(package, null, 2));
});

function onErr(err) {
    console.log(err);
    return 1;
}

This script uses the prompt module to ask the user for their project name, then reads the package.json file, replaces the name field with the user’s input, and writes the changes back to the package.json file.

Next Steps
Implement the setup script.
Update the README to include instructions for the setup script.
This will make the boilerplate more user-friendly and ready to use out of the box.

@sanjaysah101 sanjaysah101 added documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jan 1, 2024
@sanjaysah101 sanjaysah101 self-assigned this Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant