Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Lasse Moos committed Feb 10, 2015
0 parents commit d676d32
Show file tree
Hide file tree
Showing 53 changed files with 2,918 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://editorconfig.org
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/
.idea
17 changes: 17 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"undef": true,
"unused": true,
"strict": true
}
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- '0.10'
before_install:
- currentfolder=${PWD##*/}
- if [ "$currentfolder" != 'generator-drupal-gulp' ]; then cd .. && eval "mv $currentfolder generator-drupal-gulp" && cd generator-drupal-gulp; fi
3 changes: 3 additions & 0 deletions .yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"generator-generator": {}
}
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# generator-drupal-gulp [![Build Status](https://secure.travis-ci.org/lasseyls/generator-drupal-gulp.png?branch=master)](https://travis-ci.org/lasseyls/generator-drupal-gulp)

> [Yeoman](http://yeoman.io) generator

## Getting Started

### What is Yeoman?

Trick question. It's not a thing. It's this guy:

![](http://i.imgur.com/JHaAlBJ.png)

Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create.

Not every new computer comes with a Yeoman pre-installed. He lives in the [npm](https://npmjs.org) package repository. You only have to ask for him once, then he packs up and moves into your hard drive. *Make sure you clean up, he likes new and shiny things.*

```bash
npm install -g yo
```

### Yeoman Generators

Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension.

To install generator-drupal-gulp from npm, run:

```bash
npm install -g generator-drupal-gulp
```

Finally, initiate the generator:

```bash
yo drupal-gulp
```

### Getting To Know Yeoman

Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.

If you'd like to get to know Yeoman better and meet some of his friends, [Grunt](http://gruntjs.com) and [Bower](http://bower.io), check out the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started).


## License

MIT
161 changes: 161 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var path = require('path');
var _ = require('lodash');
_.str = require('underscore.string');

_.mixin(_.str.exports());

module.exports = yeoman.generators.Base.extend({
initializing: function () {
// determine theme name from cwd and form a theme name according to Drupal standards
this.dirName = path.basename(process.cwd());
this.themeName = _(_.slugify(this.dirName)).underscored();


this.pkg = require('../package.json');
},

prompting: function () {
var done = this.async();

// Have Yeoman greet the user.
this.log(yosay(
'Welcome to the superior' + chalk.red('DrupalGulp') + ' generator!'
));

this.themeDesc = 'nameless theme description';
this.themeMachineName = 'nameless';

var prompts = [
{
type: 'input',
name: 'themeName',
message: 'Name your theme:',
default: this.themeName // Default to current folder name
},
{
type: 'input',
name: 'themeDesc',
message: 'Describe your theme:',
default: 'No description'
},
{
type: 'input',
name: 'browserSyncProxy',
message: 'What is the URL of your local drupal dev setup:',
default: 'http://localhost:8888'
},
{
type: 'confirm',
name: 'TypeScript',
message: 'Would you like to enable TypeScript to JavaScript compilation instead of just using JavaScript?',
default: true
}
];

this.prompt(prompts, function (props) {
this.TypeScript = props.TypeScript;
this.themeName = props.themeName;
this.themeDesc = props.themeDesc;
this.browserSyncProxy = props.browserSyncProxy;
this.themeMachineName = _.underscored((_.slugify(this.themeName)));
// set destination path according to destination path + theme name
// this.destinationRoot(this.themeMachineName);

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

writing: {
app: function () {
this.packageInfo = {
"name": this.themeMachineName,
"version": "0.0.0"
};
this.template('_package.json', 'package.json');
this.fs.copy(
this.templatePath('_bower.json'),
this.destinationPath('bower.json')
);

this.template('_theme.info', this.themeMachineName + '.info');
this.template('template.php', 'template.php');
this.template('gulpfile.js', 'gulpfile.js');
this.template('theme-settings.php', 'theme-settings.php');
this.fs.copy(
this.templatePath('src'),
this.destinationPath('src')
);
this.log("Typescript: "+this.TypeScript);
if (!this.TypeScript) {
this.fs.copy(
this.templatePath('_js'),
this.destinationPath('src/scripts/js')
);
} else {
this.fs.copy(
this.templatePath('_ts'),
this.destinationPath('src/scripts/ts')
);
}
},

projectfiles: function () {
this.fs.copy(
this.templatePath('editorconfig'),
this.destinationPath('.editorconfig')
);
this.fs.copy(
this.templatePath('jshintrc'),
this.destinationPath('.jshintrc')
);
this.fs.copy(
this.templatePath('gitignore'),
this.destinationPath('.gitignore')
);
this.fs.copy(
this.templatePath('browserconfig.xml'),
this.destinationPath('browserconfig.xml')
);
this.fs.copy(
this.templatePath('crossdomain.xml'),
this.destinationPath('crossdomain.xml')
);
this.fs.copy(
this.templatePath('screenshot.png'),
this.destinationPath('screenshot.png')
);
this.directory('templates', 'templates');

}
},

install: function () {
this.installDependencies({
skipInstall: this.options['skip-install']
});
this.on('end', function () {
this.spawnCommand('gulp').on('close', function (code) {
var succesMessage =
'----------------------------------------------------' +
chalk.green.bold('\nYay it worked, now try running:\n') +
chalk.yellow.bold('gulp watch') +
'\nand open the BrowserSync url provided in the' +
'\nterminal output, in your preferred browser.'+
'\n----------------------------------------------------';
if (code === 0) {
this.log(succesMessage);
} else {
this.log(chalk.red.bold('Ooops, something went wrong, please check for specific errors above.'));
this.log(chalk.red.bold('If you see errors above like: ENOENT LSTAT NPM, try running:'));
this.log(chalk.yellow.bold('npm cache clean'));
}

}.bind(this));
}.bind(this));
}

});
6 changes: 6 additions & 0 deletions app/templates/_bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "package",
"version": "0.0.0",
"dependencies": {}
}

5 changes: 5 additions & 0 deletions app/templates/_js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(function($) {

// all Javascript code goes here

})(jQuery);
26 changes: 26 additions & 0 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "<%= packageInfo.name %>",
"version": "<%= packageInfo.version %>",
"dependencies": {},
"devDependencies": {
"autoprefixer-core": "^5.1.4",
"browser-sync": "^2.0.0-rc9",
"del": "^1.1.1",
"event-stream": "^3.2.2",
"gulp": "^3.8.10",
"gulp-cache": "^0.2.4",
"gulp-concat": "^2.4.3",
"gulp-filter": "^2.0.1",
"gulp-imagemin": "^2.1.0",
"gulp-load-plugins": "^0.8.0",
"gulp-postcss": "^4.0.3",
"gulp-sass": "^1.3.2",
"gulp-shell": "^0.2.11",
"gulp-size": "^1.2.0",<% if (TypeScript) { %>
"gulp-typescript": "^2.4.2",<% } %>
"gulp-sourcemaps": "^1.3.0"
},
"scripts": {
"postinstall": "find node_modules/ -name '*.info' -type f -delete"
}
}
60 changes: 60 additions & 0 deletions app/templates/_theme.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name = <%= themeName %>
description = <%= themeDesc %>
version = 1.0
core = 7.x

; ========================================
; Stylesheets
; ========================================

stylesheets[all][0] = build/css/style.css

; ========================================
; Scripts
; ========================================

scripts[0] = build/scripts/vendor/modernizr-2.8.3.min.js
scripts[1] = build/scripts/main.js

; ========================================
; Regions
; ========================================

regions[header] = Header
regions[help] = Help
regions[page_top] = Page top
regions[page_bottom] = Page bottom
regions[highlighted] = Highlighted
regions[featured] = Featured
regions[content] = Content
regions[sidebar_first] = Sidebar first
regions[sidebar_second] = Sidebar second
regions[footer] = Footer

; ========================================
; Settings
; ========================================

settings[toggle_logo] = 1
settings[toggle_name] = 1
settings[toggle_slogan] = 1
settings[toggle_node_user_picture] = 1
settings[toggle_comment_user_picture] = 1
settings[toggle_comment_user_verification] = 1
settings[toggle_favicon] = 0
settings[toggle_main_menu] = 1
settings[toggle_secondary_menu] = 1
settings[default_logo] = 1
settings[logo_path] =
settings[logo_upload] =
settings[default_favicon] = 1
settings[favicon_path] =
settings[favicon_upload] =
settings[magic_css_excludes] = :core
settings[magic_footer_js] = 0
settings[magic_library_head] = 0
settings[magic_experimental_js] = 0
settings[magic_js_excludes] =
settings[magic_rebuild_registry] = 1
settings[magic_viewport_indicator] = 0
settings[magic_modernizr_debug] =
4 changes: 4 additions & 0 deletions app/templates/_ts/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Created by Lasse on 09/02/15.
*/
console.log("hello from main.ts");
12 changes: 12 additions & 0 deletions app/templates/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Please read: http://msdn.microsoft.com/en-us/library/ie/dn455106.aspx -->
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="build/images/tile.png"/>
<square150x150logo src="build/images/tile.png"/>
<wide310x150logo src="build/images/tile-wide.png"/>
<square310x310logo src="build/images/tile.png"/>
</tile>
</msapplication>
</browserconfig>
15 changes: 15 additions & 0 deletions app/templates/crossdomain.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<!-- Read this: https://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->

<!-- Most restrictive policy: -->
<site-control permitted-cross-domain-policies="none"/>

<!-- Least restrictive policy: -->
<!--
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
-->
</cross-domain-policy>
Loading

0 comments on commit d676d32

Please sign in to comment.