Skip to content
This repository was archived by the owner on Jul 2, 2020. It is now read-only.
Merged
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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ coverage/**
node_modules/**
scripts/**
submodules/**
generators/app/templates/**
generators/web/templates/**
118 changes: 118 additions & 0 deletions generators/web/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
'use strict';

var yeoman = require('yeoman-generator'),
chalk = require('chalk');


/**
* Exports the generator
*/
module.exports = yeoman.generators.Base.extend({
constructor: function() {
yeoman.generators.Base.apply(this, arguments);
this.option('skip-install', {desc: 'Skip npm install'});
},

initializing: function() {
var welcomeMessage = [
'\nSpringworks',
chalk.bold.green('Web Scaffolding'),
'Generator\n'
];
this.log(welcomeMessage.join(' '));
this.currentYear = (new Date()).getFullYear();
},

// Ask the user a couple of questions
prompting: function() {
var done = this.async(),

prompts = [
{
type: 'input',
name: 'projectName',
message: 'What\'s your project name?',
default: this.appname
},
{
type: 'input',
name: 'projectDescription',
message: 'Whats\'s your project description?',
default: this.appname
}
];

this.prompt(prompts, function(answers) {
this.appname = answers.projectName.toLowerCase();
this.projectDescription = answers.projectDescription;
done();
}.bind(this));
},

// Writes configuration to the `.yo-rc.json` file
configuring: function() {
this.config.set({
projectName: this.appname,
projectDescription: this.projectDescription
});
},

// Writes a bunch of files to the destination directory
writing: {
projectfiles: function() {
this.template('_package.json', 'package.json');
this.template('_bower.json', 'bower.json');
this.template('_README.md', 'README.md');
this.copy('bowerrc', '.bowerrc');
},

gitFiles: function() {
this.copy('gitignore', '.gitignore');
this.copy('gitattributes', '.gitattributes');
},

lintFiles: function() {
this.copy('eslintignore', '.eslintignore');
this.copy('eslintrc', '.eslintrc');
this.copy('gjslintrc', '.gjslintrc'); // Skoog specific ;)
},

npmFiles: function() {
this.copy('npmignore', '.npmignore');
},

gulpFiles: function() {
this.copy('gulpfile', 'gulpfile.js');
this.directory('gulp', 'gulp');
},

serverFiles: function() {
this.template('config/_default.js', 'config/default.js');
this.copy('config/development.js', 'config/development.js');
this.copy('config/production.js', 'config/production.js');
this.copy('config/test.js', 'config/test.js');
this.copy('server.js', 'server.js');
this.directory('server', 'server');
},

clientFiles: function() {
this.directory('client', 'client');
}

},

// Installs dependencies and run a gulp build
install: function() {
/* istanbul ignore if */
if (!this.options['skip-install']) {
this.installDependencies({
skipInstall: false,
bower: true,
callback: function () {
this.spawnCommand('gulp', ['build']);
}.bind(this)
});
}
}

});
39 changes: 39 additions & 0 deletions generators/web/templates/_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# <%= _.slugify(appname) %>

## Directory Structure

```
├── client - All files for the client application. Gulp will build from this.
│ ├── bower_components - 3rd party libraries. Will be compiled to "bundle-vendor.min.js".
│ ├── fonts - Web fonts will be copied.
│ ├── i18n - i18n and i10n files will be copied.
│ ├── images - Gulp will optimize and copy these.
│ ├── scripts - Gulp will compile all files here to "bundle.min.js".
│ ├── styles - Less css files compiles to "style.css".
│ └── views - Jade templates compiles to .html.
├── config - Server configuration files.
├── gulp - Gulp main file. Here you find gulp configs.
│ └── tasks - All the tasks that can be run with gulp.
├── node_modules - You know what this is.
├── server - All server logic for the site.
│ ├── lib
│ ├── test
│ └── views - Jade files that the server serves. This is usually initials.
└── www - Main distribution directory. Server will serve files from here.
├── fonts - All the web fonts will be served from here. url: '/fonts/*'
├── i18n - All language files will be served from here. url: '/i18n/*'
├── images - Compiled javascript files is housed here. url: '/images/*'
├── scripts - Compiled javascript files is housed here. url: '/scripts/*'
├── styles - Compiled styles lives here. url: '/styles/*'
└── views - Compiled html files. url: '/views/*'
```


