@gik/npm
v0.1.17
Published
Scripts for your ECMAScript workflow.
Downloads
18
Maintainers
Readme
@gik/npm 0.1.17
Scripts for your ECMAScript workflow.
Contributors
Supported platforms
- linux
- darwin
Table of contents
- gik Centralizes and automates the management of projects based on ECMAScript.
- Scripts The tasks available to run against your project.
- build Transpiles the current project using babel.
- docs Generates documentation using js-to-markdown.
- lint Validates the code complies with certain rules.
- start A watcher for your scripts using nodemon.
- test Runs unit tests using Jest.
- version Automates the versioning of your project using semver.
- Configuration The default settings that control the behaviour of the scripts.
gik
Centralizes and automates the management of projects based on ECMAScript.
create-react-app inspired us to build this tool, it made our life way easier and so we decided to apply the same principle to our workflow: A single place where to put all the configuration and automation for our projects in ECMAScript (meaning Node, Cycle, Webpack, React, etc.)
Installation
Nothing special, just like every other tool in your arsenal, install as development dependency and you're good to go.
npm install --save-dev @gik/npm
Setup
Just add a reference to the "binary" gik
and pass the needed arguments according
to the task you wish to execute.
Parameters
Example package.json
{
"scripts": {
"build": "gik build",
"ver": "gik version patch",
}
}
Members
Scripts
The tasks available to run against your project.
To do
- [ ] Add typedef for error codes and Observables.
Members
build
Transpiles the current project using babel.
Base (.babelrc)`
{
"presets": [
[
"@babel/env",
{
"targets": {
"node": "current"
},
"modules": "commonjs",
"useBuiltIns": false,
"loose": false
}
]
],
"plugins": [
// STAGE-2
"@babel/plugin-proposal-class-properties",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-json-strings",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta"
]
}
The following package.json
properties are available to you in case you wish to modify
the default behaviour.
Properties
Returns
gik.Types.Observable
- An observable which gik
will subscribe to
in order to execute it.
docs
Generates documentation using js-to-markdown. The template used for the documentation is customised, you can see how it looks here, since this very documentation was generated by it. This is why even though this script uses js-to-markdown several of their configuration properties are not available due to the heavy customisation it was done to its original template. However the following ARE available.
Default jsdoc.json
config
{
"sourceType": "module",
"recurseDepth": 10,
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc","closure"]
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false
},
"plugins": [
"node_modules/jsdoc-babel"
]
}
Properties
Returns
gik.Types.Observable
- An observable which gik
will subscribe to
in order to execute it.
To do
- [ ] Add documentation about how to customize the template and the available helpers.
lint
Validates the code complies with certain rules.
It's recommended that you install one of the flavours of
eslint-config to accompany this script.
it will be as easy as to include an .eslintrc
file extending the module.
Parameters
Returns
gik.Types.Observable
- An observable which gik
will subscribe to
in order to execute it.
Example package.json
{
"directories": {
"example": './example'
},
"scripts": {
"lint": "gik lint example"
},
"devDependencies": {
"@gik/eslint-config-node": "x.x.x" // Pick a flavour according to your project
}
}
Example .eslintrc
{
"extends": "@gik/node" // Same as the module but without "eslint-config"
}
start
A watcher for your scripts using nodemon.
Below are the default properties that are being sent to the nodemon
binary.
Parameters
Properties
Related
- https://github.com/remy/nodemon#config-files
Returns
gik.Types.Observable
- An observable which gik
will subscribe to
in order to execute it.
test
Runs unit tests using Jest. This script makes no assumptions for the jest configurations, it just transpiles the test files using the same configuration as the build script and uses Jest's defaults. Below is the configuration file used by the script.
Default configuration .jest.js
const PATH = require('path');
module.exports = {
verbose: true,
bail: true,
collectCoverage: true,
testMatch: ['**/__tests__/**/*.js?(x)'], // only files inside the __tests__ folder
transform: {
'^.+\\.jsx?$': PATH.join(__dirname, 'lib', 'test-transform'),
},
};
you can customize the arguments sent to the jest
cli interface by changing the
following properties on package.json
.
Properties
Returns
gik.Types.Observable
- An observable which gik
will subscribe to
in order to execute it.
Example package.json
{
"@gik/npm": {
"jest": {
"config": "path/to/your/config",
}
}
"scripts": {
"test": "gik test", // runs test on all files on "./test"
"test:cover": "gik test cover", // runs test and generates coverage report
}
}
version
Automates the versioning of your project using semver.
internally uses npm version
(avoiding tagging) and after modifying package.json
adds it to git. This is specially useful if you add it to a precommit
script
(already available when using this library via husky),
making the change available on that commit automatically.
Available semver types:
- major
0.0.0 -> 1.0.0
- minor
0.0.0 -> 0.1.0
- patch
0.0.0 -> 0.0.1
- prerelease
0.0.0 -> 0.0.0-1
0.0.0-beta -> v0.0.0-beta.0
0.0.0-beta.0 -> 0.0.0-beta.1
Parameters
Returns
gik.Types.Observable
- An observable which gik
will subscribe to
in order to execute it.
Example packge.json
{
"scripts": {
// builds, bumps package.json and generartes docs using the new version
"precommit": "gik build && gik version patch && git-npm docs"
}
}
Configuration
The default settings that control the behaviour of the scripts.
Properties
Example package.json
{
"directories": {
"src": "./src",
"out": "./lib"
},
"scripts": {
"example": "your-script $npm_package_directories_src"
},
"@gik/npm": {
"doc": "./README.md"
},
}