Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
init first working setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ff6347 committed Sep 4, 2020
1 parent 65e38e9 commit 829eed0
Show file tree
Hide file tree
Showing 10 changed files with 11,535 additions and 17 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@inpyjamas/scripts/eslint");
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ npm-debug.log
.env
coverage
lib
.env
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#5c541f",
"activityBar.activeBorder": "#081816",
"activityBar.background": "#5c541f",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#081816",
"activityBarBadge.foreground": "#e7e7e7",
"statusBar.background": "#363112",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#5c541f",
"titleBar.activeBackground": "#363112",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#36311299",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#363112"
}
11 changes: 11 additions & 0 deletions assets/pr-body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Hey ho. It's me your friendly neighborhood Roboto and I'd like to contribute some files to your new repo.
That's why I created a file to under your .github folder. So we have some content we can work with.

This PR will contain some files you will need in any repository. Currently its these:

- `.github/renovate.json`
- `.github/CODEOWNERS`

It would be great to merge these so renovate-bot can start to keep your dependencies up to date and new PRs are assigned to you as a codeowner.

To learn more about [me](#), [renovate-bot](https://renovate.whitesourcesoftware.com/) and [codeowners](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners) follow the links.
4 changes: 4 additions & 0 deletions assets/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["@inpyjamas"]
}
12 changes: 12 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"restartable": "rs",
"ignore": [".git", "node_modules/**/node_modules"],
"verbose": true,

