0.1.17 • Published 4 years ago

@gik/npm v0.1.17

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

@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

▲ Top


Scripts

The tasks available to run against your project.

To do
  • Add typedef for error codes and Observables.
Members

▲ Top


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.

▲ Top


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.

▲ Top


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"
}

▲ Top


start

A watcher for your scripts using nodemon.

Below are the default properties that are being sent to the nodemon binary.

Parameters
Properties
Related
Returns

gik.Types.Observable - An observable which gik will subscribe to in order to execute it.

▲ Top


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
    }
}

▲ Top


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"
    }
}

▲ Top


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"
    },
}

▲ Top


0.1.17

4 years ago

0.1.14

6 years ago

0.1.14-beta.1

6 years ago

0.1.14-beta.0

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.12-0

6 years ago

0.1.11

6 years ago

0.1.11-0

6 years ago

0.1.10

6 years ago

0.1.9-1

6 years ago

0.1.9-0

7 years ago

0.1.8

7 years ago

0.1.8-0

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.3-2

7 years ago

0.1.3-1

7 years ago

0.1.3-0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.1-beta.1

7 years ago

0.1.0

7 years ago

0.1.0-beta.6

7 years ago

0.1.0-beta.4

7 years ago

0.1.0-beta.3

7 years ago

0.1.0-beta.2

7 years ago

0.0.31

7 years ago

0.0.30

7 years ago

0.0.29

7 years ago

0.0.28

7 years ago

0.0.28-0

7 years ago

0.0.27

7 years ago

0.0.27-1

7 years ago

0.0.27-0

7 years ago

0.0.26-0

7 years ago

0.0.23

7 years ago

0.0.21

7 years ago

0.0.20-2

7 years ago

0.0.20-1

7 years ago

0.0.20-0

7 years ago

0.0.19

7 years ago

0.0.19-0

7 years ago

0.0.17

7 years ago

0.0.15

7 years ago

0.0.15-3

7 years ago

0.0.15-2

7 years ago

0.0.15-1

7 years ago

0.0.15-0

7 years ago

0.0.13-2

7 years ago

0.0.13-1

7 years ago

0.0.13-0

7 years ago

0.0.6

7 years ago

0.0.6-beta-1

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago