emp-deploy
v2.0.2
Published
This module exports "configEmpDeploy" function that help you deploy easier.
Readme
This module exports "configEmpDeploy" function that help you deploy easier.
methods
const { configEmpDeploy } = require('emp-deploy');sshKeyPath- string that represents the path of the private ssh keybuildsConfigArray- an array of builds configs of this shape
export interface BuildConfig {
name: string;
buildPath: string;
serverPath: string;
url: string;
buildCommand: string;
host: string;
user: string;
}example
import { configEmpDeploy } from 'emp-deploy';
const buildsConfig = [
{
name: 'PROD',
buildPath: './dist/prod',
serverPath: '/var/www/html/prod',
url: 'https://prod.com',
buildCommand: 'npm run build:prod && npm run purgecss',
host: 'root',
user: '192.168.0.1'
},
{
name: 'DEV',
buildPath: './dist/dev',
serverPath: '/var/www/html/dev',
url: 'https://dev.com',
buildCommand: 'npm run build:dev && npm run purgecss',
host: 'root',
user: '192.168.0.1'
}
];
const sshKeyPath = '../../../.ssh/id_rsa';
const runDeploy = await configEmpDeploy(sshKeyPath, buildsConfig);
runDeploy();install
npm install emp-deploy --save-devpublish to npm
Quick steps to publish the updated package to npm:
- Preparation
- Make sure all code is committed:
git add . && git commit -m "your message". - Check
package.json: thename,version,main/typesfields and ensureprivateis not set totrueif you want to publish publicly.
- Bump version and git tag
- Bump the version and create a tag (e.g. patch):
npm version patch -m "Release v%s" - Push commits and tags:
git push origin HEAD --follow-tags
- Build & local check
- Run the build if applicable:
npm run build - Validate the package without publishing:
npm publish --dry-runornpm pack(creates a local tarball)
- Login to npm (if not logged in)
npm login(you will provide username, password and email; if you have 2FA you will be asked for an OTP)
- Publish
- For public packages (including scoped packages):
npm publish --access public - For private packages:
npm publish
- Verify after publishing
- Check the published version:
npm info <package-name> versionornpm view <package-name> dist-tags
Notes
- If you use a scope (
@scope/name) and want the package to be public, include--access publicwhen publishing. - If you use 2FA, you will need to provide an OTP at
npm publish. - For CI automation: use an
NPM_TOKENsecret and a CI job that runsnpm publishwhen a tag is created (GitHub Actions, GitLab CI, etc.).
