1.1.1 โ€ข Published 4 years ago

@vestify/dev-kit v1.1.1

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

Vestify Dev Kit

Build Status Coverage Status Depfu Maintainability

What Is It?

@vestify/dev-kit is a set of common configurations and tools for the @vestify suite of projects. It abstracts away some of these common configurations and tools so that projects are cleaner and more focused while ensuring consistency in style across all projects housed under the @vestify scope.

Feel free to use @vestify/dev-kit outside of the @vestify scope if you would just like to focus on writing a TypeScript project with some sane defaults baked in and want to write minimal boilerplate/scaffolding/configuration.

You can also roll your own dev kit using some of the tools @vestify/dev-kit makes available as a module. The exported module provides some utilities that make setting up your own dev kit nearly effortless. Just write your bin files using the provided functions and point them to your own configuration specifics. (To see some examples on how to write your bin files, check out src/bin.)

Usage

Since @vestify/dev-kit has a few peerDependencies, you may want to run the install script with the -s flag as shown below in order to avoid getting bombarded with NPM warning messages.

For a brand-spanking-new project, create a folder then navigate into it using your shell of choice and initiate it using the following commands:

MacOS and Linux

git init
npm init -y && npm i -D -s @vestify/dev-kit && npx vestify-use-dev-kit

PowerShell

git init
npm init -y; npm i -D -s @vestify/dev-kit; npx vestify-use-dev-kit

vestify-use-dev-kit will perform the following (with your permission of course ๐Ÿ˜‰):

  1. ๐Ÿ“œ Ensure that your license is set to MIT
  2. Ensure that you have build ๐Ÿงฑ, publish ๐Ÿ“‘ and test ๐Ÿงช scripts which use the @vestify standard configuration
  3. โš™๏ธ Ensure that you have all the config files you need, and that they are pointed to the @vestify/dev-kit defaults if they can extend an existing configuration
  4. ๐Ÿ• Set up your husky Git hooks
  5. ๐Ÿ’„ Set up your prettier configuration for easy code formatting
  6. ๐Ÿ—„ Alphabetize your scripts section so they are easier to sift through
  7. ๐Ÿ“‚ Ensure you have a src directory to write your code in, and add index.ts, index.spec.ts, and testDrive.ts files if not already there
  8. ๐Ÿ‘ซ Install any peerDependencies of @vestify/dev-kit

Note that once Git hooks are in place, you will only be allowed to attempt to push to the master, development and releases branches if no remote repository is found. If a remote repository is found, you will not be able to make commits to the master, development or releases branches, so make sure to create a feature/FEATURE_NAME or hotfix/FIX_NAME branch before making your commits. To learn more about the branching strategy @vestify projects follow, read this article.

Some Things You Get for "Free"

Some packages will be installed as dependencies of @vestify/dev-kit so you do not need to install them directly into your project to use them as devDependencies. (Note that if you wish to use them as dependencies of code shipped from your project, you will need to add them as such.) Check the package.json of @vestify/dev-kit to see a full list of which dependencies are included, but at a glance here are a few that are useful in almost any project:

  • glob is great for finding files that match glob patterns
  • chai is the preferred assertions library of the Vestify team for JavaScript testing
  • chalk makes writing colorful and expressive console output a breeze
  • cross-env is handy for writing cross-platform scripts that require environment variables
  • lodash takes care of a lot of low-level JavaScript object handling
  • mocha is the preferred JavaScript test runner of the Vestify team
  • shx allows you to write Unix-y scripts that will run cross-platform

You also get some commonly used type definitions, such as:

  • @types/chai
  • @types/glob
  • @types/lodash
  • @types/mocha
  • @types/node

Updates

Whenever you update @vestify/dev-kit, you will need to run npx vestify-use-dev-kit again. At that point, you will be notified if any of your configuration settings do not match the updated defaults. You can choose which settings/files to opt in or out of.

Customization

@vestify/dev-kit provides you with some configuration files which you can extend to meet your specific project's needs. You can also always update your NPM scripts in package.json if you need more control.

The following files in your root directory can be modified as needed:

  • .eslintrc.json
  • .gitignore
  • .npmignore
  • README.md
  • tsconfig.build.json (Used for compilation so that you can omit .spec. and other files from your published module)
  • tsconfig.json (Used for dev so that you can have aliases in .spec. files)

Note that if @vestify/dev-kit detects that your local configuration does not match its defaults, it will notify you when running vestify-use-dev-kit but you can select n or just hit enter when prompted since by default it will not overwrite your settings.

Mocha Config

If you'd like to use your own Mocha configuration file, point your test scripts at it:

{
  "scripts": {
    "dev:test": "vestify-dev-test --mocha-config my.mocharc.js",
    "test": "vestify-test --mocha-config my.mocharc.js"
  }
}

Note that if you'd like to extend the default config, you can import it from the templates folder of this library and merge it with your own.

Istanbul Config

If you'd like to use your own Istanbul/NYC configuration file, point your coverage script and pre-push hook at it:

{
  "scripts": {
    "cover": "vestify-cover --nyc-config my.nyc.config.js"
  },
  "husky": {
    "hooks": {
      "pre-push": "cross-env FORCE_COLOR=1 vestify-git-push --nyc-config my.nyc.config.js"
    }
  }
}

Note that if you'd like to extend the default config, you can import it from the templates folder of this library and merge it with your own.