Skip to content

Commit

Permalink
Merge pull request #19 from gokulkrishh/master
Browse files Browse the repository at this point in the history
Added angular quickcommands
  • Loading branch information
logeshpaul committed Apr 1, 2015
2 parents 26d14df + 35fba8c commit c22cec8
Show file tree
Hide file tree
Showing 14 changed files with 469 additions and 5 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,46 @@ At this stage your project is setup and dependencies are installed, It's showtim
- Run `gulp` to run the server, and you are good to start your development.
# Quick commands
**Angular App**
Use terminal to create controller, service, directive etc. Run following commands to create.
1) Controller
creates a controller in app/js/controllers
```````
yo smacss:controller <name>
```````
2) Service
creates a service in app/js/services
```````
yo smacss:service <name>
```````
3) Directive
creates a directive in app/js/directives
```````
yo smacss:directive <name>
```````
4) Filter
creates a filter in app/js/filters
```````
yo smacss:filter <name>
```````
# Docs
To be updated soon... stay tuned
Expand Down
11 changes: 7 additions & 4 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,16 @@ smacssGenerator.prototype.copyMainFiles = function copyMainFiles() {
this.copy("scss/_module.scss", this.appName + "/app/scss/modules/module.scss");
this.copy("scss/_page_landing.scss", this.appName + "/app/scss/pages/page-landing.scss");

// JS
// TODO: Add JS Structure
this.copy("js/_application.js", this.appName + "/app/js/application.js");
if (this.appType === 'typeAngularApp') {
this.copy("js/_angular_application.js", this.appName + "/app/js/application.js", smacssGenerator.context);
}
else {
this.copy("js/_application.js", this.appName + "/app/js/application.js");
}
};

smacssGenerator.prototype.projectfiles = function projectfiles() {
if(this.appType == 'typeSimpleWebApp') {
if(this.appType === 'typeSimpleWebApp') {
this.template("simple-web-app/_gulpfile.js", this.appName + "/gulpfile.js", smacssGenerator.context);
this.template("simple-web-app/_package.json", this.appName + "/package.json", smacssGenerator.context);
}
Expand Down
3 changes: 2 additions & 1 deletion app/templates/angular-app/_index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
<html ng-app="">
<html ng-app="<%= site_name %>">
<head>
<meta charset="utf-8">
<title><%= site_name %></title>
Expand Down Expand Up @@ -27,5 +27,6 @@
<!-- JS files -->
<script src="js/bower.js" type="text/javascript" charset="utf-8"></script>
<script src="js/application.js" type="text/javascript" charset="utf-8"></script>
<!-- endbuild -->
</body>
</html>
20 changes: 20 additions & 0 deletions app/templates/js/_angular_application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*================================================================
=> App = <%= site_name %>
==================================================================*/
/*global angular*/

'use strict';

var app = angular.module('<%= site_name %>', ['ngRoute']);

app.config(['$routeProvider', function($routeProvider) {

$routeProvider
.when('', {
controller: '',
templateUrl: ''
})

.otherwise({ redirectTo: '/' });
}]);

20 changes: 20 additions & 0 deletions app/templates/js/_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

/*================================================================
=> Controller = <%= classedName %>Ctrl
==================================================================*/
/*global app*/

app.controller('<%= classedName %>Ctrl', ['$scope', function ($scope) {

'use strict';




console.log('Controller === <%= classedName %>Ctrl');
}]);


/*----- End of Controller = <%= classedName %>Ctrl ------*/


21 changes: 21 additions & 0 deletions app/templates/js/_directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*================================================================
=> Directive = <%= cameledName %>
==================================================================*/
/*global app*/

app.directive('<%= cameledName %>', ['$rootScope', function ($rootScope) {

'use strict';

return {
restrict: 'A',
link: function (scope, element, attrs) {

console.log('Directive === <%= cameledName %>');
}
};

}]);


/*----- End of Directive = <%= cameledName %> ------*/
19 changes: 19 additions & 0 deletions app/templates/js/_filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*================================================================
=> Filter = <%= cameledName %>
==================================================================*/
/*global app*/

app.filter('<%= cameledName %>', function () {

'use strict';

return function (input) {

console.log('Filter == <%= cameledName %>');

return;
};
});


/*----- End of Filter = <%= cameledName %> ------*/
51 changes: 51 additions & 0 deletions app/templates/js/_service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

/*================================================================
=> Service = <%= cameledName %>
==================================================================*/
/*global app*/

app.service('<%= cameledName %>', ['$rootScope', '$q', '$http', function ($rootScope, $q, $http) {

'use strict';

//GET method
this.getUserData = function (url) {
var defer = $q.defer();

$http.get(url)
.success(function (data) {
deferred.resolve(data);
})
.error(function (err) {
deferred.reject(err);
});

return deferred.promise;

};

//POST method
this.postUserData = function (userData) {
var defer = $q.defer();

var url = ''; //POST url

$http.post({
url : url,
data : userData
})
.success(function (data) {
deferred.resolve(data);
})
.error(function (err) {
deferred.reject(err);
});

return deferred.promise;

};

}]);


/*----- End of Service = <%= cameledName %> ------*/
31 changes: 31 additions & 0 deletions controller/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';
var util = require('util'),
chalk = require('chalk');

var ScriptBase = require('../script-base.js');


var Generator = module.exports = function Generator() {
ScriptBase.apply(this, arguments);

// if the controller name is suffixed with ctrl, remove the suffix
// if the controller name is just "ctrl," don't append/remove "ctrl"
if (this.name && this.name.toLowerCase() !== 'ctrl' && this.name.substr(-4).toLowerCase() === 'ctrl') {
this.name = this.name.slice(0, -4);
}
};

util.inherits(Generator, ScriptBase);

//Function to create controller
Generator.prototype.createControllerFiles = function createControllerFiles() {

this.log(chalk.yellow('Creating controller, please wait...... \n'));

this.generateSourceAndTest(
'_controller', // controller template name
'spec/controller', //for generating test file in test folder
'controllers', //target dir
this.options['skip-add'] || false
);
};
23 changes: 23 additions & 0 deletions directive/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
var util = require('util'),
chalk = require('chalk');

var ScriptBase = require('../script-base.js');

var Generator = module.exports = function Generator() {
ScriptBase.apply(this, arguments);
};

util.inherits(Generator, ScriptBase);

Generator.prototype.createDirectiveFiles = function createDirectiveFiles() {

this.log(chalk.yellow('Creating directive, please wait...... \n'));

this.generateSourceAndTest(
'_directive',
'spec/directive',
'directives',
this.options['add-index'] || false
);
};
23 changes: 23 additions & 0 deletions filter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
var util = require('util'),
chalk = require('chalk');

var ScriptBase = require('../script-base.js');

var Generator = module.exports = function Generator() {
ScriptBase.apply(this, arguments);
};

util.inherits(Generator, ScriptBase);

Generator.prototype.createFilterFiles = function createFilterFiles() {

this.log(chalk.yellow('Creating filter, please wait...... \n'));

this.generateSourceAndTest(
'_filter',
'spec/filter',
'filters',
this.options['add-index'] || false
);
};
Loading

0 comments on commit c22cec8

Please sign in to comment.