Skip to content
Permalink
Browse files

feat(quick start): add ability to create a quick application structur…

…e fast via running rapid-build --quick-start
  • Loading branch information
jyounce committed Jul 1, 2016
1 parent fbea7ec commit 986e47634656594984638d2b14feb2ebd64e555b
@@ -75,7 +75,8 @@ $ rapid-build
```

## Directory Structure
Everthing is optional. Rapid build will be expecting this directory structure.
Must have package.json, everthing else is optional.
Rapid build will be expecting this directory structure.
```
dist/ (generated distributable folder created by rapid-build)
src/
@@ -100,7 +101,7 @@ src/
└── routes.{coffee,es6,js} (see options.dist.server.fileName)
nodes_modules/ (generated folder via package.json)
bower.json
package.json
package.json (required)
rapid-build.json (build options - can be cson, json or js file)
```

@@ -26,10 +26,16 @@ config.app.build.opts = path.join(config.app.path, config.build.pkg.name);
config.build.cli = {};
config.build.cli.path = path.join(LIB_PATH, 'cli');
config.build.cli.opts = require(path.join(config.build.cli.path, 'get-cli-opts'))(config);
config.build.cli.templates = {}
config.build.cli.templates.path = path.join(config.build.cli.path, 'templates');
config.build.cli.templates.client = path.join(config.build.cli.templates.path, 'client');
config.build.cli.templates.root = path.join(config.build.cli.templates.path, 'root');
config.build.cli.templates.server = path.join(config.build.cli.templates.path, 'server');

/* Bootstrap
************/
require(path.join(config.build.cli.path, 'add-colors'))();
if (config.build.cli.opts.quickStart.length) return require(path.join(config.build.cli.path, 'quick-start'))(config);
var build = require(path.join(config.build.cli.path, 'get-build'))(config);

/**
@@ -32,7 +32,7 @@ angular.module('rapid-build').constant 'GETTING_STARTED',
icon: 'fa-folder-open'
items: [
label: '<rb:icon kind="fa-exclamation-circle"></rb:icon>
Everthing is optional.'
Must have package.json, everthing else is optional.'
,
label: 'Rapid build will be expecting this directory structure.'
,
@@ -66,10 +66,32 @@ angular.module('rapid-build').constant 'GETTING_STARTED',
└── routes.{coffee,es6,js} # (optional, see build options dist.server.fileName)
nodes_modules/ # (generated folder via package.json)
bower.json
package.json
package.json # (required)
rapid-build.json # (build options - can be cson, json or js file)
"""

'Quick Start':
icon: 'ion-ios-redo'
iconSize: 'large'
info: 'option'
items: [
label: 'Want a quick application structure fast?'
,
label: 'Then run the following:'
items: [
label: 'It will create the above <a href="#directory-structure" rb-scroll>directory</a> structure'
,
label: 'with a couple simple files.'
info: 'will not override your files or dirs'
]
]
example:
lang: 'bash'
clipboard: 'true'
code: """
rapid-build --quick-start
"""

'rapid-build.json':
icon: 'fa-cogs'
info: 'example in cson'
@@ -19,6 +19,7 @@ <h1>Getting Started</h1>
{ caption: 'Dependencies', url: '#dependencies' },
{ caption: 'Installation', url: '#installation' },
{ caption: 'Directory Structure', url: '#directory-structure' },
{ caption: 'Quick Start', url: '#quick-start' },
{ caption: 'rapid-build.json', url: '#rapid-build.json' },
{ caption: 'Got it now what?', url: '#got-it-now-what?' }
]">
@@ -8,14 +8,24 @@ module.exports = (config) ->
list = (val) ->
val.split ','

getQuickStart = (val) ->
return [] unless val
defaults = ['client', 'server']
return defaults if val is true
val = val.toLowerCase()
return [] if defaults.indexOf(val) is -1
[val]

# configure
# =========
program
.version config.build.pkg.version
.option '-s, --skip-options [opts]', 'skip build option(s) ex: dev,prod', list, []
.option '--quick-start [location]', 'creates a simple application structure with a couple files. optional location: client or server. defaults to both'
.parse process.argv

# return
# ======
opts =
skipOpts: program.skipOptions # []
skipOpts: program.skipOptions # []
quickStart: getQuickStart program.quickStart # []
@@ -0,0 +1,42 @@
module.exports = (config) ->
# requires
# ========
path = require 'path'
fse = require 'fs-extra'

# vars
# ====
appPath = config.app.path
locs = config.build.cli.opts.quickStart
mkClient = locs.indexOf('client') isnt -1
mkServer = locs.indexOf('server') isnt -1
opts = clobber: false

# make dirs
# =========
if mkClient
for dir, i in ['images','libs','scripts','styles','test','views']
fse.mkdirsSync "#{appPath}/src/client/#{dir}"

if mkServer
for dir, i in ['test']
fse.mkdirsSync "#{appPath}/src/server/#{dir}"

# make files
# ==========
# root files
try fse.copySync "#{config.build.cli.templates.root}/gitignore.sh", "#{appPath}/.gitignore", opts
for file, i in ['rapid-build.cson']
try fse.copySync "#{config.build.cli.templates.root}/#{file}", "#{appPath}/#{file}", opts

if mkClient
for file, i in ['scripts/html5.es6', 'scripts/router.es6', 'styles/app.less', 'views/home.html']
try fse.copySync "#{config.build.cli.templates.client}/#{file}", "#{appPath}/src/client/#{file}", opts

if mkServer
for file, i in ['routes.es6']
try fse.copySync "#{config.build.cli.templates.server}/#{file}", "#{appPath}/src/server/#{file}", opts

# message
# =======
console.log 'Quick start complete! Now run: rapid-build dev'.attn
@@ -0,0 +1,17 @@
angular.module('app').config(['$locationProvider', '$routeProvider',
($locationProvider, $routeProvider) => {
/* Enable Html5 Mode
********************/
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});

/* Angular Router
*****************/
$routeProvider.when('/', {
templateUrl: '/views/home.html'
}).otherwise({
redirectTo: '/'
});
}]);
@@ -0,0 +1,34 @@
body {
margin: 25px 20px;
color: #5f6e7e;
font-size: 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h1 {
padding: 0 0 22px;
margin: 0 0 30px;
color: steelblue;
font-size: 36px;
font-weight: 300;
text-shadow: 1px 1px 4px #eee;
border-bottom: 1px solid #ddd;
}

h3 {
margin-bottom: 28px;
font-size: 18px;
}

h4 {
font-weight: 500;
}

li {
margin:0 0 8px;
}

a {
color: lightcoral;
&:focus, &:hover { text-decoration: none; }
}
@@ -0,0 +1,45 @@
<div>
<h1>Develop Rapidly!</h1>

<h3>Quick Start Includes:</h3>

<h4>Project Root:</h4>
<ul>
<li>
<a target="_blank" href="http://rapid-build.io/getting-started#directory-structure">directory structure</a>
</li>
<li>
/rapid-build.cson
<small>
- for
<a target="_blank" href="http://rapid-build.io/build-options">build options</a>
</small>
</li>
<li>
/.gitignore
</li>
</ul>

<h4>Client:</h4>
<ul>
<li>
/src/client/scripts/router.es6
<small>
- for <a target="_blank" href="https://docs.angularjs.org/api/ngRoute/provider/$routeProvider">angular router</a>
</small>
</li>
<li>/src/client/styles/app.less</li>
<li>/src/client/views/home.html</li>
</ul>

<h4>Server:</h4>
<ul>
<li>
/src/server/routes.es6
<small>
- with one <a target="_blank" href="http://expressjs.com/en/guide/routing.html">express</a> route defined:
<a target="_blank" href="/api/superheroes">/api/superheroes</a>
</small>
</li>
</ul>
</div>
@@ -0,0 +1,31 @@
# folders (common)
# ================
bower_components/
dist/
node_modules/

# dot files
# =========
.*.swp
._*
.DS_Store
.git
.lock-wscript
.svn

# file extensions
# ===============
*.db
*.log
*.map
*.orig
*.sublime*
*.tmp

# folders (project specific)
# ==========================


# files (project specific)
# ========================

@@ -0,0 +1,8 @@
# common options for all build types
common: {}

# options for default, dev and test builds
dev: {}

# options for prod build
prod: {}
@@ -0,0 +1,9 @@
module.exports = server => {
var app = server.app;

/* route example
****************/
app.get('/api/superheroes', (req, res) => {
res.json(['Superman', 'Wolverine', 'Wonder Woman']);
});
};

0 comments on commit 986e476

Please sign in to comment.
You can’t perform that action at this time.