Skip to content

Commit

Permalink
(feat) ask for Polymer support
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinspecker committed Aug 8, 2014
1 parent 5218baa commit ff3b15e
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 64 deletions.
10 changes: 9 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Generator.prototype.prompting = function prompting() {
checked: true
},
{
name: 'SASS',
name: 'SCSS',
value: 'scss'
},
{
Expand All @@ -115,6 +115,12 @@ Generator.prototype.prompting = function prompting() {
}
]
},
{
type: 'confirm',
name: 'polymer',
message: 'Should Polymer support be enabled?',
default: true
},
{
type: 'checkbox',
name: 'bower',
Expand Down Expand Up @@ -151,6 +157,7 @@ Generator.prototype.prompting = function prompting() {
this.testScript = props.testScript;
this.testDir = props.testDir;
this.style = props.style;
this.polymer = props.polymer;
this.bower = props.bower.join(',');

done();
Expand Down Expand Up @@ -180,6 +187,7 @@ Generator.prototype.configuring = function configuring() {
moduleName: this.appName,
passFunc: this.passFunc,
namedFunc: this.namedFunc,
polymer: this.polymer,
bower: this.bower
};

Expand Down
4 changes: 2 additions & 2 deletions app/templates/_bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"angular-resource": "~1.2.21",<% } %><% if (bower.indexOf('sanitize') > -1) { %>
"angular-sanitize": "~1.2.21",<% } %><% if (bower.indexOf('touch') > -1) { %>
"angular-touch": "~1.2.21",<% } %>
"angular-ui-router": "~0.2.10",
"angular-ui-router": "~0.2.10"<% if (polymer) { %>,
"polymer": "Polymer/polymer#~0.3.3",
"core-elements": "Polymer/core-elements#~0.3.3",
"paper-elements": "Polymer/paper-elements#~0.3.3"
"paper-elements": "Polymer/paper-elements#~0.3.3"<% } %>
},
"devDependencies": {
"angular-mocks": "~1.2.21"
Expand Down
122 changes: 61 additions & 61 deletions app/templates/_gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ var appBase = 'app/'
, appScriptFiles = appBase + '**/*.js'
, appStyleFiles = appBase + '**/*.{less,scss,styl}';

// custom component locations
<% if (polymer) { %>// custom component locations
var componentsBase = appBase + 'components/'
, componentsMarkupFiles = componentsBase + '**/*.{html,jade}'
, componentsScriptFiles = componentsBase + '**/*.js'
, componentsStyleFiles = componentsBase + '**/*.{less,scss,styl}';

// e2e test locations
<% } %>// e2e test locations
var e2ePoFiles = 'e2e/**/*.po.{coffee,js}'
, e2eTestsFiles = 'e2e/**/*_test.{coffee,js}'
, protractorConfig = 'protractor.config.js';
Expand All @@ -55,8 +55,8 @@ var unitTestsFiles = '{app,test}/**/*_test.{coffee,js}'

// build locations
var build = 'build/'
, buildComponents = build + 'components/'
, buildCss = build
<% if (polymer) { %> , buildComponents = build + 'components/'
<% } %> , buildCss = build
, buildJs = build;

// passed arguments
Expand All @@ -65,44 +65,44 @@ var isProd = args.stage === 'prod';
// bower assets to be injected into index.html
// 'bower_components' is automatically prepended
var injectableBowerComponents = [
'angular/angular.js',
'angular-animate/angular-animate.js',
'angular-cookies/angular-cookies.js',
'angular-resource/angular-resource.js',
'angular-sanitize/angular-sanitize.js',
'angular-touch/angular-touch.js',
'angular-ui-router/release/angular-ui-router.js',
'platform/platform.js'
'angular/angular.js'<% if (bower.length > 0 || polymer) { %>,<% } %><% if (bower.indexOf('animate') > -1) { %>
'angular-animate/angular-animate.js'<% } %><% if (bower.indexOf('cookies') > -1) { %>,
'angular-cookies/angular-cookies.js'<% } %><% if (bower.indexOf('resource') > -1) { %>,
'angular-resource/angular-resource.js'<% } %><% if (bower.indexOf('sanitize') > -1) { %>,
'angular-sanitize/angular-sanitize.js'<% } %><% if (bower.indexOf('touch') > -1) { %>,
'angular-touch/angular-touch.js'<% } %>,
'angular-ui-router/release/angular-ui-router.js'<% if (polymer) { %>,
'platform/platform.js'<% } %>
];

// minified bower assets to be injected into index.html
// 'bower_components' is automatically prepended
var minInjectableBowerComponents = [
'angular/angular.min.js',
'angular-animate/angular-animate.min.js',
'angular-cookies/angular-cookies.min.js',
'angular-resource/angular-resource.min.js',
'angular-sanitize/angular-sanitize.min.js',
'angular-touch/angular-touch.min.js',
'angular-ui-router/release/angular-ui-router.min.js',
'platform/platform.js'
'angular/angular.min.js'<% if (bower.length > 0 || polymer) { %>,<% } %><% if (bower.indexOf('animate') > -1) { %>
'angular-animate/angular-animate.min.js'<% } %><% if (bower.indexOf('cookies') > -1) { %>,
'angular-cookies/angular-cookies.min.js'<% } %><% if (bower.indexOf('resource') > -1) { %>,
'angular-resource/angular-resource.min.js'<% } %><% if (bower.indexOf('sanitize') > -1) { %>,
'angular-sanitize/angular-sanitize.min.js'<% } %><% if (bower.indexOf('touch') > -1) { %>,
'angular-touch/angular-touch.min.js'<% } %>,
'angular-ui-router/release/angular-ui-router.min.js'<% if (polymer) { %>,
'platform/platform.js'<% } %>
];

// bower polymer components that do not need to be injected into index.html
<% if (polymer) { %>// bower polymer components that do not need to be injected into index.html
// 'bower_components' is automatically prepended
var bowerPolymerComponents = [
'polymer/polymer.{js,html}',
'polymer/layout.html'
];

var bowerDir = 'bower_components/';
<% } %>var bowerDir = 'bower_components/';
function prependBowerDir(file) {
return bowerDir + file;
}

gulp.task('watch', function () {
gulp.watch([unitTestsFiles], ['unitTest']);
gulp.watch([appMarkupFiles, appScriptFiles, appStyleFiles, componentsBase + '**/*'], ['angularInject', 'polymer', browserSync.reload]);
gulp.watch([appMarkupFiles, appScriptFiles, appStyleFiles<% if (polymer) { %>, componentsBase + '**/*'<% } %>], ['angularInject'<% if (polymer) { %>, 'polymer'<% } %>, browserSync.reload]);
});

gulp.task('browser-sync', function () {
Expand Down Expand Up @@ -138,8 +138,8 @@ gulp.task('coffeelint', function () {

gulp.task('jshint', function () {
return gulp.src([
appScriptFiles,
componentsScriptFiles,
appScriptFiles<% if (polymer) { %>,
componentsScriptFiles<% } %>,
e2ePoFiles,
e2eTestsFiles,
karmaConfig,
Expand All @@ -155,7 +155,7 @@ gulp.task('jshint', function () {
;
});

gulp.task('components', ['clean', 'jshint'], function () {
<% if (polymer) { %>gulp.task('components', ['clean', 'jshint'], function () {
var stream = streamqueue({ objectMode: true });

// jade
Expand Down Expand Up @@ -210,11 +210,11 @@ gulp.task('components', ['clean', 'jshint'], function () {
;
});

gulp.task('scripts', ['clean', 'jshint'], function () {
<% } %>gulp.task('scripts', ['clean', 'jshint'], function () {
if (isProd) {
return gulp.src([
appScriptFiles,
'!' + componentsBase + '**/*',
appScriptFiles<% if (polymer) { %>,
'!' + componentsBase + '**/*'<% } %>,
'!' + unitTestsFiles
])
.pipe(angularSort())
Expand All @@ -225,8 +225,8 @@ gulp.task('scripts', ['clean', 'jshint'], function () {
.pipe(gulp.dest(buildJs));
} else {
return gulp.src([
appScriptFiles,
'!' + componentsBase + '**/*',
appScriptFiles<% if (polymer) { %>,
'!' + componentsBase + '**/*'<% } %>,
'!' + unitTestsFiles
])
.pipe(addSrc([].concat(injectableBowerComponents.map(prependBowerDir))))
Expand All @@ -242,26 +242,26 @@ gulp.task('style', ['clean'], function () {
// less
stream.queue(gulp.src([
appStyleFiles,
'!**/*.{scss,styl}',
'!' + componentsBase + '**/*'
'!**/*.{scss,styl}'<% if (polymer) { %>,
'!' + componentsBase + '**/*'<% } %>
])
.pipe(less()))
;

// sass
stream.queue(gulp.src([
appStyleFiles,
'!**/*.{less,styl}',
'!' + componentsBase + '**/*'
'!**/*.{less,styl}'<% if (polymer) { %>,
'!' + componentsBase + '**/*'<% } %>
])
.pipe(sass()))
;

// stylus
stream.queue(gulp.src([
appStyleFiles,
'!**/*.{less,scss}',
'!' + componentsBase + '**/*'
'!**/*.{less,scss}'<% if (polymer) { %>,
'!' + componentsBase + '**/*'<% } %>
])
.pipe(stylus()))
;
Expand All @@ -276,25 +276,25 @@ gulp.task('style', ['clean'], function () {

gulp.task('markup', ['clean'], function () {
return gulp.src([
appMarkupFiles,
'!' + componentsBase + '**/*',
appMarkupFiles<% if (polymer) { %>,
'!' + componentsBase + '**/*'<% } %>,
'!**/*.html'
])
.pipe(jade())
.pipe(addSrc([
appMarkupFiles,
'!' + componentsBase + '**/*',
appMarkupFiles<% if (polymer) { %>,
'!' + componentsBase + '**/*'<% } %>,
'!**/*.jade'
]))
.pipe(gulp.dest(build))
;
});

gulp.task('inject', ['components', 'markup', 'scripts', 'style'], function () {
gulp.task('inject', [<% if (polymer) { %>'components', <% } %>'markup', 'scripts', 'style'], function () {
return gulp.src(build + 'index.html')
.pipe(inject(gulp.src([
buildComponents + '**/*.html',
buildCss + '**/*.css',
<% if (polymer) { %>buildComponents + '**/*.html',
<% } %>buildCss + '**/*.css',
buildJs + 'angular.js',
buildJs + 'angular.min.js'
], { read: false }), {
Expand All @@ -305,7 +305,7 @@ gulp.task('inject', ['components', 'markup', 'scripts', 'style'], function () {
;
});

gulp.task('headInject', ['inject'], function () {
<% if (polymer) { %>gulp.task('headInject', ['inject'], function () {
return gulp.src(build + 'index.html')
.pipe(inject(gulp.src(buildJs + 'platform.js'), {
starttag: '<!-- inject:head:{{ext}} -->',
Expand All @@ -316,14 +316,14 @@ gulp.task('headInject', ['inject'], function () {
;
});

gulp.task('angularInject', ['headInject'], function () {
<% } %>gulp.task('angularInject', [<% if (polymer) { %>'headInject'<% } else { %>'inject'<% } %>], function () {
return gulp.src(build + 'index.html')
.pipe(inject(gulp.src([
buildJs + '**/*.js',
'!' + buildComponents + '**/*',
buildJs + '**/*.js'<% if (polymer) { %>,
'!' + buildComponents + '**/*'<% } %>,
'!' + buildJs + 'angular.js',
'!' + buildJs + 'angular.min.js',
'!' + buildJs + 'platform.js',
'!' + buildJs + 'angular.min.js'<% if (polymer) { %>,
'!' + buildJs + 'platform.js'<% } %>,
'!**/*_test.*'
]).pipe(angularSort()), { starttag: '<!-- inject:angular:{{ext}} -->', addRootSlash: false, ignorePath: build }))
.pipe(gulpIf(isProd, htmlmin({
Expand All @@ -334,15 +334,15 @@ gulp.task('angularInject', ['headInject'], function () {
;
});

gulp.task('polymer', ['inject'], function () {
<% if (polymer) { %>gulp.task('polymer', ['inject'], function () {
return gulp.src(bowerPolymerComponents.map(prependBowerDir), {
base: bowerDir
})
.pipe(gulp.dest(buildComponents))
;
});

gulp.task('karmaInject', function () {
<% } %>gulp.task('karmaInject', function () {
var stream = streamqueue({ objectMode: true});
stream.queue(gulp.src([
bowerDir + 'angular/angular.js',
Expand All @@ -351,14 +351,14 @@ gulp.task('karmaInject', function () {
]));

stream.queue(gulp.src([
appBase + '**/*.js',
'!' + componentsBase + '**/*',
'!**/*_test.*',
bowerDir + 'angular-animate/angular-animate.js',
bowerDir + 'angular-cookies/angular-cookies.js',
bowerDir + 'angular-resource/angular-resource.js',
bowerDir + 'angular-sanitize/angular-sanitize.js',
bowerDir + 'angular-touch/angular-touch.js',
appBase + '**/*.js'<% if (polymer) { %>,
'!' + componentsBase + '**/*'<% } %>,
'!**/*_test.*'<% if (bower.indexOf('animate') > -1) { %>,
bowerDir + 'angular-animate/angular-animate.js'<% } %><% if (bower.indexOf('cookies') > -1) { %>,
bowerDir + 'angular-cookies/angular-cookies.js'<% } %><% if (bower.indexOf('resource') > -1) { %>,
bowerDir + 'angular-resource/angular-resource.js'<% } %><% if (bower.indexOf('sanitize') > -1) { %>,
bowerDir + 'angular-sanitize/angular-sanitize.js'<% } %><% if (bower.indexOf('touch') > -1) { %>,
bowerDir + 'angular-touch/angular-touch.js'<% } %>,
bowerDir + 'angular-ui-router/release/angular-ui-router.js',
]).pipe(angularSort()));

Expand Down Expand Up @@ -399,7 +399,7 @@ gulp.task('dev', ['build', 'browser-sync'], function () {
gulp.start('watch');
});

gulp.task('build', ['angularInject', 'polymer'], function () {
gulp.task('build', ['angularInject'<% if (polymer) { %>, 'polymer'<% } %>], function () {
});

gulp.task('default', ['dev']);

0 comments on commit ff3b15e

Please sign in to comment.