1.0.0 • Published 3 years ago

pre-action v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Pre Action

The motivation for creating this module is to prevent any publication or any action that could harm a specific task, for example: the publication of a package to the npm registers with missing data, etc.

Installation

Local

npm install --save-dev pre-action

Global

npm install -g pre-action

Usage

pre-action [event]

Options

OptionTypeDescription
-fstringFormat of the file (json, json5, yaml, toml, ecld)
-cstringPath of the file
-nstringName of the file
-sbooleanStop process if a required didn't found
Example
One Level

.preactionrc

{
    "publish": {
        "file": "./package.json",
        "format": "json",
        "content": {
            "repository": {
                "required": true
            }
        }
    }
}
Nested Validation

.preactionrc

{
    "publish": {
        "file": "./package.json",
        "format": "json",
        "content": {
            "repository": {
                "required": true,
                "content": {
                    "required": true
                }
            }
        }
    }
}
Warning interface

.preactionrc

{
    "publish": {
        "file": "./package.json",
        "format": "json",
        "content": {
            "repository": {
                "warning": true
            }
        }
    }
}

If you use the 'warning' option, the dynamic interface will be activated.

Extends

We can also inherit an already established structure

.preactionrc

{
    "publish": {
        "file": "./package.json",
        "format": "json",
        "extends": "pre-action/template/npm-publish"
    }
}

List of available structures:

nameDescription
pre-action/template/npm-publishStructure for publish packages
Only check file

You have the option of validating only that a file exists

.preactionrc

{
    "publish": {
        "file": "./package.json",
        "format": "json",
        "exists": true
    }
}
Only check directory

You have the option to validate if a directory is empty

.preactionrc

{
    "publish": {
        "file": "./mydir",
        "isNotEmpty": true
    }
}

Call

we can call with this command

pre-action publish

and also we can combine this command with a flow

pre-action publish && npm publish

Create custom extends

Create a directory that has a file 'index.json' in the main root and establish the path of that folder or if it were the case the name of the module.

If you want to help this project, go to the github repository of this project