arc-pb-fusion-deployer
v0.1.0
Published
Bundles a PageBuilder project into a .zip file and posts it to the PageBuilder API.
Downloads
11
Readme
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-fusion-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-fusion-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-fusion-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-fusion-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, }
| Key | Data type | Required? | Description |
| ----------| ---------------------| ----------|-------------|
| rootDirectory
| string
| true
| Absolute path to project root directory. |
| endpoint
| string
| true
| API endpoint you want to deploy zip file to. |
| username
| string
| true
| API username credential for deployment request authentication. |
| password
| string
| true
| API password credential for deployment request authentication. |
| ommittedContent
| RegExp
| false
| File or directory name patterns to omit from being zipped/deployed. |
| environment
| string
| true
| Environment to be included in the log messages. |
| postDeploy
| function
| true
| Callback to execute after a deployment attempt. |
Developer Tools
The following developer commands are accesible after running yarn install
.
| Command | Description |
| ------------- | ------------- |
| npm run lint
| Lints the deployer package against the Airbnb styleguide. |
| npm run test
| Runs a series of unit tests. |