Skip to content

Commit 6674f51

Browse files
committedNov 28, 2015
first commit
1 parent 6485dad commit 6674f51

40 files changed

+1432
-0
lines changed
 

‎Gruntfile.js

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Gruntfile
3+
*
4+
* This Node script is executed when you run `grunt` or `sails lift`.
5+
* It's purpose is to load the Grunt tasks in your project's `tasks`
6+
* folder, and allow you to add and remove tasks as you see fit.
7+
* For more information on how this works, check out the `README.md`
8+
* file that was generated in your `tasks` folder.
9+
*
10+
* WARNING:
11+
* Unless you know what you're doing, you shouldn't change this file.
12+
* Check out the `tasks` directory instead.
13+
*/
14+
15+
module.exports = function(grunt) {
16+
17+
18+
// Load the include-all library in order to require all of our grunt
19+
// configurations and task registrations dynamically.
20+
var includeAll;
21+
try {
22+
includeAll = require('include-all');
23+
} catch (e0) {
24+
try {
25+
includeAll = require('sails/node_modules/include-all');
26+
}
27+
catch(e1) {
28+
console.error('Could not find `include-all` module.');
29+
console.error('Skipping grunt tasks...');
30+
console.error('To fix this, please run:');
31+
console.error('npm install include-all --save`');
32+
console.error();
33+
34+
grunt.registerTask('default', []);
35+
return;
36+
}
37+
}
38+
39+
40+
/**
41+
* Loads Grunt configuration modules from the specified
42+
* relative path. These modules should export a function
43+
* that, when run, should either load/configure or register
44+
* a Grunt task.
45+
*/
46+
function loadTasks(relPath) {
47+
return includeAll({
48+
dirname: require('path').resolve(__dirname, relPath),
49+
filter: /(.+)\.js$/
50+
}) || {};
51+
}
52+
53+
/**
54+
* Invokes the function from a Grunt configuration module with
55+
* a single argument - the `grunt` object.
56+
*/
57+
function invokeConfigFn(tasks) {
58+
for (var taskName in tasks) {
59+
if (tasks.hasOwnProperty(taskName)) {
60+
tasks[taskName](grunt);
61+
}
62+
}
63+
}
64+
65+
66+
67+
68+
// Load task functions
69+
var taskConfigurations = loadTasks('./tasks/config'),
70+
registerDefinitions = loadTasks('./tasks/register');
71+
72+
// (ensure that a default task exists)
73+
if (!registerDefinitions.default) {
74+
registerDefinitions.default = function (grunt) { grunt.registerTask('default', []); };
75+
}
76+
77+
// Run task functions to configure Grunt.
78+
invokeConfigFn(taskConfigurations);
79+
invokeConfigFn(registerDefinitions);
80+
81+
};

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ittool
2+
3+
a [Sails](http://sailsjs.org) application

‎app.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* app.js
3+
*
4+
* Use `app.js` to run your app without `sails lift`.
5+
* To start the server, run: `node app.js`.
6+
*
7+
* This is handy in situations where the sails CLI is not relevant or useful.
8+
*
9+
* For example:
10+
* => `node app.js`
11+
* => `forever start app.js`
12+
* => `node debug app.js`
13+
* => `modulus deploy`
14+
* => `heroku scale`
15+
*
16+
*
17+
* The same command-line arguments are supported, e.g.:
18+
* `node app.js --silent --port=80 --prod`
19+
*/
20+
21+
// Ensure we're in the project directory, so relative paths work as expected
22+
// no matter where we actually lift from.
23+
process.chdir(__dirname);
24+
25+
// Ensure a "sails" can be located:
26+
(function() {
27+
var sails;
28+
try {
29+
sails = require('sails');
30+
} catch (e) {
31+
console.error('To run an app using `node app.js`, you usually need to have a version of `sails` installed in the same directory as your app.');
32+
console.error('To do that, run `npm install sails`');
33+
console.error('');
34+
console.error('Alternatively, if you have sails installed globally (i.e. you did `npm install -g sails`), you can use `sails lift`.');
35+
console.error('When you run `sails lift`, your app will still use a local `./node_modules/sails` dependency if it exists,');
36+
console.error('but if it doesn\'t, the app will run with the global sails instead!');
37+
return;
38+
}
39+
40+
// Try to get `rc` dependency
41+
var rc;
42+
try {
43+
rc = require('rc');
44+
} catch (e0) {
45+
try {
46+
rc = require('sails/node_modules/rc');
47+
} catch (e1) {
48+
console.error('Could not find dependency: `rc`.');
49+
console.error('Your `.sailsrc` file(s) will be ignored.');
50+
console.error('To resolve this, run:');
51+
console.error('npm install rc --save');
52+
rc = function () { return {}; };
53+
}
54+
}
55+
56+
57+
// Start server
58+
sails.lift(rc('sails'));
59+
})();

‎package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "ittool",
3+
"private": true,
4+
"version": "0.0.0",
5+
"description": "a Sails application",
6+
"keywords": [],
7+
"dependencies": {
8+
"ejs": "~0.8.4",
9+
"grunt": "0.4.2",
10+
"grunt-contrib-clean": "~0.5.0",
11+
"grunt-contrib-coffee": "~0.10.1",
12+
"grunt-contrib-concat": "~0.3.0",
13+
"grunt-contrib-copy": "~0.5.0",
14+
"grunt-contrib-cssmin": "~0.9.0",
15+
"grunt-contrib-jst": "~0.6.0",
16+
"grunt-contrib-less": "0.11.1",
17+
"grunt-contrib-uglify": "~0.4.0",
18+
"grunt-contrib-watch": "~0.5.3",
19+
"grunt-sails-linker": "~0.9.5",
20+
"grunt-sync": "~0.0.4",
21+
"include-all": "~0.1.3",
22+
"rc": "~0.5.0",
23+
"sails": "~0.11.3",
24+
"sails-cbes": "^0.1.16",
25+
"sails-disk": "~0.10.0",
26+
"sails-mysql": "^0.11.2"
27+
},
28+
"scripts": {
29+
"debug": "node debug app.js",
30+
"start": "node app.js"
31+
},
32+
"main": "app.js",
33+
"repository": {
34+
"type": "git",
35+
"url": "git://github.com/laura/ittool.git"
36+
},
37+
"author": "laura",
38+
"license": ""
39+
}

