You can install Eustia using Node Package Manager(npm).
npm install -g eustia
Eustia scans code files to find the modules you need with three types of syntax supported, global, commonjs and es6.
<html>
<head>
...
<script src="util.js"></script>
</head>
<body>
<script>
var projectName = _.trim(' Eustia ');
// Some code...
</script>
</body>
</html>
var util = require('./util');
var projectName = util.trim(' Eustia ');
// Some code...
import {trim} from './util'
var projectName = trim(' Eustia ');
// Some code...
You can use Eustia with command lines totally. It usually follows the same pattern described below:
eustia <command> [<options>]
For example:
eustia build -o util.js index.html *.js ...<list of files to be scanned>
It's also possible to use a configuration file to save settings. This is pretty helpful especially when you want to generate multiple utility libraries for different sections of your website.
Just create a file named .eustia in your project root.
{
"files": "./layout/**/*.jade",
"output": "./static/js/eustia.js"
}
Running Eustia without any sub commands, the tool will find .eustia under current working directory to read configuration to generate libraries. It is almost the same as running build command from console, just a different way of passing options.
Configuration can be written in json format or js format.
module.exports = {
page: {
files: "./layout/**/*.jade",
output: "./static/js/eustia.js"
},
node: {
files: ["./lib/*.js", "./tool/**/*.js"],
output: "./lib/util.js"
},
...
};
Obviously, multiple configuration is also supported. To specify which task to run, just append the task name after command name.
eustia <task-name>
Configuration could be overwritten by command line options. And it's possible to specify another configuration path using config options.
To use Eustia from JavaScript(NodeJs), install it locally first.
npm install eustia --save-dev
Then require and run it by passing options just the same as a configuration file.
var eustia = require('eustia');
eustia.build({
files: './layout/**/*.jade',
output: './static/js/eustia.js',
...
}, function ()
{
// callback
});
Build JavaScript libraries by scanning files. When used in command line, the rest arguments will be treated as files.
eustia build [<options>]
eustia build index.html
eustia build index.html src/*.js
eusita build index.html src/*.js -o lib.js
Name | Shorthand | Default | Desc |
---|---|---|---|
encoding | utf-8 | Input file encoding | |
exclude | e | Functions excluded | |
extension | js | Module extension, useful for transpilers | |
files | ['*.html', '*.js'] | Files to scan | |
format | f | umd | Module pattern, commonjs, umd, es or global |
include | i | Functions included | |
ignore | Files excluded | ||
library | l | External library paths | |
namespace | n | _ | Namespace of generated library |
output | o | util.js | Output path |
transpilers | Use for writing modules in different formats | ||
watch | w | false | Watch files to regenerate automatically |
ts | false | Output typescript definition file | |
proxy | Request proxy |
Transpilers and extension are not available via command line arguments, use them only in configurations.
Generate documentation from generated utiltiy libraries.
eustia doc [<options>]
eustia doc util.js -o doc.html
Name | Shorthand | Default | Desc |
---|---|---|---|
description | d | Extra description markdown file path | |
format | f | html | Output format, html, json or markdown |
output | o | docs.html | Output path |
title | t | Eustia Documentation | Documentation title |
Materials must be prepared first to cook a good meal. Right now, our materials is a bunch of small modules. Eustia provides many utilities itself(currently under development). Still, there are times you want to add your own ones. To achieve that, create a directory named eustia in the root directory.
Now, let's say I want to have a function to compare version numbers. The first step is to create a js file named compareVersion.js in eustia directory. Then fills it with actual codes to finish the procedure.
// eustia/compareVersion.js
_('isStr each'); // dependencies
// export object
exports = function (v1, v2)
{
if (!isStr(v1) || !isStr(v2)) return;
...
};
Now you can use compareVersion anywhere in your project.
Using option library allows you to search functions in other paths, quite useful when sharing functions among several projects. Besides, Lodash functions is available by using eustia-lodash.
licia: Eustia official modules(updated everyday)
eustia-babel: Allow modules to be written in es6.
eustia-component: Allow modules to be written in html-like style.