1.0.4 • Published 6 years ago

arc-pb-deployer v1.0.4

Weekly downloads
729
License
ISC
Repository
github
Last release
6 years ago

Arc PageBuilder Deployer

The Arc PageBuilder Deployer package is a simple Node script which bundles a PageBuilder repository into a .zip file and then makes a POST request to the PageBuilder deployer API. Once posted you can deploy your site bundle directly through the deployer window.

For detailed setup instructions with CircleCI including examples click here.

Getting Started

To get started you must first install the npm package. You'll also need to install version 8.0 or higher of NodeJS.

npm install arc-pb-deployer

Once installed you can then require the package, passing in some information about the repository file structure and the PageBuilder API you'd like to upload to. You can then call the deploy method to start the bundling process.

const path = require('path')
const postDeploy = require('./postDeploy');
const environment = process.env.NODE_ENV

const deploy = require('arc-pb-deployer')({
  rootDirectory: path.resolve(__dirname, '..', '..'),
  endpoint: process.env[`${environment}_DEPLOYER_ENDPOINT`],
  username: process.env[`${environment}_DEPLOYER_USERNAME`],
  password: process.env[`${environment}_DEPLOYER_PASSWORD`],
  environment,
  postDeploy
})

deploy()

By default the module omits a series of folders and file types that are deemed as unnecessary for a PageBuilder bundle such as the node_modules, docker and mongo directories. However if you'd like to override the regex and setup your own you can do so by passing it in as the argument.

const deploy = require('arc-pb-deployer')({
  // ...
  ommittedContent: /node_modules$|^.*\.(scss|map|less)$|.git$|__tests__$|build$|src$|package*$|yarn.lock$|circle[.]*|bash[.]*|gulp[.]*|docker[.]*|deploy[.]*|deployment[.]*|pagebuilder[.]*|mongo[.]*|proxy[.]*/
})

deploy()

Whenever the deploy function runs it will generate a .zip file to the deployment folder in the root directory of the PageBuilder project, this folder should be ignored inside of the projects .gitignore file.

Chat Client Notifications

If you'd like to recieve a chat client notification whenever the bundle has finished deploying you can pass in a postDeploy callback that uses your chat client's webhook API. Here's a generalized example:

const someChatClient = require('some-chat-client');
const deploy = require('arc-pb-deployer')({
  // ...
  postDeploy: function(success, name, environment) {
    if (success) {
      someChatClient(`Your bundle, \`${name}\` has been deployed to the \`${environment}\` environment`)
    } else {
      someChatClient(`Your bundle, \`${name}\` to \`${environment}\` has failed.`)
    }
  }
})

deploy()

The callback will pass back if the deployment is successful, the name of the bundle, and the environment it was deployed to.

API

The following properties can be passed in as arguments when instantiating the arc-pb-deploy package. Remember to pass them as properties on an arguments object, e.g., { rootDirectory, endpoint, username, etc, }

KeyData typeRequired?Description
rootDirectorystringtrueAbsolute path to project root directory.
endpointstringtrueAPI endpoint you want to deploy zip file to.
usernamestringtrueAPI username credential for deployment request authentication.
passwordstringtrueAPI password credential for deployment request authentication.
ommittedContentRegExpfalseFile or directory name patterns to omit from being zipped/deployed.
environmentstringtrueEnvironment to be included in the log messages.
postDeployfunctiontrueCallback to execute after a deployment attempt.

Developer Tools

The following developer commands are accesible after running yarn install.

CommandDescription
yarn lintLints the deployer package against the Airbnb styleguide.
yarn testRuns a series of unit tests.
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.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago