
Security News
AI Agent Lands PRs in Major OSS Projects, Targets Maintainers via Cold Outreach
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.
generate-package
Advanced tools
[Generate] a package.json from a pre-defined or user-defined template. This generator can be used from the command line when globally installed, or as a plugin or sub-generator in your own generator.
Generate a package.json from a pre-defined or user-defined template. This generator can be used from the command line when globally installed, or as a plugin or sub-generator in your own generator.
(TOC generated by verb using markdown-toc)
Generate is a command line tool and developer framework for scaffolding out new GitHub projects using generators and tasks.
Answers to prompts and the user's environment can be used to determine the templates, directories, files and contents to build. Support for gulp, base and assemble plugins, and much more.
For more information:
Installing the CLI
To run the package generator from the command line, you'll need to install Generate globally first. You can do that now with the following command:
$ npm install --global generate
This adds the gen command to your system path, allowing it to be run from any directory.
Install generate-package
Install this module with the following command:
$ npm install --global generate-package
You should now be able to run generate-package with the following command:
$ gen package
What will happen?
Running $ gen package will run the generator's default task, which will:
Conflict detection
This generator will prompt you for feedback before overwrite existing files. You can set the destination to a new directory if you want to avoid the prompts, or avoid accidentally overwriting files with unintentional answers => 'Oops! I meant "no! Don't overwrite!!!"'.
What you should see in the terminal
If completed successfully, you should see both starting and finished events in the terminal, like the following:
[00:44:21] starting ...
...
[00:44:22] finished ✔
If you do not see one or both of those events, please let us know about it.
To see a general help menu and available commands for Generate's CLI, run:
$ gen help
--dest, -d: set the destination directory to use for generated files--no-hints: Don't use hints in prompts (except for global data, like author.name)Generators use tasks for flow control. Tasks are run by passing the name of the task to run after the generator name, delimited by a comma.
Example
For instance, the following will run generator foo, task bar:
$ gen foo:bar
^ ^
generator task
Default task
When a task name is not explicitly passed on the command line, Generate's CLI will run the default task.
Create a new package.json file, same as the raw task, but also normalizes the result using normalize-pkg.
Example
$ gen package:new
Generate a package.json file in the cwd. To use a different template, run the package:choose task, or pass the name on the -t or --template flag.
Example
$ gen package:raw
Generate a temporary package.json file in the cwd for dev, tests, etc. All of the fields in this file are pre-populated with bogus data.
Example
$ gen package:dev
Prompts the user to choose the template to use for generating a package.json file to the working directory, or specified -d | --dest.
Example
$ gen package:choose
Merge data to be used for hints onto the context.
Example
$ gen package:package-hints
Visit Generate's documentation for tasks.
Generate supports running multiple generators at once. The following generator(s) work well with generate-package:
Run generate-dest before generate-package to prompt for the destination directory to use for generated files.
$ gen dest package
Example

Use generate-package as a plugin in your own generator.
Install with npm:
$ npm install --save generate-package
When used as a plugin, tasks from generate-package are added to your generator's instance.
module.exports = function(app) {
app.use(require('generate-package'));
// do generator stuff
};
Running tasks
You can now run any tasks from generate-package as if they were part of your own generator.
module.exports = function(app) {
app.use(require('generate-package'));
app.task('foo', function(cb) {
// do task stuff
cb();
});
// run the `mit` task from `generate-package`
app.task('default', ['foo', 'mit']);
};
When registered as a generator, tasks from generate-package are added to the "namespace" you give to the generator.
module.exports = function(app) {
app.register('foo', require('generate-package'));
// generate
};
Running tasks
Pass the names of one or more tasks to run to the .generate method, prefixed with the namespace of the sub-generator (foo, in our example):
Examples
Run the bar task from generator foo:
module.exports = function(app) {
app.register('foo', require('generate-package'));
app.generate('foo:bar', function(err) {
if (err) console.log(err);
});
};
Wrap the call to .generate in a task, so it can be run on demand:
module.exports = function(app) {
app.register('foo', require('generate-package'));
app.task('bar', function(cb) {
app.generate('foo:bar', cb);
});
};
More information
Visit the generator docs to learn more about creating, installing, using and publishing generators.
The following instructions can be used to override settings in generate-package. Visit the Generate documentation to learn about other ways to override defaults.
To customize the destination directory, install generate-dest globally, then in the command line prefix dest before any other generator names.
For example, the following will prompt you for the destination path to use, then pass the result to generate-package:
$ gen dest package
You can override a template by adding a template of the same name to the templates directory in user home.
For example, to override the foo.tmpl template, add a template at the following path ~/generate/templates/foo.tmpl, where ~/ is the user-home directory that os.homedir() resolves to on your system.
package.json, .git… [more](https://github.com/generate/generate-readme) | [homepage](https://github.com/generate/generate-readme "Generate a README.md using answers to prompts and data from the environment, likepackage.json,.git` config, etc. This generator can be run by command line if Generate is installed globally, or you can use this as a plugin or sub-generator in your own")Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb-generate-readme, v0.1.29, on August 09, 2016.
FAQs
Generate a package.json from a pre-defined or user-defined template. This generator can be used from the command line when globally installed, or as a plugin or sub-generator in your own generator.
We found that generate-package demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.

Research
/Security News
Chrome extension CL Suite by @CLMasters neutralizes 2FA for Facebook and Meta Business accounts while exfiltrating Business Manager contact and analytics data.

Security News
After Matplotlib rejected an AI-written PR, the agent fired back with a blog post, igniting debate over AI contributions and maintainer burden.