Socket
Socket
Sign inDemoInstall

@emartech/client-publish

Package Overview
Dependencies
Maintainers
170
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
170
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 sets up redirection through the Redirector Service.

Install

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

Usage

This package exposes a command called client-publish. This command line utility has several subcommands:

  • deploy: Deploys assets to the given platforms
  • revision: Gets the current or next suggested revision for the project
  • tag: Creates a new git tag for the project with a given revision
  • merge: Merge master branch into production for production deploys
deploy
Deploys assets to the given platforms

Example usage:
  $ client-publish deploy --target-env production --revision 4.2.0 --create-tag

Options:
  -e, --target-env <env>     the target environment the deployment is for (choices: "staging", "production", default: "staging", env: DEPLOY_ENV)
  -r, --revision <revision>  the revision to use when deploying (default: current timestamp, env: PROJECT_REVISION)
  -t, --create-tag           create a git tag for the new revision (default: false)
  -h, --help                 display help for command

Configuration must be passed as command line arguments and/or environment variables on the CI/CD pipeline.

ConfigurationCLI argumentENV variableRequiredTypeDefault value
Basic config
Target deploy environment-eDEPLOY_ENVfalse"staging", "production""staging"
Local directory to be deployed-dLOCAL_DIRECTORYfalsestring"dist"
Revision (version) of the deployed assets-rPROJECT_REVISIONfalsestringcurrent timestamp
Should a git tag be automatically created?-tfalsebooleanfalse
S3/Redirector config
Should assets be deployed to Redirector?REDIRECTOR_DEPLOYfalsebooleantrue
(before v6.0.0: false)
Project name / S3 subdirectory nameREDIRECTOR_NAMEtruestring
Redirector service URLREDIRECTOR_URLfalsestringautomatically determined based on target env
Redirector assets URLREDIRECTOR_TARGETfalsestringautomatically determined based on target env
Redirector API secretREDIRECTOR_API_SECRETtruestring
S3 bucket to useS3_BUCKETfalsestringautomatically determined based on target env
S3 bucket ACL settingS3_ACLfalsestring"public-read"
S3 bucket cache controlS3_CACHE_CONTROLfalsestring"max-age=315360000, no-transform, public"
AWS regionAWS_REGIONfalsestring"eu-west-1"
AWS access keyAWS_ACCESS_KEY_IDtruestring
AWS secret for access keyAWS_SECRET_ACCESS_KEYtruestring
Gets the current or next suggested revision for the project

Example usage:
  $ client-publish revision --type git-tag --next

Options:
  -t, --type <type>      the way to get the revision (choices: "env", "timestamp", "package", "git-tag", default: "timestamp")
  -n, --next             get the next revision based on conventional commit messages (default: false)
  -p, --prefix [prefix]  the prefix to use when searching for the last revision (default: "")
  -h, --help             display help for command
tag
Creates a new git tag for the project with a given revision

Example usage:
  $ client-publish tag --revision 4.2.0 --prefix "v" --yes

Options:
  -r, --revision [revision]  the revision to use for the tag (env: PROJECT_REVISION)
  -p, --prefix [prefix]      the prefix to add to the version number (default: "")
  -y, --yes                  automatic yes to prompt (default: false)
  -h, --help                 display help for command
merge
Merges the `master` branch into the `production` branch

Example usage:
  $ client-publish merge --yes

Options:
  -y, --yes   automatic yes to prompt (default: false)
  -h, --help  display help for command

CI/CD configuration

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

"scripts": {
  "deploy:staging": "client-publish d -e staging"
  "deploy:production": "client-publish d -e production"
}
Usage with GitHub Actions
  1. Set up your secretes in the "Actions secrets" interface:
    • The AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REDIRECTOR_API_SECRET_STAGING, REDIRECTOR_API_SECRET_PRODUCTION are added as Organization secrets for the emartech organization.
  2. Set the required environment variables in your workflow file:
    • REDIRECTOR_NAME

Map secrets to environment variables according to your current environment:

## STAGING WORKFLOW (snippet) ##
jobs:
  deploy:
    name: Deploy
    needs: [ build ]

    steps:
      - name: Deploy
        run: npm run deploy:staging

    env:
      REDIRECTOR_NAME: my-project
      REDIRECTOR_API_SECRET: ${{ secrets.REDIRECTOR_API_SECRET_STAGING }}
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Usage with Codeship
  1. Set the required environment variables on your deploy pipeline:
    • REDIRECTOR_NAME
    • REDIRECTOR_API_SECRET_STAGING, REDIRECTOR_API_SECRET_PRODUCTION
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY

Set up deployment for master and production branch.

## MASTER BRANCH ##
export REDIRECTOR_API_SECRET=REDIRECTOR_API_SECRET_STAGING
# Run deploy scripts
npm run build
npm run deploy:staging
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 31 Jan 2023

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