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 | 07.09.2020 15:37:07 | 18,000 | 085c0664566965e798c09d7d91b17dd468d14861 | Removes JSTL. Fixes | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"gray-matter\": \"^4.0.2\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.7.6\",\n- \"javascript-stringify\": \"^2.0.1\",\n\"liquidjs\": \"^9.15.0\",\n\"lodash\": \"^4.17.20\",\n\"luxon\": \"^1.25.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyExtensionMap.js",
"new_path": "src/EleventyExtensionMap.js",
"diff": "@@ -13,12 +13,12 @@ class EleventyExtensionMap {\nreturn key.trim().toLowerCase();\n});\n- this.validTemplateLanguageKeys = this.unfilteredFormatKeys.filter(key =>\n+ this.validTemplateLanguageKeys = this.unfilteredFormatKeys.filter((key) =>\nthis.hasExtension(key)\n);\nthis.passthroughCopyKeys = this.unfilteredFormatKeys.filter(\n- key => !this.hasExtension(key)\n+ (key) => !this.hasExtension(key)\n);\n}\n@@ -141,7 +141,6 @@ class EleventyExtensionMap {\nthis._extensionToKeyMap = {\nejs: \"ejs\",\nmd: \"md\",\n- jstl: \"jstl\",\nhtml: \"html\",\nhbs: \"hbs\",\nmustache: \"mustache\",\n@@ -150,7 +149,7 @@ class EleventyExtensionMap {\nnjk: \"njk\",\nliquid: \"liquid\",\n\"11ty.js\": \"11ty.js\",\n- \"11ty.cjs\": \"11ty.js\"\n+ \"11ty.cjs\": \"11ty.js\",\n};\nif (\"extensionMap\" in this.config) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateEngineManager.js",
"new_path": "src/TemplateEngineManager.js",
"diff": "@@ -21,7 +21,6 @@ class TemplateEngineManager {\nthis._keyToClassNameMap = {\nejs: \"Ejs\",\nmd: \"Markdown\",\n- jstl: \"JavaScriptTemplateLiteral\",\nhtml: \"Html\",\nhbs: \"Handlebars\",\nmustache: \"Mustache\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/defaultConfig.js",
"new_path": "src/defaultConfig.js",
"diff": "@@ -28,8 +28,7 @@ module.exports = function(config) {\n\"pug\",\n\"njk\",\n\"html\",\n- \"jstl\",\n- \"11ty.js\"\n+ \"11ty.js\",\n],\n// if your site lives in a subdirectory, change this\npathPrefix: \"/\",\n@@ -45,19 +44,19 @@ module.exports = function(config) {\npermalink: \"permalink\",\npermalinkRoot: \"permalinkBypassOutputDir\",\nengineOverride: \"templateEngineOverride\",\n- computed: \"eleventyComputed\"\n+ computed: \"eleventyComputed\",\n},\ndir: {\ninput: \".\",\nincludes: \"_includes\",\ndata: \"_data\",\n- output: \"_site\"\n+ output: \"_site\",\n},\n// deprecated, use config.addTransform\nfilters: {},\n// deprecated, use config.addHandlebarsHelper\nhandlebarsHelpers: {},\n// deprecated, use config.addNunjucksFilter\n- nunjucksFilters: {}\n+ nunjucksFilters: {},\n};\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateLayoutPathResolverTest.js",
"new_path": "test/TemplateLayoutPathResolverTest.js",
"diff": "@@ -14,7 +14,6 @@ function getResolverInstance(path, inputDir, map) {\n\"pug\",\n\"njk\",\n\"html\",\n- \"jstl\",\n\"11ty.js\",\n]);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateLayoutTest.js",
"new_path": "test/TemplateLayoutTest.js",
"diff": "@@ -14,7 +14,6 @@ function getTemplateLayoutInstance(key, inputDir, map) {\n\"pug\",\n\"njk\",\n\"html\",\n- \"jstl\",\n\"11ty.js\",\n]);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -359,30 +359,6 @@ test(\"Liquid template with include\", async (t) => {\n);\n});\n-test(\"ES6 Template Literal (No Backticks)\", async (t) => {\n- let dataObj = new TemplateData(\"./test/stubs/\");\n- let tmpl = getNewTemplate(\n- \"./test/stubs/formatTest.jstl\",\n- \"./test/stubs/\",\n- \"dist\",\n- dataObj\n- );\n-\n- t.is((await tmpl.render(await tmpl.getData())).trim(), `<p>ZACH</p>`);\n-});\n-\n-test(\"ES6 Template Literal (with Backticks)\", async (t) => {\n- let dataObj = new TemplateData(\"./test/stubs/\");\n- let tmpl = getNewTemplate(\n- \"./test/stubs/formatTestBackticks.jstl\",\n- \"./test/stubs/\",\n- \"dist\",\n- dataObj\n- );\n-\n- t.is((await tmpl.render(await tmpl.getData())).trim(), `<p>ZACH</p>`);\n-});\n-\ntest(\"Permalink output directory\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/permalinked.ejs\",\n"
},
{
"change_type": "MODIFY",
"old_path": "test/_getNewTemplateForTests.js",
"new_path": "test/_getNewTemplateForTests.js",
"diff": "@@ -19,8 +19,7 @@ module.exports = function getNewTemplate(\n\"pug\",\n\"njk\",\n\"html\",\n- \"jstl\",\n- \"11ty.js\"\n+ \"11ty.js\",\n]);\n}\nlet tmpl = new Template(path, inputDir, outputDir, templateData, map);\n"
},
{
"change_type": "DELETE",
"old_path": "test/stubs/formatTest.jstl",
"new_path": null,
"diff": "----\n-name: zach\n----\n-<p>${name.toUpperCase()}</p>\n"
},
{
"change_type": "DELETE",
"old_path": "test/stubs/formatTestBackticks.jstl",
"new_path": null,
"diff": "----\n-name: zach\n----\n-`<p>${name.toUpperCase()}</p>`\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Removes JSTL. Fixes #1084 |
699 | 18.09.2020 22:49:15 | 18,000 | a179b71fb620ed9fb1502659eed47c92de634f5e | Adds a `changedFiles` argument to the `beforeWatch` event to facilitate some incremental behavior. | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -459,10 +459,10 @@ Arguments:\nreturn;\n}\n- this.config.events.emit(\"beforeWatch\");\n-\nthis.watchManager.setBuildRunning();\n+ this.config.events.emit(\"beforeWatch\", this.watchManager.getActiveQueue());\n+\n// reset and reload global configuration :O\nif (this.watchManager.hasQueuedFile(config.getLocalProjectConfigFile())) {\nthis.resetConfig();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyWatch.js",
"new_path": "src/EleventyWatch.js",
"diff": "@@ -36,6 +36,19 @@ class EleventyWatch {\nreturn this.activeQueue[0];\n}\n+ /* Returns the changed files currently being operated on in the current `watch` build\n+ * Works with or without incremental (though in incremental only one file per time will be processed)\n+ */\n+ getActiveQueue() {\n+ if (!this.isActive) {\n+ return [];\n+ } else if (this.incremental) {\n+ return [this.activeQueue[0]];\n+ }\n+\n+ return this.activeQueue;\n+ }\n+\n_queueMatches(file) {\nlet filterCallback;\nif (typeof file === \"function\") {\n@@ -80,6 +93,10 @@ class EleventyWatch {\nreturn this.pendingQueue.length;\n}\n+ getPendingQueue() {\n+ return this.pendingQueue;\n+ }\n+\ngetActiveQueueSize() {\nreturn this.activeQueue.length;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -75,6 +75,8 @@ class UserConfig {\n}\n}\n+ // Duplicate event bindings are avoided with the `reset` method above.\n+ // A new EventEmitter instance is created when the config is reset.\non(eventName, callback) {\nreturn this.events.on(eventName, callback);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyWatchTest.js",
"new_path": "test/EleventyWatchTest.js",
"diff": "@@ -19,21 +19,26 @@ test(\"Incremental\", (t) => {\nwatch.incremental = true;\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.addToPendingQueue(\"test.md\");\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), \"./test.md\");\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\n+ t.deepEqual(watch.getPendingQueue(), []);\n});\ntest(\"Incremental queue 2\", (t) => {\n@@ -43,22 +48,27 @@ test(\"Incremental queue 2\", (t) => {\nwatch.incremental = true;\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.addToPendingQueue(\"test.md\");\nwatch.addToPendingQueue(\"test2.md\");\nt.is(watch.getPendingQueueSize(), 2);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), \"./test.md\");\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getPendingQueue(), [\"./test2.md\"]);\n+ t.deepEqual(watch.getActiveQueue(), []);\n});\ntest(\"Incremental add while active\", (t) => {\n@@ -68,26 +78,32 @@ test(\"Incremental add while active\", (t) => {\nwatch.incremental = true;\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.addToPendingQueue(\"test.md\");\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), \"./test.md\");\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.addToPendingQueue(\"test2.md\");\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), \"./test.md\");\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getPendingQueue(), [\"./test2.md\"]);\n+ t.deepEqual(watch.getActiveQueue(), []);\n});\ntest(\"Non-incremental\", (t) => {\n@@ -96,21 +112,25 @@ test(\"Non-incremental\", (t) => {\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.addToPendingQueue(\"test.md\");\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\n});\ntest(\"Non-incremental queue 2\", (t) => {\n@@ -119,22 +139,27 @@ test(\"Non-incremental queue 2\", (t) => {\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.addToPendingQueue(\"test.md\");\nwatch.addToPendingQueue(\"test2.md\");\nt.is(watch.getPendingQueueSize(), 2);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 2);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\", \"./test2.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getPendingQueue(), []);\n+ t.deepEqual(watch.getActiveQueue(), []);\n});\ntest(\"Non-incremental add while active\", (t) => {\n@@ -148,21 +173,26 @@ test(\"Non-incremental add while active\", (t) => {\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.addToPendingQueue(\"test.md\");\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getPendingQueue(), [\"./test.md\"]);\n+ t.deepEqual(watch.getActiveQueue(), []);\n});\ntest(\"Active queue tests\", (t) => {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds a `changedFiles` argument to the `beforeWatch` event to facilitate some incremental behavior. |
699 | 18.09.2020 22:53:04 | 18,000 | 5d763c5aa8b510f3835df9111f5a05a9a31b1f5e | Test to make sure custom file extensions only init once. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -154,12 +154,12 @@ class TemplateData {\nlet paths = [\n`${dir}/**/*.json`, // covers .11tydata.json too\n`${dir}/**/*${this.config.jsDataFileSuffix}.cjs`,\n- `${dir}/**/*${this.config.jsDataFileSuffix}.js`\n+ `${dir}/**/*${this.config.jsDataFileSuffix}.js`,\n];\nif (this.hasUserDataExtensions()) {\nlet userPaths = this.getUserDataExtensions().map(\n- extension => `${dir}/**/*.${extension}` // covers .11tydata.{extension} too\n+ (extension) => `${dir}/**/*.${extension}` // covers .11tydata.{extension} too\n);\npaths = userPaths.concat(paths);\n}\n@@ -170,7 +170,7 @@ class TemplateData {\nasync getTemplateJavaScriptDataFileGlob() {\nlet dir = await this.getInputDir();\nreturn TemplatePath.addLeadingDotSlashArray([\n- `${dir}/**/*${this.config.jsDataFileSuffix}.js`\n+ `${dir}/**/*${this.config.jsDataFileSuffix}.js`,\n]);\n}\n@@ -206,7 +206,7 @@ class TemplateData {\nfsBench.before();\nlet paths = fastglob.sync(await this.getGlobalDataGlob(), {\ncaseSensitiveMatch: false,\n- dot: true\n+ dot: true,\n});\nfsBench.after();\n@@ -316,7 +316,7 @@ class TemplateData {\n}\n// Filter out files we know don't exist to avoid overhead for checking\n- localDataPaths = localDataPaths.filter(path => {\n+ localDataPaths = localDataPaths.filter((path) => {\nreturn this._fsExistsCache.exists(path);\n});\n@@ -415,11 +415,11 @@ class TemplateData {\n}\n}\n+ // ignoreProcessing = false for global data files\n+ // ignoreProcessing = true for local data files\nasync getDataValue(path, rawImports, ignoreProcessing) {\nlet extension = TemplatePath.getExtension(path);\n- // ignoreProcessing = false for global data files\n- // ignoreProcessing = true for local data files\nif (\nextension === \"js\" ||\nextension === \"cjs\" ||\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -46,6 +46,7 @@ class TemplateRender {\nreturn this._extensionMap;\n}\n+ // Runs once per template\ninit(engineNameOrPath) {\nthis.extensionMap.config = this.config;\nthis._engineName = this.extensionMap.getKey(engineNameOrPath);\n@@ -89,10 +90,10 @@ class TemplateRender {\nlet usingMarkdown = false;\n(engineName || \"\")\n.split(\",\")\n- .map(name => {\n+ .map((name) => {\nreturn name.toLowerCase().trim();\n})\n- .forEach(name => {\n+ .forEach((name) => {\n// html is assumed (treated as plaintext by the system)\nif (!name || name === \"html\") {\nreturn;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateEngineManagerTest.js",
"new_path": "test/TemplateEngineManagerTest.js",
"diff": "@@ -35,6 +35,39 @@ test(\"Supported custom engine\", async (t) => {\nt.is(await fn({ author: \"zach\" }), \"<p>This is plaintext</p>\");\n});\n+test(\"Custom engine with custom init\", async (t) => {\n+ let initCount = 0;\n+ let compileCount = 0;\n+ let tem = new TemplateEngineManager();\n+ tem.config = Object.assign({}, config);\n+ tem.config.extensionMap.add({\n+ extension: \"custom1\",\n+ key: \"custom1\",\n+ init: async function () {\n+ // do custom things, but only once\n+ initCount++;\n+ },\n+ compile: function (str, inputPath) {\n+ compileCount++;\n+ return () => str;\n+ },\n+ });\n+\n+ t.truthy(tem.hasEngine(\"custom1\"));\n+ let engine = tem.getEngine(\"custom1\");\n+ let fn = await engine.compile(\"<p>This is plaintext</p>\");\n+ t.is(await fn({}), \"<p>This is plaintext</p>\");\n+\n+ let engine2 = tem.getEngine(\"custom1\");\n+ t.is(engine, engine2);\n+\n+ let fn2 = await engine2.compile(\"<p>This is plaintext</p>\");\n+ t.is(await fn2({}), \"<p>This is plaintext</p>\");\n+\n+ t.is(initCount, 1, \"Should have only run the init callback once\");\n+ t.is(compileCount, 2, \"Should have only run the compile callback twice\");\n+});\n+\ntest(\"Handlebars Helpers\", async (t) => {\nlet tem = new TemplateEngineManager();\nlet engine = tem.getEngine(\"hbs\");\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Test to make sure custom file extensions only init once. |
691 | 07.10.2020 21:41:49 | 21,600 | 8e3eb2cc12e6074cf4e1d3e852c85abec48fac19 | Add data overwride warning for data files | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -154,12 +154,12 @@ class TemplateData {\nlet paths = [\n`${dir}/**/*.json`, // covers .11tydata.json too\n`${dir}/**/*${this.config.jsDataFileSuffix}.cjs`,\n- `${dir}/**/*${this.config.jsDataFileSuffix}.js`\n+ `${dir}/**/*${this.config.jsDataFileSuffix}.js`,\n];\nif (this.hasUserDataExtensions()) {\nlet userPaths = this.getUserDataExtensions().map(\n- extension => `${dir}/**/*.${extension}` // covers .11tydata.{extension} too\n+ (extension) => `${dir}/**/*.${extension}` // covers .11tydata.{extension} too\n);\npaths = userPaths.concat(paths);\n}\n@@ -170,7 +170,7 @@ class TemplateData {\nasync getTemplateJavaScriptDataFileGlob() {\nlet dir = await this.getInputDir();\nreturn TemplatePath.addLeadingDotSlashArray([\n- `${dir}/**/*${this.config.jsDataFileSuffix}.js`\n+ `${dir}/**/*${this.config.jsDataFileSuffix}.js`,\n]);\n}\n@@ -206,7 +206,7 @@ class TemplateData {\nfsBench.before();\nlet paths = fastglob.sync(await this.getGlobalDataGlob(), {\ncaseSensitiveMatch: false,\n- dot: true\n+ dot: true,\n});\nfsBench.after();\n@@ -316,7 +316,7 @@ class TemplateData {\n}\n// Filter out files we know don't exist to avoid overhead for checking\n- localDataPaths = localDataPaths.filter(path => {\n+ localDataPaths = localDataPaths.filter((path) => {\nreturn this._fsExistsCache.exists(path);\n});\n@@ -324,10 +324,24 @@ class TemplateData {\nreturn localData;\n}\n+ let dataSource = {};\nfor (let path of localDataPaths) {\n// clean up data for template/directory data files only.\nlet dataForPath = await this.getDataValue(path, null, true);\nlet cleanedDataForPath = TemplateData.cleanupData(dataForPath);\n+\n+ for (const key in cleanedDataForPath) {\n+ if (dataSource.hasOwnProperty(key)) {\n+ debugWarn(\n+ \"Warning: '%s' from '%s' is in use. Overwriting with %s\",\n+ key,\n+ dataSource[key],\n+ path\n+ );\n+ }\n+ dataSource[key] = path;\n+ }\n+\nTemplateData.mergeDeep(this.config, localData, cleanedDataForPath);\n// debug(\"`combineLocalData` (iterating) for %o: %O\", path, localData);\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Add data overwride warning for data files |
699 | 22.10.2020 11:39:34 | 18,000 | e9181d3a00995f95e2f9eb0f30e8448f90921fe4 | Adds afterBuild/beforeBuild events, adds argument to beforeWatch event to pass in the files that changed. | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n\"dependencies\": {\n\"@11ty/dependency-tree\": \"^1.0.0\",\n- \"browser-sync\": \"^2.26.7\",\n+ \"browser-sync\": \"^2.26.13\",\n\"chalk\": \"^3.0.0\",\n\"chokidar\": \"^3.4.0\",\n\"debug\": \"^4.1.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -457,10 +457,10 @@ Arguments:\nreturn;\n}\n- this.config.events.emit(\"beforeWatch\");\n-\nthis.watchManager.setBuildRunning();\n+ this.config.events.emit(\"beforeWatch\", this.watchManager.getActiveQueue());\n+\n// reset and reload global configuration :O\nif (this.watchManager.hasQueuedFile(config.getLocalProjectConfigFile())) {\nthis.resetConfig();\n@@ -735,10 +735,13 @@ Arguments:\nEleventyErrorHandler.logger = this.logger;\n}\n+ this.config.events.emit(\"beforeBuild\");\n+\ntry {\nlet promise = this.writer.write();\nret = await promise;\n+ this.config.events.emit(\"afterBuild\");\n} catch (e) {\nEleventyErrorHandler.initialMessage(\n\"Problem writing Eleventy templates\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyWatch.js",
"new_path": "src/EleventyWatch.js",
"diff": "@@ -36,12 +36,25 @@ class EleventyWatch {\nreturn this.activeQueue[0];\n}\n+ /* Returns the changed files currently being operated on in the current `watch` build\n+ * Works with or without incremental (though in incremental only one file per time will be processed)\n+ */\n+ getActiveQueue() {\n+ if (!this.isActive) {\n+ return [];\n+ } else if (this.incremental) {\n+ return [this.activeQueue[0]];\n+ }\n+\n+ return this.activeQueue;\n+ }\n+\n_queueMatches(file) {\nlet filterCallback;\nif (typeof file === \"function\") {\nfilterCallback = file;\n} else {\n- filterCallback = path => path === file;\n+ filterCallback = (path) => path === file;\n}\nreturn this.activeQueue.filter(filterCallback);\n@@ -80,6 +93,10 @@ class EleventyWatch {\nreturn this.pendingQueue.length;\n}\n+ getPendingQueue() {\n+ return this.pendingQueue;\n+ }\n+\ngetActiveQueueSize() {\nreturn this.activeQueue.length;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -74,6 +74,8 @@ class UserConfig {\n}\n}\n+ // Duplicate event bindings are avoided with the `reset` method above.\n+ // A new EventEmitter instance is created when the config is reset.\non(eventName, callback) {\nreturn this.events.on(eventName, callback);\n}\n@@ -325,7 +327,9 @@ class UserConfig {\n_normalizeTemplateFormats(templateFormats) {\nif (typeof templateFormats === \"string\") {\n- templateFormats = templateFormats.split(\",\").map(format => format.trim());\n+ templateFormats = templateFormats\n+ .split(\",\")\n+ .map((format) => format.trim());\n}\nreturn templateFormats;\n}\n@@ -629,7 +633,7 @@ class UserConfig {\nObject.assign(\n{\nkey: fileExtension,\n- extension: fileExtension\n+ extension: fileExtension,\n},\noptions\n)\n@@ -680,7 +684,7 @@ class UserConfig {\ndataExtensions: this.dataExtensions,\nextensionMap: this.extensionMap,\nquietMode: this.quietMode,\n- events: this.events\n+ events: this.events,\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyWatchTest.js",
"new_path": "test/EleventyWatchTest.js",
"diff": "import test from \"ava\";\nimport EleventyWatch from \"../src/EleventyWatch\";\n-test(\"Standard\", t => {\n+test(\"Standard\", (t) => {\nlet watch = new EleventyWatch();\nt.is(watch.isBuildRunning(), false);\n@@ -12,132 +12,157 @@ test(\"Standard\", t => {\nt.is(watch.isBuildRunning(), false);\n});\n-test(\"Incremental\", t => {\n+test(\"Incremental\", (t) => {\nlet watch = new EleventyWatch();\nt.is(watch.getIncrementalFile(), false);\nwatch.incremental = true;\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.addToPendingQueue(\"test.md\");\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), \"./test.md\");\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\n+ t.deepEqual(watch.getPendingQueue(), []);\n});\n-test(\"Incremental queue 2\", t => {\n+test(\"Incremental queue 2\", (t) => {\nlet watch = new EleventyWatch();\nt.is(watch.getIncrementalFile(), false);\nwatch.incremental = true;\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.addToPendingQueue(\"test.md\");\nwatch.addToPendingQueue(\"test2.md\");\nt.is(watch.getPendingQueueSize(), 2);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), \"./test.md\");\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getPendingQueue(), [\"./test2.md\"]);\n+ t.deepEqual(watch.getActiveQueue(), []);\n});\n-test(\"Incremental add while active\", t => {\n+test(\"Incremental add while active\", (t) => {\nlet watch = new EleventyWatch();\nt.is(watch.getIncrementalFile(), false);\nwatch.incremental = true;\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.addToPendingQueue(\"test.md\");\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), \"./test.md\");\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.addToPendingQueue(\"test2.md\");\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), \"./test.md\");\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getPendingQueue(), [\"./test2.md\"]);\n+ t.deepEqual(watch.getActiveQueue(), []);\n});\n-test(\"Non-incremental\", t => {\n+test(\"Non-incremental\", (t) => {\nlet watch = new EleventyWatch();\nt.is(watch.getIncrementalFile(), false);\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.addToPendingQueue(\"test.md\");\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\n});\n-test(\"Non-incremental queue 2\", t => {\n+test(\"Non-incremental queue 2\", (t) => {\nlet watch = new EleventyWatch();\nt.is(watch.getIncrementalFile(), false);\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.addToPendingQueue(\"test.md\");\nwatch.addToPendingQueue(\"test2.md\");\nt.is(watch.getPendingQueueSize(), 2);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 2);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\", \"./test2.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getPendingQueue(), []);\n+ t.deepEqual(watch.getActiveQueue(), []);\n});\n-test(\"Non-incremental add while active\", t => {\n+test(\"Non-incremental add while active\", (t) => {\nlet watch = new EleventyWatch();\nt.is(watch.getIncrementalFile(), false);\n@@ -148,42 +173,47 @@ test(\"Non-incremental add while active\", t => {\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), []);\nwatch.setBuildRunning();\nt.is(watch.getPendingQueueSize(), 0);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.addToPendingQueue(\"test.md\");\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 1);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getActiveQueue(), [\"./test.md\"]);\nwatch.setBuildFinished();\nt.is(watch.getPendingQueueSize(), 1);\nt.is(watch.getActiveQueueSize(), 0);\nt.is(watch.getIncrementalFile(), false);\n+ t.deepEqual(watch.getPendingQueue(), [\"./test.md\"]);\n+ t.deepEqual(watch.getActiveQueue(), []);\n});\n-test(\"Active queue tests\", t => {\n+test(\"Active queue tests\", (t) => {\nlet watch = new EleventyWatch();\nwatch.addToPendingQueue(\"test.md\");\nwatch.addToPendingQueue(\"test2.md\");\nwatch.addToPendingQueue(\"test.css\");\nt.is(\n- watch.hasAllQueueFiles(path => path.startsWith(\"./test\")),\n+ watch.hasAllQueueFiles((path) => path.startsWith(\"./test\")),\nfalse\n);\nwatch.setBuildRunning();\nt.is(watch.hasAllQueueFiles(\"slkdjflkjsdlkfj\"), false);\nt.is(\n- watch.hasAllQueueFiles(path => path.startsWith(\"./test\")),\n+ watch.hasAllQueueFiles((path) => path.startsWith(\"./test\")),\ntrue\n);\nt.is(\n- watch.hasAllQueueFiles(path => path.endsWith(\".css\")),\n+ watch.hasAllQueueFiles((path) => path.endsWith(\".css\")),\nfalse\n);\n@@ -192,31 +222,31 @@ test(\"Active queue tests\", t => {\nwatch.setBuildFinished();\nt.is(\n- watch.hasAllQueueFiles(path => path.startsWith(\"./test\")),\n+ watch.hasAllQueueFiles((path) => path.startsWith(\"./test\")),\nfalse\n);\n});\n-test(\"Active queue tests, all CSS files\", t => {\n+test(\"Active queue tests, all CSS files\", (t) => {\nlet watch = new EleventyWatch();\nwatch.addToPendingQueue(\"test.css\");\nwatch.addToPendingQueue(\"test2.css\");\nwatch.addToPendingQueue(\"test3.css\");\nt.is(\n- watch.hasAllQueueFiles(path => path.endsWith(\".css\")),\n+ watch.hasAllQueueFiles((path) => path.endsWith(\".css\")),\nfalse\n);\nwatch.setBuildRunning();\nt.is(\n- watch.hasAllQueueFiles(path => path.endsWith(\".css\")),\n+ watch.hasAllQueueFiles((path) => path.endsWith(\".css\")),\ntrue\n);\nwatch.setBuildFinished();\nt.is(\n- watch.hasAllQueueFiles(path => path.endsWith(\".css\")),\n+ watch.hasAllQueueFiles((path) => path.endsWith(\".css\")),\nfalse\n);\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds afterBuild/beforeBuild events, adds argument to beforeWatch event to pass in the files that changed. |
699 | 25.10.2020 21:14:47 | 18,000 | 5480a04ea5698d24798373b292c8cd38141417b0 | Nunjucks aggressively cached include content, which is a problem when it might change | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -19,10 +19,12 @@ class Nunjucks extends TemplateEngine {\nthis.njkEnv =\nenv ||\nnew NunjucksLib.Environment(\n- new NunjucksLib.FileSystemLoader([\n- super.getIncludesDir(),\n- TemplatePath.getWorkingDir(),\n- ])\n+ new NunjucksLib.FileSystemLoader(\n+ [super.getIncludesDir(), TemplatePath.getWorkingDir()],\n+ {\n+ noCache: true,\n+ }\n+ )\n);\nthis.setEngineLib(this.njkEnv);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "const test = require(\"ava\");\nconst fs = require(\"fs-extra\");\n+const fsp = require(\"fs\").promises;\nconst pretty = require(\"pretty\");\nconst Template = require(\"../src/Template\");\nconst TemplateData = require(\"../src/TemplateData\");\n@@ -2037,3 +2038,55 @@ test(\"Engine Singletons\", async (t) => {\nt.deepEqual(tmpl1.engine, tmpl2.engine);\n});\n+\n+test(\"Make sure layout cache takes new changes during watch (nunjucks)\", async (t) => {\n+ await fsp.writeFile(\n+ \"./test/stubs-layout-cache/_includes/include-script-1.js\",\n+ `alert(\"hi\");`,\n+ { encoding: \"utf8\" }\n+ );\n+\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs-layout-cache/test.njk\",\n+ \"./test/stubs-layout-cache/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+\n+ t.is((await tmpl.render(data)).trim(), '<script>alert(\"hi\");</script>');\n+\n+ await fsp.writeFile(\n+ \"./test/stubs-layout-cache/_includes/include-script-1.js\",\n+ `alert(\"bye\");`,\n+ { encoding: \"utf8\" }\n+ );\n+\n+ t.is((await tmpl.render(data)).trim(), '<script>alert(\"bye\");</script>');\n+});\n+\n+test(\"Make sure layout cache takes new changes during watch (liquid)\", async (t) => {\n+ await fsp.writeFile(\n+ \"./test/stubs-layout-cache/_includes/include-script-2.js\",\n+ `alert(\"hi\");`,\n+ { encoding: \"utf8\" }\n+ );\n+\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs-layout-cache/test.liquid\",\n+ \"./test/stubs-layout-cache/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+\n+ t.is((await tmpl.render(data)).trim(), '<script>alert(\"hi\");</script>');\n+\n+ await fsp.writeFile(\n+ \"./test/stubs-layout-cache/_includes/include-script-2.js\",\n+ `alert(\"bye\");`,\n+ { encoding: \"utf8\" }\n+ );\n+\n+ t.is((await tmpl.render(data)).trim(), '<script>alert(\"bye\");</script>');\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-layout-cache/_includes/include-script-1.js",
"diff": "+alert(\"bye\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-layout-cache/_includes/include-script-2.js",
"diff": "+alert(\"bye\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-layout-cache/_includes/layout.liquid",
"diff": "+<script>{%- include include-script-2.js -%}</script>\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-layout-cache/_includes/layout.njk",
"diff": "+<script>{%- include \"include-script-1.js\" -%}</script>\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-layout-cache/test.liquid",
"diff": "+---\n+layout: \"layout.liquid\"\n+---\n+Content\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-layout-cache/test.njk",
"diff": "+---\n+layout: \"layout.njk\"\n+---\n+Content\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Nunjucks aggressively cached include content, which is a problem when it might change |
699 | 25.10.2020 22:10:19 | 18,000 | 92bf9ba112637eb50e03c9196bd7c85ead470260 | Remove generated scripts from stubs | [
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "@@ -16,3 +16,5 @@ api-docs/\n_site/\npackage-lock.json\n+\n+test/stubs-layout-cache/_includes/*.js\n\\ No newline at end of file\n"
},
{
"change_type": "DELETE",
"old_path": "test/stubs-layout-cache/_includes/include-script-1.js",
"new_path": null,
"diff": "-alert(\"bye\");\n"
},
{
"change_type": "DELETE",
"old_path": "test/stubs-layout-cache/_includes/include-script-2.js",
"new_path": null,
"diff": "-alert(\"bye\");\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Remove generated scripts from stubs |
699 | 25.10.2020 22:10:47 | 18,000 | e5cecac6d26205b73f8464d27daf0f32abeebde8 | Update dependencies, fixes again | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "]\n},\n\"devDependencies\": {\n- \"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.0.1\",\n- \"ava\": \"^3.12.1\",\n- \"husky\": \"^4.2.5\",\n+ \"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.0.4\",\n+ \"ava\": \"^3.13.0\",\n+ \"husky\": \"^4.3.0\",\n\"ink-docstrap\": \"1.3.2\",\n\"js-yaml\": \"^3.14.0\",\n- \"jsdoc\": \"3.6.5\",\n- \"lint-staged\": \"^10.3.0\",\n- \"markdown-it-emoji\": \"^1.4.0\",\n+ \"jsdoc\": \"3.6.6\",\n+ \"lint-staged\": \"^10.4.2\",\n+ \"markdown-it-emoji\": \"^2.0.0\",\n\"node-sass\": \"^4.14.1\",\n\"nyc\": \"^15.1.0\",\n- \"prettier\": \"^2.1.1\",\n+ \"prettier\": \"^2.1.2\",\n\"rimraf\": \"^3.0.2\",\n\"toml\": \"^3.0.0\",\n\"viperhtml\": \"^2.17.1\",\n},\n\"dependencies\": {\n\"@11ty/dependency-tree\": \"^1.0.0\",\n- \"browser-sync\": \"^2.26.12\",\n+ \"browser-sync\": \"^2.26.13\",\n\"chalk\": \"^4.1.0\",\n- \"chokidar\": \"^3.4.2\",\n- \"debug\": \"^4.1.1\",\n+ \"chokidar\": \"^3.4.3\",\n+ \"debug\": \"^4.2.0\",\n\"dependency-graph\": \"^0.9.0\",\n\"ejs\": \"^3.1.5\",\n\"fast-glob\": \"^3.2.4\",\n\"gray-matter\": \"^4.0.2\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.7.6\",\n- \"liquidjs\": \"^9.15.0\",\n+ \"liquidjs\": \"^9.16.1\",\n\"lodash\": \"^4.17.20\",\n\"luxon\": \"^1.25.0\",\n- \"markdown-it\": \"^11.0.0\",\n+ \"markdown-it\": \"^12.0.2\",\n\"minimist\": \"^1.2.5\",\n\"moo\": \"^0.5.1\",\n- \"multimatch\": \"^4.0.0\",\n+ \"multimatch\": \"^5.0.0\",\n\"mustache\": \"^4.0.1\",\n\"normalize-path\": \"^3.0.0\",\n\"nunjucks\": \"^3.2.2\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Update dependencies, fixes #669 again |
699 | 30.10.2020 14:08:36 | 18,000 | 71f5943f1fa826a2b6d589cc1f49676d23b88afe | Finally remove old `filters` (was renamed to transforms in Eleventy 0.3.3). Adds an error message if the `filters` key still exists in the configuration return object. Use the addTransform method instead.
Helps with
Fixes | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "const fs = require(\"fs-extra\");\n+const chalk = require(\"chalk\");\nconst parsePath = require(\"parse-filepath\");\nconst normalize = require(\"normalize-path\");\nconst lodashIsObject = require(\"lodash/isObject\");\n@@ -354,19 +355,45 @@ class Template extends TemplateContent {\n}\nasync runLinters(str, inputPath, outputPath) {\n- this.linters.forEach(function (linter) {\n+ for (let linter of this.linters) {\n// these can be asynchronous but no guarantee of order when they run\n- linter.call(this, str, inputPath, outputPath);\n- });\n+ linter.call(\n+ {\n+ inputPath,\n+ outputPath,\n+ },\n+ str,\n+ inputPath,\n+ outputPath\n+ );\n+ }\n}\n- addTransform(callback) {\n- this.transforms.push(callback);\n+ addTransform(name, callback) {\n+ this.transforms.push({\n+ name,\n+ callback,\n+ });\n}\n- async runTransforms(str, outputPath, inputPath) {\n+ // Warning: this argument list is the reverse of linters (inputPath then outputPath)\n+ async runTransforms(str, inputPath, outputPath) {\nfor (let transform of this.transforms) {\n- str = await transform.call(this, str, outputPath, inputPath);\n+ str = await transform.callback.call(\n+ {\n+ inputPath,\n+ outputPath,\n+ },\n+ str,\n+ outputPath\n+ );\n+ if (!str && this.isVerbose) {\n+ console.log(\n+ chalk.yellow(\n+ `Warning: Transform \\`${transform.name}\\` returned empty when writing ${outputPath} from ${inputPath}.`\n+ )\n+ );\n+ }\n}\nreturn str;\n@@ -618,7 +645,11 @@ class Template extends TemplateContent {\n}\nawait this.runLinters(content, page.inputPath, page.outputPath);\n- content = await this.runTransforms(content, page.outputPath); // pass in page.inputPath?\n+ content = await this.runTransforms(\n+ content,\n+ page.inputPath,\n+ page.outputPath\n+ );\nreturn content;\n}\n@@ -654,7 +685,7 @@ class Template extends TemplateContent {\ntmpl.config = this.config;\nfor (let transform of this.transforms) {\n- tmpl.addTransform(transform);\n+ tmpl.addTransform(transform.name, transform.callback);\n}\nfor (let linter of this.linters) {\ntmpl.addLinter(linter);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -100,6 +100,15 @@ class TemplateConfig {\n);\n}\n}\n+\n+ if (\n+ localConfig.filters !== undefined &&\n+ Object.keys(localConfig.filters).length\n+ ) {\n+ throw new EleventyConfigError(\n+ `The \\`filters\\` configuration option was renamed in Eleventy 0.3.3 and removed in Eleventy 1.0. Please use the \\`addTransform\\` configuration method instead. Read more: https://www.11ty.dev/docs/config/#transforms`\n+ );\n+ }\n} catch (err) {\nthrow new EleventyConfigError(\n`Error in your Eleventy config file '${path}'.` +\n@@ -117,7 +126,7 @@ class TemplateConfig {\n// remove special merge keys from object\nlet savedForSpecialMerge = {\n- templateFormatsAdded: eleventyConfigApiMergingObject.templateFormatsAdded\n+ templateFormatsAdded: eleventyConfigApiMergingObject.templateFormatsAdded,\n};\ndelete eleventyConfigApiMergingObject.templateFormatsAdded;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -139,10 +139,10 @@ class TemplateWriter {\n* return pretty(str, { ocd: true });\n* }\n*/\n- for (let transformName in this.config.filters) {\n- let transform = this.config.filters[transformName];\n+ for (let transformName in this.config.transforms) {\n+ let transform = this.config.transforms[transformName];\nif (typeof transform === \"function\") {\n- tmpl.addTransform(transform);\n+ tmpl.addTransform(transformName, transform);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -46,8 +46,7 @@ class UserConfig {\nthis.passthroughCopies = {};\nthis.layoutAliases = {};\nthis.linters = {};\n- // now named `transforms` in API\n- this.filters = {};\n+ this.transforms = {};\nthis.activeNamespace = \"\";\nthis.DateTime = DateTime;\nthis.dynamicPermalinks = true;\n@@ -239,10 +238,7 @@ class UserConfig {\naddTransform(name, callback) {\nname = this.getNamespacedName(name);\n- // these are now called transforms\n- // this naming is kept here for backwards compatibility\n- // TODO major version change\n- this.filters[name] = callback;\n+ this.transforms[name] = callback;\n}\naddLinter(name, callback) {\n@@ -655,7 +651,8 @@ class UserConfig {\nreturn {\ntemplateFormats: this.templateFormats,\ntemplateFormatsAdded: this.templateFormatsAdded,\n- filters: this.filters, // now called transforms\n+ // filters removed in 1.0 (use addTransform instead)\n+ transforms: this.transforms,\nlinters: this.linters,\nglobalData: this.globalData,\nlayoutAliases: this.layoutAliases,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/defaultConfig.js",
"new_path": "src/defaultConfig.js",
"diff": "@@ -52,8 +52,6 @@ module.exports = function (config) {\ndata: \"_data\",\noutput: \"_site\",\n},\n- // deprecated, use config.addTransform\n- filters: {},\n// deprecated, use config.addHandlebarsHelper\nhandlebarsHelpers: {},\n// deprecated, use config.addNunjucksFilter\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateConfigTest.js",
"new_path": "test/TemplateConfigTest.js",
"diff": "@@ -18,10 +18,10 @@ test(\"Template Config local config overrides base config\", async (t) => {\nt.truthy(Object.keys(cfg.handlebarsHelpers).length);\nt.truthy(Object.keys(cfg.nunjucksFilters).length);\n- t.is(Object.keys(cfg.filters).length, 1);\n+ t.is(Object.keys(cfg.transforms).length, 1);\nt.is(\n- cfg.filters.prettyHtml(\n+ cfg.transforms.prettyHtml(\n`<html><body><div></div></body></html>`,\n\"test.html\"\n),\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateMapTest.js",
"new_path": "test/TemplateMapTest.js",
"diff": "@@ -952,7 +952,7 @@ test(\"Test a transform with a layout (via templateMap)\", async (t) => {\nt.true(outputPath.endsWith(\"transform-layout/index.html\"));\n});\n- tmpl.addTransform(function (content, outputPath) {\n+ tmpl.addTransform(\"transformName\", function (content, outputPath) {\nt.is(content, \"<html><body>This is content.</body></html>\");\nt.true(outputPath.endsWith(\"transform-layout/index.html\"));\nreturn \"OVERRIDE BY A TRANSFORM\";\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -1173,7 +1173,7 @@ test(\"Test a transform\", async (t) => {\n\"./test/stubs/_site\"\n);\n- tmpl.addTransform(function (content, outputPath) {\n+ tmpl.addTransform(\"transformName\", function (content, outputPath) {\nt.true(outputPath.endsWith(\".html\"));\nreturn \"OVERRIDE BY A TRANSFORM\";\n});\n@@ -1192,7 +1192,7 @@ test.skip(\"Test a transform (does it have inputPath?)\", async (t) => {\n\"./test/stubs/_site\"\n);\n- tmpl.addTransform(function (content, outputPath, inputPath) {\n+ tmpl.addTransform(\"transformName\", function (content, outputPath, inputPath) {\nt.true(outputPath.endsWith(\".html\"));\nt.true(!!inputPath);\nreturn \"OVERRIDE BY A TRANSFORM\";\n@@ -1211,7 +1211,7 @@ test(\"Test a transform with pages\", async (t) => {\n\"./test/stubs/_site\"\n);\n- tmpl.addTransform(function (content, outputPath) {\n+ tmpl.addTransform(\"transformName\", function (content, outputPath) {\n// should run twice, one for each page\nt.true(content.length > 0);\nt.true(outputPath.endsWith(\".html\"));\n@@ -1231,7 +1231,7 @@ test(\"Test a transform with a layout\", async (t) => {\n\"./test/stubs-475/_site\"\n);\n- tmpl.addTransform(function (content, outputPath) {\n+ tmpl.addTransform(\"transformName\", function (content, outputPath) {\nt.is(content, \"<html><body>This is content.</body></html>\");\nt.true(outputPath.endsWith(\".html\"));\nreturn \"OVERRIDE BY A TRANSFORM\";\n@@ -1250,7 +1250,7 @@ test(\"Test a single asynchronous transform\", async (t) => {\n\"./test/stubs/_site\"\n);\n- tmpl.addTransform(async function (content, outputPath) {\n+ tmpl.addTransform(\"transformName\", async function (content, outputPath) {\nt.true(outputPath.endsWith(\"template/index.html\"));\nreturn new Promise((resolve, reject) => {\n@@ -1273,7 +1273,7 @@ test(\"Test multiple asynchronous transforms\", async (t) => {\n\"./test/stubs/_site\"\n);\n- tmpl.addTransform(async function (content, outputPath) {\n+ tmpl.addTransform(\"transformName\", async function (content, outputPath) {\nt.true(outputPath.endsWith(\"template/index.html\"));\nreturn new Promise((resolve, reject) => {\n@@ -1284,7 +1284,7 @@ test(\"Test multiple asynchronous transforms\", async (t) => {\n});\n// uppercase\n- tmpl.addTransform(async function (str, outputPath) {\n+ tmpl.addTransform(\"transformName\", async function (str, outputPath) {\nt.true(outputPath.endsWith(\"template/index.html\"));\nreturn new Promise((resolve, reject) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/config.js",
"new_path": "test/stubs/config.js",
"diff": "@@ -17,21 +17,21 @@ module.exports = function(config) {\npathPrefix: \"/testdir\",\nkeys: {\n- package: \"pkg2\"\n+ package: \"pkg2\",\n},\n- filters: {\n+ transforms: {\nprettyHtml: function (str, outputPath) {\nif (outputPath.split(\".\").pop() === \"html\") {\nreturn pretty(str, { ocd: true });\n} else {\nreturn str;\n}\n- }\n+ },\n},\nnunjucksFilters: {\n- testing: str => {\n+ testing: (str) => {\nreturn str;\n- }\n- }\n+ },\n+ },\n};\n};\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Finally remove old `filters` (was renamed to transforms in Eleventy 0.3.3). Adds an error message if the `filters` key still exists in the configuration return object. Use the addTransform method instead.
Helps with #1479.
Fixes #789. |
699 | 30.10.2020 20:10:07 | 18,000 | 082b461d0df216664cb7ad611580b55781cbf79e | Attempt to fix Windows path separator test breakage | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyServe.js",
"new_path": "src/EleventyServe.js",
"diff": "@@ -23,7 +23,8 @@ class EleventyServe {\nlet cfgPrefix = this.config.pathPrefix;\nif (cfgPrefix) {\n// add leading / (for browsersync), see #1454\n- return path.join(\"/\", cfgPrefix);\n+ // path.join uses \\\\ for Windows so we split and rejoin\n+ return path.join(\"/\", cfgPrefix).split(path.sep).join(\"/\");\n}\nreturn \"/\";\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Attempt to fix Windows path separator test breakage |
699 | 30.10.2020 20:31:13 | 18,000 | 045f666fa6ff9f22a60b3dd6a972d757b0481400 | Migrating away from Travis. GitHub actions seem to be working better/faster/more reliably here. | [
{
"change_type": "DELETE",
"old_path": ".travis.yml",
"new_path": null,
"diff": "-language: node_js\n-node_js:\n- - 10\n- - 12\n- - 14\n-before_script:\n- - npm install\n-script: npm run test\n-branches:\n- except:\n- - gh-pages\n-sudo: false\n-os:\n- - linux\n- - osx\n- - windows\n-env:\n- - YARN_GPG=no\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Migrating away from Travis. GitHub actions seem to be working better/faster/more reliably here. |
699 | 30.10.2020 20:32:21 | 18,000 | b85c60bf983ea926e40485464d459f1b2f33c0b1 | Remove travis reference on readme | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -14,7 +14,6 @@ Works with HTML, Markdown, Liquid, Nunjucks, Handlebars, Mustache, EJS, Haml, Pu\n- [11ty on npm](https://www.npmjs.com/org/11ty)\n- [11ty on GitHub](https://github.com/11ty)\n- Continuous Integration:\n- - [Travis CI](https://travis-ci.org/11ty/eleventy)\n- [GitHub Actions](https://github.com/11ty/eleventy/actions?query=workflow%3A.github%2Fworkflows%2Fci.yml)\n[](https://www.npmjs.com/package/@11ty/eleventy) [](https://github.com/11ty/eleventy/issues) [](https://github.com/prettier/prettier) [](https://www.npmjs.com/package/@11ty/eleventy)\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Remove travis reference on readme |
699 | 15.11.2020 10:06:37 | 21,600 | babea4443688ee786d9a207f2acb300cf5c4c2b5 | Refactor to use safer `listeners` method instead of this._events (confirmed node 10+) | [
{
"change_type": "MODIFY",
"old_path": "src/Util/AsyncEventEmitter.js",
"new_path": "src/Util/AsyncEventEmitter.js",
"diff": "@@ -4,18 +4,12 @@ const lodashIsEmpty = require(\"lodash/isEmpty\");\nclass AsyncEventEmitter extends EventEmitter {\nasync emit(type, ...args) {\n- const handler = lodashGet(this._events, type);\n- if (lodashIsEmpty(handler) && typeof handler !== \"function\") {\n+ let listeners = this.listeners(type);\n+ if (!listeners.length) {\nreturn;\n}\n- if (typeof handler === \"function\") {\n- await handler.apply(this, args);\n- } else {\n- await Promise.all(handler.map((h) => h.apply(this, args)));\n- }\n-\n- return true;\n+ return await Promise.all(listeners.map((h) => h.apply(this, args)));\n}\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Refactor to use safer `listeners` method instead of this._events (confirmed node 10+) |
699 | 15.11.2020 14:21:11 | 21,600 | 1f827301d0f3fc59da78e2bcadf53de403fcd948 | Readable file extension output | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyExtensionMap.js",
"new_path": "src/EleventyExtensionMap.js",
"diff": "@@ -170,6 +170,10 @@ class EleventyExtensionMap {\nreturn this._extensionToKeyMap;\n}\n+\n+ getReadableFileExtensions() {\n+ return Object.keys(this.extensionToKeyMap).join(\" \");\n+ }\n}\nmodule.exports = EleventyExtensionMap;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -52,7 +52,7 @@ class TemplateRender {\nthis._engineName = this.extensionMap.getKey(engineNameOrPath);\nif (!this._engineName) {\nthrow new TemplateRenderUnknownEngineError(\n- `Unknown engine for ${engineNameOrPath} (supported extensions: ${Object.keys(this.extensionMap.extensionToKeyMap).join(' ')})`\n+ `Unknown engine for ${engineNameOrPath} (supported extensions: ${this.extensionMap.getReadableFileExtensions()})`\n);\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Readable file extension output |
676 | 24.11.2020 13:35:56 | 28,800 | 3a005de2124677722643729fb8ea96a44368b5cc | Cleanup variables and scopes per review comments. | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -5,25 +5,17 @@ const EleventyErrorUtil = require(\"../EleventyErrorUtil\");\nconst EleventyBaseError = require(\"../EleventyBaseError\");\n/*\n- * HACKITYHACKHACKHACKHACK\n+ * This IFFE applies a monkey-patch to Nunjucks internals to cache\n+ * compiled templates and re-use them where possible. It's relatively\n+ * pessimistic (conservative) about cache clearing to ensure correctness.\n*/\n-let inc = ((i) => {\n- return () => {\n- return i++;\n- };\n-})(0);\n-let pathMap = new Map();\n-\n-let clearCache = (reason = \"\") => {\n- if (pathMap.size > 0) {\n- pathMap.clear();\n- }\n-};\n+(function () {\n+ let templateCache = new Map();\nlet clearAndWrap = (name, obj = NunjucksLib.Environment) => {\nlet orig = obj.prototype[name];\nobj.prototype[name] = function (...args) {\n- clearCache(name);\n+ templateCache.clear();\nreturn orig.call(this, ...args);\n};\n};\n@@ -31,50 +23,42 @@ let clearAndWrap = (name, obj = NunjucksLib.Environment) => {\nclearAndWrap(\"addExtension\");\nclearAndWrap(\"removeExtension\");\n-(function () {\n- // IFFE to prevent temp var leakage\nlet getKey = (obj) => {\n- let eids = obj.env.extensionsList.reduce((v, c) => {\n- return c.__id ? v + \" : \" + c.__id : v;\n- }, \"\");\n- let k =\n- `${obj.path || obj.tmplStr} :: ${obj.tmplStr.length} :: ` +\n- `${obj.env.asyncFilters.length} :: (${eids})`; /* +\n- (\n- (obj.env.extensionsList.length) ?\n- `${Object.keys(obj.env.extensions).join(\"|\")} :: (${eids})` :\n- \"\"\n- );\n- */\n- return k;\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- let tc = NunjucksLib.Template.prototype._compile;\n+\n+ let _compile = NunjucksLib.Template.prototype._compile;\nNunjucksLib.Template.prototype._compile = function (...args) {\n- // console.log(`NunjucksLib.Template.prototype._compile`);\n- if (!this.compiled && !this.tmplProps && pathMap.has(getKey(this))) {\n- let pathProps = pathMap.get(getKey(this));\n+ if (!this.compiled && !this.tmplProps && templateCache.has(getKey(this))) {\n+ let pathProps = templateCache.get(getKey(this));\nthis.blocks = pathProps.blocks;\nthis.rootRenderFunc = pathProps.rootRenderFunc;\nthis.compiled = true;\n} else {\n- tc.call(this, ...args);\n- pathMap.set(getKey(this), {\n+ _compile.call(this, ...args);\n+ templateCache.set(getKey(this), {\nblocks: this.blocks,\nrootRenderFunc: this.rootRenderFunc,\n});\n}\n};\n- let ae = NunjucksLib.Environment.prototype.addExtension;\n- NunjucksLib.Environment.prototype.addExtension = function (...args) {\n- let e = args[1];\n- e.__id = inc();\n- return ae.call(this, ...args);\n+ let extensionIdCounter = 0;\n+ let addExtension = NunjucksLib.Environment.prototype.addExtension;\n+ NunjucksLib.Environment.prototype.addExtension = function (name, ext) {\n+ ext.__id = extensionIdCounter++;\n+ return addExtension.call(this, name, ext);\n};\n})();\n-/*\n- * END HACKITYHACKHACKHACKHACK\n- */\nclass EleventyShortcodeError extends EleventyBaseError {}\n@@ -137,7 +121,7 @@ class Nunjucks extends TemplateEngine {\n);\n}\n- clearCache(\"addTag\");\n+ // clearCache();\nthis.njkEnv.addExtension(name, tagObj);\n}\n@@ -238,8 +222,7 @@ class Nunjucks extends TemplateEngine {\n};\n}\n- // Invalidate the caches.\n- clearCache(\"addShortcode\");\n+ // clearCache();\nthis.njkEnv.addExtension(shortcodeName, new ShortcodeFunction());\n}\n@@ -310,7 +293,7 @@ class Nunjucks extends TemplateEngine {\n};\n}\n- clearCache(\"addPairedShortcode\");\n+ // clearCache();\nthis.njkEnv.addExtension(shortcodeName, new PairedShortcodeFunction());\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Cleanup variables and scopes per review comments. |
676 | 26.11.2020 11:03:44 | 28,800 | e15ae7914c342a87e0b014c7ac32e4183666aa23 | Less aggressive cache invalidation for a small speedup. | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -12,17 +12,6 @@ const EleventyBaseError = require(\"../EleventyBaseError\");\n(function () {\nlet templateCache = new Map();\n- let clearAndWrap = (name, obj = NunjucksLib.Environment) => {\n- let orig = obj.prototype[name];\n- obj.prototype[name] = function (...args) {\n- templateCache.clear();\n- return orig.call(this, ...args);\n- };\n- };\n-\n- clearAndWrap(\"addExtension\");\n- clearAndWrap(\"removeExtension\");\n-\nlet getKey = (obj) => {\nreturn [\nobj.path || obj.tmplStr,\n@@ -58,7 +47,9 @@ const EleventyBaseError = require(\"../EleventyBaseError\");\nname,\next\n) {\n+ if (!(\"__id\" in ext)) {\next.__id = extensionIdCounter++;\n+ }\nreturn addExtension.call(this, name, ext);\n};\n})();\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Less aggressive cache invalidation for a small speedup. |
676 | 03.12.2020 10:35:40 | 28,800 | cce873d6cfde4da12392615705c4bde175dd0dc6 | Optmises the hottest loop inside Nunjucks for another 10-20%. | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -6,8 +6,7 @@ const EleventyBaseError = require(\"../EleventyBaseError\");\n/*\n* This IFFE applies a monkey-patch to Nunjucks internals to cache\n- * compiled templates and re-use them where possible. It's relatively\n- * pessimistic (conservative) about cache clearing to ensure correctness.\n+ * compiled templates and re-use them where possible.\n*/\n(function () {\nlet templateCache = new Map();\n@@ -52,6 +51,50 @@ const EleventyBaseError = require(\"../EleventyBaseError\");\n}\nreturn 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+ if (!obj.hasOwnProperty(id)) {\n+ obj = obj[id] = {};\n+ }\n+ id = parts[++i];\n+ }\n+ obj[id] = val;\n+ };\n})();\nclass EleventyShortcodeError extends EleventyBaseError {}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Optmises the hottest loop inside Nunjucks for another 10-20%. |
676 | 04.12.2020 15:09:03 | 28,800 | 8a47a0752fc91c2d76a7dd451e0da8d7b6e3b9de | Re-enables NJK's internal caching by invalidating caches on change. | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -18,6 +18,7 @@ const deleteRequireCache = require(\"./Util/DeleteRequireCache\");\nconst config = require(\"./Config\");\nconst bench = require(\"./BenchmarkManager\");\nconst debug = require(\"debug\")(\"Eleventy\");\n+const eventBus = require(\"./EventBus\");\n/**\n* @module 11ty/eleventy/Eleventy\n@@ -449,7 +450,7 @@ Arguments:\n* @param {String} changedFilePath - File that triggered a re-run (added or modified)\n*/\nasync _addFileToWatchQueue(changedFilePath) {\n- TemplateContent.deleteCached(changedFilePath);\n+ eventBus.emit(\"resourceModified\", changedFilePath);\nthis.watchManager.addToPendingQueue(changedFilePath);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -3,9 +3,10 @@ const TemplateEngine = require(\"./TemplateEngine\");\nconst TemplatePath = require(\"../TemplatePath\");\nconst EleventyErrorUtil = require(\"../EleventyErrorUtil\");\nconst EleventyBaseError = require(\"../EleventyBaseError\");\n+const eventBus = require(\"../EventBus\");\n/*\n- * This IFFE applies a monkey-patch to Nunjucks internals to cache\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@@ -24,6 +25,17 @@ const EleventyBaseError = require(\"../EleventyBaseError\");\n].join(\" :: \");\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(\"resourceModified\", evictByPath);\n+\nlet _compile = NunjucksLib.Template.prototype._compile;\nNunjucksLib.Template.prototype._compile = function _wrap_compile(...args) {\nif (!this.compiled && !this.tmplProps && templateCache.has(getKey(this))) {\n@@ -109,16 +121,17 @@ class Nunjucks extends TemplateEngine {\n}\nsetLibrary(env) {\n- this.njkEnv =\n- env ||\n- new NunjucksLib.Environment(\n- new NunjucksLib.FileSystemLoader(\n- [super.getIncludesDir(), TemplatePath.getWorkingDir()],\n- {\n- noCache: true,\n- }\n- )\n- );\n+ let fsLoader = new NunjucksLib.FileSystemLoader([\n+ super.getIncludesDir(),\n+ TemplatePath.getWorkingDir(),\n+ ]);\n+ this.njkEnv = env || new NunjucksLib.Environment(fsLoader);\n+ // Correct, but overbroad. Better would be to evict more granularly, but\n+ // resolution from paths isn't straightforward.\n+ eventBus.on(\"resourceModified\", (path) => {\n+ this.njkEnv.invalidateCache();\n+ });\n+\nthis.setEngineLib(this.njkEnv);\nthis.addFilters(this.config.nunjucksFilters);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/EventBus.js",
"diff": "+const EventEmitter = require(\"./Util/AsyncEventEmitter\");\n+const debug = require(\"debug\")(\"Eleventy:EventBus\");\n+\n+/**\n+ * @module 11ty/eleventy/EventBus\n+ */\n+\n+debug(\"Setting up global EventBus.\");\n+/**\n+ * Provides a global event bus that modules deep down in the stack can\n+ * subscribe to from a global singleton for decoupled pub/sub.\n+ * @type * {module:11ty/eleventy/Util/AsyncEventEmitter~AsyncEventEmitter}\n+ */\n+let bus = new EventEmitter();\n+bus.setMaxListeners(100);\n+\n+module.exports = bus;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -14,6 +14,7 @@ const config = require(\"./Config\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateContent\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateContent\");\nconst bench = require(\"./BenchmarkManager\").get(\"Aggregate\");\n+const eventBus = require(\"./EventBus\");\nclass TemplateContentFrontMatterError extends EleventyBaseError {}\nclass TemplateContentCompileError extends EleventyBaseError {}\n@@ -277,5 +278,8 @@ class TemplateContent {\nTemplateContent._inputCache = new Map();\nTemplateContent._compileEngineCache = new Map();\n+eventBus.on(\"resourceModified\", (path) => {\n+ TemplateContent.deleteCached(path);\n+});\nmodule.exports = TemplateContent;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -2049,11 +2049,9 @@ test(\"Engine Singletons\", async (t) => {\n});\ntest(\"Make sure layout cache takes new changes during watch (nunjucks)\", async (t) => {\n- await fsp.writeFile(\n- \"./test/stubs-layout-cache/_includes/include-script-1.js\",\n- `alert(\"hi\");`,\n- { encoding: \"utf8\" }\n- );\n+ let filePath = \"./test/stubs-layout-cache/_includes/include-script-1.js\";\n+\n+ await fsp.writeFile(filePath, `alert(\"hi\");`, { encoding: \"utf8\" });\nlet tmpl = getNewTemplate(\n\"./test/stubs-layout-cache/test.njk\",\n@@ -2065,13 +2063,23 @@ test(\"Make sure layout cache takes new changes during watch (nunjucks)\", async (\nt.is((await tmpl.render(data)).trim(), '<script>alert(\"hi\");</script>');\n- await fsp.writeFile(\n- \"./test/stubs-layout-cache/_includes/include-script-1.js\",\n- `alert(\"bye\");`,\n- { encoding: \"utf8\" }\n- );\n+ let eventBus = require(\"../src/EventBus\");\n+ let chokidar = require(\"chokidar\");\n+ let watcher = chokidar.watch(filePath, { interval: 10, persistent: true });\n+ watcher.on(\"change\", (path, stats) => {\n+ eventBus.emit(\"resourceModified\", path);\n+ });\n+\n+ await fsp.writeFile(filePath, `alert(\"bye\");`, { encoding: \"utf8\" });\n+\n+ // Give Chokidar time to see the change;\n+ await new Promise((res, rej) => {\n+ setTimeout(res, 200);\n+ });\nt.is((await tmpl.render(data)).trim(), '<script>alert(\"bye\");</script>');\n+\n+ await watcher.close();\n});\ntest(\"Make sure layout cache takes new changes during watch (liquid)\", async (t) => {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Re-enables NJK's internal caching by invalidating caches on change. |
699 | 05.02.2021 21:54:09 | 21,600 | 81f88151f9ccbda771f1c986133c74acedc20ebb | Adds --to=json command line option. Allows you to do more complex compilaton stuff programmatically without requiring any writes to the file system. | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -19,7 +19,15 @@ const EleventyErrorHandler = require(\"./src/EleventyErrorHandler\");\ntry {\nconst EleventyCommandCheckError = require(\"./src/EleventyCommandCheckError\");\nconst argv = require(\"minimist\")(process.argv.slice(2), {\n- string: [\"input\", \"output\", \"formats\", \"config\", \"pathprefix\", \"port\"],\n+ string: [\n+ \"input\",\n+ \"output\",\n+ \"formats\",\n+ \"config\",\n+ \"pathprefix\",\n+ \"port\",\n+ \"to\",\n+ ],\nboolean: [\n\"quiet\",\n\"version\",\n@@ -86,7 +94,19 @@ try {\n} else if (argv.watch) {\nelev.watch();\n} else {\n- elev.write();\n+ if (argv.to !== \"fs\" && argv.to !== \"json\") {\n+ throw new EleventyCommandCheckError(\n+ `Invalid --to value: ${argv.to}. Supported values: \\`fs\\` and \\`json\\`.`\n+ );\n+ }\n+\n+ let promise = elev.executeBuild(argv.to);\n+\n+ if (argv.to === \"json\") {\n+ promise.then((result) => {\n+ console.log(result);\n+ });\n+ }\n}\n})\n.catch(EleventyErrorHandler.fatal);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -214,18 +214,6 @@ class Eleventy {\nawait this.init();\n}\n- /**\n- * Marks the finish of a run of Eleventy.\n- *\n- * @method\n- */\n- finish() {\n- bench.finish();\n-\n- (this.logger || console).log(this.logFinished());\n- debug(\"Finished writing templates.\");\n- }\n-\n/**\n* Logs some statistics after a complete run of Eleventy.\n*\n@@ -743,6 +731,17 @@ Arguments:\nthis.logger = logger;\n}\n+ /**\n+ * Backwards compatibility method.\n+ *\n+ * @async\n+ * @method\n+ * @returns {Promise<{}>}\n+ */\n+ async write() {\n+ return this.executeBuild();\n+ }\n+\n/**\n* tbd.\n*\n@@ -750,7 +749,7 @@ Arguments:\n* @method\n* @returns {Promise<{}>} ret - tbd.\n*/\n- async write() {\n+ async executeBuild(to = \"fs\") {\nlet ret;\nif (this.logger) {\nEleventyErrorHandler.logger = this.logger;\n@@ -759,7 +758,16 @@ Arguments:\nawait this.config.events.emit(\"beforeBuild\");\ntry {\n- let promise = this.writer.write();\n+ let promise;\n+ if (to === \"fs\") {\n+ promise = this.writer.write();\n+ } else if (to === \"json\") {\n+ promise = this.writer.getJSON();\n+ } else {\n+ throw new Error(\n+ `Invalid argument for \\`Eleventy->executeBuild(${to})\\`, expected \"json\" or \"fs\".`\n+ );\n+ }\nret = await promise;\nawait this.config.events.emit(\"afterBuild\");\n@@ -772,7 +780,12 @@ Arguments:\nEleventyErrorHandler.fatal(e);\n}\n- this.finish();\n+ bench.finish();\n+\n+ if (to !== \"json\") {\n+ (this.logger || console).log(this.logFinished());\n+ }\n+ debug(\"Finished writing templates.\");\ndebug(`\nGetting frustrated? Have a suggestion/feature request/feedback?\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -653,10 +653,18 @@ class Template extends TemplateContent {\nreturn content;\n}\n- async writeMapEntry(mapEntry) {\n- await Promise.all(\n+ async generateMapEntry(mapEntry, to) {\n+ return Promise.all(\nmapEntry._pages.map(async (page) => {\nlet content = await this.renderPageEntry(mapEntry, page);\n+ if (to === \"json\") {\n+ return {\n+ url: page.url,\n+ inputPath: page.inputPath,\n+ content: content,\n+ };\n+ }\n+\nreturn this._write(page.outputPath, content);\n})\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -8,6 +8,7 @@ const EleventyErrorHandler = require(\"./EleventyErrorHandler\");\nconst EleventyErrorUtil = require(\"./EleventyErrorUtil\");\nconst config = require(\"./Config\");\n+const lodashFlatten = require(\"lodash/flatten\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateWriter\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:TemplateWriter\");\n@@ -181,12 +182,13 @@ class TemplateWriter {\nreturn this.templateMap;\n}\n- async _writeTemplate(mapEntry) {\n+ async _generateTemplate(mapEntry, to) {\nlet tmpl = mapEntry.template;\n- return tmpl.writeMapEntry(mapEntry).then(() => {\n+ return tmpl.generateMapEntry(mapEntry, to).then((pages) => {\nthis.skippedCount += tmpl.getSkippedCount();\nthis.writeCount += tmpl.getWriteCount();\n+ return pages;\n});\n}\n@@ -204,19 +206,19 @@ class TemplateWriter {\n});\n}\n- async writeTemplates(paths) {\n+ async generateTemplates(paths, to = \"fs\") {\nlet promises = [];\n- // console.time(\"writeTemplates:_createTemplateMap\");\n+ // console.time(\"generateTemplates:_createTemplateMap\");\n// TODO optimize await here\nawait this._createTemplateMap(paths);\n- // console.timeEnd(\"writeTemplates:_createTemplateMap\");\n+ // console.timeEnd(\"generateTemplates:_createTemplateMap\");\ndebug(\"Template map created.\");\nlet usedTemplateContentTooEarlyMap = [];\nfor (let mapEntry of this.templateMap.getMap()) {\npromises.push(\n- this._writeTemplate(mapEntry).catch(function (e) {\n+ this._generateTemplate(mapEntry, to).catch(function (e) {\n// Premature templateContent in layout render, this also happens in\n// TemplateMap.populateContentDataInMap for non-layout content\nif (EleventyErrorUtil.isPrematureTemplateContentError(e)) {\n@@ -235,7 +237,7 @@ class TemplateWriter {\nfor (let mapEntry of usedTemplateContentTooEarlyMap) {\npromises.push(\n- this._writeTemplate(mapEntry).catch(function (e) {\n+ this._generateTemplate(mapEntry, to).catch(function (e) {\nreturn Promise.reject(\nnew TemplateWriterWriteError(\n`Having trouble writing template (second pass): ${mapEntry.outputPath}`,\n@@ -261,7 +263,7 @@ class TemplateWriter {\n.getPassthroughManager()\n.isPassthroughCopyFile(paths, this.incrementalFile)\n) {\n- promises.push(...(await this.writeTemplates(paths)));\n+ promises.push(...(await this.generateTemplates(paths)));\n}\nreturn Promise.all(promises).catch((e) => {\n@@ -270,6 +272,22 @@ class TemplateWriter {\n});\n}\n+ // Passthrough copy not supported in JSON output.\n+ // --incremental not supported in JSON output.\n+ async getJSON() {\n+ let paths = await this._getAllPaths();\n+ let promises = await this.generateTemplates(paths, \"json\");\n+\n+ return Promise.all(promises)\n+ .then((results) => {\n+ return lodashFlatten(results); // switch to results.flat(1) with Node 12+\n+ })\n+ .catch((e) => {\n+ EleventyErrorHandler.error(e, \"Error generating templates\");\n+ throw e;\n+ });\n+ }\n+\nsetVerboseOutput(isVerbose) {\nthis.isVerbose = isVerbose;\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds --to=json command line option. Allows you to do more complex compilaton stuff programmatically without requiring any writes to the file system. |
699 | 05.02.2021 21:58:43 | 21,600 | 8eb901c2abef4a93dbba97e25a7b01305807c125 | A little cleanup for --to | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -94,18 +94,16 @@ try {\n} else if (argv.watch) {\nelev.watch();\n} else {\n- if (argv.to !== \"fs\" && argv.to !== \"json\") {\n- throw new EleventyCommandCheckError(\n- `Invalid --to value: ${argv.to}. Supported values: \\`fs\\` and \\`json\\`.`\n- );\n- }\n-\n- let promise = elev.executeBuild(argv.to);\n-\nif (argv.to === \"json\") {\n- promise.then((result) => {\n+ elev.toJSON().then((result) => {\nconsole.log(result);\n});\n+ } else if (!argv.to || argv.to === \"fs\") {\n+ elev.write();\n+ } else {\n+ throw new EleventyCommandCheckError(\n+ `Invalid --to value: ${argv.to}. Supported values: \\`fs\\` and \\`json\\`.`\n+ );\n}\n}\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -732,7 +732,7 @@ Arguments:\n}\n/**\n- * Backwards compatibility method.\n+ * Writes templates to the file system.\n*\n* @async\n* @method\n@@ -742,6 +742,17 @@ Arguments:\nreturn this.executeBuild();\n}\n+ /**\n+ * Renders templates to a JSON object.\n+ *\n+ * @async\n+ * @method\n+ * @returns {Promise<{}>}\n+ */\n+ async toJSON() {\n+ return this.executeBuild(\"json\");\n+ }\n+\n/**\n* tbd.\n*\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | A little cleanup for --to |
699 | 06.02.2021 15:13:33 | 21,600 | 103c117eba41a835c7d298c075f4f8ad9ec82c0b | Adds `ndjson` output. Makes sure that logged output is JSON compatible so that you can parse it from stdin | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -96,13 +96,15 @@ try {\n} else {\nif (argv.to === \"json\") {\nelev.toJSON().then((result) => {\n- console.log(result);\n+ console.log(JSON.stringify(result));\n});\n+ } else if (argv.to === \"ndjson\") {\n+ elev.toNDJSON();\n} else if (!argv.to || argv.to === \"fs\") {\nelev.write();\n} else {\nthrow new EleventyCommandCheckError(\n- `Invalid --to value: ${argv.to}. Supported values: \\`fs\\` and \\`json\\`.`\n+ `Invalid --to value: ${argv.to}. Supported values: \\`fs\\`, \\`json\\`, and \\`ndjson\\`.`\n);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -753,6 +753,17 @@ Arguments:\nreturn this.executeBuild(\"json\");\n}\n+ /**\n+ * Renders templates to an NDJSON object (newline delimited).\n+ *\n+ * @async\n+ * @method\n+ * @returns {Promise<{}>}\n+ */\n+ async toNDJSON() {\n+ return this.executeBuild(\"ndjson\");\n+ }\n+\n/**\n* tbd.\n*\n@@ -773,7 +784,9 @@ Arguments:\nif (to === \"fs\") {\npromise = this.writer.write();\n} else if (to === \"json\") {\n- promise = this.writer.getJSON();\n+ promise = this.writer.getJSON(\"json\");\n+ } else if (to === \"ndjson\") {\n+ promise = this.writer.getJSON(\"ndjson\");\n} else {\nthrow new Error(\n`Invalid argument for \\`Eleventy->executeBuild(${to})\\`, expected \"json\" or \"fs\".`\n@@ -793,7 +806,7 @@ Arguments:\nbench.finish();\n- if (to !== \"json\") {\n+ if (to === \"fs\") {\n(this.logger || console).log(this.logFinished());\n}\ndebug(\"Finished writing templates.\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -657,12 +657,19 @@ class Template extends TemplateContent {\nreturn Promise.all(\nmapEntry._pages.map(async (page) => {\nlet content = await this.renderPageEntry(mapEntry, page);\n- if (to === \"json\") {\n- return {\n+ if (to === \"json\" || to === \"ndjson\") {\n+ let obj = {\nurl: page.url,\ninputPath: page.inputPath,\ncontent: content,\n};\n+\n+ if (to === \"ndjson\") {\n+ console.log(JSON.stringify(obj));\n+ }\n+\n+ // json\n+ return obj;\n}\nreturn this._write(page.outputPath, content);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -274,9 +274,9 @@ class TemplateWriter {\n// Passthrough copy not supported in JSON output.\n// --incremental not supported in JSON output.\n- async getJSON() {\n+ async getJSON(to = \"json\") {\nlet paths = await this._getAllPaths();\n- let promises = await this.generateTemplates(paths, \"json\");\n+ let promises = await this.generateTemplates(paths, to);\nreturn Promise.all(promises)\n.then((results) => {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds `ndjson` output. Makes sure that logged output is JSON compatible so that you can parse it from stdin |
699 | 07.02.2021 14:29:21 | 21,600 | cf4342acabed4de9069e314add0328ccae16feb3 | Try to make the benchmarking test a bit more resilient on GitHub actions | [
{
"change_type": "MODIFY",
"old_path": "test/BenchmarkTest.js",
"new_path": "test/BenchmarkTest.js",
"diff": "@@ -11,9 +11,9 @@ test.cb(\"Standard Benchmark\", (t) => {\nb.before();\nsetTimeout(function () {\nb.after();\n- t.truthy(b.getTotal() >= 10);\n+ t.truthy(b.getTotal() >= 0);\nt.end();\n- }, 10);\n+ }, 100);\n});\ntest.cb(\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Try to make the benchmarking test a bit more resilient on GitHub actions |
699 | 08.02.2021 19:55:59 | 21,600 | fd37bcae002969d6ba40a342a35c722efb0e5661 | Use new ConsoleLogger and EleventyErrorHandler classes (not gross static things) to handle output. | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -71,6 +71,11 @@ try {\nquietMode: argv.quiet,\n});\n+ if (argv.to === \"json\" || argv.to === \"ndjson\") {\n+ // override logging output\n+ elev.setIsVerbose(false);\n+ }\n+\nelev.setConfigPathOverride(argv.config);\nelev.setPathPrefix(argv.pathprefix);\nelev.setDryRun(argv.dryrun);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/BenchmarkGroup.js",
"new_path": "src/BenchmarkGroup.js",
"diff": "-const chalk = require(\"chalk\");\n-\n+const ConsoleLogger = require(\"./Util/ConsoleLogger\");\nconst Benchmark = require(\"./Benchmark\");\nconst debugBenchmark = require(\"debug\")(\"Eleventy:Benchmark\");\n@@ -8,12 +7,14 @@ class BenchmarkGroup {\nthis.benchmarks = {};\n// Warning: aggregate benchmarks automatically default to false via BenchmarkManager->getBenchmarkGroup\nthis.isVerbose = true;\n+ this.logger = new ConsoleLogger(this.isVerbose);\nthis.minimumThresholdMs = 0;\nthis.minimumThresholdPercent = 8;\n}\nsetIsVerbose(isVerbose) {\nthis.isVerbose = isVerbose;\n+ this.logger.isVerbose = isVerbose;\n}\nreset() {\n@@ -91,20 +92,16 @@ class BenchmarkGroup {\n);\n}\n- let str = chalk.yellow(\n- `Benchmark (${label}): ${type} took ${totalForBenchmark.toFixed(0)}ms ${\n- extraOutput.length ? `(${extraOutput.join(\", \")})` : \"\"\n- }`\n- );\n+ let str = `Benchmark (${label}): ${type} took ${totalForBenchmark.toFixed(\n+ 0\n+ )}ms ${extraOutput.length ? `(${extraOutput.join(\", \")})` : \"\"}`;\nif (\n(isAbsoluteMinimumComparison &&\ntotalForBenchmark >= this.minimumThresholdMs) ||\npercent > this.minimumThresholdPercent\n) {\n- if (this.isVerbose) {\n- console.log(str);\n- }\n+ this.logger.warn(str);\n}\nif (totalForBenchmark.toFixed(0) > 0) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -148,7 +148,6 @@ class Nunjucks extends TemplateEngine {\n});\n} else {\ntry {\n- // console.log( shortcodeFn.toString() );\nreturn new NunjucksLib.runtime.SafeString(\nshortcodeFn.call(\nNunjucks._normalizeShortcodeContext(context),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "const fs = require(\"fs-extra\");\n-const chalk = require(\"chalk\");\nconst parsePath = require(\"parse-filepath\");\nconst normalize = require(\"normalize-path\");\nconst lodashIsObject = require(\"lodash/isObject\");\n@@ -15,6 +14,7 @@ const TemplateFileSlug = require(\"./TemplateFileSlug\");\nconst ComputedData = require(\"./ComputedData\");\nconst Pagination = require(\"./Plugins/Pagination\");\nconst TemplateContentPrematureUseError = require(\"./Errors/TemplateContentPrematureUseError\");\n+const ConsoleLogger = require(\"./Util/ConsoleLogger\");\nconst debug = require(\"debug\")(\"Eleventy:Template\");\nconst debugDev = require(\"debug\")(\"Dev:Eleventy:Template\");\n@@ -61,8 +61,17 @@ class Template extends TemplateContent {\nthis.filePathStem = this.fileSlug.getFullPathWithoutExtension();\n}\n+ get logger() {\n+ if (!this._logger) {\n+ this._logger = new ConsoleLogger();\n+ this._logger.isVerbose = this.isVerbose;\n+ }\n+ return this._logger;\n+ }\n+\nsetIsVerbose(isVerbose) {\nthis.isVerbose = isVerbose;\n+ this.logger.isVerbose = isVerbose;\n}\nsetDryRun(isDryRun) {\n@@ -387,11 +396,9 @@ class Template extends TemplateContent {\nstr,\noutputPath\n);\n- if (!str && this.isVerbose) {\n- console.log(\n- chalk.yellow(\n+ if (!str) {\n+ this.logger.warn(\n`Warning: Transform \\`${transform.name}\\` returned empty when writing ${outputPath} from ${inputPath}.`\n- )\n);\n}\n}\n@@ -610,15 +617,11 @@ class Template extends TemplateContent {\n}\nlet engineList = this.templateRender.getReadableEnginesListDifferingFromFileExtension();\n- if (this.isVerbose) {\n- console.log(\n+ this.logger.log(\n`${lang.start} ${outputPath} from ${this.inputPath}${\nengineList ? ` (${engineList})` : \"\"\n}`\n);\n- } else {\n- debug(`${lang.start} %o from %o.`, outputPath, this.inputPath);\n- }\nif (!shouldWriteFile) {\nthis.skippedCount++;\n@@ -665,7 +668,9 @@ class Template extends TemplateContent {\n};\nif (to === \"ndjson\") {\n- console.log(JSON.stringify(obj));\n+ let jsonString = JSON.stringify(obj);\n+ console.log(jsonString);\n+ return jsonString;\n}\n// json\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -54,6 +54,16 @@ class TemplateWriter {\nthis._templateFormats = value;\n}\n+ /* Getter for error handler */\n+ get errorHandler() {\n+ if (!this._errorHandler) {\n+ this._errorHandler = new EleventyErrorHandler();\n+ this._errorHandler.isVerbose = this.verboseMode;\n+ }\n+\n+ return this._errorHandler;\n+ }\n+\n/* For testing */\noverrideConfig(config) {\nthis.config = config;\n@@ -199,7 +209,7 @@ class TemplateWriter {\n}\nreturn passthroughManager.copyAll(paths).catch((e) => {\n- EleventyErrorHandler.warn(e, \"Error with passthrough copy\");\n+ this.errorHandler.warn(e, \"Error with passthrough copy\");\nreturn Promise.reject(\nnew TemplateWriterWriteError(\"Having trouble copying\", e)\n);\n@@ -267,7 +277,7 @@ class TemplateWriter {\n}\nreturn Promise.all(promises).catch((e) => {\n- EleventyErrorHandler.error(e, \"Error writing templates\");\n+ this.errorHandler.error(e, \"Error writing templates\");\nthrow e;\n});\n}\n@@ -280,16 +290,18 @@ class TemplateWriter {\nreturn Promise.all(promises)\n.then((results) => {\n- return lodashFlatten(results); // switch to results.flat(1) with Node 12+\n+ let flat = lodashFlatten(results); // switch to results.flat(1) with Node 12+\n+ return flat;\n})\n.catch((e) => {\n- EleventyErrorHandler.error(e, \"Error generating templates\");\n+ this.errorHandler.error(e, \"Error generating templates\");\nthrow e;\n});\n}\nsetVerboseOutput(isVerbose) {\nthis.isVerbose = isVerbose;\n+ this.errorHandler.isVerbose = isVerbose;\n}\nsetDryRun(isDryRun) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Util/ConsoleLogger.js",
"diff": "+const chalk = require(\"chalk\");\n+const debug = require(\"debug\")(\"Eleventy:Logger\");\n+\n+class ConsoleLogger {\n+ constructor() {\n+ this._isVerbose = true;\n+ }\n+\n+ get isVerbose() {\n+ return this._isVerbose;\n+ }\n+\n+ set isVerbose(verbose) {\n+ this._isVerbose = !!verbose;\n+ }\n+\n+ get isChalkEnabled() {\n+ if (this._isChalkEnabled !== undefined) {\n+ return this._isChalkEnabled;\n+ }\n+ return true;\n+ }\n+\n+ set isChalkEnabled(enabled) {\n+ this._isChalkEnabled = !!enabled;\n+ }\n+\n+ overrideLogger(logger) {\n+ this._logger = logger;\n+ }\n+\n+ warn(msg) {\n+ this.message(msg, \"warn\", \"yellow\");\n+ }\n+\n+ error(msg) {\n+ this.message(msg, \"error\", \"red\");\n+ }\n+\n+ log(msg) {\n+ this.message(msg);\n+ }\n+\n+ message(message, type = \"log\", chalkColor = false) {\n+ if (!this.isVerbose || process.env.DEBUG) {\n+ debug(message);\n+ } else if (this._logger !== false) {\n+ let logger = this._logger || console;\n+ if (chalkColor && this.isChalkEnabled) {\n+ logger[type](chalk[chalkColor](message));\n+ } else {\n+ logger[type](message);\n+ }\n+ }\n+ }\n+}\n+\n+module.exports = ConsoleLogger;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/ConsoleLoggerTest.js",
"diff": "+const test = require(\"ava\");\n+const ConsoleLogger = require(\"../src/Util/ConsoleLogger\");\n+\n+test(\"Disable chalk\", (t) => {\n+ ConsoleLogger.isChalkEnabled = false;\n+ t.is(ConsoleLogger.isChalkEnabled, false);\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -128,14 +128,7 @@ test(\"Eleventy set input/output, one file input exitCode\", async (t) => {\n\"./test/stubs/exitCode/failure.njk\",\n\"./test/stubs/exitCode/_site\"\n);\n-\n- // TODO make this output quieter\n- elev.setLogger({\n- log: function () {},\n- warn: function () {},\n- error: function () {},\n- });\n-\n+ elev.setIsVerbose(false);\nawait elev.init();\nawait elev.write();\n@@ -143,3 +136,60 @@ test(\"Eleventy set input/output, one file input exitCode\", async (t) => {\nprocess.exitCode = previousExitCode;\n});\n+\n+test(\"Eleventy to json\", async (t) => {\n+ let elev = new Eleventy(\"./test/stubs--to/\", \"./test/stubs--to/_site\");\n+ await elev.init();\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+ 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+ content: \"hello\",\n+ },\n+ ]\n+ );\n+});\n+\n+test(\"Eleventy to ndjson\", async (t) => {\n+ let elev = new Eleventy(\"./test/stubs--to/\", \"./test/stubs--to/_site\");\n+\n+ elev.setIsVerbose(false);\n+\n+ await elev.init();\n+ let results = await elev.toNDJSON();\n+ let parsed = results.split(\"\\n\").map((entry) => JSON.parse(entry));\n+ t.deepEqual(\n+ parsed.filter((entry) => entry.url === \"/test/\"),\n+ [\n+ {\n+ url: \"/test/\",\n+ inputPath: \"./test/stubs--to/test.md\",\n+ content: \"<h1>hi</h1>\\n\",\n+ },\n+ ]\n+ );\n+ t.deepEqual(\n+ parsed.filter((entry) => entry.url === \"/test2/\"),\n+ [\n+ {\n+ url: \"/test2/\",\n+ inputPath: \"./test/stubs--to/test2.liquid\",\n+ content: \"hello\",\n+ },\n+ ]\n+ );\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/UserDataExtensionsTest.js",
"new_path": "test/UserDataExtensionsTest.js",
"diff": "@@ -27,7 +27,6 @@ test(\"Local data\", async (t) => {\nlet withLocalData = await dataObj.getLocalData(\n\"./test/stubs-630/component-yaml/component.njk\"\n);\n- // console.log(\"localdata\", withLocalData);\nt.is(withLocalData.yamlKey1, \"yaml1\");\nt.is(withLocalData.yamlKey2, \"yaml2\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs--to/test.md",
"diff": "+# hi\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs--to/test2.liquid",
"diff": "+---\n+hi: hello\n+---\n+{{ hi }}\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Use new ConsoleLogger and EleventyErrorHandler classes (not gross static things) to handle output. |
699 | 08.02.2021 19:56:26 | 21,600 | a1e6a7551a7bb52556f6ee14935b5ce25e12ba03 | Removes addExtension warning from console output. | [
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -645,12 +645,6 @@ class UserConfig {\nreturn;\n}\n- console.log(\n- chalk.yellow(\n- \"Warning: Configuration API `addExtension` is an experimental Eleventy feature with an unstable API. Be careful!\"\n- )\n- );\n-\nthis.extensionMap.add(\nObject.assign(\n{\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Removes addExtension warning from console output. |
699 | 08.02.2021 19:58:49 | 21,600 | fbe31abead7641ebde466978337bd6ea941c01a7 | More resilient benchmark tests for GitHub actions failures | [
{
"change_type": "MODIFY",
"old_path": "test/BenchmarkTest.js",
"new_path": "test/BenchmarkTest.js",
"diff": "@@ -30,7 +30,7 @@ test.cb(\nb.after();\nt.truthy(b.getTotal() >= 10);\nt.end();\n- }, 10);\n+ }, 100);\n}\n);\n@@ -49,5 +49,5 @@ test.cb(\"Reset Benchmark\", (t) => {\nb.after();\n});\nt.end();\n- }, 10);\n+ }, 100);\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | More resilient benchmark tests for GitHub actions failures |
699 | 08.02.2021 20:13:46 | 21,600 | a349edd49f3c512d673458089dfdb8005e2b03fa | Share the same logger instance, if possible. | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -305,7 +305,7 @@ class Eleventy {\nthis.templateData,\nthis.isPassthroughAll\n);\n-\n+ this.writer.logger = this.logger;\nthis.writer.extensionMap = this.extensionMap;\nthis.writer.setEleventyFiles(this.eleventyFiles);\n@@ -350,7 +350,7 @@ Verbose Output: ${this.verboseMode}`);\nreturn this._isVerboseMode;\n}\n- /* Getter for logger */\n+ /* Getter for Logger */\nget logger() {\nif (!this._logger) {\nthis._logger = new ConsoleLogger();\n@@ -360,11 +360,17 @@ Verbose Output: ${this.verboseMode}`);\nreturn this._logger;\n}\n+ /* Setter for Logger */\n+ set logger(logger) {\n+ this._logger = logger;\n+ }\n+\n/* Getter for error handler */\nget errorHandler() {\nif (!this._errorHandler) {\nthis._errorHandler = new EleventyErrorHandler();\nthis._errorHandler.isVerbose = this.verboseMode;\n+ this._errorHandler.logger = this.logger;\n}\nreturn this._errorHandler;\n@@ -750,16 +756,6 @@ Arguments:\nthis.eleventyServe.serve(port);\n}\n- /* For testing */\n- /**\n- * Updates the logger.\n- *\n- * @param {} logger - The new logger.\n- */\n- setLogger(logger) {\n- this.logger = logger;\n- }\n-\n/**\n* Writes templates to the file system.\n*\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -69,6 +69,11 @@ class Template extends TemplateContent {\nreturn this._logger;\n}\n+ /* Setter for Logger */\n+ set logger(logger) {\n+ this._logger = logger;\n+ }\n+\nsetIsVerbose(isVerbose) {\nthis.isVerbose = isVerbose;\nthis.logger.isVerbose = isVerbose;\n@@ -669,7 +674,7 @@ class Template extends TemplateContent {\nif (to === \"ndjson\") {\nlet jsonString = JSON.stringify(obj);\n- console.log(jsonString);\n+ this.logger.stdout(jsonString);\nreturn jsonString;\n}\n@@ -692,6 +697,7 @@ class Template extends TemplateContent {\nthis.extensionMap\n);\ntmpl.config = this.config;\n+ tmpl.logger = this.logger;\nfor (let transform of this.transforms) {\ntmpl.addTransform(transform.name, transform.callback);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -6,6 +6,7 @@ const EleventyExtensionMap = require(\"./EleventyExtensionMap\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\nconst EleventyErrorHandler = require(\"./EleventyErrorHandler\");\nconst EleventyErrorUtil = require(\"./EleventyErrorUtil\");\n+const ConsoleLogger = require(\"./Util/ConsoleLogger\");\nconst config = require(\"./Config\");\nconst lodashFlatten = require(\"lodash/flatten\");\n@@ -59,11 +60,27 @@ class TemplateWriter {\nif (!this._errorHandler) {\nthis._errorHandler = new EleventyErrorHandler();\nthis._errorHandler.isVerbose = this.verboseMode;\n+ this._errorHandler.logger = this.logger;\n}\nreturn this._errorHandler;\n}\n+ /* Getter for Logger */\n+ get logger() {\n+ if (!this._logger) {\n+ this._logger = new ConsoleLogger();\n+ this._logger.isVerbose = this.verboseMode;\n+ }\n+\n+ return this._logger;\n+ }\n+\n+ /* Setter for Logger */\n+ set logger(logger) {\n+ this._logger = logger;\n+ }\n+\n/* For testing */\noverrideConfig(config) {\nthis.config = config;\n@@ -133,6 +150,7 @@ class TemplateWriter {\nthis.templateData,\nthis.extensionMap\n);\n+ tmpl.logger = this.logger;\nthis._templatePathCache.set(path, tmpl);\ntmpl.setIsVerbose(this.isVerbose);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Util/ConsoleLogger.js",
"new_path": "src/Util/ConsoleLogger.js",
"diff": "@@ -41,6 +41,10 @@ class ConsoleLogger {\nthis.message(msg);\n}\n+ stdout(msg) {\n+ console.log(msg);\n+ }\n+\nmessage(message, type = \"log\", chalkColor = false) {\nif (!this.isVerbose || process.env.DEBUG) {\ndebug(message);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -139,7 +139,10 @@ test(\"Eleventy set input/output, one file input exitCode\", async (t) => {\ntest(\"Eleventy to json\", async (t) => {\nlet elev = new Eleventy(\"./test/stubs--to/\", \"./test/stubs--to/_site\");\n+ elev.setIsVerbose(false);\n+\nawait elev.init();\n+\nlet result = await elev.toJSON();\nt.deepEqual(\n@@ -169,8 +172,26 @@ test(\"Eleventy to ndjson\", async (t) => {\nelev.setIsVerbose(false);\n+ let output = [];\n+ let fn = function (str) {\n+ output.push(str);\n+ };\n+ elev.logger = {\n+ log: fn,\n+ warn: fn,\n+ error: fn,\n+ message: fn,\n+ stdout: fn,\n+ };\n+\nawait elev.init();\n+\nlet results = await elev.toNDJSON();\n+ t.deepEqual(output, [\n+ `{\"url\":\"/test/\",\"inputPath\":\"./test/stubs--to/test.md\",\"content\":\"<h1>hi</h1>\\\\n\"}`,\n+ `{\"url\":\"/test2/\",\"inputPath\":\"./test/stubs--to/test2.liquid\",\"content\":\"hello\"}`,\n+ ]);\n+\nlet parsed = results.split(\"\\n\").map((entry) => JSON.parse(entry));\nt.deepEqual(\nparsed.filter((entry) => entry.url === \"/test/\"),\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Share the same logger instance, if possible. |
699 | 08.02.2021 20:16:37 | 21,600 | 9c0079d2354d3fcbf5ecdd9c7b3ed653706d53c6 | Cleaner output for --to=json | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -101,7 +101,7 @@ try {\n} else {\nif (argv.to === \"json\") {\nelev.toJSON().then((result) => {\n- console.log(JSON.stringify(result));\n+ console.log(JSON.stringify(result, null, 2));\n});\n} else if (argv.to === \"ndjson\") {\nelev.toNDJSON();\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Cleaner output for --to=json |
699 | 09.02.2021 22:50:40 | 21,600 | d840f0ebb9a02ca00e89dea92ec657294f8f12af | Returns a readable stream when using .toNDJSON in Eleventy class programmatic API. | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -76,6 +76,7 @@ try {\nelev.setIsVerbose(false);\n}\n+ elev.setViaCommandLine(true);\nelev.setConfigPathOverride(argv.config);\nelev.setPathPrefix(argv.pathprefix);\nelev.setDryRun(argv.dryrun);\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"recursive-copy\": \"^2.0.11\",\n\"semver\": \"^7.3.2\",\n\"slugify\": \"^1.4.6\",\n+ \"split\": \"^1.0.1\",\n\"time-require\": \"^0.1.2\",\n\"valid-url\": \"^1.0.9\"\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -105,6 +105,16 @@ class Eleventy {\nreturn new Date().getTime();\n}\n+ /**\n+ * Sets the whether or not this instance was created from the command line (via cmd.js)\n+ *\n+ * @method\n+ * @param {Boolean} isViaCommandLine\n+ */\n+ setViaCommandLine(isViaCommandLine) {\n+ this.isViaCommandLine = isViaCommandLine;\n+ }\n+\n/** @type {String} */\nget input() {\nreturn this.rawInput || this.config.dir.input;\n@@ -355,6 +365,7 @@ Verbose Output: ${this.verboseMode}`);\nif (!this._logger) {\nthis._logger = new ConsoleLogger();\nthis._logger.isVerbose = this.verboseMode;\n+ this._logger.isViaCommandLine = this.isViaCommandLine;\n}\nreturn this._logger;\n@@ -779,11 +790,11 @@ Arguments:\n}\n/**\n- * Renders templates to an NDJSON object (newline delimited).\n+ * Returns a stream of new line delimited (NDJSON) objects\n*\n* @async\n* @method\n- * @returns {Promise<{}>}\n+ * @returns {Promise<{ReadableStream}>}\n*/\nasync toNDJSON() {\nreturn this.executeBuild(\"ndjson\");\n@@ -816,8 +827,10 @@ Arguments:\n}\nret = await promise;\n+\nif (to === \"ndjson\") {\n- ret = ret.join(\"\\n\");\n+ // return a stream\n+ ret = this.logger.closeStream(to);\n}\nawait this.config.events.emit(\"afterBuild\");\n} catch (e) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -674,8 +674,8 @@ class Template extends TemplateContent {\nif (to === \"ndjson\") {\nlet jsonString = JSON.stringify(obj);\n- this.logger.stdout(jsonString);\n- return jsonString;\n+ this.logger.toStream(jsonString, \"\\n\");\n+ return;\n}\n// json\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -138,7 +138,7 @@ test(\"Eleventy set input/output, one file input exitCode\", async (t) => {\n});\ntest(\"Eleventy to json\", async (t) => {\n- let elev = new Eleventy(\"./test/stubs--to/\", \"./test/stubs--to/_site\");\n+ let elev = new Eleventy(\"./test/stubs--to/\");\nelev.setIsVerbose(false);\nawait elev.init();\n@@ -167,10 +167,11 @@ test(\"Eleventy to json\", async (t) => {\n);\n});\n-test(\"Eleventy to ndjson\", async (t) => {\n- let elev = new Eleventy(\"./test/stubs--to/\", \"./test/stubs--to/_site\");\n+test(\"Eleventy to ndjson (via command line-ish, to stdout)\", async (t) => {\n+ let elev = new Eleventy(\"./test/stubs--to/\");\nelev.setIsVerbose(false);\n+ elev.setViaCommandLine(true);\nlet output = [];\nlet fn = function (str) {\n@@ -181,36 +182,81 @@ test(\"Eleventy to ndjson\", async (t) => {\nwarn: fn,\nerror: fn,\nmessage: fn,\n- stdout: fn,\n+ toStream: fn,\n};\nawait elev.init();\n+ await elev.toNDJSON();\n- let results = await elev.toNDJSON();\n- t.deepEqual(output, [\n- `{\"url\":\"/test/\",\"inputPath\":\"./test/stubs--to/test.md\",\"content\":\"<h1>hi</h1>\\\\n\"}`,\n- `{\"url\":\"/test2/\",\"inputPath\":\"./test/stubs--to/test2.liquid\",\"content\":\"hello\"}`,\n- ]);\n-\n- let parsed = results.split(\"\\n\").map((entry) => JSON.parse(entry));\nt.deepEqual(\n- parsed.filter((entry) => entry.url === \"/test/\"),\n+ output.filter((entry) => entry.startsWith(`{\"url\":\"/test/\"`)),\n[\n- {\n- url: \"/test/\",\n- inputPath: \"./test/stubs--to/test.md\",\n- content: \"<h1>hi</h1>\\n\",\n- },\n+ `{\"url\":\"/test/\",\"inputPath\":\"./test/stubs--to/test.md\",\"content\":\"<h1>hi</h1>\\\\n\"}`,\n]\n);\nt.deepEqual(\n- parsed.filter((entry) => entry.url === \"/test2/\"),\n+ output.filter((entry) => entry.startsWith(`{\"url\":\"/test2/\"`)),\n[\n- {\n+ `{\"url\":\"/test2/\",\"inputPath\":\"./test/stubs--to/test2.liquid\",\"content\":\"hello\"}`,\n+ ]\n+ );\n+});\n+\n+test(\"Eleventy to ndjson (no cmd line output when using programmatic API)\", async (t) => {\n+ let elev = new Eleventy(\"./test/stubs--to/\");\n+\n+ elev.setIsVerbose(false);\n+ elev.setViaCommandLine(false);\n+\n+ let output = [];\n+ let fn = function (str) {\n+ output.push(str);\n+ };\n+ elev.logger = {\n+ log: fn,\n+ warn: fn,\n+ error: fn,\n+ message: fn,\n+ stdout: fn,\n+ };\n+\n+ await elev.init();\n+ await elev.toNDJSON();\n+\n+ t.deepEqual(output, []);\n+});\n+\n+test.cb(\"Eleventy to ndjson (returns stream)\", (t) => {\n+ let elev = new Eleventy(\"./test/stubs--to/\");\n+\n+ elev.setIsVerbose(false);\n+ elev.setViaCommandLine(false);\n+\n+ elev.init().then(() => {\n+ elev.toNDJSON().then((stream) => {\n+ let results = [];\n+ stream.on(\"data\", function (jsonObj) {\n+ if (jsonObj.url === \"/test/\") {\n+ t.deepEqual(jsonObj, {\n+ url: \"/test/\",\n+ inputPath: \"./test/stubs--to/test.md\",\n+ content: \"<h1>hi</h1>\\n\",\n+ });\n+ }\n+ if (jsonObj.url === \"/test2/\") {\n+ t.deepEqual(jsonObj, {\nurl: \"/test2/\",\ninputPath: \"./test/stubs--to/test2.liquid\",\ncontent: \"hello\",\n- },\n- ]\n- );\n+ });\n+ }\n+\n+ results.push(jsonObj);\n+\n+ if (results.length >= 2) {\n+ t.end();\n+ }\n+ });\n+ });\n+ });\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Returns a readable stream when using .toNDJSON in Eleventy class programmatic API. |
699 | 09.02.2021 23:41:42 | 21,600 | c2e89a0da369da29bdbfa5cf6dac34012e316ba0 | Use EleventyErrorHandler instance, code cleanup to use streams in both CLI and programmatic API | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -50,17 +50,16 @@ try {\ndebug(\"command: eleventy \", argv.toString());\nconst Eleventy = require(\"./src/Eleventy\");\n+ let errorHandler = new EleventyErrorHandler();\n+\nprocess.on(\"unhandledRejection\", (error, promise) => {\n- EleventyErrorHandler.error(\n- error,\n- `Unhandled rejection in promise (${promise})`\n- );\n+ errorHandler.error(error, `Unhandled rejection in promise (${promise})`);\n});\nprocess.on(\"uncaughtException\", (error) => {\n- EleventyErrorHandler.fatal(error, \"Uncaught exception\");\n+ errorHandler.fatal(error, \"Uncaught exception\");\n});\nprocess.on(\"rejectionHandled\", (promise) => {\n- EleventyErrorHandler.warn(\n+ errorHandler.warn(\npromise,\n\"A promise rejection was handled asynchronously\"\n);\n@@ -71,12 +70,14 @@ try {\nquietMode: argv.quiet,\n});\n+ // reuse ErrorHandler instance in Eleventy\n+ errorHandler = elev.errorHandler;\n+\nif (argv.to === \"json\" || argv.to === \"ndjson\") {\n// override logging output\nelev.setIsVerbose(false);\n}\n- elev.setViaCommandLine(true);\nelev.setConfigPathOverride(argv.config);\nelev.setPathPrefix(argv.pathprefix);\nelev.setDryRun(argv.dryrun);\n@@ -101,11 +102,20 @@ try {\nelev.watch();\n} else {\nif (argv.to === \"json\") {\n- elev.toJSON().then((result) => {\n+ elev.toJSON().then(function (result) {\nconsole.log(JSON.stringify(result, null, 2));\n});\n} else if (argv.to === \"ndjson\") {\n- elev.toNDJSON();\n+ elev\n+ .toNDJSON()\n+ .then(function (stream) {\n+ stream\n+ .on(\"data\", function (jsonString) {\n+ console.log(jsonString);\n+ })\n+ .on(\"error\", errorHandler.fatal.bind(errorHandler));\n+ })\n+ .catch(errorHandler.fatal.bind(errorHandler));\n} else if (!argv.to || argv.to === \"fs\") {\nelev.write();\n} else {\n@@ -115,7 +125,7 @@ try {\n}\n}\n})\n- .catch(EleventyErrorHandler.fatal);\n+ .catch(errorHandler.fatal.bind(errorHandler));\n} catch (e) {\n- EleventyErrorHandler.fatal(e, \"Eleventy fatal error\");\n+ errorHandler.fatal(e, \"Eleventy fatal error\");\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -105,16 +105,6 @@ class Eleventy {\nreturn new Date().getTime();\n}\n- /**\n- * Sets the whether or not this instance was created from the command line (via cmd.js)\n- *\n- * @method\n- * @param {Boolean} isViaCommandLine\n- */\n- setViaCommandLine(isViaCommandLine) {\n- this.isViaCommandLine = isViaCommandLine;\n- }\n-\n/** @type {String} */\nget input() {\nreturn this.rawInput || this.config.dir.input;\n@@ -365,7 +355,6 @@ Verbose Output: ${this.verboseMode}`);\nif (!this._logger) {\nthis._logger = new ConsoleLogger();\nthis._logger.isVerbose = this.verboseMode;\n- this._logger.isViaCommandLine = this.isViaCommandLine;\n}\nreturn this._logger;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -171,7 +171,6 @@ test(\"Eleventy to ndjson (via command line-ish, to stdout)\", async (t) => {\nlet elev = new Eleventy(\"./test/stubs--to/\");\nelev.setIsVerbose(false);\n- elev.setViaCommandLine(true);\nlet output = [];\nlet fn = function (str) {\n@@ -206,7 +205,6 @@ test(\"Eleventy to ndjson (no cmd line output when using programmatic API)\", asyn\nlet elev = new Eleventy(\"./test/stubs--to/\");\nelev.setIsVerbose(false);\n- elev.setViaCommandLine(false);\nlet output = [];\nlet fn = function (str) {\n@@ -230,7 +228,6 @@ test.cb(\"Eleventy to ndjson (returns stream)\", (t) => {\nlet elev = new Eleventy(\"./test/stubs--to/\");\nelev.setIsVerbose(false);\n- elev.setViaCommandLine(false);\nelev.init().then(() => {\nelev.toNDJSON().then((stream) => {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Use EleventyErrorHandler instance, code cleanup to use streams in both CLI and programmatic API |
699 | 09.02.2021 23:51:29 | 21,600 | cc5bf0c7cedc0a059fade92a474029f340f7e972 | No more raw stdout in the Eleventy object (irrelevant tests) | [
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -167,64 +167,7 @@ test(\"Eleventy to json\", async (t) => {\n);\n});\n-test(\"Eleventy to ndjson (via command line-ish, to stdout)\", async (t) => {\n- let elev = new Eleventy(\"./test/stubs--to/\");\n-\n- elev.setIsVerbose(false);\n-\n- let output = [];\n- let fn = function (str) {\n- output.push(str);\n- };\n- elev.logger = {\n- log: fn,\n- warn: fn,\n- error: fn,\n- message: fn,\n- toStream: fn,\n- };\n-\n- await elev.init();\n- await elev.toNDJSON();\n-\n- t.deepEqual(\n- output.filter((entry) => entry.startsWith(`{\"url\":\"/test/\"`)),\n- [\n- `{\"url\":\"/test/\",\"inputPath\":\"./test/stubs--to/test.md\",\"content\":\"<h1>hi</h1>\\\\n\"}`,\n- ]\n- );\n- t.deepEqual(\n- output.filter((entry) => entry.startsWith(`{\"url\":\"/test2/\"`)),\n- [\n- `{\"url\":\"/test2/\",\"inputPath\":\"./test/stubs--to/test2.liquid\",\"content\":\"hello\"}`,\n- ]\n- );\n-});\n-\n-test(\"Eleventy to ndjson (no cmd line output when using programmatic API)\", async (t) => {\n- let elev = new Eleventy(\"./test/stubs--to/\");\n-\n- elev.setIsVerbose(false);\n-\n- let output = [];\n- let fn = function (str) {\n- output.push(str);\n- };\n- elev.logger = {\n- log: fn,\n- warn: fn,\n- error: fn,\n- message: fn,\n- stdout: fn,\n- };\n-\n- await elev.init();\n- await elev.toNDJSON();\n-\n- t.deepEqual(output, []);\n-});\n-\n-test.cb(\"Eleventy to ndjson (returns stream)\", (t) => {\n+test.cb(\"Eleventy to ndjson (returns a stream)\", (t) => {\nlet elev = new Eleventy(\"./test/stubs--to/\");\nelev.setIsVerbose(false);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | No more raw stdout in the Eleventy object (irrelevant tests) |
699 | 10.02.2021 12:20:37 | 21,600 | 8f5f9fa93632418dcf3378036457406163aaf5b2 | .on("data") with node streams uses some kind of compatibility mode per Recommend to use pipe | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -819,6 +819,7 @@ Arguments:\nif (to === \"ndjson\") {\n// return a stream\n+ // TODO this might return only after all the templates have been added to the stream\nret = this.logger.closeStream(to);\n}\nawait this.config.events.emit(\"afterBuild\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -674,7 +674,7 @@ class Template extends TemplateContent {\nif (to === \"ndjson\") {\nlet jsonString = JSON.stringify(obj);\n- this.logger.toStream(jsonString, \"\\n\");\n+ this.logger.toStream(jsonString + \"\\n\");\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Util/ConsoleLogger.js",
"new_path": "src/Util/ConsoleLogger.js",
"diff": "@@ -44,8 +44,8 @@ class ConsoleLogger {\nthis.message(msg);\n}\n- toStream(msg, suffix = \"\") {\n- this.outputStream.push(msg + suffix);\n+ toStream(msg) {\n+ this.outputStream.push(msg);\n}\ncloseStream(to = \"\") {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | .on("data") with node streams uses some kind of compatibility mode per https://github.com/substack/stream-handbook#classic-readable-streams Recommend to use pipe |
699 | 10.02.2021 12:20:59 | 21,600 | 1894b390d64101a209b5c576de6a095fca04e65e | Fix error with missing error handler on fatal errors | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -17,6 +17,7 @@ if (process.env.DEBUG) {\nconst EleventyErrorHandler = require(\"./src/EleventyErrorHandler\");\ntry {\n+ let errorHandler = new EleventyErrorHandler();\nconst EleventyCommandCheckError = require(\"./src/EleventyCommandCheckError\");\nconst argv = require(\"minimist\")(process.argv.slice(2), {\nstring: [\n@@ -50,8 +51,6 @@ try {\ndebug(\"command: eleventy \", argv.toString());\nconst Eleventy = require(\"./src/Eleventy\");\n- let errorHandler = new EleventyErrorHandler();\n-\nprocess.on(\"unhandledRejection\", (error, promise) => {\nerrorHandler.error(error, `Unhandled rejection in promise (${promise})`);\n});\n@@ -109,11 +108,7 @@ try {\nelev\n.toNDJSON()\n.then(function (stream) {\n- stream\n- .on(\"data\", function (jsonString) {\n- console.log(jsonString);\n- })\n- .on(\"error\", errorHandler.fatal.bind(errorHandler));\n+ stream.pipe(process.stdout);\n})\n.catch(errorHandler.fatal.bind(errorHandler));\n} else if (!argv.to || argv.to === \"fs\") {\n@@ -127,5 +122,6 @@ try {\n})\n.catch(errorHandler.fatal.bind(errorHandler));\n} catch (e) {\n+ let errorHandler = new EleventyErrorHandler();\nerrorHandler.fatal(e, \"Eleventy fatal error\");\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix error with missing error handler on fatal errors |
699 | 10.02.2021 12:21:11 | 21,600 | cc9cd890d0705dc2f62c7b77da0a8cd394e50c39 | Canary release docs | [
{
"change_type": "MODIFY",
"old_path": "docs/meta-release.md",
"new_path": "docs/meta-release.md",
"diff": "+# Canary Release Procedure\n+\n+1. npmclean aka `rm -rf node_modules && rm -f package-lock.json && npm install`\n+1. Make sure `npx ava` runs okay\n+1. Update version in `package.json`, include `-canary.1` suffix\n+1. Tag new version\n+1. `npm publish --access=public --tag=canary`\n+\n# Beta Release Procedure\n1. update minor dependencies in package.json?\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Canary release docs |
699 | 17.02.2021 10:58:29 | 21,600 | 3dbaab0a3e09988210c03607d9bf46e5748d8f89 | Adds setter for inputDir when you use a file input and want a different input directory root.
Think --input=./src/subdir/index.njk but you want the input directory to be ./src/ | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -113,9 +113,21 @@ class Eleventy {\n/** @type {String} */\nget inputDir() {\n+ if (this._inputDir) {\n+ // set manually via setter\n+ return this._inputDir;\n+ }\n+\nreturn TemplatePath.getDir(this.input);\n}\n+ /** @type {String} */\n+ set inputDir(dir) {\n+ if (TemplatePath.isDirectorySync(dir)) {\n+ this._inputDir = dir;\n+ }\n+ }\n+\n/** @type {String} */\nget outputDir() {\nlet dir = this.rawOutput || this.config.dir.output;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -106,6 +106,18 @@ test(\"Eleventy set input/output, one file input\", async (t) => {\nt.is(elev.outputDir, \"./test/stubs/_site\");\n});\n+test(\"Eleventy set input/output, one file input, deeper subdirectory\", async (t) => {\n+ let elev = new Eleventy(\n+ \"./test/stubs/subdir/index.html\",\n+ \"./test/stubs/_site\"\n+ );\n+ elev.inputDir = \"./test/stubs\";\n+\n+ t.is(elev.input, \"./test/stubs/subdir/index.html\");\n+ t.is(elev.inputDir, \"./test/stubs\");\n+ t.is(elev.outputDir, \"./test/stubs/_site\");\n+});\n+\ntest(\"Eleventy set input/output, one file input root dir\", async (t) => {\nlet elev = new Eleventy(\"./README.md\", \"./test/stubs/_site\");\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds setter for inputDir when you use a file input and want a different input directory root.
Think --input=./src/subdir/index.njk but you want the input directory to be ./src/ |
699 | 17.02.2021 14:46:50 | 21,600 | 2dee4ed120cb56a66708bef0109977d6ce31a1e2 | Cherry pick from master | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"@11ty/eleventy\",\n- \"version\": \"1.0.0-canary.2\",\n+ \"version\": \"1.0.0-canary.4\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"publishConfig\": {\n\"access\": \"public\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -112,9 +112,18 @@ class Eleventy {\n/** @type {String} */\nget inputDir() {\n+ if (this._inputDir) {\n+ // set manually via setter\n+ return this._inputDir;\n+ }\n+\nreturn TemplatePath.getDir(this.input);\n}\n+ setInputDir(dir) {\n+ this._inputDir = dir;\n+ }\n+\n/** @type {String} */\nget outputDir() {\nlet dir = this.rawOutput || this.config.dir.output;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -106,6 +106,18 @@ test(\"Eleventy set input/output, one file input\", async (t) => {\nt.is(elev.outputDir, \"./test/stubs/_site\");\n});\n+test(\"Eleventy set input/output, one file input, deeper subdirectory\", async (t) => {\n+ let elev = new Eleventy(\n+ \"./test/stubs/subdir/index.html\",\n+ \"./test/stubs/_site\"\n+ );\n+ elev.setInputDir(\"./test/stubs\");\n+\n+ t.is(elev.input, \"./test/stubs/subdir/index.html\");\n+ t.is(elev.inputDir, \"./test/stubs\");\n+ t.is(elev.outputDir, \"./test/stubs/_site\");\n+});\n+\ntest(\"Eleventy set input/output, one file input root dir\", async (t) => {\nlet elev = new Eleventy(\"./README.md\", \"./test/stubs/_site\");\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Cherry pick from master |
699 | 17.02.2021 17:51:37 | 21,600 | a0ed8a6b517fac190b6ab7f83feb0ea66bb8d323 | Steps to separate input from input dir. | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -295,11 +295,13 @@ class Eleventy {\nthis.extensionMap = new EleventyExtensionMap(formats);\nthis.eleventyFiles = new EleventyFiles(\n- this.input,\n+ this.inputDir,\nthis.outputDir,\nformats,\nthis.isPassthroughAll\n);\n+\n+ this.eleventyFiles.setInput(this.inputDir, this.input);\nthis.eleventyFiles.extensionMap = this.extensionMap;\nthis.eleventyFiles.init();\n@@ -308,12 +310,13 @@ class Eleventy {\nthis.eleventyFiles.templateData = this.templateData;\nthis.writer = new TemplateWriter(\n- this.input,\n+ this.inputDir,\nthis.outputDir,\nformats,\nthis.templateData,\nthis.isPassthroughAll\n);\n+ this.writer.setInput(this.inputDir, this.input);\nthis.writer.logger = this.logger;\nthis.writer.extensionMap = this.extensionMap;\nthis.writer.setEleventyFiles(this.eleventyFiles);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyFiles.js",
"new_path": "src/EleventyFiles.js",
"diff": "@@ -24,6 +24,21 @@ class EleventyFiles {\nthis.passthroughAll = !!passthroughAll;\nthis.formats = formats;\n+\n+ // init has not yet been called()\n+ this.alreadyInit = false;\n+ }\n+\n+ /* Overrides this.input and this.inputDir */\n+ setInput(inputDir, input) {\n+ this.inputDir = inputDir;\n+ this.input = input;\n+\n+ this.initConfig();\n+\n+ if (this.alreadyInit) {\n+ this.init();\n+ }\n}\ninitConfig() {\n@@ -41,6 +56,8 @@ class EleventyFiles {\n}\ninit() {\n+ this.alreadyInit = true;\n+\n// Input was a directory\nif (this.input === this.inputDir) {\nthis.templateGlobs = this.extensionMap.getGlobs(this.inputDir);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -43,6 +43,12 @@ class TemplateWriter {\nthis._templatePathCache = new Map();\n}\n+ /* Overrides this.input and this.inputDir */\n+ setInput(inputDir, input) {\n+ this.inputDir = inputDir;\n+ this.input = input;\n+ }\n+\nget templateFormats() {\nreturn this._templateFormats;\n}\n@@ -117,12 +123,13 @@ class TemplateWriter {\nif (!this._eleventyFiles) {\n// if not, we can create one (used only by tests)\nthis._eleventyFiles = new EleventyFiles(\n- this.input,\n+ this.inputDir,\nthis.outputDir,\nthis.templateFormats,\nthis.passthroughAll\n);\n+ this._eleventyFiles.setInput(this.inputDir, this.input);\nthis._eleventyFiles.init();\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Steps to separate input from input dir. |
699 | 17.02.2021 23:32:32 | 21,600 | 4bddb147217b1f3cb66f7b1744bb2bc634ae779c | Simplifes the config setup a little bit as a step toward decentralized config object cleanup. Removes EleventyConfig, moves UserConfig into TemplateConfig. Next step is to move another up the chain to Config.js | [
{
"change_type": "DELETE",
"old_path": "src/EleventyConfig.js",
"new_path": null,
"diff": "-const UserConfig = require(\"./UserConfig\");\n-\n-module.exports = new UserConfig();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -4,7 +4,7 @@ const lodashUniq = require(\"lodash/uniq\");\nconst lodashMerge = require(\"lodash/merge\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\n-const eleventyConfig = require(\"./EleventyConfig\");\n+const UserConfig = require(\"./UserConfig\");\nconst debug = require(\"debug\")(\"Eleventy:TemplateConfig\");\nconst deleteRequireCache = require(\"./Util/DeleteRequireCache\");\n@@ -37,6 +37,8 @@ class EleventyConfigError extends EleventyBaseError {}\n*/\nclass TemplateConfig {\nconstructor(customRootConfig, localProjectConfigPath) {\n+ this.userConfig = new UserConfig();\n+\n/** @member {module:11ty/eleventy/TemplateConfig~TemplateConfig~override} - tbd. */\nthis.overrides = {};\n@@ -58,10 +60,7 @@ class TemplateConfig {\nthis.initializeRootConfig();\n- /**\n- * @member {module:11ty/eleventy/TemplateConfig~TemplateConfig~config} - tbd.\n- */\n- this.config = this.mergeConfig(this.localProjectConfigPath);\n+ this.hasConfigMerged = false;\n}\n/**\n@@ -86,7 +85,7 @@ class TemplateConfig {\n* Resets the configuration.\n*/\nreset() {\n- eleventyConfig.reset();\n+ this.userConfig.reset();\nthis.initializeRootConfig();\nthis.config = this.mergeConfig(this.localProjectConfigPath);\n}\n@@ -106,6 +105,10 @@ class TemplateConfig {\n* @returns {{}} - The config object.\n*/\ngetConfig() {\n+ if (!this.hasConfigMerged) {\n+ this.config = this.mergeConfig(this.localProjectConfigPath);\n+ this.hasConfigMerged = true;\n+ }\nreturn this.config;\n}\n@@ -128,6 +131,10 @@ class TemplateConfig {\nsetPathPrefix(pathPrefix) {\ndebug(\"Setting pathPrefix to %o\", pathPrefix);\nthis.overrides.pathPrefix = pathPrefix;\n+\n+ if (!this.hasConfigMerged) {\n+ this.getConfig();\n+ }\nthis.config.pathPrefix = pathPrefix;\n}\n@@ -138,8 +145,8 @@ class TemplateConfig {\nthis.rootConfig = this.customRootConfig || require(\"./defaultConfig.js\");\nif (typeof this.rootConfig === \"function\") {\n- this.rootConfig = this.rootConfig(eleventyConfig);\n- // debug( \"rootConfig is a function, after calling, eleventyConfig is %o\", eleventyConfig );\n+ this.rootConfig = this.rootConfig(this.userConfig);\n+ // debug( \"rootConfig is a function, after calling, this.userConfig is %o\", this.userConfig );\n}\ndebug(\"rootConfig %o\", this.rootConfig);\n}\n@@ -169,8 +176,8 @@ class TemplateConfig {\n// debug( \"localConfig require return value: %o\", localConfig );\nif (typeof localConfig === \"function\") {\n- localConfig = localConfig(eleventyConfig);\n- // debug( \"localConfig is a function, after calling, eleventyConfig is %o\", eleventyConfig );\n+ localConfig = localConfig(this.userConfig);\n+ // debug( \"localConfig is a function, after calling, this.userConfig is %o\", this.userConfig );\nif (\ntypeof localConfig === \"object\" &&\n@@ -204,7 +211,7 @@ class TemplateConfig {\ndebug(\"Eleventy local project config file not found, skipping.\");\n}\n- let eleventyConfigApiMergingObject = eleventyConfig.getMergingConfigObject();\n+ let eleventyConfigApiMergingObject = this.userConfig.getMergingConfigObject();\n// remove special merge keys from object\nlet savedForSpecialMerge = {\n@@ -219,7 +226,7 @@ class TemplateConfig {\neleventyConfigApiMergingObject.templateFormats ||\nlocalConfig.templateFormats;\n- // debug(\"eleventyConfig.getMergingConfigObject: %o\", eleventyConfig.getMergingConfigObject());\n+ // debug(\"this.userConfig.getMergingConfigObject: %o\", this.userConfig.getMergingConfigObject());\ndebug(\"localConfig: %o\", localConfig);\ndebug(\"overrides: %o\", this.overrides);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -24,6 +24,8 @@ class TemplateWriter {\nisPassthroughAll\n) {\nthis.config = config.getConfig();\n+ this.userConfig = config.userConfig;\n+\nthis.input = inputPath;\nthis.inputDir = TemplatePath.getDir(inputPath);\nthis.outputDir = outputDir;\n@@ -209,6 +211,7 @@ class TemplateWriter {\nasync _createTemplateMap(paths) {\nthis.templateMap = new TemplateMap();\n+ this.templateMap.userConfig = this.userConfig;\nawait this._addToTemplateMap(paths);\nawait this.templateMap.cache();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -70,7 +70,7 @@ class UserConfig {\nversionCheck(expected) {\nif (!semver.satisfies(pkg.version, expected)) {\nthrow new UserConfigError(\n- `This project requires the eleventy version to match '${expected}' but found ${pkg.version}. Use \\`npm update @11ty/eleventy -g\\` to upgrade the eleventy global or \\`npm update @11ty/eleventy --save\\` to upgrade your local project version.`\n+ `This project requires the Eleventy version to match '${expected}' but found ${pkg.version}. Use \\`npm update @11ty/eleventy -g\\` to upgrade the eleventy global or \\`npm update @11ty/eleventy --save\\` to upgrade your local project version.`\n);\n}\n}\n"
},
{
"change_type": "DELETE",
"old_path": "test/EleventyConfigTest.js",
"new_path": null,
"diff": "-const test = require(\"ava\");\n-const eleventyConfig = require(\"../src/EleventyConfig\");\n-\n-// more in TemplateConfigTest.js\n-\n-test.cb(\"Events\", (t) => {\n- eleventyConfig.on(\"testEvent\", function (arg1, arg2, arg3) {\n- t.is(arg1, \"arg1\");\n- t.is(arg2, \"arg2\");\n- t.is(arg3, \"arg3\");\n- t.end();\n- });\n-\n- eleventyConfig.emit(\"testEvent\", \"arg1\", \"arg2\", \"arg3\");\n-});\n-\n-test.cb(\"Async Events\", (t) => {\n- let arg1;\n-\n- eleventyConfig.on(\n- \"asyncTestEvent\",\n- (_arg1) =>\n- new Promise((resolve) => {\n- setTimeout(() => {\n- arg1 = _arg1;\n- resolve();\n- }, 10);\n- })\n- );\n-\n- eleventyConfig.emit(\"asyncTestEvent\", \"arg1\").then(() => {\n- t.is(arg1, \"arg1\");\n- t.end();\n- });\n-});\n-\n-test(\"Add Collections\", (t) => {\n- eleventyConfig.addCollection(\"myCollection\", function (collection) {});\n- t.deepEqual(Object.keys(eleventyConfig.getCollections()), [\"myCollection\"]);\n-});\n-\n-test(\"Add Collections throws error on key collision\", (t) => {\n- eleventyConfig.addCollection(\"myCollectionCollision\", function (\n- collection\n- ) {});\n-\n- t.throws(() => {\n- eleventyConfig.addCollection(\"myCollectionCollision\", function (\n- collection\n- ) {});\n- });\n-});\n-\n-test(\"Set manual Pass-through File Copy (single call)\", (t) => {\n- eleventyConfig.addPassthroughCopy(\"img\");\n-\n- t.is(eleventyConfig.passthroughCopies[\"img\"], true);\n-});\n-\n-test(\"Set manual Pass-through File Copy (chained calls)\", (t) => {\n- eleventyConfig\n- .addPassthroughCopy(\"css\")\n- .addPassthroughCopy(\"js\")\n- .addPassthroughCopy({ \"./src/static\": \"static\" })\n- .addPassthroughCopy({ \"./src/empty\": \"./\" });\n-\n- t.is(eleventyConfig.passthroughCopies[\"css\"], true);\n- t.is(eleventyConfig.passthroughCopies[\"js\"], true);\n- t.is(eleventyConfig.passthroughCopies[\"./src/static\"], \"static\");\n- t.is(eleventyConfig.passthroughCopies[\"./src/empty\"], \"./\");\n-});\n-\n-test(\"Set manual Pass-through File Copy (glob patterns)\", (t) => {\n- eleventyConfig.addPassthroughCopy({\n- \"./src/static/**/*\": \"renamed\",\n- \"./src/markdown/*.md\": \"\",\n- });\n-\n- // does not exist\n- t.is(eleventyConfig.passthroughCopies[\"css/**\"], undefined);\n- t.is(eleventyConfig.passthroughCopies[\"js/**\"], undefined);\n-\n- // exists\n- t.is(eleventyConfig.passthroughCopies[\"./src/static/**/*\"], \"renamed\");\n- t.is(eleventyConfig.passthroughCopies[\"./src/markdown/*.md\"], \"\");\n-});\n-\n-test(\"Set Template Formats (string)\", (t) => {\n- eleventyConfig.setTemplateFormats(\"ejs, njk, liquid\");\n- t.deepEqual(eleventyConfig.templateFormats, [\"ejs\", \"njk\", \"liquid\"]);\n-});\n-\n-test(\"Set Template Formats (array)\", (t) => {\n- eleventyConfig.setTemplateFormats([\"ejs\", \"njk\", \"liquid\"]);\n- t.deepEqual(eleventyConfig.templateFormats, [\"ejs\", \"njk\", \"liquid\"]);\n-});\n-\n-test(\"Set Template Formats (js passthrough copy)\", (t) => {\n- eleventyConfig.setTemplateFormats(\"ejs, njk, liquid, js\");\n- t.deepEqual(eleventyConfig.templateFormats, [\"ejs\", \"njk\", \"liquid\", \"js\"]);\n-});\n-\n-test(\"Set Template Formats (11ty.js)\", (t) => {\n- eleventyConfig.setTemplateFormats(\"ejs, njk, liquid, 11ty.js\");\n- t.deepEqual(eleventyConfig.templateFormats, [\n- \"ejs\",\n- \"njk\",\n- \"liquid\",\n- \"11ty.js\",\n- ]);\n-});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/UserConfigTest.js",
"new_path": "test/UserConfigTest.js",
"diff": "@@ -2,29 +2,152 @@ const test = require(\"ava\");\nconst UserConfig = require(\"../src/UserConfig\");\ntest(\"Template Formats\", (t) => {\n- let cfg = new UserConfig();\n+ let userCfg = new UserConfig();\n- t.falsy(cfg.getMergingConfigObject().templateFormats);\n+ t.falsy(userCfg.getMergingConfigObject().templateFormats);\n- cfg.setTemplateFormats(\"njk,liquid\");\n- t.deepEqual(cfg.getMergingConfigObject().templateFormats, [\"njk\", \"liquid\"]);\n+ userCfg.setTemplateFormats(\"njk,liquid\");\n+ t.deepEqual(userCfg.getMergingConfigObject().templateFormats, [\n+ \"njk\",\n+ \"liquid\",\n+ ]);\n// setting multiple times takes the last one\n- cfg.setTemplateFormats(\"njk,liquid,pug\");\n- cfg.setTemplateFormats(\"njk,liquid\");\n- t.deepEqual(cfg.getMergingConfigObject().templateFormats, [\"njk\", \"liquid\"]);\n+ userCfg.setTemplateFormats(\"njk,liquid,pug\");\n+ userCfg.setTemplateFormats(\"njk,liquid\");\n+ t.deepEqual(userCfg.getMergingConfigObject().templateFormats, [\n+ \"njk\",\n+ \"liquid\",\n+ ]);\n});\ntest(\"Template Formats (Arrays)\", (t) => {\n- let cfg = new UserConfig();\n+ let userCfg = new UserConfig();\n- t.falsy(cfg.getMergingConfigObject().templateFormats);\n+ t.falsy(userCfg.getMergingConfigObject().templateFormats);\n- cfg.setTemplateFormats([\"njk\", \"liquid\"]);\n- t.deepEqual(cfg.getMergingConfigObject().templateFormats, [\"njk\", \"liquid\"]);\n+ userCfg.setTemplateFormats([\"njk\", \"liquid\"]);\n+ t.deepEqual(userCfg.getMergingConfigObject().templateFormats, [\n+ \"njk\",\n+ \"liquid\",\n+ ]);\n// setting multiple times takes the last one\n- cfg.setTemplateFormats([\"njk\", \"liquid\", \"pug\"]);\n- cfg.setTemplateFormats([\"njk\", \"liquid\"]);\n- t.deepEqual(cfg.getMergingConfigObject().templateFormats, [\"njk\", \"liquid\"]);\n+ userCfg.setTemplateFormats([\"njk\", \"liquid\", \"pug\"]);\n+ userCfg.setTemplateFormats([\"njk\", \"liquid\"]);\n+ t.deepEqual(userCfg.getMergingConfigObject().templateFormats, [\n+ \"njk\",\n+ \"liquid\",\n+ ]);\n+});\n+\n+// more in TemplateConfigTest.js\n+\n+test.cb(\"Events\", (t) => {\n+ let userCfg = new UserConfig();\n+ userCfg.on(\"testEvent\", function (arg1, arg2, arg3) {\n+ t.is(arg1, \"arg1\");\n+ t.is(arg2, \"arg2\");\n+ t.is(arg3, \"arg3\");\n+ t.end();\n+ });\n+\n+ userCfg.emit(\"testEvent\", \"arg1\", \"arg2\", \"arg3\");\n+});\n+\n+test.cb(\"Async Events\", (t) => {\n+ let userCfg = new UserConfig();\n+ let arg1;\n+\n+ userCfg.on(\n+ \"asyncTestEvent\",\n+ (_arg1) =>\n+ new Promise((resolve) => {\n+ setTimeout(() => {\n+ arg1 = _arg1;\n+ resolve();\n+ }, 10);\n+ })\n+ );\n+\n+ userCfg.emit(\"asyncTestEvent\", \"arg1\").then(() => {\n+ t.is(arg1, \"arg1\");\n+ t.end();\n+ });\n+});\n+\n+test(\"Add Collections\", (t) => {\n+ let userCfg = new UserConfig();\n+ userCfg.addCollection(\"myCollection\", function (collection) {});\n+ t.deepEqual(Object.keys(userCfg.getCollections()), [\"myCollection\"]);\n+});\n+\n+test(\"Add Collections throws error on key collision\", (t) => {\n+ let userCfg = new UserConfig();\n+ userCfg.addCollection(\"myCollectionCollision\", function (collection) {});\n+\n+ t.throws(() => {\n+ userCfg.addCollection(\"myCollectionCollision\", function (collection) {});\n+ });\n+});\n+\n+test(\"Set manual Pass-through File Copy (single call)\", (t) => {\n+ let userCfg = new UserConfig();\n+ userCfg.addPassthroughCopy(\"img\");\n+\n+ t.is(userCfg.passthroughCopies[\"img\"], true);\n+});\n+\n+test(\"Set manual Pass-through File Copy (chained calls)\", (t) => {\n+ let userCfg = new UserConfig();\n+ userCfg\n+ .addPassthroughCopy(\"css\")\n+ .addPassthroughCopy(\"js\")\n+ .addPassthroughCopy({ \"./src/static\": \"static\" })\n+ .addPassthroughCopy({ \"./src/empty\": \"./\" });\n+\n+ t.is(userCfg.passthroughCopies[\"css\"], true);\n+ t.is(userCfg.passthroughCopies[\"js\"], true);\n+ t.is(userCfg.passthroughCopies[\"./src/static\"], \"static\");\n+ t.is(userCfg.passthroughCopies[\"./src/empty\"], \"./\");\n+});\n+\n+test(\"Set manual Pass-through File Copy (glob patterns)\", (t) => {\n+ let userCfg = new UserConfig();\n+ userCfg.addPassthroughCopy({\n+ \"./src/static/**/*\": \"renamed\",\n+ \"./src/markdown/*.md\": \"\",\n+ });\n+\n+ // does not exist\n+ t.is(userCfg.passthroughCopies[\"css/**\"], undefined);\n+ t.is(userCfg.passthroughCopies[\"js/**\"], undefined);\n+\n+ // exists\n+ t.is(userCfg.passthroughCopies[\"./src/static/**/*\"], \"renamed\");\n+ t.is(userCfg.passthroughCopies[\"./src/markdown/*.md\"], \"\");\n+});\n+\n+test(\"Set Template Formats (string)\", (t) => {\n+ let userCfg = new UserConfig();\n+ userCfg.setTemplateFormats(\"ejs, njk, liquid\");\n+ t.deepEqual(userCfg.templateFormats, [\"ejs\", \"njk\", \"liquid\"]);\n+});\n+\n+test(\"Set Template Formats (array)\", (t) => {\n+ let userCfg = new UserConfig();\n+ userCfg.setTemplateFormats([\"ejs\", \"njk\", \"liquid\"]);\n+ t.deepEqual(userCfg.templateFormats, [\"ejs\", \"njk\", \"liquid\"]);\n+});\n+\n+test(\"Set Template Formats (js passthrough copy)\", (t) => {\n+ let userCfg = new UserConfig();\n+ userCfg.setTemplateFormats(\"ejs, njk, liquid, js\");\n+ t.deepEqual(userCfg.templateFormats, [\"ejs\", \"njk\", \"liquid\", \"js\"]);\n+});\n+\n+test(\"Set Template Formats (11ty.js)\", (t) => {\n+ let userCfg = new UserConfig();\n+ userCfg.setTemplateFormats(\"ejs, njk, liquid, 11ty.js\");\n+ t.deepEqual(userCfg.templateFormats, [\"ejs\", \"njk\", \"liquid\", \"11ty.js\"]);\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Simplifes the config setup a little bit as a step toward decentralized config object cleanup. Removes EleventyConfig, moves UserConfig into TemplateConfig. Next step is to move another up the chain to Config.js |
699 | 18.02.2021 18:02:00 | 21,600 | 3326e5e3f613091e1c4de5896d03b05ca54310da | These tests are working | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -11,12 +11,12 @@ const EleventyWatch = require(\"./EleventyWatch\");\nconst EleventyWatchTargets = require(\"./EleventyWatchTargets\");\nconst EleventyFiles = require(\"./EleventyFiles\");\nconst ConsoleLogger = require(\"./Util/ConsoleLogger\");\n+const TemplateConfig = require(\"./TemplateConfig\");\nconst { performance } = require(\"perf_hooks\");\nconst templateCache = require(\"./TemplateCache\");\nconst simplePlural = require(\"./Util/Pluralize\");\nconst deleteRequireCache = require(\"./Util/DeleteRequireCache\");\n-const config = require(\"./Config\");\nconst bench = require(\"./BenchmarkManager\");\nconst debug = require(\"debug\")(\"Eleventy\");\n@@ -32,9 +32,14 @@ const debug = require(\"debug\")(\"Eleventy\");\n* @returns {module:11ty/eleventy/Eleventy~Eleventy}\n*/\nclass Eleventy {\n- constructor(input, output, options = {}) {\n- /** @member {module:11ty/eleventy/TemplateConfig~TemplateConfig~config} - TemplateConfig instance */\n- this.config = config.getConfig();\n+ constructor(input, output, options = {}, eleventyConfig = null) {\n+ if (!eleventyConfig) {\n+ this.eleventyConfig = new TemplateConfig();\n+ } else {\n+ this.eleventyConfig = eleventyConfig;\n+ }\n+\n+ this.config = this.eleventyConfig.getConfig();\n/**\n* @member {String} - The path to Eleventy's config file.\n@@ -82,6 +87,7 @@ class Eleventy {\n/** @member {Object} - tbd. */\nthis.eleventyServe = new EleventyServe();\n+ this.eleventyServe.config = this.eleventyConfig;\n/** @member {String} - Holds the path to the input directory. */\nthis.rawInput = input;\n@@ -174,8 +180,8 @@ class Eleventy {\n*/\nsetPathPrefix(pathPrefix) {\nif (pathPrefix || pathPrefix === \"\") {\n- config.setPathPrefix(pathPrefix);\n- this.config = config.getConfig();\n+ this.eleventyConfig.setPathPrefix(pathPrefix);\n+ this.config = this.eleventyConfig.getConfig();\n}\n}\n@@ -199,8 +205,8 @@ class Eleventy {\nif (configPath) {\nthis.configPath = configPath;\n- config.setProjectConfigPath(configPath);\n- this.config = config.getConfig();\n+ this.eleventyConfig.setProjectConfigPath(configPath);\n+ this.config = this.eleventyConfig.getConfig();\n}\n}\n@@ -298,14 +304,14 @@ class Eleventy {\nthis.inputDir,\nthis.outputDir,\nformats,\n- this.isPassthroughAll\n+ this.eleventyConfig\n);\n-\n+ this.eleventyFiles.setPassthroughAll(this.isPassthroughAll);\nthis.eleventyFiles.setInput(this.inputDir, this.input);\nthis.eleventyFiles.extensionMap = this.extensionMap;\nthis.eleventyFiles.init();\n- this.templateData = new TemplateData(this.inputDir);\n+ this.templateData = new TemplateData(this.inputDir, this.eleventyConfig);\nthis.templateData.extensionMap = this.extensionMap;\nthis.eleventyFiles.templateData = this.templateData;\n@@ -314,7 +320,7 @@ class Eleventy {\nthis.outputDir,\nformats,\nthis.templateData,\n- this.isPassthroughAll\n+ this.eleventyConfig\n);\nthis.writer.setInput(this.inputDir, this.input);\nthis.writer.logger = this.logger;\n@@ -465,9 +471,9 @@ Arguments:\n* @method\n*/\nresetConfig() {\n- config.reset();\n+ this.eleventyConfig.reset();\n- this.config = config.getConfig();\n+ this.config = this.eleventyConfig.getConfig();\nthis.eleventyServe.config = this.config;\n// only use config quietMode if --quiet not set on CLI\n@@ -507,7 +513,11 @@ Arguments:\n);\n// reset and reload global configuration :O\n- if (this.watchManager.hasQueuedFile(config.getLocalProjectConfigFile())) {\n+ if (\n+ this.watchManager.hasQueuedFile(\n+ this.eleventyConfig.getLocalProjectConfigFile()\n+ )\n+ ) {\nthis.resetConfig();\n}\n@@ -599,7 +609,7 @@ Arguments:\nthis.watchTargets.add(this.eleventyFiles.getGlobWatcherFiles());\n// Watch the local project config file\n- this.watchTargets.add(config.getLocalProjectConfigFile());\n+ this.watchTargets.add(this.eleventyConfig.getLocalProjectConfigFile());\n// Template and Directory Data Files\nthis.watchTargets.add(\n@@ -636,7 +646,7 @@ Arguments:\n// Config file dependencies\nthis.watchTargets.addDependencies(\n- config.getLocalProjectConfigFile(),\n+ this.eleventyConfig.getLocalProjectConfigFile(),\nfilterOutGlobalDataFiles\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "const test = require(\"ava\");\nconst Eleventy = require(\"../src/Eleventy\");\nconst EleventyWatchTargets = require(\"../src/EleventyWatchTargets\");\n-const templateConfig = require(\"../src/Config\");\n-\n-const config = templateConfig.getConfig();\n+const TemplateConfig = require(\"../src/TemplateConfig\");\ntest(\"Eleventy, defaults inherit from config\", async (t) => {\nlet elev = new Eleventy();\n+ let config = new TemplateConfig().getConfig();\n+\nt.truthy(elev.input);\nt.truthy(elev.outputDir);\nt.is(elev.input, config.dir.input);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | These tests are working |
699 | 19.02.2021 20:33:18 | 21,600 | 2df5f88a1de657b0302ca484b419f2358d6f801b | The last one? | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyFiles.js",
"new_path": "src/EleventyFiles.js",
"diff": "@@ -139,7 +139,7 @@ class EleventyFiles {\n}\ninitPassthroughManager() {\n- let mgr = new TemplatePassthroughManager();\n+ let mgr = new TemplatePassthroughManager(this.eleventyConfig);\nmgr.setInputDir(this.inputDir);\nmgr.setOutputDir(this.outputDir);\nmgr.extensionMap = this.extensionMap;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePassthroughManager.js",
"new_path": "src/TemplatePassthroughManager.js",
"diff": "-const config = require(\"./Config\");\nconst EleventyExtensionMap = require(\"./EleventyExtensionMap\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\nconst TemplatePassthrough = require(\"./TemplatePassthrough\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst debug = require(\"debug\")(\"Eleventy:TemplatePassthroughManager\");\n+class TemplatePassthroughManagerConfigError extends EleventyBaseError {}\nclass TemplatePassthroughManagerCopyError extends EleventyBaseError {}\nclass TemplatePassthroughManager {\n- constructor() {\n- this.config = config.getConfig();\n+ constructor(eleventyConfig) {\n+ if (!eleventyConfig) {\n+ throw new TemplatePassthroughManagerConfigError(\n+ \"Missing `config` argument.\"\n+ );\n+ }\n+ this.eleventyConfig = eleventyConfig;\n+ this.config = eleventyConfig.getConfig();\nthis.reset();\n}\n@@ -19,10 +25,6 @@ class TemplatePassthroughManager {\ndebug(\"Resetting counts to 0\");\n}\n- setConfig(configOverride) {\n- this.config = configOverride || {};\n- }\n-\nset extensionMap(extensionMap) {\nthis._extensionMap = extensionMap;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyFilesTest.js",
"new_path": "test/EleventyFilesTest.js",
"diff": "@@ -660,7 +660,7 @@ test(\"Glob Watcher Files with Config Passthroughs (one template format)\", async\n);\nevf.init();\n- let mgr = new TemplatePassthroughManager();\n+ let mgr = new TemplatePassthroughManager(eleventyConfig);\nmgr.setInputDir(\"test/stubs\");\nmgr.setOutputDir(\"test/stubs/_site\");\nmgr.setConfig({\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePassthroughManagerTest.js",
"new_path": "test/TemplatePassthroughManagerTest.js",
"diff": "const test = require(\"ava\");\nconst fs = require(\"fs-extra\");\nconst TemplatePassthroughManager = require(\"../src/TemplatePassthroughManager\");\n+const TemplateConfig = require(\"../src/TemplateConfig\");\ntest(\"Get paths from Config\", async (t) => {\n- let mgr = new TemplatePassthroughManager();\n- mgr.setConfig({\n- passthroughCopies: {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.passthroughCopies = {\nimg: true,\n- },\n- });\n+ };\n+ let mgr = new TemplatePassthroughManager(eleventyConfig);\nt.deepEqual(mgr.getConfigPaths(), [{ inputPath: \"./img\", outputPath: true }]);\n});\ntest(\"isPassthroughCopyFile\", async (t) => {\n- let mgr = new TemplatePassthroughManager();\n- mgr.setConfig({\n- passthroughCopies: {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.passthroughCopies = {\nimg: true,\nfonts: true,\n- },\n- });\n+ };\n+ let mgr = new TemplatePassthroughManager(eleventyConfig);\nt.true(mgr.isPassthroughCopyFile([], \"./img/test.png\"));\nt.true(mgr.isPassthroughCopyFile([], \"./fonts/Roboto.woff\"));\n@@ -35,14 +34,13 @@ test(\"isPassthroughCopyFile\", async (t) => {\n});\ntest(\"Get glob paths from config\", async (t) => {\n- let mgr = new TemplatePassthroughManager();\n- mgr.setConfig({\n- passthroughCopies: {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.passthroughCopies = {\n\"test/stubs/img\": true,\n\"test/stubs/img/**\": \"./\",\n\"test/stubs/img/*.js\": \"./\",\n- },\n- });\n+ };\n+ let mgr = new TemplatePassthroughManager(eleventyConfig);\nt.deepEqual(mgr.getConfigPathGlobs(), [\n\"./test/stubs/img/**\",\n@@ -52,45 +50,52 @@ test(\"Get glob paths from config\", async (t) => {\n});\ntest(\"Get file paths\", async (t) => {\n- let mgr = new TemplatePassthroughManager();\n+ let eleventyConfig = new TemplateConfig();\n+ let mgr = new TemplatePassthroughManager(eleventyConfig);\n+\nt.deepEqual(mgr.getNonTemplatePaths([\"test.png\"]), [\"test.png\"]);\n});\ntest(\"Get file paths (filter out real templates)\", async (t) => {\n- let mgr = new TemplatePassthroughManager();\n+ let eleventyConfig = new TemplateConfig();\n+ let mgr = new TemplatePassthroughManager(eleventyConfig);\nt.deepEqual(mgr.getNonTemplatePaths([\"test.njk\"]), []);\n});\ntest(\"Get file paths (filter out real templates), multiple\", async (t) => {\n- let mgr = new TemplatePassthroughManager();\n+ let eleventyConfig = new TemplateConfig();\n+ let mgr = new TemplatePassthroughManager(eleventyConfig);\nt.deepEqual(mgr.getNonTemplatePaths([\"test.njk\", \"test.png\"]), [\"test.png\"]);\n});\ntest(\"Get file paths with a js file (filter out real templates), multiple\", async (t) => {\n- let mgr = new TemplatePassthroughManager();\n+ let eleventyConfig = new TemplateConfig();\n+ let mgr = new TemplatePassthroughManager(eleventyConfig);\nt.deepEqual(mgr.getNonTemplatePaths([\"test.njk\", \"test.js\"]), [\"test.js\"]);\n});\n// This test used to be for passthroughFileCopy: false in config\ntest(\"Get file paths (one image path)\", async (t) => {\n- let mgr = new TemplatePassthroughManager();\n+ let eleventyConfig = new TemplateConfig();\n+ let mgr = new TemplatePassthroughManager(eleventyConfig);\n+\nt.deepEqual(mgr.getNonTemplatePaths([\"test.png\"]), [\"test.png\"]);\n});\ntest(\"Naughty paths outside of project dir\", async (t) => {\n- let mgr = new TemplatePassthroughManager();\n- mgr.setConfig({\n- passthroughCopies: {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.passthroughCopies = {\n\"../static\": true,\n\"../*\": \"./\",\n\"./test/stubs/template-passthrough2/static/*.css\": \"./\",\n\"./test/stubs/template-passthrough2/static/*.js\": \"../../\",\n\"./test/stubs/template-passthrough2/img.jpg\": \"../../\",\n- },\n- });\n+ };\n+\n+ let mgr = new TemplatePassthroughManager(eleventyConfig);\nawait t.throwsAsync(async function () {\nfor (let path of mgr.getConfigPaths()) {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | The last one? |
699 | 19.02.2021 21:30:00 | 21,600 | 7dc72109a81e42b49013a3cbba7bfd9a4e3409c2 | Finishes config refactor. | [
{
"change_type": "DELETE",
"old_path": "src/Config.js",
"new_path": null,
"diff": "-const TemplateConfig = require(\"./TemplateConfig\");\n-const debug = require(\"debug\")(\"Eleventy:Config\");\n-\n-/**\n- * @module 11ty/eleventy/Config\n- */\n-\n-debug(\"Setting up global TemplateConfig.\");\n-/**\n- * Provides global TemplateConfig.\n- * @type {module:11ty/eleventy/TemplateConfig~TemplateConfig}\n- */\n-let config = new TemplateConfig();\n-\n-module.exports = config;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Filters/Url.js",
"new_path": "src/Filters/Url.js",
"diff": "const validUrl = require(\"valid-url\");\nconst TemplatePath = require(\"../TemplatePath\");\n+// This is also used in the Eleventy Navigation plugin\nmodule.exports = function (url, pathPrefix) {\n// work with undefined\nurl = url || \"\";\n@@ -14,8 +15,9 @@ module.exports = function(url, pathPrefix) {\n}\nif (pathPrefix === undefined || typeof pathPrefix !== \"string\") {\n- let projectConfig = require(\"../Config\").getConfig();\n- pathPrefix = projectConfig.pathPrefix;\n+ // When you retrieve this with config.getFilter(\"url\") it\n+ // grabs the pathPrefix argument from your config for you.\n+ throw new Error(\"pathPrefix (String) is required in the `url` filter.\");\n}\nlet normUrl = TemplatePath.normalizeUrlPath(url);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -145,7 +145,7 @@ class TemplateConfig {\nthis.rootConfig = this.customRootConfig || require(\"./defaultConfig.js\");\nif (typeof this.rootConfig === \"function\") {\n- this.rootConfig = this.rootConfig(this.userConfig);\n+ this.rootConfig = this.rootConfig.call(this, this.userConfig);\n// debug( \"rootConfig is a function, after calling, this.userConfig is %o\", this.userConfig );\n}\ndebug(\"rootConfig %o\", this.rootConfig);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/defaultConfig.js",
"new_path": "src/defaultConfig.js",
"diff": "@@ -3,8 +3,13 @@ const slugFilter = require(\"./Filters/Slug\");\nconst getCollectionItem = require(\"./Filters/GetCollectionItem\");\nmodule.exports = function (config) {\n+ let eleventyConfig = this;\nconfig.addFilter(\"slug\", slugFilter);\n- config.addFilter(\"url\", urlFilter);\n+ config.addFilter(\"url\", function (url, pathPrefixOverride) {\n+ let pathPrefix =\n+ pathPrefixOverride || eleventyConfig.getConfig().pathPrefix;\n+ return urlFilter.call(this, url, pathPrefix);\n+ });\nconfig.addFilter(\"log\", console.log);\nconfig.addFilter(\"getCollectionItem\", (collection, page) =>\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyFilesTest.js",
"new_path": "test/EleventyFilesTest.js",
"diff": "@@ -652,6 +652,9 @@ test(\"Glob Watcher Files with File Extension Passthroughs\", async (t) => {\ntest(\"Glob Watcher Files with Config Passthroughs (one template format)\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.passthroughCopies = {\n+ \"test/stubs/img/\": true,\n+ };\nlet evf = new EleventyFiles(\n\"test/stubs\",\n\"test/stubs/_site\",\n@@ -663,11 +666,6 @@ test(\"Glob Watcher Files with Config Passthroughs (one template format)\", async\nlet mgr = new TemplatePassthroughManager(eleventyConfig);\nmgr.setInputDir(\"test/stubs\");\nmgr.setOutputDir(\"test/stubs/_site\");\n- mgr.setConfig({\n- passthroughCopies: {\n- \"test/stubs/img/\": true,\n- },\n- });\nevf.setPassthroughManager(mgr);\nt.deepEqual(evf.getGlobWatcherFiles(), [\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -212,3 +212,15 @@ test.cb(\"Eleventy to ndjson (returns a stream)\", (t) => {\n});\n});\n});\n+\n+test(\"Two Eleventies, two configs!!! (config used to be a global)\", async (t) => {\n+ let elev1 = new Eleventy();\n+\n+ t.is(elev1.eleventyConfig, elev1.eleventyConfig);\n+ t.is(elev1.config, elev1.config);\n+ t.is(JSON.stringify(elev1.config), JSON.stringify(elev1.config));\n+\n+ let elev2 = new Eleventy();\n+ t.not(elev1.eleventyConfig, elev2.eleventyConfig);\n+ t.is(JSON.stringify(elev1.config), JSON.stringify(elev2.config));\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateWriterTest.js",
"new_path": "test/TemplateWriterTest.js",
"diff": "@@ -699,6 +699,12 @@ test.skip(\"JavaScript with alias\", async (t) => {\ntest(\"Passthrough file output\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.passthroughCopies = {\n+ \"./test/stubs/template-passthrough/static\": true,\n+ \"./test/stubs/template-passthrough/static/\": \"./\",\n+ \"./test/stubs/template-passthrough/static/**/*\": \"./all/\",\n+ \"./test/stubs/template-passthrough/static/**/*.js\": \"./js/\",\n+ };\nlet tw = new TemplateWriter(\n\"./test/stubs/template-passthrough/\",\n\"./test/stubs/template-passthrough/_site\",\n@@ -708,14 +714,6 @@ test(\"Passthrough file output\", async (t) => {\n);\nconst mgr = tw.eleventyFiles.getPassthroughManager();\n- mgr.setConfig({\n- passthroughCopies: {\n- \"./test/stubs/template-passthrough/static\": true,\n- \"./test/stubs/template-passthrough/static/\": \"./\",\n- \"./test/stubs/template-passthrough/static/**/*\": \"./all/\",\n- \"./test/stubs/template-passthrough/static/**/*.js\": \"./js/\",\n- },\n- });\nawait tw.write();\n"
},
{
"change_type": "MODIFY",
"old_path": "test/UrlTest.js",
"new_path": "test/UrlTest.js",
"diff": "const test = require(\"ava\");\n+const TemplateConfig = require(\"../src/TemplateConfig.js\");\nconst url = require(\"../src/Filters/Url.js\");\n+test(\"Test url filter passing in pathPrefix from config\", (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let pp = eleventyConfig.getConfig().pathPrefix;\n+ t.is(pp, \"/\");\n+\n+ t.is(url(\"test\", pp), \"test\");\n+ t.is(url(\"/test\", pp), \"/test\");\n+});\n+\ntest(\"Test url filter without passing in pathPrefix\", (t) => {\n- let projectConfig = require(\"../src/Config\").getConfig();\n- t.is(projectConfig.pathPrefix, \"/\");\n+ let eleventyConfig = new TemplateConfig();\n+ let urlFilter = eleventyConfig.userConfig.getFilter(\"url\");\n- t.is(url(\"test\"), \"test\");\n- t.is(url(\"/test\"), \"/test\");\n+ t.is(urlFilter(\"test\"), \"test\");\n+ t.is(urlFilter(\"/test\"), \"/test\");\n});\ntest(\"Test url filter with passthrough urls\", (t) => {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Finishes config refactor. |
699 | 20.02.2021 14:52:13 | 21,600 | 40bc8c0ba60ff7da805fe56f85c6e2ee05213dbf | Adds useTemplateCache option to remove all remaining globals. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -146,11 +146,17 @@ class TemplateContent {\nlet templateBenchmark = bench.get(\"Template Read\");\ntemplateBenchmark.before();\n- let content = TemplateContent.getCached(this.inputPath);\n+ let content;\n+ if (this.config.useTemplateCache) {\n+ content = TemplateContent.getCached(this.inputPath);\n+ }\nif (!content) {\ncontent = await fs.readFile(this.inputPath, \"utf-8\");\n+\n+ if (this.config.useTemplateCache) {\nTemplateContent.cache(this.inputPath, content);\n}\n+ }\ntemplateBenchmark.after();\nreturn content;\n@@ -224,27 +230,34 @@ class TemplateContent {\n);\ntry {\n- let [cacheable, key, cache] = this._getCompileCache(str, bypassMarkdown);\n+ let res;\n+ if (this.config.useTemplateCache) {\n+ let [cacheable, key, cache] = this._getCompileCache(\n+ str,\n+ bypassMarkdown\n+ );\nif (cacheable && cache.has(key)) {\nreturn cache.get(key);\n}\n// Compilation is async, so we eagerly cache a Promise that eventually\n// resolves to the compiled function\n- let res;\ncache.set(\nkey,\nnew Promise((resolve) => {\nres = resolve;\n})\n);\n+ }\nlet templateBenchmark = bench.get(\"Template Compile\");\ntemplateBenchmark.before();\nlet fn = await this.templateRender.getCompiledTemplate(str);\ntemplateBenchmark.after();\ndebugDev(\"%o getCompiledTemplate function created\", this.inputPath);\n+ if (this.config.useTemplateCache && res) {\nres(fn);\n+ }\nreturn fn;\n} catch (e) {\ndebug(`Having trouble compiling template ${this.inputPath}: %O`, str);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateLayout.js",
"new_path": "src/TemplateLayout.js",
"diff": "@@ -36,6 +36,7 @@ class TemplateLayout extends TemplateContent {\n}\nstatic getTemplate(key, inputDir, config, extensionMap) {\n+ if (config.useTemplateCache) {\nlet fullKey = TemplateLayout.resolveFullKey(key, inputDir);\nif (templateCache.has(fullKey)) {\ndebugDev(\"Found %o in TemplateCache\", key);\n@@ -46,6 +47,9 @@ class TemplateLayout extends TemplateContent {\ntemplateCache.add(fullKey, tmpl);\nreturn tmpl;\n+ } else {\n+ return new TemplateLayout(key, inputDir, extensionMap, config);\n+ }\n}\nasync getTemplateLayoutMapEntry() {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -65,6 +65,7 @@ class UserConfig {\nthis.dataExtensions = new Map();\nthis.quietMode = false;\n+ this.useTemplateCache = true;\n}\nversionCheck(expected) {\n@@ -660,6 +661,10 @@ class UserConfig {\nthis.dataExtensions.set(formatExtension, formatParser);\n}\n+ setUseTemplateCache(bypass) {\n+ this.useTemplateCache = !!bypass;\n+ }\n+\ngetMergingConfigObject() {\nreturn {\ntemplateFormats: this.templateFormats,\n@@ -704,6 +709,7 @@ class UserConfig {\nextensionMap: this.extensionMap,\nquietMode: this.quietMode,\nevents: this.events,\n+ useTemplateCache: this.useTemplateCache,\n};\n}\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds useTemplateCache option to remove all remaining globals. |
699 | 21.02.2021 14:32:07 | 21,600 | 2bc2da2b6a1b8be93bc30f2df1ed5cadc16851a1 | More tests for addGlobalData | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -280,13 +280,14 @@ class TemplateData {\nlet globalData = {};\nif (this.config.globalData) {\nlet keys = Object.keys(this.config.globalData);\n- for (let j = 0; j < keys.length; j++) {\n- let returnValue = this.config.globalData[keys[j]];\n+ for (let key of keys) {\n+ let returnValue = this.config.globalData[key];\nif (typeof returnValue === \"function\") {\nreturnValue = await returnValue();\n}\n- globalData[keys[j]] = returnValue;\n+\n+ globalData[key] = returnValue;\n}\n}\nreturn globalData;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -448,3 +448,24 @@ test(\"Parent directory for data (Issue #337)\", async (t) => {\n},\n});\n});\n+\n+test(\"addGlobalData values\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.addGlobalData(\"myFunction\", () => \"fn-value\");\n+ eleventyConfig.userConfig.addGlobalData(\"myPromise\", () =>\n+ Promise.resolve(\"promise-value\")\n+ );\n+ eleventyConfig.userConfig.addGlobalData(\"myAsync\", async () =>\n+ Promise.resolve(\"promise-value\")\n+ );\n+\n+ let dataObj = new TemplateData(\n+ \"./test/stubs-global-data-config-api/\",\n+ eleventyConfig\n+ );\n+ let data = await dataObj.getData();\n+\n+ t.is(data.myFunction, \"fn-value\");\n+ t.is(data.myPromise, \"promise-value\");\n+ t.is(data.myAsync, \"promise-value\");\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | More tests for addGlobalData |
699 | 21.02.2021 14:33:13 | 21,600 | eb0699308f3420b264a23c6eef151c806c382235 | Match to the docs example | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -452,9 +452,11 @@ test(\"Parent directory for data (Issue #337)\", async (t) => {\ntest(\"addGlobalData values\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\neleventyConfig.userConfig.addGlobalData(\"myFunction\", () => \"fn-value\");\n- eleventyConfig.userConfig.addGlobalData(\"myPromise\", () =>\n- Promise.resolve(\"promise-value\")\n- );\n+ eleventyConfig.userConfig.addGlobalData(\"myPromise\", () => {\n+ return new Promise((resolve) => {\n+ setTimeout(resolve, 100, \"promise-value\");\n+ });\n+ });\neleventyConfig.userConfig.addGlobalData(\"myAsync\", async () =>\nPromise.resolve(\"promise-value\")\n);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Match to the docs example |
699 | 22.02.2021 16:11:46 | 21,600 | 1c55ddbd7577cffd9a85ea893fa5ec4c3d3d8ce0 | Adds `config` option to Eleventy constructor. Pass `addGlobalData` results to global data functions. More useTemplateCache forks | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"@11ty/eleventy\",\n- \"version\": \"1.0.0-canary.9\",\n+ \"version\": \"1.0.0-canary.10\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"publishConfig\": {\n\"access\": \"public\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -42,6 +42,11 @@ class Eleventy {\n}\n}\n+ if (options.config && typeof options.config === \"function\") {\n+ // TODO use return object here?\n+ options.config(this.eleventyConfig.userConfig);\n+ }\n+\n/**\n* @member {String} - The path to Eleventy's config file.\n* @default null\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -26,6 +26,7 @@ class Nunjucks extends TemplateEngine {\n}\n)\n);\n+\nthis.setEngineLib(this.njkEnv);\nthis.addFilters(this.config.nunjucksFilters);\n@@ -255,11 +256,15 @@ class Nunjucks extends TemplateEngine {\n};\n}\n+ // for(let loader of this.njkEnv.loaders) {\n+ // loader.cache = {};\n+ // }\n+\nlet tmpl;\nif (!inputPath || inputPath === \"njk\" || inputPath === \"md\") {\n- tmpl = NunjucksLib.compile(str, this.njkEnv);\n+ tmpl = new NunjucksLib.Template(str, this.njkEnv, null, true);\n} else {\n- tmpl = NunjucksLib.compile(str, this.njkEnv, inputPath);\n+ tmpl = new NunjucksLib.Template(str, this.njkEnv, inputPath, true);\n}\nreturn async function (data) {\nreturn new Promise(function (resolve, reject) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -695,7 +695,7 @@ class Template extends TemplateContent {\nthis.outputDir,\nthis.templateData,\nthis.extensionMap,\n- this.config\n+ this.eleventyConfig\n);\ntmpl.logger = this.logger;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -86,6 +86,7 @@ class TemplateConfig {\n* Resets the configuration.\n*/\nreset() {\n+ debugDev(\"Resetting configuration: TemplateConfig and UserConfig.\");\nthis.userConfig.reset();\nthis.initializeRootConfig();\nthis.config = this.mergeConfig(this.localProjectConfigPath);\n@@ -209,6 +210,7 @@ class TemplateConfig {\n);\n}\n} catch (err) {\n+ // TODO the error message here is bad and I feel bad (needs more accurate info)\nthrow new EleventyConfigError(\n`Error in your Eleventy config file '${path}'.` +\n(err.message.includes(\"Cannot find module\")\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -61,6 +61,15 @@ class TemplateContent {\nreturn this._config;\n}\n+ get eleventyConfig() {\n+ if (this._config instanceof TemplateConfig) {\n+ return this._config;\n+ }\n+ throw new TemplateContentConfigError(\n+ \"Tried to get an eleventyConfig but none was found.\"\n+ );\n+ }\n+\nget engine() {\nreturn this.templateRender.engine;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -296,7 +296,7 @@ class TemplateData {\nasync getData() {\nlet rawImports = this.getRawImports();\n- let initialGlobalData = await this.getInitialGlobalData();\n+ this.configApiGlobalData = await this.getInitialGlobalData();\nif (!this.globalData) {\nlet globalJson = await this.getAllGlobalData();\n@@ -304,7 +304,7 @@ class TemplateData {\n// OK: Shallow merge when combining rawImports (pkg) with global data files\nthis.globalData = Object.assign(\n{},\n- initialGlobalData,\n+ this.configApiGlobalData,\nglobalJson,\nrawImports\n);\n@@ -448,7 +448,7 @@ class TemplateData {\nlet returnValue = require(localPath);\nif (typeof returnValue === \"function\") {\n- returnValue = await returnValue();\n+ returnValue = await returnValue(this.configApiGlobalData || {});\n}\ndataBench.after();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateEngineManager.js",
"new_path": "src/TemplateEngineManager.js",
"diff": "@@ -2,12 +2,12 @@ const EleventyBaseError = require(\"./EleventyBaseError\");\nclass TemplateEngineManagerConfigError extends EleventyBaseError {}\nclass TemplateEngineManager {\nconstructor(config) {\n- this.engineCache = {};\n-\nif (!config) {\nthrow new TemplateEngineManagerConfigError(\"Missing `config` argument.\");\n}\nthis.config = config;\n+\n+ this.engineCache = {};\n}\nget keyToClassNameMap() {\n@@ -57,6 +57,7 @@ class TemplateEngineManager {\nlet path = \"./Engines/\" + this.getClassNameFromTemplateKey(name);\nconst cls = require(path);\n+\nlet instance = new cls(name, includesDir, this.config);\ninstance.extensionMap = extensionMap;\ninstance.engineManager = this;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateLayout.js",
"new_path": "src/TemplateLayout.js",
"diff": "@@ -115,7 +115,7 @@ class TemplateLayout extends TemplateContent {\n}\nasync getCompiledLayoutFunctions() {\n- if (this.compileCache) {\n+ if (this.config.useTemplateCache && this.compileCache) {\nreturn this.compileCache;\n}\n@@ -128,7 +128,9 @@ class TemplateLayout extends TemplateContent {\n)\n);\n}\n+ if (this.config.useTemplateCache) {\nthis.compileCache = fns;\n+ }\nreturn fns;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -37,6 +37,7 @@ class TemplateMap {\nget userConfig() {\nif (!this._userConfig) {\nthis.config = this.eleventyConfig.getConfig();\n+ // TODO use this.config for this, need to add collections to mergable props in userconfig\nthis._userConfig = this.eleventyConfig.userConfig;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -162,7 +162,7 @@ class TemplateWriter {\nthis.outputDir,\nthis.templateData,\nthis.extensionMap,\n- this.config\n+ this.eleventyConfig\n);\ntmpl.logger = this.logger;\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds `config` option to Eleventy constructor. Pass `addGlobalData` results to global data functions. More useTemplateCache forks |
699 | 23.02.2021 22:58:25 | 21,600 | f39b93a2c372473f6d8dc4952d3e761b94a65423 | Delete entries from template cache when there are errors! | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateCache.js",
"new_path": "src/TemplateCache.js",
"diff": "@@ -29,6 +29,12 @@ class TemplateCache {\nreturn this.cache[key];\n}\n+\n+ remove(key) {\n+ if (this.cache[key]) {\n+ delete this.cache[key];\n+ }\n+ }\n}\n// singleton\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -269,6 +269,10 @@ class TemplateContent {\n}\nreturn fn;\n} catch (e) {\n+ let [cacheable, key, cache] = this._getCompileCache(str, bypassMarkdown);\n+ if (cacheable) {\n+ cache.delete(key);\n+ }\ndebug(`Having trouble compiling template ${this.inputPath}: %O`, str);\nthrow new TemplateContentCompileError(\n`Having trouble compiling template ${this.inputPath}`,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateLayout.js",
"new_path": "src/TemplateLayout.js",
"diff": "@@ -44,6 +44,7 @@ class TemplateLayout extends TemplateContent {\n}\nlet tmpl = new TemplateLayout(key, inputDir, extensionMap, config);\n+ debugDev(\"Added %o to TemplateCache\", key);\ntemplateCache.add(fullKey, tmpl);\nreturn tmpl;\n@@ -55,6 +56,7 @@ class TemplateLayout extends TemplateContent {\nasync getTemplateLayoutMapEntry() {\nreturn {\nkey: this.dataKeyLayoutPath,\n+ inputDir: this.inputDir,\ntemplate: this,\nfrontMatterData: await this.getFrontMatterData(),\n};\n@@ -73,7 +75,7 @@ class TemplateLayout extends TemplateContent {\nwhile (mapEntry.frontMatterData && cfgKey in mapEntry.frontMatterData) {\nlet layout = TemplateLayout.getTemplate(\nmapEntry.frontMatterData[cfgKey],\n- this.inputDir,\n+ mapEntry.inputDir,\nthis.config,\nthis.extensionMap\n);\n@@ -114,23 +116,22 @@ class TemplateLayout extends TemplateContent {\nreturn this.layoutChain;\n}\n- async getCompiledLayoutFunctions() {\n- if (this.config.useTemplateCache && this.compileCache) {\n- return this.compileCache;\n- }\n-\n- let map = await this.getTemplateLayoutMap();\n+ async getCompiledLayoutFunctions(layoutMap) {\nlet fns = [];\n- for (let layoutMap of map) {\n+ try {\n+ for (let layoutEntry of layoutMap) {\nfns.push(\n- await layoutMap.template.compile(\n- await layoutMap.template.getPreRender()\n+ await layoutEntry.template.compile(\n+ await layoutEntry.template.getPreRender()\n)\n);\n}\n- if (this.config.useTemplateCache) {\n- this.compileCache = fns;\n+ } catch (e) {\n+ debugDev(\"Clearing TemplateCache after error.\");\n+ templateCache.clear();\n+ return Promise.reject(e);\n}\n+\nreturn fns;\n}\n@@ -153,7 +154,8 @@ class TemplateLayout extends TemplateContent {\nasync render(data, templateContent) {\ndata = TemplateLayout.augmentDataWithContent(data, templateContent);\n- let fns = await this.getCompiledLayoutFunctions();\n+ let layoutMap = await this.getTemplateLayoutMap();\n+ let fns = await this.getCompiledLayoutFunctions(layoutMap);\nfor (let fn of fns) {\ntemplateContent = await fn(data);\ndata = TemplateLayout.augmentDataWithContent(data, templateContent);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Delete entries from template cache when there are errors! |
699 | 05.03.2021 21:55:15 | 21,600 | db902d9b75004ddfc5214b9a2361ef78dfa6b70d | Additional tests for relative dirs paths | [
{
"change_type": "MODIFY",
"old_path": "test/EleventyFilesTest.js",
"new_path": "test/EleventyFilesTest.js",
"diff": "@@ -5,6 +5,42 @@ const TemplatePath = require(\"../src/TemplatePath\");\nconst TemplateConfig = require(\"../src/TemplateConfig\");\nconst TemplatePassthroughManager = require(\"../src/TemplatePassthroughManager\");\n+test(\"Dirs paths\", async (t) => {\n+ let eleventyConfig = new TemplateConfig({\n+ dir: {\n+ input: \"src\",\n+ includes: \"includes\",\n+ data: \"data\",\n+ output: \"dist\",\n+ },\n+ });\n+\n+ let evf = new EleventyFiles(\"src\", \"dist\", [], eleventyConfig);\n+\n+ t.deepEqual(evf.inputDir, \"src\");\n+ t.deepEqual(evf.includesDir, \"src/includes\");\n+ t.deepEqual(evf.getDataDir(), \"src/data\");\n+ t.deepEqual(evf.outputDir, \"dist\");\n+});\n+\n+test(\"Dirs paths (relative)\", async (t) => {\n+ let eleventyConfig = new TemplateConfig({\n+ dir: {\n+ input: \"src\",\n+ includes: \"../includes\",\n+ data: \"../data\",\n+ output: \"dist\",\n+ },\n+ });\n+\n+ let evf = new EleventyFiles(\"src\", \"dist\", [], eleventyConfig);\n+\n+ t.deepEqual(evf.inputDir, \"src\");\n+ t.deepEqual(evf.includesDir, \"includes\");\n+ t.deepEqual(evf.getDataDir(), \"data\");\n+ t.deepEqual(evf.outputDir, \"dist\");\n+});\n+\ntest(\"getFiles\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet evf = new EleventyFiles(\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Additional tests for relative dirs paths |
699 | 17.03.2021 21:52:26 | 18,000 | f4cb6e7d55eaa492fcbebee1fa0ecc6263eb04b6 | Updates a few deps. | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"access\": \"public\"\n},\n\"main\": \"src/Eleventy.js\",\n+ \"bin\": {\n+ \"eleventy\": \"./cmd.js\"\n+ },\n\"license\": \"MIT\",\n\"engines\": {\n\"node\": \">=10\"\n\"ejs\",\n\"haml\"\n],\n- \"bin\": {\n- \"eleventy\": \"./cmd.js\"\n- },\n\"scripts\": {\n\"default\": \"npm run test\",\n\"doc\": \"jsdoc -c .jsdoc.conf.json -d ./api-docs -p ./package.json -R README.md -t ./node_modules/ink-docstrap/template -r src/\",\n]\n},\n\"devDependencies\": {\n- \"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.0.6\",\n+ \"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.0\",\n\"ava\": \"^3.15.0\",\n\"husky\": \"^5.1.3\",\n\"ink-docstrap\": \"1.3.2\",\n\"chalk\": \"^4.1.0\",\n\"chokidar\": \"^3.5.1\",\n\"debug\": \"^4.3.1\",\n- \"dependency-graph\": \"^0.10.0\",\n+ \"dependency-graph\": \"^0.11.0\",\n\"ejs\": \"^3.1.6\",\n\"fast-glob\": \"^3.2.5\",\n\"fs-extra\": \"^9.1.0\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.7.7\",\n\"is-glob\": \"^4.0.1\",\n- \"liquidjs\": \"^9.23.1\",\n+ \"liquidjs\": \"^9.23.2\",\n\"lodash\": \"^4.17.21\",\n\"luxon\": \"^1.26.0\",\n\"markdown-it\": \"^12.0.4\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Updates a few deps. |
699 | 19.03.2021 12:55:43 | 18,000 | d6536ba13fb00e4fc2abc9fc32db38f061bff2b6 | Easy deps to upgrade. Includes Pug 2 -> 3 | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"@11ty/eleventy\",\n- \"version\": \"0.11.1\",\n+ \"version\": \"0.12.0\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"publishConfig\": {\n\"access\": \"public\"\n]\n},\n\"devDependencies\": {\n- \"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.0.1\",\n+ \"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.0\",\n\"@ava/babel\": \"^1.0.1\",\n- \"ava\": \"^3.8.2\",\n+ \"ava\": \"^3.15.0\",\n\"husky\": \"^4.2.5\",\n\"ink-docstrap\": \"1.3.2\",\n\"js-yaml\": \"^3.13.1\",\n- \"jsdoc\": \"3.6.4\",\n- \"lint-staged\": \"^10.2.2\",\n+ \"jsdoc\": \"3.6.6\",\n+ \"lint-staged\": \"^10.5.4\",\n\"markdown-it-emoji\": \"^1.4.0\",\n\"node-sass\": \"^4.14.1\",\n- \"nyc\": \"^15.0.1\",\n- \"prettier\": \"^2.0.5\",\n+ \"nyc\": \"^15.1.0\",\n+ \"prettier\": \"^2.2.1\",\n\"rimraf\": \"^3.0.2\",\n\"toml\": \"^3.0.0\",\n\"viperhtml\": \"^2.17.1\",\n- \"vue\": \"^2.6.11\",\n- \"vue-server-renderer\": \"^2.6.11\"\n+ \"vue\": \"^2.6.12\",\n+ \"vue-server-renderer\": \"^2.6.12\"\n},\n\"dependencies\": {\n\"@11ty/dependency-tree\": \"^1.0.0\",\n- \"browser-sync\": \"^2.26.13\",\n+ \"browser-sync\": \"^2.26.14\",\n\"chalk\": \"^3.0.0\",\n- \"chokidar\": \"^3.4.0\",\n- \"debug\": \"^4.1.1\",\n+ \"chokidar\": \"^3.5.1\",\n+ \"debug\": \"^4.3.1\",\n\"dependency-graph\": \"^0.9.0\",\n\"ejs\": \"^2.7.4\",\n- \"fast-glob\": \"^3.2.2\",\n+ \"fast-glob\": \"^3.2.5\",\n\"fs-extra\": \"^8.1.0\",\n\"gray-matter\": \"^4.0.2\",\n\"hamljs\": \"^0.6.2\",\n- \"handlebars\": \"^4.7.6\",\n+ \"handlebars\": \"^4.7.7\",\n\"javascript-stringify\": \"^2.0.1\",\n\"liquidjs\": \"^6.4.3\",\n- \"lodash\": \"^4.17.15\",\n- \"luxon\": \"^1.24.1\",\n+ \"lodash\": \"^4.17.21\",\n+ \"luxon\": \"^1.26.0\",\n\"markdown-it\": \"^10.0.0\",\n\"minimist\": \"^1.2.5\",\n\"moo\": \"^0.5.1\",\n\"multimatch\": \"^4.0.0\",\n\"mustache\": \"^2.3.2\",\n\"normalize-path\": \"^3.0.0\",\n- \"nunjucks\": \"^3.2.1\",\n+ \"nunjucks\": \"^3.2.3\",\n\"parse-filepath\": \"^1.0.2\",\n\"please-upgrade-node\": \"^3.2.0\",\n\"pretty\": \"^2.0.0\",\n- \"pug\": \"^2.0.4\",\n- \"recursive-copy\": \"^2.0.10\",\n- \"semver\": \"^7.3.2\",\n- \"slugify\": \"^1.4.0\",\n+ \"pug\": \"^3.0.2\",\n+ \"recursive-copy\": \"^2.0.11\",\n+ \"semver\": \"^7.3.4\",\n+ \"slugify\": \"^1.4.7\",\n\"time-require\": \"^0.1.2\",\n\"valid-url\": \"^1.0.9\"\n},\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Easy deps to upgrade. Includes Pug 2 -> 3 |
699 | 19.03.2021 13:13:56 | 18,000 | 2fd65a067d659221604b725d8317a72d9016fcab | Upgrades Husky. | [
{
"change_type": "ADD",
"old_path": null,
"new_path": ".husky/pre-commit",
"diff": "+npm run lint-staged\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": ".husky/pre-push",
"diff": "+npm run test\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"@11ty/eleventy-plugin-syntaxhighlight\": \"^3.1.0\",\n\"@ava/babel\": \"^1.0.1\",\n\"ava\": \"^3.15.0\",\n- \"husky\": \"^4.2.5\",\n+ \"husky\": \"^5.1.3\",\n\"ink-docstrap\": \"1.3.2\",\n\"js-yaml\": \"^3.13.1\",\n\"jsdoc\": \"3.6.6\",\n\"slugify\": \"^1.4.7\",\n\"time-require\": \"^0.1.2\",\n\"valid-url\": \"^1.0.9\"\n- },\n- \"husky\": {\n- \"hooks\": {\n- \"pre-commit\": \"npm run lint-staged\",\n- \"pre-push\": \"npm run test\"\n- }\n}\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Upgrades Husky. |
699 | 19.03.2021 13:16:42 | 18,000 | 32e347ab8594eb5d13fb0d38972915bf95d68627 | Husky tasks. | [
{
"change_type": "MODIFY",
"old_path": ".husky/pre-commit",
"new_path": ".husky/pre-commit",
"diff": "+#!/bin/sh\n+. \"$(dirname \"$0\")/_/husky.sh\"\n+\nnpm run lint-staged\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": ".husky/pre-push",
"new_path": ".husky/pre-push",
"diff": "+#!/bin/sh\n+. \"$(dirname \"$0\")/_/husky.sh\"\n+\nnpm run test\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Husky tasks. |
699 | 19.03.2021 13:32:31 | 18,000 | 56f5bd4e1c58e355745867c14163ee296c4a7444 | Upgrade some of the other deps (not all) | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"ava\": \"^3.15.0\",\n\"husky\": \"^5.1.3\",\n\"ink-docstrap\": \"1.3.2\",\n- \"js-yaml\": \"^3.13.1\",\n+ \"js-yaml\": \"^4.0.0\",\n\"jsdoc\": \"3.6.6\",\n\"lint-staged\": \"^10.5.4\",\n- \"markdown-it-emoji\": \"^1.4.0\",\n- \"node-sass\": \"^4.14.1\",\n+ \"markdown-it-emoji\": \"^2.0.0\",\n+ \"node-sass\": \"^5.0.0\",\n\"nyc\": \"^15.1.0\",\n\"prettier\": \"^2.2.1\",\n\"rimraf\": \"^3.0.2\",\n\"dependencies\": {\n\"@11ty/dependency-tree\": \"^1.0.0\",\n\"browser-sync\": \"^2.26.14\",\n- \"chalk\": \"^3.0.0\",\n+ \"chalk\": \"^4.1.0\",\n\"chokidar\": \"^3.5.1\",\n\"debug\": \"^4.3.1\",\n- \"dependency-graph\": \"^0.9.0\",\n+ \"dependency-graph\": \"^0.11.0\",\n\"ejs\": \"^2.7.4\",\n\"fast-glob\": \"^3.2.5\",\n\"fs-extra\": \"^8.1.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "test/UserDataExtensionsTest.js",
"new_path": "test/UserDataExtensionsTest.js",
"diff": "@@ -4,12 +4,12 @@ let yaml = require(\"js-yaml\");\nfunction injectDataExtensions(dataObj) {\ndataObj.config.dataExtensions = new Map([\n- [\"yaml\", s => yaml.safeLoad(s)],\n- [\"nosj\", JSON.parse]\n+ [\"yaml\", (s) => yaml.load(s)],\n+ [\"nosj\", JSON.parse],\n]);\n}\n-test(\"Local data\", async t => {\n+test(\"Local data\", async (t) => {\nlet dataObj = new TemplateData(\"./test/stubs-630/\");\ninjectDataExtensions(dataObj);\n@@ -37,7 +37,7 @@ test(\"Local data\", async t => {\nt.is(withLocalData.jsKey1, \"js1\");\n});\n-test(\"Local files\", async t => {\n+test(\"Local files\", async (t) => {\nlet dataObj = new TemplateData(\"./test/stubs-630/\");\ninjectDataExtensions(dataObj);\nlet files = await dataObj.getLocalDataPaths(\n@@ -67,17 +67,17 @@ test(\"Local files\", async t => {\n\"./test/stubs-630/component-yaml/component.11tydata.nosj\",\n\"./test/stubs-630/component-yaml/component.11tydata.json\",\n\"./test/stubs-630/component-yaml/component.11tydata.cjs\",\n- \"./test/stubs-630/component-yaml/component.11tydata.js\"\n+ \"./test/stubs-630/component-yaml/component.11tydata.js\",\n]);\n});\n-test(\"Global data\", async t => {\n+test(\"Global data\", async (t) => {\nlet dataObj = new TemplateData(\"./test/stubs-630/\");\ninjectDataExtensions(dataObj);\nt.deepEqual(await dataObj.getGlobalDataGlob(), [\n- \"./test/stubs-630/_data/**/*.(nosj|yaml|json|cjs|js)\"\n+ \"./test/stubs-630/_data/**/*.(nosj|yaml|json|cjs|js)\",\n]);\nlet data = await dataObj.getData();\n@@ -103,7 +103,7 @@ test(\"Global data\", async t => {\nt.is(data.subdir.globalDataSubdir.keyyaml, \"yaml\");\n});\n-test(\"Global data merging and priority\", async t => {\n+test(\"Global data merging and priority\", async (t) => {\nlet dataObj = new TemplateData(\"./test/stubs-630/\");\ninjectDataExtensions(dataObj);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Upgrade some of the other deps (not all) |
699 | 19.03.2021 14:21:05 | 18,000 | 785344c535a3c9d88b2aa37f63c31dceb58d8e9e | Code coverage stats. | [
{
"change_type": "MODIFY",
"old_path": "docs-src/_data/coverage.json",
"new_path": "docs-src/_data/coverage.json",
"diff": "-{\"total\": {\"lines\":{\"total\":3463,\"covered\":3064,\"skipped\":0,\"pct\":88.48},\"statements\":{\"total\":3485,\"covered\":3085,\"skipped\":0,\"pct\":88.52},\"functions\":{\"total\":818,\"covered\":714,\"skipped\":0,\"pct\":87.29},\"branches\":{\"total\":1499,\"covered\":1213,\"skipped\":0,\"pct\":80.92}}\n+{\"total\": {\"lines\":{\"total\":3472,\"covered\":3071,\"skipped\":0,\"pct\":88.45},\"statements\":{\"total\":3493,\"covered\":3091,\"skipped\":0,\"pct\":88.49},\"functions\":{\"total\":820,\"covered\":716,\"skipped\":0,\"pct\":87.32},\"branches\":{\"total\":1503,\"covered\":1215,\"skipped\":0,\"pct\":80.84}}\n,\"/Users/zachleat/Code/eleventy/src/Benchmark.js\": {\"lines\":{\"total\":18,\"covered\":17,\"skipped\":0,\"pct\":94.44},\"functions\":{\"total\":7,\"covered\":7,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":18,\"covered\":17,\"skipped\":0,\"pct\":94.44},\"branches\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33}}\n-,\"/Users/zachleat/Code/eleventy/src/BenchmarkGroup.js\": {\"lines\":{\"total\":46,\"covered\":35,\"skipped\":0,\"pct\":76.09},\"functions\":{\"total\":9,\"covered\":6,\"skipped\":0,\"pct\":66.67},\"statements\":{\"total\":46,\"covered\":35,\"skipped\":0,\"pct\":76.09},\"branches\":{\"total\":21,\"covered\":13,\"skipped\":0,\"pct\":61.9}}\n+,\"/Users/zachleat/Code/eleventy/src/BenchmarkGroup.js\": {\"lines\":{\"total\":46,\"covered\":34,\"skipped\":0,\"pct\":73.91},\"functions\":{\"total\":9,\"covered\":6,\"skipped\":0,\"pct\":66.67},\"statements\":{\"total\":46,\"covered\":34,\"skipped\":0,\"pct\":73.91},\"branches\":{\"total\":21,\"covered\":11,\"skipped\":0,\"pct\":52.38}}\n,\"/Users/zachleat/Code/eleventy/src/BenchmarkManager.js\": {\"lines\":{\"total\":27,\"covered\":21,\"skipped\":0,\"pct\":77.78},\"functions\":{\"total\":8,\"covered\":6,\"skipped\":0,\"pct\":75},\"statements\":{\"total\":27,\"covered\":21,\"skipped\":0,\"pct\":77.78},\"branches\":{\"total\":8,\"covered\":6,\"skipped\":0,\"pct\":75}}\n,\"/Users/zachleat/Code/eleventy/src/ComputedData.js\": {\"lines\":{\"total\":46,\"covered\":46,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":8,\"covered\":8,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":46,\"covered\":46,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":17,\"covered\":17,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/ComputedDataProxy.js\": {\"lines\":{\"total\":51,\"covered\":50,\"skipped\":0,\"pct\":98.04},\"functions\":{\"total\":10,\"covered\":10,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":51,\"covered\":50,\"skipped\":0,\"pct\":98.04},\"branches\":{\"total\":32,\"covered\":29,\"skipped\":0,\"pct\":90.63}}\n,\"/Users/zachleat/Code/eleventy/src/ComputedDataQueue.js\": {\"lines\":{\"total\":21,\"covered\":21,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":10,\"covered\":10,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":21,\"covered\":21,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":11,\"covered\":8,\"skipped\":0,\"pct\":72.73}}\n,\"/Users/zachleat/Code/eleventy/src/ComputedDataTemplateString.js\": {\"lines\":{\"total\":24,\"covered\":24,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":4,\"covered\":4,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":24,\"covered\":24,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":6,\"covered\":5,\"skipped\":0,\"pct\":83.33}}\n,\"/Users/zachleat/Code/eleventy/src/Config.js\": {\"lines\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n-,\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\"lines\":{\"total\":221,\"covered\":122,\"skipped\":0,\"pct\":55.2},\"functions\":{\"total\":40,\"covered\":20,\"skipped\":0,\"pct\":50},\"statements\":{\"total\":222,\"covered\":122,\"skipped\":0,\"pct\":54.95},\"branches\":{\"total\":70,\"covered\":30,\"skipped\":0,\"pct\":42.86}}\n+,\"/Users/zachleat/Code/eleventy/src/Eleventy.js\": {\"lines\":{\"total\":223,\"covered\":123,\"skipped\":0,\"pct\":55.16},\"functions\":{\"total\":40,\"covered\":20,\"skipped\":0,\"pct\":50},\"statements\":{\"total\":224,\"covered\":123,\"skipped\":0,\"pct\":54.91},\"branches\":{\"total\":70,\"covered\":30,\"skipped\":0,\"pct\":42.86}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyBaseError.js\": {\"lines\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":1,\"covered\":1,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyCommandCheck.js\": {\"lines\":{\"total\":28,\"covered\":28,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":5,\"covered\":5,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":28,\"covered\":28,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":8,\"covered\":7,\"skipped\":0,\"pct\":87.5}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyConfig.js\": {\"lines\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyExtensionMap.js\": {\"lines\":{\"total\":64,\"covered\":64,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":23,\"covered\":23,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":64,\"covered\":64,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":31,\"covered\":31,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyFiles.js\": {\"lines\":{\"total\":165,\"covered\":155,\"skipped\":0,\"pct\":93.94},\"functions\":{\"total\":40,\"covered\":36,\"skipped\":0,\"pct\":90},\"statements\":{\"total\":165,\"covered\":155,\"skipped\":0,\"pct\":93.94},\"branches\":{\"total\":61,\"covered\":51,\"skipped\":0,\"pct\":83.61}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyServe.js\": {\"lines\":{\"total\":59,\"covered\":22,\"skipped\":0,\"pct\":37.29},\"functions\":{\"total\":16,\"covered\":9,\"skipped\":0,\"pct\":56.25},\"statements\":{\"total\":59,\"covered\":22,\"skipped\":0,\"pct\":37.29},\"branches\":{\"total\":36,\"covered\":10,\"skipped\":0,\"pct\":27.78}}\n-,\"/Users/zachleat/Code/eleventy/src/EleventyWatch.js\": {\"lines\":{\"total\":33,\"covered\":33,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":16,\"covered\":16,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":35,\"covered\":35,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":17,\"covered\":15,\"skipped\":0,\"pct\":88.24}}\n+,\"/Users/zachleat/Code/eleventy/src/EleventyWatch.js\": {\"lines\":{\"total\":39,\"covered\":39,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":18,\"covered\":18,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":41,\"covered\":41,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":21,\"covered\":19,\"skipped\":0,\"pct\":90.48}}\n,\"/Users/zachleat/Code/eleventy/src/EleventyWatchTargets.js\": {\"lines\":{\"total\":49,\"covered\":45,\"skipped\":0,\"pct\":91.84},\"functions\":{\"total\":21,\"covered\":18,\"skipped\":0,\"pct\":85.71},\"statements\":{\"total\":49,\"covered\":45,\"skipped\":0,\"pct\":91.84},\"branches\":{\"total\":15,\"covered\":14,\"skipped\":0,\"pct\":93.33}}\n,\"/Users/zachleat/Code/eleventy/src/Template.js\": {\"lines\":{\"total\":309,\"covered\":294,\"skipped\":0,\"pct\":95.15},\"functions\":{\"total\":55,\"covered\":54,\"skipped\":0,\"pct\":98.18},\"statements\":{\"total\":311,\"covered\":296,\"skipped\":0,\"pct\":95.18},\"branches\":{\"total\":115,\"covered\":102,\"skipped\":0,\"pct\":88.7}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateCache.js\": {\"lines\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":6,\"covered\":6,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":9,\"covered\":9,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/TemplatePermalinkNoWrite.js\": {\"lines\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"functions\":{\"total\":2,\"covered\":2,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":3,\"covered\":3,\"skipped\":0,\"pct\":100},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateRender.js\": {\"lines\":{\"total\":80,\"covered\":79,\"skipped\":0,\"pct\":98.75},\"functions\":{\"total\":22,\"covered\":22,\"skipped\":0,\"pct\":100},\"statements\":{\"total\":80,\"covered\":79,\"skipped\":0,\"pct\":98.75},\"branches\":{\"total\":46,\"covered\":45,\"skipped\":0,\"pct\":97.83}}\n,\"/Users/zachleat/Code/eleventy/src/TemplateWriter.js\": {\"lines\":{\"total\":112,\"covered\":88,\"skipped\":0,\"pct\":78.57},\"functions\":{\"total\":32,\"covered\":23,\"skipped\":0,\"pct\":71.88},\"statements\":{\"total\":112,\"covered\":88,\"skipped\":0,\"pct\":78.57},\"branches\":{\"total\":28,\"covered\":14,\"skipped\":0,\"pct\":50}}\n-,\"/Users/zachleat/Code/eleventy/src/UserConfig.js\": {\"lines\":{\"total\":215,\"covered\":128,\"skipped\":0,\"pct\":59.53},\"functions\":{\"total\":57,\"covered\":26,\"skipped\":0,\"pct\":45.61},\"statements\":{\"total\":216,\"covered\":129,\"skipped\":0,\"pct\":59.72},\"branches\":{\"total\":88,\"covered\":41,\"skipped\":0,\"pct\":46.59}}\n+,\"/Users/zachleat/Code/eleventy/src/UserConfig.js\": {\"lines\":{\"total\":216,\"covered\":129,\"skipped\":0,\"pct\":59.72},\"functions\":{\"total\":57,\"covered\":26,\"skipped\":0,\"pct\":45.61},\"statements\":{\"total\":216,\"covered\":129,\"skipped\":0,\"pct\":59.72},\"branches\":{\"total\":88,\"covered\":41,\"skipped\":0,\"pct\":46.59}}\n,\"/Users/zachleat/Code/eleventy/src/defaultConfig.js\": {\"lines\":{\"total\":14,\"covered\":11,\"skipped\":0,\"pct\":78.57},\"functions\":{\"total\":4,\"covered\":1,\"skipped\":0,\"pct\":25},\"statements\":{\"total\":14,\"covered\":11,\"skipped\":0,\"pct\":78.57},\"branches\":{\"total\":0,\"covered\":0,\"skipped\":0,\"pct\":100}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/Custom.js\": {\"lines\":{\"total\":34,\"covered\":15,\"skipped\":0,\"pct\":44.12},\"functions\":{\"total\":7,\"covered\":4,\"skipped\":0,\"pct\":57.14},\"statements\":{\"total\":34,\"covered\":15,\"skipped\":0,\"pct\":44.12},\"branches\":{\"total\":20,\"covered\":5,\"skipped\":0,\"pct\":25}}\n,\"/Users/zachleat/Code/eleventy/src/Engines/Ejs.js\": {\"lines\":{\"total\":19,\"covered\":18,\"skipped\":0,\"pct\":94.74},\"functions\":{\"total\":7,\"covered\":6,\"skipped\":0,\"pct\":85.71},\"statements\":{\"total\":19,\"covered\":18,\"skipped\":0,\"pct\":94.74},\"branches\":{\"total\":9,\"covered\":8,\"skipped\":0,\"pct\":88.89}}\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/coverage.md",
"new_path": "docs/coverage.md",
"diff": "-# Code Coverage for Eleventy v0.11.0\n+# Code Coverage for Eleventy v0.12.0\n| Filename | % Lines | % Statements | % Functions | % Branches |\n| ---------------------------------------------------------- | ------- | ------------ | ----------- | ---------- |\n-| `total` | 88.48% | 88.52% | 87.29% | 80.92% |\n+| `total` | 88.45% | 88.49% | 87.32% | 80.84% |\n| `src/Benchmark.js` | 94.44% | 94.44% | 100% | 83.33% |\n-| `src/BenchmarkGroup.js` | 76.09% | 76.09% | 66.67% | 61.9% |\n+| `src/BenchmarkGroup.js` | 73.91% | 73.91% | 66.67% | 52.38% |\n| `src/BenchmarkManager.js` | 77.78% | 77.78% | 75% | 75% |\n| `src/ComputedData.js` | 100% | 100% | 100% | 100% |\n| `src/ComputedDataProxy.js` | 98.04% | 98.04% | 100% | 90.63% |\n| `src/ComputedDataQueue.js` | 100% | 100% | 100% | 72.73% |\n| `src/ComputedDataTemplateString.js` | 100% | 100% | 100% | 83.33% |\n| `src/Config.js` | 100% | 100% | 100% | 100% |\n-| `src/Eleventy.js` | 55.2% | 54.95% | 50% | 42.86% |\n+| `src/Eleventy.js` | 55.16% | 54.91% | 50% | 42.86% |\n| `src/EleventyBaseError.js` | 100% | 100% | 100% | 100% |\n| `src/EleventyCommandCheck.js` | 100% | 100% | 100% | 87.5% |\n| `src/EleventyConfig.js` | 100% | 100% | 100% | 100% |\n| `src/EleventyExtensionMap.js` | 100% | 100% | 100% | 100% |\n| `src/EleventyFiles.js` | 93.94% | 93.94% | 90% | 83.61% |\n| `src/EleventyServe.js` | 37.29% | 37.29% | 56.25% | 27.78% |\n-| `src/EleventyWatch.js` | 100% | 100% | 100% | 88.24% |\n+| `src/EleventyWatch.js` | 100% | 100% | 100% | 90.48% |\n| `src/EleventyWatchTargets.js` | 91.84% | 91.84% | 85.71% | 93.33% |\n| `src/Template.js` | 95.15% | 95.18% | 98.18% | 88.7% |\n| `src/TemplateCache.js` | 100% | 100% | 100% | 100% |\n| `src/TemplatePermalinkNoWrite.js` | 100% | 100% | 100% | 100% |\n| `src/TemplateRender.js` | 98.75% | 98.75% | 100% | 97.83% |\n| `src/TemplateWriter.js` | 78.57% | 78.57% | 71.88% | 50% |\n-| `src/UserConfig.js` | 59.53% | 59.72% | 45.61% | 46.59% |\n+| `src/UserConfig.js` | 59.72% | 59.72% | 45.61% | 46.59% |\n| `src/defaultConfig.js` | 78.57% | 78.57% | 25% | 100% |\n| `src/Engines/Custom.js` | 44.12% | 44.12% | 57.14% | 25% |\n| `src/Engines/Ejs.js` | 94.74% | 94.74% | 85.71% | 88.89% |\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Code coverage stats. |
699 | 19.03.2021 21:21:52 | 18,000 | e6c2f2c82b511e8f451ff34f0c7f98c396bb01ef | Add Node 15 to GitHub Actions (to be prepared) | [
{
"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\"]\n+ node: [\"12\", \"14\", \"15\"]\nname: Node.js ${{ matrix.node }} on ${{ matrix.os }}\nsteps:\n- uses: actions/checkout@v2\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Add Node 15 to GitHub Actions (to be prepared) |
705 | 22.03.2021 11:01:30 | -39,600 | d7db5026a341c97dea82d4307393b48c8e41fcd1 | Pagination: add pageOnEmptyData option | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/Pagination.js",
"new_path": "src/Plugins/Pagination.js",
"diff": "@@ -183,7 +183,11 @@ class Pagination {\nlet hrefs = [];\nlet overrides = [];\n- for (let pageNumber = 0, k = items.length; pageNumber < k; pageNumber++) {\n+ const totalPages =\n+ items.length ? items.length : (\n+ this.data.pagination.pageOnEmptyData ? 1 : 0);\n+\n+ for (let pageNumber = 0; pageNumber < totalPages; pageNumber++) {\nlet cloned = tmpl.clone();\n// TODO maybe also move this permalink additions up into the pagination class\n"
},
{
"change_type": "MODIFY",
"old_path": "test/PaginationTest.js",
"new_path": "test/PaginationTest.js",
"diff": "@@ -44,6 +44,46 @@ test(\"No pagination\", async (t) => {\nt.is((await paging.getPageTemplates()).length, 0);\n});\n+test(\"Empty paged data\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/paged/paged-empty.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ null,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ let paging = new Pagination(data, tmpl.config);\n+ paging.setTemplate(tmpl);\n+\n+ t.is(paging.getPageCount(), 0);\n+ t.is(paging.pagedItems.length, 0);\n+ t.is((await paging.getPageTemplates()).length, 0);\n+});\n+\n+test(\"Empty paged data with pageOnEmptyData enabled\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/paged/paged-empty-pageonemptydata.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ null,\n+ null,\n+ eleventyConfig\n+ );\n+\n+ let data = await tmpl.getData();\n+ let paging = new Pagination(data, tmpl.config);\n+ paging.setTemplate(tmpl);\n+\n+ t.is(paging.getPageCount(), 0);\n+ t.is(paging.pagedItems.length, 0);\n+ t.is((await paging.getPageTemplates()).length, 1);\n+});\n+\ntest(\"Pagination enabled in frontmatter\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet tmpl = getNewTemplate(\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/paged/paged-empty-pageonemptydata.njk",
"diff": "+---\n+pagination:\n+ data: items\n+ size: 1\n+ pageOnEmptyData: true\n+items: []\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item }}</li>{% endfor %}</ol>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/paged/paged-empty.njk",
"diff": "+---\n+pagination:\n+ data: items\n+ size: 1\n+items: []\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item }}</li>{% endfor %}</ol>\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Pagination: add pageOnEmptyData option |
699 | 22.03.2021 09:04:26 | 18,000 | 77f7e88476fffd6671f5c644ce9da506695ed3c4 | Test config getting passed around. | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyExtensionMap.js",
"new_path": "src/EleventyExtensionMap.js",
"diff": "@@ -10,6 +10,9 @@ class EleventyExtensionMap {\nif (!config) {\nthrow new EleventyExtensionMapConfigError(\"Missing `config` argument.\");\n}\n+ if (config instanceof TemplateConfig) {\n+ this.eleventyConfig = config;\n+ }\nthis._config = config;\nthis.formatKeys = formatKeys;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -224,3 +224,14 @@ test(\"Two Eleventies, two configs!!! (config used to be a global)\", async (t) =>\nt.not(elev1.eleventyConfig, elev2.eleventyConfig);\nt.is(JSON.stringify(elev1.config), JSON.stringify(elev2.config));\n});\n+\n+test(\"Config propagates to other instances correctly\", async (t) => {\n+ let elev = new Eleventy();\n+ await elev.init();\n+\n+ t.is(elev.extensionMap.eleventyConfig, elev.eleventyConfig);\n+ t.is(elev.eleventyServe.config, elev.eleventyConfig);\n+ t.is(elev.eleventyFiles.eleventyConfig, elev.eleventyConfig);\n+ t.is(elev.templateData.eleventyConfig, elev.eleventyConfig);\n+ t.is(elev.writer.eleventyConfig, elev.eleventyConfig);\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Test config getting passed around. |
699 | 22.03.2021 09:04:49 | 18,000 | 6ecbd639c839944b161c4afe205730922b427945 | Node 10 note. | [
{
"change_type": "MODIFY",
"old_path": "docs/meta-release.md",
"new_path": "docs/meta-release.md",
"diff": "1. 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+\n1. npm audit\n1. Make sure `npx ava` runs okay\n1. Update version in `package.json`\n1. Tag new version\n1. `npm publish --access=public`\n-1. Bonus for 0.x branch, make sure it still works in node 8 (see `Temp/eleventy-node-8` sample project)\n-\n## If Docs branch does not yet exist\n1. Check in a new `11ty-website` site with updated `package.json` version.\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Node 10 note. |
699 | 22.03.2021 09:05:11 | 18,000 | 7b62af88610b49290e5b92aeea0d4976a8ede686 | Make the tests a bit more resilient when creating files. | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateWriterTest.js",
"new_path": "test/TemplateWriterTest.js",
"diff": "@@ -425,6 +425,8 @@ test(\"Glob Watcher Files with Passthroughs\", (t) => {\n});\ntest(\"Pagination and TemplateContent\", async (t) => {\n+ rimraf.sync(\"./test/stubs/pagination-templatecontent/_site/\");\n+\nlet eleventyConfig = new TemplateConfig();\nlet tw = new TemplateWriter(\n\"./test/stubs/pagination-templatecontent\",\n@@ -698,6 +700,8 @@ test.skip(\"JavaScript with alias\", async (t) => {\n});\ntest(\"Passthrough file output\", async (t) => {\n+ rimraf.sync(\"./test/stubs/template-passthrough/_site/\");\n+\nlet eleventyConfig = new TemplateConfig();\neleventyConfig.userConfig.passthroughCopies = {\n\"./test/stubs/template-passthrough/static\": true,\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Make the tests a bit more resilient when creating files. |
699 | 22.03.2021 17:28:24 | 18,000 | 4249f48e6b20748f172a7f12b7c00ca0a565fece | Moves incremental checks around to allow `isIncrementalMatch` checks to be passed in to custom template engines. | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -521,25 +521,8 @@ Arguments:\nlet incrementalFile = this.watchManager.getIncrementalFile();\nif (incrementalFile) {\n- // TODO remove these and delegate to the template dependency graph\n- let isInclude = TemplatePath.startsWithSubPath(\n- incrementalFile,\n- this.eleventyFiles.getIncludesDir()\n- );\n-\n- let isLayout = false;\n- let layoutsDir = this.eleventyFiles.getLayoutsDir();\n- if (layoutsDir) {\n- isLayout = TemplatePath.startsWithSubPath(incrementalFile, layoutsDir);\n- }\n-\n- let isJSDependency = this.watchTargets.isJavaScriptDependency(\n- incrementalFile\n- );\n- if (!isInclude && !isLayout && !isJSDependency) {\nthis.writer.setIncrementalFile(incrementalFile);\n}\n- }\nawait this.write();\n// let writeResult = await this.write();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyExtensionMap.js",
"new_path": "src/EleventyExtensionMap.js",
"diff": "@@ -71,7 +71,10 @@ class EleventyExtensionMap {\nreturn files;\n}\n- isFullTemplateFilename(path) {\n+ // Warning: this would false positive on an include, but is only used\n+ // on paths found from the file system glob search.\n+ // TODO: Method name might just need to be renamed to something more accurate.\n+ isFullTemplateFilePath(path) {\nfor (let extension of this.validTemplateLanguageKeys) {\nif (path.endsWith(`.${extension}`)) {\nreturn true;\n@@ -128,6 +131,18 @@ class EleventyExtensionMap {\nreturn extensions;\n}\n+ getExtensionEntriesFromKey(key) {\n+ let entries = [];\n+ if (\"extensionMap\" in this.config) {\n+ for (let entry of this.config.extensionMap) {\n+ if (entry.key === key) {\n+ entries.push(entry);\n+ }\n+ }\n+ }\n+ return entries;\n+ }\n+\nhasEngine(pathOrKey) {\nreturn !!this.getKey(pathOrKey);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EleventyFiles.js",
"new_path": "src/EleventyFiles.js",
"diff": "@@ -105,6 +105,7 @@ class EleventyFiles {\nrestart() {\nthis.passthroughManager.reset();\nthis.setupGlobs();\n+ this._glob = null;\n}\n/* For testing */\n@@ -344,42 +345,67 @@ class EleventyFiles {\n);\n}\n+ // Filter out the passthrough copy paths.\nreturn this.pathCache.filter((path) =>\n- this.extensionMap.isFullTemplateFilename(path)\n+ this.extensionMap.isFullTemplateFilePath(path)\n);\n}\n- async getFiles() {\n+ _globSearch() {\n+ if (this._glob) {\n+ return this._glob;\n+ }\n+\nlet globs = this.getFileGlobs();\n+ // returns a promise\ndebug(\"Searching for: %o\", globs);\n- let bench = aggregateBench.get(\"Searching the file system\");\n- bench.before();\n- let paths = TemplatePath.addLeadingDotSlashArray(\n- await fastglob(globs, {\n+ this._glob = fastglob(globs, {\ncaseSensitiveMatch: false,\ndot: true,\n- })\n- );\n+ });\n+\n+ return this._glob;\n+ }\n+\n+ async getFiles() {\n+ let bench = aggregateBench.get(\"Searching the file system\");\n+ bench.before();\n+ let globResults = await this._globSearch();\n+ let paths = TemplatePath.addLeadingDotSlashArray(globResults);\nbench.after();\n+ // filter individual paths in the new config-specified extension\n+ // where is this used?\nif (\"extensionMap\" in this.config) {\nlet extensions = this.config.extensionMap;\n+ if (Array.from(extensions).filter((entry) => !!entry.filter).length) {\npaths = paths.filter(function (path) {\nfor (let entry of extensions) {\n- // TODO `.${extension}` ?\n- if (path.endsWith(entry.extension) && entry.filter) {\n+ if (entry.filter && path.endsWith(`.${entry.extension}`)) {\nreturn entry.filter(path);\n}\n}\nreturn true;\n});\n}\n+ }\nthis.pathCache = paths;\nreturn paths;\n}\n+ // Assumption here that filePath is not a passthrough copy file\n+ isFullTemplateFile(paths, filePath) {\n+ for (let path of paths) {\n+ if (path === filePath) {\n+ return true;\n+ }\n+ }\n+\n+ return false;\n+ }\n+\n/* For `eleventy --watch` */\ngetGlobWatcherFiles() {\n// TODO is it better to tie the includes and data to specific file extensions or keep the **?\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/TemplateEngine.js",
"new_path": "src/Engines/TemplateEngine.js",
"diff": "@@ -61,6 +61,15 @@ class TemplateEngine {\nreturn this._extensions;\n}\n+ get extensionEntries() {\n+ if (!this._extensionEntries) {\n+ this._extensionEntries = this.extensionMap.getExtensionEntriesFromKey(\n+ this.name\n+ );\n+ }\n+ return this._extensionEntries;\n+ }\n+\ngetName() {\nreturn this.name;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -310,6 +310,50 @@ class TemplateContent {\n}\n}\n}\n+\n+ getExtensionEntries() {\n+ let extensions = this.templateRender.engine.extensionEntries;\n+ return extensions;\n+ }\n+\n+ isFileRelevantToThisTemplate(incrementalFile, metadata = {}) {\n+ // always relevant if incremental file not set (build everything)\n+ if (!incrementalFile) {\n+ return true;\n+ }\n+\n+ let incrementalFileIsFullTemplate = metadata.incrementalFileIsFullTemplate;\n+ let extensionEntries = this.getExtensionEntries().filter(\n+ (entry) => !!entry.isIncrementalMatch\n+ );\n+ if (extensionEntries.length) {\n+ for (let entry of extensionEntries) {\n+ if (\n+ entry.isIncrementalMatch.call(\n+ {\n+ inputPath: this.inputPath,\n+ },\n+ incrementalFile\n+ )\n+ ) {\n+ return true;\n+ }\n+ }\n+ } else {\n+ // Not great way of building all templates if this is a layout, include, JS dependency.\n+ // TODO improve this for default langs\n+ if (!incrementalFileIsFullTemplate) {\n+ return true;\n+ }\n+\n+ // only build if this input path is the same as the file that was changed\n+ if (this.inputPath === incrementalFile) {\n+ return true;\n+ }\n+ }\n+\n+ return false;\n+ }\n}\nTemplateContent._inputCache = new Map();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePassthroughManager.js",
"new_path": "src/TemplatePassthroughManager.js",
"diff": "@@ -51,8 +51,10 @@ class TemplatePassthroughManager {\n}\nsetIncrementalFile(path) {\n+ if (path) {\nthis.incrementalFile = path;\n}\n+ }\n_normalizePaths(path, outputPath) {\nreturn {\n@@ -168,12 +170,12 @@ class TemplatePassthroughManager {\n}\ngetAllNormalizedPaths(paths) {\n- if (\n- this.incrementalFile &&\n- this.isPassthroughCopyFile(paths, this.incrementalFile)\n- ) {\n+ if (this.incrementalFile) {\n+ if (this.isPassthroughCopyFile(paths, this.incrementalFile)) {\nreturn [this._normalizePaths(this.incrementalFile)];\n}\n+ return [];\n+ }\nlet normalizedPaths = [];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -150,12 +150,17 @@ class TemplateWriter {\nreturn this.allPaths;\n}\n- _createTemplate(path) {\n- let tmpl = this._templatePathCache.get(path);\n- if (tmpl) {\n- return tmpl;\n+ _isIncrementalFileAPassthroughCopy(paths) {\n+ let passthroughManager = this.eleventyFiles.getPassthroughManager();\n+ return passthroughManager.isPassthroughCopyFile(\n+ paths,\n+ this.incrementalFile\n+ );\n}\n+ _createTemplate(path, allPaths) {\n+ let tmpl = this._templatePathCache.get(path);\n+ if (!tmpl) {\ntmpl = new Template(\npath,\nthis.inputDir,\n@@ -168,15 +173,6 @@ class TemplateWriter {\ntmpl.logger = this.logger;\nthis._templatePathCache.set(path, tmpl);\n- tmpl.setIsVerbose(this.isVerbose);\n-\n- // --incremental only writes files that trigger a build during --watch\n- if (this.incrementalFile && path !== this.incrementalFile) {\n- tmpl.setDryRun(true);\n- } else {\n- tmpl.setDryRun(this.isDryRun);\n- }\n-\n/*\n* Sample filter: arg str, return pretty HTML string\n* function(str) {\n@@ -196,6 +192,31 @@ class TemplateWriter {\ntmpl.addLinter(linter);\n}\n}\n+ }\n+\n+ tmpl.setIsVerbose(this.isVerbose);\n+\n+ // --incremental only writes files that trigger a build during --watch\n+ if (this.incrementalFile) {\n+ // incremental file is a passthrough copy (not a template)\n+ if (this._isIncrementalFileAPassthroughCopy(allPaths)) {\n+ tmpl.setDryRun(true);\n+ // Passthrough copy check is above this (order is important)\n+ } else if (\n+ tmpl.isFileRelevantToThisTemplate(this.incrementalFile, {\n+ incrementalFileIsFullTemplate: this.eleventyFiles.isFullTemplateFile(\n+ allPaths,\n+ this.incrementalFile\n+ ),\n+ })\n+ ) {\n+ tmpl.setDryRun(this.isDryRun);\n+ } else {\n+ tmpl.setDryRun(true);\n+ }\n+ } else {\n+ tmpl.setDryRun(this.isDryRun);\n+ }\nreturn tmpl;\n}\n@@ -204,9 +225,7 @@ class TemplateWriter {\nlet promises = [];\nfor (let path of paths) {\nif (this.extensionMap.hasEngine(path)) {\n- promises.push(\n- this.templateMap.add(this._createTemplate(path))\n- );\n+ promises.push(this.templateMap.add(this._createTemplate(path, paths)));\n}\ndebug(`${path} begun adding to map.`);\n}\n@@ -236,9 +255,7 @@ class TemplateWriter {\nasync writePassthroughCopy(paths) {\nlet passthroughManager = this.eleventyFiles.getPassthroughManager();\n- if (this.incrementalFile) {\npassthroughManager.setIncrementalFile(this.incrementalFile);\n- }\nreturn passthroughManager.copyAll(paths).catch((e) => {\nthis.errorHandler.warn(e, \"Error with passthrough copy\");\n@@ -296,17 +313,11 @@ class TemplateWriter {\nasync write() {\nlet paths = await this._getAllPaths();\nlet promises = [];\n+\npromises.push(this.writePassthroughCopy(paths));\n- // Only write templates if not using incremental OR if incremental file was *not* a passthrough copy\n- if (\n- !this.incrementalFile ||\n- !this.eleventyFiles\n- .getPassthroughManager()\n- .isPassthroughCopyFile(paths, this.incrementalFile)\n- ) {\npromises.push(...(await this.generateTemplates(paths)));\n- }\n+\nreturn Promise.all(promises).catch((e) => {\nreturn Promise.reject(e);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyExtensionMapTest.js",
"new_path": "test/EleventyExtensionMapTest.js",
"diff": "@@ -133,7 +133,7 @@ test(\"getKey\", (t) => {\nt.is(map.getKey(\"component.js\"), undefined);\n});\n-test(\"isFullTemplateFilename (not a passthrough copy extension)\", (t) => {\n+test(\"isFullTemplateFilePath (not a passthrough copy extension)\", (t) => {\nlet map = getExtensionMap([\n\"liquid\",\n\"njk\",\n@@ -143,11 +143,11 @@ test(\"isFullTemplateFilename (not a passthrough copy extension)\", (t) => {\n\"js\",\n\"css\",\n]);\n- t.true(map.isFullTemplateFilename(\"template.liquid\"));\n- t.true(map.isFullTemplateFilename(\"template.njk\"));\n- t.true(map.isFullTemplateFilename(\"template.11ty.js\"));\n- t.true(map.isFullTemplateFilename(\"template.ejs\"));\n- t.true(map.isFullTemplateFilename(\"template.pug\"));\n- t.false(map.isFullTemplateFilename(\"passthrough.js\"));\n- t.false(map.isFullTemplateFilename(\"passthrough.css\"));\n+ t.true(map.isFullTemplateFilePath(\"template.liquid\"));\n+ t.true(map.isFullTemplateFilePath(\"template.njk\"));\n+ t.true(map.isFullTemplateFilePath(\"template.11ty.js\"));\n+ t.true(map.isFullTemplateFilePath(\"template.ejs\"));\n+ t.true(map.isFullTemplateFilePath(\"template.pug\"));\n+ t.false(map.isFullTemplateFilePath(\"passthrough.js\"));\n+ t.false(map.isFullTemplateFilePath(\"passthrough.css\"));\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -2056,14 +2056,16 @@ test(\"Engine Singletons\", async (t) => {\n\"./test/stubs/engine-singletons/\",\n\"./dist\",\nnull,\n- map\n+ map,\n+ eleventyConfig\n);\nlet tmpl2 = getNewTemplate(\n\"./test/stubs/engine-singletons/second.njk\",\n\"./test/stubs/engine-singletons/\",\n\"./dist\",\nnull,\n- map\n+ map,\n+ eleventyConfig\n);\nt.deepEqual(tmpl1.engine, tmpl2.engine);\n@@ -2111,3 +2113,39 @@ test(\"Make sure layout cache takes new changes during watch (liquid)\", async (t)\nt.is((await tmpl.render(data)).trim(), '<script>alert(\"bye\");</script>');\n});\n+\n+test(\"Add Extension via Configuration (txt file)\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.extensionMap.add({\n+ extension: \"txt\",\n+ key: \"txt\",\n+ isIncrementalMatch: function (incrementalFilePath) {\n+ // do some kind of check\n+ return this.inputPath === incrementalFilePath;\n+ },\n+ compile: function (str, inputPath) {\n+ // plaintext\n+ return function (data) {\n+ return str;\n+ };\n+ },\n+ });\n+\n+ let map = new EleventyExtensionMap([], eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/default.txt\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ null,\n+ map,\n+ eleventyConfig\n+ );\n+\n+ let extensions = tmpl.getExtensionEntries();\n+ t.deepEqual(extensions[0].key, \"txt\");\n+ t.deepEqual(extensions[0].extension, \"txt\");\n+\n+ t.truthy(tmpl.isFileRelevantToThisTemplate(\"./test/stubs/default.txt\"));\n+ t.falsy(tmpl.isFileRelevantToThisTemplate(\"./test/stubs/default2.txt\"));\n+ t.falsy(tmpl.isFileRelevantToThisTemplate(\"./test/stubs/default.njk\"));\n+});\n"
},
{
"change_type": "ADD",
"old_path": "test/stubs/add-extension/test.njk",
"new_path": "test/stubs/add-extension/test.njk",
"diff": ""
},
{
"change_type": "ADD",
"old_path": "test/stubs/add-extension/test.txt",
"new_path": "test/stubs/add-extension/test.txt",
"diff": ""
}
]
| JavaScript | MIT License | 11ty/eleventy | Moves incremental checks around to allow `isIncrementalMatch` checks to be passed in to custom template engines. |
699 | 22.03.2021 21:46:01 | 18,000 | a56eae493450d6e0594a9eb6e109345a2c8e3c0d | Refactor away from forEach (eww) | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyExtensionMap.js",
"new_path": "src/EleventyExtensionMap.js",
"diff": "@@ -98,17 +98,15 @@ class EleventyExtensionMap {\n_getGlobs(formatKeys, inputDir) {\nlet dir = TemplatePath.convertToRecursiveGlobSync(inputDir);\nlet globs = [];\n- formatKeys.forEach(\n- function (key) {\n+ for (let key of formatKeys) {\nif (this.hasExtension(key)) {\n- this.getExtensionsFromKey(key).forEach(function (extension) {\n+ for (let extension of this.getExtensionsFromKey(key)) {\nglobs.push(dir + \"/*.\" + extension);\n- });\n+ }\n} else {\nglobs.push(dir + \"/*.\" + key);\n}\n- }.bind(this)\n- );\n+ }\nreturn globs;\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Refactor away from forEach (eww) |
699 | 22.03.2021 21:47:08 | 18,000 | 7f86629bf18baf73bcbac947fc762b482e627c5c | Move to use fastglob ignore option instead of negated strings (for speeeed) | [
{
"change_type": "MODIFY",
"old_path": "src/EleventyFiles.js",
"new_path": "src/EleventyFiles.js",
"diff": "@@ -65,7 +65,7 @@ class EleventyFiles {\ninit() {\nthis.alreadyInit = true;\n- // Input was a directory\n+ // Input is a directory\nif (this.input === this.inputDir) {\nthis.templateGlobs = this.extensionMap.getGlobs(this.inputDir);\n} else {\n@@ -79,6 +79,7 @@ class EleventyFiles {\nget validTemplateGlobs() {\nif (!this._validTemplateGlobs) {\nlet globs;\n+ // Input is a directory\nif (this.input === this.inputDir) {\nglobs = this.extensionMap.getValidGlobs(this.inputDir);\n} else {\n@@ -175,20 +176,26 @@ class EleventyFiles {\nsetupGlobs() {\nthis.fileIgnores = this.getIgnores();\n+ this.extraIgnores = this._getIncludesAndDataDirs();\nif (this.passthroughAll) {\n- this.templateGlobsWithIgnoresFromFiles = TemplateGlob.map([\n+ this.normalizedTemplateGlobs = TemplateGlob.map([\nTemplateGlob.normalizePath(this.input, \"/**\"),\n- ]).concat(this.fileIgnores);\n+ ]);\n} else {\n- this.templateGlobsWithIgnoresFromFiles = this.templateGlobs.concat(\n- this.fileIgnores\n- );\n+ this.normalizedTemplateGlobs = this.templateGlobs;\n+ }\n}\n- this.templateGlobsWithAllIgnores = this.templateGlobsWithIgnoresFromFiles.concat(\n- this._getIncludesAndDataDirIgnores()\n- );\n+ getIgnoreGlobs() {\n+ let uniqueIgnores = new Set();\n+ for (let ignore of this.fileIgnores) {\n+ uniqueIgnores.add(ignore);\n+ }\n+ for (let ignore of this.extraIgnores) {\n+ uniqueIgnores.add(ignore);\n+ }\n+ return Array.from(uniqueIgnores);\n}\nstatic getFileIgnores(ignoreFiles, defaultIfFileDoesNotExist) {\n@@ -221,10 +228,10 @@ class EleventyFiles {\n}\nif (!fileFound && defaultIfFileDoesNotExist) {\n- ignores.push(\"!\" + TemplateGlob.normalizePath(defaultIfFileDoesNotExist));\n+ ignores.push(TemplateGlob.normalizePath(defaultIfFileDoesNotExist));\nfor (let dir of dirs) {\nignores.push(\n- \"!\" + TemplateGlob.normalizePath(dir, defaultIfFileDoesNotExist)\n+ TemplateGlob.normalizePath(dir, defaultIfFileDoesNotExist)\n);\n}\n}\n@@ -270,11 +277,11 @@ class EleventyFiles {\n// Note these folders must exist to get /** suffix\nlet stat = fs.statSync(path);\nif (stat.isDirectory()) {\n- return \"!\" + path + \"/**\";\n+ return path + \"/**\";\n}\n- return \"!\" + path;\n+ return path;\n} catch (e) {\n- return \"!\" + path;\n+ return path;\n}\n});\n}\n@@ -315,7 +322,7 @@ class EleventyFiles {\n// ignore output dir unless that would occlude all input\nif (!TemplatePath.startsWithSubPath(this.inputDir, this.outputDir)) {\n- files = files.concat(TemplateGlob.map(\"!\" + this.outputDir + \"/**\"));\n+ files = files.concat(TemplateGlob.map(this.outputDir + \"/**\"));\n}\nreturn files;\n@@ -330,7 +337,7 @@ class EleventyFiles {\n}\ngetFileGlobs() {\n- return this.templateGlobsWithAllIgnores;\n+ return this.normalizedTemplateGlobs;\n}\ngetRawFiles() {\n@@ -363,6 +370,7 @@ class EleventyFiles {\nthis._glob = fastglob(globs, {\ncaseSensitiveMatch: false,\ndot: true,\n+ ignore: this.getIgnoreGlobs(),\n});\nreturn this._glob;\n@@ -441,7 +449,7 @@ class EleventyFiles {\ngetGlobWatcherIgnores() {\n// convert to format without ! since they are passed in as a separate argument to glob watcher\nreturn this.fileIgnores.map((ignore) =>\n- TemplatePath.stripLeadingDotSlash(ignore.substr(1))\n+ TemplatePath.stripLeadingDotSlash(ignore)\n);\n}\n@@ -466,12 +474,6 @@ class EleventyFiles {\nreturn files;\n}\n-\n- _getIncludesAndDataDirIgnores() {\n- return this._getIncludesAndDataDirs().map(function (dir) {\n- return \"!\" + dir;\n- });\n- }\n}\nmodule.exports = EleventyFiles;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyFilesTest.js",
"new_path": "test/EleventyFilesTest.js",
"diff": "@@ -174,8 +174,10 @@ test(\"Single File Input (shallow path)\", async (t) => {\n);\nevf.init();\n- let globs = evf.getFileGlobs().filter((path) => path !== \"!./README.md\");\n- let files = await fastglob(globs);\n+ let globs = evf.getFileGlobs(); //.filter((path) => path !== \"./README.md\");\n+ let files = await fastglob(globs, {\n+ ignore: evf.getIgnoreGlobs(),\n+ });\nt.is(evf.getRawFiles().length, 1);\nt.is(files.length, 1);\nt.is(files[0], \"./README.md\");\n@@ -202,8 +204,8 @@ test(\"Glob Input\", async (t) => {\ntest(\".eleventyignore parsing\", (t) => {\nlet ignores = EleventyFiles.getFileIgnores(\"./test/stubs/.eleventyignore\");\nt.is(ignores.length, 2);\n- t.is(ignores[0], \"!./test/stubs/ignoredFolder/**\");\n- t.is(ignores[1], \"!./test/stubs/ignoredFolder/ignored.md\");\n+ t.is(ignores[0], \"./test/stubs/ignoredFolder/**\");\n+ t.is(ignores[1], \"./test/stubs/ignoredFolder/ignored.md\");\n});\ntest(\"Parse multiple .eleventyignores\", (t) => {\n@@ -213,15 +215,12 @@ test(\"Parse multiple .eleventyignores\", (t) => {\n]);\nt.is(ignores.length, 4);\n// Note these folders must exist!\n- t.is(ignores[0], \"!./test/stubs/multiple-ignores/ignoredFolder/**\");\n- t.is(ignores[1], \"!./test/stubs/multiple-ignores/ignoredFolder/ignored.md\");\n- t.is(\n- ignores[2],\n- \"!./test/stubs/multiple-ignores/subfolder/ignoredFolder2/**\"\n- );\n+ t.is(ignores[0], \"./test/stubs/multiple-ignores/ignoredFolder/**\");\n+ t.is(ignores[1], \"./test/stubs/multiple-ignores/ignoredFolder/ignored.md\");\n+ t.is(ignores[2], \"./test/stubs/multiple-ignores/subfolder/ignoredFolder2/**\");\nt.is(\nignores[3],\n- \"!./test/stubs/multiple-ignores/subfolder/ignoredFolder2/ignored2.md\"\n+ \"./test/stubs/multiple-ignores/subfolder/ignoredFolder2/ignored2.md\"\n);\n});\n@@ -231,7 +230,7 @@ test(\"defaults if passed file name does not exist\", (t) => {\n\"node_modules/**\"\n);\nt.truthy(ignores.length);\n- t.is(ignores[0], \"!./node_modules/**\");\n+ t.is(ignores[0], \"./node_modules/**\");\n});\ntest(\".eleventyignore files\", async (t) => {\n@@ -246,7 +245,9 @@ test(\".eleventyignore files\", async (t) => {\nlet ignoredFiles = await fastglob(\"test/stubs/ignoredFolder/*.md\");\nt.is(ignoredFiles.length, 1);\n- let files = await fastglob(evf.getFileGlobs());\n+ let files = await fastglob(evf.getFileGlobs(), {\n+ ignore: evf.getIgnoreGlobs(),\n+ });\nt.true(files.length > 0);\n@@ -272,11 +273,11 @@ test(\"Get ignores (no .eleventyignore no .gitignore)\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"!./node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/node_modules/**\",\n- \"!./test/stubs/ignore1/node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/test.md\",\n- \"!./test/stubs/ignore1/_site/**\",\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignore1/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore1/_site/**\",\n]);\n});\n@@ -292,9 +293,9 @@ test(\"Get ignores (no .eleventyignore)\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"!./test/stubs/ignore2/thisshouldnotexist12345\",\n- \"!./test/stubs/ignorelocalroot/test.md\",\n- \"!./test/stubs/ignore2/_site/**\",\n+ \"./test/stubs/ignore2/thisshouldnotexist12345\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore2/_site/**\",\n]);\n});\n@@ -317,8 +318,8 @@ test(\"Get ignores (no .eleventyignore, using setUseGitIgnore(false))\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"!./test/stubs/ignorelocalroot/test.md\",\n- \"!./test/stubs/ignore2/_site/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore2/_site/**\",\n]);\n});\n@@ -334,13 +335,13 @@ test(\"Get ignores (no .gitignore)\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"!./node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/node_modules/**\",\n- \"!./test/stubs/ignore3/node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/test.md\",\n- \"!./test/stubs/ignore3/ignoredFolder/**\",\n- \"!./test/stubs/ignore3/ignoredFolder/ignored.md\",\n- \"!./test/stubs/ignore3/_site/**\",\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignore3/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore3/ignoredFolder/**\",\n+ \"./test/stubs/ignore3/ignoredFolder/ignored.md\",\n+ \"./test/stubs/ignore3/_site/**\",\n]);\n});\n@@ -356,11 +357,11 @@ test(\"Get ignores (both .eleventyignore and .gitignore)\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"!./test/stubs/ignore4/thisshouldnotexist12345\",\n- \"!./test/stubs/ignorelocalroot/test.md\",\n- \"!./test/stubs/ignore4/ignoredFolder/**\",\n- \"!./test/stubs/ignore4/ignoredFolder/ignored.md\",\n- \"!./test/stubs/ignore4/_site/**\",\n+ \"./test/stubs/ignore4/thisshouldnotexist12345\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore4/ignoredFolder/**\",\n+ \"./test/stubs/ignore4/ignoredFolder/ignored.md\",\n+ \"./test/stubs/ignore4/_site/**\",\n]);\n});\n@@ -383,10 +384,10 @@ test(\"Get ignores (both .eleventyignore and .gitignore, using setUseGitIgnore(fa\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"!./test/stubs/ignorelocalroot/test.md\",\n- \"!./test/stubs/ignore4/ignoredFolder/**\",\n- \"!./test/stubs/ignore4/ignoredFolder/ignored.md\",\n- \"!./test/stubs/ignore4/_site/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore4/ignoredFolder/**\",\n+ \"./test/stubs/ignore4/ignoredFolder/ignored.md\",\n+ \"./test/stubs/ignore4/_site/**\",\n]);\n});\n@@ -403,11 +404,11 @@ test(\"Get ignores (no .eleventyignore .gitignore exists but empty)\", (t) => {\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"!./node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/node_modules/**\",\n- \"!./test/stubs/ignore5/node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/test.md\",\n- \"!./test/stubs/ignore5/_site/**\",\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignore5/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore5/_site/**\",\n]);\n});\n@@ -423,13 +424,13 @@ test(\"Get ignores (both .eleventyignore and .gitignore exists, but .gitignore is\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"!./node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/node_modules/**\",\n- \"!./test/stubs/ignore6/node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/test.md\",\n- \"!./test/stubs/ignore6/ignoredFolder/**\",\n- \"!./test/stubs/ignore6/ignoredFolder/ignored.md\",\n- \"!./test/stubs/ignore6/_site/**\",\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignore6/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore6/ignoredFolder/**\",\n+ \"./test/stubs/ignore6/ignoredFolder/ignored.md\",\n+ \"./test/stubs/ignore6/_site/**\",\n]);\n});\n@@ -446,11 +447,11 @@ test(\"Get ignores (no .eleventyignore .gitignore exists but has spaces inside)\"\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"!./node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/node_modules/**\",\n- \"!./test/stubs/ignore7/node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/test.md\",\n- \"!./test/stubs/ignore7/_site/**\",\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignore7/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore7/_site/**\",\n]);\n});\n@@ -466,13 +467,13 @@ test(\"Get ignores (both .eleventyignore and .gitignore exists, but .gitignore ha\nevf._setLocalPathRoot(\"./test/stubs/ignorelocalroot\");\nt.deepEqual(evf.getIgnores(), [\n- \"!./node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/node_modules/**\",\n- \"!./test/stubs/ignore8/node_modules/**\",\n- \"!./test/stubs/ignorelocalroot/test.md\",\n- \"!./test/stubs/ignore8/ignoredFolder/**\",\n- \"!./test/stubs/ignore8/ignoredFolder/ignored.md\",\n- \"!./test/stubs/ignore8/_site/**\",\n+ \"./node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/node_modules/**\",\n+ \"./test/stubs/ignore8/node_modules/**\",\n+ \"./test/stubs/ignorelocalroot/test.md\",\n+ \"./test/stubs/ignore8/ignoredFolder/**\",\n+ \"./test/stubs/ignore8/ignoredFolder/ignored.md\",\n+ \"./test/stubs/ignore8/_site/**\",\n]);\n});\n/* End .eleventyignore and .gitignore combos */\n@@ -526,22 +527,6 @@ test(\"Include and Data Dirs\", (t) => {\n]);\n});\n-test(\"Ignore Include and Data Dirs\", (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let evf = new EleventyFiles(\n- \"test/stubs\",\n- \"test/stubs/_site\",\n- [],\n- eleventyConfig\n- );\n- evf.init();\n-\n- t.deepEqual(evf._getIncludesAndDataDirIgnores(), [\n- \"!./test/stubs/_includes/**\",\n- \"!./test/stubs/_data/**\",\n- ]);\n-});\n-\ntest(\"Input to 'src' and empty includes dir (issue #403)\", (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet evf = new EleventyFiles(\n@@ -566,9 +551,9 @@ test(\"Input to 'src' and empty includes dir (issue #403)\", (t) => {\n\"./src/**/*.md\",\n\"./src/**/*.liquid\",\n\"./src/**/*.html\",\n- \"!./src/_includes/**\",\n- \"!./src/_site/**\",\n- \"!./src/_data/**\",\n+ // \"!./src/_includes/**\",\n+ // \"!./src/_site/**\",\n+ // \"!./src/_data/**\",\n]);\n});\n@@ -750,6 +735,6 @@ test(\"Test that negations are ignored (for now) PR#709, will change when #693 is\n`hello\n!testing`\n),\n- [\"!./hello\"]\n+ [\"./hello\"]\n);\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Move to use fastglob ignore option instead of negated strings (for speeeed) |
699 | 03.04.2021 15:20:49 | 18,000 | c9ca422a049f34551048579bfdd30f8768ba44c3 | Fix issue where passing an absolute path into TemplatePath.absolutePath would concat two absolute paths together. Exhibited itself with missing global data on Eleventy Cloud when you use an absolute path to an input directory. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplatePath.js",
"new_path": "src/TemplatePath.js",
"diff": "@@ -133,6 +133,19 @@ TemplatePath.normalizeUrlPath = function (...urlPaths) {\n* @returns {String} the absolute path described by the given path segments.\n*/\nTemplatePath.absolutePath = function (...paths) {\n+ let i = 0;\n+ for (let path of paths) {\n+ if (path.startsWith(\"/\")) {\n+ if (i === 0) {\n+ return path;\n+ }\n+ throw new Error(\n+ `Only the first parameter to Template.absolutePath can be an absolute path. Received: ${path} from ${paths}`\n+ );\n+ }\n+ i++;\n+ }\n+\nreturn TemplatePath.join(TemplatePath.getWorkingDir(), ...paths);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePathTest.js",
"new_path": "test/TemplatePathTest.js",
"diff": "@@ -129,6 +129,11 @@ test(\"absolutePath\", (t) => {\nTemplatePath.absolutePath(\".eleventy.js\").split(\"/\").pop(),\n\".eleventy.js\"\n);\n+ t.is(TemplatePath.absolutePath(\"/tmp/.eleventy.js\"), \"/tmp/.eleventy.js\");\n+\n+ t.throws(() => {\n+ TemplatePath.absolutePath(\"file1.js\", \"test/file2.js\", \"/tmp/.eleventy.js\");\n+ });\n});\ntest(\"absolutePath and relativePath\", (t) => {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix issue where passing an absolute path into TemplatePath.absolutePath would concat two absolute paths together. Exhibited itself with missing global data on Eleventy Cloud when you use an absolute path to an input directory. |
699 | 04.04.2021 14:42:02 | 18,000 | 659633c05f6aff016ea02e66213509c24e44d589 | Test to solidify | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateFileSlugTest.js",
"new_path": "test/TemplateFileSlugTest.js",
"diff": "@@ -52,6 +52,12 @@ test(\"Easy slug with date, index\", (t) => {\nt.is(fs.getFullPathWithoutExtension(), \"/index\");\n});\n+test(\"Easy slug with only a date and no suffix\", (t) => {\n+ let fs = getNewSlugInstance(\"./2018-01-01.html\");\n+ t.is(fs.getSlug(), \"2018-01-01\");\n+ t.is(fs.getFullPathWithoutExtension(), \"/2018-01-01\");\n+});\n+\n/* Directories */\ntest(\"Easy slug with dir\", (t) => {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Test to solidify https://github.com/11ty/11ty-website/pull/499 |
699 | 06.04.2021 22:26:32 | 18,000 | afb017a7d0371adb059baa2d87c53e5f2b2910ba | Start to support objects in `permalink` for more complex aliasing. | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "const fs = require(\"fs-extra\");\nconst parsePath = require(\"parse-filepath\");\nconst normalize = require(\"normalize-path\");\n-const lodashIsObject = require(\"lodash/isObject\");\n+const isPlainObject = require(\"lodash/isPlainObject\");\nconst { DateTime } = require(\"luxon\");\nconst TemplateData = require(\"./TemplateData\");\nconst TemplateContent = require(\"./TemplateContent\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplatePermalink = require(\"./TemplatePermalink\");\n-const TemplatePermalinkNoWrite = require(\"./TemplatePermalinkNoWrite\");\nconst TemplateLayout = require(\"./TemplateLayout\");\nconst TemplateFileSlug = require(\"./TemplateFileSlug\");\nconst ComputedData = require(\"./ComputedData\");\n@@ -135,13 +134,43 @@ class Template extends TemplateContent {\n}\nlet permalink = data[this.config.keys.permalink];\n- if (permalink) {\n- // render variables inside permalink front matter, bypass markdown\nlet permalinkValue;\n- if (!this.config.dynamicPermalinks || data.dynamicPermalink === false) {\n- debugDev(\"Not using dynamicPermalinks, using %o\", permalink);\n+\n+ // v1.0 added support for `permalink: true`\n+ // `permalink: true` is a more accurate alias for `permalink: false` behavior:\n+ // render but no file system write, e.g. use in collections only)\n+ if (typeof permalink === \"boolean\") {\n+ debugDev(\"Using boolean permalink %o\", permalink);\npermalinkValue = permalink;\n- } else {\n+ } else if (\n+ permalink &&\n+ (!this.config.dynamicPermalinks || data.dynamicPermalink === false)\n+ ) {\n+ debugDev(\"Not using dynamic permalinks, using %o\", permalink);\n+ permalinkValue = permalink;\n+ } else if (isPlainObject(permalink)) {\n+ let promises = [];\n+ let order = [];\n+ for (let key in permalink) {\n+ order.push(key);\n+ promises.push(super.render(permalink[key], data, true));\n+ }\n+ let results = await Promise.all(promises);\n+\n+ permalinkValue = {};\n+ for (let j = 0, k = order.length; j < k; j++) {\n+ permalinkValue[order[j]] = results[j];\n+ debug(\n+ \"Rendering permalink.%o for %o: %s becomes %o\",\n+ order[j],\n+ this.inputPath,\n+ permalink,\n+ results[j]\n+ );\n+ debugDev(\"Permalink rendered with data: %o\", data);\n+ }\n+ } else if (permalink) {\n+ // render variables inside permalink front matter, bypass markdown\npermalinkValue = await super.render(permalink, data, true);\ndebug(\n\"Rendering permalink for %o: %s becomes %o\",\n@@ -152,16 +181,15 @@ class Template extends TemplateContent {\ndebugDev(\"Permalink rendered with data: %o\", data);\n}\n+ if (permalinkValue !== undefined) {\nlet perm = new TemplatePermalink(\npermalinkValue,\nthis.extraOutputSubdirectory\n);\n-\nreturn perm;\n- } else if (permalink === false) {\n- return new TemplatePermalinkNoWrite();\n}\n+ // No `permalink` specified in data cascade, do the default\nreturn TemplatePermalink.generate(\nthis.getTemplateSubfolder(),\nthis.baseFile,\n@@ -171,30 +199,54 @@ class Template extends TemplateContent {\n);\n}\n+ async usePermalinkRoot() {\n+ if (this._usePermalinkRoot === undefined) {\n+ // TODO this only works with immediate front matter and not data files\n+ this._usePermalinkRoot = (await this.getFrontMatterData())[\n+ this.config.keys.permalinkRoot\n+ ];\n+ }\n+\n+ return this._usePermalinkRoot;\n+ }\n+\n// TODO instead of htmlIOException, do a global search to check if output path = input path and then add extra suffix\n+ async getOutputLocations(data) {\n+ let link = await this._getLink(data);\n+\n+ let path;\n+ if (await this.usePermalinkRoot()) {\n+ path = link.toPathFromRoot();\n+ } else {\n+ path = link.toPath(this.outputDir);\n+ }\n+\n+ return {\n+ link: link.toLink(),\n+ href: link.toHref(),\n+ path: path,\n+ };\n+ }\n+\n+ // Preferred to use the singular `getOutputLocations` above.\nasync getOutputLink(data) {\nlet link = await this._getLink(data);\n- return link.toString();\n+ return link.toLink();\n}\n+ // Preferred to use the singular `getOutputLocations` above.\nasync getOutputHref(data) {\nlet link = await this._getLink(data);\nreturn link.toHref();\n}\n+ // Preferred to use the singular `getOutputLocations` above.\nasync getOutputPath(data) {\n- let uri = await this.getOutputLink(data);\n-\n- if (uri === false) {\n- return false;\n- } else if (\n- (await this.getFrontMatterData())[this.config.keys.permalinkRoot]\n- ) {\n- // TODO this only works with immediate front matter and not data files\n- return normalize(uri);\n- } else {\n- return normalize(this.outputDir + \"/\" + uri);\n+ let link = await this._getLink(data);\n+ if (await this.usePermalinkRoot()) {\n+ return link.toPathFromRoot();\n}\n+ return link.toPath(this.outputDir);\n}\nsetPaginationData(paginationData) {\n@@ -212,7 +264,7 @@ class Template extends TemplateContent {\nreturn Promise.all(\ndata.map((item) => this.mapDataAsRenderedTemplates(item, templateData))\n);\n- } else if (lodashIsObject(data)) {\n+ } else if (isPlainObject(data)) {\nlet obj = {};\nawait Promise.all(\nObject.keys(data).map(async (value) => {\n@@ -412,10 +464,10 @@ class Template extends TemplateContent {\n}\n_addComputedEntry(computedData, obj, parentKey, declaredDependencies) {\n- // this check must come before lodashIsObject\n+ // this check must come before isPlainObject\nif (typeof obj === \"function\") {\ncomputedData.add(parentKey, obj, declaredDependencies);\n- } else if (lodashIsObject(obj)) {\n+ } else if (isPlainObject(obj)) {\nfor (let key in obj) {\nlet keys = [];\nif (parentKey) {\n@@ -483,8 +535,9 @@ class Template extends TemplateContent {\ndata.page = {};\n}\n- data.page.url = await this.getOutputHref(data);\n- data.page.outputPath = await this.getOutputPath(data);\n+ let { href, path } = await this.getOutputLocations(data);\n+ data.page.url = href;\n+ data.page.outputPath = path;\n}\n// Deprecated, use eleventyComputed instead.\n@@ -574,14 +627,12 @@ class Template extends TemplateContent {\n}\n}\n+ // TODO move this into tests (this is only used by tests)\nasync getRenderedTemplates(data) {\nlet pages = await this.getTemplates(data);\nawait Promise.all(\npages.map(async (page) => {\n- let content = await page.template._getContent(\n- page.outputPath,\n- page.data\n- );\n+ let content = await page.template._getContent(page.data);\npage.templateContent = content;\n})\n@@ -589,7 +640,7 @@ class Template extends TemplateContent {\nreturn pages;\n}\n- async _getContent(outputPath, data) {\n+ async _getContent(data) {\nreturn await this.render(data);\n}\n@@ -787,10 +838,7 @@ class Template extends TemplateContent {\nasync getTemplateMapContent(pageMapEntry) {\npageMapEntry.template.setWrapWithLayouts(false);\n- let content = await pageMapEntry.template._getContent(\n- pageMapEntry.outputPath,\n- pageMapEntry.data\n- );\n+ let content = await pageMapEntry.template._getContent(pageMapEntry.data);\npageMapEntry.template.setWrapWithLayouts(true);\nreturn content;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateCollection.js",
"new_path": "src/TemplateCollection.js",
"diff": "@@ -9,7 +9,7 @@ class TemplateCollection extends Sortable {\nthis._filteredByGlobsCache = new Map();\n}\n- // right now this is only used by the tests\n+ // TODO move this into tests (this is only used by tests)\nasync _testAddTemplate(template) {\nlet data = await template.getData();\nfor (let map of await template.getTemplates(data)) {\n@@ -34,7 +34,7 @@ class TemplateCollection extends Sortable {\nglobs = [globs];\n}\n- globs = globs.map(glob => TemplatePath.addLeadingDotSlash(glob));\n+ globs = globs.map((glob) => TemplatePath.addLeadingDotSlash(glob));\nreturn globs;\n}\n@@ -53,7 +53,7 @@ class TemplateCollection extends Sortable {\nthis._filteredByGlobsCache = new Map();\n}\n- let filtered = this.getAllSorted().filter(item => {\n+ let filtered = this.getAllSorted().filter((item) => {\nif (multimatch([item.inputPath], globs).length) {\nreturn true;\n}\n@@ -66,19 +66,19 @@ class TemplateCollection extends Sortable {\n}\ngetFilteredByTag(tagName) {\n- return this.getAllSorted().filter(item => {\n+ return this.getAllSorted().filter((item) => {\nif (!tagName) {\nreturn true;\n} else if (Array.isArray(item.data.tags)) {\n- return item.data.tags.some(tag => tag === tagName);\n+ return item.data.tags.some((tag) => tag === tagName);\n}\nreturn false;\n});\n}\ngetFilteredByTags(...tags) {\n- return this.getAllSorted().filter(item =>\n- tags.every(requiredTag => {\n+ return this.getAllSorted().filter((item) =>\n+ tags.every((requiredTag) => {\nconst itemTags = item.data.tags;\nif (Array.isArray(itemTags)) {\nreturn itemTags.includes(requiredTag);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -265,10 +265,11 @@ class TemplateMap {\nlet counter = 0;\nfor (let page of map._pages) {\n- // TODO do we need this in map entries?\n+ // Copy outputPath to map entry\nif (!map.outputPath) {\nmap.outputPath = page.outputPath;\n}\n+\nif (\ncounter === 0 ||\n(map.data.pagination &&\n"
},
{
"change_type": "DELETE",
"old_path": "src/TemplatePermalinkNoWrite.js",
"new_path": null,
"diff": "-class TemplatePermalinkNoWrite {\n- toString() {\n- return false;\n- }\n-\n- toHref() {\n- return false;\n- }\n-}\n-\n-module.exports = TemplatePermalinkNoWrite;\n"
},
{
"change_type": "DELETE",
"old_path": "test/TemplatePermalinkNoWriteTest.js",
"new_path": null,
"diff": "-const test = require(\"ava\");\n-const TemplatePermalinkNoWrite = require(\"../src/TemplatePermalinkNoWrite\");\n-\n-test(\"Test standard method signature\", (t) => {\n- let perm = new TemplatePermalinkNoWrite();\n- t.is(perm.toHref(), false);\n- t.is(perm.toString(), false);\n-});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePermalinkTest.js",
"new_path": "test/TemplatePermalinkTest.js",
"diff": "@@ -3,11 +3,11 @@ const TemplatePermalink = require(\"../src/TemplatePermalink\");\ntest(\"Simple straight permalink\", (t) => {\nt.is(\n- new TemplatePermalink(\"permalinksubfolder/test.html\").toString(),\n+ new TemplatePermalink(\"permalinksubfolder/test.html\").toLink(),\n\"permalinksubfolder/test.html\"\n);\nt.is(\n- new TemplatePermalink(\"./permalinksubfolder/test.html\").toString(),\n+ new TemplatePermalink(\"./permalinksubfolder/test.html\").toLink(),\n\"permalinksubfolder/test.html\"\n);\n@@ -28,15 +28,15 @@ test(\"Simple straight permalink\", (t) => {\ntest(\"Permalink without filename\", (t) => {\nt.is(\n- new TemplatePermalink(\"permalinksubfolder/\").toString(),\n+ new TemplatePermalink(\"permalinksubfolder/\").toLink(),\n\"permalinksubfolder/index.html\"\n);\nt.is(\n- new TemplatePermalink(\"./permalinksubfolder/\").toString(),\n+ new TemplatePermalink(\"./permalinksubfolder/\").toLink(),\n\"permalinksubfolder/index.html\"\n);\nt.is(\n- new TemplatePermalink(\"/permalinksubfolder/\").toString(),\n+ new TemplatePermalink(\"/permalinksubfolder/\").toLink(),\n\"/permalinksubfolder/index.html\"\n);\n@@ -56,11 +56,11 @@ test(\"Permalink without filename\", (t) => {\ntest(\"Permalink with pagination subdir\", (t) => {\nt.is(\n- new TemplatePermalink(\"permalinksubfolder/test.html\", \"0/\").toString(),\n+ new TemplatePermalink(\"permalinksubfolder/test.html\", \"0/\").toLink(),\n\"permalinksubfolder/0/test.html\"\n);\nt.is(\n- new TemplatePermalink(\"permalinksubfolder/test.html\", \"1/\").toString(),\n+ new TemplatePermalink(\"permalinksubfolder/test.html\", \"1/\").toLink(),\n\"permalinksubfolder/1/test.html\"\n);\n@@ -77,33 +77,33 @@ test(\"Permalink with pagination subdir\", (t) => {\ntest(\"Permalink generate\", (t) => {\nlet gen = TemplatePermalink.generate;\n- t.is(gen(\"./\", \"index\").toString(), \"index.html\");\n+ t.is(gen(\"./\", \"index\").toLink(), \"index.html\");\nt.is(gen(\"./\", \"index\").toHref(), \"/\");\n- t.is(gen(\".\", \"index\").toString(), \"index.html\");\n+ t.is(gen(\".\", \"index\").toLink(), \"index.html\");\nt.is(gen(\".\", \"index\").toHref(), \"/\");\n- t.is(gen(\".\", \"test\").toString(), \"test/index.html\");\n+ t.is(gen(\".\", \"test\").toLink(), \"test/index.html\");\nt.is(gen(\".\", \"test\").toHref(), \"/test/\");\n- t.is(gen(\".\", \"test\", \"0/\").toString(), \"test/0/index.html\");\n+ t.is(gen(\".\", \"test\", \"0/\").toLink(), \"test/0/index.html\");\nt.is(gen(\".\", \"test\", \"0/\").toHref(), \"/test/0/\");\n- t.is(gen(\".\", \"test\", \"1/\").toString(), \"test/1/index.html\");\n+ t.is(gen(\".\", \"test\", \"1/\").toLink(), \"test/1/index.html\");\nt.is(gen(\".\", \"test\", \"1/\").toHref(), \"/test/1/\");\n});\ntest(\"Permalink generate with suffix\", (t) => {\nlet gen = TemplatePermalink.generate;\n- t.is(gen(\".\", \"test\", null, \"-o\").toString(), \"test/index-o.html\");\n+ t.is(gen(\".\", \"test\", null, \"-o\").toLink(), \"test/index-o.html\");\nt.is(gen(\".\", \"test\", null, \"-o\").toHref(), \"/test/index-o.html\");\n- t.is(gen(\".\", \"test\", \"1/\", \"-o\").toString(), \"test/1/index-o.html\");\n+ t.is(gen(\".\", \"test\", \"1/\", \"-o\").toLink(), \"test/1/index-o.html\");\nt.is(gen(\".\", \"test\", \"1/\", \"-o\").toHref(), \"/test/1/index-o.html\");\n});\ntest(\"Permalink generate with new extension\", (t) => {\nlet gen = TemplatePermalink.generate;\n- t.is(gen(\".\", \"test\", null, null, \"css\").toString(), \"test.css\");\n+ t.is(gen(\".\", \"test\", null, null, \"css\").toLink(), \"test.css\");\nt.is(gen(\".\", \"test\", null, null, \"css\").toHref(), \"/test.css\");\n- t.is(gen(\".\", \"test\", \"1/\", null, \"css\").toString(), \"1/test.css\");\n+ t.is(gen(\".\", \"test\", \"1/\", null, \"css\").toLink(), \"1/test.css\");\nt.is(gen(\".\", \"test\", \"1/\", null, \"css\").toHref(), \"/1/test.css\");\n});\n@@ -111,15 +111,15 @@ test(\"Permalink generate with subfolders\", (t) => {\nlet gen = TemplatePermalink.generate;\nt.is(\n- gen(\"permalinksubfolder/\", \"index\").toString(),\n+ gen(\"permalinksubfolder/\", \"index\").toLink(),\n\"permalinksubfolder/index.html\"\n);\nt.is(\n- gen(\"permalinksubfolder/\", \"test\").toString(),\n+ gen(\"permalinksubfolder/\", \"test\").toLink(),\n\"permalinksubfolder/test/index.html\"\n);\nt.is(\n- gen(\"permalinksubfolder/\", \"test\", \"1/\", \"-o\").toString(),\n+ gen(\"permalinksubfolder/\", \"test\", \"1/\", \"-o\").toLink(),\n\"permalinksubfolder/test/1/index-o.html\"\n);\n@@ -144,6 +144,43 @@ test(\"Permalink matching folder and filename\", (t) => {\nt.is(hasDupe(\"component\", \"component\"), true);\nt.is(hasDupe(\"component/\", \"component\"), true);\n- t.is(gen(\"component/\", \"component\").toString(), \"component/index.html\");\n+ t.is(gen(\"component/\", \"component\").toLink(), \"component/index.html\");\nt.is(gen(\"component/\", \"component\").toHref(), \"/component/\");\n});\n+\n+test(\"Permalink Object, just build\", (t) => {\n+ t.is(\n+ new TemplatePermalink({\n+ build: \"permalinksubfolder/test.html\",\n+ }).toLink(),\n+ \"permalinksubfolder/test.html\"\n+ );\n+\n+ t.is(\n+ new TemplatePermalink({\n+ build: false,\n+ }).toLink(),\n+ false\n+ );\n+\n+ t.is(\n+ new TemplatePermalink({\n+ build: true,\n+ }).toLink(),\n+ false\n+ );\n+\n+ t.is(\n+ new TemplatePermalink({\n+ request: \"/url/\",\n+ }).toLink(),\n+ false\n+ );\n+\n+ t.is(\n+ new TemplatePermalink({\n+ rando: \"/url/\",\n+ }).toLink(),\n+ false\n+ );\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -1360,10 +1360,10 @@ test(\"permalink: false\", async (t) => {\n\"./test/stubs/_site\"\n);\n- t.is(await tmpl.getOutputLink(), false);\n- t.is(await tmpl.getOutputHref(), false);\n-\nlet data = await tmpl.getData();\n+ t.is(await tmpl.getOutputLink(data), false);\n+ t.is(await tmpl.getOutputHref(data), false);\n+\nawait write(tmpl, data);\n// Input file exists (sanity check for paths)\n@@ -1379,6 +1379,19 @@ test(\"permalink: false\", async (t) => {\n);\n});\n+test(\"permalink: true\", async (t) => {\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-true/permalink-true.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ await t.throwsAsync(async () => {\n+ await tmpl.getOutputLink(data);\n+ });\n+});\n+\ntest(\"Disable dynamic permalinks\", async (t) => {\nlet tmpl = getNewTemplate(\n\"./test/stubs/dynamic-permalink/test.njk\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Start to support objects in `permalink` for more complex aliasing. |
699 | 07.04.2021 17:48:54 | 18,000 | bbc461688f0babf1cbfafd5fac56ab68f569cef7 | Adds Needs Compilation checks to Liquid too (was already in Nunjucks) | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Liquid.js",
"new_path": "src/Engines/Liquid.js",
"diff": "@@ -50,6 +50,8 @@ class Liquid extends TemplateEngine {\nextname: \".liquid\",\ndynamicPartials: false,\nstrictFilters: true,\n+ // TODO?\n+ // cache: true,\n};\nlet options = Object.assign(defaults, this.liquidOptions || {});\n@@ -201,7 +203,22 @@ class Liquid extends TemplateEngine {\n});\n}\n+ needsCompilation(str) {\n+ let options = this.liquidLib.options;\n+\n+ return (\n+ str.indexOf(options.tagDelimiterLeft) !== -1 ||\n+ str.indexOf(options.outputDelimiterLeft) !== -1\n+ );\n+ }\n+\nasync compile(str, inputPath) {\n+ if (!this.needsCompilation(str)) {\n+ return async function (data) {\n+ return str;\n+ };\n+ }\n+\nlet engine = this.liquidLib;\nlet tmplReady = engine.parse(str, inputPath);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -344,18 +344,22 @@ class Nunjucks extends TemplateEngine {\nthis.njkEnv.addExtension(shortcodeName, new PairedShortcodeFunction());\n}\n- async compile(str, inputPath) {\n+ needsCompilation(str) {\n// Defend against syntax customisations:\n// https://mozilla.github.io/nunjucks/api.html#customizing-syntax\nlet optsTags = this.njkEnv.opts.tags || {};\nlet blockStart = optsTags.blockStart || \"{%\";\nlet variableStart = optsTags.variableStart || \"{{\";\nlet commentStart = optsTags.variableStart || \"{#\";\n- let needsCompile =\n- str.indexOf(blockStart) != -1 ||\n- str.indexOf(variableStart) != -1 ||\n- str.indexOf(commentStart) != -1;\n- if (!needsCompile) {\n+ return (\n+ str.indexOf(blockStart) !== -1 ||\n+ str.indexOf(variableStart) !== -1 ||\n+ str.indexOf(commentStart) !== -1\n+ );\n+ }\n+\n+ async compile(str, inputPath) {\n+ if (!this.needsCompilation(str)) {\nreturn async function () {\nreturn str;\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/TemplateEngine.js",
"new_path": "src/Engines/TemplateEngine.js",
"diff": "@@ -168,6 +168,11 @@ class TemplateEngine {\nget defaultTemplateFileExtension() {\nreturn \"html\";\n}\n+\n+ // whether or not compile is needed or can we return the plaintext?\n+ needsCompilation(str) {\n+ return true;\n+ }\n}\nmodule.exports = TemplateEngine;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderLiquidTest.js",
"new_path": "test/TemplateRenderLiquidTest.js",
"diff": "@@ -1019,3 +1019,14 @@ test(\"Liquid Render Square Brackets #680 variable reference array\", async (t) =>\n);\nt.is(await fn({ test: { \"hey-a\": 1 }, ref: [\"hey-a\"] }), \"<p>1</p>\");\n});\n+\n+test(\"Liquid bypass compilation\", async (t) => {\n+ let tr = getNewTemplateRender(\"liquid\");\n+\n+ t.is(tr.engine.needsCompilation(\"<p>{{ me }}</p>\"), true);\n+ t.is(\n+ tr.engine.needsCompilation(\"<p>{% comment %}{% endcomment %}</p>\"),\n+ true\n+ );\n+ t.is(tr.engine.needsCompilation(\"<p>test</p>\"), false);\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderNunjucksTest.js",
"new_path": "test/TemplateRenderNunjucksTest.js",
"diff": "@@ -797,3 +797,11 @@ test(\"Issue 611: Run a function\", async (t) => {\n\"alkdsjfksljaZach\"\n);\n});\n+\n+test(\"Nunjucks bypass compilation\", async (t) => {\n+ let tr = getNewTemplateRender(\"njk\");\n+\n+ t.is(tr.engine.needsCompilation(\"<p>{{ me }}</p>\"), true);\n+ t.is(tr.engine.needsCompilation(\"<p>{% tag %}{% endtag %}</p>\"), true);\n+ t.is(tr.engine.needsCompilation(\"<p>test</p>\"), false);\n+});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds Needs Compilation checks to Liquid too (was already in Nunjucks) |
699 | 07.04.2021 17:49:36 | 18,000 | b078b2df28afaa2ec60de182b535b099639519f3 | More clarify on template language console output | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -686,7 +686,7 @@ class Template extends TemplateContent {\nlet engineList = this.templateRender.getReadableEnginesListDifferingFromFileExtension();\nthis.logger.log(\n`${lang.start} ${outputPath} from ${this.inputPath}${\n- engineList ? ` (${engineList})` : \"\"\n+ engineList ? ` (using ${engineList})` : \"\"\n}`\n);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | More clarify on template language console output |
699 | 09.04.2021 14:57:03 | 18,000 | 5fe9968eecf2f86e2117209cec8201c12b888b33 | Rename `permalink.external` to `permalink.cloud` | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -171,9 +171,9 @@ class Template extends TemplateContent {\nkeys.push(\"build\");\npromises.push(super.render(permalink.build, data, true));\n}\n- if(permalink.external) {\n- keys.push(\"external\");\n- promises.push(super.render(permalink.external, data, true));\n+ if (permalink.cloud) {\n+ keys.push(\"cloud\");\n+ promises.push(super.render(permalink.cloud, data, true));\n}\nlet results = await Promise.all(promises);\n@@ -598,7 +598,9 @@ class Template extends TemplateContent {\n);\n}\n} else {\n- throw new TemplateContentUnrenderedTemplateError(`Tried to use templateContent on unrendered template. You need a valid permalink (or permalink object) to use templateContent on ${this.inputPath}`);\n+ throw new TemplateContentUnrenderedTemplateError(\n+ `Tried to use templateContent on unrendered template. You need a valid permalink (or permalink object) to use templateContent on ${this.inputPath}`\n+ );\n}\nreturn this._templateContent;\n},\n@@ -643,7 +645,9 @@ class Template extends TemplateContent {\n);\n}\n} else {\n- throw new TemplateContentUnrenderedTemplateError(`Tried to use templateContent on unrendered template. You need a valid permalink (or permalink object) to use templateContent on ${this.inputPath} page ${this.pageNumber}`);\n+ throw new TemplateContentUnrenderedTemplateError(\n+ `Tried to use templateContent on unrendered template. You need a valid permalink (or permalink object) to use templateContent on ${this.inputPath} page ${this.pageNumber}`\n+ );\n}\nreturn this._templateContent;\n},\n@@ -886,7 +890,7 @@ class Template extends TemplateContent {\ndebugDev(\"%o getMapped()\", this.inputPath);\n// Important reminder: This is where the template data is first generated via TemplateMap\n- let data = dataOverride || await this.getData();\n+ let data = dataOverride || (await this.getData());\nlet rawPermalinkValue = data[this.config.keys.permalink];\nlet link = this._getRawPermalinkInstance(rawPermalinkValue);\n@@ -899,9 +903,12 @@ class Template extends TemplateContent {\ndata,\nbehavior: {\nignored: link.isTemplateIgnored(),\n- rendered: this.outputFormat === \"json\" || this.outputFormat === \"ndjson\" || link.isTemplateRendered(),\n+ rendered:\n+ this.outputFormat === \"json\" ||\n+ this.outputFormat === \"ndjson\" ||\n+ link.isTemplateRendered(),\nwriteable: link.isTemplateWriteable(),\n- }\n+ },\n});\nreturn entries;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -273,7 +273,10 @@ class TemplateMap {\nif (map.behavior.ignored) {\nmap._pages = [];\n} else {\n- map._pages = await map.template.getTemplates(map.data, map.behavior.rendered);\n+ map._pages = await map.template.getTemplates(\n+ map.data,\n+ map.behavior.rendered\n+ );\nlet counter = 0;\nfor (let page of map._pages) {\n@@ -340,7 +343,10 @@ class TemplateMap {\nthis.checkForDuplicatePermalinks();\n- await this.config.events.emit(\"dependencyMap\", this.generateDependencyMapEventObject(orderedMap));\n+ await this.config.events.emit(\n+ \"dependencyMap\",\n+ this.generateDependencyMapEventObject(orderedMap)\n+ );\n}\ngenerateDependencyMapEventObject(orderedMap) {\n@@ -348,15 +354,17 @@ class TemplateMap {\nfor (let entry of orderedMap) {\nlet ret = {\ninputPath: entry.inputPath,\n- isExternal: !!(entry.data.permalink && entry.data.permalink.external)\n+ isExternal: !!(entry.data.permalink && entry.data.permalink.cloud),\n};\n// TODO `needs: []` array of inputPath or glob? this template uses\nfor (let page of entry._pages) {\n- entries.push(Object.assign({}, ret, {\n- url: page.url\n- }));\n+ entries.push(\n+ Object.assign({}, ret, {\n+ url: page.url,\n+ })\n+ );\n}\n}\nreturn entries;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePermalink.js",
"new_path": "src/TemplatePermalink.js",
"diff": "@@ -27,7 +27,11 @@ class TemplatePermalink {\nthis._outputToFileSystem = false;\n} else {\nthrow new Error(\n- `\\`permalink: ${isLinkAnObject ? \"build: \" : \"\"}true\\` is not a supported feature in Eleventy. Did you mean \\`permalink: ${isLinkAnObject ? \"build: \" : \"\"}false\\`?`\n+ `\\`permalink: ${\n+ isLinkAnObject ? \"build: \" : \"\"\n+ }true\\` is not a supported feature in Eleventy. Did you mean \\`permalink: ${\n+ isLinkAnObject ? \"build: \" : \"\"\n+ }false\\`?`\n);\n}\n} else if (rawLink) {\n@@ -36,7 +40,7 @@ class TemplatePermalink {\nif (isLinkAnObject) {\nif (\"external\" in link) {\n- this.externalLink = link.external;\n+ this.externalLink = link.cloud;\n}\n// default for permalink objects without a build URL\n@@ -44,7 +48,8 @@ class TemplatePermalink {\nlink.behavior = \"skip-render\";\n}\n- if(link.behavior === \"skip-write\") { // same as permalink: false and permalink: build: false\n+ if (link.behavior === \"skip-write\") {\n+ // same as permalink: false and permalink: build: false\nthis._outputToFileSystem = false;\n} else if (link.behavior === \"skip-render\") {\nthis._outputToFileSystem = false;\n@@ -64,7 +69,8 @@ class TemplatePermalink {\n}\ntoLink() {\n- if (!this.rawLink) { // empty or false\n+ if (!this.rawLink) {\n+ // empty or false\nreturn false;\n}\n@@ -85,7 +91,8 @@ class TemplatePermalink {\nif (this.externalLink) {\nreturn this.externalLink;\n}\n- if (!this.rawLink) { // empty or false\n+ if (!this.rawLink) {\n+ // empty or false\nreturn false;\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Rename `permalink.external` to `permalink.cloud` |
699 | 10.04.2021 09:57:21 | 18,000 | 749e5c1683e0c49aeb581b0d5781f955472aa536 | Add option to use absolute path for config file path. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -34,10 +34,10 @@ class EleventyConfigError extends EleventyBaseError {}\n* Config for a template.\n*\n* @param {{}} customRootConfig - tbd.\n- * @param {String} localProjectConfigPath - Path to local project config.\n+ * @param {String} projectConfigPath - Path to local project config.\n*/\nclass TemplateConfig {\n- constructor(customRootConfig, localProjectConfigPath) {\n+ constructor(customRootConfig, projectConfigPath) {\nthis.userConfig = new UserConfig();\n/** @member {module:11ty/eleventy/TemplateConfig~TemplateConfig~override} - tbd. */\n@@ -47,7 +47,7 @@ class TemplateConfig {\n* @member {String} - Path to local project config.\n* @default .eleventy.js\n*/\n- this.localProjectConfigPath = localProjectConfigPath || \".eleventy.js\";\n+ this.projectConfigPath = projectConfigPath || \".eleventy.js\";\nif (customRootConfig) {\n/**\n@@ -71,7 +71,7 @@ class TemplateConfig {\n* @returns {String} - The normalised local project config file path.\n*/\ngetLocalProjectConfigFile() {\n- return TemplatePath.addLeadingDotSlash(this.localProjectConfigPath);\n+ return TemplatePath.addLeadingDotSlash(this.projectConfigPath);\n}\nget inputDir() {\n@@ -89,7 +89,7 @@ class TemplateConfig {\ndebugDev(\"Resetting configuration: TemplateConfig and UserConfig.\");\nthis.userConfig.reset();\nthis.initializeRootConfig();\n- this.config = this.mergeConfig(this.localProjectConfigPath);\n+ this.config = this.mergeConfig(this.projectConfigPath);\n}\n/**\n@@ -109,7 +109,7 @@ class TemplateConfig {\ngetConfig() {\nif (!this.hasConfigMerged) {\ndebugDev(\"Merging via getConfig (first time)\");\n- this.config = this.mergeConfig(this.localProjectConfigPath);\n+ this.config = this.mergeConfig(this.projectConfigPath);\nthis.hasConfigMerged = true;\n}\nreturn this.config;\n@@ -121,7 +121,7 @@ class TemplateConfig {\n* @param {String} path - The new config path.\n*/\nsetProjectConfigPath(path) {\n- this.localProjectConfigPath = path;\n+ this.projectConfigPath = path;\nif (this.hasConfigMerged) {\n// merge it again\n@@ -163,15 +163,12 @@ class TemplateConfig {\n/**\n* Merges different config files together.\n*\n- * @param {String} localProjectConfigPath - Path to local project config.\n+ * @param {String} projectConfigPath - Path to project config.\n* @returns {{}} merged - The merged config file.\n*/\n- mergeConfig(localProjectConfigPath) {\n+ mergeConfig(projectConfigPath) {\nlet localConfig = {};\n- let path = TemplatePath.join(\n- TemplatePath.getWorkingDir(),\n- localProjectConfigPath\n- );\n+ let path = TemplatePath.absolutePath(projectConfigPath);\ndebug(`Merging config with ${path}`);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePath.js",
"new_path": "src/TemplatePath.js",
"diff": "@@ -134,11 +134,9 @@ TemplatePath.normalizeUrlPath = function (...urlPaths) {\n*/\nTemplatePath.absolutePath = function (...paths) {\nlet i = 0;\n+ // check all the paths before we short circuit from the first index\nfor (let path of paths) {\n- if (path.startsWith(\"/\")) {\n- if (i === 0) {\n- return path;\n- }\n+ if (path.startsWith(\"/\") && i > 0) {\nthrow new Error(\n`Only the first parameter to Template.absolutePath can be an absolute path. Received: ${path} from ${paths}`\n);\n@@ -146,6 +144,14 @@ TemplatePath.absolutePath = function (...paths) {\ni++;\n}\n+ let j = 0;\n+ for (let path of paths) {\n+ if (j === 0 && path.startsWith(\"/\")) {\n+ return TemplatePath.join(...paths);\n+ }\n+ j++;\n+ }\n+\nreturn TemplatePath.join(TemplatePath.getWorkingDir(), ...paths);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePathTest.js",
"new_path": "test/TemplatePathTest.js",
"diff": "@@ -130,6 +130,14 @@ test(\"absolutePath\", (t) => {\n\".eleventy.js\"\n);\nt.is(TemplatePath.absolutePath(\"/tmp/.eleventy.js\"), \"/tmp/.eleventy.js\");\n+ t.is(\n+ TemplatePath.absolutePath(\"/var/task/\", \".eleventy.js\"),\n+ \"/var/task/.eleventy.js\"\n+ );\n+\n+ t.throws(() => {\n+ TemplatePath.absolutePath(\"/var/task/\", \"/var/task/.eleventy.js\");\n+ });\nt.throws(() => {\nTemplatePath.absolutePath(\"file1.js\", \"test/file2.js\", \"/tmp/.eleventy.js\");\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Add option to use absolute path for config file path. |
699 | 11.04.2021 21:09:30 | 18,000 | 47a8f42cd025099d0147eb68e714a2c408328196 | Updates to dependency tree v2, adds `globalDataFiles` event | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"vue-server-renderer\": \"^2.6.12\"\n},\n\"dependencies\": {\n- \"@11ty/dependency-tree\": \"^1.0.0\",\n+ \"@11ty/dependency-tree\": \"^2.0.0\",\n\"browser-sync\": \"^2.26.14\",\n\"chalk\": \"^4.1.0\",\n\"chokidar\": \"^3.5.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -249,6 +249,8 @@ class TemplateData {\nawait this.getGlobalDataFiles()\n);\n+ this.config.events.emit(\"globalDataFiles\", files);\n+\nlet dataFileConflicts = {};\nfor (let j = 0, k = files.length; j < k; j++) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -429,15 +429,14 @@ test(\"TemplateData.cleanupData\", (t) => {\n});\ntest(\"Parent directory for data (Issue #337)\", async (t) => {\n- let eleventyConfig = new TemplateConfig();\n- let dataObj = new TemplateData(\"./test/stubs-337/src/\", eleventyConfig);\n- dataObj._setConfig({\n+ let eleventyConfig = new TemplateConfig({\ndataTemplateEngine: false,\ndir: {\ninput: \"./test/stubs-337/src/\",\ndata: \"../data/\",\n},\n});\n+ let dataObj = new TemplateData(\"./test/stubs-337/src/\", eleventyConfig);\ndataObj.setInputDir(\"./test/stubs-337/src/\");\nlet data = await dataObj.getData();\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Updates to dependency tree v2, adds `globalDataFiles` event |
699 | 15.04.2021 17:50:07 | 18,000 | 2be4ac0956bdc9ede96123fdedf9c2cc4effd5d5 | Option to use inject precompiled collections via a config option. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -252,13 +252,7 @@ class TemplateMap {\nreturn graph.overallOrder();\n}\n- // TODO(slightlyoff): major bottleneck\n- async initDependencyMap(dependencyMap) {\n- let tagPrefix = this.tagPrefix;\n- for (let depEntry of dependencyMap) {\n- if (depEntry.startsWith(tagPrefix)) {\n- // is a tag (collection) entry\n- let tagName = depEntry.substr(tagPrefix.length);\n+ async setCollectionByTagName(tagName) {\nif (this.isUserConfigCollectionName(tagName)) {\n// async\nthis.collectionsData[tagName] = await this.getUserConfigCollection(\n@@ -267,6 +261,27 @@ class TemplateMap {\n} else {\nthis.collectionsData[tagName] = this.getTaggedCollection(tagName);\n}\n+\n+ let precompiled = this.config.precompiledCollections;\n+ if (precompiled && precompiled[tagName]) {\n+ if (\n+ tagName === \"all\" ||\n+ !Array.isArray(this.collectionsData[tagName]) ||\n+ this.collectionsData[tagName].length === 0\n+ ) {\n+ this.collectionsData[tagName] = precompiled[tagName];\n+ }\n+ }\n+ }\n+\n+ // TODO(slightlyoff): major bottleneck\n+ async initDependencyMap(dependencyMap) {\n+ let tagPrefix = this.tagPrefix;\n+ for (let depEntry of dependencyMap) {\n+ if (depEntry.startsWith(tagPrefix)) {\n+ // is a tag (collection) entry\n+ let tagName = depEntry.substr(tagPrefix.length);\n+ await this.setCollectionByTagName(tagName);\n} else {\n// is a template entry\nlet map = this.getMapEntryForInputPath(depEntry);\n@@ -564,11 +579,14 @@ class TemplateMap {\n}\nlet entry = this.getMapEntryForInputPath(item.inputPath);\n+ // This check skips precompiled collections\n+ if (entry) {\nlet index = item.pageNumber || 0;\nitem.templateContent = entry._pages[index]._templateContent;\n}\n}\n}\n+ }\nasync resolveRemainingComputedData() {\nlet promises = [];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -20,6 +20,7 @@ class UserConfig {\ndebug(\"Resetting EleventyConfig to initial values.\");\nthis.events = new EventEmitter();\nthis.collections = {};\n+ this.precompiledCollections = {};\nthis.templateFormats = undefined;\nthis.liquidOptions = {};\n@@ -665,6 +666,10 @@ class UserConfig {\nthis.useTemplateCache = !!bypass;\n}\n+ setPrecompiledCollections(collections) {\n+ this.precompiledCollections = collections;\n+ }\n+\ngetMergingConfigObject() {\nreturn {\ntemplateFormats: this.templateFormats,\n@@ -710,6 +715,7 @@ class UserConfig {\nquietMode: this.quietMode,\nevents: this.events,\nuseTemplateCache: this.useTemplateCache,\n+ precompiledCollections: this.precompiledCollections,\n};\n}\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Option to use inject precompiled collections via a config option. |
699 | 20.04.2021 11:52:20 | 18,000 | f60b5b7430195b9f38328f3d0241af9ca2053383 | Switch SASS from node-sass to sass package for Node 16 compat | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"jsdoc\": \"3.6.6\",\n\"lint-staged\": \"^10.5.4\",\n\"markdown-it-emoji\": \"^2.0.0\",\n- \"node-sass\": \"^5.0.0\",\n\"nyc\": \"^15.1.0\",\n\"prettier\": \"^2.2.1\",\n\"rimraf\": \"^3.0.2\",\n+ \"sass\": \"^1.32.11\",\n\"toml\": \"^3.0.0\",\n\"viperhtml\": \"^2.17.1\",\n\"vue\": \"^2.6.12\",\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderCustomTest.js",
"new_path": "test/TemplateRenderCustomTest.js",
"diff": "@@ -56,7 +56,7 @@ test(\"Custom Vue Render\", async (t) => {\nt.is(await fn({ test: \"Hello\" }), `<p data-server-rendered=\"true\">Hello</p>`);\n});\n-const sass = require(\"node-sass\");\n+const sass = require(\"sass\");\ntest(\"Custom Sass Render\", async (t) => {\nlet tr = getNewTemplateRender(\"sass\");\n@@ -72,6 +72,7 @@ test(\"Custom Sass Render\", async (t) => {\ndata: str,\nincludePaths: [tr.inputDir, tr.includesDir],\nstyle: \"expanded\",\n+ indentType: \"space\",\n// TODO\n// sourcemap: \"file\",\noutFile: \"test_this_is_to_not_write_a_file.css\",\n@@ -93,6 +94,7 @@ test(\"Custom Sass Render\", async (t) => {\nt.is(\n(await fn({})).trim(),\n`p {\n- color: blue; }`\n+ color: blue;\n+}`\n);\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Switch SASS from node-sass to sass package for Node 16 compat |
699 | 20.04.2021 11:52:44 | 18,000 | 046fbf6320047c61317ddc3c4c1c54ca5ad9824a | Move from Node 15 to Node 16 for GitHub Actions tests | [
{
"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\", \"15\"]\n+ node: [\"12\", \"14\", \"16\"]\nname: Node.js ${{ matrix.node }} on ${{ matrix.os }}\nsteps:\n- uses: actions/checkout@v2\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Move from Node 15 to Node 16 for GitHub Actions tests |
699 | 25.04.2021 14:52:48 | 18,000 | f72751f0e812fef7887c1a8bad033129eac26d28 | Allow complex keys in `addGlobalData`, minor tweak to data cascade (addGlobalData will override global data files). Also changed to do a deep merge between the two. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -289,7 +289,7 @@ class TemplateData {\nreturnValue = await returnValue();\n}\n- globalData[key] = returnValue;\n+ lodashset(globalData, key, returnValue);\n}\n}\nreturn globalData;\n@@ -302,14 +302,10 @@ class TemplateData {\nif (!this.globalData) {\nlet globalJson = await this.getAllGlobalData();\n+ let mergedGlobalData = merge(globalJson, this.configApiGlobalData);\n// OK: Shallow merge when combining rawImports (pkg) with global data files\n- this.globalData = Object.assign(\n- {},\n- this.configApiGlobalData,\n- globalJson,\n- rawImports\n- );\n+ this.globalData = Object.assign({}, mergedGlobalData, rawImports);\n}\nreturn this.globalData;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -470,3 +470,19 @@ test(\"addGlobalData values\", async (t) => {\nt.is(data.myPromise, \"promise-value\");\nt.is(data.myAsync, \"promise-value\");\n});\n+\n+test(\"addGlobalData complex key\", 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(\n+ \"./test/stubs-global-data-config-api-nested/\",\n+ eleventyConfig\n+ );\n+ let data = await dataObj.getData();\n+\n+ t.is(data.deep.existing, true);\n+ t.is(data.deep.nested.one, \"first\");\n+ t.is(data.deep.nested.two, \"second\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs-global-data-config-api-nested/_data/deep.js",
"diff": "+module.exports = {\n+ existing: true,\n+};\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Allow complex keys in `addGlobalData`, minor tweak to data cascade (addGlobalData will override global data files). Also changed to do a deep merge between the two. |
699 | 27.04.2021 10:08:31 | 18,000 | 35c3c2effa98ec45677071eeaf8ca03f3eefb246 | Shortcut for single page renders on pagination in cloud render. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -121,7 +121,10 @@ class TemplateMap {\ngraph.addNode(entry.inputPath);\n}\n- if (!entry.data.eleventyExcludeFromCollections) {\n+ if (\n+ !entry.data.eleventyExcludeFromCollections &&\n+ entry.behavior.includeInCollections\n+ ) {\n// collections.all\ngraph.addDependency(tagPrefix + \"all\", entry.inputPath);\n@@ -172,7 +175,10 @@ class TemplateMap {\n}\ngraph.addDependency(entry.inputPath, tagPrefix + paginationTagTarget);\n- if (!entry.data.eleventyExcludeFromCollections) {\n+ if (\n+ !entry.data.eleventyExcludeFromCollections &&\n+ entry.behavior.includeInCollections\n+ ) {\n// collections.all\ngraph.addDependency(tagPrefix + \"all\", entry.inputPath);\n@@ -213,7 +219,10 @@ class TemplateMap {\ngraph.addNode(entry.inputPath);\n}\n- if (!entry.data.eleventyExcludeFromCollections) {\n+ if (\n+ !entry.data.eleventyExcludeFromCollections &&\n+ entry.behavior.includeInCollections\n+ ) {\n// collections.all\ngraph.addDependency(tagPrefix + \"all\", entry.inputPath);\n}\n@@ -242,7 +251,10 @@ class TemplateMap {\ngraph.addNode(entry.inputPath);\n}\n- if (!entry.data.eleventyExcludeFromCollections) {\n+ if (\n+ !entry.data.eleventyExcludeFromCollections &&\n+ entry.behavior.includeInCollections\n+ ) {\n// collections.all\ngraph.addDependency(tagPrefix + \"all\", entry.inputPath);\n}\n@@ -285,13 +297,10 @@ class TemplateMap {\n} else {\n// is a template entry\nlet map = this.getMapEntryForInputPath(depEntry);\n- if (map.behavior.ignored) {\n+ if (!map.behavior.read) {\nmap._pages = [];\n} else {\n- map._pages = await map.template.getTemplates(\n- map.data,\n- map.behavior.rendered\n- );\n+ map._pages = await map.template.getTemplates(map.data, map.behavior);\nlet counter = 0;\nfor (let page of map._pages) {\n@@ -305,7 +314,10 @@ class TemplateMap {\n(map.data.pagination &&\nmap.data.pagination.addAllPagesToCollections)\n) {\n- if (!map.data.eleventyExcludeFromCollections) {\n+ if (\n+ !map.data.eleventyExcludeFromCollections &&\n+ map.behavior.includeInCollections\n+ ) {\n// TODO do we need .template in collection entries?\nthis.collection.add(page);\n}\n@@ -432,7 +444,7 @@ class TemplateMap {\nif (!map._pages) {\nthrow new Error(`Content pages not found for ${map.inputPath}`);\n}\n- if (!map.behavior.rendered) {\n+ if (!map.behavior.render) {\ncontinue;\n}\ntry {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePermalink.js",
"new_path": "src/TemplatePermalink.js",
"diff": "@@ -10,7 +10,7 @@ class TemplatePermalink {\nthis._isIgnoredTemplate = false;\nthis._isRendered = true;\n- this._outputToFileSystem = true;\n+ this._writeToFileSystem = true;\nlet rawLink;\nif (isLinkAnObject) {\n@@ -24,7 +24,7 @@ class TemplatePermalink {\n// permalink: false and permalink: build: false\nif (typeof rawLink === \"boolean\") {\nif (rawLink === false) {\n- this._outputToFileSystem = false;\n+ this._writeToFileSystem = false;\n} else {\nthrow new Error(\n`\\`permalink: ${\n@@ -43,19 +43,19 @@ class TemplatePermalink {\nthis.externalLink = link.cloud;\n}\n- // default for permalink objects without a build URL\n+ // default if permalink is an Object but does not have a `build` prop\nif (!(\"behavior\" in link) && !(\"build\" in link)) {\n- link.behavior = \"skip-render\";\n+ link.behavior = \"read\";\n}\n- if (link.behavior === \"skip-write\") {\n+ if (link.behavior === \"render\") {\n// same as permalink: false and permalink: build: false\n- this._outputToFileSystem = false;\n- } else if (link.behavior === \"skip-render\") {\n- this._outputToFileSystem = false;\n+ this._writeToFileSystem = false;\n+ } else if (link.behavior === \"read\") {\n+ this._writeToFileSystem = false;\nthis._isRendered = false;\n} else if (link.behavior === \"skip\") {\n- this._outputToFileSystem = false;\n+ this._writeToFileSystem = false;\nthis._isRendered = false;\nthis._isIgnoredTemplate = true;\n}\n@@ -128,16 +128,21 @@ class TemplatePermalink {\nreturn normalize(uri);\n}\n- isTemplateIgnored() {\n- return this._isIgnoredTemplate;\n- }\n+ getBehavior(outputFormat = \"fs\") {\n+ let obj = {\n+ read: !this._isIgnoredTemplate,\n+ render: this._isRendered,\n+ write: this._writeToFileSystem,\n+ };\n- isTemplateRendered() {\n- return this._isRendered;\n+ // override render behavior for --json or --ndjson\n+ if (outputFormat !== \"fs\") {\n+ obj.render = \"override\";\n}\n- isTemplateWriteable() {\n- return this._outputToFileSystem;\n+ obj.includeInCollections = obj.read && obj.render;\n+\n+ return obj;\n}\nstatic _hasDuplicateFolder(dir, base) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateMapTest.js",
"new_path": "test/TemplateMapTest.js",
"diff": "@@ -1265,7 +1265,7 @@ test(\"permalink object with build\", async (t) => {\nt.is(map[0]._pages.length, 1);\n});\n-test(\"permalink object without build (defaults to no-render mode)\", async (t) => {\n+test(\"permalink object without build (defaults to `read` mode)\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet tm = new TemplateMap(eleventyConfig);\nlet tmpl = getNewTemplate(\n@@ -1281,9 +1281,12 @@ test(\"permalink object without build (defaults to no-render mode)\", async (t) =>\nawait tm.cache();\nt.is(map[0]._pages.length, 1);\n- t.throws(() => {\n+ t.throws(\n+ () => {\nmap[0]._pages[0].templateContent;\n- }, {\n- instanceOf: TemplateContentUnrenderedTemplateError\n- });\n+ },\n+ {\n+ instanceOf: TemplateContentUnrenderedTemplateError,\n+ }\n+ );\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Shortcut for single page renders on pagination in cloud render. |
725 | 27.04.2021 17:16:40 | -3,600 | 9cf519725e92af7024dff2fad0cf5e2ede09175a | Add failing test for nunjucks nested async paired shortcodes | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderNunjucksTest.js",
"new_path": "test/TemplateRenderNunjucksTest.js",
"diff": "@@ -545,6 +545,40 @@ test(\"Nunjucks Async Paired Shortcode\", async (t) => {\n);\n});\n+test(\"Nunjucks Nested Async Paired Shortcode\", async (t) => {\n+ t.plan(3);\n+\n+ let tr = getNewTemplateRender(\"njk\", \"./test/stubs/\");\n+ tr.engine.addPairedShortcode(\n+ \"postfixWithZach\",\n+ function (content, str) {\n+ // Data in context\n+ t.is(this.page.url, \"/hi/\");\n+\n+ return new Promise(function (resolve) {\n+ setTimeout(function () {\n+ resolve(str + content + \"Zach\");\n+ });\n+ });\n+ },\n+ true\n+ );\n+\n+ t.is(\n+ await tr._testRender(\n+ \"{% postfixWithZach name %}Content{% postfixWithZach name2 %}Content{% endpostfixWithZach %}{% endpostfixWithZach %}\",\n+ {\n+ name: \"test\",\n+ name2: \"test2\",\n+ page: {\n+ url: \"/hi/\",\n+ },\n+ }\n+ ),\n+ \"testContenttest2ContentZachZach\"\n+ );\n+});\n+\ntest(\"Nunjucks Paired Shortcode without args\", async (t) => {\nlet tr = getNewTemplateRender(\"njk\", \"./test/stubs/\");\ntr.engine.addPairedShortcode(\"postfixWithZach\", function (content) {\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Add failing test for nunjucks nested async paired shortcodes |
725 | 27.04.2021 17:19:48 | -3,600 | 5b5a45554403808ff5e4626933dc745bd72ff56d | Fix for nunjucks nested async paired shortcodes | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -287,25 +287,30 @@ class Nunjucks extends TemplateEngine {\nvar body = parser.parseUntilBlocks(\"end\" + shortcodeName);\nparser.advanceAfterBlockEnd();\n- if (isAsync) {\nreturn new nodes.CallExtensionAsync(this, \"run\", args, [body]);\n- }\n- return new nodes.CallExtension(this, \"run\", args, [body]);\n};\nthis.run = function (...args) {\n- let resolve;\n- if (isAsync) {\n- resolve = args.pop();\n- }\n+ let resolve = args.pop();\nlet body = args.pop();\nlet [context, ...argArray] = args;\n+ body(function (err, bodyContent) {\n+ if (err) {\n+ resolve(\n+ new EleventyShortcodeError(\n+ `Error with Nunjucks paired shortcode \\`${shortcodeName}\\`${EleventyErrorUtil.convertErrorToString(\n+ e\n+ )}`\n+ )\n+ );\n+ }\n+\nif (isAsync) {\nshortcodeFn\n.call(\nNunjucks._normalizeShortcodeContext(context),\n- body(),\n+ bodyContent,\n...argArray\n)\n.then(function (returnValue) {\n@@ -323,21 +328,27 @@ class Nunjucks extends TemplateEngine {\n});\n} else {\ntry {\n- return new NunjucksLib.runtime.SafeString(\n+ resolve(\n+ null,\n+ new NunjucksLib.runtime.SafeString(\nshortcodeFn.call(\nNunjucks._normalizeShortcodeContext(context),\n- body(),\n+ bodyContent,\n...argArray\n)\n+ )\n);\n} catch (e) {\n- throw new EleventyShortcodeError(\n+ resolve(\n+ new EleventyShortcodeError(\n`Error with Nunjucks paired shortcode \\`${shortcodeName}\\`${EleventyErrorUtil.convertErrorToString(\ne\n)}`\n+ )\n);\n}\n}\n+ });\n};\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix for nunjucks nested async paired shortcodes |
697 | 30.04.2021 22:58:24 | -32,400 | cf08d2dbce3e1b22216e3fc9f3932bc9ae742011 | Fix no use local timezone when parse date from filename | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -881,7 +881,7 @@ class Template extends TemplateContent {\n} else {\nlet filenameRegex = this.inputPath.match(/(\\d{4}-\\d{2}-\\d{2})/);\nif (filenameRegex !== null) {\n- let dateObj = DateTime.fromISO(filenameRegex[1]).toJSDate();\n+ let dateObj = DateTime.fromISO(filenameRegex[1], { zone: 'utc' }).toJSDate();\ndebug(\n\"getMappedDate: using filename regex time for %o of %o: %o\",\nthis.inputPath,\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix no use local timezone when parse date from filename |
699 | 30.04.2021 11:52:08 | 18,000 | b469b3eeecda067ed7f911770a43971689e3a85b | Changed Data Deep merge default to true for 1.0 | [
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -53,7 +53,7 @@ class UserConfig {\nthis.DateTime = DateTime;\nthis.dynamicPermalinks = true;\nthis.useGitIgnore = true;\n- this.dataDeepMerge = false;\n+ this.dataDeepMerge = true;\nthis.extensionMap = new Set();\nthis.watchJavaScriptDependencies = true;\nthis.additionalWatchTargets = [];\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -1486,7 +1486,8 @@ test(\"Front matter date with quotes (njk), issue #258\", async (t) => {\ntest(\"Data Cascade (Deep merge)\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\n- eleventyConfig.userConfig.setDataDeepMerge(true);\n+ // Default changed in 1.0\n+ // eleventyConfig.userConfig.setDataDeepMerge(true);\nlet dataObj = new TemplateData(\"./test/\", eleventyConfig);\nawait dataObj.cacheData();\n@@ -1520,6 +1521,8 @@ test(\"Data Cascade (Deep merge)\", async (t) => {\ntest(\"Data Cascade (Shallow merge)\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\n+ // Default changed in 1.0\n+ eleventyConfig.userConfig.setDataDeepMerge(false);\nlet dataObj = new TemplateData(\"./test/\", eleventyConfig);\nawait dataObj.cacheData();\n@@ -1549,7 +1552,8 @@ test(\"Data Cascade (Shallow merge)\", async (t) => {\ntest(\"Data Cascade Tag Merge (Deep merge)\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\n- eleventyConfig.userConfig.setDataDeepMerge(true);\n+ // Default changed in 1.0\n+ // eleventyConfig.userConfig.setDataDeepMerge(true);\nlet dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\nawait dataObj.cacheData();\n@@ -1568,6 +1572,8 @@ test(\"Data Cascade Tag Merge (Deep merge)\", async (t) => {\ntest(\"Data Cascade Tag Merge (Shallow merge)\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\n+ // Default changed in 1.0\n+ eleventyConfig.userConfig.setDataDeepMerge(false);\nlet dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\nawait dataObj.cacheData();\n@@ -1586,6 +1592,8 @@ test(\"Data Cascade Tag Merge (Shallow merge)\", async (t) => {\ntest('Local data inherits tags string ([tags] vs \"tags\") Shallow Merge', async (t) => {\nlet eleventyConfig = new TemplateConfig();\n+ // Default changed in 1.0\n+ eleventyConfig.userConfig.setDataDeepMerge(false);\nlet dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\nawait dataObj.cacheData();\n@@ -1604,7 +1612,8 @@ test('Local data inherits tags string ([tags] vs \"tags\") Shallow Merge', async (\ntest('Local data inherits tags string ([tags] vs \"tags\") Deep Merge', async (t) => {\nlet eleventyConfig = new TemplateConfig();\n- eleventyConfig.userConfig.setDataDeepMerge(true);\n+ // Default changed in 1.0\n+ // eleventyConfig.userConfig.setDataDeepMerge(true);\nlet dataObj = new TemplateData(\"./test/stubs/\", eleventyConfig);\nawait dataObj.cacheData();\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Changed Data Deep merge default to true for 1.0 |
699 | 02.05.2021 15:17:05 | 18,000 | 4ee394b76880e95e214d1ca9ea377d63b6d0ff55 | Renaming `cloud` to `serverless` for clarity after feedback from a few folks | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -172,9 +172,9 @@ class Template extends TemplateContent {\nkeys.push(\"build\");\npromises.push(super.render(permalink.build, data, true));\n}\n- if (permalink.cloud) {\n- keys.push(\"cloud\");\n- promises.push(super.render(permalink.cloud, data, true));\n+ if (permalink.serverless) {\n+ keys.push(\"serverless\");\n+ promises.push(super.render(permalink.serverless, data, true));\n}\nlet results = await Promise.all(promises);\n@@ -582,16 +582,20 @@ class Template extends TemplateContent {\n};\n}\n- // no pagination on permalink.cloud for local builds\n+ // no pagination on permalink.serverless for local builds\nlet hasPagination = Pagination.hasPagination(data);\n- let isCloudRenderOnBuild = !behavior.render;\n- let isCloudRenderOnCloud = behavior.render === \"override\";\n+ let isServerlessRenderOnBuild = !behavior.render;\n+ let isServerlessRenderOnServerless = behavior.render === \"override\";\n- if (!hasPagination || isCloudRenderOnBuild || isCloudRenderOnCloud) {\n- // inject pagination page data for just this one entry for cloud render\n- if (isCloudRenderOnCloud && hasPagination) {\n+ if (\n+ !hasPagination ||\n+ isServerlessRenderOnBuild ||\n+ isServerlessRenderOnServerless\n+ ) {\n+ // inject pagination page data for just this one entry for serverless render\n+ if (isServerlessRenderOnServerless && hasPagination) {\nlet pagination = new Pagination(data, this.config);\n- let paginationItems = pagination.getTruncatedCloudData(data);\n+ let paginationItems = pagination.getTruncatedServerlessData(data);\nlet override = pagination.getOverrideData(paginationItems);\n// TODO errors or warnings when trying to access `pagination.pages`, pageNumber, links, hrefs, etc\nthis.setPaginationData(override);\n@@ -719,7 +723,7 @@ class Template extends TemplateContent {\nlet engineList = this.templateRender.getReadableEnginesListDifferingFromFileExtension();\nthis.logger.log(\n`${lang.start} ${outputPath} from ${this.inputPath}${\n- engineList ? ` (using ${engineList})` : \"\"\n+ engineList ? ` (${engineList})` : \"\"\n}`\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -381,7 +381,7 @@ class TemplateMap {\nfor (let entry of orderedMap) {\nlet ret = {\ninputPath: entry.inputPath,\n- isExternal: !!(entry.data.permalink && entry.data.permalink.cloud),\n+ isExternal: !!(entry.data.permalink && entry.data.permalink.serverless),\n};\n// TODO `needs: []` array of inputPath or glob? this template uses\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePermalink.js",
"new_path": "src/TemplatePermalink.js",
"diff": "@@ -39,8 +39,8 @@ class TemplatePermalink {\n}\nif (isLinkAnObject) {\n- if (\"cloud\" in link) {\n- this.externalLink = link.cloud;\n+ if (\"serverless\" in link) {\n+ this.externalLink = link.serverless;\n}\n// default if permalink is an Object but does not have a `build` prop\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Renaming `cloud` to `serverless` for clarity after feedback from a few folks |
699 | 03.05.2021 17:11:52 | 18,000 | 4c8e2125383edcbeeebfbf485a813a1c8e507db5 | Set a few default environment variables useful in serverless mode. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -74,6 +74,14 @@ class TemplateData {\nthis._extensionMap = map;\n}\n+ get environmentVariables() {\n+ return this._env;\n+ }\n+\n+ set environmentVariables(env) {\n+ this._env = env;\n+ }\n+\n/* Used by tests */\n_setConfig(config) {\nthis.config = config;\n@@ -292,6 +300,15 @@ class TemplateData {\nlodashset(globalData, key, returnValue);\n}\n}\n+ if (this.environmentVariables) {\n+ if (!(\"eleventy\" in globalData)) {\n+ globalData.eleventy = {};\n+ }\n+ if (!(\"env\" in globalData.eleventy)) {\n+ globalData.eleventy.env = {};\n+ }\n+ Object.assign(globalData.eleventy.env, this.environmentVariables);\n+ }\nreturn globalData;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/EleventyTest.js",
"new_path": "test/EleventyTest.js",
"diff": "@@ -44,6 +44,19 @@ test(\"Eleventy set input/output\", async (t) => {\nt.truthy(elev.writer);\n});\n+test(\"Eleventy process.ENV\", async (t) => {\n+ let elev = new Eleventy(\"./test/stubs\", \"./test/stubs/_site\");\n+\n+ process.env.ELEVENTY_ROOT = \"\";\n+ t.falsy(process.env.ELEVENTY_ROOT);\n+ await elev.init();\n+ t.truthy(process.env.ELEVENTY_ROOT);\n+\n+ // all ELEVENTY_ env variables are also available on eleventy.env\n+ let globals = await elev.templateData.getInitialGlobalData();\n+ t.truthy(globals.eleventy.env.root);\n+});\n+\ntest(\"Eleventy file watching\", async (t) => {\nlet elev = new Eleventy(\"./test/stubs\", \"./test/stubs/_site\");\nelev.setFormats(\"njk\");\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Set a few default environment variables useful in serverless mode. |
699 | 04.05.2021 10:23:04 | 18,000 | ae1f6a85c2699adc3b0fd00550d199776b529abd | Adds `eleventy.env` event, prefixes a few other eleventy event names. | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -298,6 +298,10 @@ class Eleventy {\n* @returns {} - tbd.\n*/\nasync init() {\n+ if (this.env) {\n+ await this.config.events.emit(\"eleventy.env\", this.env);\n+ }\n+\nthis.config.inputDir = this.inputDir;\nlet formats = this.formatsOverride || this.config.templateFormats;\n@@ -348,13 +352,14 @@ Verbose Output: ${this.verboseMode}`);\nreturn this.templateData.cacheData();\n}\n+ // These are all set as initial global data under eleventy.env.* (see TemplateData->environmentVariables)\ngetEnvironmentVariableValues() {\n- let absolutePathToConfig = TemplatePath.absolutePath(\n- this.eleventyConfig.getLocalProjectConfigFile()\n- );\n+ let configPath = this.eleventyConfig.getLocalProjectConfigFile();\n+ let absolutePathToConfig = TemplatePath.absolutePath(configPath);\nlet root = TemplatePath.getDirFromFilePath(absolutePathToConfig);\nreturn {\n+ config: absolutePathToConfig,\nroot,\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -257,7 +257,7 @@ class TemplateData {\nawait this.getGlobalDataFiles()\n);\n- this.config.events.emit(\"globalDataFiles\", files);\n+ this.config.events.emit(\"eleventy.globalDataFiles\", files);\nlet dataFileConflicts = {};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -371,7 +371,7 @@ class TemplateMap {\nthis.checkForDuplicatePermalinks();\nawait this.config.events.emit(\n- \"dependencyMap\",\n+ \"eleventy.dependencyMap\",\nthis.generateDependencyMapEventObject(orderedMap)\n);\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds `eleventy.env` event, prefixes a few other eleventy event names. |
699 | 14.05.2021 14:21:04 | 18,000 | 8c1f61c710bab43542ea8781a127f9dc837dfa9b | Require `pagination.serverless` key to truncate data in serverless pagination | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/Pagination.js",
"new_path": "src/Plugins/Pagination.js",
"diff": "@@ -327,13 +327,13 @@ class Pagination {\n}\ngetTruncatedServerlessData(data) {\n- let serverlessKey = data.pagination.serverless;\n- if (!serverlessKey) {\n+ if (!(\"serverless\" in data.pagination)) {\nthrow new Error(\n\"Missing `serverless` key in `pagination` object to point to pagination data.\"\n);\n}\n- let resolvedKey = this._get(data, serverlessKey);\n+\n+ let resolvedKey = this._get(data, data.pagination.serverless);\nlet fullDataSet = this._get(data, this._getDataKey());\nreturn [this._get(fullDataSet, resolvedKey)];\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -585,7 +585,10 @@ class Template extends TemplateContent {\n// no pagination on permalink.serverless for local builds\nlet hasPagination = Pagination.hasPagination(data);\nlet isServerlessRenderOnBuild = !behavior.render;\n- let isServerlessRenderOnServerless = behavior.render === \"override\";\n+ let isServerlessRenderOnServerless =\n+ behavior.render === \"override\" &&\n+ hasPagination &&\n+ \"serverless\" in data.pagination;\nif (\n!hasPagination ||\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Require `pagination.serverless` key to truncate data in serverless pagination |
699 | 16.05.2021 20:31:00 | 18,000 | be865cff0907dd2a0ada3383554be24ddf475837 | Adds source to ENV variables. Prefixes existing event names with `eleventy.` (make dupes for backwards compat). Adds some code to prepare for browsersync middleware | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -71,6 +71,7 @@ try {\n// --quiet and --quiet=true both resolve to true\nquietMode: argv.quiet,\nconfigPath: argv.config,\n+ source: \"cli\",\n});\n// reuse ErrorHandler instance in Eleventy\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -53,6 +53,12 @@ class Eleventy {\n*/\nthis.configPath = options.configPath;\n+ /**\n+ * @member {String} - Called via CLI (`cli`) or Programmatically (`script`)\n+ * @default \"script\"\n+ */\n+ this.source = options.source || \"script\";\n+\n/**\n* @member {Object} - Initialize Eleventy environment variables\n* @default null\n@@ -373,6 +379,7 @@ Verbose Output: ${this.verboseMode}`);\nreturn {\nconfig: absolutePathToConfig,\nroot,\n+ source: this.source,\n};\n}\n@@ -385,6 +392,8 @@ Verbose Output: ${this.verboseMode}`);\nprocess.env.ELEVENTY_ROOT = env.root;\ndebug(\"Setting process.env.ELEVENTY_ROOT: %o\", env.root);\n+ process.env.ELEVENTY_SOURCE = this.source;\n+\n// careful here, setting to false will cast to string \"false\" which is truthy\nif (process.env.AWS_LAMBDA_FUNCTION_NAME) {\nprocess.env.ELEVENTY_SERVERLESS = true;\n@@ -540,7 +549,7 @@ Arguments:\n* @param {String} changedFilePath - File that triggered a re-run (added or modified)\n*/\nasync _addFileToWatchQueue(changedFilePath) {\n- eventBus.emit(\"resourceModified\", changedFilePath);\n+ eventBus.emit(\"eleventy.resourceModified\", changedFilePath);\nthis.watchManager.addToPendingQueue(changedFilePath);\n}\n@@ -557,10 +566,9 @@ Arguments:\nthis.watchManager.setBuildRunning();\n- await this.config.events.emit(\n- \"beforeWatch\",\n- this.watchManager.getActiveQueue()\n- );\n+ let queue = this.watchManager.getActiveQueue();\n+ await this.config.events.emit(\"beforeWatch\", queue);\n+ await this.config.events.emit(\"eleventy.beforeWatch\", queue);\n// reset and reload global configuration :O\nif (\n@@ -878,6 +886,8 @@ Arguments:\ntry {\nawait this.config.events.emit(\"beforeBuild\");\n+ await this.config.events.emit(\"eleventy.before\");\n+\nlet promise;\nif (to === \"fs\") {\npromise = this.writer.write();\n@@ -900,6 +910,7 @@ Arguments:\n}\nawait this.config.events.emit(\"afterBuild\");\n+ await this.config.events.emit(\"eleventy.after\");\n} catch (e) {\nhasError = true;\nret = {\n@@ -930,4 +941,4 @@ Arguments:\nmodule.exports = Eleventy;\nmodule.exports.Serverless = require(\"./Serverless\");\n-module.exports.ServerlessPlugin = require(\"./Plugins/ServerlessPlugin\");\n+module.exports.ServerlessBundlerPlugin = require(\"./Plugins/ServerlessBundlerPlugin\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "@@ -34,7 +34,7 @@ const eventBus = require(\"../EventBus\");\n// }\n// }\n// };\n-// eventBus.on(\"resourceModified\", evictByPath);\n+// eventBus.on(\"eleventy.resourceModified\", evictByPath);\n// let _compile = NunjucksLib.Template.prototype._compile;\n// NunjucksLib.Template.prototype._compile = function _wrap_compile(...args) {\n@@ -128,7 +128,7 @@ class Nunjucks extends TemplateEngine {\nthis.njkEnv = env || new NunjucksLib.Environment(fsLoader);\n// Correct, but overbroad. Better would be to evict more granularly, but\n// resolution from paths isn't straightforward.\n- eventBus.on(\"resourceModified\", (path) => {\n+ eventBus.on(\"eleventy.resourceModified\", (path) => {\nthis.njkEnv.invalidateCache();\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Serverless.js",
"new_path": "src/Serverless.js",
"diff": "@@ -7,9 +7,9 @@ const UrlPattern = require(\"url-pattern\");\nconst debug = require(\"debug\")(\"Eleventy:Serverless\");\nclass Serverless {\n- constructor(name, event, options = {}) {\n+ constructor(name, path, options = {}) {\nthis.name = name;\n- this.event = event;\n+ this.path = path;\nthis.options = Object.assign(\n{\n@@ -22,6 +22,7 @@ class Serverless {\nlet pattern = new UrlPattern(url);\nreturn pattern.match(path);\n},\n+ query: {},\n},\noptions\n);\n@@ -59,9 +60,22 @@ class Serverless {\nreturn require(fullPath);\n}\n- matchUrlPattern(contentMap) {\n+ isServerlessUrl(urlPath) {\n+ let contentMap = this.getContentMap();\n+\n+ for (let url in contentMap) {\n+ if (this.options.matchUrlPattern(urlPath, url)) {\n+ return true;\n+ }\n+ }\n+ return false;\n+ }\n+\n+ matchUrlPattern(urlPath) {\n+ let contentMap = this.getContentMap();\n+\nfor (let url in contentMap) {\n- let result = this.options.matchUrlPattern(this.event.path, url);\n+ let result = this.options.matchUrlPattern(urlPath, url);\nif (result) {\nreturn {\npathParams: result,\n@@ -70,11 +84,7 @@ class Serverless {\n}\n}\n- throw new Error(\n- `No matching URL found for ${this.event.path} in ${JSON.stringify(\n- contentMap\n- )}`\n- );\n+ return {};\n}\nasync render(options = {}) {\n@@ -85,14 +95,22 @@ class Serverless {\nlet inputDir = path.join(this.dir, this.options.inputDir);\nlet configPath = path.join(this.dir, this.options.configFilename);\n- let { pathParams, inputPath } = this.matchUrlPattern(this.getContentMap());\n+ let { pathParams, inputPath } = this.matchUrlPattern(this.path);\n+\n+ if (!pathParams || !inputPath) {\n+ throw new Error(\n+ `No matching URL found for ${this.path} in ${JSON.stringify(\n+ this.getContentMap()\n+ )}`\n+ );\n+ }\ndebug(`Current dir: ${process.cwd()}`);\ndebug(`Project dir: ${this.dir}`);\ndebug(`Config path: ${configPath}`);\ndebug(`Input dir: ${inputDir}`);\n- debug(`Requested URL: ${this.event.path}`);\n+ debug(`Requested URL: ${this.path}`);\ndebug(`Path params: ${pathParams}`);\ndebug(`Input path: ${inputPath}`);\n@@ -107,7 +125,7 @@ class Serverless {\n// Add the params to Global Data\neleventyConfig.addGlobalData(\"eleventy.serverless\", {\n- query: this.event.queryStringParameters,\n+ query: this.options.query,\npath: pathParams,\n});\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateContent.js",
"new_path": "src/TemplateContent.js",
"diff": "@@ -358,7 +358,7 @@ class TemplateContent {\nTemplateContent._inputCache = new Map();\nTemplateContent._compileEngineCache = new Map();\n-eventBus.on(\"resourceModified\", (path) => {\n+eventBus.on(\"eleventy.resourceModified\", (path) => {\nTemplateContent.deleteCached(path);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -2131,7 +2131,7 @@ test(\"Make sure layout cache takes new changes during watch (nunjucks)\", async (\nawait fsp.writeFile(filePath, `alert(\"bye\");`, { encoding: \"utf8\" });\n- eventBus.emit(\"resourceModified\", filePath);\n+ eventBus.emit(\"eleventy.resourceModified\", filePath);\nt.is((await tmpl.render(data)).trim(), '<script>alert(\"bye\");</script>');\n});\n@@ -2152,7 +2152,7 @@ test(\"Make sure layout cache takes new changes during watch (liquid)\", async (t)\nawait fsp.writeFile(filePath, `alert(\"bye\");`, { encoding: \"utf8\" });\n- eventBus.emit(\"resourceModified\", filePath);\n+ eventBus.emit(\"eleventy.resourceModified\", filePath);\nt.is((await tmpl.render(data)).trim(), '<script>alert(\"bye\");</script>');\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Adds source to ENV variables. Prefixes existing event names with `eleventy.` (make dupes for backwards compat). Adds some code to prepare for browsersync middleware |
699 | 17.05.2021 14:36:12 | 18,000 | 1c4baf22a0dcb8f4a430795a820255dbacfa7b24 | All options moved into constuctor | [
{
"change_type": "MODIFY",
"old_path": "src/Serverless.js",
"new_path": "src/Serverless.js",
"diff": "@@ -23,6 +23,7 @@ class Serverless {\nreturn pattern.match(path);\n},\nquery: {},\n+ precompiledCollections: {},\n},\noptions\n);\n@@ -87,7 +88,7 @@ class Serverless {\nreturn {};\n}\n- async render(options = {}) {\n+ async render() {\n// TODO is this necessary?\nif (this.dir.startsWith(\"/var/task/\")) {\nprocess.chdir(this.dir);\n@@ -117,9 +118,9 @@ class Serverless {\nlet elev = new Eleventy(inputPath, null, {\nconfigPath,\nconfig: (eleventyConfig) => {\n- if (options.precompiledCollections) {\n+ if (Object.keys(this.options.precompiledCollections).length > 0) {\neleventyConfig.setPrecompiledCollections(\n- options.precompiledCollections\n+ this.options.precompiledCollections\n);\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | All options moved into constuctor |
699 | 20.05.2021 16:38:49 | 18,000 | 84ce976fddbe94eee78d77e23192339b9f741a6f | Expose more requires to esbuild to make Eleventy more bundleable. | [
{
"change_type": "MODIFY",
"old_path": ".npmignore",
"new_path": ".npmignore",
"diff": "docs\ndocs-src\ntest\n+coverage\n.*\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Expose more requires to esbuild to make Eleventy more bundleable. |
699 | 26.05.2021 09:44:37 | 18,000 | 741d914f7744b8c74c0622882a97c2752a871218 | Multiple setBrowserSyncConfig calls will deep merge the options together (for plugin friendliness) | [
{
"change_type": "MODIFY",
"old_path": "src/UserConfig.js",
"new_path": "src/UserConfig.js",
"diff": "@@ -3,6 +3,7 @@ const semver = require(\"semver\");\nconst { DateTime } = require(\"luxon\");\nconst EventEmitter = require(\"./Util/AsyncEventEmitter\");\nconst EleventyBaseError = require(\"./EleventyBaseError\");\n+const merge = require(\"./Util/Merge\");\nconst bench = require(\"./BenchmarkManager\").get(\"Configuration\");\nconst aggregateBench = require(\"./BenchmarkManager\").get(\"Aggregate\");\nconst debug = require(\"debug\")(\"Eleventy:UserConfig\");\n@@ -622,9 +623,13 @@ class UserConfig {\nthis.watchJavaScriptDependencies = !!watchEnabled;\n}\n- setBrowserSyncConfig(options = {}) {\n+ setBrowserSyncConfig(options = {}, mergeOptions = true) {\n+ if (mergeOptions) {\n+ this.browserSyncConfig = merge(this.browserSyncConfig, options);\n+ } else {\nthis.browserSyncConfig = options;\n}\n+ }\nsetChokidarConfig(options = {}) {\nthis.chokidarConfig = options;\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Multiple setBrowserSyncConfig calls will deep merge the options together (for plugin friendliness) |
699 | 26.05.2021 09:45:23 | 18,000 | 9850a2cba7a39581f84a3f3c45d28b5e60c8d106 | BrowserSync will fake-run the serverless functions locally! | [
{
"change_type": "MODIFY",
"old_path": "src/Eleventy.js",
"new_path": "src/Eleventy.js",
"diff": "@@ -940,5 +940,5 @@ Arguments:\n}\nmodule.exports = Eleventy;\n-module.exports.Serverless = require(\"./Serverless\");\n-module.exports.ServerlessBundlerPlugin = require(\"./Plugins/ServerlessBundlerPlugin\");\n+module.exports.EleventyServerless = require(\"./Serverless\");\n+module.exports.EleventyServerlessBundlerPlugin = require(\"./Plugins/ServerlessBundlerPlugin\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -114,6 +114,35 @@ class BundlerHelper {\nmodules\n);\n}\n+\n+ browserSyncMiddleware() {\n+ let serverlessFilepath = TemplatePath.addLeadingDotSlash(\n+ path.join(TemplatePath.getWorkingDir(), this.dir, \"index\")\n+ );\n+\n+ return async (req, res, next) => {\n+ let serverlessFunction = require(serverlessFilepath);\n+ let url = new URL(req.url, \"http://localhost/\"); // any domain will do here, we just want the searchParams\n+\n+ let start = new Date();\n+ let result = await serverlessFunction.handler({\n+ httpMethod: \"GET\",\n+ path: req.url,\n+ queryStringParameters: Object.fromEntries(url.searchParams),\n+ });\n+\n+ if (result.statusCode === 404) {\n+ // return static file\n+ return next();\n+ }\n+\n+ res.writeHead(result.statusCode, result.headers || {});\n+ res.write(result.body);\n+ res.end();\n+\n+ console.log(`Dynamic Render: ${req.url} (${Date.now() - start}ms)`);\n+ };\n+ }\n}\nmodule.exports = function (eleventyConfig, options = {}) {\n@@ -161,6 +190,10 @@ module.exports = function (eleventyConfig, options = {}) {\nlet helper = new BundlerHelper(options.name, options);\nhelper.writeDependencyEntryFile();\n+ eleventyConfig.setBrowserSyncConfig({\n+ middleware: [helper.browserSyncMiddleware()],\n+ });\n+\neleventyConfig.on(\"eleventy.after\", async () => {\n// extra copy targets\n// we put these in after a build so that we can grab files generated _by_ the build too\n@@ -188,7 +221,6 @@ module.exports = function (eleventyConfig, options = {}) {\n);\n});\n- // TODO is this necessary or can we just use require(\"eleventy.config.js\") in the `eleventy-bundler-modules.js` file\neleventyConfig.on(\"eleventy.env\", (env) => {\nhelper.copyFile(env.config, \"eleventy.config.js\");\nhelper.writeDependencyConfigFile(env.config);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | BrowserSync will fake-run the serverless functions locally! |
699 | 02.06.2021 10:58:30 | 18,000 | 5ffb3b14229138c9de133108c2b0e8f61f5f5649 | Test for eleventyExcludeFromCollections: true and permalink:false | [
{
"change_type": "MODIFY",
"old_path": "src/TemplatePermalink.js",
"new_path": "src/TemplatePermalink.js",
"diff": "@@ -43,6 +43,7 @@ class TemplatePermalink {\n}\n// default if permalink is an Object but does not have a `build` prop\n+ // note that `read` will opt-out this template from collections. See TemplateBehavior->isIncludedInCollections\nif (!(\"behavior\" in link) && !(\"build\" in link)) {\nlink.behavior = \"read\";\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateMapTest.js",
"new_path": "test/TemplateMapTest.js",
"diff": "@@ -988,6 +988,32 @@ test(\"eleventyExcludeFromCollections\", async (t) => {\nt.is(collections.dog.length, 1);\n});\n+test(\"eleventyExcludeFromCollections and permalink: false\", async (t) => {\n+ let eleventyConfig = new TemplateConfig();\n+ let tmpl1 = getNewTemplateByNumber(1, eleventyConfig);\n+\n+ let tm = new TemplateMap(eleventyConfig);\n+ await tm.add(tmpl1);\n+\n+ let excludedTmpl = getNewTemplate(\n+ \"./test/stubs/eleventyExcludeFromCollectionsPermalinkFalse.njk\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\",\n+ eleventyConfig\n+ );\n+\n+ await tm.add(excludedTmpl);\n+\n+ await tm.cache();\n+\n+ t.is(tm.getMap().length, 2);\n+\n+ let collections = await tm._testGetCollectionsData();\n+ t.is(collections.all.length, 1);\n+ t.is(collections.post.length, 1);\n+ t.is(collections.dog.length, 1);\n+});\n+\ntest(\"Paginate over collections.all\", async (t) => {\nlet eleventyConfig = new TemplateConfig();\nlet tmpl1 = getNewTemplateByNumber(1, eleventyConfig);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/eleventyExcludeFromCollectionsPermalinkFalse.njk",
"diff": "+---\n+title: Paged Test\n+eleventyExcludeFromCollections: true\n+permalink: false\n+tags:\n+ - post\n+ - dog\n+---\n+{{ title }}\n\\ No newline at end of file\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Test for eleventyExcludeFromCollections: true and permalink:false
https://github.com/11ty/eleventy/issues/1754#issuecomment-852865233 |
699 | 07.06.2021 09:07:51 | 18,000 | e9b385fefde18fabfcae167a527a3c55095ffbcc | Fix for error messaging when two serverless permalinks match exactly | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -145,7 +145,7 @@ class BundlerHelper {\n}\n}\n-module.exports = function (eleventyConfig, options = {}) {\n+function EleventyPlugin(eleventyConfig, options = {}) {\noptions = Object.assign(\n{\nname: \"\",\n@@ -269,4 +269,6 @@ module.exports = function (eleventyConfig, options = {}) {\n}\n});\n}\n-};\n+}\n+\n+module.exports = EleventyPlugin;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Serverless.js",
"new_path": "src/Serverless.js",
"diff": "@@ -16,13 +16,13 @@ class Serverless {\ninputDir: \".\",\nfunctionsDir: \"functions/\",\nmapFilename: \"eleventy-serverless-map.json\",\n- // The ServerlessBundlerPlugin hard-codes to this (even if you used a different file name)\n+ // ServerlessBundlerPlugin hard-codes to this (even if you used a different file name)\nconfigFilename: \"eleventy.config.js\",\n- matchUrlPattern: function (path, url) {\n- let pattern = new UrlPattern(url);\n+ // Query String Parameters\n+ matchUrlToPattern(path, urlToCompare) {\n+ let pattern = new UrlPattern(urlToCompare);\nreturn pattern.match(path);\n},\n- // Query String Parameters\nquery: {},\n// Inject shared collections\nprecompiledCollections: {},\n@@ -67,7 +67,7 @@ class Serverless {\nlet contentMap = this.getContentMap();\nfor (let url in contentMap) {\n- if (this.options.matchUrlPattern(urlPath, url)) {\n+ if (this.options.matchUrlToPattern(urlPath, url)) {\nreturn true;\n}\n}\n@@ -76,15 +76,30 @@ class Serverless {\nmatchUrlPattern(urlPath) {\nlet contentMap = this.getContentMap();\n+ let matches = [];\nfor (let url in contentMap) {\n- let result = this.options.matchUrlPattern(urlPath, url);\n+ let result = this.options.matchUrlToPattern(urlPath, url);\nif (result) {\n- return {\n+ matches.push({\n+ compareTo: url,\npathParams: result,\ninputPath: contentMap[url],\n- };\n+ });\n+ }\n+ }\n+\n+ if (matches.length) {\n+ if (matches.length > 1) {\n+ console.log(\n+ `Eleventy Serverless conflict: there are multiple serverless paths that match the current URL (${urlPath}): ${JSON.stringify(\n+ matches,\n+ null,\n+ 2\n+ )}`\n+ );\n}\n+ return matches[0];\n}\nreturn {};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -614,15 +614,20 @@ class TemplateMap {\nfor (let entry of this.map) {\nfor (let page of entry._pages) {\nif (page.url === false) {\n- // do nothing\n+ // do nothing, note that url exists in serverless mode\n} else if (!permalinks[page.url]) {\npermalinks[page.url] = [entry.inputPath];\n} else {\n+ // in serverless mode, page.outputPath is `false`\n+ let isServerlessTemplate = !page.outputPath;\n+\nwarnings[\npage.outputPath\n- ] = `Output conflict: multiple input files are writing to \\`${\n- page.outputPath\n- }\\`. Use distinct \\`permalink\\` values to resolve this conflict.\n+ ] = `Output conflict: multiple input files are ${\n+ isServerlessTemplate\n+ ? \"using the same serverless path\"\n+ : `writing to \\`${page.outputPath}\\``\n+ }. Use distinct \\`permalink\\` values to resolve this conflict.\n1. ${entry.inputPath}\n${permalinks[page.url]\n.map(function (inputPath, index) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePermalinkTest.js",
"new_path": "test/TemplatePermalinkTest.js",
"diff": "@@ -168,6 +168,22 @@ test(\"Permalink Object, just build\", (t) => {\nbuild: true,\n}).toLink();\n});\n+});\n+\n+test(\"Permalink Object, serverless URLs\", (t) => {\n+ t.is(\n+ new TemplatePermalink({\n+ serverless: \"permalinksubfolder/test.html\",\n+ }).toLink(),\n+ false\n+ );\n+\n+ t.is(\n+ new TemplatePermalink({\n+ serverless: \"permalinksubfolder/test.html\",\n+ }).toHref(),\n+ \"permalinksubfolder/test.html\"\n+ );\nt.is(\nnew TemplatePermalink({\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix for error messaging when two serverless permalinks match exactly |
699 | 07.06.2021 20:45:26 | 18,000 | d3cd329d83ec31414dfecc23b30b22c876e9d238 | Reset the copy count during watch | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -52,6 +52,10 @@ class BundlerHelper {\nthis.copyCount = 0;\n}\n+ reset() {\n+ this.copyCount = 0;\n+ }\n+\ngetOutputPath(filepath) {\nreturn TemplatePath.addLeadingDotSlash(path.join(this.dir, filepath));\n}\n@@ -194,6 +198,10 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nmiddleware: [helper.browserSyncMiddleware()],\n});\n+ eleventyConfig.on(\"eleventy.before\", async () => {\n+ helper.reset();\n+ });\n+\neleventyConfig.on(\"eleventy.after\", async () => {\n// extra copy targets\n// we put these in after a build so that we can grab files generated _by_ the build too\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Reset the copy count during watch |
699 | 08.06.2021 11:01:39 | 18,000 | 7748576dcbcb30cbf817188c980d33bde7f75d89 | Original serverless templates are now included in collections (but only one entry for now) | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -587,21 +587,20 @@ class Template extends TemplateContent {\n}\nasync getTemplates(data) {\n- // no pagination on permalink.serverless for local builds\n+ // no pagination with permalink.serverless\nlet hasPagination = Pagination.hasPagination(data);\n- let isServerlessTemplateRenderingViaBuild = !this.behavior.isRenderable();\n- let isServerlessTemplateRenderingViaServerless =\n+ let isPaginatedServerlessTemplateRenderingViaServerless =\nthis.behavior.isRenderForced() &&\nhasPagination &&\n\"serverless\" in data.pagination;\nif (\n!hasPagination ||\n- isServerlessTemplateRenderingViaBuild ||\n- isServerlessTemplateRenderingViaServerless\n+ !this.behavior.isRenderable() ||\n+ isPaginatedServerlessTemplateRenderingViaServerless\n) {\n// inject pagination page data for just this one entry for serverless render\n- if (isServerlessTemplateRenderingViaServerless && hasPagination) {\n+ if (isPaginatedServerlessTemplateRenderingViaServerless) {\nlet pagination = new Pagination(data, this.config);\nlet paginationItems = pagination.getTruncatedServerlessData(data);\nlet override = pagination.getOverrideData(paginationItems);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -121,10 +121,7 @@ class TemplateMap {\ngraph.addNode(entry.inputPath);\n}\n- if (\n- !entry.data.eleventyExcludeFromCollections &&\n- entry.template.behavior.isIncludedInCollections()\n- ) {\n+ if (!entry.data.eleventyExcludeFromCollections) {\n// collections.all\ngraph.addDependency(tagPrefix + \"all\", entry.inputPath);\n@@ -175,10 +172,7 @@ class TemplateMap {\n}\ngraph.addDependency(entry.inputPath, tagPrefix + paginationTagTarget);\n- if (\n- !entry.data.eleventyExcludeFromCollections &&\n- entry.template.behavior.isIncludedInCollections()\n- ) {\n+ if (!entry.data.eleventyExcludeFromCollections) {\n// collections.all\ngraph.addDependency(tagPrefix + \"all\", entry.inputPath);\n@@ -219,10 +213,7 @@ class TemplateMap {\ngraph.addNode(entry.inputPath);\n}\n- if (\n- !entry.data.eleventyExcludeFromCollections &&\n- entry.template.behavior.isIncludedInCollections()\n- ) {\n+ if (!entry.data.eleventyExcludeFromCollections) {\n// collections.all\ngraph.addDependency(tagPrefix + \"all\", entry.inputPath);\n}\n@@ -251,10 +242,7 @@ class TemplateMap {\ngraph.addNode(entry.inputPath);\n}\n- if (\n- !entry.data.eleventyExcludeFromCollections &&\n- entry.template.behavior.isIncludedInCollections()\n- ) {\n+ if (!entry.data.eleventyExcludeFromCollections) {\n// collections.all\ngraph.addDependency(tagPrefix + \"all\", entry.inputPath);\n}\n@@ -311,10 +299,7 @@ class TemplateMap {\n(map.data.pagination &&\nmap.data.pagination.addAllPagesToCollections)\n) {\n- if (\n- !map.data.eleventyExcludeFromCollections &&\n- map.template.behavior.isIncludedInCollections()\n- ) {\n+ if (!map.data.eleventyExcludeFromCollections) {\n// TODO do we need .template in collection entries?\nthis.collection.add(page);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePermalink.js",
"new_path": "src/TemplatePermalink.js",
"diff": "@@ -44,7 +44,6 @@ class TemplatePermalink {\ndelete this.serverlessUrls.build;\n// default if permalink is an Object but does not have a `build` prop\n- // note that this will opt-out this template from collections. See TemplateBehavior->isIncludedInCollections\nif (!(\"build\" in link)) {\nthis._writeToFileSystem = false;\nthis._isRendered = false;\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Original serverless templates are now included in collections (but only one entry for now) |
699 | 08.06.2021 13:02:01 | 18,000 | 217b4e3030404406637fd5cb550231ec4d107e0c | More straightforward pagination template code for serverless. | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -263,6 +263,10 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nfor (let entry of templateMap) {\nfor (let key in entry.serverless) {\nif (key === options.name) {\n+ if (outputMap[entry.serverless[key]] === entry.inputPath) {\n+ continue;\n+ }\n+\nif (outputMap[entry.serverless[key]]) {\nthrow new Error(\n`Serverless URL conflict: multiple input files are using the same URL path (in \\`permalink\\`): ${\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | More straightforward pagination template code for serverless. |
699 | 09.06.2021 07:12:37 | 18,000 | 51917a4b832c2a0b685660a14e7a08fcc5e27042 | Support array of eliglble URL paths in a single template:
permalink:
serverless:
- "/creators/:name/"
- "/authors/:name/" | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -262,20 +262,26 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nfor (let entry of templateMap) {\nfor (let key in entry.serverless) {\n- if (key === options.name) {\n- if (outputMap[entry.serverless[key]] === entry.inputPath) {\n+ if (key !== options.name) {\n+ continue;\n+ }\n+ let urls = entry.serverless[key];\n+ if (!Array.isArray(urls)) {\n+ urls = [entry.serverless[key]];\n+ }\n+ for (let eligibleUrl of urls) {\n+ // ignore duplicates that have the same input file, via Pagination.\n+ if (outputMap[eligibleUrl] === entry.inputPath) {\ncontinue;\n}\n- if (outputMap[entry.serverless[key]]) {\n+ if (outputMap[eligibleUrl]) {\nthrow new Error(\n- `Serverless URL conflict: multiple input files are using the same URL path (in \\`permalink\\`): ${\n- outputMap[entry.serverless[key]]\n- } and ${entry.inputPath}`\n+ `Serverless URL conflict: multiple input files are using the same URL path (in \\`permalink\\`): ${outputMap[eligibleUrl]} and ${entry.inputPath}`\n);\n}\n- outputMap[entry.serverless[key]] = entry.inputPath;\n+ outputMap[eligibleUrl] = entry.inputPath;\n}\n}\n}\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Support array of eliglble URL paths in a single template:
permalink:
serverless:
- "/creators/:name/"
- "/authors/:name/" |
699 | 09.06.2021 07:44:53 | 18,000 | 86be192faeafe5fe96681c431a449a78c9b9887c | Casing on file name | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -116,7 +116,7 @@ class BundlerHelper {\nwriteDependencyGlobalDataFile(globalDataFileList) {\nlet modules = getNodeModulesList(globalDataFileList);\nthis.writeBundlerDependenciesFile(\n- \"eleventy-app-globalData-modules.js\",\n+ \"eleventy-app-globaldata-modules.js\",\nmodules.filter(\n(name) => this.options.excludeDependencies.indexOf(name) === -1\n)\n@@ -161,7 +161,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\ncopy: [],\n// Dependencies explicitly declared from configuration and global data can be excluded and hidden from bundler.\n- // Excluded from: `eleventy-app-config-modules.js` and `eleventy-app-globalData-modules.js`\n+ // Excluded from: `eleventy-app-config-modules.js` and `eleventy-app-globaldata-modules.js`\nexcludeDependencies: [],\n// Add automated redirects to netlify.toml (appends or creates, avoids duplicate entries)\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Casing on file name |
699 | 09.06.2021 07:54:52 | 18,000 | 6c9e32ff2765c9dfe3e2df056d5e2ac85eea5b2d | Removes bad chdir | [
{
"change_type": "MODIFY",
"old_path": "src/Serverless.js",
"new_path": "src/Serverless.js",
"diff": "@@ -106,11 +106,6 @@ class Serverless {\n}\nasync render() {\n- // TODO is this necessary?\n- if (this.dir.startsWith(\"/var/task/\")) {\n- process.chdir(this.dir);\n- }\n-\nlet inputDir = path.join(this.dir, this.options.inputDir);\nlet configPath = path.join(this.dir, this.configFilename);\nlet { pathParams, inputPath } = this.matchUrlPattern(this.path);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Removes bad chdir |
699 | 09.06.2021 08:02:55 | 18,000 | b7f895c929fd7a9817f79fcecfc344526c36ff29 | Work with chdir | [
{
"change_type": "MODIFY",
"old_path": "src/Serverless.js",
"new_path": "src/Serverless.js",
"diff": "@@ -42,6 +42,7 @@ class Serverless {\nlet paths = [\npath.join(TemplatePath.getWorkingDir(), dir), // netlify dev\npath.join(\"/var/task/src/\", dir), // AWS Lambda absolute path\n+ path.join(TemplatePath.getWorkingDir()), // after the chdir below\n];\nfor (let path of paths) {\n@@ -106,6 +107,10 @@ class Serverless {\n}\nasync render() {\n+ if (this.dir.startsWith(\"/var/task/\")) {\n+ process.chdir(this.dir);\n+ }\n+\nlet inputDir = path.join(this.dir, this.options.inputDir);\nlet configPath = path.join(this.dir, this.configFilename);\nlet { pathParams, inputPath } = this.matchUrlPattern(this.path);\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Work with chdir |
699 | 10.06.2021 08:28:15 | 18,000 | 9264b181227282df1d2a2b566b4de7543d3732b0 | Fix for URLs with query parameters on localhost | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -4,6 +4,7 @@ const TOML = require(\"@iarna/toml\");\nconst copy = require(\"recursive-copy\");\nconst dependencyTree = require(\"@11ty/dependency-tree\");\nconst TemplatePath = require(\"../TemplatePath\");\n+const deleteRequireCache = require(\"../Util/DeleteRequireCache\");\nconst debug = require(\"debug\")(\"Eleventy:Serverless\");\nfunction getNodeModulesList(files) {\n@@ -123,16 +124,20 @@ class BundlerHelper {\nlet serverlessFilepath = TemplatePath.addLeadingDotSlash(\npath.join(TemplatePath.getWorkingDir(), this.dir, \"index\")\n);\n+ deleteRequireCache(TemplatePath.absolutePath(serverlessFilepath));\nreturn async (req, res, next) => {\nlet serverlessFunction = require(serverlessFilepath);\nlet url = new URL(req.url, \"http://localhost/\"); // any domain will do here, we just want the searchParams\n+ let queryParams = Object.fromEntries(url.searchParams);\nlet start = new Date();\nlet result = await serverlessFunction.handler({\nhttpMethod: \"GET\",\n- path: req.url,\n- queryStringParameters: Object.fromEntries(url.searchParams),\n+ path: url.pathname,\n+ // @netlify/functions builder overwrites these to {} intentionally\n+ // See https://github.com/netlify/functions/issues/38\n+ queryStringParameters: queryParams,\n});\nif (result.statusCode === 404) {\n@@ -228,9 +233,9 @@ function EleventyPlugin(eleventyConfig, options = {}) {\n}\nconsole.log(\n- `Eleventy Serverless: ${\n- helper.copyCount\n- } files bundled to ${helper.getOutputPath(\"\")}.`\n+ `Eleventy Serverless: ${helper.copyCount} file${\n+ helper.copyCount !== 1 ? \"s\" : \"\"\n+ } bundled to ${helper.getOutputPath(\"\")}.`\n);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Serverless.js",
"new_path": "src/Serverless.js",
"diff": "@@ -21,11 +21,11 @@ class Serverless {\n{\ninputDir: \".\",\nfunctionsDir: \"functions/\",\n- // Query String Parameters\nmatchUrlToPattern(path, urlToCompare) {\nlet pattern = new UrlPattern(urlToCompare);\nreturn pattern.match(path);\n},\n+ // Query String Parameters\nquery: {},\n// Inject shared collections\nprecompiledCollections: {},\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix for URLs with query parameters on localhost |
699 | 10.06.2021 08:47:15 | 18,000 | 3482dac153505b624187015f86ba92912b24f6d1 | Cache fs.stat calls for dates | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -832,6 +832,24 @@ class Template extends TemplateContent {\nreturn this.skippedCount;\n}\n+ async getInputFileStat() {\n+ if (this._stats) {\n+ return this._stats;\n+ }\n+\n+ this._stats = new Promise((resolve, reject) => {\n+ fs.stat(this.inputPath, (err, stats) => {\n+ if (err) {\n+ reject(err);\n+ } else {\n+ resolve(stats);\n+ }\n+ });\n+ });\n+\n+ return this._stats;\n+ }\n+\nasync getMappedDate(data) {\n// TODO(slightlyoff): lots of I/O!\n@@ -847,11 +865,12 @@ class Template extends TemplateContent {\ndebug(\"getMappedDate: YAML parsed it: %o\", data.date);\nreturn data.date;\n} else {\n- let stat = fs.statSync(this.inputPath);\n// string\nif (data.date.toLowerCase() === \"last modified\") {\n+ let stat = await this.getInputFileStat();\nreturn new Date(stat.ctimeMs);\n} else if (data.date.toLowerCase() === \"created\") {\n+ let stat = await this.getInputFileStat();\nreturn new Date(stat.birthtimeMs);\n} else {\n// try to parse with Luxon\n@@ -884,7 +903,7 @@ class Template extends TemplateContent {\nreturn dateObj;\n}\n- let stat = fs.statSync(this.inputPath);\n+ let stat = await this.getInputFileStat();\nlet createdDate = new Date(stat.birthtimeMs);\ndebug(\n\"getMappedDate: using file created time for %o of %o (from %o)\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Cache fs.stat calls for dates |
699 | 10.06.2021 20:21:30 | 18,000 | d16a556b32282f50bba25bfdadf7106d17474ebb | Add global copyOptions to serverless bundler plugin options and an `options` prop in the copy object `{ from: "", to: "", options: {} }` | [
{
"change_type": "MODIFY",
"old_path": "src/Plugins/ServerlessBundlerPlugin.js",
"new_path": "src/Plugins/ServerlessBundlerPlugin.js",
"diff": "@@ -82,14 +82,22 @@ class BundlerHelper {\nthis.copyCount++;\n}\n- recursiveCopy(src, dest) {\n+ recursiveCopy(src, dest, options = {}) {\nlet finalDest = this.getOutputPath(dest || src);\n- return copy(src, finalDest, {\n+ return copy(\n+ src,\n+ finalDest,\n+ Object.assign(\n+ {\noverwrite: true,\ndot: true,\njunk: false,\nresults: false,\n- }).on(copy.events.COPY_FILE_COMPLETE, () => {\n+ },\n+ this.options.copyOptions,\n+ options\n+ )\n+ ).on(copy.events.COPY_FILE_COMPLETE, () => {\nthis.copyCount++;\n});\n}\n@@ -172,6 +180,9 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nfunctionsDir: \"./functions/\",\ncopy: [],\n+ // https://www.npmjs.com/package/recursive-copy#usage\n+ copyOptions: {},\n+\n// Dependencies explicitly declared from configuration and global data can be excluded and hidden from bundler.\n// Excluded from: `eleventy-app-config-modules.js` and `eleventy-app-globaldata-modules.js`\nexcludeDependencies: [],\n@@ -237,7 +248,7 @@ function EleventyPlugin(eleventyConfig, options = {}) {\nif (typeof cp === \"string\") {\npromises.push(helper.recursiveCopy(cp));\n} else if (cp.from && cp.to) {\n- promises.push(helper.recursiveCopy(cp.from, cp.to));\n+ promises.push(helper.recursiveCopy(cp.from, cp.to, cp.options));\n} else {\ndebug(\n\"Ignored extra copy %o (needs to be a string or a {from: '', to: ''})\",\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Add global copyOptions to serverless bundler plugin options and an `options` prop in the copy object `{ from: "", to: "", options: {} }` |
699 | 11.06.2021 13:22:40 | 18,000 | 6f9732368a67ed4a9be1a396c9137dcb0fa76a52 | Pass `pathname` in with global data. | [
{
"change_type": "MODIFY",
"old_path": "src/Serverless.js",
"new_path": "src/Serverless.js",
"diff": "@@ -145,6 +145,7 @@ class Serverless {\n// Add the params to Global Data\neleventyConfig.addGlobalData(\"eleventy.serverless\", {\n+ pathname: this.path,\nquery: this.options.query,\npath: pathParams,\n});\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Pass `pathname` in with global data. |
699 | 11.06.2021 22:02:16 | 18,000 | d19257350887c9f670f8652039555d9460f69f79 | Fix for missing serverless URLs in serverlessUrlMap event on pagination templates with empty data (and no pages) | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -151,6 +151,17 @@ class Template extends TemplateContent {\nreturn this.serverlessUrls;\n}\n+ initServerlessUrlsForEmptyPaginationTemplates(permalinkValue) {\n+ if (isPlainObject(permalinkValue)) {\n+ let buildlessPermalink = Object.assign({}, permalinkValue);\n+ delete buildlessPermalink.build;\n+\n+ if (Object.keys(buildlessPermalink).length) {\n+ return this._getRawPermalinkInstance(buildlessPermalink);\n+ }\n+ }\n+ }\n+\n_getRawPermalinkInstance(permalinkValue) {\nlet perm = new TemplatePermalink(\npermalinkValue,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateMap.js",
"new_path": "src/TemplateMap.js",
"diff": "@@ -287,6 +287,16 @@ class TemplateMap {\nlet map = this.getMapEntryForInputPath(depEntry);\nmap._pages = await map.template.getTemplates(map.data);\n+ if (map._pages.length === 0) {\n+ // Setup serverlessUrls even if data set is 0 pages. This fixes 404 issue\n+ // with full build not including Sanity drafts but serverless render does\n+ // include Sanity drafts.\n+\n+ // We want these empty-data pagination templates to show up in the serverlessUrlMap.\n+ map.template.initServerlessUrlsForEmptyPaginationTemplates(\n+ map.data.permalink\n+ );\n+ } else {\nlet counter = 0;\nfor (let page of map._pages) {\n// Copy outputPath to map entry\n@@ -309,6 +319,7 @@ class TemplateMap {\n}\n}\n}\n+ }\nasync cache() {\ndebug(\"Caching collections objects.\");\n@@ -362,6 +373,20 @@ class TemplateMap {\ngenerateServerlessUrlMap(orderedMap) {\nlet entries = [];\nfor (let entry of orderedMap) {\n+ // Pagination templates with 0 pages should still populate\n+ // serverlessUrls into this event. We want these to still show up\n+ // in the inputPath to URL map and in the redirects.\n+ if (entry._pages.length === 0) {\n+ let serverless = {};\n+ if (isPlainObject(entry.data.permalink)) {\n+ // These are rendered in the template language!\n+ Object.assign(serverless, entry.template.getServerlessUrls());\n+ entries.push({\n+ inputPath: entry.inputPath,\n+ serverless,\n+ });\n+ }\n+ } else {\nfor (let page of entry._pages) {\nlet serverless = {};\nif (isPlainObject(page.data.permalink)) {\n@@ -370,12 +395,12 @@ class TemplateMap {\nentries.push({\ninputPath: entry.inputPath,\n- url: page.url,\nserverless,\n});\n}\n}\n}\n+ }\nreturn entries;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateMapTest.js",
"new_path": "test/TemplateMapTest.js",
"diff": "@@ -1325,7 +1325,6 @@ test(\"serverlessUrlMap Event (without `build`, only `serverless`)\", async (t) =>\nt.deepEqual(templateMap, [\n{\ninputPath: \"./test/stubs/permalink-nobuild/permalink-nobuild.md\",\n- url: false,\nserverless: {\nserverless: \"/url/\",\n},\n@@ -1353,7 +1352,6 @@ test(\"serverlessUrlMap Event (with `build`)\", async (t) => {\nt.deepEqual(templateMap, [\n{\ninputPath: \"./test/stubs/permalink-build/permalink-build.md\",\n- url: \"/url/\",\nserverless: {},\n},\n]);\n@@ -1380,7 +1378,6 @@ test(\"serverlessUrlMap Event (with `build` and `serverless`)\", async (t) => {\n{\ninputPath:\n\"./test/stubs/permalink-build-serverless/permalink-build-serverless.md\",\n- url: \"/url/\",\nserverless: {\nserverless: \"/some-other-url/\",\n},\n@@ -1409,7 +1406,6 @@ test(\"serverlessUrlMap Event (with templating on both `build` and `serverless`)\"\n{\ninputPath:\n\"./test/stubs/permalink-build-serverless-rendered/permalink-build-serverless-rendered.md\",\n- url: \"/url/\",\nserverless: {\nserverless: \"/some-other-url/\",\n},\n@@ -1428,3 +1424,31 @@ test(\"serverlessUrlMap Event (with templating on both `build` and `serverless`)\"\nawait tm.add(tmpl);\nawait tm.cache();\n});\n+\n+test(\"serverlessUrlMap Event (empty pagination template with `serverless` should still show up)\", async (t) => {\n+ t.plan(1);\n+\n+ let eleventyConfig = new TemplateConfig();\n+ eleventyConfig.userConfig.on(\"eleventy.serverlessUrlMap\", (templateMap) => {\n+ t.deepEqual(templateMap, [\n+ {\n+ inputPath:\n+ \"./test/stubs/permalink-serverless-empty-pagination/permalink-serverless-empty-pagination.md\",\n+ serverless: {\n+ serverless: \"/url/\",\n+ },\n+ },\n+ ]);\n+ });\n+\n+ let tm = new TemplateMap(eleventyConfig);\n+ let tmpl = getNewTemplate(\n+ \"./test/stubs/permalink-serverless-empty-pagination/permalink-serverless-empty-pagination.md\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\",\n+ eleventyConfig\n+ );\n+\n+ await tm.add(tmpl);\n+ await tm.cache();\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/permalink-serverless-empty-pagination/permalink-serverless-empty-pagination.md",
"diff": "+---\n+sampledata: []\n+pagination:\n+ data: sampledata\n+ size: 1\n+permalink:\n+ serverless: /url/\n+---\n"
}
]
| JavaScript | MIT License | 11ty/eleventy | Fix for missing serverless URLs in serverlessUrlMap event on pagination templates with empty data (and no pages) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.