"watch": ["src/"],
"env": {
"NODE_ENV": "development"
},
"exec": "npm run build && npm start",
"ext": "ts"
}
11,303 changes: 11,303 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "roboto",
"version": "1.0.0",
"name": "@inpyjamas/roboto",
"version": "0.1.0",
"private": true,
"description": "A robot for doing chores on repos",
"author": "fabianmoronzirfas <[email protected]>",
"license": "ISC",
"author": "Fabian Morón Zirfas <[email protected]>",
"license": "MIT",
"repository": "https://github.com/fabianmoronzirfas/roboto.git",
"homepage": "https://github.com/fabianmoronzirfas/roboto",
"bugs": "https://github.com/fabianmoronzirfas/roboto/issues",
Expand All @@ -16,22 +16,28 @@
"scripts": {
"build": "tsc",
"start": "probot run ./lib/index.js",
"test": "jest"
"test": "jest",
"dev": "ts-node-dev --respawn --transpile-only src/main.ts",
"nodemon": "nodemon"
},
"dependencies": {
"probot": "^10.1.0"
"octokit-plugin-create-pull-request": "3.9.0",
"probot": "10.1.3"
},
"devDependencies": {
"@inpyjamas/scripts": "0.1.7-alpha",
"@types/jest": "^26.0.9",
"@types/nock": "^11.1.0",
"@types/node": "^14.0.27",
"@typescript-eslint/parser": "^3.9.0",
"eslint-plugin-typescript": "^0.14.0",
"jest": "^26.4.0",
"nock": "^13.0.4",
"nodemon": "2.0.4",
"smee-client": "^1.1.0",
"ts-jest": "^26.2.0",
"typescript": "^3.9.7"
"ts-node-dev": "1.0.0-pre.62",
"typescript": "4.0.2"
},
"engines": {
"node": ">= 10.13.0"
Expand Down
60 changes: 50 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,53 @@
import { Application } from 'probot' // eslint-disable-line no-unused-vars
// 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/
import { Application } from "probot";
import { composeCreatePullRequest } from "octokit-plugin-create-pull-request";
import fs from "fs";
import path from "path";
const prBody = fs.readFileSync(
path.resolve(__dirname, "../assets/pr-body.md"),
"utf8"
);
const renovateJson = fs.readFileSync(
path.resolve(__dirname, "../assets/renovate.json"),
"utf8"
);
export = (app: Application) => {
app.on('issues.opened', async (context) => {
const issueComment = context.issue({ body: 'Thanks for opening this issue!' })
await context.github.issues.createComment(issueComment)
})
// For more information on building apps:
// https://probot.github.io/docs/
app.on("repository.created", async (context) => {
const {
payload: { repository },
log,
} = context;
const configResponse = await context.github.repos.createOrUpdateFileContents(
{
owner: repository.owner.login,
repo: repository.name,
path: ".github/inpyjamas-roboto.config.yml",
message: "init roboto config",
content: Buffer.from("# hello world").toString("base64"),
}
);
if (configResponse === null) return;
log(configResponse);
const response = await composeCreatePullRequest(context.github, {
owner: repository.owner.login,
repo: repository.name,
title: "inpyjamas-roboto default configs",
body: prBody,
head: `chore/inpyjamas-roboto-onboard`,
changes: {
commit: "inpyjamas-roboto onboarding",

// To get your app running against GitHub, see:
// https://probot.github.io/docs/development/
}
files: {
".github/renovate.json": renovateJson,
".github/CODEOWNERS": `* @${repository.owner.login}`,
},
},
});
if (response === null) return;
log(response);
});
};
121 changes: 121 additions & 0 deletions test/fixtures/repository.created.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"action": "created",
"repository": {
"id": 292621599,
"node_id": "MDEwOlJlcG9zaXRvcnkyOTI2MjE1OTk=",
"name": "hello-robot-3",
"full_name": "fabianmoronzirfas/hello-robot-3",
"private": true,
"owner": {
"login": "fabianmoronzirfas",
"id": 315106,
"node_id": "MDQ6VXNlcjMxNTEwNg==",
"avatar_url": "https://avatars3.githubusercontent.com/u/315106?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/fabianmoronzirfas",
"html_url": "https://github.com/fabianmoronzirfas",
"followers_url": "https://api.github.com/users/fabianmoronzirfas/followers",
"following_url": "https://api.github.com/users/fabianmoronzirfas/following{/other_user}",
"gists_url": "https://api.github.com/users/fabianmoronzirfas/gists{/gist_id}",
"starred_url": "https://api.github.com/users/fabianmoronzirfas/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/fabianmoronzirfas/subscriptions",
"organizations_url": "https://api.github.com/users/fabianmoronzirfas/orgs",
"repos_url": "https://api.github.com/users/fabianmoronzirfas/repos",
"events_url": "https://api.github.com/users/fabianmoronzirfas/events{/privacy}",
"received_events_url": "https://api.github.com/users/fabianmoronzirfas/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/fabianmoronzirfas/hello-robot-3",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3",
"forks_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/forks",
"keys_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/teams",
"hooks_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/hooks",
"issue_events_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/issues/events{/number}",
"events_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/events",
"assignees_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/assignees{/user}",
"branches_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/branches{/branch}",
"tags_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/tags",
"blobs_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/statuses/{sha}",
"languages_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/languages",
"stargazers_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/stargazers",
"contributors_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/contributors",
"subscribers_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/subscribers",
"subscription_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/subscription",
"commits_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/contents/{+path}",
"compare_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/merges",
"archive_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/downloads",
"issues_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/issues{/number}",
"pulls_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/pulls{/number}",
"milestones_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/milestones{/number}",
"notifications_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/labels{/name}",
"releases_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/releases{/id}",
"deployments_url": "https://api.github.com/repos/fabianmoronzirfas/hello-robot-3/deployments",
"created_at": "2020-09-03T16:22:05Z",
"updated_at": "2020-09-03T16:22:05Z",
"pushed_at": null,
"git_url": "git://github.com/fabianmoronzirfas/hello-robot-3.git",
"ssh_url": "[email protected]:fabianmoronzirfas/hello-robot-3.git",
"clone_url": "https://github.com/fabianmoronzirfas/hello-robot-3.git",
"svn_url": "https://github.com/fabianmoronzirfas/hello-robot-3",
"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": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 0,
"license": null,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master"
},
"sender": {
"login": "fabianmoronzirfas",
"id": 315106,
"node_id": "MDQ6VXNlcjMxNTEwNg==",
"avatar_url": "https://avatars3.githubusercontent.com/u/315106?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/fabianmoronzirfas",
"html_url": "https://github.com/fabianmoronzirfas",
"followers_url": "https://api.github.com/users/fabianmoronzirfas/followers",
"following_url": "https://api.github.com/users/fabianmoronzirfas/following{/other_user}",
"gists_url": "https://api.github.com/users/fabianmoronzirfas/gists{/gist_id}",
"starred_url": "https://api.github.com/users/fabianmoronzirfas/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/fabianmoronzirfas/subscriptions",
"organizations_url": "https://api.github.com/users/fabianmoronzirfas/orgs",
"repos_url": "https://api.github.com/users/fabianmoronzirfas/repos",
"events_url": "https://api.github.com/users/fabianmoronzirfas/events{/privacy}",
"received_events_url": "https://api.github.com/users/fabianmoronzirfas/received_events",
"type": "User",
"site_admin": false
},
"installation": {
"id": 11619845,
"node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMTE2MTk4NDU="
}
}

0 comments on commit 829eed0

Please sign in to comment.