-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add /probot route with tests * Add index route, write tests * Remove unused arg * Pass tests * Tweak HTML string and pkg require * Add static directory * Design welcome page * Rename to probot.html * Implement EJS * Remove duplicate load * Extract default homepage into plugin * Fix issue after merge conflict * Refactor app loading * Remove autoloading of plugings BREAKING CHANGE: `probot run` without any arguments will no longer autoload apps named `probot-*`. * Move setup * Look for `apps` key instead of `plugins` * Update simulate command * Simplify resolver * Remove unused routes variable * Move views to default path * Call probot.setup to properly initialize default apps * Simplify package loading * Specify extension * Add links to docs/slack * Remove stats link * Add helper to jest ignore * Fix ejs views error * Move a require to top of file * Remove unnecessary (and breaking) test
- Loading branch information
Showing
13 changed files
with
222 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const path = require('path') | ||
|
||
let pkg | ||
|
||
try { | ||
pkg = require(path.join(process.cwd(), 'package.json')) | ||
} catch (e) { | ||
pkg = {} | ||
} | ||
|
||
module.exports = robot => { | ||
const app = robot.route() | ||
|
||
app.get('/probot', (req, res) => res.render('probot.ejs', pkg)) | ||
app.get('/', (req, res, next) => res.redirect('/probot')) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const request = require('supertest') | ||
const express = require('express') | ||
const plugin = require('../../lib/plugins/default') | ||
const helper = require('./helper') | ||
|
||
describe('default plugin', function () { | ||
let server, robot | ||
|
||
beforeEach(async () => { | ||
robot = helper.createRobot() | ||
|
||
await plugin(robot) | ||
|
||
server = express() | ||
|
||
server.use(robot.router) | ||
}) | ||
|
||
describe('GET /probot', () => { | ||
it('returns a 200 response', () => { | ||
return request(server).get('/probot').expect(200) | ||
}) | ||
}) | ||
|
||
describe('GET /', () => { | ||
it('redirects to /probot', () => { | ||
return request(server).get('/').expect(302).expect('location', '/probot') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// FIXME: move this to a test helper that can be used by other apps | ||
|
||
const cacheManager = require('cache-manager') | ||
const GitHubApi = require('github') | ||
const {createRobot} = require('../..') | ||
|
||
const cache = cacheManager.caching({store: 'memory'}) | ||
|
||
const app = { | ||
async asApp () { | ||
return new GitHubApi() | ||
}, | ||
|
||
async asInstallation () { | ||
return new GitHubApi() | ||
}, | ||
|
||
async createToken () { | ||
return {data: {token: 'test'}} | ||
} | ||
} | ||
|
||
module.exports = { | ||
createRobot () { | ||
return createRobot({app, cache}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
// This file gets loaded when mocha is run | ||
|
||
process.env.LOG_LEVEL = 'fatal' | ||
|
||
const nock = require('nock') | ||
|
||
nock.disableNetConnect() | ||
nock.enableNetConnect(/127\.0\.0\.1/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" class="height-full"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title><%= name %> | built with Probot</title> | ||
<link rel="stylesheet" href="/probot/static/primer.css"> | ||
</head> | ||
<body class="height-full bg-gray-light"> | ||
<div class="d-flex flex-column flex-justify-center flex-items-center text-center height-full"> | ||
<img src="/probot/static/robot.svg" alt="Probot Logo" width="100" class="mb-6"> | ||
<div class="box-shadow rounded-2 border p-6 bg-white"> | ||
<h1>Welcome to <%= name %> <span class="Label Label--outline v-align-middle ml-2 text-gray-light">v<%= version %></span></h1> | ||
<%if (description) { %> | ||
<p><%= description %></p> | ||
<% } else { %> | ||
<p>This bot was built using <a href="https://github.com/probot/probot">Probot</a>, a framework for building GitHub Apps.</p> | ||
<% } %> | ||
</div> | ||
|
||
<div class="mt-4"> | ||
<h4 class="alt-h4 text-gray-light">Need help?</h4> | ||
<div class="d-flex flex-justify-center mt-2"> | ||
<a href="https://probot.github.io/docs/" class="btn btn-outline mr-2">Documentation</a> | ||
<a href="https://probot-slackin.herokuapp.com/" class="btn btn-outline">Chat on Slack</a> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |