4.7.2 ā€¢ Published 2 months ago

presetter v4.7.2

Weekly downloads
9
License
MIT
Repository
github
Last release
2 months ago

Logo

šŸ„šŸ» Setup build settings from a template, quick and right!

ā€¢ā€ƒ ā€ƒQuick Startā€ƒ ā€ƒā€¢ā€ƒ ā€ƒUsageā€ƒ ā€ƒā€¢ā€ƒ ā€ƒCustomizationā€ƒ ā€ƒā€¢

npm build maintainability coverage security dependencies license

Sharing configurations for building tools across projects is painful. How many time you've copied configs for babel, eslint, jest, typescript or the life cycle scripts in package.json? How many dev dependencies you have to install before you can kick start a project?

What's more, what if you want to update configs for all projects? :man_facepalming:

Presetter is a utility for setting up building tools for your project from a template. This means with just only two dev packages, namely this package and your favorite template preset, all essential development packages, such as typescript, eslint and jest, together with their configuration files provided by the preset, are automatically setup for you upon the project's initialization.


Quick Start

FULL DOCUMENTATION IS AVAILABLE HERE

  1. Bootstrap your project with a preset (e.g. presetter-preset-esm)
npx presetter use <preset package name>

That's. One command and you're set.

  1. Develop and run life cycle scripts provided by the preset

At this point, all development packages specified in the preset are installed, and now you can try to run some example life cycle scripts (e.g. run prepare) provided by the template.

Demo


Usage

Presetter is shipped with a command line interface, which has 4 commands

āš™ presetter: your preset configurator

Commands:
  presetter use <preset>  adopt the specified preset to the project
  presetter bootstrap     apply the specified preset to the project
  presetter run           run a template script
  presetter unset         remove all artifacts created by the preset

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]

Adopting a Preset

Note: No matter which situation you're in below, you don't need to bootstrap the preset as it's done automatically.

To a Fresh Project

To adopt a preset to an empty project, simple run presetter use <preset> on your project root. By running this command, it will

  • create a .presetterrc file under the root, detailing the preset setting,
  • add a presetter bootstrap command to the prepublish life cycle script in your package.json, and
  • bootstrap the preset at the end of the process.

To an Existing Project

To adopt a preset to an existing project with all the development and life cycle script setup, follow the steps below:

  1. Check if there's anything you want to keep your own version (e.g. eslintrc) instead of the one provided by the preset
  2. Remove any unnecessary dev dependencies, .config files or life cycle scripts
  3. Make sure presetter bootstrap will be executed in the post installation life cycle.
  4. Add your preset via presetter use <preset package name>

Bootstrapping Everything Provided by the Preset

A preset is merely a collection of configuration files and dependency declarations, they have to be installed to the adopting project and it's what presetter bootstrap for.

You would have to run presetter bootstrap manually

Running a Life Cycle Script

You can combine you local life cycle script definition with the template provided by the preset.

Simple run npx presetter run <task> or an equivalent short cut npx run <task>, or if you prefer to run the script in the conventional way, you can set life cycle scripts in package.json to something like

{
  "scripts": {
    "build": "run build",
    "coverage": "run coverage",
    "lint": "run lint",
    "prepare": "run prepare",
    "prepublishOnly": "run prepublishOnly",
    "release": "run release --",
    "test": "run test --",
    "watch": "run watch"
  }
}

When you run the command, presetter will combine the scripts, place them into a temporary package.json and run the task via npm run <task> as usual.

PROTIPS: Install presetter globally via npm install -g presetter and you can ignore the need to call npx all the time.


Customization

Presetter support customization in two ways.

Preset Customization

If your preset support customization, you can supply the customization parameter via the config field in .presetterrc. e.g. For presetter-preset-esm, you can adding an expression to .gitignore with the following in .presetterrc:

{
  "preset": "presetter-preset-esm",
  "config": {
    "gitignore": ["<pattern to ignore>"]
  }
}

Local Configuration

If you prefer your own local configuration than the one provided by the preset, just simply overwrite it. Presetter always respects any local version which is not symlinked to the preset.

4.7.2

2 months ago

4.7.1

2 months ago

4.7.0

2 months ago

4.6.0

3 months ago

4.5.0

4 months ago

4.4.1

7 months ago

4.4.0

7 months ago

4.3.1

7 months ago

4.4.2

6 months ago

4.3.0

7 months ago

4.2.0

8 months ago

4.1.0

10 months ago

4.0.1

10 months ago

4.0.0

10 months ago

4.1.2

9 months ago

4.1.1

10 months ago

3.5.5

1 year ago

3.5.4

1 year ago

3.5.3

1 year ago

3.5.2

1 year ago

3.5.1

1 year ago

3.5.0

2 years ago

3.4.0

2 years ago

3.3.0

2 years ago

3.2.0

2 years ago

3.4.1

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.2.0

3 years ago

1.3.0

3 years ago

1.1.0

3 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago