Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added null check since yo element:repo throws exception #28

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

var banner = require('../banner');
var path = require('path');
var util = require('util');
var yeoman = require('yeoman-generator');
var elementNameValidator = require('validate-element-name');

Expand Down Expand Up @@ -61,9 +60,9 @@ var ElementGenerator = yeoman.generators.Base.extend({

files: function () {
var boilerplateFile = {
'Polymer' : 'src/_polymer.html',
'X-Tag' : 'src/_xtag.html',
'VanillaJS': 'src/_vanillajs.html'
'Polymer' : '_element-polymer.html',
'X-Tag' : '_element-xtag.html',
'VanillaJS': '_element-vanillajs.html'
};

this.copy(boilerplateFile[this.boilerplate], this.elementName + '.html');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-element",
"version": "1.0.0",
"version": "1.1.0",
"description": "Yeoman generator to create Custom Elements using Polymer, X-Tag or VanillaJS",
"author": {
"name": "WebComponents.org",
Expand Down
28 changes: 5 additions & 23 deletions repo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var banner = require('../banner');
var path = require('path');
var pkgNameValidator = require('pkg-name');
var util = require('util');
var yeoman = require('yeoman-generator');
var elementNameValidator = require('validate-element-name');

Expand All @@ -19,17 +18,12 @@ var RepoGenerator = yeoman.generators.Base.extend({
this.on('end', function () {
if (!this.options['skip-install']) {
this.bowerInstall();

if (this.grunt) {
this.npmInstall();
}
}
});
},

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

var prompts = [{
type: 'list',
Expand Down Expand Up @@ -62,7 +56,7 @@ var RepoGenerator = yeoman.generators.Base.extend({
var done = this.async();

pkgNameValidator(answers.githubRepo, function (err, available) {
if (!available.bower) {
if (!available || !available.bower) {
done(true);
}

Expand Down Expand Up @@ -99,11 +93,6 @@ var RepoGenerator = yeoman.generators.Base.extend({
name: 'lifecycle',
message: 'Do you want to include lifecycle callbacks?',
default: true
}, {
type: 'confirm',
name: 'grunt',
message: 'Do you want to include some useful Grunt tasks?',
default: true
}];

this.prompt(prompts, function (props) {
Expand All @@ -125,23 +114,16 @@ var RepoGenerator = yeoman.generators.Base.extend({
this.copy('_index.html', 'index.html');
this.copy('_README.md', 'README.md');

if (this.grunt) {
this.copy('_package.json', 'package.json');
this.copy('_Gruntfile.js', 'Gruntfile.js');
}

this.copy('editorconfig', '.editorconfig');
this.copy('gitignore', '.gitignore');

this.mkdir('src');

var boilerplateFile = {
'Polymer' : 'src/_polymer.html',
'X-Tag' : 'src/_xtag.html',
'VanillaJS': 'src/_vanillajs.html'
'Polymer' : '_element-polymer.html',
'X-Tag' : '_element-xtag.html',
'VanillaJS': '_element-vanillajs.html'
};

this.copy(boilerplateFile[this.boilerplate], 'src/' + this.elementName + '.html');
this.copy(boilerplateFile[this.boilerplate], this.elementName + '.html');
}
});

Expand Down
42 changes: 0 additions & 42 deletions templates/_Gruntfile.js

This file was deleted.

59 changes: 12 additions & 47 deletions templates/_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ Or [download as ZIP](https://github.com/<%= githubUser %>/<%= githubRepo %>/arch

## Usage

1. Import Web Components' polyfill:
1. Import polyfill:

```html
<script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
<script src="bower_components/webcomponentsjs/webcomponents<% if (boilerplate == 'Polymer') { %>-lite<% } %>.min.js"></script>
```

2. Import Custom Element:
2. Import custom element:

```html<% if (boilerplate == 'VanillaJS') { %>
<link rel="import" href="bower_components/<%= githubRepo %>/src/<%= elementName %>.html"><% } else { %>
<link rel="import" href="bower_components/<%= githubRepo %>/dist/<%= elementName %>.html"><% } %>
```html
<link rel="import" href="bower_components/<%= githubRepo %>/<%= elementName %>.html">
```

3. Start using it!
Expand All @@ -55,62 +54,28 @@ Event | Description
--- | ---
`onsomething` | Triggers when something happens.

## Development<% if (grunt) { %>
## Development

In order to run it locally you'll need to fetch some dependencies and a basic server setup.

* Install [Bower](http://bower.io/) & [Grunt](http://gruntjs.com/):
1. Install [bower](http://bower.io/) & [polyserve](https://npmjs.com/polyserve):

```sh
$ [sudo] npm install -g bower grunt-cli
$ npm install -g bower polyserve
```

* Install local dependencies:
2. Install local dependencies:

```sh
$ bower install && npm install
$ bower install
```

* To test your project, start the development server and open `http://localhost:8000`.

```sh
$ grunt server
```<% if (boilerplate != 'VanillaJS') { %>

* To build the distribution files before releasing a new version.

```sh
$ grunt build
```<% } %>

* To provide a live demo, send everything to `gh-pages` branch.

```sh
$ grunt deploy
```<% } else { %>

In order to run it locally you'll need to fetch some dependencies.

* Install [Bower](http://bower.io/):
3. Start development server and open `http://localhost:8080/components/my-repo/`.

```sh
$ [sudo] npm install -g bower
$ polyserve
```

* Install local dependencies:

```sh
$ bower install
```<% } %>

## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -m 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## History

For detailed changelog, check [Releases](https://github.com/<%= githubUser %>/<%= githubRepo %>/releases).
Expand Down
15 changes: 6 additions & 9 deletions templates/_bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@
"name": "<%= githubRepo %>",
"version": "0.0.0",
"description": "<%= elementDescription %>",
"license": "MIT",<% if (boilerplate == 'VanillaJS') { %>
"main": "src/<%= elementName %>.html",<% } else { %>
"main": "dist/<%= elementName %>.html",<% } %>
"license": "MIT",
"main": "<%= elementName %>.html",
"keywords": [<% if (boilerplate == 'Polymer') { %>
"polymer",<% } %><% if (boilerplate == 'X-Tag') { %>
"x-tag",<% } %>
"web-components"
],
"ignore": [
"**/.*",
"node_modules",
"bower_components"
],
"dependencies": {<% if (boilerplate == 'Polymer') { %>
"polymer": "Polymer/polymer#^0.5.1"<% } %><% if (boilerplate == 'X-Tag') { %>
"x-tag-core": "^1.0.0",
"webcomponentsjs": "^0.5.1"<% } %><% if (boilerplate == 'VanillaJS') { %>
"webcomponentsjs": "^0.5.1"<% } %>
"dependencies": {<% if (boilerplate == 'VanillaJS') { %>
"webcomponentsjs": "^0.7.2"<% } %><% if (boilerplate == 'Polymer') { %>
"polymer": "Polymer/polymer#^1.0.0"<% } %><% if (boilerplate == 'X-Tag') { %>
"x-tag-core": "^1.1.6"<% } %>
}
}
29 changes: 29 additions & 0 deletions templates/_element-polymer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- Imports polymer -->
<link rel="import" href="../polymer/polymer.html">

<!-- Defines element markup -->
<dom-module id="<%= elementName %>">
<template></template>
</dom-module>

<!-- Registers custom element -->
<script>
Polymer({
is: '<%= elementName %>'<% if (lifecycle) { %>,

// Fires when an instance of the element is created
created: function() {},

// Fires when the local DOM has been fully prepared
ready: function() {},

// Fires when the element was inserted into the document
attached: function() {},

// Fires when the element was removed from the document
detached: function() {},

// Fires when an attribute was added, removed, or updated
attributeChanged: function(attr, oldVal, newVal) {}<% } %>
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// Fires when an attribute was added, removed, or updated
element.attributeChangedCallback = function(attr, oldVal, newVal) {};<% } %>

// Registers custom element
document.registerElement('<%= elementName %>', {
prototype: element
});
Expand Down
5 changes: 3 additions & 2 deletions templates/src/_xtag.html → templates/_element-xtag.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!-- Import X-Tag -->
<script src="../bower_components/x-tag-core/src/core.js"></script>
<!-- Import x-tag -->
<script src="../x-tag-core/src/core.js"></script>

<script>
(function() {
// Registers custom element
xtag.register('<%= elementName %>', {<% if (lifecycle) { %>
lifecycle: {
// Fires when an instance of the element is created
Expand Down
16 changes: 9 additions & 7 deletions templates/_index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">

<meta charset="utf-8">
<title>&lt;<%= githubRepo %>&gt;</title>

<!-- Importing Web Component's Polyfill -->
<script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
<!-- Imports polyfill -->
<script src="../webcomponentsjs/webcomponents<% if (boilerplate == 'Polymer') { %>-lite<% } %>.min.js"></script>

<!-- Imports custom element -->
<link rel="import" href="<%= elementName %>.html">

<!-- Importing Custom Elements -->
<link rel="import" href="src/<%= elementName %>.html">
</head>
<body>

<!-- Using Custom Elements -->
<!-- Runs custom element -->
<<%= elementName %>></<%= elementName %>>

</body>
Expand Down
10 changes: 0 additions & 10 deletions templates/_package.json

This file was deleted.

1 change: 0 additions & 1 deletion templates/gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
bower_components/
node_modules/
29 changes: 0 additions & 29 deletions templates/src/_polymer.html

This file was deleted.