@emartech/client-publish

7.0.0 • Public • Published

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.

Configuration CLI argument ENV variable Required Type Default value
Basic config
Target deploy environment -e DEPLOY_ENV false "staging", "production" "staging"
Local directory to be deployed -d LOCAL_DIRECTORY false string "dist"
Revision (version) of the deployed assets -r PROJECT_REVISION false string current timestamp
Should a git tag be automatically created? -t false boolean false
S3/Redirector config
Should assets be deployed to Redirector? REDIRECTOR_DEPLOY false boolean true
(before v6.0.0: false)
Project name / S3 subdirectory name REDIRECTOR_NAME true string
Redirector service URL REDIRECTOR_URL false string automatically determined based on target env
Redirector assets URL REDIRECTOR_TARGET false string automatically determined based on target env
Redirector API secret REDIRECTOR_API_SECRET true string
S3 bucket to use S3_BUCKET false string automatically determined based on target env
S3 bucket ACL setting S3_ACL false string "public-read"
S3 bucket cache control S3_CACHE_CONTROL false string "max-age=315360000, no-transform, public"
AWS region AWS_REGION false string "eu-west-1"
AWS access key AWS_ACCESS_KEY_ID true string
AWS secret for access key AWS_SECRET_ACCESS_KEY true string
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"
}

Keywords

none

Install

npm i @emartech/client-publish

DownloadsWeekly Downloads

820

Version

7.0.0

License

MIT

Unpacked Size

44.1 kB

Total Files

35

Last publish

Collaborators

  • thomaskmartin
  • emarsys-security
  • norbert-levajsics-emarsys
  • ronnykrosse
  • vszegedi
  • sap-am
  • nnieman-sap
  • ariceem
  • dwolter_emarsys
  • rcsullag
  • ttoth2
  • tbucsanszki
  • dszunomar
  • dschuppa
  • andras.sarro
  • ndomke
  • sevket-ataseven
  • plsap
  • janetriley
  • mattfeldhake_emarsys
  • atittel
  • andrasp3a
  • mruell
  • adroszler
  • erikpetroemar
  • rimo86
  • tillmannr
  • markjarvis
  • geczirobert
  • tsiraitnpm
  • bankyadam
  • bborsi
  • zbalazs
  • ziyadg
  • pintera
  • sigee
  • apoon
  • ianhelmrich
  • varszegik
  • rkumari03
  • cseby92
  • bozsadam
  • jfillmore
  • viktor.szell
  • bencekadaremar
  • roxanams
  • dkocsis-emarsys
  • demajo_ems
  • marko.fritzsche
  • agrucza
  • dmorvai
  • nish343
  • kolosh
  • azorahai3904
  • skrivoo
  • mark.adorjan
  • burci
  • dimitrovn
  • ivanfroehlich
  • iulianmihai
  • xueboliang
  • greszter
  • bercziand
  • okovalenko
  • criley
  • drewhodsonsap
  • jviesersap
  • sixstep
  • sap-jjf
  • sapfs
  • attilamuller01
  • prasadpomaji
  • scotthetrick
  • oliverweisenburger
  • maurogreco
  • nicolaeciumac
  • asciortino1
  • pendicg24
  • marton.matusek
  • adamszabolcs
  • btalos
  • bence.uto
  • daniels1404
  • saphendricksjoerg
  • mmartin2
  • fenyopeti
  • mmothersill
  • brandon-sap
  • pjohnson02
  • mhunyady
  • faridtoubal
  • mengjiao.zhao
  • ushnpm
  • dkorpos
  • xin.he
  • viau
  • zsomborh
  • muddam
  • nvkaur2
  • jbleclerc
  • b-laczko
  • jamescocker
  • arnaud.buchholz
  • jerryrichardson
  • retfalvibence
  • akapa
  • mkls
  • probalazs
  • kaaj
  • knagy
  • pecc
  • kszalontai
  • rehreth
  • mhegedus
  • mmartin
  • bsoos
  • emarsys-deployer
  • draven
  • npospischek-emartech
  • judge
  • daniel.banky
  • szeist
  • rgargya
  • marton.papp.emarsys
  • dgyenes
  • s.viktor
  • m4w4q7
  • david.barkoczi
  • qw3r
  • tamas.toth
  • gergaczd
  • gerike
  • alkra
  • epgrubmair
  • morban
  • ettancos
  • epmartini
  • gabor.balla.emarsys
  • mzsombor
  • ejpersson
  • ejwalker
  • llosonczy
  • iben12
  • kartonfarkas
  • adamoa
  • mbarna
  • peva
  • bforgacs
  • kozma
  • ngabor84
  • zerosuxx
  • edosrecki
  • eadaniel
  • selator
  • kkimak
  • szb
  • gaborb
  • glendvai
  • lveraszto
  • rdoczi
  • fentosi
  • boristomic
  • mbazso
  • dmihalek
  • lhalasz
  • evspasevski
  • eslesnjakovic
  • dsztanko
  • tbugar
  • fqqdk
  • eggarcia
  • ems-zoltan-kohalmy
  • menyhertfatyol
  • zoltanrideg-emarsys
  • sarakoll
  • mmolnar-emar
  • attila.gal
  • benjamingehl
  • tdorkaa
  • lkonya
  • gpap_ema
  • vimtaai
  • lloki-emarsys
  • borzi
  • pmaksa_emarsys
  • dfarago