Skip to content

Commit

Permalink
React app folder structure for issue FuelFrontend#50
Browse files Browse the repository at this point in the history
  • Loading branch information
DarshanKumar89 committed Apr 22, 2016
1 parent 295bde7 commit 82c1231
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 9 deletions.
56 changes: 47 additions & 9 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ smacssGenerator.prototype.welcome = function welcome() {
this.log(
chalk.magenta("Your'e using the Perfectionist generator for Frontend\n") +
chalk.yellow('┌──────────────────────────────────────────────────────────────┐ \n' +
'| Answer simple questions to kick start your project | \n' +
'| Answer simple questions to kick start your project adsad | \n' +
'└──────────────────────────────────────────────────────────────┘ ')
);
}
Expand Down Expand Up @@ -101,6 +101,10 @@ smacssGenerator.prototype.askAppType = function askAppType() {
name: 'Angular App',
value: 'typeAngularApp',
checked: false
},{
name: 'React App',
value: 'typeReactApp',
checked: false
},{
name: 'Restify App',
value: 'typeRestifyApp',
Expand Down Expand Up @@ -250,7 +254,33 @@ smacssGenerator.prototype.scaffoldFolders = function scaffoldFolders() {
}
this.mkdir(this.appName + '/build');
}

}

if (this.appType === 'typeReactApp') {
this.mkdir(this.appName + '/components');
this.mkdir(this.appName + '/containers');
this.mkdir(this.appName + '/actions');


} else {

// Common Scaffolding for all projets
this.mkdir(this.appName + '/app');
this.mkdir(this.appName + '/app/css');
this.mkdir(this.appName + '/app/scss');
this.mkdir(this.appName + '/app/js');
this.mkdir(this.appName + '/app/images');
this.mkdir(this.appName + '/app/fonts');

if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp' || this.appType === 'typeReactApp') {
if(this.appType !== 'typeAdminWebApp' || this.appType !== 'typeReactApp') {
this.mkdir(this.appName + '/app/partials');
}
this.mkdir(this.appName + '/build');
}

}
};

