author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
699 | 19.12.2021 15:31:43 | 21,600 | 36fc4b74e2f17f3a5d229e1851ebdbf4a647383d | Add support for `compileOptions.permalink` functions in addExtension. Override just the permalink compilation with your own custom function. | [
{
"change_type": "MODIFY",
"old_path": "docs/meta-release.md",
"new_path": "docs/meta-release.md",
"diff": "-# ESM dependency list\n+# List of dependencies that went ESM\n- `lint-staged` ESM at 12.x\n- `@sindresorhus/slugify` ESM at 2.x\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -319,9 +319,9 @@ class TemplateContent {\n}\n// used by computed data or for permalink functions\n- async _renderFunction(fn, data) {\n+ async _renderFunction(fn, ...args) {\nlet mixins = Object.assign({}, this.config.javascriptFunctions);\n- let result = await fn.call(mixins, data);\n+ let result = await fn.call(mixins, ...args);\n// normalize Buffer away if returned from permalink\nif (Buffer.isBuffer(result)) {\n@@ -340,12 +340,30 @@ class TemplateContent {\n}\nasync renderPermalink(permalink, data) {\n- if (\n- typeof permalink === \"string\" &&\n- !this.engine.permalinkNeedsCompilation(permalink)\n- ) {\n+ if (typeof permalink === \"string\") {\n+ let permalinkCompilation =\n+ this.engine.permalinkNeedsCompilation(permalink);\n+ if (permalinkCompilation === false) {\nreturn permalink;\n}\n+\n+ if (permalinkCompilation && typeof permalinkCompilation === \"function\") {\n+ /* Usage:\n+ permalink: function(permalinkString, inputPath) {\n+ return async function(data) {\n+ return \"THIS IS MY RENDERED PERMALINK\";\n+ }\n+ }\n+ */\n+ let fn = await this._renderFunction(\n+ permalinkCompilation,\n+ permalink,\n+ this.inputPath\n+ );\n+ return this._renderFunction(fn, data);\n+ }\n+ }\n+\nif (typeof permalink === \"function\") {\nreturn this._renderFunction(permalink, data);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -2292,3 +2292,80 @@ test(\"Permalink is an object but an empty object (inherit default behavior)\", as\n\"./test/stubs/_site/permalink-empty-object/empty-object/index.html\"\n);\n});\n+\n+test(\"Custom extension (.txt) with custom permalink compile function\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ compileOptions: {\n+ // pass in your own custom permalink function.\n+ permalink: async function (permalinkString, inputPath) {\n+ t.is(permalinkString, \"custom-extension.lit\");\n+ t.is(inputPath, \"./test/stubs/custom-extension.txt\");\n+ return async function () {\n+ return \"HAHA_THIS_ALWAYS_GOES_HERE.txt\";\n+ };\n+ },\n+ },\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/custom-extension.txt\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.render(data), \"Sample content\");\n+ t.deepEqual(await tmpl.getOutputLocations(data), {\n+ href: \"/HAHA_THIS_ALWAYS_GOES_HERE.txt\",\n+ path: \"dist/HAHA_THIS_ALWAYS_GOES_HERE.txt\",\n+ rawPath: \"HAHA_THIS_ALWAYS_GOES_HERE.txt\",\n+ });\n+});\n+\n+test(\"Custom extension with and opt-out of permalink compilation\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ compileOptions: {\n+ permalink: false,\n+ },\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/custom-extension.txt\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.render(data), \"Sample content\");\n+ t.deepEqual(await tmpl.getOutputLocations(data), {\n+ href: \"/custom-extension.lit\",\n+ path: \"dist/custom-extension.lit\",\n+ rawPath: \"custom-extension.lit\",\n+ });\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/custom-extension.txt",
"diff": "+---\n+permalink: custom-extension.lit\n+---\n+Sample content\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Add support for `compileOptions.permalink` functions in addExtension. Override just the permalink compilation with your own custom function. |
699 | 21.12.2021 21:55:08 | 21,600 | 548752bac7ebbb7ddb57703ce11129ac19160d06 | Allow custom extensions to partially override the default permalink behavior. e.g. useful if you want to add opt-out of file writing for any scss file that starts with an underscore. | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Custom.js",
"new_path": "src/Engines/Custom.js",
"diff": "@@ -155,12 +155,12 @@ class CustomEngine extends TemplateEngine {\n}\n// TODO generalize this (look at JavaScript.js)\n- return (\n- this.entry.compile\n- .bind({ config: this.config })(str, inputPath)\n+ let fn = this.entry.compile.bind({ config: this.config })(str, inputPath);\n+ if (typeof fn === \"function\") {\n// give the user access to this engine's default renderer, if any\n- .bind({ defaultRenderer })\n- );\n+ return fn.bind({ defaultRenderer });\n+ }\n+ return fn;\n}\nget defaultTemplateFileExtension() {\n@@ -185,6 +185,10 @@ class CustomEngine extends TemplateEngine {\npermalinkNeedsCompilation(str) {\nif (this.entry.compileOptions && \"permalink\" in this.entry.compileOptions) {\n+ let p = this.entry.compileOptions.permalink;\n+ if (p === false || p === \"raw\") {\n+ return false;\n+ }\nreturn this.entry.compileOptions.permalink;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -259,6 +259,27 @@ class Template extends TemplateContent {\ndebugDev(\"Permalink rendered with data: %o\", data);\n}\n+ // Override default permalink behavior. Only do this if permalink was _not_ in the data cascade\n+ if (!permalink) {\n+ let permalinkCompilation = this.engine.permalinkNeedsCompilation(\"\");\n+ if (typeof permalinkCompilation === \"function\") {\n+ let ret = await this._renderFunction(\n+ permalinkCompilation,\n+ permalinkValue,\n+ this.inputPath\n+ );\n+ if (ret !== undefined) {\n+ if (typeof ret === \"function\") {\n+ // function\n+ permalinkValue = await this._renderFunction(ret, data);\n+ } else {\n+ // scalar\n+ permalinkValue = ret;\n+ }\n+ }\n+ }\n+ }\n+\nif (permalinkValue !== undefined) {\nreturn this._getRawPermalinkInstance(permalinkValue);\n}\n@@ -781,6 +802,16 @@ class Template extends TemplateContent {\nawait mkdir(templateOutputDir, { recursive: true });\n}\n+ if (Buffer.isBuffer(finalContent)) {\n+ finalContent = finalContent.toString();\n+ }\n+\n+ if (typeof finalContent !== \"string\") {\n+ throw new Error(\n+ `The return value from the render function for the ${this.engine.name} template was not a string. Received ${finalContent}`\n+ );\n+ }\n+\nreturn writeFile(outputPath, finalContent).then(() => {\ntemplateBenchmark.after();\nthis.writeCount++;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -340,14 +340,16 @@ class TemplateContent {\n}\nasync renderPermalink(permalink, data) {\n- if (typeof permalink === \"string\") {\n- let permalinkCompilation =\n- this.engine.permalinkNeedsCompilation(permalink);\n+ let permalinkCompilation = this.engine.permalinkNeedsCompilation(permalink);\n+ // No string compilation:\n+ // ({ compileOptions: { permalink: \"raw\" }})\n+ // These mean `permalink: false`, which is no file system writing:\n+ // ({ compileOptions: { permalink: () => false }})\n+ // ({ compileOptions: { permalink: () => (() = > false) }})\nif (permalinkCompilation === false) {\nreturn permalink;\n}\n- if (permalinkCompilation && typeof permalinkCompilation === \"function\") {\n/* Usage:\npermalink: function(permalinkString, inputPath) {\nreturn async function(data) {\n@@ -355,13 +357,12 @@ class TemplateContent {\n}\n}\n*/\n- let fn = await this._renderFunction(\n+ if (permalinkCompilation && typeof permalinkCompilation === \"function\") {\n+ permalink = await this._renderFunction(\npermalinkCompilation,\npermalink,\nthis.inputPath\n);\n- return this._renderFunction(fn, data);\n- }\n}\nif (typeof permalink === \"function\") {\n@@ -382,6 +383,8 @@ class TemplateContent {\n}\nlet fn = await this.compile(str, bypassMarkdown);\n+\n+ // Benchmark\nlet templateBenchmark = bench.get(\"Render\");\nlet paginationSuffix = [];\nif (\"pagination\" in data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -2369,3 +2369,87 @@ test(\"Custom extension with and opt-out of permalink compilation\", async (t) =>\nrawPath: \"custom-extension.lit\",\n});\n});\n+\n+test(\"Custom extension (.txt) with custom permalink compile function but no permalink in the data cascade\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ compileOptions: {\n+ // pass in your own custom permalink function.\n+ permalink: async function (permalinkString, inputPath) {\n+ t.is(permalinkString, undefined);\n+ t.is(inputPath, \"./test/stubs/custom-extension-no-permalink.txt\");\n+\n+ return async function () {\n+ return \"HAHA_THIS_ALWAYS_GOES_HERE.txt\";\n+ };\n+ },\n+ },\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/custom-extension-no-permalink.txt\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.render(data), \"Sample content\");\n+ t.deepEqual(await tmpl.getOutputLocations(data), {\n+ href: \"/HAHA_THIS_ALWAYS_GOES_HERE.txt\",\n+ path: \"dist/HAHA_THIS_ALWAYS_GOES_HERE.txt\",\n+ rawPath: \"HAHA_THIS_ALWAYS_GOES_HERE.txt\",\n+ });\n+});\n+\n+test(\"Custom extension (.txt) with custom permalink compile function (that returns a string not a function) but no permalink in the data cascade\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ compileOptions: {\n+ permalink: async function (permalinkString, inputPath) {\n+ t.is(permalinkString, undefined);\n+ t.is(inputPath, \"./test/stubs/custom-extension-no-permalink.txt\");\n+\n+ // unique part of this test: this is a string, not a function\n+ return \"HAHA_THIS_ALWAYS_GOES_HERE.txt\";\n+ },\n+ },\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/custom-extension-no-permalink.txt\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.render(data), \"Sample content\");\n+ t.deepEqual(await tmpl.getOutputLocations(data), {\n+ href: \"/HAHA_THIS_ALWAYS_GOES_HERE.txt\",\n+ path: \"dist/HAHA_THIS_ALWAYS_GOES_HERE.txt\",\n+ rawPath: \"HAHA_THIS_ALWAYS_GOES_HERE.txt\",\n+ });\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/custom-extension-no-permalink.txt",
"diff": "+Sample content\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Allow custom extensions to partially override the default permalink behavior. e.g. useful if you want to add opt-out of file writing for any scss file that starts with an underscore. |
699 | 26.12.2021 23:25:32 | 21,600 | 35eeb949ec6632919243e9f9b93ea1c261d5edf3 | Only throw transforms warning if there was a truthy content before. | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -547,6 +547,7 @@ class Template extends TemplateContent {\n// Warning: this argument list is the reverse of linters (inputPath then outputPath)\nasync runTransforms(str, inputPath, outputPath) {\nfor (let transform of this.transforms) {\n+ let hadStrBefore = !!str;\nstr = await transform.callback.call(\n{\ninputPath,\n@@ -555,7 +556,7 @@ class Template extends TemplateContent {\nstr,\noutputPath\n);\n- if (!str) {\n+ if (hadStrBefore && !str) {\nthis.logger.warn(\n`Warning: Transform \\`${transform.name}\\` returned empty when writing ${outputPath} from ${inputPath}.`\n);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Only throw transforms warning if there was a truthy content before. |
699 | 30.12.2021 09:19:46 | 21,600 | ed661f4a3208942da27d8d32a34a9cb5aea30ecf | Fix debug output for Eleventy:cmd | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -46,8 +46,7 @@ try {\n},\n});\n- // TODO fix debug output: `Eleventy:cmd command: eleventy [object Object] +0ms`\n- debug(\"command: eleventy \", argv.toString());\n+ debug(\"command: eleventy %o\", argv);\nconst Eleventy = require(\"./src/Eleventy\");\nprocess.on(\"unhandledRejection\", (error, promise) => {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix debug output for Eleventy:cmd |
699 | 30.12.2021 14:26:58 | 21,600 | fb1a7d878e119d5808a08f840d97d51ed26ac473 | Add outputFileExtension to default page variable | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -468,6 +468,7 @@ class Template extends TemplateContent {\ndata.page.inputPath = this.inputPath;\ndata.page.fileSlug = this.fileSlugStr;\ndata.page.filePathStem = this.filePathStem;\n+ data.page.outputFileExtension = this.engine.defaultTemplateFileExtension;\nreturn data;\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Add outputFileExtension to default page variable |
699 | 30.12.2021 14:28:08 | 21,600 | 5bc24ca70e16622f253979c3710c195b222fff2c | Checks when .compile returns undefined | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/RenderPlugin.js",
"new_path": "src/Plugins/RenderPlugin.js",
"diff": "@@ -267,6 +267,14 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n}\n);\n+ if (fn === undefined) {\n+ return;\n+ } else if (typeof fn !== \"function\") {\n+ throw new Error(\n+ `The \\`compile\\` function did not return a function. Received ${fn}`\n+ );\n+ }\n+\n// if the user passes a string or other literal, remap to an object.\nif (!lodashIsPlainObject(data)) {\ndata = {\n@@ -292,6 +300,14 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n}\n);\n+ if (fn === undefined) {\n+ return;\n+ } else if (typeof fn !== \"function\") {\n+ throw new Error(\n+ `The \\`compile\\` function did not return a function. Received ${fn}`\n+ );\n+ }\n+\n// if the user passes a string or other literal, remap to an object.\nif (!lodashIsPlainObject(data)) {\ndata = {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -384,6 +384,13 @@ class TemplateContent {\n}\nlet fn = await this.compile(str, bypassMarkdown);\n+ if (fn === undefined) {\n+ return;\n+ } else if (typeof fn !== \"function\") {\n+ throw new Error(\n+ `The \\`compile\\` function did not return a function. Received ${fn}`\n+ );\n+ }\n// Benchmark\nlet templateBenchmark = bench.get(\"Render\");\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Checks when .compile returns undefined |
699 | 02.01.2022 14:31:47 | 21,600 | 3cb2d714a9e338c52515441a9ef4326f3ec98481 | Change cache default for custom extensions to true, but only if `read: true` | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Custom.js",
"new_path": "src/Engines/Custom.js",
"diff": "@@ -15,6 +15,8 @@ class CustomEngine extends TemplateEngine {\n// Enable cacheability for this template\nif (this.entry.compileOptions && \"cache\" in this.entry.compileOptions) {\nthis.cacheable = this.entry.compileOptions.cache;\n+ } else if (this.needsToReadFileContents()) {\n+ this.cacheable = true;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest-CompileOptions.js",
"new_path": "test/TemplateTest-CompileOptions.js",
"diff": "@@ -2,6 +2,7 @@ const test = require(\"ava\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\nconst TemplateData = require(\"../src/TemplateData\");\n+const TemplateContent = require(\"../src/TemplateContent\");\nconst getNewTemplate = require(\"./_getNewTemplateForTests\");\n@@ -11,6 +12,7 @@ test(\"Custom extension (.txt) with custom permalink compile function\", async (t)\nextension: \"txt\",\nkey: \"txt\",\ncompileOptions: {\n+ cache: false,\n// pass in your own custom permalink function.\npermalink: async function (permalinkString, inputPath) {\nt.is(permalinkString, \"custom-extension.lit\");\n@@ -53,6 +55,7 @@ test(\"Custom extension with and compileOptions.permalink = false\", async (t) =>\nextension: \"txt\",\nkey: \"txt\",\ncompileOptions: {\n+ cache: false,\npermalink: false,\n},\ncompile: function (str, inputPath) {\n@@ -88,6 +91,7 @@ test(\"Custom extension with and opt-out of permalink compilation\", async (t) =>\nextension: \"txt\",\nkey: \"txt\",\ncompileOptions: {\n+ cache: false,\npermalink: \"raw\",\n},\ncompile: function (str, inputPath) {\n@@ -123,6 +127,7 @@ test(\"Custom extension (.txt) with custom permalink compile function but no perm\nextension: \"txt\",\nkey: \"txt\",\ncompileOptions: {\n+ cache: false,\n// pass in your own custom permalink function.\npermalink: async function (permalinkString, inputPath) {\nt.is(permalinkString, undefined);\n@@ -166,6 +171,7 @@ test(\"Custom extension (.txt) with custom permalink compile function (that retur\nextension: \"txt\",\nkey: \"txt\",\ncompileOptions: {\n+ cache: false,\npermalink: async function (permalinkString, inputPath) {\nt.is(permalinkString, undefined);\nt.is(inputPath, \"./test/stubs/custom-extension-no-permalink.txt\");\n@@ -207,6 +213,7 @@ test(\"Custom extension (.txt) with custom permalink compile function that return\nextension: \"txt\",\nkey: \"txt\",\ncompileOptions: {\n+ cache: false,\npermalink: async function (permalinkString, inputPath) {\nt.is(permalinkString, undefined);\nt.is(inputPath, \"./test/stubs/custom-extension-no-permalink.txt\");\n@@ -247,6 +254,9 @@ test(\"Custom extension (.txt) that returns undefined from compile\", async (t) =>\neleventyConfig.userConfig.extensionMap.add({\nextension: \"txt\",\nkey: \"txt\",\n+ compileOptions: {\n+ cache: false,\n+ },\ncompile: function (str, inputPath) {\nt.is(str, \"Sample content\");\nreturn function (data) {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Change cache default for custom extensions to true, but only if `read: true` |
699 | 02.01.2022 15:27:01 | 21,600 | 97570cf77362d84eaa6c66908458beac8db60a30 | Custom extensions improvement: Make `getData: false` and `getData: []` work without error. | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Custom.js",
"new_path": "src/Engines/Custom.js",
"diff": "@@ -67,23 +67,15 @@ class CustomEngine extends TemplateEngine {\nawait this._runningInit();\nif (\"getData\" in this.entry) {\n- let dataBench = bench.get(`Engine (${this.name}) Get Data From File`);\n- dataBench.before();\n-\nif (typeof this.entry.getData === \"function\") {\n+ let dataBench = bench.get(\n+ `Engine (${this.name}) Get Data From File (Function)`\n+ );\n+ dataBench.before();\nlet data = this.entry.getData(inputPath);\ndataBench.after();\nreturn data;\n} else {\n- if (!(\"getInstanceFromInputPath\" in this.entry)) {\n- dataBench.after();\n- return Promise.reject(\n- new Error(\n- `getInstanceFromInputPath callback missing from ${this.name} template engine plugin.`\n- )\n- );\n- }\n-\nlet keys = new Set();\nif (this.entry.getData === true) {\nkeys.add(\"data\");\n@@ -94,14 +86,18 @@ class CustomEngine extends TemplateEngine {\n}\nif (keys.size === 0) {\n- dataBench.after();\n+ return;\n+ } else if (!(\"getInstanceFromInputPath\" in this.entry)) {\nreturn Promise.reject(\nnew Error(\n- `getData must be an array of keys or \\`true\\` in your addExtension configuration.`\n+ `getInstanceFromInputPath callback missing from ${this.name} template engine plugin.`\n)\n);\n}\n+ let dataBench = bench.get(`Engine (${this.name}) Get Data From File`);\n+ dataBench.before();\n+\nlet inst = await this.entry.getInstanceFromInputPath(inputPath);\nlet mixins;\nif (this.config) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest-CompileOptions.js",
"new_path": "test/TemplateTest-CompileOptions.js",
"diff": "@@ -2,7 +2,6 @@ const test = require(\"ava\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\nconst TemplateData = require(\"../src/TemplateData\");\n-const TemplateContent = require(\"../src/TemplateContent\");\nconst getNewTemplate = require(\"./_getNewTemplateForTests\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/TemplateTest-CustomExtensions.js",
"diff": "+const test = require(\"ava\");\n+\n+const TemplateConfig = require(\"../src/TemplateConfig\");\n+const TemplateData = require(\"../src/TemplateData\");\n+const TemplateContent = require(\"../src/TemplateContent\");\n+\n+const getNewTemplate = require(\"./_getNewTemplateForTests\");\n+\n+test(\"Custom extension using getData: false\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ getData: false,\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/custom-extension.txt\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.render(data), \"Sample content\");\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Custom extensions improvement: Make `getData: false` and `getData: []` work without error. |
699 | 03.01.2022 10:21:54 | 21,600 | 4e2ad5e525c93e5a940d73f4ec506d54f95dbe84 | A few tweaks and tests for custom file extensions getData | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Custom.js",
"new_path": "src/Engines/Custom.js",
"diff": "@@ -64,9 +64,12 @@ class CustomEngine extends TemplateEngine {\n}\nasync getExtraDataFromFile(inputPath) {\n+ if (!(\"getData\" in this.entry) || this.entry.getData === false) {\n+ return;\n+ }\n+\nawait this._runningInit();\n- if (\"getData\" in this.entry) {\nif (typeof this.entry.getData === \"function\") {\nlet dataBench = bench.get(\n`Engine (${this.name}) Get Data From File (Function)`\n@@ -75,19 +78,10 @@ class CustomEngine extends TemplateEngine {\nlet data = this.entry.getData(inputPath);\ndataBench.after();\nreturn data;\n- } else {\n- let keys = new Set();\n- if (this.entry.getData === true) {\n- keys.add(\"data\");\n- } else if (Array.isArray(this.entry.getData)) {\n- for (let key of this.entry.getData) {\n- keys.add(key);\n- }\n}\n- if (keys.size === 0) {\n- return;\n- } else if (!(\"getInstanceFromInputPath\" in this.entry)) {\n+ // if getData is not false or a function then `getInstanceFromInputPath` must exist\n+ if (!(\"getInstanceFromInputPath\" in this.entry)) {\nreturn Promise.reject(\nnew Error(\n`getInstanceFromInputPath callback missing from ${this.name} template engine plugin.`\n@@ -95,21 +89,30 @@ class CustomEngine extends TemplateEngine {\n);\n}\n+ let keys = new Set();\n+ if (this.entry.getData === true) {\n+ keys.add(\"data\");\n+ } else if (Array.isArray(this.entry.getData)) {\n+ for (let key of this.entry.getData) {\n+ keys.add(key);\n+ }\n+ }\n+\nlet dataBench = bench.get(`Engine (${this.name}) Get Data From File`);\ndataBench.before();\nlet inst = await this.entry.getInstanceFromInputPath(inputPath);\n+ // override keys set at the plugin level in the individual template\n+ if (inst.eleventyDataKey) {\n+ keys = new Set(inst.eleventyDataKey);\n+ }\n+\nlet mixins;\nif (this.config) {\n// Object.assign usage: see TemplateRenderCustomTest.js: `JavaScript functions should not be mutable but not *that* mutable`\nmixins = Object.assign({}, this.config.javascriptFunctions);\n}\n- // override keys set at the plugin level in the individual template\n- if (inst.eleventyDataKey) {\n- keys = new Set(inst.eleventyDataKey);\n- }\n-\nlet promises = [];\nfor (let key of keys) {\npromises.push(\n@@ -129,8 +132,6 @@ class CustomEngine extends TemplateEngine {\nreturn data;\n}\n- }\n- }\nasync compile(str, inputPath, ...args) {\nawait this._runningInit();\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest-CustomExtensions.js",
"new_path": "test/TemplateTest-CustomExtensions.js",
"diff": "@@ -6,7 +6,7 @@ const TemplateContent = require(\"../src/TemplateContent\");\nconst getNewTemplate = require(\"./_getNewTemplateForTests\");\n-test(\"Custom extension using getData: false\", async (t) => {\n+test(\"Using getData: false without getInstanceFromInputPath works ok\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\neleventyConfig.userConfig.extensionMap.add({\nextension: \"txt\",\n@@ -36,3 +36,148 @@ test(\"Custom extension using getData: false\", async (t) => {\nlet data = await tmpl.getData();\nt.is(await tmpl.render(data), \"Sample content\");\n});\n+\n+test(\"Using getData: true without getInstanceFromInputPath should error\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ getData: true,\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/custom-extension.txt\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ await t.throwsAsync(async () => {\n+ await tmpl.getData();\n+ });\n+});\n+\n+test(\"Using getData: [] without getInstanceFromInputPath should error\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ getData: [],\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/custom-extension.txt\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ await t.throwsAsync(async () => {\n+ await tmpl.getData();\n+ });\n+});\n+\n+test(\"Using getData: true and getInstanceFromInputPath to get data from instance\", async (t) => {\n+ let globalData = {\n+ topLevelData: true,\n+ };\n+\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ getData: true,\n+ getInstanceFromInputPath: function () {\n+ return {\n+ data: globalData,\n+ };\n+ },\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/custom-extension.txt\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(data.topLevelData, true);\n+});\n+\n+test(\"Using eleventyDataKey to get a different key data from instance\", async (t) => {\n+ let globalData = {\n+ topLevelData: true,\n+ };\n+\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ getData: [],\n+ getInstanceFromInputPath: function () {\n+ return {\n+ eleventyDataKey: [\"otherProp\"],\n+ otherProp: globalData,\n+ };\n+ },\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/custom-extension.txt\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(data.topLevelData, true);\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | A few tweaks and tests for custom file extensions getData |
699 | 03.01.2022 14:56:57 | 21,600 | d8603741ab720234deeddb6dc23161f59509f29a | Tests for `defaultRenderer` | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"js-yaml\": \"^4.1.0\",\n\"lint-staged\": \"^11.2.6\",\n\"markdown-it-emoji\": \"^2.0.0\",\n+ \"marked\": \"^4.0.8\",\n\"nyc\": \"^15.1.0\",\n\"prettier\": \"^2.5.1\",\n\"rimraf\": \"^3.0.2\",\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest-CustomExtensions.js",
"new_path": "test/TemplateTest-CustomExtensions.js",
"diff": "@@ -181,3 +181,193 @@ test(\"Using eleventyDataKey to get a different key data from instance\", async (t\nlet data = await tmpl.getData();\nt.is(data.topLevelData, true);\n});\n+\n+test(\"Uses default renderer (no compile function) when you override an existing extension\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"liquid\",\n+ key: \"liquid\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/default.liquid\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.render(data), \"hi\");\n+});\n+\n+test(\"Access to default renderer when you override an existing extension\", async (t) => {\n+ t.plan(2);\n+\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"liquid\",\n+ key: \"liquid\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ t.true(true);\n+ return this.defaultRenderer();\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/default.liquid\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.render(data), \"hi\");\n+});\n+\n+test(\"Overridden liquid gets used from a markdown template\", async (t) => {\n+ t.plan(2);\n+\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"liquid\",\n+ key: \"liquid\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ t.true(true);\n+ return this.defaultRenderer();\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/default.md\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is((await tmpl.render(data)).trim(), \"<p>hi</p>\");\n+});\n+\n+test(\"Use marked for markdown\", async (t) => {\n+ const { marked } = require(\"marked\");\n+\n+ t.plan(2);\n+\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"md\",\n+ key: \"md\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ compile: function (str, inputPath) {\n+ let html = marked.parse(str);\n+ // plaintext\n+ return function (data) {\n+ t.true(true);\n+ return html;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/default-no-liquid.md\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is((await tmpl.render(data)).trim(), \"<p>hi</p>\");\n+});\n+\n+test(\"Use defaultRenderer for markdown\", async (t) => {\n+ t.plan(2);\n+\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"md\",\n+ key: \"md\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ compile: function (str, inputPath) {\n+ return function (data) {\n+ t.true(true);\n+ return this.defaultRenderer(data);\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/default.md\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is((await tmpl.render(data)).trim(), \"<p>hi</p>\");\n+});\n+\n+test(\"Front matter in a custom extension\", async (t) => {\n+ t.plan(2);\n+\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ compileOptions: {\n+ cache: false,\n+ },\n+ compile: function (str, inputPath) {\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/default-frontmatter.txt\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(data.frontmatter, 1);\n+ t.is((await tmpl.render(data)).trim(), \"hi\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/default-frontmatter.txt",
"diff": "+---\n+frontmatter: 1\n+---\n+hi\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/default-no-liquid.md",
"diff": "+hi\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/default.liquid",
"diff": "+{{ \"hi\" }}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/default.md",
"diff": "+{{ \"hi\" }}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Tests for `defaultRenderer` |
699 | 03.01.2022 17:43:31 | 21,600 | 9514da23cc07e0a6f1c819208bf669185a56f35f | .write, .toJSON, and .toNDJSON will now call .init() for you transparently. | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Custom.js",
"new_path": "src/Engines/Custom.js",
"diff": "@@ -45,8 +45,7 @@ class CustomEngine extends TemplateEngine {\nreturn true;\n}\n- // If we init from multiple places, wait for the first init to finish\n- // before continuing on.\n+ // If we init from multiple places, wait for the first init to finish before continuing on.\nasync _runningInit() {\nif (this.needsInit) {\nlet initBench = bench.get(`Engine (${this.name}) Init`);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -155,7 +155,7 @@ test(\"Eleventy set input/output, one file input exitCode\", async (t) => {\n);\nelev.setIsVerbose(false);\nelev.disableLogger();\n- await elev.init();\n+ // await elev.init(); // no longer necessary\nawait elev.write();\nt.is(process.exitCode, 1);\n@@ -167,7 +167,7 @@ test(\"Eleventy to json\", async (t) => {\nlet elev = new Eleventy(\"./test/stubs--to/\");\nelev.setIsVerbose(false);\n- await elev.init();\n+ // await elev.init(); // no longer necessary\nlet result = await elev.toJSON();\n@@ -200,7 +200,7 @@ test(\"Eleventy to ndjson\", async (t) => {\nelev.setIsVerbose(false);\n- await elev.init();\n+ // await elev.init(); // no longer necessary\nlet stream = await elev.toNDJSON();\nlet count = 0;\n@@ -237,7 +237,9 @@ test.cb(\"Eleventy to ndjson (returns a stream)\", (t) => {\nelev.setIsVerbose(false);\n- elev.init().then(() => {\n+ // elev.init().then(() => { // no longer necessary\n+ // });\n+\nelev.toNDJSON().then((stream) => {\nlet results = [];\nstream.on(\"data\", function (jsonObj) {\n@@ -266,7 +268,6 @@ test.cb(\"Eleventy to ndjson (returns a stream)\", (t) => {\n});\n});\n});\n-});\ntest(\"Two Eleventies, two configs!!! (config used to be a global)\", async (t) => {\nlet elev1 = new Eleventy();\n@@ -291,3 +292,33 @@ test(\"Config propagates to other instances correctly\", async (t) => {\nt.is(elev.templateData.eleventyConfig, elev.eleventyConfig);\nt.is(elev.writer.eleventyConfig, elev.eleventyConfig);\n});\n+\n+test(\"Eleventy programmatic API without init\", async (t) => {\n+ let elev = new Eleventy(\"./test/stubs--to/\");\n+ elev.setIsVerbose(false);\n+\n+ let result = await elev.toJSON();\n+\n+ t.deepEqual(\n+ result.filter((entry) => entry.url === \"/test/\"),\n+ [\n+ {\n+ url: \"/test/\",\n+ inputPath: \"./test/stubs--to/test.md\",\n+ outputPath: \"_site/test/index.html\",\n+ content: \"<h1>hi</h1>\\n\",\n+ },\n+ ]\n+ );\n+ t.deepEqual(\n+ result.filter((entry) => entry.url === \"/test2/\"),\n+ [\n+ {\n+ url: \"/test2/\",\n+ inputPath: \"./test/stubs--to/test2.liquid\",\n+ outputPath: \"_site/test2/index.html\",\n+ content: \"hello\",\n+ },\n+ ]\n+ );\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | .write, .toJSON, and .toNDJSON will now call .init() for you transparently. |
699 | 03.01.2022 17:51:13 | 21,600 | a2186071a915bea1a40a5d1ba148acf58a7bdb7e | Run executeBuild twice, in parallel | [
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -322,3 +322,48 @@ test(\"Eleventy programmatic API without init\", async (t) => {\n]\n);\n});\n+\n+test(\"Can Eleventy run two executeBuilds in parallel?\", async (t) => {\n+ let elev = new Eleventy(\"./test/stubs--to/\");\n+ elev.setIsVerbose(false);\n+\n+ let p1 = elev.toJSON();\n+ let p2 = elev.toJSON();\n+ let [result1, result2] = await Promise.all([p1, p2]);\n+\n+ let test1Result = [\n+ {\n+ url: \"/test/\",\n+ inputPath: \"./test/stubs--to/test.md\",\n+ outputPath: \"_site/test/index.html\",\n+ content: \"<h1>hi</h1>\\n\",\n+ },\n+ ];\n+\n+ let test2Result = [\n+ {\n+ url: \"/test2/\",\n+ inputPath: \"./test/stubs--to/test2.liquid\",\n+ outputPath: \"_site/test2/index.html\",\n+ content: \"hello\",\n+ },\n+ ];\n+\n+ t.deepEqual(\n+ result1.filter((entry) => entry.url === \"/test/\"),\n+ test1Result\n+ );\n+ t.deepEqual(\n+ result1.filter((entry) => entry.url === \"/test2/\"),\n+ test2Result\n+ );\n+\n+ t.deepEqual(\n+ result2.filter((entry) => entry.url === \"/test/\"),\n+ test1Result\n+ );\n+ t.deepEqual(\n+ result2.filter((entry) => entry.url === \"/test2/\"),\n+ test2Result\n+ );\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Run executeBuild twice, in parallel |
699 | 04.01.2022 10:12:58 | 21,600 | 223f9ab49e5f9ff71693f47b91dc96b1133f5179 | Updates to ava 4 | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.3\",\n\"@11ty/eleventy-plugin-vue\": \"1.0.0-canary.8\",\n\"@vue/server-renderer\": \"^3.2.26\",\n- \"ava\": \"^3.15.0\",\n+ \"ava\": \"^4.0.0\",\n\"husky\": \"^7.0.4\",\n\"js-yaml\": \"^4.1.0\",\n\"lint-staged\": \"^11.2.6\",\n"
},
{
"change_type": "MODIFY",
"old_path": "test/BenchmarkTest.js",
"new_path": "test/BenchmarkTest.js",
"diff": "@@ -6,19 +6,20 @@ function between(t, value, lowerBound, upperBound) {\nt.truthy(value <= upperBound);\n}\n-test.cb(\"Standard Benchmark\", (t) => {\n+test(\"Standard Benchmark\", async (t) => {\n+ await new Promise((resolve) => {\nlet b = new Benchmark();\nb.before();\nsetTimeout(function () {\nb.after();\nt.truthy(b.getTotal() >= 0);\n- t.end();\n+ resolve();\n}, 100);\n});\n+});\n-test.cb(\n- \"Nested Benchmark (nested calls are ignored while a parent is measuring)\",\n- (t) => {\n+test(\"Nested Benchmark (nested calls are ignored while a parent is measuring)\", async (t) => {\n+ await new Promise((resolve) => {\nlet b = new Benchmark();\nb.before();\n@@ -29,12 +30,13 @@ test.cb(\nb.after();\nt.truthy(b.getTotal() >= 10);\n- t.end();\n+ resolve();\n}, 100);\n- }\n-);\n+ });\n+});\n-test.cb(\"Reset Benchmark\", (t) => {\n+test(\"Reset Benchmark\", async (t) => {\n+ await new Promise((resolve) => {\nlet b = new Benchmark();\nb.before();\nb.reset();\n@@ -47,6 +49,8 @@ test.cb(\"Reset Benchmark\", (t) => {\n// throws because we reset\nb.after();\n});\n- t.end();\n+\n+ resolve();\n}, 100);\n});\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -232,17 +232,17 @@ test(\"Eleventy to ndjson\", async (t) => {\n});\n});\n-test.cb(\"Eleventy to ndjson (returns a stream)\", (t) => {\n+test(\"Eleventy to ndjson (returns a stream)\", async (t) => {\nlet elev = new Eleventy(\"./test/stubs--to/\");\nelev.setIsVerbose(false);\n- // elev.init().then(() => { // no longer necessary\n- // });\n+ let stream = await elev.toNDJSON();\n- elev.toNDJSON().then((stream) => {\n+ await new Promise((resolve) => {\nlet results = [];\n- stream.on(\"data\", function (jsonObj) {\n+ stream.on(\"data\", function (entry) {\n+ let jsonObj = JSON.parse(entry);\nif (jsonObj.url === \"/test/\") {\nt.deepEqual(jsonObj, {\nurl: \"/test/\",\n@@ -263,7 +263,7 @@ test.cb(\"Eleventy to ndjson (returns a stream)\", (t) => {\nresults.push(jsonObj);\nif (results.length >= 2) {\n- t.end();\n+ resolve();\n}\n});\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/UserConfigTest.js",
"new_path": "test/UserConfigTest.js",
"diff": "@@ -43,19 +43,22 @@ test(\"Template Formats (Arrays)\", (t) => {\n// more in TemplateConfigTest.js\n-test.cb(\"Events\", (t) => {\n+test(\"Events\", async (t) => {\n+ await new Promise((resolve) => {\nlet userCfg = new UserConfig();\nuserCfg.on(\"testEvent\", function (arg1, arg2, arg3) {\nt.is(arg1, \"arg1\");\nt.is(arg2, \"arg2\");\nt.is(arg3, \"arg3\");\n- t.end();\n+ resolve();\n});\nuserCfg.emit(\"testEvent\", \"arg1\", \"arg2\", \"arg3\");\n});\n+});\n-test.cb(\"Async Events\", (t) => {\n+test(\"Async Events\", async (t) => {\n+ await new Promise((resolve) => {\nlet userCfg = new UserConfig();\nlet arg1;\n@@ -72,7 +75,8 @@ test.cb(\"Async Events\", (t) => {\nuserCfg.emit(\"asyncTestEvent\", \"arg1\").then(() => {\nt.is(arg1, \"arg1\");\n- t.end();\n+ resolve();\n+ });\n});\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/cmdTest.js",
"new_path": "test/cmdTest.js",
"diff": "const test = require(\"ava\");\nconst { exec } = require(\"child_process\");\n+const { resolve } = require(\"path\");\n-test.cb(\"Test command line exit code success\", (t) => {\n+test(\"Test command line exit code success\", async (t) => {\n+ await new Promise((resolve) => {\nexec(\n\"node ./cmd.js --input=test/stubs/exitCode_success --dryrun\",\n(error, stdout, stderr) => {\nt.falsy(error);\n- t.end();\n+ resolve();\n}\n);\n});\n+});\n-test.cb(\"Test command line exit code for template error\", (t) => {\n+test(\"Test command line exit code for template error\", async (t) => {\n+ await new Promise((resolve) => {\nexec(\n\"node ./cmd.js --input=test/stubs/exitCode --dryrun\",\n(error, stdout, stderr) => {\nt.is(error.code, 1);\n- t.end();\n+ resolve();\n}\n);\n});\n+});\n-test.cb(\"Test command line exit code for global data error\", (t) => {\n+test(\"Test command line exit code for global data error\", async (t) => {\n+ await new Promise((resolve) => {\nexec(\n\"node ./cmd.js --input=test/stubs/exitCode_globalData --dryrun\",\n(error, stdout, stderr) => {\nt.is(error.code, 1);\n- t.end();\n+ resolve();\n}\n);\n});\n+});\n-test.cb(\"Test data should not process in a --help\", (t) => {\n+test(\"Test data should not process in a --help\", async (t) => {\n+ await new Promise((resolve) => {\nexec(\n\"node ./cmd.js --input=test/stubs/cmd-help-processing --help\",\n(error, stdout, stderr) => {\nt.falsy(error);\nt.is(stdout.indexOf(\"THIS SHOULD NOT LOG TO CONSOLE\"), -1);\n- t.end();\n+ resolve();\n}\n);\n});\n+});\n-test.cb(\"Test data should not process in a --version\", (t) => {\n+test(\"Test data should not process in a --version\", async (t) => {\n+ await new Promise((resolve) => {\nexec(\n\"node ./cmd.js --input=test/stubs/cmd-help-processing --version\",\n(error, stdout, stderr) => {\nt.falsy(error);\nt.is(stdout.indexOf(\"THIS SHOULD NOT LOG TO CONSOLE\"), -1);\n- t.end();\n+ resolve();\n}\n);\n});\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Updates to ava 4 https://github.com/avajs/ava/releases/tag/v4.0.0 |
699 | 04.01.2022 10:17:19 | 21,600 | 730252a065166518a303f453c9bfbd993611d0d1 | Minor tweak for local test stability | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest-CustomExtensions.js",
"new_path": "test/TemplateTest-CustomExtensions.js",
"diff": "@@ -250,9 +250,10 @@ test(\"Overridden liquid gets used from a markdown template\", async (t) => {\ncache: false,\n},\ncompile: function (str, inputPath) {\n+ t.true(true);\n+\n// plaintext\nreturn function (data) {\n- t.true(true);\nreturn this.defaultRenderer();\n};\n},\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Minor tweak for local test stability |
699 | 07.01.2022 20:07:54 | 21,600 | fca0104e02006ae15be892e08959670f7e415864 | Require key for cacheable custom template extensions | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -269,7 +269,8 @@ class TemplateContent {\nstr,\nbypassMarkdown\n);\n- if (cacheable && cache.has(key)) {\n+ if (cacheable && key) {\n+ if (cache.has(key)) {\nreturn cache.get(key);\n}\n@@ -282,6 +283,7 @@ class TemplateContent {\n})\n);\n}\n+ }\nlet templateBenchmark = bench.get(\"Template Compile\");\nlet inputPathBenchmark = bench.get(\n@@ -299,7 +301,7 @@ class TemplateContent {\nreturn fn;\n} catch (e) {\nlet [cacheable, key, cache] = this._getCompileCache(str, bypassMarkdown);\n- if (cacheable) {\n+ if (cacheable && key) {\ncache.delete(key);\n}\ndebug(`Having trouble compiling template ${this.inputPath}: %O`, str);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Require key for cacheable custom template extensions |
699 | 07.01.2022 20:08:25 | 21,600 | 2d5be6c681eaed65b66975831565e6875fe874a3 | Fixed: benchmark was misreporting too many init calls | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Custom.js",
"new_path": "src/Engines/Custom.js",
"diff": "@@ -48,9 +48,9 @@ class CustomEngine extends TemplateEngine {\n// If we init from multiple places, wait for the first init to finish before continuing on.\nasync _runningInit() {\nif (this.needsInit) {\n- let initBench = bench.get(`Engine (${this.name}) Init`);\n- initBench.before();\nif (!this._initing) {\n+ this._initBench = bench.get(`Engine (${this.name}) Init`);\n+ this._initBench.before();\nthis._initing = this.entry.init.bind({\nconfig: this.config,\nbench,\n@@ -58,7 +58,11 @@ class CustomEngine extends TemplateEngine {\n}\nawait this._initing;\nthis.needsInit = false;\n- initBench.after();\n+\n+ if (this._initBench) {\n+ this._initBench.after();\n+ this._initBench = undefined;\n+ }\n}\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fixed: benchmark was misreporting too many init calls |
699 | 11.01.2022 17:37:21 | 21,600 | f16d8cd52e27cb6b49887fc90c1542408e17628f | Benchmarks should not be a global (this is bad for serverless local dev) | [
{
"change_type": "MODIFY",
"old_path": "src/Benchmark.js",
"new_path": "src/Benchmark.js",
"diff": "@@ -18,6 +18,10 @@ class Benchmark {\nthis.beforeTimers = [];\n}\n+ incrementCount() {\n+ this.timesCalled++;\n+ }\n+\n// TODO(slightlyoff):\n// disable all of these hrtime requests when not benchmarking\nbefore() {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/BenchmarkManager.js",
"new_path": "src/BenchmarkManager.js",
"diff": "@@ -65,5 +65,4 @@ class BenchmarkManager {\n}\n}\n-let manager = new BenchmarkManager();\n-module.exports = manager;\n+module.exports = BenchmarkManager;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -16,7 +16,6 @@ const { performance } = require(\"perf_hooks\");\nconst templateCache = require(\"./TemplateCache\");\nconst simplePlural = require(\"./Util/Pluralize\");\nconst deleteRequireCache = require(\"./Util/DeleteRequireCache\");\n-const bench = require(\"./BenchmarkManager\");\nconst debug = require(\"debug\")(\"Eleventy\");\nconst eventBus = require(\"./EventBus\");\n@@ -73,6 +72,11 @@ class Eleventy {\n*/\nthis.config = this.eleventyConfig.getConfig();\n+ /**\n+ * @member {Object} - Singleton BenchmarkManager instance\n+ */\n+ this.bench = this.config.benchmarkManager;\n+\n/**\n* @member {Boolean} - Was verbose mode overwritten?\n* @default false\n@@ -246,7 +250,7 @@ class Eleventy {\ndebug(\"Restarting\");\nthis.start = this.getNewTimestamp();\ntemplateCache.clear();\n- bench.reset();\n+ this.bench.reset();\nthis.eleventyFiles.restart();\nthis.extensionMap.reset();\n@@ -438,9 +442,7 @@ Verbose Output: ${this.verboseMode}`);\nthis.writer.setVerboseOutput(this._isVerboseMode);\n}\n- if (bench) {\n- bench.setVerboseOutput(this._isVerboseMode);\n- }\n+ this.bench.setVerboseOutput(this._isVerboseMode);\nif (this.logger) {\nthis.logger.isVerbose = this._isVerboseMode;\n@@ -502,7 +504,7 @@ Verbose Output: ${this.verboseMode}`);\nthis.logger.isVerbose = isVerbose;\n}\n- bench.setVerboseOutput(isVerbose);\n+ this.bench.setVerboseOutput(isVerbose);\nthis.verboseMode = isVerbose;\n// Set verbose mode in config file\n@@ -701,7 +703,7 @@ Arguments:\n* @returns {} - tbd.\n*/\nget watcherBench() {\n- return bench.get(\"Watcher\");\n+ return this.bench.get(\"Watcher\");\n}\n/**\n@@ -1000,7 +1002,7 @@ Arguments:\n};\nthis.errorHandler.fatal(e, \"Problem writing Eleventy templates\");\n} finally {\n- bench.finish();\n+ this.bench.finish();\nif (to === \"fs\") {\nthis.logger.message(\nthis.logFinished(),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Custom.js",
"new_path": "src/Engines/Custom.js",
"diff": "const TemplateEngine = require(\"./TemplateEngine\");\nconst getJavaScriptData = require(\"../Util/GetJavaScriptData\");\n-const bench = require(\"../BenchmarkManager\").get(\"Aggregate\");\nclass CustomEngine extends TemplateEngine {\nconstructor(name, dirs, config) {\n@@ -49,11 +48,13 @@ class CustomEngine extends TemplateEngine {\nasync _runningInit() {\nif (this.needsInit) {\nif (!this._initing) {\n- this._initBench = bench.get(`Engine (${this.name}) Init`);\n+ this._initBench = this.benchmarks.aggregate.get(\n+ `Engine (${this.name}) Init`\n+ );\nthis._initBench.before();\nthis._initing = this.entry.init.bind({\nconfig: this.config,\n- bench,\n+ bench: this.benchmarks.aggregate,\n})();\n}\nawait this._initing;\n@@ -74,7 +75,7 @@ class CustomEngine extends TemplateEngine {\nawait this._runningInit();\nif (typeof this.entry.getData === \"function\") {\n- let dataBench = bench.get(\n+ let dataBench = this.benchmarks.aggregate.get(\n`Engine (${this.name}) Get Data From File (Function)`\n);\ndataBench.before();\n@@ -101,7 +102,9 @@ class CustomEngine extends TemplateEngine {\n}\n}\n- let dataBench = bench.get(`Engine (${this.name}) Get Data From File`);\n+ let dataBench = this.benchmarks.aggregate.get(\n+ `Engine (${this.name}) Get Data From File`\n+ );\ndataBench.before();\nlet inst = await this.entry.getInstanceFromInputPath(inputPath);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/TemplateEngine.js",
"new_path": "src/Engines/TemplateEngine.js",
"diff": "@@ -5,7 +5,6 @@ const TemplateConfig = require(\"../TemplateConfig\");\nconst EleventyExtensionMap = require(\"../EleventyExtensionMap\");\nconst EleventyBaseError = require(\"../EleventyBaseError\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateEngine\");\n-const aggregateBench = require(\"../BenchmarkManager\").get(\"Aggregate\");\nclass TemplateEngineConfigError extends EleventyBaseError {}\n@@ -43,6 +42,15 @@ class TemplateEngine {\nreturn this._config;\n}\n+ get benchmarks() {\n+ if (!this._benchmarks) {\n+ this._benchmarks = {\n+ aggregate: this.config.benchmarkManager.get(\"Aggregate\"),\n+ };\n+ }\n+ return this._benchmarks;\n+ }\n+\nget engineManager() {\nreturn this._engineManager;\n}\n@@ -104,7 +112,7 @@ class TemplateEngine {\n// TODO: reuse mustache partials in handlebars?\nlet partialFiles = [];\nif (this.includesDir) {\n- let bench = aggregateBench.get(\"Searching the file system\");\n+ let bench = this.benchmarks.aggregate.get(\"Searching the file system\");\nbench.before();\nthis.extensions.forEach(function (extension) {\npartialFiles = partialFiles.concat(\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -26,7 +26,6 @@ const TemplateBehavior = require(\"./TemplateBehavior\");\nconst debug = require(\"debug\")(\"Eleventy:Template\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:Template\");\n-const bench = require(\"./BenchmarkManager\").get(\"Aggregate\");\nclass Template extends TemplateContent {\nconstructor(\n@@ -810,7 +809,7 @@ class Template extends TemplateContent {\nif (!shouldWriteFile) {\nthis.skippedCount++;\n} else {\n- let templateBenchmark = bench.get(\"Template Write\");\n+ let templateBenchmark = this.bench.get(\"Template Write\");\ntemplateBenchmark.before();\n// TODO add a cache to check if this was already created\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -63,7 +63,7 @@ class TemplateConfig {\nthis.hasConfigMerged = false;\n}\n- /* Getter for Logger */\n+ /* Setter for Logger */\nsetLogger(logger) {\nthis.logger = logger;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -15,7 +15,6 @@ const EleventyBaseError = require(\"./EleventyBaseError\");\nconst EleventyErrorUtil = require(\"./EleventyErrorUtil\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateContent\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateContent\");\n-const bench = require(\"./BenchmarkManager\").get(\"Aggregate\");\nconst eventBus = require(\"./EventBus\");\nclass TemplateContentConfigError extends EleventyBaseError {}\n@@ -64,6 +63,10 @@ class TemplateContent {\nreturn this._config;\n}\n+ get bench() {\n+ return this.config.benchmarkManager.get(\"Aggregate\");\n+ }\n+\nget eleventyConfig() {\nif (this._config instanceof TemplateConfig) {\nreturn this._config;\n@@ -164,7 +167,7 @@ class TemplateContent {\nif (!this.engine.needsToReadFileContents()) {\nreturn \"\";\n}\n- let templateBenchmark = bench.get(\"Template Read\");\n+ let templateBenchmark = this.bench.get(\"Template Read\");\ntemplateBenchmark.before();\nlet content;\nif (this.config.useTemplateCache) {\n@@ -271,6 +274,7 @@ class TemplateContent {\n);\nif (cacheable && key) {\nif (cache.has(key)) {\n+ this.bench.get(\"Template Compile Cache Hit\").incrementCount();\nreturn cache.get(key);\n}\n@@ -285,8 +289,8 @@ class TemplateContent {\n}\n}\n- let templateBenchmark = bench.get(\"Template Compile\");\n- let inputPathBenchmark = bench.get(\n+ let templateBenchmark = this.bench.get(\"Template Compile\");\n+ let inputPathBenchmark = this.bench.get(\n`> Template Compile > ${this.inputPath}`\n);\ntemplateBenchmark.before();\n@@ -395,7 +399,7 @@ class TemplateContent {\n}\n// Benchmark\n- let templateBenchmark = bench.get(\"Render\");\n+ let templateBenchmark = this.bench.get(\"Render\");\nlet paginationSuffix = [];\nif (\"pagination\" in data) {\npaginationSuffix.push(\" (Pagination\");\n@@ -409,7 +413,7 @@ class TemplateContent {\npaginationSuffix.push(\")\");\n}\n- let inputPathBenchmark = bench.get(\n+ let inputPathBenchmark = this.bench.get(\n`> Render > ${this.inputPath}${paginationSuffix.join(\"\")}`\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -16,9 +16,6 @@ const debug = require(\"debug\")(\"Eleventy:TemplateData\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateData\");\nconst deleteRequireCache = require(\"./Util/DeleteRequireCache\");\n-const bench = require(\"./BenchmarkManager\").get(\"Data\");\n-const aggregateBench = require(\"./BenchmarkManager\").get(\"Aggregate\");\n-\nclass FSExistsCache {\nconstructor() {\nthis._cache = new Map();\n@@ -49,6 +46,10 @@ class TemplateData {\n}\nthis.eleventyConfig = eleventyConfig;\nthis.config = this.eleventyConfig.getConfig();\n+ this.benchmarks = {\n+ data: this.config.benchmarkManager.get(\"Data\"),\n+ aggregate: this.config.benchmarkManager.get(\"Aggregate\"),\n+ };\nthis.dataTemplateEngine = this.config.dataTemplateEngine;\n@@ -216,7 +217,7 @@ class TemplateData {\nasync getGlobalDataFiles() {\nlet priorities = this.getGlobalDataExtensionPriorities();\n- let fsBench = aggregateBench.get(\"Searching the file system\");\n+ let fsBench = this.benchmarks.aggregate.get(\"Searching the file system\");\nfsBench.before();\nlet paths = fastglob.sync(await this.getGlobalDataGlob(), {\ncaseSensitiveMatch: false,\n@@ -468,9 +469,9 @@ class TemplateData {\nreturn {};\n}\n- let aggregateDataBench = aggregateBench.get(\"Data File\");\n+ let aggregateDataBench = this.benchmarks.aggregate.get(\"Data File\");\naggregateDataBench.before();\n- let dataBench = bench.get(`\\`${path}\\``);\n+ let dataBench = this.benchmarks.data.get(`\\`${path}\\``);\ndataBench.before();\ndeleteRequireCache(localPath);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePassthrough.js",
"new_path": "src/TemplatePassthrough.js",
"diff": "@@ -5,12 +5,19 @@ const TemplatePath = require(\"./TemplatePath\");\nconst debug = require(\"debug\")(\"Eleventy:TemplatePassthrough\");\nconst fastglob = require(\"fast-glob\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\n-const aggregateBench = require(\"./BenchmarkManager\").get(\"Aggregate\");\nclass TemplatePassthroughError extends EleventyBaseError {}\nclass TemplatePassthrough {\n- constructor(path, outputDir, inputDir) {\n+ constructor(path, outputDir, inputDir, config) {\n+ if (!config) {\n+ throw new TemplatePassthroughError(\"Missing `config`.\");\n+ }\n+ this.config = config;\n+ this.benchmarks = {\n+ aggregate: this.config.benchmarkManager.get(\"Aggregate\"),\n+ };\n+\nthis.rawPath = path;\n// inputPath is relative to the root of your project and not your Eleventy input directory.\n@@ -63,15 +70,15 @@ class TemplatePassthrough {\nasync getFiles(glob) {\ndebug(\"Searching for: %o\", glob);\n- let bench = aggregateBench.get(\"Searching the file system\");\n- bench.before();\n+ let b = this.benchmarks.aggregate.get(\"Searching the file system\");\n+ b.before();\nconst files = TemplatePath.addLeadingDotSlashArray(\nawait fastglob(glob, {\ncaseSensitiveMatch: false,\ndot: true,\n})\n);\n- bench.after();\n+ b.after();\nreturn files;\n}\n@@ -98,15 +105,15 @@ class TemplatePassthrough {\n// returns a promise\nreturn copy(src, dest, copyOptions)\n- .on(copy.events.COPY_FILE_START, function (copyOp) {\n+ .on(copy.events.COPY_FILE_START, (copyOp) => {\n// Access to individual files at `copyOp.src`\ndebug(\"Copying individual file %o\", copyOp.src);\nmap[copyOp.src] = copyOp.dest;\n- aggregateBench.get(\"Passthrough Copy File\").before();\n+ this.benchmarks.aggregate.get(\"Passthrough Copy File\").before();\n})\n- .on(copy.events.COPY_FILE_COMPLETE, function () {\n+ .on(copy.events.COPY_FILE_COMPLETE, () => {\nfileCopyCount++;\n- aggregateBench.get(\"Passthrough Copy File\").after();\n+ this.benchmarks.aggregate.get(\"Passthrough Copy File\").after();\n})\n.then(() => {\nreturn {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePassthroughManager.js",
"new_path": "src/TemplatePassthroughManager.js",
"diff": "@@ -98,7 +98,12 @@ class TemplatePassthroughManager {\n}\ngetTemplatePassthroughForPath(path) {\n- return new TemplatePassthrough(path, this.outputDir, this.inputDir);\n+ return new TemplatePassthrough(\n+ path,\n+ this.outputDir,\n+ this.inputDir,\n+ this.config\n+ );\n}\nasync copyPassthrough(pass) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -3,9 +3,8 @@ const semver = require(\"semver\");\nconst { DateTime } = require(\"luxon\");\nconst EventEmitter = require(\"./Util/AsyncEventEmitter\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\n+const BenchmarkManager = require(\"./BenchmarkManager\");\nconst merge = require(\"./Util/Merge\");\n-const bench = require(\"./BenchmarkManager\").get(\"Configuration\");\n-const aggregateBench = require(\"./BenchmarkManager\").get(\"Aggregate\");\nconst debug = require(\"debug\")(\"Eleventy:UserConfig\");\nconst pkg = require(\"../package.json\");\n@@ -20,6 +19,13 @@ class UserConfig {\nreset() {\ndebug(\"Resetting EleventyConfig to initial values.\");\nthis.events = new EventEmitter();\n+\n+ this.benchmarkManager = new BenchmarkManager();\n+ this.benchmarks = {\n+ config: this.benchmarkManager.get(\"Configuration\"),\n+ aggregate: this.benchmarkManager.get(\"Aggregate\"),\n+ };\n+\nthis.collections = {};\nthis.precompiledCollections = {};\nthis.templateFormats = undefined;\n@@ -132,7 +138,10 @@ class UserConfig {\nname\n);\n}\n- this.liquidTags[name] = bench.add(`\"${name}\" Liquid Custom Tag`, tagFn);\n+ this.liquidTags[name] = this.benchmarks.config.add(\n+ `\"${name}\" Liquid Custom Tag`,\n+ tagFn\n+ );\n}\naddLiquidFilter(name, callback) {\n@@ -147,7 +156,10 @@ class UserConfig {\n);\n}\n- this.liquidFilters[name] = bench.add(`\"${name}\" Liquid Filter`, callback);\n+ this.liquidFilters[name] = this.benchmarks.config.add(\n+ `\"${name}\" Liquid Filter`,\n+ callback\n+ );\n}\naddNunjucksAsyncFilter(name, callback) {\n@@ -162,7 +174,7 @@ class UserConfig {\n);\n}\n- this.nunjucksAsyncFilters[name] = bench.add(\n+ this.nunjucksAsyncFilters[name] = this.benchmarks.config.add(\n`\"${name}\" Nunjucks Async Filter`,\ncallback\n);\n@@ -185,7 +197,7 @@ class UserConfig {\n);\n}\n- this.nunjucksFilters[name] = bench.add(\n+ this.nunjucksFilters[name] = this.benchmarks.config.add(\n`\"${name}\" Nunjucks Filter`,\ncallback\n);\n@@ -204,7 +216,7 @@ class UserConfig {\n);\n}\n- this.handlebarsHelpers[name] = bench.add(\n+ this.handlebarsHelpers[name] = this.benchmarks.config.add(\n`\"${name}\" Handlebars Helper`,\ncallback\n);\n@@ -249,7 +261,10 @@ class UserConfig {\n);\n}\n- this.nunjucksTags[name] = bench.add(`\"${name}\" Nunjucks Custom Tag`, tagFn);\n+ this.nunjucksTags[name] = this.benchmarks.config.add(\n+ `\"${name}\" Nunjucks Custom Tag`,\n+ tagFn\n+ );\n}\naddGlobalData(name, data) {\n@@ -271,7 +286,7 @@ class UserConfig {\n}\nif (typeof globalType === \"function\") {\n- this.nunjucksGlobals[name] = bench.add(\n+ this.nunjucksGlobals[name] = this.benchmarks.config.add(\n`\"${name}\" Nunjucks Global`,\nglobalType\n);\n@@ -327,20 +342,23 @@ class UserConfig {\n_executePlugin(plugin, options) {\ndebug(`Adding ${plugin.name || \"anonymous\"} plugin`);\n- let pluginBench = aggregateBench.get(\"Configuration addPlugin\");\n+ let pluginBenchmark = this.benchmarks.aggregate.get(\n+ \"Configuration addPlugin\"\n+ );\nif (typeof plugin === \"function\") {\n- pluginBench.before();\n+ pluginBenchmark.before();\n+ this.benchmarks.config;\nlet configFunction = plugin;\nconfigFunction(this, options);\n- pluginBench.after();\n+ pluginBenchmark.after();\n} else if (plugin && plugin.configFunction) {\n- pluginBench.before();\n+ pluginBenchmark.before();\nif (options && typeof options.init === \"function\") {\noptions.init.call(this, plugin.initArguments || {});\n}\nplugin.configFunction(this, options);\n- pluginBench.after();\n+ pluginBenchmark.after();\n} else {\nthrow new UserConfigError(\n\"Invalid EleventyConfig.addPlugin signature. Should be a function or a valid Eleventy plugin object.\"\n@@ -478,7 +496,7 @@ class UserConfig {\n);\n}\n- this.nunjucksAsyncShortcodes[name] = bench.add(\n+ this.nunjucksAsyncShortcodes[name] = this.benchmarks.config.add(\n`\"${name}\" Nunjucks Async Shortcode`,\ncallback\n);\n@@ -499,7 +517,7 @@ class UserConfig {\n);\n}\n- this.nunjucksShortcodes[name] = bench.add(\n+ this.nunjucksShortcodes[name] = this.benchmarks.config.add(\n`\"${name}\" Nunjucks Shortcode`,\ncallback\n);\n@@ -518,7 +536,7 @@ class UserConfig {\n);\n}\n- this.liquidShortcodes[name] = bench.add(\n+ this.liquidShortcodes[name] = this.benchmarks.config.add(\n`\"${name}\" Liquid Shortcode`,\ncallback\n);\n@@ -536,7 +554,7 @@ class UserConfig {\n);\n}\n- this.handlebarsShortcodes[name] = bench.add(\n+ this.handlebarsShortcodes[name] = this.benchmarks.config.add(\n`\"${name}\" Handlebars Shortcode`,\ncallback\n);\n@@ -574,7 +592,7 @@ class UserConfig {\n);\n}\n- this.nunjucksAsyncPairedShortcodes[name] = bench.add(\n+ this.nunjucksAsyncPairedShortcodes[name] = this.benchmarks.config.add(\n`\"${name}\" Nunjucks Async Paired Shortcode`,\ncallback\n);\n@@ -595,7 +613,7 @@ class UserConfig {\n);\n}\n- this.nunjucksPairedShortcodes[name] = bench.add(\n+ this.nunjucksPairedShortcodes[name] = this.benchmarks.config.add(\n`\"${name}\" Nunjucks Paired Shortcode`,\ncallback\n);\n@@ -614,7 +632,7 @@ class UserConfig {\n);\n}\n- this.liquidPairedShortcodes[name] = bench.add(\n+ this.liquidPairedShortcodes[name] = this.benchmarks.config.add(\n`\"${name}\" Liquid Paired Shortcode`,\ncallback\n);\n@@ -632,7 +650,7 @@ class UserConfig {\n);\n}\n- this.handlebarsPairedShortcodes[name] = bench.add(\n+ this.handlebarsPairedShortcodes[name] = this.benchmarks.config.add(\n`\"${name}\" Handlebars Paired Shortcode`,\ncallback\n);\n@@ -650,7 +668,7 @@ class UserConfig {\n);\n}\n- this.javascriptFunctions[name] = bench.add(\n+ this.javascriptFunctions[name] = this.benchmarks.config.add(\n`\"${name}\" JavaScript Function`,\ncallback\n);\n@@ -767,6 +785,7 @@ class UserConfig {\nextensionMap: this.extensionMap,\nquietMode: this.quietMode,\nevents: this.events,\n+ benchmarkManager: this.benchmarkManager,\nplugins: this.plugins,\nuseTemplateCache: this.useTemplateCache,\nprecompiledCollections: this.precompiledCollections,\n"
},
{
"change_type": "MODIFY",
"old_path": "test/BenchmarkTest.js",
"new_path": "test/BenchmarkTest.js",
"diff": "const test = require(\"ava\");\nconst Benchmark = require(\"../src/Benchmark\");\n-function between(t, value, lowerBound, upperBound) {\n- t.truthy(value >= lowerBound);\n- t.truthy(value <= upperBound);\n-}\n-\ntest(\"Standard Benchmark\", async (t) => {\nawait new Promise((resolve) => {\nlet b = new Benchmark();\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -278,6 +278,8 @@ test(\"Two Eleventies, two configs!!! (config used to be a global)\", async (t) =>\nlet elev2 = new Eleventy();\nt.not(elev1.eleventyConfig, elev2.eleventyConfig);\n+ elev1.config.benchmarkManager = null;\n+ elev2.config.benchmarkManager = null;\nt.is(JSON.stringify(elev1.config), JSON.stringify(elev2.config));\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePassthroughTest.js",
"new_path": "test/TemplatePassthroughTest.js",
"diff": "const test = require(\"ava\");\n+const TemplateConfig = require(\"../src/TemplateConfig\");\nconst TemplatePassthrough = require(\"../src/TemplatePassthrough\");\nconst getTemplatePassthrough = (path, outputDir, inputDir) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let config = eleventyConfig.getConfig();\n+\nif (typeof path === \"object\") {\n- return new TemplatePassthrough(path, outputDir, inputDir);\n+ return new TemplatePassthrough(path, outputDir, inputDir, config);\n}\nreturn new TemplatePassthrough(\n{ inputPath: path, outputPath: true },\noutputDir,\n- inputDir\n+ inputDir,\n+ config\n);\n};\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Benchmarks should not be a global (this is bad for serverless local dev) |
699 | 12.01.2022 11:00:49 | 21,600 | f91a5fce2c27c58ecd6955221bf04239d71c4e11 | Issue with duplicate permalinks when `build` missing from permalink object. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -627,7 +627,7 @@ class TemplateMap {\nlet warnings = {};\nfor (let entry of this.map) {\nfor (let page of entry._pages) {\n- if (page.url === false) {\n+ if (page.outputPath === false || page.url === false) {\n// do nothing (also serverless)\n} else if (!permalinks[page.url]) {\npermalinks[page.url] = [entry.inputPath];\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Issue with duplicate permalinks when `build` missing from permalink object. |
699 | 13.01.2022 10:23:26 | 21,600 | f3201b1ea15cbd55953494e214e6280a498463e1 | If a page has an Array of available serverless URLs, the serverlessUrl filter will return only the URLs that match (instead of throwing an error). If no results match, then an error will be thrown. | [
{
"change_type": "MODIFY",
"old_path": "src/Filters/ServerlessUrl.js",
"new_path": "src/Filters/ServerlessUrl.js",
"diff": "@@ -7,7 +7,30 @@ function stringify(url, urlData = {}) {\nmodule.exports = function (url, urlData = {}) {\nif (Array.isArray(url)) {\n- return url.slice().map((entry) => stringify(entry, urlData));\n+ let errors = [];\n+ let urls = url\n+ .slice()\n+ .map((entry) => {\n+ // if multiple serverless URLs exist, return the first one that matches\n+ let result = false;\n+ try {\n+ result = stringify(entry, urlData);\n+ } catch (e) {\n+ errors.push(e.message);\n+ } finally {\n+ return result;\n+ }\n+ })\n+ .filter((entry) => !!entry);\n+\n+ if (!urls.length) {\n+ throw new Error(\n+ \"Looked through an array of serverless URLs but found no matches, errors: \" +\n+ errors.join(\";\")\n+ );\n+ }\n+\n+ return urls;\n}\nreturn stringify(url, urlData);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePermalink.js",
"new_path": "src/TemplatePermalink.js",
"diff": "@@ -25,12 +25,7 @@ class TemplatePermalink {\ncontinue;\n}\nif (key !== \"build\" && link[key] !== false) {\n- // is array of serverless urls, use the first one\n- if (Array.isArray(link[key])) {\n- this.primaryServerlessUrl = link[key][0];\n- } else {\n- this.primaryServerlessUrl = link[key];\n- }\n+ this.primaryServerlessUrl = link[key]; // can be an array or string\n}\nbreak;\n}\n@@ -108,11 +103,25 @@ class TemplatePermalink {\ntoHref() {\nif (this.primaryServerlessUrl) {\nif (this.serverlessPathData) {\n- return serverlessUrlFilter(\n+ let urls = serverlessUrlFilter(\nthis.primaryServerlessUrl,\nthis.serverlessPathData\n);\n+\n+ // Array of *matching* serverless urls only\n+ if (Array.isArray(urls)) {\n+ // return first\n+ return urls[0];\n+ }\n+\n+ return urls;\n+ }\n+\n+ if (Array.isArray(this.primaryServerlessUrl)) {\n+ // return first\n+ return this.primaryServerlessUrl[0];\n}\n+\nreturn this.primaryServerlessUrl;\n} else if (!this.buildLink) {\n// empty or false\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | If a page has an Array of available serverless URLs, the serverlessUrl filter will return only the URLs that match (instead of throwing an error). If no results match, then an error will be thrown. |
699 | 16.01.2022 14:45:19 | 21,600 | 08fe54e03da025cda24c4b25b5b8a8d0007b4689 | Minor tweaks to help with the plugin | [
{
"change_type": "MODIFY",
"old_path": "src/BenchmarkGroup.js",
"new_path": "src/BenchmarkGroup.js",
"diff": "@@ -66,6 +66,10 @@ class BenchmarkGroup {\nthis.minimumThresholdPercent = val;\n}\n+ has(type) {\n+ return !!this.benchmarks[type];\n+ }\n+\nget(type) {\nif (!this.benchmarks[type]) {\nthis.benchmarks[type] = new Benchmark();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/BenchmarkManager.js",
"new_path": "src/BenchmarkManager.js",
"diff": "@@ -29,6 +29,10 @@ class BenchmarkManager {\nthis.isVerbose = !!isVerbose;\n}\n+ hasBenchmarkGroup(name) {\n+ return name in this.benchmarkGroups;\n+ }\n+\ngetBenchmarkGroup(name) {\nif (!this.benchmarkGroups[name]) {\nthis.benchmarkGroups[name] = new BenchmarkGroup();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -290,9 +290,7 @@ class TemplateContent {\n}\nlet templateBenchmark = this.bench.get(\"Template Compile\");\n- let inputPathBenchmark = this.bench.get(\n- `> Template Compile > ${this.inputPath}`\n- );\n+ let inputPathBenchmark = this.bench.get(`> Compile > ${this.inputPath}`);\ntemplateBenchmark.before();\ninputPathBenchmark.before();\nlet fn = await this.templateRender.getCompiledTemplate(str);\n@@ -416,14 +414,26 @@ class TemplateContent {\nlet inputPathBenchmark = this.bench.get(\n`> Render > ${this.inputPath}${paginationSuffix.join(\"\")}`\n);\n+ let outputPathBenchmark;\n+ if (data.page && data.page.outputPath) {\n+ outputPathBenchmark = this.bench.get(\n+ `> Render > ${data.page.outputPath}`\n+ );\n+ }\ntemplateBenchmark.before();\nif (inputPathBenchmark) {\ninputPathBenchmark.before();\n}\n+ if (outputPathBenchmark) {\n+ outputPathBenchmark.before();\n+ }\nlet rendered = await fn(data);\n+ if (outputPathBenchmark) {\n+ outputPathBenchmark.after();\n+ }\nif (inputPathBenchmark) {\ninputPathBenchmark.after();\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Minor tweaks to help with the https://github.com/11ty/eleventy-plugin-directory-output plugin |
719 | 07.02.2022 13:43:07 | 28,800 | 3ada1047f217c9a29d8129f6974975180d702e96 | Support rendering empty data in pagination | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/Pagination.js",
"new_path": "src/Plugins/Pagination.js",
"diff": "@@ -191,7 +191,13 @@ class Pagination {\nthrow new Error(\"Missing `setData` call for Pagination object.\");\n}\n- return lodashChunk(this.target, this.size);\n+ const chunks = lodashChunk(this.target, this.size);\n+\n+ if (this.data.pagination && this.data.pagination.renderEmpty) {\n+ return chunks.length ? chunks : [[]];\n+ } else {\n+ return chunks;\n+ }\n}\n// TODO this name is not good\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Support rendering empty data in pagination |
699 | 15.02.2022 14:23:55 | 21,600 | 3a7f568da165e5bee1955a240919c69298f6b80d | Swap to use internal IsPlainObject utility rather than lodash/isPlainObject for performance reasons. See | [
{
"change_type": "MODIFY",
"old_path": "src/ComputedDataProxy.js",
"new_path": "src/ComputedDataProxy.js",
"diff": "const lodashSet = require(\"lodash/set\");\nconst lodashGet = require(\"lodash/get\");\n-const lodashIsPlainObject = require(\"lodash/isPlainObject\");\n+const isPlainObject = require(\"./Util/isPlainObject\");\n/* Calculates computed data using Proxies */\nclass ComputedDataProxy {\n@@ -13,7 +13,7 @@ class ComputedDataProxy {\n}\nisArrayOrPlainObject(data) {\n- return Array.isArray(data) || lodashIsPlainObject(data);\n+ return Array.isArray(data) || isPlainObject(data);\n}\ngetProxyData(data, keyRef) {\n@@ -97,7 +97,7 @@ class ComputedDataProxy {\n}\n_getProxyData(data, keyRef, parentKey = \"\") {\n- if (lodashIsPlainObject(data)) {\n+ if (isPlainObject(data)) {\nreturn this._getProxyForObject(data, keyRef, parentKey);\n} else if (Array.isArray(data)) {\nreturn this._getProxyForArray(data, keyRef, parentKey);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Plugins/RenderPlugin.js",
"new_path": "src/Plugins/RenderPlugin.js",
"diff": "const fs = require(\"fs\");\nconst fsp = fs.promises;\n-const lodashIsPlainObject = require(\"lodash/isPlainObject\");\n+const isPlainObject = require(\"../Util/IsPlainObject\");\n// TODO add a first-class Markdown component to expose this using Markdown-only syntax (will need to be synchronous for markdown-it)\n@@ -276,7 +276,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n}\n// if the user passes a string or other literal, remap to an object.\n- if (!lodashIsPlainObject(data)) {\n+ if (!isPlainObject(data)) {\ndata = {\n_: data,\n};\n@@ -309,7 +309,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n}\n// if the user passes a string or other literal, remap to an object.\n- if (!lodashIsPlainObject(data)) {\n+ if (!isPlainObject(data)) {\ndata = {\n_: data,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -6,7 +6,7 @@ const mkdir = util.promisify(fs.mkdir);\nconst os = require(\"os\");\nconst path = require(\"path\");\nconst normalize = require(\"normalize-path\");\n-const isPlainObject = require(\"lodash/isPlainObject\");\n+const isPlainObject = require(\"./Util/IsPlainObject\");\nconst lodashGet = require(\"lodash/get\");\nconst lodashSet = require(\"lodash/set\");\nconst { DateTime } = require(\"luxon\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateBehavior.js",
"new_path": "src/TemplateBehavior.js",
"diff": "-const isPlainObject = require(\"lodash/isPlainObject\");\n+const isPlainObject = require(\"./Util/IsPlainObject\");\nclass TemplateBehavior {\nconstructor(config) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "-const isPlainObject = require(\"lodash/isPlainObject\");\n+const isPlainObject = require(\"./Util/IsPlainObject\");\nconst DependencyGraph = require(\"dependency-graph\").DepGraph;\nconst TemplateCollection = require(\"./TemplateCollection\");\nconst EleventyErrorUtil = require(\"./EleventyErrorUtil\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePermalink.js",
"new_path": "src/TemplatePermalink.js",
"diff": "const path = require(\"path\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst normalize = require(\"normalize-path\");\n-const isPlainObject = require(\"lodash/isPlainObject\");\n+const isPlainObject = require(\"./Util/IsPlainObject\");\nconst serverlessUrlFilter = require(\"./Filters/ServerlessUrl\");\nclass TemplatePermalink {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Util/IsPlainObject.js",
"diff": "+/* Prior art: this utility was created for https://github.com/11ty/eleventy/issues/2214\n+\n+ * Inspired by implementations from `is-what`, `typechecker`, `jQuery`, and `lodash`\n+\n+ * `is-what`\n+ * More reading at https://www.npmjs.com/package/is-what#user-content-isplainobject-vs-isanyobject\n+ * if (Object.prototype.toString.call(value).slice(8, -1) !== 'Object') return false;\n+ * return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;\n+\n+ * `typechecker`\n+ * return value !== null && typeof value === 'object' && value.__proto__ === Object.prototype;\n+\n+ * Notably jQuery and lodash have very similar implementations.\n+\n+ * For later, remember the `value === Object(value)` trick\n+ */\n+\n+module.exports = function (value) {\n+ if (value === null || typeof value !== \"object\") {\n+ return false;\n+ }\n+ let proto = Object.getPrototypeOf(value);\n+ return !proto || proto === Object.prototype;\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Util/Merge.js",
"new_path": "src/Util/Merge.js",
"diff": "-const isPlainObject = require(\"lodash/isPlainObject\");\n+const isPlainObject = require(\"../Util/IsPlainObject\");\nconst OVERRIDE_PREFIX = \"override:\";\nfunction getMergedItem(target, source, parentKey) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/IsPlainObjectTest.js",
"diff": "+const test = require(\"ava\");\n+const isPlainObject = require(\"../src/Util/IsPlainObject\");\n+\n+test(\"isPlainObject\", (t) => {\n+ t.is(isPlainObject(null), false);\n+ t.is(isPlainObject(undefined), false);\n+ t.is(isPlainObject(1), false);\n+ t.is(isPlainObject(true), false);\n+ t.is(isPlainObject(false), false);\n+ t.is(isPlainObject(\"string\"), false);\n+ t.is(isPlainObject([]), false);\n+ t.is(isPlainObject(Symbol(\"a\")), false);\n+ t.is(\n+ isPlainObject(function () {}),\n+ false\n+ );\n+});\n+\n+// https://github.com/lodash/lodash/blob/ddfd9b11a0126db2302cb70ec9973b66baec0975/test/test.js#L11447\n+// Notably, did not include the test for DOM Elements.\n+test(\"Test from lodash.isPlainObject\", (t) => {\n+ t.is(isPlainObject({}), true);\n+ t.is(isPlainObject({ a: 1 }), true);\n+\n+ function Foo(a) {\n+ this.a = 1;\n+ }\n+\n+ t.is(isPlainObject({ constructor: Foo }), true);\n+ t.is(isPlainObject([1, 2, 3]), false);\n+ t.is(isPlainObject(new Foo(1)), false);\n+});\n+\n+test(\"Test from lodash.isPlainObject: should return `true` for objects with a `[[Prototype]]` of `null`\", (t) => {\n+ let obj = Object.create(null);\n+ t.is(isPlainObject(obj), true);\n+\n+ obj.constructor = Object.prototype.constructor;\n+ t.is(isPlainObject(obj), true);\n+});\n+\n+test(\"Test from lodash.isPlainObject: should return `true` for objects with a `valueOf` property\", (t) => {\n+ t.is(isPlainObject({ valueOf: 0 }), true);\n+});\n+\n+test(\"Test from lodash.isPlainObject: should return `true` for objects with a writable `Symbol.toStringTag` property\", (t) => {\n+ let obj = {};\n+ obj[Symbol.toStringTag] = \"X\";\n+\n+ t.is(isPlainObject(obj), true);\n+});\n+\n+test(\"Test from lodash.isPlainObject: should return `false` for objects with a custom `[[Prototype]]`\", (t) => {\n+ let obj = Object.create({ a: 1 });\n+ t.is(isPlainObject(obj), false);\n+});\n+\n+test(\"Test from lodash.isPlainObject (modified): should return `false` for non-Object objects\", (t) => {\n+ t.is(isPlainObject(arguments), true); // WARNING: lodash was false\n+ t.is(isPlainObject(Error), false);\n+ t.is(isPlainObject(Math), true); // WARNING: lodash was false\n+});\n+\n+test(\"Test from lodash.isPlainObject: should return `false` for non-objects\", (t) => {\n+ t.is(isPlainObject(true), false);\n+ t.is(isPlainObject(\"a\"), false);\n+ t.is(isPlainObject(Symbol(\"a\")), false);\n+});\n+\n+test(\"Test from lodash.isPlainObject (modified): should return `true` for objects with a read-only `Symbol.toStringTag` property\", (t) => {\n+ var object = {};\n+ Object.defineProperty(object, Symbol.toStringTag, {\n+ configurable: true,\n+ enumerable: false,\n+ writable: false,\n+ value: \"X\",\n+ });\n+\n+ t.is(isPlainObject(object), true); // WARNING: lodash was false\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Swap to use internal IsPlainObject utility rather than lodash/isPlainObject for performance reasons. See #2214. |
699 | 15.02.2022 14:38:18 | 21,600 | ffdad870233ec0370804cb876e3bedac63ad3ad9 | Fixes test failure with `Eleventy addGlobalData should run once.` in EleventyTest.js | [
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -372,7 +372,7 @@ test(\"Can Eleventy run two executeBuilds in parallel?\", async (t) => {\ntest(\"Eleventy addGlobalData should run once.\", async (t) => {\nlet count = 0;\n- let elev = new Eleventy(\"./test/stubs\", \"./test/stubs/_site\", {\n+ let elev = new Eleventy(\"./test/stubs-noop/\", \"./test/stubs-noop/_site\", {\nconfig: function (eleventyConfig) {\neleventyConfig.addGlobalData(\"count\", () => {\ncount++;\n"
},
{
"change_type": "ADD",
"old_path": "test/stubs-noop/test.txt",
"new_path": "test/stubs-noop/test.txt",
"diff": ""
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/dependencies/two-deps.11ty.js",
"new_path": "test/stubs/dependencies/two-deps.11ty.js",
"diff": "const dep1 = require(\"./dep1\");\nconst dep2 = require(\"./dep2\");\n+\n+module.exports = \"\";\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fixes test failure with `Eleventy addGlobalData should run once.` in EleventyTest.js |
699 | 16.02.2022 13:22:11 | 21,600 | 64b250588e9e0c6a185100b0dac21901c2a936cf | Update a few dependencies. | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "]\n},\n\"devDependencies\": {\n- \"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.3\",\n+ \"@11ty/eleventy-plugin-syntaxhighlight\": \"^4.0.0\",\n\"@11ty/eleventy-plugin-vue\": \"1.0.0-canary.8\",\n- \"@vue/server-renderer\": \"^3.2.26\",\n+ \"@vue/server-renderer\": \"^3.2.31\",\n\"ava\": \"^4.0.1\",\n\"husky\": \"^7.0.4\",\n\"js-yaml\": \"^4.1.0\",\n\"lint-staged\": \"^11.2.6\",\n\"markdown-it-emoji\": \"^2.0.0\",\n- \"marked\": \"^4.0.9\",\n+ \"marked\": \"^4.0.12\",\n\"nyc\": \"^15.1.0\",\n\"prettier\": \"^2.5.1\",\n\"rimraf\": \"^3.0.2\",\n- \"sass\": \"^1.47.0\",\n+ \"sass\": \"^1.49.7\",\n\"toml\": \"^3.0.0\",\n\"vue\": \"^3.2.26\"\n},\n\"@iarna/toml\": \"^2.2.5\",\n\"@sindresorhus/slugify\": \"^1.1.2\",\n\"browser-sync\": \"^2.27.7\",\n- \"chokidar\": \"^3.5.2\",\n+ \"chokidar\": \"^3.5.3\",\n\"debug\": \"^4.3.3\",\n\"dependency-graph\": \"^0.11.0\",\n\"ejs\": \"^3.1.6\",\n- \"fast-glob\": \"^3.2.9\",\n+ \"fast-glob\": \"^3.2.11\",\n\"graceful-fs\": \"^4.2.9\",\n\"gray-matter\": \"^4.0.3\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.7.7\",\n\"is-glob\": \"^4.0.3\",\n\"kleur\": \"^4.1.4 \",\n- \"liquidjs\": \"^9.32.0\",\n+ \"liquidjs\": \"^9.34.0\",\n\"lodash\": \"^4.17.21\",\n\"luxon\": \"^2.3.0\",\n\"markdown-it\": \"^12.3.2\",\n\"please-upgrade-node\": \"^3.2.0\",\n\"pretty\": \"^2.0.0\",\n\"pug\": \"^3.0.2\",\n- \"recursive-copy\": \"^2.0.13\",\n+ \"recursive-copy\": \"^2.0.14\",\n\"semver\": \"^7.3.5\",\n\"slugify\": \"^1.6.5\"\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Update a few dependencies. |
699 | 16.02.2022 13:53:48 | 21,600 | ad6816cad9dfa0e57feab02c3de14fee54e49c36 | Old config file, not being used. | [
{
"change_type": "DELETE",
"old_path": ".jsdoc.conf.json",
"new_path": null,
"diff": "-{\n- \"plugins\": [\"plugins/markdown\"],\n- \"templates\": {\n- \"systemName\": \"Eleventy\",\n- \"theme\": \"cosmo\",\n- \"navType\": \"vertical\",\n- \"inverseNav\": true,\n- \"syntaxTheme\": \"dark\",\n- \"search\": false\n- }\n-}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Old config file, not being used. |
699 | 16.02.2022 17:32:05 | 21,600 | 3715a2270252bb550a5c985a9a99158b76a68aa1 | Fixes (though it was already fixed, but this is a sanity check) | [
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -398,3 +398,10 @@ test(\"Eleventy addGlobalData can feed layouts to populate data cascade with layo\nt.deepEqual(result.data, { LayoutData: 123 });\nt.is(result.content.trim(), \"FromLayoutlayout.njk\");\n});\n+\n+test(\"Unicode in front matter `tags`, issue #670\", async (t) => {\n+ let elev = new Eleventy(\"./test/stubs-670/\", \"./test/stubs-670/_site\");\n+\n+ let [result] = await elev.toJSON();\n+ t.is(result.content.trim(), \"./test/stubs-670/content.liquid\");\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fixes #670 (though it was already fixed, but this is a sanity check) |
699 | 16.02.2022 22:09:36 | 21,600 | 2c7c65b136a0601df1829d7954f54de7af504935 | Fixes brittle test for | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-670/index.njk",
"diff": "+{{ collections | length }},{% for key,item in collections %}{{ key }},{% endfor %}\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fixes brittle test for #670 |
699 | 17.02.2022 17:13:13 | 21,600 | 8f35e553f80a9a75da3b2eb1a923ecce87f65573 | Fixes
Adds `date: "git Last Modified"` support to use last git commit as `page.date` variable. | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"@sindresorhus/slugify\": \"^1.1.2\",\n\"browser-sync\": \"^2.27.7\",\n\"chokidar\": \"^3.5.3\",\n+ \"cross-spawn\": \"^7.0.3\",\n\"debug\": \"^4.3.3\",\n\"dependency-graph\": \"^0.11.0\",\n\"ejs\": \"^3.1.6\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -6,11 +6,14 @@ const mkdir = util.promisify(fs.mkdir);\nconst os = require(\"os\");\nconst path = require(\"path\");\nconst normalize = require(\"normalize-path\");\n-const isPlainObject = require(\"./Util/IsPlainObject\");\nconst lodashGet = require(\"lodash/get\");\nconst lodashSet = require(\"lodash/set\");\nconst { DateTime } = require(\"luxon\");\n+const isPlainObject = require(\"./Util/IsPlainObject\");\n+const ConsoleLogger = require(\"./Util/ConsoleLogger\");\n+const getDateFromGitLastUpdated = require(\"./Util/DateGitLastUpdated\");\n+\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateContent = require(\"./TemplateContent\");\nconst TemplatePath = require(\"./TemplatePath\");\n@@ -19,7 +22,6 @@ const TemplateLayout = require(\"./TemplateLayout\");\nconst TemplateFileSlug = require(\"./TemplateFileSlug\");\nconst ComputedData = require(\"./ComputedData\");\nconst Pagination = require(\"./Plugins/Pagination\");\n-const ConsoleLogger = require(\"./Util/ConsoleLogger\");\nconst TemplateBehavior = require(\"./TemplateBehavior\");\nconst TemplateContentPrematureUseError = require(\"./Errors/TemplateContentPrematureUseError\");\n@@ -1016,13 +1018,25 @@ class Template extends TemplateContent {\n// YAML does its own date parsing\ndebug(\"getMappedDate: YAML parsed it: %o\", data.date);\nreturn data.date;\n- } else {\n- // string\n+ }\n+\n+ // special strings\n+ if (data.date.toLowerCase() === \"git last modified\") {\n+ let d = getDateFromGitLastUpdated(this.inputPath);\n+ if (d) {\n+ return d;\n+ }\n+\n+ // return now if this file is not yet available in `git`\n+ return Date.now();\n+ }\nif (data.date.toLowerCase() === \"last modified\") {\nreturn this._getDateInstance(\"ctimeMs\");\n- } else if (data.date.toLowerCase() === \"created\") {\n+ }\n+ if (data.date.toLowerCase() === \"created\") {\nreturn this._getDateInstance(\"birthtimeMs\");\n- } else {\n+ }\n+\n// try to parse with Luxon\nlet date = DateTime.fromISO(data.date, { zone: \"utc\" });\nif (!date.isValid) {\n@@ -1038,8 +1052,6 @@ class Template extends TemplateContent {\n);\nreturn date.toJSDate();\n- }\n- }\n} else {\nlet filepathRegex = this.inputPath.match(/(\\d{4}-\\d{2}-\\d{2})/);\nif (filepathRegex !== null) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Util/DateGitLastUpdated.js",
"diff": "+const spawn = require(\"cross-spawn\");\n+\n+/* Thank you to Vuepress!\n+ * https://github.com/vuejs/vuepress/blob/89440ce552675859189ed4ab254ce19c4bba5447/packages/%40vuepress/plugin-last-updated/index.js\n+ * MIT licensed: https://github.com/vuejs/vuepress/blob/89440ce552675859189ed4ab254ce19c4bba5447/LICENSE\n+ */\n+function getGitLastUpdatedTimeStamp(filePath) {\n+ return (\n+ parseInt(\n+ spawn\n+ .sync(\n+ \"git\",\n+ // Formats https://www.git-scm.com/docs/git-log#_pretty_formats\n+ // %at author date, UNIX timestamp\n+ [\"log\", \"-1\", \"--format=%at\", filePath]\n+ )\n+ .stdout.toString(\"utf-8\")\n+ ) * 1000\n+ );\n+}\n+\n+// return a Date\n+module.exports = function (inputPath) {\n+ let timestamp = getGitLastUpdatedTimeStamp(inputPath);\n+ if (timestamp) {\n+ return new Date(timestamp);\n+ }\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs-142/index.njk",
"new_path": "test/stubs-142/index.njk",
"diff": "---\ndate: git Last Modified\n---\n-{{ page.date }}\n\\ No newline at end of file\n+{{ page.date.getTime() }}\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fixes #142.
Adds `date: "git Last Modified"` support to use last git commit as `page.date` variable. |
699 | 18.02.2022 14:40:57 | 21,600 | 30e355129382e81678e3901b55536dc2881b4ebf | Fixes changes to use event.rawUrl workaround. Also populates rawUrl for local development. | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -238,6 +238,7 @@ class BundlerHelper {\nlet result = await serverlessFunction.handler({\nhttpMethod: \"GET\",\npath: url.pathname,\n+ rawUrl: url.toString(),\n// @netlify/functions builder overwrites these to {} intentionally\n// See https://github.com/netlify/functions/issues/38\nqueryStringParameters: queryParams,\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fixes #2221, changes to use event.rawUrl workaround. Also populates rawUrl for local development. |
735 | 22.02.2022 13:48:12 | -3,600 | 2db04534a7c319f20008e08d05f75782f718cdc9 | fix: wrapper for json parse to pass only one argument | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -492,11 +492,12 @@ class TemplateData {\nreturn this._parseDataFile(path, rawImports, ignoreProcessing, parser);\n} else if (extension === \"json\") {\n// File to string, parse with JSON (preprocess)\n+ const parser = (content) => JSON.parse(content)\nreturn this._parseDataFile(\npath,\nrawImports,\nignoreProcessing,\n- JSON.parse\n+ parser\n);\n} else {\nthrow new TemplateDataParseError(\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | fix: wrapper for json parse to pass only one argument |
699 | 23.02.2022 15:53:26 | 21,600 | 7091b3db1d78c17250574dfc81428c7017a9ea53 | Somehow this test needs a join now. | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderLiquidTest.js",
"new_path": "test/TemplateRenderLiquidTest.js",
"diff": "@@ -1098,7 +1098,7 @@ test(\"Liquid bypass compilation\", async (t) => {\ntest(\"Liquid reverse filter in {{ }}\", async (t) => {\n// https://liquidjs.com/filters/reverse.html\nlet fn = await getNewTemplateRender(\"liquid\").getCompiledTemplate(\n- \"{{ test | reverse }}\"\n+ \"{{ test | reverse | join: ',' }}\"\n);\nt.is(await fn({ test: [1, 2, 3] }), \"3,2,1\");\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Somehow this test needs a join now. |
711 | 27.02.2022 19:09:14 | -3,600 | 547804bd96032f9cc0daf31202f3ad4804ec66b1 | standardize this in nunjucks filters | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -174,10 +174,22 @@ class Nunjucks extends TemplateEngine {\naddFilters(helpers, isAsync) {\nfor (let name in helpers) {\n- this.njkEnv.addFilter(name, helpers[name], isAsync);\n+ this.njkEnv.addFilter(name, this.wrapFilter(helpers[name]), isAsync);\n}\n}\n+ wrapFilter(filter) {\n+ let jsFuncs = this.config.javascriptFunctions;\n+ return function () {\n+ const newThis = {\n+ ...jsFuncs,\n+ ctx: this.ctx,\n+ page: this.ctx.page,\n+ };\n+ return filter.call(newThis, ...arguments);\n+ };\n+ }\n+\naddCustomTags(tags) {\nfor (let name in tags) {\nthis.addTag(name, tags[name]);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | standardize this in nunjucks filters |
711 | 27.02.2022 19:09:30 | -3,600 | 84b166a99628ce73ef2067308806db8c6e315097 | standardize this in liquid filters | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Liquid.js",
"new_path": "src/Engines/Liquid.js",
"diff": "@@ -65,7 +65,23 @@ class Liquid extends TemplateEngine {\n}\naddFilter(name, filter) {\n- this.liquidLib.registerFilter(name, filter);\n+ this.liquidLib.registerFilter(name, this.wrapFilter(filter));\n+ }\n+\n+ wrapFilter(filter) {\n+ let jsFuncs = this.config.javascriptFunctions;\n+ return function () {\n+ const newThis = {\n+ ...jsFuncs,\n+ ctx: {\n+ ...this.context.environments,\n+ },\n+ page: {\n+ ...this.context.environments.page,\n+ },\n+ };\n+ return filter.call(newThis, ...arguments);\n+ };\n}\naddTag(name, tagFn) {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | standardize this in liquid filters |
711 | 27.02.2022 19:09:46 | -3,600 | 6fca795eb3d97715d93726820c66506a91552eb2 | standardize this in handlebars helper | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Handlebars.js",
"new_path": "src/Engines/Handlebars.js",
"diff": "@@ -27,9 +27,22 @@ class Handlebars extends TemplateEngine {\nthis.handlebarsLib.registerHelper(name, callback);\n}\n+ wrapHelper(callback) {\n+ let jsFuncs = this.config.javascriptFunctions;\n+ return function () {\n+ const newThis = {\n+ ...jsFuncs,\n+ ctx: this,\n+ page: this.page,\n+ };\n+ // Handlebars passes an additional argument\n+ return callback.call(newThis, ...arguments);\n+ };\n+ }\n+\naddHelpers(helpers) {\nfor (let name in helpers) {\n- this.addHelper(name, helpers[name]);\n+ this.addHelper(name, this.wrapHelper(helpers[name]));\n}\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | standardize this in handlebars helper |
711 | 27.02.2022 19:10:02 | -3,600 | de99f7e01a2b2664851de299866e0995f38298e4 | standardize this in javascript function | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/JavaScript.js",
"new_path": "src/Engines/JavaScript.js",
"diff": "@@ -105,13 +105,25 @@ class JavaScript extends TemplateEngine {\nif (key === \"page\") {\n// do nothing\n} else {\n- // note: bind creates a new function\n- fns[key] = configFns[key].bind(inst);\n+ // note: wrapping creates a new function\n+ fns[key] = this.wrapJavaScriptFunction(inst, configFns[key]);\n}\n}\nreturn fns;\n}\n+ wrapJavaScriptFunction(inst, fn) {\n+ let jsFuncs = this.config.javascriptFunctions;\n+ return function () {\n+ const newThis = {\n+ ...jsFuncs,\n+ ctx: inst,\n+ page: inst.page,\n+ };\n+ return fn.call(newThis, ...arguments);\n+ };\n+ }\n+\nasync compile(str, inputPath) {\nlet inst;\nif (str) {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | standardize this in javascript function |
711 | 27.02.2022 19:56:36 | -3,600 | 1706516c7855ef6243a507253ea583a125160776 | make all filters backwards compatible | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Handlebars.js",
"new_path": "src/Engines/Handlebars.js",
"diff": "@@ -27,22 +27,20 @@ class Handlebars extends TemplateEngine {\nthis.handlebarsLib.registerHelper(name, callback);\n}\n- wrapHelper(callback) {\n- let jsFuncs = this.config.javascriptFunctions;\n+ static wrapHelper(callback) {\nreturn function () {\nconst newThis = {\n- ...jsFuncs,\n+ ...this,\nctx: this,\n- page: this.page,\n+ // page: this.page\n};\n- // Handlebars passes an additional argument\nreturn callback.call(newThis, ...arguments);\n};\n}\naddHelpers(helpers) {\nfor (let name in helpers) {\n- this.addHelper(name, this.wrapHelper(helpers[name]));\n+ this.addHelper(name, Handlebars.wrapHelper(helpers[name]));\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/JavaScript.js",
"new_path": "src/Engines/JavaScript.js",
"diff": "@@ -106,17 +106,16 @@ class JavaScript extends TemplateEngine {\n// do nothing\n} else {\n// note: wrapping creates a new function\n- fns[key] = this.wrapJavaScriptFunction(inst, configFns[key]);\n+ fns[key] = JavaScript.wrapJavaScriptFunction(inst, configFns[key]);\n}\n}\nreturn fns;\n}\n- wrapJavaScriptFunction(inst, fn) {\n- let jsFuncs = this.config.javascriptFunctions;\n+ static wrapJavaScriptFunction(inst, fn) {\nreturn function () {\nconst newThis = {\n- ...jsFuncs,\n+ ...this,\nctx: inst,\npage: inst.page,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Liquid.js",
"new_path": "src/Engines/Liquid.js",
"diff": "@@ -65,20 +65,16 @@ class Liquid extends TemplateEngine {\n}\naddFilter(name, filter) {\n- this.liquidLib.registerFilter(name, this.wrapFilter(filter));\n+ this.liquidLib.registerFilter(name, Liquid.wrapFilter(filter));\n}\n- wrapFilter(filter) {\n- let jsFuncs = this.config.javascriptFunctions;\n+ static wrapFilter(filter) {\nreturn function () {\n+ let ctx = this.context.environments;\nconst newThis = {\n- ...jsFuncs,\n- ctx: {\n- ...this.context.environments,\n- },\n- page: {\n- ...this.context.environments.page,\n- },\n+ ...this,\n+ ctx: ctx,\n+ page: ctx.page,\n};\nreturn filter.call(newThis, ...arguments);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -174,16 +174,15 @@ class Nunjucks extends TemplateEngine {\naddFilters(helpers, isAsync) {\nfor (let name in helpers) {\n- this.njkEnv.addFilter(name, this.wrapFilter(helpers[name]), isAsync);\n+ this.njkEnv.addFilter(name, Nunjucks.wrapFilter(helpers[name]), isAsync);\n}\n}\n- wrapFilter(filter) {\n- let jsFuncs = this.config.javascriptFunctions;\n+ static wrapFilter(filter) {\nreturn function () {\nconst newThis = {\n- ...jsFuncs,\n- ctx: this.ctx,\n+ ...this,\n+ // ctx: this.ctx,\npage: this.ctx.page,\n};\nreturn filter.call(newThis, ...arguments);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | make all filters backwards compatible |
711 | 28.02.2022 11:17:04 | -3,600 | aec30ea7d924cd6c0868ba49fc93d66bd982887b | Provide the datacascade in this.ctx for 11ty.js | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/JavaScript.js",
"new_path": "src/Engines/JavaScript.js",
"diff": "@@ -96,7 +96,7 @@ class JavaScript extends TemplateEngine {\nreturn getJavaScriptData(inst, inputPath);\n}\n- getJavaScriptFunctions(inst) {\n+ getJavaScriptFunctions(inst, data) {\nlet fns = {};\nlet configFns = this.config.javascriptFunctions;\n@@ -106,17 +106,21 @@ class JavaScript extends TemplateEngine {\n// do nothing\n} else {\n// note: wrapping creates a new function\n- fns[key] = JavaScript.wrapJavaScriptFunction(inst, configFns[key]);\n+ fns[key] = JavaScript.wrapJavaScriptFunction(\n+ inst,\n+ data,\n+ configFns[key]\n+ );\n}\n}\nreturn fns;\n}\n- static wrapJavaScriptFunction(inst, fn) {\n+ static wrapJavaScriptFunction(inst, data, fn) {\nreturn function () {\nconst newThis = {\n...this,\n- ctx: inst,\n+ ctx: data,\npage: inst.page,\n};\nreturn fn.call(newThis, ...arguments);\n@@ -138,7 +142,7 @@ class JavaScript extends TemplateEngine {\nif (!inst.page || inst.page.url) {\ninst.page = data.page;\n}\n- Object.assign(inst, this.getJavaScriptFunctions(inst));\n+ Object.assign(inst, this.getJavaScriptFunctions(inst, data));\nreturn this.normalize(inst.render.call(inst, data));\n}.bind(this);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Provide the datacascade in this.ctx for 11ty.js |
699 | 03.03.2022 09:56:15 | 21,600 | 4a02b2b65588d5581f7f84d4fa190cba727fa788 | Refactor some of the client, streamline the morphdom event data | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"pug\": \"^3.0.2\",\n\"recursive-copy\": \"^2.0.14\",\n\"semver\": \"^7.3.5\",\n- \"serve-static\": \"^1.14.2\",\n\"slugify\": \"^1.6.5\",\n\"ws\": \"^8.5.0\"\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyServe.js",
"new_path": "src/EleventyServe.js",
"diff": "@@ -55,7 +55,7 @@ class EleventyServe {\n}\nif (!this._server) {\n- debug(\"Using fallback serve-static\");\n+ debug(\"Using default server.\");\nthis._server = EleventyServeAdapter.getServer(\n\"eleventy-server\",\nthis.config\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyServeAdapter.js",
"new_path": "src/EleventyServeAdapter.js",
"diff": "@@ -58,12 +58,16 @@ class EleventyServeAdapter {\n}\ngetOutputDirFilePath(filepath, filename = \"\") {\n- // TODO check absolute path of the file and output folder and make sure they overlap\n- if (filepath.startsWith(\"..\")) {\n+ let computedPath = path.join(this.config.dir.output, filepath, filename);\n+\n+ // Check that the file is in the output path (error if folks try use `..` in the filepath)\n+ let absComputedPath = TemplatePath.absolutePath(computedPath);\n+ let absOutputDir = TemplatePath.absolutePath(computedPath);\n+ if (!absComputedPath.startsWith(absOutputDir)) {\nthrow new Error(\"Invalid path\");\n}\n- return path.join(this.config.dir.output, filepath, filename);\n+ return computedPath;\n}\nisOutputFilePathExists(rawPath) {\n@@ -359,11 +363,16 @@ class EleventyServeAdapter {\nlet pathprefix = EleventyServeAdapter.normalizePathPrefix(\nthis.config.pathPrefix\n);\n- // Add pathPrefix to all template urls\nif (build.templates) {\n- build.templates = build.templates.map((tmpl) => {\n- tmpl.url = EleventyServeAdapter.joinUrlParts(pathprefix, tmpl.url);\n- return tmpl;\n+ build.templates = build.templates\n+ .filter((entry) => {\n+ // Filter to only include watched templates that were updated\n+ return (files || []).includes(entry.inputPath);\n+ })\n+ .map((entry) => {\n+ // Add pathPrefix to all template urls\n+ entry.url = EleventyServeAdapter.joinUrlParts(pathprefix, entry.url);\n+ return entry;\n});\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Refactor some of the client, streamline the morphdom event data |
699 | 04.03.2022 17:51:16 | 21,600 | f1e8b84a79aefd3228c62350163a3d3b1d3dd9ba | In progress. Still needs to be published | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"dependency-graph\": \"^0.11.0\",\n\"ejs\": \"^3.1.6\",\n\"fast-glob\": \"^3.2.11\",\n- \"finalhandler\": \"^1.1.2\",\n\"graceful-fs\": \"^4.2.9\",\n\"gray-matter\": \"^4.0.3\",\n\"hamljs\": \"^0.6.2\",\n\"pug\": \"^3.0.2\",\n\"recursive-copy\": \"^2.0.14\",\n\"semver\": \"^7.3.5\",\n- \"slugify\": \"^1.6.5\",\n- \"ws\": \"^8.5.0\"\n+ \"slugify\": \"^1.6.5\"\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -10,6 +10,7 @@ const EleventyWatch = require(\"./EleventyWatch\");\nconst EleventyWatchTargets = require(\"./EleventyWatchTargets\");\nconst EleventyFiles = require(\"./EleventyFiles\");\nconst ConsoleLogger = require(\"./Util/ConsoleLogger\");\n+const PathPrefixer = require(\"./Util/PathPrefixer\");\nconst TemplateConfig = require(\"./TemplateConfig\");\nconst { performance } = require(\"perf_hooks\");\n@@ -310,11 +311,6 @@ class Eleventy {\nret.push(`(${versionStr})`);\n}\n- let pathPrefix = this.config.pathPrefix;\n- if (pathPrefix && pathPrefix !== \"/\") {\n- return `Using pathPrefix: ${pathPrefix}\\n${ret.join(\" \")}`;\n- }\n-\nreturn ret.join(\" \");\n}\n@@ -687,13 +683,25 @@ Arguments:\nerror: writeResults.error,\n});\n} else {\n+ let normalizedPathPrefix = PathPrefixer.normalizePathPrefix(\n+ this.config.pathPrefix\n+ );\nawait this.eleventyServe.reload({\nfiles: this.watchManager.getActiveQueue(),\nsubtype: onlyCssChanges ? \"css\" : undefined,\nbuild: {\n// For later?\n// passthroughCopy: passthroughCopyResults,\n- templates: templateResults.flat(),\n+ templates: templateResults\n+ .flat()\n+ .filter((entry) => !!entry)\n+ .map((entry) => {\n+ entry.url = PathPrefixer.joinUrlParts(\n+ normalizedPathPrefix,\n+ entry.url\n+ );\n+ return entry;\n+ }),\n},\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyServe.js",
"new_path": "src/EleventyServe.js",
"diff": "-const path = require(\"path\");\n-\n+const EleventyServeAdapter = require(\"@11ty/eleventy-dev-server\");\nconst TemplatePath = require(\"./TemplatePath\");\n-const EleventyServeAdapter = require(\"./EleventyServeAdapter\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\n+const ConsoleLogger = require(\"./Util/ConsoleLogger\");\n+const PathPrefixer = require(\"./Util/PathPrefixer\");\nconst debug = require(\"debug\")(\"EleventyServe\");\nclass EleventyServeConfigError extends EleventyBaseError {}\n+const DEFAULT_SERVER_OPTIONS = {\n+ port: 8080,\n+};\n+\nclass EleventyServe {\nconstructor() {}\n@@ -29,44 +33,56 @@ class EleventyServe {\n}\ngetPathPrefix() {\n- return EleventyServeAdapter.normalizePathPrefix(this.config.pathPrefix);\n+ return PathPrefixer.normalizePathPrefix(this.config.pathPrefix);\n}\n- get server() {\n- if (this._server) {\n- return this._server;\n- }\n-\n- this._usingBrowserSync = true;\n-\n+ getBrowserSync() {\ntry {\n// Look for project browser-sync (peer dep)\nlet projectRequirePath = TemplatePath.absolutePath(\n\"./node_modules/browser-sync\"\n);\n- this._server = require(projectRequirePath);\n+ return require(projectRequirePath);\n} catch (e) {\ndebug(\"Could not find local project browser-sync.\");\n- try {\n- this._server = require(\"browser-sync\");\n- } catch (e) {\n- debug(\"Could not find globally installed browser-sync.\");\n+\n+ // This will work with a globally installed browser-sync\n+ // try {\n+ // this._server = require(\"browser-sync\");\n+ // } catch (e) {\n+ // debug(\"Could not find globally installed browser-sync.\");\n+ // }\n+ }\n}\n+\n+ get server() {\n+ if (this._server) {\n+ return this._server;\n}\n+ this._usingBrowserSync = true;\n+ this._server = this.getBrowserSync();\n+\nif (!this._server) {\n- debug(\"Using default server.\");\n+ this._usingBrowserSync = false;\n+ debug(\"Using Eleventy Serve server.\");\n+ // TODO option to use a different server than @11ty/eleventy-dev-server\nthis._server = EleventyServeAdapter.getServer(\n\"eleventy-server\",\n- this.config\n+ this.config.dir.output,\n+ this.getDefaultServerOptions(),\n+ {\n+ transformUrl: PathPrefixer.joinUrlParts,\n+ templatePath: TemplatePath,\n+ logger: new ConsoleLogger(true),\n+ }\n);\n- this._usingBrowserSync = false;\n}\nreturn this._server;\n}\n- getOptions(port) {\n+ getBrowserSyncOptions(port) {\nlet pathPrefix = this.getPathPrefix();\n// TODO customize this in Configuration API?\n@@ -83,7 +99,7 @@ class EleventyServe {\nreturn Object.assign(\n{\nserver: serverConfig,\n- port: port || 8080,\n+ port: port || DEFAULT_SERVER_OPTIONS.port,\nignore: [\"node_modules\"],\nwatch: false,\nopen: false,\n@@ -96,6 +112,28 @@ class EleventyServe {\n);\n}\n+ getDefaultServerOptions(port) {\n+ let opts = Object.assign(\n+ {\n+ pathPrefix: PathPrefixer.normalizePathPrefix(this.config.pathPrefix),\n+ },\n+ DEFAULT_SERVER_OPTIONS,\n+ this.config.serverOptions\n+ );\n+\n+ if (port) {\n+ return Object.assign(opts, { port });\n+ }\n+ return opts;\n+ }\n+\n+ getOptions(port) {\n+ if (this._usingBrowserSync === true || this.getBrowserSync()) {\n+ return this.getBrowserSyncOptions(port);\n+ }\n+ return this.getDefaultServerOptions(port);\n+ }\n+\nserve(port) {\nlet options = this.getOptions(port);\n@@ -111,6 +149,7 @@ class EleventyServe {\n}\n}\n+ // Not available in Browser Sync\nsendError({ error }) {\nif (!this._usingBrowserSync && this.server) {\nthis.server.sendError({\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -223,7 +223,7 @@ class BundlerHelper {\n);\n}\n- browserSyncMiddleware() {\n+ serverMiddleware() {\nlet serverlessFilepath = TemplatePath.addLeadingDotSlash(\npath.join(TemplatePath.getWorkingDir(), this.dir, \"index\")\n);\n@@ -318,7 +318,11 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nlet helper = new BundlerHelper(options.name, options, eleventyConfig);\neleventyConfig.setBrowserSyncConfig({\n- middleware: [helper.browserSyncMiddleware()],\n+ middleware: [helper.serverMiddleware()],\n+ });\n+\n+ eleventyConfig.setServerOptions({\n+ middleware: [helper.serverMiddleware()],\n});\neleventyConfig.on(\"eleventy.before\", async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -70,6 +70,7 @@ class UserConfig {\nthis.watchJavaScriptDependencies = true;\nthis.additionalWatchTargets = [];\nthis.browserSyncConfig = {};\n+ this.serverOptions = {};\nthis.globalData = {};\nthis.chokidarConfig = {};\nthis.watchThrottleWaitTime = 0; //ms\n@@ -704,6 +705,14 @@ class UserConfig {\nthis.watchJavaScriptDependencies = !!watchEnabled;\n}\n+ setServerOptions(options = {}, override = false) {\n+ if (override) {\n+ this.serverOptions = options;\n+ } else {\n+ this.serverOptions = merge(this.serverOptions, options);\n+ }\n+ }\n+\nsetBrowserSyncConfig(options = {}, mergeOptions = true) {\nif (mergeOptions) {\nthis.browserSyncConfig = merge(this.browserSyncConfig, options);\n@@ -791,6 +800,7 @@ class UserConfig {\nwatchJavaScriptDependencies: this.watchJavaScriptDependencies,\nadditionalWatchTargets: this.additionalWatchTargets,\nbrowserSyncConfig: this.browserSyncConfig,\n+ serverOptions: this.serverOptions,\nchokidarConfig: this.chokidarConfig,\nwatchThrottleWaitTime: this.watchThrottleWaitTime,\nfrontMatterParsingOptions: this.frontMatterParsingOptions,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Util/ConsoleLogger.js",
"new_path": "src/Util/ConsoleLogger.js",
"diff": "@@ -47,6 +47,11 @@ class ConsoleLogger {\nthis.message(msg, undefined, undefined, true);\n}\n+ /** @param {string} msg */\n+ info(msg) {\n+ this.message(msg, \"warn\", \"blue\");\n+ }\n+\n/** @param {string} msg */\nwarn(msg) {\nthis.message(msg, \"warn\", \"yellow\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Util/PathPrefixer.js",
"diff": "+const path = require(\"path\");\n+\n+class PathPrefixer {\n+ static normalizePathPrefix(pathPrefix) {\n+ if (pathPrefix) {\n+ // add leading / (for browsersync), see #1454\n+ // path.join uses \\\\ for Windows so we split and rejoin\n+ return PathPrefixer.joinUrlParts(\"/\", pathPrefix);\n+ }\n+\n+ return \"/\";\n+ }\n+\n+ static joinUrlParts(...parts) {\n+ return path\n+ .join(...parts)\n+ .split(path.sep)\n+ .join(\"/\");\n+ }\n+}\n+\n+module.exports = PathPrefixer;\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | In progress. Still needs @11ty/eleventy-dev-server to be published |
699 | 04.03.2022 17:53:22 | 21,600 | e25018beef6fcf446a115f51e9e44c1d2de2a1cd | Removes transformUrl dep | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyServe.js",
"new_path": "src/EleventyServe.js",
"diff": "@@ -72,7 +72,6 @@ class EleventyServe {\nthis.config.dir.output,\nthis.getDefaultServerOptions(),\n{\n- transformUrl: PathPrefixer.joinUrlParts,\ntemplatePath: TemplatePath,\nlogger: new ConsoleLogger(true),\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Removes transformUrl dep |
699 | 04.03.2022 22:35:21 | 21,600 | 89df07e14a6d6669807684b77af45342af602c55 | Fix bug with incremental and passthrough copy with glob patterns | [
{
"change_type": "MODIFY",
"old_path": "src/TemplatePassthroughManager.js",
"new_path": "src/TemplatePassthroughManager.js",
"diff": "+const multimatch = require(\"multimatch\");\n+const isGlob = require(\"is-glob\");\nconst { TemplatePath } = require(\"@11ty/eleventy-utils\");\nconst EleventyExtensionMap = require(\"./EleventyExtensionMap\");\n@@ -177,6 +179,13 @@ class TemplatePassthroughManager {\nif (TemplatePath.startsWithSubPath(changedFile, path.inputPath)) {\nreturn path;\n}\n+ if (\n+ changedFile &&\n+ isGlob(path.inputPath) &&\n+ multimatch([changedFile], [path.inputPath]).length\n+ ) {\n+ return path;\n+ }\n}\nreturn false;\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix bug with incremental and passthrough copy with glob patterns |
699 | 08.03.2022 17:24:25 | 21,600 | 02d5a1117f8f5e74089f7771ea46481634e4eb46 | Tests cleanup for Eleventy Serve | [
{
"change_type": "MODIFY",
"old_path": "test/EleventyServeTest.js",
"new_path": "test/EleventyServeTest.js",
"diff": "@@ -2,59 +2,53 @@ const test = require(\"ava\");\nconst EleventyServe = require(\"../src/EleventyServe\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\n-test(\"Constructor\", (t) => {\n+async function getServerInstance(cfg) {\nlet es = new EleventyServe();\n- let cfg = new TemplateConfig().getConfig();\n+ if (!cfg) {\n+ cfg = new TemplateConfig().getConfig();\n+ }\nes.config = cfg;\n- t.is(es.getPathPrefix(), \"/\");\n+ await es.init();\n+\n+ delete es.options.logger;\n+ delete es.options.module;\n+\n+ return es;\n+}\n+\n+test(\"Constructor\", async (t) => {\n+ let es = await getServerInstance();\n+ t.is(es.options.pathPrefix, \"/\");\n});\n-test(\"Get Options\", (t) => {\n- let es = new EleventyServe();\n- let cfg = new TemplateConfig().getConfig();\n- cfg.pathPrefix = \"/\";\n- es.config = cfg;\n+test(\"Get Options\", async (t) => {\n+ let es = await getServerInstance();\nes.setOutputDir(\"_site\");\n- let opts = es.getOptions();\n- delete opts.logger;\n-\n- t.deepEqual(opts, {\n+ t.deepEqual(es.options, {\npathPrefix: \"/\",\nport: 8080,\n});\n});\n-test(\"Get Options (with a pathPrefix)\", (t) => {\n- let es = new EleventyServe();\n+test(\"Get Options (with a pathPrefix)\", async (t) => {\nlet cfg = new TemplateConfig().getConfig();\ncfg.pathPrefix = \"/web/\";\n- es.config = cfg;\n- es.setOutputDir(\"_site\");\n- let opts = es.getOptions();\n- delete opts.logger;\n+ let es = await getServerInstance(cfg);\n+ es.setOutputDir(\"_site\");\n- t.deepEqual(opts, {\n+ t.deepEqual(es.options, {\npathPrefix: \"/web/\",\nport: 8080,\n});\n});\n-test(\"Get Options (override in config)\", (t) => {\n- let es = new EleventyServe();\n- let cfg = new TemplateConfig().getConfig();\n- cfg.pathPrefix = \"/\";\n- cfg.browserSyncConfig = {\n- notify: true,\n- };\n- es.config = cfg;\n+test(\"Get Options (override in config)\", async (t) => {\n+ let es = await getServerInstance();\nes.setOutputDir(\"_site\");\n- let opts = es.getOptions();\n- delete opts.logger;\n-\n- t.deepEqual(opts, {\n+ t.deepEqual(es.options, {\npathPrefix: \"/\",\nport: 8080,\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Tests cleanup for Eleventy Serve |
699 | 09.03.2022 10:22:18 | 21,600 | c8dcf6fc9428141226c0485b5489b43641152f8c | Only throw an error if the `setup` callback is in play on server options | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyServe.js",
"new_path": "src/EleventyServe.js",
"diff": "@@ -92,9 +92,9 @@ class EleventyServe {\n// TODO improve by sorting keys here\nthis._savedConfigOptions = JSON.stringify(this.config.serverOptions);\n- if (!this._initOptionsFetched) {\n+ if (!this._initOptionsFetched && this.getSetupCallback()) {\nthrow new Error(\n- \"Init options have not yet been fetched in setup callback.\"\n+ \"Init options have not yet been fetched in the setup callback. This probably means that `init()` has not yet been called.\"\n);\n}\n@@ -122,11 +122,18 @@ class EleventyServe {\nthis._server = val;\n}\n+ getSetupCallback() {\n+ let setupCallback = this.config.serverOptions.setup;\n+ if (setupCallback && typeof setupCallback === \"function\") {\n+ return setupCallback;\n+ }\n+ }\n+\nasync init() {\nthis._initOptionsFetched = true;\n- let setupCallback = this.config.serverOptions.setup;\n- if (setupCallback && typeof setupCallback === \"function\") {\n+ let setupCallback = this.getSetupCallback();\n+ if (setupCallback) {\nlet opts = await setupCallback();\nif (opts) {\nmerge(this.options, opts);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Only throw an error if the `setup` callback is in play on server options |
699 | 09.03.2022 10:23:03 | 21,600 | 827ec845c83371343d7e6ca63bf575dd7ee9192f | Removes functionality from setBrowserSyncConfig configuration API method and adds removal message. | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -318,10 +318,6 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nif (process.env.ELEVENTY_SOURCE === \"cli\") {\nlet helper = new BundlerHelper(options.name, options, eleventyConfig);\n- eleventyConfig.setBrowserSyncConfig({\n- middleware: [helper.serverMiddleware()],\n- });\n-\neleventyConfig.setServerOptions({\nmiddleware: [helper.serverMiddleware()],\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -69,7 +69,6 @@ class UserConfig {\nthis.extensionMap = new Set();\nthis.watchJavaScriptDependencies = true;\nthis.additionalWatchTargets = [];\n- this.browserSyncConfig = {};\nthis.serverOptions = {};\nthis.globalData = {};\nthis.chokidarConfig = {};\n@@ -713,13 +712,10 @@ class UserConfig {\n}\n}\n- // TODO show deprecation warning (use `setServerOptions` instead)\n- setBrowserSyncConfig(options = {}, mergeOptions = true) {\n- if (mergeOptions) {\n- this.browserSyncConfig = merge(this.browserSyncConfig, options);\n- } else {\n- this.browserSyncConfig = options;\n- }\n+ setBrowserSyncConfig() {\n+ debug(\n+ \"The `setBrowserSyncConfig` method was removed in Eleventy 2.0.0. Use `setServerOptions` with the new Eleventy development server or the `@11ty/eleventy-browser-sync` plugin moving forward.\"\n+ );\n}\nsetChokidarConfig(options = {}) {\n@@ -800,7 +796,6 @@ class UserConfig {\ndataDeepMerge: this.dataDeepMerge,\nwatchJavaScriptDependencies: this.watchJavaScriptDependencies,\nadditionalWatchTargets: this.additionalWatchTargets,\n- browserSyncConfig: this.browserSyncConfig,\nserverOptions: this.serverOptions,\nchokidarConfig: this.chokidarConfig,\nwatchThrottleWaitTime: this.watchThrottleWaitTime,\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Removes functionality from setBrowserSyncConfig configuration API method and adds removal message. |
699 | 09.03.2022 17:41:50 | 21,600 | 9a9570e84b53e5c495113c256a13243999f62e91 | Updates eleventy-dev-server canary | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n\"dependencies\": {\n\"@11ty/dependency-tree\": \"^2.0.0\",\n- \"@11ty/eleventy-dev-server\": \"^1.0.0-canary.1\",\n+ \"@11ty/eleventy-dev-server\": \"^1.0.0-canary.2\",\n\"@11ty/eleventy-utils\": \"^1.0.0\",\n\"@iarna/toml\": \"^2.2.5\",\n\"@sindresorhus/slugify\": \"^1.1.2\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Updates eleventy-dev-server canary |
699 | 14.03.2022 18:02:17 | 18,000 | a1af7438e2d949aea43c93bcf2eae9d8ff08c4ac | Adds versionCheck to Server API for compatibility checking. | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -134,6 +134,7 @@ class Eleventy {\n/** @member {Object} - tbd. */\nthis.eleventyServe = new EleventyServe();\nthis.eleventyServe.config = this.config;\n+ this.eleventyServe.eleventyConfig = this.eleventyConfig;\n/** @member {String} - Holds the path to the input directory. */\nthis.rawInput = input;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyServe.js",
"new_path": "src/EleventyServe.js",
"diff": "@@ -12,6 +12,9 @@ class EleventyServeConfigError extends EleventyBaseError {}\nconst DEFAULT_SERVER_OPTIONS = {\nmodule: \"@11ty/eleventy-dev-server\",\nport: 8080,\n+ pathPrefix: \"/\",\n+ // setup: function() {},\n+ // logger: { info: function() {}, error: function() {} }\n};\nclass EleventyServe {\n@@ -35,6 +38,20 @@ class EleventyServe {\nthis._config = config;\n}\n+ get eleventyConfig() {\n+ if (!this._eleventyConfig) {\n+ throw new EleventyServeConfigError(\n+ \"You need to set the eleventyConfig property on EleventyServe.\"\n+ );\n+ }\n+\n+ return this._eleventyConfig;\n+ }\n+\n+ set eleventyConfig(config) {\n+ this._eleventyConfig = config;\n+ }\n+\nsetOutputDir(outputDir) {\nthis.outputDir = outputDir;\n}\n@@ -65,6 +82,26 @@ class EleventyServe {\n);\n}\n+ let serverPackageJsonPath = TemplatePath.absolutePath(\n+ serverPath,\n+ \"package.json\"\n+ );\n+ let serverPackageJson = require(serverPackageJsonPath);\n+ if (\n+ serverPackageJson[\"11ty\"] &&\n+ serverPackageJson[\"11ty\"].compatibility\n+ ) {\n+ try {\n+ this.eleventyConfig.userConfig.versionCheck(\n+ serverPackageJson[\"11ty\"].compatibility\n+ );\n+ } catch (e) {\n+ this.logger.warn(\n+ `WARN: Eleventy Server Plugin (${name}) Compatibility: ${e.message}`\n+ );\n+ }\n+ }\n+\nreturn module;\n} catch (e) {\nthis.logger.error(\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds versionCheck to Server API for compatibility checking. |
699 | 15.03.2022 11:26:07 | 18,000 | 285cb5d99be77e6521908b792d6ba6e96b60211b | Minor update to copy in Server API compatibility check warning | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyServe.js",
"new_path": "src/EleventyServe.js",
"diff": "@@ -86,6 +86,7 @@ class EleventyServe {\nserverPath,\n\"package.json\"\n);\n+\nlet serverPackageJson = require(serverPackageJsonPath);\nif (\nserverPackageJson[\"11ty\"] &&\n@@ -97,7 +98,7 @@ class EleventyServe {\n);\n} catch (e) {\nthis.logger.warn(\n- `WARN: Eleventy Server Plugin (${name}) Compatibility: ${e.message}`\n+ `Warning: \\`${name}\\` Plugin Compatibility: ${e.message}`\n);\n}\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Minor update to copy in Server API compatibility check warning |
699 | 16.03.2022 14:52:06 | 18,000 | 685543ec4b929885055ef2b36d99a532f2de2cb6 | Add template results to the eleventy.after event argument. | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -1018,6 +1018,11 @@ Arguments:\nret = this.logger.closeStream(to);\n}\n+ // Passing the processed output to the eleventy.after event is new in 2.0\n+ let [passthroughCopyResults, ...templateResults] = ret;\n+ let processedResults = templateResults.flat().filter((entry) => !!entry);\n+ eventsArg.results = processedResults;\n+\nawait this.config.events.emit(\"afterBuild\", eventsArg);\nawait this.config.events.emit(\"eleventy.after\", eventsArg);\n} catch (e) {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Add template results to the eleventy.after event argument. |
699 | 16.03.2022 14:57:47 | 18,000 | d1f48f77462d09d8b77ddcf0bbaa7faffb306e51 | Additions for vite integration work. Needs to know run mode (--serve or --watch) and outputPath of the files. | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -85,6 +85,12 @@ class Eleventy {\n*/\nthis.verboseModeSetViaCommandLineParam = false;\n+ /**\n+ * @member {String} - One of build, serve, or watch\n+ * @default \"build\"\n+ */\n+ this.runMode = \"build\";\n+\n/**\n* @member {Boolean} - Is Eleventy running in verbose mode?\n* @default true\n@@ -521,6 +527,16 @@ Verbose Output: ${this.verboseMode}`);\n}\n}\n+ /**\n+ * Updates the run mode of Eleventy.\n+ *\n+ * @method\n+ * @param {String} runMode - One of \"watch\" or \"serve\"\n+ */\n+ setRunMode(runMode) {\n+ this.runMode = runMode;\n+ }\n+\n/**\n* Reads the version of Eleventy.\n*\n@@ -993,6 +1009,8 @@ Arguments:\ntry {\nlet eventsArg = {\ninputDir: this.config.inputDir,\n+ dir: this.config.dir,\n+ runMode: this.runMode,\n};\nawait this.config.events.emit(\"beforeBuild\", eventsArg);\nawait this.config.events.emit(\"eleventy.before\", eventsArg);\n@@ -1012,17 +1030,17 @@ Arguments:\nret = await promise;\n+ // Passing the processed output to the eleventy.after event is new in 2.0\n+ let [passthroughCopyResults, ...templateResults] = ret;\n+ let processedResults = templateResults.flat().filter((entry) => !!entry);\n+ eventsArg.results = processedResults;\n+\nif (to === \"ndjson\") {\n// return a stream\n// TODO this might output the ndjson rows only after all the templates have been written to the stream?\nret = this.logger.closeStream(to);\n}\n- // Passing the processed output to the eleventy.after event is new in 2.0\n- let [passthroughCopyResults, ...templateResults] = ret;\n- let processedResults = templateResults.flat().filter((entry) => !!entry);\n- eventsArg.results = processedResults;\n-\nawait this.config.events.emit(\"afterBuild\", eventsArg);\nawait this.config.events.emit(\"eleventy.after\", eventsArg);\n} catch (e) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyServe.js",
"new_path": "src/EleventyServe.js",
"diff": "@@ -192,14 +192,14 @@ class EleventyServe {\n}\nasync close() {\n- if (this.server) {\n+ if (this._server) {\nawait this.server.close();\nthis.server = undefined;\n}\n}\nasync sendError({ error }) {\n- if (this.server) {\n+ if (this._server) {\nawait this.server.sendError({\nerror,\n});\n@@ -218,7 +218,7 @@ class EleventyServe {\n// Live reload the server\nasync reload(reloadEvent = {}) {\n- if (!this.server) {\n+ if (!this._server) {\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -842,6 +842,7 @@ class Template extends TemplateContent {\ndebug(`${outputPath} ${lang.finished}.`);\nreturn {\ninputPath: this.inputPath,\n+ outputPath: outputPath,\nurl,\ncontent: finalContent,\n};\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Additions for vite integration work. Needs to know run mode (--serve or --watch) and outputPath of the files. |
699 | 16.03.2022 15:35:25 | 18,000 | 9495d4b309afe354ee484388fca4c53a7a1d3721 | Report `outputMode` in build events (one of: fs, json, ndjson) | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -1011,6 +1011,7 @@ Arguments:\ninputDir: this.config.inputDir,\ndir: this.config.dir,\nrunMode: this.runMode,\n+ outputMode: to,\n};\nawait this.config.events.emit(\"beforeBuild\", eventsArg);\nawait this.config.events.emit(\"eleventy.before\", eventsArg);\n@@ -1032,8 +1033,11 @@ Arguments:\n// Passing the processed output to the eleventy.after event is new in 2.0\nlet [passthroughCopyResults, ...templateResults] = ret;\n- let processedResults = templateResults.flat().filter((entry) => !!entry);\n- eventsArg.results = processedResults;\n+ if (to === \"fs\") {\n+ eventsArg.results = templateResults.flat().filter((entry) => !!entry);\n+ } else {\n+ eventsArg.results = templateResults.filter((entry) => !!entry);\n+ }\nif (to === \"ndjson\") {\n// return a stream\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Report `outputMode` in build events (one of: fs, json, ndjson) |
699 | 25.03.2022 19:59:45 | 18,000 | 7d140fd6e75d2c5887b448cebd9b07665dcf83dc | Adds `config` callback to renderFile and render functions, export them under EleventyRenderPlugin as EleventyRenderPlugin.File and EleventyRenderPlugin.String.
Allows use of render plugin directly (instead of requiring shortcodes) | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/RenderPlugin.js",
"new_path": "src/Plugins/RenderPlugin.js",
"diff": "@@ -9,30 +9,20 @@ const TemplateRender = require(\"../TemplateRender\");\nconst TemplateConfig = require(\"../TemplateConfig\");\nconst Liquid = require(\"../Engines/Liquid\");\n-function normalizeDirectories(dir = {}) {\n- return Object.assign(\n- {\n- input: \".\",\n- },\n- dir\n- );\n-}\n-\nasync function render(\ncontent,\ntemplateLang = \"html\",\n- normalizedDirs = {},\n- { templateConfig, extensionMap }\n+ { templateConfig, extensionMap, config } = {}\n) {\nif (!templateConfig) {\n- templateConfig = new TemplateConfig();\n+ templateConfig = new TemplateConfig(null, false);\n+ }\n+ if (config && typeof config === \"function\") {\n+ await config(templateConfig.userConfig);\n}\n- let tr = new TemplateRender(\n- templateLang,\n- normalizedDirs.input,\n- templateConfig\n- );\n+ let cfg = templateConfig.getConfig();\n+ let tr = new TemplateRender(templateLang, cfg.dir.input, templateConfig);\ntr.extensionMap = extensionMap;\ntr.setEngineOverride(templateLang);\n@@ -49,9 +39,8 @@ async function render(\n// No templateLang default, it should infer from the inputPath.\nasync function renderFile(\ninputPath,\n- templateLang,\n- normalizedDirs = {},\n- { templateConfig, extensionMap }\n+ { templateConfig, extensionMap, config } = {},\n+ templateLang\n) {\nif (!inputPath) {\nthrow new Error(\n@@ -69,10 +58,14 @@ async function renderFile(\n}\nif (!templateConfig) {\n- templateConfig = new TemplateConfig();\n+ templateConfig = new TemplateConfig(null, false);\n+ }\n+ if (config && typeof config === \"function\") {\n+ await config(templateConfig.userConfig);\n}\n- let tr = new TemplateRender(inputPath, normalizedDirs.input, templateConfig);\n+ let cfg = templateConfig.getConfig();\n+ let tr = new TemplateRender(inputPath, cfg.dir.input, templateConfig);\ntr.extensionMap = extensionMap;\nif (templateLang) {\ntr.setEngineOverride(templateLang);\n@@ -256,16 +249,10 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n});\nasync function renderStringShortcodeFn(content, templateLang, data = {}) {\n- let fn = await render.call(\n- this,\n- content,\n- templateLang,\n- normalizeDirectories(eleventyConfig.dir),\n- {\n+ let fn = await render.call(this, content, templateLang, {\ntemplateConfig,\nextensionMap,\n- }\n- );\n+ });\nif (fn === undefined) {\nreturn;\n@@ -292,12 +279,11 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nlet fn = await renderFile.call(\nthis,\ninputPath,\n- templateLang,\n- normalizeDirectories(eleventyConfig.dir),\n{\ntemplateConfig,\nextensionMap,\n- }\n+ },\n+ templateLang\n);\nif (fn === undefined) {\n@@ -342,3 +328,5 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n}\nmodule.exports = EleventyPlugin;\n+module.exports.File = renderFile;\n+module.exports.String = render;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderPluginTest.js",
"new_path": "test/TemplateRenderPluginTest.js",
"diff": "const test = require(\"ava\");\nconst RenderPlugin = require(\"../src/Plugins/RenderPlugin\");\n+const RenderPluginFile = RenderPlugin.File;\n+const RenderPluginString = RenderPlugin.String;\n+\nconst VuePlugin = require(\"@11ty/eleventy-plugin-vue\");\nconst Eleventy = require(\"../src/Eleventy\");\n@@ -233,3 +236,117 @@ test(\"Remap non-object data to data._ if object is not passed in\", async (t) =>\n);\nt.is(html, \"string\");\n});\n+\n+test(\"Direct use of render string plugin, rendering Nunjucks (and nested Liquid)\", async (t) => {\n+ let fn = await RenderPluginString(\n+ `{%- set nunjucksVar = 69 -%}\n+{{ hi }}\n+{{ nunjucksVar }}\n+{{ \"who\" | testing }}\n+{% renderTemplate \"liquid\", argData %}\n+{% assign liquidVar = 138 %}\n+* {{ hi }} test test {{ bye }} {{ liquidVar }}\n+{% endrenderTemplate %}\n+`,\n+ \"njk\",\n+ {\n+ config: function (eleventyConfig) {\n+ eleventyConfig.addPlugin(RenderPlugin);\n+ eleventyConfig.addFilter(\"testing\", function () {\n+ return \"tested.\";\n+ });\n+ },\n+ }\n+ );\n+ let data = {\n+ hi: \"nunjucksHi\",\n+ argData: {\n+ hi: \"liquidHi\",\n+ bye: \"liquidBye\",\n+ },\n+ };\n+ let html = await fn(data);\n+\n+ t.is(\n+ normalizeNewLines(html.trim()),\n+ `nunjucksHi\n+69\n+tested.\n+\n+\n+* liquidHi test test liquidBye 138`\n+ );\n+});\n+\n+test(\"Direct use of render string plugin, rendering Liquid (and nested Nunjucks)\", async (t) => {\n+ let fn = await RenderPluginString(\n+ `{%- assign liquidVar = 69 -%}\n+{{ hi }}\n+{{ liquidVar }}\n+{{ \"who\" | testing }}\n+{% renderTemplate \"njk\", argData %}\n+{% set njkVar = 138 %}\n+* {{ hi }} test test {{ bye }} {{ njkVar }}\n+{% endrenderTemplate %}\n+`,\n+ \"liquid\",\n+ {\n+ config: function (eleventyConfig) {\n+ eleventyConfig.addPlugin(RenderPlugin);\n+ eleventyConfig.addFilter(\"testing\", function () {\n+ return \"tested.\";\n+ });\n+ },\n+ }\n+ );\n+ let data = {\n+ hi: \"liquidHi\",\n+ argData: {\n+ hi: \"njkHi\",\n+ bye: \"njkBye\",\n+ },\n+ };\n+ let html = await fn(data);\n+\n+ t.is(\n+ normalizeNewLines(html.trim()),\n+ `liquidHi\n+69\n+tested.\n+\n+\n+* njkHi test test njkBye 138`\n+ );\n+});\n+\n+test(\"Direct use of render file plugin, rendering Nunjucks (and nested Liquid)\", async (t) => {\n+ let fn = await RenderPluginFile(\n+ \"./test/stubs-render-plugin/liquid-direct.njk\",\n+ {\n+ config: function (eleventyConfig) {\n+ eleventyConfig.addPlugin(RenderPlugin);\n+ eleventyConfig.addFilter(\"testing\", function () {\n+ return \"tested.\";\n+ });\n+ },\n+ }\n+ );\n+ let data = {\n+ hi: \"liquidHi\",\n+ argData: {\n+ hi: \"njkHi\",\n+ bye: \"njkBye\",\n+ },\n+ };\n+ let html = await fn(data);\n+\n+ t.is(\n+ normalizeNewLines(html.trim()),\n+ `liquidHi\n+69\n+tested.\n+\n+\n+* njkHi test test njkBye 138`\n+ );\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-render-plugin/liquid-direct.njk",
"diff": "+{%- set nunjucksVar = 69 -%}\n+{{ hi }}\n+{{ nunjucksVar }}\n+{{ \"who\" | testing }}\n+{% renderTemplate \"liquid\", argData %}\n+{% assign liquidVar = 138 %}\n+* {{ hi }} test test {{ bye }} {{ liquidVar }}\n+{% endrenderTemplate %}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds `config` callback to renderFile and render functions, export them under EleventyRenderPlugin as EleventyRenderPlugin.File and EleventyRenderPlugin.String.
Allows use of render plugin directly (instead of requiring shortcodes) |
699 | 25.03.2022 20:25:00 | 18,000 | bd04095713e1a25139abbe7e82dc76342b769a7f | Downgrade ava, reliability reasons. Upgrade other deps | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"@11ty/eleventy-plugin-syntaxhighlight\": \"^4.0.0\",\n\"@11ty/eleventy-plugin-vue\": \"1.0.0-canary.8\",\n\"@vue/server-renderer\": \"^3.2.31\",\n- \"ava\": \"^4.1.0\",\n+ \"ava\": \"^3.15.0\",\n\"husky\": \"^7.0.4\",\n\"js-yaml\": \"^4.1.0\",\n- \"lint-staged\": \"^12.3.5\",\n+ \"lint-staged\": \"^12.3.7\",\n\"markdown-it-emoji\": \"^2.0.0\",\n\"marked\": \"^4.0.12\",\n\"nyc\": \"^15.1.0\",\n- \"prettier\": \"^2.5.1\",\n+ \"prettier\": \"^2.6.1\",\n\"rimraf\": \"^3.0.2\",\n\"sass\": \"^1.49.9\",\n\"toml\": \"^3.0.0\",\n\"@sindresorhus/slugify\": \"^1.1.2\",\n\"chokidar\": \"^3.5.3\",\n\"cross-spawn\": \"^7.0.3\",\n- \"debug\": \"^4.3.3\",\n+ \"debug\": \"^4.3.4\",\n\"dependency-graph\": \"^0.11.0\",\n\"ejs\": \"^3.1.6\",\n\"fast-glob\": \"^3.2.11\",\n\"lodash\": \"^4.17.21\",\n\"luxon\": \"^2.3.1\",\n\"markdown-it\": \"^12.3.2\",\n- \"minimist\": \"^1.2.5\",\n+ \"minimist\": \"^1.2.6\",\n\"moo\": \"^0.5.1\",\n\"multimatch\": \"^5.0.0\",\n\"mustache\": \"^4.2.0\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Downgrade ava, reliability reasons. Upgrade other deps |
699 | 29.03.2022 16:42:05 | 18,000 | 7d4bc4ddbac395fd18af7b26d1ace2f536902256 | Move isPlainObject to | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"dependencies\": {\n\"@11ty/dependency-tree\": \"^2.0.0\",\n\"@11ty/eleventy-dev-server\": \"^1.0.0-canary.7\",\n- \"@11ty/eleventy-utils\": \"^1.0.0\",\n+ \"@11ty/eleventy-utils\": \"^1.0.1\",\n\"@iarna/toml\": \"^2.2.5\",\n\"@sindresorhus/slugify\": \"^1.1.2\",\n\"chokidar\": \"^3.5.3\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/ComputedDataProxy.js",
"new_path": "src/ComputedDataProxy.js",
"diff": "const lodashSet = require(\"lodash/set\");\nconst lodashGet = require(\"lodash/get\");\n-const isPlainObject = require(\"./Util/IsPlainObject\");\n+const { isPlainObject } = require(\"@11ty/eleventy-utils\");\n/* Calculates computed data using Proxies */\nclass ComputedDataProxy {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Plugins/RenderPlugin.js",
"new_path": "src/Plugins/RenderPlugin.js",
"diff": "const fs = require(\"fs\");\nconst fsp = fs.promises;\n-const isPlainObject = require(\"../Util/IsPlainObject\");\n-const { TemplatePath } = require(\"@11ty/eleventy-utils\");\n+const { TemplatePath, isPlainObject } = require(\"@11ty/eleventy-utils\");\n// TODO add a first-class Markdown component to expose this using Markdown-only syntax (will need to be synchronous for markdown-it)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -9,9 +9,8 @@ const normalize = require(\"normalize-path\");\nconst lodashGet = require(\"lodash/get\");\nconst lodashSet = require(\"lodash/set\");\nconst { DateTime } = require(\"luxon\");\n-const { TemplatePath } = require(\"@11ty/eleventy-utils\");\n+const { TemplatePath, isPlainObject } = require(\"@11ty/eleventy-utils\");\n-const isPlainObject = require(\"./Util/IsPlainObject\");\nconst ConsoleLogger = require(\"./Util/ConsoleLogger\");\nconst getDateFromGitLastUpdated = require(\"./Util/DateGitLastUpdated\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateBehavior.js",
"new_path": "src/TemplateBehavior.js",
"diff": "-const isPlainObject = require(\"./Util/IsPlainObject\");\n+const { isPlainObject } = require(\"@11ty/eleventy-utils\");\nclass TemplateBehavior {\nconstructor(config) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "-const isPlainObject = require(\"./Util/IsPlainObject\");\nconst DependencyGraph = require(\"dependency-graph\").DepGraph;\n+const { isPlainObject } = require(\"@11ty/eleventy-utils\");\n+\nconst TemplateCollection = require(\"./TemplateCollection\");\nconst EleventyErrorUtil = require(\"./EleventyErrorUtil\");\nconst UsingCircularTemplateContentReferenceError = require(\"./Errors/UsingCircularTemplateContentReferenceError\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePermalink.js",
"new_path": "src/TemplatePermalink.js",
"diff": "const path = require(\"path\");\nconst normalize = require(\"normalize-path\");\n-const { TemplatePath } = require(\"@11ty/eleventy-utils\");\n+const { TemplatePath, isPlainObject } = require(\"@11ty/eleventy-utils\");\n-const isPlainObject = require(\"./Util/IsPlainObject\");\nconst serverlessUrlFilter = require(\"./Filters/ServerlessUrl\");\nclass TemplatePermalink {\n"
},
{
"change_type": "DELETE",
"old_path": "src/Util/IsPlainObject.js",
"new_path": null,
"diff": "-/* Prior art: this utility was created for https://github.com/11ty/eleventy/issues/2214\n-\n- * Inspired by implementations from `is-what`, `typechecker`, `jQuery`, and `lodash`\n-\n- * `is-what`\n- * More reading at https://www.npmjs.com/package/is-what#user-content-isplainobject-vs-isanyobject\n- * if (Object.prototype.toString.call(value).slice(8, -1) !== 'Object') return false;\n- * return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;\n-\n- * `typechecker`\n- * return value !== null && typeof value === 'object' && value.__proto__ === Object.prototype;\n-\n- * Notably jQuery and lodash have very similar implementations.\n-\n- * For later, remember the `value === Object(value)` trick\n- */\n-\n-module.exports = function (value) {\n- if (value === null || typeof value !== \"object\") {\n- return false;\n- }\n- let proto = Object.getPrototypeOf(value);\n- return !proto || proto === Object.prototype;\n-};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Util/Merge.js",
"new_path": "src/Util/Merge.js",
"diff": "-const isPlainObject = require(\"./IsPlainObject\");\n+const { isPlainObject } = require(\"@11ty/eleventy-utils\");\nconst OVERRIDE_PREFIX = \"override:\";\nfunction getMergedItem(target, source, parentKey) {\n"
},
{
"change_type": "DELETE",
"old_path": "test/IsPlainObjectTest.js",
"new_path": null,
"diff": "-const test = require(\"ava\");\n-const isPlainObject = require(\"../src/Util/IsPlainObject\");\n-\n-test(\"isPlainObject\", (t) => {\n- t.is(isPlainObject(null), false);\n- t.is(isPlainObject(undefined), false);\n- t.is(isPlainObject(1), false);\n- t.is(isPlainObject(true), false);\n- t.is(isPlainObject(false), false);\n- t.is(isPlainObject(\"string\"), false);\n- t.is(isPlainObject([]), false);\n- t.is(isPlainObject(Symbol(\"a\")), false);\n- t.is(\n- isPlainObject(function () {}),\n- false\n- );\n-});\n-\n-// https://github.com/lodash/lodash/blob/ddfd9b11a0126db2302cb70ec9973b66baec0975/test/test.js#L11447\n-// Notably, did not include the test for DOM Elements.\n-test(\"Test from lodash.isPlainObject\", (t) => {\n- t.is(isPlainObject({}), true);\n- t.is(isPlainObject({ a: 1 }), true);\n-\n- function Foo(a) {\n- this.a = 1;\n- }\n-\n- t.is(isPlainObject({ constructor: Foo }), true);\n- t.is(isPlainObject([1, 2, 3]), false);\n- t.is(isPlainObject(new Foo(1)), false);\n-});\n-\n-test(\"Test from lodash.isPlainObject: should return `true` for objects with a `[[Prototype]]` of `null`\", (t) => {\n- let obj = Object.create(null);\n- t.is(isPlainObject(obj), true);\n-\n- obj.constructor = Object.prototype.constructor;\n- t.is(isPlainObject(obj), true);\n-});\n-\n-test(\"Test from lodash.isPlainObject: should return `true` for objects with a `valueOf` property\", (t) => {\n- t.is(isPlainObject({ valueOf: 0 }), true);\n-});\n-\n-test(\"Test from lodash.isPlainObject: should return `true` for objects with a writable `Symbol.toStringTag` property\", (t) => {\n- let obj = {};\n- obj[Symbol.toStringTag] = \"X\";\n-\n- t.is(isPlainObject(obj), true);\n-});\n-\n-test(\"Test from lodash.isPlainObject: should return `false` for objects with a custom `[[Prototype]]`\", (t) => {\n- let obj = Object.create({ a: 1 });\n- t.is(isPlainObject(obj), false);\n-});\n-\n-test(\"Test from lodash.isPlainObject (modified): should return `false` for non-Object objects\", (t) => {\n- t.is(isPlainObject(arguments), true); // WARNING: lodash was false\n- t.is(isPlainObject(Error), false);\n- t.is(isPlainObject(Math), true); // WARNING: lodash was false\n-});\n-\n-test(\"Test from lodash.isPlainObject: should return `false` for non-objects\", (t) => {\n- t.is(isPlainObject(true), false);\n- t.is(isPlainObject(\"a\"), false);\n- t.is(isPlainObject(Symbol(\"a\")), false);\n-});\n-\n-test(\"Test from lodash.isPlainObject (modified): should return `true` for objects with a read-only `Symbol.toStringTag` property\", (t) => {\n- var object = {};\n- Object.defineProperty(object, Symbol.toStringTag, {\n- configurable: true,\n- enumerable: false,\n- writable: false,\n- value: \"X\",\n- });\n-\n- t.is(isPlainObject(object), true); // WARNING: lodash was false\n-});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Move isPlainObject to @11ty/eleventy-utils |
699 | 29.03.2022 16:42:48 | 18,000 | 1bfbf4daa180b2107e690c91106b80e3bd6b7a62 | Add `page.templateSyntax` to Eleventy Supplied Data (comma separated list of current template languages) | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -473,6 +473,7 @@ class Template extends TemplateContent {\ndata.page.fileSlug = this.fileSlugStr;\ndata.page.filePathStem = this.filePathStem;\ndata.page.outputFileExtension = this.engine.defaultTemplateFileExtension;\n+ data.page.templateSyntax = this.templateRender.getEnginesList();\nreturn data;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -165,6 +165,22 @@ class TemplateRender {\n}\n}\n+ getEnginesList() {\n+ if (\n+ this.engineName === \"md\" &&\n+ this.useMarkdown &&\n+ this.parseMarkdownWith\n+ ) {\n+ return `${this.parseMarkdownWith},md`;\n+ }\n+ if (this.engineName === \"html\" && this.parseHtmlWith) {\n+ return this.parseHtmlWith;\n+ }\n+\n+ // templateEngineOverride in play\n+ return this.extensionMap.getKey(this.engineNameOrPath);\n+ }\n+\nsetEngineOverride(engineName, bypassMarkdown) {\nlet engines = TemplateRender.parseEngineOverrides(engineName);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Add `page.templateSyntax` to Eleventy Supplied Data (comma separated list of current template languages) |
699 | 29.03.2022 16:56:15 | 18,000 | 4b03a3956b34a809c20fa01e284e86ccc1467b5b | Re-use `eleventy` global for free inside of renderTemplate and renderFile | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/RenderPlugin.js",
"new_path": "src/Plugins/RenderPlugin.js",
"diff": "@@ -104,6 +104,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nlet normalizedContext = {};\nif (ctx) {\nnormalizedContext.page = ctx.get([\"page\"]);\n+ normalizedContext.eleventy = ctx.get([\"eleventy\"]);\n}\nlet argArray = await Liquid.parseArguments(\n@@ -189,6 +190,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nif (context.ctx && context.ctx.page) {\nnormalizedContext.ctx = context.ctx;\nnormalizedContext.page = context.ctx.page;\n+ normalizedContext.eleventy = context.ctx.eleventy;\n}\nbody(function (e, bodyContent) {\n@@ -268,8 +270,9 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n};\n}\n- // save `page` for reuse\n+ // save `page` and `eleventy` for reuse\ndata.page = this.page;\n+ data.eleventy = this.eleventy;\nreturn fn(data);\n}\n@@ -300,8 +303,9 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n};\n}\n- // save `page` for re-use\n+ // save `page` and `eleventy` for reuse\ndata.page = this.page;\n+ data.eleventy = this.eleventy;\nreturn fn(data);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderPluginTest.js",
"new_path": "test/TemplateRenderPluginTest.js",
"diff": "@@ -350,3 +350,38 @@ tested.\n* njkHi test test njkBye 138`\n);\n});\n+\n+test(\"Use page in renderTemplate (liquid in liquid)\", async (t) => {\n+ let html = await getTestOutputForFile(\n+ \"./test/stubs-render-plugin/liquid-page.liquid\"\n+ );\n+ t.is(html, `/liquid-page/`);\n+});\n+\n+test(\"Use page in renderTemplate (liquid in njk)\", async (t) => {\n+ let html = await getTestOutputForFile(\n+ \"./test/stubs-render-plugin/liquid-page.njk\"\n+ );\n+ t.is(html, `/liquid-page/`);\n+});\n+\n+test(\"Use page in renderTemplate (njk in liquid)\", async (t) => {\n+ let html = await getTestOutputForFile(\n+ \"./test/stubs-render-plugin/njk-page.liquid\"\n+ );\n+ t.is(html, `/njk-page/`);\n+});\n+\n+test(\"Use eleventy in renderTemplate (njk in liquid)\", async (t) => {\n+ let html = await getTestOutputForFile(\n+ \"./test/stubs-render-plugin/njk-eleventy.liquid\"\n+ );\n+ t.is(html, `1`);\n+});\n+\n+test(\"Use eleventy in renderTemplate (liquid in njk)\", async (t) => {\n+ let html = await getTestOutputForFile(\n+ \"./test/stubs-render-plugin/liquid-eleventy.njk\"\n+ );\n+ t.is(html, `1`);\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-render-plugin/liquid-eleventy.njk",
"diff": "+---\n+eleventy:\n+ test: 1\n+---\n+{% renderTemplate \"liquid\" %}\n+{{ eleventy.test }}\n+{% endrenderTemplate %}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-render-plugin/liquid-page.liquid",
"diff": "+{% renderTemplate \"liquid\" %}\n+{{ page.url }}\n+{% endrenderTemplate %}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-render-plugin/liquid-page.njk",
"diff": "+{% renderTemplate \"liquid\" %}\n+{{ page.url }}\n+{% endrenderTemplate %}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-render-plugin/njk-eleventy.liquid",
"diff": "+---\n+eleventy:\n+ test: 1\n+---\n+{% renderTemplate \"njk\" %}\n+{{ eleventy.test }}\n+{% endrenderTemplate %}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-render-plugin/njk-page.liquid",
"diff": "+{% renderTemplate \"njk\" %}\n+{{ page.url }}\n+{% endrenderTemplate %}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Re-use `eleventy` global for free inside of renderTemplate and renderFile |
699 | 30.03.2022 16:59:54 | 18,000 | 5a3fb4b4528b4f61b96691a28b276a278675c677 | Trying to opt-out of fast-glob for direct render usage on bundler | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/TemplateEngine.js",
"new_path": "src/Engines/TemplateEngine.js",
"diff": "-const fastglob = require(\"fast-glob\");\nconst fs = require(\"fs\");\nconst { TemplatePath } = require(\"@11ty/eleventy-utils\");\n@@ -106,6 +105,9 @@ class TemplateEngine {\n// TODO make async\ncachePartialFiles() {\n+ // Try to skip this require if not used (for bundling reasons)\n+ const fastglob = require(\"fast-glob\");\n+\n// This only runs if getPartials() is called, which is only for Mustache/Handlebars\nthis.partialsHaveBeenCached = true;\nlet partials = {};\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Trying to opt-out of fast-glob for direct render usage on bundler |
699 | 01.04.2022 17:32:01 | 18,000 | c146407ff90c53333ca56dfbde9f0b5e57f41557 | Remove nunjucks monkey patch env opt-in | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -6,121 +6,6 @@ const EleventyErrorUtil = require(\"../EleventyErrorUtil\");\nconst EleventyBaseError = require(\"../EleventyBaseError\");\nconst eventBus = require(\"../EventBus\");\n-/*\n- * The IFFE below apply a monkey-patch to Nunjucks internals to cache\n- * compiled templates and re-use them where possible.\n- */\n-(function () {\n- if (!process.env.ELEVENTY_NUNJUCKS_SPEEDBOOST_OPTIN) {\n- return;\n- }\n-\n- let templateCache = new Map();\n-\n- let getKey = (obj) => {\n- return [\n- obj.path || obj.tmplStr,\n- obj.tmplStr.length,\n- obj.env.asyncFilters.length,\n- obj.env.extensionsList\n- .map((e) => {\n- return e.__id || \"\";\n- })\n- .join(\":\"),\n- ].join(\" :: \");\n- };\n-\n- let evictByPath = (path) => {\n- let keys = templateCache.keys();\n- // Likely to be slow; do we care?\n- for (let k of keys) {\n- if (k.indexOf(path) >= 0) {\n- templateCache.delete(k);\n- }\n- }\n- };\n- eventBus.on(\"eleventy.resourceModified\", evictByPath);\n-\n- let _compile = NunjucksLib.Template.prototype._compile;\n- NunjucksLib.Template.prototype._compile = function _wrap_compile(...args) {\n- if (!this.compiled && !this.tmplProps && templateCache.has(getKey(this))) {\n- let pathProps = templateCache.get(getKey(this));\n- this.blocks = pathProps.blocks;\n- this.rootRenderFunc = pathProps.rootRenderFunc;\n- this.compiled = true;\n- } else {\n- _compile.call(this, ...args);\n- templateCache.set(getKey(this), {\n- blocks: this.blocks,\n- rootRenderFunc: this.rootRenderFunc,\n- });\n- }\n- };\n-\n- let extensionIdCounter = 0;\n- let addExtension = NunjucksLib.Environment.prototype.addExtension;\n- NunjucksLib.Environment.prototype.addExtension = function _wrap_addExtension(\n- name,\n- ext\n- ) {\n- if (!(\"__id\" in ext)) {\n- ext.__id = extensionIdCounter++;\n- }\n- return addExtension.call(this, name, ext);\n- };\n-\n- // NunjucksLib.runtime.Frame.prototype.set is the hotest in-template method.\n- // We replace it with a version that doesn't allocate a `parts` array on\n- // repeat key use.\n- let partsCache = new Map();\n- let partsFromCache = (name) => {\n- if (partsCache.has(name)) {\n- return partsCache.get(name);\n- }\n-\n- let parts = name.split(\".\");\n- partsCache.set(name, parts);\n- return parts;\n- };\n-\n- let frameSet = NunjucksLib.runtime.Frame.prototype.set;\n- NunjucksLib.runtime.Frame.prototype.set = function _replacement_set(\n- name,\n- val,\n- resolveUp\n- ) {\n- let parts = partsFromCache(name);\n- let frame = this;\n- let obj = frame.variables;\n-\n- if (resolveUp) {\n- if ((frame = this.resolve(parts[0], true))) {\n- frame.set(name, val);\n- return;\n- }\n- }\n-\n- // A slightly faster version of the intermediate object allocation loop\n- let count = parts.length - 1;\n- let i = 0;\n- let id = parts[0];\n- while (i < count) {\n- // TODO(zachleat) use Object.hasOwn when supported\n- if (\"hasOwnProperty\" in obj) {\n- if (!obj.hasOwnProperty(id)) {\n- obj = obj[id] = {};\n- }\n- } else if (!(id in obj)) {\n- // Handle Objects with null prototypes (Nunjucks looping stuff)\n- obj = obj[id] = {};\n- }\n-\n- id = parts[++i];\n- }\n- obj[id] = val;\n- };\n-})();\n-\nclass EleventyShortcodeError extends EleventyBaseError {}\nclass Nunjucks extends TemplateEngine {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Remove nunjucks monkey patch env opt-in |
699 | 01.04.2022 17:33:09 | 18,000 | a6aac1985b0afe257776393d33dfbfcf92a65843 | Reuse eleventy global on shortcodes | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Liquid.js",
"new_path": "src/Engines/Liquid.js",
"diff": "@@ -129,6 +129,7 @@ class Liquid extends TemplateEngine {\nlet obj = {};\nif (ctx) {\nobj.page = ctx.get([\"page\"]);\n+ obj.eleventy = ctx.get([\"eleventy\"]);\n}\nreturn obj;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -110,6 +110,7 @@ class Nunjucks extends TemplateEngine {\nif (context.ctx && context.ctx.page) {\nobj.ctx = context.ctx;\nobj.page = context.ctx.page;\n+ obj.eleventy = context.ctx.eleventy;\n}\nreturn obj;\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Reuse eleventy global on shortcodes |
699 | 01.04.2022 17:33:31 | 18,000 | 76f8ef278ee3f5672ff5f082c0b697a7dbedfa40 | Support for precompiled Nunjucks templates | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -14,12 +14,40 @@ class Nunjucks extends TemplateEngine {\nthis.nunjucksEnvironmentOptions =\nthis.config.nunjucksEnvironmentOptions || {};\n+ this.nunjucksPrecompiledTemplates =\n+ this.config.nunjucksPrecompiledTemplates || {};\n+ this._usingPrecompiled =\n+ Object.keys(this.nunjucksPrecompiledTemplates).length > 0;\n+\nthis.setLibrary(this.config.libraryOverrides.njk);\nthis.cacheable = true;\n}\n- setLibrary(override) {\n+ _setEnv(override) {\n+ // Precompiled templates to avoid eval!\n+ if (this._usingPrecompiled) {\n+ function NodePrecompiledLoader() {}\n+ NodePrecompiledLoader.prototype.getSource = (name) => {\n+ // https://github.com/mozilla/nunjucks/blob/fd500902d7c88672470c87170796de52fc0f791a/nunjucks/src/precompiled-loader.js#L5\n+ return {\n+ src: {\n+ type: \"code\",\n+ obj: this.nunjucksPrecompiledTemplates[name],\n+ },\n+ // Maybe add this?\n+ // path,\n+ // noCache: true\n+ };\n+ };\n+\n+ this.njkEnv =\n+ override ||\n+ new NunjucksLib.Environment(\n+ new NodePrecompiledLoader(),\n+ this.nunjucksEnvironmentOptions\n+ );\n+ } else {\nlet fsLoader = new NunjucksLib.FileSystemLoader([\nsuper.getIncludesDir(),\nTemplatePath.getWorkingDir(),\n@@ -28,6 +56,11 @@ class Nunjucks extends TemplateEngine {\nthis.njkEnv =\noverride ||\nnew NunjucksLib.Environment(fsLoader, this.nunjucksEnvironmentOptions);\n+ }\n+ }\n+\n+ setLibrary(override) {\n+ this._setEnv(override);\n// Correct, but overbroad. Better would be to evict more granularly, but\n// resolution from paths isn't straightforward.\n@@ -283,6 +316,7 @@ class Nunjucks extends TemplateEngine {\nlet blockStart = optsTags.blockStart || \"{%\";\nlet variableStart = optsTags.variableStart || \"{{\";\nlet commentStart = optsTags.variableStart || \"{#\";\n+\nreturn (\nstr.indexOf(blockStart) !== -1 ||\nstr.indexOf(variableStart) !== -1 ||\n@@ -355,12 +389,11 @@ class Nunjucks extends TemplateEngine {\n}\nasync compile(str, inputPath) {\n- // for(let loader of this.njkEnv.loaders) {\n- // loader.cache = {};\n- // }\n-\nlet tmpl;\n- if (!inputPath || inputPath === \"njk\" || inputPath === \"md\") {\n+\n+ if (this._usingPrecompiled) {\n+ tmpl = this.njkEnv.getTemplate(str, true);\n+ } else if (!inputPath || inputPath === \"njk\" || inputPath === \"md\") {\ntmpl = new NunjucksLib.Template(str, this.njkEnv, null, true);\n} else {\ntmpl = new NunjucksLib.Template(str, this.njkEnv, inputPath, true);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -35,7 +35,9 @@ class UserConfig {\nthis.liquidFilters = {};\nthis.liquidShortcodes = {};\nthis.liquidPairedShortcodes = {};\n+\nthis.nunjucksEnvironmentOptions = {};\n+ this.nunjucksPrecompiledTemplates = {};\nthis.nunjucksFilters = {};\nthis.nunjucksAsyncFilters = {};\nthis.nunjucksTags = {};\n@@ -44,9 +46,11 @@ class UserConfig {\nthis.nunjucksAsyncShortcodes = {};\nthis.nunjucksPairedShortcodes = {};\nthis.nunjucksAsyncPairedShortcodes = {};\n+\nthis.handlebarsHelpers = {};\nthis.handlebarsShortcodes = {};\nthis.handlebarsPairedShortcodes = {};\n+\nthis.javascriptFunctions = {};\nthis.pugOptions = {};\nthis.ejsOptions = {};\n@@ -468,6 +472,10 @@ class UserConfig {\nthis.nunjucksEnvironmentOptions = options;\n}\n+ setNunjucksPrecompiledTemplates(templates) {\n+ this.nunjucksPrecompiledTemplates = templates;\n+ }\n+\nsetEjsOptions(options) {\nthis.ejsOptions = options;\n}\n@@ -774,6 +782,7 @@ class UserConfig {\nliquidShortcodes: this.liquidShortcodes,\nliquidPairedShortcodes: this.liquidPairedShortcodes,\nnunjucksEnvironmentOptions: this.nunjucksEnvironmentOptions,\n+ nunjucksPrecompiledTemplates: this.nunjucksPrecompiledTemplates,\nnunjucksFilters: this.nunjucksFilters,\nnunjucksAsyncFilters: this.nunjucksAsyncFilters,\nnunjucksTags: this.nunjucksTags,\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Support for precompiled Nunjucks templates |
699 | 01.04.2022 18:01:07 | 18,000 | 286bbc9755284bb5beb9ffac856a209fb2e24b21 | GetEmptyConfig function | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/RenderPlugin.js",
"new_path": "src/Plugins/RenderPlugin.js",
"diff": "@@ -333,3 +333,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nmodule.exports = EleventyPlugin;\nmodule.exports.File = renderFile;\nmodule.exports.String = render;\n+\n+module.exports.GetEmptyConfig = function () {\n+ return new TemplateConfig(null, false);\n+};\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | GetEmptyConfig function |
699 | 01.04.2022 19:56:55 | 18,000 | 81eefe36c768364f928615d5c88f47ca310d0acb | Pass in a templateConfig as a plugin option. | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/RenderPlugin.js",
"new_path": "src/Plugins/RenderPlugin.js",
"diff": "@@ -16,6 +16,7 @@ async function render(\nif (!templateConfig) {\ntemplateConfig = new TemplateConfig(null, false);\n}\n+ // TODO should this run every time??? probably not?\nif (config && typeof config === \"function\") {\nawait config(templateConfig.userConfig);\n}\n@@ -233,6 +234,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n{\ntagName: \"renderTemplate\",\ntagNameFile: \"renderFile\",\n+ templateConfig: null,\n},\noptions\n);\n@@ -251,7 +253,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nasync function renderStringShortcodeFn(content, templateLang, data = {}) {\nlet fn = await render.call(this, content, templateLang, {\n- templateConfig,\n+ templateConfig: opts.templateConfig || templateConfig,\nextensionMap,\n});\n@@ -282,7 +284,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nthis,\ninputPath,\n{\n- templateConfig,\n+ templateConfig: opts.templateConfig || templateConfig,\nextensionMap,\n},\ntemplateLang\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Pass in a templateConfig as a plugin option. |
699 | 04.04.2022 17:49:59 | 18,000 | 2f5178471649731cc55bcfd63016c07a64dd725d | Event for Nunjucks environment | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -25,8 +25,10 @@ class Nunjucks extends TemplateEngine {\n}\n_setEnv(override) {\n+ if (override) {\n+ this.njkEnv = override;\n+ } else if (this._usingPrecompiled) {\n// Precompiled templates to avoid eval!\n- if (this._usingPrecompiled) {\nfunction NodePrecompiledLoader() {}\nNodePrecompiledLoader.prototype.getSource = (name) => {\n// https://github.com/mozilla/nunjucks/blob/fd500902d7c88672470c87170796de52fc0f791a/nunjucks/src/precompiled-loader.js#L5\n@@ -41,9 +43,7 @@ class Nunjucks extends TemplateEngine {\n};\n};\n- this.njkEnv =\n- override ||\n- new NunjucksLib.Environment(\n+ this.njkEnv = new NunjucksLib.Environment(\nnew NodePrecompiledLoader(),\nthis.nunjucksEnvironmentOptions\n);\n@@ -53,10 +53,16 @@ class Nunjucks extends TemplateEngine {\nTemplatePath.getWorkingDir(),\n]);\n- this.njkEnv =\n- override ||\n- new NunjucksLib.Environment(fsLoader, this.nunjucksEnvironmentOptions);\n+ this.njkEnv = new NunjucksLib.Environment(\n+ fsLoader,\n+ this.nunjucksEnvironmentOptions\n+ );\n}\n+\n+ this.config.events.emit(\"eleventy.engine.njk\", {\n+ nunjucks: NunjucksLib,\n+ environment: this.njkEnv,\n+ });\n}\nsetLibrary(override) {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Event for Nunjucks environment |
699 | 04.04.2022 17:50:21 | 18,000 | d20a43ca8ea5b4685034511582e3d2cf560cef73 | Handle falsy values on RenderPlugin config (to allow partial opt-in) | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/RenderPlugin.js",
"new_path": "src/Plugins/RenderPlugin.js",
"diff": "@@ -16,6 +16,7 @@ async function render(\nif (!templateConfig) {\ntemplateConfig = new TemplateConfig(null, false);\n}\n+\n// TODO should this run every time??? probably not?\nif (config && typeof config === \"function\") {\nawait config(templateConfig.userConfig);\n@@ -313,6 +314,8 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n}\n// Render strings\n+ if (opts.tagName) {\n+ // use falsy to opt-out\neleventyConfig.addJavaScriptFunction(opts.tagName, renderStringShortcodeFn);\neleventyConfig.addLiquidTag(opts.tagName, function (liquidEngine) {\n@@ -322,15 +325,22 @@ function EleventyPlugin(eleventyConfig, options = {}) {\neleventyConfig.addNunjucksTag(opts.tagName, function (nunjucksLib) {\nreturn nunjucksTemplateTag(nunjucksLib, opts.tagName);\n});\n+ }\n// Render File\n- eleventyConfig.addJavaScriptFunction(opts.tagNameFile, renderFileShortcodeFn);\n+ if (opts.tagNameFile) {\n+ // use `false` to opt-out\n+ eleventyConfig.addJavaScriptFunction(\n+ opts.tagNameFile,\n+ renderFileShortcodeFn\n+ );\neleventyConfig.addLiquidShortcode(opts.tagNameFile, renderFileShortcodeFn);\neleventyConfig.addNunjucksAsyncShortcode(\nopts.tagNameFile,\nrenderFileShortcodeFn\n);\n}\n+}\nmodule.exports = EleventyPlugin;\nmodule.exports.File = renderFile;\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Handle falsy values on RenderPlugin config (to allow partial opt-in) |
699 | 05.04.2022 13:25:42 | 18,000 | 24fffc5208f4fbdccd2c6a354e50ed5b3998e082 | Use RenderManager so that configs are passed around and re-used for free. | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/RenderPlugin.js",
"new_path": "src/Plugins/RenderPlugin.js",
"diff": "@@ -11,7 +11,7 @@ const Liquid = require(\"../Engines/Liquid\");\nasync function render(\ncontent,\ntemplateLang,\n- { templateConfig, extensionMap, config } = {}\n+ { templateConfig, extensionMap } = {}\n) {\nif (!templateConfig) {\ntemplateConfig = new TemplateConfig(null, false);\n@@ -22,11 +22,6 @@ async function render(\ntemplateLang = this.page.templateSyntax;\n}\n- // TODO should this run every time??? probably not?\n- if (config && typeof config === \"function\") {\n- await config(templateConfig.userConfig);\n- }\n-\nlet cfg = templateConfig.getConfig();\nlet tr = new TemplateRender(templateLang, cfg.dir.input, templateConfig);\ntr.extensionMap = extensionMap;\n@@ -357,6 +352,29 @@ module.exports = EleventyPlugin;\nmodule.exports.File = renderFile;\nmodule.exports.String = render;\n-module.exports.GetEmptyConfig = function () {\n- return new TemplateConfig(null, false);\n-};\n+// Will re-use the same configuration instance both at a top level and across any nested renders\n+class RenderManager {\n+ constructor() {\n+ this.templateConfig = new TemplateConfig(null, false);\n+\n+ this.templateConfig.userConfig.addPlugin(EleventyPlugin, {\n+ templateConfig: this.templateConfig,\n+ });\n+ }\n+\n+ // Async friendly but requires await upstream\n+ config(callback) {\n+ // run an extra `function(eleventyConfig)` configuration callbacks\n+ if (callback && typeof callback === \"function\") {\n+ return callback(this.templateConfig.userConfig);\n+ }\n+ }\n+\n+ compile(content, templateLang, options = {}) {\n+ options.templateConfig = this.templateConfig;\n+\n+ return render(content, templateLang, options);\n+ }\n+}\n+\n+module.exports.RenderManager = RenderManager;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderPluginTest.js",
"new_path": "test/TemplateRenderPluginTest.js",
"diff": "const test = require(\"ava\");\nconst RenderPlugin = require(\"../src/Plugins/RenderPlugin\");\n+const RenderManager = RenderPlugin.RenderManager;\nconst RenderPluginFile = RenderPlugin.File;\nconst RenderPluginString = RenderPlugin.String;\n@@ -249,7 +250,13 @@ test(\"Remap non-object data to data._ if object is not passed in\", async (t) =>\n});\ntest(\"Direct use of render string plugin, rendering Nunjucks (and nested Liquid)\", async (t) => {\n- let fn = await RenderPluginString(\n+ let renderMgr = new RenderManager();\n+ renderMgr.config(function (eleventyConfig) {\n+ eleventyConfig.addFilter(\"testing\", function () {\n+ return \"tested.\";\n+ });\n+ });\n+ let fn = await renderMgr.compile(\n`{%- set nunjucksVar = 69 -%}\n{{ hi }}\n{{ nunjucksVar }}\n@@ -259,16 +266,9 @@ test(\"Direct use of render string plugin, rendering Nunjucks (and nested Liquid)\n* {{ hi }} test test {{ bye }} {{ liquidVar }}\n{% endrenderTemplate %}\n`,\n- \"njk\",\n- {\n- config: function (eleventyConfig) {\n- eleventyConfig.addPlugin(RenderPlugin);\n- eleventyConfig.addFilter(\"testing\", function () {\n- return \"tested.\";\n- });\n- },\n- }\n+ \"njk\"\n);\n+\nlet data = {\nhi: \"nunjucksHi\",\nargData: {\n@@ -290,7 +290,14 @@ tested.\n});\ntest(\"Direct use of render string plugin, rendering Liquid (and nested Nunjucks)\", async (t) => {\n- let fn = await RenderPluginString(\n+ let renderMgr = new RenderManager();\n+ renderMgr.config(function (eleventyConfig) {\n+ eleventyConfig.addFilter(\"testing\", function () {\n+ return \"tested.\";\n+ });\n+ });\n+\n+ let fn = await renderMgr.compile(\n`{%- assign liquidVar = 69 -%}\n{{ hi }}\n{{ liquidVar }}\n@@ -300,15 +307,7 @@ test(\"Direct use of render string plugin, rendering Liquid (and nested Nunjucks)\n* {{ hi }} test test {{ bye }} {{ njkVar }}\n{% endrenderTemplate %}\n`,\n- \"liquid\",\n- {\n- config: function (eleventyConfig) {\n- eleventyConfig.addPlugin(RenderPlugin);\n- eleventyConfig.addFilter(\"testing\", function () {\n- return \"tested.\";\n- });\n- },\n- }\n+ \"liquid\"\n);\nlet data = {\nhi: \"liquidHi\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Use RenderManager so that configs are passed around and re-used for free. |
699 | 07.04.2022 10:50:34 | 18,000 | 3c6a26580df228964e93110ccfa1893da38faf3b | Fixes bug with templateEngineOverride and page.templateSyntax | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/RenderPlugin.js",
"new_path": "src/Plugins/RenderPlugin.js",
"diff": "@@ -17,7 +17,7 @@ async function render(\ntemplateConfig = new TemplateConfig(null, false);\n}\n- // Breaking change in 2.0+, previous default was `html`\n+ // Breaking change in 2.0+, previous default was `html` and now we default to the page template syntax\nif (!templateLang) {\ntemplateLang = this.page.templateSyntax;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -473,7 +473,9 @@ class Template extends TemplateContent {\ndata.page.fileSlug = this.fileSlugStr;\ndata.page.filePathStem = this.filePathStem;\ndata.page.outputFileExtension = this.engine.defaultTemplateFileExtension;\n- data.page.templateSyntax = this.templateRender.getEnginesList();\n+ data.page.templateSyntax = this.templateRender.getEnginesList(\n+ data[this.config.keys.engineOverride]\n+ );\nreturn data;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -221,8 +221,7 @@ class TemplateContent {\nreturn frontMatterData[this.config.keys.engineOverride];\n}\n- async setupTemplateRender(bypassMarkdown) {\n- let engineOverride = await this.getEngineOverride();\n+ async setupTemplateRender(engineOverride, bypassMarkdown) {\nif (engineOverride !== undefined) {\ndebugDev(\n\"%o overriding template engine to use %o\",\n@@ -250,8 +249,8 @@ class TemplateContent {\nreturn [cacheable, key, engineMap];\n}\n- async compile(str, bypassMarkdown) {\n- await this.setupTemplateRender(bypassMarkdown);\n+ async compile(str, bypassMarkdown, engineOverride) {\n+ await this.setupTemplateRender(engineOverride, bypassMarkdown);\nif (bypassMarkdown && !this.engine.needsCompilation(str)) {\nreturn async function () {\n@@ -387,7 +386,11 @@ class TemplateContent {\nreturn str;\n}\n- let fn = await this.compile(str, bypassMarkdown);\n+ let fn = await this.compile(\n+ str,\n+ bypassMarkdown,\n+ data[this.config.keys.engineOverride]\n+ );\nif (fn === undefined) {\nreturn;\n} else if (typeof fn !== \"function\") {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -2292,3 +2292,13 @@ test(\"Permalink is an object but an empty object (inherit default behavior)\", as\n\"./test/stubs/_site/permalink-empty-object/empty-object/index.html\"\n);\n});\n+\n+test(\"page.templateSyntax works with templateEngineOverride\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/overrides/page-templatesyntax.md\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is((await tmpl.render(await tmpl.getData())).trim(), \"<p>njk,md</p>\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/overrides/page-templatesyntax.md",
"diff": "+---\n+templateEngineOverride: njk,md\n+---\n+\n+{{ page.templateSyntax }}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fixes bug with templateEngineOverride and page.templateSyntax |
699 | 07.04.2022 10:59:21 | 18,000 | a86c17c93cd31273d4496f4266d6344528a0b9ae | Make sure getEnginesList returns a string and not array | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -177,7 +177,7 @@ class TemplateRender {\nif (engineOverride) {\nlet engines =\nTemplateRender.parseEngineOverrides(engineOverride).reverse();\n- return engines;\n+ return engines.join(\",\");\n}\nif (\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderTest.js",
"new_path": "test/TemplateRenderTest.js",
"diff": "@@ -63,3 +63,8 @@ test(\"Parse Overrides to get Prioritized Engine List\", async (t) => {\nTemplateRender.parseEngineOverrides(\"ejs,njk,html\");\n});\n});\n+\n+test(\"Make sure getEnginesList returns a string\", async (t) => {\n+ let tr = getNewTemplateRender(\"liquid\", \"./test/stubs\");\n+ t.is(tr.getEnginesList(\"njk,md\"), \"njk,md\");\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Make sure getEnginesList returns a string and not array |
699 | 12.04.2022 12:36:35 | 18,000 | f3cbf54bdd1f731e8ca40ec6db1bc2509551176e | Fix a test from moving to JavaScriptDependencies util | [
{
"change_type": "MODIFY",
"old_path": "test/EleventyWatchTargetsTest.js",
"new_path": "test/EleventyWatchTargetsTest.js",
"diff": "const test = require(\"ava\");\nconst EleventyWatchTargets = require(\"../src/EleventyWatchTargets\");\n+const JavaScriptDependencies = require(\"../src/Util/JavaScriptDependencies\");\ntest(\"Basic\", (t) => {\nlet targets = new EleventyWatchTargets();\n@@ -34,9 +35,8 @@ test(\"Add and make glob\", (t) => {\n});\ntest(\"JavaScript get dependencies\", (t) => {\n- let targets = new EleventyWatchTargets();\nt.deepEqual(\n- targets.getJavaScriptDependenciesFromList([\"./test/stubs/config-deps.js\"]),\n+ JavaScriptDependencies.getDependencies([\"./test/stubs/config-deps.js\"]),\n[\"./test/stubs/config-deps-upstream.js\"]\n);\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix a test from moving to JavaScriptDependencies util |
699 | 13.04.2022 11:11:17 | 18,000 | dd99adc1ac13d09770d12fc5533821cf29f6a8bf | Tests to confirm is working okay | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -2292,3 +2292,44 @@ test(\"Permalink is an object but an empty object (inherit default behavior)\", as\n\"./test/stubs/_site/permalink-empty-object/empty-object/index.html\"\n);\n});\n+\n+test(\"permalink function returns serverless object Issue #1898\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/stubs-computed-permalink//object.11ty.js\",\n+ \"./test/stubs/stubs-computed-permalink/\",\n+ \"./test/stubs/stubs-computed-permalink/_site\"\n+ );\n+ let data = await tmpl.getData();\n+ let [page] = await tmpl.getTemplates(data);\n+\n+ t.is(page.url, \"/i18n/en/\");\n+ t.is(page.outputPath, false);\n+});\n+\n+test(\"eleventyComputed returns permalink object Issue #1898\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/stubs-computed-permalink/eleventycomputed-object.11ty.js\",\n+ \"./test/stubs/stubs-computed-permalink/\",\n+ \"./test/stubs/stubs-computed-permalink/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let [page] = await tmpl.getTemplates(data);\n+\n+ t.is(page.url, \"/i18n/en/\");\n+ t.is(page.outputPath, false);\n+});\n+\n+test(\"eleventyComputed returns nested permalink object Issue #1898\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/stubs-computed-permalink/eleventycomputed-nested-object.11ty.js\",\n+ \"./test/stubs/stubs-computed-permalink/\",\n+ \"./test/stubs/stubs-computed-permalink/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let [page] = await tmpl.getTemplates(data);\n+\n+ t.is(page.url, \"/i18n/en/\");\n+ t.is(page.outputPath, false);\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/stubs-computed-permalink/eleventycomputed-nested-object.11ty.js",
"diff": "+module.exports.data = {\n+ lang: \"en\",\n+ eleventyComputed: {\n+ permalink: function (data) {\n+ return {\n+ serverless: `/i18n/${data.lang}/`,\n+ };\n+ },\n+ },\n+};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/stubs-computed-permalink/eleventycomputed-object.11ty.js",
"diff": "+module.exports.data = {\n+ lang: \"en\",\n+ eleventyComputed: {\n+ permalink: {\n+ serverless: function (data) {\n+ return `/i18n/${data.lang}/`;\n+ },\n+ },\n+ },\n+};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/stubs-computed-permalink/object.11ty.js",
"diff": "+module.exports.data = {\n+ lang: \"en\",\n+ permalink: function (data) {\n+ return {\n+ serverless: `/i18n/${data.lang}/`,\n+ };\n+ },\n+};\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Tests to confirm #1898 is working okay |
699 | 13.04.2022 17:54:07 | 18,000 | 49cceff6939611abbc80b15dec69b5f38c386af6 | Use new dev server canary | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n\"dependencies\": {\n\"@11ty/dependency-tree\": \"^2.0.1\",\n- \"@11ty/eleventy-dev-server\": \"^1.0.0-canary.7\",\n+ \"@11ty/eleventy-dev-server\": \"^1.0.0-canary.8\",\n\"@11ty/eleventy-utils\": \"^1.0.1\",\n\"@iarna/toml\": \"^2.2.5\",\n\"@sindresorhus/slugify\": \"^1.1.2\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Use new dev server canary |
699 | 14.04.2022 12:46:37 | 18,000 | 2b18aab4be68fa89959495327cb19da16401f66a | Switch to static functions for Eleventy version and help args. Fixes | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -62,6 +62,11 @@ try {\n);\n});\n+ if (argv.version) {\n+ console.log(Eleventy.getVersion());\n+ } else if (argv.help) {\n+ console.log(Eleventy.getHelp());\n+ } else {\nlet elev = new Eleventy(argv.input, argv.output, {\n// --quiet and --quiet=true both resolve to true\nquietMode: argv.quiet,\n@@ -72,11 +77,6 @@ try {\n// reuse ErrorHandler instance in Eleventy\nerrorHandler = elev.errorHandler;\n- if (argv.version) {\n- console.log(elev.getVersion());\n- } else if (argv.help) {\n- console.log(elev.getHelp());\n- } else {\nif (argv.to === \"json\" || argv.to === \"ndjson\") {\n// override logging output\nelev.setIsVerbose(false);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -540,20 +540,27 @@ Verbose Output: ${this.verboseMode}`);\n/**\n* Reads the version of Eleventy.\n*\n- * @method\n+ * @static\n* @returns {String} - The version of Eleventy.\n*/\n- getVersion() {\n+ static getVersion() {\nreturn pkg.version;\n}\n+ /**\n+ * @deprecated since 1.0.1, use static Eleventy.getVersion()\n+ */\n+ getVersion() {\n+ return Eleventy.getVersion();\n+ }\n+\n/**\n* Shows a help message including usage.\n*\n- * @method\n+ * @static\n* @returns {String} - The help mesage.\n*/\n- getHelp() {\n+ static getHelp() {\nreturn `Usage: eleventy\neleventy --input=. --output=./_site\neleventy --serve\n@@ -599,6 +606,13 @@ Arguments:\n--help`;\n}\n+ /**\n+ * @deprecated since 1.0.1, use static Eleventy.getHelp()\n+ */\n+ getHelp() {\n+ return Eleventy.getHelp();\n+ }\n+\n/**\n* Resets the config of Eleventy.\n*\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Switch to static functions for Eleventy version and help args. Fixes #1313 |
699 | 14.04.2022 17:46:35 | 18,000 | a5c985d8b6f4b6ba70d502563f5387d1656a4ba2 | Copy update to debug output | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -942,7 +942,7 @@ Arguments:\n}\nstopWatch() {\n- debug(\"Cleaning up chokidar and browsersync (if exists) instances.\");\n+ debug(\"Cleaning up chokidar and server instances, if they exist.\");\nthis.eleventyServe.close();\nthis.watcher.close();\nprocess.exit();\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Copy update to debug output |
699 | 15.04.2022 11:53:58 | 18,000 | b46e32723f26a0f69df3a1a3097b070e86b29095 | Improvements to aggregate benchmark logs via | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -173,6 +173,19 @@ class TemplateConfig {\nthis.config.pathPrefix = pathPrefix;\n}\n+ /**\n+ * Gets the current path prefix denoting the root folder the output will be deployed to\n+ *\n+ * @returns {String} - The path prefix string\n+ */\n+ getPathPrefix() {\n+ if (!this.hasConfigMerged) {\n+ this.getConfig();\n+ }\n+\n+ return this.config.pathPrefix;\n+ }\n+\n/**\n* Bootstraps the config object.\n*/\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -278,6 +278,8 @@ class TemplateContent {\nreturn cache.get(key);\n}\n+ this.bench.get(\"Template Compile Cache Miss\").incrementCount();\n+\n// Compilation is async, so we eagerly cache a Promise that eventually\n// resolves to the compiled function\ncache.set(\n@@ -402,8 +404,10 @@ class TemplateContent {\n// Benchmark\nlet templateBenchmark = this.bench.get(\"Render\");\n+ let logRenderToOutputBenchmark = true;\nlet paginationSuffix = [];\nif (\"pagination\" in data) {\n+ logRenderToOutputBenchmark = false; // skip benchmark for each individual pagination entry\npaginationSuffix.push(\" (Pagination\");\nif (data.pagination.pages) {\npaginationSuffix.push(\n@@ -419,9 +423,9 @@ class TemplateContent {\n`> Render > ${this.inputPath}${paginationSuffix.join(\"\")}`\n);\nlet outputPathBenchmark;\n- if (data.page && data.page.outputPath) {\n+ if (data.page && data.page.outputPath && logRenderToOutputBenchmark) {\noutputPathBenchmark = this.bench.get(\n- `> Render > ${data.page.outputPath}`\n+ `> Render to > ${data.page.outputPath}`\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/defaultConfig.js",
"new_path": "src/defaultConfig.js",
"diff": "@@ -5,14 +5,13 @@ const slugifyFilter = require(\"./Filters/Slugify\");\nconst getCollectionItem = require(\"./Filters/GetCollectionItem\");\nmodule.exports = function (config) {\n- let eleventyConfig = this;\n+ let templateConfig = this;\nconfig.addFilter(\"slug\", slugFilter);\nconfig.addFilter(\"slugify\", slugifyFilter);\nconfig.addFilter(\"url\", function (url, pathPrefixOverride) {\n- let pathPrefix =\n- pathPrefixOverride || eleventyConfig.getConfig().pathPrefix;\n+ let pathPrefix = pathPrefixOverride || templateConfig.getPathPrefix();\nreturn urlFilter.call(this, url, pathPrefix);\n});\nconfig.addFilter(\"log\", console.log);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Improvements to aggregate benchmark logs via #2295 |
699 | 15.04.2022 12:43:44 | 18,000 | 089ab8f205a6b1ed790a45d1a234438649f91b74 | Adds `eleventy.version` and `eleventy.generator` to Eleventy supplied global data to fix | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "+const pkg = require(\"../package.json\");\nconst fs = require(\"fs\");\nconst fastglob = require(\"fast-glob\");\nconst path = require(\"path\");\nconst lodashset = require(\"lodash/set\");\nconst lodashget = require(\"lodash/get\");\nconst lodashUniq = require(\"lodash/uniq\");\n+const semver = require(\"semver\");\nconst { TemplatePath } = require(\"@11ty/eleventy-utils\");\nconst merge = require(\"./Util/Merge\");\n@@ -310,10 +312,14 @@ class TemplateData {\n}\n}\n- if (this.environmentVariables) {\nif (!(\"eleventy\" in globalData)) {\nglobalData.eleventy = {};\n}\n+ // #2293 for meta[name=generator]\n+ globalData.eleventy.version = semver.coerce(pkg.version).toString();\n+ globalData.eleventy.generator = `Eleventy v${globalData.eleventy.version}`;\n+\n+ if (this.environmentVariables) {\nif (!(\"env\" in globalData.eleventy)) {\nglobalData.eleventy.env = {};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -456,10 +456,8 @@ test(\"Parent directory for data (Issue #337)\", async (t) => {\nlet data = await dataObj.getData();\n- t.deepEqual(data, {\n- xyz: {\n+ t.deepEqual(data.xyz, {\nhi: \"bye\",\n- },\n});\n});\n@@ -519,3 +517,22 @@ test(\"addGlobalData complex key\", async (t) => {\nt.is(data.deep.nested.one, \"first\");\nt.is(data.deep.nested.two, \"second\");\n});\n+\n+test(\"eleventy.version and eleventy.generator returned from data\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.addGlobalData(\"deep.nested.one\", () => \"first\");\n+ eleventyConfig.userConfig.addGlobalData(\"deep.nested.two\", () => \"second\");\n+\n+ let dataObj = new TemplateData(\"./test/stubs-empty/\", eleventyConfig);\n+ let data = await dataObj.getData();\n+\n+ let version = require(\"semver\")\n+ .coerce(require(\"../package.json\").version)\n+ .toString();\n+\n+ t.is(data.eleventy.version, version);\n+ t.is(data.eleventy.generator, `Eleventy v${version}`);\n+\n+ t.is(data.deep.nested.one, \"first\");\n+ t.is(data.deep.nested.two, \"second\");\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -1362,6 +1362,7 @@ test(\"Data Cascade (Deep merge)\", async (t) => {\nlet data = await tmpl.getData();\nt.deepEqual(Object.keys(data).sort(), [\n\"datafile\",\n+ \"eleventy\",\n\"frontmatter\",\n\"page\",\n\"parent\",\n@@ -1397,6 +1398,7 @@ test(\"Data Cascade (Shallow merge)\", async (t) => {\nlet data = await tmpl.getData();\nt.deepEqual(Object.keys(data).sort(), [\n\"datafile\",\n+ \"eleventy\",\n\"frontmatter\",\n\"page\",\n\"parent\",\n"
},
{
"change_type": "ADD",
"old_path": "test/stubs-empty/.gitkeep",
"new_path": "test/stubs-empty/.gitkeep",
"diff": ""
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds `eleventy.version` and `eleventy.generator` to Eleventy supplied global data to fix #2293. |
699 | 15.04.2022 17:20:40 | 18,000 | f053bd2c3c96756c0e3361721a0fd5fcc5d0bccf | Note about npm canary | [
{
"change_type": "MODIFY",
"old_path": "docs/meta-release.md",
"new_path": "docs/meta-release.md",
"diff": "1. Tag new version\n1. `npm publish --access=public --tag=canary`\n+Unfortunate thing about npm: if you push a 1.0.0-canary.x to `canary` after a `2.0.0-canary.x`, it will use the last pushed tag (not the highest version number)\n+\n# Beta Release Procedure\n1. update minor dependencies in package.json?\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Note about npm canary |
699 | 18.04.2022 14:59:16 | 18,000 | b50ffb95700e9473b25f960ff2ed083121c3c9a7 | Outdated instructions for 11ty-website | [
{
"change_type": "MODIFY",
"old_path": "docs/meta-release.md",
"new_path": "docs/meta-release.md",
"diff": "@@ -46,7 +46,6 @@ Unfortunate thing about npm: if you push a 1.0.0-canary.x to `canary` after a `2\n1. Check in a new `11ty-website` site with updated `package.json` version.\n1. Add version to 11ty-website `versions.json`\n1. Commit it\n-1. Run ./deploy.sh to push to production branch for 11ty-website\n1. Create a new branch for branched version\n1. Go to https://app.netlify.com/sites/11ty/settings/domain and set up a subdomain for it.\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Outdated instructions for 11ty-website |
699 | 18.04.2022 23:21:27 | 18,000 | b707d8c8fe57225c0c93930e02c88041195438b2 | Initial commit for Eleventy Edge | [
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "+# Generated files\n+package/generated*\n+\n# Ignore installed npm modules\nnode_modules/\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/meta-release.md",
"new_path": "docs/meta-release.md",
"diff": "# Canary Release Procedure\n1. npmclean aka `rm -rf node_modules && rm -f package-lock.json && npm install`\n+1. `npm run package` to generate a new Eleventy Edge lib\n1. Make sure `npx ava` runs okay\n1. Update version in `package.json`, include `-canary.1` suffix\n1. Check it all in and commit\n@@ -19,6 +20,7 @@ Unfortunate thing about npm: if you push a 1.0.0-canary.x to `canary` after a `2\n1. update minor dependencies in package.json?\n1. npmclean aka `rm -rf node_modules && rm -f package-lock.json && npm install`\n+1. `npm run package` to generate a new Eleventy Edge lib\n1. npm audit\n1. Make sure `npx ava` runs okay\n1. Update version in `package.json`, include `-beta.1` suffix\n@@ -33,6 +35,7 @@ Unfortunate thing about npm: if you push a 1.0.0-canary.x to `canary` after a `2\n1. npmclean aka `rm -rf node_modules && rm -f package-lock.json && npm install`\n1. If the minimum Node version changed, make sure you update `package.json` engines property.\n1. Bonus: make sure the error message works correctly for Node versions less than 10. 0.12.x+ requires Node 10+. 1.x+ requires Node 12+\n+1. `npm run package` to generate a new Eleventy Edge lib\n1. npm audit\n1. Make sure `npx ava` runs okay\n1. Update version in `package.json`\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"@11ty/eleventy\",\n- \"version\": \"2.0.0-canary.5\",\n+ \"version\": \"2.0.0-canary.6\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"publishConfig\": {\n\"access\": \"public\"\n\"format\": \"prettier src/ --write\",\n\"test\": \"npx ava --verbose\",\n\"lint-staged\": \"lint-staged\",\n+ \"package\": \"node package/compile-edge-lib.js\",\n\"coverage\": \"npx nyc ava && npx nyc report --reporter=json-summary && cp coverage/coverage-summary.json docs-src/_data/coverage.json && node cmd.js --config=docs-src/.eleventy.docs.js\",\n\"prepare\": \"husky install\"\n},\n\"@11ty/eleventy-plugin-vue\": \"1.0.0-canary.8\",\n\"@vue/server-renderer\": \"^3.2.33\",\n\"ava\": \"^3.15.0\",\n+ \"esbuild\": \"^0.14.36\",\n\"husky\": \"^7.0.4\",\n\"js-yaml\": \"^4.1.0\",\n\"lint-staged\": \"^12.3.8\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -1096,3 +1096,4 @@ module.exports = Eleventy;\nmodule.exports.EleventyServerless = require(\"./Serverless\");\nmodule.exports.EleventyServerlessBundlerPlugin = require(\"./Plugins/ServerlessBundlerPlugin\");\nmodule.exports.EleventyRenderPlugin = require(\"./Plugins/RenderPlugin\");\n+module.exports.EleventyEdgePlugin = require(\"./Plugins/EdgePlugin\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Plugins/Edge/LiquidEdge.js",
"diff": "+const { Tokenizer, evalToken } = require(\"liquidjs\");\n+\n+function rawContentLiquidTag(liquidEngine, renderFn, tagName) {\n+ // via https://github.com/harttle/liquidjs/blob/b5a22fa0910c708fe7881ef170ed44d3594e18f3/src/builtin/tags/raw.ts\n+ return {\n+ parse: function (tagToken, remainTokens) {\n+ this.name = tagToken.name;\n+ this.args = [];\n+ this.tokens = [];\n+\n+ const tokenizer = new Tokenizer(tagToken.args);\n+ this.args = [];\n+ while (!tokenizer.end()) {\n+ let value = tokenizer.readValue();\n+ if (!value) {\n+ break;\n+ }\n+ this.args.push(value);\n+ }\n+\n+ var stream = liquidEngine.parser\n+ .parseStream(remainTokens)\n+ .on(\"token\", (token) => {\n+ if (token.name === \"end\" + tagName) stream.stop();\n+ else this.tokens.push(token);\n+ })\n+ .on(\"end\", () => {\n+ throw new Error(`tag ${tagToken.getText()} not closed`);\n+ });\n+\n+ stream.start();\n+ },\n+ render: async function (ctx) {\n+ let normalizedContext = {};\n+ if (ctx) {\n+ normalizedContext.page = ctx.get([\"page\"]);\n+ normalizedContext.eleventy = ctx.get([\"eleventy\"]);\n+ }\n+\n+ let argArray = this.args.map((token) => evalToken(token, ctx));\n+ let body = this.tokens.map((token) => token.getText()).join(\"\");\n+\n+ return renderFn.call(normalizedContext, tagName, body, ...argArray);\n+ },\n+ };\n+}\n+\n+module.exports = rawContentLiquidTag;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Plugins/Edge/NunjucksEdge.js",
"diff": "+function rawContentNunjucksTag(nunjucks, nunjucksEnv, renderFn, tagName) {\n+ return new (function () {\n+ this.tags = [tagName];\n+\n+ this.parse = function (parser, nodes) {\n+ var tok = parser.nextToken();\n+\n+ var args = parser.parseSignature(true, true);\n+ const begun = parser.advanceAfterBlockEnd(tok.value);\n+\n+ // This code was ripped from the Nunjucks parser for `raw`\n+ // https://github.com/mozilla/nunjucks/blob/fd500902d7c88672470c87170796de52fc0f791a/nunjucks/src/parser.js#L655\n+ const endTagName = \"end\" + tagName;\n+ // Look for upcoming raw blocks (ignore all other kinds of blocks)\n+ const rawBlockRegex = new RegExp(\n+ \"([\\\\s\\\\S]*?){%\\\\s*(\" + tagName + \"|\" + endTagName + \")\\\\s*(?=%})%}\"\n+ );\n+ let rawLevel = 1;\n+ let str = \"\";\n+ let matches = null;\n+\n+ // Exit when there's nothing to match\n+ // or when we've found the matching \"endraw\" block\n+ while (\n+ (matches = parser.tokens._extractRegex(rawBlockRegex)) &&\n+ rawLevel > 0\n+ ) {\n+ const all = matches[0];\n+ const pre = matches[1];\n+ const blockName = matches[2];\n+\n+ // Adjust rawlevel\n+ if (blockName === tagName) {\n+ rawLevel += 1;\n+ } else if (blockName === endTagName) {\n+ rawLevel -= 1;\n+ }\n+\n+ // Add to str\n+ if (rawLevel === 0) {\n+ // We want to exclude the last \"endraw\"\n+ str += pre;\n+ // Move tokenizer to beginning of endraw block\n+ parser.tokens.backN(all.length - pre.length);\n+ } else {\n+ str += all;\n+ }\n+ }\n+\n+ let body = new nodes.Output(begun.lineno, begun.colno, [\n+ new nodes.TemplateData(begun.lineno, begun.colno, str),\n+ ]);\n+ return new nodes.CallExtensionAsync(this, \"run\", args, [body]);\n+ };\n+\n+ this.run = function (...args) {\n+ let resolve = args.pop();\n+ let body = args.pop();\n+ let [context, arg1, arg2, ...argArray] = args;\n+\n+ let normalizedContext = {};\n+ if (context.ctx && context.ctx.page) {\n+ normalizedContext.ctx = context.ctx;\n+ normalizedContext.page = context.ctx.page;\n+ }\n+ if (context.ctx && context.ctx.eleventy) {\n+ normalizedContext.eleventy = context.ctx.eleventy;\n+ }\n+\n+ body(function (e, bodyContent) {\n+ if (e) {\n+ resolve(\n+ new Error(\n+ `Error with Nunjucks paired shortcode \\`${tagName}\\`: ${e.message}`\n+ )\n+ );\n+ }\n+\n+ Promise.resolve(\n+ renderFn.call(\n+ normalizedContext,\n+ tagName,\n+ bodyContent,\n+ arg1, // lang when edge(lang, data) and data when edge(data)\n+ arg2, // data when edge(lang, data) (all handled downstream)\n+ { nunjucks, nunjucksEnv }\n+ )\n+ )\n+ .then(function (returnValue) {\n+ resolve(null, new nunjucks.runtime.SafeString(returnValue));\n+ })\n+ .catch(function (e) {\n+ resolve(\n+ new Error(\n+ `Error with Nunjucks paired shortcode \\`${tagName}\\`: ${e.message}`\n+ ),\n+ null\n+ );\n+ });\n+ });\n+ };\n+ })();\n+}\n+\n+module.exports = rawContentNunjucksTag;\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Initial commit for Eleventy Edge |
699 | 19.04.2022 08:09:56 | 18,000 | 5a2784de8ddab5c7c0baf086960d7d5972189bb8 | Idea for later | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/EdgePlugin.js",
"new_path": "src/Plugins/EdgePlugin.js",
"diff": "@@ -264,13 +264,13 @@ function EleventyEdgePlugin(eleventyConfig, opts = {}) {\npath.join(options.functionsDir, \"_generated/precompiled.js\"),\n`export default { ${content.join(\",\\n\")} }`\n),\n+ // TODO call the esbuild stuff directly to build the lib file as part of the edge bundler\nfsp.copyFile(source, target),\n]);\n});\n}\n// TODO add a route checker to show a warning if edge shortcodes are used on pages that are not handled in edge function routes\n- // TODO make the `npm run package` script a prepublish? https://docs.npmjs.com/cli/v6/using-npm/scripts#prepare-and-prepublish\n}\nmodule.exports = EleventyEdgePlugin;\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Idea for later |
699 | 20.04.2022 16:44:13 | 18,000 | 4c5091037cef9e136f5e73a515026a688ba2ca0c | Minor tweak to generated app data file name | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/DefaultEdgeFunctionContent.js",
"new_path": "src/Plugins/DefaultEdgeFunctionContent.js",
"diff": "import { EleventyEdge } from \"eleventy:edge\";\n-import precompiled from \"./_generated/precompiled.js\";\n+import precompiledAppData from \"./_generated/eleventy-edge-app-data.js\";\nexport default async (request, context) => {\ntry {\nlet edge = new EleventyEdge(\"%%EDGE_NAME%%\", {\nrequest,\ncontext,\n- precompiled,\n+ precompiled: precompiledAppData,\n// default is [], add more keys to opt-in e.g. [\"appearance\", \"username\"]\ncookies: [],\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Plugins/EdgePlugin.js",
"new_path": "src/Plugins/EdgePlugin.js",
"diff": "@@ -246,7 +246,7 @@ function EleventyEdgePlugin(eleventyConfig, opts = {}) {\n});\n}\n- // Generate app precompiled.js file and generate default edge function (if needed)\n+ // Generate app eleventy-edge-app-data.js file and generate default edge function (if needed)\neleventyConfig.on(\"eleventy.after\", async () => {\nawait fsp.mkdir(path.join(options.functionsDir, \"_generated\"), {\nrecursive: true,\n@@ -262,7 +262,7 @@ function EleventyEdgePlugin(eleventyConfig, opts = {}) {\ncontent.push(helper.precompiledTemplates.toString());\nawait fsp.writeFile(\n- path.join(options.functionsDir, \"_generated/precompiled.js\"),\n+ path.join(options.functionsDir, \"_generated/eleventy-edge-app-data.js\"),\n`export default { ${content.join(\",\\n\")} }`\n);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Minor tweak to generated app data file name |
699 | 20.04.2022 17:39:31 | 18,000 | a2aba293c8c8c7a6ddcc2a2a2602ddc5b0f88530 | The serverless bundle module files were being created empty, which caused serverless runtime errors. | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -147,8 +147,12 @@ class BundlerHelper {\n}\nwriteBundlerDependenciesFile(filename, deps = []) {\n- let modules = deps.map((name) => `require(\"${name}\");`);\nlet fullPath = this.getOutputPath(filename);\n+ if (deps.length === 0 && fs.existsSync(fullPath)) {\n+ return;\n+ }\n+\n+ let modules = deps.map((name) => `require(\"${name}\");`);\nfs.writeFileSync(fullPath, modules.join(\"\\n\"));\nthis.copyCount++;\ndebug(\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | The serverless bundle module files were being created empty, which caused serverless runtime errors. |
699 | 28.04.2022 11:32:12 | 18,000 | c513c8939314572c1c431d361415cbb91597cffa | Fix for using the Edge plugin in a template where permalink: false | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/EdgePlugin.js",
"new_path": "src/Plugins/EdgePlugin.js",
"diff": "@@ -166,13 +166,17 @@ function renderAsLiquid(\ncss: { comments: [\"/*\", \"*/\"] },\njs: { comments: [\"/*\", \"*/\"] },\n};\n+\nlet type = \"html\";\n+ // when permalink is false, this.page.url is false\n+ if (this.page.url) {\nif (this.page.url.endsWith(\".css\")) {\ntype = \"css\";\n} else if (this.page.url.endsWith(\".js\")) {\n- // || this.page.url.endsWith(\".cjs\") || this.page.url.endsWith(\".mjs\")\n+ // TODO more extensions here?\ntype = \"js\";\n}\n+ }\nreturn `${\ntypes[type].comments[0]\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix for using the Edge plugin in a template where permalink: false |
699 | 02.05.2022 17:03:23 | 18,000 | 331f730cfea863ed24697370ae474105ee28899b | chore: Move some testing code out of the class! | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -69,7 +69,6 @@ class Template extends TemplateContent {\nthis.isDryRun = false;\nthis.writeCount = 0;\nthis.skippedCount = 0;\n- this.wrapWithLayouts = true;\nthis.fileSlug = new TemplateFileSlug(\nthis.inputPath,\nthis.inputDir,\n@@ -113,10 +112,6 @@ class Template extends TemplateContent {\nthis.isDryRun = !!isDryRun;\n}\n- setWrapWithLayouts(wrap) {\n- this.wrapWithLayouts = wrap;\n- }\n-\nsetExtraOutputSubdirectory(dir) {\nthis.extraOutputSubdirectory = dir + \"/\";\n}\n@@ -187,7 +182,6 @@ class Template extends TemplateContent {\nif (this.templateData) {\nperm.setServerlessPathData(this.templateData.getServerlessPathData());\n}\n-\nthis.behavior.setFromPermalink(perm);\nthis.serverlessUrls = perm.getServerlessUrls();\n@@ -466,29 +460,22 @@ class Template extends TemplateContent {\nreturn layout.render(tmplData, templateContent);\n}\n- async _testRenderWithoutLayouts(data) {\n- this.setWrapWithLayouts(false);\n- let ret = await this.render(data);\n- this.setWrapWithLayouts(true);\n- return ret;\n- }\n-\n// Used only by tests\nasync renderContent(str, data, bypassMarkdown) {\nreturn super.render(str, data, bypassMarkdown);\n}\n- async render(data) {\n+ async render(data, wrapWithLayouts = true) {\ndebugDev(\"%o render()\", this.inputPath);\nif (!data) {\nthrow new Error(\"`data` needs to be passed into render()\");\n}\n- if (!this.wrapWithLayouts && data[this.config.keys.layout]) {\n+ if (!wrapWithLayouts && data[this.config.keys.layout]) {\ndebugDev(\"Template.render is bypassing layouts for %o.\", this.inputPath);\n}\n- if (this.wrapWithLayouts && data[this.config.keys.layout]) {\n+ if (wrapWithLayouts && data[this.config.keys.layout]) {\ndebugDev(\n\"Template.render found layout: %o\",\ndata[this.config.keys.layout]\n@@ -588,7 +575,6 @@ class Template extends TemplateContent {\n}\nasync addComputedData(data) {\n- // will _not_ consume renderData\nthis.computedData = new ComputedData(this.config);\nif (this.config.keys.computed in data) {\n@@ -1036,11 +1022,7 @@ class Template extends TemplateContent {\n/* This is the primary render mechanism, called via TemplateMap->populateContentDataInMap */\nasync getTemplateMapContent(pageMapEntry) {\n- pageMapEntry.template.setWrapWithLayouts(false);\n- let content = await pageMapEntry.template.render(pageMapEntry.data);\n- pageMapEntry.template.setWrapWithLayouts(true);\n-\n- return content;\n+ return pageMapEntry.template.render(pageMapEntry.data, false);\n}\nasync getTemplateMapEntries(dataOverride) {\n@@ -1061,27 +1043,6 @@ class Template extends TemplateContent {\nreturn entries;\n}\n-\n- async _testCompleteRender() {\n- let entries = await this.getTemplateMapEntries();\n-\n- let nestedContent = await Promise.all(\n- entries.map(async (entry) => {\n- entry._pages = await entry.template.getTemplates(entry.data);\n- return Promise.all(\n- entry._pages.map(async (page) => {\n- page.templateContent = await entry.template.getTemplateMapContent(\n- page\n- );\n- return this.renderPageEntry(entry, page);\n- })\n- );\n- })\n- );\n-\n- let contents = [].concat(...nestedContent);\n- return contents;\n- }\n}\nmodule.exports = Template;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateMapTest.js",
"new_path": "test/TemplateMapTest.js",
"diff": "@@ -28,6 +28,11 @@ function getNewTemplateByNumber(num, eleventyConfig) {\n);\n}\n+async function testRenderWithoutLayouts(template, data) {\n+ let ret = await template.render(data, false);\n+ return ret;\n+}\n+\ntest(\"TemplateMap has collections added\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet tmpl1 = getNewTemplateByNumber(1, eleventyConfig);\n@@ -107,11 +112,11 @@ test(\"TemplateMap adds collections data and has templateContent values\", async (\nt.is(map[1].data.collections.all.length, 2);\nt.is(\n- await map[0].template._testRenderWithoutLayouts(map[0].data),\n+ await testRenderWithoutLayouts(map[0].template, map[0].data),\nmap[0]._pages[0].templateContent\n);\nt.is(\n- await map[1].template._testRenderWithoutLayouts(map[1].data),\n+ await testRenderWithoutLayouts(map[1].template, map[1].data),\nmap[1]._pages[0].templateContent\n);\n});\n@@ -132,7 +137,7 @@ test(\"TemplateMap circular references (map without templateContent)\", async (t)\nt.is(map[0].data.collections.all.length, 1);\nt.is(\n- await map[0].template._testRenderWithoutLayouts(map[0].data),\n+ await testRenderWithoutLayouts(map[0].template, map[0].data),\nmap[0]._pages[0].templateContent\n);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -22,6 +22,27 @@ function cleanHtml(str) {\nreturn pretty(str, { ocd: true });\n}\n+async function _testCompleteRender(tmpl) {\n+ let entries = await tmpl.getTemplateMapEntries();\n+\n+ let nestedContent = await Promise.all(\n+ entries.map(async (entry) => {\n+ entry._pages = await entry.template.getTemplates(entry.data);\n+ return Promise.all(\n+ entry._pages.map(async (page) => {\n+ page.templateContent = await entry.template.getTemplateMapContent(\n+ page\n+ );\n+ return tmpl.renderPageEntry(entry, page);\n+ })\n+ );\n+ })\n+ );\n+\n+ let contents = [].concat(...nestedContent);\n+ return contents;\n+}\n+\ntest(\"getTemplateSubFolder\", (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/template.ejs\",\n@@ -246,8 +267,6 @@ test(\"One Layout (layouts disabled)\", async (t) => {\neleventyConfig\n);\n- tmpl.setWrapWithLayouts(false);\n-\nt.is(\n(await tmpl.getFrontMatter()).data[tmpl.config.keys.layout],\n\"defaultLayoutLayoutContent\"\n@@ -256,7 +275,7 @@ test(\"One Layout (layouts disabled)\", async (t) => {\nlet data = await tmpl.getData();\nt.is(data[tmpl.config.keys.layout], \"defaultLayoutLayoutContent\");\n- t.is(cleanHtml(await tmpl.render(data)), \"<p>Hello.</p>\");\n+ t.is(cleanHtml(await tmpl.render(data, false)), \"<p>Hello.</p>\");\nt.is(data.keymain, \"valuemain\");\nt.is(data.keylayout, \"valuelayout\");\n@@ -1074,7 +1093,7 @@ test(\"Test a transform\", async (t) => {\nreturn \"OVERRIDE BY A TRANSFORM\";\n});\n- let renders = await tmpl._testCompleteRender();\n+ let renders = await _testCompleteRender(tmpl);\nt.is(renders[0], \"OVERRIDE BY A TRANSFORM\");\n});\n@@ -1094,7 +1113,7 @@ test.skip(\"Test a transform (does it have inputPath?)\", async (t) => {\nreturn \"OVERRIDE BY A TRANSFORM\";\n});\n- let renders = await tmpl._testCompleteRender();\n+ let renders = await _testCompleteRender(tmpl);\nt.is(renders[0], \"OVERRIDE BY A TRANSFORM\");\n});\n@@ -1114,7 +1133,7 @@ test(\"Test a transform with pages\", async (t) => {\nreturn \"OVERRIDE BY A TRANSFORM\";\n});\n- let renders = await tmpl._testCompleteRender();\n+ let renders = await _testCompleteRender(tmpl);\nt.is(renders[0], \"OVERRIDE BY A TRANSFORM\");\n});\n@@ -1133,7 +1152,7 @@ test(\"Test a transform with a layout\", async (t) => {\nreturn \"OVERRIDE BY A TRANSFORM\";\n});\n- let renders = await tmpl._testCompleteRender();\n+ let renders = await _testCompleteRender(tmpl);\nt.is(renders[0], \"OVERRIDE BY A TRANSFORM\");\n});\n@@ -1156,7 +1175,7 @@ test(\"Test a single asynchronous transform\", async (t) => {\n});\n});\n- let renders = await tmpl._testCompleteRender();\n+ let renders = await _testCompleteRender(tmpl);\nt.is(renders[0], \"OVERRIDE BY A TRANSFORM\");\n});\n@@ -1190,7 +1209,7 @@ test(\"Test multiple asynchronous transforms\", async (t) => {\n});\n});\n- let renders = await tmpl._testCompleteRender();\n+ let renders = await _testCompleteRender(tmpl);\nt.is(renders[0], \"LOWERCASE TRANSFORM\");\n});\n@@ -1208,7 +1227,7 @@ test(\"Test a linter\", async (t) => {\nt.true(outputPath.endsWith(\"index.html\"));\n});\n- await tmpl._testCompleteRender();\n+ await _testCompleteRender(tmpl);\n});\ntest(\"Front Matter Tags (Single)\", async (t) => {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | chore: Move some testing code out of the class! |
699 | 02.05.2022 17:29:23 | 18,000 | 2940de8c2edc584de9e80c04382531a14b7cdb87 | Cleanup on Template render methods | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -460,30 +460,28 @@ class Template extends TemplateContent {\nreturn layout.render(tmplData, templateContent);\n}\n- // Used only by tests\n- async renderContent(str, data, bypassMarkdown) {\n+ async renderDirect(str, data, bypassMarkdown) {\nreturn super.render(str, data, bypassMarkdown);\n}\n- async render(data, wrapWithLayouts = true) {\n+ // This is the primary render mechanism, called via TemplateMap->populateContentDataInMap\n+ async renderWithoutLayout(data) {\n+ let content = await this.getPreRender();\n+ return this.renderDirect(content, data);\n+ }\n+\n+ // render *with* Layouts\n+ async render(data) {\ndebugDev(\"%o render()\", this.inputPath);\nif (!data) {\nthrow new Error(\"`data` needs to be passed into render()\");\n}\n- if (!wrapWithLayouts && data[this.config.keys.layout]) {\n- debugDev(\"Template.render is bypassing layouts for %o.\", this.inputPath);\n- }\n-\n- if (wrapWithLayouts && data[this.config.keys.layout]) {\n- debugDev(\n- \"Template.render found layout: %o\",\n- data[this.config.keys.layout]\n- );\n+ if (data[this.config.keys.layout]) {\nreturn this.renderLayout(this, data);\n} else {\n- debugDev(\"Template.render renderContent for %o\", this.inputPath);\n- return super.render(await this.getPreRender(), data);\n+ debugDev(\"Template.render renderDirect for %o\", this.inputPath);\n+ return this.renderWithoutLayout(data);\n}\n}\n@@ -622,6 +620,7 @@ class Template extends TemplateContent {\n}\n}\n+ // Computed data consuming collections!\nasync resolveRemainingComputedData(data) {\ndebug(\"Second round of computed data for %o\", this.inputPath);\nawait this.computedData.processRemainingData(data);\n@@ -678,12 +677,10 @@ class Template extends TemplateContent {\nthis.paging.setTemplate(this);\nlet pageTemplates = await this.paging.getPageTemplates();\n-\nreturn await Promise.all(\npageTemplates.map(async (page, pageNumber) => {\n- // TODO get smarter with something like Object.assign(data, override);\n- let pageData = Object.assign({}, await page.getData());\n-\n+ // TODO `getData` was already computed in `getPageTemplates` but it does have an internal `dataCache`\n+ let pageData = Object.assign({}, await page.getData()); // re-uses .dataCache\nawait page.addComputedData(pageData);\n// Issue #115\n@@ -907,6 +904,7 @@ class Template extends TemplateContent {\nthis.eleventyConfig\n);\n+ // preserves caches too, like this.dataCache, _frontMatterDataCache\nfor (let key in this) {\ntmpl[key] = this[key];\n}\n@@ -1020,11 +1018,6 @@ class Template extends TemplateContent {\n}\n}\n- /* This is the primary render mechanism, called via TemplateMap->populateContentDataInMap */\n- async getTemplateMapContent(pageMapEntry) {\n- return pageMapEntry.template.render(pageMapEntry.data, false);\n- }\n-\nasync getTemplateMapEntries(dataOverride) {\ndebugDev(\"%o getMapped()\", this.inputPath);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -459,9 +459,8 @@ class TemplateMap {\ntry {\nfor (let pageEntry of map._pages) {\n- pageEntry.templateContent = await map.template.getTemplateMapContent(\n- pageEntry\n- );\n+ pageEntry.templateContent =\n+ await pageEntry.template.renderWithoutLayout(pageEntry.data);\n}\n} catch (e) {\nif (EleventyErrorUtil.isPrematureTemplateContentError(e)) {\n@@ -478,9 +477,8 @@ class TemplateMap {\nfor (let map of usedTemplateContentTooEarlyMap) {\ntry {\nfor (let pageEntry of map._pages) {\n- pageEntry.templateContent = await map.template.getTemplateMapContent(\n- pageEntry\n- );\n+ pageEntry.templateContent =\n+ await pageEntry.template.renderWithoutLayout(pageEntry.data);\n}\n} catch (e) {\nif (EleventyErrorUtil.isPrematureTemplateContentError(e)) {\n@@ -617,9 +615,11 @@ class TemplateMap {\nlet promises = [];\nfor (let entry of this.map) {\nfor (let page of entry._pages) {\n+ if (this.config.keys.computed in page.data) {\npromises.push(page.template.resolveRemainingComputedData(page.data));\n}\n}\n+ }\nreturn Promise.all(promises);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateMapTest.js",
"new_path": "test/TemplateMapTest.js",
"diff": "@@ -29,7 +29,7 @@ function getNewTemplateByNumber(num, eleventyConfig) {\n}\nasync function testRenderWithoutLayouts(template, data) {\n- let ret = await template.render(data, false);\n+ let ret = await template.renderWithoutLayout(data);\nreturn ret;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -30,8 +30,8 @@ async function _testCompleteRender(tmpl) {\nentry._pages = await entry.template.getTemplates(entry.data);\nreturn Promise.all(\nentry._pages.map(async (page) => {\n- page.templateContent = await entry.template.getTemplateMapContent(\n- page\n+ page.templateContent = await page.template.renderWithoutLayout(\n+ page.data\n);\nreturn tmpl.renderPageEntry(entry, page);\n})\n@@ -275,7 +275,7 @@ test(\"One Layout (layouts disabled)\", async (t) => {\nlet data = await tmpl.getData();\nt.is(data[tmpl.config.keys.layout], \"defaultLayoutLayoutContent\");\n- t.is(cleanHtml(await tmpl.render(data, false)), \"<p>Hello.</p>\");\n+ t.is(cleanHtml(await tmpl.renderWithoutLayout(data)), \"<p>Hello.</p>\");\nt.is(data.keymain, \"valuemain\");\nt.is(data.keylayout, \"valuelayout\");\n@@ -1029,7 +1029,7 @@ test(\"Override base templating engine from .md to ejs,md (with a layout that use\n);\n});\n-test(\"renderContent on a markdown file, permalink should not render markdown\", async (t) => {\n+test(\"renderDirect on a markdown file, permalink should not render markdown\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/permalink-markdown.md\",\n\"./test/stubs/\",\n@@ -1037,14 +1037,14 @@ test(\"renderContent on a markdown file, permalink should not render markdown\", a\n);\nt.is(\n- await tmpl.renderContent(\"/news/my-test-file/index.html\", {}, true),\n+ await tmpl.renderDirect(\"/news/my-test-file/index.html\", {}, true),\n\"/news/my-test-file/index.html\"\n);\nt.is(await tmpl.getRawOutputPath(), \"/news/my-test-file/index.html\");\n});\n-test(\"renderContent on a markdown file, permalink should not render markdown (with variable)\", async (t) => {\n+test(\"renderDirect on a markdown file, permalink should not render markdown (with variable)\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/permalink-markdown-var.md\",\n\"./test/stubs/\",\n@@ -1052,7 +1052,7 @@ test(\"renderContent on a markdown file, permalink should not render markdown (wi\n);\nt.is(\n- await tmpl.renderContent(\n+ await tmpl.renderDirect(\n\"/news/{{ slug }}/index.html\",\n{ slug: \"my-title\" },\ntrue\n@@ -1063,7 +1063,7 @@ test(\"renderContent on a markdown file, permalink should not render markdown (wi\nt.is(await tmpl.getRawOutputPath(), \"/news/my-title/index.html\");\n});\n-test(\"renderContent on a markdown file, permalink should not render markdown (has override)\", async (t) => {\n+test(\"renderDirect on a markdown file, permalink should not render markdown (has override)\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/permalink-markdown-override.md\",\n\"./test/stubs/\",\n@@ -1071,7 +1071,7 @@ test(\"renderContent on a markdown file, permalink should not render markdown (ha\n);\nt.is(\n- await tmpl.renderContent(\"/news/my-test-file/index.html\", {}, true),\n+ await tmpl.renderDirect(\"/news/my-test-file/index.html\", {}, true),\n\"/news/my-test-file/index.html\"\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest_Permalink.js",
"new_path": "test/TemplateTest_Permalink.js",
"diff": "@@ -25,8 +25,8 @@ async function getTemplateMapEntriesWithContent(template, data) {\nentry._pages = await entry.template.getTemplates(entry.data);\nawait Promise.all(\nentry._pages.map(async (page) => {\n- page.templateContent = await entry.template.getTemplateMapContent(\n- page\n+ page.templateContent = await page.template.renderWithoutLayout(\n+ page.data\n);\nreturn page;\n})\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Cleanup on Template render methods |
699 | 03.05.2022 09:58:09 | 18,000 | c6b43f924ec02547bfe7229c1e4b78e1bd097cc8 | More test code removal from src | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -133,14 +133,6 @@ class Template extends TemplateContent {\nreturn this._layout;\n}\n- async _testGetLayoutChain() {\n- if (!this._layout) {\n- await this.getData();\n- }\n-\n- return this._layout._testGetLayoutChain();\n- }\n-\nget baseFile() {\nreturn this.extensionMap.removeTemplateExtension(this.parsed.base);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateLayout.js",
"new_path": "src/TemplateLayout.js",
"diff": "@@ -110,13 +110,6 @@ class TemplateLayout extends TemplateContent {\nreturn data;\n}\n- async _testGetLayoutChain() {\n- if (!this.layoutChain) {\n- await this.getData();\n- }\n- return this.layoutChain;\n- }\n-\nasync getCompiledLayoutFunctions(layoutMap) {\nlet fns = [];\ntry {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateLayoutTest.js",
"new_path": "test/TemplateLayoutTest.js",
"diff": "@@ -48,7 +48,9 @@ test(\"Get Layout Chain\", async (t) => {\n\"./test/stubs\"\n);\n- t.deepEqual(await tl._testGetLayoutChain(), [\n+ await tl.getData();\n+\n+ t.deepEqual(tl.layoutChain, [\n\"./test/stubs/_includes/layouts/layout-inherit-a.njk\",\n\"./test/stubs/_includes/layouts/layout-inherit-b.njk\",\n\"./test/stubs/_includes/layouts/layout-inherit-c.njk\",\n@@ -72,7 +74,8 @@ test(\"Get Front Matter Data\", async (t) => {\nsecondinherits: \"b\",\nthirdinherits: \"c\",\n});\n- t.deepEqual(await tl._testGetLayoutChain(), [\n+\n+ t.deepEqual(tl.layoutChain, [\n\"./test/stubs/_includes/layouts/layout-inherit-a.njk\",\n\"./test/stubs/_includes/layouts/layout-inherit-b.njk\",\n\"./test/stubs/_includes/layouts/layout-inherit-c.njk\",\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -1897,8 +1897,9 @@ test(\"Get Layout Chain\", async (t) => {\n\"./dist\"\n);\n- let layoutChain = await tmpl._testGetLayoutChain();\n- t.deepEqual(layoutChain, [\n+ await tmpl.getData();\n+\n+ t.deepEqual(tmpl._layout.layoutChain, [\n\"./test/stubs-incremental/layout-chain/_includes/base.njk\",\n\"./test/stubs-incremental/layout-chain/_includes/parent.njk\",\n]);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | More test code removal from src |
699 | 03.05.2022 10:55:02 | 18,000 | 99a573c2e2af25ba9a24a8512a2ece4d019d09ad | Preferring an error instead of expensive duplicated getData calls. Test code versus real code paths cleanup | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -182,7 +182,7 @@ class Template extends TemplateContent {\nasync _getLink(data) {\nif (!data) {\n- data = await this.getData();\n+ throw new Error(\"data argument missing in Template->_getLink\");\n}\nlet permalink = data[this.config.keys.permalink];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateCollection.js",
"new_path": "src/TemplateCollection.js",
"diff": "@@ -9,14 +9,6 @@ class TemplateCollection extends Sortable {\nthis._filteredByGlobsCache = new Map();\n}\n- // TODO move this into tests (this is only used by tests)\n- async _testAddTemplate(template) {\n- let data = await template.getData();\n- for (let map of await template.getTemplates(data)) {\n- this.add(map);\n- }\n- }\n-\ngetAll() {\nreturn this.items.slice();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/PaginationTest.js",
"new_path": "test/PaginationTest.js",
"diff": "@@ -332,8 +332,8 @@ test(\"Template with Pagination, getRenderedTemplates\", async (t) => {\n\"./dist\"\n);\n- let outputPath = await tmpl.getOutputPath();\nlet data = await tmpl.getData();\n+ let outputPath = await tmpl.getOutputPath(data);\nt.is(outputPath, \"./dist/paged/index.html\");\nlet templates = await tmpl.getRenderedTemplates(data);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateCollectionTest.js",
"new_path": "test/TemplateCollectionTest.js",
"diff": "@@ -30,6 +30,13 @@ function getNewTemplateByNumber(num, eleventyConfig) {\n);\n}\n+async function addTemplate(collection, template) {\n+ let data = await template.getData();\n+ for (let map of await template.getTemplates(data)) {\n+ collection.add(map);\n+ }\n+}\n+\ntest(\"Basic setup\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet tmpl1 = getNewTemplateByNumber(1, eleventyConfig);\n@@ -37,9 +44,9 @@ test(\"Basic setup\", async (t) => {\nlet tmpl3 = getNewTemplateByNumber(3, eleventyConfig);\nlet c = new Collection();\n- await c._testAddTemplate(tmpl1);\n- await c._testAddTemplate(tmpl2);\n- await c._testAddTemplate(tmpl3);\n+ await addTemplate(c, tmpl1);\n+ await addTemplate(c, tmpl2);\n+ await addTemplate(c, tmpl3);\nt.is(c.length, 3);\n});\n@@ -51,9 +58,9 @@ test(\"sortFunctionDateInputPath\", async (t) => {\nlet tmpl5 = getNewTemplateByNumber(5, eleventyConfig);\nlet c = new Collection();\n- await c._testAddTemplate(tmpl1);\n- await c._testAddTemplate(tmpl4);\n- await c._testAddTemplate(tmpl5);\n+ await addTemplate(c, tmpl1);\n+ await addTemplate(c, tmpl4);\n+ await addTemplate(c, tmpl5);\nlet posts = c.sort(Sortable.sortFunctionDateInputPath);\nt.is(posts.length, 3);\n@@ -69,9 +76,9 @@ test(\"getFilteredByTag\", async (t) => {\nlet tmpl3 = getNewTemplateByNumber(3, eleventyConfig);\nlet c = new Collection();\n- await c._testAddTemplate(tmpl1);\n- await c._testAddTemplate(tmpl2);\n- await c._testAddTemplate(tmpl3);\n+ await addTemplate(c, tmpl1);\n+ await addTemplate(c, tmpl2);\n+ await addTemplate(c, tmpl3);\nlet posts = c.getFilteredByTag(\"post\");\nt.is(posts.length, 2);\n@@ -95,9 +102,9 @@ test(\"getFilteredByTag (added out of order, sorted)\", async (t) => {\nlet tmpl3 = getNewTemplateByNumber(3, eleventyConfig);\nlet c = new Collection();\n- await c._testAddTemplate(tmpl3);\n- await c._testAddTemplate(tmpl2);\n- await c._testAddTemplate(tmpl1);\n+ await addTemplate(c, tmpl3);\n+ await addTemplate(c, tmpl2);\n+ await addTemplate(c, tmpl1);\nlet posts = c.getFilteredByTag(\"post\");\nt.is(posts.length, 2);\n@@ -122,9 +129,9 @@ test(\"getFilteredByTags\", async (t) => {\nlet tmpl3 = getNewTemplateByNumber(3, eleventyConfig);\nlet c = new Collection();\n- await c._testAddTemplate(tmpl1);\n- await c._testAddTemplate(tmpl2);\n- await c._testAddTemplate(tmpl3);\n+ await addTemplate(c, tmpl1);\n+ await addTemplate(c, tmpl2);\n+ await addTemplate(c, tmpl3);\nlet postsAndCats = c.getFilteredByTags(\"post\", \"cat\");\nt.is(postsAndCats.length, 1);\n@@ -147,9 +154,9 @@ test(\"getFilteredByTags (added out of order, sorted)\", async (t) => {\nlet tmpl3 = getNewTemplateByNumber(3, eleventyConfig);\nlet c = new Collection();\n- await c._testAddTemplate(tmpl3);\n- await c._testAddTemplate(tmpl2);\n- await c._testAddTemplate(tmpl1);\n+ await addTemplate(c, tmpl3);\n+ await addTemplate(c, tmpl2);\n+ await addTemplate(c, tmpl1);\nlet postsAndCats = c.getFilteredByTags(\"post\", \"cat\");\nt.truthy(postsAndCats.length);\n@@ -175,9 +182,9 @@ test(\"getFilteredByGlob\", async (t) => {\nlet tmpl7 = getNewTemplateByNumber(7, eleventyConfig);\nlet c = new Collection();\n- await c._testAddTemplate(tmpl1);\n- await c._testAddTemplate(tmpl6);\n- await c._testAddTemplate(tmpl7);\n+ await addTemplate(c, tmpl1);\n+ await addTemplate(c, tmpl6);\n+ await addTemplate(c, tmpl7);\nlet markdowns = c.getFilteredByGlob(\"./**/*.md\");\nt.is(markdowns.length, 1);\n@@ -191,9 +198,9 @@ test(\"getFilteredByGlob no dash dot\", async (t) => {\nlet tmpl7 = getNewTemplateByNumber(7, eleventyConfig);\nlet c = new Collection();\n- await c._testAddTemplate(tmpl1);\n- await c._testAddTemplate(tmpl6);\n- await c._testAddTemplate(tmpl7);\n+ await addTemplate(c, tmpl1);\n+ await addTemplate(c, tmpl6);\n+ await addTemplate(c, tmpl7);\nlet markdowns = c.getFilteredByGlob(\"**/*.md\");\nt.is(markdowns.length, 1);\n@@ -222,8 +229,8 @@ test(\"partial match on tag string, issue 95\", async (t) => {\n);\nlet c = new Collection();\n- await c._testAddTemplate(cat);\n- await c._testAddTemplate(notacat);\n+ await addTemplate(c, cat);\n+ await addTemplate(c, notacat);\nlet posts = c.getFilteredByTag(\"cat\");\nt.is(posts.length, 1);\n@@ -267,9 +274,9 @@ test(\"Sort in place (issue #352)\", async (t) => {\nlet tmpl5 = getNewTemplateByNumber(5, eleventyConfig);\nlet c = new Collection();\n- await c._testAddTemplate(tmpl1);\n- await c._testAddTemplate(tmpl4);\n- await c._testAddTemplate(tmpl5);\n+ await addTemplate(c, tmpl1);\n+ await addTemplate(c, tmpl4);\n+ await addTemplate(c, tmpl5);\nlet posts = c.getAllSorted();\nt.is(posts.length, 3);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateMapTest.js",
"new_path": "test/TemplateMapTest.js",
"diff": "@@ -33,6 +33,13 @@ async function testRenderWithoutLayouts(template, data) {\nreturn ret;\n}\n+async function addTemplate(collection, template) {\n+ let data = await template.getData();\n+ for (let map of await template.getTemplates(data)) {\n+ collection.add(map);\n+ }\n+}\n+\ntest(\"TemplateMap has collections added\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet tmpl1 = getNewTemplateByNumber(1, eleventyConfig);\n@@ -63,8 +70,8 @@ test(\"TemplateMap compared to Collection API\", async (t) => {\nt.deepEqual(map[1].data.collections.post[1].template, tmpl4);\nlet c = new TemplateCollection();\n- await c._testAddTemplate(tmpl1);\n- await c._testAddTemplate(tmpl4);\n+ await addTemplate(c, tmpl1);\n+ await addTemplate(c, tmpl4);\nlet posts = c.getFilteredByTag(\"post\");\nt.is(posts.length, 2);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest-JavaScript.js",
"new_path": "test/TemplateTest-JavaScript.js",
"diff": "@@ -10,8 +10,8 @@ test(\"JavaScript template type (function)\", async (t) => {\n\"./dist\"\n);\n- t.is(await tmpl.getOutputPath(), \"./dist/function/index.html\");\nlet data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/function/index.html\");\ndata.name = \"Zach\";\nlet pages = await tmpl.getRenderedTemplates(data);\n@@ -25,8 +25,8 @@ test(\"JavaScript template type (class with data getter)\", async (t) => {\n\"./dist\"\n);\n- t.is(await tmpl.getOutputPath(), \"./dist/class-data/index.html\");\nlet data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/class-data/index.html\");\nlet pages = await tmpl.getRenderedTemplates(data);\nt.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n@@ -39,8 +39,8 @@ test(\"JavaScript template type (class with data method)\", async (t) => {\n\"./dist\"\n);\n- t.is(await tmpl.getOutputPath(), \"./dist/class-data-fn/index.html\");\nlet data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/class-data-fn/index.html\");\nlet pages = await tmpl.getRenderedTemplates(data);\nt.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n@@ -54,8 +54,8 @@ if (semver.gte(process.version, \"12.4.0\")) {\n\"./dist\"\n);\n- t.is(await tmpl.getOutputPath(), \"./dist/classfields-data/index.html\");\nlet data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/classfields-data/index.html\");\nlet pages = await tmpl.getRenderedTemplates(data);\nt.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n@@ -69,8 +69,11 @@ test(\"JavaScript template type (class with shorthand data method)\", async (t) =>\n\"./dist\"\n);\n- t.is(await tmpl.getOutputPath(), \"./dist/class-data-fn-shorthand/index.html\");\nlet data = await tmpl.getData();\n+ t.is(\n+ await tmpl.getOutputPath(data),\n+ \"./dist/class-data-fn-shorthand/index.html\"\n+ );\nlet pages = await tmpl.getRenderedTemplates(data);\nt.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n@@ -83,8 +86,8 @@ test(\"JavaScript template type (class with async data method)\", async (t) => {\n\"./dist\"\n);\n- t.is(await tmpl.getOutputPath(), \"./dist/class-async-data-fn/index.html\");\nlet data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/class-async-data-fn/index.html\");\nlet pages = await tmpl.getRenderedTemplates(data);\nt.is(pages[0].templateContent.trim(), \"<p>Ted</p>\");\n@@ -104,8 +107,8 @@ test(\"JavaScript template type (class with data getter and a javascriptFunction)\n},\n};\n- t.is(await tmpl.getOutputPath(), \"./dist/class-data-filter/index.html\");\nlet data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/class-data-filter/index.html\");\nlet pages = await tmpl.getRenderedTemplates(data);\nt.is(pages[0].templateContent.trim(), \"<p>TED</p>\");\n});\n@@ -124,8 +127,11 @@ test(\"JavaScript template type (class with data method and a javascriptFunction)\n},\n};\n- t.is(await tmpl.getOutputPath(), \"./dist/class-data-fn-filter/index.html\");\nlet data = await tmpl.getData();\n+ t.is(\n+ await tmpl.getOutputPath(data),\n+ \"./dist/class-data-fn-filter/index.html\"\n+ );\nlet pages = await tmpl.getRenderedTemplates(data);\nt.is(pages[0].templateContent.trim(), \"<p>TED</p>\");\n});\n@@ -136,8 +142,8 @@ test(\"JavaScript template type (class with data permalink)\", async (t) => {\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/my-permalink/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/my-permalink/index.html\");\n});\ntest(\"JavaScript template type (class with data permalink using a buffer)\", async (t) => {\n@@ -146,8 +152,8 @@ test(\"JavaScript template type (class with data permalink using a buffer)\", asyn\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/my-permalink/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/my-permalink/index.html\");\n});\ntest(\"JavaScript template type (class with data permalink function)\", async (t) => {\n@@ -156,8 +162,8 @@ test(\"JavaScript template type (class with data permalink function)\", async (t)\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/my-permalink/value1/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/my-permalink/value1/index.html\");\n});\ntest(\"JavaScript template type (class with data permalink function using a buffer)\", async (t) => {\n@@ -166,8 +172,8 @@ test(\"JavaScript template type (class with data permalink function using a buffe\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/my-permalink/value1/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/my-permalink/value1/index.html\");\n});\ntest(\"JavaScript template type (class with data permalink async function)\", async (t) => {\n@@ -176,8 +182,8 @@ test(\"JavaScript template type (class with data permalink async function)\", asyn\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/my-permalink/value1/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/my-permalink/value1/index.html\");\n});\ntest(\"JavaScript template type (class with data permalink function using a filter)\", async (t) => {\n@@ -187,8 +193,9 @@ test(\"JavaScript template type (class with data permalink function using a filte\n\"./dist\"\n);\n+ let data = await tmpl.getData();\nt.is(\n- await tmpl.getOutputPath(),\n+ await tmpl.getOutputPath(data),\n\"./dist/my-permalink/my-super-cool-title/index.html\"\n);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -71,7 +71,9 @@ test(\"output path maps to an html file\", async (t) => {\nt.is(tmpl.inputDir, \"./test/stubs\");\nt.is(tmpl.outputDir, \"./dist\");\nt.is(tmpl.getTemplateSubfolder(), \"\");\n- t.is(await tmpl.getOutputPath(), \"./dist/template/index.html\");\n+\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/template/index.html\");\n});\ntest(\"subfolder outputs to a subfolder\", async (t) => {\n@@ -80,9 +82,10 @@ test(\"subfolder outputs to a subfolder\", async (t) => {\n\"./test/stubs/\",\n\"./dist\"\n);\n+ let data = await tmpl.getData();\nt.is(tmpl.parsed.dir, \"./test/stubs/subfolder\");\nt.is(tmpl.getTemplateSubfolder(), \"subfolder\");\n- t.is(await tmpl.getOutputPath(), \"./dist/subfolder/index.html\");\n+ t.is(await tmpl.getOutputPath(data), \"./dist/subfolder/index.html\");\n});\ntest(\"subfolder outputs to double subfolder\", async (t) => {\n@@ -91,9 +94,10 @@ test(\"subfolder outputs to double subfolder\", async (t) => {\n\"./test/stubs/\",\n\"./dist\"\n);\n+ let data = await tmpl.getData();\nt.is(tmpl.parsed.dir, \"./test/stubs/subfolder/subfolder\");\nt.is(tmpl.getTemplateSubfolder(), \"subfolder/subfolder\");\n- t.is(await tmpl.getOutputPath(), \"./dist/subfolder/subfolder/index.html\");\n+ t.is(await tmpl.getOutputPath(data), \"./dist/subfolder/subfolder/index.html\");\n});\ntest(\"HTML files output to the same as the input directory have a file suffix added (only if index, this is not index).\", async (t) => {\n@@ -102,7 +106,8 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\n\"./test/stubs\",\n\"./test/stubs\"\n);\n- t.is(await tmpl.getOutputPath(), \"./test/stubs/testing/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./test/stubs/testing/index.html\");\n});\ntest(\"HTML files output to the same as the input directory have a file suffix added (only if index, this _is_ index).\", async (t) => {\n@@ -111,7 +116,8 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\n\"./test/stubs\",\n\"./test/stubs\"\n);\n- t.is(await tmpl.getOutputPath(), \"./test/stubs/index-o.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./test/stubs/index-o.html\");\n});\ntest(\"HTML files output to the same as the input directory have a file suffix added (only if index, this _is_ index, subfolder).\", async (t) => {\n@@ -120,7 +126,8 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\n\"./test/stubs\",\n\"./test/stubs\"\n);\n- t.is(await tmpl.getOutputPath(), \"./test/stubs/subfolder/index-o.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./test/stubs/subfolder/index-o.html\");\n});\ntest(\"Test raw front matter from template (yaml)\", async (t) => {\n@@ -407,7 +414,8 @@ test(\"Permalink output directory\", async (t) => {\n\"./test/stubs/\",\n\"./dist\"\n);\n- t.is(await tmpl.getOutputPath(), \"./dist/permalinksubfolder/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/permalinksubfolder/index.html\");\n});\ntest(\"Permalink output directory from layout\", async (t) => {\n@@ -416,7 +424,8 @@ test(\"Permalink output directory from layout\", async (t) => {\n\"./test/stubs/\",\n\"./dist\"\n);\n- t.is(await tmpl.getOutputPath(), \"./dist/hello/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/hello/index.html\");\n});\ntest(\"Permalink output directory from layout (fileslug)\", async (t) => {\n@@ -425,8 +434,9 @@ test(\"Permalink output directory from layout (fileslug)\", async (t) => {\n\"./test/stubs/\",\n\"./dist\"\n);\n+ let data = await tmpl.getData();\nt.is(\n- await tmpl.getOutputPath(),\n+ await tmpl.getOutputPath(data),\n\"./dist/test/permalink-in-layout-fileslug/index.html\"\n);\n});\n@@ -444,7 +454,7 @@ test(\"Layout from template-data-file that has a permalink (fileslug) Issue #121\"\nlet data = await tmpl.getData();\nlet renderedTmpl = (await tmpl.getRenderedTemplates(data))[0];\nt.is(renderedTmpl.templateContent, \"Wrapper:Test 1:test\");\n- t.is(await tmpl.getOutputPath(), \"./dist/test/index.html\");\n+ t.is(await tmpl.getOutputPath(data), \"./dist/test/index.html\");\n});\ntest(\"Fileslug in an 11ty.js template Issue #588\", async (t) => {\n@@ -609,10 +619,13 @@ test(\"Clone the template\", async (t) => {\n\"./dist\"\n);\n+ let data = await tmpl.getData();\n+\nlet cloned = tmpl.clone();\n+ let clonedData = await cloned.getData();\n- t.is(await tmpl.getOutputPath(), \"./dist/default/index.html\");\n- t.is(await cloned.getOutputPath(), \"./dist/default/index.html\");\n+ t.is(await tmpl.getOutputPath(data), \"./dist/default/index.html\");\n+ t.is(await cloned.getOutputPath(clonedData), \"./dist/default/index.html\");\nt.is(cloned.extensionMap, tmpl.extensionMap);\n});\n@@ -1035,13 +1048,13 @@ test(\"renderDirect on a markdown file, permalink should not render markdown\", as\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n+ let data = await tmpl.getData();\nt.is(\nawait tmpl.renderDirect(\"/news/my-test-file/index.html\", {}, true),\n\"/news/my-test-file/index.html\"\n);\n- t.is(await tmpl.getRawOutputPath(), \"/news/my-test-file/index.html\");\n+ t.is(await tmpl.getRawOutputPath(data), \"/news/my-test-file/index.html\");\n});\ntest(\"renderDirect on a markdown file, permalink should not render markdown (with variable)\", async (t) => {\n@@ -1050,7 +1063,7 @@ test(\"renderDirect on a markdown file, permalink should not render markdown (wit\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n+ let data = await tmpl.getData();\nt.is(\nawait tmpl.renderDirect(\n\"/news/{{ slug }}/index.html\",\n@@ -1060,7 +1073,7 @@ test(\"renderDirect on a markdown file, permalink should not render markdown (wit\n\"/news/my-title/index.html\"\n);\n- t.is(await tmpl.getRawOutputPath(), \"/news/my-title/index.html\");\n+ t.is(await tmpl.getRawOutputPath(data), \"/news/my-title/index.html\");\n});\ntest(\"renderDirect on a markdown file, permalink should not render markdown (has override)\", async (t) => {\n@@ -1069,13 +1082,13 @@ test(\"renderDirect on a markdown file, permalink should not render markdown (has\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n+ let data = await tmpl.getData();\nt.is(\nawait tmpl.renderDirect(\"/news/my-test-file/index.html\", {}, true),\n\"/news/my-test-file/index.html\"\n);\n- t.is(await tmpl.getRawOutputPath(), \"/news/my-test-file/index.html\");\n+ t.is(await tmpl.getRawOutputPath(data), \"/news/my-test-file/index.html\");\n});\n/* Transforms */\n@@ -2029,9 +2042,9 @@ test(\"permalink object with build\", async (t) => {\n\"./test/stubs/\",\n\"./test/stubs/_site\"\n);\n-\n- t.is(await tmpl.getRawOutputPath(), \"/url/index.html\");\n- t.is(await tmpl.getOutputHref(), \"/url/\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getRawOutputPath(data), \"/url/index.html\");\n+ t.is(await tmpl.getOutputHref(data), \"/url/\");\n});\ntest(\"permalink object without build\", async (t) => {\n@@ -2040,10 +2053,10 @@ test(\"permalink object without build\", async (t) => {\n\"./test/stubs/\",\n\"./test/stubs/_site\"\n);\n-\n- t.is(await tmpl.getRawOutputPath(), false);\n- t.is(await tmpl.getOutputPath(), false);\n- t.is(await tmpl.getOutputHref(), \"/url/\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getRawOutputPath(data), false);\n+ t.is(await tmpl.getOutputPath(data), false);\n+ t.is(await tmpl.getOutputHref(data), \"/url/\");\n});\ntest(\"permalink object _getLink\", async (t) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest_Permalink.js",
"new_path": "test/TemplateTest_Permalink.js",
"diff": "@@ -120,9 +120,10 @@ test(\"Disable dynamic permalinks\", async (t) => {\n\"./test/stubs/\",\n\"./test/stubs/_site\"\n);\n+ let data = await tmpl.getData();\n- t.is(await tmpl.getRawOutputPath(), \"/{{justastring}}/index.html\");\n- t.is(await tmpl.getOutputHref(), \"/{{justastring}}/\");\n+ t.is(await tmpl.getRawOutputPath(data), \"/{{justastring}}/index.html\");\n+ t.is(await tmpl.getOutputHref(data), \"/{{justastring}}/\");\n});\ntest(\"Permalink with variables!\", async (t) => {\n@@ -132,7 +133,12 @@ test(\"Permalink with variables!\", async (t) => {\n\"./dist\"\n);\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/slug-candidate/index.html\");\n+ let data = await tmpl.getData();\n+\n+ t.is(\n+ await tmpl.getOutputPath(data),\n+ \"./dist/subdir/slug-candidate/index.html\"\n+ );\n});\ntest(\"Permalink with variables and JS front matter!\", async (t) => {\n@@ -141,8 +147,8 @@ test(\"Permalink with variables and JS front matter!\", async (t) => {\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/slug/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/subdir/slug/index.html\");\n});\n// This is broken right now, permalink must use the same template language as the template\n@@ -153,7 +159,8 @@ test.skip(\"Use a JavaScript function for permalink in any template language\", as\n\"./dist\"\n);\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/slug/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/subdir/slug/index.html\");\n});\ntest(\"Permalink with dates!\", async (t) => {\n@@ -162,8 +169,8 @@ test(\"Permalink with dates!\", async (t) => {\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/2016/01/01/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/2016/01/01/index.html\");\n});\ntest.skip(\"Permalink with dates on file name regex!\", async (t) => {\n@@ -172,8 +179,8 @@ test.skip(\"Permalink with dates on file name regex!\", async (t) => {\n\"./test/stubs/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/2016/02/01/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/2016/02/01/index.html\");\n});\ntest(\"Reuse permalink in directory specific data file\", async (t) => {\n@@ -185,8 +192,8 @@ test(\"Reuse permalink in directory specific data file\", async (t) => {\n\"./dist\",\ndataObj\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/2016/01/01/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/2016/01/01/index.html\");\n});\ntest(\"Using slugify filter!\", async (t) => {\n@@ -195,9 +202,9 @@ test(\"Using slugify filter!\", async (t) => {\n\"./test/slugify-filter/\",\n\"./dist\"\n);\n-\n+ let data = await tmpl.getData();\nt.is(\n- await tmpl.getOutputPath(),\n+ await tmpl.getOutputPath(data),\n\"./dist/subdir/slug-love-candidate-lyublyu/index.html\"\n);\n});\n@@ -208,8 +215,8 @@ test(\"Using slugify filter with comma and apostrophe\", async (t) => {\n\"./test/slugify-filter/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/hi-i-m-zach/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/subdir/hi-i-m-zach/index.html\");\n});\ntest(\"Using slug filter with options params\", async (t) => {\n@@ -218,8 +225,8 @@ test(\"Using slug filter with options params\", async (t) => {\n\"./test/slugify-filter/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/hi_i_am_zach/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/subdir/hi_i_am_zach/index.html\");\n});\ntest(\"Using slugify filter with options params\", async (t) => {\n@@ -228,8 +235,8 @@ test(\"Using slugify filter with options params\", async (t) => {\n\"./test/slugify-filter/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/hi-i-m-z-ach/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/subdir/hi-i-m-z-ach/index.html\");\n});\ntest(\"Using slugify filter with a number #854\", async (t) => {\n@@ -238,8 +245,8 @@ test(\"Using slugify filter with a number #854\", async (t) => {\n\"./test/slugify-filter/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/1/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/subdir/1/index.html\");\n});\ntest(\"Using slug filter with a number #854\", async (t) => {\n@@ -248,6 +255,6 @@ test(\"Using slug filter with a number #854\", async (t) => {\n\"./test/slugify-filter/\",\n\"./dist\"\n);\n-\n- t.is(await tmpl.getOutputPath(), \"./dist/subdir/1/index.html\");\n+ let data = await tmpl.getData();\n+ t.is(await tmpl.getOutputPath(data), \"./dist/subdir/1/index.html\");\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateWriterTest.js",
"new_path": "test/TemplateWriterTest.js",
"diff": "@@ -35,8 +35,10 @@ test(\"Output is a subdir of input\", async (t) => {\nlet tmpl = tw._createTemplate(files[0]);\nt.is(tmpl.inputDir, \"./test/stubs/writeTest\");\n+\n+ let data = await tmpl.getData();\nt.is(\n- await tmpl.getOutputPath(),\n+ await tmpl.getOutputPath(data),\n\"./test/stubs/writeTest/_writeTestSite/test/index.html\"\n);\n});\n@@ -306,19 +308,20 @@ test(\"Pagination with a Collection (apply all pages to collections)\", async (t)\nlet mainTmpl = tw._createTemplate(\n\"./test/stubs/paged/collection-apply-to-all/main.njk\"\n);\n- let outputPath = await mainTmpl.getOutputPath();\n+ let data = await mainTmpl.getData();\n+ let outputPath = await mainTmpl.getOutputPath(data);\nt.is(outputPath, \"./test/stubs/_site/main/index.html\");\nt.is(mapEntry.outputPath, \"./test/stubs/_site/main/index.html\");\nlet templates = await mapEntry.template.getRenderedTemplates(mapEntry.data);\nt.is(templates.length, 2);\nt.is(\n- await templates[0].template.getOutputPath(),\n+ await templates[0].template.getOutputPath(templates[0].data),\n\"./test/stubs/_site/main/index.html\"\n);\nt.is(templates[0].outputPath, \"./test/stubs/_site/main/index.html\");\nt.is(\n- await templates[1].template.getOutputPath(),\n+ await templates[1].template.getOutputPath(templates[1].data),\n\"./test/stubs/_site/main/1/index.html\"\n);\nt.is(templates[1].outputPath, \"./test/stubs/_site/main/1/index.html\");\n@@ -356,7 +359,8 @@ test(\"Use a collection inside of a template\", async (t) => {\nlet mainTmpl = tw._createTemplate(\n\"./test/stubs/collection-template/template.ejs\"\n);\n- let outputPath = await mainTmpl.getOutputPath();\n+ let data = await mainTmpl.getData();\n+ let outputPath = await mainTmpl.getOutputPath(data);\nt.is(\noutputPath,\n\"./test/stubs/collection-template/_site/template/index.html\"\n@@ -401,7 +405,8 @@ test(\"Use a collection inside of a layout\", async (t) => {\nlet mainTmpl = tw._createTemplate(\n\"./test/stubs/collection-layout/template.ejs\"\n);\n- let outputPath = await mainTmpl.getOutputPath();\n+ let data = await mainTmpl.getData();\n+ let outputPath = await mainTmpl.getOutputPath(data);\nt.is(outputPath, \"./test/stubs/collection-layout/_site/template/index.html\");\nlet templates = await mapEntry.template.getRenderedTemplates(mapEntry.data);\n@@ -573,8 +578,9 @@ test(\"Write Test 11ty.js\", async (t) => {\nt.deepEqual(files, [\"./test/stubs/writeTestJS/test.11ty.js\"]);\nlet tmpl = tw._createTemplate(files[0]);\n+ let data = await tmpl.getData();\nt.is(\n- await tmpl.getOutputPath(),\n+ await tmpl.getOutputPath(data),\n\"./test/stubs/_writeTestJSSite/test/index.html\"\n);\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Preferring an error instead of expensive duplicated getData calls. Test code versus real code paths cleanup |
699 | 03.05.2022 15:07:15 | 18,000 | 22d59ad9697f510e2c39a832089bc3db4c72742e | Fixes Super important memory improvements to Pagination | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -56,8 +56,10 @@ class TemplateMap {\n}\nasync add(template) {\n- // getTemplateMapEntries is where the Template.getData is first generated\n- for (let map of await template.getTemplateMapEntries()) {\n+ // This is where the data is first generated for the template\n+ let data = await template.getData();\n+\n+ for (let map of await template.getTemplateMapEntries(data)) {\nthis.map.push(map);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Util/Merge.js",
"new_path": "src/Util/Merge.js",
"diff": "@@ -16,7 +16,7 @@ function getMergedItem(target, source, parentKey) {\nreturn target.concat(source);\n} else if (isPlainObject(target)) {\nif (isPlainObject(source)) {\n- for (var key in source) {\n+ for (let key in source) {\nlet newKey = key;\nif (key.indexOf(OVERRIDE_PREFIX) === 0) {\nnewKey = key.substr(OVERRIDE_PREFIX.length);\n@@ -30,10 +30,11 @@ function getMergedItem(target, source, parentKey) {\nreturn source;\n}\n}\n+\nfunction Merge(target, ...sources) {\n// Remove override prefixes from root target.\nif (isPlainObject(target)) {\n- for (var key in target) {\n+ for (let key in target) {\nif (key.indexOf(OVERRIDE_PREFIX) === 0) {\ntarget[key.substr(OVERRIDE_PREFIX.length)] = target[key];\ndelete target[key];\n@@ -41,7 +42,7 @@ function Merge(target, ...sources) {\n}\n}\n- for (var source of sources) {\n+ for (let source of sources) {\nif (!source) {\ncontinue;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -23,7 +23,8 @@ function cleanHtml(str) {\n}\nasync function _testCompleteRender(tmpl) {\n- let entries = await tmpl.getTemplateMapEntries();\n+ let data = await tmpl.getData();\n+ let entries = await tmpl.getTemplateMapEntries(data);\nlet nestedContent = await Promise.all(\nentries.map(async (entry) => {\n@@ -1493,7 +1494,8 @@ test(\"Throws a Premature Template Content Error from rendering (njk)\", async (t)\n\"./test/stubs/_site\"\n);\n- let mapEntries = await tmpl.getTemplateMapEntries();\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplateMapEntries(data);\nlet pageEntries = await tmpl.getTemplates({\npage: {},\nsample: {\n@@ -1562,7 +1564,8 @@ test(\"Throws a Premature Template Content Error from rendering (pug)\", async (t)\n\"./test/stubs/_site\"\n);\n- let mapEntries = await tmpl.getTemplateMapEntries();\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplateMapEntries(data);\nlet pageEntries = await tmpl.getTemplates({\npage: {},\nsample: {\n@@ -1601,7 +1604,8 @@ test(\"Throws a Premature Template Content Error from rendering (md)\", async (t)\n\"./test/stubs/_site\"\n);\n- let mapEntries = await tmpl.getTemplateMapEntries();\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplateMapEntries(data);\nlet pageEntries = await tmpl.getTemplates({\npage: {},\nsample: {\n@@ -1640,7 +1644,8 @@ test(\"Throws a Premature Template Content Error from rendering (hbs)\", async (t)\n\"./test/stubs/_site\"\n);\n- let mapEntries = await tmpl.getTemplateMapEntries();\n+ let data = await tmpl.getData();\n+ let mapEntries = await tmpl.getTemplateMapEntries(data);\nlet pageEntries = await tmpl.getTemplates({\npage: {},\nsample: {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fixes #2360. Super important memory improvements to Pagination |
699 | 04.05.2022 08:13:37 | 18,000 | eec1482df184ddf85f38904cb510f2791fc90f37 | [breaking] Bump Node minimum to 14. Fixes | [
{
"change_type": "MODIFY",
"old_path": ".github/workflows/ci.yml",
"new_path": ".github/workflows/ci.yml",
"diff": "@@ -8,7 +8,7 @@ jobs:\nstrategy:\nmatrix:\nos: [\"ubuntu-latest\", \"macos-latest\", \"windows-latest\"]\n- node: [\"12\", \"14\", \"16\"]\n+ node: [\"14\", \"16\", \"18\"]\nname: Node.js ${{ matrix.node }} on ${{ matrix.os }}\nsteps:\n- uses: actions/checkout@v2\n"
},
{
"change_type": "MODIFY",
"old_path": ".nvmrc",
"new_path": ".nvmrc",
"diff": "-12\n\\ No newline at end of file\n+14\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/meta-release.md",
"new_path": "docs/meta-release.md",
"diff": "@@ -34,7 +34,12 @@ Unfortunate thing about npm: if you push a 1.0.0-canary.x to `canary` after a `2\n1. update minor dependencies in package.json? `npm outdated` `npm update --save`\n1. npmclean aka `rm -rf node_modules && rm -f package-lock.json && npm install`\n1. If the minimum Node version changed, make sure you update `package.json` engines property.\n-1. Bonus: make sure the error message works correctly for Node versions less than 10. 0.12.x+ requires Node 10+. 1.x+ requires Node 12+\n+1. Bonus: make sure the error message works correctly for Node versions less than 10.\n+\n+- 0.12.x+ requires Node 10+\n+- 1.x+ requires Node 12+\n+- 2.x+ requires Node 14+\n+\n1. `npm run package` to generate a new Eleventy Edge lib\n1. npm audit\n1. Make sure `npx ava` runs okay\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n\"license\": \"MIT\",\n\"engines\": {\n- \"node\": \">=12\"\n+ \"node\": \">=14\"\n},\n\"funding\": {\n\"type\": \"opencollective\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | [breaking] Bump Node minimum to 14. Fixes #2336 |
699 | 04.05.2022 08:16:17 | 18,000 | 3c49f22b31b10e5dae0daf661a54750875ae5d0f | bug: Liquid and Nunjucks needsCompilation checks expected string arguments. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -357,7 +357,7 @@ class TemplateContent {\nreturn permalink;\n}\n- /* Usage:\n+ /* Custom `compile` function for permalinks, usage:\npermalink: function(permalinkString, inputPath) {\nreturn async function(data) {\nreturn \"THIS IS MY RENDERED PERMALINK\";\n@@ -372,6 +372,7 @@ class TemplateContent {\n);\n}\n+ // Raw permalink function (in the app code data cascade)\nif (typeof permalink === \"function\") {\nreturn this._renderFunction(permalink, data);\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | bug: Liquid and Nunjucks needsCompilation checks expected string arguments. |
699 | 04.05.2022 09:38:45 | 18,000 | 11176b95d883d87166ea8cdb881df3e7355a5f29 | Re-use output locations from pagination (if they exist) | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -296,6 +296,7 @@ class Template extends TemplateContent {\n// TODO instead of htmlIOException, do a global search to check if output path = input path and then add extra suffix\nasync getOutputLocations(data) {\n+ this.bench.get(\"(count) getOutputLocations\").incrementCount();\nlet link = await this._getLink(data);\nlet path;\n@@ -312,20 +313,24 @@ class Template extends TemplateContent {\n};\n}\n+ // This is likely now a test-only method\n// Preferred to use the singular `getOutputLocations` above.\nasync getRawOutputPath(data) {\n+ this.bench.get(\"(count) getRawOutputPath\").incrementCount();\nlet link = await this._getLink(data);\nreturn link.toOutputPath();\n}\n// Preferred to use the singular `getOutputLocations` above.\nasync getOutputHref(data) {\n+ this.bench.get(\"(count) getOutputHref\").incrementCount();\nlet link = await this._getLink(data);\nreturn link.toHref();\n}\n// Preferred to use the singular `getOutputLocations` above.\nasync getOutputPath(data) {\n+ this.bench.get(\"(count) getOutputPath\").incrementCount();\nlet link = await this._getLink(data);\nif (await this.usePermalinkRoot()) {\nreturn link.toPathFromRoot();\n@@ -612,6 +617,11 @@ class Template extends TemplateContent {\ndata.page = {};\n}\n+ // pagination will already have these set via Pagination->getPageTemplates\n+ if (data.page.url && data.page.outputPath) {\n+ return;\n+ }\n+\nlet { href, path } = await this.getOutputLocations(data);\ndata.page.url = href;\ndata.page.outputPath = path;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -274,11 +274,15 @@ class TemplateContent {\nif (cacheable && key) {\nif (cache.has(key)) {\n- this.bench.get(\"Template Compile Cache Hit\").incrementCount();\n+ this.bench\n+ .get(\"(count) Template Compile Cache Hit\")\n+ .incrementCount();\nreturn cache.get(key);\n}\n- this.bench.get(\"Template Compile Cache Miss\").incrementCount();\n+ this.bench\n+ .get(\"(count) Template Compile Cache Miss\")\n+ .incrementCount();\n// Compilation is async, so we eagerly cache a Promise that eventually\n// resolves to the compiled function\n@@ -346,6 +350,15 @@ class TemplateContent {\n}\nasync renderPermalink(permalink, data) {\n+ this.bench.get(\"(count) Render Permalink\").incrementCount();\n+ this.bench\n+ .get(\n+ `(count) > Render Permalink > ${\n+ this.inputPath\n+ }${this._getPaginationLogSuffix(data)}`\n+ )\n+ .incrementCount();\n+\nlet permalinkCompilation = this.engine.permalinkNeedsCompilation(permalink);\n// No string compilation:\n// ({ compileOptions: { permalink: \"raw\" }})\n@@ -384,6 +397,24 @@ class TemplateContent {\nreturn this._render(str, data, bypassMarkdown);\n}\n+ _getPaginationLogSuffix(data) {\n+ let suffix = [];\n+ if (\"pagination\" in data) {\n+ suffix.push(\" (\");\n+ if (data.pagination.pages) {\n+ suffix.push(\n+ `${data.pagination.pages.length} page${\n+ data.pagination.pages.length !== 1 ? \"s\" : \"\"\n+ }`\n+ );\n+ } else {\n+ suffix.push(\"Pagination\");\n+ }\n+ suffix.push(\")\");\n+ }\n+ return suffix.join(\"\");\n+ }\n+\nasync _render(str, data, bypassMarkdown) {\ntry {\nif (bypassMarkdown && !this.engine.needsCompilation(str)) {\n@@ -405,23 +436,10 @@ class TemplateContent {\n// Benchmark\nlet templateBenchmark = this.bench.get(\"Render\");\n- let logRenderToOutputBenchmark = true;\n- let paginationSuffix = [];\n- if (\"pagination\" in data) {\n- logRenderToOutputBenchmark = false; // skip benchmark for each individual pagination entry\n- paginationSuffix.push(\" (Pagination\");\n- if (data.pagination.pages) {\n- paginationSuffix.push(\n- `: ${data.pagination.pages.length} page${\n- data.pagination.pages.length !== 1 ? \"s\" : \"\"\n- }`\n- );\n- }\n- paginationSuffix.push(\")\");\n- }\n-\n+ // Skip benchmark for each individual pagination entry (very busy output)\n+ let logRenderToOutputBenchmark = \"pagination\" in data;\nlet inputPathBenchmark = this.bench.get(\n- `> Render > ${this.inputPath}${paginationSuffix.join(\"\")}`\n+ `> Render > ${this.inputPath}${this._getPaginationLogSuffix(data)}`\n);\nlet outputPathBenchmark;\nif (data.page && data.page.outputPath && logRenderToOutputBenchmark) {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Re-use output locations from pagination (if they exist) |
699 | 04.05.2022 16:49:14 | 18,000 | ceb5e70e7a90862da621ae9e05cc4f5c33057c94 | Huge memory wins by using a proxy for pagination data, rather than a deep copy for each page. specifically the data set linked up here | [
{
"change_type": "MODIFY",
"old_path": "src/Util/Merge.js",
"new_path": "src/Util/Merge.js",
"diff": "const { isPlainObject } = require(\"@11ty/eleventy-utils\");\nconst OVERRIDE_PREFIX = \"override:\";\n-function getMergedItem(target, source, parentKey) {\n- // if key is prefixed with OVERRIDE_PREFIX, it just keeps the new source value (no merging)\n- if (parentKey && parentKey.indexOf(OVERRIDE_PREFIX) === 0) {\n+function getMergedItem(target, source, parentKey, overridePrefix) {\n+ // if key is prefixed with overridePrefix, it just keeps the new source value (no merging)\n+ if (overridePrefix && parentKey && parentKey.indexOf(overridePrefix) === 0) {\nreturn source;\n}\n@@ -18,10 +18,15 @@ function getMergedItem(target, source, parentKey) {\nif (isPlainObject(source)) {\nfor (let key in source) {\nlet newKey = key;\n- if (key.indexOf(OVERRIDE_PREFIX) === 0) {\n- newKey = key.substr(OVERRIDE_PREFIX.length);\n+ if (overridePrefix && key.startsWith(overridePrefix)) {\n+ newKey = key.substr(overridePrefix.length);\n}\n- target[newKey] = getMergedItem(target[key], source[key], newKey);\n+ target[newKey] = getMergedItem(\n+ target[key],\n+ source[key],\n+ newKey,\n+ overridePrefix\n+ );\n}\n}\nreturn target;\n@@ -31,6 +36,18 @@ function getMergedItem(target, source, parentKey) {\n}\n}\n+// The same as Merge but without override prefixes\n+function DeepCopy(targetObject, ...sources) {\n+ for (let source of sources) {\n+ if (!source) {\n+ continue;\n+ }\n+\n+ targetObject = getMergedItem(targetObject, source);\n+ }\n+ return targetObject;\n+}\n+\nfunction Merge(target, ...sources) {\n// Remove override prefixes from root target.\nif (isPlainObject(target)) {\n@@ -46,10 +63,11 @@ function Merge(target, ...sources) {\nif (!source) {\ncontinue;\n}\n- target = getMergedItem(target, source);\n+ target = getMergedItem(target, source, null, OVERRIDE_PREFIX);\n}\nreturn target;\n}\nmodule.exports = Merge;\n+module.exports.DeepCopy = DeepCopy;\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Huge memory wins by using a proxy for pagination data, rather than a deep copy for each page. #2360 specifically the @signpostmarv data set linked up here https://github.com/11ty/eleventy/issues/2360#issuecomment-1117043607 |
699 | 06.05.2022 12:15:11 | 18,000 | 0bb2deb4de7baf707d3c9001ca5c9bc989c23587 | Get rid of hoisting code (no longer necessary) | [
{
"change_type": "MODIFY",
"old_path": "src/ComputedData.js",
"new_path": "src/ComputedData.js",
"diff": "@@ -15,7 +15,6 @@ class ComputedData {\nthis.computedKeys = new Set();\nthis.declaredDependencies = {};\nthis.queue = new ComputedDataQueue();\n- this.usesLog = {};\nthis.config = config;\n}\n@@ -78,9 +77,6 @@ class ComputedData {\nvarsUsed = await proxy.findVarsUsed(computed, data);\n}\n- // save the uses for hoisting below\n- this.usesLog[key] = varsUsed;\n-\ndebug(\"%o accesses %o variables\", key, varsUsed);\nlet filteredVarsUsed = varsUsed.filter((varUsed) => {\nreturn (\n@@ -93,39 +89,12 @@ class ComputedData {\n}\n}\n- // Workaround to hoist proxied data (via pagination) into the top level object for use in template languages\n- // (see tests: \"Pagination over collection using eleventyComputed\")\n- hoistProxyData(data, vars = []) {\n- // pagination is the only code path using proxies for data aliasing\n- if (!(\"pagination\" in data)) {\n- return;\n- }\n- let defaultValue = \"____DEFAULT_11ty_VALUE___\";\n- for (let v of vars) {\n- let value = lodashGet(data, v, defaultValue);\n- if (value !== defaultValue) {\n- lodashSet(data, v, value);\n- }\n- }\n- }\n-\n- getHoistedVars(key) {\n- let deps = this.usesLog[key];\n- let hoists = Array.from(new Set(deps));\n- return hoists;\n- }\n-\nasync _setupDataEntry(data, order) {\ndebug(\"Computed data order of execution: %o\", order);\nfor (let key of order) {\nlet computed = lodashGet(this.computed, key);\nif (typeof computed === \"function\") {\n- let shouldHoistData = !!this.templateStringKeyLookup[key];\n- if (shouldHoistData) {\n- let hoists = this.getHoistedVars(key);\n- this.hoistProxyData(data, hoists);\n- }\nlet ret = await computed(data);\nlodashSet(data, key, ret);\n} else if (computed !== undefined) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/ComputedDataProxy.js",
"new_path": "src/ComputedDataProxy.js",
"diff": "@@ -18,8 +18,10 @@ class ComputedDataProxy {\ngetProxyData(data, keyRef) {\n// WARNING: SIDE EFFECTS\n- // TODO should make another effort to get rid of this\n// Set defaults for keys not already set on parent data\n+\n+ // TODO should make another effort to get rid of this,\n+ // See the ProxyWrap util for more proxy handlers that will likely fix this\nlet undefinedValue = \"__11TY_UNDEFINED__\";\nif (this.computedKeys) {\nfor (let key of this.computedKeys) {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Get rid of hoisting code (no longer necessary) |
699 | 06.05.2022 12:21:01 | 18,000 | bc1e7ad819ef4c1b9625d883d3ad4c08b3e76f17 | Slightly better error messages on serverless errors | [
{
"change_type": "MODIFY",
"old_path": "src/Serverless.js",
"new_path": "src/Serverless.js",
"diff": "@@ -221,9 +221,12 @@ class Serverless {\n// TODO (@zachleat) https://github.com/11ty/eleventy/issues/1957\nthis.deleteEnvironmentVariables();\n- let filtered = json.filter((entry) => {\n+ let filtered = [];\n+ if (Array.isArray(json)) {\n+ filtered = json.filter((entry) => {\nreturn entry.inputPath === inputPath;\n});\n+ }\nif (!filtered.length) {\nlet err = new Error(\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Slightly better error messages on serverless errors |
699 | 06.05.2022 12:53:01 | 18,000 | f64fd8b0c161f4b2b8df58f3aacc6b4bb66255fe | Test for Handlebars partial with parameter | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderHandlebarsTest.js",
"new_path": "test/TemplateRenderHandlebarsTest.js",
"diff": "@@ -77,6 +77,14 @@ test(\"Handlebars Render Partial with variable\", async (t) => {\nt.is(await fn({ name: \"Zach\" }), \"<p>This is a Zach.</p>\");\n});\n+test(\"Handlebars Render Partial with parameter\", async (t) => {\n+ let fn = await getNewTemplateRender(\n+ \"hbs\",\n+ \"./test/stubs-hbs-partial-var/\"\n+ ).getCompiledTemplate(\"{{> myPartial parameter=name }}\");\n+ t.is(await fn({ name: \"Zach\" }), \"The result is Zach\");\n+});\n+\ntest(\"Handlebars Render: with Library Override\", async (t) => {\nlet tr = getNewTemplateRender(\"hbs\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-hbs-partial-var/_includes/myPartial.hbs",
"diff": "+The result is {{parameter}}\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Test for Handlebars partial with parameter |
699 | 06.05.2022 13:08:02 | 18,000 | f050e53c3657be6af74d411e81b790c75b142d5b | Fix for "TypeError: 'getOwnPropertyDescriptor' on proxy: trap returned descriptor for property '___' that is incompatible with the existing property in the proxy target" | [
{
"change_type": "MODIFY",
"old_path": "src/Util/ProxyWrap.js",
"new_path": "src/Util/ProxyWrap.js",
"diff": "@@ -6,19 +6,9 @@ function wrapObject(target, fallback) {\ngetOwnPropertyDescriptor(target, prop) {\n// console.log( \"handler:getOwnPropertyDescriptor\", prop );\nif (prop in target) {\n- return {\n- value: target[prop],\n- configurable: true,\n- enumerable: true,\n- writable: true,\n- };\n+ return Reflect.getOwnPropertyDescriptor(target, prop);\n} else if (prop in fallback) {\n- return {\n- value: fallback[prop],\n- configurable: true,\n- enumerable: true,\n- writable: true,\n- };\n+ return Reflect.getOwnPropertyDescriptor(fallback, prop);\n}\n},\n// Liquid needs this\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix for "TypeError: 'getOwnPropertyDescriptor' on proxy: trap returned descriptor for property '___' that is incompatible with the existing property in the proxy target" |
681 | 07.05.2022 11:48:06 | -19,080 | d252d8c62fcb34b24524603d5327d41b46d1299a | chore: Replace deprecated String.prototype.substr() with String.prototype.slice()
Replace deprecated String.prototype.substr() with String.prototype.slice() | [
{
"change_type": "MODIFY",
"old_path": "src/ComputedDataTemplateString.js",
"new_path": "src/ComputedDataTemplateString.js",
"diff": "@@ -38,7 +38,10 @@ class ComputedDataTemplateString {\nlet vars = new Set();\nlet splits = output.split(this.prefix);\nfor (let split of splits) {\n- let varName = split.substr(0, split.indexOf(this.suffix));\n+ let varName = split.slice(\n+ 0,\n+ split.indexOf(this.suffix) < 0 ? 0 : split.indexOf(this.suffix)\n+ );\nif (varName) {\nvars.add(varName);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyErrorUtil.js",
"new_path": "src/EleventyErrorUtil.js",
"diff": "@@ -28,7 +28,12 @@ class EleventyErrorUtil {\nreturn \"\" + msg;\n}\n- return msg.substr(0, msg.indexOf(EleventyErrorUtil.prefix));\n+ return msg.slice(\n+ 0,\n+ msg.indexOf(EleventyErrorUtil.prefix) < 0\n+ ? 0\n+ : msg.indexOf(EleventyErrorUtil.prefix)\n+ );\n}\nstatic deconvertErrorToObject(error) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyExtensionMap.js",
"new_path": "src/EleventyExtensionMap.js",
"diff": "@@ -217,7 +217,12 @@ class EleventyExtensionMap {\nremoveTemplateExtension(path) {\nfor (var extension in this.extensionToKeyMap) {\nif (path === extension || path.endsWith(\".\" + extension)) {\n- return path.substr(0, path.length - 1 - extension.length);\n+ return path.slice(\n+ 0,\n+ path.length - 1 - extension.length < 0\n+ ? 0\n+ : path.length - 1 - extension.length\n+ );\n}\n}\nreturn path;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -126,10 +126,10 @@ class TemplateContent {\nfm.content =\nfm.excerpt.trim() +\n\"\\n\" +\n- fm.content.substr((excerptString + os.EOL).length);\n+ fm.content.slice((excerptString + os.EOL).length);\n} else if (fm.content.startsWith(excerptString)) {\n// no newline after excerpt separator\n- fm.content = fm.excerpt + fm.content.substr(excerptString.length);\n+ fm.content = fm.excerpt + fm.content.slice(excerptString.length);\n}\n// alias, defaults to page.excerpt\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateGlob.js",
"new_path": "src/TemplateGlob.js",
"diff": "@@ -15,7 +15,7 @@ class TemplateGlob {\nstatic normalize(path) {\npath = path.trim();\nif (path.charAt(0) === \"!\") {\n- return \"!\" + TemplateGlob.normalizePath(path.substr(1));\n+ return \"!\" + TemplateGlob.normalizePath(path.slice(1));\n} else {\nreturn TemplateGlob.normalizePath(path);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -70,7 +70,7 @@ class TemplateMap {\ngetTagTarget(str) {\nif (str.startsWith(\"collections.\")) {\n- return str.substr(\"collections.\".length);\n+ return str.slice(\"collections.\".length);\n}\n}\n@@ -283,7 +283,7 @@ class TemplateMap {\nfor (let depEntry of dependencyMap) {\nif (depEntry.startsWith(tagPrefix)) {\n// is a tag (collection) entry\n- let tagName = depEntry.substr(tagPrefix.length);\n+ let tagName = depEntry.slice(tagPrefix.length);\nawait this.setCollectionByTagName(tagName);\n} else {\n// is a template entry\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePermalink.js",
"new_path": "src/TemplatePermalink.js",
"diff": "@@ -75,7 +75,7 @@ class TemplatePermalink {\n}\n_addDefaultLinkFilename(link) {\n- return link + (link.substr(-1) === \"/\" ? \"index.html\" : \"\");\n+ return link + (link.slice(-1) === \"/\" ? \"index.html\" : \"\");\n}\ntoOutputPath() {\n@@ -134,8 +134,8 @@ class TemplatePermalink {\nlet needle = \"/index.html\";\nif (original === needle) {\nreturn \"/\";\n- } else if (original.substr(-1 * needle.length) === needle) {\n- return original.substr(0, original.length - needle.length) + \"/\";\n+ } else if (original.slice(-1 * needle.length) === needle) {\n+ return original.slice(0, original.length - needle.length) + \"/\";\n}\nreturn original;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Util/Merge.js",
"new_path": "src/Util/Merge.js",
"diff": "@@ -3,7 +3,7 @@ const OVERRIDE_PREFIX = \"override:\";\nfunction cleanKey(key, prefix) {\nif (prefix && key.startsWith(prefix)) {\n- return key.substr(prefix.length);\n+ return key.slice(prefix.length);\n}\nreturn key;\n}\n@@ -60,7 +60,7 @@ function Merge(target, ...sources) {\nif (isPlainObject(target)) {\nfor (let key in target) {\nif (key.indexOf(OVERRIDE_PREFIX) === 0) {\n- target[key.substr(OVERRIDE_PREFIX.length)] = target[key];\n+ target[key.slice(OVERRIDE_PREFIX.length)] = target[key];\ndelete target[key];\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyErrorHandlerTest.js",
"new_path": "test/EleventyErrorHandlerTest.js",
"diff": "@@ -21,7 +21,7 @@ test(\"Log a warning, warning\", (t) => {\nerrorHandler.warn(new Error(\"Test warning\"), \"Hello\");\nlet expected = \"Hello: (more in DEBUG output)\";\n- t.is(output.join(\"\\n\").substr(0, expected.length), expected);\n+ t.is(output.join(\"\\n\").slice(0, expected.length), expected);\n});\ntest(\"Log a warning, error\", (t) => {\n@@ -49,5 +49,5 @@ test(\"Log a warning, error\", (t) => {\nTest error (via Error)\nOriginal error stack trace: Error: Test error`;\n- t.is(output.join(\"\\n\").substr(0, expected.length), expected);\n+ t.is(output.join(\"\\n\").slice(0, expected.length), expected);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderLiquidTest.js",
"new_path": "test/TemplateRenderLiquidTest.js",
"diff": "@@ -781,9 +781,9 @@ test(\"Issue 258: Liquid Render Date\", async (t) => {\n\"<p>{{ myDate }}</p>\"\n);\nlet dateStr = await fn({ myDate: new Date(Date.UTC(2016, 0, 1, 0, 0, 0)) });\n- t.is(dateStr.substr(0, 3), \"<p>\");\n- t.is(dateStr.substr(-4), \"</p>\");\n- t.not(dateStr.substr(2, 1), '\"');\n+ t.is(dateStr.slice(0, 3), \"<p>\");\n+ t.is(dateStr.slice(-4), \"</p>\");\n+ t.not(dateStr.slice(2, 1), '\"');\n});\ntest(\"Issue 347: Liquid addTags with space in argument\", async (t) => {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | chore: Replace deprecated String.prototype.substr() with String.prototype.slice()
Replace deprecated String.prototype.substr() with String.prototype.slice() |
699 | 09.05.2022 15:39:02 | 18,000 | 0aa204c1fd4022a9d1a91f02533c00c5f936d9ca | Test for Fails with the code before was merged and passes after it was added | [
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -3,6 +3,7 @@ const Eleventy = require(\"../src/Eleventy\");\nconst EleventyWatchTargets = require(\"../src/EleventyWatchTargets\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\nconst DateGitLastUpdated = require(\"../src/Util/DateGitLastUpdated\");\n+const normalizeNewLines = require(\"./Util/normalizeNewLines\");\ntest(\"Eleventy, defaults inherit from config\", async (t) => {\nlet elev = new Eleventy();\n@@ -500,3 +501,31 @@ test(\"Paginated template uses proxy and global data\", async (t) => {\n});\nt.is(results.length, allContentMatches.length);\n});\n+\n+test(\"Liquid shortcode with multiple arguments(issue #2348)\", async (t) => {\n+ // NOTE issue #2348 was only active when you were processing multiple templates at the same time.\n+\n+ let elev = new Eleventy(\"./test/stubs-2367/\", \"./test/stubs-2367/_site\", {\n+ config: function (eleventyConfig) {\n+ eleventyConfig.addShortcode(\"simplelink\", function (...args) {\n+ return JSON.stringify(args);\n+ });\n+ },\n+ });\n+\n+ let arr = [\n+ \"layout\",\n+ \"/mylayout\",\n+ \"layout\",\n+ \"/mylayout\",\n+ \"layout\",\n+ \"/mylayout\",\n+ ];\n+ let str = normalizeNewLines(`${JSON.stringify(arr)}\n+${JSON.stringify(arr)}`);\n+ let results = await elev.toJSON();\n+ t.is(results.length, 2);\n+ let content = results.map((entry) => entry.content).sort();\n+ t.is(normalizeNewLines(content[0]), str);\n+ t.is(normalizeNewLines(content[1]), str);\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -320,45 +320,6 @@ test(\"One Layout (_layoutContent deprecated but supported)\", async (t) => {\nt.is(data.keylayout, \"valuelayout\");\n});\n-test(\"Liquid shortcode with multiple arguments(issue #2348)\", async (t) => {\n- // NOTE issue #2348 was only active when you were processing multiple templates at the same time.\n-\n- let eleventyConfig = new TemplateConfig();\n- eleventyConfig.userConfig.addShortcode(\"simplelink\", function (text, url) {\n- return `<a href=\"${url}\">${text} (${url})</a>`;\n- });\n-\n- let dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n-\n- let tmpl = getNewTemplate(\n- \"./test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid\",\n- \"./test/stubs/\",\n- \"dist\",\n- dataObj,\n- null,\n- eleventyConfig\n- );\n-\n- t.is(\n- (await tmpl.getFrontMatter()).data[tmpl.config.keys.layout],\n- \"layoutLiquid.liquid\"\n- );\n-\n- let data = await tmpl.getData();\n- t.is(data[tmpl.config.keys.layout], \"layoutLiquid.liquid\");\n-\n- t.is(\n- normalizeNewLines(cleanHtml(await tmpl.renderLayout(tmpl, data))),\n- `<div id=\"layout\">\n- <p>Hello.</p>\n- <a href=\"/somepage\">world (/somepage)</a>\n-</div>`\n- );\n-\n- t.is(data.keymain, \"valuemain\");\n- t.is(data.keylayout, \"valuelayout\");\n-});\n-\ntest(\"One Layout (liquid test)\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-2367/_includes/layout.liquid",
"diff": "+---\n+text: layout\n+url: \"/mylayout\"\n+---\n+{% simplelink text url text url text url %}\n+{% simplelink text, url, text, url, text, url %}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-2367/templateWithLiquidShortcodeMultipleArguments-template2.liquid",
"diff": "+---\n+layout: layout.liquid\n+---\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-2367/templateWithLiquidShortcodeMultipleArguments.liquid",
"diff": "+---\n+layout: layout.liquid\n+---\n\\ No newline at end of file\n"
},
{
"change_type": "DELETE",
"old_path": "test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid",
"new_path": null,
"diff": "----\n-layout: layoutLiquid.liquid\n-keymain: valuemain\n-title: 'Font Aliasing, or How to Rename a Font in CSS'\n-permalink: /rename-font2/\n----\n-\n-<p>Hello.</p>\n-{% simplelink \"world\", \"/somepage\" %}\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Test for #2348. Fails with the code before #2367 was merged and passes after it was added |
699 | 10.05.2022 10:47:57 | 18,000 | 02b8459681b9d29ee9ab28191f381b87764fd8a9 | Super small tweaks to | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -474,13 +474,11 @@ test(\"Dots in datafile path (Issue #1242)\", async (t) => {\nlet data = await dataObj.getData();\n- t.deepEqual(data, {\n- \"xyz.dottest\": {\n+ t.deepEqual(data[\"xyz.dottest\"], {\nhi: \"bye\",\ntest: {\nabc: 42,\n},\n- },\n});\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Super small tweaks to #1912. |
699 | 10.05.2022 11:07:33 | 18,000 | d445975fc993048ce83a9ad210a7a2400a8ea3cc | Found a dependency that was a devDependency | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"markdown-it-emoji\": \"^2.0.2\",\n\"marked\": \"^4.0.15\",\n\"nyc\": \"^15.1.0\",\n+ \"pretty\": \"^2.0.0\",\n\"prettier\": \"^2.6.2\",\n\"rimraf\": \"^3.0.2\",\n\"sass\": \"^1.51.0\",\n\"nunjucks\": \"^3.2.3\",\n\"path-to-regexp\": \"^6.2.0\",\n\"please-upgrade-node\": \"^3.2.0\",\n- \"pretty\": \"^2.0.0\",\n\"pug\": \"^3.0.2\",\n\"recursive-copy\": \"^2.0.14\",\n\"semver\": \"^7.3.7\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Found a dependency that was a devDependency |
699 | 10.05.2022 11:53:55 | 18,000 | 1ac289a0a3918161919a23f6b1349ff27fbfd877 | Additional tests and cleanup for | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -985,6 +985,7 @@ class Template extends TemplateContent {\n} else {\nlet filepathRegex = this.inputPath.match(/(\\d{4}-\\d{2}-\\d{2})/);\nif (filepathRegex !== null) {\n+ // if multiple are found in the path, use the first one for the date\nlet dateObj = DateTime.fromISO(filepathRegex[1], {\nzone: \"utc\",\n}).toJSDate();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateFileSlug.js",
"new_path": "src/TemplateFileSlug.js",
"diff": "@@ -18,12 +18,13 @@ class TemplateFileSlug {\nthis.filenameNoExt = extensionMap.removeTemplateExtension(this.parsed.base);\n}\n+ // `page.filePathStem` see https://www.11ty.dev/docs/data-eleventy-supplied/#page-variable\ngetFullPathWithoutExtension() {\nreturn \"/\" + TemplatePath.join(...this.dirs, this._getRawSlug());\n}\n_getRawSlug() {\n- const slug = this.filenameNoExt;\n+ let slug = this.filenameNoExt;\nreturn this._stripDateFromSlug(slug);\n}\n@@ -36,6 +37,7 @@ class TemplateFileSlug {\nreturn slug;\n}\n+ // `page.fileSlug` see https://www.11ty.dev/docs/data-eleventy-supplied/#page-variable\ngetSlug() {\nlet rawSlug = this._getRawSlug();\n@@ -43,7 +45,7 @@ class TemplateFileSlug {\nif (!this.dirs.length) {\nreturn \"\";\n}\n- const lastDir = this.dirs[this.dirs.length - 1];\n+ let lastDir = this.dirs[this.dirs.length - 1];\nreturn this._stripDateFromSlug(lastDir);\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/TemplateTest-Dates.js",
"diff": "+const test = require(\"ava\");\n+const getNewTemplate = require(\"./_getNewTemplateForTests\");\n+\n+async function getRenderedData(tmpl, pageNumber = 0) {\n+ let data = await tmpl.getData();\n+ let templates = await tmpl.getTemplates(data);\n+ return templates[pageNumber].data;\n+}\n+\n+test(\"getMappedDate (empty, assume created)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/dates/file1.md\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let data = await getRenderedData(tmpl);\n+ let date = await tmpl.getMappedDate(data);\n+\n+ t.true(date instanceof Date);\n+ t.truthy(date.getTime());\n+});\n+\n+test(\"getMappedDate (explicit date, yaml String)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/dates/file2.md\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let data = await getRenderedData(tmpl);\n+ let date = await tmpl.getMappedDate(data);\n+\n+ t.true(date instanceof Date);\n+ t.truthy(date.getTime());\n+ t.is(Date.UTC(2016, 0, 1), date.getTime());\n+});\n+\n+test(\"getMappedDate (explicit date, yaml Date)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/dates/file2b.md\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let data = await getRenderedData(tmpl);\n+ let date = await tmpl.getMappedDate(data);\n+\n+ t.true(date instanceof Date);\n+ t.truthy(date.getTime());\n+ t.is(Date.UTC(2016, 0, 1), date.getTime());\n+});\n+\n+test(\"getMappedDate (explicit date, yaml Date and string should be the same)\", async (t) => {\n+ let tmplA = getNewTemplate(\n+ \"./test/stubs/dates/file2.md\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let dataA = await getRenderedData(tmplA);\n+ let stringDate = await tmplA.getMappedDate(dataA);\n+\n+ let tmplB = getNewTemplate(\n+ \"./test/stubs/dates/file2b.md\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let dataB = await getRenderedData(tmplB);\n+ let yamlDate = await tmplB.getMappedDate(dataB);\n+\n+ t.truthy(stringDate);\n+ t.truthy(yamlDate);\n+ t.deepEqual(stringDate, yamlDate);\n+});\n+\n+test(\"getMappedDate (modified date)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/dates/file3.md\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let data = await getRenderedData(tmpl);\n+ let date = await tmpl.getMappedDate(data);\n+\n+ t.true(date instanceof Date);\n+ t.truthy(date.getTime());\n+});\n+\n+test(\"getMappedDate (created date)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/dates/file4.md\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let data = await getRenderedData(tmpl);\n+ let date = await tmpl.getMappedDate(data);\n+\n+ t.true(date instanceof Date);\n+ t.truthy(date.getTime());\n+});\n+\n+test(\"getMappedDate (falls back to filename date)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/dates/2018-01-01-file5.md\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let data = await getRenderedData(tmpl);\n+ let date = await tmpl.getMappedDate(data);\n+\n+ t.true(date instanceof Date);\n+ t.truthy(date.getTime());\n+ t.is(Date.UTC(2018, 0, 1), date.getTime());\n+});\n+\n+test(\"getMappedDate (found multiple dates, picks first)\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/dates/2019-01-01-folder/2020-01-01-file.md\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ let data = await getRenderedData(tmpl);\n+ let date = await tmpl.getMappedDate(data);\n+\n+ t.true(date instanceof Date);\n+ t.truthy(date.getTime());\n+ t.is(Date.UTC(2019, 0, 1), date.getTime());\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -630,106 +630,6 @@ test(\"Clone the template\", async (t) => {\nt.is(cloned.extensionMap, tmpl.extensionMap);\n});\n-test(\"getMappedDate (empty, assume created)\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/dates/file1.md\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- let data = await getRenderedData(tmpl);\n- let date = await tmpl.getMappedDate(data);\n-\n- t.true(date instanceof Date);\n- t.truthy(date.getTime());\n-});\n-\n-test(\"getMappedDate (explicit date, yaml String)\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/dates/file2.md\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- let data = await getRenderedData(tmpl);\n- let date = await tmpl.getMappedDate(data);\n-\n- t.true(date instanceof Date);\n- t.truthy(date.getTime());\n-});\n-\n-test(\"getMappedDate (explicit date, yaml Date)\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/dates/file2b.md\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- let data = await getRenderedData(tmpl);\n- let date = await tmpl.getMappedDate(data);\n-\n- t.true(date instanceof Date);\n- t.truthy(date.getTime());\n-});\n-\n-test(\"getMappedDate (explicit date, yaml Date and string should be the same)\", async (t) => {\n- let tmplA = getNewTemplate(\n- \"./test/stubs/dates/file2.md\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- let dataA = await getRenderedData(tmplA);\n- let stringDate = await tmplA.getMappedDate(dataA);\n-\n- let tmplB = getNewTemplate(\n- \"./test/stubs/dates/file2b.md\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- let dataB = await getRenderedData(tmplB);\n- let yamlDate = await tmplB.getMappedDate(dataB);\n-\n- t.truthy(stringDate);\n- t.truthy(yamlDate);\n- t.deepEqual(stringDate, yamlDate);\n-});\n-\n-test(\"getMappedDate (modified date)\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/dates/file3.md\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- let data = await getRenderedData(tmpl);\n- let date = await tmpl.getMappedDate(data);\n-\n- t.true(date instanceof Date);\n- t.truthy(date.getTime());\n-});\n-\n-test(\"getMappedDate (created date)\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/dates/file4.md\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- let data = await getRenderedData(tmpl);\n- let date = await tmpl.getMappedDate(data);\n-\n- t.true(date instanceof Date);\n- t.truthy(date.getTime());\n-});\n-\n-test(\"getMappedDate (falls back to filename date)\", async (t) => {\n- let tmpl = getNewTemplate(\n- \"./test/stubs/dates/2018-01-01-file5.md\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- let data = await getRenderedData(tmpl);\n- let date = await tmpl.getMappedDate(data);\n-\n- t.true(date instanceof Date);\n- t.truthy(date.getTime());\n-});\n-\ntest(\"getRenderedData() has all the page variables\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/template.ejs\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/dates/2019-01-01-folder/2020-01-01-file.md",
"diff": "+---\n+---\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Additional tests and cleanup for #2111 |
699 | 10.05.2022 12:32:17 | 18,000 | 4599c11383c9b9f47008b5f7036ed82f1a9d5384 | debug() level warning for | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -6,7 +6,7 @@ const lodashset = require(\"lodash/set\");\nconst lodashget = require(\"lodash/get\");\nconst lodashUniq = require(\"lodash/uniq\");\nconst semver = require(\"semver\");\n-const { TemplatePath } = require(\"@11ty/eleventy-utils\");\n+const { TemplatePath, isPlainObject } = require(\"@11ty/eleventy-utils\");\nconst merge = require(\"./Util/Merge\");\nconst TemplateRender = require(\"./TemplateRender\");\n@@ -372,9 +372,16 @@ class TemplateData {\nfor (let path of localDataPaths) {\n// clean up data for template/directory data files only.\nlet dataForPath = await this.getDataValue(path, null, true);\n+ if (!isPlainObject(dataForPath)) {\n+ debug(\n+ \"Warning: Template and Directory data files expect an object to be returned, instead `%o` returned `%o`\",\n+ path,\n+ dataForPath\n+ );\n+ } else {\nlet cleanedDataForPath = TemplateData.cleanupData(dataForPath);\nTemplateData.mergeDeep(this.config, localData, cleanedDataForPath);\n- // debug(\"`combineLocalData` (iterating) for %o: %O\", path, localData);\n+ }\n}\nreturn localData;\n}\n@@ -611,7 +618,7 @@ class TemplateData {\n}\nstatic cleanupData(data) {\n- if (typeof data === \"object\" && \"tags\" in data) {\n+ if (isPlainObject(data) && \"tags\" in data) {\nif (typeof data.tags === \"string\") {\ndata.tags = data.tags ? [data.tags] : [];\n} else if (data.tags === null) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -2225,3 +2225,21 @@ test(\"page.templateSyntax works with templateEngineOverride\", async (t) => {\nt.is((await tmpl.render(await tmpl.getData())).trim(), \"<p>njk,md</p>\");\n});\n+\n+// Inspired by https://github.com/11ty/eleventy/pull/1691\n+test(\"Error messaging, returning literals (not objects) from custom data extension\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let dataObj = new TemplateData(\"./test/stubs-1691/\", eleventyConfig);\n+ dataObj.config.dataExtensions = new Map([[\"txt\", (s) => s]]);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs-1691/template.njk\",\n+ \"./test/stubs-1691/\",\n+ \"dist\",\n+ dataObj,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(data.str, \"Testing\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-1691/_data/str.txt",
"diff": "+Testing\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-1691/template.11tydata.txt",
"diff": "+Template Data File\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": "test/stubs-1691/template.njk",
"new_path": "test/stubs-1691/template.njk",
"diff": ""
}
]
| JavaScript | MIT License | 11ty/eleventy | debug() level warning for #1691 |
699 | 11.05.2022 10:04:23 | 18,000 | 73c1ec199e68449f77730d712a42439f479abd9b | A different preference for the options arg to | [
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -754,7 +754,20 @@ class UserConfig {\n);\n}\n- addDataExtension(extensionList, parser, options = {}) {\n+ addDataExtension(extensionList, parser) {\n+ let options = {};\n+ // second argument is an object with a `parser` callback\n+ if (typeof parser !== \"function\") {\n+ if (!(\"parser\" in parser)) {\n+ throw new Error(\n+ \"Expected `parser` property in second argument object to `eleventyConfig.addDataExtension`\"\n+ );\n+ }\n+\n+ options = parser;\n+ parser = options.parser;\n+ }\n+\nfor (let extension of extensionList.split(\",\")) {\nthis.dataExtensions.set(extension, {\nextension,\n"
},
{
"change_type": "MODIFY",
"old_path": "test/UserDataExtensionsTest.js",
"new_path": "test/UserDataExtensionsTest.js",
"diff": "@@ -183,17 +183,14 @@ test(\"Binary data files, encoding: null (multiple data extensions)\", async (t) =\nt.plan(4);\nlet eleventyConfig = new TemplateConfig();\n- eleventyConfig.userConfig.addDataExtension(\n- \"jpg,png\",\n- function (s) {\n+ eleventyConfig.userConfig.addDataExtension(\"jpg,png\", {\n+ parser: function (s) {\nt.true(Buffer.isBuffer(s));\n// s is a Buffer, just return the length as a sample\nreturn s.length;\n},\n- {\nencoding: null,\n- }\n- );\n+ });\nlet dataObj = new TemplateData(\"./test/stubs-2378/\", eleventyConfig);\n@@ -201,3 +198,10 @@ test(\"Binary data files, encoding: null (multiple data extensions)\", async (t) =\nt.is(data.images.dog, 43183);\nt.is(data.images.dogpng, 2890);\n});\n+\n+test(\"Missing `parser` property to addDataExtension object throws error\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ t.throws(() => {\n+ eleventyConfig.userConfig.addDataExtension(\"jpg\", {});\n+ });\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | A different preference for the options arg to #2378 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.