GithubHelp home page GithubHelp logo

js-uploader's Introduction

JS Uploader

Use to upload files to S3 and NPM.

Requirements

  • Node 4+

Configuration

You will need to have a config.ejson file with the following keys:

{
    "_public_key": "",
    "aws": {
        "accessKeyId": "",
        "secretAccessKey": "",
        "region": "",
        "bucket": ""
    }
}

You must ensure shipit runs the following command before deploy script is run.

ejson decrypt -o config.json config.ejson

Usage

Instantiate an Uploader with config object for your project:

/**
 * @param {S3} config.s3 - aws s3 instance
 * @param {Array} config.files - array of file paths to upload
 * @param {String} config.dir - directory to upload all files from
 * @param {String} config.destination - name of s3 directory to upload to
 * @param {Number|String} config.version - version number
 * @param {Boolean} [true] config.latest - whether to upload /latest file
 */
const awsSDK = require('aws-sdk');
const awsConfig = require('../config.json').aws;
const Uploader = require('js-uploader');
const uploader = new Uploader({

const awsS3 = new awsSDK.S3({
  accessKeyId: awsConfig.accessKeyId,
  secretAccessKey: awsConfig.secretAccessKey,
  region: awsConfig.region,
  params: {
    Bucket: awsConfig.bucket,
    ACL: 'public-read'
  }
});

const uploader = new Uploader({
  s3: awsS3,
  dir: 'dist',
  destination: 'buy-button',
  version: currentVersion,
});

uploader.deployStaticFiles();
uploader.npmPublish();

Add the above to a JS file and add it to your shpit.yml:

deploy:
  override:
    - npm install --no-progress
    - ejson decrypt -o config.json config.ejson
    - npm run build
    - node ./scripts/my-deply-script.js

js-uploader's People

Contributors

tessalt avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.