0.1.29 • Published 6 years ago

moe-scripts v0.1.29

Weekly downloads
8
License
MIT
Repository
github
Last release
6 years ago

moe-scripts

Commitizen friendly

Description

CLI toolbox for common scripts for JavaScript / TypeScript projects. Inspired by "Tools without config" and kcd-scripts

Synopsis

  1. Create a project:
    • npm init my-project
    • If TypeScript: add types into package.json such as:
      • { "types": "lib/index" }
  2. Install:
    • npm install --save-dev moe-scripts
  3. Use scripts:
    • npm run build -- --watch
    • npm run build:doc
    • npm run validate
    • npm run commit
    • npm run release
    • ... etc.

Beware

Build yours using script-helper.

Instead of using this toolbox directly, consider creating yours using script-helper. This library is an example usage for script-helper and not meant for general use.

If it fits you, fork it, because it may change from version to version according to needs of author.

Problem

There are lots of configuration and boilerplate to start and maintain a JavaScript project. It is very tiresome to update libraries and configurations within multiple projects. See "Tools without config"

Solution

This toolkit is provided as an npm module and every configuration for linting, testing, building and more are initialized with a single command and updated simply updating a single npm package.

Configuration

This toolkit exposes a bin called moe-scripts. All scripts are stored in lib/scripts and all configurations are stored either in lib/config or in root of the library.

Toolkit decide whether a project is a TypeScript project or JavaScript project by looking types entry in package.json.

moe-scripts init is automatically executed after package install and creates configuration files and entries in package.json if they do not exist. See init script below.

All scripts can be further refined used arguments related to used tool within that script. It is mostly avoided to provide extra besides original ones of the tool parameters if really not necessary.

Overriding Configuration

Most of the configuration can be extended by native extend mechanism of the related library. Those which cannot be extended such as .gitignore or can be extended but behaves according to location of extended file such as tsconfig.json are used with symbolic links pointing to a file in this toolkit.

All of the configuration can be overridden.

This can be a very helpful way to make editor integration work for tools like ESLint which require project-based ESLint configuration to be present to work.

ESLint

Create an .eslintrc with the contents of:

{"extends": "./node_modules/moe-scripts/eslint.js"}

Note: for now, you'll have to include an .eslintignore in your project until this eslint issue is resolved.

TSLint

It is extendible via:

{ "extends": "moe-scripts/tslint.json" }

Note: tslint.json is not a symbolic link in source root. There is no safe place to link it, because lib is not always available in source and src is not available in npm package.

Babel

Or, for babel, a .babelrc with:

{"presets": ["moe-scripts/babel"]}

Jest

const {jest: jestConfig} = require('moe-scripts/config')
module.exports = Object.assign(jestConfig, {
  // your overrides here

  // for test written in Typescript, add:
  transform: {
    '\\.(ts|tsx)$': '<rootDir>/node_modules/ts-jest/preprocessor.js',
  },
})

Inspiration

This toolkit is based on and very heavily inspired by kcd-scripts. I'm also grateful for his Tools without config article. I created this as a fork and a separate toolkit instead of contributing it, because he mentioned that, like me, kcd-scripts are a personal project and specific to his needs. (Like this one is specific to my needs).

API

Modules

build

Properties

NameTypeDefaultDescription
--bundleIf present, uses rollup, otherwise TypeScript or Babel.
--outDirstring"lib" Output destination for built files.
--no-clean If present, does not clean target directory.
--out-dirstring"lib" Output destination for built files.
OTHERSAll CLI options used by related binary. (tsc, babel or rollup)

Example

$ npm run build -- --watch --preserveWatchOutput
$ npx moe-scripts build
$ npx moe-scripts build --watch --preserveWatchOutput

commit

Example

$ npm run commit
$ npx moe-scripts commit

contributors

Example

$ npx moe-scripts contributors

doc

Properties

NameDescription
OTHERSAll CLI options used by related binary. (jsdoc2md)

Example

$ npm run build:doc
$ npx moe-scripts doc

format

Properties

NameDescription
--no-writeIf provided files are not written to disk. (Default is write to disk).
OTHERSAll CLI options used by related binary. (prettier)

Example

$ npm run format
$ npx moe-scripts format

info

Example

$ npx moe-scripts info

init

Properties

NameDescription
...filesFiles to lint
--no-cache Disables ESLint --cache arg which is added by this script.
OTHERSAll CLI options used by related binary. (TSLint or ESLint)

Example

$ npx moe-scripts init

lint

Properties

NameDescription
...filesFiles to lint
--no-cache Disables ESLint's --cache arg which is added by this script.
OTHERSAll CLI options used by related binary. (TSLint or ESLint)

Example

$ npm run lint
$ npm run lint my-file.ts -- --config my-config.json
$ npx moe-scripts lint
$ npx moe-scripts lint --no-cache
$ npx moe-scripts lint my-file.ts

precommit

Properties

NameDescription
OTHERSAll CLI options used by related binary. (prettier)

reset

Example

$ npx moe-scripts reset

test

Properties

NameDescription
--no-watchIf provided, works once. (Default is watch mode)
OTHERSAll CLI options used by related binary. (jest)

Example

$ npm run test
$ npx moe-scripts test

travis-after-success

Example

$ npx travis-after-success

validate

Properties

NameDescription
0If provided vomma separated list of npm script names to run.

Example

$ npm run validate my-custom-validator
$ npx moe-scripts validate
$ npx moe-scripts validate my-custom-validator,second-validator
0.1.29

6 years ago

0.1.28

6 years ago

0.1.27

6 years ago

0.1.26

6 years ago

0.1.25

6 years ago

0.1.24

6 years ago

0.1.23

6 years ago

0.1.22

6 years ago

0.1.21

6 years ago

0.1.20

6 years ago

0.1.19

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.0.0

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.61

6 years ago

0.0.60

6 years ago

0.0.59

6 years ago

0.0.58

6 years ago

0.0.57

6 years ago

0.0.56

6 years ago

0.0.55

6 years ago

0.0.54

6 years ago

0.0.53

6 years ago

0.0.52

6 years ago

0.0.51

6 years ago

0.0.50

6 years ago

0.0.49

6 years ago

0.0.48

6 years ago

0.0.47

6 years ago

0.0.46

6 years ago

0.0.45

6 years ago

0.0.44

6 years ago

0.0.43

6 years ago

0.0.42

6 years ago

0.0.41

6 years ago

0.0.40

6 years ago

0.0.39

6 years ago

0.0.38

6 years ago

0.0.37

6 years ago

0.0.36

6 years ago

0.0.35

6 years ago

0.0.34

6 years ago

0.0.33

6 years ago

0.0.32

6 years ago

0.0.31

6 years ago

0.0.30

6 years ago

0.0.29

6 years ago

0.0.28

6 years ago

0.0.27

6 years ago

0.0.26

6 years ago

0.0.25

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.1

6 years ago