Permalink
Browse files

Updating to version with functional element, custom-element subgenera…

…tors
  • Loading branch information...
1 parent c1da5f2 commit 4bfbc7bd4a5c609c85603fdf91b011eb6d4591a6 @addyosmani addyosmani committed Aug 11, 2013
Showing with 11,125 additions and 435 deletions.
  1. +2 −1 .editorconfig
  2. +1 −1 .gitignore
  3. +17 −18 .jshintrc
  4. +7 −0 .npmignore
  5. +42 −0 all/index.js
  6. +161 −4 app/index.js
  7. +0 −9 app/templates/AUTHORS
  8. +0 −65 app/templates/CONTRIBUTING.md
  9. +268 −0 app/templates/Gruntfile.js
  10. +0 −27 app/templates/LICENSE
  11. +0 −23 app/templates/PATENTS
  12. +0 −15 app/templates/README.md
  13. +10 −0 app/templates/_bower.json
  14. +30 −0 app/templates/_package.json
  15. +157 −0 app/templates/app/404.html
  16. BIN app/templates/app/favicon.ico
  17. +553 −0 app/templates/app/htaccess
  18. +3 −0 app/templates/app/robots.txt
  19. +3 −0 app/templates/bowerrc
  20. +21 −0 app/templates/editorconfig
  21. +1 −0 app/templates/gitattributes
  22. +7 −0 app/templates/gitignore
  23. BIN app/templates/glyphicons-halflings-white.png
  24. BIN app/templates/glyphicons-halflings.png
  25. +31 −0 app/templates/index.html
  26. +22 −0 app/templates/jshintrc
  27. +0 −35 app/templates/platform.min.js
  28. +0 −1 app/templates/platform.min.js.map
  29. +0 −33 app/templates/platform.native.min.js
  30. +0 −1 app/templates/platform.native.min.js.map
  31. +0 −35 app/templates/platform.sandbox.min.js
  32. +0 −1 app/templates/platform.sandbox.min.js.map
  33. +0 −35 app/templates/polymer.min.js
  34. +0 −1 app/templates/polymer.min.js.map
  35. +0 −34 app/templates/polymer.native.min.js
  36. +0 −1 app/templates/polymer.native.min.js.map
  37. +0 −35 app/templates/polymer.sandbox.min.js
  38. +0 −1 app/templates/polymer.sandbox.min.js.map
  39. +47 −0 app/templates/test/index.html
  40. +3,464 −0 app/templates/test/lib/chai.js
  41. +1,202 −0 app/templates/test/lib/expect.js
  42. +182 −0 app/templates/test/lib/mocha-1.2.2/mocha.css
  43. +4,494 −0 app/templates/test/lib/mocha-1.2.2/mocha.js
  44. +41 −0 app/templates/test/runner/mocha.js
  45. +1 −0 contributing.md
  46. +21 −0 custom-element/index.js
  47. +37 −0 element/index.js
  48. +16 −23 package.json
  49. +50 −8 readme.md
  50. +31 −0 script-base.js
  51. +24 −0 templates/custom-element.html
  52. +19 −0 templates/polymer-element.html
  53. +0 −28 test/test-file-creation.js
  54. +160 −0 test/test-foo.js
