Socket
Socket
Sign inDemoInstall

@emartech/client-publish

Package Overview
Dependencies
Maintainers
184
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emartech/client-publish

Deployer for client side projects


Version published
Weekly downloads
0
Maintainers
184
Weekly downloads
 
Created
Source

client-publish

NPM version Dependency Status Build status

Deployer for client side projects. Uploads the bundled client application to target distribution platform (Amazon S3 and/or Firebase) and sets up redirection to that bucket for S3 deploys.

Install

npm install @emartech/client-publish --save-dev

Usage

This package exposes a command called client-publish. It can be used for several things:

  • Get the current or next revision of the project (revision)
  • Deploy project to a target platform (deploy)
  • Create a new git tag for the project (tag)
  • Merge master branch into production for production deploys (merge)

For detailed usage see help:

client-publish help

Deployment Configuration

To deploy the project, some options must be configured via environment variables. These environment variables must be set on the CI/CD pipeline.

Generic configuration
env vardescriptionrequireddefault value
DEPLOY_ENVdeployment env, can be "staging" or "production""staging"
LOCAL_DIRECTORYplace of the bundled application"dist"
Firebase configuration
env vardescriptionrequireddefault value
FIREBASE_DEPLOYif true, it will deploy to the Firebase platform or notfalse
FIREBASE_PROJECTthe name of the GCP project for Firebase Hostingtrue
FIREBASE_SITEthe Firebase Hosting site used to host the assettrue
GOOGLE_APPLICATION_CREDENTIALS_JSONthe base64 encoded Google service account credential for Firebase deploytrue
Redirector configuration
env vardescriptionrequireddefault value
PROJECT_NAMEname of the project, will be used as the subdirectory in the S3 buckettrue
S3_ACLS3 buckets ACL setting"public-read"
S3_CACHE_CONTROLS3 buckets cache control"max-age=315360000, no-transform, public"
AWS_REGIONAWS region"eu-west-1"
AWS_ACCESS_KEY_IDAWS access keytrue
AWS_SECRET_ACCESS_KEYAWS secret for access keytrue
REDIRECTOR_API_SECRETsecret of the redirector servicetrue

Some furter options for the redirector deploy can be overridden but are not required if the DEPLOY_ENV env variable is set.

env vardescriptiondefault value for stagingdefault value for production
S3_BUCKETthe S3 bucket where the application will be uploaded to'ems-assets-staging''ems-assets'
REDIRECTOR_URLURL of the redirector service'https://redirector-staging.gservice.emarsys.com''https://redirector.gservice.emarsys.net'
REDIRECTOR_TARGETthe domain where the redirector should point'assets.emarsys.com''assets.emarsys.net'

Usage with Codeship

Set the following environment variables:

  • PROJECT_NAME
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • REDIRECTOR_API_SECRET_STAGING
  • REDIRECTOR_API_SECRET_PRODUCTION
  • FIREBASE_PROJECT_STAGING (optional)
  • FIREBASE_PROJECT_STAGING (optional)
  • GOOGLE_APPLICATION_CREDENTIALS_JSON (optional)
  • FIREBASE_SITE_STAGING (optional)
  • FIREBASE_SITE_PRODUCTION (optional)
  • GOOGLE_APPLICATION_CREDENTIALS_JSON_PRODUCTION (optional)

Set up the following NPM scripts in your package.json. You can pass additional arguments to the client-publish command here.

{
  "scripts": {
    "deploy-staging": "client-publish deploy --target-env staging",
    "deploy-production": "client-publish deploy --target-env production"
  }
}

Set up deployment for master and production branch.

# master branch
export REDIRECTOR_API_SECRET=REDIRECTOR_API_SECRET_STAGING
export FIREBASE_DEPLOY=true # enables deploying to Firebase
export FIREBASE_PROJECT=FIREBASE_PROJECT_STAGING
export FIREBASE_SITE=FIREBASE_SITE_STAGING
export GOOGLE_APPLICATION_CREDENTIALS_JSON=GOOGLE_APPLICATION_CREDENTIALS_JSON_STAGING
npm run build
npm run deploy-staging

# production branch
export REDIRECTOR_API_SECRET=REDIRECTOR_API_SECRET_STAGING
export FIREBASE_DEPLOY=true # enables deploying to Firebase
export FIREBASE_PROJECT=FIREBASE_PROJECT_STAGING
export FIREBASE_SITE=FIREBASE_SITE_STAGING
export GOOGLE_APPLICATION_CREDENTIALS_JSON=GOOGLE_APPLICATION_CREDENTIALS_JSON_STAGING
npm run build
npm run deploy-production

Legacy Usage Deprecated

For compatibility with older versions this package also exposes four other commands:

  • client-deploy: deploy application
  • client-deploy-staging: sets defaults for staging and deploy application
  • client-deploy-production: sets defaults for production and deploy application
  • client-merge: merge and push to production from master

To use these commands the environment variables in the Deployment Configuration section must be present. You can also use these commands npm scripts.

{
  "scripts": {
    "deploy-staging": "client-deploy-staging",
    "deploy-production": "client-deploy-production",
    "merge-production": "client-merge"
  }
}

FAQs

Package last updated on 20 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc