Skip to content

Commit 92b2d63

Browse files
authored
Merge pull request #28 from probot/ts-template
Add option for scaffolding with a typescript template
2 parents e2fa09a + db07b4e commit 92b2d63

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@
33
This project will generate a new [Probot](https://github.com/probot/probot) app
44
with everything you need to get started and run your app in production.
55

6-
If you're using npm:
6+
> use the --typescript flag to generate a new TypeScript project
7+
8+
If you're using npm < 6:
9+
10+
```sh
11+
npx create-probot-app [--typescript] my-first-app
12+
```
13+
14+
If you're using npm > 6:
715

816
```sh
9-
npx create-probot-app my-first-app
17+
npm init probot-app [--typescript] my-first-app
1018
```
1119

1220
If you're using Yarn:
1321

1422
```sh
15-
yarn create probot-app my-first-app
23+
yarn create probot-app [--typescript] my-first-app
1624
```
1725

1826
See the [Probot docs](https://probot.github.io/docs/development/) to get started.

bin/create-probot-app.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const stringifyAuthor = require('stringify-author')
1313
const {guessEmail, guessAuthor, guessGitHubUsername} = require('conjecture')
1414
const validatePackageName = require('validate-npm-package-name')
1515

16-
const TEMPLATE_REPO_URL = 'https://github.com/probot/template.git'
16+
const DEFAULT_TEMPLATE = 'https://github.com/probot/template.git'
1717

1818
program
1919
.usage('[options] [destination]')
@@ -27,10 +27,18 @@ program
2727
.option('-u, --user <username>', 'GitHub username or org (repo owner)')
2828
.option('-r, --repo <repo-name>', 'Repository name')
2929
.option('--overwrite', 'Overwrite existing files', false)
30-
.option('--template <template-url>', 'URL of custom template',
31-
TEMPLATE_REPO_URL)
30+
.option('--template <template-url>', 'URL or name of custom template', getTemplateRepository, DEFAULT_TEMPLATE)
31+
.option('--typescript', 'Use the TypeScript template', () => program.emit('option:template', 'typescript'))
3232
.parse(process.argv)
3333

34+
function getTemplateRepository (value) {
35+
if (/^[\w-]+$/.test(value)) {
36+
return `https://github.com/probot/template-${value}.git`
37+
} else {
38+
return value
39+
}
40+
}
41+
3442
const destination = program.args.length
3543
? path.resolve(process.cwd(), program.args.shift())
3644
: process.cwd()
@@ -116,6 +124,7 @@ inquirer.prompt(prompts)
116124
url: answers.homepage
117125
})
118126
answers.year = new Date().getFullYear()
127+
119128
return scaffold(program.template, destination, answers, {
120129
overwrite: Boolean(program.overwrite)
121130
})

0 commit comments

Comments
 (0)