View
@@ -2,7 +2,8 @@
root = true
[*]
-indent_style = tab
+indent_style = space
+indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
View
@@ -1,2 +1,2 @@
node_modules
-test/temp
+temp/
View
@@ -1,20 +1,19 @@
{
- "node": true,
- "esnext": true,
- "bitwise": true,
- "camelcase": true,
- "curly": true,
- "eqeqeq": true,
- "immed": true,
- "indent": 4,
- "latedef": true,
- "newcap": true,
- "noarg": true,
- "quotmark": "single",
- "regexp": true,
- "undef": true,
- "unused": true,
- "strict": true,
- "trailing": true,
- "smarttabs": true
+ "node" : true,
+ "esnext" : true,
+ "bitwise" : false,
+ "curly" : false,
+ "eqeqeq" : true,
+ "eqnull" : true,
+ "immed" : true,
+ "latedef" : true,
+ "newcap" : true,
+ "noarg" : true,
+ "undef" : true,
+ "strict" : false,
+ "trailing" : true,
+ "smarttabs" : true,
+ "quotmark" : "single",
+ "indent" : 2,
+ "white" : true
}
View
@@ -0,0 +1,7 @@
+contributing.md
+.editorconfig
+.gitattributes
+.jshintrc
+.npmignore
+test
+.travis.yml
View
@@ -0,0 +1,42 @@
+var path = require('path');
+var util = require('util');
+var yeoman = require('yeoman-generator');
+
+module.exports = Generator;
+
+function Generator(args, options, config) {
+ yeoman.generators.Base.apply(this, arguments);
+
+ var dirPath = '../templates';
+ this.sourceRoot(path.join(__dirname, dirPath));
+
+ this.dirs = 'element custom-element templates'.split(' ');
+
+ args = ['application'];
+
+ if (this.options['test-framework']) {
+ this.env.options['test-framework'] = this.options['test-framework'];
+ }
+
+ // the api to hookFor and pass arguments may vary a bit.
+ this.hookFor('polymer:app', {
+ args: args
+ });
+ this.hookFor('polymer:element', {
+ args: args
+ });
+
+ this.on('end', function () {
+ this.installDependencies({ skipInstall: this.options['skip-install'] });
+ });
+}
+
+util.inherits(Generator, yeoman.generators.Base);
+
+
+Generator.prototype.createDirLayout = function createDirLayout() {
+ this.dirs.forEach(function (dir) {
+ this.log.create('app/scripts/' + dir);
+ this.mkdir(path.join('app/scripts', dir));
+ }.bind(this));
+};
View
@@ -1,7 +1,164 @@
-'use strict';
+var util = require('util');
+var path = require('path');
+var yeoman = require('yeoman-generator');
-var Generator = module.exports = function () {
- this.directory('.');
+
+module.exports = Generator;
+
+function Generator(args, options, config) {
+ yeoman.generators.Base.apply(this, arguments);
+
+ this.testFramework = this.options['test-framework'] || 'mocha';
+
+
+ this.hookFor(this.testFramework, {
+ as: 'app',
+ options: {
+ options: {
+ 'skip-install': this.options['skip-install']
+ }
+ }
+ });
+
+ this.indexFile = this.readFileAsString(path.join(this.sourceRoot(), 'index.html'));
+
+ this.on('end', function () {
+ if (['app', 'backbone'].indexOf(this.generatorName) >= 0) {
+ this.installDependencies({ skipInstall: this.options['skip-install'] });
+ }
+ });
+}
+
+util.inherits(Generator, yeoman.generators.Base);
+
+Generator.prototype.askFor = function askFor() {
+ var cb = this.async();
+
+ // welcome message
+ console.log(this.yeoman);
+ console.log('Out of the box I include HTML5 Boilerplate and Polymer.');
+
+ var prompts = [{
+ type: 'confirm',
+ name: 'compassBootstrap',
+ message: 'Would you like to include Twitter Bootstrap for Sass?',
+ default: false
+ }];
+
+ this.prompt(prompts, function (props) {
+ // manually deal with the response, get back and store the results.
+ // we change a bit this way of doing to automatically do this in the self.prompt() method.
+ this.compassBootstrap = props.compassBootstrap;
+
+ cb();
+ }.bind(this));
+};
+
+Generator.prototype.git = function git() {
+ this.copy('gitignore', '.gitignore');
+ this.copy('gitattributes', '.gitattributes');
+};
+
+Generator.prototype.bower = function bower() {
+ this.copy('bowerrc', '.bowerrc');
+ this.copy('_bower.json', 'bower.json');
+};
+
+Generator.prototype.jshint = function jshint() {
+ this.copy('jshintrc', '.jshintrc');
+};
+
+Generator.prototype.editorConfig = function editorConfig() {
+ this.copy('editorconfig', '.editorconfig');
+};
+
+Generator.prototype.gruntfile = function gruntfile() {
+ this.template('Gruntfile.js');
+};
+
+Generator.prototype.packageJSON = function packageJSON() {
+ this.template('_package.json', 'package.json');
+};
+
+Generator.prototype.bootstrapImg = function bootstrapImg(){
+ if (this.compassBootstrap) {
+ this.copy('glyphicons-halflings.png', 'app/images/glyphicons-halflings.png');
+ this.copy('glyphicons-halflings-white.png', 'app/images/glyphicons-halflings-white.png');
+ }
+}
+
+Generator.prototype.mainStylesheet = function mainStylesheet() {
+ var contentText = [
+ 'body {\n background: #fafafa;\n}',
+ '\n.hero-unit {\n margin: 50px auto 0 auto;\n width: 300px;\n}'
+ ];
+ var ext = '.css';
+ if (this.compassBootstrap) {
+ contentText = [
+ '$iconSpritePath: \'/images/glyphicons-halflings.png\';',
+ '@import \'sass-bootstrap/lib/bootstrap\';',
+ '\n.hero-unit {\n margin: 50px auto 0 auto;\n width: 300px;\n}'
+ ];
+ ext = '.scss';
+ }
+ this.write('app/styles/main' + ext, contentText.join('\n'));
+};
+
+Generator.prototype.writeIndex = function writeIndex() {
+ if (this.includeRequireJS) {
+ return;
+ }
+
+ // prepare default content text
+ var defaults = ['HTML5 Boilerplate', 'Polymer', 'Bootstrap'];
+ var contentText = [
+ ' <div class="container">',
+ ' <div class="hero-unit">',
+ ' <h1>\'Allo, \'Allo!</h1>',
+ ' <p>You now have</p>',
+ ' <ul>'
+ ];
+
+ var vendorJS = [
+ 'bower_components/jquery/jquery.js',
+ 'bower_components/polymer/polymer.min.js',
+ ];
+
+ this.indexFile = this.appendScripts(this.indexFile, 'scripts/vendor.js', vendorJS);
+
+ this.indexFile = this.appendFiles(this.indexFile, 'js', 'scripts/main.js', [
+ 'scripts/combined-scripts.js'
+ ], null, '.tmp');
+
+ // iterate over defaults and create content string
+ defaults.forEach(function (el) {
+ contentText.push(' <li>' + el +'</li>');
+ });
+
+ contentText = contentText.concat([
+ ' </ul>',
+ ' <p>installed.</p>',
+ ' <h3>Enjoy coding! - Yeoman</h3>',
+ ' </div>',
+ ' </div>',
+ ''
+ ]);
+
+ // append the default content
+ this.indexFile = this.indexFile.replace('<body>', '<body>\n' + contentText.join('\n'));
+};
+
+
+Generator.prototype.setupEnv = function setupEnv() {
+ this.mkdir('app');
+ this.mkdir('app/scripts');
+ this.mkdir('app/scripts/vendor/');
+ this.mkdir('app/styles');
+ this.mkdir('app/images');
+ this.template('app/404.html');
+ this.template('app/favicon.ico');
+ this.template('app/robots.txt');
+ this.copy('app/htaccess', 'app/.htaccess');
+ this.write('app/index.html', this.indexFile);
};
-Generator.name = 'Polymer';
@@ -1,9 +0,0 @@
-# Names should be added to this file with this pattern:
-#
-# For individuals:
-# Name <email address>
-#
-# For organizations:
-# Organization <fnmatch pattern>
-#
-Google Inc. <*@google.com>
@@ -1,65 +0,0 @@
-# Contributing
-
-Want to contribute to Polymer? Great!
-
-We are more than happy to accept external contributions to the project in the form of [feedback](https://groups.google.com/forum/?fromgroups=#!forum/polymer-dev), [bug reports](../../issues), and pull requests.
-
-## Contributor License Agreement
-
-Before we can accept patches, there's a quick web form you need to fill out.
-
-- If you're contributing as an individual (e.g. you own the intellectual property), fill out [this form](http://code.google.com/legal/individual-cla-v1.0.html).
-- If you're contributing under a company, fill out [this form](http://code.google.com/legal/corporate-cla-v1.0.html) instead.
-
-This CLA asserts that contributions are owned by you and that we can license all work under our [license](LICENSE).
-
-Other projects require a similar agreement: jQuery, Firefox, Apache, Node, and many more.
-
-[More about CLAs](https://www.google.com/search?q=Contributor%20License%20Agreement)
-
-## Initial setup
-
-Here's an easy guide that should get you up and running:
-
-1. Fork the project on github and pull down your copy.
- > replace the {{ username }} with your username and {{ repository }} with the repository name
-
- git clone git@github.com:{{ username }}/{{ repository }}.git -b master --recursive
-
- Note the `--recursive`. This is necessary for submodules to initialize properly. If you don't do a recursive clone, you'll have to init them manually:
-
- git submodule init
- git submodule update
-
- Adding `-b master` is a shorthand to checkout the `master` branch. If you include it, skip step 2.
-
-2. Development happens on the `master` branch. Get yourself on it!
-
- git checkout master
-
-That's it for the one time setup. Now you're ready to make a change.
-
-## Submitting a pull request
-
-We iterate fast! To avoid potential merge conflicts, it's a good idea to pull from the main project before making a change and submitting a pull request. The easiest way to do this is setup a remote called `upstream` and do a pull before working on a change:
-
- git remote add upstream git://github.com/Polymer/{{ repository }}.git
-
-Then before making a change, do a pull from the upstream `master` branch:
-
- git pull upstream master
-
-To make life easier, add a "pull upstream" alias in your `.gitconfig`:
-
- [alias]
- pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master"
-
-That will pull in changes from your forked repo, the main (upstream) repo, and merge the two. Then it's just a matter of running `git pu` before a change and pushing to your repo:
-
- git checkout master
- git pu
- # make change
- git commit -a -m 'Awesome things.'
- git push
-
-Lastly, don't forget to submit the pull request.
Oops, something went wrong.

0 comments on commit 4bfbc7b

Please sign in to comment.