‎tasks/README.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# About the `tasks` folder
2+
3+
The `tasks` directory is a suite of Grunt tasks and their configurations, bundled for your convenience. The Grunt integration is mainly useful for bundling front-end assets, (like stylesheets, scripts, & markup templates) but it can also be used to run all kinds of development tasks, from browserify compilation to database migrations.
4+
5+
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, read on!
6+
7+
8+
### How does this work?
9+
10+
The asset pipeline bundled in Sails is a set of Grunt tasks configured with conventional defaults designed to make your project more consistent and productive.
11+
12+
The entire front-end asset workflow in Sails is completely customizable-- while it provides some suggestions out of the box, Sails makes no pretense that it can anticipate all of the needs you'll encounter building the browser-based/front-end portion of your application. Who's to say you're even building an app for a browser?
13+
14+
15+
16+
### What tasks does Sails run automatically?
17+
18+
Sails runs some of these tasks (the ones in the `tasks/register` folder) automatically when you run certain commands.
19+
20+
###### `sails lift`
21+
22+
Runs the `default` task (`tasks/register/default.js`).
23+
24+
###### `sails lift --prod`
25+
26+
Runs the `prod` task (`tasks/register/prod.js`).
27+
28+
###### `sails www`
29+
30+
Runs the `build` task (`tasks/register/build.js`).
31+
32+
###### `sails www --prod` (production)
33+
34+
Runs the `buildProd` task (`tasks/register/buildProd.js`).
35+
36+
37+
### Can I customize this for SASS, Angular, client-side Jade templates, etc?
38+
39+
You can modify, omit, or replace any of these Grunt tasks to fit your requirements. You can also add your own Grunt tasks- just add a `someTask.js` file in the `grunt/config` directory to configure the new task, then register it with the appropriate parent task(s) (see files in `grunt/register/*.js`).
40+
41+
42+
### Do I have to use Grunt?
43+
44+
Nope! To disable Grunt integration in Sails, just delete your Gruntfile or disable the Grunt hook.
45+
46+
47+
### What if I'm not building a web frontend?
48+
49+
That's ok! A core tenant of Sails is client-agnosticism-- it's especially designed for building APIs used by all sorts of clients; native Android/iOS/Cordova, serverside SDKs, etc.
50+
51+
You can completely disable Grunt by following the instructions above.
52+
53+
If you still want to use Grunt for other purposes, but don't want any of the default web front-end stuff, just delete your project's `assets` folder and remove the front-end oriented tasks from the `grunt/register` and `grunt/config` folders. You can also run `sails new myCoolApi --no-frontend` to omit the `assets` folder and front-end-oriented Grunt tasks for future projects. You can also replace your `sails-generate-frontend` module with alternative community generators, or create your own. This allows `sails new` to create the boilerplate for native iOS apps, Android apps, Cordova apps, SteroidsJS apps, etc.
54+

