Skip to content

Automate package name replacement in package.json #1

@sanjaysah101

Description

@sanjaysah101

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.

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions