Skip to content

Commit

Permalink
Adds initial prompts for generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackHawkinsMC committed Jun 21, 2016
0 parents commit e05bd5e
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- v6
- v5
- v4
- '0.12'
- '0.10'
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 ZackHawkinsMC <zack.hawkins@mediacurrent.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# generator-mc-d-8-theme [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
> Yeoman generator for creating Drupal 8 component based themes.
## Installation

First, install [Yeoman](http://yeoman.io) and generator-mc-d-8-theme using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).

```bash
npm install -g yo
npm install -g generator-mc-d-8-theme
```

Then generate your new project:

```bash
yo mc-d-8-theme
```

## Getting To Know Yeoman

* Yeoman has a heart of gold.
* Yeoman is a person with feelings and opinions, but is very easy to work with.
* Yeoman can be too opinionated at times but is easily convinced not to be.
* Feel free to [learn more about Yeoman](http://yeoman.io/).

## License

MIT © [ZackHawkinsMC]()


[npm-image]: https://badge.fury.io/js/generator-mc-d-8-theme.svg
[npm-url]: https://npmjs.org/package/generator-mc-d-8-theme
[travis-image]: https://travis-ci.org//generator-mc-d-8-theme.svg?branch=master
[travis-url]: https://travis-ci.org//generator-mc-d-8-theme
[daviddm-image]: https://david-dm.org//generator-mc-d-8-theme.svg?theme=shields.io
[daviddm-url]: https://david-dm.org//generator-mc-d-8-theme
99 changes: 99 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var _ = require('lodash');

module.exports = yeoman.Base.extend({
prompting: function () {
// Have Yeoman greet the user.
this.log(yosay(
'Welcome to the cool ' + chalk.red('Mediacurrent D8 theme') + ' generator!'
));

var prompts = [
{
name: 'themeName',
message: 'What is your theme\'s human readable name? \n It\'s recommended to add a "theme" to the name so it doesn\'t conflict with modules. EX: Unicorn Theme',
default: _.startCase(this.appname) // Default to current folder name
},
{
name: 'themeNameMachine',
message: 'What is your theme\'s machine name? EX: unicorn_theme',
default: this.appname // Default to current folder name
},
{
name: 'themeDesc',
message: 'What is your theme\'s description?'
},
{
type: 'confirm',
name: 'baseTheme',
message: 'Would you like to use a base theme?'
},
{
type: 'list',
name: 'whichBaseTheme',
message: 'Which base theme would you like to use?',
choices: [
{
value: 'stable',
name: 'Use Stable as a base theme'
},
{
value: 'classy',
name: 'Use Classy as a base theme'
}
],
when: function (answers) {
// If baseTheme is true, ask this question.
// If it's false skip this question.
return (answers.baseTheme);
}
},
{
type: 'checkbox',
name: 'howMuchTheme',
message: 'What would you like included in this build?',
choices: [
{
value: 'kssNode',
name: 'KSS Node style guide'
},
{
value: 'normalize',
name: 'Normalize.css broken up into base partials'
},
{
value: 'breakpoint',
name: 'Breakpoint plugin'
},
{
value: 'singularity',
name: 'Singularity Grid System and Breakpoint'
},
{
value: 'utilities',
name: 'Helpful mixins, utilities, components and example layout partials'
}
]
}
];

return this.prompt(prompts).then(function (props) {
// To access props later use this.props.someAnswer;
this.props = props;
}.bind(this));
},

writing: function () {
this.fs.copy(
this.templatePath('dummyfile.txt'),
this.destinationPath('dummyfile.txt')
);
},

install: function () {
this.installDependencies();
}
});
Empty file.
52 changes: 52 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use strict';
var path = require('path');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');

gulp.task('static', function () {
return gulp.src('**/*.js')
.pipe(excludeGitignore())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});

gulp.task('nsp', function (cb) {
nsp({package: path.resolve('package.json')}, cb);
});

gulp.task('pre-test', function () {
return gulp.src('generators/**/*.js')
.pipe(excludeGitignore())
.pipe(istanbul({
includeUntested: true
}))
.pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-test'], function (cb) {
var mochaErr;

gulp.src('test/**/*.js')
.pipe(plumber())
.pipe(mocha({reporter: 'spec'}))
.on('error', function (err) {
mochaErr = err;
})
.pipe(istanbul.writeReports())
.on('end', function () {
cb(mochaErr);
});
});

gulp.task('watch', function () {
gulp.watch(['generators/**/*.js', 'test/**'], ['test']);
});

gulp.task('prepublish', ['nsp']);
gulp.task('default', ['static', 'test']);
50 changes: 50 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "generator-mc-d8-theme",
"version": "0.0.0",
"description": "Yeoman generator for creating Drupal 8 component based themes.",
"homepage": "",
"author": {
"name": "ZackHawkinsMC",
"email": "zack.hawkins@mediacurrent.com",
"url": ""
},
"files": [
"generators"
],
"main": "generators/index.js",
"keywords": [
"yeoman-generator"
],
"dependencies": {
"yeoman-generator": "^0.23.0",
"chalk": "^1.0.0",
"yosay": "^1.0.0"
},
"devDependencies": {
"eslint": "^2.1.0",
"eslint-config-xo-space": "^0.13.0",
"gulp": "^3.9.0",
"gulp-eslint": "^2.0.0",
"gulp-exclude-gitignore": "^1.0.0",
"gulp-istanbul": "^0.10.3",
"gulp-line-ending-corrector": "^1.0.1",
"gulp-mocha": "^2.0.0",
"gulp-nsp": "^2.1.0",
"gulp-plumber": "^1.0.0",
"lodash": "^4.13.1",
"yeoman-assert": "^2.0.0",
"yeoman-test": "^1.0.0"
},
"eslintConfig": {
"extends": "xo-space",
"env": {
"mocha": true
}
},
"repository": "/generator-mc-d8-theme",
"scripts": {
"prepublish": "gulp prepublish",
"test": "gulp"
},
"license": "MIT"
}
18 changes: 18 additions & 0 deletions test/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';
var path = require('path');
var assert = require('yeoman-assert');
var helpers = require('yeoman-test');

describe('generator-mc-d-8-theme:app', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/app'))
.withPrompts({someAnswer: true})
.toPromise();
});

it('creates files', function () {
assert.file([
'dummyfile.txt'
]);
});
});

0 comments on commit e05bd5e

Please sign in to comment.