Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for use case templates #36

Merged
merged 41 commits into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b203255
basics
hiimbex Sep 5, 2018
7206706
use egad generate to use local templates
hiimbex Sep 6, 2018
3f3e026
update probot and add app.yml files
hiimbex Oct 4, 2018
b2dafcc
rm logs
hiimbex Oct 4, 2018
88c89e9
so i guess that never worked in the first place
hiimbex Oct 4, 2018
e6e4d89
write tests for checks example, other testing clean up
hiimbex Oct 5, 2018
71aa1de
finalize git data example and add test
hiimbex Oct 10, 2018
be2462f
update basic example to use nock
hiimbex Oct 11, 2018
2294483
rm comment
hiimbex Oct 11, 2018
4dec585
make ts use case actually work for basic example and add real tests
hiimbex Oct 11, 2018
f7c8dac
update readme
hiimbex Oct 11, 2018
1890ae5
fix permissions and rm ds store
hiimbex Oct 15, 2018
64623a5
add deployments example
hiimbex Oct 16, 2018
095e985
Merge pull request #38 from probot/deployments
hiimbex Oct 16, 2018
37721b2
update readme to include deployments
hiimbex Oct 17, 2018
9f89065
Start working on tests
bkeepers Oct 19, 2018
eead088
get test script working??
hiimbex Oct 19, 2018
b8b691c
triggering travis now that i actually enabled it for this repo 🤦🏽‍♀️
hiimbex Oct 19, 2018
01ebb21
make the script loop?
hiimbex Oct 19, 2018
1940854
Merge branch 'templatess' of github.com:probot/create-probot-app into…
hiimbex Oct 19, 2018
0e3f487
actually make it loop ;)
hiimbex Oct 19, 2018
0fb12c2
bash??
hiimbex Oct 19, 2018
073959d
fail the script if npm test fails
hiimbex Oct 19, 2018
1dc9f38
maybe fix typescript?
hiimbex Oct 20, 2018
c0af672
Update test
hiimbex Oct 20, 2018
09de52a
ok typescript 🙇🏻‍♂️
hiimbex Oct 20, 2018
e00e5be
this is definitely how this works
hiimbex Oct 20, 2018
13c478c
Update templates/basic-ts/test/index.test.ts
TimonVS Oct 25, 2018
52af17f
Update templates/basic-ts/test/index.test.ts
TimonVS Oct 25, 2018
7d52389
Update README.md
TimonVS Oct 25, 2018
85e601b
Update templates/basic-js/test/index.test.js
TimonVS Oct 25, 2018
9d129fd
Update templates/basic-js/test/index.test.js
TimonVS Oct 25, 2018
5a357b3
Update templates/checks-js/test/index.test.js
TimonVS Oct 25, 2018
3c710d4
Update templates/basic-ts/test/index.test.ts
TimonVS Oct 25, 2018
e70205c
Update templates/basic-js/test/index.test.js
TimonVS Oct 25, 2018
0560f15
Update templates/deploy-js/test/index.test.js
TimonVS Oct 25, 2018
65c4600
Switch to using list in inquirer
bkeepers Oct 25, 2018
156147e
Run tests in tmp dir
bkeepers Oct 25, 2018
9be3612
sanity checking the tests
hiimbex Oct 26, 2018
135a504
ok, I guess that was unnecessary :) tests work!
hiimbex Oct 26, 2018
946a7db
rm readme ramblings
hiimbex Oct 26, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
package-lock.json
tmp
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sudo: false
language: node_js
node_js:
- "8"
- "10"

notifications:
disabled: true

script: script/test
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
# Create Probot App

