Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yago committed Sep 30, 2016
2 parents 18c3297 + 55c84a5 commit d186ec2
Show file tree
Hide file tree
Showing 40 changed files with 1,041 additions and 1,017 deletions.
91 changes: 48 additions & 43 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var slug = require('slug');
var mkdirp = require('mkdirp');

var toolboxSay = function() {
return ' '+'\n'+
Expand Down Expand Up @@ -51,23 +52,23 @@ module.exports = yeoman.Base.extend({
value: 'fabricator',
checked: true
}, {
name: 'Framework (Bootstrap)',
name: 'Framework (Bootstrap 4)',
value: 'bootstrapSass',
checked: true
}, {
name: 'Tests (Mocha, Casperjs and Chai)',
value: 'tests',
checked: true
checked: false
}
]
},{
when: function (response) {
// this.log(response);
return response.tools.indexOf('bootstrapSass') !== -1;
return response.tools.indexOf('fabricator') !== -1;
},
name: 'bootstrap4',
type: 'confirm',
message: 'Do you want to use Bootstrap 4 Alpha?',
type: 'input',
name: 'contentful',
message: 'If you want to setup ' + chalk.blue('Contentful') + ', print your key here: (leave blank to disable)',
default: false
},{
type: 'input',
Expand All @@ -83,14 +84,14 @@ module.exports = yeoman.Base.extend({

this.prompt(prompts, function (props) {
this.name = props.name;
this.contentful = props.contentful;

// Tools
var tools = props.tools;
function hasTool(tool) { return tools.indexOf(tool) !== -1; }

this.fabricator = hasTool('fabricator');
this.bootstrapSass = hasTool('bootstrapSass');
this.bootstrap4 = props.bootstrap4;
this.tests = hasTool('tests');

if (props.assets.slice(-1) === '/') {
Expand All @@ -105,89 +106,93 @@ module.exports = yeoman.Base.extend({
this.build = props.build + '/';
}

this.fromSassToTop = '../'.repeat(this.assets.replace(/^\/|\/$/, '').split('/').length + 1);

done();
}.bind(this));
},

writing: {
app: function () {
this.template('_package.json', 'package.json');

this.template('_package.json', 'package.json');
this.template('_gulp_config.json', 'gulp_config.json');
this.template('_gulpfile.js', 'gulpfile.js');
this.template('_gulpfile.babel.js', 'gulpfile.babel.js');

this.template('tasks/_clean.js', 'tasks/clean.js');
this.template('tasks/_server.js', 'tasks/server.js');
this.copy('tasks/gh-pages.js', 'tasks/gh-pages.js');
this.copy('tasks/clean.js', 'tasks/clean.js');
this.copy('tasks/server.js', 'tasks/server.js');
this.copy('tasks/deploy.js', 'tasks/deploy.js');
this.copy('tasks/images.js', 'tasks/images.js');
this.copy('tasks/scripts.js', 'tasks/scripts.js');
this.copy('tasks/icons.js', 'tasks/icons.js');
this.copy('tasks/favicons.js', 'tasks/favicons.js');
if (this.fabricator) {
this.copy('tasks/metalsmith.js', 'tasks/metalsmith.js');
this.copy('tasks/filters.js', 'tasks/filters.js');
}
this.template('tasks/_metalsmith.js', 'tasks/metalsmith.js');
this.copy('tasks/filters.js', 'tasks/filters.js');
this.copy('tasks/single.js', 'tasks/single.js');
this.copy('tasks/styles.js', 'tasks/styles.js');
this.copy('tasks/scripts.js', 'tasks/scripts.js');
this.copy('tasks/vendors.js', 'tasks/vendors.js');

if (this.fabricator) {
this.mkdir(this.assets + 'components');
this.mkdir(this.assets + 'components/atoms');
this.mkdir(this.assets + 'components/molecules');
this.mkdir(this.assets + 'components/organisms');
this.mkdir(this.assets + 'components/pages');
mkdirp.sync(this.assets + 'components');
mkdirp.sync(this.assets + 'components/atoms');
mkdirp.sync(this.assets + 'components/molecules');
mkdirp.sync(this.assets + 'components/organisms');
mkdirp.sync(this.assets + 'components/pages');
this.directory('assets/templates', this.assets + 'templates');
this.directory('assets/data', this.assets + 'data');
this.directory('assets/docs', this.assets + 'docs');
this.mkdir(this.assets + 'sass');
this.mkdir(this.assets + 'sass/atoms');
this.mkdir(this.assets + 'sass/molecules');
this.mkdir(this.assets + 'sass/organisms');
this.mkdir(this.assets + 'sass/pages');
mkdirp.sync(this.assets + 'sass');
mkdirp.sync(this.assets + 'sass/atoms');
mkdirp.sync(this.assets + 'sass/molecules');
mkdirp.sync(this.assets + 'sass/organisms');
mkdirp.sync(this.assets + 'sass/pages');
this.copy('assets/sass/styleguide.scss', this.assets + 'sass/styleguide.scss');
this.copy('assets/sass/styleguide-variables.scss', this.assets + 'sass/styleguide-variables.scss');
}

this.directory('assets/js', this.assets + 'js');

this.mkdir(this.assets + 'img');
this.mkdir(this.assets + 'svg');
this.mkdir(this.assets + 'fonts');
this.mkdir(this.assets + 'icons');
this.mkdir(this.assets + 'favicons');
mkdirp.sync(this.assets + 'img');
mkdirp.sync(this.assets + 'svg');
mkdirp.sync(this.assets + 'fonts');
mkdirp.sync(this.assets + 'icons');
mkdirp.sync(this.assets + 'favicons');

if (this.bootstrap4) {
this.copy('assets/sass/bootstrap4.scss', this.assets + 'sass/bootstrap4.scss');
} else if (this.bootstrapSass) {
this.copy('assets/sass/bootstrap.scss', this.assets + 'sass/bootstrap.scss');
if (this.bootstrapSass) {
this.template('assets/sass/bootstrap.scss', this.assets + 'sass/bootstrap.scss');
}

this.template('assets/sass/_main.scss', this.assets + 'sass/main.scss');
this.copy('assets/sass/main-variables.scss', this.assets + 'sass/main-variables.scss');

if (this.tests) {
this.directory('tests', 'tests');
this.mkdir('tests/unit');
this.mkdir('tests/navigation');
mkdirp.sync('tests/unit');
mkdirp.sync('tests/navigation');
this.copy('tasks/tests-regression.js', 'tasks/tests-regression.js');
this.copy('tasks/tests-unit.js', 'tasks/tests-unit.js');
this.copy('tasks/tests-navigation.js', 'tasks/tests-navigation.js');
}
},

projectfiles: function () {
this.template('babelrc', '.babelrc');
this.copy('editorconfig', '.editorconfig');
this.copy('webpack.dev.config.js', 'webpack.dev.config.js');
this.copy('webpack.prod.config.js', 'webpack.prod.config.js');
this.copy('gitattributes', '.gitattributes');
this.copy('gitignore', '.gitignore');
this.template('gitignore', '.gitignore');
this.copy('eslintrc.yml', '.eslintrc.yml');
this.copy('env', '.env');
this.copy('stylelintrc', '.stylelintrc');
this.template('_stylelintrc', '.stylelintrc');

if (this.contentful) {
this.template('env', '.env');
}
}
},

install: function () {
if (!this.options['skip-install']) {
this.installDependencies();
this.npmInstall();
}
}
});
34 changes: 16 additions & 18 deletions app/templates/_gulp_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@
"ghpages": "<% if (fabricator) { %>styleguide<% } else { %>.<% } %>"
},
"vendors": {
"css": [
""
],
"css": [],
"js": [<% if (bootstrapSass) { %>
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/affix.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/alert.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/button.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/carousel.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/collapse.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/dropdown.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/modal.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/tooltip.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/popover.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/scrollspy.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/tab.js",
"node_modules/bootstrap-sass/assets/javascripts/bootstrap/transition.js"<% } %>
"node_modules/bootstrap/js/dist/alert.js",
"node_modules/bootstrap/js/dist/button.js",
"node_modules/bootstrap/js/dist/carousel.js",
"node_modules/bootstrap/js/dist/collapse.js",
"node_modules/bootstrap/js/dist/dropdown.js",
"node_modules/bootstrap/js/dist/modal.js",
"node_modules/bootstrap/js/dist/popover.js",
"node_modules/bootstrap/js/dist/scrollspy.js",
"node_modules/bootstrap/js/dist/tab.js",
"node_modules/bootstrap/js/dist/tooltip.js",
"node_modules/bootstrap/js/dist/util.js"<% } %>
],
"fonts": [<% if (bootstrapSass) { %>
"node_modules/bootstrap-sass/assets/fonts/bootstrap/*",<% } %>
"fonts": [
"<%= assets %>fonts/*"
],
"polyfills": [
Expand All @@ -42,9 +38,11 @@
"iconsFontName": "icons",
"build": "<%= build %>",
"browsers": ["last 2 versions", "safari 5", "ie 8", "ie 9", "ff 27", "opera 12.1"]<% if (fabricator) { %>,
"singles": [],
"metalsmith": {
"assets": "node_modules/toolbox-utils/styleguide/",
"dist": "styleguide/",
"url": "https://user.github.io/repo/",
"plugins": {
"permalinks": {
"pattern": ":title",
Expand Down Expand Up @@ -78,7 +76,7 @@
"layouts": {
"engine": "swig",
"default": "default.html.swig",
"directory": "assets/templates",
"directory": "<%= assets %>templates",
"rename": true
},
"metalsmithinplace": {
Expand Down
81 changes: 81 additions & 0 deletions app/templates/_gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* Import plugins
*/
import gulp from 'gulp';
import config from './gulp_config.json';
import yargs from 'yargs';

import NodeESModuleLoader from 'node-es-module-loader';
const loader = new NodeESModuleLoader();

import loadPlugins from 'gulp-load-plugins';
const $ = loadPlugins();

import { vendors, vendorsTask } from './tasks/vendors';
import { img, imgTask } from './tasks/images';
import { styles, stylesTask, stylesLintTask } from './tasks/styles';
import { scripts, scriptsTask } from './tasks/scripts';
import { icons, iconsTask } from './tasks/icons';
import { favicons, faviconsTask } from './tasks/favicons';
import { clean, cleanTask } from './tasks/clean';
import { single, singleTask } from './tasks/single';
import { deploy, deployTask } from './tasks/deploy';
import { serve } from './tasks/server';

<% if (tests) { %>
import { testRegression, testRegressionTask } from './tasks/tests-regression';
import { testUnit, testUnitTask } from './tasks/tests-unit';
import { testNavigation, testNavigationTask } from './tasks/tests-navigation';
<% } %>


const conditionalStyleguide = yargs.argv.production ? '' : './tasks/metalsmith';
const inprod = done => done();

/**
* Init project
*/
gulp.task('init', function() {
return gulp.src('node_modules/bootstrap/scss/_variables.scss')
.pipe($.rename('bootstrap-variables.scss'))
.pipe(gulp.dest(`${config.assets}sass/`));
});

/**
* Task to build assets on production server
*/
const build = gulp.series(clean, vendors, single, styles, scripts, img, icons);
gulp.task('build', build);

/**
* Default task
*/
const defaultFunc = (done, isServe) => loader.import(conditionalStyleguide)
.then(m => {
$.util.log('DEVELOPMENT MODE');
if (isServe) {
done(gulp.series(build, favicons, m.default.metalsmith, serve));
} else {
done(gulp.series(build, favicons, m.default.metalsmith));
}
})
.catch(err => {
$.util.log('PRODUCTION MODE');
if (isServe) {
done(gulp.series(build, favicons, serve));
} else {
done(gulp.series(build, favicons));
}
});

gulp.task('default', () => defaultFunc(res => res(), false));

/**
* Serve task
*/
const serveTask = gulp.task('serve', () => defaultFunc(res => res(), true));

/**
* Metalsmith task
*/
const metalsmithTask = gulp.task('metalsmith', yargs.argv.production ? inprod : require('./tasks/metalsmith').metalsmith);
57 changes: 0 additions & 57 deletions app/templates/_gulpfile.js

This file was deleted.

Loading

0 comments on commit d186ec2

Please sign in to comment.