Code Monkey home page Code Monkey logo

react-deploy's Introduction

react-deploy

GitHub issues GitHub forks GitHub stars GitHub license Build Status Twitter

Create React App deployment to S3 bucket along with app versioning and activation features.

upload revisions

Activate any revisions

show revisions

This package doesn't build the app,use webpack or create-react-app to build the application.

Table of Contents

Install

npm i react-deploy -S

# or

yarn add react-deploy

Usage

task.js

/*
 * Minimalistic script runner. Usage example:
 *
 *     node tools/deploy.js
 *     Starting 'deploy'...
 *     Starting 'build'...
 *     Finished 'build' in 3212ms
 *     Finished 'deploy' in 582ms
 */

 function run (task, action, ...args) {
   const command = process.argv[2]
   const taskName = command && !command.startsWith('-') ? `${task}:${command}` : task
   const start = new Date()
   process.stdout.write(`Starting '${taskName}'...\n`)
   return Promise.resolve().then(() => action(...args)).then(() => {
     process.stdout.write(`Finished '${taskName}' after ${new Date().getTime() - start.getTime()}ms\n`)
   }, err => process.stderr.write(`${err.stack}\n`))
 }

 process.nextTick(() => require.main.exports())
 module.exports = (task, action) => run.bind(undefined, task, action)

deploy.js

const s3 = require('react-deploy')
const task = require('./task')

module.exports = task('upload', () => Promise.resolve()
  .then(() => {
    Uploader
  })
)
const Uploader = new Promise((resolve, reject) => {
  const client = s3.createClient({
  s3Options: {
      accessKeyId: 'AWS_KEY',
      secretAccessKey: 'AWS_SECRET_ACCESSKEY',
      region: 'REGION',
      sslEnabled: true,
      Bucket:'BUCKETNAME'
    },
  })
  const uploader = client.uploadDir({
    localDir: 'DISTRIBUTIONFOLDER', //dist
    deleteRemoved: false,
    s3Params: {
      Bucket: 'BUCKETNAME'
    },
  })

  // on deploy  create a finger print
    client.createRevision()

  // display revisions
   client.displayRevisions()

  // activate the new value
   client.activateRevisions('index:a00a13d')

   uploader.on('error', reject)
   uploader.on('end', resolve)
})

Contribute

Contributors are welcome.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © sumn2u

react-deploy's People

Contributors

sumn2u avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

artursmirnov

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.