This project will generate a new [Probot](https://github.com/probot/probot) app
with everything you need to get started and run your app in production.
This project will generate a new [Probot](https://github.com/probot/probot) app
with everything you need to get started building. 👷🏽‍

> use the --typescript flag to generate a new TypeScript project

If you're using npm < 6:

```sh
npx create-probot-app [--typescript] my-first-app
```

If you're using npm > 6:
In particular, this command line interface allows you to select from our pre-defined blue prints to choose a basic working example to start from.

```sh
npm init probot-app [--typescript] my-first-app
npx create-probot-app my-first-app
```

If you're using Yarn:
If you're using Yarn:

```sh
yarn create probot-app [--typescript] my-first-app
yarn create probot-app my-first-app
```

See the [Probot docs](https://probot.github.io/docs/development/) to get started.
See the [Probot docs](https://probot.github.io/docs/development/#running-the-app-locally) to get started running your app locally.
58 changes: 35 additions & 23 deletions bin/create-probot-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const path = require('path')
const inquirer = require('inquirer')
const program = require('commander')
const {scaffold} = require('egad')
const {generate} = require('egad')
const kebabCase = require('lodash.kebabcase')
const camelCase = require('lodash.camelcase')
const chalk = require('chalk')
Expand All @@ -14,8 +14,6 @@ const stringifyAuthor = require('stringify-author')
const {guessEmail, guessAuthor, guessGitHubUsername} = require('conjecture')
const validatePackageName = require('validate-npm-package-name')

const DEFAULT_TEMPLATE = 'https://github.com/probot/template.git'

program
.usage('[options] [destination]')
.option('-n, --appName <app-name>', 'App name')
Expand All @@ -27,24 +25,16 @@ program
.option('-h, --homepage <homepage>', 'Author\'s homepage')
.option('-u, --user <username>', 'GitHub username or org (repo owner)')
.option('-r, --repo <repo-name>', 'Repository name')
.option('-b, --branch <branch-name>', 'Specify a branch', 'master')
.option('--overwrite', 'Overwrite existing files', false)
.option('--template <template-url>', 'URL or name of custom template', getTemplateRepository, DEFAULT_TEMPLATE)
.option('--typescript', 'Use the TypeScript template', () => program.emit('option:template', 'typescript'))
.option('-t, --template <template>', 'Name of use case template')
.parse(process.argv)

function getTemplateRepository (value) {
if (/^[\w-]+$/.test(value)) {
return `https://github.com/probot/template-${value}.git`
} else {
return value
}
}

const destination = program.args.length
? path.resolve(process.cwd(), program.args.shift())
: process.cwd()

const templates = ['basic-js', 'checks-js', 'git-data-js', 'deploy-js', 'basic-ts']

const prompts = [
{
type: 'input',
Expand Down Expand Up @@ -98,7 +88,7 @@ const prompts = [
},
{
type: 'input',
name: 'owner',
name: 'user',
default (answers) {
return guessGitHubUsername(answers.email)
},
Expand All @@ -113,24 +103,46 @@ const prompts = [
},
message: 'Repository name:',
when: !program.repo
},
{
type: 'list',
name: 'template',
choices: templates,
message: 'Which template would you like to use?',
when: !program.template
}
]

console.log(chalk.blue('Let\'s create a Probot app!'))
console.log(chalk.blue('\nLet\'s create a Probot app!\nHit enter to accept the suggestion.\n'))

inquirer.prompt(prompts)
.then(answers => {
answers.author = stringifyAuthor({
name: answers.author,
email: answers.email,
url: answers.homepage
name: program.author || answers.author,
email: program.email || answers.email,
url: program.homepage || answers.homepage
})
answers.year = new Date().getFullYear()
answers.camelCaseAppName = camelCase(answers.appName)
answers.camelCaseAppName = camelCase(program.appName || answers.appName)
answers.template = program.template || answers.template
answers.appName = program.appName || answers.appName
answers.desc = program.desc || answers.desc
answers.user = program.user || answers.user
answers.repo = program.repo || answers.repo
answers.template = program.template || answers.template

// TODO: clean that up into nicer object combinging

console.log(answers, destination)

if (!templates.includes(answers.template)) {
console.log(chalk.red(`Please use an existing use case template: ${templates.join(', ')}`))
process.exit(1)
}

return scaffold(program.template, destination, answers, {
overwrite: Boolean(program.overwrite),
branch: program.branch
const relativePath = path.join(__dirname, '/../templates/', answers.template)
return generate(relativePath, destination, answers, {
overwrite: Boolean(program.overwrite)
})
})
.then(results => {
Expand Down
32 changes: 32 additions & 0 deletions script/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

# Ensure we're always running from the project root
cd "$(dirname "$0")/.."

PROJECT_DIR=$(pwd)
TEMP_DIR="$PROJECT_DIR"/tmp
mkdir -p $TEMP_DIR

for i in $PROJECT_DIR/templates/*
do
template=$(basename $i)
echo $template
cd $TEMP_DIR
rm -rf $template

$PROJECT_DIR/bin/create-probot-app.js \
--appName "travis-template-test" \
--desc "A Probot App for building on Travis" \
--author "Pro Bawt" \
--email "[email protected]" \
--homepage "https://probot.github.io" \
--user "probot" \
--template $template \
--repo "probot/create-probot-app-$template" \
$template

cd $template
npm test
done
9 changes: 9 additions & 0 deletions templates/basic-js/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The ID of your GitHub App
APP_ID=
WEBHOOK_SECRET=development

# Use `trace` to get verbose logging or `info` to show less
LOG_LEVEL=debug

# Go to https://smee.io/new set this to the URL that you are redirected to.
WEBHOOK_PROXY_URL=
6 changes: 6 additions & 0 deletions templates/basic-js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
npm-debug.log
*.pem
.env
package-lock.json
coverage
74 changes: 74 additions & 0 deletions templates/basic-js/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at {{{ email }}}. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

41 changes: 41 additions & 0 deletions templates/basic-js/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Contributing

[fork]: /fork
[pr]: /compare
[style]: https://standardjs.com/
[code-of-conduct]: CODE_OF_CONDUCT.md

Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.

Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.

## Issues and PRs

If you have suggestions for how this project could be improved, or want to report a bug, open an issue! We'd love all and any contributions. If you have questions, too, we'd love to hear them.

We'd also love PRs. If you're thinking of a large PR, we advise opening up an issue first to talk about it, though! Look at the links below if you're not sure how to open a PR.

## Submitting a pull request

1. [Fork][fork] and clone the repository.
1. Configure and install the dependencies: `npm install`.
1. Make sure the tests pass on your machine: `npm test`, note: these tests also apply the linter, so there's no need to lint separately.
1. Create a new branch: `git checkout -b my-branch-name`.
1. Make your change, add tests, and make sure the tests still pass.
1. Push to your fork and [submit a pull request][pr].
1. Pat your self on the back and wait for your pull request to be reviewed and merged.

Here are a few things you can do that will increase the likelihood of your pull request being accepted:

- Follow the [style guide][style] which is using standard. Any linting errors should be shown when running `npm test`.
- Write and update tests.
- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you.

## Resources

- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
15 changes: 15 additions & 0 deletions templates/basic-js/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) {{{ year }}}, {{{ author }}}

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 changes: 23 additions & 0 deletions templates/basic-js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# {{ name }}

> 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 }}}
Loading