bdcli-deploy
v0.1.0
Published
Build and deploy projects over SSH from the current project directory.
Readme
bdcli
bdcli is a Node.js CLI for project-local build and deploy workflows. It looks for deployment config in the current directory tree, runs a build command, uploads artifacts over SSH/SFTP, and executes remote deployment commands.
Commands
bdcli init
bdcli init --with-local
bdcli build
bdcli doctor
bdcli doctor --env production
bdcli deploy
bdcli deploy staging
bdcli deploy production --dry-run
bdcli deploy production --skip-buildConfig files
/.deploy.config.json: required primary config/.deploy.local.json: optional local override config
Merge rules:
- objects: deep merge
- arrays: override completely
- scalar values: local overrides primary
/.deploy.local.json is ignored by git in this repository.
Config example
{
"version": 1,
"project": "my-app",
"build": {
"command": "npm run build",
"output": "dist"
},
"deploy": {
"strategy": "upload",
"uploadMode": "archive",
"cleanRemoteBeforeUpload": false,
"gitVersionInfo": {
"enabled": true,
"filename": "._gitVersionInfo"
}
},
"environments": {
"staging": {
"enable": true,
"remotePath": "/var/www/my-app-staging",
"beforeUpload": [
"mkdir -p /var/www/my-app-staging"
],
"afterUpload": [
"echo deployment complete"
]
},
"production": {
"enable": false,
"remotePath": "/var/www/my-app",
"beforeUpload": [
"mkdir -p /var/www/my-app"
],
"afterUpload": [
"pm2 reload my-app"
]
}
}
}Optional local override:
{
"environments": {
"staging": {
"host": "127.0.0.1",
"port": 22,
"username": "deploy",
"privateKey": "C:/Users/your-name/.ssh/id_rsa"
},
"production": {
"host": "127.0.0.1",
"port": 22,
"username": "deploy",
"privateKey": "C:/Users/your-name/.ssh/id_rsa"
}
}
}Config fields
version: config version for future compatibilityproject: project name used in logsbuild.command: local shell command for building the projectbuild.output: local artifact directory whose contents are deployeddeploy.strategy: currently onlyuploaddeploy.uploadMode:archiveordirect, defaultarchivedeploy.cleanRemoteBeforeUpload: clear target directory contents before uploaddeploy.gitVersionInfo.enabled: inject git version metadata into build output before upload, defaulttruedeploy.gitVersionInfo.filename: metadata file name written intobuild.output, default._gitVersionInfoenvironments.<name>.enable: whenfalse, deployment is blockedenvironments.<name>.host: SSH hostenvironments.<name>.port: SSH port, default22environments.<name>.username: SSH usernameenvironments.<name>.password: optional password authenvironments.<name>.privateKey: optional path to private key fileenvironments.<name>.passphrase: optional key passphraseenvironments.<name>.remotePath: remote upload directoryenvironments.<name>.beforeUpload: remote commands before uploadenvironments.<name>.afterUpload: remote commands after upload
Notes
bdcli deploydeploys all enabled environments sequentially in config order and skips environments withenable: falsebdcli deploy <env>fails whenenableisfalse- deploy uploads and extracts the contents inside
build.output, not the outer directory itself. For example,dist/index.htmlis deployed as<remotePath>/index.html, not<remotePath>/dist/index.html - clean mode refuses
/and remote paths shallower than 3 levels, and clears contents instead of deleting the directory itself - when git version info injection is enabled, bdcli writes a metadata file into
build.outputafter build and before upload. If git is unavailable or metadata collection fails, bdcli logs a warning and continues - the default metadata file name is
._gitVersionInfo. If your web server exposes dot-underscore files, add a server rule to block external access bdcli doctorvalidates config and attempts SSH connectionbdcli init --with-localcreates both config files- config discovery walks upward from the current working directory until it finds
/.deploy.config.json
