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.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yago committed Nov 18, 2016
2 parents d186ec2 + a8467c1 commit 1e0f2c8
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 76 deletions.
37 changes: 20 additions & 17 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ var toolboxSay = function() {
};

module.exports = yeoman.Base.extend({
constructor: function () {
yeoman.Base.apply(this, arguments);

// add support for a --contentful parameter
this.option('contentful');
},

initializing: function () {
this.pkg = require('../package.json');
},
Expand Down Expand Up @@ -53,23 +60,14 @@ module.exports = yeoman.Base.extend({
checked: true
}, {
name: 'Framework (Bootstrap 4)',
value: 'bootstrapSass',
value: 'bootstrap',
checked: true
}, {
name: 'Tests (Mocha, Casperjs and Chai)',
value: 'tests',
checked: false
}
]
},{
when: function (response) {
// this.log(response);
return response.tools.indexOf('fabricator') !== -1;
},
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',
name: 'assets',
Expand All @@ -79,19 +77,22 @@ module.exports = yeoman.Base.extend({
type: 'input',
name: 'build',
message: 'Where would you like to put your build ?',
default: 'build/'
default: function(answers) {
return answers.assets.indexOf('assets') !== -1 ? answers.assets.replace(/assets\/?$/, 'build/') : 'build/';
}
}];

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

this.contentful = this.options.contentful || false;

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

this.fabricator = hasTool('fabricator');
this.bootstrapSass = hasTool('bootstrapSass');
this.bootstrap = hasTool('bootstrap');
this.tests = hasTool('tests');

if (props.assets.slice(-1) === '/') {
Expand Down Expand Up @@ -145,7 +146,7 @@ module.exports = yeoman.Base.extend({
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.template('assets/sass/styleguide.scss', this.assets + 'sass/styleguide.scss');
this.copy('assets/sass/styleguide-variables.scss', this.assets + 'sass/styleguide-variables.scss');
}

Expand All @@ -157,7 +158,7 @@ module.exports = yeoman.Base.extend({
mkdirp.sync(this.assets + 'icons');
mkdirp.sync(this.assets + 'favicons');

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

Expand All @@ -181,7 +182,7 @@ module.exports = yeoman.Base.extend({
this.copy('webpack.prod.config.js', 'webpack.prod.config.js');
this.copy('gitattributes', '.gitattributes');
this.template('gitignore', '.gitignore');
this.copy('eslintrc.yml', '.eslintrc.yml');
this.copy('eslintrc', '.eslintrc');
this.template('_stylelintrc', '.stylelintrc');

if (this.contentful) {
Expand All @@ -192,7 +193,9 @@ module.exports = yeoman.Base.extend({

install: function () {
if (!this.options['skip-install']) {
this.npmInstall();
this.spawnCommand('yarn').on('error', function () {
console.error(chalk.red('Can\'t run ') + chalk.blue('yarn') + chalk.red(' command because it wasn\'t found. Please run ') + chalk.cyan('npm install -g yarn') + chalk.red(' and try again.'));
});
}
}
});
2 changes: 1 addition & 1 deletion app/templates/_gulp_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"vendors": {
"css": [],
"js": [<% if (bootstrapSass) { %>
"js": [<% if (bootstrap) { %>
"node_modules/bootstrap/js/dist/alert.js",
"node_modules/bootstrap/js/dist/button.js",
"node_modules/bootstrap/js/dist/carousel.js",
Expand Down
13 changes: 5 additions & 8 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
"browserify-shim": {
"jquery": "global:jQuery"
},
"scripts": {
"install": "npm shrinkwrap --dev"
},
"engines": {
"node": "6.7.0",
"npm": "3.10.3"
},
"dependencies": {
"autoprefixer": "^6.4.1",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.5",
"babel-plugin-transform-object-rest-spread": "^6.16.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-react": "^6.16.0",
"babel-register": "^6.14.0",<% if (bootstrapSass) { %>
"bootstrap": "git@github.com:twbs/bootstrap.git#v4-dev",<% } %>
"babel-register": "^6.14.0",<% if (bootstrap) { %>
"bootstrap": "4.0.0-alpha.5",<% } %>
"browser-sync": "^2.16.0",
"del": "~2.2.2",
"gulp": "github:gulpjs/gulp#4.0",
Expand Down Expand Up @@ -51,8 +49,7 @@
"babelify": "^7.3.0",
"browserify-shim": "^3.8.12",<% if (tests) { %>
"casperjs": "^1.1.3",
"chai": "^3.5.0",<% } %>
<% if (contentful) { %>
"chai": "^3.5.0",<% } %><% if (contentful) { %>
"contentful-metalsmith": "^0.4.0",
"dotenv": "^2.0.0",<% } %>
"eslint": "^3.5.0",
Expand Down Expand Up @@ -96,7 +93,7 @@
"sinon-chai": "^2.8.0",<% } %>
"stylelint": "^7.3.0",
"stylelint-config-standard": "^13.0.2",
"toolbox-utils": "^0.0.2",
"toolbox-utils": "^0.0.4",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"webpack-module-hot-accept": "^1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion app/templates/assets/sass/_main.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@charset "UTF-8";

// init:
@import 'main-variables';<% if (bootstrapSass) { %>
@import 'main-variables';<% if (bootstrap) { %>
@import 'bootstrap';<% } %>

<% if (fabricator) { %>
Expand Down
12 changes: 6 additions & 6 deletions app/templates/assets/sass/styleguide.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

@import 'main-variables';
@import 'styleguide-variables';
@import '../../node_modules/toolbox-utils/styleguide/styles/mixins';
@import '../../node_modules/toolbox-utils/styleguide/styles/code';
@import '../../node_modules/toolbox-utils/styleguide/styles/controls';
@import '../../node_modules/toolbox-utils/styleguide/styles/item';
@import '../../node_modules/toolbox-utils/styleguide/styles/layout';
@import '../../node_modules/toolbox-utils/styleguide/styles/menu';
@import '<%= fromSassToTop %>node_modules/toolbox-utils/styleguide/styles/mixins';
@import '<%= fromSassToTop %>node_modules/toolbox-utils/styleguide/styles/code';
@import '<%= fromSassToTop %>node_modules/toolbox-utils/styleguide/styles/controls';
@import '<%= fromSassToTop %>node_modules/toolbox-utils/styleguide/styles/item';
@import '<%= fromSassToTop %>node_modules/toolbox-utils/styleguide/styles/layout';
@import '<%= fromSassToTop %>node_modules/toolbox-utils/styleguide/styles/menu';
15 changes: 11 additions & 4 deletions app/templates/assets/templates/styleguide/item-content.html.swig
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{% macro default(type, content) %}
{% set path = '../../components/' + type + 's/' + content.name + '.html.swig' %}
<div class="styleguide-description clearfix" data-styleguide-toggle="notes">
{% if content.bootstrap %}
<a class="btn btn-secondary btn-sm float-xs-right ml-1" href="{{ content.bootstrap }}"><span class="fa fa-book" aria-hidden="true"></span> Bootstrap doc</a>
{% endif %}

{% if content.notes %}<div class="styleguide-item-notes" data-styleguide-toggle="notes">
{{content.notes|markdown|raw}}
</div>{% endif %}
<div class="styleguide-item-preview"{% if content.background %} style="background: {{ content.background }};"{% endif %}>
{% if content.notes %}
<div class="styleguide-item-notes">
{{content.notes|markdown|raw}}
</div>
{% endif %}
</div>
<div class="styleguide-item-preview"{% if content.background %} style="background: {{ content.background }};"{% endif %}>
{% if content.wrapper %}
<div class="{{ content.wrapper }}">
{% include path %}
Expand Down
15 changes: 15 additions & 0 deletions app/templates/eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"env": {
"browser": true
},
"rules": {
"arrow-body-style": 0,
"camelcase": 0,
"global-require": 0,
"import/extensions": 0,
"import/no-unresolved": 0,
},
"plugins": []
}
23 changes: 0 additions & 23 deletions app/templates/eslintrc.yml

This file was deleted.

4 changes: 2 additions & 2 deletions app/templates/tasks/_metalsmith.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const metalsmithDocs = () => {
}
}
metadatas['path'] = yargs.argv.ghpages ? config.metalsmith.url : '/';
metadatas['scriptsPath'] = yargs.argv.production ? `${metadatas['path']}build/js/` : metadatas['path'];
metadatas['scriptsPath'] = yargs.argv.production || yargs.argv.ghpages ? `${metadatas['path']}build/js/` : metadatas['path'];
done();
},
define({
Expand All @@ -117,7 +117,7 @@ export const metalsmithDocs = () => {
function(files, metalsmith, done){
// Clean dirty front-matter comment
for (let file in files) {
files[file].contents = new Buffer(files[file].contents.toString().replace(/---[\s\S]*?---/g, ''));
files[file].contents = new Buffer(files[file].contents.toString().replace(/---[\s\S]*?---\n/g, ''));
}
done();
},
Expand Down
2 changes: 1 addition & 1 deletion app/templates/tasks/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function errorAlert(error){
*/
export const scriptsBuild = (done) => {
// run webpack
if (yargs.argv.production) {
if (yargs.argv.production || yargs.argv.ghpages) {
webpack(webpackSettings, function(err, stats) {
if(err) throw new $.util.PluginError('webpack', err);
$.util.log('[webpack]', stats.toString({
Expand Down
8 changes: 3 additions & 5 deletions component/templates/_component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---
title: <%= name %>
name: <%= name.charAt(0).toUpperCase() + name.slice(1) %>
title: <%= name.charAt(0).toUpperCase() + name.slice(1) %>
name: <%= slug(name).toLowerCase() %>
collection: <%= type %>
notes: |
##### Usage : `<%= slug(name).toLowerCase() %>`
##### Options :
- **option** - Type
[Write your notes here]
---
1 change: 1 addition & 0 deletions component/templates/_doc.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: <%= name %>
name: <%= slug(name).toLowerCase() %>
collection: docs
styleguide: true
---
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-toolbox",
"version": "1.0.0",
"version": "1.0.1",
"description": "Yeoman generator",
"license": "MIT",
"main": "app/index.js",
Expand Down
11 changes: 4 additions & 7 deletions update/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = yeoman.Base.extend({
var prompts = [{
type: 'checkbox',
name: 'updates',
message: 'What would you like to update in your project ? (unselect the updates you don\'t want).\n⚠️ The updates may broken your project if you are still using the Handlebars/Fabricator components.',
message: 'What would you like to update in your project ? (unselect the updates you don\'t want).\n⚠️ The updates may break your project if you are still using the Handlebars/Fabricator components.',
choices: [{
name: 'Dev dependencies (in you package.json)',
value: 'dependencies',
Expand Down Expand Up @@ -75,15 +75,12 @@ module.exports = yeoman.Base.extend({
this.tests = true;
}

this.bootstrap4 = false;
this.bootstrapSass = false;
this.bootstrap = false;
var stylesheet = this.destinationPath(this.config.assets + 'sass/main.scss');
if(pathExists.sync(stylesheet)){
var body = fs.readFileSync(stylesheet).toString();
if (body.indexOf('bootstrap4') !== -1 ) {
this.bootstrap4 = true;
} else if (body.indexOf('bootstrap') !== -1 ) {
this.bootstrapSass = true;
if (body.indexOf('bootstrap') !== -1 ) {
this.bootstrap = true;
}
} else {
this.log(chalk.red("No main.sccs founded !") + "\nMake sure that your main.scss file is at the root of your sass folder.");
Expand Down

0 comments on commit 1e0f2c8

Please sign in to comment.