## Gulp
Gulp is the build tool that will build and compile everything we need for the app. Look in
`gulp/index.js` for configuration options and in `gulp/tasks/*.js` for various tasks.
22 changes: 22 additions & 0 deletions generators/web/templates/_bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "<%= _.slugify(appname) %>",
"version": "1.0.0",
"description": "<%= projectDescription %>",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular": "~1.3.9",
"angular-route": "~1.3.9",
"angular-translate": "~2.5.2",
"angular-translate-loader-partial": "~2.5.2",
"angular-translate-storage-cookie": "~2.5.2",
"bootstrap": "~3.3.2",
"jquery": "~2.1.1"
}
}
76 changes: 76 additions & 0 deletions generators/web/templates/_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"name": "<%= _.slugify(appname) %>",
"version": "1.0.0",
"description": "<%= projectDescription %>",
"private": true,
"engines": {
"node": ">=0.10.33"
},
"scripts": {
"test": "NODE_ENV=test istanbul cover --report teamcity --report lcov _mocha -- --ui bdd --check-leaks --recursive --slow 200 --reporter spec --globals 'Intl,IntlPolyfill' test",
"lint": "eslint .",
"inspectjs": "jsinspect --threshold 30 ./lib",
"buddyjs": "buddy ./lib",
"quality": "npm run buddyjs && npm run inspectjs && npm run lint",
"test-acceptance": "NODE_ENV=test istanbul cover --report teamcity --report lcov _mocha -- --ui bdd --check-leaks --recursive --slow 200 --reporter spec --globals 'Intl,IntlPolyfill' $(find test/**/acceptance test/acceptance -name '*.js' 2>/dev/null)",
"test-changed": "NODE_ENV=test mocha --ui bdd --check-leaks --recursive --slow 200 --reporter spec --globals 'Intl,IntlPolyfill' $(git diff --name-only test | grep -E '(\\.js)$')",
"test-component": "NODE_ENV=test istanbul cover --report teamcity --report lcov _mocha -- --ui bdd --check-leaks --recursive --slow 200 --reporter spec --globals 'Intl,IntlPolyfill' $(find test/**/component test/component -name *.js 2>/dev/null)",
"test-no-cov": "NODE_ENV=test mocha --ui bdd --check-leaks --recursive --slow 200 --reporter spec --globals 'Intl,IntlPolyfill' test",
"test-unit": "NODE_ENV=test istanbul cover --report teamcity --report lcov _mocha -- --ui bdd --check-leaks --recursive --slow 200 --reporter spec --globals 'Intl,IntlPolyfill' $(find test/**/unit test/unit -name '*.js' 2>/dev/null)"
},
"repository": {
"type": "git",
"url": "git://github.com/Springworks/<%= _.slugify(appname) %>.git"
},
"author": "Springworks",
"bugs": {
"url": "https://github.com/Springworks/<%= _.slugify(appname) %>/issues"
},
"dependencies": {
"app-root-path": "^1.0.0",
"bluebird": "^2.3.11",
"boom": "^2.6.1",
"bunyan": "^1.2.3",
"config": "^1.8.1",
"hapi": "^7.5.2",
"hapi-auth-basic": "^1.1.1",
"hapi-auth-cookie": "^1.4.2",
"hoek": "^2.8.1",
"jade": "^1.7.0",
"joi": "^4.7.0",
"wreck": "^5.0.1"
},
"devDependencies": {
"buddy.js": "^0.8.0",
"chai": "^1.10.0",
"chalk": "^0.5.1",
"code": "^1.2.1",
"eslint": "^0.10.0",
"gulp": "^3.8.10",
"gulp-concat": "^2.4.3",
"gulp-csso": "^0.2.9",
"gulp-eslint": "^0.2.0",
"gulp-gzip": "0.0.8",
"gulp-if": "^1.2.5",
"gulp-imagemin": "^2.1.0",
"gulp-jade": "^0.10.0",
"gulp-less": "^2.0.1",
"gulp-livereload": "^3.4.0",
"gulp-ng-annotate": "^0.5.0",
"gulp-notify": "^2.1.0",
"gulp-plumber": "^0.6.6",
"gulp-rimraf": "^0.1.1",
"gulp-size": "^1.2.0",
"gulp-sourcemaps": "^1.3.0",
"gulp-uglify": "^1.1.0",
"gulp-util": "^3.0.2",
"inquirer": "^0.8.0",
"istanbul": "^0.3.2",
"jsinspect": "^0.4.0",
"main-bower-files": "^2.5.0",
"mocha": "^2.0.1",
"run-sequence": "^1.0.2",
"semver": "^4.2.0",
"yargs": "^1.3.3"
}
}
3 changes: 3 additions & 0 deletions generators/web/templates/bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "client/bower_components"
}
Empty file.
4 changes: 4 additions & 0 deletions generators/web/templates/client/i18n/available.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"en",
"sv"
]
Empty file.
6 changes: 6 additions & 0 deletions generators/web/templates/client/scripts/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
env:
browser: true