‎tasks/config/clean.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Clean files and folders.
3+
*
4+
* ---------------------------------------------------------------
5+
*
6+
* This grunt task is configured to clean out the contents in the .tmp/public of your
7+
* sails project.
8+
*
9+
* For usage docs see:
10+
* https://github.com/gruntjs/grunt-contrib-clean
11+
*/
12+
module.exports = function(grunt) {
13+
14+
grunt.config.set('clean', {
15+
dev: ['.tmp/public/**'],
16+
build: ['www']
17+
});
18+
19+
grunt.loadNpmTasks('grunt-contrib-clean');
20+
};

‎tasks/config/coffee.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Compile CoffeeScript files to JavaScript.
3+
*
4+
* ---------------------------------------------------------------
5+
*
6+
* Compiles coffeeScript files from `assest/js` into Javascript and places them into
7+
* `.tmp/public/js` directory.
8+
*
9+
* For usage docs see:
10+
* https://github.com/gruntjs/grunt-contrib-coffee
11+
*/
12+
module.exports = function(grunt) {
13+
14+
grunt.config.set('coffee', {
15+
dev: {
16+
options: {
17+
bare: true,
18+
sourceMap: true,
19+
sourceRoot: './'
20+
},
21+
files: [{
22+
expand: true,
23+
cwd: 'assets/js/',
24+
src: ['**/*.coffee'],
25+
dest: '.tmp/public/js/',
26+
ext: '.js'
27+
}, {
28+
expand: true,
29+
cwd: 'assets/js/',
30+
src: ['**/*.coffee'],
31+
dest: '.tmp/public/js/',
32+
ext: '.js'
33+
}]
34+
}
35+
});
36+
37+
grunt.loadNpmTasks('grunt-contrib-coffee');
38+
};

‎tasks/config/concat.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Concatenate files.
3+
*
4+
* ---------------------------------------------------------------
5+
*
6+
* Concatenates files javascript and css from a defined array. Creates concatenated files in
7+
* .tmp/public/contact directory
8+
* [concat](https://github.com/gruntjs/grunt-contrib-concat)
9+
*
10+
* For usage docs see:
11+
* https://github.com/gruntjs/grunt-contrib-concat
12+
*/
13+
module.exports = function(grunt) {
14+
15+
grunt.config.set('concat', {
16+
js: {
17+
src: require('../pipeline').jsFilesToInject,
18+
dest: '.tmp/public/concat/production.js'
19+
},
20+
css: {
21+
src: require('../pipeline').cssFilesToInject,
22+
dest: '.tmp/public/concat/production.css'
23+
}
24+
});
25+
26+
grunt.loadNpmTasks('grunt-contrib-concat');
27+
};

‎tasks/config/copy.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copy files and folders.
3+
*
4+
* ---------------------------------------------------------------
5+
*
6+
* # dev task config
7+
* Copies all directories and files, exept coffescript and less fiels, from the sails
8+
* assets folder into the .tmp/public directory.
9+
*
10+
* # build task config
11+
* Copies all directories nd files from the .tmp/public directory into a www directory.
12+
*
13+
* For usage docs see:
14+
* https://github.com/gruntjs/grunt-contrib-copy
15+
*/
16+
module.exports = function(grunt) {
17+
18+
grunt.config.set('copy', {
19+
dev: {
20+
files: [{
21+
expand: true,
22+
cwd: './assets',
23+
src: ['**/*.!(coffee|less)'],
24+
dest: '.tmp/public'
25+
}]
26+
},
27+
build: {
28+
files: [{
29+
expand: true,
30+
cwd: '.tmp/public',
31+
src: ['**/*'],
32+
dest: 'www'
33+
}]
34+
}
35+
});
36+
37+
grunt.loadNpmTasks('grunt-contrib-copy');
38+
};

‎tasks/config/cssmin.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Compress CSS files.
3+
*
4+
* ---------------------------------------------------------------
5+
*
6+
* Minifies css files and places them into .tmp/public/min directory.
7+
*
8+
* For usage docs see:
9+
* https://github.com/gruntjs/grunt-contrib-cssmin
10+
*/
11+
module.exports = function(grunt) {
12+
13+
grunt.config.set('cssmin', {
14+
dist: {
15+
src: ['.tmp/public/concat/production.css'],
16+
dest: '.tmp/public/min/production.min.css'
17+
}
18+
});
19+
20+
grunt.loadNpmTasks('grunt-contrib-cssmin');
21+
};

0 commit comments

Comments
 (0)
Please sign in to comment.