├── .bowerrc
├── .editorconfig
├── .gitignore
├── .jshintrc
├── .travis.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── Gruntfile.js
├── LICENSE
├── README.md
├── bower.json
├── karma.conf.js
├── package.json
├── src
└── component.js
└── test
└── unit
└── componentSpec.js
/.bowerrc:
--------------------------------------------------------------------------------
1 | {
2 | "directory": "bower_components"
3 | }
4 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | components
4 | bower_components
5 | dist
6 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "node": true,
3 | "es5": true,
4 | "esnext": false,
5 | "bitwise": true,
6 | "camelcase": true,
7 | "curly": true,
8 | "eqeqeq": true,
9 | "immed": true,
10 | "indent": 2,
11 | "latedef": false,
12 | "newcap": true,
13 | "noarg": true,
14 | "quotmark": "single",
15 | "regexp": true,
16 | "undef": true,
17 | "unused": true,
18 | "strict": true,
19 | "trailing": true,
20 | "smarttabs": true
21 | }
22 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "0.10"
4 |
5 | before_install:
6 | - npm install -g grunt-cli karma bower
7 | - bower install
8 |
9 | before_script:
10 | - export DISPLAY=:99.0
11 | - sh -e /etc/init.d/xvfb start
12 |
13 | script: "grunt"
14 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0x-r4bbit/angular-component-seed/72b2bb22be0af2c4e6cee1e49e24f9d1b2696615/CHANGELOG.md
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guide
2 |
3 | Contributing to this repo is fairly easy. This document shows you how to
4 | get the project, run all provided tests and generate a production ready build.
5 |
6 | It also covers provided grunt tasks, that help you developing on this repo.
7 |
8 | ## Dependencies
9 |
10 | To make sure, that the following instructions work, please install the following dependecies
11 | on you machine:
12 |
13 | - Node.js
14 | - npm
15 | - Git
16 |
17 | If you install node through the binary installation file, **npm** will be already there.
18 | When **npm** is installed, use it to install the needed npm packages:
19 |
20 | - bower npm install -g bower
21 | - grunt-cli npm install -g grunt-cli
22 | - karma npm install -g karma
23 |
24 | ## Installation
25 |
26 | To get the source of this project clone the git repository via:
27 |
28 | ````
29 | $ git clone https://github.com/PascalPrecht/angular-component-seed
30 | ````
31 |
32 | This will clone the complete source to your local machine. Navigate to the project folder
33 | and install all needed dendencies via **npm** and **bower**:
34 |
35 | ````
36 | $ npm install
37 | $ bower install
38 | ````
39 |
40 | The project is now installed and ready to be built.
41 |
42 | ## Building
43 |
44 | This repo comes with a few **grunt tasks** which help you to automate
45 | the development process. The following grunt tasks are provided:
46 |
47 | #### grunt
48 |
49 | Running grunt
without any parameters, will actually execute the registered
50 | default task. This task is currently nothing more then a **lint task**, to make sure
51 | that your JavaScript code is written well.
52 |
53 | #### grunt test
54 |
55 | grunt test
executes (as you might thought) the unit tests, which are located
56 | in test/unit
. The task uses **karma** the spectacular test runner to executes
57 | the tests with the **jasmine testing framework**.
58 |
59 | #### grunt build
60 |
61 | You only have to use this task, if you want to generate a production ready build of
62 | this project. This task will also **lint**, **test** and **minify** the
63 | source. After running this task, you'll find the following files in a generated
64 | dist
folder:
65 |
66 | ````
67 | dist/angular--x.x.x.js
68 | dist/angular--x.x.x.min.js
69 | ````
70 |
71 | #### grunt watch
72 |
73 | This task will watch all relevant files. When it notice a change, it'll run the
74 | **lint** and **test** task. Use this task while developing on the source
75 | to make sure, everytime you make a change you get notified if your code is incosistent
76 | or doesn't pass the tests.
77 |
78 | ## Contributing/Submitting changes
79 |
80 | - Checkout a new branch based on master
and name it to what you intend to do:
81 | - Example:
82 | ````
83 | $ git checkout -b BRANCH_NAME
84 | ````
85 | - Use one branch per fix/feature
86 | - Make your changes
87 | - Make sure to provide a spec for unit tests
88 | - Run your tests with either karma start
or grunt test
89 | - When all tests pass, everything's fine
90 | - Commit your changes
91 | - Please provide a git message which explains what you've done
92 | - This repo uses [Brian's conventional-changelog task](https://github.com/btford/grunt-conventional-changelog) so please make sure your commits follow the [conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit)
93 | - Commit to the forked repository
94 | - Make a pull request
95 | - Make sure you send the PR to the canary
branch
96 | - Travis CI is watching you!
97 |
98 | If you follow these instructions, your PR will land pretty safety in the main repo!
99 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function (grunt) {
2 | 'use strict';
3 |
4 | require('load-grunt-tasks')(grunt);
5 | var _ = require('lodash');
6 |
7 | var karmaConfig = function(configFile, customOptions) {
8 | var options = { configFile: configFile, keepalive: true };
9 | var travisOptions = process.env.TRAVIS && { browsers: ['Firefox'], reporters: 'dots' };
10 | return _.extend(options, customOptions, travisOptions);
11 | };
12 |
13 | grunt.initConfig({
14 | pkg: grunt.file.readJSON('bower.json'),
15 | meta: {
16 | banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
17 | '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
18 | '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
19 | '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
20 | ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
21 | },
22 | watch: {
23 | scripts: {
24 | files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
25 | tasks: ['jshint', 'karma:unit']
26 | }
27 | },
28 | jshint: {
29 | all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
30 | options: {
31 | eqeqeq: true,
32 | globals: {
33 | angular: true
34 | }
35 | }
36 | },
37 | concat: {
38 | src: {
39 | src: ['src/**/*.js'],
40 | dest: 'dist/angular-component-<%= pkg.version %>.js'
41 | }
42 | },
43 | uglify: {
44 | src: {
45 | files: {
46 | 'dist/angular-component-<%= pkg.version %>.min.js': '<%= concat.src.dest %>'
47 | }
48 | }
49 | },
50 | karma: {
51 | unit: {
52 | options: karmaConfig('karma.conf.js', {
53 | singleRun: true
54 | })
55 | },
56 | server: {
57 | options: karmaConfig('karma.conf.js', {
58 | singleRun: false
59 | })
60 | }
61 | },
62 | changelog: {
63 | options: {
64 | dest: 'CHANGELOG.md'
65 | }
66 | },
67 | ngmin: {
68 | src: {
69 | src: '<%= concat.src.dest %>',
70 | dest: '<%= concat.src.dest %>'
71 | }
72 | },
73 | clean: ['dist/*']
74 | });
75 |
76 | grunt.registerTask('default', ['jshint', 'karma:unit']);
77 | grunt.registerTask('test', ['karma:unit']);
78 | grunt.registerTask('test-server', ['karma:server']);
79 | grunt.registerTask('build', ['clean', 'jshint', 'karma:unit', 'concat', 'ngmin', 'uglify']);
80 | };
81 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2 | Version 2, December 2004
3 |
4 | Copyright (C) 2004 Sam Hocevar
5 |
6 | Everyone is permitted to copy and distribute verbatim or modified
7 | copies of this license document, and changing it is allowed as long
8 | as the name is changed.
9 |
10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12 |
13 | 0. You just DO WHAT THE FUCK YOU WANT TO.
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # angular-component-seed
2 |
3 | [](https://travis-ci.org/PascalPrecht/angular-component-seed)
4 | +[](https://david-dm.org/PascalPrecht/angular-component-seed)
5 | +[](https://david-dm.org/PascalPrecht/angular-component-seed)
6 |
7 | > A seed for reusable Angular components
8 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "author": "Pascal Precht",
3 | "name": "angular-component-seed",
4 | "description": "Seed for reusable Angular components.",
5 | "version": "0.1.1",
6 | "homepage": "http://github.com/PascalPrecht/angular-component-seed",
7 | "repository": {
8 | "type": "git",
9 | "url": "git://github.com/PascalPrecht/angular-component-seed"
10 | },
11 | "dependencies": {
12 | "angular": "~1.2.3"
13 | },
14 | "devDependencies": {
15 | "angular-mocks": "~1.2.3"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | module.exports = function(config) {
2 | 'use strict';
3 |
4 | config.set({
5 |
6 | // base path, that will be used to resolve files and exclude
7 | basePath: '',
8 |
9 |
10 | // list of files / patterns to load in the browser
11 | files: [
12 | 'bower_components/angular/angular.js',
13 | 'bower_components/angular-mocks/angular-mocks.js',
14 | 'src/**/*.js',
15 | 'test/**/*Spec.js'
16 | ],
17 |
18 | frameworks: ['jasmine'],
19 |
20 |
21 | // list of files to exclude
22 | exclude: [
23 |
24 | ],
25 |
26 |
27 | // test results reporter to use
28 | // possible values: 'dots', 'progress', 'junit'
29 | reporters: ['progress'],
30 |
31 | // web server port
32 | port: 9876,
33 |
34 |
35 | // cli runner port
36 | runnerPort: 9100,
37 |
38 |
39 | // enable / disable colors in the output (reporters and logs)
40 | colors: true,
41 |
42 |
43 | // level of logging
44 | // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
45 | logLevel: config.LOG_INFO,
46 |
47 |
48 | // enable / disable watching file and executing tests whenever any file changes
49 | autoWatch: true,
50 |
51 |
52 | // Start these browsers, currently available:
53 | // - Chrome
54 | // - ChromeCanary
55 | // - Firefox
56 | // - Opera
57 | // - Safari (only Mac)
58 | // - PhantomJS
59 | // - IE (only Windows)
60 | browsers: ['Chrome'],
61 |
62 |
63 | // If browser does not capture in given timeout [ms], kill it
64 | captureTimeout: 60000,
65 |
66 |
67 | // Continuous Integration mode
68 | // if true, it capture browsers, run tests and exit
69 | singleRun: false
70 | });
71 | };
72 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-component-seed",
3 | "version": "0.1.1",
4 | "description": "Seed for reusable Angular components.",
5 | "main": "component.js",
6 | "scripts": {
7 | "test": "./node_modules/karma/bin/karma start --browsers Firefox --single-run"
8 | },
9 | "author": {
10 | "name": "Pascal Precht"
11 | },
12 | "license": "WTFPL",
13 | "devDependencies": {
14 | "grunt": "~0.4.2",
15 | "grunt-contrib-watch": "~0.5.3",
16 | "grunt-contrib-concat": "~0.3.x",
17 | "grunt-contrib-uglify": "~0.2.x",
18 | "grunt-contrib-jshint": "~0.4.x",
19 | "grunt-contrib-clean": "~0.5.0",
20 | "grunt-karma": "~0.7.x",
21 | "grunt-conventional-changelog": "~1.0.x",
22 | "grunt-ngmin": "~0.0.3",
23 | "load-grunt-tasks": "~0.2.0",
24 | "lodash": "~2.4.x"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/component.js:
--------------------------------------------------------------------------------
1 | angular.module('author.component-name', ['ng']);
2 |
3 | angular.module('author.component-name').factory('thingService', function () {
4 | return {
5 | sayHello: function () {
6 | return 'Hello!';
7 | }
8 | };
9 | });
10 |
--------------------------------------------------------------------------------
/test/unit/componentSpec.js:
--------------------------------------------------------------------------------
1 | describe('author.component-name', function () {
2 |
3 | beforeEach(module('author.component-name'));
4 |
5 | it('should have thingService', function () {
6 | inject(function (thingService) {
7 | expect(thingService).toBeDefined();
8 | });
9 | });
10 |
11 | describe('thingService', function () {
12 |
13 | var thingService;
14 |
15 | beforeEach(inject(function (_thingService_) {
16 | thingService = _thingService_;
17 | }));
18 |
19 | it('should be an object', function () {
20 | expect(typeof thingService).toBe('object');
21 | });
22 |
23 | it('should have a method sayHello()', function () {
24 | expect(thingService.sayHello).toBeDefined();
25 | });
26 |
27 | describe('sayHello()', function () {
28 |
29 | it('should be a function', function () {
30 | expect(typeof thingService.sayHello).toBe('function');
31 | });
32 |
33 | it('should return a string', function () {
34 | expect(typeof thingService.sayHello()).toBe('string');
35 | });
36 |
37 | it('should return \'Hello!\'', function () {
38 | expect(thingService.sayHello()).toEqual('Hello!');
39 | });
40 | });
41 | });
42 | });
43 |
--------------------------------------------------------------------------------