![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
generator-projectsetup
Advanced tools
A yeoman generator to setup projects based on a remote config
A yeoman generator to set up projects based on a remote config. The config will be hosted and maintained separately in another git repository. That means you don't need to stick to a single purpose generator and can create a customized one based on your needs.
The projectsetup generator depends on the yeoman-generator
in version 4.x. Read the API documentation for v4.x for supported features.
At first, you need to install yeoman.
npm install -g yo
Then install the projectsetup generator.
npm install -g generator-projectsetup
Create a directory for your new app.
mkdir my-new-project
cd my-new-project/
Generate your project and follow the prompts from your config.
yo projectsetup
You can pass options into the generator. These are the existing options:
option | description |
---|---|
--dir [/path/to/config] | Use this option to bypass the checkout process of the remote config and use a local version from your file system. |
--branch [name] | Set the branch that should be used instead of main . |
A configuration is located in a git repository. To run the projectsetup generator, each remote config needs a projectsetup.config.js
file. This is the entry point for the generator. It contains the settings for tasks
and routes
that describes a project setup. The outline of the config file looks like this:
module.exports = {
tasks: [ /* define tasks here */ ],
routes: { /* define routes here */ },
};
A task is described using an object which needs at least a unique key
and a name
value. The key
will be used to reference a task within the routes
later on. The name
will be used as displayable choices by the user who's executing the generator.
A task basically only makes sense when it contains some executable code. This code can be defined in an entry
. An entry
is a javascript file relatively to the config file, that exposes asynchronous functions as hooks. These hooks are beforeAll
, run
and afterAll
.
module.exports.beforeAll = async (params) => {
/* implement hook */
};
module.exports.run = async (params) => {
/* implement hook */
};
module.exports.afterAll = async (params) => {
/* implement hook */
};
The generator will call these functions (if defined) by each task that is relevant depending on the route of the user decisions. The properties of the params object, that is passed into each function call are:
property | description |
---|---|
config | The merged configuration, based on the user answers of all tasks. |
generator | The reference to the yeoman generator. This instance contains the yeoman api functions that can be used to implement the custom code for each task. |
dir | The location where the config code is located after a git clone. |
task | The corresponding task definition form the config file. |
todos | The list of task definitions based on the route of decisions. |
Each task can additionally prompt the user for more input that is required to fulfill the task or to customize the output. The input will be received in each hook using the config
property (see definition above). To prompt the user for input, the generator uses inquirer and supports all available prompt types that are defined in the questions
property.
A task entry can use external dependencies that will be downloaded and installed during the startup of a config. If a repository contains a package.json
and has dependencies listed (not dev dependencies), then the generator will install these and they will be importable in your code.
The tasks
array inside the config file contains all task definitions. Dependencies of different tasks are described in the routes
object. An example tasks definition can look like this:
module.exports = {
tasks = [
{
key: 'meal',
name: 'Order a meal',
entry: './tasks/meal.js',
questions: [
{
type: 'list',
name: 'foodGenre',
message: 'Where to order?',
choices: ['salat', 'pizza', 'burger', 'sushi'],
default: 'salat',
},
],
},
{
key: 'drink',
name: 'Order a drink',
entry: './tasks/drink.js',
},
{
key: 'soft-drink',
name: 'Soft drink',
entry: './tasks/soft-drink.js',
questions: [
{
type: 'checkbox',
name: 'softDrink',
message: 'Which soft drink?',
choices: ['coke', 'limo', 'soda', 'energy'],
},
],
},
{
key: 'alcoholic-drink',
name: 'With alcohol',
entry: './tasks/alcoholic-drink.js',
questions: [
{
type: 'list',
name: 'alcoholicDrink',
message: 'Which alcohol drink?',
choices: ['rum', 'wodka', 'gin', 'whisky'],
},
{
type: 'confirm',
name: 'withCocktailUmbrella',
message: 'Add a cocktail umbrella?',
default: true,
},
],
},
{
key: 'fruits',
name: 'Fruits',
entry: './tasks/fruits.js',
},
],
routes: { /* defined routes in the "routes" section */ },
};
The routes
object describes the decision tree, that the user can travel along. Each object is defined using a message
and a "handler". There are currently these handlers available:
oneOf
- "single choice" implementation. The user needs to select one entry.manyOf
- "multiple choice" implementation. The user can select more than one entry.An entry of these handlers uses a key
property to refer to a task definition. The value must match with a key
property value of an existing task. To nest a route and create a tree, this object takes a new routes
property and creates a recursive object structure. An example routes definition can look like this:
module.exports = {
tasks = [ /* defined tasks from the section above */ ],
routes: {
message: 'What to order',
oneOf: [
{
key: 'meal',
},
{
key: 'drink',
routes: {
message: 'What kind of drink',
oneOf: [
{
key: 'soft-drink',
},
{
key: 'alcoholic-drink',
routes: {
message: 'Mix it with',
manyOf: [
{
key: 'soft-drink'
},
{
key: 'fruits',
},
],
},
},
],
},
},
],
},
};
Install using:
git clone git@github.com:schorfES/generator-projectsetup.git
nvm install
npm install
npm link
Run locally linked generator:
yo projectsetup "git@github.com:your-username/your-projectconfig.git"
Run the generator without cloning a remote repo:
yo projectsetup --dir /path/to/local/config
Copyright (c) 2020
Licensed under the MIT license.
FAQs
A yeoman generator to setup projects based on a remote config
The npm package generator-projectsetup receives a total of 0 weekly downloads. As such, generator-projectsetup popularity was classified as not popular.
We found that generator-projectsetup 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.