2.1.0 • Published 3 years ago

rishiqing-deploy v2.1.0

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

Deploy your static files with a thousand methods :boom: :boom: :boom:

Intro

  • Integrated ftp, sftp, ssh2, aliyunOss.
  • Uses a configuration file with yaml format.
  • Reasonable notification configuration, real-time deployment status.
  • Suitable for automatic build

Install

npm i rishiqing-deploy

Implementation

In rishiqing-deploy, we provide four kinds of task: build, resource, fileReplace, endBuild. All tasks are executed in the order of : build -> resource -> fileReplace -> endBuild. Once the error, the subsequent tasks will stop.

We also intend to provide types notification tools, now only bearychat, but we will add more later.

build

Execute at the very beginning. all commands inside build will been executed. once the error, the task will stop.

resource

Resource is used to upload files to servers. Use different tools to upload. This will covere the file of the same name.

fileReplace

FileReplace is just like resource, but it is used to replace the entry files, such as index.html. Before upload, it will rename the file/directory which the target specified, then upload the local file/directory as the name of target specified.

endBuild

EndBuild is used to do some work after uploads, such as clean directory.

Usage

Configuration file

Without install rishiqing-deploy globally, you can install it locally, then add a script field to your package.json

{
  "script": {
      "rd": "rishiqing-deploy"
    }
}

When you execute npm run rd, the command will automatic load a file named .rishiqing-deploy.yml for configuration. you can also customize by npm run rd -- --config=YOUR_CONFIG_FILE_NAME.

Configuration file is NODE_ENV friendly, you can set the environment variable NODE_ENV or npm run rd -- --env=production to define the environment. once the environment is defined, the default configure will been covered by it.

default: # the default config
  notify:
    title: 'rishiqing-deploy' # the title of notification, default is rishiqing-deploy
    nodes: # define notification node
      - 'after-build' # after execute all build commands
      - 'one-build' # after one build command
      - 'one-upload' # in resource or fileReplace task, after a uploading
      - 'one-file-upload' # after one file uploaded
      - 'one-resource' # after one resource task
      - 'resource' # after all resources tasks
      - 'one-file-replace' # after one fileReplace task
      - 'file-replace' # after all fileReplace tasks
      - 'statistics' # send the statistics information
      - 'success' # ending with success
      - 'error' # when error throwing out
      - 'deploy-log' # generate deploy log after build
    list:
      - type: bearychat # bearychat notification
        param:
          hook: '' # bearychat incoming hook
          user: 'qinyang' # the user who you want to notify
          title: '' # coverd the title as previously defined
          channel: 'automaitc-deploy' # the channel which you want to notify. note: channel has priority over user
          nodes: # filter the nodes those you need
            - 'one-resource'
            - 'resource'
            - 'one-file-replace'
            - 'file-replace'
            - 'success'
      - type: dingtalk # dingding notification
        param:
          hook: 'https://oapi.dingtalk.com/robot/send?access_token=xxxxx' # dingtalk notification hook
  deployLog: # deploy log
    type: gitlab # generate deploy log from gitlab
    param:
      url: https://gitlab.com
      match: '/^log--/' # match commit message begin with log--
      token: '' # token has higher priority than jobToken
      jobToken: '' # default is process.env.CI_JOB_TOKEN
      projectId: 123 # default is process.env.CI_PROJECT_ID
      beforeSha: 1fcba37592714962 # default is process.env.CI_COMMIT_BEFORE_SHA
      branch: master # default is process.env.CI_COMMIT_REF_NAME
      projectUrl: https://gitlab.com/xxx/xxx # default is process.env.CI_PROJECT_URL
      replaceMatch: true # replace match with empty string
      title: 'deploy log' # default is deploy log
      goToLink: https://gitlab.com'
      version: '0.0.1'

  convert: # convert file type (now support convert yml to json)
    - target: /path/to/the/file/to/be/converted
      dest: /path/to/output

  build: # define the build command list
    - 'npm run webpack'
  resource:
    - dist: 'dist' # local file or directory
      ignore: # the ignore list, support regexp
        - 'images'
        - 'index.html'
        - 'manifest.json'
        - '/\.map$/'
      upload: # specify the upload tool. the tools specified will been executed one by one.
        - type: 'aliyunOss'
          param:
            accessKeyId: ''
            # accessKeySecret and secretAccessKey is same
            # There are two because the earliest parameter is called secretAccessKey
            # but after updating ali-oss, the parameter name was changed to accessKeySecret
            # in order to be compatible with the previous configuration, two parameters are supported at the same time.
            accessKeySecret: ''
            secretAccessKey: ''
            bucket: ''
            # Set the region or endpoint
            region: 'oss-cn-beijing'
            # the priority of the endpoint is higher than the region
            endpoint: 'http://oss-cn-beijing.aliyuncs.com'
            prefix: ''
        - type: 'ftp'
          param:
            host: ''
            port: 21
            user: ''
            password: ''
            path: ''
        - type: 'sftp'
          param:
            host: ''
            port: 22
            username: ''
            password: ''
            path: ''
        - type: 'ssh2' # use ssh2, you must be able to access the server through a certificate
          param:
            host: ''
            port: 22
            user: ''
            path: ''
  fileReplace:
    - dist: 'dist/app.js' # local file or directory
      ignore:
        - ''
      target: 'global.js'
      upload:
        - type: 'aliyunOss'
          param:
            accessKeyId: ''
            # accessKeySecret and secretAccessKey is same
            # There are two because the earliest parameter is called secretAccessKey
            # but after updating ali-oss, the parameter name was changed to accessKeySecret
            # in order to be compatible with the previous configuration, two parameters are supported at the same time.
            accessKeySecret: ''
            secretAccessKey: ''
            bucket: ''
            # Set the region or endpoint
            region: 'oss-cn-beijing'
            # the priority of the endpoint is higher than the region
            endpoint: 'http://oss-cn-beijing.aliyuncs.com'
            prefix: ''
        - type: 'ftp'
          param:
            host: ''
            port: 21
            user: ''
            password: ''
            path: ''
        - type: 'sftp'
          param:
            host: ''
            port: 22
            username: ''
            password: ''
            path: ''
        - type: 'ssh2'
          param:
            host: ''
            port: 22
            user: ''
            path: ''
  endBuild:
    - 'npm run clean'
production: # the production environment. will covere the defualt config
  resource:
    - dist: 'dist'
      ignore:
        - 'images'
        - 'index.html'
        - 'manifest.json'
        - '/\\.map$/' # '\' must be '\' escaped
      upload:
        - type: 'sftp'
          param:
            host: ''
            port: 22
            username: ''
            password: ''
            path: ''
        - type: 'ssh2'
          param:
            host: ''
            port: 22
            user: ''
            path: ''

License

MIT

Copyright (c) 2014-2016 Rishiqing

2.5.2-test.0

3 years ago

2.1.0

3 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.17

6 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago