Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Commit

Permalink
Support GitHub Enterprise repos
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Schnaare authored and robdodson committed Jan 7, 2016
1 parent d34f2e5 commit 5a1c7f9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/templates/polymer-starter-kit
12 changes: 10 additions & 2 deletions gh/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ module.exports = yeoman.generators.Base.extend({
default: false
});
this.includeDevDeps = this.options.nodevdeps ? 'no' : 'yes';

// Github Enterprise Support
this.option('hostname',{
desc: 'Github hostname to use. Necessary for Github Enterprise instances.',
type: String,
default: 'github.com'
});
this.ghHostname = this.options.hostname;
},
askFor: function () {
var done = this.async();
Expand All @@ -24,7 +32,7 @@ module.exports = yeoman.generators.Base.extend({
var prompts = [
{
name: 'ghUser',
message: 'What is your GitHub username?'
message: 'What is your GitHub username or organization?'
},
{
name: 'elementName',
Expand Down Expand Up @@ -66,7 +74,7 @@ module.exports = yeoman.generators.Base.extend({

var gp = spawn(
'bash',
['gp.sh', this.ghUser, this.elementName, this.branch, this.connectionType, this.includeDevDeps],
['gp.sh', this.ghHostname, this.ghUser, this.elementName, this.branch, this.connectionType, this.includeDevDeps],
{cwd: this.destinationRoot()}
);

Expand Down
14 changes: 8 additions & 6 deletions gh/templates/gp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

# usage gp Polymer core-item [branch]
# Run in a clean directory passing in a GitHub org and repo name
org=$1
repo=$2
branch=${3:-"master"} # default to master when branch isn't specified
connectionType=${4:-"https"} # defaults to https if type is set to null
hostname=$1
org=$2
repo=$3
branch=${4:-"master"} # default to master when branch isn't specified
connectionType=${5:-"https"} # defaults to https if type is set to null

# Calculate git clone url
[ "$connectionType" = "https" ] && { url=https://github.com/$org/$repo.git; true; } || url=git@github.com:$org/$repo.git;
[ "$connectionType" = "https" ] && { url=https://$hostname/$org/$repo.git; true; } || url=git@$hostname:$org/$repo.git;

# make folder (same as input, no checking!)
mkdir $repo
Expand All @@ -41,7 +42,7 @@ echo "{
}
" > .bowerrc
bower install
bower install $org/$repo#$branch
bower install git@$hostname:$org/$repo#$branch
git checkout ${branch} -- demo
rm -rf components/$repo/demo
mv demo components/$repo/
Expand All @@ -61,5 +62,6 @@ fi
git add -A .
git commit -am 'seed gh-pages'
git push -u origin gh-pages --force
git checkout $branch

popd >/dev/null
9 changes: 9 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ yo polymer:gh

If, for some reason, you don't want the devDependencies, use the `--nodevdeps` option.

#### Github Enterprise
Github Enterprise instances require a custom hostname to be defined. Use the `--hostname` option.

Example:
```bash
cd my-foo
yo polymer:gh --hostname custom.host.com
```

## Testing

The project generated by `yo polymer` contains support for [web-component-tester](https://github.com/Polymer/web-component-tester). The following commands are included:
Expand Down
2 changes: 1 addition & 1 deletion seed/templates/seed-element

0 comments on commit 5a1c7f9

Please sign in to comment.