grunt-qiniu-qupload

0.1.6 • Public • Published

grunt-qiniu-qupload

a grunt plugin which can upload assets to qiniu.

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-qiniu-qupload --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-qiniu-qupload');

The "qiniu_qupload" task

Overview

In your project's Gruntfile, add a section named qiniu_qupload to the data object passed into grunt.initConfig().

grunt.initConfig({
  qiniu_qupload: {
    default_options: {
      options: {
        ak: '<Your AccessKey>',           // required, default null
        sk: '<Your SecretKey>',           // required, default null
        bucket: '<Bucket>',               // required, default null
        removeExistOnly: false,           // optional, default false
        overwrite: true,                  // optional, default false
        assets: [{                        // required, default null
          src: 'test/upload/assets/css',  // required
          prefix: 'assets/css/',          // required, use '' when no prefix
          // skip: ['b.css'],             // optional, default undefined
        },{
          src: 'test/upload/assets/js',
          prefix: 'assets/js/'
        }]
      }
    }
  },
});

Options

options.cwd

Type: String Default value: '.'

current working directory, use to resolve assets path.

options.ak

Type: String Default value: null

.

options.sk

Type: String Default value: null

.

options.bucket

Type: String Default value: null

qiniu bucket where you want to upload your file.

options.removeExistOnly

Type: Boolean Default value: false

remove existing files without upload files. (Notice: files in <skip list> will not be affect.)

options.overwrite

Type: Boolean Default value: false

if overwrite existing files.

options.assets

Type: Array Default value: null

your assets. elements in the array must be in struct like {src: '<local assets Dir>', prefix: <Key Prefix>, skip: [<skip files list>]}, and options.cwd + '<local assets Dir>' must be an existing assets directory. skip is an optional setting, skip files must in the src directory. files in skip list will not affect by any operation.

Usage Examples

In this example, the default options are used to upload all the files in 'test/upload/assets/css' and ''test/upload/assets/js. Before you run the command grunt, you have to change the option ak, sk and bucket to your qiniu account setting.

grunt.initConfig({
  qiniu_qupload: {
    default_options: {
      options: {
        ak: '<Your AccessKey>',           // required, default null
        sk: '<Your SecretKey>',           // required, default null
        bucket: '<Bucket>',               // required, default null
        removeExistOnly: false,           // optional, default false
        overwrite: true,                  // optional, default false
        assets: [{                        // required, default null
          src: 'test/upload/assets/css',  // required
          prefix: 'assets/css/',          // required, use '' when no prefix
          // skip: ['b.css'],             // optional, default undefined
        },{
          src: 'test/upload/assets/js',
          prefix: 'assets/js/'
        }]
      }
    }
  },
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)

Package Sidebar

Install

npm i grunt-qiniu-qupload

Weekly Downloads

1

Version

0.1.6

License

none

Last publish

Collaborators

  • wjs