// Copying - HTML files
Expand Down Expand Up @@ -292,7 +322,7 @@ smacssGenerator.prototype.copyCSSFiles = function copyCSSFiles() {

// SMACSS - SCSS Structure
// TODO: Update structure based on ticket #7
if(this.appType !== "typeAdminWebApp") {
if(this.appType !== "typeAdminWebApp" ) {
this.copy("scss/_master.scss", this.appName + "/app/scss/master.scss");
this.copy("scss/_base.scss", this.appName + "/app/scss/base.scss");
this.copy("scss/_layout.scss", this.appName + "/app/scss/layout.scss");
Expand All @@ -303,7 +333,7 @@ smacssGenerator.prototype.copyCSSFiles = function copyCSSFiles() {
this.copy("scss/_page_landing.scss", this.appName + "/app/scss/pages/page-landing.scss");
}

if(this.appType === "typeAdminWebApp") {
if(this.appType === "typeAdminWebApp" ) {
this.copy("_" + this.appType + "/scss/_master.scss", this.appName + "/app/scss/master.scss");
this.copy("_" + this.appType + "/scss/_admin.scss", this.appName + "/app/scss/admin.scss");
this.copy("_" + this.appType + "/scss/_bootstrap.scss", this.appName + "/app/scss/bootstrap.scss");
Expand All @@ -315,7 +345,7 @@ smacssGenerator.prototype.copyCSSFiles = function copyCSSFiles() {
// TODO: Replace with bower font-awesome plugin
// Copy - Fonts for Admin Web App
smacssGenerator.prototype.copyFonts = function copyFonts() {
if(this.appType === "typeAdminWebApp") {
if(this.appType === "typeAdminWebApp" ) {
this.copy("_" + this.appType + "/fonts/_fontawesome-webfont.eot", this.appName + "/app/fonts/fontawesome-webfont.eot");
this.copy("_" + this.appType + "/fonts/_fontawesome-webfont.svg", this.appName + "/app/fonts/fontawesome-webfont.svg");
this.copy("_" + this.appType + "/fonts/_fontawesome-webfont.ttf", this.appName + "/app/fonts/fontawesome-webfont.ttf");
Expand All @@ -337,15 +367,20 @@ smacssGenerator.prototype.copyJSFiles = function copyJSFiles() {
else {
this.copy("js/_application.js", this.appName + "/app/js/application.js");
}

//if (this.appType === 'typeReactApp') {
// this.template("_typeReactApp/_app.js", this.appName + "/app.js", smacssGenerator.context );
//}

};

// Copy - Gulp Task Files
smacssGenerator.prototype.copyTasksFile = function copyTasksFile() {
if (this.appType === 'typeSimpleWebApp') {
if (this.appType === 'typeSimpleWebApp' || this.appType === 'typeReactApp') {
this.copy("tasks/simpleWebApp/_simple_browser_sync.js", this.appName + "/tasks/browser-sync.js");
this.copy("tasks/simpleWebApp/_simple_sass.js", this.appName + "/tasks/sass.js");
}
else if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp' || this.appType === "typeAdminWebApp") {
else if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp' || this.appType === "typeAdminWebApp" || this.appType === 'typeReactApp') {
this.copy("tasks/_bower.js", this.appName + "/tasks/bower.js");
this.copy("tasks/_browser_sync.js", this.appName + "/tasks/browser-sync.js");
this.copy("tasks/_clean.js", this.appName + "/tasks/clean.js");
Expand All @@ -372,7 +407,7 @@ smacssGenerator.prototype.copyDependencyFiles = function copyDependencyFiles() {
return false;
}

if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp' || this.appType === "typeAdminWebApp") {
if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp' || this.appType === "typeAdminWebApp" || this.appType === 'typeReactApp') {
this.template("common/_gulpfile.js", this.appName + "/gulpfile.js", smacssGenerator.context);
}
else {
Expand All @@ -399,6 +434,9 @@ smacssGenerator.prototype.copyProjectfiles = function copyProjectfiles() {
else if (this.appType === 'typeRestifyApp') {
return false;
}
else if (this.appType === 'typeReactApp') {
this.template("_typeReactApp/_README.md", this.appName + "/README.md", smacssGenerator.context);
}

this.copy("common/_editorconfig", this.appName + "/.editorconfig");
this.copy("common/_robots.txt", this.appName + "/robots.txt");
Expand All @@ -413,7 +451,7 @@ smacssGenerator.prototype.copyProjectfiles = function copyProjectfiles() {
// Bower Dependency Injection
smacssGenerator.prototype.injectDependencies = function injectDependencies() {
// Bower is supported only in full & angular app types
if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp' || this.appType === "typeAdminWebApp") {
if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp' || this.appType === "typeAdminWebApp" || this.appType !== 'typeReactApp') {
var bower = {
name: this.appName,
private: true,
Expand All @@ -433,7 +471,7 @@ smacssGenerator.prototype.install = function install() {
process.chdir(installContext.appPath); // activating app directory for installation

// Assign context based on app types
if(this.appType === 'typeSimpleWebApp' || this.appType === 'typeRestifyApp') {
if(this.appType === 'typeSimpleWebApp' || this.appType === 'typeRestifyApp' || this.appType === 'typeReactApp') {
installContext.helpCommand = 'npm install';
installContext.includeNpm = true;
installContext.includeBower = false;
Expand Down
135 changes: 135 additions & 0 deletions app/templates/_typeReactApp/_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# <%= site_name %>

**Project Setup**

## Installation

*You need to have [NodeJS](http://nodejs.org/)*

*Type below commands in terminal*

```````
npm install -g yo
npm install -g gulp
npm install -g bower
```````

### Install [smacss generator](https://github.com/FuelFrontend/generator-smacss)

*Type below commands in terminal*

```````
npm install -g generator-smacss
```````

**Clone the repo & cd into it**


```````
sudo npm install
bower install
```````

**Finally**

*Type below command in terminal*

```````
gulp
```````

**Application Directory Structure**


````````
├── app
│ ├── bower_components
│ ├── images
│ ├── js
│ │ └── lib
│ │ │ └── third-party-files.js
│ │ └── controllers
│ │ └── directives
│ │ └── services
│ │ └── filters
│ │ └── application.js
│ ├── css
│ │ └── master.css
│ ├── partials
│ │ └── header.html
│ │ └── footer.html
│ ├── scss
│ │ └── modules
│ │ │ └── module-name.scss
│ │ └── pages
│ │ │ └── page-landing.scss
│ │ └── base.scss
│ │ └── layout.css
│ │ └── mixins.css
│ │ └── reset.css
│ │ └── variables.css
│ └── index.html
├── build
│ └── build-files
├── zip
│ └── compressed-files
├── node_modules
├── package.json
├── gulpfile.js
├── bower.json
├── .bowerrc
├── .gitattributes
└── .gitignore
````````

**Quick Commands**


* **Clean** _Remove all files from your build folder_

```````
gulp clean
```````

* **Zip** _Compress you app & save in `zip` folder with timestamp for quick sharing_

```````
gulp zip
```````

* **Controller** _Creates a controller in `app/js/controllers`_

```````
yo smacss:controller <name>
```````

* **Service** _Creates a service in `app/js/services`_

```````
yo smacss:service <name>
```````

* **Directive** _Creates a directive in `app/js/directives`_

```````
yo smacss:directive <name>
```````

* **Filter** _Creates a filter in `app/js/filters`_

```````
yo smacss:filter <name>
```````

# Environment

Generator Smacss comes with development and producution modes. In default it runs in development mode.

You can switch to production mode using the following command

```````
gulp prod
```````
19 changes: 19 additions & 0 deletions app/templates/_typeReactApp/_bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "<%= appName %>",
"version": "0.0.1",
"dependencies": {
"angular": "1.2.6"<% if (includeResourceModule) { %>,
"angular-resource": "1.2.6"<% } if (includeSanitizeModule) { %>,
"angular-sanitize": "1.2.6"<% } if (includeRouteModule) { %>,
"angular-route": "1.2.6"<% } if (includeAnimateModule) { %>,
"angular-animate": "1.2.6"<% } if (includeQuery) { %>,
"jquery": "*"<% } if (includeModernizr) { %>,
"modernizr": "*" <% } %>
},
"devDependencies": {

},
"overrides": {

}
}
33 changes: 33 additions & 0 deletions app/templates/_typeReactApp/_index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE HTML>
<html ng-app="<%= site_name %>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= site_name %></title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">

<!-- CSS files -->
<link rel="stylesheet" href="css/master.css">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600' rel='stylesheet' type='text/css'>
</head>
<body>
<!-- TODO: Remove gulp partials, as angular supports partials in default -->
@@include('./partials/_header.html')

<!-- Section -->
<section>
<p style="font-size: 22px;">Sample angular page, Your good name please?</p>
<p>
<input type="text" ng-model="name" style="background: #fff; border: none; padding: 10px 15px;" />
<span ng-hide="!name" style="font-size: 14px; margin: 30px 0 0 20px;">Welcome {{ name }}, You look great today!</span>
</p>
</section>

@@include('./partials/_footer.html')

<!-- 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>
66 changes: 66 additions & 0 deletions app/templates/_typeReactApp/_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "<%= site_name %>",
"version": "0.0.1",
"description": "Application description goes here",
"licenses": "enter your license type here",
"repository": "your repository url goes here",
"devDependencies": {
"gulp": "~3.9.0",
"gulp-if": "~1.2.5",
"gulp-sass": "~2.1.1",
"gulp-concat": "~2.4.3",
"gulp-file-include": "~0.8.0",
"gulp-autoprefixer": "^2.3.1",
"gulp-load-plugins": "~0.8.0",
"gulp-changed": "^0.4.1",
"gulp-filter": "^1.0.0",
"gulp-ignore": "^1.2.0",
"gulp-imagemin": "^0.6.2",
"gulp-jshint": "^1.8.4",
"gulp-minify-html": "^0.1.4",
"gulp-minify-css": "^0.3.7",
"gulp-rename": "^1.2.0",
"gulp-size": "^1.0.0",
"gulp-task-listing": "*",
"gulp-uglify": "^0.3.1",
"gulp-zip": "^0.3.4",
"gulp-webserver": "^0.6.0",
"gulp-filter": "^2.0.2",
"gulp-sourcemaps": "^1.5.0",
"del": "~1.1.1",
"open": "~0.0.5",
"chalk": "~0.5.1",
"main-bower-files": "~2.5.0",
"browser-sync": "~1.9.1",
"run-sequence": "~1.0.2",
"jshint-stylish": "~1.0.0",
"bower": "~1.4.1",
"underscore": "~1.8.3",
"underscore.string": "3.0.3",
"require-dir": "0.3.0",
"portscanner": "^1.0.0",
"react": "~0.10.0",
"react-router-component" : "~0.18.3",
"reactify": "~0.13.1",
"babel-core": "^6.3.15",
"babel-eslint": "^4.1.6",
"babel-loader": "^6.2.0",
"babel-plugin-react-transform": "^2.0.0-beta1",
"babel-plugin-transform-object-rest-spread": "^6.3.13",
"babel-plugin-transform-runtime": "^6.3.13",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-runtime": "^6.3.13",
"react-hot-loader": "^1.3.0",
"react-transform-hmr": "^1.0.1",
"redux-devtools": "^3.0.1",
"redux": "^3.0.5",
"redux-logger": "^2.3.1",
"redux-thunk": "^1.0.3",
"es6-promise": "^3.0.2"
},
"engines": {
"node": ">=0.10.0"
}
}

0 comments on commit 82c1231

Please sign in to comment.