globals:
angular: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

angular.module('myApp.version.interpolate-filter', [])
.filter('interpolate', ['version', function(version) {
return function(text) {
return String(text).replace(/\%VERSION\%/mg, version);
};
}]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

angular.module('myApp.version.version-directive', [])
.directive('appVersion', ['version', function(version) {
return function(scope, elm, attrs) {
elm.text(version);
};
}]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

angular.module('myApp.version', [
'myApp.version.interpolate-filter',
'myApp.version.version-directive'
])
.value('version', '1.0');
19 changes: 19 additions & 0 deletions generators/web/templates/client/scripts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

/**
* This is the main starting point of the application. In here we
* bootstrap the whole application.
*/
angular
.module('myApp', [
'ngRoute',
'myApp.version',
'myApp.view1',
'myApp.view2'
])
.config([
'$routeProvider',
function($routeProvider) {
$routeProvider.otherwise({redirectTo: '/'});
}
]);
17 changes: 17 additions & 0 deletions generators/web/templates/client/scripts/view1/view1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

angular.module('myApp.view1', ['ngRoute'])
.config([
'$routeProvider',
function($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/views/view1.html',
controller: 'View1Ctrl'
});
}
])
.controller('View1Ctrl', ['$scope', function($scope) {

$scope.header = 'You did it! Good Work!';

}]);
17 changes: 17 additions & 0 deletions generators/web/templates/client/scripts/view2/view2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

angular.module('myApp.view2', ['ngRoute'])
.config([
'$routeProvider',
function($routeProvider) {
$routeProvider.when('/view2', {
templateUrl: '/views/view2.html',
controller: 'View2Ctrl'
});
}
])
.controller('View2Ctrl', ['$scope', function($scope) {

$scope.header = 'This is the second view';

}]);
11 changes: 11 additions & 0 deletions generators/web/templates/client/styles/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This files is the main file for all the styles.
// Only use imports in this file.

// Important angular cloaking
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
display: none !important;
}


// Bootstrap styles
@import "../bower_components/bootstrap/less/bootstrap.less";
6 changes: 6 additions & 0 deletions generators/web/templates/client/views/view1.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
div.jumbotron
h1 {{header}}
p This is the angular project!
p
a.btn.btn-primary.btn-lg(href='/#/view2', role='button') Page 2

6 changes: 6 additions & 0 deletions generators/web/templates/client/views/view2.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
div.jumbotron
h1 {{header}}
p This is the second page.
p
a.btn.btn-primary.btn-lg(href='/#/', role='button') Page 1

Loading