{"id":26682664,"url":"https://github.com/seonhyungjo/gardener","last_synced_at":"2026-04-09T07:33:10.052Z","repository":{"id":42338925,"uuid":"195804921","full_name":"SeonHyungJo/gardener","owner":"SeonHyungJo","description":"나만 없어 정원사. 나도 정원사 고용해보자 :house_with_garden:","archived":false,"fork":false,"pushed_at":"2022-12-09T17:33:26.000Z","size":355,"stargazers_count":1,"open_issues_count":9,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-15T22:09:15.851Z","etag":null,"topics":["fs","git","node","shell"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SeonHyungJo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-08T12:11:37.000Z","updated_at":"2023-08-22T07:09:48.000Z","dependencies_parsed_at":"2023-01-25T15:05:16.433Z","dependency_job_id":null,"html_url":"https://github.com/SeonHyungJo/gardener","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/SeonHyungJo%2Fgardener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeonHyungJo%2Fgardener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeonHyungJo%2Fgardener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeonHyungJo%2Fgardener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeonHyungJo","download_url":"https://codeload.github.com/SeonHyungJo/gardener/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245617608,"owners_count":20644848,"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":["fs","git","node","shell"],"created_at":"2025-03-26T08:27:47.759Z","updated_at":"2025-12-30T23:24:36.452Z","avatar_url":"https://github.com/SeonHyungJo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gardener\n\n**미니 정원사 고용!!** 😁\n\u003cbr/\u003e\n\n## 정원관리 시작하기\n\n```shell\n# start Gardener\nnpm start \n\n# start Gardener dev\nnpm run dev\n```\n\n## 파일 구성\n\n- `app.js` : 모든 정원관리에 대한 로직이 있는 파일(**write file**, **auto commit**, **send message_slack**)\n- `garden.md` : 정원관리 일지 \u0026 실질적으로 커밋을 하는 파일\n- `.env` : 슬랙에 대한 WEB_HOOK_API와 TOKEN_API를 저장한 환경변수 파일\n\n## 사용한 라이브러리\n\n#### package.json\n\n```json\n\"dayjs\": \"^1.8.15\",\n\"dotenv\": \"^8.0.0\",\n\"node-schedule\": \"^1.3.2\",\n\"nodemon\": \"^1.19.1\",\n\"shelljs\": \"^0.8.3\",\n\"slack-node\": \"^0.1.8\"\n```\n\n### dayjs\n\n날짜에 대한 포맷팅을 도와주는 라이브러리로 사람들이 많이 사용하는 [moment.js](https://momentjs.com/)가 있지만 현재 진행하는 프로젝트는 미니 프로젝트로 큰 용량을 요구하는 라이브러리 대신 상대적으로 용량이 적은 day.js를 사용하였다.\n\n```js\ndayjs(new Date).format(`YYYY년 MM월 DD일 HH:mm:ss`)\n```\n\n### dotenv\n\n슬랙에 메시지를 보내는 기능을 만들면서 생성한 **WEB_HOOK_API**, **TOKEN_API**를 레퍼지토리에 올려서 공개할 수 없으므로 .env 숨김 파일을 만들어서 작성한 뒤 불러와서 사용할 수 있도록 도와주는 dotenv 라이브러리를 사용했다.\n\n```js\nconst webhookUri = process.env.WEB_HOOK_API\nconst tokenApi = process.env.TOKEN_API\n```\n\n### node-schedule\n\n주기적으로 커밋을 찍기 위해서는 반복적으로 일을 해줄 수 있는 타이머가 필요하다.\n\n기본적으로 사용하는 `setInterval()`을 사용해서 맨 처음에 작성을 하였으나, 이쁘게 작성할 수 있는 포맷팅을 지원하여 사용하게 되었다. \n\n```js\nschedule.scheduleJob('* */6 * * *', function() {\n  DATE = dayjs(new Date).format(`YYYY년 MM월 DD일 HH:mm:ss`)\n\n  console.log(DATE, '=====물주기를 시작합니다.=====')\n\n  giveWater()\n    .then(autoCommit)\n    .then(sendMessage)\n    .catch((err) =\u003e {\n      console.log(err)\n    });\n});\n```\n\n`node-schedule` 라이브러리 내부적으로는 `setTimeOut()`으로 작성을 하고 있는 듯하다.\n\n\u003e [setTimeOut() 살펴보기](https://github.com/node-schedule/node-schedule/blob/cb5a08d4329f5f328cd094ca072ad7711811ece1/lib/schedule.js#L506\n\n### nodemon\n\n관련 파일의 변경사항이 있으면 서버를 재시작해주는 라이브러리인 `nodemon`을 사용하여 개발하는 시간을 줄였다.\n\n```js\n\"dev\": \"nodemon app.js\"\n```\n\n확실히 관련 라이브러리를 사용하게 되면 테스트에도 유용하다.\n\n### shell.js\n\n\u003e ShellJS is a portable (Windows/Linux/OS X) implementation of Unix shell commands on top of the Node.js API. You can use it to eliminate your shell script's dependency on Unix while still keeping its familiar and powerful commands. You can also install it globally so you can run it from outside Node projects - say goodbye to those gnarly Bash scripts!\n\n간단하게 말하자면 nodejs에서 shell script를 간편하게 사용하도록 도와주는 라이브러리이다.\n\ngit을 사용하는 데 있어서 script를 작성하는 데 도움을 주었다.\n\n```js\nshell.exec(`git add ${gardenName}`)\nshell.exec(`git commit -m \"${DATE} Auto-commit\"`)\nshell.exec(\"git push origin2 master\")\n```\n\n### slack-node\n\n정원을 관리하는 데 있어 언제 물을 주는지를 알고 싶었다.\n\n현재 사용하고 있는 개인 슬랙 채널에 알림이 오게 하는 것을 도와주는 라이브러리를 추가하였다.\n\n```js\nconst sendMessage = async () =\u003e {\n  slack.webhook(\n    {\n      text: 'Gardener-Noti',\n      attachments: [\n        {\n          fallback:\n            'GitHub으로 확인하기: \u003chttps://github.com/SeonHyungJo/gardener\u003e',\n          pretext:\n            'GitHub으로 확인하기: \u003chttps://github.com/SeonHyungJo/gardener\u003e',\n          color: '#00FFFF',\n          fields: [\n            {\n              title: `알림`,\n              value: `${DATE} 정원에 물을 주었습니다.`,\n              short: false\n            }\n          ]\n        }\n      ]\n    },\n    function(err, response) {\n      err ? console.log(err) : console.log(response);\n    }\n  );\n};\n```\n\n---\n\n#### Reference\n\n- [NPM - dayjs](https://www.npmjs.com/package/dayjs)\n- [NPM - dotenv](https://www.npmjs.com/package/dotenv)\n- [NPM - node-schedule](https://www.npmjs.com/package/node-schedule)\n- [NPM - shelljs](https://www.npmjs.com/package/shelljs)\n- [NPM - slack-node](https://www.npmjs.com/package/slack-node)\n- [NODEJS Download - nodejs](https://nodejs.org/ko/download/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseonhyungjo%2Fgardener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseonhyungjo%2Fgardener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseonhyungjo%2Fgardener/lists"}