more
This commit is contained in:
parent
fa13ba83d7
commit
fe70fae95f
1
.yarnrc.yml
Normal file
1
.yarnrc.yml
Normal file
@ -0,0 +1 @@
|
||||
nodeLinker: node-modules
|
@ -1 +0,0 @@
|
||||
<h1>Heading</h1>
|
@ -1,2 +0,0 @@
|
||||
<!doctype html><title>abs3nt.dev</title>
|
||||
<p>hello i am abs3nt</p>
|
8
eleventy.config.js
Normal file
8
eleventy.config.js
Normal file
@ -0,0 +1,8 @@
|
||||
module.exports = function (eleventyConfig) {
|
||||
return {
|
||||
dir: {
|
||||
input: "src",
|
||||
output: "dist",
|
||||
},
|
||||
};
|
||||
};
|
@ -1,2 +0,0 @@
|
||||
<!doctype html><title>abs3nt.dev</title>
|
||||
<p>hello i am abs3nt</p>
|
1
node_modules/.bin/acorn
generated
vendored
Symbolic link
1
node_modules/.bin/acorn
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../acorn/bin/acorn
|
1
node_modules/.bin/cssesc
generated
vendored
Symbolic link
1
node_modules/.bin/cssesc
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../cssesc/bin/cssesc
|
1
node_modules/.bin/dev-ip
generated
vendored
Symbolic link
1
node_modules/.bin/dev-ip
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../dev-ip/lib/dev-ip.js
|
1
node_modules/.bin/ejs
generated
vendored
Symbolic link
1
node_modules/.bin/ejs
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../ejs/bin/cli.js
|
1
node_modules/.bin/eleventy
generated
vendored
Symbolic link
1
node_modules/.bin/eleventy
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../@11ty/eleventy/cmd.js
|
1
node_modules/.bin/eleventy-dev-server
generated
vendored
Symbolic link
1
node_modules/.bin/eleventy-dev-server
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../@11ty/eleventy-dev-server/cmd.js
|
1
node_modules/.bin/errno
generated
vendored
Symbolic link
1
node_modules/.bin/errno
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../errno/cli.js
|
1
node_modules/.bin/esparse
generated
vendored
Symbolic link
1
node_modules/.bin/esparse
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../esprima/bin/esparse.js
|
1
node_modules/.bin/esvalidate
generated
vendored
Symbolic link
1
node_modules/.bin/esvalidate
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../esprima/bin/esvalidate.js
|
1
node_modules/.bin/handlebars
generated
vendored
Symbolic link
1
node_modules/.bin/handlebars
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../handlebars/bin/handlebars
|
1
node_modules/.bin/jake
generated
vendored
Symbolic link
1
node_modules/.bin/jake
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../jake/bin/cli.js
|
1
node_modules/.bin/jiti
generated
vendored
Symbolic link
1
node_modules/.bin/jiti
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../jiti/bin/jiti.js
|
1
node_modules/.bin/js-yaml
generated
vendored
Symbolic link
1
node_modules/.bin/js-yaml
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../js-yaml/bin/js-yaml.js
|
1
node_modules/.bin/liquid
generated
vendored
Symbolic link
1
node_modules/.bin/liquid
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../liquidjs/bin/liquid.js
|
1
node_modules/.bin/liquidjs
generated
vendored
Symbolic link
1
node_modules/.bin/liquidjs
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../liquidjs/bin/liquid.js
|
1
node_modules/.bin/markdown-it
generated
vendored
Symbolic link
1
node_modules/.bin/markdown-it
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../markdown-it/bin/markdown-it.js
|
1
node_modules/.bin/mime
generated
vendored
Symbolic link
1
node_modules/.bin/mime
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../mime/cli.js
|
1
node_modules/.bin/mkdirp
generated
vendored
Symbolic link
1
node_modules/.bin/mkdirp
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../mkdirp/bin/cmd.js
|
1
node_modules/.bin/mustache
generated
vendored
Symbolic link
1
node_modules/.bin/mustache
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../mustache/bin/mustache
|
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../nanoid/bin/nanoid.cjs
|
1
node_modules/.bin/node-which
generated
vendored
Symbolic link
1
node_modules/.bin/node-which
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../which/bin/node-which
|
1
node_modules/.bin/nunjucks-precompile
generated
vendored
Symbolic link
1
node_modules/.bin/nunjucks-precompile
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../nunjucks/bin/precompile
|
1
node_modules/.bin/parser
generated
vendored
Symbolic link
1
node_modules/.bin/parser
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../@babel/parser/bin/babel-parser.js
|
1
node_modules/.bin/resolve
generated
vendored
Symbolic link
1
node_modules/.bin/resolve
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../resolve/bin/resolve
|
1
node_modules/.bin/rimraf
generated
vendored
Symbolic link
1
node_modules/.bin/rimraf
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../rimraf/bin.js
|
1
node_modules/.bin/semver
generated
vendored
Symbolic link
1
node_modules/.bin/semver
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../semver/bin/semver.js
|
1
node_modules/.bin/sucrase
generated
vendored
Symbolic link
1
node_modules/.bin/sucrase
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../sucrase/bin/sucrase
|
1
node_modules/.bin/sucrase-node
generated
vendored
Symbolic link
1
node_modules/.bin/sucrase-node
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../sucrase/bin/sucrase-node
|
1
node_modules/.bin/tailwind
generated
vendored
Symbolic link
1
node_modules/.bin/tailwind
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../tailwindcss/lib/cli.js
|
1
node_modules/.bin/tailwindcss
generated
vendored
Symbolic link
1
node_modules/.bin/tailwindcss
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../tailwindcss/lib/cli.js
|
1
node_modules/.bin/uglifyjs
generated
vendored
Symbolic link
1
node_modules/.bin/uglifyjs
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../uglify-js/bin/uglifyjs
|
1
node_modules/.bin/yaml
generated
vendored
Symbolic link
1
node_modules/.bin/yaml
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../yaml/bin.mjs
|
1169
node_modules/.yarn-state.yml
generated
vendored
Normal file
1169
node_modules/.yarn-state.yml
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
21
node_modules/@11ty/dependency-tree/LICENSE
generated
vendored
Normal file
21
node_modules/@11ty/dependency-tree/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Eleventy
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
92
node_modules/@11ty/dependency-tree/README.md
generated
vendored
Normal file
92
node_modules/@11ty/dependency-tree/README.md
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
# dependency-tree
|
||||
|
||||
Returns an unordered array of local paths to dependencies of a node JavaScript file (everything it or any of its dependencies `require`s).
|
||||
|
||||
Reduced feature (faster) alternative to the [`dependency-tree` package](https://www.npmjs.com/package/dependency-tree) that only works with stock node JS. This is used by Eleventy to find dependencies of a JavaScript file to watch for changes to re-run Eleventy’s build.
|
||||
|
||||
## Big Huge Caveat
|
||||
|
||||
⚠ A big caveat to this plugin is that it will require the file in order to build a dependency tree. So if your module has side effects and you don’t want it to execute—do not use this!
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install --save-dev @11ty/dependency-tree
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
* Ignores `node_modules`
|
||||
* Or, use `nodeModuleNamesOnly` to return a list of node_modules packages (added in v2.0.0)
|
||||
* Ignores Node’s built-ins (e.g. `path`)
|
||||
* Handles circular dependencies (Node does this too)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// my-file.js
|
||||
|
||||
// if my-local-dependency.js has dependencies, it will include those too
|
||||
const test = require("./my-local-dependency.js");
|
||||
|
||||
// ignored, is a built-in
|
||||
const path = require("path");
|
||||
```
|
||||
|
||||
```js
|
||||
const DependencyTree = require("@11ty/dependency-tree");
|
||||
|
||||
DependencyTree("./my-file.js");
|
||||
// returns ["./my-local-dependency.js"]
|
||||
```
|
||||
|
||||
### `allowNotFound`
|
||||
|
||||
```js
|
||||
const DependencyTree = require("@11ty/dependency-tree");
|
||||
|
||||
DependencyTree("./this-does-not-exist.js"); // throws an error
|
||||
|
||||
DependencyTree("./this-does-not-exist.js", { allowNotFound: true });
|
||||
// returns []
|
||||
```
|
||||
|
||||
### `nodeModuleNames`
|
||||
|
||||
(Added in v2.0.1) Controls whether or not node package names are included in the list of dependencies.
|
||||
|
||||
* `nodeModuleNames: "include"`: included alongside the local JS files.
|
||||
* `nodeModuleNames: "exclude"` (default): node module package names are excluded.
|
||||
* `nodeModuleNames: "only"`: only node module package names are returned.
|
||||
|
||||
```js
|
||||
// my-file.js:
|
||||
|
||||
require("./my-local-dependency.js");
|
||||
require("@11ty/eleventy");
|
||||
```
|
||||
|
||||
```js
|
||||
const DependencyTree = require("@11ty/dependency-tree");
|
||||
|
||||
DependencyTree("./my-file.js");
|
||||
// returns ["./my-local-dependency.js"]
|
||||
|
||||
DependencyTree("./my-file.js", { nodeModuleNames: "exclude" });
|
||||
// returns ["./my-local-dependency.js"]
|
||||
|
||||
DependencyTree("./my-file.js", { nodeModuleNames: "include" });
|
||||
// returns ["./my-local-dependency.js", "@11ty/eleventy"]
|
||||
|
||||
DependencyTree("./my-file.js", { nodeModuleNames: "only" });
|
||||
// returns ["@11ty/eleventy"]
|
||||
```
|
||||
|
||||
#### (Deprecated) `nodeModuleNamesOnly`
|
||||
|
||||
(Added in v2.0.0) Changed to use `nodeModuleNames` option instead. Backwards compatibility is maintained automatically.
|
||||
|
||||
* `nodeModuleNamesOnly: false` is mapped to `nodeModuleNames: "exclude"`
|
||||
* `nodeModuleNamesOnly: true` is mapped to `nodeModuleNames: "only"`
|
||||
|
||||
If both `nodeModuleNamesOnly` and `nodeModuleNames` are included in options, `nodeModuleNames` takes precedence.
|
120
node_modules/@11ty/dependency-tree/main.js
generated
vendored
Normal file
120
node_modules/@11ty/dependency-tree/main.js
generated
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
const path = require("path");
|
||||
|
||||
function getAbsolutePath(filename) {
|
||||
let normalizedFilename = path.normalize(filename); // removes dot slash
|
||||
let hasDotSlash = filename.startsWith("./");
|
||||
return hasDotSlash ? path.join(path.resolve("."), normalizedFilename) : normalizedFilename;
|
||||
}
|
||||
|
||||
function getRelativePath(filename) {
|
||||
let normalizedFilename = path.normalize(filename); // removes dot slash
|
||||
let workingDirectory = path.resolve(".");
|
||||
let result = "./" + (normalizedFilename.startsWith(workingDirectory) ? normalizedFilename.substr(workingDirectory.length + 1) : normalizedFilename);
|
||||
return result;
|
||||
}
|
||||
|
||||
function getNodeModuleName(filename) {
|
||||
let foundNodeModules = false;
|
||||
let moduleName = [];
|
||||
|
||||
let s = filename.split(path.sep);
|
||||
for(let entry of s) {
|
||||
if(foundNodeModules) {
|
||||
moduleName.push(entry);
|
||||
if(!entry.startsWith("@")) {
|
||||
return moduleName.join("/");
|
||||
}
|
||||
}
|
||||
|
||||
if(entry === "node_modules") {
|
||||
foundNodeModules = true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* unordered */
|
||||
function getDependenciesFor(filename, avoidCircular, optionsArg = {}) {
|
||||
// backwards compatibility with `nodeModuleNamesOnly` boolean option
|
||||
// Using `nodeModuleNames` property moving forward
|
||||
if(("nodeModuleNamesOnly" in optionsArg) && !("nodeModuleNames" in optionsArg)) {
|
||||
if(optionsArg.nodeModuleNamesOnly === true) {
|
||||
optionsArg.nodeModuleNames = "only";
|
||||
}
|
||||
if(optionsArg.nodeModuleNamesOnly === false) {
|
||||
optionsArg.nodeModuleNames = "exclude";
|
||||
}
|
||||
}
|
||||
|
||||
let options = Object.assign({
|
||||
allowNotFound: false,
|
||||
nodeModuleNames: "exclude", // also "include" or "only"
|
||||
}, optionsArg);
|
||||
let absoluteFilename = getAbsolutePath(filename)
|
||||
|
||||
try {
|
||||
require(absoluteFilename);
|
||||
} catch(e) {
|
||||
if(e.code === "MODULE_NOT_FOUND" && options.allowNotFound) {
|
||||
// do nothing
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let mod;
|
||||
for(let entry in require.cache) {
|
||||
if(entry === absoluteFilename) {
|
||||
mod = require.cache[entry];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let dependencies = new Set();
|
||||
|
||||
if(!mod) {
|
||||
if(!options.allowNotFound) {
|
||||
throw new Error(`Could not find ${filename} in @11ty/dependency-tree`);
|
||||
}
|
||||
} else {
|
||||
let relativeFilename = getRelativePath(mod.filename);
|
||||
if(!avoidCircular) {
|
||||
avoidCircular = {};
|
||||
} else if(options.nodeModuleNames !== "only") {
|
||||
dependencies.add(relativeFilename);
|
||||
}
|
||||
|
||||
avoidCircular[relativeFilename] = true;
|
||||
|
||||
if(mod.children) {
|
||||
for(let child of mod.children) {
|
||||
let relativeChildFilename = getRelativePath(child.filename);
|
||||
let nodeModuleName = getNodeModuleName(child.filename);
|
||||
|
||||
if(options.nodeModuleNames !== "exclude" && nodeModuleName) {
|
||||
dependencies.add(nodeModuleName);
|
||||
}
|
||||
// Add dependencies of this dependency (not top level node_modules)
|
||||
if(nodeModuleName === false) {
|
||||
if(!dependencies.has(relativeChildFilename) && // avoid infinite looping with circular deps
|
||||
!avoidCircular[relativeChildFilename] ) {
|
||||
for(let dependency of getDependenciesFor(relativeChildFilename, avoidCircular, options)) {
|
||||
dependencies.add(dependency);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
function getCleanDependencyListFor(filename, options = {}) {
|
||||
return Array.from( getDependenciesFor(filename, null, options) );
|
||||
}
|
||||
|
||||
module.exports = getCleanDependencyListFor;
|
||||
module.exports.getNodeModuleName = getNodeModuleName;
|
30
node_modules/@11ty/dependency-tree/package.json
generated
vendored
Normal file
30
node_modules/@11ty/dependency-tree/package.json
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "@11ty/dependency-tree",
|
||||
"version": "2.0.1",
|
||||
"description": "Finds all JavaScript require dependencies from a filename.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "npx ava"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/11ty/eleventy-dependency-tree.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Zach Leatherman",
|
||||
"email": "zach@zachleat.com",
|
||||
"url": "https://zachleat.com/"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0"
|
||||
},
|
||||
"ava": {
|
||||
"files": [
|
||||
"./test/*.js"
|
||||
],
|
||||
"ignoredByWatcher": [
|
||||
"./test/stubs/**"
|
||||
]
|
||||
}
|
||||
}
|
92
node_modules/@11ty/dependency-tree/test/mainTest.js
generated
vendored
Normal file
92
node_modules/@11ty/dependency-tree/test/mainTest.js
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
const test = require("ava");
|
||||
const DependencyTree = require("../main.js");
|
||||
|
||||
test("Nonexistent", t => {
|
||||
t.throws(() => {
|
||||
DependencyTree("./test/stubs/thisdoesnotexist.js");
|
||||
});
|
||||
});
|
||||
|
||||
test("Allow not Found", t => {
|
||||
DependencyTree("./test/stubs/thisdoesnotexist.js", { allowNotFound: true });
|
||||
t.true(true);
|
||||
});
|
||||
|
||||
test("Not require()’d before calling", t => {
|
||||
DependencyTree("./test/stubs/parent/parent.js");
|
||||
t.true(true);
|
||||
});
|
||||
|
||||
test("simple.js", t => {
|
||||
t.deepEqual(DependencyTree("./test/stubs/simple.js"), ["./test/stubs/simple2.js"]);
|
||||
});
|
||||
|
||||
test("parent.js", t => {
|
||||
t.deepEqual(DependencyTree("./test/stubs/parent/parent.js").sort(), [
|
||||
"./test/stubs/parent/child1.js",
|
||||
"./test/stubs/parent/child2.js",
|
||||
"./test/stubs/parent/grandchild.js",
|
||||
"./test/stubs/parent/greatgrandchild.js"
|
||||
]);
|
||||
|
||||
t.deepEqual(DependencyTree("./test/stubs/parent/child1.js").sort(), [
|
||||
"./test/stubs/parent/grandchild.js",
|
||||
"./test/stubs/parent/greatgrandchild.js"
|
||||
]);
|
||||
|
||||
t.deepEqual(DependencyTree("./test/stubs/parent/child2.js").sort(), [
|
||||
"./test/stubs/parent/grandchild.js",
|
||||
"./test/stubs/parent/greatgrandchild.js"
|
||||
]);
|
||||
|
||||
t.deepEqual(DependencyTree("./test/stubs/parent/grandchild.js"), [
|
||||
"./test/stubs/parent/greatgrandchild.js"
|
||||
]);
|
||||
|
||||
t.deepEqual(DependencyTree("./test/stubs/parent/greatgrandchild.js"), []);
|
||||
});
|
||||
|
||||
test("circular", t => {
|
||||
t.deepEqual(DependencyTree("./test/stubs/circular/circle-a.js").sort(), [
|
||||
"./test/stubs/circular/circle-b.js",
|
||||
"./test/stubs/circular/circle-c.js"]);
|
||||
});
|
||||
|
||||
test("another circular", t => {
|
||||
t.deepEqual(DependencyTree("./test/stubs/circular2/circle-a.js").sort(), [
|
||||
"./test/stubs/circular2/circle-b.js",
|
||||
"./test/stubs/circular2/circle-c.js"
|
||||
]);
|
||||
});
|
||||
|
||||
test("dot dot (dependency is up a directory)", t => {
|
||||
t.deepEqual(DependencyTree("./test/stubs/dotdot/dotdot.js").sort(), [
|
||||
"./test/stubs/simple2.js"
|
||||
]);
|
||||
});
|
||||
|
||||
test("only node_modules", t => {
|
||||
t.deepEqual(DependencyTree("./test/stubs/uses_node_modules.js", {
|
||||
nodeModuleNamesOnly: true
|
||||
}).sort(), [
|
||||
"@sindresorhus/is",
|
||||
"lodash",
|
||||
]);
|
||||
});
|
||||
|
||||
test("getNodeModuleName", t => {
|
||||
t.is(DependencyTree.getNodeModuleName("./eleventy-dependency-tree/node_modules/lodash/lodash.js"), "lodash");
|
||||
t.is(DependencyTree.getNodeModuleName("./eleventy-dependency-tree/node_modules/@sindresorhus/is/dist/index.js"), "@sindresorhus/is");
|
||||
});
|
||||
|
||||
test("both files and node_modules", t => {
|
||||
t.deepEqual(DependencyTree("./test/stubs/uses_node_modules.js", {
|
||||
nodeModuleNames: "include"
|
||||
}).sort(), [
|
||||
"./test/stubs/parent/child1.js",
|
||||
"./test/stubs/parent/grandchild.js",
|
||||
"./test/stubs/parent/greatgrandchild.js",
|
||||
"@sindresorhus/is",
|
||||
"lodash",
|
||||
]);
|
||||
});
|
1
node_modules/@11ty/dependency-tree/test/stubs/circular/circle-a.js
generated
vendored
Normal file
1
node_modules/@11ty/dependency-tree/test/stubs/circular/circle-a.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
const circleB = require("./circle-b");
|
1
node_modules/@11ty/dependency-tree/test/stubs/circular/circle-b.js
generated
vendored
Normal file
1
node_modules/@11ty/dependency-tree/test/stubs/circular/circle-b.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
const circleC = require("./circle-c");
|
1
node_modules/@11ty/dependency-tree/test/stubs/circular/circle-c.js
generated
vendored
Normal file
1
node_modules/@11ty/dependency-tree/test/stubs/circular/circle-c.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
const circleA = require("./circle-a");
|
1
node_modules/@11ty/dependency-tree/test/stubs/circular2/circle-a.js
generated
vendored
Normal file
1
node_modules/@11ty/dependency-tree/test/stubs/circular2/circle-a.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
const circleB = require("./circle-b");
|
1
node_modules/@11ty/dependency-tree/test/stubs/circular2/circle-b.js
generated
vendored
Normal file
1
node_modules/@11ty/dependency-tree/test/stubs/circular2/circle-b.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
const circleC = require("./circle-c");
|
1
node_modules/@11ty/dependency-tree/test/stubs/circular2/circle-c.js
generated
vendored
Normal file
1
node_modules/@11ty/dependency-tree/test/stubs/circular2/circle-c.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
const circleA = require("./circle-b");
|
1
node_modules/@11ty/dependency-tree/test/stubs/dotdot/dotdot.js
generated
vendored
Normal file
1
node_modules/@11ty/dependency-tree/test/stubs/dotdot/dotdot.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
const test = require("../simple2")
|
4
node_modules/@11ty/dependency-tree/test/stubs/parent/child1.js
generated
vendored
Normal file
4
node_modules/@11ty/dependency-tree/test/stubs/parent/child1.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
const test2 = require("./grandchild");
|
||||
const lodash = require("lodash");
|
||||
|
||||
module.exports = {};
|
3
node_modules/@11ty/dependency-tree/test/stubs/parent/child2.js
generated
vendored
Normal file
3
node_modules/@11ty/dependency-tree/test/stubs/parent/child2.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
const test = require("./grandchild");
|
||||
|
||||
module.exports = {};
|
2
node_modules/@11ty/dependency-tree/test/stubs/parent/grandchild.js
generated
vendored
Normal file
2
node_modules/@11ty/dependency-tree/test/stubs/parent/grandchild.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
const test = require("./greatgrandchild.js");
|
||||
module.exports = {};
|
0
node_modules/@11ty/dependency-tree/test/stubs/parent/greatgrandchild.js
generated
vendored
Normal file
0
node_modules/@11ty/dependency-tree/test/stubs/parent/greatgrandchild.js
generated
vendored
Normal file
5
node_modules/@11ty/dependency-tree/test/stubs/parent/parent.js
generated
vendored
Normal file
5
node_modules/@11ty/dependency-tree/test/stubs/parent/parent.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
const path = require("path");
|
||||
const test = require("./child1");
|
||||
const test2 = require("./child2");
|
||||
|
||||
module.exports = {};
|
1
node_modules/@11ty/dependency-tree/test/stubs/simple.js
generated
vendored
Normal file
1
node_modules/@11ty/dependency-tree/test/stubs/simple.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
const test = require("./simple2");
|
0
node_modules/@11ty/dependency-tree/test/stubs/simple2.js
generated
vendored
Normal file
0
node_modules/@11ty/dependency-tree/test/stubs/simple2.js
generated
vendored
Normal file
4
node_modules/@11ty/dependency-tree/test/stubs/uses_node_modules.js
generated
vendored
Normal file
4
node_modules/@11ty/dependency-tree/test/stubs/uses_node_modules.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
const is = require("@sindresorhus/is");
|
||||
const child1 = require("./parent/child1.js");
|
||||
|
||||
module.exports = {};
|
56
node_modules/@11ty/eleventy-dev-server/README.md
generated
vendored
Normal file
56
node_modules/@11ty/eleventy-dev-server/README.md
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
<p align="center"><img src="https://www.11ty.dev/img/logo-github.svg" width="200" height="200" alt="11ty Logo"></p>
|
||||
|
||||
# eleventy-dev-server 🕚⚡️🎈🐀
|
||||
|
||||
A minimal, modern, generic, hot-reloading local web server to help web developers.
|
||||
|
||||
## ➡ [Documentation](https://www.11ty.dev/docs/watch-serve/#eleventy-dev-server)
|
||||
|
||||
- Please star [Eleventy on GitHub](https://github.com/11ty/eleventy/)!
|
||||
- Follow us on Twitter [@eleven_ty](https://twitter.com/eleven_ty)
|
||||
- Support [11ty on Open Collective](https://opencollective.com/11ty)
|
||||
- [11ty on npm](https://www.npmjs.com/org/11ty)
|
||||
- [11ty on GitHub](https://github.com/11ty)
|
||||
|
||||
[![npm Version](https://img.shields.io/npm/v/@11ty/eleventy-dev-server.svg?style=for-the-badge)](https://www.npmjs.com/package/@11ty/eleventy-dev-server)
|
||||
|
||||
## Installation
|
||||
|
||||
This is bundled with `@11ty/eleventy` (and you do not need to install it separately) in Eleventy v2.0.
|
||||
|
||||
## CLI
|
||||
|
||||
Eleventy Dev Server now also includes a CLI. The CLI is for **standalone** (non-Eleventy) use only: separate installation is unnecessary if you’re using this server with `@11ty/eleventy`.
|
||||
|
||||
```sh
|
||||
npm install -g @11ty/eleventy-dev-server
|
||||
|
||||
# Alternatively, install locally into your project
|
||||
npm install @11ty/eleventy-dev-server
|
||||
```
|
||||
|
||||
This package requires Node 14 or newer.
|
||||
|
||||
### CLI Usage
|
||||
|
||||
```sh
|
||||
# Serve the current directory
|
||||
npx @11ty/eleventy-dev-server
|
||||
|
||||
# Serve a different subdirectory (also aliased as --input)
|
||||
npx @11ty/eleventy-dev-server --dir=_site
|
||||
|
||||
# Disable the `domdiff` feature
|
||||
npx @11ty/eleventy-dev-server --domdiff=false
|
||||
|
||||
# Full command list in the Help
|
||||
npx @11ty/eleventy-dev-server --help
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
```
|
||||
npm run test
|
||||
```
|
||||
|
||||
- We use the [ava JavaScript test runner](https://github.com/avajs/ava) ([Assertions documentation](https://github.com/avajs/ava/blob/master/docs/03-assertions.md))
|
92
node_modules/@11ty/eleventy-dev-server/cli.js
generated
vendored
Normal file
92
node_modules/@11ty/eleventy-dev-server/cli.js
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
const chokidar = require("chokidar");
|
||||
const fs = require("fs");
|
||||
|
||||
const pkg = require("./package.json");
|
||||
const EleventyDevServer = require("./server.js");
|
||||
|
||||
const Logger = {
|
||||
info: function(...args) {
|
||||
console.log( "[11ty/eleventy-dev-server]", ...args );
|
||||
},
|
||||
error: function(...args) {
|
||||
console.error( "[11ty/eleventy-dev-server]", ...args );
|
||||
},
|
||||
fatal: function(...args) {
|
||||
Logger.error(...args);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
};
|
||||
|
||||
Logger.log = Logger.info;
|
||||
|
||||
class Cli {
|
||||
static getVersion() {
|
||||
return pkg.version;
|
||||
}
|
||||
|
||||
static getHelp() {
|
||||
return `Usage:
|
||||
|
||||
eleventy-dev-server
|
||||
eleventy-dev-server --dir=_site
|
||||
eleventy-dev-server --port=3000
|
||||
|
||||
Arguments:
|
||||
|
||||
--version
|
||||
|
||||
--dir=.
|
||||
Directory to serve (default: \`.\`)
|
||||
|
||||
--input (alias for --dir)
|
||||
|
||||
--port=8080
|
||||
Run the web server on this port (default: \`8080\`)
|
||||
Will autoincrement if already in use.
|
||||
|
||||
--domdiff (enabled, default)
|
||||
--domdiff=false (disabled)
|
||||
Apply HTML changes without a full page reload.
|
||||
|
||||
--help`;
|
||||
}
|
||||
|
||||
static getDefaultOptions() {
|
||||
return {
|
||||
port: "8080",
|
||||
input: ".",
|
||||
domDiff: true,
|
||||
}
|
||||
}
|
||||
|
||||
async serve(options = {}) {
|
||||
this.options = Object.assign(Cli.getDefaultOptions(), options);
|
||||
|
||||
this.server = EleventyDevServer.getServer("eleventy-dev-server-cli", this.options.input, {
|
||||
// TODO allow server configuration extensions
|
||||
showVersion: true,
|
||||
logger: Logger,
|
||||
domDiff: this.options.domDiff,
|
||||
|
||||
// CLI watches all files in the folder by default
|
||||
// this is different from Eleventy usage!
|
||||
watch: [ this.options.input ],
|
||||
});
|
||||
|
||||
this.server.serve(this.options.port);
|
||||
|
||||
// TODO? send any errors here to the server too
|
||||
// with server.sendError({ error });
|
||||
}
|
||||
|
||||
close() {
|
||||
if(this.server) {
|
||||
this.server.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Logger,
|
||||
Cli
|
||||
}
|
259
node_modules/@11ty/eleventy-dev-server/client/reload-client.js
generated
vendored
Normal file
259
node_modules/@11ty/eleventy-dev-server/client/reload-client.js
generated
vendored
Normal file
@ -0,0 +1,259 @@
|
||||
class Util {
|
||||
static pad(num, digits = 2) {
|
||||
let zeroes = new Array(digits + 1).join(0);
|
||||
return `${zeroes}${num}`.slice(-1 * digits);
|
||||
}
|
||||
|
||||
static log(message) {
|
||||
Util.output("log", message);
|
||||
}
|
||||
static error(message, error) {
|
||||
Util.output("error", message, error);
|
||||
}
|
||||
static output(type, ...messages) {
|
||||
let now = new Date();
|
||||
let date = `${Util.pad(now.getUTCHours())}:${Util.pad(
|
||||
now.getUTCMinutes()
|
||||
)}:${Util.pad(now.getUTCSeconds())}.${Util.pad(
|
||||
now.getUTCMilliseconds(),
|
||||
3
|
||||
)}`;
|
||||
console[type](`[11ty][${date} UTC]`, ...messages);
|
||||
}
|
||||
|
||||
static capitalize(word) {
|
||||
return word.substr(0, 1).toUpperCase() + word.substr(1);
|
||||
}
|
||||
|
||||
static matchRootAttributes(htmlContent) {
|
||||
// Workaround for morphdom bug with attributes on <html> https://github.com/11ty/eleventy-dev-server/issues/6
|
||||
// Note also `childrenOnly: true` above
|
||||
const parser = new DOMParser();
|
||||
let parsed = parser.parseFromString(htmlContent, "text/html");
|
||||
let parsedDoc = parsed.documentElement;
|
||||
let newAttrs = parsedDoc.getAttributeNames();
|
||||
|
||||
let docEl = document.documentElement;
|
||||
// Remove old
|
||||
let removedAttrs = docEl.getAttributeNames().filter(name => !newAttrs.includes(name));
|
||||
for(let attr of removedAttrs) {
|
||||
docEl.removeAttribute(attr);
|
||||
}
|
||||
|
||||
// Add new
|
||||
for(let attr of newAttrs) {
|
||||
docEl.setAttribute(attr, parsedDoc.getAttribute(attr));
|
||||
}
|
||||
}
|
||||
|
||||
static isEleventyLinkNodeMatch(from, to) {
|
||||
// Issue #18 https://github.com/11ty/eleventy-dev-server/issues/18
|
||||
// Don’t update a <link> if the _11ty searchParam is the only thing that’s different
|
||||
if(from.tagName !== "LINK" || to.tagName !== "LINK") {
|
||||
return false;
|
||||
}
|
||||
|
||||
let oldWithoutHref = from.cloneNode();
|
||||
let newWithoutHref = to.cloneNode();
|
||||
|
||||
oldWithoutHref.removeAttribute("href");
|
||||
newWithoutHref.removeAttribute("href");
|
||||
|
||||
// if all other attributes besides href match
|
||||
if(!oldWithoutHref.isEqualNode(newWithoutHref)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let oldUrl = new URL(from.href);
|
||||
let newUrl = new URL(to.href);
|
||||
|
||||
// morphdom wants to force href="style.css?_11ty" => href="style.css"
|
||||
let isErasing = oldUrl.searchParams.has("_11ty") && !newUrl.searchParams.has("_11ty");
|
||||
if(!isErasing) {
|
||||
// not a match if _11ty has a new value (not being erased)
|
||||
return false;
|
||||
}
|
||||
|
||||
oldUrl.searchParams.set("_11ty", "");
|
||||
newUrl.searchParams.set("_11ty", "");
|
||||
|
||||
// is a match if erasing and the rest of the href matches too
|
||||
return oldUrl.toString() === newUrl.toString();
|
||||
}
|
||||
|
||||
// https://github.com/patrick-steele-idem/morphdom/issues/178#issuecomment-652562769
|
||||
static runScript(source, target) {
|
||||
let script = document.createElement('script');
|
||||
|
||||
//copy over the attributes
|
||||
for(let attr of [...source.attributes]) {
|
||||
script.setAttribute(attr.nodeName ,attr.nodeValue);
|
||||
}
|
||||
|
||||
script.innerHTML = source.innerHTML;
|
||||
(target || source).replaceWith(script);
|
||||
}
|
||||
}
|
||||
|
||||
class EleventyReload {
|
||||
constructor() {
|
||||
this.connectionMessageShown = false;
|
||||
this.reconnectEventCallback = this.reconnect.bind(this);
|
||||
}
|
||||
|
||||
init(options = {}) {
|
||||
if (!("WebSocket" in window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let { protocol, host } = new URL(document.location.href);
|
||||
|
||||
// works with http (ws) and https (wss)
|
||||
let websocketProtocol = protocol.replace("http", "ws");
|
||||
|
||||
let socket = new WebSocket(`${websocketProtocol}//${host}`);
|
||||
|
||||
socket.addEventListener("message", async (event) => {
|
||||
try {
|
||||
let data = JSON.parse(event.data);
|
||||
// Util.log( JSON.stringify(data, null, 2) );
|
||||
|
||||
let { type } = data;
|
||||
|
||||
if (type === "eleventy.reload") {
|
||||
await this.onreload(data);
|
||||
} else if (type === "eleventy.msg") {
|
||||
Util.log(`${data.message}`);
|
||||
} else if (type === "eleventy.error") {
|
||||
// Log Eleventy build errors
|
||||
// Extra parsing for Node Error objects
|
||||
let e = JSON.parse(data.error);
|
||||
Util.error(`Build error: ${e.message}`, e);
|
||||
} else if (type === "eleventy.status") {
|
||||
// Full page reload on initial reconnect
|
||||
if (data.status === "connected" && options.mode === "reconnect") {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
if(data.status === "connected") {
|
||||
// With multiple windows, only show one connection message
|
||||
if(!this.isConnected) {
|
||||
Util.log(Util.capitalize(data.status));
|
||||
}
|
||||
|
||||
this.connectionMessageShown = true;
|
||||
} else {
|
||||
if(data.status === "disconnected") {
|
||||
this.addReconnectListeners();
|
||||
}
|
||||
|
||||
Util.log(Util.capitalize(data.status));
|
||||
}
|
||||
} else {
|
||||
Util.log("Unknown event type", data);
|
||||
}
|
||||
} catch (e) {
|
||||
Util.error(`Error parsing ${event.data}: ${e.message}`, e);
|
||||
}
|
||||
});
|
||||
|
||||
socket.addEventListener("open", () => {
|
||||
// no reconnection when the connect is already open
|
||||
this.removeReconnectListeners();
|
||||
});
|
||||
|
||||
socket.addEventListener("close", () => {
|
||||
this.connectionMessageShown = false;
|
||||
this.addReconnectListeners();
|
||||
});
|
||||
}
|
||||
|
||||
reconnect() {
|
||||
Util.log( "Reconnecting…" );
|
||||
this.init({ mode: "reconnect" });
|
||||
}
|
||||
|
||||
async onreload({ subtype, files, build }) {
|
||||
if (subtype === "css") {
|
||||
for (let link of document.querySelectorAll(`link[rel="stylesheet"]`)) {
|
||||
let url = new URL(link.href);
|
||||
url.searchParams.set("_11ty", Date.now());
|
||||
link.href = url.toString();
|
||||
}
|
||||
Util.log(`CSS updated without page reload.`);
|
||||
} else {
|
||||
let morphed = false;
|
||||
|
||||
try {
|
||||
if((build.templates || []).length > 0) {
|
||||
// Important: using `./` in `./morphdom.js` allows the special `.11ty` folder to be changed upstream
|
||||
const { default: morphdom } = await import(`./morphdom.js`);
|
||||
|
||||
// { url, inputPath, content }
|
||||
for (let template of build.templates || []) {
|
||||
if (template.url === document.location.pathname) {
|
||||
// Importantly, if this does not match but is still relevant (layout/include/etc), a full reload happens below. This could be improved.
|
||||
if ((files || []).includes(template.inputPath)) {
|
||||
// Notable limitation: this won’t re-run script elements or JavaScript page lifecycle events (load/DOMContentLoaded)
|
||||
morphed = true;
|
||||
|
||||
morphdom(document.documentElement, template.content, {
|
||||
childrenOnly: true,
|
||||
onBeforeElUpdated: function (fromEl, toEl) {
|
||||
if (fromEl.nodeName === "SCRIPT" && toEl.nodeName === "SCRIPT") {
|
||||
Util.runScript(toEl, fromEl);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Speed-up trick from morphdom docs
|
||||
// https://dom.spec.whatwg.org/#concept-node-equals
|
||||
if (fromEl.isEqualNode(toEl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Util.isEleventyLinkNodeMatch(fromEl, toEl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
onNodeAdded: function (node) {
|
||||
if (node.nodeName === 'SCRIPT') {
|
||||
Util.runScript(node);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Util.matchRootAttributes(template.content);
|
||||
Util.log(`HTML delta applied without page reload.`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
Util.error( "Morphdom error", e );
|
||||
}
|
||||
|
||||
if (!morphed) {
|
||||
Util.log(`Page reload initiated.`);
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addReconnectListeners() {
|
||||
this.removeReconnectListeners();
|
||||
|
||||
window.addEventListener("focus", this.reconnectEventCallback);
|
||||
window.addEventListener("visibilitychange", this.reconnectEventCallback);
|
||||
}
|
||||
|
||||
removeReconnectListeners() {
|
||||
window.removeEventListener("focus", this.reconnectEventCallback);
|
||||
window.removeEventListener("visibilitychange", this.reconnectEventCallback);
|
||||
}
|
||||
}
|
||||
|
||||
let reloader = new EleventyReload();
|
||||
reloader.init();
|
69
node_modules/@11ty/eleventy-dev-server/cmd.js
generated
vendored
Executable file
69
node_modules/@11ty/eleventy-dev-server/cmd.js
generated
vendored
Executable file
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const pkg = require("./package.json");
|
||||
|
||||
// Node check
|
||||
require("please-upgrade-node")(pkg, {
|
||||
message: function (requiredVersion) {
|
||||
return (
|
||||
"eleventy-dev-server requires Node " +
|
||||
requiredVersion +
|
||||
". You will need to upgrade Node!"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
const { Logger, Cli } = require("./cli.js");
|
||||
|
||||
const debug = require("debug")("EleventyDevServer:cmd");
|
||||
|
||||
try {
|
||||
const argv = require("minimist")(process.argv.slice(2), {
|
||||
string: [
|
||||
"dir",
|
||||
"input", // alias for dir
|
||||
"port",
|
||||
],
|
||||
boolean: [
|
||||
"version",
|
||||
"help",
|
||||
"domdiff",
|
||||
],
|
||||
default: Cli.getDefaultOptions(),
|
||||
unknown: function (unknownArgument) {
|
||||
throw new Error(
|
||||
`We don’t know what '${unknownArgument}' is. Use --help to see the list of supported commands.`
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
debug("command: eleventy-dev-server %o", argv);
|
||||
|
||||
process.on("unhandledRejection", (error, promise) => {
|
||||
Logger.fatal("Unhandled rejection in promise:", promise, error);
|
||||
});
|
||||
process.on("uncaughtException", (error) => {
|
||||
Logger.fatal("Uncaught exception:", error);
|
||||
});
|
||||
|
||||
if (argv.version) {
|
||||
console.log(Cli.getVersion());
|
||||
} else if (argv.help) {
|
||||
console.log(Cli.getHelp());
|
||||
} else {
|
||||
let cli = new Cli();
|
||||
|
||||
cli.serve({
|
||||
input: argv.dir || argv.input,
|
||||
port: argv.port,
|
||||
domDiff: argv.domdiff,
|
||||
});
|
||||
|
||||
process.on("SIGINT", () => {
|
||||
cli.close();
|
||||
process.exit();
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.fatal("Fatal Error:", e)
|
||||
}
|
56
node_modules/@11ty/eleventy-dev-server/package.json
generated
vendored
Normal file
56
node_modules/@11ty/eleventy-dev-server/package.json
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "@11ty/eleventy-dev-server",
|
||||
"version": "1.0.4",
|
||||
"description": "A minimal, modern, generic, hot-reloading local web server to help web developers.",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"test": "npx ava --verbose",
|
||||
"sample": "node cmd.js --input=test/stubs"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/11ty"
|
||||
},
|
||||
"bin": {
|
||||
"eleventy-dev-server": "./cmd.js"
|
||||
},
|
||||
"keywords": [
|
||||
"eleventy",
|
||||
"server",
|
||||
"cli"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"author": {
|
||||
"name": "Zach Leatherman",
|
||||
"email": "zachleatherman@gmail.com",
|
||||
"url": "https://zachleat.com/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/11ty/eleventy-dev-server.git"
|
||||
},
|
||||
"bugs": "https://github.com/11ty/eleventy-dev-server/issues",
|
||||
"homepage": "https://github.com/11ty/eleventy-dev-server/",
|
||||
"dependencies": {
|
||||
"@11ty/eleventy-utils": "^1.0.1",
|
||||
"chokidar": "^3.5.3",
|
||||
"debug": "^4.3.4",
|
||||
"dev-ip": "^1.0.1",
|
||||
"finalhandler": "^1.2.0",
|
||||
"mime": "^3.0.0",
|
||||
"minimist": "^1.2.8",
|
||||
"morphdom": "^2.7.0",
|
||||
"please-upgrade-node": "^3.2.0",
|
||||
"ssri": "^8.0.1",
|
||||
"ws": "^8.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^5.2.0"
|
||||
}
|
||||
}
|
807
node_modules/@11ty/eleventy-dev-server/server.js
generated
vendored
Normal file
807
node_modules/@11ty/eleventy-dev-server/server.js
generated
vendored
Normal file
@ -0,0 +1,807 @@
|
||||
const pkg = require("./package.json");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const finalhandler = require("finalhandler");
|
||||
const WebSocket = require("ws");
|
||||
const { WebSocketServer } = WebSocket;
|
||||
const mime = require("mime");
|
||||
const ssri = require("ssri");
|
||||
const devip = require("dev-ip");
|
||||
const chokidar = require("chokidar");
|
||||
const { TemplatePath } = require("@11ty/eleventy-utils");
|
||||
|
||||
const debug = require("debug")("EleventyDevServer");
|
||||
|
||||
const wrapResponse = require("./server/wrapResponse.js");
|
||||
|
||||
const DEFAULT_OPTIONS = {
|
||||
port: 8080,
|
||||
liveReload: true, // Enable live reload at all
|
||||
showAllHosts: false, // IP address based hosts (other than localhost)
|
||||
injectedScriptsFolder: ".11ty", // Change the name of the special folder used for injected scripts
|
||||
portReassignmentRetryCount: 10, // number of times to increment the port if in use
|
||||
https: {}, // `key` and `cert`, required for http/2 and https
|
||||
domDiff: true, // Use morphdom to apply DOM diffing delta updates to HTML
|
||||
showVersion: false, // Whether or not to show the server version on the command line.
|
||||
encoding: "utf-8", // Default file encoding
|
||||
pathPrefix: "/", // May be overridden by Eleventy, adds a virtual base directory to your project
|
||||
watch: [], // Globs to pass to separate dev server chokidar for watching
|
||||
aliases: {}, // Aliasing feature
|
||||
|
||||
// Logger (fancier one is injected by Eleventy)
|
||||
logger: {
|
||||
info: console.log,
|
||||
log: console.log,
|
||||
error: console.error,
|
||||
}
|
||||
}
|
||||
|
||||
class EleventyDevServer {
|
||||
static getServer(...args) {
|
||||
return new EleventyDevServer(...args);
|
||||
}
|
||||
|
||||
constructor(name, dir, options = {}) {
|
||||
debug("Creating new Dev Server instance.")
|
||||
this.name = name;
|
||||
this.normalizeOptions(options);
|
||||
|
||||
this.fileCache = {};
|
||||
// Directory to serve
|
||||
if(!dir) {
|
||||
throw new Error("Missing `dir` to serve.");
|
||||
}
|
||||
this.dir = dir;
|
||||
this.logger = this.options.logger;
|
||||
|
||||
if(this.options.watch.length > 0) {
|
||||
this.getWatcher();
|
||||
}
|
||||
}
|
||||
|
||||
normalizeOptions(options = {}) {
|
||||
this.options = Object.assign({}, DEFAULT_OPTIONS, options);
|
||||
|
||||
// better names for options https://github.com/11ty/eleventy-dev-server/issues/41
|
||||
if(options.folder !== undefined) {
|
||||
this.options.injectedScriptsFolder = options.folder;
|
||||
delete this.options.folder;
|
||||
}
|
||||
if(options.domdiff !== undefined) {
|
||||
this.options.domDiff = options.domdiff;
|
||||
delete this.options.domdiff;
|
||||
}
|
||||
if(options.enabled !== undefined) {
|
||||
this.options.liveReload = options.enabled;
|
||||
delete this.options.enabled;
|
||||
}
|
||||
|
||||
this.options.pathPrefix = this.cleanupPathPrefix(this.options.pathPrefix);
|
||||
}
|
||||
|
||||
get watcher() {
|
||||
if(!this._watcher) {
|
||||
debug("Watching %O", this.options.watch);
|
||||
// TODO if using Eleventy and `watch` option includes output folder (_site) this will trigger two update events!
|
||||
this._watcher = chokidar.watch(this.options.watch, {
|
||||
// TODO allow chokidar configuration extensions (or re-use the ones in Eleventy)
|
||||
|
||||
ignored: ["**/node_modules/**", ".git"],
|
||||
ignoreInitial: true,
|
||||
|
||||
// same values as Eleventy
|
||||
awaitWriteFinish: {
|
||||
stabilityThreshold: 150,
|
||||
pollInterval: 25,
|
||||
},
|
||||
});
|
||||
|
||||
this._watcher.on("change", (path) => {
|
||||
this.logger.log( `File changed: ${path} (skips build)` );
|
||||
this.reloadFiles([path]);
|
||||
});
|
||||
|
||||
this._watcher.on("add", (path) => {
|
||||
this.logger.log( `File added: ${path} (skips build)` );
|
||||
this.reloadFiles([path]);
|
||||
});
|
||||
}
|
||||
|
||||
return this._watcher;
|
||||
}
|
||||
|
||||
getWatcher() {
|
||||
return this.watcher;
|
||||
}
|
||||
|
||||
watchFiles(files) {
|
||||
if(Array.isArray(files)) {
|
||||
files = files.map(entry => TemplatePath.stripLeadingDotSlash(entry));
|
||||
|
||||
debug("Also watching %O", files);
|
||||
this.watcher.add(files);
|
||||
}
|
||||
}
|
||||
|
||||
cleanupPathPrefix(pathPrefix) {
|
||||
if(!pathPrefix || pathPrefix === "/") {
|
||||
return "/";
|
||||
}
|
||||
if(!pathPrefix.startsWith("/")) {
|
||||
pathPrefix = `/${pathPrefix}`
|
||||
}
|
||||
if(!pathPrefix.endsWith("/")) {
|
||||
pathPrefix = `${pathPrefix}/`;
|
||||
}
|
||||
return pathPrefix;
|
||||
}
|
||||
|
||||
// Allowed list of files that can be served from outside `dir`
|
||||
setAliases(aliases) {
|
||||
if(aliases) {
|
||||
this.passthroughAliases = aliases;
|
||||
debug( "Setting aliases (emulated passthrough copy) %O", aliases );
|
||||
}
|
||||
}
|
||||
|
||||
matchPassthroughAlias(url) {
|
||||
let aliases = Object.assign({}, this.options.aliases, this.passthroughAliases);
|
||||
for(let targetUrl in aliases) {
|
||||
if(!targetUrl) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let file = aliases[targetUrl];
|
||||
if(url.startsWith(targetUrl)) {
|
||||
let inputDirectoryPath = file + url.slice(targetUrl.length);
|
||||
|
||||
// e.g. addPassthroughCopy("img/") but <img src="/img/built/IdthKOzqFA-350.png">
|
||||
// generated by the image plugin (written to the output folder)
|
||||
// If they do not exist in the input directory, this will fallback to the output directory.
|
||||
if(fs.existsSync(inputDirectoryPath)) {
|
||||
return inputDirectoryPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
isFileInDirectory(dir, file) {
|
||||
let absoluteDir = TemplatePath.absolutePath(dir);
|
||||
let absoluteFile = TemplatePath.absolutePath(file);
|
||||
return absoluteFile.startsWith(absoluteDir);
|
||||
}
|
||||
|
||||
getOutputDirFilePath(filepath, filename = "") {
|
||||
let computedPath;
|
||||
if(filename === ".html") {
|
||||
// avoid trailing slash for filepath/.html requests
|
||||
let prefix = path.join(this.dir, filepath);
|
||||
if(prefix.endsWith(path.sep)) {
|
||||
prefix = prefix.substring(0, prefix.length - path.sep.length);
|
||||
}
|
||||
computedPath = prefix + filename;
|
||||
} else {
|
||||
computedPath = path.join(this.dir, filepath, filename);
|
||||
}
|
||||
|
||||
computedPath = decodeURIComponent(computedPath);
|
||||
|
||||
if(!filename) { // is a direct URL request (not an implicit .html or index.html add)
|
||||
let alias = this.matchPassthroughAlias(filepath);
|
||||
|
||||
if(alias) {
|
||||
if(!this.isFileInDirectory(path.resolve("."), alias)) {
|
||||
throw new Error("Invalid path");
|
||||
}
|
||||
|
||||
return alias;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the file is in the output path (error if folks try use `..` in the filepath)
|
||||
if(!this.isFileInDirectory(this.dir, computedPath)) {
|
||||
throw new Error("Invalid path");
|
||||
}
|
||||
|
||||
return computedPath;
|
||||
}
|
||||
|
||||
isOutputFilePathExists(rawPath) {
|
||||
return fs.existsSync(rawPath) && !TemplatePath.isDirectorySync(rawPath);
|
||||
}
|
||||
|
||||
/* Use conventions documented here https://www.zachleat.com/web/trailing-slash/
|
||||
* resource.html exists:
|
||||
* /resource matches
|
||||
* /resource/ redirects to /resource
|
||||
* resource/index.html exists:
|
||||