-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Differentiate between platform specific code and core code * Add gulp to build platform bundles * Use fork of github-api * Use babel + webpack to compile code
- Loading branch information
Clay Reimann
committed
Dec 11, 2015
1 parent
6503337
commit ed75c0b
Showing
15 changed files
with
400 additions
and
209 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"presets": ["es2015"], | ||
"plugins": ["transform-strict-mode"] | ||
} |
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,2 +1,3 @@ | ||
bower_components/ | ||
build/ | ||
node_modules/ | ||
bower_components/ |
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
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,105 @@ | ||
/** | ||
* Clay Reimann, 2015 | ||
* See LICENSE.txt for details | ||
*/ | ||
'use strict'; | ||
|
||
import gulp from 'gulp'; | ||
import webpack from 'webpack-stream'; | ||
|
||
import del from 'del'; | ||
import sequence from 'run-sequence'; | ||
|
||
const VENDOR_ASSETS = [ | ||
'bower_components/bootstrap/dist/css/bootstrap.min.css', | ||
'bower_components/jquery/dist/jquery.min.js', | ||
'bower_components/bootstrap/dist/js/bootstrap.min.js' | ||
] | ||
|
||
const PLATFORMS = [ | ||
'chrome' | ||
]; | ||
|
||
gulp.task('build', PLATFORMS.map((p) => `build:${p}`)); | ||
|
||
PLATFORMS.forEach((platform) => { | ||
gulp.task(`build:${platform}`, function(done) { | ||
sequence( | ||
`${platform}:clean`, | ||
`${platform}:move-assets`, | ||
`${platform}:move-vendor`, | ||
`${platform}:compile`, | ||
`${platform}:zip-extension`, | ||
done); | ||
}); | ||
}); | ||
|
||
//////////////////////////// | ||
// Build Chrome extension // | ||
//////////////////////////// | ||
gulp.task('chrome:clean', function(done) { | ||
del('build/chrome/**').then(() => { | ||
done() | ||
}); | ||
}); | ||
|
||
gulp.task('chrome:move-assets', function() { | ||
return gulp.src([ | ||
'platform/chrome/manifest.json', | ||
'platform/chrome/options/options.html', | ||
'assets/**' | ||
]) | ||
.pipe(gulp.dest('build/chrome')) | ||
; | ||
}); | ||
|
||
gulp.task('chrome:move-vendor', function() { | ||
return gulp.src(VENDOR_ASSETS) | ||
.pipe(gulp.dest('build/chrome/vendor')) | ||
}) | ||
|
||
var WEBPACK_CONFIG = { | ||
entry: { | ||
chrome: './platform/chrome/chrome.js', | ||
options: './platform/chrome/options/options.js' | ||
}, | ||
output: { | ||
filename: '[name].min.js' | ||
}, | ||
resolve: { | ||
extensions: ['', '.js'] | ||
}, | ||
externals: { | ||
chrome: 'chrome' | ||
}, | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /(node_modules|bower_components)/, | ||
loader: 'babel', | ||
query: { | ||
presets: ['es2015'] | ||
} | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
// new webpack.webpack.optimize.UglifyJsPlugin() | ||
], | ||
devtool: 'source-map', | ||
stats: { | ||
colors: 'true' | ||
} | ||
}; | ||
gulp.task('chrome:compile', function(done) { | ||
return gulp.src(['platform/chrome/chrome.js', 'platform/chrome/options/options.html']) | ||
.pipe(webpack(WEBPACK_CONFIG)) | ||
.pipe(gulp.dest('build/chrome')) | ||
; | ||
}); | ||
|
||
gulp.task('chrome:zip-extension', function(done) { | ||
// do stuff | ||
done(); | ||
}) |
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,110 @@ | ||
/** | ||
* Clay Reimann, 2015 | ||
* See LICENSE.txt for details | ||
*/ | ||
|
||
import Github from 'github-api'; | ||
|
||
class SuggestionService { | ||
/** | ||
* Constructs a new SuggestionService | ||
* | ||
* @param {array} githubDescriptors - an array of objects that describe the github instances to be searched | ||
* the objects should be of the format | ||
* { | ||
* url: the github url | ||
* auth: {oauth, basic} to describe the service type | ||
* token: required when auth == oauth | ||
* username: required when auth == basic | ||
* password: required when auth == basic | ||
* } | ||
*/ | ||
constructor(githubDescriptors) { | ||
this.__githubs = {}; | ||
githubDescriptors.forEach((descriptor) => { | ||
let opts = { | ||
apiUrl: descriptor.url, | ||
auth: descriptor.auth | ||
}; | ||
if (descriptor.auth === 'oauth') { | ||
opts.token = descriptor.token; | ||
} else { | ||
opts.username = descriptor.username; | ||
opts.password = descriptor.password; | ||
} | ||
this.__githubs[descriptor.url] = new Github(opts); | ||
}); | ||
|
||
this.__repos = []; | ||
} | ||
|
||
isLoaded() { | ||
return this.__repos.length > 0; | ||
} | ||
|
||
addRepository(githubUrl, repository) { | ||
let isAdded = this.__repos.reduce((found, r) => { | ||
return found || (r.githubUrl === githubUrl && r.name === repository.full_name); | ||
}, false); | ||
|
||
if (!isAdded) { | ||
this.__repos.push({ | ||
githubUrl, | ||
name: repository.full_name, | ||
url: repository.html_url | ||
}); | ||
} | ||
} | ||
|
||
addRepositories(githubUrl, list) { | ||
if (!list) { | ||
return; | ||
} | ||
|
||
list.forEach((repository) => { | ||
this.addRepository(githubUrl, repository); | ||
}); | ||
} | ||
|
||
queryGithubsForRepositories() { | ||
this.__repos = []; | ||
Object.keys(this.__githubs).forEach((githubUrl) => { | ||
let github = this.__githubs[githubUrl]; | ||
let user = github.getUser(); | ||
|
||
user.repos((err, repoList) => { | ||
this.addRepositories(githubUrl, repoList); | ||
}) | ||
|
||
user.orgs((err, orgs) => { | ||
if (!orgs) { | ||
return; | ||
} | ||
|
||
orgs.forEach((org) => { | ||
user.orgRepos(org.login, (err, repoList) => { | ||
console.log(`got repos for ${org.login}`); | ||
this.addRepositories(githubUrl, repoList); | ||
}) | ||
}) | ||
}) | ||
}) | ||
} | ||
|
||
getRepositoriesMatching(text) { | ||
return this.__repos.filter(function(repo) { | ||
return repo.name.search(new RegExp(text, 'i')) !== -1; | ||
}).sort(function(a, b) { | ||
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; | ||
}); | ||
} | ||
|
||
getUrlForRepo(repoFullName) { | ||
return this.__repos.reduce(function(found, repo) { | ||
return found || (repo.name === repoFullName ? repo.url : found); | ||
}, undefined); | ||
} | ||
|
||
} | ||
|
||
module.exports = SuggestionService; |
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
Oops, something went wrong.