From 84dbfc0e3fe38965ff2781112af23325a9d426ad Mon Sep 17 00:00:00 2001 From: Bex Warner Date: Thu, 23 Aug 2018 14:01:51 -0500 Subject: [PATCH] add folders for templates --- .github/CODEOWNERS | 1 - basic-js/.DS_Store | Bin 0 -> 6148 bytes .env.example => basic-js/.env.example | 0 .gitignore => basic-js/.gitignore | 0 .../CODE_OF_CONDUCT.md | 0 CONTRIBUTING.md => basic-js/CONTRIBUTING.md | 0 LICENSE => basic-js/LICENSE | 0 README.md => basic-js/README.md | 0 index.js => basic-js/index.js | 0 package.json => basic-js/package.json | 0 .../test}/fixtures/issues.opened.json | 0 {test => basic-js/test}/index.test.js | 0 .travis.yml => basic-js/travis.yml | 0 basic-ts/.env.example | 9 + basic-ts/.github/CODEOWNERS | 1 + basic-ts/.gitignore | 7 + basic-ts/.travis.yml | 6 + basic-ts/CODE_OF_CONDUCT.md | 74 ++++++++ basic-ts/CONTRIBUTING.md | 41 +++++ basic-ts/LICENSE | 15 ++ basic-ts/README.md | 26 +++ basic-ts/jest.config.js | 8 + basic-ts/package.json | 50 ++++++ basic-ts/src/index.ts | 12 ++ basic-ts/test/index.test.ts | 10 ++ basic-ts/tsconfig.json | 24 +++ checks-js/.DS_Store | Bin 0 -> 6148 bytes checks-js/.env.example | 9 + checks-js/.gitignore | 6 + checks-js/.travis.yml | 6 + checks-js/CODE_OF_CONDUCT.md | 74 ++++++++ checks-js/CONTRIBUTING.md | 41 +++++ checks-js/LICENSE | 15 ++ checks-js/README.md | 23 +++ checks-js/index.js | 34 ++++ checks-js/package.json | 43 +++++ checks-js/test/fixtures/issues.opened.json | 159 ++++++++++++++++++ checks-js/test/index.test.js | 42 +++++ git-data-js/.DS_Store | Bin 0 -> 6148 bytes git-data-js/.env.example | 9 + git-data-js/.gitignore | 6 + git-data-js/.travis.yml | 6 + git-data-js/CODE_OF_CONDUCT.md | 74 ++++++++ git-data-js/CONTRIBUTING.md | 41 +++++ git-data-js/LICENSE | 15 ++ git-data-js/README.md | 23 +++ git-data-js/index.js | 42 +++++ git-data-js/package.json | 43 +++++ git-data-js/test/fixtures/issues.opened.json | 159 ++++++++++++++++++ git-data-js/test/index.test.js | 42 +++++ 50 files changed, 1195 insertions(+), 1 deletion(-) delete mode 100644 .github/CODEOWNERS create mode 100644 basic-js/.DS_Store rename .env.example => basic-js/.env.example (100%) rename .gitignore => basic-js/.gitignore (100%) rename CODE_OF_CONDUCT.md => basic-js/CODE_OF_CONDUCT.md (100%) rename CONTRIBUTING.md => basic-js/CONTRIBUTING.md (100%) rename LICENSE => basic-js/LICENSE (100%) rename README.md => basic-js/README.md (100%) rename index.js => basic-js/index.js (100%) rename package.json => basic-js/package.json (100%) rename {test => basic-js/test}/fixtures/issues.opened.json (100%) rename {test => basic-js/test}/index.test.js (100%) rename .travis.yml => basic-js/travis.yml (100%) create mode 100755 basic-ts/.env.example create mode 100755 basic-ts/.github/CODEOWNERS create mode 100755 basic-ts/.gitignore create mode 100755 basic-ts/.travis.yml create mode 100755 basic-ts/CODE_OF_CONDUCT.md create mode 100755 basic-ts/CONTRIBUTING.md create mode 100755 basic-ts/LICENSE create mode 100755 basic-ts/README.md create mode 100755 basic-ts/jest.config.js create mode 100755 basic-ts/package.json create mode 100755 basic-ts/src/index.ts create mode 100755 basic-ts/test/index.test.ts create mode 100755 basic-ts/tsconfig.json create mode 100644 checks-js/.DS_Store create mode 100644 checks-js/.env.example create mode 100644 checks-js/.gitignore create mode 100644 checks-js/.travis.yml create mode 100644 checks-js/CODE_OF_CONDUCT.md create mode 100644 checks-js/CONTRIBUTING.md create mode 100644 checks-js/LICENSE create mode 100644 checks-js/README.md create mode 100644 checks-js/index.js create mode 100644 checks-js/package.json create mode 100644 checks-js/test/fixtures/issues.opened.json create mode 100644 checks-js/test/index.test.js create mode 100644 git-data-js/.DS_Store create mode 100644 git-data-js/.env.example create mode 100644 git-data-js/.gitignore create mode 100644 git-data-js/.travis.yml create mode 100644 git-data-js/CODE_OF_CONDUCT.md create mode 100644 git-data-js/CONTRIBUTING.md create mode 100644 git-data-js/LICENSE create mode 100644 git-data-js/README.md create mode 100644 git-data-js/index.js create mode 100644 git-data-js/package.json create mode 100644 git-data-js/test/fixtures/issues.opened.json create mode 100644 git-data-js/test/index.test.js diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 9e5dfd7..0000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @hiimbex @bkeepers diff --git a/basic-js/.DS_Store b/basic-js/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1e46bde9748f1b55e7c23d595fe1425ade6bc0ef GIT binary patch literal 6148 zcmeHKQA+|r5dPK#PYODE>hXR-&_B5Jt`O>iv}a3=sLTsA=<)t}eKWf#VsSnN$_&hW zd%H8Ux8KT*1Hg4YC+9#6AfgI3+BCn2tcz|)Bh0jjPIC-#i%SgAC7SF419EpKdS4lG z-rVZ`3S_wF$^d70$D}tc$D?UEqJR9oCVI?c%~8<%4n1@jIUp9e+A2E23uc($319So z#k^*>7Ot7S%Qr62M_%K7gbzGoj5pe6?x8!N#H=Q+&9mgVAP+ahZCGex!TfV9YBKM_ zFT>u^7%&F*nE}>pk?7E)S!2K$Fb0+k$oCF&&*s5@Nh(X26G46HM7;2&eD z|M}nj|9X%;83V?^UNPXBSwHLWNTIfF98PL&LVci$h+pM#8Nz{ A GitHub App built with [Probot](https://github.com/probot/probot) that {{ description }} + +## Setup + +```sh +# Install dependencies +npm install + +# Run typescript +npm run build + +# Run the bot +npm start +``` + +## Contributing + +If you have suggestions for how {{ name }} could be improved, or want to report a bug, open an issue! We'd love all and any contributions. + +For more, check out the [Contributing Guide](CONTRIBUTING.md). + +## License + +[ISC](LICENSE) © {{{ year }}} {{{ author }}} diff --git a/basic-ts/jest.config.js b/basic-ts/jest.config.js new file mode 100755 index 0000000..8dfffb2 --- /dev/null +++ b/basic-ts/jest.config.js @@ -0,0 +1,8 @@ +module.exports = { + roots: ['/src/', '/test/'], + transform: { + '^.+\\.tsx?$': 'ts-jest' + }, + testRegex: '(/__tests__/.*|\\.(test|spec))\\.[tj]sx?$', + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'] +} \ No newline at end of file diff --git a/basic-ts/package.json b/basic-ts/package.json new file mode 100755 index 0000000..de560bb --- /dev/null +++ b/basic-ts/package.json @@ -0,0 +1,50 @@ +{ + "name": "{{ name }}", + "version": "1.0.0", + "description": "{{{ description }}}", + "author": "{{{ author }}}", + "license": "ISC", + "repository": "https://github.com/{{ owner }}/{{ repo }}.git", + "homepage": "https://github.com/{{ owner }}/{{ repo }}", + "bugs": "https://github.com/{{ owner }}/{{ repo }}/issues", + "keywords": [ + "probot", + "github", + "probot-app" + ], + "scripts": { + "build": "tsc -p tsconfig.json", + "dev": "nodemon --exec \"npm start\"", + "start": "probot run ./lib/index.js", + "lint": "standard **/*.ts --fix", + "test": "jest && standard **/*.ts", + "test:watch": "jest --watch --notify --notifyMode=change --coverage" + }, + "dependencies": { + "probot": "^7.0.0" + }, + "devDependencies": { + "@types/jest": "^23.1.5", + "@types/node": "^10.5.2", + "eslint-plugin-typescript": "^0.12.0", + "jest": "^23.4.0", + "nodemon": "^1.17.2", + "smee-client": "^1.0.2", + "standard": "^10.0.3", + "ts-jest": "^23.0.0", + "typescript": "^2.9.2", + "typescript-eslint-parser": "^18.0.0" + }, + "engines": { + "node": ">= 8.3.0" + }, + "standard": { + "parser": "typescript-eslint-parser", + "env": [ + "jest" + ], + "plugins": [ + "typescript" + ] + } +} diff --git a/basic-ts/src/index.ts b/basic-ts/src/index.ts new file mode 100755 index 0000000..2137b0e --- /dev/null +++ b/basic-ts/src/index.ts @@ -0,0 +1,12 @@ +import { Application } from 'probot' + +export = (app: Application) => { + // Your code here + app.log('Yay, the app was loaded!') + + // For more information on building apps: + // https://probot.github.io/docs/ + + // To get your app running against GitHub, see: + // https://probot.github.io/docs/development/ +} diff --git a/basic-ts/test/index.test.ts b/basic-ts/test/index.test.ts new file mode 100755 index 0000000..c800167 --- /dev/null +++ b/basic-ts/test/index.test.ts @@ -0,0 +1,10 @@ +// You can import your modules +// import index from '../src/index' + +test('that we can run tests', () => { + // your real tests go here + expect(1 + 2 + 3).toBe(6) +}) + +// For more information about using TypeScript in your tests, Jest recommends: +// https://github.com/kulshekhar/ts-jest diff --git a/basic-ts/tsconfig.json b/basic-ts/tsconfig.json new file mode 100755 index 0000000..e4c4618 --- /dev/null +++ b/basic-ts/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "allowJs": false, + "lib": ["es2015", "es2017"], + "module": "commonjs", + "moduleResolution": "node", + "target": "es5", + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "noUnusedLocals": true, + "pretty": true, + "strict": true, + "sourceMap": true, + "outDir": "./lib", + "skipLibCheck": true, + "noImplicitAny": true, + "esModuleInterop": true, + "declaration": true + }, + "include": [ + "src/**/*" + ], + "compileOnSave": false +} diff --git a/checks-js/.DS_Store b/checks-js/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1e46bde9748f1b55e7c23d595fe1425ade6bc0ef GIT binary patch literal 6148 zcmeHKQA+|r5dPK#PYODE>hXR-&_B5Jt`O>iv}a3=sLTsA=<)t}eKWf#VsSnN$_&hW zd%H8Ux8KT*1Hg4YC+9#6AfgI3+BCn2tcz|)Bh0jjPIC-#i%SgAC7SF419EpKdS4lG z-rVZ`3S_wF$^d70$D}tc$D?UEqJR9oCVI?c%~8<%4n1@jIUp9e+A2E23uc($319So z#k^*>7Ot7S%Qr62M_%K7gbzGoj5pe6?x8!N#H=Q+&9mgVAP+ahZCGex!TfV9YBKM_ zFT>u^7%&F*nE}>pk?7E)S!2K$Fb0+k$oCF&&*s5@Nh(X26G46HM7;2&eD z|M}nj|9X%;83V?^UNPXBSwHLWNTIfF98PL&LVci$h+pM#8Nz{ A GitHub App built with [Probot](https://github.com/probot/probot) that {{ description }} + +## Setup + +```sh +# Install dependencies +npm install + +# Run the bot +npm start +``` + +## Contributing + +If you have suggestions for how {{ name }} could be improved, or want to report a bug, open an issue! We'd love all and any contributions. + +For more, check out the [Contributing Guide](CONTRIBUTING.md). + +## License + +[ISC](LICENSE) © {{{ year }}} {{{ author }}} diff --git a/checks-js/index.js b/checks-js/index.js new file mode 100644 index 0000000..84daa2e --- /dev/null +++ b/checks-js/index.js @@ -0,0 +1,34 @@ +/** + * This is the entry point for your Probot App. + * @param {import('probot').Application} app - Probot's Application class. +*/ + +// Checks API example +// See: https://developer.github.com/v3/checks/ to learn more +module.exports = app => { + app.on(['check_suite.requested', 'check_run.rerequested'], check) + + async function check (context) { + // Do stuff + // Probot API note: context.repo() => {username: 'hiimbex', repo: 'testing-things'} + return context.github.checks.create(context.repo({ + name: 'My app!', + head_branch: pr.head.ref, + head_sha: pr.head.sha, + status: 'completed', + conclusion: 'success', + completed_at: new Date(), + output: { + title: 'My Check', + summary: 'The check has passed!' + } + })) + } +} + + // For more information on building apps: + // https://probot.github.io/docs/ + + // To get your app running against GitHub, see: + // https://probot.github.io/docs/development/ +} diff --git a/checks-js/package.json b/checks-js/package.json new file mode 100644 index 0000000..1d7d8e3 --- /dev/null +++ b/checks-js/package.json @@ -0,0 +1,43 @@ +{ + "name": "{{ name }}", + "version": "1.0.0", + "description": "{{{ description }}}", + "author": "{{{ author }}}", + "license": "ISC", + "repository": "https://github.com/{{ owner }}/{{ repo }}.git", + "homepage": "https://github.com/{{ owner }}/{{ repo }}", + "bugs": "https://github.com/{{ owner }}/{{ repo }}/issues", + "keywords": [ + "probot", + "github", + "probot-app" + ], + "scripts": { + "dev": "nodemon", + "start": "probot run ./index.js", + "lint": "standard --fix", + "test": "jest && standard", + "test:watch": "jest --watch --notify --notifyMode=change --coverage" + }, + "dependencies": { + "probot": "^7.0.0" + }, + "devDependencies": { + "jest": "^22.4.3", + "nodemon": "^1.17.2", + "smee-client": "^1.0.2", + "standard": "^10.0.3" + }, + "engines": { + "node": ">= 8.3.0" + }, + "standard": { + "env": [ + "jest" + ] + }, + "nodemonConfig": { + "exec": "npm start", + "watch": [".env", "."] + } +} diff --git a/checks-js/test/fixtures/issues.opened.json b/checks-js/test/fixtures/issues.opened.json new file mode 100644 index 0000000..84ebf04 --- /dev/null +++ b/checks-js/test/fixtures/issues.opened.json @@ -0,0 +1,159 @@ +{ + "action": "opened", + "issue": { + "url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2", + "repository_url": "https://api.github.com/repos/Codertocat/Hello-World", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2/labels{/name}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2/comments", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2/events", + "html_url": "https://github.com/Codertocat/Hello-World/issues/2", + "id": 327883527, + "node_id": "MDU6SXNzdWUzMjc4ODM1Mjc=", + "number": 2, + "title": "Spelling error in the README file", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "state": "open", + "locked": false, + "assignee": null, + "assignees": [], + "milestone": null, + "comments": 0, + "created_at": "2018-05-30T20:18:32Z", + "updated_at": "2018-05-30T20:18:32Z", + "closed_at": null, + "author_association": "OWNER", + "body": "It looks like you accidently spelled 'commit' with two 't's." + }, + "repository": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:10Z", + "pushed_at": "2018-05-30T20:18:30Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 2, + "license": null, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/checks-js/test/index.test.js b/checks-js/test/index.test.js new file mode 100644 index 0000000..674c7f7 --- /dev/null +++ b/checks-js/test/index.test.js @@ -0,0 +1,42 @@ +const { Application } = require('probot') +// Requiring our app implementation +const myProbotApp = require('..') + +const issuesOpenedPayload = require('./fixtures/issues.opened.json') + +test('that we can run tests', () => { + // your real tests go here + expect(1 + 2 + 3).toBe(6) +}) + +describe('My Probot app', () => { + let app, github + + beforeEach(() => { + app = new Application() + // Initialize the app based on the code from index.js + app.load(myProbotApp) + // This is an easy way to mock out the GitHub API + github = { + issues: { + createComment: jest.fn().mockReturnValue(Promise.resolve({})) + } + } + // Passes the mocked out GitHub API into out app instance + app.auth = () => Promise.resolve(github) + }) + + test('creates a comment when an issue is opened', async () => { + // Simulates delivery of an issues.opened webhook + await app.receive({ + event: 'issues.opened', + payload: issuesOpenedPayload + }) + + // This test passes if the code in your index.js file calls `context.github.issues.createComment` + expect(github.issues.createComment).toHaveBeenCalled() + }) +}) + +// For more information about testing with Jest see: +// https://facebook.github.io/jest/ diff --git a/git-data-js/.DS_Store b/git-data-js/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1e46bde9748f1b55e7c23d595fe1425ade6bc0ef GIT binary patch literal 6148 zcmeHKQA+|r5dPK#PYODE>hXR-&_B5Jt`O>iv}a3=sLTsA=<)t}eKWf#VsSnN$_&hW zd%H8Ux8KT*1Hg4YC+9#6AfgI3+BCn2tcz|)Bh0jjPIC-#i%SgAC7SF419EpKdS4lG z-rVZ`3S_wF$^d70$D}tc$D?UEqJR9oCVI?c%~8<%4n1@jIUp9e+A2E23uc($319So z#k^*>7Ot7S%Qr62M_%K7gbzGoj5pe6?x8!N#H=Q+&9mgVAP+ahZCGex!TfV9YBKM_ zFT>u^7%&F*nE}>pk?7E)S!2K$Fb0+k$oCF&&*s5@Nh(X26G46HM7;2&eD z|M}nj|9X%;83V?^UNPXBSwHLWNTIfF98PL&LVci$h+pM#8Nz{ A GitHub App built with [Probot](https://github.com/probot/probot) that {{ description }} + +## Setup + +```sh +# Install dependencies +npm install + +# Run the bot +npm start +``` + +## Contributing + +If you have suggestions for how {{ name }} could be improved, or want to report a bug, open an issue! We'd love all and any contributions. + +For more, check out the [Contributing Guide](CONTRIBUTING.md). + +## License + +[ISC](LICENSE) © {{{ year }}} {{{ author }}} diff --git a/git-data-js/index.js b/git-data-js/index.js new file mode 100644 index 0000000..932577c --- /dev/null +++ b/git-data-js/index.js @@ -0,0 +1,42 @@ +/** + * This is the entry point for your Probot App. + * @param {import('probot').Application} app - Probot's Application class. +*/ + +// Git Data API example +// See: https://developer.github.com/v3/git/ to learn more +module.exports = app => { + app.on('*', check) + + async function check (context) { + // Probot API note: context.repo() => {username: 'hiimbex', repo: 'testing-things'} + // Get current reference in Git + const reference = await context.github.gitdata.getReference(context.repo({ ref: 'heads/master' })) + // Create a brnach + const getBranch = await context.github.gitdata.createReference(context.repo({ + ref: `refs/heads/new-branch`, + sha: reference.data.object.sha // accesses the sha from the heads/master reference we got + })) + // create a cne wfile + const file = await context.github.repos.createFile(context.repo({ + path: 'path/to/your/file.md', // the path to your config file + message: 'adds config file', // a commit message + content: 'My new file is awesome!', //the content of your file + branch: 'new-branch' // the branch name we used when creating a Git reference + })) + return await context.github.pullRequests.create(context.repo({ + title: 'Adding my file!', // the title of the PR + head: 'new-branch', // the branch our chances are on + base: 'master', // the branch to which you want to merge your changes + body: 'Adds my new file!', // the body of your PR, + maintainer_can_modify: true // allows maintainers to edit your app's PR + })) + } +} + + // For more information on building apps: + // https://probot.github.io/docs/ + + // To get your app running against GitHub, see: + // https://probot.github.io/docs/development/ +} diff --git a/git-data-js/package.json b/git-data-js/package.json new file mode 100644 index 0000000..1d7d8e3 --- /dev/null +++ b/git-data-js/package.json @@ -0,0 +1,43 @@ +{ + "name": "{{ name }}", + "version": "1.0.0", + "description": "{{{ description }}}", + "author": "{{{ author }}}", + "license": "ISC", + "repository": "https://github.com/{{ owner }}/{{ repo }}.git", + "homepage": "https://github.com/{{ owner }}/{{ repo }}", + "bugs": "https://github.com/{{ owner }}/{{ repo }}/issues", + "keywords": [ + "probot", + "github", + "probot-app" + ], + "scripts": { + "dev": "nodemon", + "start": "probot run ./index.js", + "lint": "standard --fix", + "test": "jest && standard", + "test:watch": "jest --watch --notify --notifyMode=change --coverage" + }, + "dependencies": { + "probot": "^7.0.0" + }, + "devDependencies": { + "jest": "^22.4.3", + "nodemon": "^1.17.2", + "smee-client": "^1.0.2", + "standard": "^10.0.3" + }, + "engines": { + "node": ">= 8.3.0" + }, + "standard": { + "env": [ + "jest" + ] + }, + "nodemonConfig": { + "exec": "npm start", + "watch": [".env", "."] + } +} diff --git a/git-data-js/test/fixtures/issues.opened.json b/git-data-js/test/fixtures/issues.opened.json new file mode 100644 index 0000000..84ebf04 --- /dev/null +++ b/git-data-js/test/fixtures/issues.opened.json @@ -0,0 +1,159 @@ +{ + "action": "opened", + "issue": { + "url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2", + "repository_url": "https://api.github.com/repos/Codertocat/Hello-World", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2/labels{/name}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2/comments", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/2/events", + "html_url": "https://github.com/Codertocat/Hello-World/issues/2", + "id": 327883527, + "node_id": "MDU6SXNzdWUzMjc4ODM1Mjc=", + "number": 2, + "title": "Spelling error in the README file", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "state": "open", + "locked": false, + "assignee": null, + "assignees": [], + "milestone": null, + "comments": 0, + "created_at": "2018-05-30T20:18:32Z", + "updated_at": "2018-05-30T20:18:32Z", + "closed_at": null, + "author_association": "OWNER", + "body": "It looks like you accidently spelled 'commit' with two 't's." + }, + "repository": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:10Z", + "pushed_at": "2018-05-30T20:18:30Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 2, + "license": null, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/git-data-js/test/index.test.js b/git-data-js/test/index.test.js new file mode 100644 index 0000000..674c7f7 --- /dev/null +++ b/git-data-js/test/index.test.js @@ -0,0 +1,42 @@ +const { Application } = require('probot') +// Requiring our app implementation +const myProbotApp = require('..') + +const issuesOpenedPayload = require('./fixtures/issues.opened.json') + +test('that we can run tests', () => { + // your real tests go here + expect(1 + 2 + 3).toBe(6) +}) + +describe('My Probot app', () => { + let app, github + + beforeEach(() => { + app = new Application() + // Initialize the app based on the code from index.js + app.load(myProbotApp) + // This is an easy way to mock out the GitHub API + github = { + issues: { + createComment: jest.fn().mockReturnValue(Promise.resolve({})) + } + } + // Passes the mocked out GitHub API into out app instance + app.auth = () => Promise.resolve(github) + }) + + test('creates a comment when an issue is opened', async () => { + // Simulates delivery of an issues.opened webhook + await app.receive({ + event: 'issues.opened', + payload: issuesOpenedPayload + }) + + // This test passes if the code in your index.js file calls `context.github.issues.createComment` + expect(github.issues.createComment).toHaveBeenCalled() + }) +}) + +// For more information about testing with Jest see: +// https://facebook.github.io/jest/