update modules

This commit is contained in:
s2
2020-06-08 08:50:28 +02:00
parent ae4aaf2668
commit 27635904a6
477 changed files with 20385 additions and 35036 deletions

114
node_modules/ejs/README.md generated vendored
View File

@@ -1,10 +1,8 @@
# EJS
Embedded JavaScript templates
Embedded JavaScript templates<br/>
[![Build Status](https://img.shields.io/travis/mde/ejs/master.svg?style=flat)](https://travis-ci.org/mde/ejs)
[![Developing Dependencies](https://img.shields.io/david/dev/mde/ejs.svg?style=flat)](https://david-dm.org/mde/ejs?type=dev)
[![Known Vulnerabilities](https://snyk.io/test/npm/ejs/badge.svg?style=flat)](https://snyk.io/test/npm/ejs)
=============================
## Installation
@@ -19,7 +17,7 @@ $ npm install ejs
* Unescaped raw output with `<%- %>`
* Newline-trim mode ('newline slurping') with `-%>` ending tag
* Whitespace-trim mode (slurp all whitespace) for control flow with `<%_ _%>`
* Custom delimiters (e.g., use `<? ?>` instead of `<% %>`)
* Custom delimiters (e.g. `[? ?]` instead of `<% %>`)
* Includes
* Client-side support
* Static caching of intermediate JavaScript
@@ -36,7 +34,7 @@ $ npm install ejs
Try EJS online at: https://ionicabizau.github.io/ejs-playground/.
## Usage
## Basic usage
```javascript
let template = ejs.compile(str, options);
@@ -57,19 +55,23 @@ for all the passed options. However, be aware that your code could break if we
add an option with the same name as one of your data object's properties.
Therefore, we do not recommend using this shortcut.
## Options
### Options
- `cache` Compiled functions are cached, requires `filename`
- `filename` The name of the file being rendered. Not required if you
are using `renderFile()`. Used by `cache` to key caches, and for includes.
- `root` Set project root for includes with an absolute path (/file.ejs).
- `root` Set project root for includes with an absolute path (e.g, /file.ejs).
Can be array to try to resolve include from multiple directories.
- `views` An array of paths to use when resolving includes with relative paths.
- `context` Function execution context
- `compileDebug` When `false` no debug instrumentation is compiled
- `client` When `true`, compiles a function that can be rendered
in the browser without needing to load the EJS Runtime
([ejs.min.js](https://github.com/mde/ejs/releases/latest)).
- `delimiter` Character to use with angle brackets for open/close
- `debug` Output generated function body
- `delimiter` Character to use for inner delimiter, by default '%'
- `openDelimiter` Character to use for opening delimiter, by default '<'
- `closeDelimiter` Character to use for closing delimiter, by default '>'
- `debug` Outputs generated function body
- `strict` When set to `true`, generated function is in strict mode
- `_with` Whether or not to use `with() {}` constructs. If `false`
then the locals will be stored in the `locals` object. Set to `false` in strict mode.
@@ -88,13 +90,18 @@ Therefore, we do not recommend using this shortcut.
output inside scriptlet tags.
- `async` When `true`, EJS will use an async function for rendering. (Depends
on async/await support in the JS runtime.
- `includer` Custom function to handle EJS includes, receives `(originalPath, parsedPath)`
parameters, where `originalPath` is the path in include as-is and `parsedPath` is the
previously resolved path. Should return an object `{ filename, template }`,
you may return only one of the properties, where `filename` is the final parsed path and `template`
is the included content.
This project uses [JSDoc](http://usejsdoc.org/). For the full public API
documentation, clone the repository and run `npm run doc`. This will run JSDoc
with the proper options and output the documentation to `out/`. If you want
the both the public & private API docs, run `npm run devdoc` instead.
## Tags
### Tags
- `<%` 'Scriptlet' tag, for control-flow, no output
- `<%_` 'Whitespace Slurping' Scriptlet tag, strips all whitespace before it
@@ -109,7 +116,7 @@ the both the public & private API docs, run `npm run devdoc` instead.
For the full syntax documentation, please see [docs/syntax.md](https://github.com/mde/ejs/blob/master/docs/syntax.md).
## Includes
### Includes
Includes either have to be an absolute path, or, if not, are assumed as
relative to the template with the `include` call. For example if you are
@@ -136,7 +143,7 @@ top-level data object are available to all your includes, but local variables
need to be passed down.
NOTE: Include preprocessor directives (`<% include user/show %>`) are
still supported.
not supported in v3.0+.
## Custom delimiters
@@ -147,16 +154,18 @@ let ejs = require('ejs'),
users = ['geddy', 'neil', 'alex'];
// Just one template
ejs.render('<?= users.join(" | "); ?>', {users: users}, {delimiter: '?'});
// => 'geddy | neil | alex'
ejs.render('<p>[?= users.join(" | "); ?]</p>', {users: users}, {delimiter: '?', openDelimiter: '[', closeDelimiter: ']'});
// => '<p>geddy | neil | alex</p>'
// Or globally
ejs.delimiter = '$';
ejs.render('<$= users.join(" | "); $>', {users: users});
// => 'geddy | neil | alex'
ejs.delimiter = '?';
ejs.openDelimiter = '[';
ejs.closeDelimiter = ']';
ejs.render('<p>[?= users.join(" | "); ?]</p>', {users: users});
// => '<p>geddy | neil | alex</p>'
```
## Caching
### Caching
EJS ships with a basic in-process cache for caching the intermediate JavaScript
functions used to render templates. It's easy to plug in LRU caching using
@@ -172,7 +181,7 @@ If you want to clear the EJS cache, call `ejs.clearCache`. If you're using the
LRU cache and need a different limit, simple reset `ejs.cache` to a new instance
of the LRU.
## Custom file loader
### Custom file loader
The default file loader is `fs.readFileSync`, if you want to customize it, you can set ejs.fileLoader.
@@ -187,7 +196,7 @@ ejs.fileLoader = myFileLoad;
With this feature, you can preprocess the template before reading it.
## Layouts
### Layouts
EJS does not specifically support blocks, but layouts can be implemented by
including headers and footers, like so:
@@ -248,7 +257,67 @@ Most of EJS will work as expected; however, there are a few things to note:
See the [examples folder](https://github.com/mde/ejs/tree/master/examples) for more details.
### IDE Integration with Syntax Highlighting
## CLI
EJS ships with a full-featured CLI. Available options are similar to those used in JavaScript code:
- `-o / --output-file FILE` Write the rendered output to FILE rather than stdout.
- `-f / --data-file FILE` Must be JSON-formatted. Use parsed input from FILE as data for rendering.
- `-i / --data-input STRING` Must be JSON-formatted and URI-encoded. Use parsed input from STRING as data for rendering.
- `-m / --delimiter CHARACTER` Use CHARACTER with angle brackets for open/close (defaults to %).
- `-p / --open-delimiter CHARACTER` Use CHARACTER instead of left angle bracket to open.
- `-c / --close-delimiter CHARACTER` Use CHARACTER instead of right angle bracket to close.
- `-s / --strict` When set to `true`, generated function is in strict mode
- `-n / --no-with` Use 'locals' object for vars rather than using `with` (implies --strict).
- `-l / --locals-name` Name to use for the object storing local variables when not using `with`.
- `-w / --rm-whitespace` Remove all safe-to-remove whitespace, including leading and trailing whitespace.
- `-d / --debug` Outputs generated function body
- `-h / --help` Display this help message.
- `-V/v / --version` Display the EJS version.
Here are some examples of usage:
```shell
$ ejs -p [ -c ] ./template_file.ejs -o ./output.html
$ ejs ./test/fixtures/user.ejs name=Lerxst
$ ejs -n -l _ ./some_template.ejs -f ./data_file.json
```
### Data input
There is a variety of ways to pass the CLI data for rendering.
Stdin:
```shell
$ ./test/fixtures/user_data.json | ./bin/cli.js ./test/fixtures/user.ejs
$ ./bin/cli.js ./test/fixtures/user.ejs < test/fixtures/user_data.json
```
A data file:
```shell
$ ejs ./test/fixtures/user.ejs -f ./user_data.json
```
A command-line option (must be URI-encoded):
```shell
./bin/cli.js -i %7B%22name%22%3A%20%22foo%22%7D ./test/fixtures/user.ejs
```
Or, passing values directly at the end of the invocation:
```shell
./bin/cli.js -m $ ./test/fixtures/user.ejs name=foo
```
### Output
The CLI by default send output to stdout, but you can use the `-o` or `--output-file`
flag to specify a target file to send the output to.
## IDE Integration with Syntax Highlighting
VSCode:Javascript EJS by *DigitalBrainstem*
@@ -257,7 +326,6 @@ VSCode:Javascript EJS by *DigitalBrainstem*
There are a number of implementations of EJS:
* TJ's implementation, the v1 of this library: https://github.com/tj/ejs
* Jupiter Consulting's EJS: http://www.embeddedjs.com/
* EJS Embedded JavaScript Framework on Google Code: https://code.google.com/p/embeddedjavascript/
* Sam Stephenson's Ruby implementation: https://rubygems.org/gems/ejs
* Erubis, an ERB implementation which also runs JavaScript: http://www.kuwata-lab.com/erubis/users-guide.04.html#lang-javascript

208
node_modules/ejs/bin/cli.js generated vendored Normal file
View File

@@ -0,0 +1,208 @@
#!/usr/bin/env node
/*
* EJS Embedded JavaScript templates
* Copyright 2112 Matthew Eernisse (mde@fleegix.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
let program = require('jake').program;
delete global.jake; // NO NOT WANT
program.setTaskNames = function (n) { this.taskNames = n; };
let ejs = require('../lib/ejs');
let fs = require('fs');
let args = process.argv.slice(2);
let usage = fs.readFileSync(`${__dirname}/../usage.txt`).toString();
const CLI_OPTS = [
{ full: 'output-file',
abbr: 'o',
expectValue: true,
},
{ full: 'data-file',
abbr: 'f',
expectValue: true,
},
{ full: 'data-input',
abbr: 'i',
expectValue: true,
},
{ full: 'delimiter',
abbr: 'm',
expectValue: true,
passThrough: true,
},
{ full: 'open-delimiter',
abbr: 'p',
expectValue: true,
passThrough: true,
},
{ full: 'close-delimiter',
abbr: 'c',
expectValue: true,
passThrough: true,
},
{ full: 'strict',
abbr: 's',
expectValue: false,
allowValue: false,
passThrough: true,
},
{ full: 'no-with',
abbr: 'n',
expectValue: false,
allowValue: false,
},
{ full: 'locals-name',
abbr: 'l',
expectValue: true,
passThrough: true,
},
{ full: 'rm-whitespace',
abbr: 'w',
expectValue: false,
allowValue: false,
passThrough: true,
},
{ full: 'debug',
abbr: 'd',
expectValue: false,
allowValue: false,
passThrough: true,
},
{ full: 'help',
abbr: 'h',
passThrough: true,
},
{ full: 'version',
abbr: 'V',
passThrough: true,
},
// Alias lowercase v
{ full: 'version',
abbr: 'v',
passThrough: true,
},
];
let preempts = {
version: function () {
program.die(ejs.VERSION);
},
help: function () {
program.die(usage);
}
};
let stdin = '';
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
let chunk;
while ((chunk = process.stdin.read()) !== null) {
stdin += chunk;
}
});
function run() {
program.availableOpts = CLI_OPTS;
program.parseArgs(args);
let templatePath = program.taskNames[0];
let pVals = program.envVars;
let pOpts = {};
for (let p in program.opts) {
let name = p.replace(/-[a-z]/g, (match) => { return match[1].toUpperCase(); });
pOpts[name] = program.opts[p];
}
let opts = {};
let vals = {};
// Same-named 'passthrough' opts
CLI_OPTS.forEach((opt) => {
let optName = opt.full;
if (opt.passThrough && typeof pOpts[optName] != 'undefined') {
opts[optName] = pOpts[optName];
}
});
// Bail out for help/version
for (let p in opts) {
if (preempts[p]) {
return preempts[p]();
}
}
// Ensure there's a template to render
if (!templatePath) {
throw new Error('Please provide a template path. (Run ejs -h for help)');
}
if (opts.strict) {
pOpts.noWith = true;
}
if (pOpts.noWith) {
opts._with = false;
}
// Grab and parse any input data, in order of precedence:
// 1. Stdin
// 2. CLI arg via -i
// 3. Data file via -f
// Any individual vals passed at the end (e.g., foo=bar) will override
// any vals previously set
let input;
let err = new Error('Please do not pass data multiple ways. Pick one of stdin, -f, or -i.');
if (stdin) {
input = stdin;
}
else if (pOpts.dataInput) {
if (input) {
throw err;
}
input = decodeURIComponent(pOpts.dataInput);
}
else if (pOpts.dataFile) {
if (input) {
throw err;
}
input = fs.readFileSync(pOpts.dataFile).toString();
}
if (input) {
vals = JSON.parse(input);
}
// Override / set any individual values passed from the command line
for (let p in pVals) {
vals[p] = pVals[p];
}
let template = fs.readFileSync(templatePath).toString();
let output = ejs.render(template, vals, opts);
if (pOpts.outputFile) {
fs.writeFileSync(pOpts.outputFile, output);
}
else {
process.stdout.write(output);
}
process.exit();
}
// Defer execution so that stdin can be read if necessary
setImmediate(run);

172
node_modules/ejs/ejs.js generated vendored
View File

@@ -50,6 +50,7 @@ var path = require('path');
var utils = require('./utils');
var scopeOptionWarned = false;
/** @type {string} */
var _VERSION_STRING = require('../package.json').version;
var _DEFAULT_OPEN_DELIMITER = '<';
var _DEFAULT_CLOSE_DELIMITER = '>';
@@ -100,7 +101,7 @@ exports.localsName = _DEFAULT_LOCALS_NAME;
* Promise implementation -- defaults to the native implementation if available
* This is mostly just for testability
*
* @type {Function}
* @type {PromiseConstructorLike}
* @public
*/
@@ -112,7 +113,7 @@ exports.promiseImpl = (new Function('return this;'))().Promise;
*
* @param {String} name specified path
* @param {String} filename parent file path
* @param {Boolean} isDir parent file path whether is directory
* @param {Boolean} [isDir=false] whether the parent file path is a directory
* @return {String}
*/
exports.resolveInclude = function(name, filename, isDir) {
@@ -127,6 +128,23 @@ exports.resolveInclude = function(name, filename, isDir) {
return includePath;
};
/**
* Try to resolve file path on multiple directories
*
* @param {String} name specified path
* @param {Array<String>} paths list of possible parent directory paths
* @return {String}
*/
function resolvePaths(name, paths) {
var filePath;
if (paths.some(function (v) {
filePath = exports.resolveInclude(name, v, true);
return fs.existsSync(filePath);
})) {
return filePath;
}
}
/**
* Get the path to the included file by Options
*
@@ -142,7 +160,12 @@ function getIncludePath(path, options) {
// Abs path
if (match && match.length) {
includePath = exports.resolveInclude(path.replace(/^\/*/,''), options.root || '/', true);
path = path.replace(/^\/*/, '');
if (Array.isArray(options.root)) {
includePath = resolvePaths(path, options.root);
} else {
includePath = exports.resolveInclude(path, options.root || '/', true);
}
}
// Relative paths
else {
@@ -154,15 +177,10 @@ function getIncludePath(path, options) {
}
}
// Then look in any views directories
if (!includePath) {
if (Array.isArray(views) && views.some(function (v) {
filePath = exports.resolveInclude(path, v, true);
return fs.existsSync(filePath);
})) {
includePath = filePath;
}
if (!includePath && Array.isArray(views)) {
includePath = resolvePaths(path, views);
}
if (!includePath) {
if (!includePath && typeof options.includer !== 'function') {
throw new Error('Could not find the include file "' +
options.escapeFunction(path) + '"');
}
@@ -290,53 +308,39 @@ function fileLoader(filePath){
function includeFile(path, options) {
var opts = utils.shallowCopy({}, options);
opts.filename = getIncludePath(path, opts);
if (typeof options.includer === 'function') {
var includerResult = options.includer(path, opts.filename);
if (includerResult) {
if (includerResult.filename) {
opts.filename = includerResult.filename;
}
if (includerResult.template) {
return handleCache(opts, includerResult.template);
}
}
}
return handleCache(opts);
}
/**
* Get the JavaScript source of an included file.
*
* @memberof module:ejs-internal
* @param {String} path path for the specified file
* @param {Options} options compilation options
* @return {Object}
* @static
*/
function includeSource(path, options) {
var opts = utils.shallowCopy({}, options);
var includePath;
var template;
includePath = getIncludePath(path, opts);
template = fileLoader(includePath).toString().replace(_BOM, '');
opts.filename = includePath;
var templ = new Template(template, opts);
templ.generateSource();
return {
source: templ.source,
filename: includePath,
template: template
};
}
/**
* Re-throw the given `err` in context to the `str` of ejs, `filename`, and
* `lineno`.
*
* @implements RethrowCallback
* @implements {RethrowCallback}
* @memberof module:ejs-internal
* @param {Error} err Error object
* @param {String} str EJS source
* @param {String} filename file name of the EJS file
* @param {String} lineno line number of the error
* @param {String} flnm file name of the EJS file
* @param {Number} lineno line number of the error
* @param {EscapeCallback} esc
* @static
*/
function rethrow(err, str, flnm, lineno, esc){
function rethrow(err, str, flnm, lineno, esc) {
var lines = str.split('\n');
var start = Math.max(lineno - 3, 0);
var end = Math.min(lines.length, lineno + 3);
var filename = esc(flnm); // eslint-disable-line
var filename = esc(flnm);
// Error context
var context = lines.slice(start, end).map(function (line, i){
var curr = i + start + 1;
@@ -365,7 +369,7 @@ function stripSemi(str){
*
* @param {String} template EJS template
*
* @param {Options} opts compilation options
* @param {Options} [opts] compilation options
*
* @return {(TemplateFunction|ClientFunction)}
* Depending on the value of `opts.client`, either type might be returned.
@@ -505,11 +509,11 @@ function Template(text, opts) {
opts = opts || {};
var options = {};
this.templateText = text;
/** @type {string | null} */
this.mode = null;
this.truncate = false;
this.currentLine = 1;
this.source = '';
this.dependencies = [];
options.client = opts.client || false;
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
options.compileDebug = opts.compileDebug !== false;
@@ -523,6 +527,7 @@ function Template(text, opts) {
options.cache = opts.cache || false;
options.rmWhitespace = opts.rmWhitespace;
options.root = opts.root;
options.includer = opts.includer;
options.outputFunctionName = opts.outputFunctionName;
options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
options.views = opts.views;
@@ -563,12 +568,16 @@ Template.prototype = {
},
compile: function () {
/** @type {string} */
var src;
/** @type {ClientFunction} */
var fn;
var opts = this.opts;
var prepended = '';
var appended = '';
/** @type {EscapeCallback} */
var escapeFn = opts.escapeFunction;
/** @type {FunctionConstructor} */
var ctor;
if (!this.source) {
@@ -682,7 +691,6 @@ Template.prototype = {
};
return fn.apply(opts.context, [data || {}, escapeFn, include, rethrow]);
};
returnedFn.dependencies = this.dependencies;
if (opts.filename && typeof Object.defineProperty === 'function') {
var filename = opts.filename;
var basename = path.basename(filename, path.extname(filename));
@@ -720,12 +728,7 @@ Template.prototype = {
if (matches && matches.length) {
matches.forEach(function (line, index) {
var opening;
var closing;
var include;
var includeOpts;
var includeObj;
var includeSrc;
// If this is an opening tag, check for closing tags
// FIXME: May end up with some false positives here
// Better to store modes as k/v with openDelimiter + delimiter as key
@@ -737,35 +740,6 @@ Template.prototype = {
throw new Error('Could not find matching close tag for "' + line + '".');
}
}
// HACK: backward-compat `include` preprocessor directives
if (opts.legacyInclude && (include = line.match(/^\s*include\s+(\S+)/))) {
opening = matches[index - 1];
// Must be in EVAL or RAW mode
if (opening && (opening == o + d || opening == o + d + '-' || opening == o + d + '_')) {
includeOpts = utils.shallowCopy({}, self.opts);
includeObj = includeSource(include[1], includeOpts);
if (self.opts.compileDebug) {
includeSrc =
' ; (function(){' + '\n'
+ ' var __line = 1' + '\n'
+ ' , __lines = ' + JSON.stringify(includeObj.template) + '\n'
+ ' , __filename = ' + JSON.stringify(includeObj.filename) + ';' + '\n'
+ ' try {' + '\n'
+ includeObj.source
+ ' } catch (e) {' + '\n'
+ ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
+ ' }' + '\n'
+ ' ; }).call(this)' + '\n';
}else{
includeSrc = ' ; (function(){' + '\n' + includeObj.source +
' ; }).call(this)' + '\n';
}
self.source += includeSrc;
self.dependencies.push(exports.resolveInclude(include[1],
includeOpts.filename));
return;
}
}
self.scanLine(line);
});
}
@@ -939,22 +913,6 @@ exports.escapeXML = utils.escapeXML;
exports.__express = exports.renderFile;
// Add require support
/* istanbul ignore else */
if (require.extensions) {
require.extensions['.ejs'] = function (module, flnm) {
console.log('Deprecated: this API will go away in EJS v2.8');
var filename = flnm || /* istanbul ignore next */ module.filename;
var options = {
filename: filename,
client: true
};
var template = fileLoader(filename).toString();
var fn = exports.compile(template, options);
module._compile('module.exports = ' + fn.toString() + ';', filename);
};
}
/**
* Version of EJS.
*
@@ -1129,7 +1087,7 @@ exports.shallowCopyFromList = function (to, from, list) {
* Simple in-process cache implementation. Does not implement limits of any
* sort.
*
* @implements Cache
* @implements {Cache}
* @static
* @private
*/
@@ -1652,25 +1610,31 @@ module.exports={
"engine",
"ejs"
],
"version": "2.7.4",
"version": "3.1.3",
"author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
"license": "Apache-2.0",
"bin": {
"ejs": "./bin/cli.js"
},
"main": "./lib/ejs.js",
"jsdelivr": "ejs.min.js",
"unpkg": "ejs.min.js",
"repository": {
"type": "git",
"url": "git://github.com/mde/ejs.git"
},
"bugs": "https://github.com/mde/ejs/issues",
"homepage": "https://github.com/mde/ejs",
"dependencies": {},
"dependencies": {
"jake": "^10.6.1"
},
"devDependencies": {
"browserify": "^13.1.1",
"eslint": "^4.14.0",
"browserify": "^16.5.1",
"eslint": "^6.8.0",
"git-directory-deploy": "^1.5.1",
"jake": "^10.3.1",
"jsdoc": "^3.4.0",
"jsdoc": "^3.6.4",
"lru-cache": "^4.0.1",
"mocha": "^5.0.5",
"mocha": "^7.1.1",
"uglify-js": "^3.3.16"
},
"engines": {
@@ -1678,7 +1642,7 @@ module.exports={
},
"scripts": {
"test": "mocha",
"postinstall": "node ./postinstall.js"
"postinstall": "node --harmony ./postinstall.js"
}
}

2
node_modules/ejs/ejs.min.js generated vendored

File diff suppressed because one or more lines are too long

4
node_modules/ejs/jakefile.js generated vendored
View File

@@ -63,7 +63,9 @@ publishTask('ejs', ['build'], function () {
'postinstall.js',
'ejs.js',
'ejs.min.js',
'lib/**'
'lib/**',
'bin/**',
'usage.txt'
]);
});

148
node_modules/ejs/lib/ejs.js generated vendored
View File

@@ -49,6 +49,7 @@ var path = require('path');
var utils = require('./utils');
var scopeOptionWarned = false;
/** @type {string} */
var _VERSION_STRING = require('../package.json').version;
var _DEFAULT_OPEN_DELIMITER = '<';
var _DEFAULT_CLOSE_DELIMITER = '>';
@@ -99,7 +100,7 @@ exports.localsName = _DEFAULT_LOCALS_NAME;
* Promise implementation -- defaults to the native implementation if available
* This is mostly just for testability
*
* @type {Function}
* @type {PromiseConstructorLike}
* @public
*/
@@ -111,7 +112,7 @@ exports.promiseImpl = (new Function('return this;'))().Promise;
*
* @param {String} name specified path
* @param {String} filename parent file path
* @param {Boolean} isDir parent file path whether is directory
* @param {Boolean} [isDir=false] whether the parent file path is a directory
* @return {String}
*/
exports.resolveInclude = function(name, filename, isDir) {
@@ -126,6 +127,23 @@ exports.resolveInclude = function(name, filename, isDir) {
return includePath;
};
/**
* Try to resolve file path on multiple directories
*
* @param {String} name specified path
* @param {Array<String>} paths list of possible parent directory paths
* @return {String}
*/
function resolvePaths(name, paths) {
var filePath;
if (paths.some(function (v) {
filePath = exports.resolveInclude(name, v, true);
return fs.existsSync(filePath);
})) {
return filePath;
}
}
/**
* Get the path to the included file by Options
*
@@ -141,7 +159,12 @@ function getIncludePath(path, options) {
// Abs path
if (match && match.length) {
includePath = exports.resolveInclude(path.replace(/^\/*/,''), options.root || '/', true);
path = path.replace(/^\/*/, '');
if (Array.isArray(options.root)) {
includePath = resolvePaths(path, options.root);
} else {
includePath = exports.resolveInclude(path, options.root || '/', true);
}
}
// Relative paths
else {
@@ -153,15 +176,10 @@ function getIncludePath(path, options) {
}
}
// Then look in any views directories
if (!includePath) {
if (Array.isArray(views) && views.some(function (v) {
filePath = exports.resolveInclude(path, v, true);
return fs.existsSync(filePath);
})) {
includePath = filePath;
}
if (!includePath && Array.isArray(views)) {
includePath = resolvePaths(path, views);
}
if (!includePath) {
if (!includePath && typeof options.includer !== 'function') {
throw new Error('Could not find the include file "' +
options.escapeFunction(path) + '"');
}
@@ -289,53 +307,39 @@ function fileLoader(filePath){
function includeFile(path, options) {
var opts = utils.shallowCopy({}, options);
opts.filename = getIncludePath(path, opts);
if (typeof options.includer === 'function') {
var includerResult = options.includer(path, opts.filename);
if (includerResult) {
if (includerResult.filename) {
opts.filename = includerResult.filename;
}
if (includerResult.template) {
return handleCache(opts, includerResult.template);
}
}
}
return handleCache(opts);
}
/**
* Get the JavaScript source of an included file.
*
* @memberof module:ejs-internal
* @param {String} path path for the specified file
* @param {Options} options compilation options
* @return {Object}
* @static
*/
function includeSource(path, options) {
var opts = utils.shallowCopy({}, options);
var includePath;
var template;
includePath = getIncludePath(path, opts);
template = fileLoader(includePath).toString().replace(_BOM, '');
opts.filename = includePath;
var templ = new Template(template, opts);
templ.generateSource();
return {
source: templ.source,
filename: includePath,
template: template
};
}
/**
* Re-throw the given `err` in context to the `str` of ejs, `filename`, and
* `lineno`.
*
* @implements RethrowCallback
* @implements {RethrowCallback}
* @memberof module:ejs-internal
* @param {Error} err Error object
* @param {String} str EJS source
* @param {String} filename file name of the EJS file
* @param {String} lineno line number of the error
* @param {String} flnm file name of the EJS file
* @param {Number} lineno line number of the error
* @param {EscapeCallback} esc
* @static
*/
function rethrow(err, str, flnm, lineno, esc){
function rethrow(err, str, flnm, lineno, esc) {
var lines = str.split('\n');
var start = Math.max(lineno - 3, 0);
var end = Math.min(lines.length, lineno + 3);
var filename = esc(flnm); // eslint-disable-line
var filename = esc(flnm);
// Error context
var context = lines.slice(start, end).map(function (line, i){
var curr = i + start + 1;
@@ -364,7 +368,7 @@ function stripSemi(str){
*
* @param {String} template EJS template
*
* @param {Options} opts compilation options
* @param {Options} [opts] compilation options
*
* @return {(TemplateFunction|ClientFunction)}
* Depending on the value of `opts.client`, either type might be returned.
@@ -504,11 +508,11 @@ function Template(text, opts) {
opts = opts || {};
var options = {};
this.templateText = text;
/** @type {string | null} */
this.mode = null;
this.truncate = false;
this.currentLine = 1;
this.source = '';
this.dependencies = [];
options.client = opts.client || false;
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
options.compileDebug = opts.compileDebug !== false;
@@ -522,6 +526,7 @@ function Template(text, opts) {
options.cache = opts.cache || false;
options.rmWhitespace = opts.rmWhitespace;
options.root = opts.root;
options.includer = opts.includer;
options.outputFunctionName = opts.outputFunctionName;
options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
options.views = opts.views;
@@ -562,12 +567,16 @@ Template.prototype = {
},
compile: function () {
/** @type {string} */
var src;
/** @type {ClientFunction} */
var fn;
var opts = this.opts;
var prepended = '';
var appended = '';
/** @type {EscapeCallback} */
var escapeFn = opts.escapeFunction;
/** @type {FunctionConstructor} */
var ctor;
if (!this.source) {
@@ -681,7 +690,6 @@ Template.prototype = {
};
return fn.apply(opts.context, [data || {}, escapeFn, include, rethrow]);
};
returnedFn.dependencies = this.dependencies;
if (opts.filename && typeof Object.defineProperty === 'function') {
var filename = opts.filename;
var basename = path.basename(filename, path.extname(filename));
@@ -719,12 +727,7 @@ Template.prototype = {
if (matches && matches.length) {
matches.forEach(function (line, index) {
var opening;
var closing;
var include;
var includeOpts;
var includeObj;
var includeSrc;
// If this is an opening tag, check for closing tags
// FIXME: May end up with some false positives here
// Better to store modes as k/v with openDelimiter + delimiter as key
@@ -736,35 +739,6 @@ Template.prototype = {
throw new Error('Could not find matching close tag for "' + line + '".');
}
}
// HACK: backward-compat `include` preprocessor directives
if (opts.legacyInclude && (include = line.match(/^\s*include\s+(\S+)/))) {
opening = matches[index - 1];
// Must be in EVAL or RAW mode
if (opening && (opening == o + d || opening == o + d + '-' || opening == o + d + '_')) {
includeOpts = utils.shallowCopy({}, self.opts);
includeObj = includeSource(include[1], includeOpts);
if (self.opts.compileDebug) {
includeSrc =
' ; (function(){' + '\n'
+ ' var __line = 1' + '\n'
+ ' , __lines = ' + JSON.stringify(includeObj.template) + '\n'
+ ' , __filename = ' + JSON.stringify(includeObj.filename) + ';' + '\n'
+ ' try {' + '\n'
+ includeObj.source
+ ' } catch (e) {' + '\n'
+ ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
+ ' }' + '\n'
+ ' ; }).call(this)' + '\n';
}else{
includeSrc = ' ; (function(){' + '\n' + includeObj.source +
' ; }).call(this)' + '\n';
}
self.source += includeSrc;
self.dependencies.push(exports.resolveInclude(include[1],
includeOpts.filename));
return;
}
}
self.scanLine(line);
});
}
@@ -938,22 +912,6 @@ exports.escapeXML = utils.escapeXML;
exports.__express = exports.renderFile;
// Add require support
/* istanbul ignore else */
if (require.extensions) {
require.extensions['.ejs'] = function (module, flnm) {
console.log('Deprecated: this API will go away in EJS v2.8');
var filename = flnm || /* istanbul ignore next */ module.filename;
var options = {
filename: filename,
client: true
};
var template = fileLoader(filename).toString();
var fn = exports.compile(template, options);
module._compile('module.exports = ' + fn.toString() + ';', filename);
};
}
/**
* Version of EJS.
*

2
node_modules/ejs/lib/utils.js generated vendored
View File

@@ -146,7 +146,7 @@ exports.shallowCopyFromList = function (to, from, list) {
* Simple in-process cache implementation. Does not implement limits of any
* sort.
*
* @implements Cache
* @implements {Cache}
* @static
* @private
*/

51
node_modules/ejs/package.json generated vendored
View File

@@ -1,56 +1,58 @@
{
"_args": [
[
"ejs@2.7.4",
"D:\\Projects\\siag\\vanillajs-seed"
]
],
"_from": "ejs@2.7.4",
"_id": "ejs@2.7.4",
"_from": "ejs@^3.1.3",
"_id": "ejs@3.1.3",
"_inBundle": false,
"_integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==",
"_integrity": "sha512-wmtrUGyfSC23GC/B1SMv2ogAUgbQEtDmTIhfqielrG5ExIM9TP4UoYdi90jLF1aTcsWCJNEO0UrgKzP0y3nTSg==",
"_location": "/ejs",
"_phantomChildren": {},
"_requested": {
"type": "version",
"type": "range",
"registry": true,
"raw": "ejs@2.7.4",
"raw": "ejs@^3.1.3",
"name": "ejs",
"escapedName": "ejs",
"rawSpec": "2.7.4",
"rawSpec": "^3.1.3",
"saveSpec": null,
"fetchSpec": "2.7.4"
"fetchSpec": "^3.1.3"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/ejs/-/ejs-2.7.4.tgz",
"_spec": "2.7.4",
"_where": "D:\\Projects\\siag\\vanillajs-seed",
"_resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.3.tgz",
"_shasum": "514d967a8894084d18d3d47bd169a1c0560f093d",
"_spec": "ejs@^3.1.3",
"_where": "D:\\Projects\\vanillajs-seed",
"author": {
"name": "Matthew Eernisse",
"email": "mde@fleegix.org",
"url": "http://fleegix.org"
},
"bin": {
"ejs": "bin/cli.js"
},
"bugs": {
"url": "https://github.com/mde/ejs/issues"
},
"dependencies": {},
"bundleDependencies": false,
"dependencies": {
"jake": "^10.6.1"
},
"deprecated": false,
"description": "Embedded JavaScript templates",
"devDependencies": {
"browserify": "^13.1.1",
"eslint": "^4.14.0",
"browserify": "^16.5.1",
"eslint": "^6.8.0",
"git-directory-deploy": "^1.5.1",
"jake": "^10.3.1",
"jsdoc": "^3.4.0",
"jsdoc": "^3.6.4",
"lru-cache": "^4.0.1",
"mocha": "^5.0.5",
"mocha": "^7.1.1",
"uglify-js": "^3.3.16"
},
"engines": {
"node": ">=0.10.0"
},
"homepage": "https://github.com/mde/ejs",
"jsdelivr": "ejs.min.js",
"keywords": [
"template",
"engine",
@@ -64,8 +66,9 @@
"url": "git://github.com/mde/ejs.git"
},
"scripts": {
"postinstall": "node ./postinstall.js",
"postinstall": "node --harmony ./postinstall.js",
"test": "mocha"
},
"version": "2.7.4"
"unpkg": "ejs.min.js",
"version": "3.1.3"
}

4
node_modules/ejs/postinstall.js generated vendored
View File

@@ -10,8 +10,8 @@ let envDisable = isTrue(process.env.DISABLE_OPENCOLLECTIVE) || isTrue(process.en
let logLevel = process.env.npm_config_loglevel;
let logLevelDisplay = ['silent', 'error', 'warn'].indexOf(logLevel) > -1;
if (!envDisable && !logLevelDisplay) {
console.log('Thank you for installing \u001b[35mEJS\u001b[0m: built with the \u001b[32mJake\u001b[0m JavaScript build tool (\u001b[32mhttps://jakejs.com/\u001b[0m)\n');
if (!(envDisable || logLevelDisplay)) {
console.log('Thank you for installing \u001b[35mEJS\u001b[0m: built with the \u001b[32mJake\u001b[0m JavaScript build tool (\u001b[32mhttps://jakejs.com/\u001b[0m\)\n');
}

24
node_modules/ejs/usage.txt generated vendored Normal file
View File

@@ -0,0 +1,24 @@
EJS Embedded JavaScript templates
{Usage}: ejs [options ...] template-file [data variables ...]
{Options}:
-o, --output-file FILE Write the rendered output to FILE rather than stdout.
-f, --data-file FILE Must be JSON-formatted. Use parsed input from FILE as data for rendering.
-i, --data-input STRING Must be JSON-formatted and URI-encoded. Use parsed input from STRING as data for rendering.
-m, --delimiter CHARACTER Use CHARACTER with angle brackets for open/close (defaults to %).
-p, --open-delimiter CHARACTER Use CHARACTER instead of left angle bracket to open.
-c, --close-delimiter CHARACTER Use CHARACTER instead of right angle bracket to close.
-s, --strict When set to `true`, generated function is in strict mode
-n --no-with Use 'locals' object for vars rather than using `with` (implies --strict).
-l --locals-name Name to use for the object storing local variables when not using `with`.
-w --rm-whitespace Remove all safe-to-remove whitespace, including leading and trailing whitespace.
-d --debug Outputs generated function body
-h, --help Display this help message.
-V/v, --version Display the EJS version.
{Examples}:
ejs -m $ ./test/fixtures/user.ejs -f ./user_data.json
ejs -m $ ./test/fixtures/user.ejs name=Lerxst
ejs -p [ -c ] ./template_file.ejs -o ./output.html
ejs -n -l _ ./some_template.ejs -f ./data_file.json
ejs -w ./template_with_whitspace.ejs -o ./output_file.html