├── .editorconfig
├── .gitignore
├── .npmignore
├── .travis.yml
├── README.md
├── asset
└── Notifier.app
│ └── Contents
│ ├── Info.plist
│ ├── MacOS
│ └── Notifier
│ ├── PkgInfo
│ └── Resources
│ ├── Terminal.icns
│ └── en.lproj
│ ├── Credits.rtf
│ ├── InfoPlist.strings
│ └── MainMenu.nib
├── bin
├── .gitattributes
├── mod
├── mod-debug.cmd
└── mod-dev.cmd
├── doc
├── README.md
├── api
│ ├── README.md
│ ├── exports.md
│ ├── file.md
│ ├── template.md
│ └── utils.md
├── tasks
│ ├── README.md
│ ├── build.md
│ ├── cat.md
│ ├── compile.md
│ ├── cp.md
│ ├── create.md
│ ├── deploy.md
│ ├── download.md
│ ├── hash.md
│ ├── help.md
│ ├── init.md
│ ├── lint.md
│ ├── min.md
│ ├── mkdir.md
│ ├── mv.md
│ ├── pack.md
│ ├── replace.md
│ ├── rev.md
│ ├── rm.md
│ ├── server.md
│ ├── strip.md
│ └── watch.md
├── template
│ ├── README-api.md
│ ├── README-task.md
│ ├── README.md
│ ├── api.md
│ └── task.md
└── tutorial
│ ├── configuring-tasks.md
│ ├── creating-plugins.md
│ └── getting-started.md
├── example
├── buildmobile
│ ├── Modfile.js
│ ├── README.md
│ ├── css
│ │ ├── base.css
│ │ └── main.css
│ ├── img
│ │ └── icon.png
│ ├── index.html
│ └── js
│ │ ├── ios.js
│ │ ├── main.js
│ │ └── var
│ │ ├── document.js
│ │ ├── location.js
│ │ ├── navigator.js
│ │ └── zepto.js
├── buildnormal
│ ├── Modfile.js
│ ├── README.md
│ ├── css
│ │ ├── base.css
│ │ └── main.css
│ ├── img
│ │ └── icon.png
│ ├── index.html
│ └── js
│ │ ├── bar.js
│ │ ├── baz.js
│ │ ├── corge.js
│ │ ├── foo.js
│ │ ├── quux.js
│ │ └── qux.js
├── buildrequirejs
│ ├── Modfile.js
│ ├── README.md
│ ├── css
│ │ ├── base.css
│ │ └── main.css
│ ├── index.html
│ └── js
│ │ ├── $.js
│ │ ├── main.js
│ │ └── standalone.js
├── buildseajs
│ ├── Modfile.js
│ ├── README.md
│ ├── css
│ │ └── style.css
│ ├── index.html
│ └── js
│ │ ├── main.js
│ │ └── spinning.js
├── catcss
│ ├── Modfile.js
│ ├── bar.css
│ ├── foo.css
│ └── foo.png
├── catjs
│ ├── Modfile.js
│ ├── bar.js
│ └── foo.js
├── compileamd
│ ├── Modfile.js
│ ├── README.md
│ ├── index.html
│ └── js
│ │ ├── asyncModule.js
│ │ ├── main.js
│ │ ├── syncModule.js
│ │ └── var
│ │ ├── $.js
│ │ ├── document.js
│ │ ├── location.js
│ │ └── navigator.js
├── compilecmd
│ ├── Modfile.js
│ ├── index.html
│ └── js
│ │ ├── a.js
│ │ ├── b.js
│ │ ├── c.js
│ │ ├── config.js
│ │ └── main.js
├── compilecss
│ ├── Modfile.js
│ └── conditional.css
├── compilehtml
│ ├── Modfile.js
│ └── conditional.html
├── compilejs
│ ├── Modfile.js
│ └── conditional.js
├── compilemultipage
│ ├── Modfile.js
│ ├── README.md
│ ├── js
│ │ ├── app
│ │ │ ├── controller
│ │ │ │ ├── Base.js
│ │ │ │ ├── c1.js
│ │ │ │ └── c2.js
│ │ │ ├── lib.js
│ │ │ ├── main1.js
│ │ │ ├── main2.js
│ │ │ └── model
│ │ │ │ ├── Base.js
│ │ │ │ ├── m1.js
│ │ │ │ └── m2.js
│ │ ├── common.js
│ │ └── lib
│ │ │ ├── backbone.js
│ │ │ ├── jquery.js
│ │ │ └── underscore.js
│ ├── page1.html
│ └── page2.html
├── configasync
│ ├── Modfile.js
│ ├── foobar.css
│ └── foobar.js
├── configgroup
│ ├── Modfile.js
│ ├── foobar.css
│ └── foobar.js
├── confignestedtargets
│ └── Modfile.js
├── configoptions
│ └── Modfile.js
├── configtemplate
│ ├── Modfile.js
│ ├── bar
│ │ └── b.js
│ ├── baz
│ │ └── c.js
│ └── foo
│ │ └── a.js
├── cp
│ └── Modfile.js
├── datauri
│ ├── Modfile.js
│ ├── test.css
│ └── test.png
├── deployhttp
│ ├── .testskip
│ └── Modfile.js
├── deployssh
│ ├── .testskip
│ └── Modfile.js
├── download
│ └── Modfile.js
├── mincss
│ ├── Modfile.js
│ ├── foo.png
│ └── test.css
├── minhtml
│ ├── Modfile.js
│ └── index.html
├── minjs
│ ├── Modfile.js
│ └── js
│ │ ├── unminify.js
│ │ └── unminify.min.js
├── mkdir
│ └── Modfile.js
├── plugingrunttask
│ ├── Modfile.js
│ ├── bar.js
│ └── foo.js
├── plugininlinetask
│ └── Modfile.js
├── pluginlocaltask
│ ├── Modfile.js
│ └── mytask.js
├── pluginnpmtask
│ ├── Modfile.js
│ └── test.styl
├── replace
│ ├── Modfile.js
│ └── foo.js
├── stripcode
│ ├── Modfile.js
│ └── foo.js
├── stripeol
│ ├── Modfile.js
│ └── foo.js
├── striptab
│ ├── Modfile.js
│ └── foo.js
└── watchstyl
│ ├── .testskip
│ ├── Modfile.js
│ └── styl
│ ├── bar.styl
│ └── foo.styl
├── index.js
├── lib
├── builtin.js
├── config.js
├── generators
│ ├── git
│ │ ├── .gitattributes
│ │ └── .gitignore
│ ├── jquery
│ │ ├── index.js
│ │ ├── {{name}}.jquery.json
│ │ └── {{name}}.js
│ ├── json
│ │ ├── index.js
│ │ └── templates
│ │ │ └── package.json
│ ├── licenses
│ │ ├── Apache-2.0-LICENSE.txt
│ │ ├── GPL-2.0-LICENSE.txt
│ │ ├── MIT-LICENSE.txt
│ │ ├── MPL-2.0-LICENSE.txt
│ │ └── index.js
│ ├── mocha
│ │ └── test
│ │ │ ├── index.html
│ │ │ ├── lib
│ │ │ ├── chai.js
│ │ │ ├── expect.js
│ │ │ └── mocha
│ │ │ │ ├── mocha.css
│ │ │ │ └── mocha.js
│ │ │ ├── runner
│ │ │ └── mocha.js
│ │ │ └── spec
│ │ │ └── spec.js
│ ├── modfile
│ │ └── Modfile.js
│ ├── plugin
│ │ ├── Modfile.js
│ │ ├── README.md
│ │ ├── index.js
│ │ └── {{main_name}}.js
│ ├── readme
│ │ └── README.md
│ └── webview
│ │ ├── index.html
│ │ ├── index.js
│ │ ├── main.css
│ │ └── main.js
├── options.js
├── plugins.js
├── runner.js
├── tasks
│ ├── build.js
│ ├── cat.js
│ ├── compile.js
│ ├── cp.js
│ ├── datauri.js
│ ├── deploy.js
│ ├── download.js
│ ├── exec.js
│ ├── help.js
│ ├── htmlminifier.js
│ ├── init.js
│ ├── min.js
│ ├── mkdir.js
│ ├── mv.js
│ ├── optimizecss.js
│ ├── replace.js
│ ├── rev.js
│ ├── rm.js
│ ├── search.js
│ ├── strip.js
│ ├── template.js
│ ├── uglifyjs.js
│ └── watch.js
└── utils
│ ├── file.js
│ ├── format.js
│ ├── github.js
│ ├── htmlparser.js
│ ├── index.js
│ ├── logger.js
│ ├── notifier.js
│ ├── sea.js
│ ├── sshclient.js
│ ├── suggester.js
│ └── template.js
├── package.json
└── test
├── apitesting
├── Modfile.js
└── apitesting.js
└── testrunner.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | # This file is for unifying the coding style for different editors and IDEs
2 | # editorconfig.org
3 |
4 | root = true
5 |
6 | [*]
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 | indent_style = space
12 | indent_size = 4
13 |
14 | [package.json]
15 | indent_style = space
16 | indent_size = 2
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Include your project-specific ignores in this file
2 | # Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
3 |
4 | # Numerous always-ignore extensions
5 | *.diff
6 | *.err
7 | *.orig
8 | *.log
9 | *.rej
10 | *.swo
11 | *.swp
12 | *.vi
13 | *~
14 | *.sass-cache
15 |
16 | # OS or Editor folders
17 | .DS_Store
18 | ._*
19 | Thumbs.db
20 | .cache
21 | .project
22 | .settings
23 | .tmproj
24 | nbproject
25 | *.sublime-project
26 | *.sublime-workspace
27 |
28 | # Dreamweaver added files
29 | _notes
30 | dwsync.xml
31 |
32 | # Komodo
33 | *.komodoproject
34 | .komodotools
35 |
36 | # Espresso
37 | *.esproj
38 | *.espressostorage
39 |
40 | # Rubinius
41 | *.rbc
42 |
43 | # Folders to ignore
44 | .hg
45 | .svn
46 | .CVS
47 | intermediate
48 | publish
49 | .idea
50 | node_modules
51 | dist
52 |
53 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | doc/
2 | test/
3 | example/
4 | node_modules/
5 | .*
6 | *~
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | node_js:
4 | - 0.8
5 | - 0.10
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
Stopped developping on modjs and switched to chajs
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Mod.js is a [task-based](https://github.com/taskjs/spec) workflow tooling for web, it helps developers quickly build robust and high-performance HTML5 applications.
15 |
16 | ## Why Mod.js?
17 | * Focus on the workflow of web development
18 | * Much built-in tasks, most pleasant out-of-the-box experience
19 | - Built-in source minify: `JS, CSS, HTML`
20 | - Built-in modular JS compile: `AMD, CMD (will support ES6 Module, CommonJS Module soon)`
21 | - Built-in CSS @import file combination
22 | - Built-in source stripping, automatically remove debugging code
23 | - Built-in basic file operation: `cat, rm, mv, mkdir, cp, rev`
24 | - Built-in file watcher, trigger custom tasks when file change
25 | * More simplicity plugin mechanism, auto-install plugins
26 | * Configuration less(even zero), do more
27 | - Build by html: `mod build index.html`
28 | * Compatible with [Grunt](http://gruntjs.com) plugins, with literally hundreds of plugins to choose from
29 |
30 | ## Installation
31 | [Mod.js](https://npmjs.org/package/modjs) is installed using [NPM(Node Package Manager)](http://npmjs.org/)
32 | ```sh
33 | $ npm install modjs -g
34 | ```
35 |
36 | ## Tutorials
37 | * [Getting Started](https://github.com/modjs/mod/tree/master/doc/tutorial/getting-started.md)
38 | * [Configuring Tasks](https://github.com/modjs/mod/blob/master/doc/tutorial/configuring-tasks.md)
39 | * [Creating Plugins](https://github.com/modjs/mod/tree/master/doc/tutorial/creating-plugins.md)
40 |
41 | ## Documents
42 | * [Built-in Task](https://github.com/modjs/mod/tree/master/doc/tasks)
43 | * [Plugin API](https://github.com/modjs/mod/tree/master/doc/api)
44 |
45 | ## Quick Build Demo
46 | * [Plain Project Build](https://github.com/modjs/mod/tree/master/example/buildnormal)
47 | * [Mobile Project Build](https://github.com/modjs/mod/tree/master/example/buildmobile)
48 | * [RequireJS Project Build](https://github.com/modjs/mod/tree/master/example/buildrequirejs)
49 |
50 | ## Built-in Task Examples
51 | * [Concatenate JS Files](https://github.com/modjs/mod/tree/master/example/catjs)
52 | * [Concatenate CSS Files](https://github.com/modjs/mod/tree/master/example/catcss)
53 | * [AMD Modules Compile](https://github.com/modjs/mod/tree/master/example/compileamd)
54 | * [CMD Modules Compile](https://github.com/modjs/mod/tree/master/example/compilecmd)
55 | * [Mutil-page Modules Compile](https://github.com/modjs/mod/tree/master/example/compilemultipage)
56 | * [JS Conditional Compilation](https://github.com/modjs/mod/tree/master/example/compilejs)
57 | * [CSS Conditional Compilation](https://github.com/modjs/mod/tree/master/example/compilecss)
58 | * [HTML Conditional Compilation](https://github.com/modjs/mod/tree/master/example/compilehtml)
59 | * [JS Minify](https://github.com/modjs/mod/tree/master/example/minjs)
60 | * [CSS Minify](https://github.com/modjs/mod/tree/master/example/mincss)
61 | * [HTML Minify](https://github.com/modjs/mod/tree/master/example/minhtml)
62 | * [Code Stripping](https://github.com/modjs/mod/tree/master/example/stripcode)
63 | * [EOL Stripping](https://github.com/modjs/mod/tree/master/example/stripeol)
64 | * [Tab Stripping](https://github.com/modjs/mod/tree/master/example/striptab)
65 | * [Inline Images DataURI](https://github.com/modjs/mod/tree/master/example/datauri)
66 | * [Make Dir](https://github.com/modjs/mod/tree/master/example/mkdir)
67 | * [Copy Files](https://github.com/modjs/mod/tree/master/example/cp)
68 | * [String Replace](https://github.com/modjs/mod/tree/master/example/replace)
69 |
70 | ## Plugins Examples
71 | * [NPM Task: mod-stylus](https://github.com/modjs/mod/tree/master/example/pluginnpmtask)
72 | * [Local Task: mytask.js](https://github.com/modjs/mod/tree/master/example/pluginlocaltask)
73 | * [Grunt Task: grunt-contrib-concat](https://github.com/modjs/mod/tree/master/example/plugingrunttask)
74 |
75 | ## IDE Support
76 | * [Sublime-Mod](https://github.com/yuanyan/sublime-mod)
77 |
78 | ## Platform Support
79 | Mod support Windows, OS X, Linux...
80 |
81 | ## Issue Submission
82 | Submit a [new issue](https://github.com/modjs/mod/issues/new).
83 |
84 | ## Release History
85 |
86 | * 2014-02-28 v0.4.6 Fix r.js build error.
87 | * 2014-02-20 v0.4.5 Remove built-in `server` task.
88 |
89 | ## About
90 | Mod is an open-source project by [Tencent](http://www.tencent.com/en-us/) which builds on top of [Node.js](https://nodejs.org).
91 | We utilize a number of useful open-source solutions including:
92 |
93 | * UglifyJS
94 | * CleanCSS
95 | * HTMLMinifiler
96 | * RequireJS
97 |
98 | ## Used by people within (JOIN US)
99 | 
100 |
101 | ## License
102 | Mod.js is released under a [MIT](http://yuanyan.mit-license.org/) license.
103 |
--------------------------------------------------------------------------------
/asset/Notifier.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildMachineOSBuild
6 | 13A2093
7 | CFBundleDevelopmentRegion
8 | en
9 | CFBundleExecutable
10 | Notifier
11 | CFBundleIconFile
12 | Terminal
13 | CFBundleIdentifier
14 | nl.superalloy.oss.Notifier
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | Notifier
19 | CFBundlePackageType
20 | APPL
21 | CFBundleShortVersionString
22 | 1.5.1
23 | CFBundleSignature
24 | ????
25 | CFBundleVersion
26 | 9
27 | DTCompiler
28 | com.apple.compilers.llvm.clang.1_0
29 | DTPlatformBuild
30 | 5A2053
31 | DTPlatformVersion
32 | GM
33 | DTSDKBuild
34 | 13A595
35 | DTSDKName
36 | macosx10.9
37 | DTXcode
38 | 0501
39 | DTXcodeBuild
40 | 5A2053
41 | LSMinimumSystemVersion
42 | 10.8
43 | LSUIElement
44 |
45 | NSHumanReadableCopyright
46 | Copyright © 2012 Eloy Durán. All rights reserved.
47 | NSMainNibFile
48 | MainMenu
49 | NSPrincipalClass
50 | NSApplication
51 |
52 |
53 |
--------------------------------------------------------------------------------
/asset/Notifier.app/Contents/MacOS/Notifier:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/asset/Notifier.app/Contents/MacOS/Notifier
--------------------------------------------------------------------------------
/asset/Notifier.app/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPL????
--------------------------------------------------------------------------------
/asset/Notifier.app/Contents/Resources/Terminal.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/asset/Notifier.app/Contents/Resources/Terminal.icns
--------------------------------------------------------------------------------
/asset/Notifier.app/Contents/Resources/en.lproj/Credits.rtf:
--------------------------------------------------------------------------------
1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
2 | {\colortbl;\red255\green255\blue255;}
3 | \paperw9840\paperh8400
4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
5 |
6 | \f0\b\fs24 \cf0 Engineering:
7 | \b0 \
8 | Some people\
9 | \
10 |
11 | \b Human Interface Design:
12 | \b0 \
13 | Some other people\
14 | \
15 |
16 | \b Testing:
17 | \b0 \
18 | Hopefully not nobody\
19 | \
20 |
21 | \b Documentation:
22 | \b0 \
23 | Whoever\
24 | \
25 |
26 | \b With special thanks to:
27 | \b0 \
28 | Mom\
29 | }
30 |
--------------------------------------------------------------------------------
/asset/Notifier.app/Contents/Resources/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/asset/Notifier.app/Contents/Resources/en.lproj/InfoPlist.strings
--------------------------------------------------------------------------------
/asset/Notifier.app/Contents/Resources/en.lproj/MainMenu.nib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/asset/Notifier.app/Contents/Resources/en.lproj/MainMenu.nib
--------------------------------------------------------------------------------
/bin/.gitattributes:
--------------------------------------------------------------------------------
1 | * text eol=lf
2 |
--------------------------------------------------------------------------------
/bin/mod:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var utils = require('../lib/utils/index');
4 | var logger = require('../lib/utils/logger');
5 | var runner = require('../lib/runner');
6 | var config = require('../lib/config');
7 | var colors = require('colors');
8 | var _ = require('lodash');
9 |
10 | var argv = process.argv;
11 | for (var i = 0; i < process.argv.length; i += 1) {
12 | var arg = argv[i];
13 | if (arg === '--debug') {
14 | process.argv.splice(i, 1);
15 | logger.level = 'debug';
16 | } else if (arg === '--no-color' || arg === '--no-colors') {
17 | process.argv.splice(i, 1);
18 | colors.mode = 'none';
19 | var originLog = console.log;
20 | console.log = function () {
21 | var args = _.toArray(arguments);
22 | args.map(function (arg) {
23 | return colors.stripColors(arg);
24 | });
25 | originLog.apply(this, args);
26 | };
27 | } else if (arg === '--force') {
28 | process.argv.splice(i, 1);
29 | logger.force = true;
30 | }
31 | }
32 |
33 | var cmd = argv.slice(2).shift();
34 | if (cmd === '-h' || cmd === '--help') {
35 | cmd = 'help';
36 | }
37 |
38 | if (cmd === '-v' || cmd === '--version') {
39 | var ver = utils.getVersion();
40 | console.log(ver.green);
41 | } else {
42 | config.load({
43 | cmd: cmd
44 | }, function (rc) {
45 | runner.run({
46 | rc: rc,
47 | cmd: cmd
48 | });
49 | })
50 | }
51 |
--------------------------------------------------------------------------------
/bin/mod-debug.cmd:
--------------------------------------------------------------------------------
1 | @IF EXIST "%~dp0\node.exe" (
2 | "%~dp0\node.exe --debug-brk" "%~dp0\mod" %*
3 | ) ELSE (
4 | node --debug-brk "%~dp0\mod" %*
5 | )
--------------------------------------------------------------------------------
/bin/mod-dev.cmd:
--------------------------------------------------------------------------------
1 | @IF EXIST "%~dp0\node.exe" (
2 | "%~dp0\node.exe" "%~dp0\mod" %*
3 | ) ELSE (
4 | node "%~dp0\mod" %*
5 | )
--------------------------------------------------------------------------------
/doc/README.md:
--------------------------------------------------------------------------------
1 | # Documents
2 | ## Tutorials
3 | * [Getting Started](https://github.com/modjs/mod/tree/master/doc/tutorial/getting-started.md)
4 | * [Configuring Tasks](https://github.com/modjs/mod/blob/master/doc/tutorial/configuring-tasks.md)
5 | * [Creating Plugins](https://github.com/modjs/mod/tree/master/doc/tutorial/creating-plugins.md)
6 |
7 | ## Built-in Tasks
8 | Mod supports a powerful set of high-level tasks:
9 |
10 | * [help](https://github.com/modjs/mod/tree/master/doc/tasks/help.md) - get help on mod
11 | * [build](https://github.com/modjs/mod/tree/master/doc/tasks/build.md) - build project with html
12 | * [init](https://github.com/modjs/mod/tree/master/doc/tasks/init.md) - generate project skeleton from template
13 | * [watch](https://github.com/modjs/mod/tree/master/doc/tasks/watch.md) - run predefined tasks whenever watched files change
14 | * [deploy](https://github.com/modjs/mod/tree/master/doc/tasks/deploy.md) - remote deployment via ssh
15 | * [download](https://github.com/modjs/mod/tree/master/doc/tasks/download.md) - download resource from URI
16 | * [compile](https://github.com/modjs/mod/tree/master/doc/tasks/compile.md) - compile JavaScript/CSS/HTML source
17 | * [min](https://github.com/modjs/mod/tree/master/doc/tasks/min.md) - minify JavaScript/CSS/HTML source
18 | * [replace](https://github.com/modjs/mod/tree/master/doc/tasks/replace.md) - replace the contents of files
19 | * [cat](https://github.com/modjs/mod/tree/master/doc/tasks/cat.md) - concatenate the content of files
20 | * [cp](https://github.com/modjs/mod/tree/master/doc/tasks/cp.md) - copy one or more files to another location
21 | * [mkdir](https://github.com/modjs/mod/tree/master/doc/tasks/mkdir.md) - make a new directory
22 | * [mv](https://github.com/modjs/mod/tree/master/doc/tasks/mv.md) - move or rename files or directories
23 | * [rm](https://github.com/modjs/mod/tree/master/doc/tasks/rm.md) - remove files
24 | * [rev](https://github.com/modjs/mod/tree/master/doc/tasks/rev.md) - rename file with it hash value
25 | * [strip](https://github.com/modjs/mod/tree/master/doc/tasks/strip.md) - source stripping
26 |
27 | ## API
28 |
29 | * [exports](https://github.com/modjs/mod/tree/master/doc/api/exports.md) - The exports API
30 | * [exports.file](https://github.com/modjs/mod/tree/master/doc/api/file.md) - There are many provided methods for reading and writing files, traversing the filesystem and finding files by matching globbing patterns. Many of these methods are wrappers around built-in Node.js file functionality, but with additional error handling, logging and character encoding normalization.
31 | * [exports.utils](https://github.com/modjs/mod/tree/master/doc/api/utils.md) - Miscellaneous utilities
32 | * [exports.template](https://github.com/modjs/mod/tree/master/doc/api/template.md) - Compiles templates into strings
33 | * [exports._](http://underscorejs.org/) - Underscore provides 80-odd functions that support both the usual functional suspects: map, select, invoke — as well as more specialized helpers: function binding, javascript templating, deep equality testing, and so on. It delegates to built-in functions, if present, so modern browsers will use the native implementations of forEach, map, reduce, filter, every, some and indexOf.
34 | * [exports.async](https://github.com/caolan/async) - Async provides around 20 functions that include the usual 'functional' suspects (map, reduce, filter, each…) as well as some common patterns for asynchronous control flow (parallel, series, waterfall…). All these functions assume you follow the node.js convention of providing a single callback as the last argument of your async function.
35 | * [exports.request](https://github.com/mikeal/request) - Simplified HTTP request method
36 | * [exports.prompt](https://github.com/flatiron/prompt) - Using prompt is relatively straight forward. There are two core methods you should be aware of: prompt.get() and prompt.addProperties(). There methods take strings representing property names in addition to objects for complex property validation (and more).
37 |
38 |
39 |
--------------------------------------------------------------------------------
/doc/api/README.md:
--------------------------------------------------------------------------------
1 | ## API
2 |
3 | * [exports](https://github.com/modjs/mod/tree/master/doc/api/exports.md) - The exports API
4 | * [exports.file](https://github.com/modjs/mod/tree/master/doc/api/file.md) - There are many provided methods for reading and writing files, traversing the filesystem and finding files by matching globbing patterns. Many of these methods are wrappers around built-in Node.js file functionality, but with additional error handling, logging and character encoding normalization.
5 | * [exports.utils](https://github.com/modjs/mod/tree/master/doc/api/utils.md) - Miscellaneous utilities
6 | * [exports.template](https://github.com/modjs/mod/tree/master/doc/api/template.md) - Compiles templates into strings
7 | * [exports._](http://underscorejs.org/) - Underscore provides 80-odd functions that support both the usual functional suspects: map, select, invoke — as well as more specialized helpers: function binding, javascript templating, deep equality testing, and so on. It delegates to built-in functions, if present, so modern browsers will use the native implementations of forEach, map, reduce, filter, every, some and indexOf.
8 | * [exports.async](https://github.com/caolan/async) - Async provides around 20 functions that include the usual 'functional' suspects (map, reduce, filter, each…) as well as some common patterns for asynchronous control flow (parallel, series, waterfall…). All these functions assume you follow the node.js convention of providing a single callback as the last argument of your async function.
9 | * [exports.request](https://github.com/mikeal/request) - Simplified HTTP request method
10 | * [exports.prompt](https://github.com/flatiron/prompt) - Using prompt is relatively straight forward. There are two core methods you should be aware of: prompt.get() and prompt.addProperties(). There methods take strings representing property names in addition to objects for complex property validation (and more).
11 |
--------------------------------------------------------------------------------
/doc/api/exports.md:
--------------------------------------------------------------------------------
1 | ## exports
2 | > The exports API
3 |
4 |
5 | ### Properties
6 |
7 | #### exports.taskName
8 | Describe: Current task's name
9 |
10 |
11 | #### exports.template
12 | Describe: Compiles templates into strings
13 |
14 |
15 | #### exports.utils
16 | Describe: Miscellaneous utilities
17 |
18 |
19 | #### exports.file
20 | Describe: Provided many methods for reading and writing files, traversing the filesystem and finding files by matching globbing patterns. Many of these methods are wrappers around built-in Node.js file functionality, but with additional error handling, logging and character encoding normalization.
21 |
22 |
23 | #### exports._
24 | Describe: Tons of super-useful array, function and object utility methods.
25 |
26 |
27 | #### exports.async
28 | Describe: Async utilities for node and the browser
29 |
30 |
31 | #### exports.files
32 | Describe: An array of all file paths that match the given wildcard patterns.
33 |
34 |
35 |
36 |
37 |
38 | ### Methods
39 |
40 | #### exports.loadTask(taskName)
41 | Describe: Load a task
42 | Return: {object}
43 |
44 |
45 |
46 | #### exports.runTask(name [, options] [, callback])
47 | Describe: Run task
48 |
49 |
50 |
51 |
52 | #### exports.runTargets(targets [, callback])
53 | Describe: Run targets
54 |
55 |
56 |
57 |
58 | #### exports.config([name])
59 | Describe: Get peoject config
60 | Return: {*}
61 |
62 |
63 |
64 | #### exports.logger
65 | Describe: Logging object
66 |
67 |
68 |
69 |
70 | #### exports.log(arg1 [,arg2...])
71 | Describe: Print log
72 |
73 |
74 |
75 |
76 | #### exports.debug(arg1 [,arg2...])
77 | Describe: Print debug
78 |
79 |
80 |
81 |
82 | #### exports.error(arg1 [,arg2...])
83 | Describe: Print error
84 |
85 |
86 |
87 |
88 | #### exports.warn(arg1 [,arg2...])
89 | Describe: Print warning
90 |
91 |
92 |
93 |
94 | #### exports.notify
95 | Describe: Push message to OSX notification system
96 |
97 | Example:
98 | ```js
99 | exports.notify({
100 | title: 'Hi',
101 | message: 'I am ok'
102 | });
103 | ```
104 |
105 |
106 |
107 | #### exports.help()
108 | Describe: Print task help
109 |
110 |
111 |
112 |
113 | #### exports.request
114 | Describe: Simplified HTTP request method
115 |
116 | Example:
117 | ```js
118 | request('http://www.google.com', function (error, response, body) {
119 | if (!error && response.statusCode == 200) {
120 | console.log(body) // Print the google web page.
121 | }
122 | })
123 | ```
124 |
125 |
126 |
127 | #### exports.prompt
128 | Describe: Using prompt is relatively straight forward. There are two core methods you should be aware of: prompt.get() and prompt.addProperties(). There methods take strings representing property names in addition to objects for complex property validation (and more).
129 |
130 | Example:
131 | ```js
132 | // Start the prompt
133 | prompt.start();
134 | // Get two properties from the user: username and email
135 | prompt.get(['username', 'email'], function (err, result) {
136 | // Log the results.
137 | console.log('Command-line input received:');
138 | console.log(' username: ' + result.username);
139 | console.log(' email: ' + result.email);
140 | });
141 | ```
142 |
143 |
144 |
145 |
146 |
147 |
148 |
--------------------------------------------------------------------------------
/doc/api/file.md:
--------------------------------------------------------------------------------
1 | ## file
2 | > There are many provided methods for reading and writing files, traversing the filesystem and finding files by matching globbing patterns. Many of these methods are wrappers around built-in Node.js file functionality, but with additional error handling, logging and character encoding normalization.
3 |
4 |
5 |
6 |
7 | ### Methods
8 |
9 | #### file.exists(filepath)
10 | Describe: File exists
11 |
12 |
13 |
14 |
15 | #### file.isFile(filepath)
16 | Describe: Is the given path a file? Returns a boolean.
17 |
18 |
19 |
20 |
21 | #### file.isPlaintextFile(filepath)
22 | Describe: Is the given path a plaintext file? Returns a boolean.
23 |
24 |
25 |
26 |
27 | #### file.isUTF8EncodingFile(filepath)
28 | Describe: Is the given path a UTF8 encoding file? Returns a boolean.
29 |
30 |
31 |
32 |
33 | #### file.suffix(filename, suffix)
34 | Describe: File suffix append
35 | Return: {*}
36 | Example:
37 | ```js
38 | file.suffiex("jquery.js", "min") // => jquery.min.js
39 | ```
40 |
41 |
42 |
43 | #### file.isDir(filepath)
44 | Describe: Is the given path a directory? Returns a boolean.
45 |
46 |
47 |
48 |
49 | #### file.isDirname(filepath)
50 | Describe: Is dir format name
51 |
52 |
53 |
54 |
55 | #### file.readJSON(filepath)
56 | Describe: Read a file from the filesystem and parse as JSON
57 |
58 |
59 |
60 |
61 | #### file.findPackageJSON
62 | Describe: Looks for a project's package.json file. Walks up the directory tree untilit finds a package.json file or hits the root. Does not throw when nopackages.json is found, just returns null.
63 |
64 |
65 |
66 |
67 | #### file.readPackageJSON( [dir] )
68 | Describe: Read a package.json file's contents, parsing the data as JSON and returning the result
69 |
70 |
71 |
72 |
73 | #### file.listdir(dir, callback)
74 | Describe: List directories within a directory.
75 |
76 |
77 |
78 |
79 | #### file.glob(pattern [, rootdir])
80 | Describe: Get the pattern matched files, default root dir is cwd
81 |
82 |
83 |
84 |
85 | #### file.expand(patterns [, options])
86 | Describe: Return a unique array of all file or directory paths that match the given globbing pattern(s).
87 | Return: {array} matche files
88 | Example:
89 | ```js
90 | file.expand(['!./foo/.css', './foo/'])
91 | ```
92 |
93 |
94 |
95 | #### file.delete(filepath)
96 | Describe: Delete the specified filepath. Will delete files and folders recursively.
97 |
98 |
99 |
100 |
101 | #### file.read(filepath [, encoding])
102 | Describe: Read and return a file's contents.
103 |
104 |
105 |
106 |
107 | #### file.write(filepath, contents [, encoding])
108 | Describe: Write the specified contents to a file, creating intermediate directories if necessary
109 |
110 |
111 |
112 |
113 | #### file.writeTemp(filepath, contents [, encoding])
114 | Describe: Write the specified contents to a temp file
115 |
116 |
117 |
118 |
119 | #### file.copy(src, dest)
120 | Describe: Copy a source file or directory to a destination path, creating intermediate directories if necessary
121 |
122 |
123 |
124 |
125 | #### file.find(dirpath, filename);
126 | Describe: Search for a filename in the given directory or all parent directories.
127 | Return: {string}
128 |
129 |
130 |
131 | #### file.mkdir(dirpath [, mode])
132 | Describe: Given a path to a directory, create it, and all the intermediate directories as well
133 |
134 | Example:
135 | ```js
136 | file.mkdir("/tmp/dir", 755)
137 | ```
138 |
139 |
140 |
141 | #### file.mkdirTemp([dirname] [, mode])
142 | Describe: Create temp dir
143 | Return: {string}
144 |
145 |
146 |
147 | #### file.walkdir(rootdir, callback)
148 | Describe: Recurse into a directory, executing callback for each file.
149 |
150 | Example:
151 | ```js
152 | file.walkdir("/tmp", function(error, path, dirs, name) {
153 | // path is the current directory we're in
154 | // dirs is the list of directories below it
155 | // names is the list of files in it
156 | })
157 | ```
158 |
159 |
160 |
161 |
162 |
163 |
164 |
--------------------------------------------------------------------------------
/doc/api/template.md:
--------------------------------------------------------------------------------
1 | ## template
2 | > Compiles templates into strings
3 |
4 |
5 | ### Properties
6 |
7 | #### template.settings
8 | Describe: By default, uses ERB-style template delimiters, change the following template settings to use alternative delimiters.
9 |
10 |
11 |
12 |
13 |
14 | ### Methods
15 |
16 | #### template(text, data, settings)
17 | Describe: Compiles templates into strings
18 |
19 | Example:
20 | ```js
21 | template("hello <%= foo %>", {foo:"modjs"}) // => hello modjs
22 | ```
23 |
24 |
25 |
26 | #### template.registerHelper(name, helper)
27 | Describe: Helpers can be accessed from any context in a template
28 |
29 | Example:
30 | ```js
31 | template.registerHelper("echo", function(val){
32 | console.log(val);
33 | })
34 | ```
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/doc/api/utils.md:
--------------------------------------------------------------------------------
1 | ## utils
2 | > miscellaneous utilities
3 |
4 |
5 |
6 |
7 | ### Methods
8 |
9 | #### utils.getHttpProxy( hostname )
10 | Describe: Get the system's http proxy
11 |
12 |
13 |
14 |
15 | #### utils.isRelativeURI(uri)
16 | Describe: Is a relative URI?
17 |
18 | Example:
19 | ```js
20 | utils.isRelativeURI("../path/to"); // => return true
21 | utils.isRelativeURI("path/to"); // => return true
22 | utils.isRelativeURI("#id"); // => return false
23 | utils.isRelativeURI("http://www.qq.com"); // => return false
24 | utils.isRelativeURI("/relative/to/root"); // => return false
25 | utils.isRelativeURI("//without/protocol"); // => return false
26 | utils.isRelativeURI("data:image/gif;base64,lGODlhEAA..."); // => return false
27 | ```
28 |
29 |
30 |
31 | #### utils.download(url, local, callback)
32 | Describe: Download file
33 |
34 |
35 |
36 |
37 | #### utils.isPlainObject(obj)
38 | Describe: Check to see if an object is a plain object (created using “{}” or “new Object”).
39 |
40 |
41 |
42 |
43 | #### utils.clone(obj)
44 | Describe: Deep copy of the object
45 |
46 |
47 |
48 |
49 | #### utils.walk(value, fn, fnContinue)
50 | Describe: Recurse through objects and arrays, executing fn for each non-object.
51 |
52 |
53 |
54 |
55 | #### utils.namespace(obj, parts, create)
56 | Describe: Get the value of a deeply-nested property exist in an object.
57 |
58 |
59 |
60 |
61 | #### utils.merge(a, b)
62 | Describe: Deep merge for JSON objects, overwrites conflicting properties
63 |
64 |
65 |
66 |
67 | #### utils.arrayify()
68 | Describe: Convert 'a,b,c' to [a,b,c]
69 |
70 |
71 |
72 |
73 | #### utils.getVersion()
74 | Describe: Reads the version property from modjs's package.json
75 |
76 |
77 |
78 |
79 | #### utils.open(target, appName, callback)
80 | Describe: Open application
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/doc/tasks/README.md:
--------------------------------------------------------------------------------
1 | ## Built-in Tasks
2 | Mod supports a powerful set of high-level tasks:
3 |
4 | * [help](https://github.com/modjs/mod/tree/master/doc/tasks/help.md) - get help on mod
5 | * [build](https://github.com/modjs/mod/tree/master/doc/tasks/build.md) - build project with html
6 | * [init](https://github.com/modjs/mod/tree/master/doc/tasks/init.md) - generate project skeleton from template
7 | * [watch](https://github.com/modjs/mod/tree/master/doc/tasks/watch.md) - run predefined tasks whenever watched files change
8 | * [deploy](https://github.com/modjs/mod/tree/master/doc/tasks/deploy.md) - remote deployment via ssh
9 | * [download](https://github.com/modjs/mod/tree/master/doc/tasks/download.md) - download resource from URI
10 | * [compile](https://github.com/modjs/mod/tree/master/doc/tasks/compile.md) - compile JavaScript/CSS/HTML source
11 | * [min](https://github.com/modjs/mod/tree/master/doc/tasks/min.md) - minify JavaScript/CSS/HTML source
12 | * [replace](https://github.com/modjs/mod/tree/master/doc/tasks/replace.md) - replace the contents of files
13 | * [cat](https://github.com/modjs/mod/tree/master/doc/tasks/cat.md) - concatenate the content of files
14 | * [cp](https://github.com/modjs/mod/tree/master/doc/tasks/cp.md) - copy one or more files to another location
15 | * [mkdir](https://github.com/modjs/mod/tree/master/doc/tasks/mkdir.md) - make a new directory
16 | * [mv](https://github.com/modjs/mod/tree/master/doc/tasks/mv.md) - move or rename files or directories
17 | * [rm](https://github.com/modjs/mod/tree/master/doc/tasks/rm.md) - remove files
18 | * [rev](https://github.com/modjs/mod/tree/master/doc/tasks/rev.md) - rename file with it hash value
19 | * [strip](https://github.com/modjs/mod/tree/master/doc/tasks/strip.md) - source stripping
20 |
--------------------------------------------------------------------------------
/doc/tasks/build.md:
--------------------------------------------------------------------------------
1 | ## build
2 | > Build project with html
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod build [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### dest
13 |
14 | Default: dist
15 | Describe: Destination build directory
16 |
17 |
18 | #### rev
19 |
20 | Default: true
21 | Describe: Insert a hash of the file content into the filename end
22 |
23 |
24 | #### charset
25 |
26 | Default: utf-8
27 | Describe: File encoding type
28 |
29 |
30 | #### wrap
31 |
32 | Default: false
33 | Describe: Wrap any build bundle in a start and end text specified by wrap
34 |
35 |
36 | #### urlPrepend
37 |
38 | Default:
39 | Describe: Url prepend with relative address
40 |
41 |
42 | #### stripDefine
43 |
44 | Default: false
45 | Describe: Strip all definitions in generated source
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/doc/tasks/cat.md:
--------------------------------------------------------------------------------
1 | ## cat
2 | > Concatenate the content of files
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod cat [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### dest
13 |
14 | Default:
15 | Describe: Destination file
16 |
17 |
18 | #### charset
19 |
20 | Default: utf-8
21 | Describe: File encoding type
22 |
23 |
24 | #### endings
25 |
26 | Default:
27 |
28 | Describe: Make sure each file endings with newline
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/doc/tasks/cp.md:
--------------------------------------------------------------------------------
1 | ## cp
2 | > Copy one or more files to another location
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod cp [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### dest
13 |
14 |
15 | Describe: Destination directory or file
16 |
17 |
18 | #### flatten
19 |
20 |
21 | Describe: Remove all path parts from generated dest paths
22 |
23 |
24 | #### recursive
25 |
26 | Default: true
27 | Describe: Copy directories recursively
28 |
29 |
30 | #### verbose
31 |
32 | Default: true
33 | Describe: Shows file/directory names after they are copied
34 |
35 |
36 | #### force
37 |
38 | Default: true
39 | Describe: Force overwriting the existing files
40 |
41 |
42 | #### update
43 |
44 | Default: false
45 | Describe: Copy only when the SOURCE file is newer than the destination file or when the destination file is missing
46 |
47 |
48 | #### backup
49 |
50 | Default: true
51 | Describe: Make a backup of each existing destination file
52 |
53 |
54 | #### parents
55 |
56 | Default: false
57 | Describe: Full path to be copied to the destination directory
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/doc/tasks/create.md:
--------------------------------------------------------------------------------
1 | ## create
2 | > Generate project skeleton and create project directory
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod create [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### template
13 |
14 |
15 | Describe: Destination template
16 |
17 |
18 | #### dest
19 |
20 | Default: .
21 | Describe: Target project directory
22 |
23 |
24 | #### mod
25 | Type: Boolean
26 |
27 | Describe: Create a mod files in target directory
28 |
29 |
30 | #### json
31 | Type: Boolean
32 |
33 | Describe: Create a package.json file in target directory
34 |
35 |
36 | #### git
37 | Type: Boolean
38 |
39 | Describe: Create git files in target directory
40 |
41 |
42 | #### readme
43 | Type: Boolean
44 |
45 | Describe: Create a README.md file in target directory
46 |
47 |
48 | #### mocha
49 | Type: Boolean
50 |
51 | Describe: Create test files in target directory
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/doc/tasks/deploy.md:
--------------------------------------------------------------------------------
1 | ## deploy
2 | > Remote deployment via ssh
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod deploy [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### src
13 |
14 |
15 | Describe: Local file or directory
16 |
17 |
18 | #### basedir
19 |
20 |
21 | Describe: Local file base dir
22 |
23 |
24 | #### dest
25 |
26 |
27 | Describe: The remote, eg. username:password@host:/path/to/
28 |
29 |
30 | #### port
31 |
32 | Default: 22
33 | Describe: The port to connect to on the remote host.
34 |
35 |
36 | #### username
37 |
38 |
39 | Describe: The remote username
40 |
41 |
42 | #### password
43 |
44 |
45 | Describe: The remote password
46 |
47 |
48 | #### host
49 |
50 |
51 | Describe: The remote host
52 |
53 |
54 | #### path
55 |
56 |
57 | Describe: The remote path
58 |
59 |
60 | #### protocol
61 |
62 | Default: ssh
63 | Describe: Deploy tunnel protocol, ssh or http
64 |
65 |
66 | #### url
67 |
68 |
69 | Describe: The upload url
70 |
71 |
72 | #### overwrite
73 |
74 | Default: true
75 | Describe: Overwrite existed file
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/doc/tasks/download.md:
--------------------------------------------------------------------------------
1 | ## download
2 | > Download resource from URI
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod download [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### src
13 |
14 |
15 | Describe: The URI which to download a resource
16 |
17 |
18 | #### dest
19 |
20 | Default: ./
21 | Describe: The file or directory where to store the requested resource(s)
22 |
23 |
24 | #### verbose
25 |
26 |
27 | Describe: Show verbose progress information
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/doc/tasks/hash.md:
--------------------------------------------------------------------------------
1 | ## hash
2 | > Rename file with it hash value
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod hash [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### algorithm
13 |
14 | Default: md5
15 | Describe: Target build level
16 |
17 |
18 | #### encoding
19 |
20 | Default: hex
21 | Describe: File encoding type
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/doc/tasks/help.md:
--------------------------------------------------------------------------------
1 | ## help
2 | > Get help on mod
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod help [command]
8 | ```
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/doc/tasks/init.md:
--------------------------------------------------------------------------------
1 | ## init
2 | > Generate project skeleton from template
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod init [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### template
13 |
14 |
15 | Describe: Destination template
16 |
17 |
18 | #### dest
19 |
20 | Default: .
21 | Describe: Target project directory
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/doc/tasks/lint.md:
--------------------------------------------------------------------------------
1 | ## lint
2 | > Validate JavaScript/CSS source
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod lint
8 | ```
9 |
10 | ### Options
11 |
12 | #### charset
13 |
14 | Default: utf-8
15 | Describe: File encoding type
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/doc/tasks/min.md:
--------------------------------------------------------------------------------
1 | ## min
2 | > Minify JavaScript/CSS/HTML source
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod min [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### dest
13 |
14 |
15 | Describe: Destination directory or file
16 |
17 |
18 | #### suffix
19 |
20 |
21 | Describe: Destination file suffix append, default suffix is ".min" when "dest" parameter is not set
22 |
23 |
24 | #### charset
25 |
26 | Default: utf-8
27 | Describe: File encoding type
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/doc/tasks/mkdir.md:
--------------------------------------------------------------------------------
1 | ## mkdir
2 | > Make a new directory
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod mkdir [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### dest
13 |
14 |
15 | Describe: The name of the directory one wants to create
16 |
17 |
18 | #### mode
19 |
20 | Default: 0777
21 | Describe: Specify the octal permissions of directory
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/doc/tasks/mv.md:
--------------------------------------------------------------------------------
1 | ## mv
2 | > Move or rename files or directories
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod mv
8 | ```
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/doc/tasks/pack.md:
--------------------------------------------------------------------------------
1 | ## pack
2 | > Create a tarball from a module
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod pack [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### dest
13 |
14 |
15 | Describe: Target pack file path
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/doc/tasks/replace.md:
--------------------------------------------------------------------------------
1 | ## replace
2 | > Replace the contents of files
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod replace [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### dest
13 |
14 | Default:
15 | Describe: Destination directory or file
16 |
17 |
18 | #### search
19 |
20 |
21 | Describe: A string or regular expression that will be replaced by the new value
22 |
23 |
24 | #### replace
25 |
26 |
27 | Describe: A string that replaces the search string or a function to be invoked to create the new string
28 |
29 |
30 | #### flags
31 |
32 | Default: gm
33 | Describe: A String containing any combination of the RegExp flags: g - global match, i - ignore case, m - match over multiple lines. This parameter is only used if the search parameter is a string
34 |
35 |
36 | #### output
37 |
38 | Default: file
39 | Describe: Specify output type: file pipe
40 |
41 |
42 | #### charset
43 |
44 | Default: utf-8
45 | Describe: File encoding type
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/doc/tasks/rev.md:
--------------------------------------------------------------------------------
1 | ## rev
2 | > Rename file with it hash value
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod rev [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### algorithm
13 |
14 | Default: md5
15 | Describe: Target build level
16 |
17 |
18 | #### encoding
19 |
20 | Default: hex
21 | Describe: File encoding type
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/doc/tasks/rm.md:
--------------------------------------------------------------------------------
1 | ## rm
2 | > Remove files
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod rm
8 | ```
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/doc/tasks/server.md:
--------------------------------------------------------------------------------
1 | ## server
2 | > Start a static web server
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod server [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### target
13 |
14 | Default: .
15 | Describe: Target directory
16 |
17 |
18 | #### port
19 |
20 | Default: 3000
21 | Describe: Server port
22 |
23 |
24 | #### log
25 |
26 | Default: false
27 | Describe: Log requests
28 |
29 |
30 | #### delay
31 | Type: number
32 |
33 | Describe: Bandwidth delay
34 |
35 |
36 | #### reload
37 |
38 | Default: false
39 | Describe: Enable live reload changed files
40 |
41 |
42 | #### watch
43 |
44 |
45 | Describe: Files be watched and reloaded
46 |
47 |
48 | #### console
49 |
50 | Default: false
51 | Describe: Enable remote logging service
52 |
53 |
54 | #### proxies
55 | Type: array
56 |
57 | Describe: Enable request proxy
58 |
59 |
60 | #### open
61 |
62 | Default: true
63 | Describe: Open the default browser after server starting
64 |
65 |
66 | #### deploy
67 |
68 |
69 | Describe: Start as a deploy server
70 |
71 |
72 | #### token
73 |
74 |
75 | Describe: Remote deploy token
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/doc/tasks/strip.md:
--------------------------------------------------------------------------------
1 | ## strip
2 | > Source stripping
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod strip [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### dest
13 |
14 |
15 | Describe: Destination directory or file
16 |
17 |
18 | #### charset
19 |
20 | Default: utf-8
21 | Describe: File encoding type
22 |
23 |
24 | #### bom
25 | Type: boolean
26 | Default: true
27 | Describe: Strip bom
28 |
29 |
30 | #### tab
31 |
32 | Default: false
33 | Describe: Convert tab (default replace by 4 spaces if enable)
34 |
35 |
36 | #### eol
37 |
38 | Default: false
39 | Describe: Convert line ending (default replace by lf if enable)
40 |
41 |
42 | #### code
43 |
44 | Default: false
45 | Describe: Strip code (default remove alert call if enable)
46 |
47 |
48 | #### output
49 |
50 | Default: file
51 | Describe: Specify output type: file pipe
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/doc/tasks/watch.md:
--------------------------------------------------------------------------------
1 | ## watch
2 | > Run predefined tasks whenever watched files change
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod watch [options]
8 | ```
9 |
10 | ### Options
11 |
12 | #### src
13 |
14 |
15 | Describe: Files to be watched
16 |
17 |
18 | #### tasks
19 |
20 |
21 | Describe: Tasks to run whenever files change
22 |
23 |
24 | #### whole
25 |
26 | Default: false
27 | Describe: Run predefined tasks for whole files whatever watched files change
28 |
29 |
30 | #### debounce
31 |
32 | Default: 1000
33 | Describe: Tasks debounce delay time
34 |
35 |
36 | #### verbose
37 |
38 | Default: true
39 | Describe: Print watched files
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/doc/template/README-api.md:
--------------------------------------------------------------------------------
1 | ## <%= name %>
2 | <% _.each(items, function(item) { %>
3 | * [<%= item.title == 'exports' ? item.title : 'exports.' + item.title %>](<%= item.href %>) - <%= item.summary.ucfirst() %> <% }); %>
4 | * [exports._](http://underscorejs.org/) - Underscore provides 80-odd functions that support both the usual functional suspects: map, select, invoke — as well as more specialized helpers: function binding, javascript templating, deep equality testing, and so on. It delegates to built-in functions, if present, so modern browsers will use the native implementations of forEach, map, reduce, filter, every, some and indexOf.
5 | * [exports.async](https://github.com/caolan/async) - Async provides around 20 functions that include the usual 'functional' suspects (map, reduce, filter, each…) as well as some common patterns for asynchronous control flow (parallel, series, waterfall…). All these functions assume you follow the node.js convention of providing a single callback as the last argument of your async function.
6 | * [exports.request](https://github.com/mikeal/request) - Simplified HTTP request method
7 | * [exports.prompt](https://github.com/flatiron/prompt) - Using prompt is relatively straight forward. There are two core methods you should be aware of: prompt.get() and prompt.addProperties(). There methods take strings representing property names in addition to objects for complex property validation (and more).
8 |
--------------------------------------------------------------------------------
/doc/template/README-task.md:
--------------------------------------------------------------------------------
1 | ## Built-in Tasks
2 | Mod supports a powerful set of high-level tasks:
3 | <% _.each(items, function(item) { %>
4 | * [<%= item.title %>](<%= item.href %>) - <%= item.summary.lcfirst() %> <% }); %>
5 |
--------------------------------------------------------------------------------
/doc/template/README.md:
--------------------------------------------------------------------------------
1 | # <%= name %>
2 | ## Tutorials
3 | * [Getting Started](https://github.com/modjs/mod/tree/master/doc/tutorial/getting-started.md)
4 | * [Configuring Tasks](https://github.com/modjs/mod/blob/master/doc/tutorial/configuring-tasks.md)
5 | * [Creating Plugins](https://github.com/modjs/mod/tree/master/doc/tutorial/creating-plugins.md)
6 |
7 | <% _.each(items, function(item) { print(item + "\n") }); %>
8 |
--------------------------------------------------------------------------------
/doc/template/api.md:
--------------------------------------------------------------------------------
1 | ## <%= name %>
2 | > <%= summary %>
3 |
4 | <% if(typeof properties !== 'undefined' && !_.isEmpty(properties)){ %>
5 | ### Properties
6 | <% _.each(properties, function(property) { %>
7 | #### <%= property.name %>
8 | <% if(typeof property.describe !== 'undefined'){ %> Describe: <%= property.describe.ucfirst() %>
<% } %>
9 |
10 | <% }); %>
11 | <% } %>
12 |
13 | <% if(typeof methods !== 'undefined' && !_.isEmpty(methods)){ %>
14 | ### Methods
15 | <% _.each(methods, function(method) { %>
16 | #### <%= method.name %>
17 | <% if(method.describe){ %> Describe: <%= method.describe.ucfirst() %>
<% } %>
18 | <% if(method.ret){ %> Return: <%= method.ret %>
<% } %>
19 | <% if(method.example){ %> Example:
20 | ```js
21 | <%= method.example %>
22 | ```
23 | <% } %>
24 |
25 | <% }); %>
26 | <% } %>
27 |
28 |
29 |
--------------------------------------------------------------------------------
/doc/template/task.md:
--------------------------------------------------------------------------------
1 | ## <%= taskName %>
2 | > <%= summary %>
3 |
4 | ### Usage
5 |
6 | ```sh
7 | $ mod <%= taskName %> <%= usage %>
8 | ```
9 | <% if(typeof options !== 'undefined' && !_.isEmpty(options)){ %>
10 | ### Options
11 | <% _.each(options, function(option, name) { %>
12 | #### <%= name %>
13 | <% if(typeof option.type !== 'undefined'){ %> Type: <%= option.type %>
<% } %>
14 | <% if(typeof option.default !== 'undefined'){ %> Default: <%= option.default %>
<% } %>
15 | <% if(typeof option.describe !== 'undefined'){ %> Describe: <%= option.describe.ucfirst() %>
<% } %>
16 |
17 | <% }); %>
18 | <% } %>
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/doc/tutorial/creating-plugins.md:
--------------------------------------------------------------------------------
1 | Tasks are mod's bread and butter. The stuff you do most often, like `min` or `cat`. Every time Mod is run, you specify one or more tasks to run, which tells Mod what you'd like it to do.
2 |
3 | In addition to the built-in tasks, you can create your own task:
4 |
5 | ## Plugin skeleton
6 | ```js
7 | exports.summary = 'my task';
8 |
9 | exports.usage = ' [options]';
10 |
11 | exports.options = {
12 | "dest" : {
13 | alias : 'd'
14 | ,default : ''
15 | ,describe : 'destination file'
16 | },
17 |
18 | "charset" : {
19 | alias : 'c'
20 | ,default : 'utf-8'
21 | ,describe : 'file encoding type'
22 | }
23 | };
24 |
25 | exports.run = function (options, done) {
26 | var target = options.target;
27 | // ...
28 | done();
29 | };
30 | ```
31 |
32 | ## Options
33 |
34 | ```
35 | exports.usage = ' [options]';
36 |
37 | exports.options = {
38 | "dest" : {
39 | alias : 'd'
40 | ,default : ''
41 | ,describe : 'destination file'
42 | },
43 |
44 | "charset" : {
45 | alias : 'c'
46 | ,default : 'utf-8'
47 | ,describe : 'file encoding type'
48 | }
49 | };
50 | ```
51 |
52 | ## Done callback
53 |
54 | General task is asynchronous, how mod know task is run over? We use done callback.
55 | When a asynchronous task is over, call the `done()` method.
56 |
57 | ```js
58 | exports.run = function (options, done) {
59 | exec(function(){
60 | // balabal...
61 | done();
62 | });
63 | };
64 | ```
65 |
66 | If task is a synchronous, the done callback is optional:
67 | ```js
68 | exports.run = function (options) {
69 | console.log('run done');
70 | };
71 | ```
72 |
73 | ## Plugin API
74 |
75 | Mod plugin API are provided directly on the `exports` object for convenience. See the individual api section docs for detailed explanations and examples.
76 |
77 | ```js
78 | exports.taskName
79 | exports.files
80 | exports.loadTask()
81 | exports.runTask()
82 | exports.config()
83 |
84 | exports.log()
85 | exports.error()
86 | exports.warn()
87 | exports.debug()
88 |
89 | exports.file
90 | exports.utils
91 |
92 | exports._
93 | exports.async
94 | exports.request
95 | exports.prompt
96 | ```
97 |
98 |
99 | ## Plugin publish
100 | 1. Author project's `package.json`.
101 | 1. Run `npm publish` to publish the mod plugin to npm
102 |
--------------------------------------------------------------------------------
/doc/tutorial/getting-started.md:
--------------------------------------------------------------------------------
1 | # Getting started
2 |
3 | Mod and mod plugins are installed and managed via [npm](https://npmjs.org/), the [Node.js](http://nodejs.org/) package manager.
4 |
5 | _Mod 0.4.x requires Node.js version `>= 0.8.0`._
6 |
7 | ## Installing
8 |
9 | In order to get started, you'll want to install Mod globally. You may need to use sudo (for OSX, *nix, BSD etc) or run your command shell as Administrator (for Windows) to do this.
10 |
11 | ```shell
12 | npm install -g modjs
13 | ```
14 |
15 | This will put the `mod` command in your system path, allowing it to be run from any directory.
16 |
17 | ## How mod works
18 |
19 | Each time `mod` is run, it looks for `Modfile` deeply. Because of this, you can run `mod` from any subfolder in your project.
20 |
21 | If a `Modfile` is found, mod applies the configuration from your `Modfile`, and if there is a configuration of plugins, mod will automatically install the uninstlled plugins, if a plugin is your own custom task, mod load it by node's `require()` system, then executes any tasks you've requested for it to run.
22 |
23 | If you don't specify a target or task, but the only defined target or task will run by default.
24 |
25 | Installed Mod tasks can be listed by running `mod --help` but it's usually a good idea to start with the project's documentation.
26 |
27 | ## Preparing a new mod project
28 | A typical setup will involve adding only one file to your project: `Modfile`.
29 |
30 | **Modfile**: This file used to configure tasks and plugins.
31 |
32 | ## The Modfile
33 | The `Modfile` or `Modfile.js` file is a valid JavaScript file that belongs in the root directory of your project.
34 |
35 | A Modfile is comprised of the following parts:
36 |
37 | * The "runner" object
38 | * The plugins configuration
39 | * The tasks configuration
40 | * The targets configuration
41 |
42 | ### An example Modfile
43 | In the following Modfile, the [mod-sprite] plugin's `sprite` task is configured to generate css sprite. When mod is run on the command line, the `sprite` task will be run by default.
44 |
45 | ```js
46 | module.exports = {
47 | // Load the plugin that provides the "sprite" task.
48 | plugins: {
49 | sprite: "mod-sprite"
50 | },
51 |
52 | // Project configuration.
53 | tasks: {
54 | sprite: {
55 | "src": "./css/find.css", // required
56 | "dest": "./dist/css/find.css", // required
57 | "destImageRoot": "./sprites/", // optional relative to dest path, default "./sprites/"
58 | "maxSize": 60, // optional "kb"
59 | "margin": 5, // optional default 0
60 | "prefix": "sprite_", // optional
61 | "igts": true // optional
62 | },
63 | "min" : {
64 | "css": {
65 | "src": "./dist/css/*.css",
66 | "dest": "./dist/css"
67 | },
68 | "html": {
69 | "src": "*.html",
70 | "dest": "./dist/"
71 | },
72 | "js": {
73 | "src": "./dist/js/*.js",
74 | "dest": "./dist/js"
75 | }
76 | }
77 | },
78 |
79 | // Target task(s).
80 | targets: {
81 | dist: "sprite min"
82 | }
83 | };
84 | ```
85 |
86 | It's so easy to start working with Mod. Because `Modfile` is a JavaScript file, you're not limited to JSON, can use any valid JS here. You can even programmatically generate the configuration if necessary.
87 |
88 | Now that you've seen the whole Modfile, let's look at its component parts.
89 |
90 |
91 | ### Plugins configuration
92 |
93 | ```js
94 | module.exports = {
95 | plugins: {
96 | // Plugin task
97 | sprite: "mod-sprite",
98 | // Custom task
99 | mytask: "./tasks/mytask"
100 | }
101 | }
102 | ```
103 |
104 | ### Tasks configuration
105 |
106 | ```js
107 | module.exports = {
108 | tasks: {
109 | pkg: {
110 | name: "foo"
111 | },
112 | min: {
113 | source: 'src/{{pkg.name}}.js',
114 | dest: 'build/{{pkg.name}}.min.js'
115 | }
116 | }
117 |
118 | };
119 | ```
120 |
121 | ### Targets configuration
122 |
123 | ```js
124 | module.exports = {
125 | targets: {
126 | dev: "cat min:js",
127 | dist: "sprite min"
128 | }
129 | };
130 | ```
131 |
132 |
133 | ## Further Reading
134 |
135 | * The [Configuring Tasks](https://github.com/modjs/mod/blob/master/doc/tutorial/configuring-tasks.md) guide has an in-depth explanation on how to configure tasks, targets, options and files inside the Modfile, along with an explanation of templates, globbing patterns.
136 | * For more information about writing [custom tasks or Mod plugins](https://github.com/modjs/mod/blob/master/doc/tutorial/creating-plugins.md).
137 |
--------------------------------------------------------------------------------
/example/buildmobile/Modfile.js:
--------------------------------------------------------------------------------
1 | // Mod.js
2 | // More info at https://github.com/modjs/mod/
3 |
4 | module.exports = {
5 | tasks: {
6 | build: {
7 | src: "./index.html",
8 | stripDefine: true
9 | }
10 | }
11 | };
--------------------------------------------------------------------------------
/example/buildmobile/README.md:
--------------------------------------------------------------------------------
1 | ### Usage
2 |
3 | super easy:
4 |
5 | ```sh
6 | $ mod
7 | ```
8 |
9 |
--------------------------------------------------------------------------------
/example/buildmobile/css/base.css:
--------------------------------------------------------------------------------
1 | body{
2 | color: grey
3 | }
--------------------------------------------------------------------------------
/example/buildmobile/css/main.css:
--------------------------------------------------------------------------------
1 | @import "base.css";
2 | #only {
3 | love: u;
4 | }
5 |
--------------------------------------------------------------------------------
/example/buildmobile/img/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/example/buildmobile/img/icon.png
--------------------------------------------------------------------------------
/example/buildmobile/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Build Demo
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/example/buildmobile/js/ios.js:
--------------------------------------------------------------------------------
1 | /* ios */
2 | define(['./var/navigator'],function(navigator){
3 | var ios = /ios/i.test(navigator.userAgent);
4 | })
--------------------------------------------------------------------------------
/example/buildmobile/js/main.js:
--------------------------------------------------------------------------------
1 | define([
2 | './var/zepto',
3 | './var/document',
4 | './var/navigator',
5 | './var/location',
6 | './ios'
7 | ], function ($, document, navigator, location, ios) {
8 | $('#hi').text("Hello ModJS");
9 | })
--------------------------------------------------------------------------------
/example/buildmobile/js/var/document.js:
--------------------------------------------------------------------------------
1 | define(function(){
2 | return window.document;
3 | })
--------------------------------------------------------------------------------
/example/buildmobile/js/var/location.js:
--------------------------------------------------------------------------------
1 | define(function(){
2 | return window.location;
3 | })
--------------------------------------------------------------------------------
/example/buildmobile/js/var/navigator.js:
--------------------------------------------------------------------------------
1 | define(function(){
2 | return window.navigator;
3 | })
--------------------------------------------------------------------------------
/example/buildmobile/js/var/zepto.js:
--------------------------------------------------------------------------------
1 | define(function(){
2 | return Zepto;
3 | });
--------------------------------------------------------------------------------
/example/buildnormal/Modfile.js:
--------------------------------------------------------------------------------
1 | // Mod.js
2 | // More info at https://github.com/modjs/mod/
3 |
4 | module.exports = {
5 | tasks: {
6 | build: {
7 | src: "./index.html"
8 | }
9 | }
10 | };
--------------------------------------------------------------------------------
/example/buildnormal/README.md:
--------------------------------------------------------------------------------
1 | ### Usage
2 |
3 | super easy:
4 |
5 | ```sh
6 | $ mod build index.html
7 | ```
8 |
9 |
--------------------------------------------------------------------------------
/example/buildnormal/css/base.css:
--------------------------------------------------------------------------------
1 | body{
2 | background-color: grey
3 | }
4 |
5 | #baz {
6 | background: url('../img/icon.png') no-repeat;
7 | height: 24px;
8 | width: 24px
9 | }
--------------------------------------------------------------------------------
/example/buildnormal/css/main.css:
--------------------------------------------------------------------------------
1 | @import "base.css";
2 |
3 | #foo {
4 | background: url('../img/icon.png?datauri') no-repeat;
5 | height: 24px;
6 | width: 24px
7 | }
8 |
9 | #bar {
10 | background: url('../img/icon.png?url-prepend=http://cdn2.qq.com') no-repeat;
11 | height: 24px;
12 | width: 24px
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/example/buildnormal/img/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/example/buildnormal/img/icon.png
--------------------------------------------------------------------------------
/example/buildnormal/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Build Demo
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/example/buildnormal/js/bar.js:
--------------------------------------------------------------------------------
1 | (function stand(status){
2 | window['console'] && console.log(status);
3 | })('bar');
--------------------------------------------------------------------------------
/example/buildnormal/js/baz.js:
--------------------------------------------------------------------------------
1 | (function stand(status){
2 | window['console'] && console.log(status);
3 | })('baz');
--------------------------------------------------------------------------------
/example/buildnormal/js/corge.js:
--------------------------------------------------------------------------------
1 | (function stand(status){
2 | window['console'] && console.log(status);
3 | })('corge');
--------------------------------------------------------------------------------
/example/buildnormal/js/foo.js:
--------------------------------------------------------------------------------
1 | (function stand(status){
2 | window['console'] && console.log(status);
3 | })('foo');
--------------------------------------------------------------------------------
/example/buildnormal/js/quux.js:
--------------------------------------------------------------------------------
1 | (function stand(status){
2 | window['console'] && console.log(status);
3 | })('quux');
--------------------------------------------------------------------------------
/example/buildnormal/js/qux.js:
--------------------------------------------------------------------------------
1 | (function stand(status){
2 | window['console'] && console.log(status);
3 | })('quz');
--------------------------------------------------------------------------------
/example/buildrequirejs/Modfile.js:
--------------------------------------------------------------------------------
1 | // Mod.js
2 | // More info at https://github.com/modjs/mod/
3 |
4 | module.exports = {
5 | tasks: {
6 | build: {
7 | src: "./index.html"
8 | }
9 | }
10 | };
--------------------------------------------------------------------------------
/example/buildrequirejs/README.md:
--------------------------------------------------------------------------------
1 | ### Usage
2 |
3 | super easy:
4 |
5 | ```sh
6 | $ mod build index.html
7 | ```
8 |
9 |
--------------------------------------------------------------------------------
/example/buildrequirejs/css/base.css:
--------------------------------------------------------------------------------
1 | body{
2 | color: grey
3 | }
--------------------------------------------------------------------------------
/example/buildrequirejs/css/main.css:
--------------------------------------------------------------------------------
1 | @import "base.css";
2 | #only {
3 | love: u;
4 | }
5 |
--------------------------------------------------------------------------------
/example/buildrequirejs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Build Demo
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/example/buildrequirejs/js/$.js:
--------------------------------------------------------------------------------
1 | !(function (factory) {
2 | if (typeof define === 'function') {
3 | define(factory);
4 | } else {
5 | factory();
6 | }
7 | })(function () {
8 | return jQuery;
9 | });
--------------------------------------------------------------------------------
/example/buildrequirejs/js/main.js:
--------------------------------------------------------------------------------
1 | // Require.js allows us to configure shortcut alias
2 | require.config({
3 | paths: {
4 | $ : './$'
5 | }
6 | });
7 |
8 | require([
9 | '$'
10 | ], function ($) {
11 | $('#hi').text("Hello ModJS");
12 | })
--------------------------------------------------------------------------------
/example/buildrequirejs/js/standalone.js:
--------------------------------------------------------------------------------
1 | (function stand(status){
2 | window['console'] && console.log(status);
3 | })('alone');
--------------------------------------------------------------------------------
/example/buildseajs/Modfile.js:
--------------------------------------------------------------------------------
1 | // Mod.js
2 | // More info at https://github.com/modjs/mod/
3 |
4 | module.exports = {
5 | tasks: {
6 | build: {
7 | src: "*.html"
8 | }
9 | }
10 | };
--------------------------------------------------------------------------------
/example/buildseajs/README.md:
--------------------------------------------------------------------------------
1 | ### Usage
2 |
3 | super easy:
4 |
5 | ```sh
6 | $ mod build index.html
7 | ```
8 |
9 | ### copyright
10 |
11 | http://seajs.org/LICENSE.md
--------------------------------------------------------------------------------
/example/buildseajs/css/style.css:
--------------------------------------------------------------------------------
1 | html, body, div, span, h1, h2, h3, h4, p, img, strong, ol, ul, li {
2 | margin: 0;
3 | padding: 0;
4 | border: 0;
5 | font-size: 100%;
6 | vertical-align: baseline;
7 | background: transparent;
8 | }
9 |
10 | body {
11 | background: #F4F4F4;
12 | }
13 |
14 | #container {
15 | position: relative;
16 | margin: 40px 120px;
17 | background: url(https://a248.e.akamai.net/assets.github.com/images/spinners/octocat-spinner-32.gif) no-repeat;
18 | min-height: 32px;
19 | }
20 |
21 | #container img {
22 | position: absolute;
23 | cursor: pointer;
24 | opacity: .6;
25 | display: none;
26 |
27 | -webkit-transition-property: -webkit-transform;
28 | -moz-transition-property: -moz-transform;
29 | -o-transition-property: -o-transform;
30 | transition-property: transform;
31 | -webkit-transition-duration: 0.8s;
32 | -moz-transition-duration: 0.8s;
33 | -o-transition-duration: 0.8s;
34 | transition-duration: 0.8s;
35 | }
--------------------------------------------------------------------------------
/example/buildseajs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Hello SeaJS
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
35 |
36 |
--------------------------------------------------------------------------------
/example/buildseajs/js/main.js:
--------------------------------------------------------------------------------
1 | define(function(require) {
2 |
3 | var Spinning = require('./spinning');
4 |
5 | var s = new Spinning('#container');
6 | s.render();
7 |
8 | });
9 |
10 |
--------------------------------------------------------------------------------
/example/buildseajs/js/spinning.js:
--------------------------------------------------------------------------------
1 | define(function(require, exports, module) {
2 |
3 | var $ = require('jquery');
4 |
5 | function Spinning(container) {
6 | this.container = $(container);
7 | this.icons = this.container.children();
8 | this.spinnings = [];
9 | }
10 |
11 | module.exports = Spinning;
12 |
13 | Spinning.prototype.render = function() {
14 | this._init();
15 | this.container.css('background', 'none');
16 | this.icons.show();
17 | this._spin();
18 | }
19 |
20 | Spinning.prototype._init = function() {
21 | var spinnings = this.spinnings;
22 |
23 | $(this.icons).each(function(n) {
24 | var startDeg = random(360);
25 | var node = $(this);
26 | var timer;
27 |
28 | node.css({
29 | top: random(40),
30 | left: n * 50 + random(10),
31 | zIndex: 1000
32 | }).hover(
33 | function() {
34 | node.fadeTo(250, 1)
35 | .css('zIndex', 1001)
36 | .css('transform', 'rotate(0deg)');
37 |
38 | },
39 | function() {
40 | node.fadeTo(250, .6).css('zIndex', 1000);
41 | timer && clearTimeout(timer);
42 | timer = setTimeout(spin, Math.ceil(random(10000)));
43 | }
44 | );
45 |
46 | function spin() {
47 | node.css('transform', 'rotate(' + startDeg + 'deg)');
48 | }
49 |
50 | spinnings[n] = spin;
51 | })
52 |
53 | return this;
54 | }
55 |
56 | Spinning.prototype._spin = function() {
57 |
58 | $(this.spinnings).each(function(i, fn) {
59 | setTimeout(fn, Math.ceil(random(3000)));
60 | });
61 |
62 | return this;
63 | }
64 |
65 | function random(x) { return Math.random() * x };
66 |
67 | });
68 |
69 |
--------------------------------------------------------------------------------
/example/catcss/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | cat: {
5 | src: ["foo.css","bar.css"],
6 | dest: "dist/foobar.css"
7 | }
8 | }
9 | };
10 |
--------------------------------------------------------------------------------
/example/catcss/bar.css:
--------------------------------------------------------------------------------
1 | .bar{background-image: url("./img/bar.png")}
2 |
--------------------------------------------------------------------------------
/example/catcss/foo.css:
--------------------------------------------------------------------------------
1 | .foo{background-image: url("foo.png")}
2 |
--------------------------------------------------------------------------------
/example/catcss/foo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/example/catcss/foo.png
--------------------------------------------------------------------------------
/example/catjs/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | cat: {
5 | src: ["foo.js", "bar.js"],
6 | dest: "dist/foobar.js"
7 | }
8 | }
9 | };
10 |
--------------------------------------------------------------------------------
/example/catjs/bar.js:
--------------------------------------------------------------------------------
1 | var bar= '';
--------------------------------------------------------------------------------
/example/catjs/foo.js:
--------------------------------------------------------------------------------
1 | var foo='';
--------------------------------------------------------------------------------
/example/compileamd/Modfile.js:
--------------------------------------------------------------------------------
1 | // Mod.js
2 | // More info at https://github.com/modjs/mod/
3 |
4 | module.exports = {
5 | tasks: {
6 | compile: {
7 | options: {
8 | loader: 'requirejs',
9 | baseUrl: './js',
10 | dest: './dist/js'
11 | },
12 | mainModule: {
13 | src: 'js/main.js'
14 | },
15 | asyncModule: {
16 | src: 'js/asyncModule.js',
17 | exclude: ['./var/navigator']
18 | }
19 | },
20 | cp: {
21 | src: '*.html',
22 | dest: './dist'
23 | }
24 | },
25 |
26 | targets: {
27 | dist: "compile cp"
28 | }
29 | };
--------------------------------------------------------------------------------
/example/compileamd/README.md:
--------------------------------------------------------------------------------
1 | ### Usage
2 |
3 | super easy:
4 |
5 | ```sh
6 | $ mod
7 | ```
8 |
9 |
--------------------------------------------------------------------------------
/example/compileamd/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Build Demo
6 |
7 |
8 |
9 | Load Async Module
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/example/compileamd/js/asyncModule.js:
--------------------------------------------------------------------------------
1 | /* async module */
2 | define(['./var/navigator'],function(navigator){
3 | return "async Module loaded"
4 | })
--------------------------------------------------------------------------------
/example/compileamd/js/main.js:
--------------------------------------------------------------------------------
1 | define([
2 | './var/$',
3 | './var/document',
4 | './var/navigator',
5 | './var/location',
6 | './syncModule'
7 | ], function ($, document, navigator, location, syncModule) {
8 |
9 | $('#foo').text(syncModule);
10 |
11 | $('#load').on('click', function(){
12 | require(['./asyncModule'], function(asyncModule){
13 | $('#bar').text(asyncModule);
14 | });
15 | })
16 |
17 | })
--------------------------------------------------------------------------------
/example/compileamd/js/syncModule.js:
--------------------------------------------------------------------------------
1 | /* sync Module */
2 | define(['./var/navigator'],function(navigator){
3 | return "sync Module loaded"
4 | })
--------------------------------------------------------------------------------
/example/compileamd/js/var/$.js:
--------------------------------------------------------------------------------
1 | define(function(){
2 | return Zepto;
3 | });
--------------------------------------------------------------------------------
/example/compileamd/js/var/document.js:
--------------------------------------------------------------------------------
1 | define(function(){
2 | return window.document;
3 | })
--------------------------------------------------------------------------------
/example/compileamd/js/var/location.js:
--------------------------------------------------------------------------------
1 | define(function(){
2 | return window.location;
3 | })
--------------------------------------------------------------------------------
/example/compileamd/js/var/navigator.js:
--------------------------------------------------------------------------------
1 | define(function(){
2 | return window.navigator;
3 | })
--------------------------------------------------------------------------------
/example/compilecmd/Modfile.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | tasks: {
3 | compile:{
4 | options: {
5 | loader: 'seajs'
6 | },
7 | // do not combine all require module
8 | demo1: {
9 | src: "./js/*.js",
10 | dest: "./dist/js/",
11 | combine: false
12 | },
13 | demo2: {
14 | src: "./js/main.js",
15 | dest: "./dist/js2/",
16 | mainConfigFile: "./js/config.js"
17 | }
18 | }
19 | },
20 | targets: {
21 | dist: "compile"
22 | }
23 | };
--------------------------------------------------------------------------------
/example/compilecmd/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CMD
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/compilecmd/js/a.js:
--------------------------------------------------------------------------------
1 | define(function (require) {
2 | return {a:1, b: require('./b')};
3 | });
--------------------------------------------------------------------------------
/example/compilecmd/js/b.js:
--------------------------------------------------------------------------------
1 | define(function (require) {
2 | return {b:2, c: require('./c')};
3 | });
--------------------------------------------------------------------------------
/example/compilecmd/js/c.js:
--------------------------------------------------------------------------------
1 | define(function (require) {
2 | return {c:3};
3 | });
--------------------------------------------------------------------------------
/example/compilecmd/js/config.js:
--------------------------------------------------------------------------------
1 | seajs.config({
2 | // Enable plugins
3 | plugins: ['shim'],
4 |
5 | // Configure alias
6 | alias: {
7 | 'jquery': {
8 | src: 'http://code.jquery.com/jquery-1.9.1.min.js',
9 | exports: 'jQuery'
10 | }
11 | }
12 | });
--------------------------------------------------------------------------------
/example/compilecmd/js/main.js:
--------------------------------------------------------------------------------
1 | define(function(require){
2 | var a = require('./a');
3 | var $ = require('jquery');
4 | $('#hi').text(JSON.stringify(a));
5 | });
--------------------------------------------------------------------------------
/example/compilecss/Modfile.js:
--------------------------------------------------------------------------------
1 | // Modfile
2 | module.exports = {
3 | tasks: {
4 | compile: {
5 | src: "conditional.css"
6 | }
7 | }
8 | };
--------------------------------------------------------------------------------
/example/compilecss/conditional.css:
--------------------------------------------------------------------------------
1 | #main{
2 | /* #if @target dev */ color: blue; /* #endif */
3 | /* #if @target default / color: black; /* #endif */
4 | }
5 | /* #if @target dev */
6 | #id { color: blue}
7 | /* #endif */
8 | /* #if @target default /
9 | #id { color: black}
10 | /* #endif */
11 |
12 |
--------------------------------------------------------------------------------
/example/compilehtml/Modfile.js:
--------------------------------------------------------------------------------
1 | // Modfile
2 | module.exports = {
3 | tasks: {
4 | compile: {
5 | src: "conditional.html"
6 | }
7 | }
8 | };
--------------------------------------------------------------------------------
/example/compilehtml/conditional.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/example/compilejs/Modfile.js:
--------------------------------------------------------------------------------
1 | // Modfile
2 | module.exports = {
3 | tasks: {
4 | compile: {
5 | src: "conditional.js"
6 | }
7 | }
8 | };
--------------------------------------------------------------------------------
/example/compilejs/conditional.js:
--------------------------------------------------------------------------------
1 | var target = /* #if @target dev */ 'dev' /* #endif */ /* #if @target default / 'default' /* #endif */
2 |
3 | /* #if @target dev */
4 | alert(target)
5 | /* #endif */
6 | /* #if @target default /
7 | console.log(target)
8 | /* #endif */
9 |
10 |
--------------------------------------------------------------------------------
/example/compilemultipage/Modfile.js:
--------------------------------------------------------------------------------
1 | // Mod.js
2 | // More info at https://github.com/modjs/mod/
3 |
4 | module.exports = {
5 | tasks: {
6 | compile: {
7 | options: {
8 | baseUrl: 'js/lib',
9 | loader: 'requirejs',
10 | mainConfigFile: '../common.js'
11 | },
12 | common: {
13 | name: "../common",
14 | src: '../common.js',
15 | dest: './dist/js',
16 | },
17 | main1: {
18 | name: "app/main1",
19 | src: '../app/main1.js',
20 | dest: './dist/js/app/',
21 | exclude: ['../common']
22 | },
23 | main2: {
24 | name: "app/main2",
25 | src: '../app/main2.js',
26 | dest: './dist/js/app/',
27 | exclude: ['../common']
28 | }
29 | },
30 | cp : {
31 | src: '*.html',
32 | dest: './dist'
33 | }
34 |
35 | },
36 | targets: {
37 | dist: "compile cp"
38 | }
39 | };
--------------------------------------------------------------------------------
/example/compilemultipage/README.md:
--------------------------------------------------------------------------------
1 | ### Usage
2 |
3 | super easy:
4 |
5 | ```sh
6 | $ mod
7 | ```
8 |
9 | ### copyright
10 |
11 | https://github.com/requirejs/example-multipage-shim
--------------------------------------------------------------------------------
/example/compilemultipage/js/app/controller/Base.js:
--------------------------------------------------------------------------------
1 | define(function () {
2 | function controllerBase(id) {
3 | this.id = id;
4 | }
5 |
6 | controllerBase.prototype = {
7 | setModel: function (model) {
8 | this.model = model;
9 | },
10 |
11 | render: function (bodyDom) {
12 | bodyDom.prepend('Controller ' + this.id + ' says "' +
13 | this.model.getTitle() + '"');
14 | }
15 | };
16 |
17 | return controllerBase;
18 | });
19 |
--------------------------------------------------------------------------------
/example/compilemultipage/js/app/controller/c1.js:
--------------------------------------------------------------------------------
1 | define(['./Base'], function (Base) {
2 | var c1 = new Base('Controller 1');
3 | return c1;
4 | });
5 |
--------------------------------------------------------------------------------
/example/compilemultipage/js/app/controller/c2.js:
--------------------------------------------------------------------------------
1 | define(['./Base'], function (Base) {
2 | var c2 = new Base('Controller 2');
3 | return c2;
4 | });
5 |
--------------------------------------------------------------------------------
/example/compilemultipage/js/app/lib.js:
--------------------------------------------------------------------------------
1 | define(['jquery'], function ($) {
2 | return {
3 | getBody: function () {
4 | return $('body');
5 | }
6 | }
7 | });
8 |
--------------------------------------------------------------------------------
/example/compilemultipage/js/app/main1.js:
--------------------------------------------------------------------------------
1 | define(function (require) {
2 | var $ = require('jquery'),
3 | lib = require('./lib'),
4 | controller = require('./controller/c1'),
5 | model = require('./model/m1'),
6 | backbone = require('backbone'),
7 | underscore = require('underscore');
8 |
9 | //A fabricated API to show interaction of
10 | //common and specific pieces.
11 | controller.setModel(model);
12 | $(function () {
13 | controller.render(lib.getBody());
14 |
15 | //Display backbone and underscore versions
16 | $('body')
17 | .append(' backbone version: ' + backbone.VERSION + '
')
18 | .append('underscore version: ' + underscore.VERSION + '
');
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/example/compilemultipage/js/app/main2.js:
--------------------------------------------------------------------------------
1 | define(function (require) {
2 | var $ = require('jquery'),
3 | lib = require('./lib'),
4 | controller = require('./controller/c2'),
5 | model = require('./model/m2');
6 |
7 | //A fabricated API to show interaction of
8 | //common and specific pieces.
9 | controller.setModel(model);
10 | $(function () {
11 | controller.render(lib.getBody());
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/example/compilemultipage/js/app/model/Base.js:
--------------------------------------------------------------------------------
1 | define(function () {
2 | function modelBase(title) {
3 | this.title = title;
4 | }
5 |
6 | modelBase.prototype = {
7 | getTitle: function () {
8 | return this.title;
9 | }
10 | };
11 |
12 | return modelBase;
13 | });
14 |
--------------------------------------------------------------------------------
/example/compilemultipage/js/app/model/m1.js:
--------------------------------------------------------------------------------
1 | define(['./Base'], function (Base) {
2 | var m1 = new Base('This is the data for Page 1');
3 | return m1;
4 | });
5 |
--------------------------------------------------------------------------------
/example/compilemultipage/js/app/model/m2.js:
--------------------------------------------------------------------------------
1 | define(['./Base'], function (Base) {
2 | var m2 = new Base('This is the data for Page 2');
3 | return m2;
4 | });
5 |
--------------------------------------------------------------------------------
/example/compilemultipage/js/common.js:
--------------------------------------------------------------------------------
1 | //The build will inline common dependencies into this file.
2 |
3 | //For any third party dependencies, like jQuery, place them in the lib folder.
4 |
5 | //Configure loading modules from the lib directory,
6 | //except for 'app' ones, which are in a sibling
7 | //directory.
8 | requirejs.config({
9 | baseUrl: 'js/lib',
10 | paths: {
11 | app: '../app'
12 | },
13 | shim: {
14 | backbone: {
15 | deps: ['jquery', 'underscore'],
16 | exports: 'Backbone'
17 | },
18 | underscore: {
19 | exports: '_'
20 | }
21 | }
22 | });
23 |
24 | define(['jquery', 'app/lib', 'app/controller/Base', 'app/model/Base'], function(){
25 |
26 | })
27 |
--------------------------------------------------------------------------------
/example/compilemultipage/page1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Page 1
5 |
6 |
18 |
19 |
20 | Go to Page 2
21 |
22 |
23 |
--------------------------------------------------------------------------------
/example/compilemultipage/page2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Page 2
5 |
6 |
18 |
19 |
20 | Go to Page 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/example/configasync/Modfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function(options, done){
2 |
3 | var runner = {
4 | tasks: {
5 | cat: {
6 | options: {
7 | // Task-level options may go here, overriding task defaults.
8 | },
9 | test: {
10 | options: {
11 | // "bar" target options may go here, overriding task-level options.
12 | },
13 | group: [
14 | {src: ['../catjs/foo.js', '../catjs/bar.js'], dest: './dist/foobar.js'},
15 | {src: ['../catcss/foo.css', '../catcss/bar.css'], dest: './dist/foobar.css'},
16 | ]
17 | }
18 | }
19 | },
20 | targets: {
21 | dist: 'cat:test'
22 | }
23 | };
24 |
25 | done(runner);
26 | }
--------------------------------------------------------------------------------
/example/configasync/foobar.css:
--------------------------------------------------------------------------------
1 | .foo{background-image: url("./img/foo.png")}
2 | .bar{background-image: url("./img/bar.png")}
3 |
--------------------------------------------------------------------------------
/example/configasync/foobar.js:
--------------------------------------------------------------------------------
1 | var foo='';
2 | var bar= '';
3 |
--------------------------------------------------------------------------------
/example/configgroup/Modfile.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | tasks: {
3 | cat: {
4 | options: {
5 | // Task-level options may go here, overriding task defaults.
6 | },
7 | test: {
8 | options: {
9 | // "bar" target options may go here, overriding task-level options.
10 | },
11 | group: [
12 | {src: ['../catjs/foo.js', '../catjs/bar.js'], dest: './dist/foobar.js'},
13 | {src: ['../catcss/foo.css', '../catcss/bar.css'], dest: './dist/foobar.css'},
14 | ]
15 | }
16 | }
17 | },
18 | targets: {
19 | dist: 'cat:test'
20 | }
21 | };
--------------------------------------------------------------------------------
/example/configgroup/foobar.css:
--------------------------------------------------------------------------------
1 | .foo{background-image: url("./img/foo.png")}
2 | .bar{background-image: url("./img/bar.png")}
3 |
--------------------------------------------------------------------------------
/example/configgroup/foobar.js:
--------------------------------------------------------------------------------
1 | var foo='';
2 | var bar= '';
3 |
--------------------------------------------------------------------------------
/example/confignestedtargets/Modfile.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | echo: function(options){
4 | console.log(options.text)
5 | }
6 | },
7 | tasks: {
8 | echo: {
9 | text: "echo a echo"
10 | },
11 | cp: {
12 | options: {
13 | // Task-level options may go here, overriding task defaults.
14 | dest: './dist'
15 | },
16 | test: {
17 | options: {
18 | // "bar" target options may go here, overriding task-level options.
19 | },
20 | group: [
21 | {src: ['../catjs/foo.js', '../catjs/bar.js']},
22 | {src: ['../catcss/foo.css', '../catcss/bar.css']},
23 | ]
24 | }
25 | }
26 | },
27 | targets: {
28 | dist: 'cp:test',
29 | default: ["dist", "echo"]
30 | }
31 | };
--------------------------------------------------------------------------------
/example/configoptions/Modfile.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | tasks: {
3 | cp: {
4 | options: {
5 | // Task-level options may go here, overriding task defaults.
6 | dest: './dist'
7 | },
8 | test: {
9 | options: {
10 | // "bar" target options may go here, overriding task-level options.
11 | },
12 | group: [
13 | {src: ['../catjs/foo.js', '../catjs/bar.js']},
14 | {src: ['../catcss/foo.css', '../catcss/bar.css']},
15 | ]
16 | }
17 | }
18 | },
19 | targets: {
20 | dist: 'cp:test'
21 | }
22 | };
--------------------------------------------------------------------------------
/example/configtemplate/Modfile.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | tasks: {
3 | cat: {
4 | test: {
5 | src: ['{{ qux.src }}', 'baz/*.js'], // [['foo/*.js', 'bar/*.js'], 'baz/*.js']
6 | dest: 'dist/abc.js' // 'dist/abc.js'
7 | }
8 | },
9 | // Arbitrary properties used in task configuration templates.
10 | foo: 'foo',
11 | bar: '{{ foo }}/*', // 'foo/*'
12 | baz: '{{ bar }}.js', // 'foo/*.js'
13 | qux: {
14 | src: ['{{ baz }}', 'bar/*.js']
15 | }
16 | },
17 | targets: {
18 | dist: 'cat:test'
19 | }
20 | };
--------------------------------------------------------------------------------
/example/configtemplate/bar/b.js:
--------------------------------------------------------------------------------
1 | var b = 2;
--------------------------------------------------------------------------------
/example/configtemplate/baz/c.js:
--------------------------------------------------------------------------------
1 | var c = 3;
--------------------------------------------------------------------------------
/example/configtemplate/foo/a.js:
--------------------------------------------------------------------------------
1 | var a = 1;
--------------------------------------------------------------------------------
/example/cp/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | cp: {
5 | file: {
6 | src: ["../catjs/*.js", "../catcss/*.css"],
7 | dest: "./dist/a",
8 | filter: /foobar/
9 | },
10 | dir: {
11 | src: ["./dist/a/"],
12 | dest: "./dist/b"
13 | },
14 | subdir: {
15 | src: ["../catjs/foo.js"],
16 | dest: "./dist/b/bb",
17 | backup: false
18 | },
19 | fileAndDir: {
20 | src: ["./dist/b"],
21 | dest: "./dist/c"
22 | },
23 | fileAndDirFlatten: {
24 | src: ["./dist/b"],
25 | flatten: true,
26 | dest: "./dist/d"
27 | },
28 | flattenSrc: {
29 | src: ["./dist/b/**/*.js"],
30 | dest: "./dist/e"
31 | },
32 | fileCopyRoot: {
33 | src: "./dist",
34 | dest: "./dist/f"
35 | }
36 | }
37 | },
38 | targets: {
39 | default: "cp"
40 | }
41 | };
42 |
--------------------------------------------------------------------------------
/example/datauri/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | datauri: {
5 | src: "test.css",
6 | dest: "dist/test.datauri.css",
7 | igts: true
8 | }
9 | }
10 | };
--------------------------------------------------------------------------------
/example/datauri/test.css:
--------------------------------------------------------------------------------
1 | .logo {
2 | background-image: url("test.png");
3 | }
4 |
5 | .logo2 {
6 | background-image: url("test.png?20130630520");
7 | }
--------------------------------------------------------------------------------
/example/datauri/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/example/datauri/test.png
--------------------------------------------------------------------------------
/example/deployhttp/.testskip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/example/deployhttp/.testskip
--------------------------------------------------------------------------------
/example/deployhttp/Modfile.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | tasks:{
3 | watch: {
4 | tasks: 'deploy'
5 | },
6 | deploy: {
7 | src: './dist/**/*',
8 | basedir: './dist/',
9 | token: 'private',
10 | dest: '/Users/yuanyan/Github/modjs/test/deployhttp/tmp',
11 | protocol: 'http',
12 | url: 'http://localhost:3000/upload'
13 | },
14 | server: {
15 | deploy: true,
16 | token: 'private'
17 | }
18 | },
19 |
20 | targets: {
21 | default: 'deploy watch',
22 | server: 'server'
23 | }
24 | };
25 |
--------------------------------------------------------------------------------
/example/deployssh/.testskip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/example/deployssh/.testskip
--------------------------------------------------------------------------------
/example/deployssh/Modfile.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | tasks:{
3 | watch: {
4 | src: './dist/',
5 | tasks: 'deploy'
6 | },
7 | deploy: {
8 | src: './dist/',
9 | dest: 'username:password@host:path' // replace with your own ssh server
10 | }
11 | },
12 |
13 | targets: {
14 | default: 'deploy watch'
15 | }
16 | };
17 |
--------------------------------------------------------------------------------
/example/download/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | plugins: {
4 | tar: "mod-tar"
5 | },
6 | tasks: {
7 | download: {
8 | jquery: {
9 | src: ["http://code.jquery.com/jquery-1.8.2.js"],
10 | dest: "./dist/js"
11 | },
12 | github: {
13 | src: "jquery/jquery",
14 | dest: "./dist/lib/jquery"
15 | }
16 | }
17 | },
18 | targets: {
19 | dist: "download"
20 | }
21 | };
22 |
--------------------------------------------------------------------------------
/example/mincss/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | min: {
5 | src: "test.css",
6 | dest: "dist/test.min.css"
7 | }
8 | }
9 | };
--------------------------------------------------------------------------------
/example/mincss/foo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/example/mincss/foo.png
--------------------------------------------------------------------------------
/example/mincss/test.css:
--------------------------------------------------------------------------------
1 | @import "../catcss/foo.css";
2 | .a {font-family: monospace;}
3 | .b {font-family: monospace;}
4 | .d {font-family: monospace;}
5 | .c {font-family: monospace;}
6 | #main{}
--------------------------------------------------------------------------------
/example/minhtml/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | min: {
5 | src: "*.html",
6 | dest: "./dist"
7 | }
8 | }
9 | };
--------------------------------------------------------------------------------
/example/minhtml/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Build Demo
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/example/minjs/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | min: {
5 | src: "./js/*.js"
6 | }
7 | }
8 | };
--------------------------------------------------------------------------------
/example/minjs/js/unminify.js:
--------------------------------------------------------------------------------
1 | // Simple JavaScript Templating
2 | // John Resig - http://ejohn.org/ - MIT Licensed
3 | (function(){
4 | var cache = {};
5 |
6 | this.tmpl = function tmpl(str, data){
7 | // Figure out if we're getting a template, or if we need to
8 | // load the template - and be sure to cache the result.
9 | var fn = !/\W/.test(str) ?
10 | cache[str] = cache[str] ||
11 | tmpl(document.getElementById(str).innerHTML) :
12 |
13 | // Generate a reusable function that will serve as a template
14 | // generator (and which will be cached).
15 | new Function("obj",
16 | "var p=[],print=function(){p.push.apply(p,arguments);};" +
17 |
18 | // Introduce the data as local variables using with(){}
19 | "with(obj){p.push('" +
20 |
21 | // Convert the template into pure JavaScript
22 | str
23 | .replace(/[\r\t\n]/g, " ")
24 | .split("<%").join("\t")
25 | .replace(/((^|%>)[^\t]*)'/g, "$1\r")
26 | .replace(/\t=(.*?)%>/g, "',$1,'")
27 | .split("\t").join("');")
28 | .split("%>").join("p.push('")
29 | .split("\r").join("\\'")
30 | + "');}return p.join('');");
31 |
32 | // Provide some basic currying to the user
33 | return data ? fn( data ) : fn;
34 | };
35 | })();
--------------------------------------------------------------------------------
/example/minjs/js/unminify.min.js:
--------------------------------------------------------------------------------
1 | // John Resig - http://ejohn.org/ - MIT Licensed
2 | (function(){var e={};this.tmpl=function t(n,r){var i=/\W/.test(n)?new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+n.replace(/[\r\t\n]/g," ").split("<%").join(" ").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split(" ").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');"):e[n]=e[n]||t(document.getElementById(n).innerHTML);return r?i(r):i}})()
--------------------------------------------------------------------------------
/example/mkdir/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | mkdir: {
5 | dest: "dist"
6 | }
7 | }
8 | };
9 |
--------------------------------------------------------------------------------
/example/plugingrunttask/Modfile.js:
--------------------------------------------------------------------------------
1 | // Mod.js
2 | // More info at https://github.com/modjs/mod/
3 |
4 | module.exports = {
5 | plugins: {
6 | concat: "grunt-contrib-concat@0.3.0"
7 | },
8 | tasks: {
9 | concat: {
10 | options: {
11 | separator: '/* separator */',
12 | },
13 | dist: {
14 | src: ['foo.js', 'bar.js'],
15 | dest: 'dist/foobar.js',
16 | },
17 | }
18 | }
19 | };
--------------------------------------------------------------------------------
/example/plugingrunttask/bar.js:
--------------------------------------------------------------------------------
1 | var bar= '';
--------------------------------------------------------------------------------
/example/plugingrunttask/foo.js:
--------------------------------------------------------------------------------
1 | var foo='';
--------------------------------------------------------------------------------
/example/plugininlinetask/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | plugins: {
4 | echo: function (options, done) {
5 | var text = options.text;
6 | setTimeout(function(){
7 | console.log(text);
8 | done();
9 | }, 100);
10 | },
11 | echo2 : {
12 | options: {
13 |
14 | },
15 | run: function (options, done) {
16 | var text = options.text;
17 | setTimeout(function(){
18 | console.log(text);
19 | done();
20 | }, 100);
21 | }
22 | }
23 | },
24 | tasks : {
25 | echo : {
26 | text: "hello modjs"
27 | },
28 | echo2 : {
29 | text: "hello modjs2"
30 | }
31 | },
32 | targets: {
33 | dist: "echo echo2"
34 | }
35 | };
--------------------------------------------------------------------------------
/example/pluginlocaltask/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | plugins: {
4 | mytask: "./mytask"
5 | },
6 | tasks : {
7 | mytask : {
8 | text: "hello modjs"
9 | }
10 | }
11 | };
--------------------------------------------------------------------------------
/example/pluginlocaltask/mytask.js:
--------------------------------------------------------------------------------
1 | exports.summary = 'my task';
2 |
3 | exports.run = function (options, callback) {
4 | var text = options.text;
5 | exports.log(text);
6 | callback();
7 | };
8 |
--------------------------------------------------------------------------------
/example/pluginnpmtask/Modfile.js:
--------------------------------------------------------------------------------
1 | // Mod.js
2 | // More info at https://github.com/modjs/mod/
3 |
4 | module.exports = {
5 | plugins: {
6 | stylus: "mod-stylus"
7 | },
8 | tasks: {
9 | stylus: {
10 | src: "test.styl",
11 | dest: "dist/test.css"
12 | }
13 | }
14 | };
--------------------------------------------------------------------------------
/example/pluginnpmtask/test.styl:
--------------------------------------------------------------------------------
1 | @import 'nib/vendor'
2 |
3 | gray = #ebebeb
4 |
5 | body
6 | padding: 50px
7 |
8 | h1, h2, h3
9 | font-family: helvetica, arial
10 |
11 | table
12 | border-collapse: collapse
13 | td
14 | padding: 3px 10px
15 | border-left: 1px solid #eee
16 | &:first-child
17 | font: 12px helvetica, arial
18 | tr:nth-child(4n)
19 | border-bottom: 1px solid #eee
20 | td
21 | padding-bottom: 15px
22 | tr:nth-child(4n+1)
23 | td
24 | padding-top: 15px
25 |
26 | #color-images
27 | width: 400
28 | height: 300
29 | background: url(http://f.cl.ly/items/0W1R2J2L3g2C2L3p1l1e/Image%202011.08.26%2011:42:20%20AM.png) center
30 | box-sizing: border-box
31 | padding-top: 130px
32 | text-align: center
33 |
34 | div
35 | display: inline-block
36 | width: 50px
37 | height: 50px
38 | margin: 0 15px
39 | box-sizing: border-box
40 | padding-top: 18px
41 | border: 1px solid #fff
42 | font: 9px Lucida Grande
43 | color: #666
--------------------------------------------------------------------------------
/example/replace/Modfile.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | tasks: {
3 | replace: {
4 | string: {
5 | src: "foo.js",
6 | dest: "dist/foo.js",
7 | search: "TIMESTAMP",
8 | replace: +new Date
9 | },
10 | regexp: {
11 | src: "dist/foo.js",
12 | search: /DEBUG/g,
13 | replace: true
14 | },
15 | func: {
16 | src: "dist/foo.js",
17 | search: /v(\d+)/,
18 | replace: function(match, v){
19 | var v = Number(v);
20 | return 'v' + ++v
21 | }
22 | }
23 | }
24 | },
25 | targets: {
26 | default: "replace"
27 | }
28 | };
--------------------------------------------------------------------------------
/example/replace/foo.js:
--------------------------------------------------------------------------------
1 | var ts = TIMESTAMP;
2 | var debug = DEBUG;
3 | var ver = "v1";
4 |
--------------------------------------------------------------------------------
/example/stripcode/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | strip: {
5 | src: "foo.js",
6 | dest: "dist/foo.js",
7 | code: ['alert']
8 | }
9 | }
10 | };
--------------------------------------------------------------------------------
/example/stripcode/foo.js:
--------------------------------------------------------------------------------
1 | define(function (require) {
2 |
3 | if(true) {
4 | // @keep
5 | alert(123);
6 | }
7 | true && alert( 123);
8 | /*
9 | @ignore
10 | */
11 | true, alert( 123);
12 |
13 | console.log(123);
14 |
15 | return {"作者":"元彦","version": VERSION}, alert(2);
16 | });
--------------------------------------------------------------------------------
/example/stripeol/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | strip: {
5 | src: "foo.js",
6 | dest: "dist/foo.js",
7 | eol: 'lf'
8 | }
9 | }
10 | };
--------------------------------------------------------------------------------
/example/stripeol/foo.js:
--------------------------------------------------------------------------------
1 | define(function (require) {
2 |
3 | if(true) {
4 | // @keep
5 | alert(123);
6 | }
7 | true && alert( 123);
8 | /*
9 | @ignore
10 | */
11 | true, alert( 123);
12 |
13 | console.log(123);
14 |
15 | return {"作者":"元彦","version": VERSION}, alert(2);
16 | });
--------------------------------------------------------------------------------
/example/striptab/Modfile.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | tasks: {
4 | strip: {
5 | src: "foo.js",
6 | dest: "dist/foo.js",
7 | eol: 'lf',
8 | tab: ' '
9 | }
10 | }
11 | };
--------------------------------------------------------------------------------
/example/striptab/foo.js:
--------------------------------------------------------------------------------
1 | define(function (require) {
2 |
3 | if(true) {
4 | // @keep
5 | alert(123);
6 | }
7 | true && alert( 123);
8 | /*
9 | @ignore
10 | */
11 | true, alert( 123);
12 |
13 | console.log(123);
14 |
15 | return {"作者":"元彦","version": VERSION}, alert(2);
16 | });
--------------------------------------------------------------------------------
/example/watchstyl/.testskip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/modjs/mod/e1215bd34e5f8d610e8ae17542c8e1cbd3c0a75f/example/watchstyl/.testskip
--------------------------------------------------------------------------------
/example/watchstyl/Modfile.js:
--------------------------------------------------------------------------------
1 | // Modfile
2 | // More info at https://github.com/modjs/mod/
3 |
4 | module.exports = {
5 | plugins: {
6 | stylus: "mod-stylus"
7 | },
8 | tasks: {
9 | stylus: {
10 | src: "./styl/*.styl",
11 | dest: "./css/"
12 | },
13 | watch: {
14 | tasks: ['stylus']
15 | }
16 | },
17 | targets: {
18 | default: "stylus watch"
19 | }
20 | };
--------------------------------------------------------------------------------
/example/watchstyl/styl/bar.styl:
--------------------------------------------------------------------------------
1 | @import 'nib/vendor'
2 |
3 | gray = #ccc
4 |
5 | body
6 | padding: 50px
7 |
8 | h1, h2, h3
9 | font-family: helvetica, arial
10 |
11 | table
12 | border-collapse: collapse
13 | td
14 | padding: 3px 10px
15 | border-left: 1px solid #eee
16 | &:first-child
17 | font: 12px helvetica, arial
18 | tr:nth-child(4n)
19 | border-bottom: 1px solid #eee
20 | td
21 | padding-bottom: 15px
22 | tr:nth-child(4n+1)
23 | td
24 | padding-top: 15px
25 |
26 | #color-images
27 | width: 400
28 | height: 300
29 | background: url(http://f.cl.ly/items/0W1R2J2L3g2C2L3p1l1e/Image%202011.08.26%2011:42:20%20AM.png) center
30 | box-sizing: border-box
31 | padding-top: 130px
32 | text-align: center
33 |
34 | div
35 | display: inline-block
36 | width: 50px
37 | height: 50px
38 | margin: 0 15px
39 | box-sizing: border-box
40 | padding-top: 18px
41 | border: 1px solid #fff
42 | font: 9px Lucida Grande
43 | color: #666
--------------------------------------------------------------------------------
/example/watchstyl/styl/foo.styl:
--------------------------------------------------------------------------------
1 | @import 'nib/vendor'
2 |
3 | gray = #ebebec
4 |
5 | body
6 | padding: 50px
7 |
8 | h1, h2, h3
9 | font-family: helvetica, arial
10 |
11 | table
12 | border-collapse: collapse
13 | td
14 | padding: 3px 10px
15 | border-left: 1px solid #eee
16 | &:first-child
17 | font: 12px helvetica, arial
18 | tr:nth-child(4n)
19 | border-bottom: 1px solid #eee
20 | td
21 | padding-bottom: 15px
22 | tr:nth-child(4n+1)
23 | td
24 | padding-top: 15px
25 |
26 | #color-images
27 | width: 400
28 | height: 300
29 | background: url(http://f.cl.ly/items/0W1R2J2L3g2C2L3p1l1e/Image%202011.08.26%2011:42:20%20AM.png) center
30 | box-sizing: border-box
31 | padding-top: 130px
32 | text-align: center
33 |
34 | div
35 | display: inline-block
36 | width: 50px
37 | height: 50px
38 | margin: 0 15px
39 | box-sizing: border-box
40 | padding-top: 18px
41 | border: 1px solid #fff
42 | font: 9px Lucida Grande
43 | color: #666
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | // exports modjs api
2 | module.exports = require('./lib/runner');
3 |
--------------------------------------------------------------------------------
/lib/builtin.js:
--------------------------------------------------------------------------------
1 | var taskMap = {
2 | help: './tasks/help',
3 | build: './tasks/build',
4 | // helper tasks
5 | init: './tasks/init',
6 | watch: './tasks/watch',
7 | deploy: './tasks/deploy',
8 | download: './tasks/download',
9 | // base tasks
10 | compile: './tasks/compile',
11 | min: './tasks/min',
12 | replace: './tasks/replace',
13 | cat: './tasks/cat',
14 | cp: './tasks/cp',
15 | mkdir: './tasks/mkdir',
16 | mv: './tasks/mv',
17 | rm: './tasks/rm',
18 | rev: './tasks/rev',
19 | strip :'./tasks/strip'
20 | };
21 |
22 | exports.getTaskList = function(){
23 | return Object.keys(taskMap);
24 | };
25 |
26 | exports.getTasks = function(){
27 | var tasks = {};
28 | exports.getTaskList().forEach(function(taskName){
29 | var path = taskMap[taskName];
30 | tasks[taskName] = require(path);
31 | });
32 | return tasks;
33 | };
34 |
--------------------------------------------------------------------------------
/lib/config.js:
--------------------------------------------------------------------------------
1 | var utils = require('./utils');
2 | var file = require('./utils/file');
3 | var path = require('path');
4 | var _ = require('lodash');
5 | var fs = require('fs');
6 | var os = require('os');
7 |
8 | var isWindows = process.platform === 'win32';
9 | // env tmp path
10 | exports.ENV_TMP = 'tmpdir' in os && os.tmpdir() || 'tmpDir' in os && os.tmpDir() || process.env.TMPDIR || process.env.TMP || process.env.TEMP || ( isWindows ? "c:\\windows\\temp" : "/tmp" );
11 | // env home path
12 | exports.ENV_HOME = isWindows? process.env.USERPROFILE: process.env.HOME;
13 | // rc filename
14 | exports.RC_NAME = ".modrc";
15 | // build file, like Makefile
16 | exports.BUILDFILE = [
17 | "Modfile", "Modfile.js"
18 | ];
19 | // default modules directory
20 | exports.MODULES_DIR = "components";
21 | // default tmp directory save downloaded package
22 | exports.TMP_DIR = exports.ENV_TMP + '/.mod/tmp';
23 | // default cache directory save unpack downloaded package
24 | exports.CACHE_DIR = exports.ENV_TMP + '/.mod/cache';
25 |
26 | exports.PATHS = [
27 | //'/etc/' + exports.RC_NAME,
28 | //'/usr/local/etc/' + exports.RC_NAME',
29 | exports.ENV_HOME + '/' + exports.RC_NAME
30 | ];
31 |
32 | /**
33 | * The defaults runtime config
34 | */
35 | exports.DEFAULTS = {
36 | directory: exports.MODULES_DIR
37 | };
38 |
39 | exports.getBuildFilePath = function(cwd){
40 | for (var i = 0, len = exports.BUILDFILE.length; i < len; i++) {
41 | var filepath = path.resolve(cwd || process.cwd(), exports.BUILDFILE[i]);
42 | if (file.exists(filepath)) {
43 | return filepath;
44 | }
45 | }
46 | };
47 |
48 | // Config template Regexp.
49 | var propStringTmplRe = /{{\s*([a-z0-9_$]+(?:\.[a-z0-9_$]+)*)\s*}}/i;
50 |
51 | // TODO: could change template by setting
52 |
53 | // Get config data, recursively processing templates.
54 | function getProperty(value, data) {
55 | // process string value
56 | if (_.isString(value)) {
57 |
58 | var matches = value.match(propStringTmplRe);
59 | if (matches) {
60 | var propName = matches[1];
61 | var template = matches[0];
62 | // Get raw, unprocessed config data.
63 | var rawValue = utils.namespace(data, propName);
64 | var result = getProperty(rawValue, data);
65 |
66 | if(_.isString(result))
67 | return value.replace(template, result);
68 | else
69 | return result;
70 | }
71 | // process array value
72 | } else if (_.isArray(value)) {
73 | return value.map(function(val){
74 | return getProperty(val, data)
75 | });
76 | }
77 |
78 | return value;
79 | }
80 |
81 | exports.processTemplate = function (raw){
82 | return utils.walk(raw, function(value) {
83 | // TODO: if processed vlaue is null or undefined, print warn
84 | return getProperty(value, raw);
85 | });
86 | };
87 |
88 | exports.load = function (options, done) {
89 | exports.loadBuildFile(options, function (runner) {
90 | var cwd = options.cwd;
91 | var config = [
92 | exports.loadRC(cwd),
93 | runner
94 | ].reduce(function (previousValue, currentValue) {
95 | return utils.merge(previousValue, currentValue);
96 | });
97 |
98 | // process template for each config section
99 | ['plugins', 'tasks', 'targets'].forEach(function (section) {
100 | config[section] = exports.processTemplate(config[section] || {});
101 | });
102 |
103 | done(config);
104 | })
105 | };
106 |
107 | exports.loadBuildFile = function (options, done) {
108 | var modfilePath = exports.getBuildFilePath(options.cwd);
109 | var runner;
110 | if(modfilePath){
111 | runner = require(modfilePath);
112 | }
113 |
114 | // asynchronous init config
115 | if (_.isFunction(runner)) {
116 | runner(options, done);
117 | }else{
118 | done(runner || {});
119 | }
120 | };
121 |
122 | /**
123 | * load config file
124 | */
125 | exports.loadRC = function(cwd){
126 |
127 | return [
128 | exports.loadGlobalRC(),
129 | exports.loadProjectRC(cwd)
130 | ].reduce(function (previousValue, currentValue) {
131 | return utils.merge(previousValue, currentValue);
132 | });
133 | };
134 |
135 | /**
136 | * load global config file
137 | */
138 | exports.loadGlobalRC = function () {
139 |
140 | var results = exports.PATHS.map(function(p){
141 | return exports.loadRCFile(p);
142 | });
143 |
144 | var defaults = _.clone(exports.DEFAULTS);
145 | var rc = results.reduce(function (previousValue, currentValue) {
146 | return utils.merge(previousValue, currentValue);
147 | }, defaults);
148 |
149 | return rc;
150 | };
151 |
152 | /**
153 | * find rc file, return default config if no one find
154 | */
155 | exports.loadProjectRC = function (cwd) {
156 |
157 | var p = file.find(cwd || process.cwd(), exports.RC_NAME);
158 | if (p) {
159 | // find project-level rc file,else return default
160 | return exports.loadRCFile(p);
161 | }
162 | return {};
163 | };
164 |
165 | /**
166 | * load rc file, return empty object if error occurs
167 | */
168 | exports.loadRCFile = function (p) {
169 |
170 | if(file.exists(p)){
171 | return file.readJSON(path.resolve(p)) || {};
172 | }
173 | return {};
174 | };
175 |
--------------------------------------------------------------------------------
/lib/generators/git/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
--------------------------------------------------------------------------------
/lib/generators/git/.gitignore:
--------------------------------------------------------------------------------
1 | # Include your project-specific ignores in this file
2 | # Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
3 |
4 | # Numerous always-ignore extensions
5 | *.diff
6 | *.err
7 | *.orig
8 | *.log
9 | *.rej
10 | *.swo
11 | *.swp
12 | *.vi
13 | *~
14 | *.sass-cache
15 |
16 | # OS or Editor folders
17 | .DS_Store
18 | ._*
19 | Thumbs.db
20 | .cache
21 | .project
22 | .settings
23 | .tmproj
24 | nbproject
25 | *.sublime-project
26 | *.sublime-workspace
27 | .idea
28 |
29 | # Dreamweaver added files
30 | _notes
31 | dwsync.xml
32 |
33 | # Komodo
34 | *.komodoproject
35 | .komodotools
36 |
37 | # Espresso
38 | *.esproj
39 | *.espressostorage
40 |
41 | # Rubinius
42 | *.rbc
43 |
44 | # Folders to ignore
45 | .hg
46 | .svn
47 | .CVS
48 |
49 | # Node
50 | npm-debug.log
51 | node_modules
52 |
53 |
--------------------------------------------------------------------------------
/lib/generators/jquery/index.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 |
3 | exports.summary = 'jquery generator';
4 |
5 | exports.options = {
6 | demo: {
7 | message: 'Demo URL',
8 | default: ''
9 | },
10 | docs: {
11 | message: 'Docs URL',
12 | default: ''
13 | },
14 | jquery_version: {
15 | message: 'Required jQuery version',
16 | default: '*'
17 | },
18 | author_name: {
19 | message: 'Author name',
20 | default: process.env.USER || process.env.USERNAME
21 | }
22 | };
23 |
24 | exports.generators = {
25 | json: {
26 | dest: '.',
27 | data: {}
28 | },
29 | licenses: {
30 | dest: ".",
31 | data: {}
32 | },
33 | modfile: {
34 | dest: ".",
35 | data: {}
36 | },
37 | git: {
38 | dest: ".",
39 | data: {}
40 | },
41 | readme: {
42 | dest: ".",
43 | data: {}
44 | }
45 | };
46 |
47 | exports.run = function (options) {
48 | exports.copyTemplate('{{name}}.jquery.json');
49 | exports.copyTemplate('{{name}}.js');
50 | };
51 |
--------------------------------------------------------------------------------
/lib/generators/jquery/{{name}}.jquery.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "{{name}}",
3 | "title": "{{title}}",
4 | "description": "{{description}}",
5 | "version": "{{version}}",
6 | "homepage": "{{homepage}}",
7 | "demo": "{{demo}}",
8 | "docs": "{{docs}}",
9 | "author": {
10 | "name": "{{author_name}}",
11 | "email": "{{author_email}}",
12 | "url": "{{author_url}}"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "{{repository}}"
17 | },
18 | "bugs": "{{bugs}}",
19 | "dependencies": {
20 | "jquery": "{{jquery_version}}"
21 | },
22 | "keywords": [{{keywords}}],
23 | "licenses": [
24 | {
25 | "type": "{{license_type}}",
26 | "url": "{{license_url}}"
27 | }
28 | ]
29 | }
--------------------------------------------------------------------------------
/lib/generators/jquery/{{name}}.js:
--------------------------------------------------------------------------------
1 | (function (factory) {
2 | if (typeof define === 'function') {
3 | define(['$'], factory);
4 | } else {
5 | factory($);
6 | }
7 | })(function ($) {
8 | 'use strict';
9 |
10 | var pluginName = '{{name}}';
11 |
12 | function plugin( options ){
13 | // ...
14 | }
15 |
16 | $.fn[pluginName] = function ( options ) {
17 | return this.each(function () {
18 | // ...
19 | })
20 |
21 | };
22 |
23 | $[pluginName] = plugin;
24 | })
--------------------------------------------------------------------------------
/lib/generators/json/index.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var url = require('url');
3 |
4 | exports.summary = 'package generator';
5 |
6 | exports.options = {
7 | name: {
8 | message: 'Project name',
9 | default: function () {
10 | var types = ['javascript', 'js'];
11 | var type = '(?:' + types.join('|') + ')';
12 | // This regexp matches:
13 | // leading type- type. type_
14 | // trailing -type .type _type and/or -js .js _js
15 | var re = new RegExp('^' + type + '[\\-\\._]?|(?:[\\-\\._]?' + type + ')?(?:[\\-\\._]?js)?$', 'ig');
16 | // Strip the above stuff from the current dirname.
17 | var name = path.basename(process.cwd()).replace(re, '');
18 | // Remove anything not a letter, number, dash, dot or underscore.
19 | return name.replace(/[^\w\-\.]/g, '');
20 | },
21 | validator: /^[\w\-\.]+$/,
22 | warning: 'Must be only letters, numbers, dashes, dots or underscores.'
23 | },
24 | description: {
25 | message: 'Project description',
26 | default: '{{name}}'
27 | },
28 | version: {
29 | message: 'Version',
30 | default: '0.1.0',
31 | warning: 'Must be a valid semantic version (semver.org).'
32 | },
33 | author_name: {
34 | message: 'Author name',
35 | default: process.env.USER || process.env.USERNAME,
36 | warning: 'May consist of any characters.'
37 | },
38 | author_email: {
39 | message: 'Author email',
40 | warning: 'Should be a valid email address.'
41 | },
42 | author_url: {
43 | message: 'Author url',
44 | warning: 'Should be a public URL.',
45 | default: 'https://github.com/{{author_name}}'
46 | },
47 | repository: {
48 | message: 'Project git repository',
49 | default: 'git://github.com/{{author_name}}/{{name}}.git',
50 | before: function (value) {
51 | if(!url.parse(value).host){
52 | value = 'git://github.com/'+ value + '.git';
53 | }
54 | return value;
55 | }
56 | },
57 | homepage: {
58 | message: 'Project homepage',
59 | default: function(options){
60 | var value = url.parse(options.repository).path;
61 | if(value){
62 | value = 'https://github.com'+ value.replace('.git','');
63 | }else{
64 | value = 'https://github.com/'+ options.author_name + '/' + options.name
65 | }
66 | return value;
67 | },
68 | warning: 'Should be a public URL.',
69 | before: function (value) {
70 | if(!url.parse(value).host){
71 | value = 'https://github.com/'+ value;
72 | }
73 | return value;
74 | }
75 | },
76 | bugs: {
77 | message: 'Project issues tracker',
78 | // If GitHub is the origin, the issues tracker is easy to figure out.
79 | default: '{{homepage}}/issues',
80 | warning: 'Should be a public URL.'
81 | },
82 | node_version: {
83 | message: 'What versions of node does it run on?',
84 | default: '>= 0.6.0',
85 | warning: 'Must be a valid semantic version range descriptor.'
86 | },
87 | main: {
88 | message: 'Main module/entry point',
89 | default: "index.js",
90 | warning: 'Must be a path relative to the project root.'
91 | },
92 | bin: {
93 | message: 'CLI script',
94 | default: 'bin/{{name}}',
95 | warning: 'Must be a path relative to the project root.'
96 | },
97 | npm_test: {
98 | message: 'Npm test command',
99 | default: "npm test",
100 | warning: 'Must be an executable command.'
101 | }
102 | };
103 |
104 | exports.generators = {
105 | licenses: {
106 | dest: ".",
107 | data: {}
108 | }
109 | };
110 |
111 | exports.run = function (options) {
112 | exports.copyTemplate("templates/package.json", "package.json");
113 | };
114 |
--------------------------------------------------------------------------------
/lib/generators/json/templates/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "{{name}}",
3 | "description": "{{description}}",
4 | "version": "{{version}}",
5 | "homepage": "{{homepage}}",
6 | "author": {
7 | "name": "{{author_name}}",
8 | "url": "{{author_url}}"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "{{repository}}"
13 | },
14 | "bugs": {
15 | "url": "{{bugs}}"
16 | },
17 | "licenses": [
18 | {
19 | "type": "{{license_type}}",
20 | "url": "{{license_url}}"
21 | }
22 | ],
23 | "bin": "{{bin}}",
24 | "engines": {
25 | "node": "{{node_version}}"
26 | },
27 | "scripts": {
28 | "test": "{{npm_test}}"
29 | },
30 | "dependencies": {
31 | },
32 | "devDependencies": {
33 | },
34 | "keywords": []
35 | }
--------------------------------------------------------------------------------
/lib/generators/licenses/MIT-LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) {{ copyright_year }} {{ copyright_holders }}
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the "Software"), to deal in the Software without
6 | restriction, including without limitation the rights to use,
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following
10 | conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/lib/generators/licenses/index.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 |
3 | exports.summary = 'licenses generator';
4 |
5 | exports.options = {
6 | licenses: {
7 | message: 'Licenses',
8 | default: 'MIT'
9 | },
10 | copyright_year: {
11 | message: "Copyright year",
12 | default: new Date().getFullYear()
13 | },
14 | copyright_holders: {
15 | message: 'Copyright holders',
16 | default: "{{author_name}}"
17 | }
18 | };
19 |
20 | exports.run = function (options) {
21 | var license = options.licenses;
22 |
23 | var licenses = {
24 | "apache": "Apache-2.0",
25 | "apache2": "Apache-2.0",
26 | "apache-2.0": "Apache-2.0",
27 | "gpl": "GPL-2.0t",
28 | "gpl2": "GPL-2.0t",
29 | "gpl-2.0": "GPL-2.0",
30 | "mpl": "MPL-2.0",
31 | "mpl-2.0": "MPL-2.0",
32 | "mpl2": "MPL-2.0",
33 | "mit": "MIT"
34 | };
35 |
36 | var license_type = licenses[license.toLowerCase()];
37 | if (license_type) {
38 | exports.templateData['license_type'] = license_type;
39 | var license_file = license_type + "-LICENSE.txt";
40 | exports.templateData['license_url'] = "{{homepage}}/blob/master/" + license_file;
41 | exports.copyTemplate( license_file );
42 | } else {
43 | exports.templateData['license_type'] = license;
44 |
45 | }
46 | };
--------------------------------------------------------------------------------
/lib/generators/mocha/test/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Mocha Spec Runner
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |