Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lanceli committed Jun 30, 2014
0 parents commit 93c10bc
Show file tree
Hide file tree
Showing 14 changed files with 305 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

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

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
node_modules/
temp/
21 changes: 21 additions & 0 deletions .jshintrc
@@ -0,0 +1,21 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"white": true
}
7 changes: 7 additions & 0 deletions .travis.yml
@@ -0,0 +1,7 @@
language: node_js
node_js:
- '0.10'
before_install:
- currentfolder=${PWD##*/}
- if [ "$currentfolder" != 'generator-safari-extension' ]; then cd .. && eval "mv $currentfolder generator-safari-extension" && cd generator-safari-extension; fi

47 changes: 47 additions & 0 deletions README.md
@@ -0,0 +1,47 @@
# generator-safari-extension [![Build Status](https://secure.travis-ci.org/lanceli/generator-safari-extension.png?branch=master)](https://travis-ci.org/lanceli/generator-safari-extension)

> [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-safari-extension from npm, run:

```bash
$ npm install -g generator-safari-extension
```

Finally, initiate the generator:

```bash
$ yo safari-extension
```

### 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
87 changes: 87 additions & 0 deletions app/index.js
@@ -0,0 +1,87 @@
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');


var SafariExtensionGenerator = yeoman.generators.Base.extend({
init: function () {
this.pkg = require('../package.json');

// init extension info
this.Info = {
};

this.on('end', function () {
if (!this.options['skip-install']) {
this.installDependencies();
}
});
},

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

// Have Yeoman greet the user.
this.log(yosay('Welcome to the marvelous SafariExtension generator!'));

var prompts = [
{
name: 'CFBundleDisplayName',
message: 'The extension display name?',
default: 'demo'
},
{
name: 'Author',
message: 'The author name?',
default: ''
},
{
name: 'Description',
message: 'The description?',
default: 'Description'
},
{
name: 'CFBundleIdentifier',
message: 'The Identifier?',
default: 'com.yourcompany.name'
},
{
name: 'CFBundleShortVersionString',
message: 'The display version?',
default: '0.1.0'
},
{
name: 'CFBundleVersion',
message: 'The display version?',
default: '0.1.0'
}
];

this.prompt(prompts, function (answers) {
this.Info = answers;
console.log(this.Info);

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

app: function () {
this.mkdir('app.safariextension');

this.copy('_package.json', 'package.json');
this.copy('_bower.json', 'bower.json');
},
hahei: function() {
console.log('hahei');
},

projectfiles: function () {
this.copy('editorconfig', '.editorconfig');
this.copy('jshintrc', '.jshintrc');
}
});

module.exports = SafariExtensionGenerator;
6 changes: 6 additions & 0 deletions app/templates/_bower.json
@@ -0,0 +1,6 @@
{
"name": "package",
"version": "0.0.0",
"dependencies": {}
}

5 changes: 5 additions & 0 deletions app/templates/_package.json
@@ -0,0 +1,5 @@
{
"name": "package",
"version": "0.0.0",
"dependencies": {}
}
13 changes: 13 additions & 0 deletions app/templates/editorconfig
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

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

[*.md]
trim_trailing_whitespace = false
21 changes: 21 additions & 0 deletions app/templates/jshintrc
@@ -0,0 +1,21 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"white": true
}
36 changes: 36 additions & 0 deletions package.json
@@ -0,0 +1,36 @@
{
"name": "generator-safari-extension",
"version": "0.0.0",
"description": "Yeoman generator",
"license": "MIT",
"main": "app/index.js",
"repository": "lanceli/generator-safari-extension",
"author": {
"name": "Lance Li",
"email": "",
"url": "https://github.com/lanceli"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"app"
],
"keywords": [
"yeoman-generator"
],
"dependencies": {
"yeoman-generator": "~0.16.0",
"chalk": "~0.4.0",
"yosay": "^0.1.0"
},
"devDependencies": {
"mocha": "*"
},
"peerDependencies": {
"yo": ">=1.0.0"
}
}
36 changes: 36 additions & 0 deletions test/test-creation.js
@@ -0,0 +1,36 @@
/*global describe, beforeEach, it */
'use strict';
var path = require('path');
var helpers = require('yeoman-generator').test;

describe('safari-extension generator', function () {
beforeEach(function (done) {
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
if (err) {
return done(err);
}

this.app = helpers.createGenerator('safari-extension:app', [
'../../app'
]);
done();
}.bind(this));
});

it('creates expected files', function (done) {
var expected = [
// add files you expect to exist here.
'.jshintrc',
'.editorconfig'
];

helpers.mockPrompt(this.app, {
'someOption': true
});
this.app.options['skip-install'] = true;
this.app.run({}, function () {
helpers.assertFile(expected);
done();
});
});
});
10 changes: 10 additions & 0 deletions test/test-load.js
@@ -0,0 +1,10 @@
/*global describe, beforeEach, it*/
'use strict';
var assert = require('assert');

describe('safari-extension generator', function () {
it('can be imported without blowing up', function () {
var app = require('../app');
assert(app !== undefined);
});
});

0 comments on commit 93c10bc

Please sign in to comment.