probot/bin/probot-run.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-03-18 12:04:23 +08:00
#!/usr/bin/env node
2017-08-23 11:06:31 +08:00
require('dotenv').config()
2017-03-18 12:04:23 +08:00
2017-08-23 11:06:31 +08:00
const pkgConf = require('pkg-conf')
const program = require('commander')
2019-01-28 02:13:40 +08:00
const { findPrivateKey } = require('../lib/private-key')
2017-03-18 12:04:23 +08:00
program
2017-08-20 23:42:51 +08:00
.usage('[options] <apps...>')
.option('-p, --port <n>', 'Port to start the server on', process.env.PORT || 3000)
.option('-W, --webhook-proxy <url>', 'URL of the webhook proxy service.`', process.env.WEBHOOK_PROXY_URL)
.option('-w, --webhook-path <path>', 'URL path which receives webhooks. Ex: `/webhook`', process.env.WEBHOOK_PATH)
.option('-a, --app <id>', 'ID of the GitHub App', process.env.APP_ID)
.option('-s, --secret <secret>', 'Webhook secret of the GitHub App', process.env.WEBHOOK_SECRET)
.option('-P, --private-key <file>', 'Path to certificate of the GitHub App', findPrivateKey)
2017-08-23 11:06:31 +08:00
.parse(process.argv)
2017-03-18 12:04:23 +08:00
Probot Support for GitHub App Manifests (#650) * Add button to setup GitHub app * Add app.yml * Add some comments to app.yml * Associate events with permissions * Allow configuring app with manifest * Hacky version of callback URL for configuring app * Remove manifest stuff for now * Return nil if private key is not found * Move setup stuff to a separate plugin * Revert changes to default plugin * Remove FIXME * Revert changes to default template * Use separate template for setup * Fix lint warnings * Convert test helper to typescript * Initial test for setup app * Require tests files to match `.test.(js|ts)` * Account for multiple protocols in x-forwarded-proto * Wrap pem in quotes * Collapse class into request method for now * run `refresh` after updating .env on Glitch * Extract update-dotenv to a node module * Create a smee url if one does not exist * Hacky version of serving up the manifest * WIP Manifest with code * add comments for plan + figure out port * using user-agent header for review lab * add success view to redirect to after installation * api is actually on github * start making post * fix quoting issue on POST * everything is off review lab and on dotcom * working version of app manifest flow * Start trying to write tests against setup * more refactor into thingerator; basic tests; write plans for other tests * merge better.. * ok atom conflict handling broke * hack the tests back together * pass the tests 👊🏼 * moar test * make it open in a new tab for Wil 💖 * make boolean work * clean up logic, move messgae, just return html url not response * clean up tests 👷🏾‍♀️ * rename Brandon's thingerator to manifest-creation
2018-09-27 03:22:11 +08:00
program.privateKey = findPrivateKey()
2019-01-28 02:13:40 +08:00
const { createProbot } = require('../')
2017-03-18 12:04:23 +08:00
const probot = createProbot({
id: program.app,
2017-03-18 12:04:23 +08:00
secret: program.secret,
2017-03-20 00:58:12 +08:00
cert: program.privateKey,
port: program.port,
webhookPath: program.webhookPath,
webhookProxy: program.webhookProxy
2017-08-23 11:06:31 +08:00
})
2017-03-18 12:04:23 +08:00
Probot Support for GitHub App Manifests (#650) * Add button to setup GitHub app * Add app.yml * Add some comments to app.yml * Associate events with permissions * Allow configuring app with manifest * Hacky version of callback URL for configuring app * Remove manifest stuff for now * Return nil if private key is not found * Move setup stuff to a separate plugin * Revert changes to default plugin * Remove FIXME * Revert changes to default template * Use separate template for setup * Fix lint warnings * Convert test helper to typescript * Initial test for setup app * Require tests files to match `.test.(js|ts)` * Account for multiple protocols in x-forwarded-proto * Wrap pem in quotes * Collapse class into request method for now * run `refresh` after updating .env on Glitch * Extract update-dotenv to a node module * Create a smee url if one does not exist * Hacky version of serving up the manifest * WIP Manifest with code * add comments for plan + figure out port * using user-agent header for review lab * add success view to redirect to after installation * api is actually on github * start making post * fix quoting issue on POST * everything is off review lab and on dotcom * working version of app manifest flow * Start trying to write tests against setup * more refactor into thingerator; basic tests; write plans for other tests * merge better.. * ok atom conflict handling broke * hack the tests back together * pass the tests 👊🏼 * moar test * make it open in a new tab for Wil 💖 * make boolean work * clean up logic, move messgae, just return html url not response * clean up tests 👷🏾‍♀️ * rename Brandon's thingerator to manifest-creation
2018-09-27 03:22:11 +08:00
const setupMode = !program.app || !program.privateKey
if (setupMode) {
const setupApp = require('../lib/apps/setup')
probot.load(setupApp)
2017-08-23 11:06:31 +08:00
probot.start()
Probot Support for GitHub App Manifests (#650) * Add button to setup GitHub app * Add app.yml * Add some comments to app.yml * Associate events with permissions * Allow configuring app with manifest * Hacky version of callback URL for configuring app * Remove manifest stuff for now * Return nil if private key is not found * Move setup stuff to a separate plugin * Revert changes to default plugin * Remove FIXME * Revert changes to default template * Use separate template for setup * Fix lint warnings * Convert test helper to typescript * Initial test for setup app * Require tests files to match `.test.(js|ts)` * Account for multiple protocols in x-forwarded-proto * Wrap pem in quotes * Collapse class into request method for now * run `refresh` after updating .env on Glitch * Extract update-dotenv to a node module * Create a smee url if one does not exist * Hacky version of serving up the manifest * WIP Manifest with code * add comments for plan + figure out port * using user-agent header for review lab * add success view to redirect to after installation * api is actually on github * start making post * fix quoting issue on POST * everything is off review lab and on dotcom * working version of app manifest flow * Start trying to write tests against setup * more refactor into thingerator; basic tests; write plans for other tests * merge better.. * ok atom conflict handling broke * hack the tests back together * pass the tests 👊🏼 * moar test * make it open in a new tab for Wil 💖 * make boolean work * clean up logic, move messgae, just return html url not response * clean up tests 👷🏾‍♀️ * rename Brandon's thingerator to manifest-creation
2018-09-27 03:22:11 +08:00
} else {
pkgConf('probot').then(pkg => {
probot.setup(program.args.concat(pkg.apps || pkg.plugins || []))
probot.start()
})
}