{"id":22433701,"url":"https://github.com/gavinning/deploy","last_synced_at":"2025-03-27T07:45:58.581Z","repository":{"id":57174863,"uuid":"65999013","full_name":"gavinning/deploy","owner":"gavinning","description":"Nodejs服务发布工具，发布和回滚指定历史","archived":false,"fork":false,"pushed_at":"2016-08-21T09:21:49.000Z","size":226,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T12:46:36.502Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gavinning.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-18T13:23:05.000Z","updated_at":"2017-11-23T08:56:58.000Z","dependencies_parsed_at":"2022-08-29T00:11:08.574Z","dependency_job_id":null,"html_url":"https://github.com/gavinning/deploy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinning%2Fdeploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinning%2Fdeploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinning%2Fdeploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinning%2Fdeploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gavinning","download_url":"https://codeload.github.com/gavinning/deploy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245806390,"owners_count":20675296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-05T22:15:41.965Z","updated_at":"2025-03-27T07:45:58.564Z","avatar_url":"https://github.com/gavinning.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"deploy\n---\n\n### Install\n```sh\n$ npm i aimee-deploy --save\n```\n```sh\n$ npm i co gre --save\n$ npm i pm2 -g\n```\n\n### Usage\n```js\nvar $ = require('co');\nvar Gre = require('gre')\nvar gre = Gre.create('[:time][:title][:git] :message')\nvar Deploy = require('deploy');\nvar deploy = new Deploy({\n    git: {\n        // 远程Git仓库地址\n        url: 'https://github.com/gavinning/deploy-test.git',\n        // 本地目标地址\n        target: '/Users/gavinning/Desktop/test1234'\n    },\n    pm: {\n        // 应用名称\n        name: 'test',\n        // 可选，为空时自动赋值为 this.git.target\n        script: '/Users/gavinning/Desktop/test1234',\n        exec_mode : 'cluster',\n        instances : 1,\n        max_memory_restart : '100M'\n    }\n})\n```\n\n### Example\nPublish 发布\n```js\n// 快捷发布方式\ndeploy.publish().then(function(){\n    // do something\n})\n```\n```js\n// 详细发布流程\n$(function *(){\n    try{\n        // 连接git仓库\n        gre.info('Deploy start...')\n        gre.info('Deploy connect repository')\n        yield deploy.git.repo()\n\n        // 更新git仓库\n        gre.info('Deploy pull repository')\n        yield deploy.git.pull()\n\n        // 发布新版本\n        gre.info('Deploy publish repository')\n        yield deploy.git.publish()\n\n        // 安装NPM依赖\n        gre.info('Deploy install dependencies...')\n        yield deploy.npm.install()\n\n        // 连接pm2\n        gre.info('Deploy connect pm2')\n        yield deploy.pm.connect()\n\n        // 启动app\n        gre.info('Deploy start', deploy.config.pm.name)\n        yield deploy.pm.start()\n\n        // 关闭pm2连接\n        gre.info('Deploy close pm2 connect', deploy.config.pm.name)\n        deploy.pm.disconnect()\n\n        gre.info('Deploy all process done!')\n    }\n    catch(e){\n        console.log(e.message)\n    }\n})\n```\n![](examples/img/1.jpg)\n\n### Example\nRollback 回滚\n```js\n// 快捷回滚方式\ndeploy.rollback(tagName).then(function(){\n    // do something\n})\n```\n```js\n// 详细回滚流程\n$(function *(){\n    try{\n        // 连接git仓库\n        gre.info('Deploy start...')\n        gre.info('Deploy connect repository')\n        yield deploy.git.repo()\n\n        // 回滚到指定版本\n        gre.info('Deploy rollback repository')\n        yield deploy.git.rollback(tagName)\n\n        // 连接pm2\n        gre.info('Deploy connect pm2')\n        yield deploy.pm.connect()\n\n        // 启动app\n        gre.info('Deploy start', deploy.config.pm.name)\n        yield deploy.pm.start()\n\n        // 关闭pm2连接\n        gre.info('Deploy close pm2 connect', deploy.config.pm.name)\n        deploy.pm.disconnect()\n\n        gre.info('Deploy all process done!')\n    }\n    catch(e){\n        console.log(e.message)\n    }\n})\n```\n\n---\n```sh\n$ pm2 ls\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavinning%2Fdeploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgavinning%2Fdeploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavinning%2Fdeploy/lists"}