From 6140ceca72bb774458294d261d6f3e1be1450a6e Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Sep 2025 16:50:04 -0500 Subject: [PATCH 01/53] Working demo --- ...obalData.js => ConfigurationGlobalData.js} | 4 +- src/Data/DataCascade.js | 104 ++++++++++ src/Data/TemplateData.js | 182 ++++++++++++------ src/Plugins/RenderPlugin.js | 4 +- src/Template.js | 81 ++++---- src/TemplateContent.js | 47 ++++- src/Util/HtmlRelativeCopy.js | 1 + src/Util/ImportJsonSync.js | 6 +- src/Util/ProjectDirectories.js | 8 +- test/TemplateTest-Dates.js | 18 +- 10 files changed, 326 insertions(+), 129 deletions(-) rename src/Data/{TemplateDataInitialGlobalData.js => ConfigurationGlobalData.js} (92%) create mode 100644 src/Data/DataCascade.js diff --git a/src/Data/TemplateDataInitialGlobalData.js b/src/Data/ConfigurationGlobalData.js similarity index 92% rename from src/Data/TemplateDataInitialGlobalData.js rename to src/Data/ConfigurationGlobalData.js index 7e2a7ee2e..2737bc1ca 100644 --- a/src/Data/TemplateDataInitialGlobalData.js +++ b/src/Data/ConfigurationGlobalData.js @@ -6,7 +6,7 @@ const { set: lodashSet } = lodash; class TemplateDataConfigError extends EleventyBaseError {} -class TemplateDataInitialGlobalData { +export default class ConfigurationGlobalData { constructor(templateConfig) { if (!templateConfig || templateConfig.constructor.name !== "TemplateConfig") { throw new TemplateDataConfigError("Missing or invalid `templateConfig` (via Render plugin)."); @@ -36,5 +36,3 @@ class TemplateDataInitialGlobalData { return globalData; } } - -export default TemplateDataInitialGlobalData; diff --git a/src/Data/DataCascade.js b/src/Data/DataCascade.js new file mode 100644 index 000000000..d193b5210 --- /dev/null +++ b/src/Data/DataCascade.js @@ -0,0 +1,104 @@ +import { isPlainObject, Merge } from "@11ty/eleventy-utils"; +import lodash from "@11ty/lodash-custom"; + +const { set: lodashSet, get: lodashGet } = lodash; + +export class DataCascade { + static READ_ONLY_KEY = "11ty:readonly"; + static UNEDITABLE_TYPE_KEY = "11ty:invalid_type"; + static INTERNAL_KEY = "11ty:internal"; + + static PREFIX = "[[via::"; + static POSTFIX = "]]"; + + constructor() { + this.dataSourceLocations = { + collections: [], + // __useInternalDataMapSource: true, // toggle on no-op behavior for filters + }; + } + + #getMergedSource(target, source) { + if (isPlainObject(target)) { + if (isPlainObject(source)) { + return Merge(target, source); + } + return target; + } + if (Array.isArray(target)) { + if (Array.isArray(source)) { + return [...target, ...source]; + } + return target; + } + return source; + } + + // Global Data and Template Data Cascade combine + mergeWithUpstreamDataCascade(...upstreamDataCascades) { + let locations = upstreamDataCascades.map((entry) => entry.getLocations()); + this.dataSourceLocations = Merge({}, ...locations, this.dataSourceLocations); + } + + mergeTopLevel(data, dataSourceLocation) { + let newSources = DataCascade.getMappingObject( + data, + dataSourceLocation || DataCascade.READ_ONLY_KEY, + ); + Merge(this.dataSourceLocations, newSources); + } + + mergeToLocation(data, location, dataSourceLocation) { + let target = lodashGet(this.dataSourceLocations, location); + let source = DataCascade.getMappingObject( + data, + dataSourceLocation || DataCascade.READ_ONLY_KEY, + ); + lodashSet(this.dataSourceLocations, location, this.#getMergedSource(target, source)); + } + + getLocations() { + return this.dataSourceLocations; + } + + static #getPropertySelector(selector, propName) { + if (selector) { + if (propName.includes("-") || propName.includes("'") || propName.includes('"')) { + return `${selector}[${propName}]`; + } + return `${selector}.${propName}`; + } + + // lodash.get selector locations work fine with top level prop names with - characters + return propName; + } + + static getMappingObject(target, sourceLocation, selector = "") { + if (Array.isArray(target)) { + return target.map((entry, index) => + this.getMappingObject(entry, sourceLocation, `${selector}[${index}]`), + ); + } + + if (isPlainObject(target)) { + let obj = {}; + for (let propName in target) { + obj[propName] = this.getMappingObject( + target[propName], + sourceLocation, + this.#getPropertySelector(selector, propName), + ); + } + return obj; + } + + if (typeof target === "function") { + return this.UNEDITABLE_TYPE_KEY; + } + + if (sourceLocation.startsWith("11ty:")) { + return this.PREFIX + sourceLocation + this.POSTFIX; + } + return this.PREFIX + sourceLocation + "::" + selector + this.POSTFIX; + } +} diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index d47600f57..85d03f349 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -6,12 +6,18 @@ import debugUtil from "debug"; import { inspect } from "../Adapters/Packages/inspect.js"; import unique from "../Util/Objects/Unique.js"; import TemplateGlob from "../TemplateGlob.js"; +import { DataCascade } from "./DataCascade.js"; import EleventyBaseError from "../Errors/EleventyBaseError.js"; -import TemplateDataInitialGlobalData from "./TemplateDataInitialGlobalData.js"; -import { getEleventyPackageJson, getWorkingProjectPackageJson } from "../Util/ImportJsonSync.js"; +import ConfigurationGlobalData from "./ConfigurationGlobalData.js"; +import { + getEleventyPackageJson, + importJsonSync, + getWorkingProjectPackageJsonPath, +} from "../Util/ImportJsonSync.js"; import { EleventyImport, EleventyLoadContent } from "../Util/Require.js"; import { DeepFreeze } from "../Util/Objects/DeepFreeze.js"; import { coerce } from "../Util/SemverCoerce.js"; +import ProjectDirectories from "../Util/ProjectDirectories.js"; const { set: lodashSet, get: lodashGet } = lodash; @@ -22,6 +28,12 @@ const debugDev = debugUtil("Dev:Eleventy:TemplateData"); class TemplateDataParseError extends EleventyBaseError {} class TemplateData { + #rawImports; + #globalData; + #templateDirectoryData = {}; + #globalDataCascade = new DataCascade(); + #templateDirectoryDataCascade = {}; + constructor(templateConfig) { if (!templateConfig || templateConfig.constructor.name !== "TemplateConfig") { throw new Error( @@ -37,12 +49,8 @@ class TemplateData { aggregate: this.config.benchmarkManager.get("Aggregate"), }; - this.rawImports = {}; - this.globalData = null; - this.templateDirectoryData = {}; this.isEsm = false; - - this.initialGlobalData = new TemplateDataInitialGlobalData(this.templateConfig); + this.initialGlobalData = new ConfigurationGlobalData(this.templateConfig); } get dirs() { @@ -114,25 +122,41 @@ class TemplateData { debug( "Opted-out of package.json assignment for global data with falsy value for `keys.package` configuration.", ); - return this.rawImports; - } else if (Object.keys(this.rawImports).length > 0) { - return this.rawImports; + return; + } + + if (this.#rawImports) { + return this.#rawImports; + } + + let projectPackageJsonPath = getWorkingProjectPackageJsonPath(); + let packageJson = {}; + if (projectPackageJsonPath) { + packageJson = importJsonSync(projectPackageJsonPath); } - let pkgJson = getWorkingProjectPackageJson(); - this.rawImports[this.config.keys.package] = pkgJson; + this.#rawImports = { + [this.config.keys.package]: packageJson, + }; + + if (projectPackageJsonPath) { + let relativeProjectPackageJsonPath = + ProjectDirectories.relativeToProjectRoot(projectPackageJsonPath); + this.#globalDataCascade.mergeTopLevel(this.#rawImports, relativeProjectPackageJsonPath); + } if (this.config.freezeReservedData) { - DeepFreeze(this.rawImports); + DeepFreeze(this.#rawImports); } - return this.rawImports; + return this.#rawImports; } clearData() { - this.globalData = null; + this.#globalData = null; this.configApiGlobalData = null; - this.templateDirectoryData = {}; + this.#templateDirectoryData = {}; + this.#templateDirectoryDataCascade = {}; } _getGlobalDataGlobByExtension(extension) { @@ -281,15 +305,16 @@ class TemplateData { async getAllGlobalData() { let globalData = {}; + let files = TemplatePath.addLeadingDotSlashArray(await this.getGlobalDataFiles()); this.config.events.emit("eleventy.globalDataFiles", files); let dataFileConflicts = {}; - for (let j = 0, k = files.length; j < k; j++) { - let data = await this.getDataValue(files[j]); - let objectPathTarget = this.getObjectPathForDataFile(files[j]); + for (let file of Object.values(files)) { + let data = await this.getDataValue(file); + let objectPathTarget = this.getObjectPathForDataFile(file); // Since we're joining directory paths and an array is not usable as an objectkey since two identical arrays are not double equal, // we can just join the array by a forbidden character ("/"" is chosen here, since it works on Linux, Mac and Windows). @@ -301,54 +326,53 @@ class TemplateData { // and conflict, let’s merge them. if (dataFileConflicts[objectPathTargetString]) { debugWarn( - `merging global data from ${files[j]} with an already existing global data file (${dataFileConflicts[objectPathTargetString]}). Overriding existing keys.`, + `merging global data from ${file} with an already existing global data file (${dataFileConflicts[objectPathTargetString]}). Overriding existing keys.`, ); let oldData = lodashGet(globalData, objectPathTarget); data = TemplateData.mergeDeep(this.config.dataDeepMerge, oldData, data); } - dataFileConflicts[objectPathTargetString] = files[j]; - debug(`Found global data file ${files[j]} and adding as: ${objectPathTarget}`); + dataFileConflicts[objectPathTargetString] = file; + debug(`Found global data file ${file} and adding as: ${objectPathTarget}`); + + this.#globalDataCascade.mergeToLocation(data, objectPathTargetString, file); + lodashSet(globalData, objectPathTarget, data); } return globalData; } - async #getInitialGlobalData() { - let globalData = await this.initialGlobalData.getData(); - - if (!("eleventy" in globalData)) { - globalData.eleventy = {}; - } - + getEleventyGlobal() { // #2293 for meta[name=generator] const pkg = getEleventyPackageJson(); - globalData.eleventy.version = coerce(pkg.version).toString(); - globalData.eleventy.generator = `Eleventy v${globalData.eleventy.version}`; + let version = coerce(pkg.version).toString(); + let eleventy = { + version, + generator: `Eleventy v${version}`, + }; if (this.environmentVariables) { - if (!("env" in globalData.eleventy)) { - globalData.eleventy.env = {}; - } - - Object.assign(globalData.eleventy.env, this.environmentVariables); + eleventy.env = Object.assign({}, this.environmentVariables); } - if (this.dirs) { - if (!("directories" in globalData.eleventy)) { - globalData.eleventy.directories = {}; - } - - Object.assign(globalData.eleventy.directories, this.dirs.getUserspaceInstance()); + eleventy.directories = Object.assign({}, this.dirs.getUserspaceInstance()); } - // Reserved + // `eleventy` is Reserved if (this.config.freezeReservedData) { - DeepFreeze(globalData.eleventy); + DeepFreeze(eleventy); } + return eleventy; + } + + async #getInitialGlobalData() { + let globalData = await this.initialGlobalData.getData(); + + globalData.eleventy = this.getEleventyGlobal(); + return globalData; } @@ -362,8 +386,17 @@ class TemplateData { async #getGlobalData() { let rawImports = this.getRawImports(); + + // Data from the configuration API eleventyConfig.addGLobalData and `eleventy` global let configApiGlobalData = await this.getInitialGlobalData(); + this.#globalDataCascade.mergeTopLevel(configApiGlobalData); + this.#globalDataCascade.mergeToLocation( + configApiGlobalData.eleventy, + "eleventy", + DataCascade.INTERNAL_KEY, + ); + let globalJson = await this.getAllGlobalData(); let mergedGlobalData = Merge(globalJson, configApiGlobalData); @@ -372,15 +405,15 @@ class TemplateData { } async getGlobalData() { - if (!this.globalData) { - this.globalData = this.#getGlobalData(); + if (!this.#globalData) { + this.#globalData = this.#getGlobalData(); } - return this.globalData; + return this.#globalData; } /* Template and Directory data files */ - async combineLocalData(localDataPaths) { + async combineLocalData(localDataPaths, dataCascade) { let localData = {}; if (!Array.isArray(localDataPaths)) { localDataPaths = [localDataPaths]; @@ -423,19 +456,40 @@ class TemplateData { dataSource[key] = path; } TemplateData.mergeDeep(this.config.dataDeepMerge, localData, cleanedDataForPath); + + if (dataCascade) { + dataCascade.mergeTopLevel(localData, path); + } } } + return localData; } + getGlobalDataCascade() { + return this.#globalDataCascade; + } + async getTemplateDirectoryData(templatePath) { - if (!this.templateDirectoryData[templatePath]) { + if (!this.#templateDirectoryData[templatePath]) { + this.#templateDirectoryDataCascade[templatePath] = new DataCascade(); let localDataPaths = await this.getLocalDataPaths(templatePath); - let importedData = await this.combineLocalData(localDataPaths); + let importedData = await this.combineLocalData( + localDataPaths, + this.#templateDirectoryDataCascade[templatePath], + ); + + this.#templateDirectoryData[templatePath] = importedData; + } + return this.#templateDirectoryData[templatePath]; + } - this.templateDirectoryData[templatePath] = importedData; + getTemplateDirectoryDataCascade(templatePath) { + if (!this.#templateDirectoryDataCascade[templatePath]) { + throw new Error("Missing template data cascade for " + templatePath); } - return this.templateDirectoryData[templatePath]; + + return this.#templateDirectoryDataCascade[templatePath]; } getUserDataExtensions() { @@ -509,7 +563,10 @@ class TemplateData { // We always need to use `import()`, as `require` isn’t available in ESM. let returnValue = await EleventyImport(path, type); - // TODO special exception for Global data `permalink.js` + // Returning a function is executed immediately (it has always done this for global data) + + // TODO some API to allow returning a function without executing it immediately + // (e.g. `permalink.js` or `eleventyDataSchema.js` global data) // module.exports = (data) => `${data.page.filePathStem}/`; // Does not work // module.exports = () => ((data) => `${data.page.filePathStem}/`); // Works if (typeof returnValue === "function") { @@ -525,11 +582,14 @@ class TemplateData { // Other extensions let { parser, options } = this.getUserDataParser(extension); - return this._parseDataFile(path, parser, options); + let returnValue = this._parseDataFile(path, parser, options); + + return returnValue; } else if (extension === "json") { // File to string, parse with JSON (preprocess) - const parser = (content) => JSON.parse(content); - return this._parseDataFile(path, parser); + let returnValue = this._parseDataFile(path, (content) => JSON.parse(content)); + + return returnValue; } else { throw new TemplateDataParseError( `Could not find an appropriate data parser for ${path}. Do you need to add a plugin to your config file?`, @@ -632,16 +692,16 @@ class TemplateData { return unique(paths).reverse(); } - static mergeDeep(deepMerge, target, ...source) { + static mergeDeep(deepMerge, target, ...sources) { if (!deepMerge && deepMerge !== undefined) { - return Object.assign(target, ...source); + return Object.assign(target, ...sources); } else { - return TemplateData.merge(target, ...source); + return TemplateData.merge(target, ...sources); } } - static merge(target, ...source) { - return Merge(target, ...source); + static merge(target, ...sources) { + return Merge(target, ...sources); } /* Like cleanupData() but does not mutate */ diff --git a/src/Plugins/RenderPlugin.js b/src/Plugins/RenderPlugin.js index a928f87ec..8c22c8302 100644 --- a/src/Plugins/RenderPlugin.js +++ b/src/Plugins/RenderPlugin.js @@ -4,7 +4,7 @@ import { Merge, TemplatePath, isPlainObject } from "@11ty/eleventy-utils"; // TODO add a first-class Markdown component to expose this using Markdown-only syntax (will need to be synchronous for markdown-it) import { ProxyWrap } from "../Util/Objects/ProxyWrap.js"; -import TemplateDataInitialGlobalData from "../Data/TemplateDataInitialGlobalData.js"; +import ConfigurationGlobalData from "../Data/ConfigurationGlobalData.js"; import EleventyBaseError from "../Errors/EleventyBaseError.js"; import TemplateRender from "../TemplateRender.js"; import ProjectDirectories from "../Util/ProjectDirectories.js"; @@ -463,7 +463,7 @@ class RenderManager { get initialGlobalData() { if (!this._data) { - this._data = new TemplateDataInitialGlobalData(this.templateConfig); + this._data = new ConfigurationGlobalData(this.templateConfig); } return this._data; } diff --git a/src/Template.js b/src/Template.js index 83898f5a9..7bbb6db7c 100755 --- a/src/Template.js +++ b/src/Template.js @@ -2,7 +2,7 @@ import path from "node:path"; import { statSync } from "node:fs"; import lodash from "@11ty/lodash-custom"; -import { TemplatePath, isPlainObject } from "@11ty/eleventy-utils"; +import { TemplatePath, isPlainObject, Merge } from "@11ty/eleventy-utils"; import debugUtil from "debug"; import chalk from "./Adapters/Packages/chalk.js"; @@ -34,6 +34,9 @@ class Template extends TemplateContent { #logger; #fsManager; #stats; + #dataCache; + #cacheRenderedPromise; + #cacheRenderedTransformsAndLayoutsPromise; constructor(templatePath, templateData, extensionMap, config) { debugDev("new Template(%o)", templatePath); @@ -130,14 +133,14 @@ class Template extends TemplateContent { super.resetCaches(types); if (types.data) { - delete this._dataCache; + this.#dataCache = undefined; // delete this._usePermalinkRoot; // delete this.#stats; } if (types.render) { - delete this._cacheRenderedPromise; - delete this._cacheRenderedTransformsAndLayoutsPromise; + this.#cacheRenderedPromise = undefined; + this.#cacheRenderedTransformsAndLayoutsPromise = undefined; } } @@ -374,7 +377,7 @@ class Template extends TemplateContent { if (this.templateData) { localData = await this.templateData.getTemplateDirectoryData(this.inputPath); - globalData = await this.templateData.getGlobalData(this.inputPath); + globalData = await this.templateData.getGlobalData(); debugDev("%o getData getTemplateDirectoryData and getGlobalData", this.inputPath); } @@ -411,7 +414,8 @@ class Template extends TemplateContent { ReservedData.check(mergedData); } - await this.addPage(mergedData); + let pageData = await this.getPageData(mergedData); + Merge(mergedData, { page: pageData }); debugDev("%o getData mergedData", this.inputPath); @@ -434,38 +438,36 @@ class Template extends TemplateContent { } async getData() { - if (!this._dataCache) { + if (!this.#dataCache) { // @cachedproperty - this._dataCache = this.#getData(); + this.#dataCache = this.#getData(); } - return this._dataCache; + return this.#dataCache; } - async addPage(data) { - if (!("page" in data)) { - data.page = {}; - } - - // Make sure to keep these keys synchronized in src/Util/ReservedData.js - data.page.inputPath = this.inputPath; - data.page.fileSlug = this.fileSlugStr; - data.page.filePathStem = this.filePathStem; - data.page.outputFileExtension = this.engine.defaultTemplateFileExtension; - data.page.templateSyntax = this.templateRender.getEnginesList( - data[this.config.keys.engineOverride], - ); + async getPageData(data) { + let page = { + // Make sure to keep these keys synchronized in src/Util/ReservedData.js + inputPath: this.inputPath, + fileSlug: this.fileSlugStr, + filePathStem: this.filePathStem, + outputFileExtension: this.engine.defaultTemplateFileExtension, + templateSyntax: this.templateRender.getEnginesList(data[this.config.keys.engineOverride]), + }; - let newDate = await this.getMappedDate(data); + let newDate = await this.getMappedDate(data?.date, page); // Skip date assignment if custom date is falsy. if (newDate) { - data.page.date = newDate; + page.date = newDate; } - // data.page.url - // data.page.outputPath - // data.page.excerpt from gray-matter and Front Matter - // data.page.lang from I18nPlugin + // page.url + // page.outputPath + // page.excerpt from gray-matter and Front Matter + // page.lang from I18nPlugin + + return page; } // Tests only @@ -485,12 +487,12 @@ class Template extends TemplateContent { // This is the primary render mechanism, called via TemplateMap->populateContentDataInMap async renderPageEntryWithoutLayout(pageEntry) { // @cachedproperty - if (!this._cacheRenderedPromise) { - this._cacheRenderedPromise = this.renderDirect(pageEntry.rawInput, pageEntry.data); + if (!this.#cacheRenderedPromise) { + this.#cacheRenderedPromise = this.renderDirect(pageEntry.rawInput, pageEntry.data); this.renderCount++; } - return this._cacheRenderedPromise; + return this.#cacheRenderedPromise; } setLinters(linters) { @@ -938,14 +940,15 @@ class Template extends TemplateContent { return content; } + // This could be `static` async renderPageEntry(pageEntry) { // @cachedproperty - if (!pageEntry.template._cacheRenderedTransformsAndLayoutsPromise) { - pageEntry.template._cacheRenderedTransformsAndLayoutsPromise = - this.#renderPageEntryWithLayoutsAndTransforms(pageEntry); + if (!pageEntry.template.#cacheRenderedTransformsAndLayoutsPromise) { + pageEntry.template.#cacheRenderedTransformsAndLayoutsPromise = + pageEntry.template.#renderPageEntryWithLayoutsAndTransforms(pageEntry); } - return pageEntry.template._cacheRenderedTransformsAndLayoutsPromise; + return pageEntry.template.#cacheRenderedTransformsAndLayoutsPromise; } retrieveDataForJsonOutput(data, selectors) { @@ -1077,15 +1080,13 @@ class Template extends TemplateContent { return newDate; } - async getMappedDate(data) { - let dateValue = data?.date; - + async getMappedDate(dateValue, pageData) { // These can return a Date object, or a string. // Already type checked to be functions in UserConfig for (let fn of this.config.customDateParsing) { let ret = fn.call( { - page: data.page, + page: pageData, }, dateValue, ); @@ -1097,7 +1098,7 @@ class Template extends TemplateContent { } if (dateValue) { - debug("getMappedDate: using a date in the data for %o of %o", this.inputPath, data.date); + debug("getMappedDate: using a date in the data for %o of %o", this.inputPath, dateValue); if (dateValue?.constructor?.name === "DateTime") { // a luxon instance debug("getMappedDate: found DateTime instance: %o", dateValue); diff --git a/src/TemplateContent.js b/src/TemplateContent.js index 436836c85..8a8f2ca66 100644 --- a/src/TemplateContent.js +++ b/src/TemplateContent.js @@ -394,30 +394,59 @@ class TemplateContent { return fm.content; } + get dataCascade() { + if (this.templateData) { + return this.templateData.getTemplateDirectoryDataCascade(this.inputPath); + } + } + async #getFrontMatterData() { let fm = await this.read(); + let virtualTemplateDefinition = this.getVirtualTemplateDefinition(); + let virtualTemplateData; + if (virtualTemplateDefinition) { + virtualTemplateData = virtualTemplateDefinition.data; + + TemplateData.cleanupData(virtualTemplateData, { + file: this.inputPath, + isVirtualTemplate: Boolean(virtualTemplateData), + }); + } + // gray-matter isn’t async-friendly but can return a promise from custom front matter if (fm.data instanceof Promise) { fm.data = await fm.data; } - let tr = await this.getTemplateRender(); - let extraData = await tr.engine.getExtraDataFromFile(this.inputPath); + let frontMatterData = Object.assign({}, fm.data); - let virtualTemplateDefinition = this.getVirtualTemplateDefinition(); - let virtualTemplateData; - if (virtualTemplateDefinition) { - virtualTemplateData = virtualTemplateDefinition.data; - } + TemplateData.cleanupData(frontMatterData, { + file: this.inputPath, + isVirtualTemplate: Boolean(virtualTemplateData), + }); - let data = Object.assign({}, fm.data, extraData, virtualTemplateData); + let tr = await this.getTemplateRender(); + let extraData = await tr.engine.getExtraDataFromFile(this.inputPath); - TemplateData.cleanupData(data, { + TemplateData.cleanupData(extraData, { file: this.inputPath, isVirtualTemplate: Boolean(virtualTemplateData), }); + if (this.dataCascade) { + this.dataCascade.mergeTopLevel(frontMatterData, this.inputPath); + + if (extraData) { + this.dataCascade.mergeTopLevel(extraData); + } + if (virtualTemplateData) { + this.dataCascade.mergeTopLevel(virtualTemplateData); + } + } + + let data = Object.assign(frontMatterData, extraData, virtualTemplateData); + return { data, excerpt: fm.excerpt, diff --git a/src/Util/HtmlRelativeCopy.js b/src/Util/HtmlRelativeCopy.js index fe2ebe1a2..a2074e268 100644 --- a/src/Util/HtmlRelativeCopy.js +++ b/src/Util/HtmlRelativeCopy.js @@ -112,6 +112,7 @@ class HtmlRelativeCopy { } // Relative to source file’s input path + // Maybe use ProjectDirectories.relativeToProjectRoot() let source = this.getFilePathRelativeToProjectRoot(fileRef, tmplInputPath); if (!this.isCopyableTarget(source)) { return; diff --git a/src/Util/ImportJsonSync.js b/src/Util/ImportJsonSync.js index b6e0b3d32..3c43d77fa 100644 --- a/src/Util/ImportJsonSync.js +++ b/src/Util/ImportJsonSync.js @@ -45,8 +45,10 @@ function getWorkingProjectPackageJsonPath() { return findFilePathInParentDirs(dir, "package.json"); } -function getWorkingProjectPackageJson() { - let filePath = getWorkingProjectPackageJsonPath(); +function getWorkingProjectPackageJson(filePath) { + if (!filePath) { + filePath = getWorkingProjectPackageJsonPath(); + } // Fails nicely if (!filePath) { diff --git a/src/Util/ProjectDirectories.js b/src/Util/ProjectDirectories.js index e34dd18c4..78070d285 100644 --- a/src/Util/ProjectDirectories.js +++ b/src/Util/ProjectDirectories.js @@ -6,7 +6,7 @@ import { isDynamicPattern } from "../Util/GlobMatcher.js"; import DirContains from "./DirContains.js"; /* Directories internally should always use *nix forward slashes */ -class ProjectDirectories { +export default class ProjectDirectories { static defaults = { input: "./", data: "./_data/", // Relative to input directory @@ -25,6 +25,10 @@ class ProjectDirectories { inputFile = undefined; inputGlob = undefined; + static relativeToProjectRoot(fileOrDir) { + return this.normalizePath(TemplatePath.relativePath(fileOrDir)); + } + // Add leading dot slash // Use forward slashes static normalizePath(fileOrDir) { @@ -365,5 +369,3 @@ class ProjectDirectories { }; } } - -export default ProjectDirectories; diff --git a/test/TemplateTest-Dates.js b/test/TemplateTest-Dates.js index baccde0bd..368145fc9 100644 --- a/test/TemplateTest-Dates.js +++ b/test/TemplateTest-Dates.js @@ -10,7 +10,7 @@ async function getRenderedData(tmpl, pageNumber = 0) { test("getMappedDate (empty, assume created)", async (t) => { let tmpl = await getNewTemplate("./test/stubs/dates/file1.md", "./test/stubs/", "./dist"); let data = await getRenderedData(tmpl); - let date = await tmpl.getMappedDate(data); + let date = await tmpl.getMappedDate(data.date, data.page); t.true(date instanceof Date); t.truthy(date.getTime()); @@ -19,7 +19,7 @@ test("getMappedDate (empty, assume created)", async (t) => { test("getMappedDate (explicit date, yaml String)", async (t) => { let tmpl = await getNewTemplate("./test/stubs/dates/file2.md", "./test/stubs/", "./dist"); let data = await getRenderedData(tmpl); - let date = await tmpl.getMappedDate(data); + let date = await tmpl.getMappedDate(data.date, data.page); t.true(date instanceof Date); t.truthy(date.getTime()); @@ -29,7 +29,7 @@ test("getMappedDate (explicit date, yaml String)", async (t) => { test("getMappedDate (explicit date, yaml Date)", async (t) => { let tmpl = await getNewTemplate("./test/stubs/dates/file2b.md", "./test/stubs/", "./dist"); let data = await getRenderedData(tmpl); - let date = await tmpl.getMappedDate(data); + let date = await tmpl.getMappedDate(data.date, data.page); t.true(date instanceof Date); t.truthy(date.getTime()); @@ -39,11 +39,11 @@ test("getMappedDate (explicit date, yaml Date)", async (t) => { test("getMappedDate (explicit date, yaml Date and string should be the same)", async (t) => { let tmplA = await getNewTemplate("./test/stubs/dates/file2.md", "./test/stubs/", "./dist"); let dataA = await getRenderedData(tmplA); - let stringDate = await tmplA.getMappedDate(dataA); + let stringDate = await tmplA.getMappedDate(dataA.date, dataA.page); let tmplB = await getNewTemplate("./test/stubs/dates/file2b.md", "./test/stubs/", "./dist"); let dataB = await getRenderedData(tmplB); - let yamlDate = await tmplB.getMappedDate(dataB); + let yamlDate = await tmplB.getMappedDate(dataB.date, dataB.page); t.truthy(stringDate); t.truthy(yamlDate); @@ -53,7 +53,7 @@ test("getMappedDate (explicit date, yaml Date and string should be the same)", a test("getMappedDate (modified date)", async (t) => { let tmpl = await getNewTemplate("./test/stubs/dates/file3.md", "./test/stubs/", "./dist"); let data = await getRenderedData(tmpl); - let date = await tmpl.getMappedDate(data); + let date = await tmpl.getMappedDate(data.date, data.page); t.true(date instanceof Date); t.truthy(date.getTime()); @@ -62,7 +62,7 @@ test("getMappedDate (modified date)", async (t) => { test("getMappedDate (created date)", async (t) => { let tmpl = await getNewTemplate("./test/stubs/dates/file4.md", "./test/stubs/", "./dist"); let data = await getRenderedData(tmpl); - let date = await tmpl.getMappedDate(data); + let date = await tmpl.getMappedDate(data.date, data.page); t.true(date instanceof Date); t.truthy(date.getTime()); @@ -75,7 +75,7 @@ test("getMappedDate (falls back to filename date)", async (t) => { "./dist" ); let data = await getRenderedData(tmpl); - let date = await tmpl.getMappedDate(data); + let date = await tmpl.getMappedDate(data.date, data.page); t.true(date instanceof Date); t.truthy(date.getTime()); @@ -89,7 +89,7 @@ test("getMappedDate (found multiple dates, picks first)", async (t) => { "./dist" ); let data = await getRenderedData(tmpl); - let date = await tmpl.getMappedDate(data); + let date = await tmpl.getMappedDate(data.date, data.page); t.true(date instanceof Date); t.truthy(date.getTime()); From 354303c9ef576e99d34cc65338043efa502c69ca Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Fri, 26 Sep 2025 15:49:21 -0500 Subject: [PATCH 02/53] Working example --- src/Data/DataCascade.js | 139 +++++++++++++++++------- src/Data/DataSourceLocation.js | 156 +++++++++++++++++++++++++++ src/Data/TemplateData.js | 35 +++--- src/Engines/JavaScript.js | 1 + src/Engines/Liquid.js | 2 + src/Engines/Nunjucks.js | 4 +- src/Engines/Util/ContextAugmenter.js | 9 +- src/Template.js | 79 +++++++++++++- src/TemplateContent.js | 18 ++++ src/TemplateLayout.js | 25 +++-- src/TemplateMap.js | 39 +++++++ src/TemplateWriter.js | 1 + 12 files changed, 435 insertions(+), 73 deletions(-) create mode 100644 src/Data/DataSourceLocation.js diff --git a/src/Data/DataCascade.js b/src/Data/DataCascade.js index d193b5210..58396d49b 100644 --- a/src/Data/DataCascade.js +++ b/src/Data/DataCascade.js @@ -1,60 +1,107 @@ -import { isPlainObject, Merge } from "@11ty/eleventy-utils"; +import { isPlainObject, DeepCopy } from "@11ty/eleventy-utils"; import lodash from "@11ty/lodash-custom"; +import { LocationFactory, stringifyReadonlyLocation } from "./DataSourceLocation.js"; + const { set: lodashSet, get: lodashGet } = lodash; +export class DataCascadeManager { + constructor() { + this.dataCascades = new Map(); + } + + has(templatePath) { + return this.dataCascades.has(templatePath); + } + + create(templatePath) { + let cascade = new DataCascade(); + this.dataCascades.set(templatePath, cascade); + return cascade; + } + + get(templatePath) { + if (!this.has(templatePath)) { + throw new Error("Internal error: missing data cascade for " + templatePath); + } + + return this.dataCascades.get(templatePath); + } + + reset() { + this.dataCascades = new Map(); + } +} + export class DataCascade { static READ_ONLY_KEY = "11ty:readonly"; - static UNEDITABLE_TYPE_KEY = "11ty:invalid_type"; - static INTERNAL_KEY = "11ty:internal"; - - static PREFIX = "[[via::"; - static POSTFIX = "]]"; + static TOGGLE_PROP_NAME = "__useInternalDataMapSource"; constructor() { - this.dataSourceLocations = { - collections: [], - // __useInternalDataMapSource: true, // toggle on no-op behavior for filters - }; + this.dataSourceLocations = {}; + + Object.defineProperty(this.dataSourceLocations, DataCascade.TOGGLE_PROP_NAME, { + value: true + }); } - #getMergedSource(target, source) { - if (isPlainObject(target)) { - if (isPlainObject(source)) { - return Merge(target, source); - } - return target; + // TODO start here, circular references are maximum call stacking + static deepThaw(target) { + if(Array.isArray(target)) { + return target.map(entry => this.deepThaw(entry)); } - if (Array.isArray(target)) { - if (Array.isArray(source)) { - return [...target, ...source]; + + if(isPlainObject(target)) { + if(Object.isFrozen(target)) { + let thawed = {}; + for(let key in target) { + thawed[key] = this.deepThaw(target[key]); + } + return thawed; + } + + // reuse existing + for(let key in target) { + target[key] = this.deepThaw(target[key]); } - return target; } - return source; + return target; } // Global Data and Template Data Cascade combine mergeWithUpstreamDataCascade(...upstreamDataCascades) { let locations = upstreamDataCascades.map((entry) => entry.getLocations()); - this.dataSourceLocations = Merge({}, ...locations, this.dataSourceLocations); + this.dataSourceLocations = DeepCopy({}, ...locations, this.dataSourceLocations); + } + + assignFromUpstreamDataCascade(...upstreamDataCascades) { + let locations = upstreamDataCascades.map((entry) => entry.getLocations()); + this.dataSourceLocations = Object.assign({}, ...locations, this.dataSourceLocations); } - mergeTopLevel(data, dataSourceLocation) { + mergeTopLevel(data, sourceFilePath) { let newSources = DataCascade.getMappingObject( data, - dataSourceLocation || DataCascade.READ_ONLY_KEY, + sourceFilePath || DataCascade.READ_ONLY_KEY, ); - Merge(this.dataSourceLocations, newSources); + DeepCopy(this.dataSourceLocations, newSources); } - mergeToLocation(data, location, dataSourceLocation) { + mergeToLocation(data, location, sourceFilePath, dataSourceSelector) { let target = lodashGet(this.dataSourceLocations, location); let source = DataCascade.getMappingObject( data, - dataSourceLocation || DataCascade.READ_ONLY_KEY, + sourceFilePath || DataCascade.READ_ONLY_KEY, + dataSourceSelector ); - lodashSet(this.dataSourceLocations, location, this.#getMergedSource(target, source)); + + let merged = DeepCopy(target, source); + lodashSet(this.dataSourceLocations, location, merged); + } + + // For computed data + markLocationAsReadOnly(location) { + lodashSet(this.dataSourceLocations, location, stringifyReadonlyLocation(location)); } getLocations() { @@ -73,32 +120,44 @@ export class DataCascade { return propName; } - static getMappingObject(target, sourceLocation, selector = "") { + static getMappingObject(target, sourceFilePath, dataLocationSelector = "") { + if (typeof target === "function") { + return target; + } else if(sourceFilePath.startsWith("11ty:")) { // readonly/internal mappings + // internal data may be frozen (think `eleventy` global) + return DataCascade.deepThaw(target); + } + + if(sourceFilePath.startsWith("./")) { + sourceFilePath = sourceFilePath.slice(2); + } + + if(typeof target === "string" || typeof target === "number") { + return LocationFactory(target, sourceFilePath, dataLocationSelector); + } + if (Array.isArray(target)) { return target.map((entry, index) => - this.getMappingObject(entry, sourceLocation, `${selector}[${index}]`), + this.getMappingObject(entry, sourceFilePath, `${dataLocationSelector}[${index}]`), ); } if (isPlainObject(target)) { + if(Object.isFrozen(target)) { + return DataCascade.deepThaw(target); + } + let obj = {}; for (let propName in target) { obj[propName] = this.getMappingObject( target[propName], - sourceLocation, - this.#getPropertySelector(selector, propName), + sourceFilePath, + this.#getPropertySelector(dataLocationSelector, propName), ); } return obj; } - if (typeof target === "function") { - return this.UNEDITABLE_TYPE_KEY; - } - - if (sourceLocation.startsWith("11ty:")) { - return this.PREFIX + sourceLocation + this.POSTFIX; - } - return this.PREFIX + sourceLocation + "::" + selector + this.POSTFIX; + return target; } } diff --git a/src/Data/DataSourceLocation.js b/src/Data/DataSourceLocation.js new file mode 100644 index 000000000..c2925d87d --- /dev/null +++ b/src/Data/DataSourceLocation.js @@ -0,0 +1,156 @@ +import { isPlainObject } from "@11ty/eleventy-utils"; + +export class ArgumentHelper { + static isComplexArgument(v) { + return !this.isPrimitive(v) && !this.hasLocation(v); + } + static isPrimitive(v) { + return v !== Object(v); + } + static hasLocation(obj) { + return ["StringLocation", "NumberLocation"].includes(obj?.constructor?.name); + } + + static getFriendlyType(obj) { + if(this.hasLocation(obj)) { + let original = obj.getOriginalValue(); + if(this.hasLocation(original)) { + throw new Error("Internal error: data source location mapped to self (circular reference)") + } + return this.getFriendlyType(original); + } + if(Array.isArray(obj)) { + return "array"; + } + if(isPlainObject(obj)) { + return "object"; + } + return typeof obj; + } + + static hasArgumentParity(args = []) { + let types = {}; + for(let a of args) { + let type = this.getFriendlyType(a); + if(!types[type]) { + types[type] = 0; + } + types[type]++; + } + let keys = Object.keys(types); + return keys.length === 1; + } + + // TODO add configuration option to hard-code the execution mode for a filter + static getExecutionMode(...args) { + // skips if args.length is 1 + if(!this.hasArgumentParity(args)) { + return "partial"; + } + + // some args are not primitives and aren’t location-aware + let complexArgs = args.filter(a => this.isComplexArgument(a)); + if(complexArgs.length > 0) { + return "execute"; + } + + // is empty or single literal + return "passthrough"; + } + + static mapToLocation(args) { + return args.filter(a => this.hasLocation(a)).map(a => a.getLocation()); + } + + static wrapFilter(callback) { + return function(...args) { + if(this.__useInternalDataMapSource) { + let mode = ArgumentHelper.getExecutionMode(...args); + if(mode === "passthrough") { + return ArgumentHelper.mapToLocation(args); + } + + if(mode === "partial") { + args = args.map((entry, index) => { + if(index > 0 && ArgumentHelper.hasLocation(entry)) { + return entry.getOriginalValue(); + } + return entry; + }) + } + } + + // @ts-ignore + return callback.call(this, ...args); + }; + } +} + +function stringifyLocation(target) { + return `[[via::${target.filePath}::${target.selectorLocation}]]`; +} +export function stringifyReadonlyLocation(label) { + return `[[via::11ty_readonly${label ? `::${label}` : ""}]]`; +} + +class StringLocation extends String { + constructor(val, filePath, selectorLocation) { + super(val); + this.original = val; + this.val = ""+val; + this.filePath = filePath; + this.selectorLocation = selectorLocation; + } + + getLocation() { + return stringifyLocation(this); + } + + getOriginalValue() { + return this.original; + } + + toString() { + return this.getLocation(); + } + + [Symbol.toPrimitive](hint) { + return this.val; + } +} + +class NumberLocation extends Number { + constructor(val, filePath, selectorLocation) { + super(val); + this.original = val; + this.val = Number(val); + this.filePath = filePath; + this.selectorLocation = selectorLocation; + } + + getLocation() { + return stringifyLocation(this); + } + + getOriginalValue() { + return this.original; + } + + toString() { + return this.getLocation(); + } + + [Symbol.toPrimitive](hint) { + return this.val; + } +} + +export function LocationFactory(val, ...args) { + if(typeof val === "number") { + return new NumberLocation(val, ...args); + } else if(typeof val === "string") { + return new StringLocation(val, ...args); + } + + throw new Error("Incorrect type passed to LocationFactory, needs string or number."); +} diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index 85d03f349..6177d94fb 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -6,7 +6,7 @@ import debugUtil from "debug"; import { inspect } from "../Adapters/Packages/inspect.js"; import unique from "../Util/Objects/Unique.js"; import TemplateGlob from "../TemplateGlob.js"; -import { DataCascade } from "./DataCascade.js"; +import { DataCascade, DataCascadeManager } from "./DataCascade.js"; import EleventyBaseError from "../Errors/EleventyBaseError.js"; import ConfigurationGlobalData from "./ConfigurationGlobalData.js"; import { @@ -31,8 +31,9 @@ class TemplateData { #rawImports; #globalData; #templateDirectoryData = {}; + #templateDataCascadeManager = new DataCascadeManager(); #globalDataCascade = new DataCascade(); - #templateDirectoryDataCascade = {}; + #collectionsDataCascade = new DataCascade(); constructor(templateConfig) { if (!templateConfig || templateConfig.constructor.name !== "TemplateConfig") { @@ -156,7 +157,7 @@ class TemplateData { this.#globalData = null; this.configApiGlobalData = null; this.#templateDirectoryData = {}; - this.#templateDirectoryDataCascade = {}; + this.#templateDataCascadeManager.reset(); } _getGlobalDataGlobByExtension(extension) { @@ -389,13 +390,8 @@ class TemplateData { // Data from the configuration API eleventyConfig.addGLobalData and `eleventy` global let configApiGlobalData = await this.getInitialGlobalData(); - + // Some day we may treat the `eleventy` global assigned here as different to Config API data (readonly vs internal) this.#globalDataCascade.mergeTopLevel(configApiGlobalData); - this.#globalDataCascade.mergeToLocation( - configApiGlobalData.eleventy, - "eleventy", - DataCascade.INTERNAL_KEY, - ); let globalJson = await this.getAllGlobalData(); let mergedGlobalData = Merge(globalJson, configApiGlobalData); @@ -466,30 +462,37 @@ class TemplateData { return localData; } + getCollectionsDataCascade() { + return this.#collectionsDataCascade; + } + getGlobalDataCascade() { return this.#globalDataCascade; } async getTemplateDirectoryData(templatePath) { if (!this.#templateDirectoryData[templatePath]) { - this.#templateDirectoryDataCascade[templatePath] = new DataCascade(); + let cascade; + if(!this.#templateDataCascadeManager.has(templatePath)) { + cascade = this.#templateDataCascadeManager.create(templatePath); + } else { + cascade = this.#templateDataCascadeManager.get(templatePath); + } + let localDataPaths = await this.getLocalDataPaths(templatePath); let importedData = await this.combineLocalData( localDataPaths, - this.#templateDirectoryDataCascade[templatePath], + cascade, ); this.#templateDirectoryData[templatePath] = importedData; } + return this.#templateDirectoryData[templatePath]; } getTemplateDirectoryDataCascade(templatePath) { - if (!this.#templateDirectoryDataCascade[templatePath]) { - throw new Error("Missing template data cascade for " + templatePath); - } - - return this.#templateDirectoryDataCascade[templatePath]; + return this.#templateDataCascadeManager.get(templatePath); } getUserDataExtensions() { diff --git a/src/Engines/JavaScript.js b/src/Engines/JavaScript.js index 29b3b7c54..f9dc10c80 100644 --- a/src/Engines/JavaScript.js +++ b/src/Engines/JavaScript.js @@ -158,6 +158,7 @@ export default class JavaScript extends TemplateEngine { // Backwards compat static wrapJavaScriptFunction(inst, fn) { + // TODO ArgumentHelper.wrapFilter(fn); return augmentFunction(fn, { source: inst, }); diff --git a/src/Engines/Liquid.js b/src/Engines/Liquid.js index d13ee62d5..5dfb8813f 100644 --- a/src/Engines/Liquid.js +++ b/src/Engines/Liquid.js @@ -64,6 +64,8 @@ export default class Liquid extends TemplateEngine { * @this {object} */ return function (...args) { + // TODO ArgumentHelper.wrapFilter(fn); + // Set this.eleventy and this.page if (typeof this.context?.get === "function") { augmentObject(this, { diff --git a/src/Engines/Nunjucks.js b/src/Engines/Nunjucks.js index 5d9c9268f..7e1a20acd 100755 --- a/src/Engines/Nunjucks.js +++ b/src/Engines/Nunjucks.js @@ -7,6 +7,7 @@ import TemplateEngine from "./TemplateEngine.js"; import EleventyBaseError from "../Errors/EleventyBaseError.js"; import { augmentObject } from "./Util/ContextAugmenter.js"; import { withResolvers } from "../Util/PromiseUtil.js"; +import { ArgumentHelper } from "../Data/DataSourceLocation.js"; const debug = debugUtil("Eleventy:Nunjucks"); @@ -141,7 +142,8 @@ export default class Nunjucks extends TemplateEngine { lazy: false, // context.env?.opts.throwOnUndefined, }); - return fn.call(this, ...args); + let callback = ArgumentHelper.wrapFilter(fn); + return callback.call(this, ...args); } catch (e) { throw new EleventyNunjucksError( `Error in Nunjucks Filter \`${name}\`${this.page ? ` (${this.page.inputPath})` : ""}`, diff --git a/src/Engines/Util/ContextAugmenter.js b/src/Engines/Util/ContextAugmenter.js index dd5fbc640..d5706861c 100644 --- a/src/Engines/Util/ContextAugmenter.js +++ b/src/Engines/Util/ContextAugmenter.js @@ -1,6 +1,8 @@ const DATA_KEYS = ["page", "eleventy"]; -function augmentFunction(fn, options = {}) { +export { DATA_KEYS as augmentKeys }; + +export function augmentFunction(fn, options = {}) { let t = typeof fn; if (t !== "function") { throw new Error( @@ -11,11 +13,12 @@ function augmentFunction(fn, options = {}) { /** @this {object} */ return function (...args) { let context = augmentObject(this || {}, options); + return fn.call(context, ...args); }; } -function augmentObject(targetObject, options = {}) { +export function augmentObject(targetObject, options = {}) { options = Object.assign( { source: undefined, // where to copy from @@ -63,5 +66,3 @@ function augmentObject(targetObject, options = {}) { return targetObject; } - -export { DATA_KEYS as augmentKeys, augmentFunction, augmentObject }; diff --git a/src/Template.js b/src/Template.js index 7bbb6db7c..fb6091993 100755 --- a/src/Template.js +++ b/src/Template.js @@ -37,6 +37,7 @@ class Template extends TemplateContent { #dataCache; #cacheRenderedPromise; #cacheRenderedTransformsAndLayoutsPromise; + #cacheRenderedDataLocationsTransformsAndLayoutsPromise; constructor(templatePath, templateData, extensionMap, config) { debugDev("new Template(%o)", templatePath); @@ -141,6 +142,7 @@ class Template extends TemplateContent { if (types.render) { this.#cacheRenderedPromise = undefined; this.#cacheRenderedTransformsAndLayoutsPromise = undefined; + this.#cacheRenderedDataLocationsTransformsAndLayoutsPromise = undefined; } } @@ -415,6 +417,7 @@ class Template extends TemplateContent { } let pageData = await this.getPageData(mergedData); + Merge(mergedData, { page: pageData }); debugDev("%o getData mergedData", this.inputPath); @@ -446,6 +449,30 @@ class Template extends TemplateContent { return this.#dataCache; } + mergeDataCascadeLocations(data) { + // Set page.* as read only + this.dataCascade.mergeToLocation( data.page, "page"); // read only + + // TODO add support for page.date (points to `date`) + + // Only works with strings here, functions are read-only (above) + if(typeof data?.eleventyComputed?.permalink === "string") { + this.dataCascade.mergeToLocation( data.page.url, "page.url", data?.eleventyComputed?.permalink, "eleventyComputed.permalink"); + this.dataCascade.mergeToLocation( data.page.outputPath, "page.outputPath", data?.eleventyComputed?.permalink, "eleventyComputed.permalink"); + } else if(typeof data?.permalink === "string") { + this.dataCascade.mergeToLocation( data.page.url, "page.url", data?.permalink, "permalink"); + this.dataCascade.mergeToLocation( data.page.outputPath, "page.outputPath", data?.permalink, "permalink"); + } + + if(this.computedData?.computedKeys) { + let keys = Array.from(this.computedData?.computedKeys).filter(selector => !(["page.url", "page.outputPath"].includes(selector))); + for(let selector of keys) { + // TODO add support for string computed data + this.dataCascade.markLocationAsReadOnly(selector); + } + } + } + async getPageData(data) { let page = { // Make sure to keep these keys synchronized in src/Util/ReservedData.js @@ -806,6 +833,8 @@ class Template extends TemplateContent { if (!Pagination.hasPagination(data)) { await this.addComputedData(data); + this.mergeDataCascadeLocations(data); + let obj = { template: this, // not on the docs but folks are relying on it rawInput, @@ -835,6 +864,8 @@ class Template extends TemplateContent { for (let pageEntry of pageTemplates) { await pageEntry.template.addComputedData(pageEntry.data); + pageEntry.template.mergeDataCascadeLocations(pageEntry.data); + let obj = { template: pageEntry.template, // not on the docs but folks are relying on it rawInput, @@ -929,7 +960,7 @@ class Template extends TemplateContent { let layoutKey = pageEntry.data[this.config.keys.layout]; if (this.engine.useLayouts() && layoutKey) { let layout = pageEntry.template.getLayout(layoutKey); - content = await layout.renderPageEntry(pageEntry); + content = await layout.renderLayoutPageEntry(pageEntry); } else { content = pageEntry.templateContent; } @@ -940,6 +971,38 @@ class Template extends TemplateContent { return content; } + async #renderDataLocationsPageEntry(pageEntry) { + if(!(pageEntry?.outputPath || "").endsWith(".html")) { + return; + } + + // Don’t run linters/transforms/layouts if we didn’t render (via incremental)! + if (pageEntry.template.isDryRun && pageEntry.template.isIncremental) { + return pageEntry.template.getDataMapContent(); + } + + let content; + let layoutKey = pageEntry.data[this.config.keys.layout]; + if (this.engine.useLayouts() && layoutKey) { + let layout = pageEntry.template.getLayout(layoutKey); + content = await layout.renderLayoutPageEntry(pageEntry, this.dataCascade); + } else { + content = pageEntry.template.getDataMapContent(); + } + + content = await this.runTransforms(content, pageEntry); + return content; + } + + static async renderPageEntryDataLocations(pageEntry) { + // @cachedproperty + if(!pageEntry.template.#cacheRenderedDataLocationsTransformsAndLayoutsPromise) { + pageEntry.template.#cacheRenderedDataLocationsTransformsAndLayoutsPromise = + pageEntry.template.#renderDataLocationsPageEntry(pageEntry); + } + return pageEntry.template.#cacheRenderedDataLocationsTransformsAndLayoutsPromise; + } + // This could be `static` async renderPageEntry(pageEntry) { // @cachedproperty @@ -970,11 +1033,13 @@ class Template extends TemplateContent { for (let page of mapEntry._pages) { let content; + let contentMap; // Note that behavior.render is overridden when using json output if (page.template.isRenderable()) { // this reuses page.templateContent, it doesn’t render it content = await page.template.renderPageEntry(page); + contentMap = await Template.renderPageEntryDataLocations(page); } if (to === "json") { @@ -983,7 +1048,8 @@ class Template extends TemplateContent { inputPath: page.inputPath, outputPath: page.outputPath, rawInput: page.rawInput, - content: content, + content, + // contentMap, }; if (this.config.dataFilterSelectors?.size > 0) { @@ -1013,6 +1079,14 @@ class Template extends TemplateContent { if (content !== undefined) { ret.push(this._write(page, content)); } + + // write data map + if (contentMap !== undefined) { + // TODO customize this + let mapOutputPath = page.outputPath + ".map"; + this.fsManager.createDirectoryForFileSync(mapOutputPath); + this.fsManager.writeFileSync(mapOutputPath, contentMap); + } } return Promise.all(ret); @@ -1174,7 +1248,6 @@ class Template extends TemplateContent { // Important reminder: Template data is first generated in TemplateMap async getTemplateMapEntries(data) { debugDev("%o getMapped()", this.inputPath); - this.behavior.setRenderViaDataCascade(data); let entries = []; diff --git a/src/TemplateContent.js b/src/TemplateContent.js index 8a8f2ca66..8920b283f 100644 --- a/src/TemplateContent.js +++ b/src/TemplateContent.js @@ -30,6 +30,7 @@ class TemplateContent { #extensionMap; #configOptions; #frontMatterOptions; + #dataMapContent; constructor(inputPath, templateConfig) { if (!templateConfig || templateConfig.constructor.name !== "TemplateConfig") { @@ -677,6 +678,10 @@ class TemplateContent { return suffix.join(""); } + getDataMapContent() { + return this.#dataMapContent; + } + async _render(str, data, options = {}) { let { bypassMarkdown, type } = options; @@ -708,6 +713,18 @@ class TemplateContent { inputPathBenchmark.before(); } + // Only HTML output files + if(this.dataCascade && type === "Content" && (data.page?.outputPath || "").endsWith(".html")) { + // Merge local data cascade with global + this.dataCascade.mergeWithUpstreamDataCascade(this.templateData.getGlobalDataCascade()); + this.dataCascade.assignFromUpstreamDataCascade(this.templateData.getCollectionsDataCascade()); + + let dataSourceLocations = this.dataCascade.getLocations(); + let dataMapContent = await fn(dataSourceLocations); + // cache data map html content + this.#dataMapContent = dataMapContent; + } + let rendered = await fn(data); if (inputPathBenchmark) { @@ -715,6 +732,7 @@ class TemplateContent { } templateBenchmark.after(); debugDev("%o getCompiledTemplate called, rendered content created", this.inputPath); + return rendered; } catch (e) { if (EleventyErrorUtil.isPrematureTemplateContentError(e)) { diff --git a/src/TemplateLayout.js b/src/TemplateLayout.js index f8526f23e..c90a525b3 100644 --- a/src/TemplateLayout.js +++ b/src/TemplateLayout.js @@ -212,20 +212,27 @@ class TemplateLayout extends TemplateContent { // Inefficient? We want to compile all the templatelayouts into a single reusable callback? // Trouble: layouts may need data variables present downstream/upstream // This is called from Template->renderPageEntry - async renderPageEntry(pageEntry) { - let templateContent = pageEntry.templateContent; + async renderLayoutPageEntry(pageEntry, dataCascade) { + let content = dataCascade ? pageEntry.template.getDataMapContent() : pageEntry.templateContent; let compiledFunctions = await this.getCompiledLayoutFunctions(); for (let { render } of compiledFunctions) { - let data = { - content: templateContent, - ...pageEntry.data, - }; - - templateContent = await render(data); + if(dataCascade) { + let dataSources = { + ...dataCascade.getLocations(), + content, + } + content = await render(dataSources); + } else { + let data = { + content, + ...pageEntry.data, + }; + content = await render(data); + } } // Don’t set `templateContent` on pageEntry because collection items should not have layout markup - return templateContent; + return content; } resetCaches(types) { diff --git a/src/TemplateMap.js b/src/TemplateMap.js index 52cceb187..d976e88d6 100644 --- a/src/TemplateMap.js +++ b/src/TemplateMap.js @@ -29,6 +29,7 @@ const SPECIAL_COLLECTION_NAMES = { class TemplateMap { #dependencyMapInitialized = false; + #templateData; constructor(eleventyConfig) { if (!eleventyConfig || eleventyConfig.constructor.name !== "TemplateConfig") { @@ -62,6 +63,14 @@ class TemplateMap { return this._config; } + setTemplateData(templateData) { + if(templateData.constructor.name !== "TemplateData") { + throw new Error("Internal error: invalid TemplateData instance"); + } + + this.#templateData = templateData; + } + async add(template) { if (!template) { return; @@ -253,6 +262,35 @@ class TemplateMap { .filter(Boolean); } + mergeDataCascadeLocations() { + let collectionsDataCascade = this.#templateData.getCollectionsDataCascade(); + + for(let [name, collection] of Object.entries(this.collectionsData)) { + let index = 0; + for(let entry of collection) { + let dataWithoutCollections = { + ...entry.data, + }; + delete dataWithoutCollections.collections; + + let readOnlyEntry = { + page: entry.page, + rawInput: entry.rawInput, + inputPath: entry.inputPath, + date: entry.date, + outputPath: entry.outputPath, + url: entry.url, + templateContent: "", + content: "", + }; + + collectionsDataCascade.mergeToLocation(readOnlyEntry, `collections[${name}][${index}]`); + collectionsDataCascade.mergeToLocation(dataWithoutCollections, `collections[${name}][${index}].data`, entry.inputPath); + index++; + } + } + } + async cache() { if (!this.#dependencyMapInitialized) { this.addAllToGlobalDependencyGraph(); @@ -273,6 +311,7 @@ class TemplateMap { await this.initDependencyMap(fullTemplateOrder); await this.resolveRemainingComputedData(); + this.mergeDataCascadeLocations(); let orderedPaths = this.#removeTagsFromTemplateOrder(fullTemplateOrder); diff --git a/src/TemplateWriter.js b/src/TemplateWriter.js index 0374f9df9..f2abfe0ce 100755 --- a/src/TemplateWriter.js +++ b/src/TemplateWriter.js @@ -393,6 +393,7 @@ class TemplateWriter { async _createTemplateMap(paths, to) { this.templateMap = new TemplateMap(this.templateConfig); + this.templateMap.setTemplateData(this.templateData); await this._addToTemplateMap(paths, to); await this.templateMap.cache(); From 5243eaf31bee854b34bf2b65daf9112f1fb27491 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 29 Sep 2025 12:44:01 -0500 Subject: [PATCH 03/53] Opt-in feature via experimental flags --- src/Data/DataCascade.js | 52 ++++++++++++++++++++++++++--------- src/Data/TemplateData.js | 42 +++++++++++++++++----------- src/Template.js | 49 +++++++++++++++++++++++++-------- src/TemplateContent.js | 22 +++++++++++---- src/TemplateMap.js | 19 +++++++------ src/TemplateWriter.js | 4 ++- src/UserConfig.js | 38 +++++++++++++++---------- test/_getRenderedTemplates.js | 4 +-- 8 files changed, 158 insertions(+), 72 deletions(-) diff --git a/src/Data/DataCascade.js b/src/Data/DataCascade.js index 58396d49b..d6d91a1e7 100644 --- a/src/Data/DataCascade.js +++ b/src/Data/DataCascade.js @@ -6,21 +6,46 @@ import { LocationFactory, stringifyReadonlyLocation } from "./DataSourceLocation const { set: lodashSet, get: lodashGet } = lodash; export class DataCascadeManager { + static FLAGS = { + DATA_LOCATION: "INTERNAL_DATA_LOCATION_MAPPING", + }; + + #factoryEnabled = false; + constructor() { this.dataCascades = new Map(); } + setEnabled(isEnabled) { + this.#factoryEnabled = Boolean(isEnabled); + } + has(templatePath) { return this.dataCascades.has(templatePath); } + factory() { + if (!this.#factoryEnabled) { + return; + } + return new DataCascade(); + } + create(templatePath) { - let cascade = new DataCascade(); + let cascade = this.factory(); + if (!cascade) { + return; + } + this.dataCascades.set(templatePath, cascade); return cascade; } get(templatePath) { + if (!this.#factoryEnabled) { + return; + } + if (!this.has(templatePath)) { throw new Error("Internal error: missing data cascade for " + templatePath); } @@ -41,27 +66,27 @@ export class DataCascade { this.dataSourceLocations = {}; Object.defineProperty(this.dataSourceLocations, DataCascade.TOGGLE_PROP_NAME, { - value: true + value: true, }); } // TODO start here, circular references are maximum call stacking static deepThaw(target) { - if(Array.isArray(target)) { - return target.map(entry => this.deepThaw(entry)); + if (Array.isArray(target)) { + return target.map((entry) => this.deepThaw(entry)); } - if(isPlainObject(target)) { - if(Object.isFrozen(target)) { + if (isPlainObject(target)) { + if (Object.isFrozen(target)) { let thawed = {}; - for(let key in target) { + for (let key in target) { thawed[key] = this.deepThaw(target[key]); } return thawed; } // reuse existing - for(let key in target) { + for (let key in target) { target[key] = this.deepThaw(target[key]); } } @@ -92,7 +117,7 @@ export class DataCascade { let source = DataCascade.getMappingObject( data, sourceFilePath || DataCascade.READ_ONLY_KEY, - dataSourceSelector + dataSourceSelector, ); let merged = DeepCopy(target, source); @@ -123,16 +148,17 @@ export class DataCascade { static getMappingObject(target, sourceFilePath, dataLocationSelector = "") { if (typeof target === "function") { return target; - } else if(sourceFilePath.startsWith("11ty:")) { // readonly/internal mappings + } else if (sourceFilePath.startsWith("11ty:")) { + // readonly/internal mappings // internal data may be frozen (think `eleventy` global) return DataCascade.deepThaw(target); } - if(sourceFilePath.startsWith("./")) { + if (sourceFilePath.startsWith("./")) { sourceFilePath = sourceFilePath.slice(2); } - if(typeof target === "string" || typeof target === "number") { + if (typeof target === "string" || typeof target === "number") { return LocationFactory(target, sourceFilePath, dataLocationSelector); } @@ -143,7 +169,7 @@ export class DataCascade { } if (isPlainObject(target)) { - if(Object.isFrozen(target)) { + if (Object.isFrozen(target)) { return DataCascade.deepThaw(target); } diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index 6177d94fb..da3be623d 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -6,7 +6,7 @@ import debugUtil from "debug"; import { inspect } from "../Adapters/Packages/inspect.js"; import unique from "../Util/Objects/Unique.js"; import TemplateGlob from "../TemplateGlob.js"; -import { DataCascade, DataCascadeManager } from "./DataCascade.js"; +import { DataCascadeManager } from "./DataCascade.js"; import EleventyBaseError from "../Errors/EleventyBaseError.js"; import ConfigurationGlobalData from "./ConfigurationGlobalData.js"; import { @@ -31,9 +31,9 @@ class TemplateData { #rawImports; #globalData; #templateDirectoryData = {}; - #templateDataCascadeManager = new DataCascadeManager(); - #globalDataCascade = new DataCascade(); - #collectionsDataCascade = new DataCascade(); + #dataCascadeManager = new DataCascadeManager(); + #globalDataCascade; + #collectionsDataCascade; constructor(templateConfig) { if (!templateConfig || templateConfig.constructor.name !== "TemplateConfig") { @@ -45,6 +45,12 @@ class TemplateData { this.templateConfig = templateConfig; this.config = this.templateConfig.getConfig(); + if (this.config.experimentalFlags.includes(DataCascadeManager.FLAGS.DATA_LOCATION)) { + this.#dataCascadeManager.setEnabled(true); + this.#globalDataCascade = this.#dataCascadeManager.factory(); + this.#collectionsDataCascade = this.#dataCascadeManager.factory(); + } + this.benchmarks = { data: this.config.benchmarkManager.get("Data"), aggregate: this.config.benchmarkManager.get("Aggregate"), @@ -143,7 +149,10 @@ class TemplateData { if (projectPackageJsonPath) { let relativeProjectPackageJsonPath = ProjectDirectories.relativeToProjectRoot(projectPackageJsonPath); - this.#globalDataCascade.mergeTopLevel(this.#rawImports, relativeProjectPackageJsonPath); + + if (this.#globalDataCascade) { + this.#globalDataCascade.mergeTopLevel(this.#rawImports, relativeProjectPackageJsonPath); + } } if (this.config.freezeReservedData) { @@ -157,7 +166,7 @@ class TemplateData { this.#globalData = null; this.configApiGlobalData = null; this.#templateDirectoryData = {}; - this.#templateDataCascadeManager.reset(); + this.#dataCascadeManager.reset(); } _getGlobalDataGlobByExtension(extension) { @@ -337,7 +346,9 @@ class TemplateData { dataFileConflicts[objectPathTargetString] = file; debug(`Found global data file ${file} and adding as: ${objectPathTarget}`); - this.#globalDataCascade.mergeToLocation(data, objectPathTargetString, file); + if (this.#globalDataCascade) { + this.#globalDataCascade.mergeToLocation(data, objectPathTargetString, file); + } lodashSet(globalData, objectPathTarget, data); } @@ -391,7 +402,9 @@ class TemplateData { // Data from the configuration API eleventyConfig.addGLobalData and `eleventy` global let configApiGlobalData = await this.getInitialGlobalData(); // Some day we may treat the `eleventy` global assigned here as different to Config API data (readonly vs internal) - this.#globalDataCascade.mergeTopLevel(configApiGlobalData); + if (this.#globalDataCascade) { + this.#globalDataCascade.mergeTopLevel(configApiGlobalData); + } let globalJson = await this.getAllGlobalData(); let mergedGlobalData = Merge(globalJson, configApiGlobalData); @@ -473,17 +486,14 @@ class TemplateData { async getTemplateDirectoryData(templatePath) { if (!this.#templateDirectoryData[templatePath]) { let cascade; - if(!this.#templateDataCascadeManager.has(templatePath)) { - cascade = this.#templateDataCascadeManager.create(templatePath); + if (!this.#dataCascadeManager.has(templatePath)) { + cascade = this.#dataCascadeManager.create(templatePath); } else { - cascade = this.#templateDataCascadeManager.get(templatePath); + cascade = this.#dataCascadeManager.get(templatePath); } let localDataPaths = await this.getLocalDataPaths(templatePath); - let importedData = await this.combineLocalData( - localDataPaths, - cascade, - ); + let importedData = await this.combineLocalData(localDataPaths, cascade); this.#templateDirectoryData[templatePath] = importedData; } @@ -492,7 +502,7 @@ class TemplateData { } getTemplateDirectoryDataCascade(templatePath) { - return this.#templateDataCascadeManager.get(templatePath); + return this.#dataCascadeManager.get(templatePath); } getUserDataExtensions() { diff --git a/src/Template.js b/src/Template.js index fb6091993..7f0cf0884 100755 --- a/src/Template.js +++ b/src/Template.js @@ -450,23 +450,44 @@ class Template extends TemplateContent { } mergeDataCascadeLocations(data) { + if (!this.dataCascade) { + return; + } + // Set page.* as read only - this.dataCascade.mergeToLocation( data.page, "page"); // read only + this.dataCascade.mergeToLocation(data.page, "page"); // read only // TODO add support for page.date (points to `date`) // Only works with strings here, functions are read-only (above) - if(typeof data?.eleventyComputed?.permalink === "string") { - this.dataCascade.mergeToLocation( data.page.url, "page.url", data?.eleventyComputed?.permalink, "eleventyComputed.permalink"); - this.dataCascade.mergeToLocation( data.page.outputPath, "page.outputPath", data?.eleventyComputed?.permalink, "eleventyComputed.permalink"); - } else if(typeof data?.permalink === "string") { - this.dataCascade.mergeToLocation( data.page.url, "page.url", data?.permalink, "permalink"); - this.dataCascade.mergeToLocation( data.page.outputPath, "page.outputPath", data?.permalink, "permalink"); + if (typeof data?.eleventyComputed?.permalink === "string") { + this.dataCascade.mergeToLocation( + data.page.url, + "page.url", + data?.eleventyComputed?.permalink, + "eleventyComputed.permalink", + ); + this.dataCascade.mergeToLocation( + data.page.outputPath, + "page.outputPath", + data?.eleventyComputed?.permalink, + "eleventyComputed.permalink", + ); + } else if (typeof data?.permalink === "string") { + this.dataCascade.mergeToLocation(data.page.url, "page.url", data?.permalink, "permalink"); + this.dataCascade.mergeToLocation( + data.page.outputPath, + "page.outputPath", + data?.permalink, + "permalink", + ); } - if(this.computedData?.computedKeys) { - let keys = Array.from(this.computedData?.computedKeys).filter(selector => !(["page.url", "page.outputPath"].includes(selector))); - for(let selector of keys) { + if (this.computedData?.computedKeys) { + let keys = Array.from(this.computedData?.computedKeys).filter( + (selector) => !["page.url", "page.outputPath"].includes(selector), + ); + for (let selector of keys) { // TODO add support for string computed data this.dataCascade.markLocationAsReadOnly(selector); } @@ -972,7 +993,7 @@ class Template extends TemplateContent { } async #renderDataLocationsPageEntry(pageEntry) { - if(!(pageEntry?.outputPath || "").endsWith(".html")) { + if (!(pageEntry?.outputPath || "").endsWith(".html")) { return; } @@ -995,8 +1016,12 @@ class Template extends TemplateContent { } static async renderPageEntryDataLocations(pageEntry) { + if (!pageEntry.template.dataCascade) { + return; + } + // @cachedproperty - if(!pageEntry.template.#cacheRenderedDataLocationsTransformsAndLayoutsPromise) { + if (!pageEntry.template.#cacheRenderedDataLocationsTransformsAndLayoutsPromise) { pageEntry.template.#cacheRenderedDataLocationsTransformsAndLayoutsPromise = pageEntry.template.#renderDataLocationsPageEntry(pageEntry); } diff --git a/src/TemplateContent.js b/src/TemplateContent.js index 8920b283f..e3fdb343d 100644 --- a/src/TemplateContent.js +++ b/src/TemplateContent.js @@ -396,9 +396,10 @@ class TemplateContent { } get dataCascade() { - if (this.templateData) { - return this.templateData.getTemplateDirectoryDataCascade(this.inputPath); + if (!this.templateData) { + return; } + return this.templateData.getTemplateDirectoryDataCascade(this.inputPath); } async #getFrontMatterData() { @@ -714,10 +715,21 @@ class TemplateContent { } // Only HTML output files - if(this.dataCascade && type === "Content" && (data.page?.outputPath || "").endsWith(".html")) { + if ( + this.dataCascade && + type === "Content" && + (data.page?.outputPath || "").endsWith(".html") + ) { // Merge local data cascade with global - this.dataCascade.mergeWithUpstreamDataCascade(this.templateData.getGlobalDataCascade()); - this.dataCascade.assignFromUpstreamDataCascade(this.templateData.getCollectionsDataCascade()); + let globalDataCascade = this.templateData.getGlobalDataCascade(); + if (globalDataCascade) { + this.dataCascade.mergeWithUpstreamDataCascade(globalDataCascade); + } + + let collectionsDataCascade = this.templateData.getCollectionsDataCascade(); + if (collectionsDataCascade) { + this.dataCascade.assignFromUpstreamDataCascade(collectionsDataCascade); + } let dataSourceLocations = this.dataCascade.getLocations(); let dataMapContent = await fn(dataSourceLocations); diff --git a/src/TemplateMap.js b/src/TemplateMap.js index d976e88d6..2e676738e 100644 --- a/src/TemplateMap.js +++ b/src/TemplateMap.js @@ -64,10 +64,6 @@ class TemplateMap { } setTemplateData(templateData) { - if(templateData.constructor.name !== "TemplateData") { - throw new Error("Internal error: invalid TemplateData instance"); - } - this.#templateData = templateData; } @@ -263,11 +259,14 @@ class TemplateMap { } mergeDataCascadeLocations() { - let collectionsDataCascade = this.#templateData.getCollectionsDataCascade(); + let collectionsDataCascade = this.#templateData?.getCollectionsDataCascade(); + if (!collectionsDataCascade) { + return; + } - for(let [name, collection] of Object.entries(this.collectionsData)) { + for (let [name, collection] of Object.entries(this.collectionsData)) { let index = 0; - for(let entry of collection) { + for (let entry of collection) { let dataWithoutCollections = { ...entry.data, }; @@ -285,7 +284,11 @@ class TemplateMap { }; collectionsDataCascade.mergeToLocation(readOnlyEntry, `collections[${name}][${index}]`); - collectionsDataCascade.mergeToLocation(dataWithoutCollections, `collections[${name}][${index}].data`, entry.inputPath); + collectionsDataCascade.mergeToLocation( + dataWithoutCollections, + `collections[${name}][${index}].data`, + entry.inputPath, + ); index++; } } diff --git a/src/TemplateWriter.js b/src/TemplateWriter.js index f2abfe0ce..71f30afd4 100755 --- a/src/TemplateWriter.js +++ b/src/TemplateWriter.js @@ -393,7 +393,9 @@ class TemplateWriter { async _createTemplateMap(paths, to) { this.templateMap = new TemplateMap(this.templateConfig); - this.templateMap.setTemplateData(this.templateData); + if (this.templateData) { + this.templateMap.setTemplateData(this.templateData); + } await this._addToTemplateMap(paths, to); await this.templateMap.cache(); diff --git a/src/UserConfig.js b/src/UserConfig.js index 483298607..18a4c41b4 100644 --- a/src/UserConfig.js +++ b/src/UserConfig.js @@ -32,6 +32,7 @@ class UserConfig { /** @type {number} */ #concurrency = 1; // Before using os.availableParallelism(); see https://github.com/11ty/eleventy/issues/3596 + #experimentalFlags = []; constructor() { // These are completely unnecessary lines to satisfy TypeScript @@ -62,13 +63,6 @@ class UserConfig { this.#uniqueId = Math.random(); } - // this.DateTime removed in v4 - get DateTime() { - throw new Error( - 'Luxon’s DateTime property in configuration was removed in Eleventy v4. Please `import { DateTime } from "luxon"` directly.', - ); - } - // Internally used in TemplateContent for cache keys _getUniqueId() { return this.#uniqueId; @@ -797,9 +791,6 @@ class UserConfig { /* * Template Formats */ - _normalizeTemplateFormats() { - throw new Error("The internal _normalizeTemplateFormats() method was removed in Eleventy 3.0"); - } setTemplateFormats(templateFormats) { this.templateFormats = templateFormats; @@ -1172,11 +1163,6 @@ class UserConfig { Object.assign(this.errorReporting, options); } - configureTemplateHandling(options = {}) { - // Was used for sync/async swapping on file write operations - throw new Error("Internal configuration API method `configureTemplateHandling` was removed."); - } - /* * Collections */ @@ -1221,6 +1207,10 @@ class UserConfig { return this.#concurrency; } + addExperimentalBehavior(flag) { + this.#experimentalFlags.push(flag); + } + getMergingConfigObject() { let obj = { // filters removed in 1.0 (use addTransform instead) @@ -1294,6 +1284,7 @@ class UserConfig { freezeReservedData: this.freezeReservedData, customDateParsing: this.customDateParsingCallbacks, errorReporting: this.errorReporting, + experimentalFlags: this.#experimentalFlags, }; if (Array.isArray(this.dataFileSuffixesOverride)) { @@ -1310,6 +1301,23 @@ class UserConfig { return obj; } + // Throws an error (no backwards compat) + get DateTime() { + // this.DateTime removed in v4 + throw new Error( + 'Luxon’s DateTime property in configuration was removed in Eleventy v4. Please `import { DateTime } from "luxon"` directly.', + ); + } + + _normalizeTemplateFormats() { + throw new Error("The internal _normalizeTemplateFormats() method was removed in Eleventy 3.0"); + } + + configureTemplateHandling(options = {}) { + // Was used for sync/async swapping on file write operations + throw new Error("Internal configuration API method `configureTemplateHandling` was removed."); + } + // No-op functions for backwards compat addHandlebarsHelper() {} setPugOptions() {} diff --git a/test/_getRenderedTemplates.js b/test/_getRenderedTemplates.js index 4a70d3a6c..f0c35e476 100644 --- a/test/_getRenderedTemplates.js +++ b/test/_getRenderedTemplates.js @@ -18,14 +18,14 @@ async function renderLayout(tmpl, tmplData) { let layoutKey = tmplData[tmpl.config.keys.layout]; let layout = tmpl.getLayout(layoutKey); - return layout.renderPageEntry({ + return layout.renderLayoutPageEntry({ data: tmplData, templateContent: content, }); } async function renderLayoutViaLayout(layout, tmplData, templateContent) { - return layout.renderPageEntry({ + return layout.renderLayoutPageEntry({ data: tmplData, templateContent, }); From 1acc7f8b6b90786cd05b8567c45fc5dcee52a6a1 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 21 Oct 2025 09:58:26 -0500 Subject: [PATCH 04/53] Status --- src/Data/DataCascade.js | 19 ++++++++----- src/Data/DataSourceLocation.js | 51 ++++++++++++++++++---------------- src/Template.js | 16 ++++++++++- src/TemplateContent.js | 11 ++++---- src/TemplateLayout.js | 14 ++++++++-- src/Util/ProjectDirectories.js | 8 ++++++ 6 files changed, 79 insertions(+), 40 deletions(-) diff --git a/src/Data/DataCascade.js b/src/Data/DataCascade.js index d6d91a1e7..c3116cb15 100644 --- a/src/Data/DataCascade.js +++ b/src/Data/DataCascade.js @@ -70,7 +70,6 @@ export class DataCascade { }); } - // TODO start here, circular references are maximum call stacking static deepThaw(target) { if (Array.isArray(target)) { return target.map((entry) => this.deepThaw(entry)); @@ -95,13 +94,17 @@ export class DataCascade { // Global Data and Template Data Cascade combine mergeWithUpstreamDataCascade(...upstreamDataCascades) { - let locations = upstreamDataCascades.map((entry) => entry.getLocations()); - this.dataSourceLocations = DeepCopy({}, ...locations, this.dataSourceLocations); + let locations = upstreamDataCascades.filter(Boolean).map((entry) => entry.getLocations()); + if (locations.length > 0) { + this.dataSourceLocations = DeepCopy({}, ...locations, this.dataSourceLocations); + } } assignFromUpstreamDataCascade(...upstreamDataCascades) { - let locations = upstreamDataCascades.map((entry) => entry.getLocations()); - this.dataSourceLocations = Object.assign({}, ...locations, this.dataSourceLocations); + let locations = upstreamDataCascades.filter(Boolean).map((entry) => entry.getLocations()); + if (locations.length > 0) { + this.dataSourceLocations = Object.assign({}, ...locations, this.dataSourceLocations); + } } mergeTopLevel(data, sourceFilePath) { @@ -158,12 +161,14 @@ export class DataCascade { sourceFilePath = sourceFilePath.slice(2); } - if (typeof target === "string" || typeof target === "number") { - return LocationFactory(target, sourceFilePath, dataLocationSelector); + let primitiveLocation = LocationFactory(target, sourceFilePath, dataLocationSelector); + if (primitiveLocation !== undefined) { + return primitiveLocation; } if (Array.isArray(target)) { return target.map((entry, index) => + // Array property [] index this.getMappingObject(entry, sourceFilePath, `${dataLocationSelector}[${index}]`), ); } diff --git a/src/Data/DataSourceLocation.js b/src/Data/DataSourceLocation.js index c2925d87d..60ae1d5de 100644 --- a/src/Data/DataSourceLocation.js +++ b/src/Data/DataSourceLocation.js @@ -12,17 +12,17 @@ export class ArgumentHelper { } static getFriendlyType(obj) { - if(this.hasLocation(obj)) { + if (this.hasLocation(obj)) { let original = obj.getOriginalValue(); - if(this.hasLocation(original)) { - throw new Error("Internal error: data source location mapped to self (circular reference)") + if (this.hasLocation(original)) { + throw new Error("Internal error: data source location mapped to self (circular reference)"); } return this.getFriendlyType(original); } - if(Array.isArray(obj)) { + if (Array.isArray(obj)) { return "array"; } - if(isPlainObject(obj)) { + if (isPlainObject(obj)) { return "object"; } return typeof obj; @@ -30,9 +30,9 @@ export class ArgumentHelper { static hasArgumentParity(args = []) { let types = {}; - for(let a of args) { + for (let a of args) { let type = this.getFriendlyType(a); - if(!types[type]) { + if (!types[type]) { types[type] = 0; } types[type]++; @@ -44,13 +44,13 @@ export class ArgumentHelper { // TODO add configuration option to hard-code the execution mode for a filter static getExecutionMode(...args) { // skips if args.length is 1 - if(!this.hasArgumentParity(args)) { + if (!this.hasArgumentParity(args)) { return "partial"; } // some args are not primitives and aren’t location-aware - let complexArgs = args.filter(a => this.isComplexArgument(a)); - if(complexArgs.length > 0) { + let complexArgs = args.filter((a) => this.isComplexArgument(a)); + if (complexArgs.length > 0) { return "execute"; } @@ -59,24 +59,24 @@ export class ArgumentHelper { } static mapToLocation(args) { - return args.filter(a => this.hasLocation(a)).map(a => a.getLocation()); + return args.filter((a) => this.hasLocation(a)).map((a) => a.getLocation()); } static wrapFilter(callback) { - return function(...args) { - if(this.__useInternalDataMapSource) { + return function (...args) { + if (this.__useInternalDataMapSource) { let mode = ArgumentHelper.getExecutionMode(...args); - if(mode === "passthrough") { + if (mode === "passthrough") { return ArgumentHelper.mapToLocation(args); } - if(mode === "partial") { + if (mode === "partial") { args = args.map((entry, index) => { - if(index > 0 && ArgumentHelper.hasLocation(entry)) { + if (index > 0 && ArgumentHelper.hasLocation(entry)) { return entry.getOriginalValue(); } return entry; - }) + }); } } @@ -87,17 +87,17 @@ export class ArgumentHelper { } function stringifyLocation(target) { - return `[[via::${target.filePath}::${target.selectorLocation}]]`; + return `{via::${target.filePath}::${target.selectorLocation}::${("" + target).length}}`; } export function stringifyReadonlyLocation(label) { - return `[[via::11ty_readonly${label ? `::${label}` : ""}]]`; + return `{via::11ty_readonly${label ? `::${label}` : ""}}`; } class StringLocation extends String { constructor(val, filePath, selectorLocation) { super(val); this.original = val; - this.val = ""+val; + this.val = "" + val; this.filePath = filePath; this.selectorLocation = selectorLocation; } @@ -146,11 +146,14 @@ class NumberLocation extends Number { } export function LocationFactory(val, ...args) { - if(typeof val === "number") { + if (typeof val === "number") { return new NumberLocation(val, ...args); - } else if(typeof val === "string") { + } + if (typeof val === "string") { return new StringLocation(val, ...args); } - - throw new Error("Incorrect type passed to LocationFactory, needs string or number."); + // Not supported yet (there is no userland way to intercept boolean coercion, e.g. `new BooleanLocation()` would always return true) + // if(typeof val === "boolean") { + // return val; + // } } diff --git a/src/Template.js b/src/Template.js index 7f0cf0884..1c93fa4eb 100755 --- a/src/Template.js +++ b/src/Template.js @@ -38,6 +38,7 @@ class Template extends TemplateContent { #cacheRenderedPromise; #cacheRenderedTransformsAndLayoutsPromise; #cacheRenderedDataLocationsTransformsAndLayoutsPromise; + #layoutDataCascade; constructor(templatePath, templateData, extensionMap, config) { debugDev("new Template(%o)", templatePath); @@ -372,6 +373,10 @@ class Template extends TemplateContent { return {}; } + getLayoutDataCascade() { + return this.#layoutDataCascade; + } + async #getData() { debugDev("%o getData", this.inputPath); let localData = {}; @@ -398,6 +403,9 @@ class Template extends TemplateContent { let layout = this.getLayout(layoutKey); mergedLayoutData = await layout.getData(); + + // TODO disable/toggle enabled + this.#layoutDataCascade = layout.getLayoutDataCascade(); debugDev("%o getData merged layout chain front matter", this.inputPath); } } @@ -702,6 +710,12 @@ class Template extends TemplateContent { let { href, path } = await this.getOutputLocations(data); data.page.url = href; data.page.outputPath = path; + if (this.dataCascade) { + data.page.mapUrl = + this.eleventyConfig.directories.getOutputPathRelativeToOutputDirectory( + data.page.outputPath, + ) + ".map"; + } } } @@ -1106,7 +1120,7 @@ class Template extends TemplateContent { } // write data map - if (contentMap !== undefined) { + if (contentMap !== undefined && page.outputPath) { // TODO customize this let mapOutputPath = page.outputPath + ".map"; this.fsManager.createDirectoryForFileSync(mapOutputPath); diff --git a/src/TemplateContent.js b/src/TemplateContent.js index e3fdb343d..62a79e59b 100644 --- a/src/TemplateContent.js +++ b/src/TemplateContent.js @@ -722,19 +722,18 @@ class TemplateContent { ) { // Merge local data cascade with global let globalDataCascade = this.templateData.getGlobalDataCascade(); - if (globalDataCascade) { - this.dataCascade.mergeWithUpstreamDataCascade(globalDataCascade); - } + let layoutDataCascade = this.getLayoutDataCascade(); + this.dataCascade.mergeWithUpstreamDataCascade(layoutDataCascade, globalDataCascade); let collectionsDataCascade = this.templateData.getCollectionsDataCascade(); - if (collectionsDataCascade) { - this.dataCascade.assignFromUpstreamDataCascade(collectionsDataCascade); - } + this.dataCascade.assignFromUpstreamDataCascade(collectionsDataCascade); let dataSourceLocations = this.dataCascade.getLocations(); let dataMapContent = await fn(dataSourceLocations); // cache data map html content this.#dataMapContent = dataMapContent; + } else { + this.#dataMapContent = undefined; } let rendered = await fn(data); diff --git a/src/TemplateLayout.js b/src/TemplateLayout.js index c90a525b3..2e9dd8cd6 100644 --- a/src/TemplateLayout.js +++ b/src/TemplateLayout.js @@ -5,11 +5,14 @@ import TemplateLayoutPathResolver from "./TemplateLayoutPathResolver.js"; import TemplateContent from "./TemplateContent.js"; import TemplateData from "./Data/TemplateData.js"; import layoutCache from "./LayoutCache.js"; +import { DataCascade } from "./Data/DataCascade.js"; // const debug = debugUtil("Eleventy:TemplateLayout"); const debugDev = debugUtil("Dev:Eleventy:TemplateLayout"); class TemplateLayout extends TemplateContent { + #layoutDataCascade = new DataCascade(); + constructor(key, extensionMap, eleventyConfig) { if (!eleventyConfig || eleventyConfig.constructor.name !== "TemplateConfig") { throw new Error("Expected `eleventyConfig` in TemplateLayout constructor."); @@ -30,6 +33,10 @@ class TemplateLayout extends TemplateContent { this.inputPath = resolvedPath; } + getLayoutDataCascade() { + return this.#layoutDataCascade; + } + getKey() { return this.key; } @@ -72,6 +79,8 @@ class TemplateLayout extends TemplateContent { // Used by `TemplateLayout.getTemplate()` key: this.dataKeyLayoutPath, + inputPath: this.inputPath, + // used by `this.getData()` frontMatterData, }; @@ -140,6 +149,7 @@ class TemplateLayout extends TemplateContent { let dataToMerge = []; for (let j = map.length - 1; j >= 0; j--) { dataToMerge.push(map[j].frontMatterData); + this.#layoutDataCascade.mergeTopLevel(map[j].frontMatterData, map[j].inputPath); } // Deep merge of layout front matter @@ -216,11 +226,11 @@ class TemplateLayout extends TemplateContent { let content = dataCascade ? pageEntry.template.getDataMapContent() : pageEntry.templateContent; let compiledFunctions = await this.getCompiledLayoutFunctions(); for (let { render } of compiledFunctions) { - if(dataCascade) { + if (dataCascade) { let dataSources = { ...dataCascade.getLocations(), content, - } + }; content = await render(dataSources); } else { let data = { diff --git a/src/Util/ProjectDirectories.js b/src/Util/ProjectDirectories.js index 78070d285..bc9f4172f 100644 --- a/src/Util/ProjectDirectories.js +++ b/src/Util/ProjectDirectories.js @@ -291,6 +291,14 @@ export default class ProjectDirectories { return TemplatePath.stripLeadingSubPath(filePathRelativeToInputDir, inputDir); } + // Removes output dir from path + getOutputPathRelativeToOutputDirectory(filePathRelativeToRootDir) { + let filePath = TemplatePath.addLeadingDotSlash(filePathRelativeToRootDir); + let outputDir = TemplatePath.addLeadingDotSlash(TemplatePath.join(this.output)); + + return "/" + TemplatePath.stripLeadingSubPath(filePath, outputDir); + } + // for a hypothetical Eleventy layout file getLayoutPath(filePathRelativeToLayoutDir) { return TemplatePath.addLeadingDotSlash( From 437df4f02532fca7fc5a7c2178740862a7872d63 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 12 Feb 2026 14:47:01 -0600 Subject: [PATCH 05/53] Removes page.inputPathDir and page.dir (temporarily) --- src/Plugins/Pagination.js | 1 - src/Template.js | 2 +- test/EleventyTest-PageData.js | 14 +++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Plugins/Pagination.js b/src/Plugins/Pagination.js index da2f51fb8..7b9bc86de 100755 --- a/src/Plugins/Pagination.js +++ b/src/Plugins/Pagination.js @@ -349,7 +349,6 @@ class Pagination { // page.url and page.outputPath are used to avoid another getOutputLocations call later, see Template->addComputedData clonedData.page.url = href; clonedData.page.outputPath = path; - clonedData.page.dir = dir; entries.push({ pageNumber, diff --git a/src/Template.js b/src/Template.js index 3be84d666..1472b2aaa 100755 --- a/src/Template.js +++ b/src/Template.js @@ -703,7 +703,7 @@ class Template extends TemplateContent { return; } - let { href, path, dir } = await this.getOutputLocations(data); + let { href, path } = await this.getOutputLocations(data); data.page.url = href; data.page.outputPath = path; diff --git a/test/EleventyTest-PageData.js b/test/EleventyTest-PageData.js index 8fe703a84..a10403382 100644 --- a/test/EleventyTest-PageData.js +++ b/test/EleventyTest-PageData.js @@ -1,7 +1,7 @@ import test from "ava"; import Eleventy from "../src/Eleventy.js"; -test("#3794: page.inputPathDir and page.dir", async (t) => { +test.skip("#3794: page.inputPathDir and page.dir", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { config: function(eleventyConfig) { eleventyConfig.addTemplate("test.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, {}); @@ -12,7 +12,7 @@ test("#3794: page.inputPathDir and page.dir", async (t) => { t.is(result.content, "./test/stubs-virtual/ and /test/"); }); -test("#3794: page.inputPathDir and page.dir (index file)", async (t) => { +test.skip("#3794: page.inputPathDir and page.dir (index file)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { config: function(eleventyConfig) { eleventyConfig.addTemplate("index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, {}); @@ -23,7 +23,7 @@ test("#3794: page.inputPathDir and page.dir (index file)", async (t) => { t.is(result.content, "./test/stubs-virtual/ and /"); }); -test("#3794: page.inputPathDir and page.dir (paginated)", async (t) => { +test.skip("#3794: page.inputPathDir and page.dir (paginated)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { config: function(eleventyConfig) { eleventyConfig.addTemplate("index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { @@ -45,7 +45,7 @@ test("#3794: page.inputPathDir and page.dir (paginated)", async (t) => { t.is(page3.content, "./test/stubs-virtual/ and /2/"); }); -test("#3794: page.inputPathDir and page.dir (with file slug and index)", async (t) => { +test.skip("#3794: page.inputPathDir and page.dir (with file slug and index)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { config: function(eleventyConfig) { eleventyConfig.addTemplate("yawn/index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { @@ -61,7 +61,7 @@ test("#3794: page.inputPathDir and page.dir (with file slug and index)", async ( t.is(page1.content, "./test/stubs-virtual/yawn/ and /yawn/"); }); -test("#3794: page.inputPathDir and page.dir (with file slug and not-index)", async (t) => { +test.skip("#3794: page.inputPathDir and page.dir (with file slug and not-index)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { config: function(eleventyConfig) { eleventyConfig.addTemplate("yawn/test.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { @@ -77,7 +77,7 @@ test("#3794: page.inputPathDir and page.dir (with file slug and not-index)", asy t.is(page1.content, "./test/stubs-virtual/yawn/ and /yawn/"); }); -test("#3794: page.inputPathDir and page.dir (paginated with file slug and not-index)", async (t) => { +test.skip("#3794: page.inputPathDir and page.dir (paginated with file slug and not-index)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { config: function(eleventyConfig) { eleventyConfig.addTemplate("yawn/test.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { @@ -100,7 +100,7 @@ test("#3794: page.inputPathDir and page.dir (paginated with file slug and not-in t.is(page3.content, "./test/stubs-virtual/yawn/ and /2/yawn/"); }); -test("#3794: page.inputPathDir and page.dir (permalink: false)", async (t) => { +test.skip("#3794: page.inputPathDir and page.dir (permalink: false)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { config: function(eleventyConfig) { eleventyConfig.addTemplate("index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { permalink: false }); From 023669e2e4be485e85b390e46dad56bf864b259d Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 12 Feb 2026 14:48:42 -0600 Subject: [PATCH 06/53] Working localedit demo --- package-lock.json | 297 +++++--------------------------------- package.json | 2 +- src/Data/TemplateData.js | 8 +- src/Eleventy.js | 4 + src/EleventyServe.js | 31 ++++ src/TemplateConfig.js | 36 +++++ src/TemplateContent.js | 7 +- src/Watch.js | 4 + test/EleventyServeTest.js | 18 +-- 9 files changed, 132 insertions(+), 275 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4575b25f5..cb746f151 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@11ty/dependency-tree": "^4.0.2", "@11ty/dependency-tree-esm": "^2.0.4", "@11ty/dependency-tree-typescript": "^1.0.0", - "@11ty/eleventy-dev-server": "^3.0.0-alpha.6", + "@11ty/eleventy-dev-server": "file:../eleventy-dev-server", "@11ty/eleventy-plugin-bundle": "^3.0.7", "@11ty/eleventy-utils": "^2.0.7", "@11ty/gray-matter": "^2.0.1", @@ -93,6 +93,38 @@ "url": "https://opencollective.com/11ty" } }, + "../eleventy-dev-server": { + "name": "@11ty/eleventy-dev-server", + "version": "3.0.0-alpha.6", + "license": "MIT", + "dependencies": { + "@11ty/eleventy-utils": "^2.0.7", + "@11ty/node-version-check": "^1.0.1", + "chokidar": "^5.0.0", + "debug": "^4.4.3", + "finalhandler": "^2.1.1", + "mime": "^4.1.0", + "minimist": "^1.2.8", + "morphdom": "^2.7.7", + "send": "^1.2.0", + "ssri": "^13.0.0", + "urlpattern-polyfill": "^10.1.0", + "ws": "^8.18.3" + }, + "bin": { + "eleventy-dev-server": "cmd.cjs" + }, + "devDependencies": { + "ava": "^6.4.1" + }, + "engines": { + "node": ">=20.19" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/11ty" + } + }, "node_modules/@11ty/client": { "resolved": "packages/client", "link": true @@ -133,34 +165,8 @@ } }, "node_modules/@11ty/eleventy-dev-server": { - "version": "3.0.0-alpha.6", - "resolved": "https://registry.npmjs.org/@11ty/eleventy-dev-server/-/eleventy-dev-server-3.0.0-alpha.6.tgz", - "integrity": "sha512-ZfQL/HG0UB2Vyr9k4VCQilCzbMNjc+/887w7eKN5xCf0/a3bWRxXAxreX71UFhIXafH6DFuRYKUQ4mbYhYjiSg==", - "license": "MIT", - "dependencies": { - "@11ty/eleventy-utils": "^2.0.7", - "@11ty/node-version-check": "^1.0.1", - "chokidar": "^5.0.0", - "debug": "^4.4.3", - "finalhandler": "^2.1.1", - "mime": "^4.1.0", - "minimist": "^1.2.8", - "morphdom": "^2.7.7", - "send": "^1.2.0", - "ssri": "^13.0.0", - "urlpattern-polyfill": "^10.1.0", - "ws": "^8.18.3" - }, - "bin": { - "eleventy-dev-server": "cmd.cjs" - }, - "engines": { - "node": ">=20.19" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/11ty" - } + "resolved": "../eleventy-dev-server", + "link": true }, "node_modules/@11ty/eleventy-fetch": { "version": "5.1.0", @@ -4762,15 +4768,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/dependency-graph": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/dependency-graph/-/dependency-graph-1.0.0.tgz", @@ -4909,12 +4906,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", - "license": "MIT" - }, "node_modules/emittery": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/emittery/-/emittery-1.2.0.tgz", @@ -4935,15 +4926,6 @@ "dev": true, "license": "MIT" }, - "node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/entities": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", @@ -5094,12 +5076,6 @@ "node": ">=6" } }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "license": "MIT" - }, "node_modules/escape-string-regexp": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", @@ -5450,15 +5426,6 @@ "node": ">=0.10.0" } }, - "node_modules/etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, "node_modules/evaluate-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/evaluate-value/-/evaluate-value-2.0.0.tgz", @@ -5649,27 +5616,6 @@ "node": ">=8" } }, - "node_modules/finalhandler": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", - "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "on-finished": "^2.4.1", - "parseurl": "^1.3.3", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -5754,15 +5700,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/fresh": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", - "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -6179,31 +6116,6 @@ "node": ">= 6" } }, - "node_modules/http-errors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", - "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", - "license": "MIT", - "dependencies": { - "depd": "2.0.0", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "toidentifier": "1.0.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/http-errors/node_modules/statuses": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/https-proxy-agent": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", @@ -6357,6 +6269,7 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, "license": "ISC" }, "node_modules/ini": { @@ -8025,42 +7938,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/mime": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-4.1.0.tgz", - "integrity": "sha512-X5ju04+cAzsojXKes0B/S4tcYtFAJ6tTMuSPBEn9CPGlrWr8Fiw7qYeLT0XyH80HSoAoqWCaz+MWKh22P7G1cw==", - "funding": [ - "https://github.com/sponsors/broofa" - ], - "license": "MIT", - "bin": { - "mime": "bin/cli.js" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/mime-db": { - "version": "1.54.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", - "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", - "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", - "license": "MIT", - "dependencies": { - "mime-db": "^1.54.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/mimic-function": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", @@ -8100,6 +7977,7 @@ "version": "7.1.2", "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, "license": "ISC", "engines": { "node": ">=16 || 14 >=14.17" @@ -8140,12 +8018,6 @@ "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==", "license": "BSD-3-Clause" }, - "node_modules/morphdom": { - "version": "2.7.7", - "resolved": "https://registry.npmjs.org/morphdom/-/morphdom-2.7.7.tgz", - "integrity": "sha512-04GmsiBcalrSCNmzfo+UjU8tt3PhZJKzcOy+r1FlGA7/zri8wre3I1WkYN9PT3sIeIKfW9bpyElA+VzOg2E24g==", - "license": "MIT" - }, "node_modules/mrmime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", @@ -8339,18 +8211,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", - "license": "MIT", - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -8573,15 +8433,6 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/path": { "version": "0.12.7", "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", @@ -9114,15 +8965,6 @@ ], "license": "MIT" }, - "node_modules/range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, "node_modules/react": { "version": "19.2.4", "resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz", @@ -9598,28 +9440,6 @@ "node": ">=10" } }, - "node_modules/send": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", - "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", - "license": "MIT", - "dependencies": { - "debug": "^4.3.5", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "mime-types": "^3.0.1", - "ms": "^2.1.3", - "on-finished": "^2.4.1", - "range-parser": "^1.2.1", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 18" - } - }, "node_modules/serialize-error": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz", @@ -9654,12 +9474,6 @@ "node": ">= 0.4" } }, - "node_modules/setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "license": "ISC" - }, "node_modules/sharp": { "version": "0.33.5", "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.5.tgz", @@ -9834,18 +9648,6 @@ "dev": true, "license": "BSD-3-Clause" }, - "node_modules/ssri": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/ssri/-/ssri-13.0.0.tgz", - "integrity": "sha512-yizwGBpbCn4YomB2lzhZqrHLJoqFGXihNbib3ozhqF/cIp5ue+xSmOQrjNasEE62hFxsCcg/V/z23t4n8jMEng==", - "license": "ISC", - "dependencies": { - "minipass": "^7.0.3" - }, - "engines": { - "node": "^20.17.0 || >=22.9.0" - } - }, "node_modules/stack-utils": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", @@ -9876,15 +9678,6 @@ "dev": true, "license": "MIT" }, - "node_modules/statuses": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", - "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/std-env": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", @@ -10279,15 +10072,6 @@ "node": ">=8.0" } }, - "node_modules/toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "license": "MIT", - "engines": { - "node": ">=0.6" - } - }, "node_modules/totalist": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", @@ -11041,12 +10825,6 @@ "punycode": "^2.1.0" } }, - "node_modules/urlpattern-polyfill": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-10.1.0.tgz", - "integrity": "sha512-IGjKp/o0NL3Bso1PymYURCJxMPNAf/ILOpendP9f5B6e1rTJgdgiOvgfoT8VxCAdY+Wisb9uhGaJJf3yZ2V9nw==", - "license": "MIT" - }, "node_modules/util": { "version": "0.12.5", "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", @@ -11610,6 +11388,7 @@ "version": "8.18.3", "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "dev": true, "license": "MIT", "engines": { "node": ">=10.0.0" diff --git a/package.json b/package.json index f7db3b72e..1c617a6df 100644 --- a/package.json +++ b/package.json @@ -136,7 +136,7 @@ "@11ty/dependency-tree": "^4.0.2", "@11ty/dependency-tree-esm": "^2.0.4", "@11ty/dependency-tree-typescript": "^1.0.0", - "@11ty/eleventy-dev-server": "^3.0.0-alpha.6", + "@11ty/eleventy-dev-server": "file:../eleventy-dev-server", "@11ty/eleventy-plugin-bundle": "^3.0.7", "@11ty/eleventy-utils": "^2.0.7", "@11ty/gray-matter": "^2.0.1", diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index 43e1b193e..a90986122 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -389,6 +389,7 @@ class TemplateData { if (this.dirs) { eleventy.directories = Object.assign({}, this.dirs.getUserspaceInstance()); } + eleventy.pendingEditCount = this.templateConfig.getPendingDataOverrides(); // `eleventy` is Reserved if (this.config.freezeReservedData) { @@ -571,8 +572,6 @@ class TemplateData { } } - // ignoreProcessing = false for global data files - // ignoreProcessing = true for local data files async getDataValue(path) { let extension = TemplatePath.getExtension(path); @@ -606,6 +605,11 @@ class TemplateData { returnValue = await returnValue(configApiGlobalData || {}); } + let editOverrides = this.templateConfig.getDataOverrideForPath(path); + if (editOverrides) { + returnValue = Merge(returnValue, editOverrides); + } + dataBench.after(); aggregateDataBench.after(); diff --git a/src/Eleventy.js b/src/Eleventy.js index 08cd19ca3..8002d0160 100644 --- a/src/Eleventy.js +++ b/src/Eleventy.js @@ -496,6 +496,10 @@ export default class Eleventy extends Core { * @param {Number} port - The HTTP port to serve Eleventy from. */ async serve(port) { + this.eleventyServe.onEdit(async (path) => { + this.watcher.emit("change", path); + }); + // Port is optional and in this case likely via --port on the command line // May defer to configuration API options `port` property return this.eleventyServe.serve(port); diff --git a/src/EleventyServe.js b/src/EleventyServe.js index 32ab8290b..f8fcfd3fc 100644 --- a/src/EleventyServe.js +++ b/src/EleventyServe.js @@ -42,6 +42,7 @@ class EleventyServe { #chokidar; // these are *not* normalized #watchTargets = new Set(); + #editCallbacks = []; constructor() { this.logger = new ConsoleLogger(); @@ -170,6 +171,28 @@ class EleventyServe { { pathPrefix: PathPrefixer.normalizePathPrefix(this.config.pathPrefix), logger: this.logger, + onClientMessage: async (type, data) => { + let paths = []; + if (type === "eleventy.editReset") { + // Reset previous modified files + paths.push(...this.eleventyConfig.resetDataOverrides()); + + // Reset configuration file + paths.push(this.eleventyConfig.getActiveConfigPath()); + } else if (type === "eleventy.edit") { + for (let dataFileSelector of Object.keys(data)) { + let [filePath, selector] = dataFileSelector.split("#"); + this.eleventyConfig.addDataEditOverride(filePath, selector, data[dataFileSelector]); + paths.push(filePath); + } + } + + for (let filePath of new Set(paths)) { + for (let fn of this.#editCallbacks) { + await fn(filePath); + } + } + }, }, DEFAULT_SERVER_OPTIONS, this.config.serverOptions, @@ -340,6 +363,14 @@ class EleventyServe { await this.server.reload(reloadEvent); } } + + // TODO change this to onmessage + onEdit(callback) { + if (typeof callback !== "function") { + return; + } + this.#editCallbacks.push(callback); + } } export default EleventyServe; diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index 41327e725..2c3a95d15 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -1,5 +1,6 @@ import { Merge, TemplatePath, isPlainObject } from "@11ty/eleventy-utils"; import debugUtil from "debug"; +import lodash from "@11ty/lodash-custom"; import chalk from "./Adapters/Packages/chalk.js"; import getDefaultConfig from "./Adapters/getDefaultConfig.js"; @@ -12,6 +13,7 @@ import eventBus from "./EventBus.js"; import ProjectTemplateFormats from "./Util/ProjectTemplateFormats.js"; import { isTypeScriptSupported } from "./Util/FeatureTests.cjs"; +const { set: lodashSet } = lodash; const debug = debugUtil("Eleventy:TemplateConfig"); const debugDev = debugUtil("Dev:Eleventy:TemplateConfig"); @@ -53,6 +55,7 @@ class TemplateConfig { #usesGraph; #previousBuildModifiedFile; #activeConfigPath; + #dataEditOverrides = {}; constructor(customRootConfig, projectConfigPath) { /** @type {object} */ @@ -601,6 +604,39 @@ class TemplateConfig { get existsCache() { return this.#existsCache; } + + addDataEditOverride(filePath, dataSelector, value) { + if (!this.#dataEditOverrides[filePath]) { + this.#dataEditOverrides[filePath] = {}; + } + lodashSet(this.#dataEditOverrides[filePath], dataSelector, value); + } + + getDataOverrideForPath(filePath) { + filePath = TemplatePath.stripLeadingDotSlash(filePath); + + return this.#dataEditOverrides[filePath]; + } + + deleteDataOverrideForPath(filePath) { + filePath = TemplatePath.stripLeadingDotSlash(filePath); + delete this.#dataEditOverrides[filePath]; + } + + getAllDataOverrides() { + return this.#dataEditOverrides; + } + + resetDataOverrides() { + let filePaths = Object.keys(this.#dataEditOverrides); + this.#dataEditOverrides = {}; + return filePaths; + } + + // only a count of files changed, not edits + getPendingDataOverrides() { + return Object.keys(this.#dataEditOverrides).length; + } } export default TemplateConfig; diff --git a/src/TemplateContent.js b/src/TemplateContent.js index f701a0b7e..58c061878 100644 --- a/src/TemplateContent.js +++ b/src/TemplateContent.js @@ -1,7 +1,7 @@ import { readFileSync } from "node:fs"; import matter from "@11ty/gray-matter"; import lodash from "@11ty/lodash-custom"; -import { DeepCopy, TemplatePath } from "@11ty/eleventy-utils"; +import { Merge, DeepCopy, TemplatePath } from "@11ty/eleventy-utils"; import debugUtil from "debug"; import JavaScriptFrontMatter from "./Engines/FrontMatter/JavaScript.js"; @@ -449,6 +449,11 @@ class TemplateContent { let data = Object.assign(frontMatterData, extraData, virtualTemplateData); + let editOverrides = this.eleventyConfig.getDataOverrideForPath(this.inputPath); + if (editOverrides) { + data = Merge(data, editOverrides); + } + return { data, excerpt: fm.excerpt, diff --git a/src/Watch.js b/src/Watch.js index a0c0c1555..090e771ac 100644 --- a/src/Watch.js +++ b/src/Watch.js @@ -122,6 +122,10 @@ export class Watch { this.#chokidar.on(event, callback); } + emit(event, ...args) { + this.#chokidar.emit(event, ...args); + } + async close() { return this.#chokidar?.close(); } diff --git a/test/EleventyServeTest.js b/test/EleventyServeTest.js index d1baafbd3..bcfa7e827 100644 --- a/test/EleventyServeTest.js +++ b/test/EleventyServeTest.js @@ -29,10 +29,8 @@ test("Get Options", async (t) => { let es = await getServerInstance(); es.setOutputDir("_site"); - t.deepEqual(es.options, { - pathPrefix: "/", - port: 8080, - }); + t.is(es.options.pathPrefix, "/"); + t.is(es.options.port, 8080); }); test("Get Options (with a pathPrefix)", async (t) => { @@ -42,20 +40,16 @@ test("Get Options (with a pathPrefix)", async (t) => { let es = await getServerInstance(eleventyConfig); es.setOutputDir("_site"); - t.deepEqual(es.options, { - pathPrefix: "/web/", - port: 8080, - }); + t.is(es.options.pathPrefix, "/web/"); + t.is(es.options.port, 8080); }); test("Get Options (override in config)", async (t) => { let es = await getServerInstance(); es.setOutputDir("_site"); - t.deepEqual(es.options, { - pathPrefix: "/", - port: 8080, - }); + t.is(es.options.pathPrefix, "/"); + t.is(es.options.port, 8080); }); test("Sanity test that default output is set correctly", async (t) => { From 60086f8da77c5a2344fe9840f6552f6a1aaa3260 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Fri, 13 Mar 2026 16:46:37 -0500 Subject: [PATCH 07/53] Status --- package.json | 6 +++--- src/Eleventy.js | 2 +- src/TemplateConfig.js | 3 +++ src/Util/ConsoleLogger.js | 4 ++-- src/Watch.js | 15 +++++++++++++-- test/TemplateDataTest.js | 2 +- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index f7db3b72e..1d92bfc90 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "@11ty/eleventy", + "name": "@awesome.me/build", "version": "4.0.0-alpha.6", - "description": "A simpler static site generator.", + "description": "A simpler way to build awesome web sites.", "publishConfig": { "access": "public", "provenance": true @@ -19,7 +19,7 @@ "./utils/git": "./src/Util/Git.js" }, "bin": { - "eleventy": "cmd.cjs" + "build": "cmd.cjs" }, "license": "MIT", "engines": { diff --git a/src/Eleventy.js b/src/Eleventy.js index 08cd19ca3..b46632f5d 100644 --- a/src/Eleventy.js +++ b/src/Eleventy.js @@ -325,7 +325,7 @@ export default class Eleventy extends Core { await this.watcher.start(); - this.logger.forceLog("Watching…"); + this.logger.forceLog("Watching: ", await this.watcher.getWatched()); let watchDelay; let watchRun = async (path) => { diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index 41327e725..43b9fd37f 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -74,6 +74,9 @@ class TemplateConfig { } } else { this.projectConfigPaths = [ + "buildawesome.config.js", + "buildawesome.config.mjs", + "buildawesome.config.cjs", ".eleventy.js", "eleventy.config.js", "eleventy.config.mjs", diff --git a/src/Util/ConsoleLogger.js b/src/Util/ConsoleLogger.js index 87f7a4cf2..e80574724 100644 --- a/src/Util/ConsoleLogger.js +++ b/src/Util/ConsoleLogger.js @@ -99,12 +99,12 @@ class ConsoleLogger { type = "log", chalkColor = undefined, forceToConsole = false, - prefix = "[11ty]", + prefix = "[build]", ) { if (!forceToConsole && (!this.isVerbose || process.env.DEBUG)) { debug(message); } else if (this.#logger !== false) { - message = `${chalk.gray(prefix)} ${message.split("\n").join(`\n${chalk.gray(prefix)} `)}`; + message = `${prefix ? `${chalk.gray(prefix)} ` : ""}${message.split("\n").join(`\n${chalk.gray(prefix)} `)}`; if (chalkColor && this.isChalkEnabled) { this.logger[type](chalk[chalkColor](message)); diff --git a/src/Watch.js b/src/Watch.js index a0c0c1555..61da55751 100644 --- a/src/Watch.js +++ b/src/Watch.js @@ -14,6 +14,8 @@ export class Watch { #watchedGlobs = []; /** @type {Set} */ #ignoredGlobs = []; + /** @type {Promise} */ + #ready; constructor(config) { if (!config || config.constructor.name !== "TemplateConfig") { @@ -107,17 +109,26 @@ export class Watch { return path; }) .filter(Boolean); - this.#chokidar = chokidar.watch(targets, options); // Note: if there are no watch targets the `ready` event doesn’t fire so skip it if (targets.length > 0) { - await new Promise((resolve) => { + this.#ready = await new Promise((resolve) => { this.#chokidar.on("ready", () => resolve()); }); + } else { + this.#ready = Promise.resolve(); } } + async getWatched() { + if (this.#ready) { + await this.#ready; + } + + return this.#chokidar.getWatched(); + } + on(event, callback) { this.#chokidar.on(event, callback); } diff --git a/test/TemplateDataTest.js b/test/TemplateDataTest.js index 3aa5c7467..77a0ffed6 100644 --- a/test/TemplateDataTest.js +++ b/test/TemplateDataTest.js @@ -681,7 +681,7 @@ test("getRawImports", async (t) => { dataObj.setProjectUsingEsm(true); let data = await dataObj.getRawImports(); - t.is(data.pkg.name, "@11ty/eleventy"); + t.is(data.pkg.name, "@awesome.me/build"); }); test("getTemplateDataFileGlob", async (t) => { From 76fd63f3192b2de8eadd33dbb4f8450da67379cd Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 20 Apr 2026 16:39:18 -0500 Subject: [PATCH 08/53] Status --- src/Data/TemplateData.js | 7 +++++-- src/EleventyServe.js | 12 +++++++----- src/Template.js | 12 ++++++------ src/TemplateConfig.js | 23 +++++++++++++++-------- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index a90986122..caeb67ddc 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -389,7 +389,7 @@ class TemplateData { if (this.dirs) { eleventy.directories = Object.assign({}, this.dirs.getUserspaceInstance()); } - eleventy.pendingEditCount = this.templateConfig.getPendingDataOverrides(); + eleventy.pendingEdits = this.templateConfig.getPendingDataOverrides(); // `eleventy` is Reserved if (this.config.freezeReservedData) { @@ -426,7 +426,10 @@ class TemplateData { } let globalJson = await this.getAllGlobalData(); - let mergedGlobalData = Merge(globalJson, configApiGlobalData); + + let noFilePathEditOverrides = this.templateConfig.getDataOverrideForPath(); + + let mergedGlobalData = Merge(globalJson, configApiGlobalData, noFilePathEditOverrides); // OK: Shallow merge when combining rawImports (pkg) with global data files return Object.assign({}, mergedGlobalData, rawImports); diff --git a/src/EleventyServe.js b/src/EleventyServe.js index f8fcfd3fc..76b9cb579 100644 --- a/src/EleventyServe.js +++ b/src/EleventyServe.js @@ -174,11 +174,11 @@ class EleventyServe { onClientMessage: async (type, data) => { let paths = []; if (type === "eleventy.editReset") { - // Reset previous modified files - paths.push(...this.eleventyConfig.resetDataOverrides()); - // Reset configuration file paths.push(this.eleventyConfig.getActiveConfigPath()); + + // Reset previous modified files + paths.push(...this.eleventyConfig.resetDataOverrides()); } else if (type === "eleventy.edit") { for (let dataFileSelector of Object.keys(data)) { let [filePath, selector] = dataFileSelector.split("#"); @@ -188,8 +188,10 @@ class EleventyServe { } for (let filePath of new Set(paths)) { - for (let fn of this.#editCallbacks) { - await fn(filePath); + if (filePath) { + for (let fn of this.#editCallbacks) { + await fn(filePath); + } } } }, diff --git a/src/Template.js b/src/Template.js index 1472b2aaa..c95a3f120 100755 --- a/src/Template.js +++ b/src/Template.js @@ -706,13 +706,13 @@ class Template extends TemplateContent { let { href, path } = await this.getOutputLocations(data); data.page.url = href; data.page.outputPath = path; + } - if (this.dataCascade) { - data.page.mapUrl = - this.eleventyConfig.directories.getOutputPathRelativeToOutputDirectory( - data.page.outputPath, - ) + ".map"; - } + if (this.dataCascade) { + data.page.mapUrl = + this.eleventyConfig.directories.getOutputPathRelativeToOutputDirectory( + data.page.outputPath, + ) + ".map"; } } diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index 945370411..1c30db7c7 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -612,6 +612,7 @@ class TemplateConfig { if (!this.#dataEditOverrides[filePath]) { this.#dataEditOverrides[filePath] = {}; } + lodashSet(this.#dataEditOverrides[filePath], dataSelector, value); } @@ -621,14 +622,14 @@ class TemplateConfig { return this.#dataEditOverrides[filePath]; } - deleteDataOverrideForPath(filePath) { - filePath = TemplatePath.stripLeadingDotSlash(filePath); - delete this.#dataEditOverrides[filePath]; - } + // deleteDataOverrideForPath(filePath) { + // filePath = TemplatePath.stripLeadingDotSlash(filePath); + // delete this.#dataEditOverrides[filePath]; + // } - getAllDataOverrides() { - return this.#dataEditOverrides; - } + // getAllDataOverrides() { + // return this.#dataEditOverrides; + // } resetDataOverrides() { let filePaths = Object.keys(this.#dataEditOverrides); @@ -638,7 +639,13 @@ class TemplateConfig { // only a count of files changed, not edits getPendingDataOverrides() { - return Object.keys(this.#dataEditOverrides).length; + let s = new Set(); + for (let [filePath, overrides] of Object.entries(this.#dataEditOverrides)) { + for (let dataProp of Object.keys(overrides)) { + s.add(`${filePath}#${dataProp}`); + } + } + return Array.from(s); } } From 08bd0737f91213c965c78bf4e695a885d3ce2b49 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Wed, 6 May 2026 17:07:25 -0500 Subject: [PATCH 09/53] Status --- src/Data/TemplateData.js | 2 +- src/EleventyServe.js | 9 ++++-- src/TemplateConfig.js | 61 ++++++++++++++++++++++++--------------- src/Util/ConsoleLogger.js | 2 +- 4 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index caeb67ddc..cef67d2ea 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -389,7 +389,7 @@ class TemplateData { if (this.dirs) { eleventy.directories = Object.assign({}, this.dirs.getUserspaceInstance()); } - eleventy.pendingEdits = this.templateConfig.getPendingDataOverrides(); + eleventy.pendingEditsCount = (this.templateConfig.getPendingDataOverrides() || []).length; // `eleventy` is Reserved if (this.config.freezeReservedData) { diff --git a/src/EleventyServe.js b/src/EleventyServe.js index 76b9cb579..890f71a26 100644 --- a/src/EleventyServe.js +++ b/src/EleventyServe.js @@ -171,7 +171,7 @@ class EleventyServe { { pathPrefix: PathPrefixer.normalizePathPrefix(this.config.pathPrefix), logger: this.logger, - onClientMessage: async (type, data) => { + onClientMessage: async ({ id, type, data, timestamp }) => { let paths = []; if (type === "eleventy.editReset") { // Reset configuration file @@ -182,7 +182,12 @@ class EleventyServe { } else if (type === "eleventy.edit") { for (let dataFileSelector of Object.keys(data)) { let [filePath, selector] = dataFileSelector.split("#"); - this.eleventyConfig.addDataEditOverride(filePath, selector, data[dataFileSelector]); + this.eleventyConfig.addDataEditOverride( + filePath, + selector, + data[dataFileSelector], + timestamp, + ); paths.push(filePath); } } diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index 1c30db7c7..027c9d21a 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -13,7 +13,7 @@ import eventBus from "./EventBus.js"; import ProjectTemplateFormats from "./Util/ProjectTemplateFormats.js"; import { isTypeScriptSupported } from "./Util/FeatureTests.cjs"; -const { set: lodashSet } = lodash; +const { set: lodashSet, get: lodashGet } = lodash; const debug = debugUtil("Eleventy:TemplateConfig"); const debugDev = debugUtil("Dev:Eleventy:TemplateConfig"); @@ -55,7 +55,7 @@ class TemplateConfig { #usesGraph; #previousBuildModifiedFile; #activeConfigPath; - #dataEditOverrides = {}; + #dataEdits = []; constructor(customRootConfig, projectConfigPath) { /** @type {object} */ @@ -608,42 +608,55 @@ class TemplateConfig { return this.#existsCache; } - addDataEditOverride(filePath, dataSelector, value) { - if (!this.#dataEditOverrides[filePath]) { - this.#dataEditOverrides[filePath] = {}; - } - - lodashSet(this.#dataEditOverrides[filePath], dataSelector, value); + addDataEditOverride(filePath, dataSelector, value, timestamp) { + this.#dataEdits.push({ + filePath, + dataSelector, + value, + timestamp, + }); } getDataOverrideForPath(filePath) { filePath = TemplatePath.stripLeadingDotSlash(filePath); - return this.#dataEditOverrides[filePath]; - } + let edits = this.#dataEdits + .filter((entry) => entry.filePath === filePath) + .sort((a, b) => { + // crdt algorithm: newest timestamp wins + return a.timestamp - b.timestamp; + }); + + if (edits.length === 0) { + return; + } - // deleteDataOverrideForPath(filePath) { - // filePath = TemplatePath.stripLeadingDotSlash(filePath); - // delete this.#dataEditOverrides[filePath]; - // } + // TODO add a cache for this + let obj = {}; + for (let edit of edits) { + let { filePath, dataSelector, value, timestamp } = edit; - // getAllDataOverrides() { - // return this.#dataEditOverrides; - // } + if (lodashGet(obj, dataSelector)) { + // console.log( "Warning: override conflict", {filePath, dataSelector, value, timestamp}, "with", lodashGet(obj, dataSelector) ); + } + + lodashSet(obj, dataSelector, value); + } + + return obj; + } resetDataOverrides() { - let filePaths = Object.keys(this.#dataEditOverrides); - this.#dataEditOverrides = {}; + let filePaths = this.#dataEdits.map((entry) => entry.filePath); + this.#dataEdits = []; return filePaths; } - // only a count of files changed, not edits + // only a count of files+keys changed, not individual edits getPendingDataOverrides() { let s = new Set(); - for (let [filePath, overrides] of Object.entries(this.#dataEditOverrides)) { - for (let dataProp of Object.keys(overrides)) { - s.add(`${filePath}#${dataProp}`); - } + for (let { filePath, dataSelector } of this.#dataEdits) { + s.add(`${filePath}#${dataSelector}`); } return Array.from(s); } diff --git a/src/Util/ConsoleLogger.js b/src/Util/ConsoleLogger.js index e80574724..bb089506b 100644 --- a/src/Util/ConsoleLogger.js +++ b/src/Util/ConsoleLogger.js @@ -99,7 +99,7 @@ class ConsoleLogger { type = "log", chalkColor = undefined, forceToConsole = false, - prefix = "[build]", + prefix = "[awesome.me/build]", ) { if (!forceToConsole && (!this.isVerbose || process.env.DEBUG)) { debug(message); From 3272486a0a7608a16f17af8bd87664d8fb9d1246 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Wed, 6 May 2026 17:09:24 -0500 Subject: [PATCH 10/53] Upgrade deps --- package-lock.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 981268a42..281172f53 100644 --- a/package-lock.json +++ b/package-lock.json @@ -94,7 +94,7 @@ }, "../eleventy-dev-server": { "name": "@11ty/eleventy-dev-server", - "version": "3.0.0-alpha.6", + "version": "3.0.0-alpha.8", "license": "MIT", "dependencies": { "@11ty/eleventy-utils": "^2.0.7", @@ -104,11 +104,11 @@ "finalhandler": "^2.1.1", "mime": "^4.1.0", "minimist": "^1.2.8", - "morphdom": "^2.7.7", - "send": "^1.2.0", - "ssri": "^13.0.0", + "morphdom": "^2.7.8", + "send": "^1.2.1", + "ssri": "^13.0.1", "urlpattern-polyfill": "^10.1.0", - "ws": "^8.18.3" + "ws": "^8.20.0" }, "bin": { "eleventy-dev-server": "cmd.cjs" From 2b4a09b66807f69ee41402cd9a42b41813a21732 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Fri, 15 May 2026 10:21:18 -0500 Subject: [PATCH 11/53] De-dupe file paths --- src/TemplateConfig.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index 027c9d21a..3a020d455 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -647,7 +647,8 @@ class TemplateConfig { } resetDataOverrides() { - let filePaths = this.#dataEdits.map((entry) => entry.filePath); + // de-duped + let filePaths = Array.from(new Set(this.#dataEdits.map((entry) => entry.filePath))); this.#dataEdits = []; return filePaths; } From 08589e6c00c7792f289e7ded41f49b46b4ba2f0a Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Fri, 5 Jun 2026 17:12:48 -0500 Subject: [PATCH 12/53] Priority for #4247 changed to prefer JS over TS if both exist --- package-lock.json | 4 +- package.json | 2 +- src/Data/TemplateData.js | 8 +- src/TemplateConfig.js | 16 +--- src/Util/ConsoleLogger.js | 2 +- src/Util/FilePathUtil.js | 25 +++++- test/TemplateDataTest.js | 143 +++++++++++++++++---------------- test/TemplateTest.js | 74 +++++++++-------- test/UserDataExtensionsTest.js | 20 ++--- 9 files changed, 160 insertions(+), 134 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6828a2b5f..e405ce6c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@awesome.me/build", + "name": "@11ty/eleventy", "version": "4.0.0-alpha.8", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@awesome.me/build", + "name": "@11ty/eleventy", "version": "4.0.0-alpha.8", "license": "MIT", "workspaces": [ diff --git a/package.json b/package.json index 8a03ae7a0..80f6370ad 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@awesome.me/build", + "name": "@11ty/eleventy", "version": "4.0.0-alpha.8", "description": "A simpler way to build awesome web sites.", "publishConfig": { diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index 9d3c1aca8..b6fa0b921 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -30,15 +30,17 @@ const debugDev = createDebug("Dev:Eleventy:TemplateData"); class TemplateDataParseError extends EleventyBaseError {} class TemplateData { - // order is important (json not included) + // Would be nice if the priorities here matched (see also FilePathUtil used by config file paths) + + // (json not included) priority is reverse order #eligiblePrioritizedExtensions = [ + ...(isTypeScriptSupported() ? ["ts", "cts", "mts"] : []), "js", "cjs", "mjs", - ...(isTypeScriptSupported() ? ["ts", "cts", "mts"] : []), ]; - // order is important + // in order of priority #globalDataOrderedExtensions = [ "json", "mjs", diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index ff82c032e..cc7a834de 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -11,7 +11,7 @@ import GlobalDependencyMap from "./GlobalDependencyMap.js"; import ExistsCache from "./Util/ExistsCache.js"; import eventBus from "./EventBus.js"; import ProjectTemplateFormats from "./Util/ProjectTemplateFormats.js"; -import { isTypeScriptSupported } from "./Util/FeatureTests.cjs"; +import { expandEligibleJavaScriptFilePaths } from "./Util/FilePathUtil.js"; const { set: lodashSet, get: lodashGet } = lodash; const debug = createDebug("Eleventy:TemplateConfig"); @@ -76,20 +76,10 @@ class TemplateConfig { } } else { this.projectConfigPaths = [ - "buildawesome.config.js", - "buildawesome.config.mjs", - "buildawesome.config.cjs", + ...expandEligibleJavaScriptFilePaths("build-awesome.config"), ".eleventy.js", - "eleventy.config.js", - "eleventy.config.mjs", - "eleventy.config.cjs", + ...expandEligibleJavaScriptFilePaths("eleventy.config"), ]; - - if (isTypeScriptSupported()) { - this.projectConfigPaths.push("eleventy.config.ts"); - this.projectConfigPaths.push("eleventy.config.mts"); - this.projectConfigPaths.push("eleventy.config.cts"); - } } if (customRootConfig) { diff --git a/src/Util/ConsoleLogger.js b/src/Util/ConsoleLogger.js index 16646d90d..7e737a489 100644 --- a/src/Util/ConsoleLogger.js +++ b/src/Util/ConsoleLogger.js @@ -107,7 +107,7 @@ class ConsoleLogger { type = "log", chalkColor = undefined, forceToConsole = false, - prefix = "[awesome.me/build]", + prefix = "[11ty]", ) { if (!forceToConsole && (!this.isVerbose || process.env.DEBUG)) { debug(message); diff --git a/src/Util/FilePathUtil.js b/src/Util/FilePathUtil.js index 1675e8ecd..3bd30a3ea 100644 --- a/src/Util/FilePathUtil.js +++ b/src/Util/FilePathUtil.js @@ -1,4 +1,14 @@ -class FilePathUtil { +import { isTypeScriptSupported } from "./FeatureTests.cjs"; + +// the order here is important +const ELIGIBLE_EXTENSIONS = [ + "js", + "mjs", + "cjs", + ...(isTypeScriptSupported() ? ["ts", "mts", "cts"] : []), +]; + +export class FilePathUtil { static isMatchingExtension(filepath, fileExtension) { if (!fileExtension) { return false; @@ -16,4 +26,15 @@ class FilePathUtil { } } -export { FilePathUtil }; +export function isEligibleJavaScriptFileExtension(ext) { + return ELIGIBLE_EXTENSIONS.includes((ext || "").toLowerCase()); +} + +// used for Config Paths (not yet for template data) +export function expandEligibleJavaScriptFilePaths(fileslug) { + let results = []; + for (let ext of ELIGIBLE_EXTENSIONS) { + results.push(`${fileslug}.${ext}`); + } + return results; +} diff --git a/test/TemplateDataTest.js b/test/TemplateDataTest.js index 411bf5337..b53f5fb1a 100644 --- a/test/TemplateDataTest.js +++ b/test/TemplateDataTest.js @@ -380,25 +380,25 @@ test("getLocalDataPaths", async (t) => { t.deepEqual(paths, [ "./test/stubs/stubs.json", "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.11tydata.mts", "./test/stubs/stubs.11tydata.cts", "./test/stubs/stubs.11tydata.ts", ] : []), - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", "./test/stubs/component/component.json", "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.11tydata.mts", "./test/stubs/component/component.11tydata.cts", "./test/stubs/component/component.11tydata.ts", ] : []), - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", ]); }); @@ -416,35 +416,35 @@ test("getLocalDataPaths (with setDataFileBaseName #1699)", async (t) => { t.deepEqual(paths, [ "./test/stubs/index.11tydata.json", + "./test/stubs/index.11tydata.mjs", + "./test/stubs/index.11tydata.cjs", + "./test/stubs/index.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/index.11tydata.mts", "./test/stubs/index.11tydata.cts", "./test/stubs/index.11tydata.ts", ] : []), - "./test/stubs/index.11tydata.mjs", - "./test/stubs/index.11tydata.cjs", - "./test/stubs/index.11tydata.js", "./test/stubs/component/index.11tydata.json", + "./test/stubs/component/index.11tydata.mjs", + "./test/stubs/component/index.11tydata.cjs", + "./test/stubs/component/index.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/index.11tydata.mts", "./test/stubs/component/index.11tydata.cts", "./test/stubs/component/index.11tydata.ts", ] : []), - "./test/stubs/component/index.11tydata.mjs", - "./test/stubs/component/index.11tydata.cjs", - "./test/stubs/component/index.11tydata.js", "./test/stubs/component/component.json", "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.11tydata.mts", "./test/stubs/component/component.11tydata.cts", "./test/stubs/component/component.11tydata.ts", ] : []), - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", ]); }); @@ -477,24 +477,24 @@ test("getLocalDataPaths (with setDataFileSuffixes override #1699)", async (t) => t.deepEqual(paths, [ "./test/stubs/stubs.howdy.json", + "./test/stubs/stubs.howdy.mjs", + "./test/stubs/stubs.howdy.cjs", + "./test/stubs/stubs.howdy.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.howdy.mts", "./test/stubs/stubs.howdy.cts", "./test/stubs/stubs.howdy.ts", ] : []), - "./test/stubs/stubs.howdy.mjs", - "./test/stubs/stubs.howdy.cjs", - "./test/stubs/stubs.howdy.js", "./test/stubs/component/component.howdy.json", + "./test/stubs/component/component.howdy.mjs", + "./test/stubs/component/component.howdy.cjs", + "./test/stubs/component/component.howdy.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.howdy.mts", "./test/stubs/component/component.howdy.cts", "./test/stubs/component/component.howdy.ts", ] : []), - "./test/stubs/component/component.howdy.mjs", - "./test/stubs/component/component.howdy.cjs", - "./test/stubs/component/component.howdy.js", ]); }); @@ -530,25 +530,27 @@ test("getLocalDataPaths (with setDataFileSuffixes override with two entries #169 t.deepEqual(paths, [ "./test/stubs/stubs.json", "./test/stubs/stubs.howdy.json", + "./test/stubs/stubs.howdy.mjs", + "./test/stubs/stubs.howdy.cjs", + "./test/stubs/stubs.howdy.js", + ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.howdy.mts", "./test/stubs/stubs.howdy.cts", "./test/stubs/stubs.howdy.ts", ] : []), - "./test/stubs/stubs.howdy.mjs", - "./test/stubs/stubs.howdy.cjs", - "./test/stubs/stubs.howdy.js", "./test/stubs/component/component.json", "./test/stubs/component/component.howdy.json", + "./test/stubs/component/component.howdy.mjs", + "./test/stubs/component/component.howdy.cjs", + "./test/stubs/component/component.howdy.js", + ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.howdy.mts", "./test/stubs/component/component.howdy.cts", "./test/stubs/component/component.howdy.ts", ] : []), - "./test/stubs/component/component.howdy.mjs", - "./test/stubs/component/component.howdy.cjs", - "./test/stubs/component/component.howdy.js", ]); }); @@ -567,35 +569,35 @@ test("getLocalDataPaths (with setDataFileSuffixes and setDataFileBaseName #1699) t.deepEqual(paths, [ "./test/stubs/index.howdy.json", + "./test/stubs/index.howdy.mjs", + "./test/stubs/index.howdy.cjs", + "./test/stubs/index.howdy.js", ...(isTypeScriptSupported() ? [ "./test/stubs/index.howdy.mts", "./test/stubs/index.howdy.cts", "./test/stubs/index.howdy.ts", ] : []), - "./test/stubs/index.howdy.mjs", - "./test/stubs/index.howdy.cjs", - "./test/stubs/index.howdy.js", "./test/stubs/component/index.howdy.json", + "./test/stubs/component/index.howdy.mjs", + "./test/stubs/component/index.howdy.cjs", + "./test/stubs/component/index.howdy.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/index.howdy.mts", "./test/stubs/component/index.howdy.cts", "./test/stubs/component/index.howdy.ts", ] : []), - "./test/stubs/component/index.howdy.mjs", - "./test/stubs/component/index.howdy.cjs", - "./test/stubs/component/index.howdy.js", "./test/stubs/component/component.json", "./test/stubs/component/component.howdy.json", + "./test/stubs/component/component.howdy.mjs", + "./test/stubs/component/component.howdy.cjs", + "./test/stubs/component/component.howdy.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.howdy.mts", "./test/stubs/component/component.howdy.cts", "./test/stubs/component/component.howdy.ts", ] : []), - "./test/stubs/component/component.howdy.mjs", - "./test/stubs/component/component.howdy.cjs", - "./test/stubs/component/component.howdy.js", ]); }); @@ -610,34 +612,35 @@ test("Deeper getLocalDataPaths", async (t) => { t.deepEqual(paths, [ "./test/test.json", "./test/test.11tydata.json", + "./test/test.11tydata.mjs", + "./test/test.11tydata.cjs", + "./test/test.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/test.11tydata.mts", "./test/test.11tydata.cts", "./test/test.11tydata.ts", ] : []), - "./test/test.11tydata.mjs", - "./test/test.11tydata.cjs", - "./test/test.11tydata.js", + "./test/stubs/stubs.json", "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.11tydata.mts", "./test/stubs/stubs.11tydata.cts", "./test/stubs/stubs.11tydata.ts", ] : []), - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", "./test/stubs/component/component.json", "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.11tydata.mts", "./test/stubs/component/component.11tydata.cts", "./test/stubs/component/component.11tydata.ts", ] : []), - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", ]); }); @@ -656,24 +659,24 @@ test("getLocalDataPaths with an 11ty js template", async (t) => { t.deepEqual(paths, [ "./test/stubs/stubs.json", "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.11tydata.mts", "./test/stubs/stubs.11tydata.cts", "./test/stubs/stubs.11tydata.ts", ] : []), - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", "./test/stubs/component/component.json", "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.11tydata.mts", "./test/stubs/component/component.11tydata.cts", "./test/stubs/component/component.11tydata.ts", ] : []), - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", ]); }); @@ -692,24 +695,24 @@ test("getLocalDataPaths with inputDir passed in (trailing slash)", async (t) => t.deepEqual(paths, [ "./test/stubs/stubs.json", "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.11tydata.mts", "./test/stubs/stubs.11tydata.cts", "./test/stubs/stubs.11tydata.ts", ] : []), - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", "./test/stubs/component/component.json", "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.11tydata.mts", "./test/stubs/component/component.11tydata.cts", "./test/stubs/component/component.11tydata.ts", ] : []), - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", ]); }); @@ -728,24 +731,24 @@ test("getLocalDataPaths with inputDir passed in (no trailing slash)", async (t) t.deepEqual(paths, [ "./test/stubs/stubs.json", "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.11tydata.mts", "./test/stubs/stubs.11tydata.cts", "./test/stubs/stubs.11tydata.ts", ] : []), - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", "./test/stubs/component/component.json", "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.11tydata.mts", "./test/stubs/component/component.11tydata.cts", "./test/stubs/component/component.11tydata.ts", ] : []), - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", ]); }); @@ -764,24 +767,24 @@ test("getLocalDataPaths with inputDir passed in (no leading slash)", async (t) = t.deepEqual(paths, [ "./test/stubs/stubs.json", "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.11tydata.mts", "./test/stubs/stubs.11tydata.cts", "./test/stubs/stubs.11tydata.ts", ] : []), - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", "./test/stubs/component/component.json", "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.11tydata.mts", "./test/stubs/component/component.11tydata.cts", "./test/stubs/component/component.11tydata.ts", ] : []), - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", ]); }); @@ -796,7 +799,7 @@ test("getRawImports", async (t) => { dataObj.setProjectUsingEsm(true); let data = await dataObj.getRawImports(); - t.is(data.pkg.name, "@awesome.me/build"); + t.is(data.pkg.name, "@11ty/eleventy"); }); test("getTemplateDataFileGlob", async (t) => { diff --git a/test/TemplateTest.js b/test/TemplateTest.js index f5bebdcb7..80faf6864 100644 --- a/test/TemplateTest.js +++ b/test/TemplateTest.js @@ -474,24 +474,25 @@ test("Local template data file import (without a global data json)", async (t) = t.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [ "./test/stubs/stubs.json", "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.11tydata.mts", "./test/stubs/stubs.11tydata.cts", "./test/stubs/stubs.11tydata.ts", ] : []), - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", + "./test/stubs/component/component.json", "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/component/component.11tydata.mts", "./test/stubs/component/component.11tydata.cts", "./test/stubs/component/component.11tydata.ts", ] : []), - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", ]); t.is(data.localdatakey1, "localdatavalue1"); t.is(await renderTemplate(tmpl, data), "localdatavalue1"); @@ -521,44 +522,48 @@ test("Local template data file import (two subdirectories deep)", async (t) => { t.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [ "./test/stubs/stubs.json", "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.11tydata.mts", "./test/stubs/stubs.11tydata.cts", "./test/stubs/stubs.11tydata.ts", ] : []), - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", + "./test/stubs/firstdir/firstdir.json", "./test/stubs/firstdir/firstdir.11tydata.json", + "./test/stubs/firstdir/firstdir.11tydata.mjs", + "./test/stubs/firstdir/firstdir.11tydata.cjs", + "./test/stubs/firstdir/firstdir.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/firstdir/firstdir.11tydata.mts", "./test/stubs/firstdir/firstdir.11tydata.cts", "./test/stubs/firstdir/firstdir.11tydata.ts", ] : []), - "./test/stubs/firstdir/firstdir.11tydata.mjs", - "./test/stubs/firstdir/firstdir.11tydata.cjs", - "./test/stubs/firstdir/firstdir.11tydata.js", + "./test/stubs/firstdir/seconddir/seconddir.json", "./test/stubs/firstdir/seconddir/seconddir.11tydata.json", + "./test/stubs/firstdir/seconddir/seconddir.11tydata.mjs", + "./test/stubs/firstdir/seconddir/seconddir.11tydata.cjs", + "./test/stubs/firstdir/seconddir/seconddir.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/firstdir/seconddir/seconddir.11tydata.mts", "./test/stubs/firstdir/seconddir/seconddir.11tydata.cts", "./test/stubs/firstdir/seconddir/seconddir.11tydata.ts", ] : []), - "./test/stubs/firstdir/seconddir/seconddir.11tydata.mjs", - "./test/stubs/firstdir/seconddir/seconddir.11tydata.cjs", - "./test/stubs/firstdir/seconddir/seconddir.11tydata.js", + "./test/stubs/firstdir/seconddir/component.json", "./test/stubs/firstdir/seconddir/component.11tydata.json", + "./test/stubs/firstdir/seconddir/component.11tydata.mjs", + "./test/stubs/firstdir/seconddir/component.11tydata.cjs", + "./test/stubs/firstdir/seconddir/component.11tydata.js", + ...(isTypeScriptSupported() ? [ "./test/stubs/firstdir/seconddir/component.11tydata.mts", "./test/stubs/firstdir/seconddir/component.11tydata.cts", "./test/stubs/firstdir/seconddir/component.11tydata.ts", ] : []), - "./test/stubs/firstdir/seconddir/component.11tydata.mjs", - "./test/stubs/firstdir/seconddir/component.11tydata.cjs", - "./test/stubs/firstdir/seconddir/component.11tydata.js", ]); }); @@ -587,34 +592,36 @@ test("Posts inherits local JSON, layouts", async (t) => { t.deepEqual(localDataPaths, [ "./test/stubs/stubs.json", "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.11tydata.mts", "./test/stubs/stubs.11tydata.cts", "./test/stubs/stubs.11tydata.ts", ] : []), - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", + "./test/stubs/posts/posts.json", "./test/stubs/posts/posts.11tydata.json", + "./test/stubs/posts/posts.11tydata.mjs", + "./test/stubs/posts/posts.11tydata.cjs", + "./test/stubs/posts/posts.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/posts/posts.11tydata.mts", "./test/stubs/posts/posts.11tydata.cts", "./test/stubs/posts/posts.11tydata.ts", ] : []), - "./test/stubs/posts/posts.11tydata.mjs", - "./test/stubs/posts/posts.11tydata.cjs", - "./test/stubs/posts/posts.11tydata.js", + "./test/stubs/posts/post1.json", "./test/stubs/posts/post1.11tydata.json", + "./test/stubs/posts/post1.11tydata.mjs", + "./test/stubs/posts/post1.11tydata.cjs", + "./test/stubs/posts/post1.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/posts/post1.11tydata.mts", "./test/stubs/posts/post1.11tydata.cts", "./test/stubs/posts/post1.11tydata.ts", ] : []), - "./test/stubs/posts/post1.11tydata.mjs", - "./test/stubs/posts/post1.11tydata.cjs", - "./test/stubs/posts/post1.11tydata.js", ]); let localData = await dataObj.getTemplateDirectoryData(tmpl.getInputPath()); @@ -658,24 +665,25 @@ test("Template and folder name are the same, make sure data imports work ok", as t.deepEqual(localDataPaths, [ "./test/stubs/stubs.json", "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/stubs.11tydata.mts", "./test/stubs/stubs.11tydata.cts", "./test/stubs/stubs.11tydata.ts", ] : []), - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", + "./test/stubs/posts/posts.json", "./test/stubs/posts/posts.11tydata.json", + "./test/stubs/posts/posts.11tydata.mjs", + "./test/stubs/posts/posts.11tydata.cjs", + "./test/stubs/posts/posts.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs/posts/posts.11tydata.mts", "./test/stubs/posts/posts.11tydata.cts", "./test/stubs/posts/posts.11tydata.ts", ] : []), - "./test/stubs/posts/posts.11tydata.mjs", - "./test/stubs/posts/posts.11tydata.cjs", - "./test/stubs/posts/posts.11tydata.js", ]); let localData = await dataObj.getTemplateDirectoryData(tmpl.getInputPath()); diff --git a/test/UserDataExtensionsTest.js b/test/UserDataExtensionsTest.js index ecfdb13f7..951d03197 100644 --- a/test/UserDataExtensionsTest.js +++ b/test/UserDataExtensionsTest.js @@ -71,42 +71,44 @@ test("Local files", async (t) => { "./test/stubs-630/stubs-630.11tydata.yaml", "./test/stubs-630/stubs-630.11tydata.nosj", "./test/stubs-630/stubs-630.11tydata.json", + "./test/stubs-630/stubs-630.11tydata.mjs", + "./test/stubs-630/stubs-630.11tydata.cjs", + "./test/stubs-630/stubs-630.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs-630/stubs-630.11tydata.mts", "./test/stubs-630/stubs-630.11tydata.cts", "./test/stubs-630/stubs-630.11tydata.ts", ] : []), - "./test/stubs-630/stubs-630.11tydata.mjs", - "./test/stubs-630/stubs-630.11tydata.cjs", - "./test/stubs-630/stubs-630.11tydata.js", + "./test/stubs-630/component-yaml/component-yaml.yaml", "./test/stubs-630/component-yaml/component-yaml.nosj", "./test/stubs-630/component-yaml/component-yaml.json", "./test/stubs-630/component-yaml/component-yaml.11tydata.yaml", "./test/stubs-630/component-yaml/component-yaml.11tydata.nosj", "./test/stubs-630/component-yaml/component-yaml.11tydata.json", + "./test/stubs-630/component-yaml/component-yaml.11tydata.mjs", + "./test/stubs-630/component-yaml/component-yaml.11tydata.cjs", + "./test/stubs-630/component-yaml/component-yaml.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs-630/component-yaml/component-yaml.11tydata.mts", "./test/stubs-630/component-yaml/component-yaml.11tydata.cts", "./test/stubs-630/component-yaml/component-yaml.11tydata.ts", ] : []), - "./test/stubs-630/component-yaml/component-yaml.11tydata.mjs", - "./test/stubs-630/component-yaml/component-yaml.11tydata.cjs", - "./test/stubs-630/component-yaml/component-yaml.11tydata.js", + "./test/stubs-630/component-yaml/component.yaml", "./test/stubs-630/component-yaml/component.nosj", "./test/stubs-630/component-yaml/component.json", "./test/stubs-630/component-yaml/component.11tydata.yaml", "./test/stubs-630/component-yaml/component.11tydata.nosj", "./test/stubs-630/component-yaml/component.11tydata.json", + "./test/stubs-630/component-yaml/component.11tydata.mjs", + "./test/stubs-630/component-yaml/component.11tydata.cjs", + "./test/stubs-630/component-yaml/component.11tydata.js", ...(isTypeScriptSupported() ? [ "./test/stubs-630/component-yaml/component.11tydata.mts", "./test/stubs-630/component-yaml/component.11tydata.cts", "./test/stubs-630/component-yaml/component.11tydata.ts", ] : []), - "./test/stubs-630/component-yaml/component.11tydata.mjs", - "./test/stubs-630/component-yaml/component.11tydata.cjs", - "./test/stubs-630/component-yaml/component.11tydata.js", ]); }); From d9f0d5c970914eb698164971c7ca8803b7a10e00 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Fri, 5 Jun 2026 17:23:47 -0500 Subject: [PATCH 13/53] A few more package ignores --- .npmignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.npmignore b/.npmignore index 7bfc930d2..7e1e1f71c 100644 --- a/.npmignore +++ b/.npmignore @@ -6,3 +6,5 @@ coverage eslint.config.js .* packages/client/ +scripts +tsconfig.json From ebc3264774b93f263ebe5c6958fc71125547b4f1 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Fri, 5 Jun 2026 17:34:03 -0500 Subject: [PATCH 14/53] Move packages/client to packages/browser --- .npmignore | 2 +- README.md | 2 +- package-lock.json | 8 ++++---- package.json | 2 +- packages/{client => browser}/README.md | 0 packages/{client => browser}/generate-bundle.js | 5 +++-- packages/{client => browser}/package.json | 0 packages/{client => browser}/src/BundleCore.js | 0 packages/{client => browser}/src/BundleEleventy.js | 0 packages/{client => browser}/src/BundleI18nPlugin.js | 0 packages/{client => browser}/src/BundleLiquid.js | 0 packages/{client => browser}/src/BundleMarkdown.js | 0 packages/{client => browser}/src/BundleNunjucks.js | 0 packages/{client => browser}/src/shims/process.cjs | 0 packages/{client => browser}/src/shims/shim-core.js | 0 packages/{client => browser}/test/client-core.test.js | 0 packages/{client => browser}/test/client-eleventy.test.js | 0 packages/{client => browser}/test/shared-tests.js | 0 packages/{client => browser}/update-package-json.js | 4 ++-- packages/{client => browser}/vitest.config.js | 0 scripts/release.sh | 2 +- 21 files changed, 13 insertions(+), 12 deletions(-) rename packages/{client => browser}/README.md (100%) rename packages/{client => browser}/generate-bundle.js (93%) rename packages/{client => browser}/package.json (100%) rename packages/{client => browser}/src/BundleCore.js (100%) rename packages/{client => browser}/src/BundleEleventy.js (100%) rename packages/{client => browser}/src/BundleI18nPlugin.js (100%) rename packages/{client => browser}/src/BundleLiquid.js (100%) rename packages/{client => browser}/src/BundleMarkdown.js (100%) rename packages/{client => browser}/src/BundleNunjucks.js (100%) rename packages/{client => browser}/src/shims/process.cjs (100%) rename packages/{client => browser}/src/shims/shim-core.js (100%) rename packages/{client => browser}/test/client-core.test.js (100%) rename packages/{client => browser}/test/client-eleventy.test.js (100%) rename packages/{client => browser}/test/shared-tests.js (100%) rename packages/{client => browser}/update-package-json.js (80%) rename packages/{client => browser}/vitest.config.js (100%) diff --git a/.npmignore b/.npmignore index 7e1e1f71c..8f05265bb 100644 --- a/.npmignore +++ b/.npmignore @@ -5,6 +5,6 @@ test_node coverage eslint.config.js .* -packages/client/ +packages/browser/ scripts tsconfig.json diff --git a/README.md b/README.md index 725fdbb33..0ba575976 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ We have a few test suites, for various reasons: - [ava JavaScript test runner](https://github.com/avajs/ava) ([assertions docs](https://github.com/avajs/ava/blob/main/docs/03-assertions.md)) (primary test suite in `test/`) - [Node.js Test runner](https://nodejs.org/api/test.html) (secondary test suite in `test_node/`) -- [Vitest (in Browser Mode)](https://vitest.dev/guide/browser/) (client tests in `packages/client/test/`) +- [Vitest (in Browser Mode)](https://vitest.dev/guide/browser/) (client tests in `packages/browser/test/`) - [Benchmark for Performance Regressions](https://github.com/11ty/eleventy-benchmark) These run in various environments: diff --git a/package-lock.json b/package-lock.json index e405ce6c4..a8a5bd8f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "4.0.0-alpha.8", "license": "MIT", "workspaces": [ - "packages/client" + "packages/browser" ], "dependencies": { "@11ty/dependency-tree": "^4.0.2", @@ -124,7 +124,7 @@ } }, "node_modules/@11ty/client": { - "resolved": "packages/client", + "resolved": "packages/browser", "link": true }, "node_modules/@11ty/dependency-tree": { @@ -11023,9 +11023,9 @@ "url": "https://github.com/sponsors/wooorm" } }, - "packages/client": { + "packages/browser": { "name": "@11ty/client", - "version": "PRIVATE", + "version": "4.0.0-alpha.8", "license": "MIT", "devDependencies": { "@11ty/package-bundler": "^0.5.6", diff --git a/package.json b/package.json index 80f6370ad..2c485cc3d 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "node": ">=22.15" }, "workspaces": [ - "packages/client" + "packages/browser" ], "funding": { "type": "opencollective", diff --git a/packages/client/README.md b/packages/browser/README.md similarity index 100% rename from packages/client/README.md rename to packages/browser/README.md diff --git a/packages/client/generate-bundle.js b/packages/browser/generate-bundle.js similarity index 93% rename from packages/client/generate-bundle.js rename to packages/browser/generate-bundle.js index 5d04aefa0..f099124df 100644 --- a/packages/client/generate-bundle.js +++ b/packages/browser/generate-bundle.js @@ -1,10 +1,11 @@ import fs from "node:fs"; +import chalk from "kleur"; import { default as bundleClient } from "@11ty/package-bundler"; import pkg from "../../package.json" with { type: "json" }; import { readableFileSize } from "../../src/Util/FileSize.js"; -const PREFIX = `[11ty/bundle/client] `; +const PREFIX = chalk.dim(`[11ty/bundle/client] `); function size(filepath) { return readableFileSize(fs.statSync(filepath).size); @@ -36,7 +37,7 @@ console.log(`${PREFIX}Wrote dist/eleventy.js: ${size("./dist/eleventy.js")}`); // fs.mkdirSync("./visualize/", { recursive: true }); // fs.writeFileSync("./visualize/meta.json", JSON.stringify(result.metafile)); -// npx esbuild-visualizer --metadata ./packages/client/visualize/meta.json --filename packages/client/visualize/index.html +// npx esbuild-visualizer --metadata ./packages/browser/visualize/meta.json --filename packages/browser/visualize/index.html await bundleClient( import.meta.resolve("./src/BundleLiquid.js"), diff --git a/packages/client/package.json b/packages/browser/package.json similarity index 100% rename from packages/client/package.json rename to packages/browser/package.json diff --git a/packages/client/src/BundleCore.js b/packages/browser/src/BundleCore.js similarity index 100% rename from packages/client/src/BundleCore.js rename to packages/browser/src/BundleCore.js diff --git a/packages/client/src/BundleEleventy.js b/packages/browser/src/BundleEleventy.js similarity index 100% rename from packages/client/src/BundleEleventy.js rename to packages/browser/src/BundleEleventy.js diff --git a/packages/client/src/BundleI18nPlugin.js b/packages/browser/src/BundleI18nPlugin.js similarity index 100% rename from packages/client/src/BundleI18nPlugin.js rename to packages/browser/src/BundleI18nPlugin.js diff --git a/packages/client/src/BundleLiquid.js b/packages/browser/src/BundleLiquid.js similarity index 100% rename from packages/client/src/BundleLiquid.js rename to packages/browser/src/BundleLiquid.js diff --git a/packages/client/src/BundleMarkdown.js b/packages/browser/src/BundleMarkdown.js similarity index 100% rename from packages/client/src/BundleMarkdown.js rename to packages/browser/src/BundleMarkdown.js diff --git a/packages/client/src/BundleNunjucks.js b/packages/browser/src/BundleNunjucks.js similarity index 100% rename from packages/client/src/BundleNunjucks.js rename to packages/browser/src/BundleNunjucks.js diff --git a/packages/client/src/shims/process.cjs b/packages/browser/src/shims/process.cjs similarity index 100% rename from packages/client/src/shims/process.cjs rename to packages/browser/src/shims/process.cjs diff --git a/packages/client/src/shims/shim-core.js b/packages/browser/src/shims/shim-core.js similarity index 100% rename from packages/client/src/shims/shim-core.js rename to packages/browser/src/shims/shim-core.js diff --git a/packages/client/test/client-core.test.js b/packages/browser/test/client-core.test.js similarity index 100% rename from packages/client/test/client-core.test.js rename to packages/browser/test/client-core.test.js diff --git a/packages/client/test/client-eleventy.test.js b/packages/browser/test/client-eleventy.test.js similarity index 100% rename from packages/client/test/client-eleventy.test.js rename to packages/browser/test/client-eleventy.test.js diff --git a/packages/client/test/shared-tests.js b/packages/browser/test/shared-tests.js similarity index 100% rename from packages/client/test/shared-tests.js rename to packages/browser/test/shared-tests.js diff --git a/packages/client/update-package-json.js b/packages/browser/update-package-json.js similarity index 80% rename from packages/client/update-package-json.js rename to packages/browser/update-package-json.js index 60983e0c8..0422e5033 100644 --- a/packages/client/update-package-json.js +++ b/packages/browser/update-package-json.js @@ -12,10 +12,10 @@ delete clientPkg.private; // allow publish if ( corePkg.name !== "@11ty/eleventy" || clientPkg.name !== "@11ty/client" || - !fs.existsSync("./packages/client/package.json") + !fs.existsSync("./packages/browser/package.json") ) { throw new Error("Did you run this script from the wrong directory?"); } -fs.writeFileSync("./packages/client/package.json", JSON.stringify(clientPkg, null, 2), "utf8"); +fs.writeFileSync("./packages/browser/package.json", JSON.stringify(clientPkg, null, 2), "utf8"); console.log(`[11ty/bundle/client] Updated @11ty/client package version to ${corePkg.version}`); diff --git a/packages/client/vitest.config.js b/packages/browser/vitest.config.js similarity index 100% rename from packages/client/vitest.config.js rename to packages/browser/vitest.config.js diff --git a/scripts/release.sh b/scripts/release.sh index 0cc71f859..90322293a 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -19,7 +19,7 @@ if [ -z "$NPM_PUBLISH_TAG" ]; then exit 1 fi -node packages/client/update-package-json.js +node packages/browser/update-package-json.js # Will skip publishing root if publishing workspaces fails if npm publish --workspaces --provenance --access=public --tag=$NPM_PUBLISH_TAG $DRY_RUN; then From f60a2a845536210cd01718a6e6c469a53b69910f Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 9 Jun 2026 12:05:21 -0500 Subject: [PATCH 15/53] `eleventy.*` events now also emit as `buildawesome.*`, ELEVENTY_ env now aliased as BUILDAWESOME_. DEBUG logs uses BuildAwesome: prefix --- .github/ISSUE_TEMPLATE/config.yml | 12 +- .github/ISSUE_TEMPLATE/possible-bug.yml | 6 +- .github/workflows/release.yml | 2 +- .gitignore | 2 +- CODE_OF_CONDUCT.md | 4 +- README.md | 21 +- SECURITY.md | 2 +- cmd.cjs | 67 +- docs/ba-11ty-logo.png | Bin 0 -> 11602 bytes docs/coverage.njk | 2 +- docs/eleventy.coverage.js | 4 +- docs/release-instructions.md | 4 +- package.json | 10 +- packages/browser/README.md | 2 +- packages/browser/generate-bundle.js | 72 +- packages/browser/package.json | 20 +- .../{BundleEleventy.js => BundleCoreFs.js} | 2 +- .../{BundleCore.js => BundleCoreMinimal.js} | 2 +- packages/browser/src/shims/shim-core.js | 4 +- packages/browser/test/client-core-fs.test.js | 4 + packages/browser/test/client-core.test.js | 4 +- packages/browser/test/client-eleventy.test.js | 4 - packages/browser/test/shared-tests.js | 88 +-- src/Benchmark/BenchmarkGroup.js | 2 +- src/Core.js | 642 +++++++++++++++++- src/CoreFs.js | 51 ++ src/CoreMinimal.js | 104 ++- src/Data/ComputedData.js | 2 +- src/Data/ComputedDataTemplateString.js | 2 +- src/Data/ConfigurationGlobalData.js | 4 +- src/Data/TemplateData.js | 34 +- src/Eleventy.js | 631 ----------------- src/Engines/Custom.js | 2 +- src/Engines/JavaScript.js | 10 +- src/Engines/Nunjucks.js | 10 +- src/Engines/TemplateEngine.js | 6 +- src/Engines/TemplateEngineManager.js | 5 +- .../{EleventyBaseError.js => BaseError.js} | 3 +- src/Errors/DuplicatePermalinkOutputError.js | 6 +- ...leventyErrorHandler.js => ErrorHandler.js} | 16 +- .../{EleventyErrorUtil.js => ErrorUtil.js} | 23 +- .../TemplateContentPrematureUseError.js | 6 +- .../TemplateContentUnrenderedTemplateError.js | 6 +- ...ngCircularTemplateContentReferenceError.js | 6 +- src/EventBus.js | 2 +- ...leventyExtensionMap.js => ExtensionMap.js} | 8 +- src/FileSystemSearch.js | 2 +- src/{EleventyFiles.js => Files.js} | 12 +- src/GlobalDependencyMap.js | 2 +- src/LayoutCache.js | 2 +- src/Plugins/I18nPlugin.js | 4 +- src/Plugins/InputPathToUrl.js | 4 +- src/Plugins/Pagination.js | 6 +- src/Plugins/RenderPlugin.js | 22 +- ...CommonJs.cjs => RequireEsmFeatureTest.cjs} | 2 +- src/{EleventyServe.js => Serve.js} | 32 +- src/Template.js | 23 +- src/TemplateConfig.js | 34 +- src/TemplateContent.js | 25 +- src/TemplateLayout.js | 5 - src/TemplateMap.js | 12 +- src/TemplatePassthrough.js | 6 +- src/TemplatePassthroughManager.js | 14 +- src/TemplateRender.js | 6 +- src/TemplateWriter.js | 28 +- src/UserConfig.js | 6 +- src/Util/AsyncEventEmitter.js | 57 +- src/Util/Compatibility.js | 4 +- src/Util/ConsoleLogger.js | 2 +- src/Util/DateParse.js | 2 +- src/Util/EnvironmentVars.cjs | 14 + src/Util/EsmResolver.js | 2 +- src/Util/EsmResolverPortAdapter.js | 5 +- src/Util/EventBusUtil.js | 2 +- src/Util/FeatureTests.cjs | 22 - src/Util/FilePathUtil.js | 2 +- ...ystemManager.js => FileSystemUtilities.js} | 4 +- src/Util/GetJavaScriptData.js | 4 +- src/Util/HtmlRelativeCopy.js | 2 +- src/Util/ImportJsonSync.js | 12 +- src/Util/JavaScriptDependencies.js | 8 +- src/Util/Objects/ProxyWrap.js | 18 +- src/Util/ProjectTemplateFormats.js | 2 +- src/Util/Require.js | 16 +- src/Util/RequireUtils.core.js | 8 +- src/Util/RequireUtils.js | 7 +- src/Util/TemplateDepGraph.js | 2 +- src/Util/TransformsUtil.js | 8 +- src/Util/TypeScriptFeatureTest.cjs | 30 + ...ore.cjs => TypeScriptFeatureTest.core.cjs} | 0 src/Util/importer.core.js | 4 +- src/Watch.js | 2 +- src/WatchTargets.js | 2 +- src/defaultConfigExtended.client.js | 4 +- test/BundlePluginTest.js | 2 +- ...rsing.js => CoreTest-CustomDateParsing.js} | 2 +- ...yTest-PageData.js => CoreTest-PageData.js} | 2 +- ...rocessors.js => CoreTest-Preprocessors.js} | 2 +- ...t-Shortcodes.js => CoreTest-Shortcodes.js} | 2 +- ...esTest.js => CoreTest-VirtualTemplates.js} | 2 +- test/{EleventyTest.js => CoreTest.js} | 169 +++-- test/EleventyAddGlobalDataTest.js | 2 +- test/EleventyImgTransformTest.js | 2 +- test/EleventyMarkdownTest.js | 2 +- test/EleventyNunjucksTest.js | 2 +- ...rrorHandlerTest.js => ErrorHandlerTest.js} | 6 +- ...ventyErrorUtilTest.js => ErrorUtilTest.js} | 4 +- ...xtensionMapTest.js => ExtensionMapTest.js} | 4 +- ...js => FilesGitIgnoreEleventyIgnoreTest.js} | 0 test/{EleventyFilesTest.js => FilesTest.js} | 3 +- test/HtmlBasePluginTest.js | 2 +- test/HtmlRelativeCopyTest.js | 30 +- test/I18nPluginTest.js | 4 +- test/IdAttributePluginTest.js | 2 +- test/InputPathToUrlPluginTest.js | 2 +- test/Issue3467Test.js | 2 +- test/Issue3788Test.js | 2 +- test/Issue3797Test.js | 2 +- test/Issue3808Test.js | 11 +- test/Issue3816Test.js | 2 +- test/Issue3818Test.js | 2 +- test/Issue3823Test.js | 2 +- test/Issue3825Test.js | 2 +- test/Issue3831Test.js | 2 +- test/Issue3833Test.js | 2 +- test/Issue3850Test.js | 2 +- test/Issue3860Test.js | 2 +- test/Issue3870IncrementalTest.js | 4 +- test/Issue3870Test.js | 4 +- test/Issue3875Test.js | 2 +- test/Issue434Test.js | 2 +- test/Issue775Test.js | 2 +- test/JavaScriptFrontMatterTest.js | 2 +- test/PaginationTest.js | 16 +- test/PreserveClosingTagsPluginTest.js | 2 +- test/ReservedDataTest.js | 2 +- test/{EleventyServeTest.js => ServeTest.js} | 4 +- test/TemplateDataTest.js | 38 +- test/TemplateEngineManagerTest.js | 8 +- test/TemplateFileSlugTest.js | 4 +- test/TemplateLayoutPathResolverTest.js | 4 +- test/TemplateLayoutTest.js | 4 +- test/TemplateMapTest-ComputedData.js | 18 +- test/TemplateMapTest.js | 2 +- test/TemplatePassthroughManagerTest.js | 14 +- test/TemplateRenderCustomTest.js | 12 +- test/TemplateRenderHTMLTest.js | 4 +- test/TemplateRenderJavaScriptTest.js | 6 +- test/TemplateRenderLiquidTest.js | 6 +- test/TemplateRenderMarkdownPluginTest.js | 4 +- test/TemplateRenderMarkdownTest.js | 4 +- test/TemplateRenderNunjucksTest.js | 4 +- test/TemplateRenderPluginTest.js | 2 +- test/TemplateRenderTest.js | 4 +- test/TemplateTest-CompileOptions.js | 16 +- test/TemplateTest-ComputedData.js | 8 +- test/TemplateTest-CustomExtensions.js | 32 +- test/TemplateTest.js | 56 +- test/TemplateWriterTest.js | 8 +- test/UserDataExtensionsTest.js | 18 +- test/_getNewTemplateForTests.js | 4 +- test/_issues/2250/2250-test.js | 2 +- test/_issues/3697/3697-test.js | 2 +- test/_testHelpers.js | 10 +- test/stubs-3807/Issue3807test.js | 4 +- test/stubs-3810/eleventy.config.js | 2 +- .../3824-incremental/3824-incremental-test.js | 4 +- test_node/3824-incremental/eleventy.config.js | 10 +- test_node/3824/3824-test.js | 4 +- test_node/3824/eleventy.config.js | 10 +- test_node/jsx.test.js | 2 +- test_node/mdx.test.js | 2 +- tsconfig.json | 12 +- 173 files changed, 1544 insertions(+), 1530 deletions(-) create mode 100644 docs/ba-11ty-logo.png rename packages/browser/src/{BundleEleventy.js => BundleCoreFs.js} (92%) rename packages/browser/src/{BundleCore.js => BundleCoreMinimal.js} (50%) create mode 100644 packages/browser/test/client-core-fs.test.js delete mode 100644 packages/browser/test/client-eleventy.test.js create mode 100644 src/CoreFs.js delete mode 100644 src/Eleventy.js rename src/Errors/{EleventyBaseError.js => BaseError.js} (88%) rename src/Errors/{EleventyErrorHandler.js => ErrorHandler.js} (85%) rename src/Errors/{EleventyErrorUtil.js => ErrorUtil.js} (65%) rename src/{EleventyExtensionMap.js => ExtensionMap.js} (97%) rename src/{EleventyFiles.js => Files.js} (97%) rename src/{EleventyCommonJs.cjs => RequireEsmFeatureTest.cjs} (97%) rename src/{EleventyServe.js => Serve.js} (91%) create mode 100644 src/Util/EnvironmentVars.cjs delete mode 100644 src/Util/FeatureTests.cjs rename src/Util/{FileSystemManager.js => FileSystemUtilities.js} (93%) create mode 100644 src/Util/TypeScriptFeatureTest.cjs rename src/Util/{FeatureTests.core.cjs => TypeScriptFeatureTest.core.cjs} (100%) rename test/{EleventyTest-CustomDateParsing.js => CoreTest-CustomDateParsing.js} (99%) rename test/{EleventyTest-PageData.js => CoreTest-PageData.js} (98%) rename test/{EleventyTest-Preprocessors.js => CoreTest-Preprocessors.js} (99%) rename test/{EleventyTest-Shortcodes.js => CoreTest-Shortcodes.js} (92%) rename test/{EleventyVirtualTemplatesTest.js => CoreTest-VirtualTemplates.js} (99%) rename test/{EleventyTest.js => CoreTest.js} (91%) rename test/{EleventyErrorHandlerTest.js => ErrorHandlerTest.js} (85%) rename test/{EleventyErrorUtilTest.js => ErrorUtilTest.js} (94%) rename test/{EleventyExtensionMapTest.js => ExtensionMapTest.js} (98%) rename test/{EleventyFilesGitIgnoreEleventyIgnoreTest.js => FilesGitIgnoreEleventyIgnoreTest.js} (100%) rename test/{EleventyFilesTest.js => FilesTest.js} (99%) rename test/{EleventyServeTest.js => ServeTest.js} (95%) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 3ce54d182..0aa052214 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,10 +1,10 @@ contact_links: - - name: I have a question about Eleventy - url: https://github.com/11ty/eleventy/discussions/ - about: General education topics should be filed on our Discussions board e.g. “How do I do this in Eleventy?” or “Can Eleventy do this?” (Please search existing discussions first!) - - name: I have a feature request for Eleventy - url: https://github.com/11ty/eleventy/discussions/new?category=enhancement-queue - about: Enhancement or new Features. e.g. “I wish Eleventy did this.” Suggest an idea! (Please search existing discussions first!) + - name: I have a question + url: https://github.com/11ty/build-awesome/discussions/ + about: General education topics should be filed on our Discussions board e.g. “How do I do this?” or “Can I do this?” (Please search existing discussions first!) + - name: I have a feature request + url: https://github.com/11ty/build-awesome/discussions/new?category=enhancement-queue + about: Enhancement or new Features. Suggest an idea! (Please search existing discussions first!) - name: I wish the docs were different! url: https://github.com/11ty/11ty-website/issues/new/choose about: Something missing from the documentation? Something wrong? Something confusing? You want the 11ty-website repo! diff --git a/.github/ISSUE_TEMPLATE/possible-bug.yml b/.github/ISSUE_TEMPLATE/possible-bug.yml index bd00a9ffc..ef01a167c 100644 --- a/.github/ISSUE_TEMPLATE/possible-bug.yml +++ b/.github/ISSUE_TEMPLATE/possible-bug.yml @@ -1,4 +1,4 @@ -name: I’m having trouble with Eleventy +name: I’m having trouble with Build Awesome or Eleventy description: Have a problem? It might be a bug! Create a report to help us improve. labels: [needs-triage] body: @@ -22,8 +22,8 @@ body: id: eleventy attributes: label: Eleventy - description: Which version of Eleventy do you use? - placeholder: eleventy --version or npx @11ty/eleventy --version + description: Which version of Build Awesome or Eleventy do you use? + placeholder: npx @awesome.me/build --version or npx @11ty/eleventy --version validations: required: true - type: textarea diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b99bf0379..0a378c17d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: permissions: read-all jobs: release: - # see https://github.com/11ty/eleventy/settings/environments + # see https://github.com/11ty/build-awesome/settings/environments environment: GitHub Publish runs-on: ubuntu-latest permissions: diff --git a/.gitignore b/.gitignore index 6b7069445..daacd780e 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ api-docs/ .vscode .idea -# Ignore eleventy output when doing manual tests +# Ignore build output when doing manual tests _site/ # Ignore test files diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 318db5786..6f3ebd5e1 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,4 +1,4 @@ -# Eleventy Community Code of Conduct +# Build Awesome (Eleventy) Community Code of Conduct View the [Code of Conduct](https://www.11ty.dev/docs/code-of-conduct/) on 11ty.dev @@ -36,7 +36,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at eleventy@zachleat.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at maintainers@11ty.dev. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. diff --git a/README.md b/README.md index 0ba575976..6b3a612e5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -

eleventy Logo

+

Build Awesome (balloon) and 11ty Logo

-# eleventy 🕚⚡️🎈🐀 +# Build Awesome (Eleventy) 🕚⚡️🎈🐀 A simpler static site generator. An alternative to Jekyll. Written in JavaScript. Transforms a directory of templates (of varying types) into HTML. @@ -8,7 +8,7 @@ Works with HTML, Markdown, JavaScript, Liquid, Nunjucks, with addons for WebC, S ## ➡ [Documentation](https://www.11ty.dev/docs/) -- Star [this repo on GitHub](https://github.com/11ty/eleventy/)! +- Star [this repo on GitHub](https://github.com/11ty/build-awesome/)! - Follow us [on Mastodon `@11ty@neighborhood.11ty.dev`](https://neighborhood.11ty.dev/@11ty) - Follow us [on Bluesky `@11ty.dev`](https://bsky.app/profile/11ty.dev) - Install [from npm](https://www.npmjs.com/org/11ty) @@ -20,6 +20,9 @@ Works with HTML, Markdown, JavaScript, Liquid, Nunjucks, with addons for WebC, S ## Installation ``` +npm install @awesome.me/build --save-dev + +# Backwards compatible here too: npm install @11ty/eleventy --save-dev ``` @@ -35,18 +38,18 @@ We have a few test suites, for various reasons: - [ava JavaScript test runner](https://github.com/avajs/ava) ([assertions docs](https://github.com/avajs/ava/blob/main/docs/03-assertions.md)) (primary test suite in `test/`) - [Node.js Test runner](https://nodejs.org/api/test.html) (secondary test suite in `test_node/`) -- [Vitest (in Browser Mode)](https://vitest.dev/guide/browser/) (client tests in `packages/browser/test/`) -- [Benchmark for Performance Regressions](https://github.com/11ty/eleventy-benchmark) +- [Vitest (in Browser Mode)](https://vitest.dev/guide/browser/) (browser tests in `packages/browser/test/`) +- [Benchmark for Performance Regressions](https://github.com/11ty/build-benchmark) These run in various environments: -- [Continuous Integration on GitHub Actions](https://github.com/11ty/eleventy/actions/workflows/ci.yml) -- [Code Coverage Statistics](https://github.com/11ty/eleventy/blob/master/docs/coverage.md) +- [Continuous Integration on GitHub Actions](https://github.com/11ty/build-awesome/actions/workflows/ci.yml) +- [Code Coverage Statistics](https://github.com/11ty/build-awesome/blob/master/docs/coverage.md) ## Community Roadmap -- [Top Feature Requests](https://github.com/11ty/eleventy/discussions/categories/enhancement-queue?discussions_q=is%3Aopen+category%3A%22Enhancement+Queue%22+sort%3Atop) (Vote for your favorites!) -- [Top Bugs 😱](https://github.com/11ty/eleventy/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions) (Add your own votes using the 👍 reaction) +- [Top Feature Requests](https://github.com/11ty/build-awesome/discussions/categories/enhancement-queue?discussions_q=is%3Aopen+category%3A%22Enhancement+Queue%22+sort%3Atop) (Vote for your favorites!) +- [Top Bugs 😱](https://github.com/11ty/build-awesome/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions) (Add your own votes using the 👍 reaction) ## Plugins diff --git a/SECURITY.md b/SECURITY.md index 0947081a6..e31fa3d67 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,7 +2,7 @@ ## Reporting a Vulnerability -Privately report a security issue by navigating to https://github.com/11ty/eleventy/security and using the “Report a vulnerability” button. +Privately report a security issue by navigating to https://github.com/11ty/build-awesome/security and using the “Report a vulnerability” button. Read more at: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability diff --git a/cmd.cjs b/cmd.cjs index 654ecdb50..53d5521eb 100755 --- a/cmd.cjs +++ b/cmd.cjs @@ -7,11 +7,11 @@ const pkg = require("./package.json"); require("@11ty/node-version-check")(pkg, { message: function (requiredVersion) { return ( - "Eleventy " + + "Build Awesome (Eleventy) " + pkg.version + " requires Node " + requiredVersion + - ". You will need to upgrade Node to use Eleventy!" + ". You will need to upgrade Node!" ); }, }); @@ -27,18 +27,19 @@ class SimpleError extends Error { async function exec() { const { createDebug } = await import("obug"); - const debug = createDebug("Eleventy:cmd"); + const debug = createDebug("BuildAwesome:CLI"); - // Notes about friendly error messaging with outdated Node versions: https://github.com/11ty/eleventy/issues/3761 - const { EleventyErrorHandler } = await import("./src/Errors/EleventyErrorHandler.js"); + // Notes about friendly error messaging with outdated Node versions: https://github.com/11ty/build-awesome/issues/3761 + const { ErrorHandler } = await import("./src/Errors/ErrorHandler.js"); + const { getEnvValue } = await import("./src/Util/EnvironmentVars.cjs"); // Defensive use of Node 22.8+ Module Compile Cache - if(!process.env?.ELEVENTY_SKIP_NODE_COMPILE_CACHE) { + if(!getEnvValue("SKIP_NODE_COMPILE_CACHE")) { try { const nodeMod = await import('node:module').then(mod => mod.default); nodeMod.enableCompileCache?.(); } catch(e) { - debug("Node compile cache error (optional API) %o", e); + debug("Node compile cache error (ignored: optional API) %o", e); } } @@ -66,30 +67,30 @@ async function exec() { }, }); - debug("command: eleventy %o", argv); - const { Eleventy } = await import("./src/Eleventy.js"); + debug("Arguments: %o", argv); + const { default: Core } = await import("./src/Core.js"); - let ErrorHandler = new EleventyErrorHandler(); + let handler = new ErrorHandler(); process.on("unhandledRejection", (error, promise) => { - ErrorHandler.fatal(error, "Unhandled rejection in promise"); + handler.fatal(error, "Unhandled rejection in promise"); }); process.on("uncaughtException", (error) => { - ErrorHandler.fatal(error, "Uncaught exception"); + handler.fatal(error, "Uncaught exception"); }); process.on("rejectionHandled", (promise) => { - ErrorHandler.warn(promise, "A promise rejection was handled asynchronously"); + handler.warn(promise, "A promise rejection was handled asynchronously"); }); if (argv.version) { - console.log(Eleventy.getVersion()); + console.log(Core.getVersion()); return; } else if (argv.help) { - console.log(Eleventy.getHelp()); + console.log(Core.getHelp()); return; } - let elev = new Eleventy(argv.input, argv.output, { + let core = new Core(argv.input, argv.output, { source: "cli", // --quiet and --quiet=true both resolve to true quietMode: argv.quiet, @@ -100,29 +101,29 @@ async function exec() { loader: argv.loader, }); - // reuse ErrorHandler instance in Eleventy - ErrorHandler = elev.errorHandler; + // reuse ErrorHandler instance in Core + handler = core.errorHandler; // Before init - elev.setFormats(argv.formats); + core.setFormats(argv.formats); - await elev.init(); + await core.init(); if (argv.to === "json") { // override logging output - elev.setIsVerbose(false); + core.setIsVerbose(false); } // Only relevant for watch/serve - elev.setIgnoreInitial(argv["ignore-initial"]); + core.setIgnoreInitial(argv["ignore-initial"]); // v4.0.0-alpha.8 multiple now supported via: // --incremental=one.md --incremental=two.md => ["one.md", "two.md"] // --incremental=one.md,two.md => ["one.md", "two.md"] if(argv.incremental) { - elev.setIncrementalFiles(argv.incremental); + core.setIncrementalFiles(argv.incremental); } else if(argv.incremental !== undefined) { - elev.setIncrementalBuild(argv.incremental === "" || argv.incremental); + core.setIncrementalBuild(argv.incremental === "" || argv.incremental); } if (argv.serve || argv.watch) { @@ -130,25 +131,25 @@ async function exec() { throw new SimpleError("--to=json is not compatible with --serve or --watch."); } - await elev.watch(); + await core.watch(); if (argv.serve) { // TODO await here? - elev.serve(argv.port); + core.serve(argv.port); } process.on("SIGINT", async () => { - elev.interrupt(); + core.interrupt(); - await elev.stopWatch(); + await core.stopWatch(); process.exitCode = 0; }); } else { // `fs:templates` will skip passthrough copy if (!argv.to || argv.to === "fs" || argv.to.startsWith("fs:")) { - await elev.write(argv.to); + await core.write(argv.to); } else if (argv.to === "json") { - let result = await elev.toJSON() + let result = await core.toJSON() console.log(JSON.stringify(result, null, 2)); } else { throw new SimpleError( @@ -157,9 +158,9 @@ async function exec() { } } } catch (error) { - if(typeof EleventyErrorHandler !== "undefined") { - let ErrorHandler = new EleventyErrorHandler(); - ErrorHandler.fatal(error, "Eleventy Fatal Error (CLI)"); + if(typeof ErrorHandler !== "undefined") { + let handler = new ErrorHandler(); + handler.fatal(error, "Fatal Error (CLI)"); } else { console.error(error); process.exitCode = 1; diff --git a/docs/ba-11ty-logo.png b/docs/ba-11ty-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..156568d84bf1e8d970bd5cde7897c962c2749e75 GIT binary patch literal 11602 zcmeHtg+o-|w(tOhgc1^>bO_P|0}?|^w~|A54BgET5=w(Glz@VObay!@T}lc{DV@^N z-{I%)zI)$&_x%OmJ8`hhP#IR6Hxgu^*ZpSzzVKtt*Q!Q2imxxTNorDtQ!#E4}?Jp!v3ob0_k8-{a4!< zgY|D1fF=en=!P;ma9c+rK;XaO1Aynvr2yOjr9aQ72p=m4M>7v+H~Ob;&h&iTg512o z7}gt%f6n;^^B*)Y65e3_vkkz3pkJ#dfd`(8f}T4Fber_%#sFo!z7NoFLTJG~;HoMx z3ui}eGfQW4D{dc0mm4gQs1FQiI$C*{(fc?$IJv`o#2EjAfC25BZU`g&Umza#VvKOr zr}Wa!ZdUXH+&tVojNW zEDYg+LZDDC0D{Zi*U7`ohs(*G=?{^A(2=onw{Szacp#je=x^wnnLB%Wh%qwWO!QyZ zpLJUKApSX%ll$Ln0SrQJMj*W0Jdpo{1~B_y>-%q5K4vceE0PDo`hS`0X5~S?9LfU~;Nsx}{&nWK7-)ej#gzxlQA^D)?10r#QwCre4v2+0MhR#OM8?pqEGQ^%v{?XxHL zg8Wk_*#Jm zT?#V#1tm!tyTjbLs@o#nx(%ug0*$B><2TjL?~Z>>H+%bU5FKjWiS@5g=p%U;Y?@;F zIncwmxXjh^XMZ9A2Mem3!=3Mzhhzu&18Zz0*b-$}yl&ZF3CBoY4c7qxnXp<>melS&adN&!*2nP&@O-@^R5O zW@3Os`F�hOmfaoI5oIEJ11V*(p>$X7(6dTR3};m^v{|G0Oro7P+i?dlj@d@1h8v zXEyiu^PT$oA#;WVoc$|~B<7OCjr?FQbgM`tE6uw~s`gZ-Kd0D_%+)`e46xhEud%N_ ztKFVI;ola5qdd7Ki_5_5`UYdC4|;Xp$Q|0-x&ACFGq_b>I-sL{f6*oT)sN$~v*n-m zspGUT1N7*rC`>0vwz8D4LUT2u+;Hq5eyX=3L@k{qzwc~fv1C%~PW;sCHNigT00Jox z8Xse%wz#@^V_d>vr(<#Sl;TpweI9MH{^CyElKk^CtVhfFvXLYYrvaX-IkLO_`Rd-S zf0`BSwb0sQELc(Da-?l?kiBdvWS8@;nHi_|JETJIGd2fzT+a!2=Pj#pm=T_tdUGT1&4^O&ARf4e6lb11z<>eucFrq-74* zse*|)GjrEJr?yi~ognw~tR6_C^n?#TsB5tB`5|od1Pr{_Vsh+~AOA6Gm_jq>FJt%X zRfD7CbRX>Mvw!Ss_Evu|d;7IFAXviYRSd3bW#V2h3B>m1Bljk@ZBaoEx5gza@8D{H zD3%o~!96-nZ)9qG1O~Cqdme{c$y1MPb}g)wH~E$%UH8^3ey`Rz_NiP`ldR;#Uui1u z#gEW5`TBa0)4!`%M*I3bf62!cy|@rEN=A68r%RZHIU__O^L|~fxH`9^_?5cgP(=%K>tQ?Gb`pOLWsU71A1GOju?jwnj#$7}@bF#bYg%s^2>T=`yamRjnDgDVP*0b8Za^^4DSS$HP zQ_%f(v*pk5A=hJ17ukHzkV7KM&y?{D!+pONRmLT5_umcKR^Lq`ZMcBi25kRILsh_U z=gvI05gO@qmaJo!@Xi*ZtHHDER|~r8x3!6rDb%?fvB7+wl8`KzaJ0ns0<5KnXnpt2 z2Dj5c+%()Kts2|6!PhC#Qid-5smcD*aa@maBH!}!bWRAAnQl@7L_gE1h_2b(Q-R4$tpV)Vt9A1^+5 zOR=<7nt&XDSF8?mO)G7y|LC(^`Mk%Q0QhFp&%;fkRd#!8%vpo7k204v2cW3emVEg0x*&=nS%JRO1DqBBUb>DFl& zQ2Nr;5hVT24kH6(c>K%cUb~wa7y~@;f@fKT4I(@s4n8ds?-;<3h?6%#Vdsi(4w0ue zu?t6f{&v>QJde%^x4`c`(kkU@*XhWWv7T>#`EstF_`*nGTcXz?Fim$jeERESUc{IoA))vSI_b zyXz%(2(M&HZ7NESqZGXlIzB?x$ElZ>5K-VS$P6o z-?%h`iAz0BaS%oV*0>s6g=*jEyiRARm5j^9kJSZZ4GWHyiA07Wc+-K$ifiA}ms1e_;rd6gbbljt}yTeZT||C+(X%TD5S zzC5R_>LN8gLBZno;|LnSQ4l_@RZW^uXUH+pH~zX>ESdW#V%c_ ztMe8(x{ZdiWRP+^ag5XmT6mXQuEym=-E1D4nuJQhdpQNAobkdzj|%Xg#;J1Ot~1tB zYwT}WI}H4l;Ymp=xVwb-gkac{+ag$r0s_vc;4cv2K@%;jYum2Ma{*{IhIC)M0mZEf zq+oO%Edvm$>Y!Y29oLzE8fzNbw@6pr6*%vFJmIw3BHvEGW^x}rDj~NjI+&~q!EbN; zl6NQ8-q+k6dN;!fu@Ez1`7{!NjmDRTG&PT@dQSH*pp$Yw6i`ewHH-Kmz?q*~>T_){ z&>~|?aSH0I$~`3uL0I`86(Y0yXWl0`-7yY)I}>`R;z|2SUVTN-j)!gU*~u3VqPv`Y zjQ5e7havWmY`C6>Sr}(4?D9l64b3P3u_>ENW)yIENhw!J(nZtA8~^Gl{`r2d`wxyO z;r8c@H5QL{uHb2kfwC>PtcJ$j!`gNhs{>YvXZQS%AxUD!GDk9LmVN#|%RjnNzvT=_ zZQ}B^adFYqtyel9Qx~hjH{>Dd4KXOprNG2RQ7EmazWnuqa(ex1|4`gV9JVLDi&^MU zCJb6Unkw7W`}^Z~+h=)&(hSJRi5lr+-*D4u3Qa$<1W8ml9HWm}mjJC4=b46rj`5il zYfjz9p!a{9?DXJ9^o$Ko8u?;$-ILuJ6Vi`sFXJ?|M@bliO_{+kOFr_vR}5TFXHz7* z?k5;AORJ(>GMkfl7QJ~Ja+KRoX}UyAfj=0~zJl?Xvh$>VOe zAq`xejKj7DE-HOrh)SO+IG8%dAgPYH^dSPrnS<}~Pb-}E1%l)NRWwI}GVSvn5HaU0 zQ|&^|327!pvCCo>$fvDFsp?^93S&T!>cF?4EB2=|L>Rx$-lpj5fjJ%@BB{#7zw9>P zFSn7t7bi5{t<~UoX__A~=lroQa^$S+iSI7ht_8iBrDMl@w{-mTxntwTR%K7k!wda_ z)?o5hm(PF9zW8C~aoZRja*-W|85|pD)rul6^*NQZZ@bFMwk0rk%m$gNHjxr@YBD}v zwV6e#_Y7r@Gm8aam(seroM58eY~HEA>_=B+#7ao`$#=n=zhrgFd)^LDB~e+@2@LO-dzgFpGYWIxo2rh{CLfOc+&?I)h9GgzKh${)1^gog*zt>UWD{?V}LCykln%xDp4bPybZfR z3tsKU2frZ=zS?-Ij|GV5Eh*fMC!6lhyf)OJY)MiN40a7>Phede47fXzR`UvD0tK;w zSY)=L!`_eCZ6!hIQF>ekL)$>4iM1OnEF`Ify%DV6=lKmq$ON~RuQs<0*mHNzn2oe- zqcFtenifECK>=!(tYgsei_wq`TEg+YFcV2UZgp9Eob4RhJZ}>!DrYP%Gq}f&L}QtOA-yhc(65fy6R^bbOk|thWFXo31#a^jkAmjV+;$ ze9<*1Uk)iP(Hv?%fM4rReG>!wRekyDPTpKP)z~QUDpleXhm*2(p-?MT)`1PeLr%Z+ z2Ud~6`1eA7CP*bAfM9iuvEa~qkI%nEoq#<$*{}d~my>zQQCTF$RFC}Y;Njq?Nk>L{ zMpdyc1B{7vC0GUPAy_7>m=O+>Wx_WpRwv{udRN~IJo8^WR}jI%MR_s2>}Qz1ZaB!f*5K85i;jOc;7&uA{vzt3 z*C7Lt@R3HZi50>4YPU?TG&CeAm2C0{M)%eb=Fk2d_lvRc45l`k_%;ppmW~nY{F>2a zp_k?&s+bo_X)KqPGvzQoLt!C-W~484DF15|r@8I-kLdSoa`eXqcT2zC-TW*$^b)!G zSb02(i^HRF+WZIu9YtOt*KHqnqDvSv0~^-gU-BAP%4^{g&?PSY`gy~~$LTe5h9?m8 zv*hJ?ONsScKQO?yvN09|545I*@4@+%3u;%o^_B%}QPf}S4)+{YTbe)eye*dkPUU$h zd2Gpq*z;=X^|grQ>Ha8N&H~H)0CT%(CWzpcNTS9$eG;CdDQug(kkdE}#?t=JeIQ_8>9U_n`ZcfN~TQ90i8L z1uaMQyY;F&X5mvBSV-9GA#S9X^Z8gs^f&aGGS?WOt_AWunAcW>?Z*ncUu9{g?E(vH z*&}*VFXweLj76xWB6-a?fw1oDXW0!O?cEo)=<%eLqT>Pu0(py4U6EioNKmNI%tPd5uXvl*|a4qmDpyGXY7!@-px-nM-#8IxL#fbrwu8!(8RYJehZw8 z??~pt!%QzPFHc%y&AOvx>V|ONElYh=GbDX!&||fTX@kBMn{s(X%z17>tw_`Zu@wpI z(cZg^V9lh2_?nC46)S{VRoyj0-l@J{MPpPVJVUh^fV!W`vSlg@`N0IJde0>L027t2 zDx^5NLfPCf{t_qY+^h;NjyND2(G$gnZf)hwr@J6d>7yKx#y z2kdG(RQG2KWw8Nch*3CRBgbtb-1c7F7k_NXbJSyhdo=e7IMhpv&I1xDA%|OCsLfzEeS_^MZiWwIVpu6H~h3^Y5Tdw_kgBebb_9+ z(S;TRyeUc@5CQ^w`~$mWi;69Cs9*){;5CdPPAmlYRZnrE_CQI=;qY>ifR*RYiq|F? z_i&P&QjTi@tBat^1*)f~BMqZ=qFn`J8_;b(z~=bA)ylQnm=mj8%fIaNMt)JodAGjw zEnoH$&&4k8idSju(VS_5foZlbR9^T-_g& z#)V4*()@RyWaU;ouUJ^{V_?(lpD4=Hn@Rxs_5TT2h|+nB0+A;3Q$4-Y%iW;s=FRef z1M`4@3p5Vh#kO-$X6mpmE-S8Ob8|DFMcA=k}(SmT$bN zGPqe8c+v`}fjb=G&OQKpH7Z z-yN{MwM7<7B9$1VTMB=+=B=%r67v#yHkNbGnq2wrDRCmnb4HELsR|R~qVM~vE(yxzIc4PCN91TfRerP_cJZW; z74ow}WT(;MXLqcz4Et2vjDu4ju;bq=!lz;?@zWD>>EATJC7W^Z+j|1)IAG3-ey`5ziOx$u|8TO&G{{}WXBBNX=j&&5_e<5{M~9?>zs)^D>LPAY4@Jvxx%r@&U@)Ju>-0z{IBCEi^Uu z%b_{3ns3pYx{IptV!ML@E|J*{vCQr=T&+|}7M~?l0+Mwl?jk=;O-)yR=5Nos%mhXX zHgP!~%nlwzRjdGO@ra+zxjHOdUtc$bL`FuoNhB}p47Od(?jlpqwJrC06PcRW5)GN) ziKd@=F)@sX^d#S|cU4*RATNH>1?@$fi25C_aa6SKZ5_kGs{Qenl z;(Ui&c2P~qnDm{3r;>i=1cVU2q3V)mWboSbPht$!6kB@Ku zeC{N-PS1A8lQ3Go^NH;{R@`3-?}IG@bbddQmj}-cF~Z|Oig$oQHGWK7)DGAXdtesK zOrHSQnf?&7;rtU`wdO!Ka!y*jF@glwGA4L;_~64xBkX~9!wV(10BIr!HLbYKX-vt_2dD(FI{Y3l=WPsFv%5Q@tQ(Nx&TnUDcMo4- z-fBH)f$7V=Etk83Ks@Bs+5PoI+=+dX`Lrf=Y}L7Wy}%qBe@wz_M>7q1yfrPd+j@}Y zJ=ZsMb~+M-9N=nLD&RC!S5rftf1AGoEJsH|ZsYH>sgA2y=YYJ*4}u-1L#-4b{DFid zZXjlS>T1r4A@WNF1 zp0ah0e@}tpp#q>Yxcyh=H@LX=VQEX?ZbSR>%+CW%*{{P;23>n+Kk2T0coANr@snS0 zUm}3=$tWXTu~GbwA5~vlIok0>{7h7Esc*NitPBN_t0Bns8@H+l@JSCe$ZSMdYM#qx zO9UJN46&%gc0ryv>1iARPaKw*3%b(H}w z7l!v}{tjhw< z@Ji8WDPgstibu)n*`UxAQFr}2vZlZ}ZJYt`0T)v!i^Q97flQB8Rvj~@(@-7`eYV_~ z+G-vaZkq0PzyL3hVfT{2vW=W6>?If$YzVqW`i5%qbG_P(i>4wA?NSfJ&(^nM0E!`4 zHsA4j*}0|)pY$x};iJvNmWPevNpMlLt}l9`)4GLdhx|D2z1b|^T_aPo=u`Uz_%#m) z<$81y*Afj-kB$X|!9eC$PZp3WC%r7&cUx^SGS*K%fP6Q|54#0^E&V>kqR~_|y5s4>g%ek2u2iCgKDvHtKkY;d_=)Z3iD_tNUhL!O&$)G?ZCG>LLaa^Ycq- zkGT{Kr717go0N4CMWYTef0RS5Y)A>5FO*)P@jd+;<5=d++348H`^IeV?J_;*vZZGH zURn^d%1MfKlGMR`_upB}w)vmH3SPbclk?-uf5)R1c6(P?SO{;5ii!djFSG*fbo-R+ z%NUyP8|*TY6?|6olz-q0SmG|s{EO&a^r)z$b;~Mj*VrM)(_~ghf*h8SguNplPwP3z z_{;{V;|zbn+srI62HVp=si{tN<)L%4FOr8hF;kQ;`|@-ebEYjbIsqZT_b}y|_SbLn zcY@}g-QDQya&xM)=Z)X(Pe_xKcbSYi_b1vHfq&#$DbhO%Iee{=1 zfT~3w%g#R8gZ5{f4}q*xDccv!Wet4*(b1TyBYmXSc-Dj%W0``MV=vux_V5_5`x<~T zEgPMeEml2RcK=3~L{DEellbmem#Va(=UNlX3>y4u3s_k&Yu#7XWJA7lX5+Xc(mZ2L z)5$AN+Kz-emD-$Jym!5h7J*pdYO)( zv}j^#swC@bL$~8BeI!6`C8eOCfaTGnWs}q1q!%XFXH#=sT`i`(of?tStA>AU;!v{u z6JHJgtJ779(?0ck+kH3>21WwKe;;36JGUK8esk_M28xsi0xU)cR>wt!+54*=Y6#)W!?Bzz54F$@4dnSjt_%(lt%uQY zv0X%~7T`6CeoPg)nn0Ik_av@QN06y+S1C{G$mRx;(@$&$4Fww~|G1!1PwAC+I~~_o zmd%CYt;jhXFh@H4(>Q)8Iq6rQp>AGE4LT*t0*QFh{THc`bv&wrQ?iwveB<9SZ-nmk z?5k7C)fnO;*RQX=tsq^nXbtDuD{qcpvS82A&BC@CR zpv$sf+CkjP_f zZ0z8=KfIQi>cMJL;g!CoCX>w~YrRqXYPP>9q1psNV&**zo#sMWafg=u$Zc3J{^y7^ z8fxl0PkG_w>Cd8EG!)4U-|GB$JHMx2srHOR98;8}yXW43BI)m5dGTCZjYA_b=8E^q zsDA_`SGc`~+KagR0!_A0Xjw3IDP5xHRObK zD-jeQMl1D9g$Z-YB&f~A**NIZbG#qIPcXm)r@V!oYKU8^U)P^6BX#^UUcxv*E)+=4 zI1kJtda7ZA6k&^tixL-$MD4{-;p%{e%63I_kYjX&9xc66_mj|+pWyLD0M(k&IMDX_ zqXp&4?(S|{zcq&I*r(F+0C?Op^rOcZ)9pq^^n$v^4PJo=-UiVr7=UqOxP?i7qlu98 z5GvSeR?gXvXo&dPTHb2m-jFGPibiwjO<7%!w(PbW)Wz|NF)hVTK+C?G`0m8J#Lzaa+{sl;XB4$uVN+Z3%O;9%g|0`co8 zJGBrN2JU;HV8jkvk^*7=anJup^8fboKL}CCHBkWZ?xSSOHtw6B4J*p3$&^1a4gG(3 C9B_jG literal 0 HcmV?d00001 diff --git a/docs/coverage.njk b/docs/coverage.njk index f2aa72313..254cd9468 100644 --- a/docs/coverage.njk +++ b/docs/coverage.njk @@ -1,7 +1,7 @@ --- permalink: coverage.md --- -# Code Coverage for Eleventy v{{ pkg.version }} +# Code Coverage for Build Awesome v{{ pkg.version }} | Filename | % Lines | % Statements | % Functions | % Branches | | --- | --- | --- | --- | --- | diff --git a/docs/eleventy.coverage.js b/docs/eleventy.coverage.js index ae7cd17a9..0e170b893 100644 --- a/docs/eleventy.coverage.js +++ b/docs/eleventy.coverage.js @@ -4,8 +4,8 @@ import { TemplatePath } from "@11ty/eleventy-utils"; const __dirname = dirname(fileURLToPath(import.meta.url)); -export default function (eleventyConfig) { - eleventyConfig.addFilter("removeDir", function (str) { +export default function (config) { + config.addFilter("removeDir", function (str) { return TemplatePath.stripLeadingSubPath(str, TemplatePath.join(__dirname, "..")); }); diff --git a/docs/release-instructions.md b/docs/release-instructions.md index 88054a3f6..e45c3c7ff 100644 --- a/docs/release-instructions.md +++ b/docs/release-instructions.md @@ -26,11 +26,11 @@ 1. Check it all in and commit 1. Tag new version 1. Wait for GitHub Actions to complete to know that the build did not fail. -1. Publish a release on GitHub at https://github.com/11ty/eleventy/releases pointing to the tag of the release. Hitting the publish button on this workflow will use GitHub Actions to publish the package to npm on the correct dist-tag and includes npm package provenance for the release. +1. Publish a release on GitHub at https://github.com/11ty/build-awesome/releases pointing to the tag of the release. Hitting the publish button on this workflow will use GitHub Actions to publish the package to npm on the correct dist-tag and includes npm package provenance for the release. - Main release: no version suffix publishes to `latest` (default) tag on npm - Make sure to include OpenCollective usernames for release notes here https://www.11ty.dev/supporters-for-release-notes/ -- Canary release: `-alpha.` version suffix in `package.json` publishes to `canary` tag on npm: https://github.com/11ty/eleventy/issues/2758 +- Canary release: `-alpha.` version suffix in `package.json` publishes to `canary` tag on npm: https://github.com/11ty/build-awesome/issues/2758 - Beta release: `-beta.` version suffix publishes to `beta` tag on npm Unfortunate note about npm and tags (specifically `canary` here): if you push a 1.0.0-canary.x to `canary` (even though `2.0.0-canary.x` exists), it will use the last pushed tag when you npm install from `@canary` (not the highest version number) diff --git a/package.json b/package.json index 2c485cc3d..bc01c8207 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,11 @@ "provenance": true }, "type": "module", - "main": "./src/Eleventy.js", + "main": "./src/Core.js", "exports": { ".": { - "import": "./src/Eleventy.js", - "require": "./src/EleventyCommonJs.cjs" + "import": "./src/Core.js", + "require": "./src/RequireEsmFeatureTest.cjs" }, "./UserConfig": { "types": "./src/UserConfig.js" @@ -67,9 +67,9 @@ "author": "Zach Leatherman (https://zachleat.com/)", "repository": { "type": "git", - "url": "git+https://github.com/11ty/eleventy.git" + "url": "git+https://github.com/11ty/build-awesome.git" }, - "bugs": "https://github.com/11ty/eleventy/issues", + "bugs": "https://github.com/11ty/build-awesome/issues", "homepage": "https://www.11ty.dev/", "ava": { "environmentVariables": {}, diff --git a/packages/browser/README.md b/packages/browser/README.md index e8e21c338..52637b5c7 100644 --- a/packages/browser/README.md +++ b/packages/browser/README.md @@ -6,7 +6,7 @@ The client (browser-friendly) version of `@11ty/eleventy` Eleventy, a simpler st ## ➡ [Documentation](https://www.11ty.dev/docs/) -- Star [this repo on GitHub](https://github.com/11ty/eleventy/)! +- Star [this repo on GitHub](https://github.com/11ty/build-awesome/)! - Follow us [on Mastodon `@11ty@neighborhood.11ty.dev`](https://neighborhood.11ty.dev/@11ty) - Follow us [on Bluesky `@11ty.dev`](https://bsky.app/profile/11ty.dev) - Install [from npm](https://www.npmjs.com/org/11ty) diff --git a/packages/browser/generate-bundle.js b/packages/browser/generate-bundle.js index f099124df..94ca86348 100644 --- a/packages/browser/generate-bundle.js +++ b/packages/browser/generate-bundle.js @@ -11,8 +11,8 @@ function size(filepath) { return readableFileSize(fs.statSync(filepath).size); } -await bundleClient("./src/BundleCore.js", "./dist/eleventy.core.js", { - name: `Eleventy v${pkg.version} (@11ty/client Bundle)`, +await bundleClient("./src/BundleCoreMinimal.js", "./dist/core-minimal.js", { + name: `Eleventy (Build Awesome) v${pkg.version} (@11ty/client Bundle)`, moduleRoot: "../../", // No core-bundled plugins, reduced feature set adapterSuffixes: [".client.js", ".core.js", ".core.cjs"], @@ -23,69 +23,49 @@ await bundleClient("./src/BundleCore.js", "./dist/eleventy.core.js", { }, }); -console.log(`${PREFIX}Wrote dist/eleventy.core.js: ${size("./dist/eleventy.core.js")}`); +console.log(`${PREFIX}Wrote dist/core-minimal.js: ${size("./dist/core-minimal.js")}`); // Careful, this one is big! -await bundleClient("./src/BundleEleventy.js", `./dist/eleventy.js`, { - name: `Eleventy v${pkg.version} (@11ty/client/eleventy Bundle)`, +await bundleClient("./src/BundleCoreFs.js", `./dist/core-fs.js`, { + name: `Eleventy (Build Awesome) v${pkg.version} (@11ty/client/core-fs Bundle)`, moduleRoot: "../../", adapterSuffixes: [".core.js", ".core.cjs"], // Adds named export FileSystem for using the file system in other packages fileSystemMode: "publish", }); -console.log(`${PREFIX}Wrote dist/eleventy.js: ${size("./dist/eleventy.js")}`); +console.log(`${PREFIX}Wrote dist/core-fs.js: ${size("./dist/core-fs.js")}`); // fs.mkdirSync("./visualize/", { recursive: true }); // fs.writeFileSync("./visualize/meta.json", JSON.stringify(result.metafile)); // npx esbuild-visualizer --metadata ./packages/browser/visualize/meta.json --filename packages/browser/visualize/index.html -await bundleClient( - import.meta.resolve("./src/BundleLiquid.js"), - `./dist/formats/eleventy-liquid.js`, - { - name: `Eleventy v${pkg.version} (@11ty/client/liquid Engine Bundle)`, - moduleRoot: "../../", - adapterSuffixes: [".core.js", ".core.cjs"], - }, -); -console.log( - `${PREFIX}Wrote dist/formats/eleventy-liquid.js: ${size("./dist/formats/eleventy-liquid.js")}`, -); +await bundleClient(import.meta.resolve("./src/BundleLiquid.js"), `./dist/formats/liquid.js`, { + name: `Eleventy (Build Awesome) v${pkg.version} (@11ty/client/liquid Engine Bundle)`, + moduleRoot: "../../", + adapterSuffixes: [".core.js", ".core.cjs"], +}); +console.log(`${PREFIX}Wrote dist/formats/liquid.js: ${size("./dist/formats/liquid.js")}`); -await bundleClient( - import.meta.resolve("./src/BundleNunjucks.js"), - `./dist/formats/eleventy-nunjucks.js`, - { - name: `Eleventy v${pkg.version} (@11ty/client/njk Engine Bundle)`, - moduleRoot: "../../", - }, -); -console.log( - `${PREFIX}Wrote dist/formats/eleventy-nunjucks.js: ${size("./dist/formats/eleventy-nunjucks.js")}`, -); +await bundleClient(import.meta.resolve("./src/BundleNunjucks.js"), `./dist/formats/nunjucks.js`, { + name: `Eleventy (Build Awesome) v${pkg.version} (@11ty/client/njk Engine Bundle)`, + moduleRoot: "../../", +}); +console.log(`${PREFIX}Wrote dist/formats/nunjucks.js: ${size("./dist/formats/nunjucks.js")}`); -await bundleClient( - import.meta.resolve("./src/BundleMarkdown.js"), - `./dist/formats/eleventy-markdown.js`, - { - name: `Eleventy v${pkg.version} (@11ty/client/md Engine Bundle)`, - moduleRoot: "../../", - adapterSuffixes: [".core.js", ".core.cjs"], - }, -); -console.log( - `${PREFIX}Wrote dist/formats/eleventy-markdown.js: ${size("./dist/formats/eleventy-markdown.js")}`, -); +await bundleClient(import.meta.resolve("./src/BundleMarkdown.js"), `./dist/formats/markdown.js`, { + name: `Eleventy (Build Awesome) v${pkg.version} (@11ty/client/md Engine Bundle)`, + moduleRoot: "../../", + adapterSuffixes: [".core.js", ".core.cjs"], +}); +console.log(`${PREFIX}Wrote dist/formats/markdown.js: ${size("./dist/formats/markdown.js")}`); await bundleClient( import.meta.resolve("./src/BundleI18nPlugin.js"), - `./dist/plugins/eleventy-plugin-i18n.js`, + `./dist/plugins/plugin-i18n.js`, { - name: `Eleventy v${pkg.version} (i18n Plugin)`, + name: `Eleventy (Build Awesome) v${pkg.version} (i18n Plugin)`, moduleRoot: "../../", adapterSuffixes: [".core.js", ".core.cjs"], }, ); -console.log( - `${PREFIX}Wrote dist/plugins/eleventy-plugin-i18n.js: ${size("./dist/plugins/eleventy-plugin-i18n.js")}`, -); +console.log(`${PREFIX}Wrote dist/plugins/plugin-i18n.js: ${size("./dist/plugins/plugin-i18n.js")}`); diff --git a/packages/browser/package.json b/packages/browser/package.json index 19848ac8e..0b42b32f6 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -1,6 +1,6 @@ { "name": "@11ty/client", - "description": "Run Eleventy in your browser.", + "description": "Run Build Awesome (Eleventy) in your browser.", "version": "PRIVATE", "private": true, "publishConfig": { @@ -8,14 +8,14 @@ "provenance": true }, "type": "module", - "main": "./dist/eleventy.core.js", + "main": "./dist/core-minimal.js", "exports": { - ".": "./dist/eleventy.core.js", - "./eleventy": "./dist/eleventy.js", - "./liquid": "./dist/formats/eleventy-liquid.js", - "./njk": "./dist/formats/eleventy-nunjucks.js", - "./md": "./dist/formats/eleventy-markdown.js", - "./i18n": "./dist/plugins/eleventy-plugin-i18n.js" + ".": "./dist/core-minimal.js", + "./core-fs": "./dist/core-fs.js", + "./liquid": "./dist/formats/liquid.js", + "./njk": "./dist/formats/nunjucks.js", + "./md": "./dist/formats/markdown.js", + "./i18n": "./dist/plugins/plugin-i18n.js" }, "files": [ "./dist/**/*.js" @@ -33,9 +33,9 @@ "author": "Zach Leatherman (https://zachleat.com/)", "repository": { "type": "git", - "url": "git://github.com/11ty/eleventy.git" + "url": "git://github.com/11ty/build-awesome.git" }, - "bugs": "https://github.com/11ty/eleventy/issues", + "bugs": "https://github.com/11ty/build-awesome/issues", "homepage": "https://www.11ty.dev/", "devDependencies": { "@11ty/package-bundler": "^0.5.6", diff --git a/packages/browser/src/BundleEleventy.js b/packages/browser/src/BundleCoreFs.js similarity index 92% rename from packages/browser/src/BundleEleventy.js rename to packages/browser/src/BundleCoreFs.js index bce949294..64f20690b 100644 --- a/packages/browser/src/BundleEleventy.js +++ b/packages/browser/src/BundleCoreFs.js @@ -12,6 +12,6 @@ export { default as RenderPlugin } from "../../../src/Plugins/RenderPlugin.js"; // - Extended configuration was removed from defaultConfig.js // This saved ~400KB (unmin) from the bundle but the separate bundle was way larger than the savings (> 1MB) -export { Core as Eleventy } from "../../../src/Core.js"; +export { CoreFs as Eleventy, CoreFs as BuildAwesome } from "../../../src/CoreFs.js"; export { default as FileSystem } from "node:fs"; diff --git a/packages/browser/src/BundleCore.js b/packages/browser/src/BundleCoreMinimal.js similarity index 50% rename from packages/browser/src/BundleCore.js rename to packages/browser/src/BundleCoreMinimal.js index 07f3e1324..28944e25f 100644 --- a/packages/browser/src/BundleCore.js +++ b/packages/browser/src/BundleCoreMinimal.js @@ -1,4 +1,4 @@ // see BundleEleventy.js for Core WITH bundled Eleventy core plugins import "./shims/shim-core.js"; -export { MinimalCore as Eleventy } from "../../../src/CoreMinimal.js"; +export { CoreMinimal as Eleventy, CoreMinimal as BuildAwesome } from "../../../src/CoreMinimal.js"; diff --git a/packages/browser/src/shims/shim-core.js b/packages/browser/src/shims/shim-core.js index f4feb1164..705030bde 100644 --- a/packages/browser/src/shims/shim-core.js +++ b/packages/browser/src/shims/shim-core.js @@ -3,10 +3,10 @@ import * as process from "./process.cjs"; // `path` polyfill needs this window.process = globalThis.process = process; -// `recursive-copy` needs this (not necessary for Core.js) +// `recursive-copy` needs this (not necessary for CoreFs.js) window.global = globalThis || window; -// @11ty/eleventy needs this +// Core needs this class Buffer { static [Symbol.hasInstance](instance) { return this.isBuffer(instance); diff --git a/packages/browser/test/client-core-fs.test.js b/packages/browser/test/client-core-fs.test.js new file mode 100644 index 000000000..c42dc3382 --- /dev/null +++ b/packages/browser/test/client-core-fs.test.js @@ -0,0 +1,4 @@ +import { BuildAwesome } from "../dist/core-fs.js"; +import sharedTests from "./shared-tests.js"; + +sharedTests(BuildAwesome); diff --git a/packages/browser/test/client-core.test.js b/packages/browser/test/client-core.test.js index 629a44b31..a833590f8 100644 --- a/packages/browser/test/client-core.test.js +++ b/packages/browser/test/client-core.test.js @@ -1,4 +1,4 @@ -import { Eleventy } from "../dist/eleventy.core.js"; +import { BuildAwesome } from "../dist/core-minimal.js"; import sharedTests from "./shared-tests.js"; -sharedTests(Eleventy); +sharedTests(BuildAwesome); diff --git a/packages/browser/test/client-eleventy.test.js b/packages/browser/test/client-eleventy.test.js deleted file mode 100644 index cf70606f6..000000000 --- a/packages/browser/test/client-eleventy.test.js +++ /dev/null @@ -1,4 +0,0 @@ -import { Eleventy } from "../dist/eleventy.js"; -import sharedTests from "./shared-tests.js"; - -sharedTests(Eleventy); diff --git a/packages/browser/test/shared-tests.js b/packages/browser/test/shared-tests.js index f59a3e9cd..2d71bfe04 100644 --- a/packages/browser/test/shared-tests.js +++ b/packages/browser/test/shared-tests.js @@ -1,22 +1,22 @@ import { assert, test } from "vitest"; -import { Markdown } from "../dist/formats/eleventy-markdown.js"; -import { Liquid } from "../dist/formats/eleventy-liquid.js"; -import { Nunjucks } from "../dist/formats/eleventy-nunjucks.js"; -import { I18nPlugin } from "../dist/plugins/eleventy-plugin-i18n.js"; +import { Markdown } from "../dist/formats/markdown.js"; +import { Liquid } from "../dist/formats/liquid.js"; +import { Nunjucks } from "../dist/formats/nunjucks.js"; +import { I18nPlugin } from "../dist/plugins/plugin-i18n.js"; -export default function(Eleventy) { +export default function(BuildAwesome) { test("Get version number", async () => { - assert.typeOf(Eleventy.getVersion(), "string"); + assert.typeOf(BuildAwesome.getVersion(), "string"); }); test("Markdown (no preprocessor) template", async () => { - let elev = new Eleventy({ - config(eleventyConfig) { - eleventyConfig.addEngine("md", Markdown); - eleventyConfig.setMarkdownTemplateEngine(false); - eleventyConfig.setHtmlTemplateEngine(false); - eleventyConfig.setTemplateFormats("md"); - eleventyConfig.addTemplate("index.md", `# Heading`); + let elev = new BuildAwesome({ + config(configApi) { + configApi.addEngine("md", Markdown); + configApi.setMarkdownTemplateEngine(false); + configApi.setHtmlTemplateEngine(false); + configApi.setTemplateFormats("md"); + configApi.addTemplate("index.md", `# Heading`); } }); @@ -26,12 +26,12 @@ export default function(Eleventy) { }); test("Markdown (via Liquid) template", async () => { - let elev = new Eleventy({ - config(eleventyConfig) { - eleventyConfig.addEngine("md", Markdown); - eleventyConfig.addEngine("liquid", Liquid); - eleventyConfig.setTemplateFormats("md"); - eleventyConfig.addTemplate("index.md", `# {{ title }}`, { + let elev = new BuildAwesome({ + config(configApi) { + configApi.addEngine("md", Markdown); + configApi.addEngine("liquid", Liquid); + configApi.setTemplateFormats("md"); + configApi.addTemplate("index.md", `# {{ title }}`, { title: "Heading" }); @@ -43,11 +43,11 @@ export default function(Eleventy) { }); test("Liquid template", async () => { - let elev = new Eleventy({ - config(eleventyConfig) { - eleventyConfig.addEngine("liquid", Liquid); - eleventyConfig.setTemplateFormats("liquid"); - eleventyConfig.addTemplate("index.liquid", `

{{ title }}

`, { title: "Heading" }); + let elev = new BuildAwesome({ + config(configApi) { + configApi.addEngine("liquid", Liquid); + configApi.setTemplateFormats("liquid"); + configApi.addTemplate("index.liquid", `

{{ title }}

`, { title: "Heading" }); } }); @@ -56,11 +56,11 @@ export default function(Eleventy) { }); test("Nunjucks template", async () => { - let elev = new Eleventy({ - config(eleventyConfig) { - eleventyConfig.addEngine("njk", Nunjucks); - eleventyConfig.setTemplateFormats("njk"); - eleventyConfig.addTemplate("index.njk", `

{{ title }}

`, { title: "Heading" }); + let elev = new BuildAwesome({ + config(configApi) { + configApi.addEngine("njk", Nunjucks); + configApi.setTemplateFormats("njk"); + configApi.addTemplate("index.njk", `

{{ title }}

`, { title: "Heading" }); } }); @@ -70,15 +70,15 @@ export default function(Eleventy) { }); test("i18n Plugin Use (with 11ty.js)", async () => { - let elev = new Eleventy({ - config(eleventyConfig) { - eleventyConfig.addPlugin(I18nPlugin, { + let elev = new BuildAwesome({ + config(configApi) { + configApi.addPlugin(I18nPlugin, { defaultLanguage: "en" }); - eleventyConfig.addTemplate("./en/index.11ty.js", function (data) { + configApi.addTemplate("./en/index.11ty.js", function (data) { return `Home`; }); - eleventyConfig.addTemplate("./es/index.11ty.js", function (data) { + configApi.addTemplate("./es/index.11ty.js", function (data) { return `Home`; }); } @@ -91,11 +91,11 @@ export default function(Eleventy) { // Careful, `@11ty/client` will resolve slugify via Vite instead of it bundled with the package test("slugify Filter in Liquid", async () => { - let elev = new Eleventy({ - config(eleventyConfig) { - eleventyConfig.addEngine("liquid", Liquid); - eleventyConfig.setTemplateFormats("liquid"); - eleventyConfig.addTemplate("index.liquid", `{{ title | slugify }}`, { title: "This is a heading" }); + let elev = new BuildAwesome({ + config(configApi) { + configApi.addEngine("liquid", Liquid); + configApi.setTemplateFormats("liquid"); + configApi.addTemplate("index.liquid", `{{ title | slugify }}`, { title: "This is a heading" }); } }); @@ -105,11 +105,11 @@ export default function(Eleventy) { // Careful, `@11ty/client` will resolve slugify via Vite instead of it bundled with the package test("slugify Filter in Nunjucks", async () => { - let elev = new Eleventy({ - config(eleventyConfig) { - eleventyConfig.addEngine("njk", Nunjucks); - eleventyConfig.setTemplateFormats("njk"); - eleventyConfig.addTemplate("index.njk", `{{ title | slugify }}`, { title: "This is a heading" }); + let elev = new BuildAwesome({ + config(configApi) { + configApi.addEngine("njk", Nunjucks); + configApi.setTemplateFormats("njk"); + configApi.addTemplate("index.njk", `{{ title | slugify }}`, { title: "This is a heading" }); } }); diff --git a/src/Benchmark/BenchmarkGroup.js b/src/Benchmark/BenchmarkGroup.js index eded8756a..601e10b7c 100644 --- a/src/Benchmark/BenchmarkGroup.js +++ b/src/Benchmark/BenchmarkGroup.js @@ -4,7 +4,7 @@ import ConsoleLogger from "../Util/ConsoleLogger.js"; import isAsyncFunction from "../Util/IsAsyncFunction.js"; import Benchmark from "./Benchmark.js"; -const debugBenchmark = createDebug("Eleventy:Benchmark"); +const debugBenchmark = createDebug("BuildAwesome:Benchmark"); class BenchmarkGroup { constructor() { diff --git a/src/Core.js b/src/Core.js index fbe146ec7..1db68b439 100644 --- a/src/Core.js +++ b/src/Core.js @@ -1,51 +1,631 @@ -import { MinimalCore } from "./CoreMinimal.js"; -import FileSystemSearch from "./FileSystemSearch.js"; -import EleventyFiles from "./EleventyFiles.js"; -import TemplatePassthroughManager from "./TemplatePassthroughManager.js"; +import { relative } from "node:path"; +import { createDebug } from "obug"; + +import { TemplatePath } from "@11ty/eleventy-utils"; + +import { CoreFs } from "./CoreFs.js"; +import Serve from "./Serve.js"; +import { Watch } from "./Watch.js"; +import WatchQueue from "./WatchQueue.js"; +import WatchTargets from "./WatchTargets.js"; +import BaseError from "./Errors/BaseError.js"; + +// Utils +import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; +import PathPrefixer from "./Util/PathPrefixer.js"; +import PathNormalizer from "./Util/PathNormalizer.js"; +import { isGlobMatch } from "./Util/GlobMatcher.js"; +import eventBus from "./EventBus.js"; + +const debug = createDebug("BuildAwesome:Core"); + +export default class Core extends CoreFs { + /** @type {boolean} */ + #isStopping = false; + + /** @type {WatchQueue} */ + #watchQueue; + + #watchDelay; + #interrupted = false; + + // constructor(input, output, options = {}, eleventyConfig = null) { + // super(input, output, options, eleventyConfig); + // } + + get watchQueue() { + if (!this.#watchQueue) { + this.#watchQueue = new WatchQueue(); + } + return this.#watchQueue; + } -// Core with File System support (but without Dev Server or Chokidar or Bundled Plugins) -export class Core extends MinimalCore { async initializeConfig(initOverrides) { await super.initializeConfig(initOverrides); + // Careful to make sure the previous server closes on SIGINT, issue #3873 + if (!this.eleventyServe) { + /** @type {object} */ + this.eleventyServe = new Serve(); + } + this.eleventyServe.eleventyConfig = this.eleventyConfig; + /** @type {object} */ - this.fileSystemSearch = new FileSystemSearch(); + this.watchTargets = new WatchTargets(this.eleventyConfig); + this.watchTargets.add(this.config.additionalWatchTargets); } + async resetConfig() { + await super.resetConfig(); + + // TODO set this.eleventyServe with this.getChokidarConfig() + if (checkPassthroughCopyBehavior(this.config, this.runMode)) { + this.eleventyServe.resetConfig(); + } + } + + /** + * Starts Eleventy. + */ async init(options = {}) { await super.init(options); - this.templateData.setFileSystemSearch(this.fileSystemSearch); + // eleventyServe is always available, even when not in --serve mode + // TODO directorynorm + this.eleventyServe.setOutputDir(this.outputDir); + + if (checkPassthroughCopyBehavior(this.config, this.runMode)) { + this.eleventyServe.watchPassthroughCopy( + this.eleventyFiles.getGlobWatcherFilesForPassthroughCopy(), + ); + } + } + + /** + * @param {string} changedFilePath - File that triggered a re-run (added or modified) + * @param {boolean} [isResetConfig] - are we doing a config reset + */ + #resetFileInWatchQueue(changedFilePath, isResetConfig) { + // v3.1.0: `eleventy.templateModified` is no longer used internally + // v4.0.0-alpha.8 `eleventy.templateModified` event removed + + // These listeners are *global*, not cleared even on config reset (v4.0.0-alpha.8 removed some arguments here) + eventBus.emit("buildawesome.resourcemodified", changedFilePath); + + this.config.events.emit("buildawesome#templatemodified", changedFilePath); + } + + shouldTriggerConfigReset(changedFiles) { + // looks for all eligible config files (not just the active one, handles config file rename) + let configFilePaths = new Set(this.eleventyConfig.getLocalProjectConfigFiles()); + + // https://www.11ty.dev/docs/watch-serve/#reset-configuration + let resetConfigGlobs = WatchTargets.normalizeToGlobs( + Array.from(this.eleventyConfig.userConfig.watchTargetsConfigReset), + ); + + for (let filePath of changedFiles) { + if (configFilePaths.has(filePath)) { + return true; + } + if (isGlobMatch(filePath, resetConfigGlobs)) { + return true; + } + } + + for (let configFilePath of configFilePaths) { + // Any dependencies of the config file changed + let configFileDependencies = new Set(this.watchTargets.getDependenciesOf(configFilePath)); + + for (let filePath of changedFiles) { + if (configFileDependencies.has(filePath)) { + return true; + } + } + } + + return false; + } + + // Checks the build queue to see if any configuration related files have changed + #shouldResetConfig(activeQueue = []) { + if (!activeQueue.length) { + return false; + } + + return this.shouldTriggerConfigReset( + activeQueue.map((path) => { + return PathNormalizer.normalizeSeperator(TemplatePath.addLeadingDotSlash(path)); + }), + ); + } + + async #rewatch() { + if (this.watchQueue.isBuildRunning()) { + // this.logger.forceLog("Waiting for previous build to finish…"); + return; + } + + this.watchQueue.startBuild(); + + let queue = this.watchQueue.getActiveQueue(); + let isResetConfig = this.#shouldResetConfig(queue); + + for (let p of queue) { + this.#resetFileInWatchQueue(p, isResetConfig); + } + + this.logger.forceLog( + `Build starting${queue.length > 1 ? ` (${queue.length} queued changes)` : ""}…` + + (isResetConfig ? " (configuration reset)" : ""), + ); + + await this.config.events.emit("buildawesome.beforewatch", queue); + + // Clear `import` cache for all files that triggered the rebuild (sync event) + this.watchTargets.clearImportCacheFor(queue); + + // reset and reload global configuration + if (isResetConfig) { + // important: run this before config resets otherwise the handlers will disappear. + await this.config.events.emit("buildawesome.reset"); + this.resetConfig(); + } + + await this.restart(); + await this.init({ viaConfigReset: isResetConfig }); + + try { + let [passthroughCopyResults, templateResults] = await this.write(); + + if (isResetConfig) { + // make sure this happens after write() + await this.startWatch(); + } + + this.watchTargets.reset(); + + await this.#initWatchDependencies(); + + // Add new deps to chokidar + let newWatchTargets = this.watchTargets.getNewTargetsSinceLastReset(); + this.watcher.watchTargets(newWatchTargets); + + // Is a CSS input file and is not in the includes folder + // TODO check output path file extension of this template (not input path) + // TODO add additional API for this, maybe a config callback? + let onlyCssChanges = this.watchQueue.hasAllQueueFiles((path) => { + return ( + path.endsWith(".css") && + // TODO how to make this work with relative includes? + !TemplatePath.startsWithSubPath(path, this.eleventyFiles.getIncludesDir()) + ); + }); + + // Maps passthrough copy files to output URLs for CSS live reload + let stylesheetUrls = new Set(); + for (let entry of passthroughCopyResults) { + for (let filepath in entry.map) { + if ( + filepath.endsWith(".css") && + queue.includes(TemplatePath.addLeadingDotSlash(filepath)) + ) { + stylesheetUrls.add( + "/" + TemplatePath.stripLeadingSubPath(entry.map[filepath], this.outputDir), + ); + } + } + } + + let normalizedPathPrefix = PathPrefixer.normalizePathPrefix(this.config.pathPrefix); + let matchingTemplates = templateResults + .flat() + .filter((entry) => Boolean(entry)) + .map((entry) => { + // only `url`, `inputPath`, and `content` are used: https://github.com/11ty/eleventy-dev-server/blob/1c658605f75224fdc76f68aebe7a412eeb4f1bc9/client/reload-client.js#L140 + entry.url = PathPrefixer.joinUrlParts(normalizedPathPrefix, entry.url); + delete entry.rawInput; // Issue #3481 + return entry; + }); + + await this.eleventyServe.reload({ + files: queue, + subtype: onlyCssChanges ? "css" : undefined, + build: { + stylesheets: Array.from(stylesheetUrls), + templates: matchingTemplates, + }, + }); + } catch (error) { + this.eleventyServe.sendError({ + error, + }); + } + + this.watchQueue.finishBuild(); + + // Re-fetch + let pendingQueue = this.watchQueue.getPendingQueue(); + if (pendingQueue.length > 0) { + await this.#rewatch(); + } else if (!this.#interrupted) { + // also logs in startWatch for initial build + this.logger.forceLog(`Waiting…`); + } + } + + /* + * SIGINT + */ + interrupt() { + this.#interrupted = true; + + // Clear the queue to prevent additional builds + this.watchQueue.reset(); + } + + /** + * @returns {module:11ty/eleventy/src/Benchmark/BenchmarkGroup~BenchmarkGroup} + */ + get watcherBench() { + return this.bench.get("Watcher"); + } + + async waitThrottle() { + if (this.#watchDelay) { + clearTimeout(this.#watchDelay); + } + + if (this.config.watchThrottleWaitTime > 0) { + let { promise, resolve } = Promise.withResolvers(); + + this.#watchDelay = setTimeout(resolve, this.config.watchThrottleWaitTime); + + return promise; + } + } + + // Triggers when files are modified on file system + async triggerWatchRunForPath(path) { + this.watchQueue.addToPendingQueue(path); + + await this.waitThrottle(); + + try { + await this.#rewatch(); + } catch (e) { + this.watchQueue.finishBuild(); + + if (e instanceof BaseError) { + this.errorHandler.error(e, "Eleventy watch error"); + } else { + this.errorHandler.fatal(e, "Eleventy fatal watch error"); + await this.close(); + } + } + + // Internal event for testing + // v4.0.0-alpha.8 swapped to async-friendly + await this.config.events.emit("buildawesome.afterwatch"); + } + + /** + * Set up watchers and benchmarks. + * + * @async + * @method + */ + async startWatch() { + if (this.projectPackageJsonPath) { + this.watchTargets.add([relative(TemplatePath.getWorkingDir(), this.projectPackageJsonPath)]); + } + this.watchTargets.add(this.eleventyFiles.getGlobWatcherFiles()); + this.watchTargets.add(this.eleventyFiles.getIgnoreFiles()); + + // Watch the local project config file + this.watchTargets.add(this.eleventyConfig.getActiveConfigPath()); + + // Template and Directory Data Files + this.watchTargets.add(await this.eleventyFiles.getGlobWatcherTemplateDataFiles()); - this.passthroughManager = new TemplatePassthroughManager(this.eleventyConfig); - this.passthroughManager.setRunMode(this.runMode); - this.passthroughManager.setDryRun(this.isDryRun); - this.passthroughManager.extensionMap = this.extensionMap; - this.passthroughManager.setFileSystemSearch(this.fileSystemSearch); + let benchmark = this.watcherBench.get( + "Watching JavaScript Dependencies (disable with `eleventyConfig.setWatchJavaScriptDependencies(false)`)", + ); + benchmark.before(); + await this.#initWatchDependencies(); + benchmark.after(); - let formats = this.templateFormats.getTemplateFormats(); - this.eleventyFiles = new EleventyFiles(formats, this.eleventyConfig); - this.eleventyFiles.setPassthroughManager(this.passthroughManager); - this.eleventyFiles.setFileSystemSearch(this.fileSystemSearch); - this.eleventyFiles.setRunMode(this.runMode); - this.eleventyFiles.extensionMap = this.extensionMap; - // This needs to be set before init or it’ll construct a new one - this.eleventyFiles.templateData = this.templateData; - this.eleventyFiles.init(); + // Close previous watcher + if (this.watcher) { + await this.watcher.close(); + } - this.writer.setPassthroughManager(this.passthroughManager); - this.writer.setEleventyFiles(this.eleventyFiles); + // TODO improve unwatching if JS dependencies are removed (or files are deleted) + let { targets, ignores } = await this.getWatchedTargets(); + debug("Watching for changes to: %o", targets); + + this.watcher = new Watch(this.eleventyConfig); + this.watcher.watchTargets(targets); + this.watcher.addIgnores(ignores); + + await this.watcher.start(); + + // This logs in #rewatch for rebuilds + if (this.buildCount <= 1) { + this.logger.forceLog("Waiting…"); + } + + this.watcher.on("change", async (path) => { + // Emulated passthrough copy logs from the server + if (!this.eleventyServe.isEmulatedPassthroughCopyMatch(path)) { + this.logger.forceLog( + `File changed: ${TemplatePath.stripLeadingDotSlash(TemplatePath.standardizeFilePath(path))}${this.watchQueue.isBuildRunning() ? " (queued for next build)" : ""}`, + ); + } + + // don’t await + this.triggerWatchRunForPath(path); + }); + + this.watcher.on("add", async (path) => { + // Emulated passthrough copy logs from the server + if (!this.eleventyServe.isEmulatedPassthroughCopyMatch(path)) { + this.logger.forceLog( + `File added: ${TemplatePath.stripLeadingDotSlash(TemplatePath.standardizeFilePath(path))}${this.watchQueue.isBuildRunning() ? " (queued for next build)" : ""}`, + ); + } + + this.fileSystemSearch.add(path); + // don’t await + this.triggerWatchRunForPath(path); + }); + + this.watcher.on("unlink", async (path) => { + // Emulated passthrough copy logs from the server + if (!this.eleventyServe.isEmulatedPassthroughCopyMatch(path)) { + this.logger.forceLog( + `File deleted: ${TemplatePath.stripLeadingDotSlash(TemplatePath.standardizeFilePath(path))}${this.watchQueue.isBuildRunning() ? " (queued for next build)" : ""}`, + ); + } + + this.fileSystemSearch.delete(path); + // don’t await + this.triggerWatchRunForPath(path); + }); + } + + /** + * Starts watching dependencies. + */ + async #initWatchDependencies() { + if (!this.eleventyConfig.shouldSpiderJavaScriptDependencies()) { + return; + } + + // Lazy resolve isEsm only for --watch + this.watchTargets.setProjectUsingEsm(this.isEsm); + + // Template files .11ty.js + let templateFiles = await this.eleventyFiles.getWatchPathCache(); + await this.watchTargets.addDependencies(templateFiles); + + // TODO use DirContains + let dataDir = TemplatePath.stripLeadingDotSlash(this.templateData.getDataDir()); + function filterOutGlobalDataFiles(path) { + return !dataDir || !TemplatePath.stripLeadingDotSlash(path).startsWith(dataDir); + } + + // Config file dependencies + await this.watchTargets.addDependencies( + this.eleventyConfig.getActiveConfigPath(), + filterOutGlobalDataFiles, + ); + + // Deps from Global Data (that aren’t in the global data directory, everything is watched there) + let globalDataDeps = this.templateData.getWatchPathCache(); + await this.watchTargets.addDependencies(globalDataDeps, filterOutGlobalDataFiles); + + await this.watchTargets.addDependencies( + await this.eleventyFiles.getWatcherTemplateJavaScriptDataFiles(), + ); + } + + /** + * Returns all watched paths + * + * @async + * @method + * @returns {Object} `targets` file paths, and `ignores` globs Array + */ + async getWatchedTargets() { + return { + targets: await this.watchTargets.getTargets(), + ignores: this.eleventyFiles.getGlobWatcherIgnores(), + }; + } + + /** + * Start watching files + * + * @async + * @method + */ + async watch() { + this.watcherBench.setMinimumThresholdMs(500); + this.watcherBench.reset(); + + // Note that watching indirectly depends on this for fetching dependencies from JS files + // See: TemplateWriter:pathCache and WatchTargets + await this.write(); + + let initWatchBench = this.watcherBench.get("Start up --watch"); + initWatchBench.before(); + + await this.startWatch(); + + initWatchBench.after(); + + this.watcherBench.finish("Watch"); + } + + // Renamed to close() + async stopWatch() { + return this.close(); + } + + async close() { + // Prevent multiple invocations. + if (this.#isStopping) { + return this.#isStopping; + } + + debug("Cleaning up chokidar and server instances, if they exist."); + this.#isStopping = Promise.all([this.eleventyServe.close(), this.watcher?.close()]).then(() => { + this.#isStopping = false; + }); + + return this.#isStopping; } /** - * Restarts Eleventy. + * Serve Eleventy on this port. + * + * @param {Number} port - The HTTP port to serve Eleventy from. */ - async restart() { - await super.restart(); + async serve(port) { + this.eleventyServe.onEdit(async (path) => { + this.watcher.emit("change", path); + }); - // TODO - this.passthroughManager.reset(); - // TODO - this.eleventyFiles.restart(); + // Port is optional and in this case likely via --port on the command line + // May defer to configuration API options `port` property + return this.eleventyServe.serve(port); } + + /** + * Shows a help message including usage. + * + * @static + * @returns {string} - The help message. + */ + static getHelp() { + return `Usage: eleventy + eleventy --input=. --output=./_site + eleventy --serve + +Arguments: + + --version + + --input=. + Input template files (default: \`.\`) + + --output=_site + Write HTML output to this folder (default: \`_site\`) + + --serve + Run web server on --port (default 8080) and watch them too + + --port + Run the --serve web server on this port (default 8080) + + --watch + Wait for files to change and automatically rewrite (no web server) + + --incremental + Only build the files that have changed. Best with watch/serve. + + --incremental=first.md,second.md + --incremental=first.md --incremental=second.md + Does not require watch/serve. Run an incremental build targeting one or more files. + + --ignore-initial + Start without a build; build when files change. Works best with watch/serve/incremental. + + --formats=liquid,md + Allow only certain template types (default: \`*\`) + + --quiet + Don’t print all written files (off by default) + + --config=filename.js + Override the eleventy config file path (default: \`buildawesome.config.js\`) + + --pathprefix='/' + Change all url template filters to use this subdirectory. + + --dryrun + Don’t write any files. Useful in DEBUG mode, for example: \`DEBUG=Eleventy* npx @11ty/eleventy --dryrun\` + + --loader + Set to "esm" to force ESM mode, "cjs" to force CommonJS mode, or "auto" (default) to infer it from package.json. + + --to=json + Change the output to JSON (default: \`fs\`) + + --to=fs:templates + Writes templates, skips passthrough copy + + --help`; + } + + /** + * @deprecated since 1.0.1, use static getHelp() instead + */ + getHelp() { + return Core.getHelp(); + } + + /* Removed methods */ + initWatch() { + throw new Error( + "#initWatch() was removed in v4. Use #startWatch() instead (initializes and starts the watcher)", + ); + } + getWatchedFiles() { + throw new Error( + "#getWatchedFiles() was removed in v4. Use #getWatchedTargets().targets instead.", + ); + } +} + +// Named export for backwards compatibility +export { Core as Eleventy }; + +/* Utils */ +export { DynamicImport as ImportFile } from "./Util/Require.js"; + +// TODO(breaking) remove these and recommend folks use package level exports e.g. "@11ty/eleventy/plugins/i18n" + +/* Plugins */ +export { default as BundlePlugin } from "@11ty/eleventy-plugin-bundle"; + +// Eleventy*Plugin names are backwards-compatibility legacy names +export { + default as RenderPlugin, + default as EleventyRenderPlugin, +} from "./Plugins/RenderPlugin.js"; +export { default as I18nPlugin, default as EleventyI18nPlugin } from "./Plugins/I18nPlugin.js"; +export { + default as HtmlBasePlugin, + default as EleventyHtmlBasePlugin, +} from "./Plugins/HtmlBasePlugin.js"; +export { TransformPlugin as InputPathToUrlTransformPlugin } from "./Plugins/InputPathToUrl.js"; +export { IdAttributePlugin } from "./Plugins/IdAttributePlugin.js"; + +export { PreserveClosingTagsPlugin } from "./Plugins/PreserveClosingTagsPlugin.js"; + +// Error messages for Removed plugins +export function EleventyServerlessBundlerPlugin() { + throw new Error( + "Following feedback from our Community Survey, low interest in this plugin prompted its removal from core v3.0 as we refocus on static sites. Learn more: https://v3.11ty.dev/docs/plugins/serverless/", + ); +} + +export { EleventyServerlessBundlerPlugin as EleventyServerless }; + +export function EleventyEdgePlugin() { + throw new Error( + "Following feedback from our Community Survey, low interest in this plugin prompted its removal from core v3.0 as we refocus on static sites. Learn more: https://v3.11ty.dev/docs/plugins/edge/", + ); } diff --git a/src/CoreFs.js b/src/CoreFs.js new file mode 100644 index 000000000..5bfd43ce2 --- /dev/null +++ b/src/CoreFs.js @@ -0,0 +1,51 @@ +import { CoreMinimal } from "./CoreMinimal.js"; +import FileSystemSearch from "./FileSystemSearch.js"; +import { Files } from "./Files.js"; +import TemplatePassthroughManager from "./TemplatePassthroughManager.js"; + +// Core with File System support (but without Dev Server or Chokidar or Bundled Plugins) +export class CoreFs extends CoreMinimal { + async initializeConfig(initOverrides) { + await super.initializeConfig(initOverrides); + + /** @type {object} */ + this.fileSystemSearch = new FileSystemSearch(); + } + + async init(options = {}) { + await super.init(options); + + this.templateData.setFileSystemSearch(this.fileSystemSearch); + + this.passthroughManager = new TemplatePassthroughManager(this.eleventyConfig); + this.passthroughManager.setRunMode(this.runMode); + this.passthroughManager.setDryRun(this.isDryRun); + this.passthroughManager.extensionMap = this.extensionMap; + this.passthroughManager.setFileSystemSearch(this.fileSystemSearch); + + let formats = this.templateFormats.getTemplateFormats(); + this.eleventyFiles = new Files(formats, this.eleventyConfig); + this.eleventyFiles.setPassthroughManager(this.passthroughManager); + this.eleventyFiles.setFileSystemSearch(this.fileSystemSearch); + this.eleventyFiles.setRunMode(this.runMode); + this.eleventyFiles.extensionMap = this.extensionMap; + // This needs to be set before init or it’ll construct a new one + this.eleventyFiles.templateData = this.templateData; + this.eleventyFiles.init(); + + this.writer.setPassthroughManager(this.passthroughManager); + this.writer.setEleventyFiles(this.eleventyFiles); + } + + /** + * Restarts Eleventy. + */ + async restart() { + await super.restart(); + + // TODO + this.passthroughManager.reset(); + // TODO + this.eleventyFiles.restart(); + } +} diff --git a/src/CoreMinimal.js b/src/CoreMinimal.js index fe0aafa61..bcf4a6f7d 100644 --- a/src/CoreMinimal.js +++ b/src/CoreMinimal.js @@ -5,8 +5,8 @@ import chalk from "./Adapters/Packages/chalk.js"; import TemplateData from "./Data/TemplateData.js"; import TemplateWriter from "./TemplateWriter.js"; -import EleventyExtensionMap from "./EleventyExtensionMap.js"; -import { EleventyErrorHandler } from "./Errors/EleventyErrorHandler.js"; +import ExtensionMap from "./ExtensionMap.js"; +import { ErrorHandler } from "./Errors/ErrorHandler.js"; import TemplateConfig from "./TemplateConfig.js"; import TemplateEngineManager from "./Engines/TemplateEngineManager.js"; @@ -16,21 +16,17 @@ import simplePlural from "./Util/Pluralize.js"; import ConsoleLogger from "./Util/ConsoleLogger.js"; import ProjectDirectories from "./Util/ProjectDirectories.js"; import { - getEleventyPackageJson, + getCorePackageJson, importJsonSync, getWorkingProjectPackageJsonPath, } from "./Util/ImportJsonSync.js"; import ProjectTemplateFormats from "./Util/ProjectTemplateFormats.js"; +import { setEnvValue } from "./Util/EnvironmentVars.cjs"; -const pkg = getEleventyPackageJson(); -const debug = createDebug("Eleventy"); +const pkg = getCorePackageJson(); +const debug = createDebug("BuildAwesome:Core"); -/** - * Eleventy’s programmatic API - * @module 11ty/eleventy/Eleventy - */ - -export class MinimalCore { +export class CoreMinimal { /** * Userspace package.json file contents * @type {object|undefined} @@ -56,7 +52,7 @@ export class MinimalCore { #needsInit = true; /** @type {Promise|undefined} */ #initPromise; - /** @type {EleventyErrorHandler|undefined} */ + /** @type {ErrorHandler|undefined} */ #errorHandler; /** @type {Map} */ #privateCaches = new Map(); @@ -93,7 +89,7 @@ export class MinimalCore { } /** - * @typedef {object} EleventyOptions + * @typedef {object} BuildAwesomeOptions * @property {'cli'|'script'=} source * @property {'build'|'serve'|'watch'=} runMode * @property {boolean=} dryRun @@ -105,7 +101,7 @@ export class MinimalCore { * @param {string} [input] - Directory or filename for input/sources files. * @param {string} [output] - Directory serving as the target for writing the output files. - * @param {EleventyOptions} [options={}] + * @param {BuildAwesomeOptions} [options={}] * @param {TemplateConfig} [eleventyConfig] */ constructor(...args) { @@ -135,8 +131,8 @@ export class MinimalCore { this.eleventyConfig = eleventyConfig; /** - * @type {EleventyOptions} - * @description Options object passed to the Eleventy constructor + * @type {BuildAwesomeOptions} + * @description Options object passed to the constructor * @default {} */ this.options = options; @@ -232,10 +228,10 @@ export class MinimalCore { } /** - * @deprecated since 1.0.1, use static Eleventy.getVersion() + * @deprecated since 1.0.1, use static getVersion() */ getVersion() { - return MinimalCore.getVersion(); + return CoreMinimal.getVersion(); } async initializeConfig(initOverrides) { @@ -274,7 +270,7 @@ export class MinimalCore { /* Programmatic API config */ if (this.options.config && typeof this.options.config === "function") { - debug("Running options.config configuration callback (passed to Eleventy constructor)"); + debug("Running options.config configuration callback (passed to constructor)"); // TODO use return object here? await this.options.config(this.eleventyConfig.userConfig); } @@ -293,7 +289,7 @@ export class MinimalCore { /** * @type {object} - * @description Initialize Eleventy’s configuration, including the user config file + * @description Initialize configuration, including the user config file */ this.config = this.eleventyConfig.getConfig(); @@ -353,7 +349,7 @@ export class MinimalCore { // Not used internally, removed in 3.0. setInputDir() { throw new Error( - "Eleventy->setInputDir was removed in 3.0. Use the inputDir option to the constructor", + "The setInputDir method was removed in 3.0. Use the inputDir option passed to the constructor.", ); } @@ -363,9 +359,9 @@ export class MinimalCore { } /** - * Updates the dry-run mode of Eleventy. + * Updates the dry-run mode (whether or not to write files). * - * @param {boolean} isDryRun - Shall Eleventy run in dry mode? + * @param {boolean} isDryRun - Shall we run in dry mode? */ setDryRun(isDryRun) { this.isDryRun = !!isDryRun; @@ -374,7 +370,7 @@ export class MinimalCore { /** * Sets the incremental build mode. * - * @param {boolean} isIncremental - Shall Eleventy run in incremental build mode and only write the files that trigger watch updates + * @param {boolean} isIncremental - Shall we run in incremental build mode and only write the files that trigger watch updates */ setIncrementalBuild(isIncremental) { this.isIncremental = Boolean(isIncremental); @@ -407,9 +403,6 @@ export class MinimalCore { } } - /** - * Restarts Eleventy. - */ async restart() { debug("Restarting."); this.start = this.getNewTimestamp(); @@ -439,9 +432,6 @@ export class MinimalCore { } } - /** - * Starts Eleventy. - */ async init(options = {}) { let { viaConfigReset } = Object.assign({ viaConfigReset: false }, options); if (!this.#hasConfigInitialized) { @@ -451,18 +441,18 @@ export class MinimalCore { this.config.events.reset(); } - await this.config.events.emit("eleventy.config", this.eleventyConfig); + await this.config.events.emit("buildawesome.config", this.eleventyConfig); if (this.env) { - await this.config.events.emit("eleventy.env", this.env); + await this.config.events.emit("buildawesome.env", this.env); } let formats = this.templateFormats.getTemplateFormats(); let engineManager = new TemplateEngineManager(this.eleventyConfig); - this.extensionMap = new EleventyExtensionMap(this.eleventyConfig); + this.extensionMap = new ExtensionMap(this.eleventyConfig); this.extensionMap.setFormats(formats); this.extensionMap.engineManager = engineManager; - await this.config.events.emit("eleventy.extensionmap", this.extensionMap); + await this.config.events.emit("buildawesome.extensionmap", this.extensionMap); this.templateData = new TemplateData(this.eleventyConfig); this.templateData.setProjectUsingEsm(this.isEsm); @@ -472,7 +462,7 @@ export class MinimalCore { } // Note these directories are all project root relative - this.config.events.emit("eleventy.directories", this.directories.getUserspaceInstance()); + this.config.events.emit("buildawesome.directories", this.directories.getUserspaceInstance()); this.writer = new TemplateWriter(formats, this.templateData, this.eleventyConfig); @@ -538,13 +528,13 @@ Verbose Output: ${this.verboseMode}`; // Recognize that global data `eleventy.version` is coerced to remove prerelease tags // and this is the raw version (3.0.0 versus 3.0.0-alpha.6). // `eleventy.env.version` does not yet exist (unnecessary) - process.env.ELEVENTY_VERSION = MinimalCore.getVersion(); + setEnvValue("VERSION", CoreMinimal.getVersion()); - process.env.ELEVENTY_ROOT = env.root; - debug("Setting process.env.ELEVENTY_ROOT: %o", env.root); + setEnvValue("ROOT", env.root); + debug("Setting process.env.ELEVENTY_ROOT and BUILDAWESOME_ROOT: %o", env.root); - process.env.ELEVENTY_SOURCE = env.source; - process.env.ELEVENTY_RUN_MODE = env.runMode; + setEnvValue("SOURCE", env.source); + setEnvValue("RUN_MODE", env.runMode); } /** @param {boolean} value */ @@ -577,10 +567,10 @@ Verbose Output: ${this.verboseMode}`; this.logger.overrideLogger(false); } - /** @type {EleventyErrorHandler} */ + /** @type {ErrorHandler} */ get errorHandler() { if (!this.#errorHandler) { - this.#errorHandler = new EleventyErrorHandler(); + this.#errorHandler = new ErrorHandler(); this.#errorHandler.isVerbose = this.verboseMode; this.#errorHandler.logger = this.logger; } @@ -589,10 +579,10 @@ Verbose Output: ${this.verboseMode}`; } /** - * Updates the verbose mode of Eleventy. + * Updates the verbose mode (logs more detailed information). * * @method - * @param {boolean} isVerbose - Shall Eleventy run in verbose mode? + * @param {boolean} isVerbose - Shall we run in verbose mode? */ setIsVerbose(isVerbose) { if (!this.#hasConfigInitialized) { @@ -633,7 +623,7 @@ Verbose Output: ${this.verboseMode}`; } /** - * Updates the template formats of Eleventy. + * Updates the template formats. * * @method * @param {string} formats - The new template formats. @@ -643,7 +633,7 @@ Verbose Output: ${this.verboseMode}`; } /** - * Updates the run mode of Eleventy. + * Updates the run mode (build/watch/serve). * * @method * @param {string} runMode - One of "build", "watch", or "serve" @@ -691,7 +681,7 @@ Verbose Output: ${this.verboseMode}`; } /** - * Resets the config of Eleventy. + * Resets the config * * @method */ @@ -772,7 +762,7 @@ Verbose Output: ${this.verboseMode}`; } toNDJSON() { - throw new Error("Feature removed in Eleventy v4: https://github.com/11ty/eleventy/issues/3382"); + throw new Error("Feature removed in v4: https://github.com/11ty/eleventy/issues/3382"); } /* @@ -844,8 +834,7 @@ Verbose Output: ${this.verboseMode}`; incremental: this.isIncremental, }; - await this.config.events.emit("beforeBuild", eventsArg); - await this.config.events.emit("eleventy.before", eventsArg); + await this.config.events.emit("buildawesome.before", eventsArg); let promise; if (to === "fs") { @@ -862,7 +851,7 @@ Verbose Output: ${this.verboseMode}`; let resolved = await promise; - // Passing the processed output to the eleventy.after event (2.0+) + // Passing the processed output to the buildawesome.after event (2.0+) eventsArg.results = resolved.templates; if (to === "json" || to === "fs:templates") { @@ -876,11 +865,10 @@ Verbose Output: ${this.verboseMode}`; // always reset after first build this.setIgnoreInitial(false); this.writer.resetIncremental(); - this.config.events.emit("eleventy#previousqueue", incrementalFiles); + this.config.events.emit("buildawesome#previousqueue", incrementalFiles); eventsArg.uses = this.eleventyConfig.usesGraph.map; - await this.config.events.emit("afterBuild", eventsArg); - await this.config.events.emit("eleventy.after", eventsArg); + await this.config.events.emit("buildawesome.after", eventsArg); this.buildCount++; } catch (error) { @@ -906,21 +894,21 @@ Verbose Output: ${this.verboseMode}`; debug(` Have a suggestion/feature request/feedback? Feeling frustrated? I want to hear it! -Open an issue: https://github.com/11ty/eleventy/issues/new`); +Open an issue: https://github.com/11ty/build-awesome/issues/new`); } return returnObj; } /** - * Logs some statistics after a complete run of Eleventy. + * Logs some statistics after a complete run. * * @returns {string} ret - The log message. */ logFinished() { if (!this.writer) { throw new Error( - "Did you call Eleventy.init to create the TemplateWriter instance? Hint: you probably didn’t.", + "Internal error: missing TemplateWriter instance. Make sure you call init() to create it.", ); } @@ -969,7 +957,7 @@ Open an issue: https://github.com/11ty/eleventy/issues/new`); chalk.gray(`(${((time * 1000) / writeCount).toFixed(1)}ms each, v${pkg.version}${cfgStr})`), ); } else { - ret.push(chalk.gray(`(v${MinimalCore.getVersion()}${cfgStr})`)); + ret.push(chalk.gray(`(v${CoreMinimal.getVersion()}${cfgStr})`)); } return ret.join(" "); diff --git a/src/Data/ComputedData.js b/src/Data/ComputedData.js index 22196b7db..40f998a06 100644 --- a/src/Data/ComputedData.js +++ b/src/Data/ComputedData.js @@ -6,7 +6,7 @@ import ComputedDataTemplateString from "./ComputedDataTemplateString.js"; import ComputedDataProxy from "./ComputedDataProxy.js"; const { set: lodashSet, get: lodashGet } = lodash; -const debug = createDebug("Eleventy:ComputedData"); +const debug = createDebug("BuildAwesome:ComputedData"); class ComputedData { constructor(config) { diff --git a/src/Data/ComputedDataTemplateString.js b/src/Data/ComputedDataTemplateString.js index 9e29f3be3..228ec2da4 100644 --- a/src/Data/ComputedDataTemplateString.js +++ b/src/Data/ComputedDataTemplateString.js @@ -2,7 +2,7 @@ import lodash from "@11ty/lodash-custom"; import { createDebug } from "obug"; const { set: lodashSet } = lodash; -const debug = createDebug("Eleventy:ComputedDataTemplateString"); +const debug = createDebug("BuildAwesome:ComputedDataTemplateString"); /* Calculates computed data in Template Strings. * Ideally we would use the Proxy approach but it doesn’t work diff --git a/src/Data/ConfigurationGlobalData.js b/src/Data/ConfigurationGlobalData.js index e0a190cb3..9b86095e9 100644 --- a/src/Data/ConfigurationGlobalData.js +++ b/src/Data/ConfigurationGlobalData.js @@ -1,11 +1,11 @@ import lodash from "@11ty/lodash-custom"; import ReservedData from "../Util/ReservedData.js"; -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; const { set: lodashSet } = lodash; -class TemplateDataConfigError extends EleventyBaseError {} +class TemplateDataConfigError extends BaseError {} export default class ConfigurationGlobalData { constructor(templateConfig) { diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index b6fa0b921..870cc5225 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -7,27 +7,26 @@ import { inspect } from "../Adapters/Packages/inspect.js"; import unique from "../Util/Objects/Unique.js"; import TemplateGlob from "../TemplateGlob.js"; import { DataCascadeManager } from "./DataCascade.js"; -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; import ConfigurationGlobalData from "./ConfigurationGlobalData.js"; import { - getEleventyPackageJson, + getCorePackageJson, importJsonSync, getWorkingProjectPackageJsonPath, } from "../Util/ImportJsonSync.js"; -import { EleventyImport, EleventyLoadContent } from "../Util/Require.js"; +import { DynamicImport, LoadContent } from "../Util/Require.js"; import { DeepFreeze } from "../Util/Objects/DeepFreeze.js"; import { coerce } from "../Util/SemverCoerce.js"; import ProjectDirectories from "../Util/ProjectDirectories.js"; import ReservedData from "../Util/ReservedData.js"; -import { isTypeScriptSupported } from "../Util/FeatureTests.cjs"; +import { isTypeScriptSupported } from "../Util/TypeScriptFeatureTest.cjs"; const { set: lodashSet, get: lodashGet } = lodash; -const debugWarn = createDebug("Eleventy:Warnings"); -const debug = createDebug("Eleventy:TemplateData"); -const debugDev = createDebug("Dev:Eleventy:TemplateData"); +const debugWarn = createDebug("BuildAwesome:Warnings"); +const debug = createDebug("BuildAwesome:TemplateData"); -class TemplateDataParseError extends EleventyBaseError {} +class TemplateDataParseError extends BaseError {} class TemplateData { // Would be nice if the priorities here matched (see also FilePathUtil used by config file paths) @@ -351,7 +350,7 @@ class TemplateData { let files = TemplatePath.addLeadingDotSlashArray(await this.getGlobalDataFiles()); - this.config.events.emit("eleventy.globalDataFiles", files); + this.config.events.emit("buildawesome.globaldatafiles", files); let dataFileConflicts = {}; @@ -395,12 +394,12 @@ class TemplateData { getEleventyGlobal() { // #2293 for meta[name=generator] - const pkg = getEleventyPackageJson(); + const pkg = getCorePackageJson(); let version = coerce(pkg.version).toString(); let eleventy = { version, - generator: `Eleventy v${version}`, + generator: `Eleventy (Build Awesome) v${version}`, }; if (this.environmentVariables) { eleventy.env = Object.assign({}, this.environmentVariables); @@ -474,7 +473,7 @@ class TemplateData { return this.exists(path); }); - this.config.events.emit("eleventy.dataFiles", localDataPaths); + this.config.events.emit("buildawesome.datafiles", localDataPaths); if (!localDataPaths.length) { return localData; @@ -574,7 +573,7 @@ class TemplateData { let rawInput; if (readFile) { - rawInput = EleventyLoadContent(path, options); + rawInput = LoadContent(path, options); } if (readFile && !rawInput) { @@ -619,7 +618,7 @@ class TemplateData { } // We always need to use `import()`, as `require` isn’t available in ESM. - let returnValue = await EleventyImport(path, type); + let returnValue = await DynamicImport(path, type); // Returning a function is executed immediately (it has always done this for global data) @@ -694,9 +693,6 @@ class TemplateData { let parsed = path.parse(templatePath); let inputDir = this.inputDir; - debugDev("getLocalDataPaths(%o)", templatePath); - debugDev("parsed.dir: %o", parsed.dir); - let userExtensions = this.getUserDataExtensions(); if (parsed.dir) { @@ -712,14 +708,10 @@ class TemplateData { // Directory data file paths let allDirs = TemplatePath.getAllDirs(parsed.dir); - debugDev("allDirs: %o", allDirs); for (let dir of allDirs) { let lastDir = TemplatePath.getLastPathSegment(dir); let dirPathNoExt = dir + "/" + lastDir; - if (inputDir) { - debugDev("dirStr: %o; inputDir: %o", dir, inputDir); - } // TODO use DirContains if (!inputDir || (dir.startsWith(inputDir) && dir !== inputDir)) { if (this.config.dataFileDirBaseNameOverride) { diff --git a/src/Eleventy.js b/src/Eleventy.js deleted file mode 100644 index 6f2a0f5f5..000000000 --- a/src/Eleventy.js +++ /dev/null @@ -1,631 +0,0 @@ -import { relative } from "node:path"; -import { createDebug } from "obug"; - -import { TemplatePath } from "@11ty/eleventy-utils"; - -import { Core } from "./Core.js"; -import EleventyServe from "./EleventyServe.js"; -import { Watch } from "./Watch.js"; -import WatchQueue from "./WatchQueue.js"; -import WatchTargets from "./WatchTargets.js"; -import EleventyBaseError from "./Errors/EleventyBaseError.js"; - -// Utils -import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; -import PathPrefixer from "./Util/PathPrefixer.js"; -import PathNormalizer from "./Util/PathNormalizer.js"; -import { isGlobMatch } from "./Util/GlobMatcher.js"; -import eventBus from "./EventBus.js"; - -const debug = createDebug("Eleventy"); - -export default class Eleventy extends Core { - /** @type {boolean} */ - #isStopping = false; - - /** @type {WatchQueue} */ - #watchQueue; - - #watchDelay; - #interrupted = false; - - // constructor(input, output, options = {}, eleventyConfig = null) { - // super(input, output, options, eleventyConfig); - // } - - get watchQueue() { - if (!this.#watchQueue) { - this.#watchQueue = new WatchQueue(); - } - return this.#watchQueue; - } - - async initializeConfig(initOverrides) { - await super.initializeConfig(initOverrides); - - // Careful to make sure the previous server closes on SIGINT, issue #3873 - if (!this.eleventyServe) { - /** @type {object} */ - this.eleventyServe = new EleventyServe(); - } - this.eleventyServe.eleventyConfig = this.eleventyConfig; - - /** @type {object} */ - this.watchTargets = new WatchTargets(this.eleventyConfig); - this.watchTargets.add(this.config.additionalWatchTargets); - } - - async resetConfig() { - await super.resetConfig(); - - // TODO set this.eleventyServe with this.getChokidarConfig() - if (checkPassthroughCopyBehavior(this.config, this.runMode)) { - this.eleventyServe.resetConfig(); - } - } - - /** - * Starts Eleventy. - */ - async init(options = {}) { - await super.init(options); - - // eleventyServe is always available, even when not in --serve mode - // TODO directorynorm - this.eleventyServe.setOutputDir(this.outputDir); - - if (checkPassthroughCopyBehavior(this.config, this.runMode)) { - this.eleventyServe.watchPassthroughCopy( - this.eleventyFiles.getGlobWatcherFilesForPassthroughCopy(), - ); - } - } - - /** - * @param {string} changedFilePath - File that triggered a re-run (added or modified) - * @param {boolean} [isResetConfig] - are we doing a config reset - */ - #resetFileInWatchQueue(changedFilePath, isResetConfig) { - // v3.1.0: `eleventy.templateModified` is no longer used internally - // v4.0.0-alpha.8 `eleventy.templateModified` event removed - - // These listeners are *global*, not cleared even on config reset (v4.0.0-alpha.8 removed some arguments here) - eventBus.emit("eleventy.resourceModified", changedFilePath); - - this.config.events.emit("eleventy#templateModified", changedFilePath); - } - - shouldTriggerConfigReset(changedFiles) { - // looks for all eligible config files (not just the active one, handles config file rename) - let configFilePaths = new Set(this.eleventyConfig.getLocalProjectConfigFiles()); - - // https://www.11ty.dev/docs/watch-serve/#reset-configuration - let resetConfigGlobs = WatchTargets.normalizeToGlobs( - Array.from(this.eleventyConfig.userConfig.watchTargetsConfigReset), - ); - - for (let filePath of changedFiles) { - if (configFilePaths.has(filePath)) { - return true; - } - if (isGlobMatch(filePath, resetConfigGlobs)) { - return true; - } - } - - for (let configFilePath of configFilePaths) { - // Any dependencies of the config file changed - let configFileDependencies = new Set(this.watchTargets.getDependenciesOf(configFilePath)); - - for (let filePath of changedFiles) { - if (configFileDependencies.has(filePath)) { - return true; - } - } - } - - return false; - } - - // Checks the build queue to see if any configuration related files have changed - #shouldResetConfig(activeQueue = []) { - if (!activeQueue.length) { - return false; - } - - return this.shouldTriggerConfigReset( - activeQueue.map((path) => { - return PathNormalizer.normalizeSeperator(TemplatePath.addLeadingDotSlash(path)); - }), - ); - } - - async #rewatch() { - if (this.watchQueue.isBuildRunning()) { - // this.logger.forceLog("Waiting for previous build to finish…"); - return; - } - - this.watchQueue.startBuild(); - - let queue = this.watchQueue.getActiveQueue(); - let isResetConfig = this.#shouldResetConfig(queue); - - for (let p of queue) { - this.#resetFileInWatchQueue(p, isResetConfig); - } - - this.logger.forceLog( - `Build starting${queue.length > 1 ? ` (${queue.length} queued changes)` : ""}…` + - (isResetConfig ? " (configuration reset)" : ""), - ); - - await this.config.events.emit("beforeWatch", queue); - await this.config.events.emit("eleventy.beforeWatch", queue); - - // Clear `import` cache for all files that triggered the rebuild (sync event) - this.watchTargets.clearImportCacheFor(queue); - - // reset and reload global configuration - if (isResetConfig) { - // important: run this before config resets otherwise the handlers will disappear. - await this.config.events.emit("eleventy.reset"); - this.resetConfig(); - } - - await this.restart(); - await this.init({ viaConfigReset: isResetConfig }); - - try { - let [passthroughCopyResults, templateResults] = await this.write(); - - if (isResetConfig) { - // make sure this happens after write() - await this.startWatch(); - } - - this.watchTargets.reset(); - - await this.#initWatchDependencies(); - - // Add new deps to chokidar - let newWatchTargets = this.watchTargets.getNewTargetsSinceLastReset(); - this.watcher.watchTargets(newWatchTargets); - - // Is a CSS input file and is not in the includes folder - // TODO check output path file extension of this template (not input path) - // TODO add additional API for this, maybe a config callback? - let onlyCssChanges = this.watchQueue.hasAllQueueFiles((path) => { - return ( - path.endsWith(".css") && - // TODO how to make this work with relative includes? - !TemplatePath.startsWithSubPath(path, this.eleventyFiles.getIncludesDir()) - ); - }); - - // Maps passthrough copy files to output URLs for CSS live reload - let stylesheetUrls = new Set(); - for (let entry of passthroughCopyResults) { - for (let filepath in entry.map) { - if ( - filepath.endsWith(".css") && - queue.includes(TemplatePath.addLeadingDotSlash(filepath)) - ) { - stylesheetUrls.add( - "/" + TemplatePath.stripLeadingSubPath(entry.map[filepath], this.outputDir), - ); - } - } - } - - let normalizedPathPrefix = PathPrefixer.normalizePathPrefix(this.config.pathPrefix); - let matchingTemplates = templateResults - .flat() - .filter((entry) => Boolean(entry)) - .map((entry) => { - // only `url`, `inputPath`, and `content` are used: https://github.com/11ty/eleventy-dev-server/blob/1c658605f75224fdc76f68aebe7a412eeb4f1bc9/client/reload-client.js#L140 - entry.url = PathPrefixer.joinUrlParts(normalizedPathPrefix, entry.url); - delete entry.rawInput; // Issue #3481 - return entry; - }); - - await this.eleventyServe.reload({ - files: queue, - subtype: onlyCssChanges ? "css" : undefined, - build: { - stylesheets: Array.from(stylesheetUrls), - templates: matchingTemplates, - }, - }); - } catch (error) { - this.eleventyServe.sendError({ - error, - }); - } - - this.watchQueue.finishBuild(); - - // Re-fetch - let pendingQueue = this.watchQueue.getPendingQueue(); - if (pendingQueue.length > 0) { - await this.#rewatch(); - } else if (!this.#interrupted) { - // also logs in startWatch for initial build - this.logger.forceLog(`Waiting…`); - } - } - - /* - * SIGINT - */ - interrupt() { - this.#interrupted = true; - - // Clear the queue to prevent additional builds - this.watchQueue.reset(); - } - - /** - * @returns {module:11ty/eleventy/src/Benchmark/BenchmarkGroup~BenchmarkGroup} - */ - get watcherBench() { - return this.bench.get("Watcher"); - } - - async waitThrottle() { - if (this.#watchDelay) { - clearTimeout(this.#watchDelay); - } - - if (this.config.watchThrottleWaitTime > 0) { - let { promise, resolve } = Promise.withResolvers(); - - this.#watchDelay = setTimeout(resolve, this.config.watchThrottleWaitTime); - - return promise; - } - } - - // Triggers when files are modified on file system - async triggerWatchRunForPath(path) { - this.watchQueue.addToPendingQueue(path); - - await this.waitThrottle(); - - try { - await this.#rewatch(); - } catch (e) { - this.watchQueue.finishBuild(); - - if (e instanceof EleventyBaseError) { - this.errorHandler.error(e, "Eleventy watch error"); - } else { - this.errorHandler.fatal(e, "Eleventy fatal watch error"); - await this.close(); - } - } - - // Internal event for testing - // v4.0.0-alpha.8 swapped to async-friendly - await this.config.events.emit("eleventy.afterwatch"); - } - - /** - * Set up watchers and benchmarks. - * - * @async - * @method - */ - async startWatch() { - if (this.projectPackageJsonPath) { - this.watchTargets.add([relative(TemplatePath.getWorkingDir(), this.projectPackageJsonPath)]); - } - this.watchTargets.add(this.eleventyFiles.getGlobWatcherFiles()); - this.watchTargets.add(this.eleventyFiles.getIgnoreFiles()); - - // Watch the local project config file - this.watchTargets.add(this.eleventyConfig.getActiveConfigPath()); - - // Template and Directory Data Files - this.watchTargets.add(await this.eleventyFiles.getGlobWatcherTemplateDataFiles()); - - let benchmark = this.watcherBench.get( - "Watching JavaScript Dependencies (disable with `eleventyConfig.setWatchJavaScriptDependencies(false)`)", - ); - benchmark.before(); - await this.#initWatchDependencies(); - benchmark.after(); - - // Close previous watcher - if (this.watcher) { - await this.watcher.close(); - } - - // TODO improve unwatching if JS dependencies are removed (or files are deleted) - let { targets, ignores } = await this.getWatchedTargets(); - debug("Watching for changes to: %o", targets); - - this.watcher = new Watch(this.eleventyConfig); - this.watcher.watchTargets(targets); - this.watcher.addIgnores(ignores); - - await this.watcher.start(); - - // This logs in #rewatch for rebuilds - if (this.buildCount <= 1) { - this.logger.forceLog("Waiting…"); - } - - this.watcher.on("change", async (path) => { - // Emulated passthrough copy logs from the server - if (!this.eleventyServe.isEmulatedPassthroughCopyMatch(path)) { - this.logger.forceLog( - `File changed: ${TemplatePath.stripLeadingDotSlash(TemplatePath.standardizeFilePath(path))}${this.watchQueue.isBuildRunning() ? " (queued for next build)" : ""}`, - ); - } - - // don’t await - this.triggerWatchRunForPath(path); - }); - - this.watcher.on("add", async (path) => { - // Emulated passthrough copy logs from the server - if (!this.eleventyServe.isEmulatedPassthroughCopyMatch(path)) { - this.logger.forceLog( - `File added: ${TemplatePath.stripLeadingDotSlash(TemplatePath.standardizeFilePath(path))}${this.watchQueue.isBuildRunning() ? " (queued for next build)" : ""}`, - ); - } - - this.fileSystemSearch.add(path); - // don’t await - this.triggerWatchRunForPath(path); - }); - - this.watcher.on("unlink", async (path) => { - // Emulated passthrough copy logs from the server - if (!this.eleventyServe.isEmulatedPassthroughCopyMatch(path)) { - this.logger.forceLog( - `File deleted: ${TemplatePath.stripLeadingDotSlash(TemplatePath.standardizeFilePath(path))}${this.watchQueue.isBuildRunning() ? " (queued for next build)" : ""}`, - ); - } - - this.fileSystemSearch.delete(path); - // don’t await - this.triggerWatchRunForPath(path); - }); - } - - /** - * Starts watching dependencies. - */ - async #initWatchDependencies() { - if (!this.eleventyConfig.shouldSpiderJavaScriptDependencies()) { - return; - } - - // Lazy resolve isEsm only for --watch - this.watchTargets.setProjectUsingEsm(this.isEsm); - - // Template files .11ty.js - let templateFiles = await this.eleventyFiles.getWatchPathCache(); - await this.watchTargets.addDependencies(templateFiles); - - // TODO use DirContains - let dataDir = TemplatePath.stripLeadingDotSlash(this.templateData.getDataDir()); - function filterOutGlobalDataFiles(path) { - return !dataDir || !TemplatePath.stripLeadingDotSlash(path).startsWith(dataDir); - } - - // Config file dependencies - await this.watchTargets.addDependencies( - this.eleventyConfig.getActiveConfigPath(), - filterOutGlobalDataFiles, - ); - - // Deps from Global Data (that aren’t in the global data directory, everything is watched there) - let globalDataDeps = this.templateData.getWatchPathCache(); - await this.watchTargets.addDependencies(globalDataDeps, filterOutGlobalDataFiles); - - await this.watchTargets.addDependencies( - await this.eleventyFiles.getWatcherTemplateJavaScriptDataFiles(), - ); - } - - /** - * Returns all watched paths - * - * @async - * @method - * @returns {Object} `targets` file paths, and `ignores` globs Array - */ - async getWatchedTargets() { - return { - targets: await this.watchTargets.getTargets(), - ignores: this.eleventyFiles.getGlobWatcherIgnores(), - }; - } - - /** - * Start watching files - * - * @async - * @method - */ - async watch() { - this.watcherBench.setMinimumThresholdMs(500); - this.watcherBench.reset(); - - // Note that watching indirectly depends on this for fetching dependencies from JS files - // See: TemplateWriter:pathCache and WatchTargets - await this.write(); - - let initWatchBench = this.watcherBench.get("Start up --watch"); - initWatchBench.before(); - - await this.startWatch(); - - initWatchBench.after(); - - this.watcherBench.finish("Watch"); - } - - // Renamed to close() - async stopWatch() { - return this.close(); - } - - async close() { - // Prevent multiple invocations. - if (this.#isStopping) { - return this.#isStopping; - } - - debug("Cleaning up chokidar and server instances, if they exist."); - this.#isStopping = Promise.all([this.eleventyServe.close(), this.watcher?.close()]).then(() => { - this.#isStopping = false; - }); - - return this.#isStopping; - } - - /** - * Serve Eleventy on this port. - * - * @param {Number} port - The HTTP port to serve Eleventy from. - */ - async serve(port) { - this.eleventyServe.onEdit(async (path) => { - this.watcher.emit("change", path); - }); - - // Port is optional and in this case likely via --port on the command line - // May defer to configuration API options `port` property - return this.eleventyServe.serve(port); - } - - /** - * Shows a help message including usage. - * - * @static - * @returns {string} - The help message. - */ - static getHelp() { - return `Usage: eleventy - eleventy --input=. --output=./_site - eleventy --serve - -Arguments: - - --version - - --input=. - Input template files (default: \`.\`) - - --output=_site - Write HTML output to this folder (default: \`_site\`) - - --serve - Run web server on --port (default 8080) and watch them too - - --port - Run the --serve web server on this port (default 8080) - - --watch - Wait for files to change and automatically rewrite (no web server) - - --incremental - Only build the files that have changed. Best with watch/serve. - - --incremental=first.md,second.md - --incremental=first.md --incremental=second.md - Does not require watch/serve. Run an incremental build targeting one or more files. - - --ignore-initial - Start without a build; build when files change. Works best with watch/serve/incremental. - - --formats=liquid,md - Allow only certain template types (default: \`*\`) - - --quiet - Don’t print all written files (off by default) - - --config=filename.js - Override the eleventy config file path (default: \`.eleventy.js\`) - - --pathprefix='/' - Change all url template filters to use this subdirectory. - - --dryrun - Don’t write any files. Useful in DEBUG mode, for example: \`DEBUG=Eleventy* npx @11ty/eleventy --dryrun\` - - --loader - Set to "esm" to force ESM mode, "cjs" to force CommonJS mode, or "auto" (default) to infer it from package.json. - - --to=json - Change the output to JSON (default: \`fs\`) - - --to=fs:templates - Writes templates, skips passthrough copy - - --help`; - } - - /** - * @deprecated since 1.0.1, use static Eleventy.getHelp() - */ - getHelp() { - return Eleventy.getHelp(); - } - - /* Removed methods */ - initWatch() { - throw new Error( - "Eleventy#initWatch() was removed in v4. Use Eleventy#startWatch() instead (initializes and starts the watcher)", - ); - } - getWatchedFiles() { - throw new Error( - "Eleventy#getWatchedFiles() was removed in Eleventy v4. Use Eleventy#getWatchedTargets().targets instead.", - ); - } -} - -export { Eleventy }; - -/* Utils */ -export { EleventyImport as ImportFile } from "./Util/Require.js"; - -// TODO(breaking) remove these and recommend folks use package level exports e.g. "@11ty/eleventy/plugins/i18n" - -/* Plugins */ -export { default as BundlePlugin } from "@11ty/eleventy-plugin-bundle"; - -// Eleventy*Plugin names are legacy names -export { - default as RenderPlugin, - default as EleventyRenderPlugin, -} from "./Plugins/RenderPlugin.js"; -export { default as I18nPlugin, default as EleventyI18nPlugin } from "./Plugins/I18nPlugin.js"; -export { - default as HtmlBasePlugin, - default as EleventyHtmlBasePlugin, -} from "./Plugins/HtmlBasePlugin.js"; -export { TransformPlugin as InputPathToUrlTransformPlugin } from "./Plugins/InputPathToUrl.js"; -export { IdAttributePlugin } from "./Plugins/IdAttributePlugin.js"; - -export { PreserveClosingTagsPlugin } from "./Plugins/PreserveClosingTagsPlugin.js"; - -// Error messages for Removed plugins -export function EleventyServerlessBundlerPlugin() { - throw new Error( - "Following feedback from our Community Survey, low interest in this plugin prompted its removal from Eleventy core in 3.0 as we refocus on static sites. Learn more: https://v3.11ty.dev/docs/plugins/serverless/", - ); -} - -export { EleventyServerlessBundlerPlugin as EleventyServerless }; - -export function EleventyEdgePlugin() { - throw new Error( - "Following feedback from our Community Survey, low interest in this plugin prompted its removal from Eleventy core in 3.0 as we refocus on static sites. Learn more: https://v3.11ty.dev/docs/plugins/edge/", - ); -} diff --git a/src/Engines/Custom.js b/src/Engines/Custom.js index 4d28ac9bb..0bd86d7a7 100644 --- a/src/Engines/Custom.js +++ b/src/Engines/Custom.js @@ -11,7 +11,7 @@ export default class CustomEngine extends TemplateEngine { this.setDefaultEngine(undefined); this.previousQueue = []; - this.config.events.on("eleventy#previousqueue", (filePaths) => { + this.config.events.on("buildawesome#previousqueue", (filePaths) => { this.previousQueue = filePaths; }); } diff --git a/src/Engines/JavaScript.js b/src/Engines/JavaScript.js index 659d165c6..2f9e8e2fd 100644 --- a/src/Engines/JavaScript.js +++ b/src/Engines/JavaScript.js @@ -1,19 +1,19 @@ import { TemplatePath, isPlainObject } from "@11ty/eleventy-utils"; import TemplateEngine from "./TemplateEngine.js"; -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; import getJavaScriptData from "../Util/GetJavaScriptData.js"; -import { EleventyImport } from "../Util/Require.js"; +import { DynamicImport } from "../Util/Require.js"; import { augmentFunction, augmentObject } from "./Util/ContextAugmenter.js"; -class JavaScriptTemplateNotDefined extends EleventyBaseError {} +class JavaScriptTemplateNotDefined extends BaseError {} export default class JavaScript extends TemplateEngine { constructor(name, templateConfig) { super(name, templateConfig); this.instances = {}; - this.config.events.on("eleventy#templateModified", (inputPath, metadata = {}) => { + this.config.events.on("buildawesome#templatemodified", (inputPath, metadata = {}) => { let { usedByDependants, relevantLayouts } = metadata; // Remove from cached instances when modified let instancesToDelete = [ @@ -117,7 +117,7 @@ export default class JavaScript extends TemplateEngine { } else { let isEsm = this.eleventyConfig.getIsProjectUsingEsm(); let cacheBust = !this.cacheable || !this.config.useTemplateCache; - mod = await EleventyImport(inputPath, isEsm ? "esm" : "cjs", { + mod = await DynamicImport(inputPath, isEsm ? "esm" : "cjs", { cacheBust, }); } diff --git a/src/Engines/Nunjucks.js b/src/Engines/Nunjucks.js index e0267d5ba..2c3afc4ae 100755 --- a/src/Engines/Nunjucks.js +++ b/src/Engines/Nunjucks.js @@ -9,13 +9,13 @@ import { Template, } from "@11ty/nunjucks/index.js"; import TemplateEngine from "./TemplateEngine.js"; -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; import { augmentObject } from "./Util/ContextAugmenter.js"; import { ArgumentHelper } from "../Data/DataSourceLocation.js"; -const debug = createDebug("Eleventy:Nunjucks"); +const debug = createDebug("BuildAwesome:Nunjucks"); -class EleventyNunjucksError extends EleventyBaseError {} +class EleventyNunjucksError extends BaseError {} export default class Nunjucks extends TemplateEngine { constructor(name, eleventyConfig) { @@ -77,7 +77,7 @@ export default class Nunjucks extends TemplateEngine { this.njkEnv = new Environment(loaders, this.nunjucksEnvironmentOptions); } - this.config.events.emit("eleventy.engine.njk", { + this.config.events.emit("buildawesome.engine.njk", { nunjucks: NunjucksLib, environment: this.njkEnv, }); @@ -88,7 +88,7 @@ export default class Nunjucks extends TemplateEngine { // Note that a new Nunjucks engine instance is created for subsequent builds // Eleventy Nunjucks is set to `cacheable` false above to opt out of Eleventy cache - this.config.events.on("eleventy#templateModified", (templatePath) => { + this.config.events.on("buildawesome#templatemodified", (templatePath) => { // NunjucksEnvironment: // loader.pathToNames: {'ABSOLUTE_PATH/src/_includes/components/possum-home.css': 'components/possum-home.css'} // loader.cache: { 'components/possum-home.css': [Template] } diff --git a/src/Engines/TemplateEngine.js b/src/Engines/TemplateEngine.js index 1f72f6ac7..8f3cbb8d7 100644 --- a/src/Engines/TemplateEngine.js +++ b/src/Engines/TemplateEngine.js @@ -1,9 +1,9 @@ import { createDebug } from "obug"; -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; -class TemplateEngineConfigError extends EleventyBaseError {} +class TemplateEngineConfigError extends BaseError {} -const debug = createDebug("Eleventy:TemplateEngine"); +const debug = createDebug("BuildAwesome:TemplateEngine"); const AMENDED_INSTANCES = new Set(); diff --git a/src/Engines/TemplateEngineManager.js b/src/Engines/TemplateEngineManager.js index 3ff6d0bbe..41143183c 100644 --- a/src/Engines/TemplateEngineManager.js +++ b/src/Engines/TemplateEngineManager.js @@ -1,14 +1,13 @@ import { createDebug } from "obug"; -import EleventyBaseError from "../Errors/EleventyBaseError.js"; -const debug = createDebug("Eleventy:TemplateEngineManager"); +const debug = createDebug("BuildAwesome:TemplateEngineManager"); class TemplateEngineManager { #CustomEngine; constructor(eleventyConfig) { if (!eleventyConfig || eleventyConfig.constructor.name !== "TemplateConfig") { - throw new EleventyBaseError("Missing or invalid `config` argument."); + throw new Error("Internal error: missing or invalid `config` argument."); } this.eleventyConfig = eleventyConfig; diff --git a/src/Errors/EleventyBaseError.js b/src/Errors/BaseError.js similarity index 88% rename from src/Errors/EleventyBaseError.js rename to src/Errors/BaseError.js index daf7f35e9..5e16bc841 100644 --- a/src/Errors/EleventyBaseError.js +++ b/src/Errors/BaseError.js @@ -2,7 +2,7 @@ * This class serves as basis for all Eleventy-specific errors. * @ignore */ -class EleventyBaseError extends Error { +export default class BaseError extends Error { /** * @param {string} message - The error message to display. * @param {unknown} [originalError] - The original error caught. @@ -26,4 +26,3 @@ class EleventyBaseError extends Error { } } } -export default EleventyBaseError; diff --git a/src/Errors/DuplicatePermalinkOutputError.js b/src/Errors/DuplicatePermalinkOutputError.js index 444195c70..f5ed3493d 100644 --- a/src/Errors/DuplicatePermalinkOutputError.js +++ b/src/Errors/DuplicatePermalinkOutputError.js @@ -1,9 +1,7 @@ -import EleventyBaseError from "./EleventyBaseError.js"; +import BaseError from "./BaseError.js"; -class DuplicatePermalinkOutputError extends EleventyBaseError { +export default class DuplicatePermalinkOutputError extends BaseError { get removeDuplicateErrorStringFromOutput() { return true; } } - -export default DuplicatePermalinkOutputError; diff --git a/src/Errors/EleventyErrorHandler.js b/src/Errors/ErrorHandler.js similarity index 85% rename from src/Errors/EleventyErrorHandler.js rename to src/Errors/ErrorHandler.js index c747cba1f..56cd6a97a 100644 --- a/src/Errors/EleventyErrorHandler.js +++ b/src/Errors/ErrorHandler.js @@ -2,11 +2,11 @@ import { createDebug } from "obug"; import { inspect } from "../Adapters/Packages/inspect.js"; import ConsoleLogger from "../Util/ConsoleLogger.js"; -import EleventyErrorUtil from "./EleventyErrorUtil.js"; +import ErrorUtil from "./ErrorUtil.js"; -const debug = createDebug("Eleventy:EleventyErrorHandler"); +const debug = createDebug("BuildAwesome:ErrorHandler"); -class EleventyErrorHandler { +export class ErrorHandler { constructor() { this._isVerbose = true; } @@ -80,7 +80,7 @@ class EleventyErrorHandler { showStack = false; } - let totalErrorCount = EleventyErrorHandler.getTotalErrorCount(e); + let totalErrorCount = ErrorHandler.getTotalErrorCount(e); let ref = e; let index = 1; let debugs = []; @@ -92,8 +92,8 @@ class EleventyErrorHandler { nextRef.originalError = nextRef.cause?.originalError ?? nextRef?.cause; } - if (!nextRef && EleventyErrorUtil.hasEmbeddedError(ref.message)) { - nextRef = EleventyErrorUtil.deconvertErrorToObject(ref); + if (!nextRef && ErrorUtil.hasEmbeddedError(ref.message)) { + nextRef = ErrorUtil.deconvertErrorToObject(ref); } if (nextRef?.skipOriginalStack) { @@ -102,7 +102,7 @@ class EleventyErrorHandler { messages.push( `${totalErrorCount > 1 ? `${index}. ` : ""}${( - EleventyErrorUtil.cleanMessage(ref.message) || "(No error message provided)" + ErrorUtil.cleanMessage(ref.message) || "(No error message provided)" ).trim()}${ref.name !== "Error" ? ` (via ${ref.name})` : ""}`, ); @@ -140,5 +140,3 @@ class EleventyErrorHandler { } } } - -export { EleventyErrorHandler }; diff --git a/src/Errors/EleventyErrorUtil.js b/src/Errors/ErrorUtil.js similarity index 65% rename from src/Errors/EleventyErrorUtil.js rename to src/Errors/ErrorUtil.js index 6b374d01a..fa05498a6 100644 --- a/src/Errors/EleventyErrorUtil.js +++ b/src/Errors/ErrorUtil.js @@ -1,7 +1,7 @@ import TemplateContentPrematureUseError from "./TemplateContentPrematureUseError.js"; /* Hack to workaround the variety of error handling schemes in template languages */ -class EleventyErrorUtil { +export default class ErrorUtil { static get prefix() { return ">>>>>11ty>>>>>"; } @@ -14,7 +14,7 @@ class EleventyErrorUtil { return false; } - return msg.includes(EleventyErrorUtil.prefix) && msg.includes(EleventyErrorUtil.suffix); + return msg.includes(ErrorUtil.prefix) && msg.includes(ErrorUtil.suffix); } static cleanMessage(msg) { @@ -22,25 +22,25 @@ class EleventyErrorUtil { return ""; } - if (!EleventyErrorUtil.hasEmbeddedError(msg)) { + if (!ErrorUtil.hasEmbeddedError(msg)) { return "" + msg; } - return msg.slice(0, Math.max(0, msg.indexOf(EleventyErrorUtil.prefix))); + return msg.slice(0, Math.max(0, msg.indexOf(ErrorUtil.prefix))); } static deconvertErrorToObject(error) { if (!error || !error.message) { throw new Error(`Could not convert error object from: ${error}`); } - if (!EleventyErrorUtil.hasEmbeddedError(error.message)) { + if (!ErrorUtil.hasEmbeddedError(error.message)) { return error; } let msg = error.message; let objectString = msg.substring( - msg.indexOf(EleventyErrorUtil.prefix) + EleventyErrorUtil.prefix.length, - msg.lastIndexOf(EleventyErrorUtil.suffix), + msg.indexOf(ErrorUtil.prefix) + ErrorUtil.prefix.length, + msg.lastIndexOf(ErrorUtil.suffix), ); let obj = JSON.parse(objectString); obj.name = error.name; @@ -50,9 +50,9 @@ class EleventyErrorUtil { // pass an error through a random template engine’s error handling unscathed static convertErrorToString(error) { return ( - EleventyErrorUtil.prefix + + ErrorUtil.prefix + JSON.stringify({ message: error.message, stack: error.stack }) + - EleventyErrorUtil.suffix + ErrorUtil.suffix ); } @@ -61,10 +61,9 @@ class EleventyErrorUtil { return ( e instanceof TemplateContentPrematureUseError || e?.cause instanceof TemplateContentPrematureUseError || // Custom (per Node-convention) - ["RenderError", "UndefinedVariableError"].includes(e?.originalError?.name) && e?.originalError?.originalError instanceof TemplateContentPrematureUseError || // Liquid + (["RenderError", "UndefinedVariableError"].includes(e?.originalError?.name) && + e?.originalError?.originalError instanceof TemplateContentPrematureUseError) || // Liquid e?.message?.includes("TemplateContentPrematureUseError") // Nunjucks ); } } - -export default EleventyErrorUtil; diff --git a/src/Errors/TemplateContentPrematureUseError.js b/src/Errors/TemplateContentPrematureUseError.js index 5266cd271..11fe2018d 100644 --- a/src/Errors/TemplateContentPrematureUseError.js +++ b/src/Errors/TemplateContentPrematureUseError.js @@ -1,5 +1,3 @@ -import EleventyBaseError from "./EleventyBaseError.js"; +import BaseError from "./BaseError.js"; -class TemplateContentPrematureUseError extends EleventyBaseError {} - -export default TemplateContentPrematureUseError; +export default class TemplateContentPrematureUseError extends BaseError {} diff --git a/src/Errors/TemplateContentUnrenderedTemplateError.js b/src/Errors/TemplateContentUnrenderedTemplateError.js index ee270d5de..f032cbc52 100644 --- a/src/Errors/TemplateContentUnrenderedTemplateError.js +++ b/src/Errors/TemplateContentUnrenderedTemplateError.js @@ -1,5 +1,3 @@ -import EleventyBaseError from "./EleventyBaseError.js"; +import BaseError from "./BaseError.js"; -class TemplateContentUnrenderedTemplateError extends EleventyBaseError {} - -export default TemplateContentUnrenderedTemplateError; +export default class TemplateContentUnrenderedTemplateError extends BaseError {} diff --git a/src/Errors/UsingCircularTemplateContentReferenceError.js b/src/Errors/UsingCircularTemplateContentReferenceError.js index 5608febb3..b4660e721 100644 --- a/src/Errors/UsingCircularTemplateContentReferenceError.js +++ b/src/Errors/UsingCircularTemplateContentReferenceError.js @@ -1,5 +1,3 @@ -import EleventyBaseError from "./EleventyBaseError.js"; +import BaseError from "./BaseError.js"; -class UsingCircularTemplateContentReferenceError extends EleventyBaseError {} - -export default UsingCircularTemplateContentReferenceError; +export default class UsingCircularTemplateContentReferenceError extends BaseError {} diff --git a/src/EventBus.js b/src/EventBus.js index 127f5697d..b3e0c1a76 100644 --- a/src/EventBus.js +++ b/src/EventBus.js @@ -2,7 +2,7 @@ import { createDebug } from "obug"; import EventEmitter from "./Util/AsyncEventEmitter.js"; -const debug = createDebug("Eleventy:EventBus"); +const debug = createDebug("BuildAwesome:EventBus"); /** * @module 11ty/eleventy/EventBus diff --git a/src/EleventyExtensionMap.js b/src/ExtensionMap.js similarity index 97% rename from src/EleventyExtensionMap.js rename to src/ExtensionMap.js index 051dc7547..36300d628 100644 --- a/src/EleventyExtensionMap.js +++ b/src/ExtensionMap.js @@ -1,8 +1,8 @@ import { TemplatePath } from "@11ty/eleventy-utils"; -import { isTypeScriptSupported } from "./Util/FeatureTests.cjs"; +import { isTypeScriptSupported } from "./Util/TypeScriptFeatureTest.cjs"; -class EleventyExtensionMap { +export default class ExtensionMap { #engineManager; constructor(config) { @@ -42,7 +42,7 @@ class EleventyExtensionMap { get engineManager() { if (!this.#engineManager) { - throw new Error("Internal error: Missing `#engineManager` in EleventyExtensionMap."); + throw new Error("Internal error: Missing `#engineManager` in ExtensionMap."); } return this.#engineManager; @@ -288,5 +288,3 @@ class EleventyExtensionMap { return Object.keys(this.extensionToKeyMap).join(" "); } } - -export default EleventyExtensionMap; diff --git a/src/FileSystemSearch.js b/src/FileSystemSearch.js index efc8ea1db..2d6496a79 100644 --- a/src/FileSystemSearch.js +++ b/src/FileSystemSearch.js @@ -5,7 +5,7 @@ import { createDebug } from "obug"; import GlobRemap from "./Util/GlobRemap.js"; import { isGlobMatch } from "./Util/GlobMatcher.js"; -const debug = createDebug("Eleventy:FileSystemSearch"); +const debug = createDebug("BuildAwesome:FileSystemSearch"); class FileSystemSearch { constructor() { diff --git a/src/EleventyFiles.js b/src/Files.js similarity index 97% rename from src/EleventyFiles.js rename to src/Files.js index 69d438100..e989b664b 100644 --- a/src/EleventyFiles.js +++ b/src/Files.js @@ -8,9 +8,9 @@ import TemplateData from "./Data/TemplateData.js"; import TemplateGlob from "./TemplateGlob.js"; import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; -const debug = createDebug("Eleventy:EleventyFiles"); +const debug = createDebug("BuildAwesome:Files"); -class EleventyFiles { +export class Files { #extensionMap; #watcherGlobs; @@ -158,7 +158,7 @@ class EleventyFiles { // Conditional added for tests that don’t have a config if (this.config?.events) { - this.config.events.emit("eleventy.ignores", this.uniqueIgnores); + this.config.events.emit("buildawesome.ignores", this.uniqueIgnores); } this.normalizedTemplateGlobs = this.templateGlobs; @@ -228,7 +228,9 @@ class EleventyFiles { ">>> When processing .gitignore/.eleventyignore, Eleventy does not currently support negative patterns but encountered one:", ); debug(">>>", line); - debug("Follow along at https://github.com/11ty/eleventy/issues/693 to track support."); + debug( + "Follow along at https://github.com/11ty/build-awesome/issues/693 to track support.", + ); } // empty lines or comments get filtered out @@ -459,5 +461,3 @@ class EleventyFiles { }); } } - -export default EleventyFiles; diff --git a/src/GlobalDependencyMap.js b/src/GlobalDependencyMap.js index e6be20ac4..d1a8e4cfd 100644 --- a/src/GlobalDependencyMap.js +++ b/src/GlobalDependencyMap.js @@ -5,7 +5,7 @@ import JavaScriptDependencies from "./Util/JavaScriptDependencies.js"; import PathNormalizer from "./Util/PathNormalizer.js"; import { TemplateDepGraph } from "./Util/TemplateDepGraph.js"; -const debug = createDebug("Eleventy:Dependencies"); +const debug = createDebug("BuildAwesome:Dependencies"); class GlobalDependencyMap { // dependency-graph requires these keys to be alphabetic strings diff --git a/src/LayoutCache.js b/src/LayoutCache.js index 006f502d0..48142e982 100644 --- a/src/LayoutCache.js +++ b/src/LayoutCache.js @@ -89,7 +89,7 @@ class LayoutCache { let layoutCache = new LayoutCache(); -eventBus.on("eleventy.resourceModified", () => { +eventBus.on("buildawesome.resourceModified", () => { // https://github.com/11ty/eleventy-plugin-bundle/issues/10 layoutCache.removeAll(); }); diff --git a/src/Plugins/I18nPlugin.js b/src/Plugins/I18nPlugin.js index 6d48c633a..66c3d56d0 100644 --- a/src/Plugins/I18nPlugin.js +++ b/src/Plugins/I18nPlugin.js @@ -174,13 +174,13 @@ function I18nPlugin(eleventyConfig, opts = {}) { } let extensionMap; - eleventyConfig.on("eleventy.extensionmap", (map) => { + eleventyConfig.on("buildawesome.extensionmap", (map) => { extensionMap = map; }); let bench = eleventyConfig.benchmarkManager.get("Aggregate"); let contentMaps = {}; - eleventyConfig.on("eleventy.contentMap", function ({ urlToInputPath, inputPathToUrl }) { + eleventyConfig.on("buildawesome.contentmap", function ({ urlToInputPath, inputPathToUrl }) { let b = bench.get("(i18n Plugin) Setting up content map."); b.before(); contentMaps.inputPathToUrl = inputPathToUrl; diff --git a/src/Plugins/InputPathToUrl.js b/src/Plugins/InputPathToUrl.js index 1878a0d6d..4aee918e1 100644 --- a/src/Plugins/InputPathToUrl.js +++ b/src/Plugins/InputPathToUrl.js @@ -84,7 +84,7 @@ function parseFilePath(filepath) { function FilterPlugin(eleventyConfig) { let contentMap; - eleventyConfig.on("eleventy.contentMap", function ({ inputPathToUrl }) { + eleventyConfig.on("buildawesome.contentmap", function ({ inputPathToUrl }) { contentMap = inputPathToUrl; }); @@ -130,7 +130,7 @@ function TransformPlugin(eleventyConfig, defaultOptions = {}) { ); let contentMap = null; - eleventyConfig.on("eleventy.contentMap", function ({ inputPathToUrl }) { + eleventyConfig.on("buildawesome.contentmap", function ({ inputPathToUrl }) { contentMap = inputPathToUrl; }); diff --git a/src/Plugins/Pagination.js b/src/Plugins/Pagination.js index 7b9bc86de..11b991d19 100755 --- a/src/Plugins/Pagination.js +++ b/src/Plugins/Pagination.js @@ -2,15 +2,15 @@ import { isPlainObject } from "@11ty/eleventy-utils"; import lodash from "@11ty/lodash-custom"; import { DeepCopy } from "@11ty/eleventy-utils"; -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; import { ProxyWrap } from "../Util/Objects/ProxyWrap.js"; // import { DeepFreeze } from "../Util/Objects/DeepFreeze.js"; import TemplateData from "../Data/TemplateData.js"; const { set: lodashSet, get: lodashGet, chunk: lodashChunk } = lodash; -class PaginationConfigError extends EleventyBaseError {} -class PaginationError extends EleventyBaseError {} +class PaginationConfigError extends BaseError {} +class PaginationError extends BaseError {} class Pagination { constructor(tmpl, data, config) { diff --git a/src/Plugins/RenderPlugin.js b/src/Plugins/RenderPlugin.js index 972dbd660..589199359 100644 --- a/src/Plugins/RenderPlugin.js +++ b/src/Plugins/RenderPlugin.js @@ -5,15 +5,15 @@ import { Merge, TemplatePath, isPlainObject } from "@11ty/eleventy-utils"; import { ProxyWrap } from "../Util/Objects/ProxyWrap.js"; import ConfigurationGlobalData from "../Data/ConfigurationGlobalData.js"; -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; import TemplateRender from "../TemplateRender.js"; import ProjectDirectories from "../Util/ProjectDirectories.js"; import TemplateConfig from "../TemplateConfig.js"; -import EleventyExtensionMap from "../EleventyExtensionMap.js"; +import ExtensionMap from "../ExtensionMap.js"; import TemplateEngineManager from "../Engines/TemplateEngineManager.js"; import Liquid from "../Adapters/Engines/Liquid.js"; -class EleventyNunjucksError extends EleventyBaseError {} +class NunjucksError extends BaseError {} /** @this {object} */ async function compile(content, templateLang, options = {}) { @@ -35,7 +35,7 @@ async function compile(content, templateLang, options = {}) { if (strictMode) { throw new Error("Internal error: missing `extensionMap` in RenderPlugin->compile."); } - extensionMap = new EleventyExtensionMap(templateConfig); + extensionMap = new ExtensionMap(templateConfig); extensionMap.engineManager = new TemplateEngineManager(templateConfig); } let tr = new TemplateRender(templateLang, templateConfig); @@ -99,7 +99,7 @@ async function compileFile(inputPath, options = {}, templateLang) { throw new Error("Internal error: missing `extensionMap` in RenderPlugin->compileFile."); } - extensionMap = new EleventyExtensionMap(templateConfig); + extensionMap = new ExtensionMap(templateConfig); extensionMap.engineManager = new TemplateEngineManager(templateConfig); } let tr = new TemplateRender(inputPath, templateConfig); @@ -163,12 +163,12 @@ async function renderShortcodeFn(fn, data) { */ function RenderPlugin(eleventyConfig, options = {}) { let templateConfig; - eleventyConfig.on("eleventy.config", (tmplConfigInstance) => { + eleventyConfig.on("buildawesome.config", (tmplConfigInstance) => { templateConfig = tmplConfigInstance; }); let extensionMap; - eleventyConfig.on("eleventy.extensionmap", (map) => { + eleventyConfig.on("buildawesome.extensionmap", (map) => { extensionMap = map; }); @@ -328,9 +328,7 @@ function RenderPlugin(eleventyConfig, options = {}) { body(function (e, bodyContent) { if (e) { - resolve( - new EleventyNunjucksError(`Error with Nunjucks paired shortcode \`${tagName}\``, e), - ); + resolve(new NunjucksError(`Error with Nunjucks paired shortcode \`${tagName}\``, e)); } Promise.resolve( @@ -346,7 +344,7 @@ function RenderPlugin(eleventyConfig, options = {}) { }, function (e) { resolve( - new EleventyNunjucksError(`Error with Nunjucks paired shortcode \`${tagName}\``, e), + new NunjucksError(`Error with Nunjucks paired shortcode \`${tagName}\``, e), null, ); }, @@ -440,7 +438,7 @@ class RenderManager { accessGlobalData: true, }); - this.#extensionMap = new EleventyExtensionMap(this.#templateConfig); + this.#extensionMap = new ExtensionMap(this.#templateConfig); this.#extensionMap.engineManager = new TemplateEngineManager(this.#templateConfig); } diff --git a/src/EleventyCommonJs.cjs b/src/RequireEsmFeatureTest.cjs similarity index 97% rename from src/EleventyCommonJs.cjs rename to src/RequireEsmFeatureTest.cjs index 5191bc144..66422f50e 100644 --- a/src/EleventyCommonJs.cjs +++ b/src/RequireEsmFeatureTest.cjs @@ -38,6 +38,6 @@ if(!canRequireModules()) { } // If we made it here require(ESM) works fine (via --experimental-require-module or newer Node.js defaults) -let mod = require("./Eleventy.js"); +let mod = require("./Core.js"); module.exports = mod; diff --git a/src/EleventyServe.js b/src/Serve.js similarity index 91% rename from src/EleventyServe.js rename to src/Serve.js index 61190a7b5..34fd3d8cb 100644 --- a/src/EleventyServe.js +++ b/src/Serve.js @@ -13,17 +13,17 @@ function stringifyOptions(options) { }); } -import EleventyBaseError from "./Errors/EleventyBaseError.js"; +import BaseError from "./Errors/BaseError.js"; import ConsoleLogger from "./Util/ConsoleLogger.js"; import PathPrefixer from "./Util/PathPrefixer.js"; import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; import { getModulePackageJson } from "./Util/ImportJsonSync.js"; -import { EleventyImport } from "./Util/Require.js"; +import { DynamicImport } from "./Util/Require.js"; import { isGlobMatch } from "./Util/GlobMatcher.js"; -const debug = createDebug("Eleventy:EleventyServe"); +const debug = createDebug("BuildAwesome:Serve"); -class EleventyServeConfigError extends EleventyBaseError {} +class ServeConfigError extends BaseError {} const DEFAULT_SERVER_OPTIONS = { module: "@11ty/eleventy-dev-server", @@ -34,7 +34,7 @@ const DEFAULT_SERVER_OPTIONS = { // logger: { info: function() {}, error: function() {} } }; -class EleventyServe { +export default class Serve { #eleventyConfig; #savedConfigOptions; #aliases; @@ -50,16 +50,14 @@ class EleventyServe { get config() { if (!this.eleventyConfig) { - throw new EleventyServeConfigError( - "You need to set the eleventyConfig property on EleventyServe.", - ); + throw new ServeConfigError("You need to set the eleventyConfig property on Serve."); } return this.eleventyConfig.getConfig(); } set config(config) { - throw new Error("It’s not allowed to set config on EleventyServe. Set eleventyConfig instead."); + throw new Error("It’s not allowed to set config on Serve. Set eleventyConfig instead."); } setAliases(aliases) { @@ -72,9 +70,7 @@ class EleventyServe { get eleventyConfig() { if (!this.#eleventyConfig) { - throw new EleventyServeConfigError( - "You need to set the eleventyConfig property on EleventyServe.", - ); + throw new ServeConfigError("You need to set the eleventyConfig property on Serve."); } return this.#eleventyConfig; @@ -84,7 +80,7 @@ class EleventyServe { this.#eleventyConfig = config; if (checkPassthroughCopyBehavior(this.#eleventyConfig.userConfig, "serve")) { - this.#eleventyConfig.userConfig.events.on("eleventy.passthrough", ({ map }) => { + this.#eleventyConfig.userConfig.events.on("buildawesome.passthrough", ({ map }) => { // for-free passthrough copy this.setAliases(map); }); @@ -107,7 +103,7 @@ class EleventyServe { async getServerModule(name) { try { if (!name || name === DEFAULT_SERVER_OPTIONS.module) { - return EleventyServe.getDevServer(); + return Serve.getDevServer(); } // Look for peer dep in local project @@ -134,7 +130,7 @@ class EleventyServe { } } - let module = await EleventyImport(serverPath); + let module = await DynamicImport(serverPath); if (!("getServer" in module)) { throw new Error( @@ -158,7 +154,7 @@ class EleventyServe { ); debug("Eleventy server error %o", e); - return EleventyServe.getDevServer(); + return Serve.getDevServer(); } } @@ -334,7 +330,7 @@ class EleventyServe { await this.serve(this._commandLinePort); } - // checkPassthroughCopyBehavior check is called upstream in Eleventy.js + // checkPassthroughCopyBehavior check is called upstream in Core.js watchPassthroughCopy(globs = []) { for (let glob of globs) { this.#watchTargets.add(glob); @@ -379,5 +375,3 @@ class EleventyServe { this.#editCallbacks.push(callback); } } - -export default EleventyServe; diff --git a/src/Template.js b/src/Template.js index c89ced342..4559d0c93 100755 --- a/src/Template.js +++ b/src/Template.js @@ -17,18 +17,17 @@ import Pagination from "./Plugins/Pagination.js"; import TemplateBehavior from "./TemplateBehavior.js"; import TemplateContentPrematureUseError from "./Errors/TemplateContentPrematureUseError.js"; import TemplateContentUnrenderedTemplateError from "./Errors/TemplateContentUnrenderedTemplateError.js"; -import EleventyBaseError from "./Errors/EleventyBaseError.js"; +import BaseError from "./Errors/BaseError.js"; import { fromISOtoDateUTC } from "./Util/DateParse.js"; import ReservedData from "./Util/ReservedData.js"; import TransformsUtil from "./Util/TransformsUtil.js"; -import { FileSystemManager } from "./Util/FileSystemManager.js"; +import { FileSystemUtilities } from "./Util/FileSystemUtilities.js"; import { TemplatePreprocessors } from "./TemplatePreprocessors.js"; import { getDirectoryFromUrl } from "./Util/UrlUtil.js"; const { set: lodashSet, get: lodashGet } = lodash; -const debug = createDebug("Eleventy:Template"); -const debugDev = createDebug("Dev:Eleventy:Template"); +const debug = createDebug("BuildAwesome:Template"); class Template extends TemplateContent { #logger; @@ -44,7 +43,6 @@ class Template extends TemplateContent { #preprocessorCache; constructor(templatePath, templateData, extensionMap, config) { - debugDev("new Template(%o)", templatePath); super(templatePath, config); this.parsed = parse(templatePath); @@ -90,7 +88,7 @@ class Template extends TemplateContent { get fsManager() { if (!this.#fsManager) { - this.#fsManager = new FileSystemManager(this.eleventyConfig); + this.#fsManager = new FileSystemUtilities(this.eleventyConfig); } return this.#fsManager; } @@ -200,7 +198,7 @@ class Template extends TemplateContent { try { return TemplateLayout.getTemplate(layoutKey, this.eleventyConfig, this.extensionMap); } catch (e) { - throw new EleventyBaseError( + throw new BaseError( `Problem creating an Eleventy Layout for the "${this.inputPath}" template file.`, e, ); @@ -226,11 +224,9 @@ class Template extends TemplateContent { // `permalink: false` means render but no file system write, e.g. use in collections only) // `permalink: true` throws an error if (typeof permalink === "boolean") { - debugDev("Using boolean permalink %o", permalink); permalinkValue = permalink; } else if (permalink && !isDynamicPermalinkEnabled) { // Issue #838 - debugDev("Not using dynamic permalinks, using %o", permalink); permalinkValue = permalink; } else if (isPlainObject(permalink)) { // Empty permalink {} object should act as if no permalink was set at all @@ -269,7 +265,6 @@ class Template extends TemplateContent { // render variables inside permalink front matter, bypass markdown permalinkValue = await super.renderPermalink(permalink, data); debug("Rendering permalink for %o: %s becomes %o", this.inputPath, permalink, permalinkValue); - debugDev("Permalink rendered with data: %o", data); } // Override default permalink behavior. Only do this if permalink was _not_ in the data cascade @@ -385,14 +380,12 @@ class Template extends TemplateContent { } async #getData() { - debugDev("%o getData", this.inputPath); let localData = {}; let globalData = {}; if (this.templateData) { localData = await this.templateData.getTemplateDirectoryData(this.inputPath); globalData = await this.templateData.getGlobalData(); - debugDev("%o getData getTemplateDirectoryData and getGlobalData", this.inputPath); } let { data: frontMatterData } = await this.getFrontMatterData(); @@ -413,7 +406,6 @@ class Template extends TemplateContent { // TODO disable/toggle enabled this.#layoutDataCascade = layout.getLayoutDataCascade(); - debugDev("%o getData merged layout chain front matter", this.inputPath); } } @@ -428,8 +420,6 @@ class Template extends TemplateContent { Merge(mergedData, { page: pageData }); - debugDev("%o getData mergedData", this.inputPath); - return mergedData; } catch (e) { // if ReservedDataError, defer to that (from ReservedData.checkSubset above) @@ -534,7 +524,7 @@ class Template extends TemplateContent { // see also Eleventy->#resetFileInWatchQueue() internalTriggerTemplateModifiedPath(changedFilePath) { - this.config.events.emit("eleventy#templateModified", changedFilePath); + this.config.events.emit("buildawesome#templatemodified", changedFilePath); } // This is the primary render mechanism, called via TemplateMap->populateContentDataInMap @@ -1239,7 +1229,6 @@ class Template extends TemplateContent { // Important reminder: Template data is first generated in TemplateMap async getTemplateMapEntry(data) { - debugDev("%o getMapped()", this.inputPath); this.behavior.setRenderViaDataCascade(data); // does not return outputPath or url, we don’t want to render permalinks yet diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index cc7a834de..41353887c 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -4,8 +4,8 @@ import lodash from "@11ty/lodash-custom"; import chalk from "./Adapters/Packages/chalk.js"; import getDefaultConfig from "./Adapters/getDefaultConfig.js"; -import { EleventyImportRaw } from "./Util/Require.js"; -import EleventyBaseError from "./Errors/EleventyBaseError.js"; +import { DynamicImportRaw } from "./Util/Require.js"; +import BaseError from "./Errors/BaseError.js"; import UserConfig from "./UserConfig.js"; import GlobalDependencyMap from "./GlobalDependencyMap.js"; import ExistsCache from "./Util/ExistsCache.js"; @@ -14,8 +14,7 @@ import ProjectTemplateFormats from "./Util/ProjectTemplateFormats.js"; import { expandEligibleJavaScriptFilePaths } from "./Util/FilePathUtil.js"; const { set: lodashSet, get: lodashGet } = lodash; -const debug = createDebug("Eleventy:TemplateConfig"); -const debugDev = createDebug("Dev:Eleventy:TemplateConfig"); +const debug = createDebug("BuildAwesome:TemplateConfig"); /** * @module 11ty/eleventy/TemplateConfig @@ -31,13 +30,13 @@ const debugDev = createDebug("Dev:Eleventy:TemplateConfig"); * Errors in eleventy config. * @ignore */ -class EleventyConfigError extends EleventyBaseError {} +class ConfigError extends BaseError {} /** * Errors in eleventy plugins. * @ignore */ -class EleventyPluginError extends EleventyBaseError {} +class PluginError extends BaseError {} /** * Config for a template. @@ -63,7 +62,7 @@ class TemplateConfig { /** * @type {String} * @description Path to local project config. - * @default .eleventy.js + * @default buildawesome.config.js */ if (projectConfigPath !== undefined) { this.#configManuallyDefined = true; @@ -101,7 +100,7 @@ class TemplateConfig { return this.existsCache.exists(filePath); }; - this.userConfig.events.on("eleventy#templateModified", (inputPath, metadata = {}) => { + this.userConfig.events.on("buildawesome#templatemodified", (inputPath, metadata = {}) => { // Issue #3569, set that this file exists in the cache this.#existsCache.set(inputPath, true); }); @@ -199,8 +198,6 @@ class TemplateConfig { */ async reset() { this.#existsCache.reset(); - - debugDev("Resetting configuration: TemplateConfig and UserConfig."); this.userConfig.reset(); this.usesGraph.reset(); // needs to be before forceReloadConfig #3711 @@ -208,7 +205,7 @@ class TemplateConfig { await this.forceReloadConfig(); // Clear the compile cache - eventBus.emit("eleventy.compileCacheReset"); + eventBus.emit("buildawesome.compilecachereset"); } /** @@ -277,7 +274,6 @@ class TemplateConfig { if (this.hasConfigMerged) { // merge it again - debugDev("Merging in getConfig again after setting the local project config path."); await this.forceReloadConfig(); } } @@ -363,7 +359,7 @@ class TemplateConfig { namespaceStr = ` (namespace: ${namespaces.join(".")})`; } - throw new EleventyPluginError( + throw new PluginError( `Error processing ${name ? `the \`${name}\`` : "a"} plugin${namespaceStr}`, e, ); @@ -387,7 +383,7 @@ class TemplateConfig { let path = this.getActiveConfigPath(); if (this.projectConfigPaths.length > 0 && this.#configManuallyDefined && !path) { - throw new EleventyConfigError( + throw new ConfigError( "A configuration file was specified but not found: " + this.projectConfigPaths.join(", "), ); } @@ -395,8 +391,10 @@ class TemplateConfig { debug(`Merging default config with ${path}`); if (path) { try { - let { default: configDefaultReturn, config: exportedConfigObject } = - await EleventyImportRaw(path, this.isEsm ? "esm" : "cjs"); + let { default: configDefaultReturn, config: exportedConfigObject } = await DynamicImportRaw( + path, + this.isEsm ? "esm" : "cjs", + ); exportedConfig = exportedConfigObject || {}; @@ -421,7 +419,7 @@ class TemplateConfig { // TODO the error message here is bad and I feel bad (needs more accurate info) return Promise.reject( - new EleventyConfigError( + new ConfigError( `Error in your Eleventy config file '${path}'.` + (isModuleError ? chalk.cyan(" You may need to run `npm install`.") : ""), err, @@ -524,7 +522,7 @@ class TemplateConfig { // But BEFORE the rest of the config options are merged // this way we can pass directories and other template information to plugins - await this.userConfig.events.emit("eleventy.beforeConfig", this.userConfig); + await this.userConfig.events.emit("buildawesome.beforeconfig", this.userConfig); let pluginsBench = this.aggregateBenchmark.get("Processing plugins in config"); pluginsBench.before(); diff --git a/src/TemplateContent.js b/src/TemplateContent.js index fe7f74710..9dc632dca 100644 --- a/src/TemplateContent.js +++ b/src/TemplateContent.js @@ -8,17 +8,16 @@ import JavaScriptFrontMatter from "./Engines/FrontMatter/JavaScript.js"; import { EOL } from "./Util/NewLineAdapter.js"; import TemplateData from "./Data/TemplateData.js"; import TemplateRender from "./TemplateRender.js"; -import EleventyBaseError from "./Errors/EleventyBaseError.js"; -import EleventyErrorUtil from "./Errors/EleventyErrorUtil.js"; +import BaseError from "./Errors/BaseError.js"; +import ErrorUtil from "./Errors/ErrorUtil.js"; import eventBus from "./EventBus.js"; const { set: lodashSet } = lodash; -const debug = createDebug("Eleventy:TemplateContent"); -const debugDev = createDebug("Dev:Eleventy:TemplateContent"); +const debug = createDebug("BuildAwesome:TemplateContent"); -class TemplateContentFrontMatterError extends EleventyBaseError {} -class TemplateContentCompileError extends EleventyBaseError {} -class TemplateContentRenderError extends EleventyBaseError {} +class TemplateContentFrontMatterError extends BaseError {} +class TemplateContentCompileError extends BaseError {} +class TemplateContentRenderError extends BaseError {} class TemplateContent { #initialized = false; @@ -515,7 +514,6 @@ class TemplateContent { // this.templateRender is guaranteed here let tr = await this.getTemplateRender(); if (engineOverride !== undefined) { - debugDev("%o overriding template engine to use %o", this.inputPath, engineOverride); await tr.setEngineOverride(engineOverride, bypassMarkdown); } else { tr.setUseMarkdown(!bypassMarkdown); @@ -526,8 +524,6 @@ class TemplateContent { }; } - debugDev("%o compile() using engine: %o", this.inputPath, tr.engineName); - try { let res; if (this.config.useTemplateCache) { @@ -560,7 +556,7 @@ class TemplateContent { let fn = await tr.getCompiledTemplate(str); inputPathBenchmark.after(); templateBenchmark.after(); - debugDev("%o getCompiledTemplate function created", this.inputPath); + if (this.config.useTemplateCache && res) { res(fn); } @@ -749,11 +745,10 @@ class TemplateContent { inputPathBenchmark.after(); } templateBenchmark.after(); - debugDev("%o getCompiledTemplate called, rendered content created", this.inputPath); return rendered; } catch (e) { - if (EleventyErrorUtil.isPrematureTemplateContentError(e)) { + if (ErrorUtil.isPrematureTemplateContentError(e)) { return Promise.reject(e); } else { let tr = await this.getTemplateRender(); @@ -831,7 +826,7 @@ class TemplateContent { TemplateContent._inputCache = new Map(); TemplateContent._compileCache = new Map(); -eventBus.on("eleventy.resourceModified", (path) => { +eventBus.on("buildawesome.resourcemodified", (path) => { // delete from input cache TemplateContent.deleteFromInputCache(path); @@ -844,7 +839,7 @@ eventBus.on("eleventy.resourceModified", (path) => { }); // Used when the configuration file reset https://github.com/11ty/eleventy/issues/2147 -eventBus.on("eleventy.compileCacheReset", () => { +eventBus.on("buildawesome.compilecachereset", () => { TemplateContent._compileCache = new Map(); }); diff --git a/src/TemplateLayout.js b/src/TemplateLayout.js index 42a8c9240..c573b3fe4 100644 --- a/src/TemplateLayout.js +++ b/src/TemplateLayout.js @@ -1,13 +1,10 @@ import { Merge, TemplatePath } from "@11ty/eleventy-utils"; -import { createDebug } from "obug"; import TemplateLayoutPathResolver from "./TemplateLayoutPathResolver.js"; import TemplateContent from "./TemplateContent.js"; import layoutCache from "./LayoutCache.js"; import { DataCascade } from "./Data/DataCascade.js"; -const debugDev = createDebug("Dev:Eleventy:TemplateLayout"); - // https://github.com/11ty/eleventy/issues/3954 class CdataWrapper { static PREFIX = " { + await this.config.events.emitLazy("buildawesome.contentmap", () => { return { inputPathToUrl: this.generateInputUrlContentMap(orderedMap), urlToInputPath: this.generateUrlMap(orderedMap), @@ -342,7 +342,7 @@ class TemplateMap { this.checkForDuplicatePermalinks(); this.checkForMissingFileExtensions(); - await this.config.events.emitLazy("eleventy.layouts", () => this.generateLayoutsMap()); + await this.config.events.emitLazy("buildawesome.layouts", () => this.generateLayoutsMap()); } generateInputUrlContentMap(orderedMap) { @@ -431,7 +431,7 @@ class TemplateMap { await pageEntry.template.renderPageEntryWithoutLayout(pageEntry); } } catch (e) { - if (EleventyErrorUtil.isPrematureTemplateContentError(e)) { + if (ErrorUtil.isPrematureTemplateContentError(e)) { // Add to list of templates that need to be processed again usedTemplateContentTooEarlyMap.push(map); @@ -456,7 +456,7 @@ class TemplateMap { await pageEntry.template.renderPageEntryWithoutLayout(pageEntry); } } catch (e) { - if (EleventyErrorUtil.isPrematureTemplateContentError(e)) { + if (ErrorUtil.isPrematureTemplateContentError(e)) { // If we still have template content errors after the second pass, // it's likely a circular reference throw new UsingCircularTemplateContentReferenceError( diff --git a/src/TemplatePassthrough.js b/src/TemplatePassthrough.js index 3e5148ab5..77a038c65 100644 --- a/src/TemplatePassthrough.js +++ b/src/TemplatePassthrough.js @@ -6,13 +6,13 @@ import { createDebug } from "obug"; import { readableFileSize } from "./Util/FileSize.js"; import { isDynamicPattern } from "./Util/GlobMatcher.js"; -import EleventyBaseError from "./Errors/EleventyBaseError.js"; +import BaseError from "./Errors/BaseError.js"; import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; import ProjectDirectories from "./Util/ProjectDirectories.js"; -const debug = createDebug("Eleventy:TemplatePassthrough"); +const debug = createDebug("BuildAwesome:TemplatePassthrough"); -class TemplatePassthroughError extends EleventyBaseError {} +class TemplatePassthroughError extends BaseError {} class TemplatePassthrough { isDryRun = false; diff --git a/src/TemplatePassthroughManager.js b/src/TemplatePassthroughManager.js index 8ffbdee66..d142b9d1d 100644 --- a/src/TemplatePassthroughManager.js +++ b/src/TemplatePassthroughManager.js @@ -1,14 +1,14 @@ import { TemplatePath } from "@11ty/eleventy-utils"; import { createDebug } from "obug"; -import EleventyBaseError from "./Errors/EleventyBaseError.js"; +import BaseError from "./Errors/BaseError.js"; import TemplatePassthrough from "./TemplatePassthrough.js"; import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; import { isGlobMatch, isDynamicPattern } from "./Util/GlobMatcher.js"; -const debug = createDebug("Eleventy:TemplatePassthroughManager"); +const debug = createDebug("BuildAwesome:TemplatePassthroughManager"); -class TemplatePassthroughManagerCopyError extends EleventyBaseError {} +class TemplatePassthroughManagerCopyError extends BaseError {} class TemplatePassthroughManager { #isDryRun = false; @@ -25,15 +25,15 @@ class TemplatePassthroughManager { this.config = templateConfig.getConfig(); // eleventy# event listeners are removed on each build - this.config.events.on("eleventy#copy", ({ source, target, options }) => { + this.config.events.on("buildawesome#copy", ({ source, target, options }) => { this.enqueueCopy(source, target, options); }); - this.config.events.on("eleventy#beforerender", () => { + this.config.events.on("buildawesome#beforerender", () => { this.#afterBuild = Promise.withResolvers(); }); - this.config.events.on("eleventy#render", () => { + this.config.events.on("buildawesome#render", () => { let { resolve } = this.#afterBuild; resolve(); }); @@ -376,7 +376,7 @@ class TemplatePassthroughManager { return Promise.all(promises).then(async (results) => { let aliases = this.getAliasesFromPassthroughResults(results); - await this.config.events.emit("eleventy.passthrough", { + await this.config.events.emit("buildawesome.passthrough", { map: aliases, }); diff --git a/src/TemplateRender.js b/src/TemplateRender.js index 63dc07042..6452af18b 100644 --- a/src/TemplateRender.js +++ b/src/TemplateRender.js @@ -1,10 +1,10 @@ import { createDebug } from "obug"; -import EleventyBaseError from "./Errors/EleventyBaseError.js"; +import BaseError from "./Errors/BaseError.js"; import TemplateEngineManager from "./Engines/TemplateEngineManager.js"; -const debugConfiguration = createDebug("Eleventy:UserConfig"); +const debugConfiguration = createDebug("BuildAwesome:UserConfig"); -class TemplateRenderUnknownEngineError extends EleventyBaseError {} +class TemplateRenderUnknownEngineError extends BaseError {} // works with full path names or short engine name export default class TemplateRender { diff --git a/src/TemplateWriter.js b/src/TemplateWriter.js index 80c36984b..80e281ad6 100755 --- a/src/TemplateWriter.js +++ b/src/TemplateWriter.js @@ -3,16 +3,16 @@ import { createDebug } from "obug"; import Template from "./Template.js"; import TemplateMap from "./TemplateMap.js"; -import EleventyBaseError from "./Errors/EleventyBaseError.js"; -import { EleventyErrorHandler } from "./Errors/EleventyErrorHandler.js"; -import EleventyErrorUtil from "./Errors/EleventyErrorUtil.js"; +import BaseError from "./Errors/BaseError.js"; +import { ErrorHandler } from "./Errors/ErrorHandler.js"; +import ErrorUtil from "./Errors/ErrorUtil.js"; import ConsoleLogger from "./Util/ConsoleLogger.js"; -const debug = createDebug("Eleventy:TemplateWriter"); +const debug = createDebug("BuildAwesome:TemplateWriter"); -class TemplateWriterMissingConfigArgError extends EleventyBaseError {} -class EleventyPassthroughCopyError extends EleventyBaseError {} -class EleventyTemplateError extends EleventyBaseError {} +class TemplateWriterMissingConfigArgError extends BaseError {} +class PassthroughCopyError extends BaseError {} +class TemplateError extends BaseError {} class TemplateWriter { #eleventyFiles; @@ -69,7 +69,7 @@ class TemplateWriter { /* Getter for error handler */ get errorHandler() { if (!this.#errorHandler) { - this.#errorHandler = new EleventyErrorHandler(); + this.#errorHandler = new ErrorHandler(); this.#errorHandler.isVerbose = this.verboseMode; this.#errorHandler.logger = this.logger; } @@ -436,7 +436,7 @@ class TemplateWriter { return this.#passthroughManager.copyAll(templateExtensionPaths).catch((e) => { this.errorHandler.warn(e, "Error with passthrough copy"); - return Promise.reject(new EleventyPassthroughCopyError("Having trouble copying", e)); + return Promise.reject(new PassthroughCopyError("Having trouble copying", e)); }); } @@ -452,12 +452,12 @@ class TemplateWriter { this.#generateTemplate(mapEntry, to).catch(function (e) { // Premature templateContent in layout render, this also happens in // TemplateMap.populateContentDataInMap for non-layout content - if (EleventyErrorUtil.isPrematureTemplateContentError(e)) { + if (ErrorUtil.isPrematureTemplateContentError(e)) { usedTemplateContentTooEarlyMap.push(mapEntry); } else { let outputPaths = `"${mapEntry._pages.map((page) => page.outputPath).join(`", "`)}"`; return Promise.reject( - new EleventyTemplateError( + new TemplateError( `Having trouble writing to ${outputPaths} from "${mapEntry.inputPath}"`, e, ), @@ -471,7 +471,7 @@ class TemplateWriter { promises.push( this.#generateTemplate(mapEntry, to).catch(function (e) { return Promise.reject( - new EleventyTemplateError( + new TemplateError( `Having trouble writing to (second pass) "${mapEntry.outputPath}" from "${mapEntry.inputPath}"`, e, ), @@ -504,12 +504,12 @@ class TemplateWriter { let paths = await this._getAllPaths(); // This must happen before writePassthroughCopy - this.templateConfig.userConfig.emit("eleventy#beforerender"); + this.templateConfig.userConfig.emit("buildawesome#beforerender"); let aggregatePassthroughCopyPromise = this.writePassthroughCopy(paths); let templatesPromise = Promise.all(await this.generateTemplates(paths)).then((results) => { - this.templateConfig.userConfig.emit("eleventy#render"); + this.templateConfig.userConfig.emit("buildawesome#render"); return results; }); diff --git a/src/UserConfig.js b/src/UserConfig.js index 98e5cc093..b940425d7 100644 --- a/src/UserConfig.js +++ b/src/UserConfig.js @@ -8,13 +8,13 @@ import isAsyncFunction from "./Util/IsAsyncFunction.js"; import objectFilter from "./Util/Objects/ObjectFilter.js"; import EventEmitter from "./Util/AsyncEventEmitter.js"; import EleventyCompatibility from "./Util/Compatibility.js"; -import EleventyBaseError from "./Errors/EleventyBaseError.js"; +import BaseError from "./Errors/BaseError.js"; import BenchmarkManager from "./Benchmark/BenchmarkManager.js"; import { augmentFunction } from "./Engines/Util/ContextAugmenter.js"; -const debug = createDebug("Eleventy:UserConfig"); +const debug = createDebug("BuildAwesome:UserConfig"); -class UserConfigError extends EleventyBaseError {} +class UserConfigError extends BaseError {} /** * Eleventy’s user-land Configuration API diff --git a/src/Util/AsyncEventEmitter.js b/src/Util/AsyncEventEmitter.js index 0bc471f9b..4f55d26f6 100644 --- a/src/Util/AsyncEventEmitter.js +++ b/src/Util/AsyncEventEmitter.js @@ -10,6 +10,43 @@ import { EventEmitter } from "node:events"; class AsyncEventEmitter extends EventEmitter { #handlerMode = "parallel"; + /* Order matters */ + #emitAliases = { + "buildawesome.before": ["beforeBuild", "eleventy.before", "buildawesome.before"], + "buildawesome.beforewatch": ["beforeWatch", "eleventy.beforeWatch", "buildawesome.beforewatch"], + "buildawesome.beforeconfig": ["eleventy.beforeConfig", "buildawesome.beforeconfig"], + "buildawesome.after": ["afterBuild", "eleventy.after", "buildawesome.after"], + + // Internal + "buildawesome.engine.njk": ["eleventy.engine.njk", "buildawesome.engine.njk"], + "buildawesome.globaldatafiles": ["eleventy.globalDataFiles", "buildawesome.globaldatafiles"], + "buildawesome.contentmap": ["eleventy.contentMap", "buildawesome.contentmap"], + "buildawesome.layouts": ["eleventy.layouts", "buildawesome.layouts"], + "buildawesome.datafiles": ["eleventy.dataFiles", "buildawesome.datafiles"], + "buildawesome.passthrough": ["eleventy.passthrough", "buildawesome.passthrough"], + "buildawesome.config": ["eleventy.config", "buildawesome.config"], + "buildawesome.env": ["eleventy.env", "buildawesome.env"], + "buildawesome.extensionmap": ["eleventy.extensionmap", "buildawesome.extensionmap"], + "buildawesome.directories": ["eleventy.directories", "buildawesome.directories"], + "buildawesome.ignores": ["eleventy.ignores", "buildawesome.ignores"], + "buildawesome.reset": ["eleventy.reset", "buildawesome.reset"], + "buildawesome.afterwatch": ["eleventy.afterwatch", "buildawesome.afterwatch"], + "buildawesome.resourcemodified": ["eleventy.resourceModified", "buildawesome.resourcemodified"], + "buildawesome.compilecachereset": [ + "eleventy.compileCacheReset", + "buildawesome.compilecachereset", + ], + "buildawesome.importcachereset": ["eleventy.importCacheReset", "buildawesome.importcachereset"], + + "buildawesome#templatemodified": ["eleventy#templateModified", "buildawesome#templatemodified"], + "buildawesome#copy": ["eleventy#copy", "buildawesome#copy"], + + // Internal but not aliased + // "buildawesome#previousqueue" + // "buildawesome#beforerender", + // "buildawesome#render" + }; + // TypeScript slop constructor(...args) { super(...args); @@ -18,11 +55,25 @@ class AsyncEventEmitter extends EventEmitter { reset() { // `eleventy#` event type listeners are removed at the start of each build (singletons) for (let type of this.eventNames()) { - if (typeof type === "string" && type.startsWith("eleventy#")) { + if ( + typeof type === "string" && + (type.startsWith("eleventy#") || type.startsWith("buildawesome#")) + ) { this.removeAllListeners(type); } } + } + + getAliasedListeners(type) { + if (this.#emitAliases[type]) { + let listeners = []; + for (let alias of this.#emitAliases[type]) { + listeners.push(...this.listeners(alias)); + } + return listeners; + } + return this.listeners(type); } /** @@ -32,7 +83,7 @@ class AsyncEventEmitter extends EventEmitter { */ /** @ts-expect-error */ async emit(type, ...args) { - let listeners = this.listeners(type); + let listeners = this.getAliasedListeners(type); if (listeners.length === 0) { return []; } @@ -59,7 +110,7 @@ class AsyncEventEmitter extends EventEmitter { * @returns {Promise} - Promise resolves once all listeners were invoked */ async emitLazy(type, ...args) { - let listeners = this.listeners(type); + let listeners = this.getAliasedListeners(type); if (listeners.length === 0) { return []; } diff --git a/src/Util/Compatibility.js b/src/Util/Compatibility.js index aa7fbc411..55279e478 100644 --- a/src/Util/Compatibility.js +++ b/src/Util/Compatibility.js @@ -1,7 +1,7 @@ import { satisfies } from "../Adapters/Packages/semver.js"; -import { getEleventyPackageJson, getWorkingProjectPackageJson } from "./ImportJsonSync.js"; +import { getCorePackageJson, getWorkingProjectPackageJson } from "./ImportJsonSync.js"; -const pkg = getEleventyPackageJson(); +const pkg = getCorePackageJson(); // Used in user config versionCheck method. class Compatibility { diff --git a/src/Util/ConsoleLogger.js b/src/Util/ConsoleLogger.js index 7e737a489..6a9231765 100644 --- a/src/Util/ConsoleLogger.js +++ b/src/Util/ConsoleLogger.js @@ -1,7 +1,7 @@ import { createDebug } from "obug"; import chalk from "../Adapters/Packages/chalk.js"; -const debug = createDebug("Eleventy:Logger"); +const debug = createDebug("BuildAwesome:Logger"); /** * Logger implementation that logs to STDOUT. diff --git a/src/Util/DateParse.js b/src/Util/DateParse.js index ef0c3e601..cc60b5f23 100644 --- a/src/Util/DateParse.js +++ b/src/Util/DateParse.js @@ -1,7 +1,7 @@ import { createDebug } from "obug"; import { IsoDate } from "@11ty/parse-date-strings"; -const debug = createDebug("Eleventy:DateTime"); +const debug = createDebug("BuildAwesome:DateTime"); export function fromISOtoDateUTC(dateValue, inputPath) { // This has had a UTC default since the beginnning: diff --git a/src/Util/EnvironmentVars.cjs b/src/Util/EnvironmentVars.cjs new file mode 100644 index 000000000..c98eaf2b1 --- /dev/null +++ b/src/Util/EnvironmentVars.cjs @@ -0,0 +1,14 @@ +// Used by CommonJS upstream (cmd.cjs and TypeScript feature test) + +module.exports.getEnvValue = function(key) { + return process?.env?.[`BUILDAWESOME_${key}`] || process?.env?.[`ELEVENTY_${key}`]; +} + +module.exports.setEnvValue = function(key, value) { + if(!process?.env) { + return; + } + + process.env[`BUILDAWESOME_${key}`] = value; + process.env[`ELEVENTY_${key}`] = value; +} diff --git a/src/Util/EsmResolver.js b/src/Util/EsmResolver.js index ef49951ae..5b67191b0 100644 --- a/src/Util/EsmResolver.js +++ b/src/Util/EsmResolver.js @@ -2,7 +2,7 @@ import { createDebug } from "obug"; import { fileURLToPath } from "../Adapters/Packages/url.js"; import PathNormalizer from "./PathNormalizer.js"; -const debug = createDebug("Eleventy:EsmResolver"); +const debug = createDebug("BuildAwesome:EsmResolver"); let lastModifiedPaths = new Map(); diff --git a/src/Util/EsmResolverPortAdapter.js b/src/Util/EsmResolverPortAdapter.js index 0c47ffdde..a50597ad9 100644 --- a/src/Util/EsmResolverPortAdapter.js +++ b/src/Util/EsmResolverPortAdapter.js @@ -2,6 +2,7 @@ import module from "node:module"; import { fileURLToPath } from "../Adapters/Packages/url.js"; import PathNormalizer from "./PathNormalizer.js"; import { resolve, addToModifiedPaths } from "./EsmResolver.js"; +import { getEnvValue } from "./EnvironmentVars.cjs"; // ESM Cache Buster // - registerHooks requires Node 22.15+ (and is sync only, shipped with v4.0.0-alpha.8) @@ -10,7 +11,7 @@ import { resolve, addToModifiedPaths } from "./EsmResolver.js"; // Fixes https://github.com/11ty/eleventy/issues/3270 // ENV variable for https://github.com/11ty/eleventy/issues/3371 -if (!process?.env?.ELEVENTY_SKIP_ESM_RESOLVER) { +if (!getEnvValue("SKIP_ESM_RESOLVER")) { if ("registerHooks" in module) { module.registerHooks({ // sync-only @@ -20,7 +21,7 @@ if (!process?.env?.ELEVENTY_SKIP_ESM_RESOLVER) { } export function addModifiedPath(path, date) { - if (process?.env?.ELEVENTY_SKIP_ESM_RESOLVER) { + if (getEnvValue("SKIP_ESM_RESOLVER")) { return; } diff --git a/src/Util/EventBusUtil.js b/src/Util/EventBusUtil.js index e7ff05d6b..da43b19c1 100644 --- a/src/Util/EventBusUtil.js +++ b/src/Util/EventBusUtil.js @@ -1,7 +1,7 @@ import eventBus from "../EventBus.js"; import { createDebug } from "obug"; -const debug = createDebug("Eleventy:EventBus"); +const debug = createDebug("BuildAwesome:EventBus"); class EventBusUtil { static debugCurrentListenerCounts() { diff --git a/src/Util/FeatureTests.cjs b/src/Util/FeatureTests.cjs deleted file mode 100644 index dea947ca6..000000000 --- a/src/Util/FeatureTests.cjs +++ /dev/null @@ -1,22 +0,0 @@ -function canRequireTypeScript() { - try { - let res = require("./TypeScript/TypeScriptSample.cts"); - return typeof res === "function"; - } catch(e) { - // Not supported in node_modules, but we know it is supported! - if(e.code === "ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING") { - return true; - } - return false; - } -} - -const TYPESCRIPT_ENABLED = canRequireTypeScript(); - -module.exports.isTypeScriptSupported = function() { - if (process?.env?.ELEVENTY_SKIP_TYPESCRIPT) { - return false; - } - - return TYPESCRIPT_ENABLED; -} diff --git a/src/Util/FilePathUtil.js b/src/Util/FilePathUtil.js index 3bd30a3ea..9f76b1b25 100644 --- a/src/Util/FilePathUtil.js +++ b/src/Util/FilePathUtil.js @@ -1,4 +1,4 @@ -import { isTypeScriptSupported } from "./FeatureTests.cjs"; +import { isTypeScriptSupported } from "./TypeScriptFeatureTest.cjs"; // the order here is important const ELIGIBLE_EXTENSIONS = [ diff --git a/src/Util/FileSystemManager.js b/src/Util/FileSystemUtilities.js similarity index 93% rename from src/Util/FileSystemManager.js rename to src/Util/FileSystemUtilities.js index fdd58d747..10932d3bc 100644 --- a/src/Util/FileSystemManager.js +++ b/src/Util/FileSystemUtilities.js @@ -1,7 +1,7 @@ import path from "node:path"; import { mkdirSync, writeFileSync } from "node:fs"; -class FileSystemManager { +export class FileSystemUtilities { constructor(templateConfig) { if (!templateConfig || templateConfig.constructor.name !== "TemplateConfig") { throw new Error( @@ -30,5 +30,3 @@ class FileSystemManager { writeFileSync(filePath, content); } } - -export { FileSystemManager }; diff --git a/src/Util/GetJavaScriptData.js b/src/Util/GetJavaScriptData.js index 7d72a64f8..b29bac413 100644 --- a/src/Util/GetJavaScriptData.js +++ b/src/Util/GetJavaScriptData.js @@ -1,6 +1,6 @@ -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; -class JavaScriptInvalidDataFormatError extends EleventyBaseError {} +class JavaScriptInvalidDataFormatError extends BaseError {} export default async function (inst, inputPath, key = "data", options = {}) { let { mixins, isObjectRequired } = Object.assign( diff --git a/src/Util/HtmlRelativeCopy.js b/src/Util/HtmlRelativeCopy.js index f4f225c1a..3940896aa 100644 --- a/src/Util/HtmlRelativeCopy.js +++ b/src/Util/HtmlRelativeCopy.js @@ -141,7 +141,7 @@ class HtmlRelativeCopy { // We use a Set here to allow passthrough copy manager to properly error on conflicts upstream // Only errors when different inputs write to the same output // Also errors if attempts to write outside the output folder. - this.#userConfig.emit("eleventy#copy", { + this.#userConfig.emit("buildawesome#copy", { source, target, options: this.#copyOptions, diff --git a/src/Util/ImportJsonSync.js b/src/Util/ImportJsonSync.js index b6b2074b6..22deab002 100644 --- a/src/Util/ImportJsonSync.js +++ b/src/Util/ImportJsonSync.js @@ -2,9 +2,9 @@ import { existsSync } from "node:fs"; import { createDebug } from "obug"; import { TemplatePath } from "@11ty/eleventy-utils"; -import { importJsonSync, eleventyPackageJson } from "./RequireUtils.js"; +import { importJsonSync, corePackageJson } from "./RequireUtils.js"; -const debug = createDebug("Eleventy:ImportJsonSync"); +const debug = createDebug("BuildAwesome:ImportJsonSync"); function findFilePathInParentDirs(dir, filename) { // `package.json` searches look in parent dirs: @@ -23,11 +23,11 @@ function findFilePathInParentDirs(dir, filename) { } } -function getEleventyPackageJson() { - return eleventyPackageJson; +function getCorePackageJson() { + return corePackageJson; } -// Used by EleventyServe.js for custom servers only +// Used by Serve.js for custom servers only function getModulePackageJson(dir) { let filePath = findFilePathInParentDirs(TemplatePath.absolutePath(dir), "package.json"); @@ -60,7 +60,7 @@ function getWorkingProjectPackageJson(filePath) { export { importJsonSync, - getEleventyPackageJson, + getCorePackageJson, getModulePackageJson, getWorkingProjectPackageJson, findFilePathInParentDirs, diff --git a/src/Util/JavaScriptDependencies.js b/src/Util/JavaScriptDependencies.js index 24d2883fd..471d7acfb 100644 --- a/src/Util/JavaScriptDependencies.js +++ b/src/Util/JavaScriptDependencies.js @@ -8,7 +8,7 @@ import { TemplatePath } from "@11ty/eleventy-utils"; import { DepGraph } from "dependency-graph"; import { union } from "./SetUtil.js"; -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; class JavaScriptDependencies { static getErrorMessage(file, type) { @@ -58,7 +58,7 @@ class JavaScriptDependencies { depSet.add(dep); } } catch (e) { - throw new EleventyBaseError(this.getErrorMessage(file, "CommonJS"), e); + throw new BaseError(this.getErrorMessage(file, "CommonJS"), e); } } @@ -77,7 +77,7 @@ class JavaScriptDependencies { depSet.add(dep); } } catch (e) { - throw new EleventyBaseError(this.getErrorMessage(file, "ESM"), e); + throw new BaseError(this.getErrorMessage(file, "ESM"), e); } } @@ -100,7 +100,7 @@ class JavaScriptDependencies { mergeGraphs(rootGraph, graph); } catch (e) { - throw new EleventyBaseError(this.getErrorMessage(file, "ESM"), e); + throw new BaseError(this.getErrorMessage(file, "ESM"), e); } } diff --git a/src/Util/Objects/ProxyWrap.js b/src/Util/Objects/ProxyWrap.js index 14e168443..5559e532f 100644 --- a/src/Util/Objects/ProxyWrap.js +++ b/src/Util/Objects/ProxyWrap.js @@ -1,7 +1,7 @@ -import { createDebug } from "obug"; +// import { createDebug } from "obug"; import { isPlainObject } from "@11ty/eleventy-utils"; -const debug = createDebug("Dev:Eleventy:Proxy"); +// const debug = createDebug("Dev:Eleventy:Proxy"); const ProxySymbol = Symbol.for("11ty.ProxySymbol"); @@ -46,7 +46,7 @@ function wrapObject(target, fallback) { return Array.from(s); }, get(target, prop) { - debug("handler:get", prop); + // debug("handler:get", prop); if (prop === ProxySymbol) { return true; } @@ -65,11 +65,11 @@ function wrapObject(target, fallback) { } let ret = wrapObject(value, Reflect.get(fallback, prop)); - debug("handler:get (primary, object)", prop); + // debug("handler:get (primary, object)", prop); return ret; } - debug("handler:get (primary)", prop); + // debug("handler:get (primary)", prop); return value; } @@ -86,7 +86,7 @@ function wrapObject(target, fallback) { return fallbackValue; } - debug("handler:get (fallback, object)", prop); + // debug("handler:get (fallback, object)", prop); // set empty object on primary let emptyObject = {}; Reflect.set(target, prop, emptyObject); @@ -94,17 +94,17 @@ function wrapObject(target, fallback) { return wrapObject(emptyObject, fallbackValue); } - debug("handler:get (fallback)", prop); + // debug("handler:get (fallback)", prop); return fallbackValue; } // primary *and* fallback do _not_ have prop - debug("handler:get (not on primary or fallback)", prop); + // debug("handler:get (not on primary or fallback)", prop); return value; }, set(target, prop, value) { - debug("handler:set", prop); + // debug("handler:set", prop); return Reflect.set(target, prop, value); }, diff --git a/src/Util/ProjectTemplateFormats.js b/src/Util/ProjectTemplateFormats.js index 4b958b8c4..6707b84e8 100644 --- a/src/Util/ProjectTemplateFormats.js +++ b/src/Util/ProjectTemplateFormats.js @@ -1,5 +1,5 @@ import { createDebug } from "obug"; -const debug = createDebug("Eleventy:Util:ProjectTemplateFormats"); +const debug = createDebug("BuildAwesome:Util:ProjectTemplateFormats"); class ProjectTemplateFormats { #useAll = {}; diff --git a/src/Util/Require.js b/src/Util/Require.js index a3fa08227..0424a6664 100644 --- a/src/Util/Require.js +++ b/src/Util/Require.js @@ -5,10 +5,10 @@ import { TemplatePath } from "@11ty/eleventy-utils"; import importer from "./importer.js"; import { clearRequireCache, requireCommonJsTypeScript } from "../Util/RequireUtils.js"; import { addModifiedPath } from "./EsmResolverPortAdapter.js"; -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; import eventBus from "../EventBus.js"; -class EleventyImportError extends EleventyBaseError {} +class ImportError extends BaseError {} const requestPromiseCache = new Map(); @@ -56,7 +56,7 @@ function loadContents(path, options = {}) { } let lastModifiedPaths = new Map(); -eventBus.on("eleventy.importCacheReset", (fileQueue) => { +eventBus.on("buildawesome.importcachereset", (fileQueue) => { for (let filePath of fileQueue) { let absolutePath = TemplatePath.absolutePath(filePath); let newDate = Date.now(); @@ -92,7 +92,7 @@ async function dynamicImportAbsolutePath(absolutePath, options = {}) { return JSON.parse(rawInput); } catch (e) { return Promise.reject( - new EleventyImportError(getImportErrorMessage(absolutePath, "fs.readFile(json)"), e), + new ImportError(getImportErrorMessage(absolutePath, "fs.readFile(json)"), e), ); } } @@ -187,7 +187,7 @@ async function dynamicImportAbsolutePath(absolutePath, options = {}) { }, (error) => { return Promise.reject( - new EleventyImportError(getImportErrorMessage(absolutePath, `import(${type})`), error), + new ImportError(getImportErrorMessage(absolutePath, `import(${type})`), error), ); }, ); @@ -210,7 +210,7 @@ async function dynamicImportRaw(localPath, type) { } export { - loadContents as EleventyLoadContent, - dynamicImport as EleventyImport, - dynamicImportRaw as EleventyImportRaw, + loadContents as LoadContent, + dynamicImport as DynamicImport, + dynamicImportRaw as DynamicImportRaw, }; diff --git a/src/Util/RequireUtils.core.js b/src/Util/RequireUtils.core.js index 25ad2a973..e3c09a1f0 100644 --- a/src/Util/RequireUtils.core.js +++ b/src/Util/RequireUtils.core.js @@ -1,9 +1,9 @@ -import { EleventyLoadContent } from "./Require.js"; +import { LoadContent } from "./Require.js"; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with#browser_compatibility -import eleventyPackageJson from "../../package.json" with { type: "json" }; +import corePackageJson from "../../package.json" with { type: "json" }; // We *could* prune everything but `name`, `version`, and `type` here but esbuild will still bundle the entire package.json -export { eleventyPackageJson }; +export { corePackageJson }; // noop export function clearRequireCache() {} @@ -15,7 +15,7 @@ export function requireCommonJsTypeScript() { export function importJsonSync(path) { // should not be a no-op - let rawInput = EleventyLoadContent(path); + let rawInput = LoadContent(path); if (!rawInput) { // should not error when file exists but is _empty_ return; diff --git a/src/Util/RequireUtils.js b/src/Util/RequireUtils.js index 4a08d850e..9340c3578 100644 --- a/src/Util/RequireUtils.js +++ b/src/Util/RequireUtils.js @@ -1,9 +1,12 @@ import { createRequire } from "node:module"; +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with#browser_compatibility +import corePackageJson from "../../package.json" with { type: "json" }; + // important to clear the require.cache in CJS projects -const require = createRequire(import.meta.url); +export { corePackageJson }; -export const eleventyPackageJson = require("../../package.json"); +const require = createRequire(import.meta.url); export function clearRequireCache(absolutePath) { // ESM Eleventy when using `import()` on a CJS project file still adds to require.cache diff --git a/src/Util/TemplateDepGraph.js b/src/Util/TemplateDepGraph.js index 7752a9146..7fb789107 100644 --- a/src/Util/TemplateDepGraph.js +++ b/src/Util/TemplateDepGraph.js @@ -1,7 +1,7 @@ import { DepGraph as DependencyGraph } from "dependency-graph"; import { createDebug } from "obug"; -const debug = createDebug("Eleventy:TemplateDepGraph"); +const debug = createDebug("BuildAwesome:TemplateDepGraph"); const COLLECTION_PREFIX = "__collection:"; diff --git a/src/Util/TransformsUtil.js b/src/Util/TransformsUtil.js index 8c959e391..cef23f41e 100644 --- a/src/Util/TransformsUtil.js +++ b/src/Util/TransformsUtil.js @@ -1,10 +1,10 @@ -import EleventyBaseError from "../Errors/EleventyBaseError.js"; +import BaseError from "../Errors/BaseError.js"; import { isPlainObject } from "@11ty/eleventy-utils"; import { createDebug } from "obug"; -const debug = createDebug("Eleventy:Transforms"); +const debug = createDebug("BuildAwesome:Transforms"); -class EleventyTransformError extends EleventyBaseError {} +class TransformError extends BaseError {} class TransformsUtil { static changeTransformsToArray(transformsObj) { @@ -56,7 +56,7 @@ class TransformsUtil { ); } } catch (e) { - throw new EleventyTransformError( + throw new TransformError( `Transform \`${name}\` encountered an error when transforming ${inputPath}.`, e, ); diff --git a/src/Util/TypeScriptFeatureTest.cjs b/src/Util/TypeScriptFeatureTest.cjs new file mode 100644 index 000000000..17f485427 --- /dev/null +++ b/src/Util/TypeScriptFeatureTest.cjs @@ -0,0 +1,30 @@ +const { getEnvValue } = require("./EnvironmentVars.cjs"); + +/** + * Checks whether the current Node.js runtime supports TypeScript type stripping. + * @returns {boolean} `true` if the runtime supports TypeScript, `false` otherwise + */ +function canRequireTypeScript() { + try { + + let res = require("./TypeScript/TypeScriptSample.cts"); + return typeof res === "function"; + } catch(e) { + // Type stripping is not allowed in node_modules, but the error code tells us that it is supported by the runtime! + let code = e && /** @type {{ code?: string }} */ (e).code; + if(code === "ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING") { + return true; + } + return false; + } +} + +const TYPESCRIPT_ENABLED = canRequireTypeScript(); + +module.exports.isTypeScriptSupported = function() { + if (getEnvValue("SKIP_TYPESCRIPT")) { + return false; + } + + return TYPESCRIPT_ENABLED; +} diff --git a/src/Util/FeatureTests.core.cjs b/src/Util/TypeScriptFeatureTest.core.cjs similarity index 100% rename from src/Util/FeatureTests.core.cjs rename to src/Util/TypeScriptFeatureTest.core.cjs diff --git a/src/Util/importer.core.js b/src/Util/importer.core.js index e2cc4c354..1ee824794 100644 --- a/src/Util/importer.core.js +++ b/src/Util/importer.core.js @@ -2,13 +2,13 @@ import { existsSync, readFileSync } from "node:fs"; import { importFromString } from "import-module-string"; import { fileURLToPath } from "../Adapters/Packages/url.js"; -import { EleventyLoadContent } from "./Require.js"; +import { LoadContent } from "./Require.js"; export default function importer(relPath) { let filePath = fileURLToPath(relPath); // `import-module-string` can now `import()` so we avoid needing to esbuild these - let code = EleventyLoadContent(filePath); + let code = LoadContent(filePath); return importFromString(code, { implicitExports: false, filePath, diff --git a/src/Watch.js b/src/Watch.js index 33811003b..aaac3613d 100644 --- a/src/Watch.js +++ b/src/Watch.js @@ -5,7 +5,7 @@ import chokidar from "chokidar"; import { isGlobMatch } from "./Util/GlobMatcher.js"; import { GlobStripper } from "./Util/GlobStripper.js"; -const debug = createDebug("Eleventy:Watch"); +const debug = createDebug("BuildAwesome:Watch"); export class Watch { /** @type {module:chokidar} */ diff --git a/src/WatchTargets.js b/src/WatchTargets.js index 77879c689..2c4c7e165 100644 --- a/src/WatchTargets.js +++ b/src/WatchTargets.js @@ -162,7 +162,7 @@ export default class WatchTargets { } } - eventBus.emit("eleventy.importCacheReset", paths); + eventBus.emit("buildawesome.importcachereset", paths); } getNewTargetsSinceLastReset() { diff --git a/src/defaultConfigExtended.client.js b/src/defaultConfigExtended.client.js index f4345e974..d967740a9 100644 --- a/src/defaultConfigExtended.client.js +++ b/src/defaultConfigExtended.client.js @@ -1,13 +1,13 @@ export default function (config) { config.addFilter("url", () => { throw new Error( - "The `url` filter is not included with the `@11ty/client` bundle. Use the `@11ty/client/eleventy` bundle.", + "The `url` filter is not included with the `@awesome.me/buildawesome-browser` bundle. Use the `@awesome.me/buildawesome-browser/core-fs` bundle.", ); }); config.addFilter("inputPathToUrl", () => { throw new Error( - "The `inputPathToUrl` filter is not included with the `@11ty/client` bundle. Use the larger `@11ty/client/eleventy` bundle.", + "The `inputPathToUrl` filter is not included with the `@awesome.me/buildawesome-browser` bundle. Use the larger `@awesome.me/buildawesome-browser/core-fs` bundle.", ); }); diff --git a/test/BundlePluginTest.js b/test/BundlePluginTest.js index ca891a329..b362667f8 100644 --- a/test/BundlePluginTest.js +++ b/test/BundlePluginTest.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("addBundle", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { diff --git a/test/EleventyTest-CustomDateParsing.js b/test/CoreTest-CustomDateParsing.js similarity index 99% rename from test/EleventyTest-CustomDateParsing.js rename to test/CoreTest-CustomDateParsing.js index 02818b334..60e59badf 100644 --- a/test/EleventyTest-CustomDateParsing.js +++ b/test/CoreTest-CustomDateParsing.js @@ -1,7 +1,7 @@ import { createRequire } from "node:module"; import test from "ava"; import { DateTime } from "luxon"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; const require = createRequire(import.meta.url); diff --git a/test/EleventyTest-PageData.js b/test/CoreTest-PageData.js similarity index 98% rename from test/EleventyTest-PageData.js rename to test/CoreTest-PageData.js index a10403382..ec8d767a7 100644 --- a/test/EleventyTest-PageData.js +++ b/test/CoreTest-PageData.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test.skip("#3794: page.inputPathDir and page.dir", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { diff --git a/test/EleventyTest-Preprocessors.js b/test/CoreTest-Preprocessors.js similarity index 99% rename from test/EleventyTest-Preprocessors.js rename to test/CoreTest-Preprocessors.js index 3d6a4ad2b..7eba71b55 100644 --- a/test/EleventyTest-Preprocessors.js +++ b/test/CoreTest-Preprocessors.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#188: Content preprocessing (dot in file extension)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { diff --git a/test/EleventyTest-Shortcodes.js b/test/CoreTest-Shortcodes.js similarity index 92% rename from test/EleventyTest-Shortcodes.js rename to test/CoreTest-Shortcodes.js index 6e610991f..9a80be245 100644 --- a/test/EleventyTest-Shortcodes.js +++ b/test/CoreTest-Shortcodes.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test.skip("#3400: Both a paired and unpaired shortcode.", async (t) => { let count = 0; diff --git a/test/EleventyVirtualTemplatesTest.js b/test/CoreTest-VirtualTemplates.js similarity index 99% rename from test/EleventyVirtualTemplatesTest.js rename to test/CoreTest-VirtualTemplates.js index c2751f4bb..6d4260330 100644 --- a/test/EleventyVirtualTemplatesTest.js +++ b/test/CoreTest-VirtualTemplates.js @@ -2,7 +2,7 @@ import test from "ava"; import fs from "fs"; import { feedPlugin } from "@11ty/eleventy-plugin-rss"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import DuplicatePermalinkOutputError from "../src/Errors/DuplicatePermalinkOutputError.js"; import { deleteDirectory } from "./_testHelpers.js"; diff --git a/test/EleventyTest.js b/test/CoreTest.js similarity index 91% rename from test/EleventyTest.js rename to test/CoreTest.js index ecae5c44f..55251727e 100644 --- a/test/EleventyTest.js +++ b/test/CoreTest.js @@ -8,14 +8,14 @@ import { marked } from "marked"; import nunjucks from "@11ty/nunjucks"; import * as sass from "sass"; -import Eleventy, { HtmlBasePlugin } from "../src/Eleventy.js"; +import Eleventy, { HtmlBasePlugin } from "../src/Core.js"; import TemplateContent from "../src/TemplateContent.js"; import TemplateMap from "../src/TemplateMap.js"; import TemplateConfig from "../src/TemplateConfig.js"; import { getCreatedTimestamp, getUpdatedTimestamp } from "../src/Util/Git.js"; import PathNormalizer from "../src/Util/PathNormalizer.js"; import { normalizeNewLines, localizeNewLines } from "./Util/normalizeNewLines.js"; -import { isTypeScriptSupported } from "../src/Util/FeatureTests.cjs"; +import { isTypeScriptSupported } from "../src/Util/TypeScriptFeatureTest.cjs"; import { deleteDirectory } from "./_testHelpers.js"; const lodashGet = lodash.get; @@ -93,7 +93,7 @@ test("Eleventy set input/output", async (t) => { t.truthy(elev.writer); }); -test("Eleventy process.ENV", async (t) => { +test("process.env.ELEVENTY_*", async (t) => { delete process.env.ELEVENTY_ROOT; t.falsy(process.env.ELEVENTY_ROOT); @@ -106,6 +106,19 @@ test("Eleventy process.ENV", async (t) => { t.truthy(globals.eleventy.env.root); }); +test("process.env.BUILDAWESOME_*", async (t) => { + delete process.env.BUILDAWESOME_ROOT; + t.falsy(process.env.BUILDAWESOME_ROOT); + + let elev = new Eleventy("./test/stubs", "./test/stubs/_site"); + await elev.init(); + t.truthy(process.env.BUILDAWESOME_ROOT); + + // all BUILDAWESOME_ env variables are also available on eleventy.env + let globals = await elev.templateData.getInitialGlobalData(); + t.truthy(globals.eleventy.env.root); +}); + test("Eleventy file watching", async (t) => { let elev = new Eleventy("./test/stubs", "./test/stubs/_site", { runMode: "watch" // required to spider deps @@ -739,8 +752,8 @@ test("Access to raw input of file (dryRun), issue #1206", async (t) => { deleteDirectory("./test/stubs-1206/_site/"); }); -test("eleventy.before and eleventy.after Event Arguments, directories", async (t) => { - t.plan(6); +test("{eleventy,buildawesome}.before and {eleventy,buildawesome}.after Event Arguments, directories", async (t) => { + t.plan(12); let elev = new Eleventy("./test/noop/", "./test/noop/_site", { config: function (eleventyConfig) { eleventyConfig.on("eleventy.before", arg => { @@ -748,31 +761,41 @@ test("eleventy.before and eleventy.after Event Arguments, directories", async (t t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/_includes/"); }) + eleventyConfig.on("buildawesome.before", arg => { + t.is(arg.inputDir, "./test/noop/"); + t.is(arg.directories.input, "./test/noop/"); + t.is(arg.directories.includes, "./test/noop/_includes/"); + }) eleventyConfig.on("eleventy.after", arg => { t.is(arg.inputDir, "./test/noop/"); t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/_includes/"); }) + eleventyConfig.on("buildawesome.after", arg => { + t.is(arg.inputDir, "./test/noop/"); + t.is(arg.directories.input, "./test/noop/"); + t.is(arg.directories.includes, "./test/noop/_includes/"); + }) }, }); let results = await elev.toJSON(); }); -test("eleventy.after fires sequentially setting eventEmitterMode 'sequential'", async (t) => { +test("buildawesome.after fires sequentially setting eventEmitterMode 'sequential'", async (t) => { let reachFirst; const firstReached = new Promise(resolve => reachFirst = resolve) let next; const firstResult = new Promise(resolve => next = resolve) let secondCalled = false; let elev = new Eleventy("./test/noop/", "./test/noop/_site", { - config: function (eleventyConfig) { - eleventyConfig.setEventEmitterMode('sequential') - eleventyConfig.on("eleventy.after", arg => { + config: function (configApi) { + configApi.setEventEmitterMode('sequential') + configApi.on("buildawesome.after", arg => { reachFirst() return firstResult; }) - eleventyConfig.on("eleventy.after", arg => { + configApi.on("buildawesome.after", arg => { secondCalled = true; }) }, @@ -792,7 +815,7 @@ test("setInputDirectory config method #1503", async (t) => { config: function (eleventyConfig) { eleventyConfig.setInputDirectory("./test/noop2/"); - eleventyConfig.on("eleventy.before", arg => { + eleventyConfig.on("buildawesome.before", arg => { t.is(arg.directories.input, "./test/noop2/"); t.is(arg.directories.includes, "./test/noop2/_includes/"); t.is(arg.directories.data, "./test/noop2/_data/"); @@ -811,7 +834,7 @@ test("setIncludesDirectory config method #1503", async (t) => { config: function (eleventyConfig) { eleventyConfig.setIncludesDirectory("myincludes"); - eleventyConfig.on("eleventy.before", arg => { + eleventyConfig.on("buildawesome.before", arg => { t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/myincludes/"); t.is(arg.directories.data, "./test/noop/_data/"); @@ -830,7 +853,7 @@ test("setDataDirectory config method #1503", async (t) => { config: function (eleventyConfig) { eleventyConfig.setDataDirectory("data"); - eleventyConfig.on("eleventy.before", arg => { + eleventyConfig.on("buildawesome.before", arg => { t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/_includes/"); t.is(arg.directories.data, "./test/noop/data/"); @@ -849,7 +872,7 @@ test("setLayoutsDirectory config method #1503", async (t) => { config: function (eleventyConfig) { eleventyConfig.setLayoutsDirectory("layouts"); - eleventyConfig.on("eleventy.before", arg => { + eleventyConfig.on("buildawesome.before", arg => { t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/_includes/"); t.is(arg.directories.data, "./test/noop/_data/"); @@ -919,8 +942,8 @@ test("Eleventy config export (ESM)", async (t) => { t.plan(5); let elev = new Eleventy("test/stubs/cfg-directories-export", null, { configPath: "./test/stubs/cfg-directories-export/eleventy.config.js", - config: function (eleventyConfig) { - eleventyConfig.on("eleventy.after", arg => { + config: function (configApi) { + configApi.on("buildawesome.after", arg => { t.is(arg.directories.input, "./src/"); t.is(arg.directories.includes, "./src/myincludes/"); t.is(arg.directories.data, "./src/mydata/"); @@ -937,8 +960,8 @@ test("Eleventy config export (CommonJS)", async (t) => { t.plan(5); let elev = new Eleventy("test/stubs/cfg-directories-export-cjs", null, { configPath: "./test/stubs/cfg-directories-export-cjs/eleventy.config.cjs", - config: function (eleventyConfig) { - eleventyConfig.on("eleventy.after", arg => { + config: function (configApi) { + configApi.on("buildawesome.after", arg => { t.is(arg.directories.input, "./src/"); t.is(arg.directories.includes, "./src/myincludes2/"); t.is(arg.directories.data, "./src/mydata2/"); @@ -953,8 +976,8 @@ test("Eleventy config export (CommonJS)", async (t) => { test("Eleventy setting reserved data throws error (eleventy)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", `--- + config: configApi => { + configApi.addTemplate("index.html", `--- eleventy: key1: NOOOOO ---`); @@ -971,8 +994,8 @@ eleventy: test("Eleventy setting reserved data throws error (pkg)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", `--- + config: configApi => { + configApi.addTemplate("index.html", `--- pkg: myOwn: OVERRIDE ---`); @@ -989,8 +1012,8 @@ pkg: test("Eleventy pagination works okay with reserved data throws (eleventy) Issue #3262", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", `--- + config: configApi => { + configApi.addTemplate("index.html", `--- pagination: data: "test" size: 1 @@ -1010,8 +1033,8 @@ test: test("Eleventy setting reserved data throws error (page)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", `--- + config: configApi => { + configApi.addTemplate("index.html", `--- page: "My page value" ---`) } @@ -1025,8 +1048,8 @@ page: "My page value" test("Eleventy setting reserved data throws error (content)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", `--- + config: configApi => { + configApi.addTemplate("index.html", `--- content: "My page value" ---`) } @@ -1040,8 +1063,8 @@ content: "My page value" test("Eleventy setting reserved data throws error (collections)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", `--- + config: configApi => { + configApi.addTemplate("index.html", `--- collections: [] ---`) } @@ -1055,8 +1078,8 @@ collections: [] test("Eleventy setting pkg data is okay when pkg is remapped to parkour", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", `--- + config: configApi => { + configApi.addTemplate("index.html", `--- pkg: myOwn: OVERRIDE ---`); @@ -1085,8 +1108,8 @@ pkg: test("Eleventy setting pkg data is okay when keys.package is false", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", `--- + config: configApi => { + configApi.addTemplate("index.html", `--- pkg: myOwn: OVERRIDE --- @@ -1116,8 +1139,8 @@ pkg: test("Eleventy setting reserved data throws error (pkg remapped to parkour)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", `--- + config: configApi => { + configApi.addTemplate("index.html", `--- parkour: myOwn: OVERRIDE ---`); @@ -1143,8 +1166,8 @@ parkour: test("Eleventy data schema (success) #879", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index1.html", "", { + config: configApi => { + configApi.addTemplate("index1.html", "", { draft: true, eleventyDataSchema: function(data) { if(typeof data.draft !== "boolean") { @@ -1153,7 +1176,7 @@ test("Eleventy data schema (success) #879", async (t) => { } }); - eleventyConfig.addTemplate("index2.html", "", { + configApi.addTemplate("index2.html", "", { draft: true, eleventyDataSchema: function(data) { if(typeof data.draft !== "boolean") { @@ -1171,8 +1194,8 @@ test("Eleventy data schema (success) #879", async (t) => { test("Eleventy data schema (fails) #879", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index1.html", "", { + config: configApi => { + configApi.addTemplate("index1.html", "", { draft: 1, eleventyDataSchema: function(data) { if(typeof data.draft !== "boolean") { @@ -1193,8 +1216,8 @@ test("Eleventy data schema (fails) #879", async (t) => { test("Eleventy data schema (fails, using zod) #879", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index1.html", "", { + config: configApi => { + configApi.addTemplate("index1.html", "", { draft: 1, eleventyDataSchema: function(data) { let result = z.object({ @@ -1220,12 +1243,12 @@ test("Eleventy data schema (fails, using zod) #879", async (t) => { test("Eleventy data schema has access to custom collections created via API #879", async (t) => { t.plan(2); let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addCollection("userCollection", function (collection) { + config: configApi => { + configApi.addCollection("userCollection", function (collection) { return collection.getAll(); }); - eleventyConfig.addTemplate("index1.html", "", { + configApi.addTemplate("index1.html", "", { eleventyDataSchema: function(data) { t.is(data.collections.userCollection.length, 1); } @@ -1241,11 +1264,11 @@ test("Eleventy data schema has access to custom collections created via API #879 test("Eleventy transforms filter (using collections and page override data)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { pathPrefix: "hi", - config: eleventyConfig => { - eleventyConfig.addPlugin(HtmlBasePlugin); + config: configApi => { + configApi.addPlugin(HtmlBasePlugin); - eleventyConfig.addTemplate("index.html", `abc`, { tags: "posts" }); - eleventyConfig.addTemplate("feed.njk", `{% for post in collections.posts %}{{ post.content | renderTransforms(post.page) | safe }}{% endfor %}`, { + configApi.addTemplate("index.html", `abc`, { tags: "posts" }); + configApi.addTemplate("feed.njk", `{% for post in collections.posts %}{{ post.content | renderTransforms(post.page) | safe }}{% endfor %}`, { permalink: "feed.xml" }); } @@ -1261,14 +1284,14 @@ test("Eleventy transforms filter (using collections and page override data)", as test("Custom Markdown Render with permalink, Issue #2780", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addExtension("md", { + config: configApi => { + configApi.addExtension("md", { compile: str => { return data => marked.parse(str); } }); - eleventyConfig.addTemplate("template.md", `# Markdown?`, { permalink: "/permalink.html" }); + configApi.addTemplate("template.md", `# Markdown?`, { permalink: "/permalink.html" }); } }); @@ -1280,13 +1303,13 @@ test("Custom Markdown Render with permalink, Issue #2780", async (t) => { test("Custom Markdown Render with permalink, Issue #2780 #3339", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplateFormats("markdown"); - eleventyConfig.addExtension("markdown", { + config: configApi => { + configApi.addTemplateFormats("markdown"); + configApi.addExtension("markdown", { key: "md" }); - eleventyConfig.addTemplate("filename-hi.markdown", `# Markdown?`, { permalink: "/{{ page.fileSlug }}.html" }); + configApi.addTemplate("filename-hi.markdown", `# Markdown?`, { permalink: "/{{ page.fileSlug }}.html" }); } }); @@ -1298,8 +1321,8 @@ test("Custom Markdown Render with permalink, Issue #2780 #3339", async (t) => { test("Test input/output conflicts (input overwrites output), Issue #3327", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/", { - config: eleventyConfig => { - eleventyConfig.addTemplate("test.html", `# Markdown`, { permalink: "test.html" }); + config: configApi => { + configApi.addTemplate("test.html", `# Markdown`, { permalink: "test.html" }); } }); elev.disableLogger(); @@ -1312,9 +1335,9 @@ test("Test input/output conflicts (input overwrites output), Issue #3327", async test("Test input/output conflicts (output overwrites another input), Issue #3327", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/", { - config: eleventyConfig => { - eleventyConfig.addTemplate("test.html", `# Markdown`); - eleventyConfig.addTemplate("index.html", `# Markdown`, { permalink: "test.html" }); + config: configApi => { + configApi.addTemplate("test.html", `# Markdown`); + configApi.addTemplate("index.html", `# Markdown`, { permalink: "test.html" }); } }); elev.disableLogger(); @@ -1328,8 +1351,8 @@ test("Test input/output conflicts (output overwrites another input), Issue #3327 test("Eleventy data schema has access to custom collections created via API #613 #3345", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addCollection("userCollection", async function (collection) { + config: configApi => { + configApi.addCollection("userCollection", async function (collection) { let c = collection.getFilteredByTag("posts"); for(let item of c) { const frontMatter = await item.template.read(); @@ -1339,8 +1362,8 @@ test("Eleventy data schema has access to custom collections created via API #613 return c; }); - eleventyConfig.addTemplate("home.html", "{% for post in collections.userCollection %}{{ post.content }}{% endfor %}"); - eleventyConfig.addTemplate("post.html", "test", { tags: "posts" }); + configApi.addTemplate("home.html", "{% for post in collections.userCollection %}{{ post.content }}{% endfor %}"); + configApi.addTemplate("post.html", "test", { tags: "posts" }); } }); elev.disableLogger(); @@ -1353,8 +1376,8 @@ test("Eleventy data schema has access to custom collections created via API #613 test("Custom Nunjucks syntax has shortcode with access to `this`, Issue #3310", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addShortcode("customized", function(argString) { + config: configApi => { + configApi.addShortcode("customized", function(argString) { return `${this.page.url}:${argString}:Custom Shortcode`; }); @@ -1372,8 +1395,8 @@ test("Custom Nunjucks syntax has shortcode with access to `this`, Issue #3310", }; this.run = function(context, argString) { - let fn = eleventyConfig.augmentFunctionContext( - eleventyConfig.getShortcode("customized"), + let fn = configApi.augmentFunctionContext( + configApi.getShortcode("customized"), { source: context.ctx, // lazy: false, @@ -1388,9 +1411,9 @@ test("Custom Nunjucks syntax has shortcode with access to `this`, Issue #3310", njkEnv.addExtension('CustomExtension', new CustomExtension()); - eleventyConfig.addTemplateFormats("njknew"); + configApi.addTemplateFormats("njknew"); - eleventyConfig.addExtension("njknew", { + configApi.addExtension("njknew", { compile: (str, inputPath) => { let tmpl = new nunjucks.Template(str, njkEnv, inputPath, false); return function(data) { @@ -1407,7 +1430,7 @@ test("Custom Nunjucks syntax has shortcode with access to `this`, Issue #3310", } }); - eleventyConfig.addTemplate("template.njknew", `

{{ hello }}:{% customized "passed in" %}

`, { + configApi.addTemplate("template.njknew", `

{{ hello }}:{% customized "passed in" %}

`, { hello: "goodbye" }); } diff --git a/test/EleventyAddGlobalDataTest.js b/test/EleventyAddGlobalDataTest.js index 9181dfd74..4f339ce54 100644 --- a/test/EleventyAddGlobalDataTest.js +++ b/test/EleventyAddGlobalDataTest.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("Eleventy addGlobalData should run once", async (t) => { let count = 0; diff --git a/test/EleventyImgTransformTest.js b/test/EleventyImgTransformTest.js index 9dbc9736f..68e9c7629 100644 --- a/test/EleventyImgTransformTest.js +++ b/test/EleventyImgTransformTest.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import { eleventyImageTransformPlugin } from "@11ty/eleventy-img"; import { normalizeNewLines } from "./Util/normalizeNewLines.js"; diff --git a/test/EleventyMarkdownTest.js b/test/EleventyMarkdownTest.js index e2f6839fd..699ee45d9 100644 --- a/test/EleventyMarkdownTest.js +++ b/test/EleventyMarkdownTest.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("Markdown in markdown #3954", async (t) => { let elev = new Eleventy({ diff --git a/test/EleventyNunjucksTest.js b/test/EleventyNunjucksTest.js index 2cfb01e21..68b74c007 100644 --- a/test/EleventyNunjucksTest.js +++ b/test/EleventyNunjucksTest.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("Paired shortcodes in macros #2261 #1749", async (t) => { let elev = new Eleventy({ diff --git a/test/EleventyErrorHandlerTest.js b/test/ErrorHandlerTest.js similarity index 85% rename from test/EleventyErrorHandlerTest.js rename to test/ErrorHandlerTest.js index bc7aab229..c1c905864 100644 --- a/test/EleventyErrorHandlerTest.js +++ b/test/ErrorHandlerTest.js @@ -1,8 +1,8 @@ import test from "ava"; -import { EleventyErrorHandler } from "../src/Errors/EleventyErrorHandler.js"; +import { ErrorHandler } from "../src/Errors/ErrorHandler.js"; test("Log a warning, warning", (t) => { - let errorHandler = new EleventyErrorHandler(); + let errorHandler = new ErrorHandler(); let output = []; errorHandler.logger = { log: function (str) { @@ -25,7 +25,7 @@ test("Log a warning, warning", (t) => { }); test("Log a warning, error", (t) => { - let errorHandler = new EleventyErrorHandler(); + let errorHandler = new ErrorHandler(); let output = []; errorHandler.logger = { diff --git a/test/EleventyErrorUtilTest.js b/test/ErrorUtilTest.js similarity index 94% rename from test/EleventyErrorUtilTest.js rename to test/ErrorUtilTest.js index 34728abd9..5c4789497 100644 --- a/test/EleventyErrorUtilTest.js +++ b/test/ErrorUtilTest.js @@ -1,10 +1,10 @@ import test from "ava"; -import EleventyErrorUtil from "../src/Errors/EleventyErrorUtil.js"; +import ErrorUtil from "../src/Errors/ErrorUtil.js"; const SAMPLE_ERROR = new Error("Nothing to see here"); const { cleanMessage, hasEmbeddedError, convertErrorToString, deconvertErrorToObject } = - EleventyErrorUtil; + ErrorUtil; test("hasEmbeddedError()", (t) => { t.false(hasEmbeddedError("")); diff --git a/test/EleventyExtensionMapTest.js b/test/ExtensionMapTest.js similarity index 98% rename from test/EleventyExtensionMapTest.js rename to test/ExtensionMapTest.js index 03f2b1ca1..1105de5e9 100644 --- a/test/EleventyExtensionMapTest.js +++ b/test/ExtensionMapTest.js @@ -1,5 +1,5 @@ import test from "ava"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import TemplateConfig from "../src/TemplateConfig.js"; @@ -7,7 +7,7 @@ async function getExtensionMap(formats, config = new TemplateConfig()) { if (config) { await config.init(); } - let map = new EleventyExtensionMap(config); + let map = new ExtensionMap(config); map.setFormats(formats); map.engineManager = new TemplateEngineManager(config); return map; diff --git a/test/EleventyFilesGitIgnoreEleventyIgnoreTest.js b/test/FilesGitIgnoreEleventyIgnoreTest.js similarity index 100% rename from test/EleventyFilesGitIgnoreEleventyIgnoreTest.js rename to test/FilesGitIgnoreEleventyIgnoreTest.js diff --git a/test/EleventyFilesTest.js b/test/FilesTest.js similarity index 99% rename from test/EleventyFilesTest.js rename to test/FilesTest.js index fdb71b58b..52099ed75 100644 --- a/test/EleventyFilesTest.js +++ b/test/FilesTest.js @@ -1,11 +1,10 @@ import test from "ava"; import { glob } from "tinyglobby"; -import EleventyFiles from "../src/EleventyFiles.js"; import TemplateConfig from "../src/TemplateConfig.js"; import TemplatePassthroughManager from "../src/TemplatePassthroughManager.js"; import ProjectDirectories from "../src/Util/ProjectDirectories.js"; -import { isTypeScriptSupported } from "../src/Util/FeatureTests.cjs"; +import { isTypeScriptSupported } from "../src/Util/TypeScriptFeatureTest.cjs"; import { getTemplateConfigInstance, getTemplateConfigInstanceCustomCallback, getEleventyFilesInstance } from "./_testHelpers.js"; diff --git a/test/HtmlBasePluginTest.js b/test/HtmlBasePluginTest.js index d0e02e85d..8c9326dac 100644 --- a/test/HtmlBasePluginTest.js +++ b/test/HtmlBasePluginTest.js @@ -1,7 +1,7 @@ import test from "ava"; import { default as HtmlBasePlugin, applyBaseToUrl } from "../src/Plugins/HtmlBasePlugin.js"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import { normalizeNewLines } from "./Util/normalizeNewLines.js"; function getContentFor(results, filename) { diff --git a/test/HtmlRelativeCopyTest.js b/test/HtmlRelativeCopyTest.js index 7cfd1f31f..611b93926 100644 --- a/test/HtmlRelativeCopyTest.js +++ b/test/HtmlRelativeCopyTest.js @@ -5,7 +5,7 @@ import { globSync } from "tinyglobby"; import { TransformPlugin as InputPathToUrlTransformPlugin } from "../src/Plugins/InputPathToUrl.js"; import { default as HtmlBasePlugin } from "../src/Plugins/HtmlBasePlugin.js"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import { deleteDirectory } from "./_testHelpers.js"; test.after.always("Directory cleanup", () => { @@ -30,7 +30,7 @@ test("Basic usage", async (t) => { mode: "html-relative" }) - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: { "/test/possum.png": TemplatePath.normalizeOperatingSystemFilePath("test/stubs-autocopy/possum.png") @@ -79,7 +79,7 @@ test("More complex image path (parent dir)", async (t) => { mode: "html-relative" }) - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: { "/stubs-img-transform/possum.png": TemplatePath.normalizeOperatingSystemFilePath("test/stubs-img-transform/possum.png") @@ -129,7 +129,7 @@ test("No matches", async (t) => { mode: "html-relative" }) - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); @@ -156,7 +156,7 @@ test("Match but does not exist (throws error)", async (t) => { mode: "html-relative" }); - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); @@ -187,7 +187,7 @@ test("Match but does not exist (no error, using `failOnError: false`)", async (t failOnError: false, }) - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); @@ -221,7 +221,7 @@ test("Copying dotfiles are not allowed", async (t) => { } }); - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); @@ -256,7 +256,7 @@ test("Using with InputPathToUrl plugin", async (t) => { eleventyConfig.addPlugin(InputPathToUrlTransformPlugin); - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); @@ -292,7 +292,7 @@ test("Using with InputPathToUrl plugin (reverse addPlugin order)", async (t) => mode: "html-relative" }); - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); @@ -326,7 +326,7 @@ test("Use with HtmlBasePlugin usage", async (t) => { mode: "html-relative" }); - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: { "/test/possum.png": TemplatePath.normalizeOperatingSystemFilePath("test/stubs-autocopy/possum.png") @@ -380,7 +380,7 @@ test("Using with InputPathToUrl plugin and HtmlBasePlugin", async (t) => { eleventyConfig.addPlugin(InputPathToUrlTransformPlugin); eleventyConfig.addPlugin(HtmlBasePlugin); - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); @@ -416,7 +416,7 @@ test("Multiple addPlugin calls (use both globs)", async (t) => { mode: "html-relative" }); - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: { "/test/possum.jpg": TemplatePath.normalizeOperatingSystemFilePath("test/stubs-autocopy/possum.jpg"), @@ -473,7 +473,7 @@ test("Array of globs", async (t) => { mode: "html-relative" }); - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: { "/test/possum.jpg": TemplatePath.normalizeOperatingSystemFilePath("test/stubs-autocopy/possum.jpg"), @@ -536,7 +536,7 @@ test("overwrite: false", async (t) => { } }); - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) @@ -582,7 +582,7 @@ test("Input -> output remapping not yet supported (throws error)", async (t) => mode: "html-relative" }); - eleventyConfig.on("eleventy.passthrough", copyMap => { + eleventyConfig.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); diff --git a/test/I18nPluginTest.js b/test/I18nPluginTest.js index b352ea218..02a4f7c77 100644 --- a/test/I18nPluginTest.js +++ b/test/I18nPluginTest.js @@ -1,6 +1,6 @@ import test from "ava"; import { Comparator, LangUtils, default as I18nPlugin } from "../src/Plugins/I18nPlugin.js"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import { normalizeNewLines } from "./Util/normalizeNewLines.js"; test("Comparator.isLangCode", (t) => { @@ -36,7 +36,7 @@ test("contentMap Event from Eleventy", async (t) => { errorMode: "allow-fallback", }); - eleventyConfig.on("eleventy.contentMap", (maps) => { + eleventyConfig.on("buildawesome.contentmap", (maps) => { t.truthy(maps); // if future maps are added, they should be tested here diff --git a/test/IdAttributePluginTest.js b/test/IdAttributePluginTest.js index 69e21908b..84553bc74 100644 --- a/test/IdAttributePluginTest.js +++ b/test/IdAttributePluginTest.js @@ -1,7 +1,7 @@ import test from "ava"; import { IdAttributePlugin } from "../src/Plugins/IdAttributePlugin.js"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("Using the IdAttribute plugin #3356", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { diff --git a/test/InputPathToUrlPluginTest.js b/test/InputPathToUrlPluginTest.js index b21f741f7..05c96db9f 100644 --- a/test/InputPathToUrlPluginTest.js +++ b/test/InputPathToUrlPluginTest.js @@ -2,7 +2,7 @@ import test from "ava"; import { TransformPlugin } from "../src/Plugins/InputPathToUrl.js"; import { default as HtmlBasePlugin } from "../src/Plugins/HtmlBasePlugin.js"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import { normalizeNewLines } from "./Util/normalizeNewLines.js"; const OUTPUT_HTML_STD = ` diff --git a/test/Issue3467Test.js b/test/Issue3467Test.js index 508b4f58b..328360b7d 100644 --- a/test/Issue3467Test.js +++ b/test/Issue3467Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("Empty collections api #3467 (return undefined)", async (t) => { let elev = new Eleventy("./test/stubs-virtual", "./test/stubs-virtual/_site", { diff --git a/test/Issue3788Test.js b/test/Issue3788Test.js index 9b74461ad..504bac170 100644 --- a/test/Issue3788Test.js +++ b/test/Issue3788Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#3788 Nunjucks shortcodes args", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/Issue3797Test.js b/test/Issue3797Test.js index e5de3b962..2f81ca072 100644 --- a/test/Issue3797Test.js +++ b/test/Issue3797Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#3797 Virtual templates with empty includes", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/Issue3808Test.js b/test/Issue3808Test.js index f38d19ce4..258549eb0 100644 --- a/test/Issue3808Test.js +++ b/test/Issue3808Test.js @@ -1,15 +1,14 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; -test("#3808 addCollection in eleventy.before", async (t) => { +test("#3808 addCollection in buildawesome.before", async (t) => { let elev = new Eleventy("test/noop", false, { config(eleventyConfig) { eleventyConfig.addTemplate("post1.md", "# Post1"); eleventyConfig.addTemplate("post2.md", "# Post2"); eleventyConfig.addTemplate("index.njk", "{{ collections.posts.length }}"); - eleventyConfig.on("eleventy.before", async () => { - // eleventyConfig.on("eleventy.beforeConfig", async (eleventyConfig) => { + eleventyConfig.on("buildawesome.before", async () => { eleventyConfig.addCollection("posts", async collectionApi => { return collectionApi.getFilteredByGlob("**/post*.md"); }); @@ -24,7 +23,7 @@ test("#3808 addCollection in eleventy.before", async (t) => { // /* broken */ // export default function(eleventyConfig) { -// eleventyConfig.on("eleventy.before", async () => { +// eleventyConfig.on("buildawesome.before", async () => { // eleventyConfig.addCollection("posts", collectionApi => { // return collectionApi.getFilteredByGlob("**/post*.md"); // }); @@ -33,7 +32,7 @@ test("#3808 addCollection in eleventy.before", async (t) => { // /* works */ // export default function(eleventyConfig) { -// eleventyConfig.on("eleventy.beforeConfig", async (eleventyConfig) => { +// eleventyConfig.on("buildawesome.beforeConfig", async (eleventyConfig) => { // eleventyConfig.addCollection("posts", collectionApi => { // return collectionApi.getFilteredByGlob("**/post*.md"); // }); diff --git a/test/Issue3816Test.js b/test/Issue3816Test.js index 5eadf486f..ef2a62163 100644 --- a/test/Issue3816Test.js +++ b/test/Issue3816Test.js @@ -2,7 +2,7 @@ import markdownIt from "markdown-it"; import markdownItAbbr from "markdown-it-abbr"; import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#3816 amendLibrary and setLibrary together", async (t) => { t.plan(1); diff --git a/test/Issue3818Test.js b/test/Issue3818Test.js index edf79ec1a..ca49eb3db 100644 --- a/test/Issue3818Test.js +++ b/test/Issue3818Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import WebCPlugin from "@11ty/eleventy-plugin-webc"; test("#3818 WebC Permalink", async (t) => { diff --git a/test/Issue3823Test.js b/test/Issue3823Test.js index b415eb58c..12025c430 100644 --- a/test/Issue3823Test.js +++ b/test/Issue3823Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#3823 addCollection -> pagination over `collections`", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/Issue3825Test.js b/test/Issue3825Test.js index f8e3fdb4b..815b41888 100644 --- a/test/Issue3825Test.js +++ b/test/Issue3825Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#3825 #3834 addCollection consumes tag from pagination template", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/Issue3831Test.js b/test/Issue3831Test.js index 9045c36b0..aa6101a66 100644 --- a/test/Issue3831Test.js +++ b/test/Issue3831Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#3831 Computed Data regression", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/Issue3833Test.js b/test/Issue3833Test.js index ff3471208..ec610d505 100644 --- a/test/Issue3833Test.js +++ b/test/Issue3833Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#3831 Computed Data regression", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/Issue3850Test.js b/test/Issue3850Test.js index 60f067d2d..596ced028 100644 --- a/test/Issue3850Test.js +++ b/test/Issue3850Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#3850 Computed Data regression part 2", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/Issue3860Test.js b/test/Issue3860Test.js index c34c2f6d9..c8952836f 100644 --- a/test/Issue3860Test.js +++ b/test/Issue3860Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#3860 addCollection consumes `collections` but is missing `collections.all`", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/Issue3870IncrementalTest.js b/test/Issue3870IncrementalTest.js index 5b382d640..40b7b647f 100644 --- a/test/Issue3870IncrementalTest.js +++ b/test/Issue3870IncrementalTest.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; // This tests Eleventy Watch WITHOUT using the file system! @@ -34,7 +34,7 @@ test("#3870 templateRender has not yet initialized (not incremental)", async (t) } }); - eleventyConfig.on("eleventy.after", ({ results }) => { + eleventyConfig.on("buildawesome.after", ({ results }) => { t.is(results[0]?.content, runs[index].expected); }); } diff --git a/test/Issue3870Test.js b/test/Issue3870Test.js index 201b72c9e..9ce3a2ad5 100644 --- a/test/Issue3870Test.js +++ b/test/Issue3870Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; // This tests Eleventy Watch WITHOUT using the file system! @@ -34,7 +34,7 @@ test("#3870 templateRender has not yet initialized (not incremental)", async (t) } }); - eleventyConfig.on("eleventy.after", ({ results }) => { + eleventyConfig.on("buildawesome.after", ({ results }) => { t.is(results[0]?.content, runs[index].expected); }); } diff --git a/test/Issue3875Test.js b/test/Issue3875Test.js index 49c272b49..c3e3d4ef1 100644 --- a/test/Issue3875Test.js +++ b/test/Issue3875Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#3875 numeric tags", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/Issue434Test.js b/test/Issue434Test.js index 296dfc7e0..3ae64d560 100644 --- a/test/Issue434Test.js +++ b/test/Issue434Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#434 Using `with context` to access collections", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/Issue775Test.js b/test/Issue775Test.js index 61353e296..d79acabfc 100644 --- a/test/Issue775Test.js +++ b/test/Issue775Test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("#775 Using data cascade in Collection API", async (t) => { let elev = new Eleventy("test/noop", false, { diff --git a/test/JavaScriptFrontMatterTest.js b/test/JavaScriptFrontMatterTest.js index f446efe2f..5d40d4355 100644 --- a/test/JavaScriptFrontMatterTest.js +++ b/test/JavaScriptFrontMatterTest.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("Custom Front Matter Parsing Options (using JavaScript node-retrieve-globals)", async (t) => { let elev = new Eleventy("./test/stubs/script-frontmatter/test.njk", "./_site"); diff --git a/test/PaginationTest.js b/test/PaginationTest.js index b96e19c42..12a5bbe16 100644 --- a/test/PaginationTest.js +++ b/test/PaginationTest.js @@ -1,10 +1,10 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import TemplateData from "../src/Data/TemplateData.js"; import Pagination from "../src/Plugins/Pagination.js"; import FileSystemSearch from "../src/FileSystemSearch.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import getNewTemplate from "./_getNewTemplateForTests.js"; import { getRenderedTemplates as getRenderedTmpls, renderTemplate } from "./_getRenderedTemplates.js"; import { getTemplateConfigInstance } from "./_testHelpers.js"; @@ -139,7 +139,7 @@ test("Paginate external data file", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -362,7 +362,7 @@ test("Issue 135", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -700,7 +700,7 @@ test("Pagination new v0.10.0 href/hrefs", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -738,7 +738,7 @@ test("Pagination new v0.10.0 page/pages", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -804,7 +804,7 @@ test("Pagination mutable global data", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -848,7 +848,7 @@ test("Pagination template/dir data files run once, Issue 919", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( diff --git a/test/PreserveClosingTagsPluginTest.js b/test/PreserveClosingTagsPluginTest.js index 8210fe903..fd144e188 100644 --- a/test/PreserveClosingTagsPluginTest.js +++ b/test/PreserveClosingTagsPluginTest.js @@ -1,7 +1,7 @@ import test from "ava"; import { PreserveClosingTagsPlugin } from "../src/Plugins/PreserveClosingTagsPlugin.js"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("Using the PreserveClosingTagsPlugin plugin (meta off) #3356", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { diff --git a/test/ReservedDataTest.js b/test/ReservedDataTest.js index 4c1043000..b5a893de8 100644 --- a/test/ReservedDataTest.js +++ b/test/ReservedDataTest.js @@ -1,6 +1,6 @@ import test from "ava"; import ReservedData from "../src/Util/ReservedData.js"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("No reserved Keys", t => { t.deepEqual(ReservedData.getReservedKeys({ key: {} }).sort(), []); diff --git a/test/EleventyServeTest.js b/test/ServeTest.js similarity index 95% rename from test/EleventyServeTest.js rename to test/ServeTest.js index bcfa7e827..362931971 100644 --- a/test/EleventyServeTest.js +++ b/test/ServeTest.js @@ -1,10 +1,10 @@ import test from "ava"; -import EleventyServe from "../src/EleventyServe.js"; +import Serve from "../src/Serve.js"; import TemplateConfig from "../src/TemplateConfig.js"; async function getServerInstance(eleventyConfig) { - let es = new EleventyServe(); + let es = new Serve(); if (!eleventyConfig) { eleventyConfig = new TemplateConfig(); await eleventyConfig.init(); diff --git a/test/TemplateDataTest.js b/test/TemplateDataTest.js index b53f5fb1a..b9ad090ad 100644 --- a/test/TemplateDataTest.js +++ b/test/TemplateDataTest.js @@ -5,8 +5,8 @@ import { Merge } from "@11ty/eleventy-utils"; import TemplateData from "../src/Data/TemplateData.js"; import FileSystemSearch from "../src/FileSystemSearch.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; -import { isTypeScriptSupported } from "../src/Util/FeatureTests.cjs"; +import ExtensionMap from "../src/ExtensionMap.js"; +import { isTypeScriptSupported } from "../src/Util/TypeScriptFeatureTest.cjs"; import { getTemplateConfigInstance, getTemplateConfigInstanceCustomCallback } from "./_testHelpers.js"; @@ -105,7 +105,7 @@ test("Add local data", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); @@ -134,7 +134,7 @@ test("Get local data async JS", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); @@ -153,7 +153,7 @@ test("addLocalData() doesn’t exist but doesn’t fail (template file does exis }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); @@ -178,7 +178,7 @@ test("addLocalData() doesn’t exist but doesn’t fail (template file does not }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); @@ -373,7 +373,7 @@ test("getLocalDataPaths", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -410,7 +410,7 @@ test("getLocalDataPaths (with setDataFileBaseName #1699)", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -456,7 +456,7 @@ test("getLocalDataPaths (with empty setDataFileSuffixes #1699)", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -471,7 +471,7 @@ test("getLocalDataPaths (with setDataFileSuffixes override #1699)", async (t) => }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -507,7 +507,7 @@ test("getLocalDataPaths (with setDataFileSuffixes empty string override #1699)", let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -523,7 +523,7 @@ test("getLocalDataPaths (with setDataFileSuffixes override with two entries #169 let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -563,7 +563,7 @@ test("getLocalDataPaths (with setDataFileSuffixes and setDataFileBaseName #1699) }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -605,7 +605,7 @@ test("Deeper getLocalDataPaths", async (t) => { let eleventyConfig = await getTemplateConfigInstance(); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -652,7 +652,7 @@ test("getLocalDataPaths with an 11ty js template", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.11ty.js"); @@ -688,7 +688,7 @@ test("getLocalDataPaths with inputDir passed in (trailing slash)", async (t) => }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -724,7 +724,7 @@ test("getLocalDataPaths with inputDir passed in (no trailing slash)", async (t) }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -760,7 +760,7 @@ test("getLocalDataPaths with inputDir passed in (no leading slash)", async (t) = }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); @@ -961,7 +961,7 @@ test("eleventy.version and eleventy.generator returned from data", async (t) => let version = semver.coerce(pkg.version).toString(); t.is(data.eleventy.version, version); - t.is(data.eleventy.generator, `Eleventy v${version}`); + t.is(data.eleventy.generator, `Eleventy (Build Awesome) v${version}`); t.is(data.deep.nested.one, "first"); t.is(data.deep.nested.two, "second"); diff --git a/test/TemplateEngineManagerTest.js b/test/TemplateEngineManagerTest.js index 996c9774b..a44a552ec 100644 --- a/test/TemplateEngineManagerTest.js +++ b/test/TemplateEngineManagerTest.js @@ -1,7 +1,7 @@ import test from "ava"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import TemplateConfig from "../src/TemplateConfig.js"; test("Unsupported engine", async (t) => { @@ -34,7 +34,7 @@ test("Supported custom engine", async (t) => { }); await eleventyConfig.init(); - let extensionMap = new EleventyExtensionMap(eleventyConfig); + let extensionMap = new ExtensionMap(eleventyConfig); let tem = new TemplateEngineManager(eleventyConfig); @@ -62,7 +62,7 @@ test("Custom engine with custom init", async (t) => { }); await eleventyConfig.init(); - let extensionMap = new EleventyExtensionMap(eleventyConfig); + let extensionMap = new ExtensionMap(eleventyConfig); // let config = eleventyConfig.getConfig(); let tem = new TemplateEngineManager(eleventyConfig); @@ -85,7 +85,7 @@ test("Custom engine with custom init", async (t) => { test("getEngineLib", async (t) => { let eleventyConfig = new TemplateConfig(); await eleventyConfig.init(); - let extensionMap = new EleventyExtensionMap(eleventyConfig); + let extensionMap = new ExtensionMap(eleventyConfig); let tem = new TemplateEngineManager(eleventyConfig); let engine = await tem.getEngine("md", extensionMap); diff --git a/test/TemplateFileSlugTest.js b/test/TemplateFileSlugTest.js index 1ce9e8650..c45c7c555 100644 --- a/test/TemplateFileSlugTest.js +++ b/test/TemplateFileSlugTest.js @@ -1,7 +1,7 @@ import test from "ava"; import TemplateFileSlug from "../src/TemplateFileSlug.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import { getTemplateConfigInstance } from "./_testHelpers.js"; @@ -12,7 +12,7 @@ async function getNewSlugInstance(path, inputDir) { } }); - let extensionMap = new EleventyExtensionMap(eleventyConfig); + let extensionMap = new ExtensionMap(eleventyConfig); extensionMap.setFormats([]); let fs = new TemplateFileSlug(path, extensionMap, eleventyConfig); return fs; diff --git a/test/TemplateLayoutPathResolverTest.js b/test/TemplateLayoutPathResolverTest.js index 959783573..e8ebd775f 100644 --- a/test/TemplateLayoutPathResolverTest.js +++ b/test/TemplateLayoutPathResolverTest.js @@ -1,7 +1,7 @@ import test from "ava"; import TemplateLayoutPathResolver from "../src/TemplateLayoutPathResolver.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import { getTemplateConfigInstance, getTemplateConfigInstanceCustomCallback } from "./_testHelpers.js"; @@ -15,7 +15,7 @@ async function getResolverInstance(path, inputDir, { eleventyConfig, map } = {}) } if (!map) { - map = new EleventyExtensionMap(eleventyConfig); + map = new ExtensionMap(eleventyConfig); map.setFormats(["liquid", "md", "njk", "html", "11ty.js"]); } diff --git a/test/TemplateLayoutTest.js b/test/TemplateLayoutTest.js index f50c404f9..89fb30bf9 100644 --- a/test/TemplateLayoutTest.js +++ b/test/TemplateLayoutTest.js @@ -1,7 +1,7 @@ import test from "ava"; import TemplateLayout from "../src/TemplateLayout.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import { renderLayoutViaLayout } from "./_getRenderedTemplates.js"; @@ -16,7 +16,7 @@ async function getTemplateLayoutInstance(key, inputDir, map) { let mgr = new TemplateEngineManager(eleventyConfig); if (!map) { - map = new EleventyExtensionMap(eleventyConfig); + map = new ExtensionMap(eleventyConfig); map.setFormats(["liquid", "md", "njk", "html", "11ty.js"]); map.engineManager = mgr; } diff --git a/test/TemplateMapTest-ComputedData.js b/test/TemplateMapTest-ComputedData.js index 009bbb4d1..8f2af910e 100644 --- a/test/TemplateMapTest-ComputedData.js +++ b/test/TemplateMapTest-ComputedData.js @@ -5,7 +5,7 @@ import TemplateMap from "../src/TemplateMap.js"; import getNewTemplate from "./_getNewTemplateForTests.js"; import { getTemplateConfigInstance } from "./_testHelpers.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; test("Computed data can see tag generated collections", async (t) => { let eleventyConfig = await getTemplateConfigInstance({ @@ -17,7 +17,7 @@ test("Computed data can see tag generated collections", async (t) => { let tm = new TemplateMap(eleventyConfig); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); let tmpl = await getNewTemplate( "./test/stubs-computed-collections/collections.njk", "./test/stubs-computed-collections/", @@ -30,7 +30,7 @@ test("Computed data can see tag generated collections", async (t) => { await tm.add(tmpl); let dataObj2 = new TemplateData(eleventyConfig); - dataObj2.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj2.extensionMap = new ExtensionMap(eleventyConfig); let tmpl2 = await getNewTemplate( "./test/stubs-computed-collections/dog.njk", "./test/stubs-computed-collections/", @@ -69,7 +69,7 @@ test("Computed data can see paginated data, Issue #1138", async (t) => { let tm = new TemplateMap(eleventyConfig); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); let tmpl = await getNewTemplate( "./test/stubs-computed-pagination/paginated.njk", "./test/stubs-computed-pagination/", @@ -82,7 +82,7 @@ test("Computed data can see paginated data, Issue #1138", async (t) => { await tm.add(tmpl); let dataObj2 = new TemplateData(eleventyConfig); - dataObj2.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj2.extensionMap = new ExtensionMap(eleventyConfig); let tmpl2 = await getNewTemplate( "./test/stubs-computed-pagination/child.11ty.cjs", "./test/stubs-computed-pagination/", @@ -134,7 +134,7 @@ test("Computed data in directory data file consumes data file data, Issue #1137" let tm = new TemplateMap(eleventyConfig); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); let tmpl = await getNewTemplate( "./test/stubs-computed-dirdata/dir/first.11ty.cjs", "./test/stubs-computed-dirdata/", @@ -147,7 +147,7 @@ test("Computed data in directory data file consumes data file data, Issue #1137" await tm.add(tmpl); let dataObj2 = new TemplateData(eleventyConfig); - dataObj2.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj2.extensionMap = new ExtensionMap(eleventyConfig); let tmpl2 = await getNewTemplate( "./test/stubs-computed-dirdata/dir/second.11ty.cjs", "./test/stubs-computed-dirdata/", @@ -178,7 +178,7 @@ test("Computed data can filter collections (and other array methods)", async (t) let tm = new TemplateMap(eleventyConfig); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); let tmpl = await getNewTemplate( "./test/stubs-computed-collections-filter/collections.njk", "./test/stubs-computed-collections-filter/", @@ -191,7 +191,7 @@ test("Computed data can filter collections (and other array methods)", async (t) await tm.add(tmpl); let dataObj2 = new TemplateData(eleventyConfig); - dataObj2.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj2.extensionMap = new ExtensionMap(eleventyConfig); let tmpl2 = await getNewTemplate( "./test/stubs-computed-collections-filter/dog.njk", "./test/stubs-computed-collections-filter/", diff --git a/test/TemplateMapTest.js b/test/TemplateMapTest.js index b347a20a2..01f8f64e6 100644 --- a/test/TemplateMapTest.js +++ b/test/TemplateMapTest.js @@ -1473,7 +1473,7 @@ test("eleventy.layouts Event", async (t) => { output: "./test/stubs-layouts-event/_site", }, function(cfg) { - cfg.on("eleventy.layouts", (layoutMap) => { + cfg.on("buildawesome.layouts", (layoutMap) => { t.deepEqual(layoutMap, { "./test/stubs-layouts-event/_includes/first.liquid": ["./test/stubs-layouts-event/page.md"], "./test/stubs-layouts-event/_includes/second.liquid": [ diff --git a/test/TemplatePassthroughManagerTest.js b/test/TemplatePassthroughManagerTest.js index 333327abc..767828f03 100644 --- a/test/TemplatePassthroughManagerTest.js +++ b/test/TemplatePassthroughManagerTest.js @@ -4,7 +4,7 @@ import fs from "fs"; import TemplatePassthroughManager from "../src/TemplatePassthroughManager.js"; import TemplateConfig from "../src/TemplateConfig.js"; import FileSystemSearch from "../src/FileSystemSearch.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import ProjectDirectories from "../src/Util/ProjectDirectories.js"; import { getTemplateConfigInstance, getTemplateConfigInstanceCustomCallback, getEleventyFilesInstance, deleteDirectory } from "./_testHelpers.js"; @@ -30,7 +30,7 @@ test("filterToPassthroughCopyFilesOnly", async (t) => { await eleventyConfig.init(); let mgr = new TemplatePassthroughManager(eleventyConfig); - mgr.extensionMap = new EleventyExtensionMap(eleventyConfig); + mgr.extensionMap = new ExtensionMap(eleventyConfig); t.deepEqual(mgr.filterToPassthroughCopyFilesOnly([]), []); t.deepEqual(mgr.filterToPassthroughCopyFilesOnly([], ""), []); @@ -74,7 +74,7 @@ test("Get file paths", async (t) => { await eleventyConfig.init(); let mgr = new TemplatePassthroughManager(eleventyConfig); - mgr.extensionMap = new EleventyExtensionMap(eleventyConfig); + mgr.extensionMap = new ExtensionMap(eleventyConfig); t.deepEqual(mgr.getNonTemplatePaths(["test.png"]), ["test.png"]); }); @@ -84,7 +84,7 @@ test("Get file paths (filter out real templates)", async (t) => { await eleventyConfig.init(); let mgr = new TemplatePassthroughManager(eleventyConfig); - mgr.extensionMap = new EleventyExtensionMap(eleventyConfig); + mgr.extensionMap = new ExtensionMap(eleventyConfig); mgr.extensionMap.setFormats(["njk"]); t.deepEqual(mgr.getNonTemplatePaths(["test.njk"]), []); @@ -95,7 +95,7 @@ test("Get file paths (filter out real templates), multiple", async (t) => { await eleventyConfig.init(); let mgr = new TemplatePassthroughManager(eleventyConfig); - mgr.extensionMap = new EleventyExtensionMap(eleventyConfig); + mgr.extensionMap = new ExtensionMap(eleventyConfig); mgr.extensionMap.setFormats(["njk"]); t.deepEqual(mgr.getNonTemplatePaths(["test.njk", "test.png"]), ["test.png"]); @@ -106,7 +106,7 @@ test("Get file paths with a js file (filter out real templates), multiple", asyn await eleventyConfig.init(); let mgr = new TemplatePassthroughManager(eleventyConfig); - mgr.extensionMap = new EleventyExtensionMap(eleventyConfig); + mgr.extensionMap = new ExtensionMap(eleventyConfig); mgr.extensionMap.setFormats(["njk"]); t.deepEqual(mgr.getNonTemplatePaths(["test.njk", "test.js"]), ["test.js"]); @@ -118,7 +118,7 @@ test("Get file paths (one image path)", async (t) => { await eleventyConfig.init(); let mgr = new TemplatePassthroughManager(eleventyConfig); - mgr.extensionMap = new EleventyExtensionMap(eleventyConfig); + mgr.extensionMap = new ExtensionMap(eleventyConfig); t.deepEqual(mgr.getNonTemplatePaths(["test.png"]), ["test.png"]); }); diff --git a/test/TemplateRenderCustomTest.js b/test/TemplateRenderCustomTest.js index dfb469e80..6182661f2 100644 --- a/test/TemplateRenderCustomTest.js +++ b/test/TemplateRenderCustomTest.js @@ -4,7 +4,7 @@ import { renderToString } from "@vue/server-renderer"; import * as sass from "sass"; import TemplateRender from "../src/TemplateRender.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import getNewTemplate from "./_getNewTemplateForTests.js"; import { renderTemplate } from "./_getRenderedTemplates.js"; @@ -19,7 +19,7 @@ async function getNewTemplateRender(name, inputDir, eleventyConfig, extensionMap if (!extensionMap) { - extensionMap = new EleventyExtensionMap(eleventyConfig); + extensionMap = new ExtensionMap(eleventyConfig); extensionMap.setFormats([]); } @@ -324,7 +324,7 @@ test.skip("Breaking Change (3.0): Two simple aliases to JavaScript Render", asyn } ); - let map = new EleventyExtensionMap(eleventyConfig); // reuse this + let map = new ExtensionMap(eleventyConfig); // reuse this map.setFormats([]); let tr = await getNewTemplateRender("./test/stubs/string.11ty.custom", null, eleventyConfig, map); @@ -363,7 +363,7 @@ test("Double override (one simple alias to custom) works fine", async (t) => { } ); - let map = new EleventyExtensionMap(eleventyConfig); // reuse this + let map = new ExtensionMap(eleventyConfig); // reuse this // map.setFormats(["11ty.possum", "11ty.custom"]); map.setFormats(["customhtml"]); @@ -393,7 +393,7 @@ test("Double override (two simple aliases)", async (t) => { } ); - let map = new EleventyExtensionMap(eleventyConfig); // reuse this + let map = new ExtensionMap(eleventyConfig); // reuse this // map.setFormats(["11ty.possum", "11ty.custom"]); map.setFormats(["customhtml"]); @@ -444,7 +444,7 @@ test("Double override (two complex aliases) is supported as of 3.0", async (t) = } ); - let map = new EleventyExtensionMap(eleventyConfig); // reuse this + let map = new ExtensionMap(eleventyConfig); // reuse this map.setFormats(["possum", "11ty.custom"]); let tr = await getNewTemplateRender( diff --git a/test/TemplateRenderHTMLTest.js b/test/TemplateRenderHTMLTest.js index 009293ae6..3d051b5bf 100644 --- a/test/TemplateRenderHTMLTest.js +++ b/test/TemplateRenderHTMLTest.js @@ -1,6 +1,6 @@ import test from "ava"; import TemplateRender from "../src/TemplateRender.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import { getTemplateConfigInstance } from "./_testHelpers.js"; @@ -13,7 +13,7 @@ async function getNewTemplateRender(name, inputDir) { }); let tr = new TemplateRender(name, eleventyConfig); - tr.extensionMap = new EleventyExtensionMap(eleventyConfig); + tr.extensionMap = new ExtensionMap(eleventyConfig); tr.extensionMap.engineManager = new TemplateEngineManager(eleventyConfig); tr.extensionMap.setFormats([]); await tr.init(); diff --git a/test/TemplateRenderJavaScriptTest.js b/test/TemplateRenderJavaScriptTest.js index ef15fe611..1f7880084 100644 --- a/test/TemplateRenderJavaScriptTest.js +++ b/test/TemplateRenderJavaScriptTest.js @@ -1,8 +1,8 @@ import test from "ava"; import TemplateRender from "../src/TemplateRender.js"; -import Eleventy from "../src/Eleventy.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import Eleventy from "../src/Core.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import { getTemplateConfigInstance } from "./_testHelpers.js"; @@ -17,7 +17,7 @@ async function getNewTemplateRender(name, inputDir, extendedConfig) { eleventyConfig.setProjectUsingEsm(true); let tr = new TemplateRender(name, eleventyConfig); - tr.extensionMap = new EleventyExtensionMap(eleventyConfig); + tr.extensionMap = new ExtensionMap(eleventyConfig); tr.extensionMap.engineManager = new TemplateEngineManager(eleventyConfig); tr.extensionMap.setFormats([]); await tr.init(); diff --git a/test/TemplateRenderLiquidTest.js b/test/TemplateRenderLiquidTest.js index fecf67963..76d3822ce 100644 --- a/test/TemplateRenderLiquidTest.js +++ b/test/TemplateRenderLiquidTest.js @@ -1,9 +1,9 @@ import test from "ava"; import { Liquid, Drop } from "liquidjs"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import TemplateRender from "../src/TemplateRender.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import { getTemplateConfigInstance } from "./_testHelpers.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; @@ -16,7 +16,7 @@ async function getNewTemplateRender(name, inputDir, userConfig = {}) { }, null, userConfig); let tr = new TemplateRender(name, eleventyConfig); - tr.extensionMap = new EleventyExtensionMap(eleventyConfig); + tr.extensionMap = new ExtensionMap(eleventyConfig); tr.extensionMap.engineManager = new TemplateEngineManager(eleventyConfig); tr.extensionMap.setFormats([]); await tr.init(); diff --git a/test/TemplateRenderMarkdownPluginTest.js b/test/TemplateRenderMarkdownPluginTest.js index aa438ff8c..163ed60ff 100644 --- a/test/TemplateRenderMarkdownPluginTest.js +++ b/test/TemplateRenderMarkdownPluginTest.js @@ -2,7 +2,7 @@ import test from "ava"; import md from "markdown-it"; import TemplateRender from "../src/TemplateRender.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import { getTemplateConfigInstance } from "./_testHelpers.js"; @@ -11,7 +11,7 @@ async function getNewTemplateRender(name, inputDir) { let eleventyConfig = await getTemplateConfigInstance(); let tr = new TemplateRender(name, eleventyConfig); - tr.extensionMap = new EleventyExtensionMap(eleventyConfig); + tr.extensionMap = new ExtensionMap(eleventyConfig); tr.extensionMap.engineManager = new TemplateEngineManager(eleventyConfig); tr.extensionMap.setFormats([]); await tr.init(); diff --git a/test/TemplateRenderMarkdownTest.js b/test/TemplateRenderMarkdownTest.js index 2d6454678..c2e554c75 100644 --- a/test/TemplateRenderMarkdownTest.js +++ b/test/TemplateRenderMarkdownTest.js @@ -6,7 +6,7 @@ import eleventySyntaxHighlightPlugin from "@11ty/eleventy-plugin-syntaxhighlight import TemplateRender from "../src/TemplateRender.js"; import Liquid from "../src/Engines/Liquid.js"; import Nunjucks from "../src/Engines/Nunjucks.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import { normalizeNewLines } from "./Util/normalizeNewLines.js"; @@ -22,7 +22,7 @@ async function getNewTemplateRender(name, inputDir, eleventyConfig) { } let tr = new TemplateRender(name, eleventyConfig); - tr.extensionMap = new EleventyExtensionMap(eleventyConfig); + tr.extensionMap = new ExtensionMap(eleventyConfig); tr.extensionMap.engineManager = new TemplateEngineManager(eleventyConfig); tr.extensionMap.setFormats([]); await tr.init(); diff --git a/test/TemplateRenderNunjucksTest.js b/test/TemplateRenderNunjucksTest.js index 22fa1e754..c1f6156e8 100644 --- a/test/TemplateRenderNunjucksTest.js +++ b/test/TemplateRenderNunjucksTest.js @@ -2,7 +2,7 @@ import test from "ava"; import Nunjucks from "@11ty/nunjucks"; import TemplateRender from "../src/TemplateRender.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import { normalizeNewLines } from "./Util/normalizeNewLines.js"; @@ -18,7 +18,7 @@ async function getNewTemplateRender(name, inputDir, eleventyConfig) { } let tr = new TemplateRender(name, eleventyConfig); - tr.extensionMap = new EleventyExtensionMap(eleventyConfig); + tr.extensionMap = new ExtensionMap(eleventyConfig); tr.extensionMap.engineManager = new TemplateEngineManager(eleventyConfig); tr.extensionMap.setFormats([]); await tr.init(); diff --git a/test/TemplateRenderPluginTest.js b/test/TemplateRenderPluginTest.js index 2a073adcb..8d89be4be 100644 --- a/test/TemplateRenderPluginTest.js +++ b/test/TemplateRenderPluginTest.js @@ -6,7 +6,7 @@ import { String as RenderPluginString, RenderManager, } from "../src/Plugins/RenderPlugin.js"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import { normalizeNewLines } from "./Util/normalizeNewLines.js"; diff --git a/test/TemplateRenderTest.js b/test/TemplateRenderTest.js index 403c583a3..cbfd7a8e9 100644 --- a/test/TemplateRenderTest.js +++ b/test/TemplateRenderTest.js @@ -1,7 +1,7 @@ import test from "ava"; import TemplateRender from "../src/TemplateRender.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import { getTemplateConfigInstance } from "./_testHelpers.js"; @@ -14,7 +14,7 @@ async function getNewTemplateRender(name, inputDir) { }); let tr = new TemplateRender(name, eleventyConfig); - tr.extensionMap = new EleventyExtensionMap(eleventyConfig); + tr.extensionMap = new ExtensionMap(eleventyConfig); tr.extensionMap.engineManager = new TemplateEngineManager(eleventyConfig); tr.extensionMap.setFormats([]); await tr.init(); diff --git a/test/TemplateTest-CompileOptions.js b/test/TemplateTest-CompileOptions.js index 542420e90..86b454e33 100644 --- a/test/TemplateTest-CompileOptions.js +++ b/test/TemplateTest-CompileOptions.js @@ -1,7 +1,7 @@ import test from "ava"; import TemplateData from "../src/Data/TemplateData.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import getNewTemplate from "./_getNewTemplateForTests.js"; import { renderTemplate } from "./_getRenderedTemplates.js"; @@ -36,7 +36,7 @@ test("Custom extension (.txt) with custom permalink compile function", async (t) }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( @@ -78,7 +78,7 @@ test("Custom extension with and compileOptions.permalink = false", async (t) => }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( @@ -120,7 +120,7 @@ test("Custom extension with and opt-out of permalink compilation", async (t) => }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( @@ -170,7 +170,7 @@ test("Custom extension (.txt) with custom permalink compile function but no perm }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( @@ -218,7 +218,7 @@ test("Custom extension (.txt) with custom permalink compile function (that retur }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( @@ -266,7 +266,7 @@ test("Custom extension (.txt) with custom permalink compile function that return }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( @@ -307,7 +307,7 @@ test("Custom extension (.txt) that returns undefined from compile", async (t) => }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( diff --git a/test/TemplateTest-ComputedData.js b/test/TemplateTest-ComputedData.js index 098b733e9..8ad8dca3f 100644 --- a/test/TemplateTest-ComputedData.js +++ b/test/TemplateTest-ComputedData.js @@ -1,8 +1,8 @@ import test from "ava"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import TemplateData from "../src/Data/TemplateData.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import getNewTemplate from "./_getNewTemplateForTests.js"; import { renderTemplate } from "./_getRenderedTemplates.js"; @@ -132,7 +132,7 @@ test("eleventyComputed relies on global data", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/eleventyComputed/use-global-data.njk", @@ -159,7 +159,7 @@ test("eleventyComputed intermixes with global data", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( diff --git a/test/TemplateTest-CustomExtensions.js b/test/TemplateTest-CustomExtensions.js index d0184421a..5b56582d0 100644 --- a/test/TemplateTest-CustomExtensions.js +++ b/test/TemplateTest-CustomExtensions.js @@ -2,7 +2,7 @@ import test from "ava"; import { marked } from "marked"; import TemplateData from "../src/Data/TemplateData.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import getNewTemplate from "./_getNewTemplateForTests.js"; import { renderTemplate } from "./_getRenderedTemplates.js"; @@ -29,7 +29,7 @@ test("Using getData: false without getInstanceFromInputPath works ok", async (t) }) let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/custom-extension.txt", @@ -65,7 +65,7 @@ test("Using getData: true without getInstanceFromInputPath should error", async }) let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/custom-extension.txt", @@ -104,7 +104,7 @@ test("Using getData: [] without getInstanceFromInputPath should error", async (t }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/custom-extension.txt", @@ -152,7 +152,7 @@ test("Using getData: true and getInstanceFromInputPath to get data from instance }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/custom-extension.txt", @@ -198,7 +198,7 @@ test("Using eleventyDataKey to get a different key data from instance", async (t }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/custom-extension.txt", @@ -227,7 +227,7 @@ test("Uses default renderer (no compile function) when you override an existing }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/default.liquid", @@ -265,7 +265,7 @@ test("Access to default renderer when you override an existing extension", async }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/default.liquid", @@ -304,7 +304,7 @@ test("Overridden liquid gets used from a markdown template", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/default.md", @@ -343,7 +343,7 @@ test("Use marked for markdown", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/default-no-liquid.md", @@ -380,7 +380,7 @@ test("Use defaultRenderer for markdown", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/default.md", @@ -416,7 +416,7 @@ test("Front matter in a custom extension", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/default-frontmatter.txt", @@ -455,7 +455,7 @@ test("Access to default renderer when you override an existing extension (async }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/default.liquid", @@ -493,7 +493,7 @@ test("Access to default renderer when you override an existing extension (async }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/default.liquid", @@ -526,7 +526,7 @@ test("Return undefined in compile to ignore #2267", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/custom-extension.txt", @@ -559,7 +559,7 @@ test("Return undefined in compile to ignore (async compile function) #2350", asy }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/custom-extension.txt", diff --git a/test/TemplateTest.js b/test/TemplateTest.js index 80faf6864..eb0222d60 100644 --- a/test/TemplateTest.js +++ b/test/TemplateTest.js @@ -5,10 +5,10 @@ import TOML from "@iarna/toml"; import TemplateData from "../src/Data/TemplateData.js"; import FileSystemSearch from "../src/FileSystemSearch.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; -import EleventyErrorUtil from "../src/Errors/EleventyErrorUtil.js"; +import ExtensionMap from "../src/ExtensionMap.js"; +import ErrorUtil from "../src/Errors/ErrorUtil.js"; import TemplateContentPrematureUseError from "../src/Errors/TemplateContentPrematureUseError.js"; -import { isTypeScriptSupported } from "../src/Util/FeatureTests.cjs"; +import { isTypeScriptSupported } from "../src/Util/TypeScriptFeatureTest.cjs"; import { normalizeNewLines } from "./Util/normalizeNewLines.js"; import getNewTemplate from "./_getNewTemplateForTests.js"; @@ -191,7 +191,7 @@ test("One Layout (using new content var)", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/templateWithLayoutKey.liquid", @@ -227,7 +227,7 @@ test("One Layout (using content)", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/templateWithLayoutContent.liquid", @@ -263,7 +263,7 @@ test("One Layout (layouts disabled)", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/templateWithLayoutContent.liquid", @@ -297,7 +297,7 @@ test("One Layout (liquid test)", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/templateWithLayout.liquid", @@ -333,7 +333,7 @@ test("Two Layouts", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/templateTwoLayouts.liquid", @@ -371,7 +371,7 @@ test("Liquid template", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/formatTest.liquid", @@ -426,7 +426,7 @@ test("Layout from template-data-file that has a permalink (fileslug) Issue #121" }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( "./test/stubs/permalink-data-layout/test.njk", @@ -458,7 +458,7 @@ test("Local template data file import (without a global data json)", async (t) = }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -507,7 +507,7 @@ test("Local template data file import (two subdirectories deep)", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -576,7 +576,7 @@ test("Posts inherits local JSON, layouts", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -649,7 +649,7 @@ test("Template and folder name are the same, make sure data imports work ok", as }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -1220,7 +1220,7 @@ test("Data Cascade (Deep merge)", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -1260,7 +1260,7 @@ test("Data Cascade Tag Merge (Deep merge)", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -1288,7 +1288,7 @@ test("Data Cascade Tag Merge (Deep Merge - Deduplication)", async (t) => { }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -1316,7 +1316,7 @@ test('Local data inherits tags string ([tags] vs "tags") Deep Merge', async (t) }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -1346,7 +1346,7 @@ test("Throws a Premature Template Content Error (njk)", async (t) => { let error = t.throws(() => { mapEntries[0].templateContent; }); - t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true); + t.is(ErrorUtil.isPrematureTemplateContentError(error), true); }); test("Throws a Premature Template Content Error from rendering (njk)", async (t) => { @@ -1372,7 +1372,7 @@ test("Throws a Premature Template Content Error from rendering (njk)", async (t) let error = await t.throwsAsync(async () => { await tmpl.renderPageEntry(pageEntries[0]); }); - t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true); + t.is(ErrorUtil.isPrematureTemplateContentError(error), true); }); test("Throws a Premature Template Content Error (liquid)", async (t) => { @@ -1387,7 +1387,7 @@ test("Throws a Premature Template Content Error (liquid)", async (t) => { let error = t.throws(() => { mapEntries[0].templateContent; }); - t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true); + t.is(ErrorUtil.isPrematureTemplateContentError(error), true); }); test("Throws a Premature Template Content Error (11ty.js)", async (t) => { @@ -1402,7 +1402,7 @@ test("Throws a Premature Template Content Error (11ty.js)", async (t) => { let error = t.throws(() => { mapEntries[0].templateContent; }); - t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true); + t.is(ErrorUtil.isPrematureTemplateContentError(error), true); }); test("Throws a Premature Template Content Error (md)", async (t) => { @@ -1417,7 +1417,7 @@ test("Throws a Premature Template Content Error (md)", async (t) => { let error = t.throws(() => { mapEntries[0].templateContent; }); - t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true); + t.is(ErrorUtil.isPrematureTemplateContentError(error), true); }); test("Throws a Premature Template Content Error from rendering (md)", async (t) => { @@ -1443,7 +1443,7 @@ test("Throws a Premature Template Content Error from rendering (md)", async (t) let error = await t.throwsAsync(async () => { await tmpl.renderPageEntry(pageEntries[0]); }); - t.is(EleventyErrorUtil.isPrematureTemplateContentError(error), true); + t.is(ErrorUtil.isPrematureTemplateContentError(error), true); }); test("Issue 413 weird date format", async (t) => { @@ -1698,7 +1698,7 @@ test("Engine Singletons", async (t) => { } }); - let map = new EleventyExtensionMap(eleventyConfig); + let map = new ExtensionMap(eleventyConfig); map.engineManager = new TemplateEngineManager(eleventyConfig); map.setFormats(["njk"]); let tmpl1 = await getNewTemplate( @@ -1738,7 +1738,7 @@ test("Make sure layout cache takes new changes during watch (nunjucks)", async ( fs.writeFileSync(filePath, `alert("bye");`, "utf8"); - tmpl.config.events.emit("eleventy#templateModified", filePath); + tmpl.config.events.emit("buildawesome#templatemodified", filePath); t.is((await renderTemplate(tmpl, data)).trim(), ''); }); @@ -1784,7 +1784,7 @@ test("Add Extension via Configuration (txt file)", async (t) => { }); }); - let map = new EleventyExtensionMap(eleventyConfig); + let map = new ExtensionMap(eleventyConfig); map.engineManager = new TemplateEngineManager(eleventyConfig); map.setFormats([]); let tmpl = await getNewTemplate( @@ -1953,7 +1953,7 @@ test("Error messaging, returning literals (not objects) from custom data extensi }); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( diff --git a/test/TemplateWriterTest.js b/test/TemplateWriterTest.js index dc7af0376..11975122d 100644 --- a/test/TemplateWriterTest.js +++ b/test/TemplateWriterTest.js @@ -3,8 +3,8 @@ import fs from "fs"; import { glob } from "tinyglobby"; import path from "path"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; -import { isTypeScriptSupported } from "../src/Util/FeatureTests.cjs"; +import ExtensionMap from "../src/ExtensionMap.js"; +import { isTypeScriptSupported } from "../src/Util/TypeScriptFeatureTest.cjs"; import { normalizeNewLines } from "./Util/normalizeNewLines.js"; import { getRenderedTemplates as getRenderedTmpls } from "./_getRenderedTemplates.js"; @@ -527,7 +527,7 @@ test.skip("Markdown with alias", async (t) => { } }); - let map = new EleventyExtensionMap(eleventyConfig); + let map = new ExtensionMap(eleventyConfig); map.setFormats(["md"]); map.config = { templateExtensionAliases: { @@ -564,7 +564,7 @@ test.skip("JavaScript with alias", async (t) => { } }); - let map = new EleventyExtensionMap(eleventyConfig); + let map = new ExtensionMap(eleventyConfig); map.setFormats(["11ty.js"]); map.config = { templateExtensionAliases: { diff --git a/test/UserDataExtensionsTest.js b/test/UserDataExtensionsTest.js index 951d03197..d3571f196 100644 --- a/test/UserDataExtensionsTest.js +++ b/test/UserDataExtensionsTest.js @@ -5,10 +5,10 @@ import yaml from "js-yaml"; import TemplateConfig from "../src/TemplateConfig.js"; import FileSystemSearch from "../src/FileSystemSearch.js"; import TemplateData from "../src/Data/TemplateData.js"; -import { isTypeScriptSupported } from "../src/Util/FeatureTests.cjs"; +import { isTypeScriptSupported } from "../src/Util/TypeScriptFeatureTest.cjs"; import { getTemplateConfigInstanceCustomCallback } from "./_testHelpers.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; test("Local data", async (t) => { let eleventyConfig = await getTemplateConfigInstanceCustomCallback( @@ -22,7 +22,7 @@ test("Local data", async (t) => { ); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); @@ -61,7 +61,7 @@ test("Local files", async (t) => { ); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); let files = await dataObj.getLocalDataPaths("./test/stubs-630/component-yaml/component.njk"); t.deepEqual(files, [ @@ -124,7 +124,7 @@ test("Global data", async (t) => { ); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); @@ -167,7 +167,7 @@ test("Global data merging and priority", async (t) => { ); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); @@ -207,7 +207,7 @@ test("Binary data files, encoding: null", async (t) => { ); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); @@ -235,7 +235,7 @@ test("Binary data files, read: false", async (t) => { ); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); @@ -263,7 +263,7 @@ test("Binary data files, encoding: null (multiple data extensions)", async (t) = ); let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new EleventyExtensionMap(eleventyConfig); + dataObj.extensionMap = new ExtensionMap(eleventyConfig); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); diff --git a/test/_getNewTemplateForTests.js b/test/_getNewTemplateForTests.js index be0e4ee5d..02d952011 100644 --- a/test/_getNewTemplateForTests.js +++ b/test/_getNewTemplateForTests.js @@ -1,4 +1,4 @@ -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import Template from "../src/Template.js"; import FileSystemSearch from "../src/FileSystemSearch.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; @@ -24,7 +24,7 @@ export default async function getNewTemplate( let engineManager = new TemplateEngineManager(eleventyConfig); if (!map) { - map = new EleventyExtensionMap(eleventyConfig); + map = new ExtensionMap(eleventyConfig); map.setFormats(["liquid", "md", "njk", "html", "11ty.js"]); map.engineManager = engineManager; } diff --git a/test/_issues/2250/2250-test.js b/test/_issues/2250/2250-test.js index aba681a22..6d7f763cf 100644 --- a/test/_issues/2250/2250-test.js +++ b/test/_issues/2250/2250-test.js @@ -1,5 +1,5 @@ import test from "ava"; -import Eleventy from "../../../src/Eleventy.js"; +import Eleventy from "../../../src/Core.js"; test("Issue #2250, page is available in filters", async (t) => { let elev = new Eleventy("./test/_issues/2250/", "./test/_issues/2250/_site", { diff --git a/test/_issues/3697/3697-test.js b/test/_issues/3697/3697-test.js index 4024e5b6a..643514214 100644 --- a/test/_issues/3697/3697-test.js +++ b/test/_issues/3697/3697-test.js @@ -1,7 +1,7 @@ // import path from "node:path"; // import { fileURLToPath } from "node:url"; import test from "ava"; -import Eleventy from "../../../src/Eleventy.js"; +import Eleventy from "../../../src/Core.js"; test("Number file names on global data files", async t => { // TODO fix absolute paths here diff --git a/test/_testHelpers.js b/test/_testHelpers.js index c90263162..eb4808488 100644 --- a/test/_testHelpers.js +++ b/test/_testHelpers.js @@ -2,9 +2,9 @@ import { existsSync, rmSync } from "node:fs"; import { isPlainObject } from "@11ty/eleventy-utils"; import TemplateConfig from "../src/TemplateConfig.js"; import ProjectDirectories from "../src/Util/ProjectDirectories.js"; -import EleventyExtensionMap from "../src/EleventyExtensionMap.js"; +import ExtensionMap from "../src/ExtensionMap.js"; import TemplatePassthroughManager from "../src/TemplatePassthroughManager.js"; -import EleventyFiles from "../src/EleventyFiles.js"; +import { Files } from "../src/Files.js"; import FileSystemSearch from "../src/FileSystemSearch.js"; import TemplateWriter from "../src/TemplateWriter.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; @@ -63,7 +63,7 @@ export function getTemplateWriterInstance(formats, templateConfig) { ); let engineManager = new TemplateEngineManager(templateConfig); - let map = new EleventyExtensionMap(templateConfig); + let map = new ExtensionMap(templateConfig); map.engineManager = engineManager; map.setFormats(formats); @@ -80,7 +80,7 @@ export function getTemplateWriterInstance(formats, templateConfig) { } export function getEleventyFilesInstance(formats, templateConfig) { - let map = new EleventyExtensionMap(templateConfig); + let map = new ExtensionMap(templateConfig); map.setFormats(formats); let fss = new FileSystemSearch(); @@ -89,7 +89,7 @@ export function getEleventyFilesInstance(formats, templateConfig) { mgr.extensionMap = map; mgr.setFileSystemSearch(fss); - let files = new EleventyFiles(formats, templateConfig); + let files = new Files(formats, templateConfig); files.setPassthroughManager(mgr); files.setFileSystemSearch(fss); files.extensionMap = map; diff --git a/test/stubs-3807/Issue3807test.js b/test/stubs-3807/Issue3807test.js index 38a49a733..74194307f 100644 --- a/test/stubs-3807/Issue3807test.js +++ b/test/stubs-3807/Issue3807test.js @@ -1,6 +1,6 @@ import test from "ava"; import fs from "node:fs"; -import Eleventy from "../../src/Eleventy.js"; +import Eleventy from "../../src/Core.js"; // This tests Eleventy Watch and the file system! @@ -33,7 +33,7 @@ test("#3807 Nunjucks cacheable should be reused when Nunjucks is the preprocesso let elev = new Eleventy("test/stubs-3807/", "test/stubs-3807/_site", { configPath: "test/stubs-3807/eleventy.config.js", config(eleventyConfig) { - eleventyConfig.on("eleventy.afterwatch", () => { + eleventyConfig.on("buildawesome.afterwatch", () => { let {resolve} = runs[index]; index++; resolve(); diff --git a/test/stubs-3810/eleventy.config.js b/test/stubs-3810/eleventy.config.js index b73543382..804019fca 100644 --- a/test/stubs-3810/eleventy.config.js +++ b/test/stubs-3810/eleventy.config.js @@ -1,5 +1,5 @@ import fs from 'fs'; -import { RenderPlugin } from '../../src/Eleventy.js'; +import { RenderPlugin } from '../../src/Core.js'; const { RenderManager } = RenderPlugin; export default function(eleventyConfig) { diff --git a/test_node/3824-incremental/3824-incremental-test.js b/test_node/3824-incremental/3824-incremental-test.js index 51a8d4d41..a457d281e 100644 --- a/test_node/3824-incremental/3824-incremental-test.js +++ b/test_node/3824-incremental/3824-incremental-test.js @@ -5,7 +5,7 @@ import test from "node:test"; import fs from "node:fs"; import assert from "node:assert"; -import Eleventy from "../../src/Eleventy.js"; +import Eleventy from "../../src/Core.js"; // This tests Eleventy Watch and the file system! @@ -56,7 +56,7 @@ test( let elev = new Eleventy(ROOT_DIR, OUTPUT_DIR, { configPath: ROOT_DIR + "eleventy.config.js", config(eleventyConfig) { - eleventyConfig.on("eleventy.afterwatch", () => { + eleventyConfig.on("buildawesome.afterwatch", () => { let { resolve } = runs[index]; index++; resolve(); diff --git a/test_node/3824-incremental/eleventy.config.js b/test_node/3824-incremental/eleventy.config.js index c7b324503..2827e7404 100644 --- a/test_node/3824-incremental/eleventy.config.js +++ b/test_node/3824-incremental/eleventy.config.js @@ -3,8 +3,8 @@ import { register } from "tsx/esm/api"; import { jsxToString } from "jsx-async-runtime"; // import { renderToStaticMarkup } from "react-dom/server"; -export default async function (eleventyConfig) { - eleventyConfig.addExtension(["11ty.jsx", "11ty.ts", "11ty.tsx"], { +export default async function (configApi) { + configApi.addExtension(["11ty.jsx", "11ty.ts", "11ty.tsx"], { key: "11ty.js", compile: async function (inputContent, inputPath) { this.addDependencies(inputPath, ["./test_node/3824-incremental/_includes/head.tsx"]); @@ -17,16 +17,16 @@ export default async function (eleventyConfig) { }, }); - eleventyConfig.addTemplateFormats(["11ty.jsx", "11ty.tsx"]); + configApi.addTemplateFormats(["11ty.jsx", "11ty.tsx"]); let unregister; - eleventyConfig.on("eleventy.before", () => { + configApi.on("buildawesome.before", () => { unregister = register({ // custom tsconfig tsconfig: "test_node/3824-incremental/tsconfig-3824.json", }); }); - eleventyConfig.on("eleventy.after", () => { + configApi.on("buildawesome.after", () => { unregister(); }); } diff --git a/test_node/3824/3824-test.js b/test_node/3824/3824-test.js index 8c58233ee..c333272b6 100644 --- a/test_node/3824/3824-test.js +++ b/test_node/3824/3824-test.js @@ -5,7 +5,7 @@ import test from "node:test"; import fs from "node:fs"; import assert from "node:assert"; -import Eleventy from "../../src/Eleventy.js"; +import Eleventy from "../../src/Core.js"; // This tests Eleventy Watch and the file system! @@ -56,7 +56,7 @@ test( let elev = new Eleventy(ROOT_DIR, OUTPUT_DIR, { configPath: ROOT_DIR + "eleventy.config.js", config(eleventyConfig) { - eleventyConfig.on("eleventy.afterwatch", () => { + eleventyConfig.on("buildawesome.afterwatch", () => { let { resolve } = runs[index]; index++; resolve(); diff --git a/test_node/3824/eleventy.config.js b/test_node/3824/eleventy.config.js index f1017e820..a1a77ee5d 100644 --- a/test_node/3824/eleventy.config.js +++ b/test_node/3824/eleventy.config.js @@ -3,8 +3,8 @@ import { register } from "tsx/esm/api"; import { jsxToString } from "jsx-async-runtime"; // import { renderToStaticMarkup } from "react-dom/server"; -export default async function (eleventyConfig) { - eleventyConfig.addExtension(["11ty.jsx", "11ty.ts", "11ty.tsx"], { +export default async function (configApi) { + configApi.addExtension(["11ty.jsx", "11ty.ts", "11ty.tsx"], { key: "11ty.js", compile: async function (inputContent, inputPath) { this.addDependencies(inputPath, ["./test_node/3824/_includes/head.tsx"]); @@ -17,16 +17,16 @@ export default async function (eleventyConfig) { }, }); - eleventyConfig.addTemplateFormats(["11ty.jsx", "11ty.tsx"]); + configApi.addTemplateFormats(["11ty.jsx", "11ty.tsx"]); let unregister; - eleventyConfig.on("eleventy.before", () => { + configApi.on("buildawesome.before", () => { unregister = register({ // custom tsconfig tsconfig: "test_node/3824/tsconfig-3824.json", }); }); - eleventyConfig.on("eleventy.after", () => { + configApi.on("buildawesome.after", () => { unregister(); }); } diff --git a/test_node/jsx.test.js b/test_node/jsx.test.js index 0f47d01e9..e6a0c5282 100644 --- a/test_node/jsx.test.js +++ b/test_node/jsx.test.js @@ -10,7 +10,7 @@ import { renderToStaticMarkup } from "react-dom/server"; import "tsx/esm"; // import 'tsimp'; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; test("Eleventy with JSX", async () => { let elev = new Eleventy("./test/stubs-fancyjs/test.11ty.tsx", undefined, { diff --git a/test_node/mdx.test.js b/test_node/mdx.test.js index a8636da11..537c76e17 100644 --- a/test_node/mdx.test.js +++ b/test_node/mdx.test.js @@ -6,7 +6,7 @@ import assert from "node:assert"; import module from "node:module"; import { renderToStaticMarkup } from "react-dom/server"; -import Eleventy from "../src/Eleventy.js"; +import Eleventy from "../src/Core.js"; import { load } from "./mdx-hooks.js"; if ("registerHooks" in module) { diff --git a/tsconfig.json b/tsconfig.json index a01ba080f..60520be35 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "include": [ - // "src/Eleventy.js", + // "src/Core.js", "src/UserConfig.js", "src/Util/ConsoleLogger.js", ], @@ -18,8 +18,8 @@ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ /* Language and Environment */ - "target": "ES2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - "lib": ["ES2021"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + "target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "lib": ["esnext"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ // "jsx": "preserve", /* Specify what JSX code is generated. */ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ @@ -32,9 +32,9 @@ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ /* Modules */ - "module": "Node16", /* Specify what module code is generated. */ + "module": "nodenext", /* Specify what module code is generated. */ // "rootDir": "./src/", /* Specify the root folder within your source files. */ - "moduleResolution": "Node16", /* Specify how TypeScript looks up a file from a given module specifier. */ + "moduleResolution": "nodenext", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ @@ -42,7 +42,7 @@ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ From 0ce6f276011b885be46b6278dfaef698de603c90 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 9 Jun 2026 12:08:34 -0500 Subject: [PATCH 16/53] Use buildawesome.config.js instead of build-awesome.config.js --- src/TemplateConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index 41353887c..e3e70c0ce 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -75,7 +75,7 @@ class TemplateConfig { } } else { this.projectConfigPaths = [ - ...expandEligibleJavaScriptFilePaths("build-awesome.config"), + ...expandEligibleJavaScriptFilePaths("buildawesome.config"), ".eleventy.js", ...expandEligibleJavaScriptFilePaths("eleventy.config"), ]; From d3888c01944094b988832b3b98a0b64de545859b Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 9 Jun 2026 15:47:13 -0500 Subject: [PATCH 17/53] Resolve buildawesome.* for data cascade. Prefer buildawesome.computed to eleventyComputed. --- src/Data/ResolveConfigurationData.js | 38 ++++++++++++++ src/Data/TemplateData.js | 20 +++++--- src/Plugins/Pagination.js | 12 ++--- src/Template.js | 16 ++++-- src/TemplateBehavior.js | 8 ++- src/TemplateMap.js | 25 +++++++--- src/defaultConfig.js | 9 ++-- test/CoreTest-ComputedData.js | 74 ++++++++++++++++++++++++++++ test/ResolveConfigurationDataTest.js | 53 ++++++++++++++++++++ 9 files changed, 224 insertions(+), 31 deletions(-) create mode 100644 src/Data/ResolveConfigurationData.js create mode 100644 test/CoreTest-ComputedData.js create mode 100644 test/ResolveConfigurationDataTest.js diff --git a/src/Data/ResolveConfigurationData.js b/src/Data/ResolveConfigurationData.js new file mode 100644 index 000000000..fe0393872 --- /dev/null +++ b/src/Data/ResolveConfigurationData.js @@ -0,0 +1,38 @@ +import lodash from "@11ty/lodash-custom"; + +const { set: lodashSet, get: lodashGet } = lodash; + +export class ResolveConfigurationData { + static BUILDAWESOME_PREFIX = "buildawesome."; + static ELEVENTY_PREFIX = "eleventy"; + + static capitalize(propName) { + return propName.slice(0, 1).toUpperCase() + propName.slice(1); + } + + // buildawesome.dataSchema becomes eleventyDataSchema + static getAlternatePropertyName(propertyName) { + if ( + typeof propertyName === "string" && + propertyName.startsWith(ResolveConfigurationData.BUILDAWESOME_PREFIX) + ) { + let prefixRemoved = propertyName.slice(ResolveConfigurationData.BUILDAWESOME_PREFIX.length); + return this.ELEVENTY_PREFIX + this.capitalize(prefixRemoved); + } + } + + static getValue(data, location) { + let eligibleLocations = [location]; + let alternate = ResolveConfigurationData.getAlternatePropertyName(location); + if (alternate !== undefined) { + eligibleLocations.push(alternate); + } + + for (let loc of eligibleLocations) { + let val = lodashGet(data, loc, undefined); + if (val !== undefined) { + return val; + } + } + } +} diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index 870cc5225..f3494ad7c 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -20,6 +20,7 @@ import { coerce } from "../Util/SemverCoerce.js"; import ProjectDirectories from "../Util/ProjectDirectories.js"; import ReservedData from "../Util/ReservedData.js"; import { isTypeScriptSupported } from "../Util/TypeScriptFeatureTest.cjs"; +import { ResolveConfigurationData } from "../Data/ResolveConfigurationData.js"; const { set: lodashSet, get: lodashGet } = lodash; @@ -780,19 +781,22 @@ class TemplateData { static getNormalizedExcludedCollections(data) { let excludes = []; - let key = "eleventyExcludeFromCollections"; - - if (data?.[key] !== true) { - if (Array.isArray(data[key])) { - excludes = data[key]; - } else if (typeof data[key] === "string") { - excludes = (data[key] || "").split(","); + // TODO move this key to defaultConfig->keys->excludeFromCollections + let excludeValue = ResolveConfigurationData.getValue( + data, + "buildawesome.excludeFromCollections", + ); + if (excludeValue !== true) { + if (Array.isArray(excludeValue)) { + excludes = excludeValue; + } else if (typeof excludeValue === "string") { + excludes = (excludeValue || "").split(","); } } return { excludes, - excludeAll: data?.eleventyExcludeFromCollections === true, + excludeAll: excludeValue === true, }; } diff --git a/src/Plugins/Pagination.js b/src/Plugins/Pagination.js index 11b991d19..1a217c454 100755 --- a/src/Plugins/Pagination.js +++ b/src/Plugins/Pagination.js @@ -13,6 +13,8 @@ class PaginationConfigError extends BaseError {} class PaginationError extends BaseError {} class Pagination { + static NOT_FOUND_VALUE = "__NOT_FOUND_ERROR__"; + constructor(tmpl, data, config) { if (!config) { throw new PaginationConfigError("Expected `config` argument to Pagination class."); @@ -113,15 +115,13 @@ class Pagination { } _has(target, key) { - let notFoundValue = "__NOT_FOUND_ERROR__"; - let data = lodashGet(target, key, notFoundValue); - return data !== notFoundValue; + let data = lodashGet(target, key, Pagination.NOT_FOUND_VALUE); + return data !== Pagination.NOT_FOUND_VALUE; } _get(target, key) { - let notFoundValue = "__NOT_FOUND_ERROR__"; - let data = lodashGet(target, key, notFoundValue); - if (data === notFoundValue) { + let data = lodashGet(target, key, Pagination.NOT_FOUND_VALUE); + if (data === Pagination.NOT_FOUND_VALUE) { throw new Error( `Could not find pagination data${this.inputPathForErrorMessages}, went looking for: ${key}`, ); diff --git a/src/Template.js b/src/Template.js index 4559d0c93..cacb05c81 100755 --- a/src/Template.js +++ b/src/Template.js @@ -24,6 +24,7 @@ import TransformsUtil from "./Util/TransformsUtil.js"; import { FileSystemUtilities } from "./Util/FileSystemUtilities.js"; import { TemplatePreprocessors } from "./TemplatePreprocessors.js"; import { getDirectoryFromUrl } from "./Util/UrlUtil.js"; +import { ResolveConfigurationData } from "./Data/ResolveConfigurationData.js"; const { set: lodashSet, get: lodashGet } = lodash; @@ -215,8 +216,11 @@ class Template extends TemplateContent { } let permalink = - data[this.config.keys.permalink] ?? - data?.[this.config.keys.computed]?.[this.config.keys.permalink]; + ResolveConfigurationData.getValue(data, this.config.keys.permalink) ?? + ResolveConfigurationData.getValue( + data, + `${this.config.keys.computed}.${this.config.keys.permalink}`, + ); let permalinkValue; let isDynamicPermalinkEnabled = this.config.dynamicPermalinks && data.dynamicPermalink !== false; @@ -638,7 +642,8 @@ class Template extends TemplateContent { } async addComputedData(data) { - if (isPlainObject(data?.[this.config.keys.computed])) { + let computedData = ResolveConfigurationData.getValue(data, this.config.keys.computed); + if (isPlainObject(computedData)) { this.computedData = new ComputedData(this.config); // Note that `permalink` is only a thing that gets consumed—it does not go directly into generated data @@ -667,12 +672,13 @@ class Template extends TemplateContent { ); // Check for reserved properties in computed data + let computedData = ResolveConfigurationData.getValue(data, this.config.keys.computed); if (this.config.freezeReservedData) { - ReservedData.checkSubset(data[this.config.keys.computed]); + ReservedData.checkSubset(computedData); } // actually add the computed data - this._addComputedEntry(this.computedData, data[this.config.keys.computed]); + this._addComputedEntry(this.computedData, computedData); // limited run of computed data—save the stuff that relies on collections for later. debug("First round of computed data for %o", this.inputPath); diff --git a/src/TemplateBehavior.js b/src/TemplateBehavior.js index dde513e4c..adf6e33fd 100644 --- a/src/TemplateBehavior.js +++ b/src/TemplateBehavior.js @@ -1,5 +1,7 @@ import { isPlainObject } from "@11ty/eleventy-utils"; +import { ResolveConfigurationData } from "./Data/ResolveConfigurationData.js"; + class TemplateBehavior { #isRenderOptional; @@ -64,8 +66,10 @@ class TemplateBehavior { } let computedKey = this.config.keys.computed; - if (computedKey in data && isPlainObject(data[computedKey]?.permalink)) { - for (let key of Object.keys(data[computedKey].permalink)) { + let computedData = ResolveConfigurationData.getValue(data, this.config.keys.computed); + let permalink = ResolveConfigurationData.getValue(computedData, this.config.keys.permalink); + if (computedData && isPlainObject(permalink)) { + for (let key of Object.keys(permalink)) { keys.add(key); } } diff --git a/src/TemplateMap.js b/src/TemplateMap.js index e0e02edd1..5ad5d0cfc 100644 --- a/src/TemplateMap.js +++ b/src/TemplateMap.js @@ -7,6 +7,7 @@ import UsingCircularTemplateContentReferenceError from "./Errors/UsingCircularTe import DuplicatePermalinkOutputError from "./Errors/DuplicatePermalinkOutputError.js"; import TemplateData from "./Data/TemplateData.js"; import GlobalDependencyMap from "./GlobalDependencyMap.js"; +import { ResolveConfigurationData } from "./Data/ResolveConfigurationData.js"; const debug = createDebug("BuildAwesome:TemplateMap"); @@ -117,8 +118,9 @@ class TemplateMap { let consumes = []; consumes.push(this.getPaginationTagTarget(entry)); - if (Array.isArray(entry.data.eleventyImport?.collections)) { - for (let tag of entry.data.eleventyImport.collections) { + let importData = ResolveConfigurationData.getValue(entry.data, this.config.keys.import); + if (Array.isArray(importData?.collections)) { + for (let tag of importData.collections) { consumes.push(tag); } } @@ -229,7 +231,10 @@ class TemplateMap { } if (counter === 0 || map.data.pagination?.addAllPagesToCollections) { - if (map.data.eleventyExcludeFromCollections !== true) { + if ( + ResolveConfigurationData.getValue(map.data, "buildawesome.excludeFromCollections") !== + true + ) { // is in *some* collections this.collection.add(page); } @@ -388,9 +393,13 @@ class TemplateMap { for (let pageEntry of map._pages) { // Data Schema callback #879 - if (typeof pageEntry.data[this.config.keys.dataSchema] === "function") { + let dataSchema = ResolveConfigurationData.getValue( + pageEntry.data, + this.config.keys.dataSchema, + ); + if (dataSchema !== undefined && typeof dataSchema === "function") { try { - await pageEntry.data[this.config.keys.dataSchema](pageEntry.data); + await dataSchema(pageEntry.data); } catch (e) { throw new Error( `Error in the data schema for: ${map.inputPath} (via \`eleventyDataSchema\`)`, @@ -537,7 +546,11 @@ class TemplateMap { let promises = []; for (let entry of this.map) { for (let pageEntry of entry._pages) { - if (this.config.keys.computed in pageEntry.data) { + let computedData = ResolveConfigurationData.getValue( + pageEntry.data, + this.config.keys.computed, + ); + if (computedData !== undefined) { promises.push(pageEntry.template.resolveRemainingComputedData(pageEntry.data)); } } diff --git a/src/defaultConfig.js b/src/defaultConfig.js index 21225cbd7..0db9c2cd5 100644 --- a/src/defaultConfig.js +++ b/src/defaultConfig.js @@ -34,8 +34,8 @@ import TransformsUtil from "./Util/TransformsUtil.js"; * @property {string} [keys.permalink='permalink'] * @property {string} [keys.permalinkRoot='permalinkBypassOutputDir'] * @property {string} [keys.engineOverride='templateEngineOverride'] - * @property {string} [keys.computed='eleventyComputed'] - * @property {string} [keys.dataSchema='eleventyDataSchema'] + * @property {string} [keys.computed='buildawesome.computed'] + * @property {string} [keys.dataSchema='buildawesome.dataSchema'] * @property {object} dir * @property {string} [dir.input='.'] * @property {string} [dir.includes='_includes'] @@ -92,8 +92,9 @@ export default function (config) { permalink: "permalink", permalinkRoot: "permalinkBypassOutputDir", engineOverride: "templateEngineOverride", - computed: "eleventyComputed", - dataSchema: "eleventyDataSchema", + computed: "buildawesome.computed", + dataSchema: "buildawesome.dataSchema", + import: "buildawesome.import", }, // Deprecated, define using `export const directories = {}` instead. diff --git a/test/CoreTest-ComputedData.js b/test/CoreTest-ComputedData.js new file mode 100644 index 000000000..d5354fff4 --- /dev/null +++ b/test/CoreTest-ComputedData.js @@ -0,0 +1,74 @@ +import test from "ava"; +import BuildAwesome from "../src/Core.js"; + +test("Using buildawesome.computed and eleventyComputed (prefers former)", async (t) => { + let elev = new BuildAwesome("./test/stubs-virtual/", undefined, { + config: configApi => { + // will override + configApi.addGlobalData("buildawesome.computed", () => { + return { + key1: "value1" + } + }); + + configApi.addGlobalData("eleventyComputed", () => { + return { + key2: "value2" + } + }); + + configApi.addTemplate("index.njk", "{{ key1 }}", { key1: "original" }); + } + }); + + let results = await elev.toJSON(); + t.is(results.length, 1); + t.is(results[0].content, `value1`); +}); + +test("Using buildawesome.computed and eleventyComputed (prefers former, reverse add)", async (t) => { + let elev = new BuildAwesome("./test/stubs-virtual/", undefined, { + config: configApi => { + configApi.addGlobalData("eleventyComputed", () => { + return { + key2: "value2" + } + }); + + // will override + configApi.addGlobalData("buildawesome.computed", () => { + return { + key1: "value1" + } + }); + + configApi.addTemplate("index.njk", "{{ key1 }}", { key1: "original" }); + } + }); + + let results = await elev.toJSON(); + t.is(results.length, 1); + t.is(results[0].content, `value1`); +}); + +test("Using buildawesome.computed.permalink", async (t) => { + let elev = new BuildAwesome("./test/stubs-virtual/", undefined, { + config: configApi => { + configApi.addGlobalData("permalink", () => { + return () => "/rewritten2.html" + }); + + // will override + configApi.addGlobalData("buildawesome.computed.permalink", () => { + return () => "/rewritten1.html" + }); + + configApi.addTemplate("index.njk", "{{ key1 }}", { key1: "original" }); + } + }); + + let results = await elev.toJSON(); + t.is(results.length, 1); + t.is(results[0].content, `original`); + t.is(results[0].url, `/rewritten1.html`); +}); diff --git a/test/ResolveConfigurationDataTest.js b/test/ResolveConfigurationDataTest.js new file mode 100644 index 000000000..82226109c --- /dev/null +++ b/test/ResolveConfigurationDataTest.js @@ -0,0 +1,53 @@ +import test from "ava"; + +import { ResolveConfigurationData } from "../src/Data/ResolveConfigurationData.js"; + +test("Alternate location", (t) => { + t.is(ResolveConfigurationData.getAlternatePropertyName("permalink"), undefined); + t.is(ResolveConfigurationData.getAlternatePropertyName("eleventyComputed"), undefined); + t.is(ResolveConfigurationData.getAlternatePropertyName("buildawesome.computed"), "eleventyComputed"); + t.is(ResolveConfigurationData.getAlternatePropertyName("buildawesome.dataSchema"), "eleventyDataSchema"); + t.is(ResolveConfigurationData.getAlternatePropertyName("buildawesome.excludeFromCollections"), "eleventyExcludeFromCollections"); +}); + +test("Permalink (empty data)", (t) => { + let data = {}; + t.is(ResolveConfigurationData.getValue(data, "permalink"), undefined); +}); + +test("Permalink", (t) => { + let data = { permalink: "test" }; + t.is(ResolveConfigurationData.getValue(data, "permalink"), "test"); +}); + +test("Computed Data", (t) => { + let data = { eleventyComputed: { key: "value" } }; + t.deepEqual(ResolveConfigurationData.getValue(data, "eleventyComputed"), { key: "value" }); +}); + +test("Computed Data, alternate location", (t) => { + let data = { eleventyComputed: { key: "value1" } }; + t.deepEqual(ResolveConfigurationData.getValue(data, "buildawesome.computed"), { key: "value1" }); +}); + +test("Both locations exist, prefer primary", (t) => { + let data = { + eleventyComputed: { key1: "value1" }, + buildawesome: { + computed: { key2: "value2" }, + }, + }; + + t.deepEqual(ResolveConfigurationData.getValue(data, "buildawesome.computed"), { key2: "value2" }); +}); + +test("Both locations exist, no alternate", (t) => { + let data = { + eleventyComputed: { key1: "value1" }, + buildawesome: { + computed: { key2: "value2" }, + }, + }; + + t.deepEqual(ResolveConfigurationData.getValue(data, "eleventyComputed"), { key1: "value1" }); +}); From 3d8abff805f244abe69b88dc45e88320114c271b Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 9 Jun 2026 17:06:10 -0500 Subject: [PATCH 18/53] Breaking: changes directory dtaq file suffix from `11tydata.*` to `data.*` --- src/Data/TemplateData.js | 71 +++-- src/defaultConfig.js | 4 +- test/CoreTest.js | 4 +- test/FilesTest.js | 2 +- test/TemplateDataTest.js | 265 ++++++++---------- test/TemplateTest.js | 177 +++++------- test/UserDataExtensionsTest.js | 60 ++-- ...emplate.11tydata.txt => template.data.txt} | 0 ...ponent.11tydata.cjs => component.data.cjs} | 0 ...nent.11tydata.json => component.data.json} | 0 ...nent.11tydata.nosj => component.data.nosj} | 0 ...nent.11tydata.yaml => component.data.yaml} | 0 .../{test.11tydata.cjs => test.data.cjs} | 0 .../dir/{dir.11tydata.cjs => dir.data.cjs} | 0 .../{test.11tydata.cjs => test.data.cjs} | 0 .../src/{src.11tydata.cjs => src.data.cjs} | 0 .../{test.11tydata.cjs => test.data.cjs} | 0 ...ponent.11tydata.cjs => component.data.cjs} | 0 ...omponent.11tydata.js => component.data.js} | 0 ...ponent.11tydata.cjs => component.data.cjs} | 0 ...omponent.11tydata.js => component.data.js} | 0 ...nent.11tydata.json => component.data.json} | 0 ...emplate.11tydata.cjs => template.data.cjs} | 0 ...ponent.11tydata.cjs => component.data.cjs} | 0 24 files changed, 260 insertions(+), 323 deletions(-) rename test/stubs-1691/{template.11tydata.txt => template.data.txt} (100%) rename test/stubs-630/component-yaml/{component.11tydata.cjs => component.data.cjs} (100%) rename test/stubs-630/component-yaml/{component.11tydata.json => component.data.json} (100%) rename test/stubs-630/component-yaml/{component.11tydata.nosj => component.data.nosj} (100%) rename test/stubs-630/component-yaml/{component.11tydata.yaml => component.data.yaml} (100%) rename test/stubs-919/{test.11tydata.cjs => test.data.cjs} (100%) rename test/stubs-computed-dirdata/dir/{dir.11tydata.cjs => dir.data.cjs} (100%) rename test/stubs-data-cascade/layout-data-files/{test.11tydata.cjs => test.data.cjs} (100%) rename test/stubs-data-cascade/layout-versus-dirdatafile/src/{src.11tydata.cjs => src.data.cjs} (100%) rename test/stubs-data-cascade/layout-versus-tmpldatafile/{test.11tydata.cjs => test.data.cjs} (100%) rename test/stubs/component-async/{component.11tydata.cjs => component.data.cjs} (100%) rename test/stubs/component-async/{component.11tydata.js => component.data.js} (100%) rename test/stubs/component/{component.11tydata.cjs => component.data.cjs} (100%) rename test/stubs/component/{component.11tydata.js => component.data.js} (100%) rename test/stubs/component/{component.11tydata.json => component.data.json} (100%) rename test/stubs/data-cascade/{template.11tydata.cjs => template.data.cjs} (100%) rename test/stubs/local-data-tags/{component.11tydata.cjs => component.data.cjs} (100%) diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index f3494ad7c..291fc2312 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -204,63 +204,56 @@ class TemplateData { // Backwards compatibility if (this.config.jsDataFileSuffix) { let suffixes = []; - suffixes.push(this.config.jsDataFileSuffix); // e.g. filename.11tydata.json + suffixes.push(this.config.jsDataFileSuffix); // e.g. filename.data.json suffixes.push(""); // suffix-less for free with old API, e.g. filename.json return suffixes; } + return []; // if both of these entries are set to false, use no files } // This is used exclusively for --watch and --serve chokidar targets async getTemplateDataFileGlob() { let suffixes = this.getDataFileSuffixes(); - let globSuffixesWithLeadingDot = new Set(); - globSuffixesWithLeadingDot.add("json"); // covers .11tydata.json too - let globSuffixesWithoutLeadingDot = new Set(); + let globSuffixes = new Set(); + globSuffixes.add("json"); // covers .data.json too - // Typically using [ '.11tydata', '' ] suffixes to find data files + // Typically using [ '.data', '' ] suffixes to find data files for (let suffix of suffixes) { - // TODO the `suffix` truthiness check is purely for backwards compat? - if (suffix && typeof suffix === "string") { - if (suffix.startsWith(".")) { - // .suffix.js - globSuffixesWithLeadingDot.add(`${suffix.slice(1)}.mjs`); - globSuffixesWithLeadingDot.add(`${suffix.slice(1)}.cjs`); - globSuffixesWithLeadingDot.add(`${suffix.slice(1)}.js`); - - if (isTypeScriptSupported()) { - globSuffixesWithLeadingDot.add(`${suffix.slice(1)}.mts`); - globSuffixesWithLeadingDot.add(`${suffix.slice(1)}.cts`); - globSuffixesWithLeadingDot.add(`${suffix.slice(1)}.ts`); - } - } else { - // "suffix.js" without leading dot - globSuffixesWithoutLeadingDot.add(`${suffix || ""}.mjs`); - globSuffixesWithoutLeadingDot.add(`${suffix || ""}.cjs`); - globSuffixesWithoutLeadingDot.add(`${suffix || ""}.js`); - - if (isTypeScriptSupported()) { - globSuffixesWithoutLeadingDot.add(`${suffix || ""}.mts`); - globSuffixesWithoutLeadingDot.add(`${suffix || ""}.cts`); - globSuffixesWithoutLeadingDot.add(`${suffix || ""}.ts`); - } - } + if (!suffix || typeof suffix !== "string") { + continue; + } + + // .suffix.js + if (suffix.startsWith(".")) { + suffix = suffix.slice(1); + } + + globSuffixes.add(`${suffix || ""}.mjs`); + globSuffixes.add(`${suffix || ""}.cjs`); + globSuffixes.add(`${suffix || ""}.js`); + + if (isTypeScriptSupported()) { + globSuffixes.add(`${suffix || ""}.mts`); + globSuffixes.add(`${suffix || ""}.cts`); + globSuffixes.add(`${suffix || ""}.ts`); } } // Configuration Data Extensions e.g. yaml if (this.hasUserDataExtensions()) { for (let extension of this.getUserDataExtensions()) { - globSuffixesWithLeadingDot.add(extension); // covers .11tydata.{extension} too + if (extension.startsWith(".")) { + extension = extension.slice(1); + } + + globSuffixes.add(extension); // covers .data.{extension} too } } let paths = []; - if (globSuffixesWithLeadingDot.size > 0) { - paths.push(`${this.inputDir}**/*.{${Array.from(globSuffixesWithLeadingDot).join(",")}}`); - } - if (globSuffixesWithoutLeadingDot.size > 0) { - paths.push(`${this.inputDir}**/*{${Array.from(globSuffixesWithoutLeadingDot).join(",")}}`); + if (globSuffixes.size > 0) { + paths.push(`${this.inputDir}**/*.{${Array.from(globSuffixes).join(",")}}`); } return TemplatePath.addLeadingDotSlashArray(paths); @@ -682,7 +675,7 @@ class TemplateData { paths.push(base + suffix + "." + extension); } } - paths.push(base + suffix + ".json"); // default: .11tydata.json + paths.push(base + suffix + ".json"); // default: .data.json // inject user extensions this._pushExtensionsToPaths(paths, base + suffix, extensions); @@ -699,7 +692,7 @@ class TemplateData { if (parsed.dir) { let fileNameNoExt = this.extensionMap.removeTemplateExtension(parsed.base); - // default dataSuffix: .11tydata, is appended in _addBaseToPaths + // default dataSuffix: .data, is appended in _addBaseToPaths debug("Using %o suffixes to find data files.", this.getDataFileSuffixes()); // Template data file paths @@ -731,7 +724,7 @@ class TemplateData { TemplatePath.join(inputDir, TemplatePath.getLastPathSegment(inputDir)), ); - // in root input dir, search for index.11tydata.json et al + // in root input dir, search for index.data.json et al if (this.config.dataFileDirBaseNameOverride) { let indexDataFile = TemplatePath.getDirFromFilePath(lastInputDir) + diff --git a/src/defaultConfig.js b/src/defaultConfig.js index 0db9c2cd5..531cab5b7 100644 --- a/src/defaultConfig.js +++ b/src/defaultConfig.js @@ -27,7 +27,6 @@ import TransformsUtil from "./Util/TransformsUtil.js"; * @property {string} [markdownTemplateEngine='liquid'] - Template engine to process markdown files with. * @property {string} [htmlTemplateEngine='liquid'] - Template engine to process html files with. * @property {boolean} [dataTemplateEngine=false] - Changed in v1.0 - * @property {string} [jsDataFileSuffix='.11tydata'] - File suffix for jsData files. * @property {object} keys * @property {string} [keys.package='pkg'] - Global data property for package.json data * @property {string} [keys.layout='layout'] @@ -73,6 +72,7 @@ export default function (config) { return { templateFormats: ["liquid", "md", "njk", "html", "11ty.js"], + // to add a parent directory structure to URLs (not reflected on the file system), change this pathPrefix: "/", markdownTemplateEngine: "liquid", @@ -80,7 +80,7 @@ export default function (config) { // Renamed from `jsDataFileSuffix` in 2.0 (and swapped to an Array) // If you remove "" we won’t look for dir/dir.json or file.json - dataFileSuffixes: [".11tydata", ""], + dataFileSuffixes: [".data", ""], // "index" will look for `directory/index.*` directory data files instead of `directory/directory.*` dataFileDirBaseNameOverride: false, diff --git a/test/CoreTest.js b/test/CoreTest.js index 55251727e..5c8fc95b4 100644 --- a/test/CoreTest.js +++ b/test/CoreTest.js @@ -143,7 +143,7 @@ test("Eleventy file watching", async (t) => { "./.gitignore", "./.eleventyignore", "./test/stubs/.eleventyignore", - `./test/stubs/**/*.{json,11tydata.mjs,11tydata.cjs,11tydata.js${isTypeScriptSupported() ? ",11tydata.mts,11tydata.cts,11tydata.ts" : ""}}`, + "./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts}", "./test/stubs/deps/dep1.cjs", "./test/stubs/deps/dep2.cjs", ]); @@ -194,7 +194,7 @@ test("Eleventy file watching (no JS dependencies)", async (t) => { "./.gitignore", "./.eleventyignore", "./test/stubs/.eleventyignore", - `./test/stubs/**/*.{json,11tydata.mjs,11tydata.cjs,11tydata.js${isTypeScriptSupported() ? ",11tydata.mts,11tydata.cts,11tydata.ts" : ""}}`, + `./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts}`, ]); t.true(ignores.includes("node_modules/**")); diff --git a/test/FilesTest.js b/test/FilesTest.js index 52099ed75..1e8aeeb8d 100644 --- a/test/FilesTest.js +++ b/test/FilesTest.js @@ -452,7 +452,7 @@ test("Glob Watcher Files with Config Passthroughs (no template formats)", async evf.init(); t.deepEqual(await evf.getGlobWatcherTemplateDataFiles(), [ - `./test/stubs/**/*.{json,11tydata.mjs,11tydata.cjs,11tydata.js${isTypeScriptSupported() ? ",11tydata.mts,11tydata.cts,11tydata.ts" : ""}}`, + `./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts}`, ]); }); diff --git a/test/TemplateDataTest.js b/test/TemplateDataTest.js index b9ad090ad..74b30de29 100644 --- a/test/TemplateDataTest.js +++ b/test/TemplateDataTest.js @@ -379,26 +379,22 @@ test("getLocalDataPaths", async (t) => { t.deepEqual(paths, [ "./test/stubs/stubs.json", - "./test/stubs/stubs.11tydata.json", - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/stubs.11tydata.mts", - "./test/stubs/stubs.11tydata.cts", - "./test/stubs/stubs.11tydata.ts", - ] : []), + "./test/stubs/stubs.data.json", + "./test/stubs/stubs.data.mjs", + "./test/stubs/stubs.data.cjs", + "./test/stubs/stubs.data.js", + "./test/stubs/stubs.data.mts", + "./test/stubs/stubs.data.cts", + "./test/stubs/stubs.data.ts", "./test/stubs/component/component.json", - "./test/stubs/component/component.11tydata.json", - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/component.11tydata.mts", - "./test/stubs/component/component.11tydata.cts", - "./test/stubs/component/component.11tydata.ts", - ] : []), + "./test/stubs/component/component.data.json", + "./test/stubs/component/component.data.mjs", + "./test/stubs/component/component.data.cjs", + "./test/stubs/component/component.data.js", + "./test/stubs/component/component.data.mts", + "./test/stubs/component/component.data.cts", + "./test/stubs/component/component.data.ts", ]); }); @@ -415,36 +411,30 @@ test("getLocalDataPaths (with setDataFileBaseName #1699)", async (t) => { let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); t.deepEqual(paths, [ - "./test/stubs/index.11tydata.json", - "./test/stubs/index.11tydata.mjs", - "./test/stubs/index.11tydata.cjs", - "./test/stubs/index.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/index.11tydata.mts", - "./test/stubs/index.11tydata.cts", - "./test/stubs/index.11tydata.ts", - ] : []), - - "./test/stubs/component/index.11tydata.json", - "./test/stubs/component/index.11tydata.mjs", - "./test/stubs/component/index.11tydata.cjs", - "./test/stubs/component/index.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/index.11tydata.mts", - "./test/stubs/component/index.11tydata.cts", - "./test/stubs/component/index.11tydata.ts", - ] : []), + "./test/stubs/index.data.json", + "./test/stubs/index.data.mjs", + "./test/stubs/index.data.cjs", + "./test/stubs/index.data.js", + "./test/stubs/index.data.mts", + "./test/stubs/index.data.cts", + "./test/stubs/index.data.ts", + + "./test/stubs/component/index.data.json", + "./test/stubs/component/index.data.mjs", + "./test/stubs/component/index.data.cjs", + "./test/stubs/component/index.data.js", + "./test/stubs/component/index.data.mts", + "./test/stubs/component/index.data.cts", + "./test/stubs/component/index.data.ts", "./test/stubs/component/component.json", - "./test/stubs/component/component.11tydata.json", - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/component.11tydata.mts", - "./test/stubs/component/component.11tydata.cts", - "./test/stubs/component/component.11tydata.ts", - ] : []), + "./test/stubs/component/component.data.json", + "./test/stubs/component/component.data.mjs", + "./test/stubs/component/component.data.cjs", + "./test/stubs/component/component.data.js", + "./test/stubs/component/component.data.mts", + "./test/stubs/component/component.data.cts", + "./test/stubs/component/component.data.ts", ]); }); @@ -611,36 +601,31 @@ test("Deeper getLocalDataPaths", async (t) => { t.deepEqual(paths, [ "./test/test.json", - "./test/test.11tydata.json", - "./test/test.11tydata.mjs", - "./test/test.11tydata.cjs", - "./test/test.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/test.11tydata.mts", - "./test/test.11tydata.cts", - "./test/test.11tydata.ts", - ] : []), + "./test/test.data.json", + "./test/test.data.mjs", + "./test/test.data.cjs", + "./test/test.data.js", + "./test/test.data.mts", + "./test/test.data.cts", + "./test/test.data.ts", "./test/stubs/stubs.json", - "./test/stubs/stubs.11tydata.json", - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/stubs.11tydata.mts", - "./test/stubs/stubs.11tydata.cts", - "./test/stubs/stubs.11tydata.ts", - ] : []), + "./test/stubs/stubs.data.json", + "./test/stubs/stubs.data.mjs", + "./test/stubs/stubs.data.cjs", + "./test/stubs/stubs.data.js", + "./test/stubs/stubs.data.mts", + "./test/stubs/stubs.data.cts", + "./test/stubs/stubs.data.ts", + "./test/stubs/component/component.json", - "./test/stubs/component/component.11tydata.json", - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/component.11tydata.mts", - "./test/stubs/component/component.11tydata.cts", - "./test/stubs/component/component.11tydata.ts", - ] : []), + "./test/stubs/component/component.data.json", + "./test/stubs/component/component.data.mjs", + "./test/stubs/component/component.data.cjs", + "./test/stubs/component/component.data.js", + "./test/stubs/component/component.data.mts", + "./test/stubs/component/component.data.cts", + "./test/stubs/component/component.data.ts", ]); }); @@ -658,25 +643,22 @@ test("getLocalDataPaths with an 11ty js template", async (t) => { t.deepEqual(paths, [ "./test/stubs/stubs.json", - "./test/stubs/stubs.11tydata.json", - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/stubs.11tydata.mts", - "./test/stubs/stubs.11tydata.cts", - "./test/stubs/stubs.11tydata.ts", - ] : []), + "./test/stubs/stubs.data.json", + "./test/stubs/stubs.data.mjs", + "./test/stubs/stubs.data.cjs", + "./test/stubs/stubs.data.js", + "./test/stubs/stubs.data.mts", + "./test/stubs/stubs.data.cts", + "./test/stubs/stubs.data.ts", + "./test/stubs/component/component.json", - "./test/stubs/component/component.11tydata.json", - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/component.11tydata.mts", - "./test/stubs/component/component.11tydata.cts", - "./test/stubs/component/component.11tydata.ts", - ] : []), + "./test/stubs/component/component.data.json", + "./test/stubs/component/component.data.mjs", + "./test/stubs/component/component.data.cjs", + "./test/stubs/component/component.data.js", + "./test/stubs/component/component.data.mts", + "./test/stubs/component/component.data.cts", + "./test/stubs/component/component.data.ts", ]); }); @@ -694,25 +676,22 @@ test("getLocalDataPaths with inputDir passed in (trailing slash)", async (t) => t.deepEqual(paths, [ "./test/stubs/stubs.json", - "./test/stubs/stubs.11tydata.json", - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/stubs.11tydata.mts", - "./test/stubs/stubs.11tydata.cts", - "./test/stubs/stubs.11tydata.ts", - ] : []), + "./test/stubs/stubs.data.json", + "./test/stubs/stubs.data.mjs", + "./test/stubs/stubs.data.cjs", + "./test/stubs/stubs.data.js", + "./test/stubs/stubs.data.mts", + "./test/stubs/stubs.data.cts", + "./test/stubs/stubs.data.ts", + "./test/stubs/component/component.json", - "./test/stubs/component/component.11tydata.json", - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/component.11tydata.mts", - "./test/stubs/component/component.11tydata.cts", - "./test/stubs/component/component.11tydata.ts", - ] : []), + "./test/stubs/component/component.data.json", + "./test/stubs/component/component.data.mjs", + "./test/stubs/component/component.data.cjs", + "./test/stubs/component/component.data.js", + "./test/stubs/component/component.data.mts", + "./test/stubs/component/component.data.cts", + "./test/stubs/component/component.data.ts", ]); }); @@ -730,25 +709,22 @@ test("getLocalDataPaths with inputDir passed in (no trailing slash)", async (t) t.deepEqual(paths, [ "./test/stubs/stubs.json", - "./test/stubs/stubs.11tydata.json", - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/stubs.11tydata.mts", - "./test/stubs/stubs.11tydata.cts", - "./test/stubs/stubs.11tydata.ts", - ] : []), + "./test/stubs/stubs.data.json", + "./test/stubs/stubs.data.mjs", + "./test/stubs/stubs.data.cjs", + "./test/stubs/stubs.data.js", + "./test/stubs/stubs.data.mts", + "./test/stubs/stubs.data.cts", + "./test/stubs/stubs.data.ts", + "./test/stubs/component/component.json", - "./test/stubs/component/component.11tydata.json", - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/component.11tydata.mts", - "./test/stubs/component/component.11tydata.cts", - "./test/stubs/component/component.11tydata.ts", - ] : []), + "./test/stubs/component/component.data.json", + "./test/stubs/component/component.data.mjs", + "./test/stubs/component/component.data.cjs", + "./test/stubs/component/component.data.js", + "./test/stubs/component/component.data.mts", + "./test/stubs/component/component.data.cts", + "./test/stubs/component/component.data.ts", ]); }); @@ -766,25 +742,22 @@ test("getLocalDataPaths with inputDir passed in (no leading slash)", async (t) = t.deepEqual(paths, [ "./test/stubs/stubs.json", - "./test/stubs/stubs.11tydata.json", - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/stubs.11tydata.mts", - "./test/stubs/stubs.11tydata.cts", - "./test/stubs/stubs.11tydata.ts", - ] : []), + "./test/stubs/stubs.data.json", + "./test/stubs/stubs.data.mjs", + "./test/stubs/stubs.data.cjs", + "./test/stubs/stubs.data.js", + "./test/stubs/stubs.data.mts", + "./test/stubs/stubs.data.cts", + "./test/stubs/stubs.data.ts", + "./test/stubs/component/component.json", - "./test/stubs/component/component.11tydata.json", - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/component.11tydata.mts", - "./test/stubs/component/component.11tydata.cts", - "./test/stubs/component/component.11tydata.ts", - ] : []), + "./test/stubs/component/component.data.json", + "./test/stubs/component/component.data.mjs", + "./test/stubs/component/component.data.cjs", + "./test/stubs/component/component.data.js", + "./test/stubs/component/component.data.mts", + "./test/stubs/component/component.data.cts", + "./test/stubs/component/component.data.ts", ]); }); @@ -812,7 +785,7 @@ test("getTemplateDataFileGlob", async (t) => { let tw = new TemplateData(eleventyConfig); t.deepEqual(await tw.getTemplateDataFileGlob(), [ - `./test/stubs/**/*.{json,11tydata.mjs,11tydata.cjs,11tydata.js${isTypeScriptSupported() ? ",11tydata.mts,11tydata.cts,11tydata.ts" : ""}}`, + `./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts}`, ]); }); diff --git a/test/TemplateTest.js b/test/TemplateTest.js index eb0222d60..af45a4b12 100644 --- a/test/TemplateTest.js +++ b/test/TemplateTest.js @@ -473,26 +473,22 @@ test("Local template data file import (without a global data json)", async (t) = let data = await tmpl.getData(); t.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [ "./test/stubs/stubs.json", - "./test/stubs/stubs.11tydata.json", - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/stubs.11tydata.mts", - "./test/stubs/stubs.11tydata.cts", - "./test/stubs/stubs.11tydata.ts", - ] : []), + "./test/stubs/stubs.data.json", + "./test/stubs/stubs.data.mjs", + "./test/stubs/stubs.data.cjs", + "./test/stubs/stubs.data.js", + "./test/stubs/stubs.data.mts", + "./test/stubs/stubs.data.cts", + "./test/stubs/stubs.data.ts", "./test/stubs/component/component.json", - "./test/stubs/component/component.11tydata.json", - "./test/stubs/component/component.11tydata.mjs", - "./test/stubs/component/component.11tydata.cjs", - "./test/stubs/component/component.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/component.11tydata.mts", - "./test/stubs/component/component.11tydata.cts", - "./test/stubs/component/component.11tydata.ts", - ] : []), + "./test/stubs/component/component.data.json", + "./test/stubs/component/component.data.mjs", + "./test/stubs/component/component.data.cjs", + "./test/stubs/component/component.data.js", + "./test/stubs/component/component.data.mts", + "./test/stubs/component/component.data.cts", + "./test/stubs/component/component.data.ts", ]); t.is(data.localdatakey1, "localdatavalue1"); t.is(await renderTemplate(tmpl, data), "localdatavalue1"); @@ -521,49 +517,40 @@ test("Local template data file import (two subdirectories deep)", async (t) => { t.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [ "./test/stubs/stubs.json", - "./test/stubs/stubs.11tydata.json", - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/stubs.11tydata.mts", - "./test/stubs/stubs.11tydata.cts", - "./test/stubs/stubs.11tydata.ts", - ] : []), + "./test/stubs/stubs.data.json", + "./test/stubs/stubs.data.mjs", + "./test/stubs/stubs.data.cjs", + "./test/stubs/stubs.data.js", + "./test/stubs/stubs.data.mts", + "./test/stubs/stubs.data.cts", + "./test/stubs/stubs.data.ts", "./test/stubs/firstdir/firstdir.json", - "./test/stubs/firstdir/firstdir.11tydata.json", - "./test/stubs/firstdir/firstdir.11tydata.mjs", - "./test/stubs/firstdir/firstdir.11tydata.cjs", - "./test/stubs/firstdir/firstdir.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/firstdir/firstdir.11tydata.mts", - "./test/stubs/firstdir/firstdir.11tydata.cts", - "./test/stubs/firstdir/firstdir.11tydata.ts", - ] : []), + "./test/stubs/firstdir/firstdir.data.json", + "./test/stubs/firstdir/firstdir.data.mjs", + "./test/stubs/firstdir/firstdir.data.cjs", + "./test/stubs/firstdir/firstdir.data.js", + "./test/stubs/firstdir/firstdir.data.mts", + "./test/stubs/firstdir/firstdir.data.cts", + "./test/stubs/firstdir/firstdir.data.ts", "./test/stubs/firstdir/seconddir/seconddir.json", - "./test/stubs/firstdir/seconddir/seconddir.11tydata.json", - "./test/stubs/firstdir/seconddir/seconddir.11tydata.mjs", - "./test/stubs/firstdir/seconddir/seconddir.11tydata.cjs", - "./test/stubs/firstdir/seconddir/seconddir.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/firstdir/seconddir/seconddir.11tydata.mts", - "./test/stubs/firstdir/seconddir/seconddir.11tydata.cts", - "./test/stubs/firstdir/seconddir/seconddir.11tydata.ts", - ] : []), + "./test/stubs/firstdir/seconddir/seconddir.data.json", + "./test/stubs/firstdir/seconddir/seconddir.data.mjs", + "./test/stubs/firstdir/seconddir/seconddir.data.cjs", + "./test/stubs/firstdir/seconddir/seconddir.data.js", + "./test/stubs/firstdir/seconddir/seconddir.data.mts", + "./test/stubs/firstdir/seconddir/seconddir.data.cts", + "./test/stubs/firstdir/seconddir/seconddir.data.ts", "./test/stubs/firstdir/seconddir/component.json", - "./test/stubs/firstdir/seconddir/component.11tydata.json", - "./test/stubs/firstdir/seconddir/component.11tydata.mjs", - "./test/stubs/firstdir/seconddir/component.11tydata.cjs", - "./test/stubs/firstdir/seconddir/component.11tydata.js", - - ...(isTypeScriptSupported() ? [ - "./test/stubs/firstdir/seconddir/component.11tydata.mts", - "./test/stubs/firstdir/seconddir/component.11tydata.cts", - "./test/stubs/firstdir/seconddir/component.11tydata.ts", - ] : []), + "./test/stubs/firstdir/seconddir/component.data.json", + "./test/stubs/firstdir/seconddir/component.data.mjs", + "./test/stubs/firstdir/seconddir/component.data.cjs", + "./test/stubs/firstdir/seconddir/component.data.js", + "./test/stubs/firstdir/seconddir/component.data.mts", + "./test/stubs/firstdir/seconddir/component.data.cts", + "./test/stubs/firstdir/seconddir/component.data.ts", ]); }); @@ -591,37 +578,31 @@ test("Posts inherits local JSON, layouts", async (t) => { let localDataPaths = await dataObj.getLocalDataPaths(tmpl.getInputPath()); t.deepEqual(localDataPaths, [ "./test/stubs/stubs.json", - "./test/stubs/stubs.11tydata.json", - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/stubs.11tydata.mts", - "./test/stubs/stubs.11tydata.cts", - "./test/stubs/stubs.11tydata.ts", - ] : []), + "./test/stubs/stubs.data.json", + "./test/stubs/stubs.data.mjs", + "./test/stubs/stubs.data.cjs", + "./test/stubs/stubs.data.js", + "./test/stubs/stubs.data.mts", + "./test/stubs/stubs.data.cts", + "./test/stubs/stubs.data.ts", "./test/stubs/posts/posts.json", - "./test/stubs/posts/posts.11tydata.json", - "./test/stubs/posts/posts.11tydata.mjs", - "./test/stubs/posts/posts.11tydata.cjs", - "./test/stubs/posts/posts.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/posts/posts.11tydata.mts", - "./test/stubs/posts/posts.11tydata.cts", - "./test/stubs/posts/posts.11tydata.ts", - ] : []), + "./test/stubs/posts/posts.data.json", + "./test/stubs/posts/posts.data.mjs", + "./test/stubs/posts/posts.data.cjs", + "./test/stubs/posts/posts.data.js", + "./test/stubs/posts/posts.data.mts", + "./test/stubs/posts/posts.data.cts", + "./test/stubs/posts/posts.data.ts", "./test/stubs/posts/post1.json", - "./test/stubs/posts/post1.11tydata.json", - "./test/stubs/posts/post1.11tydata.mjs", - "./test/stubs/posts/post1.11tydata.cjs", - "./test/stubs/posts/post1.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/posts/post1.11tydata.mts", - "./test/stubs/posts/post1.11tydata.cts", - "./test/stubs/posts/post1.11tydata.ts", - ] : []), + "./test/stubs/posts/post1.data.json", + "./test/stubs/posts/post1.data.mjs", + "./test/stubs/posts/post1.data.cjs", + "./test/stubs/posts/post1.data.js", + "./test/stubs/posts/post1.data.mts", + "./test/stubs/posts/post1.data.cts", + "./test/stubs/posts/post1.data.ts", ]); let localData = await dataObj.getTemplateDirectoryData(tmpl.getInputPath()); @@ -664,26 +645,22 @@ test("Template and folder name are the same, make sure data imports work ok", as let localDataPaths = await dataObj.getLocalDataPaths(tmpl.getInputPath()); t.deepEqual(localDataPaths, [ "./test/stubs/stubs.json", - "./test/stubs/stubs.11tydata.json", - "./test/stubs/stubs.11tydata.mjs", - "./test/stubs/stubs.11tydata.cjs", - "./test/stubs/stubs.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/stubs.11tydata.mts", - "./test/stubs/stubs.11tydata.cts", - "./test/stubs/stubs.11tydata.ts", - ] : []), + "./test/stubs/stubs.data.json", + "./test/stubs/stubs.data.mjs", + "./test/stubs/stubs.data.cjs", + "./test/stubs/stubs.data.js", + "./test/stubs/stubs.data.mts", + "./test/stubs/stubs.data.cts", + "./test/stubs/stubs.data.ts", "./test/stubs/posts/posts.json", - "./test/stubs/posts/posts.11tydata.json", - "./test/stubs/posts/posts.11tydata.mjs", - "./test/stubs/posts/posts.11tydata.cjs", - "./test/stubs/posts/posts.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/posts/posts.11tydata.mts", - "./test/stubs/posts/posts.11tydata.cts", - "./test/stubs/posts/posts.11tydata.ts", - ] : []), + "./test/stubs/posts/posts.data.json", + "./test/stubs/posts/posts.data.mjs", + "./test/stubs/posts/posts.data.cjs", + "./test/stubs/posts/posts.data.js", + "./test/stubs/posts/posts.data.mts", + "./test/stubs/posts/posts.data.cts", + "./test/stubs/posts/posts.data.ts", ]); let localData = await dataObj.getTemplateDirectoryData(tmpl.getInputPath()); diff --git a/test/UserDataExtensionsTest.js b/test/UserDataExtensionsTest.js index d3571f196..26f6af68c 100644 --- a/test/UserDataExtensionsTest.js +++ b/test/UserDataExtensionsTest.js @@ -68,47 +68,41 @@ test("Local files", async (t) => { "./test/stubs-630/stubs-630.yaml", "./test/stubs-630/stubs-630.nosj", "./test/stubs-630/stubs-630.json", - "./test/stubs-630/stubs-630.11tydata.yaml", - "./test/stubs-630/stubs-630.11tydata.nosj", - "./test/stubs-630/stubs-630.11tydata.json", - "./test/stubs-630/stubs-630.11tydata.mjs", - "./test/stubs-630/stubs-630.11tydata.cjs", - "./test/stubs-630/stubs-630.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs-630/stubs-630.11tydata.mts", - "./test/stubs-630/stubs-630.11tydata.cts", - "./test/stubs-630/stubs-630.11tydata.ts", - ] : []), + "./test/stubs-630/stubs-630.data.yaml", + "./test/stubs-630/stubs-630.data.nosj", + "./test/stubs-630/stubs-630.data.json", + "./test/stubs-630/stubs-630.data.mjs", + "./test/stubs-630/stubs-630.data.cjs", + "./test/stubs-630/stubs-630.data.js", + "./test/stubs-630/stubs-630.data.mts", + "./test/stubs-630/stubs-630.data.cts", + "./test/stubs-630/stubs-630.data.ts", "./test/stubs-630/component-yaml/component-yaml.yaml", "./test/stubs-630/component-yaml/component-yaml.nosj", "./test/stubs-630/component-yaml/component-yaml.json", - "./test/stubs-630/component-yaml/component-yaml.11tydata.yaml", - "./test/stubs-630/component-yaml/component-yaml.11tydata.nosj", - "./test/stubs-630/component-yaml/component-yaml.11tydata.json", - "./test/stubs-630/component-yaml/component-yaml.11tydata.mjs", - "./test/stubs-630/component-yaml/component-yaml.11tydata.cjs", - "./test/stubs-630/component-yaml/component-yaml.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs-630/component-yaml/component-yaml.11tydata.mts", - "./test/stubs-630/component-yaml/component-yaml.11tydata.cts", - "./test/stubs-630/component-yaml/component-yaml.11tydata.ts", - ] : []), + "./test/stubs-630/component-yaml/component-yaml.data.yaml", + "./test/stubs-630/component-yaml/component-yaml.data.nosj", + "./test/stubs-630/component-yaml/component-yaml.data.json", + "./test/stubs-630/component-yaml/component-yaml.data.mjs", + "./test/stubs-630/component-yaml/component-yaml.data.cjs", + "./test/stubs-630/component-yaml/component-yaml.data.js", + "./test/stubs-630/component-yaml/component-yaml.data.mts", + "./test/stubs-630/component-yaml/component-yaml.data.cts", + "./test/stubs-630/component-yaml/component-yaml.data.ts", "./test/stubs-630/component-yaml/component.yaml", "./test/stubs-630/component-yaml/component.nosj", "./test/stubs-630/component-yaml/component.json", - "./test/stubs-630/component-yaml/component.11tydata.yaml", - "./test/stubs-630/component-yaml/component.11tydata.nosj", - "./test/stubs-630/component-yaml/component.11tydata.json", - "./test/stubs-630/component-yaml/component.11tydata.mjs", - "./test/stubs-630/component-yaml/component.11tydata.cjs", - "./test/stubs-630/component-yaml/component.11tydata.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs-630/component-yaml/component.11tydata.mts", - "./test/stubs-630/component-yaml/component.11tydata.cts", - "./test/stubs-630/component-yaml/component.11tydata.ts", - ] : []), + "./test/stubs-630/component-yaml/component.data.yaml", + "./test/stubs-630/component-yaml/component.data.nosj", + "./test/stubs-630/component-yaml/component.data.json", + "./test/stubs-630/component-yaml/component.data.mjs", + "./test/stubs-630/component-yaml/component.data.cjs", + "./test/stubs-630/component-yaml/component.data.js", + "./test/stubs-630/component-yaml/component.data.mts", + "./test/stubs-630/component-yaml/component.data.cts", + "./test/stubs-630/component-yaml/component.data.ts", ]); }); diff --git a/test/stubs-1691/template.11tydata.txt b/test/stubs-1691/template.data.txt similarity index 100% rename from test/stubs-1691/template.11tydata.txt rename to test/stubs-1691/template.data.txt diff --git a/test/stubs-630/component-yaml/component.11tydata.cjs b/test/stubs-630/component-yaml/component.data.cjs similarity index 100% rename from test/stubs-630/component-yaml/component.11tydata.cjs rename to test/stubs-630/component-yaml/component.data.cjs diff --git a/test/stubs-630/component-yaml/component.11tydata.json b/test/stubs-630/component-yaml/component.data.json similarity index 100% rename from test/stubs-630/component-yaml/component.11tydata.json rename to test/stubs-630/component-yaml/component.data.json diff --git a/test/stubs-630/component-yaml/component.11tydata.nosj b/test/stubs-630/component-yaml/component.data.nosj similarity index 100% rename from test/stubs-630/component-yaml/component.11tydata.nosj rename to test/stubs-630/component-yaml/component.data.nosj diff --git a/test/stubs-630/component-yaml/component.11tydata.yaml b/test/stubs-630/component-yaml/component.data.yaml similarity index 100% rename from test/stubs-630/component-yaml/component.11tydata.yaml rename to test/stubs-630/component-yaml/component.data.yaml diff --git a/test/stubs-919/test.11tydata.cjs b/test/stubs-919/test.data.cjs similarity index 100% rename from test/stubs-919/test.11tydata.cjs rename to test/stubs-919/test.data.cjs diff --git a/test/stubs-computed-dirdata/dir/dir.11tydata.cjs b/test/stubs-computed-dirdata/dir/dir.data.cjs similarity index 100% rename from test/stubs-computed-dirdata/dir/dir.11tydata.cjs rename to test/stubs-computed-dirdata/dir/dir.data.cjs diff --git a/test/stubs-data-cascade/layout-data-files/test.11tydata.cjs b/test/stubs-data-cascade/layout-data-files/test.data.cjs similarity index 100% rename from test/stubs-data-cascade/layout-data-files/test.11tydata.cjs rename to test/stubs-data-cascade/layout-data-files/test.data.cjs diff --git a/test/stubs-data-cascade/layout-versus-dirdatafile/src/src.11tydata.cjs b/test/stubs-data-cascade/layout-versus-dirdatafile/src/src.data.cjs similarity index 100% rename from test/stubs-data-cascade/layout-versus-dirdatafile/src/src.11tydata.cjs rename to test/stubs-data-cascade/layout-versus-dirdatafile/src/src.data.cjs diff --git a/test/stubs-data-cascade/layout-versus-tmpldatafile/test.11tydata.cjs b/test/stubs-data-cascade/layout-versus-tmpldatafile/test.data.cjs similarity index 100% rename from test/stubs-data-cascade/layout-versus-tmpldatafile/test.11tydata.cjs rename to test/stubs-data-cascade/layout-versus-tmpldatafile/test.data.cjs diff --git a/test/stubs/component-async/component.11tydata.cjs b/test/stubs/component-async/component.data.cjs similarity index 100% rename from test/stubs/component-async/component.11tydata.cjs rename to test/stubs/component-async/component.data.cjs diff --git a/test/stubs/component-async/component.11tydata.js b/test/stubs/component-async/component.data.js similarity index 100% rename from test/stubs/component-async/component.11tydata.js rename to test/stubs/component-async/component.data.js diff --git a/test/stubs/component/component.11tydata.cjs b/test/stubs/component/component.data.cjs similarity index 100% rename from test/stubs/component/component.11tydata.cjs rename to test/stubs/component/component.data.cjs diff --git a/test/stubs/component/component.11tydata.js b/test/stubs/component/component.data.js similarity index 100% rename from test/stubs/component/component.11tydata.js rename to test/stubs/component/component.data.js diff --git a/test/stubs/component/component.11tydata.json b/test/stubs/component/component.data.json similarity index 100% rename from test/stubs/component/component.11tydata.json rename to test/stubs/component/component.data.json diff --git a/test/stubs/data-cascade/template.11tydata.cjs b/test/stubs/data-cascade/template.data.cjs similarity index 100% rename from test/stubs/data-cascade/template.11tydata.cjs rename to test/stubs/data-cascade/template.data.cjs diff --git a/test/stubs/local-data-tags/component.11tydata.cjs b/test/stubs/local-data-tags/component.data.cjs similarity index 100% rename from test/stubs/local-data-tags/component.11tydata.cjs rename to test/stubs/local-data-tags/component.data.cjs From e839957a197ae81d229c6e1b9a31decf9364b204 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 9 Jun 2026 17:17:44 -0500 Subject: [PATCH 19/53] Adds server.* JavaScript templates aliased to 11ty.js --- src/ExtensionMap.js | 11 ++++++++--- test/CoreTest-VirtualTemplates.js | 22 ++++++++++++++++++++++ test/TemplateWriterTest.js | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/ExtensionMap.js b/src/ExtensionMap.js index 36300d628..56518e7cd 100644 --- a/src/ExtensionMap.js +++ b/src/ExtensionMap.js @@ -262,15 +262,20 @@ export default class ExtensionMap { html: { key: "html", extension: "html" }, njk: { key: "njk", extension: "njk" }, liquid: { key: "liquid", extension: "liquid" }, + + "server.js": { key: "11ty.js", extension: "server.js" }, + "server.cjs": { key: "11ty.js", extension: "server.cjs" }, + "server.mjs": { key: "11ty.js", extension: "server.mjs" }, + "11ty.js": { key: "11ty.js", extension: "11ty.js" }, "11ty.cjs": { key: "11ty.js", extension: "11ty.cjs" }, "11ty.mjs": { key: "11ty.js", extension: "11ty.mjs" }, }; if (isTypeScriptSupported()) { - this._extensionToKeyMap["11ty.ts"] = { key: "11ty.js", extension: "11ty.ts" }; - this._extensionToKeyMap["11ty.cts"] = { key: "11ty.js", extension: "11ty.cts" }; - this._extensionToKeyMap["11ty.mts"] = { key: "11ty.js", extension: "11ty.mts" }; + this._extensionToKeyMap["server.ts"] = { key: "11ty.js", extension: "server.ts" }; + this._extensionToKeyMap["server.cts"] = { key: "11ty.js", extension: "server.cts" }; + this._extensionToKeyMap["server.mts"] = { key: "11ty.js", extension: "server.mts" }; } if ("extensionMap" in this.config) { diff --git a/test/CoreTest-VirtualTemplates.js b/test/CoreTest-VirtualTemplates.js index 6d4260330..ad7b7bca2 100644 --- a/test/CoreTest-VirtualTemplates.js +++ b/test/CoreTest-VirtualTemplates.js @@ -310,3 +310,25 @@ test("11ty.js class templates with instance properties (data and render arrows, t.deepEqual(results.length, 1); t.deepEqual(results[0].content.trim(), `Hello world!`); }); + +test("server.js Virtual Templates (object)", async (t) => { + let templateDefinition = { + data: () => { + return { var: 2 }; + }, + render: function(data) { + return `this is a test ${data.var}.`; + } + }; + + let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { + config: function (eleventyConfig) { + eleventyConfig.addTemplate("virtual.server.js", templateDefinition); + } + }); + + let results = await elev.toJSON(); + + t.deepEqual(results.length, 1); + t.deepEqual(results[0].content.trim(), `this is a test 2.`); +}); diff --git a/test/TemplateWriterTest.js b/test/TemplateWriterTest.js index 11975122d..2ff10a76f 100644 --- a/test/TemplateWriterTest.js +++ b/test/TemplateWriterTest.js @@ -511,7 +511,7 @@ test("Write Test 11ty.js", async (t) => { let { templateWriter: tw, eleventyFiles: evf } = getTemplateWriterInstance(["11ty.js"], eleventyConfig); let files = await glob(evf.getFileGlobs()); - t.deepEqual(evf.getRawFiles(), [`./test/stubs/writeTestJS/**/*.{11ty.js,11ty.cjs,11ty.mjs${isTypeScriptSupported() ? ",11ty.ts,11ty.cts,11ty.mts" : ""}}`]); + t.deepEqual(evf.getRawFiles(), [`./test/stubs/writeTestJS/**/*.{server.js,server.cjs,server.mjs,11ty.js,11ty.cjs,11ty.mjs,server.ts,server.cts,server.mts}`]); t.deepEqual(files, ["test/stubs/writeTestJS/test.11ty.cjs"]); let { template: tmpl } = tw.createTemplate(files[0]); From 1c6ae1efe5ff492fdc497dd0af2c979b90434ac6 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Wed, 10 Jun 2026 12:04:00 -0500 Subject: [PATCH 20/53] Adds `buildawesome` global data (aliased to `eleventy`) --- src/Data/ResolveConfigurationData.js | 56 ++++++++++++++++++++-------- src/Data/TemplateData.js | 21 ++++++----- src/Engines/Liquid.js | 1 + src/Plugins/RenderPlugin.js | 3 ++ src/Template.js | 6 +-- src/TemplateBehavior.js | 2 +- src/TemplateMap.js | 6 +-- src/Util/ReservedData.js | 9 +++-- src/defaultConfig.js | 10 ++--- test/CoreTest-ComputedData.js | 12 +++--- test/CoreTest.js | 12 +++--- test/ReservedDataTest.js | 8 ++-- test/ResolveConfigurationDataTest.js | 24 ++++++------ test/TemplateTest.js | 1 + 14 files changed, 101 insertions(+), 70 deletions(-) diff --git a/src/Data/ResolveConfigurationData.js b/src/Data/ResolveConfigurationData.js index fe0393872..05fceef95 100644 --- a/src/Data/ResolveConfigurationData.js +++ b/src/Data/ResolveConfigurationData.js @@ -2,33 +2,57 @@ import lodash from "@11ty/lodash-custom"; const { set: lodashSet, get: lodashGet } = lodash; +// buildawesomeDataSchema looks for buildawesomeDataSchema and eleventyDataSchema (this is what we use internally) +// eleventyDataSchema looks for eleventyDataSchema (and not buildawesomeDataSchema) export class ResolveConfigurationData { - static BUILDAWESOME_PREFIX = "buildawesome."; + static ELIGIBLE_PROPS = new Set([ + "buildawesomeComputed", + "buildawesomeDataSchema", + "buildawesomeExcludeFromCollections", + "buildawesomeImport", + ]); + static BUILDAWESOME_PREFIX = "buildawesome"; static ELEVENTY_PREFIX = "eleventy"; - static capitalize(propName) { - return propName.slice(0, 1).toUpperCase() + propName.slice(1); - } - - // buildawesome.dataSchema becomes eleventyDataSchema + // buildawesomeDataSchema becomes eleventyDataSchema + // eleventyDataSchema returned undefined static getAlternatePropertyName(propertyName) { - if ( - typeof propertyName === "string" && - propertyName.startsWith(ResolveConfigurationData.BUILDAWESOME_PREFIX) - ) { + if (typeof propertyName === "string" && this.ELIGIBLE_PROPS.has(propertyName)) { let prefixRemoved = propertyName.slice(ResolveConfigurationData.BUILDAWESOME_PREFIX.length); - return this.ELEVENTY_PREFIX + this.capitalize(prefixRemoved); + return this.ELEVENTY_PREFIX + prefixRemoved; } } - static getValue(data, location) { - let eligibleLocations = [location]; - let alternate = ResolveConfigurationData.getAlternatePropertyName(location); - if (alternate !== undefined) { + static getEligibleLocations(original) { + let eligibleLocations = [original]; + let alternate = this.getAlternatePropertyName(original); + if (alternate !== undefined && alternate !== original) { eligibleLocations.push(alternate); } + return eligibleLocations; + } + + static resolve(data, location) { + let eligible = this.getEligibleLocations(location); + for (let loc of eligible) { + let val = lodashGet(data, loc, undefined); + if (val !== undefined) { + return { + location: loc, + value: val, + }; + } + } + + return { + location: undefined, + }; + } + + static getValue(data, location) { + let eligible = this.getEligibleLocations(location); - for (let loc of eligibleLocations) { + for (let loc of eligible) { let val = lodashGet(data, loc, undefined); if (val !== undefined) { return val; diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index 291fc2312..c8bed5361 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -386,35 +386,36 @@ class TemplateData { return globalData; } - getEleventyGlobal() { + getCoreGlobal() { // #2293 for meta[name=generator] const pkg = getCorePackageJson(); let version = coerce(pkg.version).toString(); - let eleventy = { + let global = { version, generator: `Eleventy (Build Awesome) v${version}`, }; if (this.environmentVariables) { - eleventy.env = Object.assign({}, this.environmentVariables); + global.env = Object.assign({}, this.environmentVariables); } if (this.dirs) { - eleventy.directories = Object.assign({}, this.dirs.getUserspaceInstance()); + global.directories = Object.assign({}, this.dirs.getUserspaceInstance()); } - eleventy.pendingEditsCount = (this.templateConfig.getPendingDataOverrides() || []).length; + global.pendingEditsCount = (this.templateConfig.getPendingDataOverrides() || []).length; - // `eleventy` is Reserved if (this.config.freezeReservedData) { - DeepFreeze(eleventy); + DeepFreeze(global); } - return eleventy; + return global; } async #getInitialGlobalData() { let globalData = await this.initialGlobalData.getData(); - globalData.eleventy = this.getEleventyGlobal(); + let coreGlobal = this.getCoreGlobal(); + globalData.eleventy = coreGlobal; + globalData.buildawesome = coreGlobal; return globalData; } @@ -777,7 +778,7 @@ class TemplateData { // TODO move this key to defaultConfig->keys->excludeFromCollections let excludeValue = ResolveConfigurationData.getValue( data, - "buildawesome.excludeFromCollections", + "buildawesomeExcludeFromCollections", ); if (excludeValue !== true) { if (Array.isArray(excludeValue)) { diff --git a/src/Engines/Liquid.js b/src/Engines/Liquid.js index bd44aa6e1..8cc0aed35 100644 --- a/src/Engines/Liquid.js +++ b/src/Engines/Liquid.js @@ -329,6 +329,7 @@ export default class Liquid extends TemplateEngine { { page: data?.page, eleventy: data?.eleventy, + buildawesome: data?.buildawesome, collections: data?.collections, }, liquidOptions?.globals, diff --git a/src/Plugins/RenderPlugin.js b/src/Plugins/RenderPlugin.js index 589199359..51dde9b23 100644 --- a/src/Plugins/RenderPlugin.js +++ b/src/Plugins/RenderPlugin.js @@ -144,6 +144,7 @@ async function renderShortcodeFn(fn, data) { // save `page` and `eleventy` for reuse data.page = this.page; data.eleventy = this.eleventy; + data.buildawesome = this.buildawesome; } return fn(data); @@ -224,6 +225,7 @@ function RenderPlugin(eleventyConfig, options = {}) { normalizedContext.page = ctx.get(["page"]); normalizedContext.eleventy = ctx.get(["eleventy"]); + normalizedContext.buildawesome = ctx.get(["buildawesome"]); } let argArray = []; @@ -324,6 +326,7 @@ function RenderPlugin(eleventyConfig, options = {}) { normalizedContext.page = context.ctx.page; normalizedContext.eleventy = context.ctx.eleventy; + normalizedContext.buildawesome = context.ctx.buildawesome; } body(function (e, bodyContent) { diff --git a/src/Template.js b/src/Template.js index cacb05c81..acdd51338 100755 --- a/src/Template.js +++ b/src/Template.js @@ -215,12 +215,10 @@ class Template extends TemplateContent { throw new Error("Internal error: data argument missing in Template->_getLink"); } + let computedData = ResolveConfigurationData.getValue(data, this.config.keys.computed); let permalink = ResolveConfigurationData.getValue(data, this.config.keys.permalink) ?? - ResolveConfigurationData.getValue( - data, - `${this.config.keys.computed}.${this.config.keys.permalink}`, - ); + ResolveConfigurationData.getValue(computedData, this.config.keys.permalink); let permalinkValue; let isDynamicPermalinkEnabled = this.config.dynamicPermalinks && data.dynamicPermalink !== false; diff --git a/src/TemplateBehavior.js b/src/TemplateBehavior.js index adf6e33fd..853cc035b 100644 --- a/src/TemplateBehavior.js +++ b/src/TemplateBehavior.js @@ -65,9 +65,9 @@ class TemplateBehavior { } } - let computedKey = this.config.keys.computed; let computedData = ResolveConfigurationData.getValue(data, this.config.keys.computed); let permalink = ResolveConfigurationData.getValue(computedData, this.config.keys.permalink); + if (computedData && isPlainObject(permalink)) { for (let key of Object.keys(permalink)) { keys.add(key); diff --git a/src/TemplateMap.js b/src/TemplateMap.js index 5ad5d0cfc..9eb02bbf8 100644 --- a/src/TemplateMap.js +++ b/src/TemplateMap.js @@ -232,7 +232,7 @@ class TemplateMap { if (counter === 0 || map.data.pagination?.addAllPagesToCollections) { if ( - ResolveConfigurationData.getValue(map.data, "buildawesome.excludeFromCollections") !== + ResolveConfigurationData.getValue(map.data, "buildawesomeExcludeFromCollections") !== true ) { // is in *some* collections @@ -393,7 +393,7 @@ class TemplateMap { for (let pageEntry of map._pages) { // Data Schema callback #879 - let dataSchema = ResolveConfigurationData.getValue( + let { location: dataSchemaLocation, value: dataSchema } = ResolveConfigurationData.resolve( pageEntry.data, this.config.keys.dataSchema, ); @@ -402,7 +402,7 @@ class TemplateMap { await dataSchema(pageEntry.data); } catch (e) { throw new Error( - `Error in the data schema for: ${map.inputPath} (via \`eleventyDataSchema\`)`, + `Error in the data schema for: ${map.inputPath} (via \`${dataSchemaLocation}\`)`, { cause: e }, ); } diff --git a/src/Util/ReservedData.js b/src/Util/ReservedData.js index ab7fa8060..8c48c35b7 100644 --- a/src/Util/ReservedData.js +++ b/src/Util/ReservedData.js @@ -1,8 +1,9 @@ -class EleventyReservedDataError extends TypeError {} +class CoreReservedDataError extends TypeError {} class ReservedData { static fullProperties = [ "pkg", // Object.freeze’d upstream + "buildawesome", // Object.freeze’d upstream "eleventy", // Object.freeze’d upstream // "page" is only frozen for specific subproperties below "content", @@ -79,8 +80,8 @@ class ReservedData { reservedNames ??= cause.reservedNames; } - let e = new EleventyReservedDataError( - `You attempted to set one of Eleventy’s reserved data property names${reservedNames ? `: ${reservedNames.join(", ")}` : ""}${sourceLocation ? ` (source: ${sourceLocation})` : ""}. You can opt-out of this behavior with \`eleventyConfig.setFreezeReservedData(false)\` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. \`eleventy\`, \`pkg\`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/`, + let e = new CoreReservedDataError( + `You attempted to set one of Build Awesome’s reserved data property names${reservedNames ? `: ${reservedNames.join(", ")}` : ""}${sourceLocation ? ` (source: ${sourceLocation})` : ""}. You can opt-out of this behavior with \`$config.setFreezeReservedData(false)\` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. \`buildawesome\`, \`eleventy\`, \`pkg\`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/`, { cause }, ); @@ -99,7 +100,7 @@ class ReservedData { } static isReservedDataError(e) { - return e instanceof EleventyReservedDataError; + return e instanceof CoreReservedDataError; } } diff --git a/src/defaultConfig.js b/src/defaultConfig.js index 531cab5b7..9a0a6ecb7 100644 --- a/src/defaultConfig.js +++ b/src/defaultConfig.js @@ -33,8 +33,8 @@ import TransformsUtil from "./Util/TransformsUtil.js"; * @property {string} [keys.permalink='permalink'] * @property {string} [keys.permalinkRoot='permalinkBypassOutputDir'] * @property {string} [keys.engineOverride='templateEngineOverride'] - * @property {string} [keys.computed='buildawesome.computed'] - * @property {string} [keys.dataSchema='buildawesome.dataSchema'] + * @property {string} [keys.computed='buildawesomeComputed'] + * @property {string} [keys.dataSchema='buildawesomeDataSchema'] * @property {object} dir * @property {string} [dir.input='.'] * @property {string} [dir.includes='_includes'] @@ -92,9 +92,9 @@ export default function (config) { permalink: "permalink", permalinkRoot: "permalinkBypassOutputDir", engineOverride: "templateEngineOverride", - computed: "buildawesome.computed", - dataSchema: "buildawesome.dataSchema", - import: "buildawesome.import", + computed: "buildawesomeComputed", + dataSchema: "buildawesomeDataSchema", + import: "buildawesomeImport", }, // Deprecated, define using `export const directories = {}` instead. diff --git a/test/CoreTest-ComputedData.js b/test/CoreTest-ComputedData.js index d5354fff4..1a65e5960 100644 --- a/test/CoreTest-ComputedData.js +++ b/test/CoreTest-ComputedData.js @@ -1,11 +1,11 @@ import test from "ava"; import BuildAwesome from "../src/Core.js"; -test("Using buildawesome.computed and eleventyComputed (prefers former)", async (t) => { +test("Using buildawesomeComputed and eleventyComputed (prefers former)", async (t) => { let elev = new BuildAwesome("./test/stubs-virtual/", undefined, { config: configApi => { // will override - configApi.addGlobalData("buildawesome.computed", () => { + configApi.addGlobalData("buildawesomeComputed", () => { return { key1: "value1" } @@ -26,7 +26,7 @@ test("Using buildawesome.computed and eleventyComputed (prefers former)", async t.is(results[0].content, `value1`); }); -test("Using buildawesome.computed and eleventyComputed (prefers former, reverse add)", async (t) => { +test("Using buildawesomeComputed and eleventyComputed (prefers former, reverse add)", async (t) => { let elev = new BuildAwesome("./test/stubs-virtual/", undefined, { config: configApi => { configApi.addGlobalData("eleventyComputed", () => { @@ -36,7 +36,7 @@ test("Using buildawesome.computed and eleventyComputed (prefers former, reverse }); // will override - configApi.addGlobalData("buildawesome.computed", () => { + configApi.addGlobalData("buildawesomeComputed", () => { return { key1: "value1" } @@ -51,7 +51,7 @@ test("Using buildawesome.computed and eleventyComputed (prefers former, reverse t.is(results[0].content, `value1`); }); -test("Using buildawesome.computed.permalink", async (t) => { +test("Using buildawesomeComputed.permalink", async (t) => { let elev = new BuildAwesome("./test/stubs-virtual/", undefined, { config: configApi => { configApi.addGlobalData("permalink", () => { @@ -59,7 +59,7 @@ test("Using buildawesome.computed.permalink", async (t) => { }); // will override - configApi.addGlobalData("buildawesome.computed.permalink", () => { + configApi.addGlobalData("buildawesomeComputed.permalink", () => { return () => "/rewritten1.html" }); diff --git a/test/CoreTest.js b/test/CoreTest.js index 5c8fc95b4..956dcbc9f 100644 --- a/test/CoreTest.js +++ b/test/CoreTest.js @@ -986,7 +986,7 @@ eleventy: elev.disableLogger(); let e = await t.throwsAsync(() => elev.toJSON(), { - message: 'You attempted to set one of Eleventy’s reserved data property names. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' + message: 'You attempted to set one of Build Awesome’s reserved data property names. You can opt-out of this behavior with `$config.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. `buildawesome`, `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' }); t.is(e.cause.toString(), "TypeError: Cannot add property key1, object is not extensible"); @@ -1004,7 +1004,7 @@ pkg: elev.disableLogger(); let e = await t.throwsAsync(() => elev.toJSON(), { - message: 'You attempted to set one of Eleventy’s reserved data property names. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' + message: 'You attempted to set one of Build Awesome’s reserved data property names. You can opt-out of this behavior with `$config.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. `buildawesome`, `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' }); t.is(e.cause.toString(), "TypeError: Cannot add property myOwn, object is not extensible"); @@ -1042,7 +1042,7 @@ page: "My page value" elev.disableLogger(); let e = await t.throwsAsync(() => elev.toJSON(), { - message: 'You attempted to set one of Eleventy’s reserved data property names: page. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' + message: 'You attempted to set one of Build Awesome’s reserved data property names: page. You can opt-out of this behavior with `$config.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. `buildawesome`, `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' }); }); @@ -1057,7 +1057,7 @@ content: "My page value" elev.disableLogger(); await t.throwsAsync(() => elev.toJSON(), { - message: 'You attempted to set one of Eleventy’s reserved data property names: content. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' + message: 'You attempted to set one of Build Awesome’s reserved data property names: content. You can opt-out of this behavior with `$config.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. `buildawesome`, `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' }); }); @@ -1072,7 +1072,7 @@ collections: [] elev.disableLogger(); await t.throwsAsync(() => elev.toJSON(), { - message: 'You attempted to set one of Eleventy’s reserved data property names: collections. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' + message: 'You attempted to set one of Build Awesome’s reserved data property names: collections. You can opt-out of this behavior with `$config.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. `buildawesome`, `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' }); }); @@ -1158,7 +1158,7 @@ parkour: t.is(elev.eleventyConfig.config.keys.package, "parkour"); let e = await t.throwsAsync(() => elev.toJSON(), { - message: 'You attempted to set one of Eleventy’s reserved data property names. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' + message: 'You attempted to set one of Build Awesome’s reserved data property names. You can opt-out of this behavior with `$config.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. `buildawesome`, `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' }); t.is(e.cause.toString(), "TypeError: Cannot add property myOwn, object is not extensible"); diff --git a/test/ReservedDataTest.js b/test/ReservedDataTest.js index b5a893de8..a242e2d93 100644 --- a/test/ReservedDataTest.js +++ b/test/ReservedDataTest.js @@ -37,7 +37,7 @@ test("Eleventy freeze data set via config API throws error (page)", async (t) => elev.disableLogger(); await t.throwsAsync(() => elev.toJSON(), { - message: 'You attempted to set one of Eleventy’s reserved data property names: page (source: ./test/stubs-virtual/eleventy.config.js). You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' + message: 'You attempted to set one of Build Awesome’s reserved data property names: page (source: ./test/stubs-virtual/eleventy.config.js). You can opt-out of this behavior with `$config.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. `buildawesome`, `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' }); }); @@ -52,7 +52,7 @@ test("Eleventy freeze data set via config API throws error (eleventy)", async (t elev.disableLogger(); await t.throwsAsync(() => elev.toJSON(), { - message: 'You attempted to set one of Eleventy’s reserved data property names: eleventy (source: ./test/stubs-virtual/eleventy.config.js). You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' + message: 'You attempted to set one of Build Awesome’s reserved data property names: eleventy (source: ./test/stubs-virtual/eleventy.config.js). You can opt-out of this behavior with `$config.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. `buildawesome`, `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' }); }); @@ -66,7 +66,7 @@ test("Eleventy freeze data set global data file throws error (page)", async (t) elev.disableLogger(); await t.throwsAsync(() => elev.toJSON(), { - message: 'You attempted to set one of Eleventy’s reserved data property names: page.url (source: ./test/stubs-freeze/page/_data/page.js). You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' + message: 'You attempted to set one of Build Awesome’s reserved data property names: page.url (source: ./test/stubs-freeze/page/_data/page.js). You can opt-out of this behavior with `$config.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. `buildawesome`, `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' }); }); @@ -80,6 +80,6 @@ test("Eleventy freeze data set global data file throws error (eleventy)", async elev.disableLogger(); await t.throwsAsync(() => elev.toJSON(), { - message: 'You attempted to set one of Eleventy’s reserved data property names: eleventy (source: ./test/stubs-freeze/eleventy/_data/eleventy.js). You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' + message: 'You attempted to set one of Build Awesome’s reserved data property names: eleventy (source: ./test/stubs-freeze/eleventy/_data/eleventy.js). You can opt-out of this behavior with `$config.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with reserved property names (e.g. `buildawesome`, `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/' }); }); diff --git a/test/ResolveConfigurationDataTest.js b/test/ResolveConfigurationDataTest.js index 82226109c..4797128ce 100644 --- a/test/ResolveConfigurationDataTest.js +++ b/test/ResolveConfigurationDataTest.js @@ -5,49 +5,51 @@ import { ResolveConfigurationData } from "../src/Data/ResolveConfigurationData.j test("Alternate location", (t) => { t.is(ResolveConfigurationData.getAlternatePropertyName("permalink"), undefined); t.is(ResolveConfigurationData.getAlternatePropertyName("eleventyComputed"), undefined); - t.is(ResolveConfigurationData.getAlternatePropertyName("buildawesome.computed"), "eleventyComputed"); - t.is(ResolveConfigurationData.getAlternatePropertyName("buildawesome.dataSchema"), "eleventyDataSchema"); - t.is(ResolveConfigurationData.getAlternatePropertyName("buildawesome.excludeFromCollections"), "eleventyExcludeFromCollections"); + t.is(ResolveConfigurationData.getAlternatePropertyName("buildawesomeComputed"), "eleventyComputed"); + t.is(ResolveConfigurationData.getAlternatePropertyName("buildawesomeDataSchema"), "eleventyDataSchema"); + t.is(ResolveConfigurationData.getAlternatePropertyName("buildawesomeExcludeFromCollections"), "eleventyExcludeFromCollections"); }); test("Permalink (empty data)", (t) => { let data = {}; t.is(ResolveConfigurationData.getValue(data, "permalink"), undefined); + t.deepEqual(ResolveConfigurationData.resolve(data, "permalink"), { location: undefined }); }); test("Permalink", (t) => { let data = { permalink: "test" }; t.is(ResolveConfigurationData.getValue(data, "permalink"), "test"); + t.deepEqual(ResolveConfigurationData.resolve(data, "permalink"), { location: "permalink", value: "test" }); }); test("Computed Data", (t) => { let data = { eleventyComputed: { key: "value" } }; t.deepEqual(ResolveConfigurationData.getValue(data, "eleventyComputed"), { key: "value" }); + t.deepEqual(ResolveConfigurationData.resolve(data, "eleventyComputed"), {location: "eleventyComputed", value: { key: "value" }}); }); test("Computed Data, alternate location", (t) => { let data = { eleventyComputed: { key: "value1" } }; - t.deepEqual(ResolveConfigurationData.getValue(data, "buildawesome.computed"), { key: "value1" }); + t.deepEqual(ResolveConfigurationData.getValue(data, "buildawesomeComputed"), { key: "value1" }); + t.deepEqual(ResolveConfigurationData.resolve(data, "buildawesomeComputed"), { location: "eleventyComputed", value: { key: "value1" } }); }); test("Both locations exist, prefer primary", (t) => { let data = { eleventyComputed: { key1: "value1" }, - buildawesome: { - computed: { key2: "value2" }, - }, + buildawesomeComputed: { key2: "value2" }, }; - t.deepEqual(ResolveConfigurationData.getValue(data, "buildawesome.computed"), { key2: "value2" }); + t.deepEqual(ResolveConfigurationData.getValue(data, "buildawesomeComputed"), { key2: "value2" }); + t.deepEqual(ResolveConfigurationData.resolve(data, "buildawesomeComputed"), { location: "buildawesomeComputed", value: { key2: "value2" } }); }); test("Both locations exist, no alternate", (t) => { let data = { eleventyComputed: { key1: "value1" }, - buildawesome: { - computed: { key2: "value2" }, - }, + buildawesomeComputed: { key2: "value2" }, }; t.deepEqual(ResolveConfigurationData.getValue(data, "eleventyComputed"), { key1: "value1" }); + t.deepEqual(ResolveConfigurationData.resolve(data, "eleventyComputed"), { location: "eleventyComputed", value: { key1: "value1" } }); }); diff --git a/test/TemplateTest.js b/test/TemplateTest.js index af45a4b12..5025e526e 100644 --- a/test/TemplateTest.js +++ b/test/TemplateTest.js @@ -1213,6 +1213,7 @@ test("Data Cascade (Deep merge)", async (t) => { let data = await tmpl.getData(); t.deepEqual(Object.keys(data).sort(), [ + "buildawesome", "datafile", "eleventy", "frontmatter", From 7d27fb6550b020e844fdfaebd25b2bc362c4533a Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Wed, 10 Jun 2026 12:19:56 -0500 Subject: [PATCH 21/53] Rename eleventyConfig to $config for configuration callback tests --- src/Plugins/RenderPlugin.js | 22 +-- src/TemplateMap.js | 2 +- test/BundlePluginTest.js | 64 +++---- test/CoreTest-CustomDateParsing.js | 68 +++---- test/CoreTest-PageData.js | 28 +-- test/CoreTest-Preprocessors.js | 108 +++++------ test/CoreTest-Shortcodes.js | 8 +- test/CoreTest-VirtualTemplates.js | 86 ++++----- test/CoreTest.js | 178 +++++++++--------- test/EleventyAddGlobalDataTest.js | 38 ++-- test/EleventyImgTransformTest.js | 16 +- test/EleventyMarkdownTest.js | 12 +- test/FilesGitIgnoreEleventyIgnoreTest.js | 84 ++++----- test/FilesTest.js | 114 +++++------ test/HtmlBasePluginTest.js | 86 ++++----- test/HtmlRelativeCopyTest.js | 162 ++++++++-------- test/I18nPluginTest.js | 14 +- test/IdAttributePluginTest.js | 68 +++---- test/InputPathToUrlPluginTest.js | 72 +++---- test/Issue3467Test.js | 18 +- test/Issue3788Test.js | 6 +- test/Issue3797Test.js | 10 +- test/Issue3808Test.js | 32 ++-- test/Issue3816Test.js | 8 +- test/Issue3818Test.js | 24 +-- test/Issue3823Test.js | 10 +- test/Issue3825Test.js | 42 ++--- test/Issue3831Test.js | 6 +- test/Issue3833Test.js | 4 +- test/Issue3850Test.js | 4 +- test/Issue3860Test.js | 10 +- test/Issue3870IncrementalTest.js | 6 +- test/Issue3870Test.js | 6 +- test/Issue3875Test.js | 34 ++-- test/Issue434Test.js | 14 +- test/Issue775Test.js | 12 +- test/JavaScriptFrontMatterTest.js | 8 +- test/PaginationTest.js | 64 +++---- test/PreserveClosingTagsPluginTest.js | 30 +-- test/ReservedDataTest.js | 20 +- test/TemplateCollectionTest.js | 102 +++++----- test/TemplateConfigTest.js | 66 +++---- test/TemplateDataTest.js | 24 +-- test/TemplateRenderLiquidTest.js | 56 +++--- test/TemplateRenderPluginTest.js | 24 +-- test/TemplateTest-ComputedData.js | 22 +-- test/_getNewTemplateForTests.js | 12 +- test/_issues/2250/2250-test.js | 4 +- test/_issues/3697/3697-test.js | 4 +- test/_testHelpers.js | 18 +- .../eleventy.config.cjs | 6 +- test/stubs-2258/eleventy.config.cjs | 6 +- test/stubs-2261/eleventy.config.js | 4 +- test/stubs-3807/Issue3807test.js | 4 +- test/stubs-3807/eleventy.config.js | 4 +- test/stubs-3810/eleventy.config.js | 6 +- test/stubs-virtual/eleventy.config.js | 2 +- test/stubs/broken-config.cjs | 4 +- .../eleventy.config.cjs | 2 +- .../cfg-directories-export/eleventy.config.js | 2 +- 60 files changed, 982 insertions(+), 988 deletions(-) diff --git a/src/Plugins/RenderPlugin.js b/src/Plugins/RenderPlugin.js index 51dde9b23..8a2253e58 100644 --- a/src/Plugins/RenderPlugin.js +++ b/src/Plugins/RenderPlugin.js @@ -159,17 +159,17 @@ async function renderShortcodeFn(fn, data) { * string (or file) inside of another template. {@link https://v3.11ty.dev/docs/plugins/render/} * * @since 1.0.0 - * @param {module:11ty/eleventy/UserConfig} eleventyConfig - User-land configuration instance. + * @param {module:11ty/eleventy/UserConfig} $config - User-land configuration instance. * @param {object} options - Plugin options */ -function RenderPlugin(eleventyConfig, options = {}) { +function RenderPlugin($config, options = {}) { let templateConfig; - eleventyConfig.on("buildawesome.config", (tmplConfigInstance) => { + $config.on("buildawesome.config", (tmplConfigInstance) => { templateConfig = tmplConfigInstance; }); let extensionMap; - eleventyConfig.on("buildawesome.extensionmap", (map) => { + $config.on("buildawesome.extensionmap", (map) => { extensionMap = map; }); @@ -194,7 +194,7 @@ function RenderPlugin(eleventyConfig, options = {}) { parse: function (tagToken, remainTokens) { this.name = tagToken.name; - if (eleventyConfig.liquid.parameterParsing === "builtin") { + if ($config.liquid.parameterParsing === "builtin") { this.orderedArgs = Liquid.parseArgumentsBuiltin(tagToken.args); // note that Liquid does have a Hash class for name-based argument parsing but offers no easy to support both modes in one class } else { @@ -389,26 +389,26 @@ function RenderPlugin(eleventyConfig, options = {}) { // Render strings if (options.tagName) { // use falsy to opt-out - eleventyConfig.addJavaScriptFunction(options.tagName, _renderStringShortcodeFn); + $config.addJavaScriptFunction(options.tagName, _renderStringShortcodeFn); - eleventyConfig.addLiquidTag(options.tagName, function (liquidEngine, extras) { + $config.addLiquidTag(options.tagName, function (liquidEngine, extras) { return liquidTemplateTag(liquidEngine, options.tagName, extras); }); - eleventyConfig.addNunjucksTag(options.tagName, function (nunjucksLib) { + $config.addNunjucksTag(options.tagName, function (nunjucksLib) { return nunjucksTemplateTag(nunjucksLib, options.tagName); }); } // Filter for rendering strings if (options.filterName) { - eleventyConfig.addAsyncFilter(options.filterName, _renderStringShortcodeFn); + $config.addAsyncFilter(options.filterName, _renderStringShortcodeFn); } // Render File // use `false` to opt-out if (options.tagNameFile) { - eleventyConfig.addAsyncShortcode(options.tagNameFile, _renderFileShortcodeFn); + $config.addAsyncShortcode(options.tagNameFile, _renderFileShortcodeFn); } } @@ -460,7 +460,7 @@ class RenderManager { // `callback` is async-friendly but requires await upstream config(callback) { - // run an extra `function(eleventyConfig)` configuration callbacks + // run an extra `function($config)` configuration callbacks if (callback && typeof callback === "function") { return callback(this.templateConfig.userConfig); } diff --git a/src/TemplateMap.js b/src/TemplateMap.js index 9eb02bbf8..a617d2cd4 100644 --- a/src/TemplateMap.js +++ b/src/TemplateMap.js @@ -667,7 +667,7 @@ You *probably* want to add a file extension to your permalink so that hosts will Learn more: https://v3.11ty.dev/docs/permalinks/#trailing-slashes -This is usually but not *always* an error so if you’d like to disable this error message, add \`eleventyAllowMissingExtension: true\` somewhere in the data cascade for this template or use \`eleventyConfig.configureErrorReporting({ allowMissingExtensions: true });\` to disable this feature globally.`); +This is usually but not *always* an error so if you’d like to disable this error message, add \`eleventyAllowMissingExtension: true\` somewhere in the data cascade for this template or use \`$config.configureErrorReporting({ allowMissingExtensions: true });\` to disable this feature globally.`); e.skipOriginalStack = true; throw e; } diff --git a/test/BundlePluginTest.js b/test/BundlePluginTest.js index b362667f8..96a57d318 100644 --- a/test/BundlePluginTest.js +++ b/test/BundlePluginTest.js @@ -3,11 +3,11 @@ import Eleventy from "../src/Core.js"; test("addBundle", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPlugin(() => { - eleventyConfig.addBundle("css") + config: $config => { + $config.addPlugin(() => { + $config.addBundle("css") }); - eleventyConfig.addTemplate("index.njk", "{% css %}/* Hi */{% endcss %}"); + $config.addTemplate("index.njk", "{% css %}/* Hi */{% endcss %}"); } }); @@ -17,12 +17,12 @@ test("addBundle", async (t) => { test("addBundle (empty css)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPlugin(() => { - eleventyConfig.addBundle("css"); + config: $config => { + $config.addPlugin(() => { + $config.addBundle("css"); }); - eleventyConfig.addTemplate("index.njk", "Hi"); + $config.addTemplate("index.njk", "Hi"); } }); @@ -32,12 +32,12 @@ test("addBundle (empty css)", async (t) => { test("addBundle (empty js)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPlugin(() => { - eleventyConfig.addBundle("js"); + config: $config => { + $config.addPlugin(() => { + $config.addBundle("js"); }); - eleventyConfig.addTemplate("index.njk", "Hi"); + $config.addTemplate("index.njk", "Hi"); } }); @@ -47,12 +47,12 @@ test("addBundle (empty js)", async (t) => { test("Empty script node is removed (not using bundle)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPlugin(() => { - eleventyConfig.addBundle("js"); + config: $config => { + $config.addPlugin(() => { + $config.addBundle("js"); }); - eleventyConfig.addTemplate("index.njk", "Hi"); + $config.addTemplate("index.njk", "Hi"); } }); @@ -63,12 +63,12 @@ test("Empty script node is removed (not using bundle)", async (t) => { test("Empty style node is removed (not using bundle)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPlugin(() => { - eleventyConfig.addBundle("css"); + config: $config => { + $config.addPlugin(() => { + $config.addBundle("css"); }); - eleventyConfig.addTemplate("index.njk", "Hi"); + $config.addTemplate("index.njk", "Hi"); } }); @@ -78,12 +78,12 @@ test("Empty style node is removed (not using bundle)", async (t) => { test("Empty link node is removed (not using bundle)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPlugin(() => { - eleventyConfig.addBundle("css"); + config: $config => { + $config.addPlugin(() => { + $config.addBundle("css"); }); - eleventyConfig.addTemplate("index.njk", "Hi"); + $config.addTemplate("index.njk", "Hi"); } }); @@ -93,12 +93,12 @@ test("Empty link node is removed (not using bundle)", async (t) => { test("Empty link node is removed (no href attribute at all, not using bundle)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPlugin(() => { - eleventyConfig.addBundle("css"); + config: $config => { + $config.addPlugin(() => { + $config.addBundle("css"); }); - eleventyConfig.addTemplate("index.njk", "Hi"); + $config.addTemplate("index.njk", "Hi"); } }); @@ -108,12 +108,12 @@ test("Empty link node is removed (no href attribute at all, not using bundle)", test("Empty link node is kept (no rel attribute, not using bundle)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPlugin(() => { - eleventyConfig.addBundle("css"); + config: $config => { + $config.addPlugin(() => { + $config.addBundle("css"); }); - eleventyConfig.addTemplate("index.njk", "Hi"); + $config.addTemplate("index.njk", "Hi"); } }); diff --git a/test/CoreTest-CustomDateParsing.js b/test/CoreTest-CustomDateParsing.js index 60e59badf..30ce78ab4 100644 --- a/test/CoreTest-CustomDateParsing.js +++ b/test/CoreTest-CustomDateParsing.js @@ -9,11 +9,11 @@ test("Custom date parsing callback (return string), Issue #867", async (t) => { t.plan(3); let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/", { - config: eleventyConfig => { - eleventyConfig.addTemplate("test.html", `# Markdown`); - eleventyConfig.dataFilterSelectors.add("page.date"); + config: $config => { + $config.addTemplate("test.html", `# Markdown`); + $config.dataFilterSelectors.add("page.date"); - eleventyConfig.addDateParsing(function(dateValue) { + $config.addDateParsing(function(dateValue) { t.truthy(this.page.inputPath); t.is(dateValue, undefined); return "2001-01-01T12:00:00Z"; @@ -30,14 +30,14 @@ test("Custom date parsing callback (input a non-YAML date format), Issue #867", t.plan(2); let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/", { - config: eleventyConfig => { - eleventyConfig.addTemplate("test.html", `--- + config: $config => { + $config.addTemplate("test.html", `--- date: 2019-08-31 23:59:56 America/New_York --- # Markdown`); - eleventyConfig.dataFilterSelectors.add("page.date"); + $config.dataFilterSelectors.add("page.date"); - eleventyConfig.addDateParsing(function(dateValue) { + $config.addDateParsing(function(dateValue) { t.is(dateValue, "2019-08-31 23:59:56 America/New_York"); // returns DateTime instance from Luxon return DateTime.fromFormat(dateValue, "yyyy-MM-dd hh:mm:ss z"); @@ -54,11 +54,11 @@ test("Custom date parsing callback (return Date), Issue #867", async (t) => { t.plan(3); let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/", { - config: eleventyConfig => { - eleventyConfig.addTemplate("test.html", `# Markdown`); - eleventyConfig.dataFilterSelectors.add("page.date"); + config: $config => { + $config.addTemplate("test.html", `# Markdown`); + $config.dataFilterSelectors.add("page.date"); - eleventyConfig.addDateParsing(function(dateValue) { + $config.addDateParsing(function(dateValue) { t.truthy(this.page.inputPath); t.is(dateValue, undefined); return new Date(Date.UTC(2001,0,1,12)); @@ -75,13 +75,13 @@ test("Custom date parsing callback (using date from data cascade, return string) t.plan(3); let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/", { - config: eleventyConfig => { - eleventyConfig.addTemplate("test.html", `# Markdown`, { + config: $config => { + $config.addTemplate("test.html", `# Markdown`, { date: new Date(Date.UTC(2002, 0, 1, 12)) }); - eleventyConfig.dataFilterSelectors.add("page.date"); + $config.dataFilterSelectors.add("page.date"); - eleventyConfig.addDateParsing(function (dateValue) { + $config.addDateParsing(function (dateValue) { t.truthy(this.page.inputPath); t.true(dateValue instanceof Date); return "2001-01-01T12:00:00Z"; @@ -98,19 +98,19 @@ test("Custom date parsing callback (two, return undefined/falsy), Issue #867", a t.plan(5); let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/", { - config: eleventyConfig => { - eleventyConfig.addTemplate("test.html", `# Markdown`, { + config: $config => { + $config.addTemplate("test.html", `# Markdown`, { date: new Date(Date.UTC(2003, 0, 1, 12)) }); - eleventyConfig.dataFilterSelectors.add("page.date"); + $config.dataFilterSelectors.add("page.date"); - eleventyConfig.addDateParsing(function (dateValue) { + $config.addDateParsing(function (dateValue) { t.truthy(this.page.inputPath); t.deepEqual(dateValue, new Date(Date.UTC(2003,0,1,12))); // return nothing }); - eleventyConfig.addDateParsing(function (dateValue) { + $config.addDateParsing(function (dateValue) { t.truthy(this.page.inputPath); t.deepEqual(dateValue, new Date(Date.UTC(2003,0,1,12))); // return nothing @@ -127,13 +127,13 @@ test("Custom date parsing callback (return explicit false), Issue #867", async ( t.plan(2); let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/", { - config: eleventyConfig => { - eleventyConfig.addTemplate("test.html", `# Markdown`, { + config: $config => { + $config.addTemplate("test.html", `# Markdown`, { date: new Date(Date.UTC(2003, 0, 1, 12)) }); - eleventyConfig.dataFilterSelectors.add("page.date"); + $config.dataFilterSelectors.add("page.date"); - eleventyConfig.addDateParsing(function (dateValue) { + $config.addDateParsing(function (dateValue) { t.truthy(this.page.inputPath); return false; }); @@ -150,17 +150,17 @@ test("Custom date parsing callbacks (two, last wins, return string), Issue #867" t.plan(5); let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/", { - config: eleventyConfig => { - eleventyConfig.addTemplate("test.html", `# Markdown`); - eleventyConfig.dataFilterSelectors.add("page.date"); + config: $config => { + $config.addTemplate("test.html", `# Markdown`); + $config.dataFilterSelectors.add("page.date"); - eleventyConfig.addDateParsing(function (dateValue) { + $config.addDateParsing(function (dateValue) { t.truthy(this.page.inputPath); t.is(dateValue, undefined); return "2010-01-01T12:00:00Z"; }); - eleventyConfig.addDateParsing(function (dateValue) { + $config.addDateParsing(function (dateValue) { t.truthy(this.page.inputPath); t.is(dateValue, "2010-01-01T12:00:00Z"); return "2001-01-01T12:00:00Z"; @@ -179,11 +179,11 @@ test("instanceof DateTime issue, Issue #3674", async (t) => { // this test *requires* a non-virtual template to repro let elev = new Eleventy("./test/stubs/index.html", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("test.html", `# Markdown`); - eleventyConfig.dataFilterSelectors.add("page.date"); + config: $config => { + $config.addTemplate("test.html", `# Markdown`); + $config.dataFilterSelectors.add("page.date"); - eleventyConfig.addDateParsing(function (dateValue) { + $config.addDateParsing(function (dateValue) { return DateTime.fromISO("2001-01-01T12:00:00Z"); }); } diff --git a/test/CoreTest-PageData.js b/test/CoreTest-PageData.js index ec8d767a7..60a7fd687 100644 --- a/test/CoreTest-PageData.js +++ b/test/CoreTest-PageData.js @@ -3,8 +3,8 @@ import Eleventy from "../src/Core.js"; test.skip("#3794: page.inputPathDir and page.dir", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function(eleventyConfig) { - eleventyConfig.addTemplate("test.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, {}); + config: function($config) { + $config.addTemplate("test.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, {}); } }); @@ -14,8 +14,8 @@ test.skip("#3794: page.inputPathDir and page.dir", async (t) => { test.skip("#3794: page.inputPathDir and page.dir (index file)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function(eleventyConfig) { - eleventyConfig.addTemplate("index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, {}); + config: function($config) { + $config.addTemplate("index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, {}); } }); @@ -25,8 +25,8 @@ test.skip("#3794: page.inputPathDir and page.dir (index file)", async (t) => { test.skip("#3794: page.inputPathDir and page.dir (paginated)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function(eleventyConfig) { - eleventyConfig.addTemplate("index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { + config: function($config) { + $config.addTemplate("index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { data: [1,2,3], pagination: { data: "data", @@ -47,8 +47,8 @@ test.skip("#3794: page.inputPathDir and page.dir (paginated)", async (t) => { test.skip("#3794: page.inputPathDir and page.dir (with file slug and index)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function(eleventyConfig) { - eleventyConfig.addTemplate("yawn/index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { + config: function($config) { + $config.addTemplate("yawn/index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { permalink: "{{ page.filePathStem }}.{{ page.outputFileExtension }}" }); } @@ -63,8 +63,8 @@ test.skip("#3794: page.inputPathDir and page.dir (with file slug and index)", as test.skip("#3794: page.inputPathDir and page.dir (with file slug and not-index)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function(eleventyConfig) { - eleventyConfig.addTemplate("yawn/test.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { + config: function($config) { + $config.addTemplate("yawn/test.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { permalink: "{{ page.filePathStem }}.{{ page.outputFileExtension }}" }); } @@ -79,8 +79,8 @@ test.skip("#3794: page.inputPathDir and page.dir (with file slug and not-index)" test.skip("#3794: page.inputPathDir and page.dir (paginated with file slug and not-index)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function(eleventyConfig) { - eleventyConfig.addTemplate("yawn/test.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { + config: function($config) { + $config.addTemplate("yawn/test.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { data: [1,2,3], pagination: { data: "data", @@ -102,8 +102,8 @@ test.skip("#3794: page.inputPathDir and page.dir (paginated with file slug and n test.skip("#3794: page.inputPathDir and page.dir (permalink: false)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function(eleventyConfig) { - eleventyConfig.addTemplate("index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { permalink: false }); + config: function($config) { + $config.addTemplate("index.njk", `{{ page.inputPathDir }} and {{ page.dir }}`, { permalink: false }); } }); diff --git a/test/CoreTest-Preprocessors.js b/test/CoreTest-Preprocessors.js index 7eba71b55..081ff9bdf 100644 --- a/test/CoreTest-Preprocessors.js +++ b/test/CoreTest-Preprocessors.js @@ -3,16 +3,16 @@ import Eleventy from "../src/Core.js"; test("#188: Content preprocessing (dot in file extension)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPreprocessor("drafts", ".njk", (data, content) => { + config: $config => { + $config.addPreprocessor("drafts", ".njk", (data, content) => { if(data.draft) { return false; } return `Hello ${content}`; }); - eleventyConfig.addTemplate("index.njk", "Before"); - eleventyConfig.addTemplate("draft.njk", "Before", { draft: true }); + $config.addTemplate("index.njk", "Before"); + $config.addTemplate("draft.njk", "Before", { draft: true }); } }); @@ -23,16 +23,16 @@ test("#188: Content preprocessing (dot in file extension)", async (t) => { test("#188: Content preprocessing (no dot in file extension)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPreprocessor("drafts", "njk", (data, content) => { + config: $config => { + $config.addPreprocessor("drafts", "njk", (data, content) => { if(data.draft) { return false; } return `Hello ${content}`; }); - eleventyConfig.addTemplate("index.njk", "Before"); - eleventyConfig.addTemplate("draft.njk", "Before", { draft: true }); + $config.addTemplate("index.njk", "Before"); + $config.addTemplate("draft.njk", "Before", { draft: true }); } }); @@ -44,16 +44,16 @@ test("#188: Content preprocessing (no dot in file extension)", async (t) => { test("#188: Content preprocessing (array, no dot in file extension)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPreprocessor("drafts", ["njk"], (data, content) => { + config: $config => { + $config.addPreprocessor("drafts", ["njk"], (data, content) => { if(data.draft) { return false; } return `Hello ${content}`; }); - eleventyConfig.addTemplate("index.njk", "Before"); - eleventyConfig.addTemplate("draft.njk", "Before", { draft: true }); + $config.addTemplate("index.njk", "Before"); + $config.addTemplate("draft.njk", "Before", { draft: true }); } }); @@ -64,16 +64,16 @@ test("#188: Content preprocessing (array, no dot in file extension)", async (t) test("#188: Content preprocessing (array, dot in file extension)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPreprocessor("drafts", [".njk"], (data, content) => { + config: $config => { + $config.addPreprocessor("drafts", [".njk"], (data, content) => { if(data.draft) { return false; } return `Hello ${content}`; }); - eleventyConfig.addTemplate("index.njk", "Before"); - eleventyConfig.addTemplate("draft.njk", "Before", { draft: true }); + $config.addTemplate("index.njk", "Before"); + $config.addTemplate("draft.njk", "Before", { draft: true }); } }); @@ -84,16 +84,16 @@ test("#188: Content preprocessing (array, dot in file extension)", async (t) => test("#188: Content preprocessing (wildcard)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPreprocessor("drafts", "*", (data, content) => { + config: $config => { + $config.addPreprocessor("drafts", "*", (data, content) => { if(data.draft) { return false; } return `Hello ${content}`; }); - eleventyConfig.addTemplate("index.njk", "Before"); - eleventyConfig.addTemplate("draft.njk", "Before", { draft: true }); + $config.addTemplate("index.njk", "Before"); + $config.addTemplate("draft.njk", "Before", { draft: true }); } }); @@ -107,8 +107,8 @@ test("addPreprocessor with 11ty.js, Issue #3433", async (t) => { t.plan(5); let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPreprocessor("testing", "11ty.js", (data, content) => { + config: $config => { + $config.addPreprocessor("testing", "11ty.js", (data, content) => { t.is( typeof content, "function" ); t.is(content(), "Hello!"); @@ -119,7 +119,7 @@ test("addPreprocessor with 11ty.js, Issue #3433", async (t) => { }; }); - eleventyConfig.addTemplate("template.11ty.js", function() { + $config.addTemplate("template.11ty.js", function() { return "Hello!" }); } @@ -136,13 +136,13 @@ test("addPreprocessor and addExtension, Issue #3433", async (t) => { t.plan(5); let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplateFormats("11ty.test"); - eleventyConfig.addExtension("11ty.test", { + config: $config => { + $config.addTemplateFormats("11ty.test"); + $config.addExtension("11ty.test", { key: "11ty.js", }); - eleventyConfig.addPreprocessor("testing", "11ty.test", (data, content) => { + $config.addPreprocessor("testing", "11ty.test", (data, content) => { t.is( typeof content, "function" ); t.is(content(), "Hello!"); @@ -153,7 +153,7 @@ test("addPreprocessor and addExtension, Issue #3433", async (t) => { }; }); - eleventyConfig.addTemplate("template.11ty.test", function() { + $config.addTemplate("template.11ty.test", function() { return "Hello!" }); } @@ -169,16 +169,16 @@ test("addPreprocessor and addExtension with custom `compile` (defaultRenderer), t.plan(5); let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplateFormats("11ty.test"); - eleventyConfig.addExtension("11ty.test", { + config: $config => { + $config.addTemplateFormats("11ty.test"); + $config.addExtension("11ty.test", { key: "11ty.js", compile: function() { return this.defaultRenderer; } }); - eleventyConfig.addPreprocessor("testing", "11ty.test", (data, content) => { + $config.addPreprocessor("testing", "11ty.test", (data, content) => { t.is( typeof content, "function" ); t.is(content(), "Hello!"); @@ -189,7 +189,7 @@ test("addPreprocessor and addExtension with custom `compile` (defaultRenderer), }; }); - eleventyConfig.addTemplate("template.11ty.test", function() { + $config.addTemplate("template.11ty.test", function() { return "Hello!" }); } @@ -205,9 +205,9 @@ test("addPreprocessor and addExtension with custom `compile` (re-use render func t.plan(5); let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplateFormats("11ty.test"); - eleventyConfig.addExtension("11ty.test", { + config: $config => { + $config.addTemplateFormats("11ty.test"); + $config.addExtension("11ty.test", { key: "11ty.js", compile: function(content) { return function() { @@ -216,7 +216,7 @@ test("addPreprocessor and addExtension with custom `compile` (re-use render func } }); - eleventyConfig.addPreprocessor("testing", "11ty.test", (data, content) => { + $config.addPreprocessor("testing", "11ty.test", (data, content) => { t.is( typeof content, "function" ); t.is(content(), "Hello!"); @@ -227,7 +227,7 @@ test("addPreprocessor and addExtension with custom `compile` (re-use render func }; }); - eleventyConfig.addTemplate("template.11ty.test", function() { + $config.addTemplate("template.11ty.test", function() { return "Hello!" }); } @@ -243,9 +243,9 @@ test("addPreprocessor and addExtension with custom `compile` (new render functio t.plan(7); let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplateFormats("11ty.test"); - eleventyConfig.addExtension("11ty.test", { + config: $config => { + $config.addTemplateFormats("11ty.test"); + $config.addExtension("11ty.test", { key: "11ty.js", compile: function(content) { // check preprocessor override @@ -258,7 +258,7 @@ test("addPreprocessor and addExtension with custom `compile` (new render functio } }); - eleventyConfig.addPreprocessor("testing", "11ty.test", (data, content) => { + $config.addPreprocessor("testing", "11ty.test", (data, content) => { // check template content directly t.is( typeof content, "function" ); t.is(content(), "Original template content"); @@ -270,7 +270,7 @@ test("addPreprocessor and addExtension with custom `compile` (new render functio }; }); - eleventyConfig.addTemplate("template.11ty.test", function() { + $config.addTemplate("template.11ty.test", function() { return "Original template content" }); } @@ -286,8 +286,8 @@ test("addPreprocessor and addExtension with custom `compile` (new render functio test("Tags in pages excluded with preprocessing should not populate collections props", async (t) => { let preprocessorRuns = 0; let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPreprocessor("drafts", "njk", (data, content) => { + config: $config => { + $config.addPreprocessor("drafts", "njk", (data, content) => { preprocessorRuns++; if(data.draft) { return false; @@ -295,7 +295,7 @@ test("Tags in pages excluded with preprocessing should not populate collections return `Hello ${content}`; }); - eleventyConfig.addTemplate("paged.njk", "{{ tag }}", { + $config.addTemplate("paged.njk", "{{ tag }}", { pagination: { data: "collections", size: 1, @@ -304,8 +304,8 @@ test("Tags in pages excluded with preprocessing should not populate collections }, permalink: "/{{ tag }}/" }); - eleventyConfig.addTemplate("source.njk", "Before", { tags: ["yep"] }); - eleventyConfig.addTemplate("source-draft.njk", "Before", { draft: true, tags: ["nope"] }); + $config.addTemplate("source.njk", "Before", { tags: ["yep"] }); + $config.addTemplate("source-draft.njk", "Before", { draft: true, tags: ["nope"] }); } }); @@ -325,13 +325,13 @@ test("#4292: Preprocessors should only run once per build (bug running twice dur let preprocessorRuns = 0; let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPreprocessor("drafts", ".njk", (data, content) => { + config: $config => { + $config.addPreprocessor("drafts", ".njk", (data, content) => { preprocessorRuns++; return `Hello ${content} Suffix`; }); - eleventyConfig.addTemplate("index.njk", "Before"); + $config.addTemplate("index.njk", "Before"); } }); @@ -350,8 +350,8 @@ test("#4292: Preprocessors mutable data", async (t) => { t.plan(9); let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addPreprocessor("drafts", ".njk", (data, content) => { + config: $config => { + $config.addPreprocessor("drafts", ".njk", (data, content) => { t.is(data.title, "Title"); data.title += " (draft)"; t.is(data.title, "Title (draft)"); @@ -360,7 +360,7 @@ test("#4292: Preprocessors mutable data", async (t) => { return content; }); - eleventyConfig.addTemplate("index.njk", "Hello {{title}} Suffix", { + $config.addTemplate("index.njk", "Hello {{title}} Suffix", { title: "Title" }); } diff --git a/test/CoreTest-Shortcodes.js b/test/CoreTest-Shortcodes.js index 9a80be245..2cb512ed4 100644 --- a/test/CoreTest-Shortcodes.js +++ b/test/CoreTest-Shortcodes.js @@ -4,15 +4,15 @@ import Eleventy from "../src/Core.js"; test.skip("#3400: Both a paired and unpaired shortcode.", async (t) => { let count = 0; let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function(eleventyConfig) { - eleventyConfig.addShortcode("single", function() { + config: function($config) { + $config.addShortcode("single", function() { count++; }); - eleventyConfig.addPairedShortcode("single", function() { + $config.addPairedShortcode("single", function() { count++; }); - eleventyConfig.addTemplate("test.njk", `{% single %} + $config.addTemplate("test.njk", `{% single %} {% single %}{% endsingle %}`, {}); } }); diff --git a/test/CoreTest-VirtualTemplates.js b/test/CoreTest-VirtualTemplates.js index ad7b7bca2..1e738359f 100644 --- a/test/CoreTest-VirtualTemplates.js +++ b/test/CoreTest-VirtualTemplates.js @@ -9,8 +9,8 @@ import { deleteDirectory } from "./_testHelpers.js"; test("Virtual templates, issue #1612", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `# Hello`) + config: function ($config) { + $config.addTemplate("virtual.md", `# Hello`) }, }); @@ -23,8 +23,8 @@ test("Virtual templates, issue #1612", async (t) => { test("Virtual templates with front matter, issue #1612", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("./virtual.md", `--- + config: function ($config) { + $config.addTemplate("./virtual.md", `--- myKey: myValue --- # {{ myKey }}`) @@ -40,8 +40,8 @@ myKey: myValue test("Virtual templates with supplemental data, issue #1612", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `# {{ myKey }}`, { myKey: "myValue" }) + config: function ($config) { + $config.addTemplate("virtual.md", `# {{ myKey }}`, { myKey: "myValue" }) }, }); @@ -55,8 +55,8 @@ test("Virtual templates with supplemental data, issue #1612", async (t) => { // Supplemental data overrides front matter. test("Virtual templates with front matter and supplemental data, issue #1612", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `--- + config: function ($config) { + $config.addTemplate("virtual.md", `--- myKey1: myValue1 myKey3: myValueFm --- @@ -73,8 +73,8 @@ myKey3: myValueFm test("Virtual template conflicts with file on file system, issue #1612", async (t) => { let elev = new Eleventy("./test/stubs/stubs-virtual-conflict", "./test/stubs/stubs-virtual-conflict/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `# Virtual template`) + config: function ($config) { + $config.addTemplate("virtual.md", `# Virtual template`) }, }); elev.disableLogger(); @@ -86,11 +86,11 @@ test("Virtual template conflicts with file on file system, issue #1612", async ( test("Virtual templates try to output to the same file, issue #1612", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual-one.md", "", { + config: function ($config) { + $config.addTemplate("virtual-one.md", "", { permalink: "/output.html" }) - eleventyConfig.addTemplate("virtual-two.md", "", { + $config.addTemplate("virtual-two.md", "", { permalink: "/output.html" }) }, @@ -105,8 +105,8 @@ test("Virtual templates try to output to the same file, issue #1612", async (t) // Warning: this test writes to the file system test("Virtual template writes to file system, issue #1612", async (t) => { let elev = new Eleventy("./test/stubs-virtual", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `# Hello`) + config: function ($config) { + $config.addTemplate("virtual.md", `# Hello`) }, }); elev.disableLogger(); @@ -123,9 +123,9 @@ test("Virtual template writes to file system, issue #1612", async (t) => { test("Virtual templates conflict", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `# Hello`); - eleventyConfig.addTemplate("virtual.md", `# Hello`); + config: function ($config) { + $config.addTemplate("virtual.md", `# Hello`); + $config.addTemplate("virtual.md", `# Hello`); }, }); @@ -139,10 +139,10 @@ test("Virtual templates conflict", async (t) => { // https://github.com/11ty/eleventy-plugin-rss/issues/50 test("RSS virtual templates plugin", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `# Hello`, { tag: "posts" }) + config: function ($config) { + $config.addTemplate("virtual.md", `# Hello`, { tag: "posts" }) - eleventyConfig.addPlugin(feedPlugin, { + $config.addPlugin(feedPlugin, { type: "atom", // or "rss", "json" outputPath: "/feed.xml", collection: { @@ -162,13 +162,13 @@ test("RSS virtual templates plugin", async (t) => { test("Virtual templates as layouts, issue #2307", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `# Hello`, { + config: function ($config) { + $config.addTemplate("virtual.md", `# Hello`, { layout: "virtual.html" }); - let layoutPath = eleventyConfig.directories.getLayoutPathRelativeToInputDirectory("virtual.html"); - eleventyConfig.addTemplate(layoutPath, `{{ content }}`); + let layoutPath = $config.directories.getLayoutPathRelativeToInputDirectory("virtual.html"); + $config.addTemplate(layoutPath, `{{ content }}`); }, }); @@ -190,8 +190,8 @@ test("11ty.js Virtual Templates (object), issue #3347", async (t) => { }; let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.11ty.js", templateDefinition); + config: function ($config) { + $config.addTemplate("virtual.11ty.js", templateDefinition); } }); @@ -210,8 +210,8 @@ test("11ty.js Virtual Templates (function), issue #3347", async (t) => { }; let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.11ty.js", templateDefinition); + config: function ($config) { + $config.addTemplate("virtual.11ty.js", templateDefinition); } }); @@ -226,8 +226,8 @@ test("11ty.js Virtual Templates (function), issue #3347", async (t) => { test("11ty.js class templates with invalid signature, issue #1645", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.11ty.js", class {}); + config: function ($config) { + $config.addTemplate("virtual.11ty.js", class {}); } }); elev.disableLogger(); @@ -239,8 +239,8 @@ test("11ty.js class templates with invalid signature, issue #1645", async (t) => test("11ty.js class templates with instance properties (data), issue #1645", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.11ty.js", class { data() { return {} } }); + config: function ($config) { + $config.addTemplate("virtual.11ty.js", class { data() { return {} } }); } }); @@ -252,8 +252,8 @@ test("11ty.js class templates with instance properties (data), issue #1645", asy test("11ty.js class templates with instance properties (render), issue #1645", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.11ty.js", class { render() { return "Hello!" } }); + config: function ($config) { + $config.addTemplate("virtual.11ty.js", class { render() { return "Hello!" } }); } }); @@ -265,8 +265,8 @@ test("11ty.js class templates with instance properties (render), issue #1645", a test("11ty.js class templates with instance properties (data and render), issue #1645", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.11ty.js", class { + config: function ($config) { + $config.addTemplate("virtual.11ty.js", class { data() { return { key: "world" }; } render(data) { return `Hello ${data.key}!` } }); @@ -281,8 +281,8 @@ test("11ty.js class templates with instance properties (data and render), issue test("11ty.js class templates with instance properties (data and render arrows), issue #1645", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.11ty.js", class { + config: function ($config) { + $config.addTemplate("virtual.11ty.js", class { data = () => { return { key: "world" }; } render = (data) => { return `Hello ${data.key}!` } }); @@ -297,8 +297,8 @@ test("11ty.js class templates with instance properties (data and render arrows), test("11ty.js class templates with instance properties (data and render arrows, new), issue #1645", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.11ty.js", new class { + config: function ($config) { + $config.addTemplate("virtual.11ty.js", new class { data = () => { return { key: "world" }; } render = (data) => { return `Hello ${data.key}!` } }); @@ -322,8 +322,8 @@ test("server.js Virtual Templates (object)", async (t) => { }; let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.server.js", templateDefinition); + config: function ($config) { + $config.addTemplate("virtual.server.js", templateDefinition); } }); diff --git a/test/CoreTest.js b/test/CoreTest.js index 956dcbc9f..403a717f5 100644 --- a/test/CoreTest.js +++ b/test/CoreTest.js @@ -23,11 +23,11 @@ const lodashGet = lodash.get; test("Eleventy, defaults inherit from config", async (t) => { let elev = new Eleventy(); - let eleventyConfig = new TemplateConfig(); - await eleventyConfig.init(); + let $config = new TemplateConfig(); + await $config.init(); await elev.initializeConfig(); - let config = eleventyConfig.getConfig(); + let config = $config.getConfig(); t.truthy(elev.input); t.truthy(elev.outputDir); @@ -40,11 +40,11 @@ test("Eleventy, defaults inherit from config", async (t) => { test("Eleventy, null output directory should default to _site", async (t) => { let elev = new Eleventy(".", null); - let eleventyConfig = new TemplateConfig(); - await eleventyConfig.init(); + let $config = new TemplateConfig(); + await $config.init(); await elev.initializeConfig(); - let config = eleventyConfig.getConfig(); + let config = $config.getConfig(); t.is(config.dir.input, "."); t.is(elev.input, "./"); @@ -172,8 +172,8 @@ test("Eleventy file watching (don’t watch deps of passthrough copy .js files)" test("Eleventy file watching (no JS dependencies)", async (t) => { let elev = new Eleventy("./test/stubs", "./test/stubs/_site", { - config: eleventyConfig => { - eleventyConfig.setWatchJavaScriptDependencies(false); + config: $config => { + $config.setWatchJavaScriptDependencies(false); } }); elev.setFormats("njk"); @@ -463,8 +463,8 @@ test("Pagination over collection using eleventyComputed (liquid)", async (t) => "./test/stubs-pagination-computed-quotes/", "./test/stubs-pagination-computed-quotes/_site", { - config: function (eleventyConfig) { - eleventyConfig.addFilter("selectRandomFromArray", (arr) => { + config: function ($config) { + $config.addFilter("selectRandomFromArray", (arr) => { t.true(Array.isArray(arr)); t.deepEqual(arr, ["The person that shared this is awesome"]); return arr[0]; @@ -486,8 +486,8 @@ test("Pagination over collection using eleventyComputed (njk)", async (t) => { "./test/stubs-pagination-computed-quotes-njk/", "./test/stubs-pagination-computed-quotes-njk/_site", { - config: function (eleventyConfig) { - eleventyConfig.addFilter("selectRandomFromArray", (arr) => { + config: function ($config) { + $config.addFilter("selectRandomFromArray", (arr) => { t.true(Array.isArray(arr)); t.deepEqual(arr, ["The person that shared this is awesome"]); return arr[0]; @@ -508,7 +508,7 @@ test("Paginated template uses proxy and global data", async (t) => { "./test/proxy-pagination-globaldata/", "./test/proxy-pagination-globaldata/_site", { - config: function (eleventyConfig) {}, + config: function ($config) {}, } ); @@ -523,8 +523,8 @@ test("Liquid shortcode with multiple arguments(issue #2348)", async (t) => { // NOTE issue #2348 was only active when you were processing multiple templates at the same time. let elev = new Eleventy("./test/stubs-2367/", "./test/stubs-2367/_site", { - config: function (eleventyConfig) { - eleventyConfig.addShortcode("simplelink", function (...args) { + config: function ($config) { + $config.addShortcode("simplelink", function (...args) { return JSON.stringify(args); }); }, @@ -559,7 +559,7 @@ test("git getCreatedTimestamp returns undefined on nonexistent path", async (t) test("Does pathPrefix affect page URLs", async (t) => { let elev = new Eleventy("./README.md", "./_site", { - config: function (eleventyConfig) { + config: function ($config) { return { pathPrefix: "/testdirectory/", }; @@ -669,8 +669,8 @@ test("Lodash get (for pagination data target) object key with spaces, issue #285 test("Eleventy tag collection with spaces in the tag name, issue #2851", async (t) => { let elev = new Eleventy("./test/stubs-2851", "./test/stubs-2851/_site", { - config: function (eleventyConfig) { - eleventyConfig.dataFilterSelectors.add("collections"); + config: function ($config) { + $config.dataFilterSelectors.add("collections"); }, }); elev.setIsVerbose(false); @@ -685,8 +685,8 @@ test("this.eleventy on JavaScript template functions, issue #2790", async (t) => t.plan(3); let elev = new Eleventy("./test/stubs-2790", "./test/stubs-2790/_site", { - config: function (eleventyConfig) { - eleventyConfig.addJavaScriptFunction("jsfunction", function () { + config: function ($config) { + $config.addJavaScriptFunction("jsfunction", function () { t.truthy(this.eleventy); return this.eleventy.generator.split(" ")[0]; }); @@ -699,7 +699,7 @@ test("this.eleventy on JavaScript template functions, issue #2790", async (t) => test("Global data JS files should only execute once, issue #2753", async (t) => { let elev = new Eleventy("./test/stubs-2753", "./test/stubs-2753/_site", { - config: function (eleventyConfig) {}, + config: function ($config) {}, }); let result = await elev.toJSON(); t.deepEqual(result.length, 2); @@ -721,7 +721,7 @@ function sortResultsBy(results, key = "content") { test("Access to raw input of file (toJSON), issue #1206", async (t) => { let elev = new Eleventy("./test/stubs-1206", "./test/stubs-1206/_site", { - config: function (eleventyConfig) {}, + config: function ($config) {}, }); let results = await elev.toJSON(); sortResultsBy(results, "content"); @@ -736,7 +736,7 @@ test("Access to raw input of file (toJSON), issue #1206", async (t) => { // Warning: this test writes to the file system test("Access to raw input of file (dryRun), issue #1206", async (t) => { let elev = new Eleventy("./test/stubs-1206", "./test/stubs-1206/_site", { - config: function (eleventyConfig) {}, + config: function ($config) {}, }); elev.disableLogger(); @@ -755,23 +755,23 @@ test("Access to raw input of file (dryRun), issue #1206", async (t) => { test("{eleventy,buildawesome}.before and {eleventy,buildawesome}.after Event Arguments, directories", async (t) => { t.plan(12); let elev = new Eleventy("./test/noop/", "./test/noop/_site", { - config: function (eleventyConfig) { - eleventyConfig.on("eleventy.before", arg => { + config: function ($config) { + $config.on("eleventy.before", arg => { t.is(arg.inputDir, "./test/noop/"); t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/_includes/"); }) - eleventyConfig.on("buildawesome.before", arg => { + $config.on("buildawesome.before", arg => { t.is(arg.inputDir, "./test/noop/"); t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/_includes/"); }) - eleventyConfig.on("eleventy.after", arg => { + $config.on("eleventy.after", arg => { t.is(arg.inputDir, "./test/noop/"); t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/_includes/"); }) - eleventyConfig.on("buildawesome.after", arg => { + $config.on("buildawesome.after", arg => { t.is(arg.inputDir, "./test/noop/"); t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/_includes/"); @@ -812,10 +812,10 @@ test("buildawesome.after fires sequentially setting eventEmitterMode 'sequential test("setInputDirectory config method #1503", async (t) => { t.plan(5); let elev = new Eleventy("./test/noop/", "./test/noop/_site", { - config: function (eleventyConfig) { - eleventyConfig.setInputDirectory("./test/noop2/"); + config: function ($config) { + $config.setInputDirectory("./test/noop2/"); - eleventyConfig.on("buildawesome.before", arg => { + $config.on("buildawesome.before", arg => { t.is(arg.directories.input, "./test/noop2/"); t.is(arg.directories.includes, "./test/noop2/_includes/"); t.is(arg.directories.data, "./test/noop2/_data/"); @@ -831,10 +831,10 @@ test("setInputDirectory config method #1503", async (t) => { test("setIncludesDirectory config method #1503", async (t) => { t.plan(5); let elev = new Eleventy("./test/noop/", "./test/noop/_site", { - config: function (eleventyConfig) { - eleventyConfig.setIncludesDirectory("myincludes"); + config: function ($config) { + $config.setIncludesDirectory("myincludes"); - eleventyConfig.on("buildawesome.before", arg => { + $config.on("buildawesome.before", arg => { t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/myincludes/"); t.is(arg.directories.data, "./test/noop/_data/"); @@ -850,10 +850,10 @@ test("setIncludesDirectory config method #1503", async (t) => { test("setDataDirectory config method #1503", async (t) => { t.plan(5); let elev = new Eleventy("./test/noop/", "./test/noop/_site", { - config: function (eleventyConfig) { - eleventyConfig.setDataDirectory("data"); + config: function ($config) { + $config.setDataDirectory("data"); - eleventyConfig.on("buildawesome.before", arg => { + $config.on("buildawesome.before", arg => { t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/_includes/"); t.is(arg.directories.data, "./test/noop/data/"); @@ -869,10 +869,10 @@ test("setDataDirectory config method #1503", async (t) => { test("setLayoutsDirectory config method #1503", async (t) => { t.plan(5); let elev = new Eleventy("./test/noop/", "./test/noop/_site", { - config: function (eleventyConfig) { - eleventyConfig.setLayoutsDirectory("layouts"); + config: function ($config) { + $config.setLayoutsDirectory("layouts"); - eleventyConfig.on("buildawesome.before", arg => { + $config.on("buildawesome.before", arg => { t.is(arg.directories.input, "./test/noop/"); t.is(arg.directories.includes, "./test/noop/_includes/"); t.is(arg.directories.data, "./test/noop/_data/"); @@ -887,9 +887,9 @@ test("setLayoutsDirectory config method #1503", async (t) => { test("setInputDirectory config method #1503 in a plugin throws error", async (t) => { let elev = new Eleventy("./test/noop/", "./test/noop/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(() => { - eleventyConfig.setInputDirectory("./test/noop2/"); + config: function ($config) { + $config.addPlugin(() => { + $config.setInputDirectory("./test/noop2/"); }); }, }); @@ -929,8 +929,8 @@ test("Accepts absolute paths urls for input and output and a virtual template, r let input = path.resolve("./test/noop/"); let output = path.resolve("./test/noop/_site"); let elev = new Eleventy(input, output, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.md", `# Title`) + config: $config => { + $config.addTemplate("index.md", `# Title`) } }); @@ -1443,16 +1443,16 @@ test("Custom Nunjucks syntax has shortcode with access to `this`, Issue #3310", test("Related to issue 3206: Does Nunjucks throwOnUndefined variables require normalizeContext to be a lazy get", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addShortcode("customized", function(argString) { + config: $config => { + $config.addShortcode("customized", function(argString) { return `${this.page.url}:Custom Shortcode`; }); - eleventyConfig.setNunjucksEnvironmentOptions({ + $config.setNunjucksEnvironmentOptions({ throwOnUndefined: true, }); - eleventyConfig.addTemplate("index.html", `HELLO{% customized %}:{{ page.url }}`); + $config.addTemplate("index.html", `HELLO{% customized %}:{{ page.url }}`); } }); @@ -1463,8 +1463,8 @@ test("Related to issue 3206: Does Nunjucks throwOnUndefined variables require no test("#727: Error messaging when trying to use a missing layout", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", `HELLO {{ page.url }}`, { + config: $config => { + $config.addTemplate("index.html", `HELLO {{ page.url }}`, { layout: "does-not-exist.html", }); } @@ -1478,9 +1478,9 @@ test("#727: Error messaging when trying to use a missing layout", async (t) => { test("#1419: Shortcode in a permalink", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addShortcode("shortcode", () => "url-slug"); - eleventyConfig.addTemplate("index.njk", "", { + config: $config => { + $config.addShortcode("shortcode", () => "url-slug"); + $config.addTemplate("index.njk", "", { permalink: "/{% shortcode %}/", }); } @@ -1518,9 +1518,9 @@ test("Eleventy loader can force CommonJS mode", async (t) => { test("Truthy outputPath without a file extension now throws an error, issue #3399", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - // eleventyConfig.configureErrorReporting({ allowMissingExtensions: true }); - eleventyConfig.addTemplate("index.html", "", { permalink: "foo" }) + config: function ($config) { + // $config.configureErrorReporting({ allowMissingExtensions: true }); + $config.addTemplate("index.html", "", { permalink: "foo" }) }, }); elev.disableLogger(); @@ -1533,15 +1533,15 @@ You *probably* want to add a file extension to your permalink so that hosts will Learn more: https://v3.11ty.dev/docs/permalinks/#trailing-slashes -This is usually but not *always* an error so if you’d like to disable this error message, add \`eleventyAllowMissingExtension: true\` somewhere in the data cascade for this template or use \`eleventyConfig.configureErrorReporting({ allowMissingExtensions: true });\` to disable this feature globally.` +This is usually but not *always* an error so if you’d like to disable this error message, add \`eleventyAllowMissingExtension: true\` somewhere in the data cascade for this template or use \`$config.configureErrorReporting({ allowMissingExtensions: true });\` to disable this feature globally.` }); }); test("Truthy outputPath without a file extension can be ignored, issue #3399", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - // eleventyConfig.configureErrorReporting({ allowMissingExtensions: true }); - eleventyConfig.addTemplate("index.html", "", { permalink: "foo", eleventyAllowMissingExtension: true }) + config: function ($config) { + // $config.configureErrorReporting({ allowMissingExtensions: true }); + $config.addTemplate("index.html", "", { permalink: "foo", eleventyAllowMissingExtension: true }) }, }); elev.disableLogger(); @@ -1554,8 +1554,8 @@ test("Truthy outputPath without a file extension can be ignored, issue #3399", a test("Allow list for some file types without a file extension, issue #3399", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("index.html", "", { permalink: "/test/_redirects" }) + config: function ($config) { + $config.addTemplate("index.html", "", { permalink: "/test/_redirects" }) }, }); elev.disableLogger(); @@ -1567,9 +1567,9 @@ test("Allow list for some file types without a file extension, issue #3399", asy test("Truthy outputPath without a file extension error message is disabled, issue #3399", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.configureErrorReporting({ allowMissingExtensions: true }); - eleventyConfig.addTemplate("index.html", "", { permalink: "foo" }) + config: function ($config) { + $config.configureErrorReporting({ allowMissingExtensions: true }); + $config.addTemplate("index.html", "", { permalink: "foo" }) }, }); elev.disableLogger(); @@ -1580,8 +1580,8 @@ test("Truthy outputPath without a file extension error message is disabled, issu test("permalink: false outputPath new error message won’t throw an error, issue #3399", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("index.html", "", { permalink: false }) + config: function ($config) { + $config.addTemplate("index.html", "", { permalink: false }) }, }); elev.disableLogger(); @@ -1592,15 +1592,15 @@ test("permalink: false outputPath new error message won’t throw an error, issu test("permalink on custom template lang, issue #3619", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.addGlobalData("permalink", () => { + config: function ($config) { + $config.addGlobalData("permalink", () => { return (data) => `/rewrite/${data.page.filePathStem}.${data.page.outputFileExtension}`; }); - eleventyConfig.addTemplateFormats("scss"); + $config.addTemplateFormats("scss"); - eleventyConfig.addExtension("scss", { + $config.addExtension("scss", { outputFileExtension: "css", compileOptions: { permalink(inputContent, inputPath) { @@ -1631,7 +1631,7 @@ test("permalink on custom template lang, issue #3619", async (t) => { }, }); - eleventyConfig.addTemplate("index.scss", `html { + $config.addTemplate("index.scss", `html { color: red; }`) }, @@ -1647,8 +1647,8 @@ test("permalink on custom template lang, issue #3619", async (t) => { test("Template data throws error when tags is not an Array or String #1791", async (t) => { let elev = new Eleventy("./test/noop/", "./test/noop/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("index.html", "", { + config: function ($config) { + $config.addTemplate("index.html", "", { tags: {"one": 1, "two": 2} }); }, @@ -1663,10 +1663,10 @@ test("Template data throws error when tags is not an Array or String #1791", asy test("sass docs on 11ty.dev, issue #408", async (t) => { let elev = new Eleventy("./test/stubs-408-sass/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.addTemplateFormats("scss"); + config: function ($config) { + $config.addTemplateFormats("scss"); - eleventyConfig.addExtension("scss", { + $config.addExtension("scss", { outputFileExtension: "css", // opt-out of Eleventy Layouts @@ -1717,9 +1717,9 @@ test("sass docs on 11ty.dev, issue #408", async (t) => { test("Use a date object for `date`, issue #3022", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.dataFilterSelectors.add("page.date"); - eleventyConfig.addTemplate("index.html", "", { date: new Date() }) + config: function ($config) { + $config.dataFilterSelectors.add("page.date"); + $config.addTemplate("index.html", "", { date: new Date() }) }, }); elev.disableLogger(); @@ -1731,9 +1731,9 @@ test("Use a date object for `date`, issue #3022", async (t) => { test("Use a date object for `date` (js object front matter), issue #3022", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.dataFilterSelectors.add("page.date"); - eleventyConfig.addTemplate("index.html", `---js + config: function ($config) { + $config.dataFilterSelectors.add("page.date"); + $config.addTemplate("index.html", `---js { date: new Date(), } @@ -1749,9 +1749,9 @@ test("Use a date object for `date` (js object front matter), issue #3022", async test("Use a date object for `date` (js front matter), issue #3022", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.dataFilterSelectors.add("page.date"); - eleventyConfig.addTemplate("index.html", `---js + config: function ($config) { + $config.dataFilterSelectors.add("page.date"); + $config.addTemplate("index.html", `---js let date = new Date(); ---`); }, @@ -1766,8 +1766,8 @@ let date = new Date(); test("Cleaner constructor args #3880", async (t) => { let elev = new Eleventy({ input: "./test/stubs-virtual/", - config: eleventyConfig => { - eleventyConfig.addTemplate("index.md", `# Title`) + config: $config => { + $config.addTemplate("index.md", `# Title`) } }); diff --git a/test/EleventyAddGlobalDataTest.js b/test/EleventyAddGlobalDataTest.js index 4f339ce54..04825c39b 100644 --- a/test/EleventyAddGlobalDataTest.js +++ b/test/EleventyAddGlobalDataTest.js @@ -4,8 +4,8 @@ import Eleventy from "../src/Core.js"; test("Eleventy addGlobalData should run once", async (t) => { let count = 0; let elev = new Eleventy("./test/stubs-addglobaldata/", "./test/stubs-addglobaldata/_site", { - config: function (eleventyConfig) { - eleventyConfig.addGlobalData("count", () => { + config: function ($config) { + $config.addGlobalData("count", () => { count++; return count; }); @@ -22,8 +22,8 @@ test("Eleventy addGlobalData shouldn’t run if no input templates match!", asyn "./test/stubs-addglobaldata-noop/", "./test/stubs-addglobaldata-noop/_site", { - config: function (eleventyConfig) { - eleventyConfig.addGlobalData("count", () => { + config: function ($config) { + $config.addGlobalData("count", () => { count++; return count; }); @@ -37,9 +37,9 @@ test("Eleventy addGlobalData shouldn’t run if no input templates match!", asyn test("Eleventy addGlobalData can feed layouts to populate data cascade with layout data, issue #1245", async (t) => { let elev = new Eleventy("./test/stubs-2145/", "./test/stubs-2145/_site", { - config: function (eleventyConfig) { - eleventyConfig.addGlobalData("layout", () => "layout.njk"); - eleventyConfig.dataFilterSelectors.add("LayoutData"); + config: function ($config) { + $config.addGlobalData("layout", () => "layout.njk"); + $config.dataFilterSelectors.add("LayoutData"); }, }); @@ -50,20 +50,20 @@ test("Eleventy addGlobalData can feed layouts to populate data cascade with layo test("Eleventy addGlobalData merge data #3389", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.addGlobalData("eleventyComputed", { + config: function ($config) { + $config.addGlobalData("eleventyComputed", { testing(data) { return `testing:${data.page.url}`; } }); - eleventyConfig.addGlobalData("eleventyComputed", { + $config.addGlobalData("eleventyComputed", { other(data) { return `other:${data.page.url}`; } }); - eleventyConfig.addTemplate("computed.njk", "{{ testing }}|{{ other }}", {}) + $config.addTemplate("computed.njk", "{{ testing }}|{{ other }}", {}) }, }); @@ -74,20 +74,20 @@ test("Eleventy addGlobalData merge data #3389", async (t) => { test("Eleventy addGlobalData merge data #3389 lodash set", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.addGlobalData("eleventyComputed.testing", () => { + config: function ($config) { + $config.addGlobalData("eleventyComputed.testing", () => { return (data) => { return `testing:${data.page.url}`; } }); - eleventyConfig.addGlobalData("eleventyComputed.other", () => { + $config.addGlobalData("eleventyComputed.other", () => { return (data) => { return `other:${data.page.url}`; } }); - eleventyConfig.addTemplate("computed.njk", "{{ testing }}|{{ other }}", {}) + $config.addTemplate("computed.njk", "{{ testing }}|{{ other }}", {}) }, }); @@ -98,16 +98,16 @@ test("Eleventy addGlobalData merge data #3389 lodash set", async (t) => { test.skip("Eleventy addGlobalData merge data #3389 no nested function", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: function (eleventyConfig) { - eleventyConfig.addGlobalData("eleventyComputed.testing", (data) => { + config: function ($config) { + $config.addGlobalData("eleventyComputed.testing", (data) => { return `testing:${data.page.url}`; }); - eleventyConfig.addGlobalData("eleventyComputed.other", (data) => { + $config.addGlobalData("eleventyComputed.other", (data) => { return `other:${data.page.url}`; }); - eleventyConfig.addTemplate("computed.njk", "{{ testing }}|{{ other }}", {}) + $config.addTemplate("computed.njk", "{{ testing }}|{{ other }}", {}) }, }); diff --git a/test/EleventyImgTransformTest.js b/test/EleventyImgTransformTest.js index 68e9c7629..6e7f99827 100644 --- a/test/EleventyImgTransformTest.js +++ b/test/EleventyImgTransformTest.js @@ -5,8 +5,8 @@ import { normalizeNewLines } from "./Util/normalizeNewLines.js"; test("Default image transform with a single image", async (t) => { let elev = new Eleventy("./test/stubs-img-transform/single.md", "./test/stubs-img-transform/_site", { - config: eleventyConfig => { - eleventyConfig.addPlugin(eleventyImageTransformPlugin, { + config: $config => { + $config.addPlugin(eleventyImageTransformPlugin, { extensions: "html", dryRun: true, formats: ["auto"], @@ -24,8 +24,8 @@ test("Default image transform with a single image", async (t) => { test("Default image transform with multiple images", async (t) => { let elev = new Eleventy("./test/stubs-img-transform/multiple.md", "./test/stubs-img-transform/_site", { - config: eleventyConfig => { - eleventyConfig.addPlugin(eleventyImageTransformPlugin, { + config: $config => { + $config.addPlugin(eleventyImageTransformPlugin, { extensions: "html", dryRun: true, formats: ["auto"], @@ -44,8 +44,8 @@ test("Default image transform with multiple images", async (t) => { test("Default image transform with an ignored image", async (t) => { let elev = new Eleventy("./test/stubs-img-transform/ignored.md", "./test/stubs-img-transform/_site", { - config: eleventyConfig => { - eleventyConfig.addPlugin(eleventyImageTransformPlugin, { + config: $config => { + $config.addPlugin(eleventyImageTransformPlugin, { extensions: "html", dryRun: true, formats: ["auto"], @@ -63,8 +63,8 @@ test("Default image transform with an ignored image", async (t) => { test("Missing alt", async (t) => { let elev = new Eleventy("./test/stubs-img-transform/missing-alt.md", "./test/stubs-img-transform/_site", { - config: eleventyConfig => { - eleventyConfig.addPlugin(eleventyImageTransformPlugin, { + config: $config => { + $config.addPlugin(eleventyImageTransformPlugin, { extensions: "html", dryRun: true, formats: ["auto"], diff --git a/test/EleventyMarkdownTest.js b/test/EleventyMarkdownTest.js index 699ee45d9..512a7a80c 100644 --- a/test/EleventyMarkdownTest.js +++ b/test/EleventyMarkdownTest.js @@ -4,9 +4,9 @@ import Eleventy from "../src/Core.js"; test("Markdown in markdown #3954", async (t) => { let elev = new Eleventy({ input: "./test/stubs-virtual/", - config: eleventyConfig => { - eleventyConfig.addTemplate("_includes/layout.md", `{{ content }}`); - eleventyConfig.addTemplate("index.md", `--- + config: $config => { + $config.addTemplate("_includes/layout.md", `{{ content }}`); + $config.addTemplate("index.md", `--- layout: layout.md --- # Heading @@ -32,9 +32,9 @@ layout: layout.md test("Preprocess Markdown with markdown #3925", async (t) => { let elev = new Eleventy({ input: "./test/stubs-virtual/", - config: eleventyConfig => { - eleventyConfig.setMarkdownTemplateEngine("md"); - eleventyConfig.addTemplate("index.md", `# Heading + config: $config => { + $config.setMarkdownTemplateEngine("md"); + $config.addTemplate("index.md", `# Heading \`\`\` # This is code diff --git a/test/FilesGitIgnoreEleventyIgnoreTest.js b/test/FilesGitIgnoreEleventyIgnoreTest.js index f98982823..bbccb9e60 100644 --- a/test/FilesGitIgnoreEleventyIgnoreTest.js +++ b/test/FilesGitIgnoreEleventyIgnoreTest.js @@ -6,14 +6,14 @@ import { getTemplateConfigInstance, getTemplateConfigInstanceCustomCallback, get /* .eleventyignore and .gitignore combos */ test("Get ignores (no .eleventyignore no .gitignore)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs/ignore1", output: "test/stubs/ignore1/_site" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf._setLocalPathRoot("./test/stubs/ignorelocalroot"); t.deepEqual(evf.getIgnores(), [ @@ -28,14 +28,14 @@ test("Get ignores (no .eleventyignore no .gitignore)", async (t) => { }); test("Get ignores (no .eleventyignore)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs/ignore2", output: "test/stubs/ignore2/_site" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf._setLocalPathRoot("./test/stubs/ignorelocalrootgitignore"); t.deepEqual(evf.getIgnores(), [ @@ -51,14 +51,14 @@ test("Get ignores (no .eleventyignore)", async (t) => { }); test("Get ignores (no .eleventyignore, using setUseGitIgnore(false))", async (t) => { - let eleventyConfig = await getTemplateConfigInstanceCustomCallback({ + let $config = await getTemplateConfigInstanceCustomCallback({ input: "test/stubs/ignore2", output: "test/stubs/ignore2/_site", - }, function(eleventyConfig) { - eleventyConfig.setUseGitIgnore(false); + }, function($config) { + $config.setUseGitIgnore(false); }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf._setLocalPathRoot("./test/stubs/ignorelocalroot"); t.deepEqual(evf.getIgnores(), [ @@ -73,14 +73,14 @@ test("Get ignores (no .eleventyignore, using setUseGitIgnore(false))", async (t) }); test("Get ignores (no .gitignore)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs/ignore3", output: "test/stubs/ignore3/_site" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf._setLocalPathRoot("./test/stubs/ignorelocalroot"); t.deepEqual(evf.getIgnores(), [ @@ -97,14 +97,14 @@ test("Get ignores (no .gitignore)", async (t) => { }); test("Get ignores (project .eleventyignore and root .gitignore)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs/ignore4", output: "test/stubs/ignore4/_site" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf._setLocalPathRoot("./test/stubs/ignorelocalrootgitignore"); t.deepEqual(evf.getIgnores(), [ @@ -122,14 +122,14 @@ test("Get ignores (project .eleventyignore and root .gitignore)", async (t) => { }); test("Get ignores (project .eleventyignore and root .gitignore, using setUseGitIgnore(false))", async (t) => { - let eleventyConfig = await getTemplateConfigInstanceCustomCallback({ + let $config = await getTemplateConfigInstanceCustomCallback({ input: "test/stubs/ignore4", output: "test/stubs/ignore4/_site", - }, function(eleventyConfig) { - eleventyConfig.setUseGitIgnore(false); + }, function($config) { + $config.setUseGitIgnore(false); }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf._setLocalPathRoot("./test/stubs/ignorelocalrootgitignore"); @@ -147,14 +147,14 @@ test("Get ignores (project .eleventyignore and root .gitignore, using setUseGitI }); test("Get ignores (no .eleventyignore .gitignore exists but empty)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs/ignore5", output: "test/stubs/ignore5/_site" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf._setLocalPathRoot("./test/stubs/ignorelocalroot"); @@ -170,14 +170,14 @@ test("Get ignores (no .eleventyignore .gitignore exists but empty)", async (t) }); test("Get ignores (both .eleventyignore and .gitignore exists, but .gitignore is empty)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs/ignore6", output: "test/stubs/ignore6/_site" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf._setLocalPathRoot("./test/stubs/ignorelocalroot"); t.deepEqual(evf.getIgnores(), [ @@ -194,16 +194,16 @@ test("Get ignores (both .eleventyignore and .gitignore exists, but .gitignore is }); test("Bad expected output, this indicates a bug upstream in a dependency (update, was fixed in fast-glob@3.3.3). Input to 'src' and empty includes dir (issue #403, full paths in eleventyignore)", async (t) => { - let eleventyConfig = await getTemplateConfigInstanceCustomCallback({ + let $config = await getTemplateConfigInstanceCustomCallback({ input: "test/stubs-403", output: "_site", includes: "", data: false, - }, function(eleventyConfig) { - eleventyConfig.setUseGitIgnore(false); + }, function($config) { + $config.setUseGitIgnore(false); }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid"], $config); evf._setEleventyIgnoreContent(TemplatePath.absolutePath("test/stubs-403/_includes") + "/**"); evf.init(); // duplicate init @@ -216,16 +216,16 @@ test("Bad expected output, this indicates a bug upstream in a dependency (update }); test("Workaround for Bad expected output, this indicates a bug upstream in a dependency. Input to 'src' and empty includes dir (issue #403, full paths in eleventyignore)", async (t) => { - let eleventyConfig = await getTemplateConfigInstanceCustomCallback({ + let $config = await getTemplateConfigInstanceCustomCallback({ input: "test/stubs-403", output: "_site", includes: "", data: false, - }, function(eleventyConfig) { - eleventyConfig.setUseGitIgnore(false); + }, function($config) { + $config.setUseGitIgnore(false); }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid"], $config); evf._setEleventyIgnoreContent("./test/stubs-403/_includes/**"); evf.init(); // duplicate init @@ -233,16 +233,16 @@ test("Workaround for Bad expected output, this indicates a bug upstream in a dep }); test("Issue #403: all .eleventyignores should be relative paths not absolute paths", async (t) => { - let eleventyConfig = await getTemplateConfigInstanceCustomCallback({ + let $config = await getTemplateConfigInstanceCustomCallback({ input: "test/stubs-403", output: "_site", includes: "", data: false, - }, function(eleventyConfig) { - eleventyConfig.setUseGitIgnore(false); + }, function($config) { + $config.setUseGitIgnore(false); }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid"], $config); let globs = await evf.getFileGlobs(); t.is( @@ -254,14 +254,14 @@ test("Issue #403: all .eleventyignores should be relative paths not absolute pat }); test("Same input and output directories, issues #186 and #1129", async (t) => { - let eleventyConfig = await getTemplateConfigInstanceCustomCallback({ + let $config = await getTemplateConfigInstanceCustomCallback({ input: "test/stubs", output: "", - }, function(eleventyConfig) { - eleventyConfig.setUseGitIgnore(false); + }, function($config) { + $config.setUseGitIgnore(false); }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); t.deepEqual( evf.getIgnores().filter((entry) => entry.indexOf("_site") > -1), @@ -270,15 +270,15 @@ test("Same input and output directories, issues #186 and #1129", async (t) => { }); test("Single input file is in the output directory, issues #186", async (t) => { - let eleventyConfig = await getTemplateConfigInstanceCustomCallback({ + let $config = await getTemplateConfigInstanceCustomCallback({ input: "test/stubs", output: "", includes: "", - }, function(eleventyConfig) { - eleventyConfig.setUseGitIgnore(false); + }, function($config) { + $config.setUseGitIgnore(false); }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["njk"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["njk"], $config); t.deepEqual( evf.getIgnores().filter((entry) => entry.indexOf("_site") > -1), @@ -287,14 +287,14 @@ test("Single input file is in the output directory, issues #186", async (t) => { }); test("De-duplicated ignores", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs/ignore-dedupe", output: "test/stubs/ignore-dedupe/_site" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf._setLocalPathRoot("./test/stubs/ignore-dedupe"); diff --git a/test/FilesTest.js b/test/FilesTest.js index 1e8aeeb8d..4504fb092 100644 --- a/test/FilesTest.js +++ b/test/FilesTest.js @@ -9,7 +9,7 @@ import { isTypeScriptSupported } from "../src/Util/TypeScriptFeatureTest.cjs"; import { getTemplateConfigInstance, getTemplateConfigInstanceCustomCallback, getEleventyFilesInstance } from "./_testHelpers.js"; test("Dirs paths", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "src", includes: "includes", @@ -18,7 +18,7 @@ test("Dirs paths", async (t) => { } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); t.deepEqual(evf.inputDir, "./src/"); t.deepEqual(evf.includesDir, "./src/includes/"); @@ -27,7 +27,7 @@ test("Dirs paths", async (t) => { }); test("Dirs paths (relative)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "src", includes: "../includes", @@ -36,7 +36,7 @@ test("Dirs paths (relative)", async (t) => { }, }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); t.deepEqual(evf.inputDir, "./src/"); t.deepEqual(evf.includesDir, "./includes/"); @@ -45,49 +45,49 @@ test("Dirs paths (relative)", async (t) => { }); test("getFiles", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./test/stubs/writeTest", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md"], $config); t.deepEqual(await evf.getFiles(), ["./test/stubs/writeTest/test.md"]); }); test("getFiles (without 11ty.js)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./test/stubs/writeTestJS" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md"], $config); t.deepEqual(await evf.getFiles(), []); }); test("getFiles (with 11ty.js)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./test/stubs/writeTestJS", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md", "11ty.js"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md", "11ty.js"], $config); t.deepEqual(await evf.getFiles(), ["./test/stubs/writeTestJS/test.11ty.cjs"]); }); test("getFiles (with js, treated as passthrough copy)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./test/stubs/writeTestJS-passthrough", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md", "js", "11ty.js"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md", "js", "11ty.js"], $config); const files = await evf.getFiles(); t.deepEqual( @@ -103,13 +103,13 @@ test("getFiles (with js, treated as passthrough copy)", async (t) => { }); test("getFiles (with case insensitivity)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./test/stubs/writeTestJS-casesensitive", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["11ty.js", "JS"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["11ty.js", "JS"], $config); t.deepEqual( (await evf.getFiles()).sort(), @@ -123,13 +123,13 @@ test("getFiles (with case insensitivity)", async (t) => { }); test("Mutually exclusive Input and Output dirs", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./test/stubs/writeTest", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md"], $config); let files = await glob(evf.getFileGlobs()); t.deepEqual(evf.getRawFiles(), ["./test/stubs/writeTest/**/*.{liquid,md}"]); @@ -138,13 +138,13 @@ test("Mutually exclusive Input and Output dirs", async (t) => { }); test("Single File Input (deep path)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./test/stubs/index.html", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md"], $config); let files = await glob(evf.getFileGlobs()); t.is(evf.getRawFiles().length, 1); @@ -153,13 +153,13 @@ test("Single File Input (deep path)", async (t) => { }); test("Single File Input (shallow path)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "README.md", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["md"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["md"], $config); let globs = evf.getFileGlobs(); //.filter((path) => path !== "./README.md"); let files = await glob(globs, { @@ -171,12 +171,12 @@ test("Single File Input (shallow path)", async (t) => { }); test("Glob Input", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./test/stubs/glob-pages/!(contact.md)", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["md"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["md"], $config); let globs = evf.getFileGlobs(); let files = await glob(globs); @@ -187,12 +187,12 @@ test("Glob Input", async (t) => { }); test(".eleventyignore parsing", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./test/stubs/", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["md"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["md"], $config); let ignores = evf.getFileIgnores("./test/stubs/.eleventyignore"); t.is(ignores.length, 2); @@ -201,12 +201,12 @@ test(".eleventyignore parsing", async (t) => { }); test("Parse multiple .eleventyignores", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./test/stubs/multiple-ignores/", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["md"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["md"], $config); let ignores = evf.getFileIgnores([ "./test/stubs/multiple-ignores/.eleventyignore", @@ -221,24 +221,24 @@ test("Parse multiple .eleventyignores", async (t) => { }); test("Passed file name does not exist", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "./", } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["md"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["md"], $config); let ignores = evf.getFileIgnores(".thisfiledoesnotexist"); t.deepEqual(ignores, []); }); test(".eleventyignore files", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["liquid", "md"], $config); let ignoredFiles = await glob("test/stubs/ignoredFolder/*.md"); t.is(ignoredFiles.length, 1); @@ -258,13 +258,13 @@ test(".eleventyignore files", async (t) => { }); test("getTemplateData caching", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf.init(); let templateDataFirstCall = evf.templateData; let templateDataSecondCall = evf.templateData; @@ -272,36 +272,36 @@ test("getTemplateData caching", async (t) => { }); test("getDataDir", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "." } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf.init(); t.is(evf.getDataDir(), "./_data/"); }); test("getDataDir subdir", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf.init(); t.is(evf.getDataDir(), "./test/stubs/_data/"); }); test("Include and Data Dirs", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf.init(); t.deepEqual(evf.getIncludesAndDataDirs(), [ @@ -311,12 +311,12 @@ test("Include and Data Dirs", async (t) => { }); test("Input to 'src' and empty includes dir (issue #403)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "src" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["md", "liquid", "html"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["md", "liquid", "html"], $config); evf._setEleventyIgnoreContent("!./src/_includes/**"); evf._setConfig({ useGitIgnore: false, @@ -338,13 +338,13 @@ test("Input to 'src' and empty includes dir (issue #403)", async (t) => { }); test("Glob Watcher Files", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["njk"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["njk"], $config); t.deepEqual(evf.getGlobWatcherFiles(), [ "./test/stubs/**/*.njk", @@ -354,12 +354,12 @@ test("Glob Watcher Files", async (t) => { }); test("Glob Watcher Files with File Extension Passthroughs", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs" } }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["njk", "png"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["njk", "png"], $config); t.deepEqual(evf.getGlobWatcherFiles(), [ "./test/stubs/**/*.njk", @@ -370,16 +370,16 @@ test("Glob Watcher Files with File Extension Passthroughs", async (t) => { }); test("Glob Watcher Files with File Extension Passthroughs with Dev Server (for free passthrough copy #2456)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs" } }); - eleventyConfig.userConfig.setServerPassthroughCopyBehavior("passthrough"); - eleventyConfig.config.serverPassthroughCopyBehavior = "passthrough"; + $config.userConfig.setServerPassthroughCopyBehavior("passthrough"); + $config.config.serverPassthroughCopyBehavior = "passthrough"; - let { eleventyFiles: evf } = getEleventyFilesInstance(["njk", "png"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["njk", "png"], $config); evf.setRunMode("serve"); evf.init(); // duplicate init @@ -393,7 +393,7 @@ test("Glob Watcher Files with File Extension Passthroughs with Dev Server (for f }); test("Glob Watcher Files with Config Passthroughs (one template format)", async (t) => { - let eleventyConfig = await getTemplateConfigInstanceCustomCallback({ + let $config = await getTemplateConfigInstanceCustomCallback({ input: "test/stubs", output: "test/stubs/_site" }, function(cfg) { @@ -403,7 +403,7 @@ test("Glob Watcher Files with Config Passthroughs (one template format)", async }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["njk"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["njk"], $config); t.deepEqual(evf.getGlobWatcherFiles(), [ "./test/stubs/**/*.njk", @@ -414,7 +414,7 @@ test("Glob Watcher Files with Config Passthroughs (one template format)", async }); test("Glob Watcher Files with Config Passthroughs (one template format) with Dev Server (for free passthrough copy #2456)", async (t) => { - let eleventyConfig = await getTemplateConfigInstanceCustomCallback({ + let $config = await getTemplateConfigInstanceCustomCallback({ input: "test/stubs" }, function(cfg) { cfg.setServerPassthroughCopyBehavior("passthrough"); @@ -424,11 +424,11 @@ test("Glob Watcher Files with Config Passthroughs (one template format) with Dev }; }); - let { eleventyFiles: evf } = getEleventyFilesInstance(["njk"], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance(["njk"], $config); evf.setRunMode("serve"); evf.init(); // duplicate init - let mgr = new TemplatePassthroughManager(eleventyConfig); + let mgr = new TemplatePassthroughManager($config); evf.setPassthroughManager(mgr); t.deepEqual(evf.getGlobWatcherFiles(), [ @@ -446,9 +446,9 @@ test("Glob Watcher Files with Config Passthroughs (no template formats)", async projectDirs.setViaConfigObject({ input: "test/stubs" }); - let eleventyConfig = await getTemplateConfigInstance(templateConfig, projectDirs); + let $config = await getTemplateConfigInstance(templateConfig, projectDirs); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); evf.init(); t.deepEqual(await evf.getGlobWatcherTemplateDataFiles(), [ @@ -462,8 +462,8 @@ test("Test that negations are ignored (for now) PR#709, will change when #693 is projectDirs.setViaConfigObject({ input: "test/stubs" }); - let eleventyConfig = await getTemplateConfigInstance(templateConfig, projectDirs); - let { eleventyFiles: evf } = getEleventyFilesInstance([], eleventyConfig); + let $config = await getTemplateConfigInstance(templateConfig, projectDirs); + let { eleventyFiles: evf } = getEleventyFilesInstance([], $config); t.deepEqual( evf.normalizeIgnoreContent( diff --git a/test/HtmlBasePluginTest.js b/test/HtmlBasePluginTest.js index 8c9326dac..163676dbb 100644 --- a/test/HtmlBasePluginTest.js +++ b/test/HtmlBasePluginTest.js @@ -246,9 +246,9 @@ test("Using the filter directly", async (t) => { test("Using the HTML base plugin (default values)", async (t) => { let elev = new Eleventy("./test/stubs-base/", "./test/stubs-base/_site", { configPath: false, - config: function (eleventyConfig) { - eleventyConfig.setUseTemplateCache(false); - eleventyConfig.addPlugin(HtmlBasePlugin); + config: function ($config) { + $config.setUseTemplateCache(false); + $config.addPlugin(HtmlBasePlugin); }, }); await elev.initializeConfig(); @@ -286,9 +286,9 @@ test("Using the HTML base plugin with pathPrefix: /test/", async (t) => { pathPrefix: "/test/", configPath: false, - config: function (eleventyConfig) { - eleventyConfig.setUseTemplateCache(false); - eleventyConfig.addPlugin(HtmlBasePlugin); + config: function ($config) { + $config.setUseTemplateCache(false); + $config.addPlugin(HtmlBasePlugin); }, }); @@ -327,9 +327,9 @@ test("Using the HTML base plugin with pathPrefix: /test/ and base: http://exampl pathPrefix: "/test/", configPath: false, - config: function (eleventyConfig) { - eleventyConfig.setUseTemplateCache(false); - eleventyConfig.addPlugin(HtmlBasePlugin, { + config: function ($config) { + $config.setUseTemplateCache(false); + $config.addPlugin(HtmlBasePlugin, { baseHref: "http://example.com/", }); }, @@ -368,9 +368,9 @@ test("Using the HTML base plugin with pathPrefix: /test/ and base: http://exampl test("Using the HTML base plugin strips extra path in full URL base (default pathPrefix)", async (t) => { let elev = new Eleventy("./test/stubs-base/", "./test/stubs-base/_site", { configPath: false, - config: function (eleventyConfig) { - eleventyConfig.setUseTemplateCache(false); - eleventyConfig.addPlugin(HtmlBasePlugin, { + config: function ($config) { + $config.setUseTemplateCache(false); + $config.addPlugin(HtmlBasePlugin, { baseHref: "http://example.com/hello/", // extra path will be stripped }); }, @@ -411,9 +411,9 @@ test("Using the HTML base plugin strips extra path in full URL base (pathPrefix: pathPrefix: "/test/", configPath: false, - config: function (eleventyConfig) { - eleventyConfig.setUseTemplateCache(false); - eleventyConfig.addPlugin(HtmlBasePlugin, { + config: function ($config) { + $config.setUseTemplateCache(false); + $config.addPlugin(HtmlBasePlugin, { baseHref: "http://example.com/hello/", // extra path will be stripped }); }, @@ -454,9 +454,9 @@ test("Opt out of the transform with falsy extensions list", async (t) => { pathPrefix: "/test/", configPath: false, - config: function (eleventyConfig) { - eleventyConfig.setUseTemplateCache(false); - eleventyConfig.addPlugin(HtmlBasePlugin, { + config: function ($config) { + $config.setUseTemplateCache(false); + $config.addPlugin(HtmlBasePlugin, { extensions: false, }); }, @@ -497,9 +497,9 @@ test("Base plugin with permalink: false, #2602", async (t) => { pathPrefix: "/test/", configPath: false, - config: function (eleventyConfig) { - eleventyConfig.setUseTemplateCache(false); - eleventyConfig.addPlugin(HtmlBasePlugin); + config: function ($config) { + $config.setUseTemplateCache(false); + $config.addPlugin(HtmlBasePlugin); }, }); @@ -537,9 +537,9 @@ test("Using the HTML base plugin with pathPrefix: /test/ and transformed attribu pathPrefix: "/test/", configPath: false, - config: function (eleventyConfig) { - eleventyConfig.setUseTemplateCache(false); - eleventyConfig.addPlugin(HtmlBasePlugin); + config: function ($config) { + $config.setUseTemplateCache(false); + $config.addPlugin(HtmlBasePlugin); }, }); @@ -576,14 +576,14 @@ test("HTML base plugin only adds once (unique)", async (t) => { t.plan(2); let elev = new Eleventy("./test/stubs-base/", "./test/stubs-base/_site", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Runs before defaultConfig.js - t.is(eleventyConfig.plugins.length, 0); - eleventyConfig.addPlugin(HtmlBasePlugin); - eleventyConfig.addPlugin(HtmlBasePlugin); - eleventyConfig.addPlugin(HtmlBasePlugin); - eleventyConfig.addPlugin(HtmlBasePlugin); - t.is(eleventyConfig.plugins.length, 1); + t.is($config.plugins.length, 0); + $config.addPlugin(HtmlBasePlugin); + $config.addPlugin(HtmlBasePlugin); + $config.addPlugin(HtmlBasePlugin); + $config.addPlugin(HtmlBasePlugin); + t.is($config.plugins.length, 1); }, }); await elev.init(); @@ -593,21 +593,21 @@ test("HTML base plugin can resolve by name", async (t) => { t.plan(2); let elev = new Eleventy("./test/stubs-base/", "./test/stubs-base/_site", { configPath: false, - config: async function (eleventyConfig) { + config: async function ($config) { // Runs before defaultConfig.js - t.is(eleventyConfig.plugins.length, 0); + t.is($config.plugins.length, 0); - let plugin = await eleventyConfig.resolvePlugin("@11ty/eleventy/html-base-plugin"); - eleventyConfig.addPlugin(plugin); + let plugin = await $config.resolvePlugin("@11ty/eleventy/html-base-plugin"); + $config.addPlugin(plugin); // does not add duplicate - eleventyConfig.addPlugin(plugin); + $config.addPlugin(plugin); // does not add duplicate even with a different reference - eleventyConfig.addPlugin(HtmlBasePlugin); - eleventyConfig.addPlugin(HtmlBasePlugin); + $config.addPlugin(HtmlBasePlugin); + $config.addPlugin(HtmlBasePlugin); - t.is(eleventyConfig.plugins.length, 1); + t.is($config.plugins.length, 1); }, }); await elev.init(); @@ -618,9 +618,9 @@ test("Using recognizeNoValueAttribute for boolean attributes without quotes #276 input: "./test/stubs-virtual/", pathPrefix: "/prefixed/", configPath: false, - config: function (eleventyConfig) { - eleventyConfig.setUseTemplateCache(false); - eleventyConfig.addTemplate("index.njk", `--- + config: function ($config) { + $config.setUseTemplateCache(false); + $config.addTemplate("index.njk", `--- permalink: /deep/ --- @@ -632,7 +632,7 @@ permalink: /deep/ `) - eleventyConfig.addPlugin(HtmlBasePlugin); + $config.addPlugin(HtmlBasePlugin); }, }); diff --git a/test/HtmlRelativeCopyTest.js b/test/HtmlRelativeCopyTest.js index 611b93926..114c27d41 100644 --- a/test/HtmlRelativeCopyTest.js +++ b/test/HtmlRelativeCopyTest.js @@ -22,15 +22,15 @@ test.after.always("Directory cleanup", () => { test("Basic usage", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site-basica", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); - eleventyConfig.addPassthroughCopy("**/*.png", { + $config.addPassthroughCopy("**/*.png", { mode: "html-relative" }) - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: { "/test/possum.png": TemplatePath.normalizeOperatingSystemFilePath("test/stubs-autocopy/possum.png") @@ -38,7 +38,7 @@ test("Basic usage", async (t) => { }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -71,15 +71,15 @@ test("Basic usage", async (t) => { test("More complex image path (parent dir)", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site-basicb", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); - eleventyConfig.addPassthroughCopy("**/*.png", { + $config.addPassthroughCopy("**/*.png", { mode: "html-relative" }) - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: { "/stubs-img-transform/possum.png": TemplatePath.normalizeOperatingSystemFilePath("test/stubs-img-transform/possum.png") @@ -87,7 +87,7 @@ test("More complex image path (parent dir)", async (t) => { }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -121,19 +121,19 @@ test("More complex image path (parent dir)", async (t) => { test("No matches", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site2", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); - eleventyConfig.addPassthroughCopy("**/*.jpeg", { + $config.addPassthroughCopy("**/*.jpeg", { mode: "html-relative" }) - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -151,16 +151,16 @@ test("No matches", async (t) => { test("Match but does not exist (throws error)", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site3", { configPath: false, - config: function (eleventyConfig) { - eleventyConfig.addPassthroughCopy("**/*.png", { + config: function ($config) { + $config.addPassthroughCopy("**/*.png", { mode: "html-relative" }); - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -178,20 +178,20 @@ test("Match but does not exist (throws error)", async (t) => { test("Match but does not exist (no error, using `failOnError: false`)", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site4", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); - eleventyConfig.addPassthroughCopy("**/*.png", { + $config.addPassthroughCopy("**/*.png", { mode: "html-relative", failOnError: false, }) - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -209,23 +209,23 @@ test("Match but does not exist (no error, using `failOnError: false`)", async (t test("Copying dotfiles are not allowed", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site5", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); // WARNING: don’t do this - eleventyConfig.addPassthroughCopy("**/*", { + $config.addPassthroughCopy("**/*", { mode: "html-relative", copyOptions: { // debug: true, } }); - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -245,23 +245,23 @@ test("Copying dotfiles are not allowed", async (t) => { test("Using with InputPathToUrl plugin", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site6", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); // order of addPlugin shouldn’t matter here - eleventyConfig.addPassthroughCopy("**/*.{html,njk}", { + $config.addPassthroughCopy("**/*.{html,njk}", { mode: "html-relative" }); - eleventyConfig.addPlugin(InputPathToUrlTransformPlugin); + $config.addPlugin(InputPathToUrlTransformPlugin); - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); - eleventyConfig.addTemplate("test1.njk", `Test 1`) - eleventyConfig.addTemplate("test2.njk", `Test 2`) + $config.addTemplate("test1.njk", `Test 1`) + $config.addTemplate("test2.njk", `Test 2`) }, }); @@ -281,23 +281,23 @@ test("Using with InputPathToUrl plugin", async (t) => { test("Using with InputPathToUrl plugin (reverse addPlugin order)", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site7", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); // order of addPlugin shouldn’t matter here - eleventyConfig.addPlugin(InputPathToUrlTransformPlugin); + $config.addPlugin(InputPathToUrlTransformPlugin); - eleventyConfig.addPassthroughCopy("**/*.{html,njk}", { + $config.addPassthroughCopy("**/*.{html,njk}", { mode: "html-relative" }); - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); - eleventyConfig.addTemplate("test1.njk", `Test 1`) - eleventyConfig.addTemplate("test2.njk", `Test 2`) + $config.addTemplate("test1.njk", `Test 1`) + $config.addTemplate("test2.njk", `Test 2`) }, }); @@ -317,16 +317,16 @@ test("Use with HtmlBasePlugin usage", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site8a", { configPath: false, pathPrefix: "yolo", - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); - eleventyConfig.addPlugin(HtmlBasePlugin); - eleventyConfig.addPassthroughCopy("**/*.png", { + $config.addPlugin(HtmlBasePlugin); + $config.addPassthroughCopy("**/*.png", { mode: "html-relative" }); - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: { "/test/possum.png": TemplatePath.normalizeOperatingSystemFilePath("test/stubs-autocopy/possum.png") @@ -334,7 +334,7 @@ test("Use with HtmlBasePlugin usage", async (t) => { }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -368,24 +368,24 @@ test("Using with InputPathToUrl plugin and HtmlBasePlugin", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site8b", { configPath: false, pathPrefix: "yolo", - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); // order of addPlugin shouldn’t matter here - eleventyConfig.addPassthroughCopy("**/*.{html,njk}", { + $config.addPassthroughCopy("**/*.{html,njk}", { mode: "html-relative" }); - eleventyConfig.addPlugin(InputPathToUrlTransformPlugin); - eleventyConfig.addPlugin(HtmlBasePlugin); + $config.addPlugin(InputPathToUrlTransformPlugin); + $config.addPlugin(HtmlBasePlugin); - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); - eleventyConfig.addTemplate("test1.njk", `Test 1`) - eleventyConfig.addTemplate("test2.njk", `Test 2`) + $config.addTemplate("test1.njk", `Test 1`) + $config.addTemplate("test2.njk", `Test 2`) }, }); @@ -405,18 +405,18 @@ test("Using with InputPathToUrl plugin and HtmlBasePlugin", async (t) => { test("Multiple addPlugin calls (use both globs)", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site9", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); - eleventyConfig.addPassthroughCopy("**/*.jpg", { + $config.addPassthroughCopy("**/*.jpg", { mode: "html-relative" }); - eleventyConfig.addPassthroughCopy("**/*.png", { + $config.addPassthroughCopy("**/*.png", { mode: "html-relative" }); - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: { "/test/possum.jpg": TemplatePath.normalizeOperatingSystemFilePath("test/stubs-autocopy/possum.jpg"), @@ -425,7 +425,7 @@ test("Multiple addPlugin calls (use both globs)", async (t) => { }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -465,15 +465,15 @@ test("Multiple addPlugin calls (use both globs)", async (t) => { test("Array of globs", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site10", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); - eleventyConfig.addPassthroughCopy(["**/*.jpg", "**/*.png"], { + $config.addPassthroughCopy(["**/*.jpg", "**/*.png"], { mode: "html-relative" }); - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: { "/test/possum.jpg": TemplatePath.normalizeOperatingSystemFilePath("test/stubs-autocopy/possum.jpg"), @@ -482,7 +482,7 @@ test("Array of globs", async (t) => { }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -525,24 +525,24 @@ test("overwrite: false", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site11", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); - eleventyConfig.addPassthroughCopy("**/*.png", { + $config.addPassthroughCopy("**/*.png", { mode: "html-relative", copyOptions: { overwrite: false, } }); - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -573,20 +573,20 @@ test("overwrite: false", async (t) => { test("Input -> output remapping not yet supported (throws error)", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site12", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); // not yet supported - eleventyConfig.addPassthroughCopy({"**/*.png": "yo"}, { + $config.addPassthroughCopy({"**/*.png": "yo"}, { mode: "html-relative" }); - eleventyConfig.on("buildawesome.passthrough", copyMap => { + $config.on("buildawesome.passthrough", copyMap => { t.deepEqual(copyMap, { map: {} }) }); - eleventyConfig.addTemplate("test.njk", ``) + $config.addTemplate("test.njk", ``) }, }); @@ -604,12 +604,12 @@ test("Input -> output remapping not yet supported (throws error)", async (t) => test("Invalid copy mode throws error", async (t) => { let elev = new Eleventy("./test/stubs-autocopy/", "./test/stubs-autocopy/_site13", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // Node 24: workaround for re-using input directory (and not ignoring all output directories by default) - eleventyConfig.ignores.add("./test/stubs-autocopy/_site*/**"); + $config.ignores.add("./test/stubs-autocopy/_site*/**"); // not yet supported - eleventyConfig.addPassthroughCopy({"**/*.png": "yo"}, { + $config.addPassthroughCopy({"**/*.png": "yo"}, { mode: "throw-an-error" }); }, diff --git a/test/I18nPluginTest.js b/test/I18nPluginTest.js index 02a4f7c77..6df06f084 100644 --- a/test/I18nPluginTest.js +++ b/test/I18nPluginTest.js @@ -30,13 +30,13 @@ test("LangUtils.swapLanguageCode", (t) => { test("contentMap Event from Eleventy", async (t) => { t.plan(4); let elev = new Eleventy("./test/stubs-i18n/", "./test/stubs-i18n/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(I18nPlugin, { + config: function ($config) { + $config.addPlugin(I18nPlugin, { defaultLanguage: "en", errorMode: "allow-fallback", }); - eleventyConfig.on("buildawesome.contentmap", (maps) => { + $config.on("buildawesome.contentmap", (maps) => { t.truthy(maps); // if future maps are added, they should be tested here @@ -81,8 +81,8 @@ function getContentFor(results, filename) { test("errorMode default (strict)", async (t) => { let elev = new Eleventy("./test/stubs-i18n/", "./test/stubs-i18n/_site", { quietMode: true, - config: function (eleventyConfig) { - eleventyConfig.addPlugin(I18nPlugin, { + config: function ($config) { + $config.addPlugin(I18nPlugin, { _test: "this is from errorMode default (strict)", defaultLanguage: "en", // errorMode: "allow-fallback" @@ -102,8 +102,8 @@ test("errorMode default (strict)", async (t) => { test("locale_url and locale_links Filters", async (t) => { let elev = new Eleventy("./test/stubs-i18n/", "./test/stubs-i18n/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(I18nPlugin, { + config: function ($config) { + $config.addPlugin(I18nPlugin, { _test: "this is from locale_url and locale_links Filters", defaultLanguage: "en", errorMode: "allow-fallback", diff --git a/test/IdAttributePluginTest.js b/test/IdAttributePluginTest.js index 84553bc74..03655bf19 100644 --- a/test/IdAttributePluginTest.js +++ b/test/IdAttributePluginTest.js @@ -5,10 +5,10 @@ import Eleventy from "../src/Core.js"; test("Using the IdAttribute plugin #3356", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin); + config: function ($config) { + $config.addPlugin(IdAttributePlugin); - eleventyConfig.addTemplate("test.njk", `

This is a heading

This is another heading

This is another heading

This is another heading

`, {}); + $config.addTemplate("test.njk", `

This is a heading

This is another heading

This is another heading

This is another heading

`, {}); }, }); @@ -20,10 +20,10 @@ test("Using the IdAttribute plugin, ignore attribute #3356", async (t) => { let elev = new Eleventy({ input: "./test/stubs-3356/", // configPath: false, - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin); + config: function ($config) { + $config.addPlugin(IdAttributePlugin); - eleventyConfig.addTemplate("test.njk", `

This is a heading

This is another heading

This is another heading

This is another heading

`, {}); + $config.addTemplate("test.njk", `

This is a heading

This is another heading

This is another heading

This is another heading

`, {}); }, }); @@ -33,10 +33,10 @@ test("Using the IdAttribute plugin, ignore attribute #3356", async (t) => { test("Using the IdAttribute plugin with escaped quoted text", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin); + config: function ($config) { + $config.addPlugin(IdAttributePlugin); - eleventyConfig.addTemplate("test.md", `# This is a \`"heading"\``, {}); + $config.addTemplate("test.md", `# This is a \`"heading"\``, {}); }, }); @@ -46,10 +46,10 @@ test("Using the IdAttribute plugin with escaped quoted text", async (t) => { test("Issue #3424, id attribute conflicts (id attribute supplied first)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin); + config: function ($config) { + $config.addPlugin(IdAttributePlugin); - eleventyConfig.addTemplate("test.html", `

Testing

`, {}); + $config.addTemplate("test.html", `

Testing

`, {}); }, }); @@ -59,10 +59,10 @@ test("Issue #3424, id attribute conflicts (id attribute supplied first)", async test("Issue #3424, id attribute conflicts (id attribute supplied last)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin); + config: function ($config) { + $config.addPlugin(IdAttributePlugin); - eleventyConfig.addTemplate("test.html", `

Testing

`, {}); + $config.addTemplate("test.html", `

Testing

`, {}); }, }); @@ -72,10 +72,10 @@ test("Issue #3424, id attribute conflicts (id attribute supplied last)", async ( test("Issue #3424, id attribute conflicts (hard coded id conflicts)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin); + config: function ($config) { + $config.addPlugin(IdAttributePlugin); - eleventyConfig.addTemplate("test.html", `

Testing

Testing

`, {}); + $config.addTemplate("test.html", `

Testing

Testing

`, {}); }, }); @@ -85,10 +85,10 @@ test("Issue #3424, id attribute conflicts (hard coded id conflicts)", async (t) test("Issue #3424, id attribute conflicts (three deep, hard coded id conflicts)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin); + config: function ($config) { + $config.addPlugin(IdAttributePlugin); - eleventyConfig.addTemplate("test.html", `

Testing

Testing

Testing

`, {}); + $config.addTemplate("test.html", `

Testing

Testing

Testing

`, {}); }, }); @@ -98,10 +98,10 @@ test("Issue #3424, id attribute conflicts (three deep, hard coded id conflicts)" test("Issue #3424, id attribute conflicts (four deep, hard coded id conflicts)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin); + config: function ($config) { + $config.addPlugin(IdAttributePlugin); - eleventyConfig.addTemplate("test.html", `

Testing

Testing

Testing

Testing

`, {}); + $config.addTemplate("test.html", `

Testing

Testing

Testing

Testing

`, {}); }, }); @@ -111,10 +111,10 @@ test("Issue #3424, id attribute conflicts (four deep, hard coded id conflicts)", test("Issue #3424, id attribute conflicts (five deep, hard coded id conflicts)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin); + config: function ($config) { + $config.addPlugin(IdAttributePlugin); - eleventyConfig.addTemplate("test.html", `

Testing

Testing

Testing

Testing

Testing

`, {}); + $config.addTemplate("test.html", `

Testing

Testing

Testing

Testing

Testing

`, {}); }, }); @@ -124,10 +124,10 @@ test("Issue #3424, id attribute conflicts (five deep, hard coded id conflicts)", test("Issue #3424, id attribute conflicts (two hard coded id conflicts)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin); + config: function ($config) { + $config.addPlugin(IdAttributePlugin); - eleventyConfig.addTemplate("test.html", `

Testing

Testing

`, {}); + $config.addTemplate("test.html", `

Testing

Testing

`, {}); }, }); elev.disableLogger(); @@ -138,8 +138,8 @@ test("Issue #3424, id attribute conflicts (two hard coded id conflicts)", async test("Issue #3424, filter callback skips", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(IdAttributePlugin, { + config: function ($config) { + $config.addPlugin(IdAttributePlugin, { filter: function({ page }) { if(page.inputPath.endsWith("test-skipped.html")) { return false; @@ -148,8 +148,8 @@ test("Issue #3424, filter callback skips", async (t) => { } }); - eleventyConfig.addTemplate("test.html", `

Testing

Testing

`, {}); - eleventyConfig.addTemplate("test-skipped.html", `

Testing

Testing

`, {}); + $config.addTemplate("test.html", `

Testing

Testing

`, {}); + $config.addTemplate("test-skipped.html", `

Testing

Testing

`, {}); }, }); elev.disableLogger(); diff --git a/test/InputPathToUrlPluginTest.js b/test/InputPathToUrlPluginTest.js index 05c96db9f..fa39389ff 100644 --- a/test/InputPathToUrlPluginTest.js +++ b/test/InputPathToUrlPluginTest.js @@ -55,9 +55,9 @@ function getContentFor(results, filename) { test("Using the transform (and the filter too)", async (t) => { let elev = new Eleventy("./test/stubs-pathtourl/", "./test/stubs-pathtourl/_site", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // FilterPlugin is available in the default config. - eleventyConfig.addPlugin(TransformPlugin); + $config.addPlugin(TransformPlugin); }, }); @@ -94,9 +94,9 @@ test("Using the transform and the base plugin", async (t) => { let elev = new Eleventy("./test/stubs-pathtourl/", "./test/stubs-pathtourl/_site", { configPath: false, pathPrefix: "/gh-pages/", - config: function (eleventyConfig) { - eleventyConfig.addPlugin(TransformPlugin); - eleventyConfig.addPlugin(HtmlBasePlugin); + config: function ($config) { + $config.addPlugin(TransformPlugin); + $config.addPlugin(HtmlBasePlugin); }, }); @@ -115,9 +115,9 @@ test("Using the transform and the base plugin, reverse order", async (t) => { let elev = new Eleventy("./test/stubs-pathtourl/", "./test/stubs-pathtourl/_site", { configPath: false, pathPrefix: "/gh-pages/", - config: function (eleventyConfig) { - eleventyConfig.addPlugin(HtmlBasePlugin); - eleventyConfig.addPlugin(TransformPlugin); + config: function ($config) { + $config.addPlugin(HtmlBasePlugin); + $config.addPlugin(TransformPlugin); }, }); @@ -136,12 +136,12 @@ test("Using the transform and the base plugin, reverse order", async (t) => { test("Issue #3417 Using the transform with relative path (dot slash)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // FilterPlugin is available in the default config. - eleventyConfig.addPlugin(TransformPlugin); + $config.addPlugin(TransformPlugin); - eleventyConfig.addTemplate("source/test.njk", `Target`) - eleventyConfig.addTemplate("source/target.njk", "lol") + $config.addTemplate("source/test.njk", `Target`) + $config.addTemplate("source/target.njk", "lol") }, }); @@ -156,12 +156,12 @@ test("Issue #3417 Using the transform with relative path (dot slash)", async (t) test("Issue #3417 Using the transform with relative path (no dot slash)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { configPath: false, - config: function (eleventyConfig) { + config: function ($config) { // FilterPlugin is available in the default config. - eleventyConfig.addPlugin(TransformPlugin); + $config.addPlugin(TransformPlugin); - eleventyConfig.addTemplate("source/test.njk", `Target`) - eleventyConfig.addTemplate("source/target.njk", "lol") + $config.addTemplate("source/test.njk", `Target`) + $config.addTemplate("source/target.njk", "lol") }, }); @@ -176,10 +176,10 @@ test("Issue #3417 Using the transform with relative path (no dot slash)", async test("Issue #3581 #build-cost-🧰", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { configPath: false, - config: function (eleventyConfig) { - eleventyConfig.addPlugin(TransformPlugin); + config: function ($config) { + $config.addPlugin(TransformPlugin); - eleventyConfig.addTemplate("source/test.njk", `Target`) + $config.addTemplate("source/test.njk", `Target`) }, }); @@ -194,8 +194,8 @@ test("Issue #3581 #build-cost-🧰", async (t) => { test("Issue #3583 Markdown diacritics (no plugin)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { configPath: false, - config: function (eleventyConfig) { - eleventyConfig.addTemplate("test.md", `[Target]()`) + config: function ($config) { + $config.addTemplate("test.md", `[Target]()`) }, }); @@ -210,11 +210,11 @@ test("Issue #3583 Markdown diacritics (no plugin)", async (t) => { test("Issue #3583 Diacritics", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { configPath: false, - config: function (eleventyConfig) { - eleventyConfig.addPlugin(TransformPlugin); + config: function ($config) { + $config.addPlugin(TransformPlugin); - eleventyConfig.addTemplate("test.md", `[Target](/hypothèse.md)`) - eleventyConfig.addTemplate("hypothèse.md", "lol") + $config.addTemplate("test.md", `[Target](/hypothèse.md)`) + $config.addTemplate("hypothèse.md", "lol") }, }); @@ -229,11 +229,11 @@ test("Issue #3583 Diacritics", async (t) => { test("Issue #3583 Diacritics Markdown raw", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { configPath: false, - config: function (eleventyConfig) { - eleventyConfig.addPlugin(TransformPlugin); + config: function ($config) { + $config.addPlugin(TransformPlugin); - eleventyConfig.addTemplate("test.md", `[Target]()`) - eleventyConfig.addTemplate("hypothèse.md", "lol") + $config.addTemplate("test.md", `[Target]()`) + $config.addTemplate("hypothèse.md", "lol") }, }); @@ -248,8 +248,8 @@ test("Issue #3583 Diacritics Markdown raw", async (t) => { test("Issue #3583 #3559 Markdown link with spaces (no plugin)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { configPath: false, - config: function (eleventyConfig) { - eleventyConfig.addTemplate("test.md", `[Target]()`) + config: function ($config) { + $config.addTemplate("test.md", `[Target]()`) }, }); @@ -264,13 +264,13 @@ test("Issue #3583 #3559 Markdown link with spaces (no plugin)", async (t) => { test("Issue #3583 #3559 Markdown spaces", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { configPath: false, - config: function (eleventyConfig) { - eleventyConfig.addPlugin(TransformPlugin); + config: function ($config) { + $config.addPlugin(TransformPlugin); - // eleventyConfig.addFilter("encode_uri_component", encodeURIComponent); + // $config.addFilter("encode_uri_component", encodeURIComponent); - eleventyConfig.addTemplate("test.md", `[Target]()`) - eleventyConfig.addTemplate("target 1.md", "lol", { + $config.addTemplate("test.md", `[Target]()`) + $config.addTemplate("target 1.md", "lol", { permalink: "/{{ page.fileSlug | slugify }}/" }) }, diff --git a/test/Issue3467Test.js b/test/Issue3467Test.js index 328360b7d..10e1bbb4e 100644 --- a/test/Issue3467Test.js +++ b/test/Issue3467Test.js @@ -3,10 +3,10 @@ import Eleventy from "../src/Core.js"; test("Empty collections api #3467 (return undefined)", async (t) => { let elev = new Eleventy("./test/stubs-virtual", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `# Hello`); + config: function ($config) { + $config.addTemplate("virtual.md", `# Hello`); - eleventyConfig.addCollection("brokenCollection", function(collection) { + $config.addCollection("brokenCollection", function(collection) { // returns nothing }); }, @@ -21,10 +21,10 @@ test("Empty collections api #3467 (return undefined)", async (t) => { test("Empty collections api #3467 (return false)", async (t) => { let elev = new Eleventy("./test/stubs-virtual", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `# Hello`); + config: function ($config) { + $config.addTemplate("virtual.md", `# Hello`); - eleventyConfig.addCollection("brokenCollection", function(collection) { + $config.addCollection("brokenCollection", function(collection) { return false; }); }, @@ -39,10 +39,10 @@ test("Empty collections api #3467 (return false)", async (t) => { test("Empty collections api #3467 (return empty string)", async (t) => { let elev = new Eleventy("./test/stubs-virtual", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("virtual.md", `# Hello`); + config: function ($config) { + $config.addTemplate("virtual.md", `# Hello`); - eleventyConfig.addCollection("brokenCollection", function(collection) { + $config.addCollection("brokenCollection", function(collection) { return ""; }); }, diff --git a/test/Issue3788Test.js b/test/Issue3788Test.js index 504bac170..3c8714a4d 100644 --- a/test/Issue3788Test.js +++ b/test/Issue3788Test.js @@ -3,10 +3,10 @@ import Eleventy from "../src/Core.js"; test("#3788 Nunjucks shortcodes args", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addTemplate("index.njk", `{% test %}:{% test "" %}`); + config($config) { + $config.addTemplate("index.njk", `{% test %}:{% test "" %}`); - eleventyConfig.addShortcode("test", (args) => { + $config.addShortcode("test", (args) => { return JSON.stringify(args); }) } diff --git a/test/Issue3797Test.js b/test/Issue3797Test.js index 2f81ca072..8da433610 100644 --- a/test/Issue3797Test.js +++ b/test/Issue3797Test.js @@ -3,11 +3,11 @@ import Eleventy from "../src/Core.js"; test("#3797 Virtual templates with empty includes", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.setIncludesDirectory(""); - eleventyConfig.setLayoutsDirectory("_layouts"); - eleventyConfig.addTemplate("post1.md", "# Post1", { layout: "layout.html" }); - eleventyConfig.addTemplate("_layouts/layout.html", "{{ content }}"); + config($config) { + $config.setIncludesDirectory(""); + $config.setLayoutsDirectory("_layouts"); + $config.addTemplate("post1.md", "# Post1", { layout: "layout.html" }); + $config.addTemplate("_layouts/layout.html", "{{ content }}"); } }); diff --git a/test/Issue3808Test.js b/test/Issue3808Test.js index 258549eb0..8682e3912 100644 --- a/test/Issue3808Test.js +++ b/test/Issue3808Test.js @@ -3,13 +3,13 @@ import Eleventy from "../src/Core.js"; test("#3808 addCollection in buildawesome.before", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addTemplate("post1.md", "# Post1"); - eleventyConfig.addTemplate("post2.md", "# Post2"); - eleventyConfig.addTemplate("index.njk", "{{ collections.posts.length }}"); + config($config) { + $config.addTemplate("post1.md", "# Post1"); + $config.addTemplate("post2.md", "# Post2"); + $config.addTemplate("index.njk", "{{ collections.posts.length }}"); - eleventyConfig.on("buildawesome.before", async () => { - eleventyConfig.addCollection("posts", async collectionApi => { + $config.on("buildawesome.before", async () => { + $config.addCollection("posts", async collectionApi => { return collectionApi.getFilteredByGlob("**/post*.md"); }); }) @@ -22,33 +22,33 @@ test("#3808 addCollection in buildawesome.before", async (t) => { }); // /* broken */ -// export default function(eleventyConfig) { -// eleventyConfig.on("buildawesome.before", async () => { -// eleventyConfig.addCollection("posts", collectionApi => { +// export default function($config) { +// $config.on("buildawesome.before", async () => { +// $config.addCollection("posts", collectionApi => { // return collectionApi.getFilteredByGlob("**/post*.md"); // }); // }) // } // /* works */ -// export default function(eleventyConfig) { -// eleventyConfig.on("buildawesome.beforeConfig", async (eleventyConfig) => { -// eleventyConfig.addCollection("posts", collectionApi => { +// export default function($config) { +// $config.on("buildawesome.beforeConfig", async ($config) => { +// $config.addCollection("posts", collectionApi => { // return collectionApi.getFilteredByGlob("**/post*.md"); // }); // }) // } // /* works */ -// export default async function(eleventyConfig) { -// eleventyConfig.addCollection("posts", collectionApi => { +// export default async function($config) { +// $config.addCollection("posts", collectionApi => { // return collectionApi.getFilteredByGlob("**/post*.md"); // }); // } // /* works */ -// export default function(eleventyConfig) { -// eleventyConfig.addCollection("posts", async collectionApi => { +// export default function($config) { +// $config.addCollection("posts", async collectionApi => { // return collectionApi.getFilteredByGlob("**/post*.md"); // }); // } diff --git a/test/Issue3816Test.js b/test/Issue3816Test.js index ef2a62163..ef0e1ccab 100644 --- a/test/Issue3816Test.js +++ b/test/Issue3816Test.js @@ -8,10 +8,10 @@ test("#3816 amendLibrary and setLibrary together", async (t) => { t.plan(1); let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addTemplate("index.md", "# Heading"); - eleventyConfig.setLibrary("md", markdownIt()); - eleventyConfig.amendLibrary("md", (mdLib) => { + config($config) { + $config.addTemplate("index.md", "# Heading"); + $config.setLibrary("md", markdownIt()); + $config.amendLibrary("md", (mdLib) => { // this will only run once, t.plan is important! let before = mdLib.core.ruler.getRules("").length; mdLib.use(markdownItAbbr); diff --git a/test/Issue3818Test.js b/test/Issue3818Test.js index ca49eb3db..effc3352f 100644 --- a/test/Issue3818Test.js +++ b/test/Issue3818Test.js @@ -4,9 +4,9 @@ import WebCPlugin from "@11ty/eleventy-plugin-webc"; test("#3818 WebC Permalink", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addPlugin(WebCPlugin); - eleventyConfig.addTemplate("index.webc", `--- + config($config) { + $config.addPlugin(WebCPlugin); + $config.addTemplate("index.webc", `--- eleventyComputed: permalink: "page//" ---`); @@ -20,9 +20,9 @@ eleventyComputed: test("#3818 WebC Permalink Pagination JavaScript function", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addPlugin(WebCPlugin); - eleventyConfig.addTemplate("index.webc", `---js + config($config) { + $config.addPlugin(WebCPlugin); + $config.addTemplate("index.webc", `---js const pagination = { data: "posts", size: 2, @@ -60,9 +60,9 @@ function permalink(data) { test("#3818 WebC Permalink Pagination, eleventyComputed.permalink String", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addPlugin(WebCPlugin); - eleventyConfig.addTemplate("index.webc", `--- + config($config) { + $config.addPlugin(WebCPlugin); + $config.addTemplate("index.webc", `--- pagination: data: posts size: 2 @@ -98,9 +98,9 @@ eleventyComputed: test("#3818 WebC Permalink Pagination, permalink String", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addPlugin(WebCPlugin); - eleventyConfig.addTemplate("index.webc", `--- + config($config) { + $config.addPlugin(WebCPlugin); + $config.addTemplate("index.webc", `--- pagination: data: posts size: 2 diff --git a/test/Issue3823Test.js b/test/Issue3823Test.js index 12025c430..787a9743d 100644 --- a/test/Issue3823Test.js +++ b/test/Issue3823Test.js @@ -3,10 +3,10 @@ import Eleventy from "../src/Core.js"; test("#3823 addCollection -> pagination over `collections`", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addTemplate("post1.md", "# Post1"); - eleventyConfig.addTemplate("post2.md", "# Post2"); - eleventyConfig.addTemplate("index.njk", `--- + config($config) { + $config.addTemplate("post1.md", "# Post1"); + $config.addTemplate("post2.md", "# Post2"); + $config.addTemplate("index.njk", `--- pagination: data: collections size: 1 @@ -17,7 +17,7 @@ pagination: --- {{ tag }}`); - eleventyConfig.addCollection("posts", async collectionApi => { + $config.addCollection("posts", async collectionApi => { return collectionApi.getFilteredByGlob("**/post*.md"); }); } diff --git a/test/Issue3825Test.js b/test/Issue3825Test.js index 815b41888..71591da7d 100644 --- a/test/Issue3825Test.js +++ b/test/Issue3825Test.js @@ -3,20 +3,20 @@ import Eleventy from "../src/Core.js"; test("#3825 #3834 addCollection consumes tag from pagination template", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addTemplate("post1.md", "# Post1"); - eleventyConfig.addTemplate("post2.md", "# Post2"); + config($config) { + $config.addTemplate("post1.md", "# Post1"); + $config.addTemplate("post2.md", "# Post2"); - eleventyConfig.addCollection("posts", async collectionApi => { + $config.addCollection("posts", async collectionApi => { return collectionApi.getFilteredByGlob("**/post*.md"); }); - eleventyConfig.addCollection("myCollection", collectionApi => { + $config.addCollection("myCollection", collectionApi => { // populated by child.njk return collectionApi.getFilteredByTag("childTag"); }) - eleventyConfig.addTemplate("child.njk", `--- + $config.addTemplate("child.njk", `--- pagination: data: collections.posts size: 1 @@ -28,7 +28,7 @@ tags: childTag --- {{ tag }}`); - eleventyConfig.addTemplate("index.njk", `{{ collections.myCollection.length }}`, { + $config.addTemplate("index.njk", `{{ collections.myCollection.length }}`, { // eleventyImport: { // collections: ["myCollection"] // } @@ -44,20 +44,20 @@ tags: childTag test("#3825 addCollection consumes tag from pagination template", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addTemplate("post1.md", "# Post1"); - eleventyConfig.addTemplate("post2.md", "# Post2"); + config($config) { + $config.addTemplate("post1.md", "# Post1"); + $config.addTemplate("post2.md", "# Post2"); - eleventyConfig.addCollection("homepageLinks", function(collectionApi) { + $config.addCollection("homepageLinks", function(collectionApi) { // glob consumes pagination over another userconfig collection return collectionApi.getFilteredByGlob(["**/principles.njk"]); }); - eleventyConfig.addCollection("getAllPrinciplesOrderedByTitle", function(collectionApi) { + $config.addCollection("getAllPrinciplesOrderedByTitle", function(collectionApi) { return collectionApi.getFilteredByGlob("**/post*.md"); }); - eleventyConfig.addTemplate("principles.njk", `--- + $config.addTemplate("principles.njk", `--- pagination: data: collections.getAllPrinciplesOrderedByTitle size: 1 @@ -68,7 +68,7 @@ pagination: --- {{ tag }}`); - eleventyConfig.addTemplate("index.njk", `{{ collections.homepageLinks.length }}`, { + $config.addTemplate("index.njk", `{{ collections.homepageLinks.length }}`, { // eleventyImport: { // collections: ["homepageLinks"] // } @@ -84,20 +84,20 @@ pagination: test("Side-issue #3825 #3834 tried to Reflect.has on a string in pagination", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addTemplate("post1.md", "# Post1"); - eleventyConfig.addTemplate("post2.md", "# Post2"); + config($config) { + $config.addTemplate("post1.md", "# Post1"); + $config.addTemplate("post2.md", "# Post2"); - eleventyConfig.addCollection("posts", async collectionApi => { + $config.addCollection("posts", async collectionApi => { return collectionApi.getFilteredByGlob("**/post*.md"); }); - eleventyConfig.addCollection("myCollection", collectionApi => { + $config.addCollection("myCollection", collectionApi => { // populated by child.njk return collectionApi.getFilteredByTag("someArbitraryTag"); }) - eleventyConfig.addTemplate("child.njk", `--- + $config.addTemplate("child.njk", `--- pagination: data: collections.posts size: 1 @@ -110,7 +110,7 @@ tag: someArbitraryTag --- {{ tag }}`); - eleventyConfig.addTemplate("index.njk", `{{ collections.myCollection.length }}`); + $config.addTemplate("index.njk", `{{ collections.myCollection.length }}`); } }); diff --git a/test/Issue3831Test.js b/test/Issue3831Test.js index aa6101a66..7a3aece6d 100644 --- a/test/Issue3831Test.js +++ b/test/Issue3831Test.js @@ -3,12 +3,12 @@ import Eleventy from "../src/Core.js"; test("#3831 Computed Data regression", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addGlobalData("eleventyComputed", { + config($config) { + $config.addGlobalData("eleventyComputed", { first_letter: function (data) { return data.title[0] } }); - eleventyConfig.addTemplate("index.njk", `--- + $config.addTemplate("index.njk", `--- title: "Title" metadata: url: "/url/" diff --git a/test/Issue3833Test.js b/test/Issue3833Test.js index ec610d505..d3a7c7317 100644 --- a/test/Issue3833Test.js +++ b/test/Issue3833Test.js @@ -3,9 +3,9 @@ import Eleventy from "../src/Core.js"; test("#3831 Computed Data regression", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { + config($config) { - eleventyConfig.addTemplate("index.njk", `--- + $config.addTemplate("index.njk", `--- date: - April 1, 2025 ---`); diff --git a/test/Issue3850Test.js b/test/Issue3850Test.js index 596ced028..7c425e173 100644 --- a/test/Issue3850Test.js +++ b/test/Issue3850Test.js @@ -3,8 +3,8 @@ import Eleventy from "../src/Core.js"; test("#3850 Computed Data regression part 2", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addTemplate("index.njk", `--- + config($config) { + $config.addTemplate("index.njk", `--- site: download_link_mac: "http://example.com/" eleventyComputed: diff --git a/test/Issue3860Test.js b/test/Issue3860Test.js index c8952836f..a34d6d592 100644 --- a/test/Issue3860Test.js +++ b/test/Issue3860Test.js @@ -3,12 +3,12 @@ import Eleventy from "../src/Core.js"; test("#3860 addCollection consumes `collections` but is missing `collections.all`", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addFilter("keys", obj => Object.keys(obj)); - eleventyConfig.addTemplate("post1.md", "# Post1", { tags: ["bar"]}); - eleventyConfig.addTemplate("post2.md", "# Post2", { tags: ["foo"]}); + config($config) { + $config.addFilter("keys", obj => Object.keys(obj)); + $config.addTemplate("post1.md", "# Post1", { tags: ["bar"]}); + $config.addTemplate("post2.md", "# Post2", { tags: ["foo"]}); - eleventyConfig.addTemplate("tag.njk", "{{ collections | keys }}", { + $config.addTemplate("tag.njk", "{{ collections | keys }}", { pagination: { data: "collections", size: 1, diff --git a/test/Issue3870IncrementalTest.js b/test/Issue3870IncrementalTest.js index 40b7b647f..dd3fb0ec8 100644 --- a/test/Issue3870IncrementalTest.js +++ b/test/Issue3870IncrementalTest.js @@ -18,8 +18,8 @@ test("#3870 templateRender has not yet initialized (not incremental)", async (t) let index = 0; let elev = new Eleventy("test/stubs-virtual/", "test/stubs-virtual/_site", { configPath: "test/stubs-virtual/eleventy.config.js", - config(eleventyConfig) { - eleventyConfig.addTemplate("search.11ty.js", class { + config($config) { + $config.addTemplate("search.11ty.js", class { data() { return { permalink: '/search.json', @@ -34,7 +34,7 @@ test("#3870 templateRender has not yet initialized (not incremental)", async (t) } }); - eleventyConfig.on("buildawesome.after", ({ results }) => { + $config.on("buildawesome.after", ({ results }) => { t.is(results[0]?.content, runs[index].expected); }); } diff --git a/test/Issue3870Test.js b/test/Issue3870Test.js index 9ce3a2ad5..1cfa409a0 100644 --- a/test/Issue3870Test.js +++ b/test/Issue3870Test.js @@ -18,8 +18,8 @@ test("#3870 templateRender has not yet initialized (not incremental)", async (t) let index = 0; let elev = new Eleventy("test/stubs-virtual/", "test/stubs-virtual/_site", { configPath: "test/stubs-virtual/eleventy.config.js", - config(eleventyConfig) { - eleventyConfig.addTemplate("search.11ty.js", class { + config($config) { + $config.addTemplate("search.11ty.js", class { data() { return { permalink: '/search.json', @@ -34,7 +34,7 @@ test("#3870 templateRender has not yet initialized (not incremental)", async (t) } }); - eleventyConfig.on("buildawesome.after", ({ results }) => { + $config.on("buildawesome.after", ({ results }) => { t.is(results[0]?.content, runs[index].expected); }); } diff --git a/test/Issue3875Test.js b/test/Issue3875Test.js index c3e3d4ef1..adbdc1489 100644 --- a/test/Issue3875Test.js +++ b/test/Issue3875Test.js @@ -3,9 +3,9 @@ import Eleventy from "../src/Core.js"; test("#3875 numeric tags", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addFilter("keys", (obj) => Object.keys(obj)); - eleventyConfig.addTemplate("index.njk", "{{ collections | keys }}", { + config($config) { + $config.addFilter("keys", (obj) => Object.keys(obj)); + $config.addTemplate("index.njk", "{{ collections | keys }}", { tags: [1,2,3] }); } @@ -17,9 +17,9 @@ test("#3875 numeric tags", async (t) => { test("#3875 numeric tags (via front matter)", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addFilter("keys", (obj) => Object.keys(obj)); - eleventyConfig.addTemplate("index.njk", `--- + config($config) { + $config.addFilter("keys", (obj) => Object.keys(obj)); + $config.addTemplate("index.njk", `--- tags: - 1 - 2 @@ -35,12 +35,12 @@ tags: test("#3875 consume a numeric tag collection (njk)", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addFilter("keyTypes", (obj) => Object.keys(obj).map(entry => typeof entry).join(",")); - eleventyConfig.addTemplate("child.njk", "", { + config($config) { + $config.addFilter("keyTypes", (obj) => Object.keys(obj).map(entry => typeof entry).join(",")); + $config.addTemplate("child.njk", "", { tags: [1] }); - eleventyConfig.addTemplate("index.njk", `{{ collections | keyTypes }}:{{ collections[1].length }}:{{ collections['1'].length }}`); + $config.addTemplate("index.njk", `{{ collections | keyTypes }}:{{ collections[1].length }}:{{ collections['1'].length }}`); } }); @@ -50,12 +50,12 @@ test("#3875 consume a numeric tag collection (njk)", async (t) => { test("#3875 consume a numeric tag collection (liquid)", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addFilter("keyTypes", (obj) => Object.keys(obj).map(entry => typeof entry).join(",")); - eleventyConfig.addTemplate("child.njk", "", { + config($config) { + $config.addFilter("keyTypes", (obj) => Object.keys(obj).map(entry => typeof entry).join(",")); + $config.addTemplate("child.njk", "", { tags: [1] }); - eleventyConfig.addTemplate("index.liquid", `{{ collections | keyTypes }}:{{ collections[1].length }}:{{ collections['1'].length }}`); + $config.addTemplate("index.liquid", `{{ collections | keyTypes }}:{{ collections[1].length }}:{{ collections['1'].length }}`); } }); @@ -65,11 +65,11 @@ test("#3875 consume a numeric tag collection (liquid)", async (t) => { test("#3875 consume a numeric tag collection (11ty.js)", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addTemplate("child.njk", "", { + config($config) { + $config.addTemplate("child.njk", "", { tags: [1] }); - eleventyConfig.addTemplate("index.11ty.js", { + $config.addTemplate("index.11ty.js", { render(data) { return `${Object.keys(data.collections).map(entry => typeof entry).join(",")}:${data.collections[1].length}:${data.collections['1'].length}` } diff --git a/test/Issue434Test.js b/test/Issue434Test.js index 3ae64d560..2fd56dfd5 100644 --- a/test/Issue434Test.js +++ b/test/Issue434Test.js @@ -3,9 +3,9 @@ import Eleventy from "../src/Core.js"; test("#434 Using `with context` to access collections", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.setIncludesDirectory("../stubs-434/_includes/"); - eleventyConfig.addTemplate("index.njk", `{% import "macros.njk" as forms with context %}{{ forms.label('test') }}`); + config($config) { + $config.setIncludesDirectory("../stubs-434/_includes/"); + $config.addTemplate("index.njk", `{% import "macros.njk" as forms with context %}{{ forms.label('test') }}`); } }); @@ -16,17 +16,17 @@ test("#434 Using `with context` to access collections", async (t) => { test("#434 (not ideal) Filters in macros cannot access global data", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.setIncludesDirectory("../stubs-434/_includes/"); + config($config) { + $config.setIncludesDirectory("../stubs-434/_includes/"); // This doesn’t work to fetch collections from macros - eleventyConfig.addFilter("getCollection", function(name) { + $config.addFilter("getCollection", function(name) { return this.collections?.[name] || this.ctx?.collections?.[name] || this.context?.environments?.collections?.[name]; }); - eleventyConfig.addTemplate("index.njk", `{% import "macros-filter.njk" as forms %}{{ forms.label('test') }}`); + $config.addTemplate("index.njk", `{% import "macros-filter.njk" as forms %}{{ forms.label('test') }}`); } }); diff --git a/test/Issue775Test.js b/test/Issue775Test.js index d79acabfc..9ea4d9bbd 100644 --- a/test/Issue775Test.js +++ b/test/Issue775Test.js @@ -3,16 +3,16 @@ import Eleventy from "../src/Core.js"; test("#775 Using data cascade in Collection API", async (t) => { let elev = new Eleventy("test/noop", false, { - config(eleventyConfig) { - eleventyConfig.addCollection("apic", collectionApi => { + config($config) { + $config.addCollection("apic", collectionApi => { return collectionApi.getFilteredByTag("posts").filter(entry => { return entry.data.keep; }); }) - eleventyConfig.addTemplate("post1.md", `# Header`, { tags: "posts", keep: true }); - eleventyConfig.addTemplate("post2.md", `# Header`, { tags: "posts" }); - eleventyConfig.addTemplate("post3.md", `# Header`, { tags: "posts" }); - eleventyConfig.addTemplate("index.njk", `{{ collections.apic.length }}`); + $config.addTemplate("post1.md", `# Header`, { tags: "posts", keep: true }); + $config.addTemplate("post2.md", `# Header`, { tags: "posts" }); + $config.addTemplate("post3.md", `# Header`, { tags: "posts" }); + $config.addTemplate("index.njk", `{{ collections.apic.length }}`); } }); diff --git a/test/JavaScriptFrontMatterTest.js b/test/JavaScriptFrontMatterTest.js index 5d40d4355..415aff2b3 100644 --- a/test/JavaScriptFrontMatterTest.js +++ b/test/JavaScriptFrontMatterTest.js @@ -14,8 +14,8 @@ test("Custom Front Matter Parsing Options (using JavaScript node-retrieve-global test("Custom Front Matter Parsing Options (using JavaScript node-retrieve-globals), override project-wide front matter default.", async (t) => { let elev = new Eleventy("./test/stubs/script-frontmatter/test-default.njk", "./_site", { - config: (eleventyConfig) => { - eleventyConfig.setFrontMatterParsingOptions({ + config: ($config) => { + $config.setFrontMatterParsingOptions({ language: "js", }); }, @@ -43,8 +43,8 @@ test("Custom Front Matter Parsing Options (using backwards-compatible `js` inste // https://github.com/11ty/eleventy/issues/3917 test("Issue #3917 previous JS object front matter shouldn’t have had implicit exports turned on", async (t) => { let elev = new Eleventy("./test/stubs-virtual-nowrite", "./test/stubs-virtual-nowrite/_site", { - config: function(eleventyConfig) { - eleventyConfig.addTemplate("test.njk", `---js + config: function($config) { + $config.addTemplate("test.njk", `---js { eleventyComputed: { summary: async function (data) { diff --git a/test/PaginationTest.js b/test/PaginationTest.js index 12a5bbe16..41a56d4ba 100644 --- a/test/PaginationTest.js +++ b/test/PaginationTest.js @@ -131,15 +131,15 @@ test("Paginate data in frontmatter", async (t) => { }); test("Paginate external data file", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs", output: "dist", } }); - let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new ExtensionMap(eleventyConfig); + let dataObj = new TemplateData($config); + dataObj.extensionMap = new ExtensionMap($config); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -150,7 +150,7 @@ test("Paginate external data file", async (t) => { "./dist", dataObj, null, - eleventyConfig + $config ); let data = await tmpl.getData(); @@ -354,15 +354,15 @@ test("Template with Pagination", async (t) => { }); test("Issue 135", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs", output: "dist", } }); - let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new ExtensionMap(eleventyConfig); + let dataObj = new TemplateData($config); + dataObj.extensionMap = new ExtensionMap($config); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -373,7 +373,7 @@ test("Issue 135", async (t) => { "./dist", dataObj, null, - eleventyConfig + $config ); let data = await tmpl.getData(); @@ -507,7 +507,7 @@ test("Page over an object (filtered, string)", async (t) => { }); test("Pagination with deep data merge #147", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs", output: "dist", @@ -520,7 +520,7 @@ test("Pagination with deep data merge #147", async (t) => { "./dist", null, null, - eleventyConfig + $config ); tmpl.config.keys.layout = "layout"; @@ -580,7 +580,7 @@ test("Paginate data in frontmatter (reversed)", async (t) => { }); test("No circular dependency (does not throw)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); new Pagination( null, @@ -594,7 +594,7 @@ test("No circular dependency (does not throw)", async (t) => { }, tags: ["tag2"], }, - eleventyConfig + $config ); t.true(true); @@ -602,7 +602,7 @@ test("No circular dependency (does not throw)", async (t) => { test("Circular dependency (pagination iterates over tag1 but also supplies pages to tag1)", async (t) => { await t.throwsAsync(async () => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); new Pagination( null, @@ -617,13 +617,13 @@ test("Circular dependency (pagination iterates over tag1 but also supplies pages }, tags: ["tag1"], }, - eleventyConfig + $config ); }); }); test("Circular dependency but should not error because it uses eleventyExcludeFromCollections", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); new Pagination( null, @@ -639,7 +639,7 @@ test("Circular dependency but should not error because it uses eleventyExcludeFr }, tags: ["tag1"], }, - eleventyConfig + $config ); t.true(true); @@ -692,15 +692,15 @@ test("Pagination `before` Callback with `reverse: true` (test order of operation }); test("Pagination new v0.10.0 href/hrefs", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs", output: "dist", } }); - let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new ExtensionMap(eleventyConfig); + let dataObj = new TemplateData($config); + dataObj.extensionMap = new ExtensionMap($config); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -711,7 +711,7 @@ test("Pagination new v0.10.0 href/hrefs", async (t) => { "./dist", dataObj, null, - eleventyConfig + $config ); let data = await tmpl.getData(); @@ -730,15 +730,15 @@ test("Pagination new v0.10.0 href/hrefs", async (t) => { }); test("Pagination new v0.10.0 page/pages", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs", output: "dist", } }); - let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new ExtensionMap(eleventyConfig); + let dataObj = new TemplateData($config); + dataObj.extensionMap = new ExtensionMap($config); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -749,7 +749,7 @@ test("Pagination new v0.10.0 page/pages", async (t) => { "./dist", dataObj, null, - eleventyConfig + $config ); let data = await tmpl.getData(); @@ -796,15 +796,15 @@ test("Pagination make sure pageNumber is numeric for {{ pageNumber + 1 }} Issue }); test("Pagination mutable global data", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs/paged-global-data-mutable/", output: "dist", } }); - let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new ExtensionMap(eleventyConfig); + let dataObj = new TemplateData($config); + dataObj.extensionMap = new ExtensionMap($config); dataObj.setProjectUsingEsm(true); dataObj.setFileSystemSearch(new FileSystemSearch()); await dataObj.getGlobalData(); @@ -815,7 +815,7 @@ test("Pagination mutable global data", async (t) => { "./dist", dataObj, null, - eleventyConfig + $config ); let data = await tmpl.getData(); @@ -840,15 +840,15 @@ test("Pagination mutable global data", async (t) => { }); test("Pagination template/dir data files run once, Issue 919", async (t) => { - let eleventyConfig = await getTemplateConfigInstance({ + let $config = await getTemplateConfigInstance({ dir: { input: "test/stubs-919", output: "dist", } }); - let dataObj = new TemplateData(eleventyConfig); - dataObj.extensionMap = new ExtensionMap(eleventyConfig); + let dataObj = new TemplateData($config); + dataObj.extensionMap = new ExtensionMap($config); dataObj.setProjectUsingEsm(true); let tmpl = await getNewTemplate( @@ -857,7 +857,7 @@ test("Pagination template/dir data files run once, Issue 919", async (t) => { "./dist", dataObj, null, - eleventyConfig + $config ); let data = await tmpl.getData(); diff --git a/test/PreserveClosingTagsPluginTest.js b/test/PreserveClosingTagsPluginTest.js index fd144e188..ee2b88d66 100644 --- a/test/PreserveClosingTagsPluginTest.js +++ b/test/PreserveClosingTagsPluginTest.js @@ -5,10 +5,10 @@ import Eleventy from "../src/Core.js"; test("Using the PreserveClosingTagsPlugin plugin (meta off) #3356", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(PreserveClosingTagsPlugin); + config: function ($config) { + $config.addPlugin(PreserveClosingTagsPlugin); - eleventyConfig.addTemplate("test.njk", ``, {}); + $config.addTemplate("test.njk", ``, {}); }, }); @@ -18,12 +18,12 @@ test("Using the PreserveClosingTagsPlugin plugin (meta off) #3356", async (t) => test("Using the PreserveClosingTagsPlugin plugin (meta on) #3356", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(PreserveClosingTagsPlugin, { + config: function ($config) { + $config.addPlugin(PreserveClosingTagsPlugin, { tags: ["meta"] }); - eleventyConfig.addTemplate("test.njk", ``, {}); + $config.addTemplate("test.njk", ``, {}); }, }); @@ -33,12 +33,12 @@ test("Using the PreserveClosingTagsPlugin plugin (meta on) #3356", async (t) => test("Using the PreserveClosingTagsPlugin plugin (meta on, link off) #3356", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(PreserveClosingTagsPlugin, { + config: function ($config) { + $config.addPlugin(PreserveClosingTagsPlugin, { tags: ["meta"] }); - eleventyConfig.addTemplate("test.njk", ``, {}); + $config.addTemplate("test.njk", ``, {}); }, }); @@ -48,12 +48,12 @@ test("Using the PreserveClosingTagsPlugin plugin (meta on, link off) #3356", asy test("Using the PreserveClosingTagsPlugin plugin (meta on, link on) #3356", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(PreserveClosingTagsPlugin, { + config: function ($config) { + $config.addPlugin(PreserveClosingTagsPlugin, { tags: ["meta", "link"] }); - eleventyConfig.addTemplate("test.njk", ``, {}); + $config.addTemplate("test.njk", ``, {}); }, }); @@ -63,12 +63,12 @@ test("Using the PreserveClosingTagsPlugin plugin (meta on, link on) #3356", asyn test("Using the PreserveClosingTagsPlugin plugin (meta on, link on, title off) #3356", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(PreserveClosingTagsPlugin, { + config: function ($config) { + $config.addPlugin(PreserveClosingTagsPlugin, { tags: ["meta", "link"] }); - eleventyConfig.addTemplate("test.njk", `My Title`, {}); + $config.addTemplate("test.njk", `My Title`, {}); }, }); diff --git a/test/ReservedDataTest.js b/test/ReservedDataTest.js index a242e2d93..2f68a7e3c 100644 --- a/test/ReservedDataTest.js +++ b/test/ReservedDataTest.js @@ -29,9 +29,9 @@ test("`page` subkeys", t => { test("Eleventy freeze data set via config API throws error (page)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { configPath: "./test/stubs-virtual/eleventy.config.js", - config: eleventyConfig => { - eleventyConfig.addGlobalData("page", "lol no"); - eleventyConfig.addTemplate("index.html", ``); + config: $config => { + $config.addGlobalData("page", "lol no"); + $config.addTemplate("index.html", ``); } }); elev.disableLogger(); @@ -44,9 +44,9 @@ test("Eleventy freeze data set via config API throws error (page)", async (t) => test("Eleventy freeze data set via config API throws error (eleventy)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { configPath: "./test/stubs-virtual/eleventy.config.js", - config: eleventyConfig => { - eleventyConfig.addGlobalData("eleventy", "lol no"); - eleventyConfig.addTemplate("index.html", ``); + config: $config => { + $config.addGlobalData("eleventy", "lol no"); + $config.addTemplate("index.html", ``); } }); elev.disableLogger(); @@ -59,8 +59,8 @@ test("Eleventy freeze data set via config API throws error (eleventy)", async (t test("Eleventy freeze data set global data file throws error (page)", async (t) => { let elev = new Eleventy({ input: "./test/stubs-freeze/page/", - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", ``); + config: $config => { + $config.addTemplate("index.html", ``); } }); elev.disableLogger(); @@ -73,8 +73,8 @@ test("Eleventy freeze data set global data file throws error (page)", async (t) test("Eleventy freeze data set global data file throws error (eleventy)", async (t) => { let elev = new Eleventy({ input: "./test/stubs-freeze/eleventy/", - config: eleventyConfig => { - eleventyConfig.addTemplate("index.html", ``); + config: $config => { + $config.addTemplate("index.html", ``); } }); elev.disableLogger(); diff --git a/test/TemplateCollectionTest.js b/test/TemplateCollectionTest.js index 55983104a..ae9ab2c0b 100644 --- a/test/TemplateCollectionTest.js +++ b/test/TemplateCollectionTest.js @@ -7,11 +7,11 @@ import Sortable from "../src/Util/Objects/Sortable.js"; import getNewTemplateForTests from "../test/_getNewTemplateForTests.js"; import { getTemplateConfigInstance } from "./_testHelpers.js"; -function getNewTemplate(filename, input, output, eleventyConfig) { - return getNewTemplateForTests(filename, input, output, null, null, eleventyConfig); +function getNewTemplate(filename, input, output, $config) { + return getNewTemplateForTests(filename, input, output, null, null, $config); } -function getNewTemplateByNumber(num, eleventyConfig) { +function getNewTemplateByNumber(num, $config) { let extensions = ["md", "md", "md", "md", "md", "html", "njk", "md", "md", "md"]; return getNewTemplateForTests( @@ -20,7 +20,7 @@ function getNewTemplateByNumber(num, eleventyConfig) { "./test/stubs/_site", null, null, - eleventyConfig, + $config, ); } @@ -32,11 +32,11 @@ async function addTemplate(collection, template) { } test("Basic setup", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl1 = await getNewTemplateByNumber(1, eleventyConfig); - let tmpl2 = await getNewTemplateByNumber(2, eleventyConfig); - let tmpl3 = await getNewTemplateByNumber(3, eleventyConfig); + let tmpl1 = await getNewTemplateByNumber(1, $config); + let tmpl2 = await getNewTemplateByNumber(2, $config); + let tmpl3 = await getNewTemplateByNumber(3, $config); let c = new Collection(); await addTemplate(c, tmpl1); @@ -47,11 +47,11 @@ test("Basic setup", async (t) => { }); test("sortFunctionDate", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl1 = await getNewTemplateByNumber(1, eleventyConfig); - let tmpl4 = await getNewTemplateByNumber(4, eleventyConfig); - let tmpl5 = await getNewTemplateByNumber(5, eleventyConfig); + let tmpl1 = await getNewTemplateByNumber(1, $config); + let tmpl4 = await getNewTemplateByNumber(4, $config); + let tmpl5 = await getNewTemplateByNumber(5, $config); let c = new Collection(); await addTemplate(c, tmpl1); @@ -66,11 +66,11 @@ test("sortFunctionDate", async (t) => { }); test("sortFunctionDateInputPath", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl1 = await getNewTemplateByNumber(1, eleventyConfig); - let tmpl4 = await getNewTemplateByNumber(4, eleventyConfig); - let tmpl5 = await getNewTemplateByNumber(5, eleventyConfig); + let tmpl1 = await getNewTemplateByNumber(1, $config); + let tmpl4 = await getNewTemplateByNumber(4, $config); + let tmpl5 = await getNewTemplateByNumber(5, $config); let c = new Collection(); await addTemplate(c, tmpl1); @@ -85,11 +85,11 @@ test("sortFunctionDateInputPath", async (t) => { }); test("getFilteredByTag", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl1 = await getNewTemplateByNumber(1, eleventyConfig); - let tmpl2 = await getNewTemplateByNumber(2, eleventyConfig); - let tmpl3 = await getNewTemplateByNumber(3, eleventyConfig); + let tmpl1 = await getNewTemplateByNumber(1, $config); + let tmpl2 = await getNewTemplateByNumber(2, $config); + let tmpl3 = await getNewTemplateByNumber(3, $config); let c = new Collection(); await addTemplate(c, tmpl1); @@ -112,11 +112,11 @@ test("getFilteredByTag", async (t) => { }); test("getFilteredByTag (added out of order, sorted)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl1 = await getNewTemplateByNumber(1, eleventyConfig); - let tmpl2 = await getNewTemplateByNumber(2, eleventyConfig); - let tmpl3 = await getNewTemplateByNumber(3, eleventyConfig); + let tmpl1 = await getNewTemplateByNumber(1, $config); + let tmpl2 = await getNewTemplateByNumber(2, $config); + let tmpl3 = await getNewTemplateByNumber(3, $config); let c = new Collection(); await addTemplate(c, tmpl3); @@ -140,11 +140,11 @@ test("getFilteredByTag (added out of order, sorted)", async (t) => { }); test("getFilteredByTags", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl1 = await getNewTemplateByNumber(1, eleventyConfig); - let tmpl2 = await getNewTemplateByNumber(2, eleventyConfig); - let tmpl3 = await getNewTemplateByNumber(3, eleventyConfig); + let tmpl1 = await getNewTemplateByNumber(1, $config); + let tmpl2 = await getNewTemplateByNumber(2, $config); + let tmpl3 = await getNewTemplateByNumber(3, $config); let c = new Collection(); await addTemplate(c, tmpl1); @@ -166,11 +166,11 @@ test("getFilteredByTags", async (t) => { }); test("getFilteredByTags (added out of order, sorted)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl1 = await getNewTemplateByNumber(1, eleventyConfig); - let tmpl2 = await getNewTemplateByNumber(2, eleventyConfig); - let tmpl3 = await getNewTemplateByNumber(3, eleventyConfig); + let tmpl1 = await getNewTemplateByNumber(1, $config); + let tmpl2 = await getNewTemplateByNumber(2, $config); + let tmpl3 = await getNewTemplateByNumber(3, $config); let c = new Collection(); await addTemplate(c, tmpl3); @@ -195,11 +195,11 @@ test("getFilteredByTags (added out of order, sorted)", async (t) => { }); test("getFilteredByGlob", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl1 = await getNewTemplateByNumber(1, eleventyConfig); - let tmpl6 = await getNewTemplateByNumber(6, eleventyConfig); - let tmpl7 = await getNewTemplateByNumber(7, eleventyConfig); + let tmpl1 = await getNewTemplateByNumber(1, $config); + let tmpl6 = await getNewTemplateByNumber(6, $config); + let tmpl7 = await getNewTemplateByNumber(7, $config); let c = new Collection(); await addTemplate(c, tmpl1); @@ -212,11 +212,11 @@ test("getFilteredByGlob", async (t) => { }); test("getFilteredByGlob no dash dot", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl1 = await getNewTemplateByNumber(1, eleventyConfig); - let tmpl6 = await getNewTemplateByNumber(6, eleventyConfig); - let tmpl7 = await getNewTemplateByNumber(7, eleventyConfig); + let tmpl1 = await getNewTemplateByNumber(1, $config); + let tmpl6 = await getNewTemplateByNumber(6, $config); + let tmpl7 = await getNewTemplateByNumber(7, $config); let c = new Collection(); await addTemplate(c, tmpl1); @@ -234,19 +234,19 @@ test("getFilteredByGlob no dash dot", async (t) => { }); test("partial match on tag string, issue 95", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); let cat = await getNewTemplate( "./test/stubs/issue-95/cat.md", "./test/stubs/", "./test/stubs/_site", - eleventyConfig, + $config, ); let notacat = await getNewTemplate( "./test/stubs/issue-95/notacat.md", "./test/stubs/", "./test/stubs/_site", - eleventyConfig, + $config, ); let c = new Collection(); @@ -282,11 +282,11 @@ test("micromatch assumptions, issue #127", async (t) => { }); test("Sort in place (issue #352)", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl1 = await getNewTemplateByNumber(1, eleventyConfig); - let tmpl4 = await getNewTemplateByNumber(4, eleventyConfig); - let tmpl5 = await getNewTemplateByNumber(5, eleventyConfig); + let tmpl1 = await getNewTemplateByNumber(1, $config); + let tmpl4 = await getNewTemplateByNumber(4, $config); + let tmpl5 = await getNewTemplateByNumber(5, $config); let c = new Collection(); await addTemplate(c, tmpl1); @@ -313,11 +313,11 @@ test("Sort in place (issue #352)", async (t) => { }); test("getFilteredByTag with excludes", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); + let $config = await getTemplateConfigInstance(); - let tmpl8 = await getNewTemplateByNumber(8, eleventyConfig); - let tmpl9 = await getNewTemplateByNumber(9, eleventyConfig); - let tmpl10 = await getNewTemplateByNumber(10, eleventyConfig); + let tmpl8 = await getNewTemplateByNumber(8, $config); + let tmpl9 = await getNewTemplateByNumber(9, $config); + let tmpl10 = await getNewTemplateByNumber(10, $config); let c = new Collection(); await addTemplate(c, tmpl8); diff --git a/test/TemplateConfigTest.js b/test/TemplateConfigTest.js index 26a0e9afc..4e117e09e 100644 --- a/test/TemplateConfigTest.js +++ b/test/TemplateConfigTest.js @@ -126,8 +126,8 @@ test("Add namespaced plugin", async (t) => { let templateCfg = new TemplateConfig(); templateCfg.userConfig.namespace("testNamespace", function () { - templateCfg.userConfig.addPlugin(function (eleventyConfig) { - eleventyConfig.addFilter("MyFilterName", function () {}); + templateCfg.userConfig.addPlugin(function ($config) { + $config.addFilter("MyFilterName", function () {}); }); }); @@ -195,7 +195,7 @@ test("Nested Empty Outer namespace", async (t) => { }); // important for backwards compatibility with old -// `module.exports = function (eleventyConfig, pluginNamespace) {` +// `module.exports = function ($config, pluginNamespace) {` // plugin code test("Non-string namespaces are ignored", async (t) => { let templateCfg = new TemplateConfig(defaultConfig, "./test/stubs/config.cjs"); @@ -212,9 +212,9 @@ test("Non-string namespaces are ignored", async (t) => { test(".addPlugin oddity: I don’t think pluginNamespace was ever passed in here, but we don’t want this to break", async (t) => { let templateCfg = new TemplateConfig(defaultConfig, "./test/stubs/config.cjs"); - templateCfg.userConfig.addPlugin(function (eleventyConfig, pluginNamespace) { - eleventyConfig.namespace(pluginNamespace, () => { - eleventyConfig.addNunjucksFilter("myFilterName", function () {}); + templateCfg.userConfig.addPlugin(function ($config, pluginNamespace) { + $config.namespace(pluginNamespace, () => { + $config.addNunjucksFilter("myFilterName", function () {}); }); }); @@ -413,10 +413,10 @@ test("Nested .addPlugin calls", async (t) => { t.plan(2); let templateCfg = new TemplateConfig(); - templateCfg.userConfig.addPlugin(function OuterPlugin(eleventyConfig) { + templateCfg.userConfig.addPlugin(function OuterPlugin($config) { t.truthy(true); - eleventyConfig.addPlugin(function InnerPlugin(eleventyConfig) { + $config.addPlugin(function InnerPlugin($config) { t.truthy(true); }); }); @@ -430,13 +430,13 @@ test("Nested .addPlugin calls (×3)", async (t) => { t.plan(3); let templateCfg = new TemplateConfig(); - templateCfg.userConfig.addPlugin(function OuterPlugin(eleventyConfig) { + templateCfg.userConfig.addPlugin(function OuterPlugin($config) { t.truthy(true); - eleventyConfig.addPlugin(function InnerPlugin(eleventyConfig) { + $config.addPlugin(function InnerPlugin($config) { t.truthy(true); - eleventyConfig.addPlugin(function InnerPlugin(eleventyConfig) { + $config.addPlugin(function InnerPlugin($config) { t.truthy(true); }); }); @@ -452,15 +452,15 @@ test("Nested .addPlugin calls order", async (t) => { let templateCfg = new TemplateConfig(); let order = []; - templateCfg.userConfig.addPlugin(function OuterPlugin(eleventyConfig) { + templateCfg.userConfig.addPlugin(function OuterPlugin($config) { order.push(1); t.deepEqual(order, [1]); - eleventyConfig.addPlugin(function InnerPlugin(eleventyConfig) { + $config.addPlugin(function InnerPlugin($config) { order.push(2); t.deepEqual(order, [1, 2]); - eleventyConfig.addPlugin(function InnerPlugin(eleventyConfig) { + $config.addPlugin(function InnerPlugin($config) { order.push(3); t.deepEqual(order, [1, 2, 3]); }); @@ -477,26 +477,26 @@ test("Nested .addPlugin calls. More complex order", async (t) => { let templateCfg = new TemplateConfig(); let order = []; - templateCfg.userConfig.addPlugin(function OuterPlugin(eleventyConfig) { + templateCfg.userConfig.addPlugin(function OuterPlugin($config) { order.push("1"); t.deepEqual(order, ["1"]); - eleventyConfig.addPlugin(function InnerPlugin(eleventyConfig) { + $config.addPlugin(function InnerPlugin($config) { order.push("2"); t.deepEqual(order, ["1", "2"]); - eleventyConfig.addPlugin(function InnerPlugin(eleventyConfig) { + $config.addPlugin(function InnerPlugin($config) { order.push("3a"); t.deepEqual(order, ["1", "2", "3a"]); }); - eleventyConfig.addPlugin(function InnerPlugin(eleventyConfig) { + $config.addPlugin(function InnerPlugin($config) { order.push("3b"); t.deepEqual(order, ["1", "2", "3a", "3b"]); }); }); - eleventyConfig.addPlugin(function InnerPlugin(eleventyConfig) { + $config.addPlugin(function InnerPlugin($config) { order.push("2b"); t.deepEqual(order, ["1", "2", "3a", "3b", "2b"]); }); @@ -511,8 +511,8 @@ test(".addPlugin has access to pathPrefix", async (t) => { t.plan(1); let templateCfg = new TemplateConfig(); - templateCfg.userConfig.addPlugin(function (eleventyConfig) { - t.is(eleventyConfig.pathPrefix, "/"); + templateCfg.userConfig.addPlugin(function ($config) { + t.is($config.pathPrefix, "/"); }); await templateCfg.init(); @@ -525,8 +525,8 @@ test(".addPlugin has access to pathPrefix (override method)", async (t) => { let templateCfg = new TemplateConfig(); templateCfg.setPathPrefix("/test/"); - templateCfg.userConfig.addPlugin(function (eleventyConfig) { - t.is(eleventyConfig.pathPrefix, "/test/"); + templateCfg.userConfig.addPlugin(function ($config) { + t.is($config.pathPrefix, "/test/"); }); await templateCfg.init(); @@ -538,8 +538,8 @@ test("falsy pathPrefix should fall back to default", async (t) => { t.plan(1); let templateCfg = new TemplateConfig(defaultConfig, "./test/stubs/config-empty-pathprefix.cjs"); - templateCfg.userConfig.addPlugin(function (eleventyConfig) { - t.is(eleventyConfig.pathPrefix, "/"); + templateCfg.userConfig.addPlugin(function ($config) { + t.is($config.pathPrefix, "/"); }); await templateCfg.init(); @@ -550,10 +550,10 @@ test("falsy pathPrefix should fall back to default", async (t) => { test("Add async plugin", async (t) => { let templateCfg = new TemplateConfig(); - await templateCfg.userConfig.addPlugin(async (eleventyConfig) => { + await templateCfg.userConfig.addPlugin(async ($config) => { await new Promise((resolve) => { setTimeout(() => { - eleventyConfig.addFilter("myFilterName", function () {}); + $config.addFilter("myFilterName", function () {}); resolve(); }, 10); }); @@ -569,10 +569,10 @@ test("Add async plugin", async (t) => { test("Async namespace", async (t) => { let templateCfg = new TemplateConfig(); - await templateCfg.userConfig.namespace("testNamespace", async (eleventyConfig) => { + await templateCfg.userConfig.namespace("testNamespace", async ($config) => { await new Promise((resolve) => { setTimeout(() => { - eleventyConfig.addFilter("MyFilterName", function () {}); + $config.addFilter("MyFilterName", function () {}); resolve(); }, 10); }); @@ -586,8 +586,8 @@ test("Async namespace", async (t) => { }); test("ProjectDirectories instance exists in user accessible config", async (t) => { - let eleventyConfig = await getTemplateConfigInstance(); - let cfg = eleventyConfig.getConfig(); + let $config = await getTemplateConfigInstance(); + let cfg = $config.getConfig(); t.truthy(cfg.directories); t.is(cfg.directories.input, "./"); @@ -625,8 +625,8 @@ test("Test getters #3310", async (t) => { userCfg.addFilter("myFilter", function () {}); userCfg.addFilter("myAsyncFilter", async function () {}); - userCfg.addPlugin(function (eleventyConfig) { - eleventyConfig.addFilter("myPluginFilter", function () {}); + userCfg.addPlugin(function ($config) { + $config.addFilter("myPluginFilter", function () {}); }); await templateCfg.init(); diff --git a/test/TemplateDataTest.js b/test/TemplateDataTest.js index 74b30de29..ae377cb20 100644 --- a/test/TemplateDataTest.js +++ b/test/TemplateDataTest.js @@ -562,32 +562,26 @@ test("getLocalDataPaths (with setDataFileSuffixes and setDataFileBaseName #1699) "./test/stubs/index.howdy.mjs", "./test/stubs/index.howdy.cjs", "./test/stubs/index.howdy.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/index.howdy.mts", - "./test/stubs/index.howdy.cts", - "./test/stubs/index.howdy.ts", - ] : []), + "./test/stubs/index.howdy.mts", + "./test/stubs/index.howdy.cts", + "./test/stubs/index.howdy.ts", "./test/stubs/component/index.howdy.json", "./test/stubs/component/index.howdy.mjs", "./test/stubs/component/index.howdy.cjs", "./test/stubs/component/index.howdy.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/index.howdy.mts", - "./test/stubs/component/index.howdy.cts", - "./test/stubs/component/index.howdy.ts", - ] : []), + "./test/stubs/component/index.howdy.mts", + "./test/stubs/component/index.howdy.cts", + "./test/stubs/component/index.howdy.ts", "./test/stubs/component/component.json", "./test/stubs/component/component.howdy.json", "./test/stubs/component/component.howdy.mjs", "./test/stubs/component/component.howdy.cjs", "./test/stubs/component/component.howdy.js", - ...(isTypeScriptSupported() ? [ - "./test/stubs/component/component.howdy.mts", - "./test/stubs/component/component.howdy.cts", - "./test/stubs/component/component.howdy.ts", - ] : []), + "./test/stubs/component/component.howdy.mts", + "./test/stubs/component/component.howdy.cts", + "./test/stubs/component/component.howdy.ts", ]); }); diff --git a/test/TemplateRenderLiquidTest.js b/test/TemplateRenderLiquidTest.js index 76d3822ce..d0227d516 100644 --- a/test/TemplateRenderLiquidTest.js +++ b/test/TemplateRenderLiquidTest.js @@ -1047,12 +1047,12 @@ test("Liquid Parse for Symbols", async (t) => { test("Eleventy shortcode uses new built-in Liquid argument parsing behavior (spaces)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.setLiquidParameterParsing("builtin"); - eleventyConfig.addShortcode("test", (...args) => { + config: $config => { + $config.setLiquidParameterParsing("builtin"); + $config.addShortcode("test", (...args) => { return JSON.stringify(args); }) - eleventyConfig.addTemplate("index.liquid", `{% test abc def %}`, { + $config.addTemplate("index.liquid", `{% test abc def %}`, { abc: 123, def: 456 }); @@ -1066,12 +1066,12 @@ test("Eleventy shortcode uses new built-in Liquid argument parsing behavior (spa test("Eleventy shortcode uses new built-in Liquid argument parsing behavior (commas)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.setLiquidParameterParsing("builtin"); - eleventyConfig.addShortcode("test", (...args) => { + config: $config => { + $config.setLiquidParameterParsing("builtin"); + $config.addShortcode("test", (...args) => { return JSON.stringify(args); }) - eleventyConfig.addTemplate("index.liquid", `{% test abc, def %}`, { + $config.addTemplate("index.liquid", `{% test abc, def %}`, { abc: 123, def: 456 }); @@ -1085,12 +1085,12 @@ test("Eleventy shortcode uses new built-in Liquid argument parsing behavior (com test("Eleventy shortcode uses new built-in Liquid argument parsing behavior (commas, no spaces)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.setLiquidParameterParsing("builtin"); - eleventyConfig.addShortcode("test", (...args) => { + config: $config => { + $config.setLiquidParameterParsing("builtin"); + $config.addShortcode("test", (...args) => { return JSON.stringify(args); }) - eleventyConfig.addTemplate("index.liquid", `{% test abc,def %}`, { + $config.addTemplate("index.liquid", `{% test abc,def %}`, { abc: 123, def: 456 }); @@ -1104,12 +1104,12 @@ test("Eleventy shortcode uses new built-in Liquid argument parsing behavior (com test("Eleventy paired shortcode uses new built-in Liquid argument parsing behavior (spaces)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.setLiquidParameterParsing("builtin"); - eleventyConfig.addPairedShortcode("test", (...args) => { + config: $config => { + $config.setLiquidParameterParsing("builtin"); + $config.addPairedShortcode("test", (...args) => { return JSON.stringify(args); }) - eleventyConfig.addTemplate("index.liquid", `{% test abc def %}hi{% endtest %}`, { + $config.addTemplate("index.liquid", `{% test abc def %}hi{% endtest %}`, { abc: 123, def: 456 }); @@ -1123,12 +1123,12 @@ test("Eleventy paired shortcode uses new built-in Liquid argument parsing behavi test("Eleventy paired shortcode uses new built-in Liquid argument parsing behavior (commas)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.setLiquidParameterParsing("builtin"); - eleventyConfig.addPairedShortcode("test", (...args) => { + config: $config => { + $config.setLiquidParameterParsing("builtin"); + $config.addPairedShortcode("test", (...args) => { return JSON.stringify(args); }) - eleventyConfig.addTemplate("index.liquid", `{% test abc, def %}hi{% endtest %}`, { + $config.addTemplate("index.liquid", `{% test abc, def %}hi{% endtest %}`, { abc: 123, def: 456 }); @@ -1142,12 +1142,12 @@ test("Eleventy paired shortcode uses new built-in Liquid argument parsing behavi test("Eleventy paired shortcode uses new built-in Liquid argument parsing behavior (commas, no spaces)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.setLiquidParameterParsing("builtin"); - eleventyConfig.addPairedShortcode("test", (...args) => { + config: $config => { + $config.setLiquidParameterParsing("builtin"); + $config.addPairedShortcode("test", (...args) => { return JSON.stringify(args); }) - eleventyConfig.addTemplate("index.liquid", `{% test abc,def %}hi{% endtest %}`, { + $config.addTemplate("index.liquid", `{% test abc,def %}hi{% endtest %}`, { abc: 123, def: 456 }); @@ -1161,8 +1161,8 @@ test("Eleventy paired shortcode uses new built-in Liquid argument parsing behavi test("jsTruthy default changed, breaking in v4 #3507", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.liquid", `{% if emptyString %}notempty{% endif %}-{% if zero %}notzero{% endif %}-{% if not emptyString %}empty{% endif %}-{% if not zero %}zero{% endif %}`, { + config: $config => { + $config.addTemplate("index.liquid", `{% if emptyString %}notempty{% endif %}-{% if zero %}notzero{% endif %}-{% if not emptyString %}empty{% endif %}-{% if not zero %}zero{% endif %}`, { emptyString: "", zero: 0 }); @@ -1175,8 +1175,8 @@ test("jsTruthy default changed, breaking in v4 #3507", async (t) => { test("Use globals for page/eleventy/collections for use inside {% render %} #1541", async (t) => { let elev = new Eleventy("./test/stubs/stubs-1541/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.liquid", `{% render "render-source.liquid" %}`); + config: $config => { + $config.addTemplate("index.liquid", `{% render "render-source.liquid" %}`); } }); diff --git a/test/TemplateRenderPluginTest.js b/test/TemplateRenderPluginTest.js index 8d89be4be..023f0f5c4 100644 --- a/test/TemplateRenderPluginTest.js +++ b/test/TemplateRenderPluginTest.js @@ -12,9 +12,9 @@ import { normalizeNewLines } from "./Util/normalizeNewLines.js"; async function getTestOutput(input, configCallback = function () {}) { let elev = new Eleventy(input, "./_site/", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(RenderPlugin); - configCallback(eleventyConfig); + config: function ($config) { + $config.addPlugin(RenderPlugin); + configCallback($config); }, }); @@ -166,8 +166,8 @@ test("Remap non-object data to data._ if object is not passed in", async (t) => test("Direct use of render string plugin, rendering Nunjucks (and nested Liquid)", async (t) => { let renderMgr = new RenderManager(); - renderMgr.config(function (eleventyConfig) { - eleventyConfig.addFilter("testing", function () { + renderMgr.config(function ($config) { + $config.addFilter("testing", function () { return "tested."; }); }); @@ -206,8 +206,8 @@ tested. test("Direct use of render string plugin, rendering Liquid (and nested Nunjucks)", async (t) => { let renderMgr = new RenderManager(); - renderMgr.config(function (eleventyConfig) { - eleventyConfig.addFilter("testing", function () { + renderMgr.config(function ($config) { + $config.addFilter("testing", function () { return "tested."; }); }); @@ -246,9 +246,9 @@ tested. test("Direct use of render file plugin, rendering Nunjucks (and nested Liquid)", async (t) => { let fn = await RenderPluginFile("./test/stubs-render-plugin/liquid-direct.njk", { - config: function (eleventyConfig) { - eleventyConfig.addPlugin(RenderPlugin); - eleventyConfig.addFilter("testing", function () { + config: function ($config) { + $config.addPlugin(RenderPlugin); + $config.addFilter("testing", function () { return "tested."; }); }, @@ -308,8 +308,8 @@ test.skip("Use liquid in njk (access to all global data)", async (t) => { }); test("renderContent filter #3369 #3370 via renderTemplate (njk)", async (t) => { - let html = await getTestOutputForFile("./test/stubs-render-plugin/nunjucks-frontmatter.njk", (eleventyConfig) => { - eleventyConfig.addShortcode("test", () => "test content") + let html = await getTestOutputForFile("./test/stubs-render-plugin/nunjucks-frontmatter.njk", ($config) => { + $config.addShortcode("test", () => "test content") }); t.is(html, "test content"); }); diff --git a/test/TemplateTest-ComputedData.js b/test/TemplateTest-ComputedData.js index 8ad8dca3f..3951f7356 100644 --- a/test/TemplateTest-ComputedData.js +++ b/test/TemplateTest-ComputedData.js @@ -257,8 +257,8 @@ test("eleventyComputed render strings in arrays", async (t) => { test("Issue #3728 Computed data with arrays of different sizes, arrays are treated as a single unit", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("index.njk", `---js + config: $config => { + $config.addTemplate("index.njk", `---js const arr = [1,2,3,4,5]; const eleventyComputed = { arr: ["a", "b", "c"] @@ -276,21 +276,21 @@ const eleventyComputed = { test("Issue #3827 with Computed data with arrays and layouts (×2 eleventyComputed)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.setUseTemplateCache(false); - eleventyConfig.addTemplate("_includes/base.njk", `---js + config: $config => { + $config.setUseTemplateCache(false); + $config.addTemplate("_includes/base.njk", `---js const eleventyComputed = { arr: ["base", "base2"] }; --- {{ content | safe }}`); - eleventyConfig.addTemplate("page1.njk", `---js + $config.addTemplate("page1.njk", `---js const layout = "base.njk"; --- {{ arr }}`); - eleventyConfig.addTemplate("page2.njk", `---js + $config.addTemplate("page2.njk", `---js const layout = "base.njk"; const eleventyComputed = { arr: ["override", "override2"] @@ -317,18 +317,18 @@ const eleventyComputed = { test("Issue #3728 with Computed data with arrays and layouts (×1 eleventyComputed)", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", undefined, { - config: eleventyConfig => { - eleventyConfig.addTemplate("_includes/base.njk", `---js + config: $config => { + $config.addTemplate("_includes/base.njk", `---js const arr = ["base", 1]; --- {{ content | safe }}`); - eleventyConfig.addTemplate("page1.njk", `---js + $config.addTemplate("page1.njk", `---js const layout = "base.njk"; --- {{ arr }}`); - eleventyConfig.addTemplate("page2.njk", `---js + $config.addTemplate("page2.njk", `---js const layout = "base.njk"; const eleventyComputed = { arr: ["override", 2] diff --git a/test/_getNewTemplateForTests.js b/test/_getNewTemplateForTests.js index 02d952011..a3c443908 100644 --- a/test/_getNewTemplateForTests.js +++ b/test/_getNewTemplateForTests.js @@ -11,10 +11,10 @@ export default async function getNewTemplate( outputDir, templateData = null, map = null, - eleventyConfig = null + $config = null ) { - if (!eleventyConfig) { - eleventyConfig = await getTemplateConfigInstance({ + if (!$config) { + $config = await getTemplateConfigInstance({ dir: { input: inputDir, output: outputDir, @@ -22,9 +22,9 @@ export default async function getNewTemplate( }); } - let engineManager = new TemplateEngineManager(eleventyConfig); + let engineManager = new TemplateEngineManager($config); if (!map) { - map = new ExtensionMap(eleventyConfig); + map = new ExtensionMap($config); map.setFormats(["liquid", "md", "njk", "html", "11ty.js"]); map.engineManager = engineManager; } @@ -32,7 +32,7 @@ export default async function getNewTemplate( templateData.setFileSystemSearch(new FileSystemSearch()); templateData.extensionMap = map; } - let tmpl = new Template(path, templateData, map, eleventyConfig); + let tmpl = new Template(path, templateData, map, $config); await tmpl.getTemplateRender(); diff --git a/test/_issues/2250/2250-test.js b/test/_issues/2250/2250-test.js index 6d7f763cf..04d0647b0 100644 --- a/test/_issues/2250/2250-test.js +++ b/test/_issues/2250/2250-test.js @@ -3,8 +3,8 @@ import Eleventy from "../../../src/Core.js"; test("Issue #2250, page is available in filters", async (t) => { let elev = new Eleventy("./test/_issues/2250/", "./test/_issues/2250/_site", { - config: function (eleventyConfig) { - eleventyConfig.addFilter("getUrl", function () { + config: function ($config) { + $config.addFilter("getUrl", function () { return this.page.url; }); }, diff --git a/test/_issues/3697/3697-test.js b/test/_issues/3697/3697-test.js index 643514214..5e15bdc20 100644 --- a/test/_issues/3697/3697-test.js +++ b/test/_issues/3697/3697-test.js @@ -8,8 +8,8 @@ test("Number file names on global data files", async t => { // let dir = path.parse(fileURLToPath(import.meta.url)).dir; let dir = "./test/_issues/3697/"; let elev = new Eleventy(dir, undefined, { - config: function (eleventyConfig) { - eleventyConfig.addTemplate("index.11ty.js", function(data) { + config: function ($config) { + $config.addTemplate("index.11ty.js", function(data) { return '' + JSON.stringify(data.folder); }) }, diff --git a/test/_testHelpers.js b/test/_testHelpers.js index eb4808488..172be7355 100644 --- a/test/_testHelpers.js +++ b/test/_testHelpers.js @@ -11,19 +11,19 @@ import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import TemplateData from "../src/Data/TemplateData.js"; export async function getTemplateConfigInstance(configObj, dirs, configObjOverride = undefined) { - let eleventyConfig; + let $config; if(configObj instanceof TemplateConfig) { - eleventyConfig = configObj; + $config = configObj; configObj = undefined; if(!(dirs instanceof ProjectDirectories)) { throw new Error("Testing error: second argument to getTemplateConfigInstance must be a ProjectDirectories instance when the first argument is a TemplateConfig instance.") } } else { - eleventyConfig = new TemplateConfig(); + $config = new TemplateConfig(); } - eleventyConfig.setProjectUsingEsm(true); + $config.setProjectUsingEsm(true); if(!(dirs instanceof ProjectDirectories)) { dirs = new ProjectDirectories(); @@ -33,11 +33,11 @@ export async function getTemplateConfigInstance(configObj, dirs, configObjOverri dirs.setViaConfigObject(configObj?.dir || {}); } - eleventyConfig.setDirectories(dirs); + $config.setDirectories(dirs); - await eleventyConfig.init(configObjOverride || configObj); // overrides + await $config.init(configObjOverride || configObj); // overrides - return eleventyConfig; + return $config; } export async function getTemplateConfigInstanceCustomCallback(dirObject, configCallback) { @@ -48,10 +48,10 @@ export async function getTemplateConfigInstanceCustomCallback(dirObject, configC let dirs = new ProjectDirectories(); dirs.setViaConfigObject(dirObject); - let eleventyConfig = await getTemplateConfigInstance(tmplCfg, dirs, { + let $config = await getTemplateConfigInstance(tmplCfg, dirs, { dir: dirObject }); - return eleventyConfig; + return $config; } export function getTemplateWriterInstance(formats, templateConfig) { diff --git a/test/stubs-2258-2830-skip-layouts/eleventy.config.cjs b/test/stubs-2258-2830-skip-layouts/eleventy.config.cjs index 6f8a3758b..d63bb3898 100644 --- a/test/stubs-2258-2830-skip-layouts/eleventy.config.cjs +++ b/test/stubs-2258-2830-skip-layouts/eleventy.config.cjs @@ -1,10 +1,10 @@ const path = require("path"); const sass = require("sass"); -module.exports = function (eleventyConfig) { - eleventyConfig.addTemplateFormats("scss"); +module.exports = function ($config) { + $config.addTemplateFormats("scss"); - eleventyConfig.addExtension("scss", { + $config.addExtension("scss", { useLayouts: false, outputFileExtension: "css", // optional, default: "html" diff --git a/test/stubs-2258/eleventy.config.cjs b/test/stubs-2258/eleventy.config.cjs index 1098b8a8f..8b301a448 100644 --- a/test/stubs-2258/eleventy.config.cjs +++ b/test/stubs-2258/eleventy.config.cjs @@ -1,10 +1,10 @@ const path = require("path"); const sass = require("sass"); -module.exports = function (eleventyConfig) { - eleventyConfig.addTemplateFormats("scss"); +module.exports = function ($config) { + $config.addTemplateFormats("scss"); - eleventyConfig.addExtension("scss", { + $config.addExtension("scss", { outputFileExtension: "css", // optional, default: "html" compile: function (inputContent, inputPath) { diff --git a/test/stubs-2261/eleventy.config.js b/test/stubs-2261/eleventy.config.js index 076d99fe2..71e145244 100644 --- a/test/stubs-2261/eleventy.config.js +++ b/test/stubs-2261/eleventy.config.js @@ -1,5 +1,5 @@ -export default function(eleventyConfig) { - eleventyConfig.addPairedShortcode("sample", function(content, firstName) { +export default function($config) { + $config.addPairedShortcode("sample", function(content, firstName) { return `${content} ${firstName}` }); }; \ No newline at end of file diff --git a/test/stubs-3807/Issue3807test.js b/test/stubs-3807/Issue3807test.js index 74194307f..dbe1e3ad9 100644 --- a/test/stubs-3807/Issue3807test.js +++ b/test/stubs-3807/Issue3807test.js @@ -32,8 +32,8 @@ test("#3807 Nunjucks cacheable should be reused when Nunjucks is the preprocesso let index = 0; let elev = new Eleventy("test/stubs-3807/", "test/stubs-3807/_site", { configPath: "test/stubs-3807/eleventy.config.js", - config(eleventyConfig) { - eleventyConfig.on("buildawesome.afterwatch", () => { + config($config) { + $config.on("buildawesome.afterwatch", () => { let {resolve} = runs[index]; index++; resolve(); diff --git a/test/stubs-3807/eleventy.config.js b/test/stubs-3807/eleventy.config.js index 26e8f68ce..d97c31af7 100644 --- a/test/stubs-3807/eleventy.config.js +++ b/test/stubs-3807/eleventy.config.js @@ -1,5 +1,5 @@ -export default function(eleventyConfig) { - eleventyConfig.setLayoutsDirectory("_layouts"); +export default function($config) { + $config.setLayoutsDirectory("_layouts"); } export const config = { markdownTemplateEngine: "njk", diff --git a/test/stubs-3810/eleventy.config.js b/test/stubs-3810/eleventy.config.js index 804019fca..01b646eff 100644 --- a/test/stubs-3810/eleventy.config.js +++ b/test/stubs-3810/eleventy.config.js @@ -2,14 +2,14 @@ import fs from 'fs'; import { RenderPlugin } from '../../src/Core.js'; const { RenderManager } = RenderPlugin; -export default function(eleventyConfig) { +export default function($config) { const rm = new RenderManager(); - eleventyConfig.on('eleventy.config', cfg => { + $config.on('eleventy.config', cfg => { rm.templateConfig = cfg; }); - eleventyConfig.addAsyncShortcode('promo', async function (promoType) { + $config.addAsyncShortcode('promo', async function (promoType) { let content = fs.readFileSync('./test/stubs-3810/_includes/promo.njk').toString(); const fn = await rm.compile(content, 'njk'); diff --git a/test/stubs-virtual/eleventy.config.js b/test/stubs-virtual/eleventy.config.js index df22a2d10..e80fa91c4 100644 --- a/test/stubs-virtual/eleventy.config.js +++ b/test/stubs-virtual/eleventy.config.js @@ -1,2 +1,2 @@ // generic config file -export default function(eleventyConfig) {}; \ No newline at end of file +export default function($config) {}; \ No newline at end of file diff --git a/test/stubs/broken-config.cjs b/test/stubs/broken-config.cjs index 8c4d54ab5..d583cd5ea 100644 --- a/test/stubs/broken-config.cjs +++ b/test/stubs/broken-config.cjs @@ -1,7 +1,7 @@ const missingModule = require("this-is-a-module-that-does-not-exist"); -module.exports = function(eleventyConfig) { - eleventyConfig.addFilter("cssmin", function(code) { +module.exports = function($config) { + $config.addFilter("cssmin", function(code) { return missingModule(code); }); diff --git a/test/stubs/cfg-directories-export-cjs/eleventy.config.cjs b/test/stubs/cfg-directories-export-cjs/eleventy.config.cjs index c5ef04d72..8cea9f325 100644 --- a/test/stubs/cfg-directories-export-cjs/eleventy.config.cjs +++ b/test/stubs/cfg-directories-export-cjs/eleventy.config.cjs @@ -1,4 +1,4 @@ -module.exports = function(eleventyConfig) { +module.exports = function($config) { }; diff --git a/test/stubs/cfg-directories-export/eleventy.config.js b/test/stubs/cfg-directories-export/eleventy.config.js index 91e5e3112..0bb4f5191 100644 --- a/test/stubs/cfg-directories-export/eleventy.config.js +++ b/test/stubs/cfg-directories-export/eleventy.config.js @@ -1,4 +1,4 @@ -export default function(eleventyConfig) { +export default function($config) { }; From 96b5724a3a33d38d4ba52372596aaf172fa79dbf Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Wed, 10 Jun 2026 14:18:29 -0500 Subject: [PATCH 22/53] Add support for buildawesome: prefix on post html transformer API --- src/Plugins/IdAttributePlugin.js | 11 +++++++---- src/Util/PostHtml/Attrs.js | 19 +++++++++++++++++++ test/IdAttributePluginTest.js | 17 ++++++++++++++++- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 src/Util/PostHtml/Attrs.js diff --git a/src/Plugins/IdAttributePlugin.js b/src/Plugins/IdAttributePlugin.js index c8d165b17..5a7aa9076 100644 --- a/src/Plugins/IdAttributePlugin.js +++ b/src/Plugins/IdAttributePlugin.js @@ -1,12 +1,15 @@ import matchHelper from "posthtml-match-helper"; import { decodeHTML } from "entities"; -const POSTHTML_PLUGIN_NAME = "11ty/eleventy/id-attribute"; +import { resolveAttributeName } from "../Util/PostHtml/Attrs.js"; + +const POSTHTML_PLUGIN_NAME = "awesome.me/build/id-attribute"; function getTextNodeContent(node) { - let ignoredAttr = node.attrs?.["eleventy:id-ignore"]; - if (ignoredAttr === "" || ignoredAttr === true) { - delete node.attrs["eleventy:id-ignore"]; + let ignoredAttrName = resolveAttributeName(node.attrs, "buildawesome:id-ignore"); + + if (ignoredAttrName !== undefined) { + delete node.attrs[ignoredAttrName]; return ""; } if (!node.content) { diff --git a/src/Util/PostHtml/Attrs.js b/src/Util/PostHtml/Attrs.js new file mode 100644 index 000000000..4061acfdb --- /dev/null +++ b/src/Util/PostHtml/Attrs.js @@ -0,0 +1,19 @@ +const PREFIXES = { + eleventy: "eleventy:", + buildawesome: "buildawesome:", +}; + +export function resolveAttributeName(attrs = {}, attrName = "") { + let [prefix, name] = attrName.split(":"); + if (PREFIXES.eleventy + name in attrs) { + return PREFIXES.eleventy + name; + } + if (PREFIXES.buildawesome + name in attrs) { + return PREFIXES.buildawesome + name; + } +} + +export function hasAttribute(attrs = {}, attrName = "") { + let resolved = resolveAttributeName(attrName); + return attrs[resolved] !== undefined; +} diff --git a/test/IdAttributePluginTest.js b/test/IdAttributePluginTest.js index 03655bf19..e0752d81c 100644 --- a/test/IdAttributePluginTest.js +++ b/test/IdAttributePluginTest.js @@ -16,7 +16,7 @@ test("Using the IdAttribute plugin #3356", async (t) => { t.is(results[0].content, `

This is a heading

This is another heading

This is another heading

This is another heading

`); }); -test("Using the IdAttribute plugin, ignore attribute #3356", async (t) => { +test("Using the IdAttribute plugin, eleventy:ignore attribute #3356", async (t) => { let elev = new Eleventy({ input: "./test/stubs-3356/", // configPath: false, @@ -31,6 +31,21 @@ test("Using the IdAttribute plugin, ignore attribute #3356", async (t) => { t.is(results[0].content, `

This is a heading

This is another heading

This is another heading

This is another heading

`); }); +test("Using the IdAttribute plugin, buildawesome:ignore attribute #3356", async (t) => { + let elev = new Eleventy({ + input: "./test/stubs-3356/", + // configPath: false, + config: function ($config) { + $config.addPlugin(IdAttributePlugin); + + $config.addTemplate("test.njk", `

This is a heading

This is another heading

This is another heading

This is another heading

`, {}); + }, + }); + + let results = await elev.toJSON(); + t.is(results[0].content, `

This is a heading

This is another heading

This is another heading

This is another heading

`); +}); + test("Using the IdAttribute plugin with escaped quoted text", async (t) => { let elev = new Eleventy("./test/stubs-virtual/", "./test/stubs-virtual/_site", { config: function ($config) { From c1bda253aba845f879d0f2f496d0c75c6da1276c Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Wed, 10 Jun 2026 15:55:46 -0500 Subject: [PATCH 23/53] Restore .11tydata directory data file extension (default, unbreaking change) --- src/defaultConfig.js | 2 +- test/CoreTest.js | 4 +- test/FilesTest.js | 2 +- test/TemplateDataTest.js | 145 ++++++++++++++++++++++++++++++++- test/TemplateTest.js | 99 ++++++++++++++++++++++ test/UserDataExtensionsTest.js | 33 ++++++++ 6 files changed, 279 insertions(+), 6 deletions(-) diff --git a/src/defaultConfig.js b/src/defaultConfig.js index 9a0a6ecb7..daa7f5a11 100644 --- a/src/defaultConfig.js +++ b/src/defaultConfig.js @@ -80,7 +80,7 @@ export default function (config) { // Renamed from `jsDataFileSuffix` in 2.0 (and swapped to an Array) // If you remove "" we won’t look for dir/dir.json or file.json - dataFileSuffixes: [".data", ""], + dataFileSuffixes: [".data", ".11tydata", ""], // "index" will look for `directory/index.*` directory data files instead of `directory/directory.*` dataFileDirBaseNameOverride: false, diff --git a/test/CoreTest.js b/test/CoreTest.js index 403a717f5..5c514705d 100644 --- a/test/CoreTest.js +++ b/test/CoreTest.js @@ -143,7 +143,7 @@ test("Eleventy file watching", async (t) => { "./.gitignore", "./.eleventyignore", "./test/stubs/.eleventyignore", - "./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts}", + "./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts,11tydata.mjs,11tydata.cjs,11tydata.js,11tydata.mts,11tydata.cts,11tydata.ts}", "./test/stubs/deps/dep1.cjs", "./test/stubs/deps/dep2.cjs", ]); @@ -194,7 +194,7 @@ test("Eleventy file watching (no JS dependencies)", async (t) => { "./.gitignore", "./.eleventyignore", "./test/stubs/.eleventyignore", - `./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts}`, + `./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts,11tydata.mjs,11tydata.cjs,11tydata.js,11tydata.mts,11tydata.cts,11tydata.ts}`, ]); t.true(ignores.includes("node_modules/**")); diff --git a/test/FilesTest.js b/test/FilesTest.js index 4504fb092..d47f2c9a5 100644 --- a/test/FilesTest.js +++ b/test/FilesTest.js @@ -452,7 +452,7 @@ test("Glob Watcher Files with Config Passthroughs (no template formats)", async evf.init(); t.deepEqual(await evf.getGlobWatcherTemplateDataFiles(), [ - `./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts}`, + `./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts,11tydata.mjs,11tydata.cjs,11tydata.js,11tydata.mts,11tydata.cts,11tydata.ts}`, ]); }); diff --git a/test/TemplateDataTest.js b/test/TemplateDataTest.js index ae377cb20..69de38f29 100644 --- a/test/TemplateDataTest.js +++ b/test/TemplateDataTest.js @@ -141,8 +141,8 @@ test("Get local data async JS", async (t) => { let withLocalData = await testGetLocalData(dataObj, "./test/stubs/component-async/component.njk"); // from the js file - t.is(withLocalData.localdatakeyfromjs, "howdydoody"); t.is(withLocalData.localdatakeyfromcjs, "common-js-howdydoody"); + t.is(withLocalData.localdatakeyfromjs, "howdydoody"); }); test("addLocalData() doesn’t exist but doesn’t fail (template file does exist)", async (t) => { @@ -379,6 +379,15 @@ test("getLocalDataPaths", async (t) => { t.deepEqual(paths, [ "./test/stubs/stubs.json", + + "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", + "./test/stubs/stubs.11tydata.mts", + "./test/stubs/stubs.11tydata.cts", + "./test/stubs/stubs.11tydata.ts", + "./test/stubs/stubs.data.json", "./test/stubs/stubs.data.mjs", "./test/stubs/stubs.data.cjs", @@ -388,6 +397,15 @@ test("getLocalDataPaths", async (t) => { "./test/stubs/stubs.data.ts", "./test/stubs/component/component.json", + + "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", + "./test/stubs/component/component.11tydata.mts", + "./test/stubs/component/component.11tydata.cts", + "./test/stubs/component/component.11tydata.ts", + "./test/stubs/component/component.data.json", "./test/stubs/component/component.data.mjs", "./test/stubs/component/component.data.cjs", @@ -411,6 +429,14 @@ test("getLocalDataPaths (with setDataFileBaseName #1699)", async (t) => { let paths = await dataObj.getLocalDataPaths("./test/stubs/component/component.liquid"); t.deepEqual(paths, [ + "./test/stubs/index.11tydata.json", + "./test/stubs/index.11tydata.mjs", + "./test/stubs/index.11tydata.cjs", + "./test/stubs/index.11tydata.js", + "./test/stubs/index.11tydata.mts", + "./test/stubs/index.11tydata.cts", + "./test/stubs/index.11tydata.ts", + "./test/stubs/index.data.json", "./test/stubs/index.data.mjs", "./test/stubs/index.data.cjs", @@ -419,6 +445,14 @@ test("getLocalDataPaths (with setDataFileBaseName #1699)", async (t) => { "./test/stubs/index.data.cts", "./test/stubs/index.data.ts", + "./test/stubs/component/index.11tydata.json", + "./test/stubs/component/index.11tydata.mjs", + "./test/stubs/component/index.11tydata.cjs", + "./test/stubs/component/index.11tydata.js", + "./test/stubs/component/index.11tydata.mts", + "./test/stubs/component/index.11tydata.cts", + "./test/stubs/component/index.11tydata.ts", + "./test/stubs/component/index.data.json", "./test/stubs/component/index.data.mjs", "./test/stubs/component/index.data.cjs", @@ -428,6 +462,15 @@ test("getLocalDataPaths (with setDataFileBaseName #1699)", async (t) => { "./test/stubs/component/index.data.ts", "./test/stubs/component/component.json", + + "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", + "./test/stubs/component/component.11tydata.mts", + "./test/stubs/component/component.11tydata.cts", + "./test/stubs/component/component.11tydata.ts", + "./test/stubs/component/component.data.json", "./test/stubs/component/component.data.mjs", "./test/stubs/component/component.data.cjs", @@ -595,6 +638,15 @@ test("Deeper getLocalDataPaths", async (t) => { t.deepEqual(paths, [ "./test/test.json", + + "./test/test.11tydata.json", + "./test/test.11tydata.mjs", + "./test/test.11tydata.cjs", + "./test/test.11tydata.js", + "./test/test.11tydata.mts", + "./test/test.11tydata.cts", + "./test/test.11tydata.ts", + "./test/test.data.json", "./test/test.data.mjs", "./test/test.data.cjs", @@ -604,6 +656,15 @@ test("Deeper getLocalDataPaths", async (t) => { "./test/test.data.ts", "./test/stubs/stubs.json", + + "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", + "./test/stubs/stubs.11tydata.mts", + "./test/stubs/stubs.11tydata.cts", + "./test/stubs/stubs.11tydata.ts", + "./test/stubs/stubs.data.json", "./test/stubs/stubs.data.mjs", "./test/stubs/stubs.data.cjs", @@ -613,6 +674,15 @@ test("Deeper getLocalDataPaths", async (t) => { "./test/stubs/stubs.data.ts", "./test/stubs/component/component.json", + + "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", + "./test/stubs/component/component.11tydata.mts", + "./test/stubs/component/component.11tydata.cts", + "./test/stubs/component/component.11tydata.ts", + "./test/stubs/component/component.data.json", "./test/stubs/component/component.data.mjs", "./test/stubs/component/component.data.cjs", @@ -637,6 +707,15 @@ test("getLocalDataPaths with an 11ty js template", async (t) => { t.deepEqual(paths, [ "./test/stubs/stubs.json", + + "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", + "./test/stubs/stubs.11tydata.mts", + "./test/stubs/stubs.11tydata.cts", + "./test/stubs/stubs.11tydata.ts", + "./test/stubs/stubs.data.json", "./test/stubs/stubs.data.mjs", "./test/stubs/stubs.data.cjs", @@ -646,6 +725,15 @@ test("getLocalDataPaths with an 11ty js template", async (t) => { "./test/stubs/stubs.data.ts", "./test/stubs/component/component.json", + + "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", + "./test/stubs/component/component.11tydata.mts", + "./test/stubs/component/component.11tydata.cts", + "./test/stubs/component/component.11tydata.ts", + "./test/stubs/component/component.data.json", "./test/stubs/component/component.data.mjs", "./test/stubs/component/component.data.cjs", @@ -670,6 +758,15 @@ test("getLocalDataPaths with inputDir passed in (trailing slash)", async (t) => t.deepEqual(paths, [ "./test/stubs/stubs.json", + + "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", + "./test/stubs/stubs.11tydata.mts", + "./test/stubs/stubs.11tydata.cts", + "./test/stubs/stubs.11tydata.ts", + "./test/stubs/stubs.data.json", "./test/stubs/stubs.data.mjs", "./test/stubs/stubs.data.cjs", @@ -679,6 +776,15 @@ test("getLocalDataPaths with inputDir passed in (trailing slash)", async (t) => "./test/stubs/stubs.data.ts", "./test/stubs/component/component.json", + + "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", + "./test/stubs/component/component.11tydata.mts", + "./test/stubs/component/component.11tydata.cts", + "./test/stubs/component/component.11tydata.ts", + "./test/stubs/component/component.data.json", "./test/stubs/component/component.data.mjs", "./test/stubs/component/component.data.cjs", @@ -703,6 +809,15 @@ test("getLocalDataPaths with inputDir passed in (no trailing slash)", async (t) t.deepEqual(paths, [ "./test/stubs/stubs.json", + + "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", + "./test/stubs/stubs.11tydata.mts", + "./test/stubs/stubs.11tydata.cts", + "./test/stubs/stubs.11tydata.ts", + "./test/stubs/stubs.data.json", "./test/stubs/stubs.data.mjs", "./test/stubs/stubs.data.cjs", @@ -712,6 +827,15 @@ test("getLocalDataPaths with inputDir passed in (no trailing slash)", async (t) "./test/stubs/stubs.data.ts", "./test/stubs/component/component.json", + + "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", + "./test/stubs/component/component.11tydata.mts", + "./test/stubs/component/component.11tydata.cts", + "./test/stubs/component/component.11tydata.ts", + "./test/stubs/component/component.data.json", "./test/stubs/component/component.data.mjs", "./test/stubs/component/component.data.cjs", @@ -736,6 +860,15 @@ test("getLocalDataPaths with inputDir passed in (no leading slash)", async (t) = t.deepEqual(paths, [ "./test/stubs/stubs.json", + + "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", + "./test/stubs/stubs.11tydata.mts", + "./test/stubs/stubs.11tydata.cts", + "./test/stubs/stubs.11tydata.ts", + "./test/stubs/stubs.data.json", "./test/stubs/stubs.data.mjs", "./test/stubs/stubs.data.cjs", @@ -745,6 +878,14 @@ test("getLocalDataPaths with inputDir passed in (no leading slash)", async (t) = "./test/stubs/stubs.data.ts", "./test/stubs/component/component.json", + "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", + "./test/stubs/component/component.11tydata.mts", + "./test/stubs/component/component.11tydata.cts", + "./test/stubs/component/component.11tydata.ts", + "./test/stubs/component/component.data.json", "./test/stubs/component/component.data.mjs", "./test/stubs/component/component.data.cjs", @@ -779,7 +920,7 @@ test("getTemplateDataFileGlob", async (t) => { let tw = new TemplateData(eleventyConfig); t.deepEqual(await tw.getTemplateDataFileGlob(), [ - `./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts}`, + `./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts,11tydata.mjs,11tydata.cjs,11tydata.js,11tydata.mts,11tydata.cts,11tydata.ts}`, ]); }); diff --git a/test/TemplateTest.js b/test/TemplateTest.js index 5025e526e..19d7dc9bc 100644 --- a/test/TemplateTest.js +++ b/test/TemplateTest.js @@ -473,6 +473,15 @@ test("Local template data file import (without a global data json)", async (t) = let data = await tmpl.getData(); t.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [ "./test/stubs/stubs.json", + + "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", + "./test/stubs/stubs.11tydata.mts", + "./test/stubs/stubs.11tydata.cts", + "./test/stubs/stubs.11tydata.ts", + "./test/stubs/stubs.data.json", "./test/stubs/stubs.data.mjs", "./test/stubs/stubs.data.cjs", @@ -482,6 +491,15 @@ test("Local template data file import (without a global data json)", async (t) = "./test/stubs/stubs.data.ts", "./test/stubs/component/component.json", + + "./test/stubs/component/component.11tydata.json", + "./test/stubs/component/component.11tydata.mjs", + "./test/stubs/component/component.11tydata.cjs", + "./test/stubs/component/component.11tydata.js", + "./test/stubs/component/component.11tydata.mts", + "./test/stubs/component/component.11tydata.cts", + "./test/stubs/component/component.11tydata.ts", + "./test/stubs/component/component.data.json", "./test/stubs/component/component.data.mjs", "./test/stubs/component/component.data.cjs", @@ -517,6 +535,15 @@ test("Local template data file import (two subdirectories deep)", async (t) => { t.deepEqual(await dataObj.getLocalDataPaths(tmpl.getInputPath()), [ "./test/stubs/stubs.json", + + "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", + "./test/stubs/stubs.11tydata.mts", + "./test/stubs/stubs.11tydata.cts", + "./test/stubs/stubs.11tydata.ts", + "./test/stubs/stubs.data.json", "./test/stubs/stubs.data.mjs", "./test/stubs/stubs.data.cjs", @@ -526,6 +553,15 @@ test("Local template data file import (two subdirectories deep)", async (t) => { "./test/stubs/stubs.data.ts", "./test/stubs/firstdir/firstdir.json", + + "./test/stubs/firstdir/firstdir.11tydata.json", + "./test/stubs/firstdir/firstdir.11tydata.mjs", + "./test/stubs/firstdir/firstdir.11tydata.cjs", + "./test/stubs/firstdir/firstdir.11tydata.js", + "./test/stubs/firstdir/firstdir.11tydata.mts", + "./test/stubs/firstdir/firstdir.11tydata.cts", + "./test/stubs/firstdir/firstdir.11tydata.ts", + "./test/stubs/firstdir/firstdir.data.json", "./test/stubs/firstdir/firstdir.data.mjs", "./test/stubs/firstdir/firstdir.data.cjs", @@ -535,6 +571,15 @@ test("Local template data file import (two subdirectories deep)", async (t) => { "./test/stubs/firstdir/firstdir.data.ts", "./test/stubs/firstdir/seconddir/seconddir.json", + + "./test/stubs/firstdir/seconddir/seconddir.11tydata.json", + "./test/stubs/firstdir/seconddir/seconddir.11tydata.mjs", + "./test/stubs/firstdir/seconddir/seconddir.11tydata.cjs", + "./test/stubs/firstdir/seconddir/seconddir.11tydata.js", + "./test/stubs/firstdir/seconddir/seconddir.11tydata.mts", + "./test/stubs/firstdir/seconddir/seconddir.11tydata.cts", + "./test/stubs/firstdir/seconddir/seconddir.11tydata.ts", + "./test/stubs/firstdir/seconddir/seconddir.data.json", "./test/stubs/firstdir/seconddir/seconddir.data.mjs", "./test/stubs/firstdir/seconddir/seconddir.data.cjs", @@ -544,6 +589,15 @@ test("Local template data file import (two subdirectories deep)", async (t) => { "./test/stubs/firstdir/seconddir/seconddir.data.ts", "./test/stubs/firstdir/seconddir/component.json", + + "./test/stubs/firstdir/seconddir/component.11tydata.json", + "./test/stubs/firstdir/seconddir/component.11tydata.mjs", + "./test/stubs/firstdir/seconddir/component.11tydata.cjs", + "./test/stubs/firstdir/seconddir/component.11tydata.js", + "./test/stubs/firstdir/seconddir/component.11tydata.mts", + "./test/stubs/firstdir/seconddir/component.11tydata.cts", + "./test/stubs/firstdir/seconddir/component.11tydata.ts", + "./test/stubs/firstdir/seconddir/component.data.json", "./test/stubs/firstdir/seconddir/component.data.mjs", "./test/stubs/firstdir/seconddir/component.data.cjs", @@ -578,6 +632,15 @@ test("Posts inherits local JSON, layouts", async (t) => { let localDataPaths = await dataObj.getLocalDataPaths(tmpl.getInputPath()); t.deepEqual(localDataPaths, [ "./test/stubs/stubs.json", + + "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", + "./test/stubs/stubs.11tydata.mts", + "./test/stubs/stubs.11tydata.cts", + "./test/stubs/stubs.11tydata.ts", + "./test/stubs/stubs.data.json", "./test/stubs/stubs.data.mjs", "./test/stubs/stubs.data.cjs", @@ -587,6 +650,15 @@ test("Posts inherits local JSON, layouts", async (t) => { "./test/stubs/stubs.data.ts", "./test/stubs/posts/posts.json", + + "./test/stubs/posts/posts.11tydata.json", + "./test/stubs/posts/posts.11tydata.mjs", + "./test/stubs/posts/posts.11tydata.cjs", + "./test/stubs/posts/posts.11tydata.js", + "./test/stubs/posts/posts.11tydata.mts", + "./test/stubs/posts/posts.11tydata.cts", + "./test/stubs/posts/posts.11tydata.ts", + "./test/stubs/posts/posts.data.json", "./test/stubs/posts/posts.data.mjs", "./test/stubs/posts/posts.data.cjs", @@ -596,6 +668,15 @@ test("Posts inherits local JSON, layouts", async (t) => { "./test/stubs/posts/posts.data.ts", "./test/stubs/posts/post1.json", + + "./test/stubs/posts/post1.11tydata.json", + "./test/stubs/posts/post1.11tydata.mjs", + "./test/stubs/posts/post1.11tydata.cjs", + "./test/stubs/posts/post1.11tydata.js", + "./test/stubs/posts/post1.11tydata.mts", + "./test/stubs/posts/post1.11tydata.cts", + "./test/stubs/posts/post1.11tydata.ts", + "./test/stubs/posts/post1.data.json", "./test/stubs/posts/post1.data.mjs", "./test/stubs/posts/post1.data.cjs", @@ -645,6 +726,15 @@ test("Template and folder name are the same, make sure data imports work ok", as let localDataPaths = await dataObj.getLocalDataPaths(tmpl.getInputPath()); t.deepEqual(localDataPaths, [ "./test/stubs/stubs.json", + + "./test/stubs/stubs.11tydata.json", + "./test/stubs/stubs.11tydata.mjs", + "./test/stubs/stubs.11tydata.cjs", + "./test/stubs/stubs.11tydata.js", + "./test/stubs/stubs.11tydata.mts", + "./test/stubs/stubs.11tydata.cts", + "./test/stubs/stubs.11tydata.ts", + "./test/stubs/stubs.data.json", "./test/stubs/stubs.data.mjs", "./test/stubs/stubs.data.cjs", @@ -654,6 +744,15 @@ test("Template and folder name are the same, make sure data imports work ok", as "./test/stubs/stubs.data.ts", "./test/stubs/posts/posts.json", + + "./test/stubs/posts/posts.11tydata.json", + "./test/stubs/posts/posts.11tydata.mjs", + "./test/stubs/posts/posts.11tydata.cjs", + "./test/stubs/posts/posts.11tydata.js", + "./test/stubs/posts/posts.11tydata.mts", + "./test/stubs/posts/posts.11tydata.cts", + "./test/stubs/posts/posts.11tydata.ts", + "./test/stubs/posts/posts.data.json", "./test/stubs/posts/posts.data.mjs", "./test/stubs/posts/posts.data.cjs", diff --git a/test/UserDataExtensionsTest.js b/test/UserDataExtensionsTest.js index 26f6af68c..6dd963bf7 100644 --- a/test/UserDataExtensionsTest.js +++ b/test/UserDataExtensionsTest.js @@ -68,6 +68,17 @@ test("Local files", async (t) => { "./test/stubs-630/stubs-630.yaml", "./test/stubs-630/stubs-630.nosj", "./test/stubs-630/stubs-630.json", + + "./test/stubs-630/stubs-630.11tydata.yaml", + "./test/stubs-630/stubs-630.11tydata.nosj", + "./test/stubs-630/stubs-630.11tydata.json", + "./test/stubs-630/stubs-630.11tydata.mjs", + "./test/stubs-630/stubs-630.11tydata.cjs", + "./test/stubs-630/stubs-630.11tydata.js", + "./test/stubs-630/stubs-630.11tydata.mts", + "./test/stubs-630/stubs-630.11tydata.cts", + "./test/stubs-630/stubs-630.11tydata.ts", + "./test/stubs-630/stubs-630.data.yaml", "./test/stubs-630/stubs-630.data.nosj", "./test/stubs-630/stubs-630.data.json", @@ -81,6 +92,17 @@ test("Local files", async (t) => { "./test/stubs-630/component-yaml/component-yaml.yaml", "./test/stubs-630/component-yaml/component-yaml.nosj", "./test/stubs-630/component-yaml/component-yaml.json", + + "./test/stubs-630/component-yaml/component-yaml.11tydata.yaml", + "./test/stubs-630/component-yaml/component-yaml.11tydata.nosj", + "./test/stubs-630/component-yaml/component-yaml.11tydata.json", + "./test/stubs-630/component-yaml/component-yaml.11tydata.mjs", + "./test/stubs-630/component-yaml/component-yaml.11tydata.cjs", + "./test/stubs-630/component-yaml/component-yaml.11tydata.js", + "./test/stubs-630/component-yaml/component-yaml.11tydata.mts", + "./test/stubs-630/component-yaml/component-yaml.11tydata.cts", + "./test/stubs-630/component-yaml/component-yaml.11tydata.ts", + "./test/stubs-630/component-yaml/component-yaml.data.yaml", "./test/stubs-630/component-yaml/component-yaml.data.nosj", "./test/stubs-630/component-yaml/component-yaml.data.json", @@ -94,6 +116,17 @@ test("Local files", async (t) => { "./test/stubs-630/component-yaml/component.yaml", "./test/stubs-630/component-yaml/component.nosj", "./test/stubs-630/component-yaml/component.json", + + "./test/stubs-630/component-yaml/component.11tydata.yaml", + "./test/stubs-630/component-yaml/component.11tydata.nosj", + "./test/stubs-630/component-yaml/component.11tydata.json", + "./test/stubs-630/component-yaml/component.11tydata.mjs", + "./test/stubs-630/component-yaml/component.11tydata.cjs", + "./test/stubs-630/component-yaml/component.11tydata.js", + "./test/stubs-630/component-yaml/component.11tydata.mts", + "./test/stubs-630/component-yaml/component.11tydata.cts", + "./test/stubs-630/component-yaml/component.11tydata.ts", + "./test/stubs-630/component-yaml/component.data.yaml", "./test/stubs-630/component-yaml/component.data.nosj", "./test/stubs-630/component-yaml/component.data.json", From 6bc39be2bc1cc6c9f4c428d7a83baf5f54610c77 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Wed, 10 Jun 2026 17:50:55 -0500 Subject: [PATCH 24/53] Upgrade deps --- package-lock.json | 355 +++++++++++++++++++++++++++++++++++----------- package.json | 10 +- 2 files changed, 274 insertions(+), 91 deletions(-) diff --git a/package-lock.json b/package-lock.json index a8a5bd8f5..d99ff6dab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@11ty/dependency-tree": "^4.0.2", "@11ty/dependency-tree-esm": "^2.0.4", "@11ty/dependency-tree-typescript": "^1.0.0", - "@11ty/eleventy-dev-server": "file:../eleventy-dev-server", + "@11ty/eleventy-dev-server": "^3.0.0-alpha.10", "@11ty/eleventy-plugin-bundle": "^3.0.7", "@11ty/eleventy-utils": "^2.0.7", "@11ty/gray-matter": "^2.0.2", @@ -42,7 +42,7 @@ "picomatch": "^4.0.4", "posthtml": "^0.16.7", "posthtml-match-helper": "^2.0.3", - "semver": "^7.8.1", + "semver": "^7.8.4", "tinyglobby": "^0.2.17" }, "bin": { @@ -57,7 +57,7 @@ "@iarna/toml": "^2.2.5", "@mdx-js/node-loader": "^3.1.1", "@stylistic/eslint-plugin": "^5.10.0", - "@types/node": "^25.9.1", + "@types/node": "^25.9.3", "@vue/server-renderer": "^3.5.35", "@zachleat/noop": "^1.0.7", "ava": "^6.4.1", @@ -72,14 +72,14 @@ "markdown-it-emoji": "^3.0.0", "marked": "^17.0.6", "nano-staged": "^0.9.0", - "prettier": "^3.8.3", + "prettier": "^3.8.4", "pretty": "^2.0.0", "react": "^19.2.7", "react-dom": "^19.2.7", "sass": "^1.100.0", "simple-git-hooks": "^2.13.1", "tsx": "^4.22.4", - "typescript": "6.0.2", + "typescript": "6.0.3", "vue": "^3.5.35", "zod": "^4.4.3", "zod-validation-error": "^5.0.0" @@ -92,37 +92,6 @@ "url": "https://opencollective.com/11ty" } }, - "../eleventy-dev-server": { - "name": "@11ty/eleventy-dev-server", - "version": "3.0.0-alpha.8", - "license": "MIT", - "dependencies": { - "@11ty/eleventy-utils": "^2.0.7", - "@11ty/node-version-check": "^1.0.1", - "chokidar": "^5.0.0", - "debug": "^4.4.3", - "finalhandler": "^2.1.1", - "mime": "^4.1.0", - "minimist": "^1.2.8", - "morphdom": "^2.7.8", - "send": "^1.2.1", - "urlpattern-polyfill": "^10.1.0", - "ws": "^8.20.1" - }, - "bin": { - "eleventy-dev-server": "cmd.cjs" - }, - "devDependencies": { - "ava": "^6.4.1" - }, - "engines": { - "node": ">=20.19" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/11ty" - } - }, "node_modules/@11ty/client": { "resolved": "packages/browser", "link": true @@ -163,8 +132,33 @@ } }, "node_modules/@11ty/eleventy-dev-server": { - "resolved": "../eleventy-dev-server", - "link": true + "version": "3.0.0-alpha.10", + "resolved": "https://registry.npmjs.org/@11ty/eleventy-dev-server/-/eleventy-dev-server-3.0.0-alpha.10.tgz", + "integrity": "sha512-/3bR71s1Wgavp6wmTWPSEmVbNIawnaZiushHIPMuq9vVUKwJtegmY9C1TTPD2Z/Z1IHzuft/QNlZxEnKzXJttw==", + "license": "MIT", + "dependencies": { + "@11ty/eleventy-utils": "^2.0.7", + "@11ty/node-version-check": "^1.0.1", + "chokidar": "^5.0.0", + "debug": "^4.4.3", + "finalhandler": "^2.1.1", + "mime": "^4.1.0", + "minimist": "^1.2.8", + "morphdom": "^2.7.8", + "send": "^1.2.1", + "urlpattern-polyfill": "^10.1.0", + "ws": "^8.21.0" + }, + "bin": { + "eleventy-dev-server": "cmd.cjs" + }, + "engines": { + "node": ">=22.15" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/11ty" + } }, "node_modules/@11ty/eleventy-fetch": { "version": "5.1.0", @@ -2691,9 +2685,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2711,9 +2702,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2731,9 +2719,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2751,9 +2736,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2771,9 +2753,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2791,9 +2770,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3130,9 +3106,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "25.9.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.9.1.tgz", - "integrity": "sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg==", + "version": "25.9.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.9.3.tgz", + "integrity": "sha512-603BddQMv3pUcr4U2dhujk83N2tTDVr/34wII2B6bJy6g+8WD6yUb11jszNs0gdi4PesVWl7ABt8nYMVpnLUcg==", "dev": true, "license": "MIT", "dependencies": { @@ -4647,6 +4623,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/dependency-graph": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/dependency-graph/-/dependency-graph-1.0.0.tgz", @@ -4785,6 +4770,12 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, "node_modules/emittery": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/emittery/-/emittery-1.2.0.tgz", @@ -4805,6 +4796,15 @@ "dev": true, "license": "MIT" }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/entities": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/entities/-/entities-8.0.0.tgz", @@ -4955,6 +4955,12 @@ "node": ">=6" } }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, "node_modules/escape-string-regexp": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", @@ -5300,6 +5306,15 @@ "node": ">=0.10.0" } }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/evaluate-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/evaluate-value/-/evaluate-value-2.0.0.tgz", @@ -5486,6 +5501,27 @@ "node": ">=8" } }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -5570,6 +5606,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -5973,6 +6018,26 @@ "node": ">= 6" } }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/https-proxy-agent": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", @@ -6099,7 +6164,6 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, "license": "ISC" }, "node_modules/ini": { @@ -6771,9 +6835,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -6795,9 +6856,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -6819,9 +6877,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -6843,9 +6898,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -8062,6 +8114,46 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/mime": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-4.1.0.tgz", + "integrity": "sha512-X5ju04+cAzsojXKes0B/S4tcYtFAJ6tTMuSPBEn9CPGlrWr8Fiw7qYeLT0XyH80HSoAoqWCaz+MWKh22P7G1cw==", + "funding": [ + "https://github.com/sponsors/broofa" + ], + "license": "MIT", + "bin": { + "mime": "bin/cli.js" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/mimic-function": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", @@ -8128,6 +8220,12 @@ "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==", "license": "BSD-3-Clause" }, + "node_modules/morphdom": { + "version": "2.7.8", + "resolved": "https://registry.npmjs.org/morphdom/-/morphdom-2.7.8.tgz", + "integrity": "sha512-D/fR4xgGUyVRbdMGU6Nejea1RFzYxYtyurG4Fbv2Fi/daKlWKuXGLOdXtl+3eIwL110cI2hz1ZojGICjjFLgTg==", + "license": "MIT" + }, "node_modules/mrmime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", @@ -8334,6 +8432,18 @@ "node": ">=12.20.0" } }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -8533,6 +8643,15 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/path": { "version": "0.12.7", "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", @@ -8911,9 +9030,9 @@ } }, "node_modules/prettier": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.3.tgz", - "integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==", + "version": "3.8.4", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.4.tgz", + "integrity": "sha512-N2MylSdi48+5N/6S5j+maeHbUSIzzZ5uOcX5Hm4QpV8Dkb1HFjfAKTKX6yNPJQD9AhcT3ifHNB66tWTTJDi11Q==", "dev": true, "license": "MIT", "bin": { @@ -9051,6 +9170,15 @@ ], "license": "MIT" }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/react": { "version": "19.2.7", "resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz", @@ -9386,9 +9514,9 @@ } }, "node_modules/semver": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.1.tgz", - "integrity": "sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg==", + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.4.tgz", + "integrity": "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==", "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -9397,6 +9525,32 @@ "node": ">=10" } }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/serialize-error": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz", @@ -9431,6 +9585,12 @@ "node": ">= 0.4" } }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, "node_modules/sharp": { "version": "0.33.5", "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.5.tgz", @@ -9635,6 +9795,15 @@ "dev": true, "license": "MIT" }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/std-env": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.1.0.tgz", @@ -10014,6 +10183,15 @@ "node": ">=8.0" } }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, "node_modules/totalist": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", @@ -10123,9 +10301,9 @@ } }, "node_modules/typescript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.2.tgz", - "integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", + "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", "dev": true, "license": "Apache-2.0", "bin": { @@ -10279,6 +10457,12 @@ "punycode": "^2.1.0" } }, + "node_modules/urlpattern-polyfill": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-10.1.0.tgz", + "integrity": "sha512-IGjKp/o0NL3Bso1PymYURCJxMPNAf/ILOpendP9f5B6e1rTJgdgiOvgfoT8VxCAdY+Wisb9uhGaJJf3yZ2V9nw==", + "license": "MIT" + }, "node_modules/util": { "version": "0.12.5", "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", @@ -10851,10 +11035,9 @@ } }, "node_modules/ws": { - "version": "8.18.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", - "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", - "dev": true, + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", + "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", "license": "MIT", "engines": { "node": ">=10.0.0" @@ -11025,7 +11208,7 @@ }, "packages/browser": { "name": "@11ty/client", - "version": "4.0.0-alpha.8", + "version": "PRIVATE", "license": "MIT", "devDependencies": { "@11ty/package-bundler": "^0.5.6", diff --git a/package.json b/package.json index bc01c8207..325aa0309 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "@iarna/toml": "^2.2.5", "@mdx-js/node-loader": "^3.1.1", "@stylistic/eslint-plugin": "^5.10.0", - "@types/node": "^25.9.1", + "@types/node": "^25.9.3", "@vue/server-renderer": "^3.5.35", "@zachleat/noop": "^1.0.7", "ava": "^6.4.1", @@ -119,14 +119,14 @@ "markdown-it-emoji": "^3.0.0", "marked": "^17.0.6", "nano-staged": "^0.9.0", - "prettier": "^3.8.3", + "prettier": "^3.8.4", "pretty": "^2.0.0", "react": "^19.2.7", "react-dom": "^19.2.7", "sass": "^1.100.0", "simple-git-hooks": "^2.13.1", "tsx": "^4.22.4", - "typescript": "6.0.2", + "typescript": "6.0.3", "vue": "^3.5.35", "zod": "^4.4.3", "zod-validation-error": "^5.0.0" @@ -135,7 +135,7 @@ "@11ty/dependency-tree": "^4.0.2", "@11ty/dependency-tree-esm": "^2.0.4", "@11ty/dependency-tree-typescript": "^1.0.0", - "@11ty/eleventy-dev-server": "file:../eleventy-dev-server", + "@11ty/eleventy-dev-server": "^3.0.0-alpha.10", "@11ty/eleventy-plugin-bundle": "^3.0.7", "@11ty/eleventy-utils": "^2.0.7", "@11ty/gray-matter": "^2.0.2", @@ -162,7 +162,7 @@ "picomatch": "^4.0.4", "posthtml": "^0.16.7", "posthtml-match-helper": "^2.0.3", - "semver": "^7.8.1", + "semver": "^7.8.4", "tinyglobby": "^0.2.17" }, "overrides": { From b4ff9983b072cda65ef6d4944ca10e5a65618550 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Wed, 10 Jun 2026 17:51:29 -0500 Subject: [PATCH 25/53] Fetch data file globs correctly --- src/Core.js | 2 +- src/Data/TemplateData.js | 67 +++++++++++++++++++++++----------------- src/Files.js | 9 +++--- test/TemplateDataTest.js | 2 +- 4 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/Core.js b/src/Core.js index 1db68b439..63b22e327 100644 --- a/src/Core.js +++ b/src/Core.js @@ -326,7 +326,7 @@ export default class Core extends CoreFs { this.watchTargets.add(this.eleventyConfig.getActiveConfigPath()); // Template and Directory Data Files - this.watchTargets.add(await this.eleventyFiles.getGlobWatcherTemplateDataFiles()); + this.watchTargets.add(this.eleventyFiles.getGlobWatcherTemplateDataFiles()); let benchmark = this.watcherBench.get( "Watching JavaScript Dependencies (disable with `eleventyConfig.setWatchJavaScriptDependencies(false)`)", diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index c8bed5361..24d39fdd7 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -33,7 +33,7 @@ class TemplateData { // Would be nice if the priorities here matched (see also FilePathUtil used by config file paths) // (json not included) priority is reverse order - #eligiblePrioritizedExtensions = [ + #eligibleJavaScriptExtensions = [ ...(isTypeScriptSupported() ? ["ts", "cts", "mts"] : []), "js", "cjs", @@ -195,7 +195,7 @@ class TemplateData { } // This is a backwards compatibility helper with the old `jsDataFileSuffix` configuration API - getDataFileSuffixes() { + getConfigurationDataFileSuffixes() { // New API if (Array.isArray(this.config.dataFileSuffixes)) { return this.config.dataFileSuffixes; @@ -212,11 +212,10 @@ class TemplateData { return []; // if both of these entries are set to false, use no files } - // This is used exclusively for --watch and --serve chokidar targets - async getTemplateDataFileGlob() { - let suffixes = this.getDataFileSuffixes(); - let globSuffixes = new Set(); - globSuffixes.add("json"); // covers .data.json too + getAllDataFileSuffixes() { + let suffixes = this.getConfigurationDataFileSuffixes(); + let suffixesWithExtensions = new Set(); + suffixesWithExtensions.add("json"); // covers .data.json too // Typically using [ '.data', '' ] suffixes to find data files for (let suffix of suffixes) { @@ -229,14 +228,14 @@ class TemplateData { suffix = suffix.slice(1); } - globSuffixes.add(`${suffix || ""}.mjs`); - globSuffixes.add(`${suffix || ""}.cjs`); - globSuffixes.add(`${suffix || ""}.js`); + suffixesWithExtensions.add(`${suffix || ""}.mjs`); + suffixesWithExtensions.add(`${suffix || ""}.cjs`); + suffixesWithExtensions.add(`${suffix || ""}.js`); if (isTypeScriptSupported()) { - globSuffixes.add(`${suffix || ""}.mts`); - globSuffixes.add(`${suffix || ""}.cts`); - globSuffixes.add(`${suffix || ""}.ts`); + suffixesWithExtensions.add(`${suffix || ""}.mts`); + suffixesWithExtensions.add(`${suffix || ""}.cts`); + suffixesWithExtensions.add(`${suffix || ""}.ts`); } } @@ -247,29 +246,40 @@ class TemplateData { extension = extension.slice(1); } - globSuffixes.add(extension); // covers .data.{extension} too + suffixesWithExtensions.add(extension); // covers .data.{extension} too } } + return suffixesWithExtensions; + } + + // This is used exclusively for --watch and --serve chokidar targets + getTemplateDataFileGlob() { + let suffixesSet = this.getAllDataFileSuffixes(); + let paths = []; - if (globSuffixes.size > 0) { - paths.push(`${this.inputDir}**/*.{${Array.from(globSuffixes).join(",")}}`); + if (suffixesSet.size > 0) { + paths.push(`${this.inputDir}**/*.{${Array.from(suffixesSet).join(",")}}`); } return TemplatePath.addLeadingDotSlashArray(paths); } // For spidering dependencies - // TODO Can we reuse getTemplateDataFileGlob instead? Maybe just filter off the .json files before scanning for dependencies getTemplateJavaScriptDataFileGlob() { - let paths = []; - let suffixes = this.getDataFileSuffixes(); - for (let suffix of suffixes) { - if (suffix) { - // TODO this check is purely for backwards compat and I kinda feel like it shouldn’t be here - // paths.push(`${this.inputDir}/**/*${suffix || ""}.cjs`); // Same as above - paths.push(`${this.inputDir}**/*${suffix || ""}.js`); // TODO typescript? + let suffixes = Array.from(this.getAllDataFileSuffixes()).filter((entry) => { + let lastDotIndex = entry.lastIndexOf("."); + if (lastDotIndex === -1) { + return false; } + let ext = entry.slice(lastDotIndex + 1); + // prune out any non-JS extensions + return this.#eligibleJavaScriptExtensions.includes(ext); + }); + + let paths = []; + if (suffixes.length > 0) { + paths.push(`${this.inputDir}**/*.{${suffixes.join(",")}}`); } return TemplatePath.addLeadingDotSlashArray(paths); @@ -464,6 +474,7 @@ class TemplateData { } // Filter out files we know don't exist to avoid overhead for checking + // June 2026 tested improvement from short-circuiting first match for any file filename.11tydata.cjs would skip remaining filename.11tydata.* localDataPaths = localDataPaths.filter((path) => { return this.exists(path); }); @@ -591,7 +602,7 @@ class TemplateData { async getDataValue(path) { let extension = TemplatePath.getExtension(path); - if (this.#eligiblePrioritizedExtensions.includes(extension)) { + if (this.#eligibleJavaScriptExtensions.includes(extension)) { // JS data file or require’d JSON (no preprocessing needed) if (!this.exists(path)) { return {}; @@ -661,7 +672,7 @@ class TemplateData { } _addBaseToPaths(paths, base, extensions, nonEmptySuffixesOnly = false) { - let suffixes = this.getDataFileSuffixes(); + let suffixes = this.getConfigurationDataFileSuffixes(); for (let suffix of suffixes) { suffix = suffix || ""; @@ -672,7 +683,7 @@ class TemplateData { // data suffix if (suffix) { - for (let extension of this.#eligiblePrioritizedExtensions) { + for (let extension of this.#eligibleJavaScriptExtensions) { paths.push(base + suffix + "." + extension); } } @@ -694,7 +705,7 @@ class TemplateData { let fileNameNoExt = this.extensionMap.removeTemplateExtension(parsed.base); // default dataSuffix: .data, is appended in _addBaseToPaths - debug("Using %o suffixes to find data files.", this.getDataFileSuffixes()); + debug("Using %o suffixes to find data files.", this.getConfigurationDataFileSuffixes()); // Template data file paths let filePathNoExt = parsed.dir + "/" + fileNameNoExt; diff --git a/src/Files.js b/src/Files.js index e989b664b..12f7ec77c 100644 --- a/src/Files.js +++ b/src/Files.js @@ -403,17 +403,17 @@ export class Files { } /* For `eleventy --watch` */ - async getGlobWatcherTemplateDataFiles() { - let templateData = this.templateData; - return await templateData.getTemplateDataFileGlob(); + getGlobWatcherTemplateDataFiles() { + return this.templateData.getTemplateDataFileGlob(); } /* For `eleventy --watch` */ - // TODO this isn’t great but reduces complexity avoiding using TemplateData:getLocalDataPaths for each template in the cache + // Improvement: Move this up the pipeline and feed into the ExistsCache to alleviate TemplateData checks async getWatcherTemplateJavaScriptDataFiles() { let globs = this.templateData.getTemplateJavaScriptDataFileGlob(); let bench = this.aggregateBench.get("Searching the file system (watching)"); bench.before(); + let results = TemplatePath.addLeadingDotSlashArray( await this.fileSystemSearch.search("js-dependencies", globs, { ignore: [ @@ -425,6 +425,7 @@ export class Files { }), ); bench.after(); + return results; } diff --git a/test/TemplateDataTest.js b/test/TemplateDataTest.js index 69de38f29..9578d9cce 100644 --- a/test/TemplateDataTest.js +++ b/test/TemplateDataTest.js @@ -919,7 +919,7 @@ test("getTemplateDataFileGlob", async (t) => { let tw = new TemplateData(eleventyConfig); - t.deepEqual(await tw.getTemplateDataFileGlob(), [ + t.deepEqual(tw.getTemplateDataFileGlob(), [ `./test/stubs/**/*.{json,data.mjs,data.cjs,data.js,data.mts,data.cts,data.ts,11tydata.mjs,11tydata.cjs,11tydata.js,11tydata.mts,11tydata.cts,11tydata.ts}`, ]); }); From f881ed9930e03f3f35e093c7ad08a456f43216d2 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Wed, 10 Jun 2026 17:55:24 -0500 Subject: [PATCH 26/53] Restore 11ty.* typescript template support --- src/ExtensionMap.js | 4 ++++ test/TemplateWriterTest.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ExtensionMap.js b/src/ExtensionMap.js index 56518e7cd..0be6b2653 100644 --- a/src/ExtensionMap.js +++ b/src/ExtensionMap.js @@ -276,6 +276,10 @@ export default class ExtensionMap { this._extensionToKeyMap["server.ts"] = { key: "11ty.js", extension: "server.ts" }; this._extensionToKeyMap["server.cts"] = { key: "11ty.js", extension: "server.cts" }; this._extensionToKeyMap["server.mts"] = { key: "11ty.js", extension: "server.mts" }; + + this._extensionToKeyMap["11ty.ts"] = { key: "11ty.js", extension: "11ty.ts" }; + this._extensionToKeyMap["11ty.cts"] = { key: "11ty.js", extension: "11ty.cts" }; + this._extensionToKeyMap["11ty.mts"] = { key: "11ty.js", extension: "11ty.mts" }; } if ("extensionMap" in this.config) { diff --git a/test/TemplateWriterTest.js b/test/TemplateWriterTest.js index 2ff10a76f..50406df6d 100644 --- a/test/TemplateWriterTest.js +++ b/test/TemplateWriterTest.js @@ -511,7 +511,7 @@ test("Write Test 11ty.js", async (t) => { let { templateWriter: tw, eleventyFiles: evf } = getTemplateWriterInstance(["11ty.js"], eleventyConfig); let files = await glob(evf.getFileGlobs()); - t.deepEqual(evf.getRawFiles(), [`./test/stubs/writeTestJS/**/*.{server.js,server.cjs,server.mjs,11ty.js,11ty.cjs,11ty.mjs,server.ts,server.cts,server.mts}`]); + t.deepEqual(evf.getRawFiles(), [`./test/stubs/writeTestJS/**/*.{server.js,server.cjs,server.mjs,11ty.js,11ty.cjs,11ty.mjs,server.ts,server.cts,server.mts,11ty.ts,11ty.cts,11ty.mts}`]); t.deepEqual(files, ["test/stubs/writeTestJS/test.11ty.cjs"]); let { template: tmpl } = tw.createTemplate(files[0]); From 9d2136789e7c2215a804ba2cb6ef5ad65a01ccb0 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 10:31:30 -0500 Subject: [PATCH 27/53] Cleanup for verbose being passed around everywhere, orchestrate through logger instance. --- cmd.cjs | 13 ++++++++++--- src/Benchmark/BenchmarkGroup.js | 14 +++++++++----- src/Benchmark/BenchmarkManager.js | 26 +++++++++++++++++--------- src/CoreMinimal.js | 15 ++------------- src/Errors/ErrorHandler.js | 22 ++++++---------------- src/Template.js | 16 ++++------------ src/TemplateMap.js | 1 - src/TemplateWriter.js | 23 ++++++----------------- test/TemplateWriterTest.js | 2 -- test/_getNewTemplateForTests.js | 4 ++++ test/_testHelpers.js | 5 +++++ 11 files changed, 63 insertions(+), 78 deletions(-) diff --git a/cmd.cjs b/cmd.cjs index 53d5521eb..50684326c 100755 --- a/cmd.cjs +++ b/cmd.cjs @@ -32,6 +32,7 @@ async function exec() { // Notes about friendly error messaging with outdated Node versions: https://github.com/11ty/build-awesome/issues/3761 const { ErrorHandler } = await import("./src/Errors/ErrorHandler.js"); const { getEnvValue } = await import("./src/Util/EnvironmentVars.cjs"); + const { default: ConsoleLogger } = await import("./src/Util/ConsoleLogger.js"); // Defensive use of Node 22.8+ Module Compile Cache if(!getEnvValue("SKIP_NODE_COMPILE_CACHE")) { @@ -44,6 +45,12 @@ async function exec() { } try { + function getFallbackErrorHandler() { + let handler = new ErrorHandler(); + handler.logger = new ConsoleLogger(); + return handler; + } + const argv = minimist(process.argv.slice(2), { string: ["input", "output", "formats", "config", "pathprefix", "port", "to", "incremental", "loader"], boolean: [ @@ -70,7 +77,7 @@ async function exec() { debug("Arguments: %o", argv); const { default: Core } = await import("./src/Core.js"); - let handler = new ErrorHandler(); + let handler = getFallbackErrorHandler(); process.on("unhandledRejection", (error, promise) => { handler.fatal(error, "Unhandled rejection in promise"); @@ -101,7 +108,7 @@ async function exec() { loader: argv.loader, }); - // reuse ErrorHandler instance in Core + // override with ErrorHandler instance in Core handler = core.errorHandler; // Before init @@ -159,7 +166,7 @@ async function exec() { } } catch (error) { if(typeof ErrorHandler !== "undefined") { - let handler = new ErrorHandler(); + let handler = getFallbackErrorHandler(); handler.fatal(error, "Fatal Error (CLI)"); } else { console.error(error); diff --git a/src/Benchmark/BenchmarkGroup.js b/src/Benchmark/BenchmarkGroup.js index 601e10b7c..66628beb1 100644 --- a/src/Benchmark/BenchmarkGroup.js +++ b/src/Benchmark/BenchmarkGroup.js @@ -1,6 +1,5 @@ import { createDebug } from "obug"; -import ConsoleLogger from "../Util/ConsoleLogger.js"; import isAsyncFunction from "../Util/IsAsyncFunction.js"; import Benchmark from "./Benchmark.js"; @@ -9,16 +8,19 @@ const debugBenchmark = createDebug("BuildAwesome:Benchmark"); class BenchmarkGroup { constructor() { this.benchmarks = {}; - // Warning: aggregate benchmarks automatically default to false via BenchmarkManager->getBenchmarkGroup + this.isVerbose = true; - this.logger = new ConsoleLogger(); this.minimumThresholdMs = 50; this.minimumThresholdPercent = 8; } + setLogger(logger) { + this.logger = logger; + } + + // This is an override for aggregate benchmarks automatically default to false via BenchmarkManager->getBenchmarkGroup setIsVerbose(isVerbose) { this.isVerbose = isVerbose; - this.logger.isVerbose = isVerbose; } reset() { @@ -118,7 +120,9 @@ class BenchmarkGroup { totalForBenchmark >= this.minimumThresholdMs && percent > this.minimumThresholdPercent ) { - this.logger.warn(str); + if (this.isVerbose) { + this.logger.warn(str); + } } // Opt out of logging if low count (1× or 2×) or 0ms / 1% diff --git a/src/Benchmark/BenchmarkManager.js b/src/Benchmark/BenchmarkManager.js index ff937bd6c..61c00334c 100644 --- a/src/Benchmark/BenchmarkManager.js +++ b/src/Benchmark/BenchmarkManager.js @@ -1,11 +1,8 @@ import BenchmarkGroup from "./BenchmarkGroup.js"; -// TODO this should not be a singleton, it belongs in the config or somewhere on the Eleventy instance. - class BenchmarkManager { constructor() { this.benchmarkGroups = {}; - this.isVerbose = true; this.start = this.getNewTimestamp(); } @@ -24,8 +21,16 @@ class BenchmarkManager { return new Date().getTime(); } - setVerboseOutput(isVerbose) { - this.isVerbose = !!isVerbose; + setLogger(logger) { + if (!logger) { + return; + } + + this.logger = logger; + + for (let group of Object.values(this.benchmarkGroups)) { + group.setLogger(logger); + } } hasBenchmarkGroup(name) { @@ -34,15 +39,18 @@ class BenchmarkManager { getBenchmarkGroup(name) { if (!this.benchmarkGroups[name]) { - this.benchmarkGroups[name] = new BenchmarkGroup(); + let group = new BenchmarkGroup(); + if (this.logger) { + group.setLogger(this.logger); + } // Special behavior for aggregate benchmarks // so they don’t console.log every time if (name === "Aggregate") { - this.benchmarkGroups[name].setIsVerbose(false); - } else { - this.benchmarkGroups[name].setIsVerbose(this.isVerbose); + group.setIsVerbose(false); } + + this.benchmarkGroups[name] = group; } return this.benchmarkGroups[name]; diff --git a/src/CoreMinimal.js b/src/CoreMinimal.js index bcf4a6f7d..e5eaa7f53 100644 --- a/src/CoreMinimal.js +++ b/src/CoreMinimal.js @@ -298,6 +298,7 @@ export class CoreMinimal { * @description Singleton BenchmarkManager instance */ this.bench = this.config.benchmarkManager; + this.bench.setLogger(this.logger); if (performance) { debug("Eleventy warm up time: %o (ms)", performance.now()); @@ -465,13 +466,13 @@ export class CoreMinimal { this.config.events.emit("buildawesome.directories", this.directories.getUserspaceInstance()); this.writer = new TemplateWriter(formats, this.templateData, this.eleventyConfig); + this.writer.logger = this.logger; if (!viaConfigReset) { // set or restore cache this.#cache("TemplateWriter", this.writer); } - this.writer.logger = this.logger; this.writer.extensionMap = this.extensionMap; this.writer.setRunInitialBuild(this.isRunInitialBuild); @@ -488,7 +489,6 @@ Template Formats: ${formats.join(",")} Verbose Output: ${this.verboseMode}`; debug(debugStr); - this.writer.setVerboseOutput(this.verboseMode); this.writer.setDryRun(this.isDryRun); this.#needsInit = false; @@ -571,7 +571,6 @@ Verbose Output: ${this.verboseMode}`; get errorHandler() { if (!this.#errorHandler) { this.#errorHandler = new ErrorHandler(); - this.#errorHandler.isVerbose = this.verboseMode; this.#errorHandler.logger = this.logger; } @@ -599,16 +598,6 @@ Verbose Output: ${this.verboseMode}`; this.logger.isVerbose = isVerbose; } - this.bench.setVerboseOutput(isVerbose); - - if (this.writer) { - this.writer.setVerboseOutput(isVerbose); - } - - if (this.errorHandler) { - this.errorHandler.isVerbose = isVerbose; - } - // Set verbose mode in config file this.eleventyConfig.verbose = isVerbose; } diff --git a/src/Errors/ErrorHandler.js b/src/Errors/ErrorHandler.js index 56cd6a97a..a63e75734 100644 --- a/src/Errors/ErrorHandler.js +++ b/src/Errors/ErrorHandler.js @@ -7,30 +7,20 @@ import ErrorUtil from "./ErrorUtil.js"; const debug = createDebug("BuildAwesome:ErrorHandler"); export class ErrorHandler { - constructor() { - this._isVerbose = true; - } - - get isVerbose() { - return this._isVerbose; - } + #logger; - set isVerbose(verbose) { - this._isVerbose = !!verbose; - this.logger.isVerbose = !!verbose; - } + constructor() {} get logger() { - if (!this._logger) { - this._logger = new ConsoleLogger(); - this._logger.isVerbose = this.isVerbose; + if (!this.#logger) { + throw new Error("Internal error: missing logger instance."); } - return this._logger; + return this.#logger; } set logger(logger) { - this._logger = logger; + this.#logger = logger; } warn(e, msg) { diff --git a/src/Template.js b/src/Template.js index acdd51338..a2ce548a3 100755 --- a/src/Template.js +++ b/src/Template.js @@ -58,7 +58,6 @@ class Template extends TemplateContent { this.linters = []; this.transforms = {}; - this.isVerbose = true; this.isDryRun = false; this.writeCount = 0; @@ -96,8 +95,7 @@ class Template extends TemplateContent { get logger() { if (!this.#logger) { - this.#logger = new ConsoleLogger(); - this.#logger.isVerbose = this.isVerbose; + throw new Error("Internal error: missing ConsoleLogger instance."); } return this.#logger; } @@ -154,11 +152,6 @@ class Template extends TemplateContent { this.behavior.setOutputFormat(to); } - setIsVerbose(isVerbose) { - this.isVerbose = isVerbose; - this.logger.isVerbose = isVerbose; - } - setDryRunViaIncremental(isIncremental) { this.isDryRun = isIncremental; this.isIncremental = isIncremental; @@ -1060,7 +1053,7 @@ class Template extends TemplateContent { // write data map if (contentMap !== undefined && page.outputPath) { - // TODO customize this + // TODO unlock option to customize this let mapOutputPath = page.outputPath + ".map"; this.fsManager.createDirectoryForFileSync(mapOutputPath); this.fsManager.writeFileSync(mapOutputPath, contentMap); @@ -1071,7 +1064,7 @@ class Template extends TemplateContent { } async clone() { - // TODO do we need to even run the constructor here or can we simplify it even more + // QUESTION do we need to even run the constructor here or can we simplify it even more let tmpl = new Template( this.inputPath, this.templateData, @@ -1079,8 +1072,7 @@ class Template extends TemplateContent { this.eleventyConfig, ); - // We use this cheap property setter below instead - // await tmpl.getTemplateRender(); + tmpl.logger = this.logger; // preserves caches too, e.g. _frontMatterDataCache // Does not yet include .computedData diff --git a/src/TemplateMap.js b/src/TemplateMap.js index a617d2cd4..bcb962dcc 100644 --- a/src/TemplateMap.js +++ b/src/TemplateMap.js @@ -37,7 +37,6 @@ class TemplateMap { this.inputPathMap = new Map(); // NEW: O(1) lookup Map for performance this.collectionsData = null; this.cached = false; - this.verboseOutput = true; this.collection = new TemplateCollection(); } diff --git a/src/TemplateWriter.js b/src/TemplateWriter.js index 80e281ad6..2a0e41584 100755 --- a/src/TemplateWriter.js +++ b/src/TemplateWriter.js @@ -18,6 +18,7 @@ class TemplateWriter { #eleventyFiles; #passthroughManager; #errorHandler; + #logger; #extensionMap; #incrementalFiles = []; @@ -36,7 +37,6 @@ class TemplateWriter { this.templateFormats = templateFormats; this.templateData = templateData; - this.isVerbose = true; this.isDryRun = false; this.writeCount = 0; this.renderCount = 0; @@ -69,27 +69,22 @@ class TemplateWriter { /* Getter for error handler */ get errorHandler() { if (!this.#errorHandler) { - this.#errorHandler = new ErrorHandler(); - this.#errorHandler.isVerbose = this.verboseMode; - this.#errorHandler.logger = this.logger; + throw new Error("Internal error: missing ErrorHandler instance."); } return this.#errorHandler; } - /* Getter for Logger */ get logger() { - if (!this._logger) { - this._logger = new ConsoleLogger(); - this._logger.isVerbose = this.verboseMode; + if (!this.#logger) { + throw new Error("Internal error: missing ConsoleLogger instance."); } - return this._logger; + return this.#logger; } - /* Setter for Logger */ set logger(logger) { - this._logger = logger; + this.#logger = logger; } /* For testing */ @@ -200,7 +195,6 @@ class TemplateWriter { tmpl.setPreprocessors(this.config.preprocessors); tmpl.setLinters(this.config.linters); tmpl.setDryRun(this.isDryRun); - tmpl.setIsVerbose(this.isVerbose); tmpl.reset(); return { @@ -547,11 +541,6 @@ class TemplateWriter { ); } - setVerboseOutput(isVerbose) { - this.isVerbose = isVerbose; - this.errorHandler.isVerbose = isVerbose; - } - setDryRun(isDryRun) { this.isDryRun = Boolean(isDryRun); } diff --git a/test/TemplateWriterTest.js b/test/TemplateWriterTest.js index 50406df6d..6e372633b 100644 --- a/test/TemplateWriterTest.js +++ b/test/TemplateWriterTest.js @@ -406,8 +406,6 @@ test("Pagination and TemplateContent", async (t) => { }); let { templateWriter: tw } = getTemplateWriterInstance(["njk", "md"], eleventyConfig); - - tw.setVerboseOutput(false); await tw.write(); let content = fs.readFileSync("./test/stubs/pagination-templatecontent/_site/index.html", "utf8"); diff --git a/test/_getNewTemplateForTests.js b/test/_getNewTemplateForTests.js index a3c443908..c29b4f513 100644 --- a/test/_getNewTemplateForTests.js +++ b/test/_getNewTemplateForTests.js @@ -4,6 +4,7 @@ import FileSystemSearch from "../src/FileSystemSearch.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import { getTemplateConfigInstance } from "./_testHelpers.js"; +import ConsoleLogger from "../src/Util/ConsoleLogger.js"; export default async function getNewTemplate( path, @@ -33,6 +34,9 @@ export default async function getNewTemplate( templateData.extensionMap = map; } let tmpl = new Template(path, templateData, map, $config); + let logger = new ConsoleLogger();; + logger.isVerbose = false; + tmpl.logger = logger; await tmpl.getTemplateRender(); diff --git a/test/_testHelpers.js b/test/_testHelpers.js index 172be7355..e94a4a8a5 100644 --- a/test/_testHelpers.js +++ b/test/_testHelpers.js @@ -9,6 +9,7 @@ import FileSystemSearch from "../src/FileSystemSearch.js"; import TemplateWriter from "../src/TemplateWriter.js"; import TemplateEngineManager from "../src/Engines/TemplateEngineManager.js"; import TemplateData from "../src/Data/TemplateData.js"; +import ConsoleLogger from "../src/Util/ConsoleLogger.js"; export async function getTemplateConfigInstance(configObj, dirs, configObjOverride = undefined) { let $config; @@ -55,12 +56,16 @@ export async function getTemplateConfigInstanceCustomCallback(dirObject, configC } export function getTemplateWriterInstance(formats, templateConfig) { + let logger = new ConsoleLogger(); + logger.isVerbose = false; + let { eleventyFiles, passthroughManager } = getEleventyFilesInstance(formats, templateConfig); let templateWriter = new TemplateWriter( formats, null, templateConfig, ); + templateWriter.logger = logger; let engineManager = new TemplateEngineManager(templateConfig); let map = new ExtensionMap(templateConfig); From 154a9d423cd13bb6c2f5e4c7a9526717cd3b0a14 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 11:24:25 -0500 Subject: [PATCH 28/53] Fix server output from ConsoleLogger reuse --- src/Core.js | 2 ++ src/Serve.js | 50 ++++++++++++++++++++++++++++++--------- src/Util/ConsoleLogger.js | 34 ++++++++++++++++---------- test/ServeTest.js | 2 ++ 4 files changed, 65 insertions(+), 23 deletions(-) diff --git a/src/Core.js b/src/Core.js index 63b22e327..33079ae73 100644 --- a/src/Core.js +++ b/src/Core.js @@ -48,6 +48,8 @@ export default class Core extends CoreFs { /** @type {object} */ this.eleventyServe = new Serve(); } + + this.eleventyServe.logger = this.logger; this.eleventyServe.eleventyConfig = this.eleventyConfig; /** @type {object} */ diff --git a/src/Serve.js b/src/Serve.js index 34fd3d8cb..b1187f966 100644 --- a/src/Serve.js +++ b/src/Serve.js @@ -31,10 +31,11 @@ const DEFAULT_SERVER_OPTIONS = { // pathPrefix: "/", // setup: function() {}, // ready: function(server) {}, - // logger: { info: function() {}, error: function() {} } + // logger: { log: function() {}, info: function() {}, error: function() {} } }; export default class Serve { + #options; #eleventyConfig; #savedConfigOptions; #aliases; @@ -43,10 +44,7 @@ export default class Serve { // these are *not* normalized #watchTargets = new Set(); #editCallbacks = []; - - constructor() { - this.logger = new ConsoleLogger(); - } + #logger; get config() { if (!this.eleventyConfig) { @@ -87,6 +85,18 @@ export default class Serve { } } + get logger() { + if (!this.#logger) { + throw new Error("Internal error: missing ConsoleLogger instance."); + } + + return this.#logger; + } + + set logger(logger) { + this.#logger = logger; + } + // TODO directorynorm setOutputDir(outputDir) { // TODO check if this is different and if so, restart server (if already running) @@ -158,15 +168,33 @@ export default class Serve { } } + getForcedOutputLogger() { + // Server logging overrides verbose values. + return { + log: (message) => { + return this.logger.logWithOptions({ message, force: true }); + }, + info: (message) => { + return this.logger.logWithOptions({ message, type: "info", force: true }); + }, + warn: (message) => { + return this.logger.logWithOptions({ message, type: "warn", force: true }); + }, + error: (message) => { + return this.logger.logWithOptions({ message, type: "error", force: true }); + }, + }; + } + get options() { - if (this._options) { - return this._options; + if (this.#options) { + return this.#options; } - this._options = Object.assign( + this.#options = Object.assign( { pathPrefix: PathPrefixer.normalizePathPrefix(this.config.pathPrefix), - logger: this.logger, + logger: this.getForcedOutputLogger(), onClientMessage: async ({ id, type, data, timestamp }) => { let paths = []; if (type === "eleventy.editReset") { @@ -209,7 +237,7 @@ export default class Serve { ); } - return this._options; + return this.#options; } get server() { @@ -322,7 +350,7 @@ export default class Serve { // we can correctly handle a `module` property change (changing the server type) async restart() { // Blow away cached options - delete this._options; + this.#options = undefined; await this.close(); diff --git a/src/Util/ConsoleLogger.js b/src/Util/ConsoleLogger.js index 6a9231765..4073a5bb9 100644 --- a/src/Util/ConsoleLogger.js +++ b/src/Util/ConsoleLogger.js @@ -14,8 +14,14 @@ class ConsoleLogger { #isChalkEnabled = true; /** @type {object|boolean|undefined} */ #logger; - - constructor() {} + /** @type {string} */ + #logPrefix = "[11ty]"; + /** @type {object} */ + #colorFallbacks = { + info: "blue", + warn: "yellow", + error: "red", + }; isLoggingEnabled() { if (!this.isVerbose || process.env.DEBUG) { @@ -73,17 +79,18 @@ class ConsoleLogger { /** @param {string} msg */ info(msg) { - this.message(msg, "log", "blue"); + // Similar to log, but blue + this.message(msg, "log", this.#colorFallbacks.info); } /** @param {string} msg */ warn(msg) { - this.message(msg, "warn", "yellow"); + this.message(msg, "warn", this.#colorFallbacks.warn); } /** @param {string} msg */ error(msg) { - this.message(msg, "error", "red"); + this.message(msg, "error", this.#colorFallbacks.error); } /** @param {string} message */ @@ -102,18 +109,21 @@ class ConsoleLogger { * @param {string|undefined} [chalkColor=undefined] - Color name or falsy to disable * @param {boolean} [forceToConsole=false] - Enforce a log on console instead of specified target. */ - message( - message, - type = "log", - chalkColor = undefined, - forceToConsole = false, - prefix = "[11ty]", - ) { + message(message, type = "log", chalkColor = undefined, forceToConsole = false, prefix = "") { if (!forceToConsole && (!this.isVerbose || process.env.DEBUG)) { debug(message); } else if (this.#logger !== false) { + if (!prefix) { + prefix = this.#logPrefix; + } + message = `${this.#dim(prefix)} ${message.split("\n").join(`\n${chalk.gray(prefix)} `)}`; + // default color for every type but log + if (chalkColor === undefined && type) { + chalkColor = this.#colorFallbacks[type]; + } + if (chalkColor && this.isChalkEnabled) { this.logger[type](chalk[chalkColor](message)); } else { diff --git a/test/ServeTest.js b/test/ServeTest.js index 362931971..8ab5274ce 100644 --- a/test/ServeTest.js +++ b/test/ServeTest.js @@ -2,6 +2,7 @@ import test from "ava"; import Serve from "../src/Serve.js"; import TemplateConfig from "../src/TemplateConfig.js"; +import ConsoleLogger from "../src/Util/ConsoleLogger.js"; async function getServerInstance(eleventyConfig) { let es = new Serve(); @@ -11,6 +12,7 @@ async function getServerInstance(eleventyConfig) { } es.eleventyConfig = eleventyConfig; + es.logger = new ConsoleLogger(); await es.init(); From 1a11ddcebddca2c63486470ed002505c020cb42c Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 15:57:52 -0500 Subject: [PATCH 29/53] Change logging prefix based on configuration file used. --- src/CoreMinimal.js | 16 +++++++++++++++- src/TemplateConfig.js | 2 +- src/Util/ConsoleLogger.js | 7 ++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/CoreMinimal.js b/src/CoreMinimal.js index e5eaa7f53..7a03edcaa 100644 --- a/src/CoreMinimal.js +++ b/src/CoreMinimal.js @@ -234,6 +234,16 @@ export class CoreMinimal { return CoreMinimal.getVersion(); } + static isUsingBuildAwesomeConfigurationFile(configPath) { + if (typeof configPath !== "string") { + return; + } + if (configPath.includes("buildawesome.config")) { + return true; + } + return false; + } + async initializeConfig(initOverrides) { if (!this.eleventyConfig) { this.eleventyConfig = new TemplateConfig(null, this.configPath); @@ -244,6 +254,10 @@ export class CoreMinimal { this.#activeConfigurationPath = this.configPath ?? this.eleventyConfig.getLocalProjectConfigFile(); + if (CoreMinimal.isUsingBuildAwesomeConfigurationFile(this.#activeConfigurationPath)) { + this.logger.setPrefix(`[buildawesome]`); + } + this.eleventyConfig.setRunMode(this.runMode); this.eleventyConfig.setProjectUsingEsm(this.isEsm); this.eleventyConfig.setLogger(this.logger); @@ -559,8 +573,8 @@ Verbose Output: ${this.verboseMode}`; /** @param {ConsoleLogger} logger */ set logger(logger) { - this.eleventyConfig.setLogger(logger); this.#logger = logger; + this.eleventyConfig.setLogger(logger); } disableLogger() { diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index e3e70c0ce..44f317ee6 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -76,7 +76,7 @@ class TemplateConfig { } else { this.projectConfigPaths = [ ...expandEligibleJavaScriptFilePaths("buildawesome.config"), - ".eleventy.js", + ".eleventy.js", // intentionally has never included other JS extensions ...expandEligibleJavaScriptFilePaths("eleventy.config"), ]; } diff --git a/src/Util/ConsoleLogger.js b/src/Util/ConsoleLogger.js index 4073a5bb9..31a8c7980 100644 --- a/src/Util/ConsoleLogger.js +++ b/src/Util/ConsoleLogger.js @@ -30,6 +30,10 @@ class ConsoleLogger { return this.#logger !== false; } + setPrefix(prefix) { + this.#logPrefix = prefix; + } + get isVerbose() { return this.#isVerbose; } @@ -117,7 +121,8 @@ class ConsoleLogger { prefix = this.#logPrefix; } - message = `${this.#dim(prefix)} ${message.split("\n").join(`\n${chalk.gray(prefix)} `)}`; + let prefixStr = prefix ? `${this.#dim(prefix)} ` : ""; + message = `${prefixStr}${message.split("\n").join(`\n${prefixStr}`)}`; // default color for every type but log if (chalkColor === undefined && type) { From b4dfeeae8933f8c02d01dd74c8df9d43e043937a Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 15:59:34 -0500 Subject: [PATCH 30/53] Standardize on browser instead of client for Vitest runs --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 325aa0309..ccd67ab7b 100644 --- a/package.json +++ b/package.json @@ -52,11 +52,11 @@ ], "scripts": { "default": "npm run test", - "test": "npm run test:server && npm run test:client", + "test": "npm run test:server && npm run test:browser", "test:server": "npm run test:node && npm run test:ava", "test:ava": "ava --verbose --timeout 20s", "test:node": "node --test 'test_node/**/*test.js'", - "test:client": "cross-env CI=true npm run test --workspaces", + "test:browser": "cross-env CI=true npm run test --workspaces", "format": "prettier . --write", "check": "eslint src", "check-types": "tsc", From 3c3c21b1641679ec67ad7977951509113d229949 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 16:17:25 -0500 Subject: [PATCH 31/53] Missed a reference to test:client --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a55ecffdc..ac165fa38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,6 @@ jobs: node-version: ${{ matrix.node }} - run: npm ci - run: npx playwright install - - run: npm run test:client + - run: npm run test:browser env: YARN_GPG: no From f25edfc0eb3987c82123e7937508372d34c6e305 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 17:03:10 -0500 Subject: [PATCH 32/53] First version of Build Awesome release script --- .github/ISSUE_TEMPLATE/possible-bug.yml | 2 +- README.md | 2 +- package-lock.json | 28 ++++++++++++- package.json | 8 ++-- packages/build-awesome/cmd.js | 6 +++ packages/build-awesome/package.json | 39 +++++++++++++++++++ packages/build-awesome/src/Core.js | 2 + packages/build-awesome/src/UserConfig.d.ts | 4 ++ packages/build-awesome/src/Util/Git.js | 4 ++ packages/build-awesome/update-package-json.js | 28 +++++++++++++ scripts/release-dryrun.sh | 2 +- scripts/release.sh | 9 +++-- src/CoreMinimal.js | 9 +++-- src/Plugins/IdAttributePlugin.js | 2 +- src/UserConfig.js | 4 +- src/defaultConfigExtended.client.js | 4 +- 16 files changed, 132 insertions(+), 21 deletions(-) create mode 100755 packages/build-awesome/cmd.js create mode 100644 packages/build-awesome/package.json create mode 100644 packages/build-awesome/src/Core.js create mode 100644 packages/build-awesome/src/UserConfig.d.ts create mode 100644 packages/build-awesome/src/Util/Git.js create mode 100644 packages/build-awesome/update-package-json.js diff --git a/.github/ISSUE_TEMPLATE/possible-bug.yml b/.github/ISSUE_TEMPLATE/possible-bug.yml index ef01a167c..5af95c6f7 100644 --- a/.github/ISSUE_TEMPLATE/possible-bug.yml +++ b/.github/ISSUE_TEMPLATE/possible-bug.yml @@ -23,7 +23,7 @@ body: attributes: label: Eleventy description: Which version of Build Awesome or Eleventy do you use? - placeholder: npx @awesome.me/build --version or npx @11ty/eleventy --version + placeholder: npx @awesome.me/buildawesome --version or npx @11ty/eleventy --version validations: required: true - type: textarea diff --git a/README.md b/README.md index 6b3a612e5..71dcabcc4 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Works with HTML, Markdown, JavaScript, Liquid, Nunjucks, with addons for WebC, S ## Installation ``` -npm install @awesome.me/build --save-dev +npm install @awesome.me/buildawesome --save-dev # Backwards compatible here too: npm install @11ty/eleventy --save-dev diff --git a/package-lock.json b/package-lock.json index d99ff6dab..6a0f0d4a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "version": "4.0.0-alpha.8", "license": "MIT", "workspaces": [ - "packages/browser" + "packages/browser", + "packages/build-awesome" ], "dependencies": { "@11ty/dependency-tree": "^4.0.2", @@ -46,7 +47,7 @@ "tinyglobby": "^0.2.17" }, "bin": { - "build": "cmd.cjs" + "eleventy": "cmd.cjs" }, "devDependencies": { "@11ty/eleventy-img": "^6.0.4", @@ -131,6 +132,10 @@ "node": ">=18" } }, + "node_modules/@11ty/eleventy": { + "resolved": "", + "link": true + }, "node_modules/@11ty/eleventy-dev-server": { "version": "3.0.0-alpha.10", "resolved": "https://registry.npmjs.org/@11ty/eleventy-dev-server/-/eleventy-dev-server-3.0.0-alpha.10.tgz", @@ -454,6 +459,10 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/@awesome.me/buildawesome": { + "resolved": "packages/build-awesome", + "link": true + }, "node_modules/@babel/helper-string-parser": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", @@ -11221,6 +11230,21 @@ "type": "opencollective", "url": "https://opencollective.com/11ty" } + }, + "packages/build-awesome": { + "name": "@awesome.me/buildawesome", + "version": "PRIVATE", + "license": "MIT", + "dependencies": { + "@11ty/eleventy": "file:../../" + }, + "bin": { + "buildawesome": "cmd.js" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/11ty" + } } } } diff --git a/package.json b/package.json index ccd67ab7b..c235b0d71 100644 --- a/package.json +++ b/package.json @@ -16,17 +16,19 @@ "./UserConfig": { "types": "./src/UserConfig.js" }, - "./utils/git": "./src/Util/Git.js" + "./utils/git": "./src/Util/Git.js", + "./cli": "./cmd.cjs" }, "bin": { - "build": "cmd.cjs" + "eleventy": "cmd.cjs" }, "license": "MIT", "engines": { "node": ">=22.15" }, "workspaces": [ - "packages/browser" + "packages/browser", + "packages/build-awesome" ], "funding": { "type": "opencollective", diff --git a/packages/build-awesome/cmd.js b/packages/build-awesome/cmd.js new file mode 100755 index 000000000..58fa5b2fc --- /dev/null +++ b/packages/build-awesome/cmd.js @@ -0,0 +1,6 @@ +#!/usr/bin/env node + +// Influences console prefix +process.env.BUILDAWESOME_PACKAGE = "@awesome.me/buildawesome"; + +import "@11ty/eleventy/cli"; diff --git a/packages/build-awesome/package.json b/packages/build-awesome/package.json new file mode 100644 index 000000000..193285780 --- /dev/null +++ b/packages/build-awesome/package.json @@ -0,0 +1,39 @@ +{ + "name": "@awesome.me/buildawesome", + "description": "Run Build Awesome (Eleventy) in your browser.", + "version": "PRIVATE", + "private": true, + "publishConfig": { + "access": "public", + "provenance": true + }, + "type": "module", + "exports": { + ".": "./src/Core.js", + "./UserConfig": { + "types": "./src/UserConfig.d.ts" + }, + "./utils/git": "./src/Util/Git.js" + }, + "bin": { + "buildawesome": "cmd.js" + }, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/11ty" + }, + "scripts": { + "test": "" + }, + "author": "Zach Leatherman (https://zachleat.com/)", + "repository": { + "type": "git", + "url": "git://github.com/11ty/build-awesome.git" + }, + "bugs": "https://github.com/11ty/build-awesome/issues", + "homepage": "https://build.awesome.me/", + "dependencies": { + "@11ty/eleventy": "file:../../" + } +} diff --git a/packages/build-awesome/src/Core.js b/packages/build-awesome/src/Core.js new file mode 100644 index 000000000..d25348ca7 --- /dev/null +++ b/packages/build-awesome/src/Core.js @@ -0,0 +1,2 @@ +export * from "@11ty/eleventy"; +export { default } from "@11ty/eleventy"; diff --git a/packages/build-awesome/src/UserConfig.d.ts b/packages/build-awesome/src/UserConfig.d.ts new file mode 100644 index 000000000..2e9156f3e --- /dev/null +++ b/packages/build-awesome/src/UserConfig.d.ts @@ -0,0 +1,4 @@ +// No named exports +// export * from "@11ty/eleventy/UserConfig"; + +export { default } from "@11ty/eleventy/UserConfig"; diff --git a/packages/build-awesome/src/Util/Git.js b/packages/build-awesome/src/Util/Git.js new file mode 100644 index 000000000..ca8d9d98f --- /dev/null +++ b/packages/build-awesome/src/Util/Git.js @@ -0,0 +1,4 @@ +// Named exports only + +export * from "@11ty/eleventy/git"; +// export { default } from "@11ty/eleventy/git"; diff --git a/packages/build-awesome/update-package-json.js b/packages/build-awesome/update-package-json.js new file mode 100644 index 000000000..5d49737a6 --- /dev/null +++ b/packages/build-awesome/update-package-json.js @@ -0,0 +1,28 @@ +// Intended to run from repository root in release.sh script + +import fs from "node:fs"; +import corePkg from "../../package.json" with { type: "json" }; + +// assign new version in local package.json from core package.json +import buildawesomePkg from "./package.json" with { type: "json" }; + +buildawesomePkg.version = corePkg.version; +buildawesomePkg.dependencies[corePkg.name] = corePkg.version; +delete buildawesomePkg.private; // allow publish + +if ( + corePkg.name !== "@11ty/eleventy" || + buildawesomePkg.name !== "@awesome.me/buildawesome" || + !fs.existsSync("./packages/build-awesome/package.json") +) { + throw new Error("Did you run this script from the wrong directory?"); +} + +fs.writeFileSync( + "./packages/build-awesome/package.json", + JSON.stringify(buildawesomePkg, null, 2), + "utf8", +); +console.log( + `[awesome.me/buildawesome] Updated @awesome.me/buildawesome package version to ${corePkg.version}`, +); diff --git a/scripts/release-dryrun.sh b/scripts/release-dryrun.sh index ffde53523..98d6ad7f6 100755 --- a/scripts/release-dryrun.sh +++ b/scripts/release-dryrun.sh @@ -1,6 +1,6 @@ export NPM_PUBLISH_TAG="canary" export DRY_RUN="--dry-run" # leave that space as-is -echo "Running @11ty/eleventy and @11ty/client publish dry run test" +echo "Publishing: @11ty/eleventy, @11ty/client, @awesome.me/buildawesome publish (dry run)" ./scripts/release.sh diff --git a/scripts/release.sh b/scripts/release.sh index 90322293a..00acd8993 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -19,9 +19,10 @@ if [ -z "$NPM_PUBLISH_TAG" ]; then exit 1 fi -node packages/browser/update-package-json.js -# Will skip publishing root if publishing workspaces fails -if npm publish --workspaces --provenance --access=public --tag=$NPM_PUBLISH_TAG $DRY_RUN; then - npm publish --provenance --access=public --tag=$NPM_PUBLISH_TAG $DRY_RUN +# Will skip publishing @11ty/client and @awesome.me/buildawesome if @11ty/eleventy fails +if npm publish --provenance --access=public --tag=$NPM_PUBLISH_TAG $DRY_RUN; then + node packages/browser/update-package-json.js + node packages/build-awesome/update-package-json.js + npm publish --workspaces --provenance --access=public --tag=$NPM_PUBLISH_TAG $DRY_RUN fi diff --git a/src/CoreMinimal.js b/src/CoreMinimal.js index 7a03edcaa..d482192af 100644 --- a/src/CoreMinimal.js +++ b/src/CoreMinimal.js @@ -234,11 +234,14 @@ export class CoreMinimal { return CoreMinimal.getVersion(); } - static isUsingBuildAwesomeConfigurationFile(configPath) { + static isUsingBuildAwesome(configPath) { if (typeof configPath !== "string") { return; } - if (configPath.includes("buildawesome.config")) { + if ( + process?.env?.BUILDAWESOME_PACKAGE === "@awesome.me/buildawesome" || + configPath.includes("buildawesome.config") + ) { return true; } return false; @@ -254,7 +257,7 @@ export class CoreMinimal { this.#activeConfigurationPath = this.configPath ?? this.eleventyConfig.getLocalProjectConfigFile(); - if (CoreMinimal.isUsingBuildAwesomeConfigurationFile(this.#activeConfigurationPath)) { + if (CoreMinimal.isUsingBuildAwesome(this.#activeConfigurationPath)) { this.logger.setPrefix(`[buildawesome]`); } diff --git a/src/Plugins/IdAttributePlugin.js b/src/Plugins/IdAttributePlugin.js index 5a7aa9076..f525f5cd7 100644 --- a/src/Plugins/IdAttributePlugin.js +++ b/src/Plugins/IdAttributePlugin.js @@ -3,7 +3,7 @@ import { decodeHTML } from "entities"; import { resolveAttributeName } from "../Util/PostHtml/Attrs.js"; -const POSTHTML_PLUGIN_NAME = "awesome.me/build/id-attribute"; +const POSTHTML_PLUGIN_NAME = "awesome.me/buildawesome/id-attribute"; function getTextNodeContent(node) { let ignoredAttrName = resolveAttributeName(node.attrs, "buildawesome:id-ignore"); diff --git a/src/UserConfig.js b/src/UserConfig.js index b940425d7..4dc8f0d08 100644 --- a/src/UserConfig.js +++ b/src/UserConfig.js @@ -20,7 +20,7 @@ class UserConfigError extends BaseError {} * Eleventy’s user-land Configuration API * @module 11ty/eleventy/UserConfig */ -class UserConfig { +export default class UserConfig { /** @type {boolean} */ #pluginExecution = false; /** @type {boolean} */ @@ -1318,5 +1318,3 @@ class UserConfig { // No-op from v2 setBrowserSyncConfig() {} } - -export default UserConfig; diff --git a/src/defaultConfigExtended.client.js b/src/defaultConfigExtended.client.js index d967740a9..e7489b41d 100644 --- a/src/defaultConfigExtended.client.js +++ b/src/defaultConfigExtended.client.js @@ -1,13 +1,13 @@ export default function (config) { config.addFilter("url", () => { throw new Error( - "The `url` filter is not included with the `@awesome.me/buildawesome-browser` bundle. Use the `@awesome.me/buildawesome-browser/core-fs` bundle.", + "The `url` filter is not included with the `@11ty/client` bundle. Use the `@11ty/client/core-fs` bundle.", ); }); config.addFilter("inputPathToUrl", () => { throw new Error( - "The `inputPathToUrl` filter is not included with the `@awesome.me/buildawesome-browser` bundle. Use the larger `@awesome.me/buildawesome-browser/core-fs` bundle.", + "The `inputPathToUrl` filter is not included with the `@11ty/client` bundle. Use the larger `@11ty/client/core-fs` bundle.", ); }); From e9e00ac0e089bafdfbc69fda12e0bdc04b9a20dd Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 17:05:25 -0500 Subject: [PATCH 33/53] Whitespace consistency --- packages/build-awesome/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/build-awesome/package.json b/packages/build-awesome/package.json index 193285780..f5430aaf8 100644 --- a/packages/build-awesome/package.json +++ b/packages/build-awesome/package.json @@ -15,7 +15,7 @@ }, "./utils/git": "./src/Util/Git.js" }, - "bin": { + "bin": { "buildawesome": "cmd.js" }, "license": "MIT", From 4daa1354b8bba9297fc60ac1f427842716f0ee14 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 17:11:04 -0500 Subject: [PATCH 34/53] Revert override --- package-lock.json | 9 ++++++--- package.json | 3 --- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6a0f0d4a9..d9338bf06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5448,10 +5448,13 @@ } }, "node_modules/fdir": { - "version": "6.4.6", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz", - "integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, "peerDependencies": { "picomatch": "^3 || ^4" }, diff --git a/package.json b/package.json index c235b0d71..7c3de5269 100644 --- a/package.json +++ b/package.json @@ -166,8 +166,5 @@ "posthtml-match-helper": "^2.0.3", "semver": "^7.8.4", "tinyglobby": "^0.2.17" - }, - "overrides": { - "fdir": "6.4.6" } } From 9b2d619111f1ad4bb61cda6aedb8d77a33f9f538 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 17:24:53 -0500 Subject: [PATCH 35/53] Remove the dash from the future repo name --- .github/ISSUE_TEMPLATE/config.yml | 4 ++-- .github/workflows/release.yml | 2 +- README.md | 12 ++++++------ SECURITY.md | 2 +- cmd.cjs | 2 +- docs/release-instructions.md | 4 ++-- package.json | 4 ++-- packages/browser/README.md | 2 +- packages/browser/package.json | 4 ++-- packages/build-awesome/package.json | 4 ++-- src/CoreMinimal.js | 2 +- src/Files.js | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 0aa052214..198559d16 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,9 +1,9 @@ contact_links: - name: I have a question - url: https://github.com/11ty/build-awesome/discussions/ + url: https://github.com/11ty/buildawesome/discussions/ about: General education topics should be filed on our Discussions board e.g. “How do I do this?” or “Can I do this?” (Please search existing discussions first!) - name: I have a feature request - url: https://github.com/11ty/build-awesome/discussions/new?category=enhancement-queue + url: https://github.com/11ty/buildawesome/discussions/new?category=enhancement-queue about: Enhancement or new Features. Suggest an idea! (Please search existing discussions first!) - name: I wish the docs were different! url: https://github.com/11ty/11ty-website/issues/new/choose diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a378c17d..fc6a77e6f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: permissions: read-all jobs: release: - # see https://github.com/11ty/build-awesome/settings/environments + # see https://github.com/11ty/buildawesome/settings/environments environment: GitHub Publish runs-on: ubuntu-latest permissions: diff --git a/README.md b/README.md index 71dcabcc4..593dc9c4a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Works with HTML, Markdown, JavaScript, Liquid, Nunjucks, with addons for WebC, S ## ➡ [Documentation](https://www.11ty.dev/docs/) -- Star [this repo on GitHub](https://github.com/11ty/build-awesome/)! +- Star [this repo on GitHub](https://github.com/11ty/buildawesome/)! - Follow us [on Mastodon `@11ty@neighborhood.11ty.dev`](https://neighborhood.11ty.dev/@11ty) - Follow us [on Bluesky `@11ty.dev`](https://bsky.app/profile/11ty.dev) - Install [from npm](https://www.npmjs.com/org/11ty) @@ -39,17 +39,17 @@ We have a few test suites, for various reasons: - [ava JavaScript test runner](https://github.com/avajs/ava) ([assertions docs](https://github.com/avajs/ava/blob/main/docs/03-assertions.md)) (primary test suite in `test/`) - [Node.js Test runner](https://nodejs.org/api/test.html) (secondary test suite in `test_node/`) - [Vitest (in Browser Mode)](https://vitest.dev/guide/browser/) (browser tests in `packages/browser/test/`) -- [Benchmark for Performance Regressions](https://github.com/11ty/build-benchmark) +- [Benchmark for Performance Regressions](https://github.com/11ty/buildbenchmark) These run in various environments: -- [Continuous Integration on GitHub Actions](https://github.com/11ty/build-awesome/actions/workflows/ci.yml) -- [Code Coverage Statistics](https://github.com/11ty/build-awesome/blob/master/docs/coverage.md) +- [Continuous Integration on GitHub Actions](https://github.com/11ty/buildawesome/actions/workflows/ci.yml) +- [Code Coverage Statistics](https://github.com/11ty/buildawesome/blob/master/docs/coverage.md) ## Community Roadmap -- [Top Feature Requests](https://github.com/11ty/build-awesome/discussions/categories/enhancement-queue?discussions_q=is%3Aopen+category%3A%22Enhancement+Queue%22+sort%3Atop) (Vote for your favorites!) -- [Top Bugs 😱](https://github.com/11ty/build-awesome/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions) (Add your own votes using the 👍 reaction) +- [Top Feature Requests](https://github.com/11ty/buildawesome/discussions/categories/enhancement-queue?discussions_q=is%3Aopen+category%3A%22Enhancement+Queue%22+sort%3Atop) (Vote for your favorites!) +- [Top Bugs 😱](https://github.com/11ty/buildawesome/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions) (Add your own votes using the 👍 reaction) ## Plugins diff --git a/SECURITY.md b/SECURITY.md index e31fa3d67..670a96d43 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,7 +2,7 @@ ## Reporting a Vulnerability -Privately report a security issue by navigating to https://github.com/11ty/build-awesome/security and using the “Report a vulnerability” button. +Privately report a security issue by navigating to https://github.com/11ty/buildawesome/security and using the “Report a vulnerability” button. Read more at: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability diff --git a/cmd.cjs b/cmd.cjs index 50684326c..ea95f75c8 100755 --- a/cmd.cjs +++ b/cmd.cjs @@ -29,7 +29,7 @@ async function exec() { const { createDebug } = await import("obug"); const debug = createDebug("BuildAwesome:CLI"); - // Notes about friendly error messaging with outdated Node versions: https://github.com/11ty/build-awesome/issues/3761 + // Notes about friendly error messaging with outdated Node versions: https://github.com/11ty/buildawesome/issues/3761 const { ErrorHandler } = await import("./src/Errors/ErrorHandler.js"); const { getEnvValue } = await import("./src/Util/EnvironmentVars.cjs"); const { default: ConsoleLogger } = await import("./src/Util/ConsoleLogger.js"); diff --git a/docs/release-instructions.md b/docs/release-instructions.md index e45c3c7ff..fa9dd1854 100644 --- a/docs/release-instructions.md +++ b/docs/release-instructions.md @@ -26,11 +26,11 @@ 1. Check it all in and commit 1. Tag new version 1. Wait for GitHub Actions to complete to know that the build did not fail. -1. Publish a release on GitHub at https://github.com/11ty/build-awesome/releases pointing to the tag of the release. Hitting the publish button on this workflow will use GitHub Actions to publish the package to npm on the correct dist-tag and includes npm package provenance for the release. +1. Publish a release on GitHub at https://github.com/11ty/buildawesome/releases pointing to the tag of the release. Hitting the publish button on this workflow will use GitHub Actions to publish the package to npm on the correct dist-tag and includes npm package provenance for the release. - Main release: no version suffix publishes to `latest` (default) tag on npm - Make sure to include OpenCollective usernames for release notes here https://www.11ty.dev/supporters-for-release-notes/ -- Canary release: `-alpha.` version suffix in `package.json` publishes to `canary` tag on npm: https://github.com/11ty/build-awesome/issues/2758 +- Canary release: `-alpha.` version suffix in `package.json` publishes to `canary` tag on npm: https://github.com/11ty/buildawesome/issues/2758 - Beta release: `-beta.` version suffix publishes to `beta` tag on npm Unfortunate note about npm and tags (specifically `canary` here): if you push a 1.0.0-canary.x to `canary` (even though `2.0.0-canary.x` exists), it will use the last pushed tag when you npm install from `@canary` (not the highest version number) diff --git a/package.json b/package.json index 7c3de5269..fe3aa319b 100644 --- a/package.json +++ b/package.json @@ -69,9 +69,9 @@ "author": "Zach Leatherman (https://zachleat.com/)", "repository": { "type": "git", - "url": "git+https://github.com/11ty/build-awesome.git" + "url": "git+https://github.com/11ty/buildawesome.git" }, - "bugs": "https://github.com/11ty/build-awesome/issues", + "bugs": "https://github.com/11ty/buildawesome/issues", "homepage": "https://www.11ty.dev/", "ava": { "environmentVariables": {}, diff --git a/packages/browser/README.md b/packages/browser/README.md index 52637b5c7..b63b484b8 100644 --- a/packages/browser/README.md +++ b/packages/browser/README.md @@ -6,7 +6,7 @@ The client (browser-friendly) version of `@11ty/eleventy` Eleventy, a simpler st ## ➡ [Documentation](https://www.11ty.dev/docs/) -- Star [this repo on GitHub](https://github.com/11ty/build-awesome/)! +- Star [this repo on GitHub](https://github.com/11ty/buildawesome/)! - Follow us [on Mastodon `@11ty@neighborhood.11ty.dev`](https://neighborhood.11ty.dev/@11ty) - Follow us [on Bluesky `@11ty.dev`](https://bsky.app/profile/11ty.dev) - Install [from npm](https://www.npmjs.com/org/11ty) diff --git a/packages/browser/package.json b/packages/browser/package.json index 0b42b32f6..610386eb8 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -33,9 +33,9 @@ "author": "Zach Leatherman (https://zachleat.com/)", "repository": { "type": "git", - "url": "git://github.com/11ty/build-awesome.git" + "url": "git://github.com/11ty/buildawesome.git" }, - "bugs": "https://github.com/11ty/build-awesome/issues", + "bugs": "https://github.com/11ty/buildawesome/issues", "homepage": "https://www.11ty.dev/", "devDependencies": { "@11ty/package-bundler": "^0.5.6", diff --git a/packages/build-awesome/package.json b/packages/build-awesome/package.json index f5430aaf8..3e2aff103 100644 --- a/packages/build-awesome/package.json +++ b/packages/build-awesome/package.json @@ -29,9 +29,9 @@ "author": "Zach Leatherman (https://zachleat.com/)", "repository": { "type": "git", - "url": "git://github.com/11ty/build-awesome.git" + "url": "git://github.com/11ty/buildawesome.git" }, - "bugs": "https://github.com/11ty/build-awesome/issues", + "bugs": "https://github.com/11ty/buildawesome/issues", "homepage": "https://build.awesome.me/", "dependencies": { "@11ty/eleventy": "file:../../" diff --git a/src/CoreMinimal.js b/src/CoreMinimal.js index d482192af..12981bf8b 100644 --- a/src/CoreMinimal.js +++ b/src/CoreMinimal.js @@ -900,7 +900,7 @@ Verbose Output: ${this.verboseMode}`; debug(` Have a suggestion/feature request/feedback? Feeling frustrated? I want to hear it! -Open an issue: https://github.com/11ty/build-awesome/issues/new`); +Open an issue: https://github.com/11ty/buildawesome/issues/new`); } return returnObj; diff --git a/src/Files.js b/src/Files.js index 12f7ec77c..a488fe261 100644 --- a/src/Files.js +++ b/src/Files.js @@ -229,7 +229,7 @@ export class Files { ); debug(">>>", line); debug( - "Follow along at https://github.com/11ty/build-awesome/issues/693 to track support.", + "Follow along at https://github.com/11ty/buildawesome/issues/693 to track support.", ); } From 650e8b4247899aa6e0b3a961f9fb08a4837b6c06 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 17:33:34 -0500 Subject: [PATCH 36/53] Fix signing From e803e26cc3a7a9fd03a3f774a001753a4022df51 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Thu, 11 Jun 2026 17:36:00 -0500 Subject: [PATCH 37/53] Fix signing From 568dbabb41f908bb1baf80914b5ae571ecfc6f88 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 09:44:01 -0500 Subject: [PATCH 38/53] Resolves https://github.com/11ty/eleventy/pull/4294#discussion_r3407816743 --- src/Errors/ErrorHandler.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Errors/ErrorHandler.js b/src/Errors/ErrorHandler.js index a63e75734..f8d4ced85 100644 --- a/src/Errors/ErrorHandler.js +++ b/src/Errors/ErrorHandler.js @@ -9,8 +9,6 @@ const debug = createDebug("BuildAwesome:ErrorHandler"); export class ErrorHandler { #logger; - constructor() {} - get logger() { if (!this.#logger) { throw new Error("Internal error: missing logger instance."); From 3f1f35a46b27572e6ad68773586ef9d8b8ff9be2 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 10:10:36 -0500 Subject: [PATCH 39/53] Resolves https://github.com/11ty/eleventy/pull/4294#discussion_r3407813110 --- packages/browser/update-package-json.js | 4 +++- packages/build-awesome/update-package-json.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/browser/update-package-json.js b/packages/browser/update-package-json.js index 0422e5033..b2d7a0c09 100644 --- a/packages/browser/update-package-json.js +++ b/packages/browser/update-package-json.js @@ -14,7 +14,9 @@ if ( clientPkg.name !== "@11ty/client" || !fs.existsSync("./packages/browser/package.json") ) { - throw new Error("Did you run this script from the wrong directory?"); + throw new Error( + "Did you run this script from the wrong directory? (Should be the repository root)", + ); } fs.writeFileSync("./packages/browser/package.json", JSON.stringify(clientPkg, null, 2), "utf8"); diff --git a/packages/build-awesome/update-package-json.js b/packages/build-awesome/update-package-json.js index 5d49737a6..b2274922b 100644 --- a/packages/build-awesome/update-package-json.js +++ b/packages/build-awesome/update-package-json.js @@ -15,7 +15,9 @@ if ( buildawesomePkg.name !== "@awesome.me/buildawesome" || !fs.existsSync("./packages/build-awesome/package.json") ) { - throw new Error("Did you run this script from the wrong directory?"); + throw new Error( + "Did you run this script from the wrong directory? (Should be the repository root)", + ); } fs.writeFileSync( From 0fd1c2f484e9e41b988227669f8dd2df21647ac1 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 11:04:54 -0500 Subject: [PATCH 40/53] A few more tests for attribute resolution. Resolves https://github.com/11ty/eleventy/pull/4294#discussion_r3407824372 --- src/Util/PostHtml/Attrs.js | 15 +++++++++++++-- test/PostHtmlAttrsTest.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 test/PostHtmlAttrsTest.js diff --git a/src/Util/PostHtml/Attrs.js b/src/Util/PostHtml/Attrs.js index 4061acfdb..f76b00647 100644 --- a/src/Util/PostHtml/Attrs.js +++ b/src/Util/PostHtml/Attrs.js @@ -3,14 +3,25 @@ const PREFIXES = { buildawesome: "buildawesome:", }; +// Should always cross-map to the attribute name that exists +// Request for eleventy: should map to buildawesome: if buildawesome: is in attrs (and vice versa) export function resolveAttributeName(attrs = {}, attrName = "") { + if (typeof attrName !== "string") { + return; + } let [prefix, name] = attrName.split(":"); - if (PREFIXES.eleventy + name in attrs) { - return PREFIXES.eleventy + name; + if (!prefix || !name) { + return; + } + if (prefix && !(prefix in PREFIXES)) { + return; } if (PREFIXES.buildawesome + name in attrs) { return PREFIXES.buildawesome + name; } + if (PREFIXES.eleventy + name in attrs) { + return PREFIXES.eleventy + name; + } } export function hasAttribute(attrs = {}, attrName = "") { diff --git a/test/PostHtmlAttrsTest.js b/test/PostHtmlAttrsTest.js new file mode 100644 index 000000000..d7e702c81 --- /dev/null +++ b/test/PostHtmlAttrsTest.js @@ -0,0 +1,35 @@ +import test from "ava"; +import { resolveAttributeName } from "../src/Util/PostHtml/Attrs.js"; + +test("Looking for unprefixed key", t => { + t.is(resolveAttributeName({"key": "value"}, "key"), undefined); + t.is(resolveAttributeName({"eleventy:key": "value"}, "key"), undefined); + t.is(resolveAttributeName({"buildawesome:key": "value"}, "key"), undefined); + t.is(resolveAttributeName({"eleventy:key": "value1", "buildawesome:key": "value2"}, "key"), undefined); +}); + +test("Looking for notfound:key", t => { + t.is(resolveAttributeName({"buildawesome:key": "value"}, "notfound:key"), undefined); + t.is(resolveAttributeName({"eleventy:key": "value"}, "notfound:key"), undefined); + t.is(resolveAttributeName({"eleventy:key": "value1", "buildawesome:key": "value2"}, "notfound:key"), undefined); +}); + +// Should always cross-map to the attribute name that exists +test("Looking for buildawesome:key", t => { + t.is(resolveAttributeName({"buildawesome:key": "value"}, "buildawesome:key"), "buildawesome:key"); + t.is(resolveAttributeName({"eleventy:key": "value"}, "buildawesome:key"), "eleventy:key"); + + // if conflict, buildawesome: is preferred + t.is(resolveAttributeName({"eleventy:key": "value1", "buildawesome:key": "value2"}, "buildawesome:key"), "buildawesome:key"); +}); + +// Should always cross-map to the attribute name that exists +test("Looking for eleventy:key", t => { + t.is(resolveAttributeName({"buildawesome:key": "value"}, "eleventy:key"), "buildawesome:key"); + t.is(resolveAttributeName({"eleventy:key": "value"}, "eleventy:key"), "eleventy:key"); + + // if conflict, buildawesome: is preferred + t.is(resolveAttributeName({"eleventy:key": "value1", "buildawesome:key": "value2"}, "eleventy:key"), "buildawesome:key"); + +}); + From dbc09e9f0f3a1481e92a3f573dbfa7f056be6e0f Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 11:06:57 -0500 Subject: [PATCH 41/53] Remove comment --- src/Util/ConsoleLogger.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Util/ConsoleLogger.js b/src/Util/ConsoleLogger.js index 31a8c7980..a3e15882a 100644 --- a/src/Util/ConsoleLogger.js +++ b/src/Util/ConsoleLogger.js @@ -83,7 +83,6 @@ class ConsoleLogger { /** @param {string} msg */ info(msg) { - // Similar to log, but blue this.message(msg, "log", this.#colorFallbacks.info); } From 0c0c70bf259d834e9fdbffa449043cf17c5fda3b Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 11:10:53 -0500 Subject: [PATCH 42/53] Resolves https://github.com/11ty/eleventy/pull/4294#discussion_r3407830439 --- src/Util/ConsoleLogger.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Util/ConsoleLogger.js b/src/Util/ConsoleLogger.js index a3e15882a..ed0745d58 100644 --- a/src/Util/ConsoleLogger.js +++ b/src/Util/ConsoleLogger.js @@ -111,12 +111,19 @@ class ConsoleLogger { * @param {LogType} [type='log'] - The error level to log. * @param {string|undefined} [chalkColor=undefined] - Color name or falsy to disable * @param {boolean} [forceToConsole=false] - Enforce a log on console instead of specified target. + * @param {string|undefined} [prefix=undefined] - Dimmed string at the start of each line */ - message(message, type = "log", chalkColor = undefined, forceToConsole = false, prefix = "") { + message( + message, + type = "log", + chalkColor = undefined, + forceToConsole = false, + prefix = undefined, + ) { if (!forceToConsole && (!this.isVerbose || process.env.DEBUG)) { debug(message); } else if (this.#logger !== false) { - if (!prefix) { + if (prefix === undefined) { prefix = this.#logPrefix; } From 59ff2a9e48b808f4bd68244cf72504a81c258a21 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 11:12:24 -0500 Subject: [PATCH 43/53] Resolves https://github.com/11ty/eleventy/pull/4294#discussion_r3407831801 --- src/Util/EnvironmentVars.cjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Util/EnvironmentVars.cjs b/src/Util/EnvironmentVars.cjs index c98eaf2b1..189a70b7e 100644 --- a/src/Util/EnvironmentVars.cjs +++ b/src/Util/EnvironmentVars.cjs @@ -1,7 +1,11 @@ // Used by CommonJS upstream (cmd.cjs and TypeScript feature test) module.exports.getEnvValue = function(key) { - return process?.env?.[`BUILDAWESOME_${key}`] || process?.env?.[`ELEVENTY_${key}`]; + if(!process?.env) { + return; + } + + return process.env[`BUILDAWESOME_${key}`] || process.env[`ELEVENTY_${key}`]; } module.exports.setEnvValue = function(key, value) { From 9bc119a506c8a7dd3a81d08f029be9739b2724e4 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 13:54:30 -0500 Subject: [PATCH 44/53] Remove the data editing from this PR, needs to be decoupled --- src/Core.js | 4 --- src/Data/TemplateData.js | 11 +------- src/Serve.js | 37 +-------------------------- src/TemplateConfig.js | 55 ---------------------------------------- src/TemplateContent.js | 5 ---- 5 files changed, 2 insertions(+), 110 deletions(-) diff --git a/src/Core.js b/src/Core.js index 33079ae73..c0c6a81a8 100644 --- a/src/Core.js +++ b/src/Core.js @@ -495,10 +495,6 @@ export default class Core extends CoreFs { * @param {Number} port - The HTTP port to serve Eleventy from. */ async serve(port) { - this.eleventyServe.onEdit(async (path) => { - this.watcher.emit("change", path); - }); - // Port is optional and in this case likely via --port on the command line // May defer to configuration API options `port` property return this.eleventyServe.serve(port); diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index 24d39fdd7..97f66d81c 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -411,7 +411,6 @@ class TemplateData { if (this.dirs) { global.directories = Object.assign({}, this.dirs.getUserspaceInstance()); } - global.pendingEditsCount = (this.templateConfig.getPendingDataOverrides() || []).length; if (this.config.freezeReservedData) { DeepFreeze(global); @@ -449,10 +448,7 @@ class TemplateData { } let globalJson = await this.getAllGlobalData(); - - let noFilePathEditOverrides = this.templateConfig.getDataOverrideForPath(); - - let mergedGlobalData = Merge(globalJson, configApiGlobalData, noFilePathEditOverrides); + let mergedGlobalData = Merge(globalJson, configApiGlobalData); // OK: Shallow merge when combining rawImports (pkg) with global data files return Object.assign({}, mergedGlobalData, rawImports); @@ -637,11 +633,6 @@ class TemplateData { returnValue = await returnValue(configApiGlobalData || {}); } - let editOverrides = this.templateConfig.getDataOverrideForPath(path); - if (editOverrides) { - returnValue = Merge(returnValue, editOverrides); - } - dataBench.after(); aggregateDataBench.after(); diff --git a/src/Serve.js b/src/Serve.js index b1187f966..3623d137a 100644 --- a/src/Serve.js +++ b/src/Serve.js @@ -43,7 +43,6 @@ export default class Serve { #chokidar; // these are *not* normalized #watchTargets = new Set(); - #editCallbacks = []; #logger; get config() { @@ -196,33 +195,7 @@ export default class Serve { pathPrefix: PathPrefixer.normalizePathPrefix(this.config.pathPrefix), logger: this.getForcedOutputLogger(), onClientMessage: async ({ id, type, data, timestamp }) => { - let paths = []; - if (type === "eleventy.editReset") { - // Reset configuration file - paths.push(this.eleventyConfig.getActiveConfigPath()); - - // Reset previous modified files - paths.push(...this.eleventyConfig.resetDataOverrides()); - } else if (type === "eleventy.edit") { - for (let dataFileSelector of Object.keys(data)) { - let [filePath, selector] = dataFileSelector.split("#"); - this.eleventyConfig.addDataEditOverride( - filePath, - selector, - data[dataFileSelector], - timestamp, - ); - paths.push(filePath); - } - } - - for (let filePath of new Set(paths)) { - if (filePath) { - for (let fn of this.#editCallbacks) { - await fn(filePath); - } - } - } + // do nothing }, }, DEFAULT_SERVER_OPTIONS, @@ -394,12 +367,4 @@ export default class Serve { await this.server.reload(reloadEvent); } } - - // TODO change this to onmessage - onEdit(callback) { - if (typeof callback !== "function") { - return; - } - this.#editCallbacks.push(callback); - } } diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index 44f317ee6..dfaf916f0 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -53,7 +53,6 @@ class TemplateConfig { #existsCache = new ExistsCache(); #usesGraph; #activeConfigPath; - #dataEdits = []; constructor(customRootConfig, projectConfigPath) { /** @type {object} */ @@ -583,60 +582,6 @@ class TemplateConfig { get existsCache() { return this.#existsCache; } - - addDataEditOverride(filePath, dataSelector, value, timestamp) { - this.#dataEdits.push({ - filePath, - dataSelector, - value, - timestamp, - }); - } - - getDataOverrideForPath(filePath) { - filePath = TemplatePath.stripLeadingDotSlash(filePath); - - let edits = this.#dataEdits - .filter((entry) => entry.filePath === filePath) - .sort((a, b) => { - // crdt algorithm: newest timestamp wins - return a.timestamp - b.timestamp; - }); - - if (edits.length === 0) { - return; - } - - // TODO add a cache for this - let obj = {}; - for (let edit of edits) { - let { filePath, dataSelector, value, timestamp } = edit; - - if (lodashGet(obj, dataSelector)) { - // console.log( "Warning: override conflict", {filePath, dataSelector, value, timestamp}, "with", lodashGet(obj, dataSelector) ); - } - - lodashSet(obj, dataSelector, value); - } - - return obj; - } - - resetDataOverrides() { - // de-duped - let filePaths = Array.from(new Set(this.#dataEdits.map((entry) => entry.filePath))); - this.#dataEdits = []; - return filePaths; - } - - // only a count of files+keys changed, not individual edits - getPendingDataOverrides() { - let s = new Set(); - for (let { filePath, dataSelector } of this.#dataEdits) { - s.add(`${filePath}#${dataSelector}`); - } - return Array.from(s); - } } export default TemplateConfig; diff --git a/src/TemplateContent.js b/src/TemplateContent.js index 9dc632dca..0eadd04b2 100644 --- a/src/TemplateContent.js +++ b/src/TemplateContent.js @@ -446,11 +446,6 @@ class TemplateContent { let data = Object.assign(frontMatterData, extraData, virtualTemplateData); - let editOverrides = this.eleventyConfig.getDataOverrideForPath(this.inputPath); - if (editOverrides) { - data = Merge(data, editOverrides); - } - return { data, excerpt: fm.excerpt, From 6f87e70d2982b4637ca2bf822ff445064f0205cf Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 16:35:36 -0500 Subject: [PATCH 45/53] Remove data cascade location mapping (needs to be in a separate PR) --- src/Data/DataCascade.js | 194 --------------------------------- src/Data/DataSourceLocation.js | 159 --------------------------- src/Data/TemplateData.js | 55 +--------- src/Engines/Nunjucks.js | 4 +- src/Template.js | 104 ------------------ src/TemplateContent.js | 45 -------- src/TemplateLayout.js | 34 ++---- src/TemplateMap.js | 37 ------- 8 files changed, 11 insertions(+), 621 deletions(-) delete mode 100644 src/Data/DataCascade.js delete mode 100644 src/Data/DataSourceLocation.js diff --git a/src/Data/DataCascade.js b/src/Data/DataCascade.js deleted file mode 100644 index c3116cb15..000000000 --- a/src/Data/DataCascade.js +++ /dev/null @@ -1,194 +0,0 @@ -import { isPlainObject, DeepCopy } from "@11ty/eleventy-utils"; -import lodash from "@11ty/lodash-custom"; - -import { LocationFactory, stringifyReadonlyLocation } from "./DataSourceLocation.js"; - -const { set: lodashSet, get: lodashGet } = lodash; - -export class DataCascadeManager { - static FLAGS = { - DATA_LOCATION: "INTERNAL_DATA_LOCATION_MAPPING", - }; - - #factoryEnabled = false; - - constructor() { - this.dataCascades = new Map(); - } - - setEnabled(isEnabled) { - this.#factoryEnabled = Boolean(isEnabled); - } - - has(templatePath) { - return this.dataCascades.has(templatePath); - } - - factory() { - if (!this.#factoryEnabled) { - return; - } - return new DataCascade(); - } - - create(templatePath) { - let cascade = this.factory(); - if (!cascade) { - return; - } - - this.dataCascades.set(templatePath, cascade); - return cascade; - } - - get(templatePath) { - if (!this.#factoryEnabled) { - return; - } - - if (!this.has(templatePath)) { - throw new Error("Internal error: missing data cascade for " + templatePath); - } - - return this.dataCascades.get(templatePath); - } - - reset() { - this.dataCascades = new Map(); - } -} - -export class DataCascade { - static READ_ONLY_KEY = "11ty:readonly"; - static TOGGLE_PROP_NAME = "__useInternalDataMapSource"; - - constructor() { - this.dataSourceLocations = {}; - - Object.defineProperty(this.dataSourceLocations, DataCascade.TOGGLE_PROP_NAME, { - value: true, - }); - } - - static deepThaw(target) { - if (Array.isArray(target)) { - return target.map((entry) => this.deepThaw(entry)); - } - - if (isPlainObject(target)) { - if (Object.isFrozen(target)) { - let thawed = {}; - for (let key in target) { - thawed[key] = this.deepThaw(target[key]); - } - return thawed; - } - - // reuse existing - for (let key in target) { - target[key] = this.deepThaw(target[key]); - } - } - return target; - } - - // Global Data and Template Data Cascade combine - mergeWithUpstreamDataCascade(...upstreamDataCascades) { - let locations = upstreamDataCascades.filter(Boolean).map((entry) => entry.getLocations()); - if (locations.length > 0) { - this.dataSourceLocations = DeepCopy({}, ...locations, this.dataSourceLocations); - } - } - - assignFromUpstreamDataCascade(...upstreamDataCascades) { - let locations = upstreamDataCascades.filter(Boolean).map((entry) => entry.getLocations()); - if (locations.length > 0) { - this.dataSourceLocations = Object.assign({}, ...locations, this.dataSourceLocations); - } - } - - mergeTopLevel(data, sourceFilePath) { - let newSources = DataCascade.getMappingObject( - data, - sourceFilePath || DataCascade.READ_ONLY_KEY, - ); - DeepCopy(this.dataSourceLocations, newSources); - } - - mergeToLocation(data, location, sourceFilePath, dataSourceSelector) { - let target = lodashGet(this.dataSourceLocations, location); - let source = DataCascade.getMappingObject( - data, - sourceFilePath || DataCascade.READ_ONLY_KEY, - dataSourceSelector, - ); - - let merged = DeepCopy(target, source); - lodashSet(this.dataSourceLocations, location, merged); - } - - // For computed data - markLocationAsReadOnly(location) { - lodashSet(this.dataSourceLocations, location, stringifyReadonlyLocation(location)); - } - - getLocations() { - return this.dataSourceLocations; - } - - static #getPropertySelector(selector, propName) { - if (selector) { - if (propName.includes("-") || propName.includes("'") || propName.includes('"')) { - return `${selector}[${propName}]`; - } - return `${selector}.${propName}`; - } - - // lodash.get selector locations work fine with top level prop names with - characters - return propName; - } - - static getMappingObject(target, sourceFilePath, dataLocationSelector = "") { - if (typeof target === "function") { - return target; - } else if (sourceFilePath.startsWith("11ty:")) { - // readonly/internal mappings - // internal data may be frozen (think `eleventy` global) - return DataCascade.deepThaw(target); - } - - if (sourceFilePath.startsWith("./")) { - sourceFilePath = sourceFilePath.slice(2); - } - - let primitiveLocation = LocationFactory(target, sourceFilePath, dataLocationSelector); - if (primitiveLocation !== undefined) { - return primitiveLocation; - } - - if (Array.isArray(target)) { - return target.map((entry, index) => - // Array property [] index - this.getMappingObject(entry, sourceFilePath, `${dataLocationSelector}[${index}]`), - ); - } - - if (isPlainObject(target)) { - if (Object.isFrozen(target)) { - return DataCascade.deepThaw(target); - } - - let obj = {}; - for (let propName in target) { - obj[propName] = this.getMappingObject( - target[propName], - sourceFilePath, - this.#getPropertySelector(dataLocationSelector, propName), - ); - } - return obj; - } - - return target; - } -} diff --git a/src/Data/DataSourceLocation.js b/src/Data/DataSourceLocation.js deleted file mode 100644 index 60ae1d5de..000000000 --- a/src/Data/DataSourceLocation.js +++ /dev/null @@ -1,159 +0,0 @@ -import { isPlainObject } from "@11ty/eleventy-utils"; - -export class ArgumentHelper { - static isComplexArgument(v) { - return !this.isPrimitive(v) && !this.hasLocation(v); - } - static isPrimitive(v) { - return v !== Object(v); - } - static hasLocation(obj) { - return ["StringLocation", "NumberLocation"].includes(obj?.constructor?.name); - } - - static getFriendlyType(obj) { - if (this.hasLocation(obj)) { - let original = obj.getOriginalValue(); - if (this.hasLocation(original)) { - throw new Error("Internal error: data source location mapped to self (circular reference)"); - } - return this.getFriendlyType(original); - } - if (Array.isArray(obj)) { - return "array"; - } - if (isPlainObject(obj)) { - return "object"; - } - return typeof obj; - } - - static hasArgumentParity(args = []) { - let types = {}; - for (let a of args) { - let type = this.getFriendlyType(a); - if (!types[type]) { - types[type] = 0; - } - types[type]++; - } - let keys = Object.keys(types); - return keys.length === 1; - } - - // TODO add configuration option to hard-code the execution mode for a filter - static getExecutionMode(...args) { - // skips if args.length is 1 - if (!this.hasArgumentParity(args)) { - return "partial"; - } - - // some args are not primitives and aren’t location-aware - let complexArgs = args.filter((a) => this.isComplexArgument(a)); - if (complexArgs.length > 0) { - return "execute"; - } - - // is empty or single literal - return "passthrough"; - } - - static mapToLocation(args) { - return args.filter((a) => this.hasLocation(a)).map((a) => a.getLocation()); - } - - static wrapFilter(callback) { - return function (...args) { - if (this.__useInternalDataMapSource) { - let mode = ArgumentHelper.getExecutionMode(...args); - if (mode === "passthrough") { - return ArgumentHelper.mapToLocation(args); - } - - if (mode === "partial") { - args = args.map((entry, index) => { - if (index > 0 && ArgumentHelper.hasLocation(entry)) { - return entry.getOriginalValue(); - } - return entry; - }); - } - } - - // @ts-ignore - return callback.call(this, ...args); - }; - } -} - -function stringifyLocation(target) { - return `{via::${target.filePath}::${target.selectorLocation}::${("" + target).length}}`; -} -export function stringifyReadonlyLocation(label) { - return `{via::11ty_readonly${label ? `::${label}` : ""}}`; -} - -class StringLocation extends String { - constructor(val, filePath, selectorLocation) { - super(val); - this.original = val; - this.val = "" + val; - this.filePath = filePath; - this.selectorLocation = selectorLocation; - } - - getLocation() { - return stringifyLocation(this); - } - - getOriginalValue() { - return this.original; - } - - toString() { - return this.getLocation(); - } - - [Symbol.toPrimitive](hint) { - return this.val; - } -} - -class NumberLocation extends Number { - constructor(val, filePath, selectorLocation) { - super(val); - this.original = val; - this.val = Number(val); - this.filePath = filePath; - this.selectorLocation = selectorLocation; - } - - getLocation() { - return stringifyLocation(this); - } - - getOriginalValue() { - return this.original; - } - - toString() { - return this.getLocation(); - } - - [Symbol.toPrimitive](hint) { - return this.val; - } -} - -export function LocationFactory(val, ...args) { - if (typeof val === "number") { - return new NumberLocation(val, ...args); - } - if (typeof val === "string") { - return new StringLocation(val, ...args); - } - // Not supported yet (there is no userland way to intercept boolean coercion, e.g. `new BooleanLocation()` would always return true) - // if(typeof val === "boolean") { - // return val; - // } -} diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index 97f66d81c..c36565ef9 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -6,7 +6,6 @@ import { createDebug } from "obug"; import { inspect } from "../Adapters/Packages/inspect.js"; import unique from "../Util/Objects/Unique.js"; import TemplateGlob from "../TemplateGlob.js"; -import { DataCascadeManager } from "./DataCascade.js"; import BaseError from "../Errors/BaseError.js"; import ConfigurationGlobalData from "./ConfigurationGlobalData.js"; import { @@ -52,9 +51,6 @@ class TemplateData { #rawImports; #globalData; #templateDirectoryData = {}; - #dataCascadeManager = new DataCascadeManager(); - #globalDataCascade; - #collectionsDataCascade; constructor(templateConfig) { if (!templateConfig || templateConfig.constructor.name !== "TemplateConfig") { @@ -66,12 +62,6 @@ class TemplateData { this.templateConfig = templateConfig; this.config = this.templateConfig.getConfig(); - if (this.config.experimentalFlags.includes(DataCascadeManager.FLAGS.DATA_LOCATION)) { - this.#dataCascadeManager.setEnabled(true); - this.#globalDataCascade = this.#dataCascadeManager.factory(); - this.#collectionsDataCascade = this.#dataCascadeManager.factory(); - } - this.benchmarks = { data: this.config.benchmarkManager.get("Data"), aggregate: this.config.benchmarkManager.get("Aggregate"), @@ -167,15 +157,6 @@ class TemplateData { [this.config.keys.package]: packageJson, }; - if (projectPackageJsonPath) { - let relativeProjectPackageJsonPath = - ProjectDirectories.relativeToProjectRoot(projectPackageJsonPath); - - if (this.#globalDataCascade) { - this.#globalDataCascade.mergeTopLevel(this.#rawImports, relativeProjectPackageJsonPath); - } - } - if (this.config.freezeReservedData) { DeepFreeze(this.#rawImports); } @@ -187,7 +168,6 @@ class TemplateData { this.#globalData = null; this.configApiGlobalData = null; this.#templateDirectoryData = {}; - this.#dataCascadeManager.reset(); } _getGlobalDataGlobByExtension(extension) { @@ -382,10 +362,6 @@ class TemplateData { dataFileConflicts[objectPathTargetString] = file; debug(`Found global data file ${file} and adding as: ${objectPathTarget}`); - if (this.#globalDataCascade) { - this.#globalDataCascade.mergeToLocation(data, objectPathTargetString, file); - } - lodashSet(globalData, objectPathTarget, data); if (this.config.freezeReservedData) { @@ -442,10 +418,6 @@ class TemplateData { // Data from the configuration API eleventyConfig.addGLobalData and `eleventy` global let configApiGlobalData = await this.getInitialGlobalData(); - // Some day we may treat the `eleventy` global assigned here as different to Config API data (readonly vs internal) - if (this.#globalDataCascade) { - this.#globalDataCascade.mergeTopLevel(configApiGlobalData); - } let globalJson = await this.getAllGlobalData(); let mergedGlobalData = Merge(globalJson, configApiGlobalData); @@ -463,7 +435,7 @@ class TemplateData { } /* Template and Directory data files */ - async combineLocalData(localDataPaths, dataCascade) { + async combineLocalData(localDataPaths) { let localData = {}; if (!Array.isArray(localDataPaths)) { localDataPaths = [localDataPaths]; @@ -508,35 +480,16 @@ class TemplateData { } Merge(localData, cleanedDataForPath); - - if (dataCascade) { - dataCascade.mergeTopLevel(localData, path); - } } } return localData; } - getCollectionsDataCascade() { - return this.#collectionsDataCascade; - } - - getGlobalDataCascade() { - return this.#globalDataCascade; - } - async getTemplateDirectoryData(templatePath) { if (!this.#templateDirectoryData[templatePath]) { - let cascade; - if (!this.#dataCascadeManager.has(templatePath)) { - cascade = this.#dataCascadeManager.create(templatePath); - } else { - cascade = this.#dataCascadeManager.get(templatePath); - } - let localDataPaths = await this.getLocalDataPaths(templatePath); - let importedData = await this.combineLocalData(localDataPaths, cascade); + let importedData = await this.combineLocalData(localDataPaths); this.#templateDirectoryData[templatePath] = importedData; } @@ -544,10 +497,6 @@ class TemplateData { return this.#templateDirectoryData[templatePath]; } - getTemplateDirectoryDataCascade(templatePath) { - return this.#dataCascadeManager.get(templatePath); - } - getUserDataExtensions() { if (!this.config.dataExtensions) { return []; diff --git a/src/Engines/Nunjucks.js b/src/Engines/Nunjucks.js index 2c3afc4ae..94765f95a 100755 --- a/src/Engines/Nunjucks.js +++ b/src/Engines/Nunjucks.js @@ -11,7 +11,6 @@ import { import TemplateEngine from "./TemplateEngine.js"; import BaseError from "../Errors/BaseError.js"; import { augmentObject } from "./Util/ContextAugmenter.js"; -import { ArgumentHelper } from "../Data/DataSourceLocation.js"; const debug = createDebug("BuildAwesome:Nunjucks"); @@ -151,8 +150,7 @@ export default class Nunjucks extends TemplateEngine { lazy: false, // context.env?.opts.throwOnUndefined, }); - let callback = ArgumentHelper.wrapFilter(fn); - return callback.call(this, ...args); + return fn.call(this, ...args); } catch (e) { throw new EleventyNunjucksError( `Error in Nunjucks Filter \`${name}\`${this.page ? ` (${this.page.inputPath})` : ""}`, diff --git a/src/Template.js b/src/Template.js index a2ce548a3..09bbf4d9e 100755 --- a/src/Template.js +++ b/src/Template.js @@ -39,7 +39,6 @@ class Template extends TemplateContent { #cacheRenderedPromise; #cacheRenderedTransformsAndLayoutsPromise; #cacheRenderedDataLocationsTransformsAndLayoutsPromise; - #layoutDataCascade; #preprocessors; #preprocessorCache; @@ -370,10 +369,6 @@ class Template extends TemplateContent { return {}; } - getLayoutDataCascade() { - return this.#layoutDataCascade; - } - async #getData() { let localData = {}; let globalData = {}; @@ -398,9 +393,6 @@ class Template extends TemplateContent { let layout = this.getLayout(layoutKey); mergedLayoutData = await layout.getData(); - - // TODO disable/toggle enabled - this.#layoutDataCascade = layout.getLayoutDataCascade(); } } @@ -434,51 +426,6 @@ class Template extends TemplateContent { return this.#dataCache; } - mergeDataCascadeLocations(data) { - if (!this.dataCascade) { - return; - } - - // Set page.* as read only - this.dataCascade.mergeToLocation(data.page, "page"); // read only - - // TODO add support for page.date (points to `date`) - - // Only works with strings here, functions are read-only (above) - if (typeof data?.eleventyComputed?.permalink === "string") { - this.dataCascade.mergeToLocation( - data.page.url, - "page.url", - data?.eleventyComputed?.permalink, - "eleventyComputed.permalink", - ); - this.dataCascade.mergeToLocation( - data.page.outputPath, - "page.outputPath", - data?.eleventyComputed?.permalink, - "eleventyComputed.permalink", - ); - } else if (typeof data?.permalink === "string") { - this.dataCascade.mergeToLocation(data.page.url, "page.url", data?.permalink, "permalink"); - this.dataCascade.mergeToLocation( - data.page.outputPath, - "page.outputPath", - data?.permalink, - "permalink", - ); - } - - if (this.computedData?.computedKeys) { - let keys = Array.from(this.computedData?.computedKeys).filter( - (selector) => !["page.url", "page.outputPath"].includes(selector), - ); - for (let selector of keys) { - // TODO add support for string computed data - this.dataCascade.markLocationAsReadOnly(selector); - } - } - } - async getPageData(data) { let page = { // Make sure to keep these keys synchronized in src/Util/ReservedData.js @@ -800,8 +747,6 @@ class Template extends TemplateContent { if (!Pagination.hasPagination(data)) { await this.addComputedData(data); - this.mergeDataCascadeLocations(data); - let obj = { template: this, // not on the docs but folks are relying on it rawInput, @@ -831,8 +776,6 @@ class Template extends TemplateContent { for (let pageEntry of pageTemplates) { await pageEntry.template.addComputedData(pageEntry.data); - pageEntry.template.mergeDataCascadeLocations(pageEntry.data); - let obj = { template: pageEntry.template, // not on the docs but folks are relying on it rawInput, @@ -938,42 +881,6 @@ class Template extends TemplateContent { return content; } - async #renderDataLocationsPageEntry(pageEntry) { - if (!(pageEntry?.outputPath || "").endsWith(".html")) { - return; - } - - // Don’t run linters/transforms/layouts if we didn’t render (via incremental)! - if (pageEntry.template.isDryRun && pageEntry.template.isIncremental) { - return pageEntry.template.getDataMapContent(); - } - - let content; - let layoutKey = pageEntry.data[this.config.keys.layout]; - if (this.engine.useLayouts() && layoutKey) { - let layout = pageEntry.template.getLayout(layoutKey); - content = await layout.renderLayoutPageEntry(pageEntry, this.dataCascade); - } else { - content = pageEntry.template.getDataMapContent(); - } - - content = await this.runTransforms(content, pageEntry); - return content; - } - - static async renderPageEntryDataLocations(pageEntry) { - if (!pageEntry.template.dataCascade) { - return; - } - - // @cachedproperty - if (!pageEntry.template.#cacheRenderedDataLocationsTransformsAndLayoutsPromise) { - pageEntry.template.#cacheRenderedDataLocationsTransformsAndLayoutsPromise = - pageEntry.template.#renderDataLocationsPageEntry(pageEntry); - } - return pageEntry.template.#cacheRenderedDataLocationsTransformsAndLayoutsPromise; - } - // This could be `static` async renderPageEntry(pageEntry) { // @cachedproperty @@ -1004,13 +911,11 @@ class Template extends TemplateContent { for (let page of mapEntry._pages) { let content; - let contentMap; // Note that behavior.render is overridden when using json output if (page.template.isRenderable()) { // this reuses page.templateContent, it doesn’t render it content = await page.template.renderPageEntry(page); - contentMap = await Template.renderPageEntryDataLocations(page); } if (to === "json") { @@ -1020,7 +925,6 @@ class Template extends TemplateContent { outputPath: page.outputPath, rawInput: page.rawInput, content, - // contentMap, }; if (this.config.dataFilterSelectors?.size > 0) { @@ -1050,14 +954,6 @@ class Template extends TemplateContent { if (content !== undefined) { ret.push(this._write(page, content)); } - - // write data map - if (contentMap !== undefined && page.outputPath) { - // TODO unlock option to customize this - let mapOutputPath = page.outputPath + ".map"; - this.fsManager.createDirectoryForFileSync(mapOutputPath); - this.fsManager.writeFileSync(mapOutputPath, contentMap); - } } return Promise.all(ret); diff --git a/src/TemplateContent.js b/src/TemplateContent.js index 0eadd04b2..bb4a08458 100644 --- a/src/TemplateContent.js +++ b/src/TemplateContent.js @@ -27,7 +27,6 @@ class TemplateContent { #extensionMap; #configOptions; #frontMatterOptions; - #dataMapContent; constructor(inputPath, templateConfig) { if (!templateConfig || templateConfig.constructor.name !== "TemplateConfig") { @@ -392,13 +391,6 @@ class TemplateContent { return fm.content; } - get dataCascade() { - if (!this.templateData) { - return; - } - return this.templateData.getTemplateDirectoryDataCascade(this.inputPath); - } - async #getFrontMatterData() { let fm = await this.read(); @@ -433,17 +425,6 @@ class TemplateContent { isVirtualTemplate: Boolean(virtualTemplateData), }); - if (this.dataCascade) { - this.dataCascade.mergeTopLevel(frontMatterData, this.inputPath); - - if (extraData) { - this.dataCascade.mergeTopLevel(extraData); - } - if (virtualTemplateData) { - this.dataCascade.mergeTopLevel(virtualTemplateData); - } - } - let data = Object.assign(frontMatterData, extraData, virtualTemplateData); return { @@ -677,10 +658,6 @@ class TemplateContent { return suffix.join(""); } - getDataMapContent() { - return this.#dataMapContent; - } - async _render(str, data, options = {}) { let { bypassMarkdown, type } = options; @@ -712,28 +689,6 @@ class TemplateContent { inputPathBenchmark.before(); } - // Only HTML output files - if ( - this.dataCascade && - type === "Content" && - (data.page?.outputPath || "").endsWith(".html") - ) { - // Merge local data cascade with global - let globalDataCascade = this.templateData.getGlobalDataCascade(); - let layoutDataCascade = this.getLayoutDataCascade(); - this.dataCascade.mergeWithUpstreamDataCascade(layoutDataCascade, globalDataCascade); - - let collectionsDataCascade = this.templateData.getCollectionsDataCascade(); - this.dataCascade.assignFromUpstreamDataCascade(collectionsDataCascade); - - let dataSourceLocations = this.dataCascade.getLocations(); - let dataMapContent = await fn(dataSourceLocations); - // cache data map html content - this.#dataMapContent = dataMapContent; - } else { - this.#dataMapContent = undefined; - } - let rendered = await fn(data); if (inputPathBenchmark) { diff --git a/src/TemplateLayout.js b/src/TemplateLayout.js index c573b3fe4..91823c772 100644 --- a/src/TemplateLayout.js +++ b/src/TemplateLayout.js @@ -3,7 +3,6 @@ import { Merge, TemplatePath } from "@11ty/eleventy-utils"; import TemplateLayoutPathResolver from "./TemplateLayoutPathResolver.js"; import TemplateContent from "./TemplateContent.js"; import layoutCache from "./LayoutCache.js"; -import { DataCascade } from "./Data/DataCascade.js"; // https://github.com/11ty/eleventy/issues/3954 class CdataWrapper { @@ -39,7 +38,6 @@ class CdataWrapper { class TemplateLayout extends TemplateContent { #dataCache; - #layoutDataCascade = new DataCascade(); constructor(key, extensionMap, eleventyConfig) { if (!eleventyConfig || eleventyConfig.constructor.name !== "TemplateConfig") { @@ -61,10 +59,6 @@ class TemplateLayout extends TemplateContent { this.inputPath = resolvedPath; } - getLayoutDataCascade() { - return this.#layoutDataCascade; - } - getKey() { return this.key; } @@ -176,7 +170,6 @@ class TemplateLayout extends TemplateContent { let dataToMerge = []; for (let j = map.length - 1; j >= 0; j--) { dataToMerge.push(map[j].frontMatterData); - this.#layoutDataCascade.mergeTopLevel(map[j].frontMatterData, map[j].inputPath); } // Deep merge of layout front matter @@ -250,13 +243,11 @@ class TemplateLayout extends TemplateContent { // Inefficient? We want to compile all the templatelayouts into a single reusable callback? // Trouble: layouts may need data variables present downstream/upstream // This is called from Template->renderPageEntry - async renderLayoutPageEntry(pageEntry, dataCascade) { + async renderLayoutPageEntry(pageEntry) { let pageTemplateSyntax = pageEntry.template?.getEngineNames( pageEntry.data[this.config.keys.engineOverride], ); - let templateContent = dataCascade - ? pageEntry.template.getDataMapContent() - : pageEntry.templateContent; + let templateContent = pageEntry.templateContent; let compiledFunctions = await this.getCompiledLayoutFunctions(); for (let { render, template } of compiledFunctions) { @@ -265,21 +256,12 @@ class TemplateLayout extends TemplateContent { let layoutTemplateSyntax = template.getEngineNames(); // templateEngineOverride not supported in layouts let cdata = new CdataWrapper(pageTemplateSyntax, layoutTemplateSyntax); - if (dataCascade) { - let dataSources = { - ...dataCascade.getLocations(), - // This should come *after* data, so `content` have override `content` props set in data cascade - content: cdata.wrap(templateContent), - }; - templateContent = cdata.unwrap(await render(dataSources)); - } else { - let data = { - ...pageEntry.data, - // This should come *after* data, so `content` have override `content` props set in data cascade - content: cdata.wrap(templateContent), - }; - templateContent = cdata.unwrap(await render(data)); - } + let data = { + ...pageEntry.data, + // This should come *after* data, so `content` have override `content` props set in data cascade + content: cdata.wrap(templateContent), + }; + templateContent = cdata.unwrap(await render(data)); } // Don’t set `templateContent` on pageEntry because collection items should not have layout markup diff --git a/src/TemplateMap.js b/src/TemplateMap.js index bcb962dcc..bd0fd9b7b 100644 --- a/src/TemplateMap.js +++ b/src/TemplateMap.js @@ -266,42 +266,6 @@ class TemplateMap { .filter(Boolean); } - mergeDataCascadeLocations() { - let collectionsDataCascade = this.#templateData?.getCollectionsDataCascade(); - if (!collectionsDataCascade) { - return; - } - - for (let [name, collection] of Object.entries(this.collectionsData)) { - let index = 0; - for (let entry of collection) { - let dataWithoutCollections = { - ...entry.data, - }; - delete dataWithoutCollections.collections; - - let readOnlyEntry = { - page: entry.page, - rawInput: entry.rawInput, - inputPath: entry.inputPath, - date: entry.date, - outputPath: entry.outputPath, - url: entry.url, - templateContent: "", - content: "", - }; - - collectionsDataCascade.mergeToLocation(readOnlyEntry, `collections[${name}][${index}]`); - collectionsDataCascade.mergeToLocation( - dataWithoutCollections, - `collections[${name}][${index}].data`, - entry.inputPath, - ); - index++; - } - } - } - async cache() { if (!this.#dependencyMapInitialized) { this.addAllToGlobalDependencyGraph(); @@ -322,7 +286,6 @@ class TemplateMap { await this.initDependencyMap(fullTemplateOrder); await this.resolveRemainingComputedData(); - this.mergeDataCascadeLocations(); let orderedPaths = this.#removeTagsFromTemplateOrder(fullTemplateOrder); From ee65fb8fc00e205f19e4153b3374cb0008170e39 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 16:49:06 -0500 Subject: [PATCH 46/53] Resolve https://github.com/11ty/eleventy/pull/4294/changes/BASE..e803e26cc3a7a9fd03a3f774a001753a4022df51#r3407864771 --- test/ServeTest.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/test/ServeTest.js b/test/ServeTest.js index 8ab5274ce..ace0926db 100644 --- a/test/ServeTest.js +++ b/test/ServeTest.js @@ -31,8 +31,11 @@ test("Get Options", async (t) => { let es = await getServerInstance(); es.setOutputDir("_site"); - t.is(es.options.pathPrefix, "/"); - t.is(es.options.port, 8080); + t.deepEqual(es.options, { + onClientMessage: async() => {}, + pathPrefix: "/", + port: 8080, + }); }); test("Get Options (with a pathPrefix)", async (t) => { @@ -42,16 +45,22 @@ test("Get Options (with a pathPrefix)", async (t) => { let es = await getServerInstance(eleventyConfig); es.setOutputDir("_site"); - t.is(es.options.pathPrefix, "/web/"); - t.is(es.options.port, 8080); + t.deepEqual(es.options, { + onClientMessage: async() => {}, + pathPrefix: "/web/", + port: 8080, + }); }); test("Get Options (override in config)", async (t) => { let es = await getServerInstance(); es.setOutputDir("_site"); - t.is(es.options.pathPrefix, "/"); - t.is(es.options.port, 8080); + t.deepEqual(es.options, { + onClientMessage: async() => {}, + pathPrefix: "/", + port: 8080, + }); }); test("Sanity test that default output is set correctly", async (t) => { From 97e763fa113a1967365fd3dab91f3532b1639569 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 16:51:14 -0500 Subject: [PATCH 47/53] Resolves https://github.com/11ty/eleventy/pull/4294#discussion_r3407880830 --- packages/browser/test/shared-tests.js | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/browser/test/shared-tests.js b/packages/browser/test/shared-tests.js index 2d71bfe04..aad82b91e 100644 --- a/packages/browser/test/shared-tests.js +++ b/packages/browser/test/shared-tests.js @@ -10,7 +10,7 @@ export default function(BuildAwesome) { }); test("Markdown (no preprocessor) template", async () => { - let elev = new BuildAwesome({ + let ba = new BuildAwesome({ config(configApi) { configApi.addEngine("md", Markdown); configApi.setMarkdownTemplateEngine(false); @@ -21,12 +21,12 @@ export default function(BuildAwesome) { } }); - let json = await elev.toJSON(); + let json = await ba.toJSON(); assert.strictEqual(json[0].content.trim(), `

Heading

`); }); test("Markdown (via Liquid) template", async () => { - let elev = new BuildAwesome({ + let ba = new BuildAwesome({ config(configApi) { configApi.addEngine("md", Markdown); configApi.addEngine("liquid", Liquid); @@ -38,12 +38,12 @@ export default function(BuildAwesome) { } }); - let json = await elev.toJSON(); + let json = await ba.toJSON(); assert.strictEqual(json[0].content.trim(), `

Heading

`); }); test("Liquid template", async () => { - let elev = new BuildAwesome({ + let ba = new BuildAwesome({ config(configApi) { configApi.addEngine("liquid", Liquid); configApi.setTemplateFormats("liquid"); @@ -51,12 +51,12 @@ export default function(BuildAwesome) { } }); - let json = await elev.toJSON(); + let json = await ba.toJSON(); assert.strictEqual(json[0].content.trim(), `

Heading

`); }); test("Nunjucks template", async () => { - let elev = new BuildAwesome({ + let ba = new BuildAwesome({ config(configApi) { configApi.addEngine("njk", Nunjucks); configApi.setTemplateFormats("njk"); @@ -65,12 +65,12 @@ export default function(BuildAwesome) { } }); - let json = await elev.toJSON(); + let json = await ba.toJSON(); assert.strictEqual(json[0].content.trim(), `

Heading

`); }); test("i18n Plugin Use (with 11ty.js)", async () => { - let elev = new BuildAwesome({ + let ba = new BuildAwesome({ config(configApi) { configApi.addPlugin(I18nPlugin, { defaultLanguage: "en" @@ -84,14 +84,14 @@ export default function(BuildAwesome) { } }); - let json = await elev.toJSON(); + let json = await ba.toJSON(); assert.strictEqual(json[0].content.trim(), `Home`); assert.strictEqual(json[1].content.trim(), `Home`); }); // Careful, `@11ty/client` will resolve slugify via Vite instead of it bundled with the package test("slugify Filter in Liquid", async () => { - let elev = new BuildAwesome({ + let ba = new BuildAwesome({ config(configApi) { configApi.addEngine("liquid", Liquid); configApi.setTemplateFormats("liquid"); @@ -99,13 +99,13 @@ export default function(BuildAwesome) { } }); - let json = await elev.toJSON(); + let json = await ba.toJSON(); assert.strictEqual(json[0].content.trim(), `this-is-a-heading`); }); // Careful, `@11ty/client` will resolve slugify via Vite instead of it bundled with the package test("slugify Filter in Nunjucks", async () => { - let elev = new BuildAwesome({ + let ba = new BuildAwesome({ config(configApi) { configApi.addEngine("njk", Nunjucks); configApi.setTemplateFormats("njk"); @@ -113,7 +113,7 @@ export default function(BuildAwesome) { } }); - let json = await elev.toJSON(); + let json = await ba.toJSON(); assert.strictEqual(json[0].content.trim(), `this-is-a-heading`); }); } From a779d77b14afd9ff7e0442eb35e67ca1c6e256bb Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 15 Jun 2026 17:18:17 -0500 Subject: [PATCH 48/53] Only use BuildAwesome: debug log prefix if running from the Build Awesome npm package --- cmd.cjs | 4 ++-- packages/build-awesome/cmd.js | 2 +- src/Benchmark/BenchmarkGroup.js | 5 ++--- src/Core.js | 4 ++-- src/CoreMinimal.js | 13 +++++++------ src/Data/ComputedData.js | 4 ++-- src/Data/ComputedDataTemplateString.js | 5 +++-- src/Data/TemplateData.js | 6 +++--- src/Engines/Nunjucks.js | 4 ++-- src/Engines/TemplateEngine.js | 4 ++-- src/Engines/TemplateEngineManager.js | 4 ++-- src/Errors/ErrorHandler.js | 5 ++--- src/EventBus.js | 5 ++--- src/FileSystemSearch.js | 4 ++-- src/Files.js | 4 ++-- src/GlobalDependencyMap.js | 4 ++-- src/Serve.js | 4 ++-- src/Template.js | 4 ++-- src/TemplateConfig.js | 4 ++-- src/TemplateContent.js | 4 ++-- src/TemplateMap.js | 4 ++-- src/TemplatePassthrough.js | 4 ++-- src/TemplatePassthroughManager.js | 4 ++-- src/TemplateRender.js | 4 ++-- src/TemplateWriter.js | 4 ++-- src/UserConfig.js | 5 ++--- src/Util/ConsoleLogger.js | 4 ++-- src/Util/DateParse.js | 5 +++-- src/Util/DebugLogUtil.js | 8 ++++++++ src/Util/EsmResolver.js | 4 ++-- src/Util/EventBusUtil.js | 4 ++-- src/Util/ImportJsonSync.js | 4 ++-- src/Util/Objects/ProxyWrap.js | 2 +- src/Util/ProjectTemplateFormats.js | 5 +++-- src/Util/TemplateDepGraph.js | 4 ++-- src/Util/TransformsUtil.js | 7 ++++--- src/Watch.js | 4 ++-- 37 files changed, 89 insertions(+), 80 deletions(-) create mode 100644 src/Util/DebugLogUtil.js diff --git a/cmd.cjs b/cmd.cjs index ea95f75c8..b45992cf2 100755 --- a/cmd.cjs +++ b/cmd.cjs @@ -26,8 +26,8 @@ class SimpleError extends Error { } async function exec() { - const { createDebug } = await import("obug"); - const debug = createDebug("BuildAwesome:CLI"); + const { createDebug } = await import("./src/Util/DebugLogUtil.js"); + const debug = createDebug("CLI"); // Notes about friendly error messaging with outdated Node versions: https://github.com/11ty/buildawesome/issues/3761 const { ErrorHandler } = await import("./src/Errors/ErrorHandler.js"); diff --git a/packages/build-awesome/cmd.js b/packages/build-awesome/cmd.js index 58fa5b2fc..2779d3e83 100755 --- a/packages/build-awesome/cmd.js +++ b/packages/build-awesome/cmd.js @@ -1,6 +1,6 @@ #!/usr/bin/env node -// Influences console prefix +// Influences console and DEBUG log prefixes process.env.BUILDAWESOME_PACKAGE = "@awesome.me/buildawesome"; import "@11ty/eleventy/cli"; diff --git a/src/Benchmark/BenchmarkGroup.js b/src/Benchmark/BenchmarkGroup.js index 66628beb1..fcca92335 100644 --- a/src/Benchmark/BenchmarkGroup.js +++ b/src/Benchmark/BenchmarkGroup.js @@ -1,9 +1,8 @@ -import { createDebug } from "obug"; - +import { createDebug } from "../Util/DebugLogUtil.js"; import isAsyncFunction from "../Util/IsAsyncFunction.js"; import Benchmark from "./Benchmark.js"; -const debugBenchmark = createDebug("BuildAwesome:Benchmark"); +const debugBenchmark = createDebug("Benchmark"); class BenchmarkGroup { constructor() { diff --git a/src/Core.js b/src/Core.js index c0c6a81a8..583a6713a 100644 --- a/src/Core.js +++ b/src/Core.js @@ -1,5 +1,4 @@ import { relative } from "node:path"; -import { createDebug } from "obug"; import { TemplatePath } from "@11ty/eleventy-utils"; @@ -11,13 +10,14 @@ import WatchTargets from "./WatchTargets.js"; import BaseError from "./Errors/BaseError.js"; // Utils +import { createDebug } from "./Util/DebugLogUtil.js"; import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; import PathPrefixer from "./Util/PathPrefixer.js"; import PathNormalizer from "./Util/PathNormalizer.js"; import { isGlobMatch } from "./Util/GlobMatcher.js"; import eventBus from "./EventBus.js"; -const debug = createDebug("BuildAwesome:Core"); +const debug = createDebug("Core"); export default class Core extends CoreFs { /** @type {boolean} */ diff --git a/src/CoreMinimal.js b/src/CoreMinimal.js index 12981bf8b..d081293c6 100644 --- a/src/CoreMinimal.js +++ b/src/CoreMinimal.js @@ -1,4 +1,3 @@ -import { createDebug } from "obug"; import { isPlainObject, TemplatePath } from "@11ty/eleventy-utils"; import chalk from "./Adapters/Packages/chalk.js"; @@ -11,6 +10,7 @@ import TemplateConfig from "./TemplateConfig.js"; import TemplateEngineManager from "./Engines/TemplateEngineManager.js"; /* Utils */ +import { createDebug } from "./Util/DebugLogUtil.js"; import { readableFileSize } from "./Util/FileSize.js"; import simplePlural from "./Util/Pluralize.js"; import ConsoleLogger from "./Util/ConsoleLogger.js"; @@ -24,7 +24,7 @@ import ProjectTemplateFormats from "./Util/ProjectTemplateFormats.js"; import { setEnvValue } from "./Util/EnvironmentVars.cjs"; const pkg = getCorePackageJson(); -const debug = createDebug("BuildAwesome:Core"); +const debug = createDebug("Core"); export class CoreMinimal { /** @@ -234,13 +234,14 @@ export class CoreMinimal { return CoreMinimal.getVersion(); } - static isUsingBuildAwesome(configPath) { - if (typeof configPath !== "string") { + isUsingBuildAwesome() { + if (typeof this.#activeConfigurationPath !== "string") { return; } + if ( process?.env?.BUILDAWESOME_PACKAGE === "@awesome.me/buildawesome" || - configPath.includes("buildawesome.config") + this.#activeConfigurationPath.includes("buildawesome.config") ) { return true; } @@ -257,7 +258,7 @@ export class CoreMinimal { this.#activeConfigurationPath = this.configPath ?? this.eleventyConfig.getLocalProjectConfigFile(); - if (CoreMinimal.isUsingBuildAwesome(this.#activeConfigurationPath)) { + if (this.isUsingBuildAwesome()) { this.logger.setPrefix(`[buildawesome]`); } diff --git a/src/Data/ComputedData.js b/src/Data/ComputedData.js index 40f998a06..cb3bf2993 100644 --- a/src/Data/ComputedData.js +++ b/src/Data/ComputedData.js @@ -1,12 +1,12 @@ import lodash from "@11ty/lodash-custom"; -import { createDebug } from "obug"; +import { createDebug } from "../Util/DebugLogUtil.js"; import ComputedDataQueue from "./ComputedDataQueue.js"; import ComputedDataTemplateString from "./ComputedDataTemplateString.js"; import ComputedDataProxy from "./ComputedDataProxy.js"; const { set: lodashSet, get: lodashGet } = lodash; -const debug = createDebug("BuildAwesome:ComputedData"); +const debug = createDebug("ComputedData"); class ComputedData { constructor(config) { diff --git a/src/Data/ComputedDataTemplateString.js b/src/Data/ComputedDataTemplateString.js index 228ec2da4..7cfcfa512 100644 --- a/src/Data/ComputedDataTemplateString.js +++ b/src/Data/ComputedDataTemplateString.js @@ -1,8 +1,9 @@ import lodash from "@11ty/lodash-custom"; -import { createDebug } from "obug"; + +import { createDebug } from "../Util/DebugLogUtil.js"; const { set: lodashSet } = lodash; -const debug = createDebug("BuildAwesome:ComputedDataTemplateString"); +const debug = createDebug("ComputedDataTemplateString"); /* Calculates computed data in Template Strings. * Ideally we would use the Proxy approach but it doesn’t work diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index c36565ef9..45e1a0625 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -1,7 +1,6 @@ import path from "node:path"; import lodash from "@11ty/lodash-custom"; import { Merge, TemplatePath, isPlainObject } from "@11ty/eleventy-utils"; -import { createDebug } from "obug"; import { inspect } from "../Adapters/Packages/inspect.js"; import unique from "../Util/Objects/Unique.js"; @@ -20,11 +19,12 @@ import ProjectDirectories from "../Util/ProjectDirectories.js"; import ReservedData from "../Util/ReservedData.js"; import { isTypeScriptSupported } from "../Util/TypeScriptFeatureTest.cjs"; import { ResolveConfigurationData } from "../Data/ResolveConfigurationData.js"; +import { createDebug } from "../Util/DebugLogUtil.js"; const { set: lodashSet, get: lodashGet } = lodash; -const debugWarn = createDebug("BuildAwesome:Warnings"); -const debug = createDebug("BuildAwesome:TemplateData"); +const debugWarn = createDebug("Warnings"); +const debug = createDebug("TemplateData"); class TemplateDataParseError extends BaseError {} diff --git a/src/Engines/Nunjucks.js b/src/Engines/Nunjucks.js index 94765f95a..62c8723ea 100755 --- a/src/Engines/Nunjucks.js +++ b/src/Engines/Nunjucks.js @@ -1,4 +1,3 @@ -import { createDebug } from "obug"; import { TemplatePath } from "@11ty/eleventy-utils"; // Direct reference to avoid use of `browser` Nunjucks variant in bundles @@ -11,8 +10,9 @@ import { import TemplateEngine from "./TemplateEngine.js"; import BaseError from "../Errors/BaseError.js"; import { augmentObject } from "./Util/ContextAugmenter.js"; +import { createDebug } from "../Util/DebugLogUtil.js"; -const debug = createDebug("BuildAwesome:Nunjucks"); +const debug = createDebug("Nunjucks"); class EleventyNunjucksError extends BaseError {} diff --git a/src/Engines/TemplateEngine.js b/src/Engines/TemplateEngine.js index 8f3cbb8d7..24bb72803 100644 --- a/src/Engines/TemplateEngine.js +++ b/src/Engines/TemplateEngine.js @@ -1,9 +1,9 @@ -import { createDebug } from "obug"; +import { createDebug } from "../Util/DebugLogUtil.js"; import BaseError from "../Errors/BaseError.js"; class TemplateEngineConfigError extends BaseError {} -const debug = createDebug("BuildAwesome:TemplateEngine"); +const debug = createDebug("TemplateEngine"); const AMENDED_INSTANCES = new Set(); diff --git a/src/Engines/TemplateEngineManager.js b/src/Engines/TemplateEngineManager.js index 41143183c..5deb542f0 100644 --- a/src/Engines/TemplateEngineManager.js +++ b/src/Engines/TemplateEngineManager.js @@ -1,6 +1,6 @@ -import { createDebug } from "obug"; +import { createDebug } from "../Util/DebugLogUtil.js"; -const debug = createDebug("BuildAwesome:TemplateEngineManager"); +const debug = createDebug("TemplateEngineManager"); class TemplateEngineManager { #CustomEngine; diff --git a/src/Errors/ErrorHandler.js b/src/Errors/ErrorHandler.js index f8d4ced85..fa59f5afa 100644 --- a/src/Errors/ErrorHandler.js +++ b/src/Errors/ErrorHandler.js @@ -1,10 +1,9 @@ -import { createDebug } from "obug"; - +import { createDebug } from "../Util/DebugLogUtil.js"; import { inspect } from "../Adapters/Packages/inspect.js"; import ConsoleLogger from "../Util/ConsoleLogger.js"; import ErrorUtil from "./ErrorUtil.js"; -const debug = createDebug("BuildAwesome:ErrorHandler"); +const debug = createDebug("ErrorHandler"); export class ErrorHandler { #logger; diff --git a/src/EventBus.js b/src/EventBus.js index b3e0c1a76..9edeb70b9 100644 --- a/src/EventBus.js +++ b/src/EventBus.js @@ -1,8 +1,7 @@ -import { createDebug } from "obug"; - +import { createDebug } from "./Util/DebugLogUtil.js"; import EventEmitter from "./Util/AsyncEventEmitter.js"; -const debug = createDebug("BuildAwesome:EventBus"); +const debug = createDebug("EventBus"); /** * @module 11ty/eleventy/EventBus diff --git a/src/FileSystemSearch.js b/src/FileSystemSearch.js index 2d6496a79..5bda2474e 100644 --- a/src/FileSystemSearch.js +++ b/src/FileSystemSearch.js @@ -1,11 +1,11 @@ import { glob } from "tinyglobby"; import { TemplatePath } from "@11ty/eleventy-utils"; -import { createDebug } from "obug"; +import { createDebug } from "./Util/DebugLogUtil.js"; import GlobRemap from "./Util/GlobRemap.js"; import { isGlobMatch } from "./Util/GlobMatcher.js"; -const debug = createDebug("BuildAwesome:FileSystemSearch"); +const debug = createDebug("FileSystemSearch"); class FileSystemSearch { constructor() { diff --git a/src/Files.js b/src/Files.js index a488fe261..99bda06c7 100644 --- a/src/Files.js +++ b/src/Files.js @@ -1,14 +1,14 @@ import { statSync, readFileSync } from "node:fs"; import { TemplatePath } from "@11ty/eleventy-utils"; -import { createDebug } from "obug"; +import { createDebug } from "./Util/DebugLogUtil.js"; import DirContains from "./Util/DirContains.js"; import TemplateData from "./Data/TemplateData.js"; import TemplateGlob from "./TemplateGlob.js"; import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; -const debug = createDebug("BuildAwesome:Files"); +const debug = createDebug("Files"); export class Files { #extensionMap; diff --git a/src/GlobalDependencyMap.js b/src/GlobalDependencyMap.js index d1a8e4cfd..374599b50 100644 --- a/src/GlobalDependencyMap.js +++ b/src/GlobalDependencyMap.js @@ -1,11 +1,11 @@ -import { createDebug } from "obug"; import { TemplatePath } from "@11ty/eleventy-utils"; +import { createDebug } from "./Util/DebugLogUtil.js"; import JavaScriptDependencies from "./Util/JavaScriptDependencies.js"; import PathNormalizer from "./Util/PathNormalizer.js"; import { TemplateDepGraph } from "./Util/TemplateDepGraph.js"; -const debug = createDebug("BuildAwesome:Dependencies"); +const debug = createDebug("Dependencies"); class GlobalDependencyMap { // dependency-graph requires these keys to be alphabetic strings diff --git a/src/Serve.js b/src/Serve.js index 3623d137a..3212c0620 100644 --- a/src/Serve.js +++ b/src/Serve.js @@ -1,4 +1,3 @@ -import { createDebug } from "obug"; import { Merge, TemplatePath } from "@11ty/eleventy-utils"; import { Watch } from "./Watch.js"; @@ -14,6 +13,7 @@ function stringifyOptions(options) { } import BaseError from "./Errors/BaseError.js"; +import { createDebug } from "./Util/DebugLogUtil.js"; import ConsoleLogger from "./Util/ConsoleLogger.js"; import PathPrefixer from "./Util/PathPrefixer.js"; import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; @@ -21,7 +21,7 @@ import { getModulePackageJson } from "./Util/ImportJsonSync.js"; import { DynamicImport } from "./Util/Require.js"; import { isGlobMatch } from "./Util/GlobMatcher.js"; -const debug = createDebug("BuildAwesome:Serve"); +const debug = createDebug("Serve"); class ServeConfigError extends BaseError {} diff --git a/src/Template.js b/src/Template.js index 09bbf4d9e..d60d80277 100755 --- a/src/Template.js +++ b/src/Template.js @@ -3,10 +3,10 @@ import { statSync } from "node:fs"; import lodash from "@11ty/lodash-custom"; import { Merge, TemplatePath, isPlainObject } from "@11ty/eleventy-utils"; -import { createDebug } from "obug"; import chalk from "./Adapters/Packages/chalk.js"; import ConsoleLogger from "./Util/ConsoleLogger.js"; +import { createDebug } from "./Util/DebugLogUtil.js"; import { getCreatedTimestamp, getUpdatedTimestamp } from "./Util/Git.js"; import TemplateContent from "./TemplateContent.js"; import TemplatePermalink from "./TemplatePermalink.js"; @@ -28,7 +28,7 @@ import { ResolveConfigurationData } from "./Data/ResolveConfigurationData.js"; const { set: lodashSet, get: lodashGet } = lodash; -const debug = createDebug("BuildAwesome:Template"); +const debug = createDebug("Template"); class Template extends TemplateContent { #logger; diff --git a/src/TemplateConfig.js b/src/TemplateConfig.js index dfaf916f0..e1ad1006a 100644 --- a/src/TemplateConfig.js +++ b/src/TemplateConfig.js @@ -1,9 +1,9 @@ -import { createDebug } from "obug"; import { Merge, TemplatePath, isPlainObject } from "@11ty/eleventy-utils"; import lodash from "@11ty/lodash-custom"; import chalk from "./Adapters/Packages/chalk.js"; import getDefaultConfig from "./Adapters/getDefaultConfig.js"; +import { createDebug } from "./Util/DebugLogUtil.js"; import { DynamicImportRaw } from "./Util/Require.js"; import BaseError from "./Errors/BaseError.js"; import UserConfig from "./UserConfig.js"; @@ -14,7 +14,7 @@ import ProjectTemplateFormats from "./Util/ProjectTemplateFormats.js"; import { expandEligibleJavaScriptFilePaths } from "./Util/FilePathUtil.js"; const { set: lodashSet, get: lodashGet } = lodash; -const debug = createDebug("BuildAwesome:TemplateConfig"); +const debug = createDebug("TemplateConfig"); /** * @module 11ty/eleventy/TemplateConfig diff --git a/src/TemplateContent.js b/src/TemplateContent.js index bb4a08458..ada08098d 100644 --- a/src/TemplateContent.js +++ b/src/TemplateContent.js @@ -1,10 +1,10 @@ import { readFileSync } from "node:fs"; -import { createDebug } from "obug"; import matter from "@11ty/gray-matter"; import lodash from "@11ty/lodash-custom"; import { Merge, DeepCopy, TemplatePath } from "@11ty/eleventy-utils"; import JavaScriptFrontMatter from "./Engines/FrontMatter/JavaScript.js"; +import { createDebug } from "./Util/DebugLogUtil.js"; import { EOL } from "./Util/NewLineAdapter.js"; import TemplateData from "./Data/TemplateData.js"; import TemplateRender from "./TemplateRender.js"; @@ -13,7 +13,7 @@ import ErrorUtil from "./Errors/ErrorUtil.js"; import eventBus from "./EventBus.js"; const { set: lodashSet } = lodash; -const debug = createDebug("BuildAwesome:TemplateContent"); +const debug = createDebug("TemplateContent"); class TemplateContentFrontMatterError extends BaseError {} class TemplateContentCompileError extends BaseError {} diff --git a/src/TemplateMap.js b/src/TemplateMap.js index bd0fd9b7b..e7f3a9a3d 100644 --- a/src/TemplateMap.js +++ b/src/TemplateMap.js @@ -1,5 +1,4 @@ import { isPlainObject, TemplatePath } from "@11ty/eleventy-utils"; -import { createDebug } from "obug"; import TemplateCollection from "./TemplateCollection.js"; import ErrorUtil from "./Errors/ErrorUtil.js"; @@ -8,8 +7,9 @@ import DuplicatePermalinkOutputError from "./Errors/DuplicatePermalinkOutputErro import TemplateData from "./Data/TemplateData.js"; import GlobalDependencyMap from "./GlobalDependencyMap.js"; import { ResolveConfigurationData } from "./Data/ResolveConfigurationData.js"; +import { createDebug } from "./Util/DebugLogUtil.js"; -const debug = createDebug("BuildAwesome:TemplateMap"); +const debug = createDebug("TemplateMap"); // These template URL filenames are allowed to exclude file extensions const EXTENSIONLESS_URL_ALLOWLIST = [ diff --git a/src/TemplatePassthrough.js b/src/TemplatePassthrough.js index 77a038c65..96bf4765f 100644 --- a/src/TemplatePassthrough.js +++ b/src/TemplatePassthrough.js @@ -2,15 +2,15 @@ import path from "node:path"; import copy from "@11ty/recursive-copy"; import { TemplatePath } from "@11ty/eleventy-utils"; -import { createDebug } from "obug"; import { readableFileSize } from "./Util/FileSize.js"; import { isDynamicPattern } from "./Util/GlobMatcher.js"; import BaseError from "./Errors/BaseError.js"; import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; import ProjectDirectories from "./Util/ProjectDirectories.js"; +import { createDebug } from "./Util/DebugLogUtil.js"; -const debug = createDebug("BuildAwesome:TemplatePassthrough"); +const debug = createDebug("TemplatePassthrough"); class TemplatePassthroughError extends BaseError {} diff --git a/src/TemplatePassthroughManager.js b/src/TemplatePassthroughManager.js index d142b9d1d..97cb2d955 100644 --- a/src/TemplatePassthroughManager.js +++ b/src/TemplatePassthroughManager.js @@ -1,12 +1,12 @@ import { TemplatePath } from "@11ty/eleventy-utils"; -import { createDebug } from "obug"; import BaseError from "./Errors/BaseError.js"; import TemplatePassthrough from "./TemplatePassthrough.js"; import checkPassthroughCopyBehavior from "./Util/PassthroughCopyBehaviorCheck.js"; import { isGlobMatch, isDynamicPattern } from "./Util/GlobMatcher.js"; +import { createDebug } from "./Util/DebugLogUtil.js"; -const debug = createDebug("BuildAwesome:TemplatePassthroughManager"); +const debug = createDebug("TemplatePassthroughManager"); class TemplatePassthroughManagerCopyError extends BaseError {} diff --git a/src/TemplateRender.js b/src/TemplateRender.js index 6452af18b..71ff94a48 100644 --- a/src/TemplateRender.js +++ b/src/TemplateRender.js @@ -1,8 +1,8 @@ -import { createDebug } from "obug"; import BaseError from "./Errors/BaseError.js"; import TemplateEngineManager from "./Engines/TemplateEngineManager.js"; +import { createDebug } from "./Util/DebugLogUtil.js"; -const debugConfiguration = createDebug("BuildAwesome:UserConfig"); +const debugConfiguration = createDebug("UserConfig"); class TemplateRenderUnknownEngineError extends BaseError {} diff --git a/src/TemplateWriter.js b/src/TemplateWriter.js index 2a0e41584..8852c903a 100755 --- a/src/TemplateWriter.js +++ b/src/TemplateWriter.js @@ -1,5 +1,4 @@ import { TemplatePath, isPlainObject } from "@11ty/eleventy-utils"; -import { createDebug } from "obug"; import Template from "./Template.js"; import TemplateMap from "./TemplateMap.js"; @@ -7,8 +6,9 @@ import BaseError from "./Errors/BaseError.js"; import { ErrorHandler } from "./Errors/ErrorHandler.js"; import ErrorUtil from "./Errors/ErrorUtil.js"; import ConsoleLogger from "./Util/ConsoleLogger.js"; +import { createDebug } from "./Util/DebugLogUtil.js"; -const debug = createDebug("BuildAwesome:TemplateWriter"); +const debug = createDebug("TemplateWriter"); class TemplateWriterMissingConfigArgError extends BaseError {} class PassthroughCopyError extends BaseError {} diff --git a/src/UserConfig.js b/src/UserConfig.js index 4dc8f0d08..36130efa2 100644 --- a/src/UserConfig.js +++ b/src/UserConfig.js @@ -1,8 +1,7 @@ -import { createDebug } from "obug"; - import { DeepCopy, TemplatePath, isPlainObject } from "@11ty/eleventy-utils"; import chalk from "./Adapters/Packages/chalk.js"; +import { createDebug } from "./Util/DebugLogUtil.js"; import { resolvePlugin } from "./Util/ResolvePlugin.js"; import isAsyncFunction from "./Util/IsAsyncFunction.js"; import objectFilter from "./Util/Objects/ObjectFilter.js"; @@ -12,7 +11,7 @@ import BaseError from "./Errors/BaseError.js"; import BenchmarkManager from "./Benchmark/BenchmarkManager.js"; import { augmentFunction } from "./Engines/Util/ContextAugmenter.js"; -const debug = createDebug("BuildAwesome:UserConfig"); +const debug = createDebug("UserConfig"); class UserConfigError extends BaseError {} diff --git a/src/Util/ConsoleLogger.js b/src/Util/ConsoleLogger.js index ed0745d58..dd28bb559 100644 --- a/src/Util/ConsoleLogger.js +++ b/src/Util/ConsoleLogger.js @@ -1,7 +1,7 @@ -import { createDebug } from "obug"; +import { createDebug } from "./DebugLogUtil.js"; import chalk from "../Adapters/Packages/chalk.js"; -const debug = createDebug("BuildAwesome:Logger"); +const debug = createDebug("Logger"); /** * Logger implementation that logs to STDOUT. diff --git a/src/Util/DateParse.js b/src/Util/DateParse.js index cc60b5f23..51de93b14 100644 --- a/src/Util/DateParse.js +++ b/src/Util/DateParse.js @@ -1,7 +1,8 @@ -import { createDebug } from "obug"; import { IsoDate } from "@11ty/parse-date-strings"; -const debug = createDebug("BuildAwesome:DateTime"); +import { createDebug } from "./DebugLogUtil.js"; + +const debug = createDebug("DateTime"); export function fromISOtoDateUTC(dateValue, inputPath) { // This has had a UTC default since the beginnning: diff --git a/src/Util/DebugLogUtil.js b/src/Util/DebugLogUtil.js new file mode 100644 index 000000000..7306bd1a7 --- /dev/null +++ b/src/Util/DebugLogUtil.js @@ -0,0 +1,8 @@ +import { createDebug as createDebugObug } from "obug"; + +const PREFIX = + process?.env?.BUILDAWESOME_PACKAGE === "@awesome.me/buildawesome" ? "BuildAwesome:" : "Eleventy:"; + +export function createDebug(name) { + return createDebugObug(`${PREFIX}:${name}`); +} diff --git a/src/Util/EsmResolver.js b/src/Util/EsmResolver.js index 5b67191b0..15a4bedcc 100644 --- a/src/Util/EsmResolver.js +++ b/src/Util/EsmResolver.js @@ -1,8 +1,8 @@ -import { createDebug } from "obug"; import { fileURLToPath } from "../Adapters/Packages/url.js"; import PathNormalizer from "./PathNormalizer.js"; +import { createDebug } from "./DebugLogUtil.js"; -const debug = createDebug("BuildAwesome:EsmResolver"); +const debug = createDebug("EsmResolver"); let lastModifiedPaths = new Map(); diff --git a/src/Util/EventBusUtil.js b/src/Util/EventBusUtil.js index da43b19c1..98885dac8 100644 --- a/src/Util/EventBusUtil.js +++ b/src/Util/EventBusUtil.js @@ -1,7 +1,7 @@ import eventBus from "../EventBus.js"; -import { createDebug } from "obug"; +import { createDebug } from "./DebugLogUtil.js"; -const debug = createDebug("BuildAwesome:EventBus"); +const debug = createDebug("EventBus"); class EventBusUtil { static debugCurrentListenerCounts() { diff --git a/src/Util/ImportJsonSync.js b/src/Util/ImportJsonSync.js index 22deab002..4a65e64b0 100644 --- a/src/Util/ImportJsonSync.js +++ b/src/Util/ImportJsonSync.js @@ -1,10 +1,10 @@ import { existsSync } from "node:fs"; -import { createDebug } from "obug"; import { TemplatePath } from "@11ty/eleventy-utils"; +import { createDebug } from "./DebugLogUtil.js"; import { importJsonSync, corePackageJson } from "./RequireUtils.js"; -const debug = createDebug("BuildAwesome:ImportJsonSync"); +const debug = createDebug("ImportJsonSync"); function findFilePathInParentDirs(dir, filename) { // `package.json` searches look in parent dirs: diff --git a/src/Util/Objects/ProxyWrap.js b/src/Util/Objects/ProxyWrap.js index 5559e532f..43a2343b6 100644 --- a/src/Util/Objects/ProxyWrap.js +++ b/src/Util/Objects/ProxyWrap.js @@ -1,5 +1,5 @@ -// import { createDebug } from "obug"; import { isPlainObject } from "@11ty/eleventy-utils"; +// import { createDebug } from "../DebugLogUtil.js"; // const debug = createDebug("Dev:Eleventy:Proxy"); diff --git a/src/Util/ProjectTemplateFormats.js b/src/Util/ProjectTemplateFormats.js index 6707b84e8..254634543 100644 --- a/src/Util/ProjectTemplateFormats.js +++ b/src/Util/ProjectTemplateFormats.js @@ -1,5 +1,6 @@ -import { createDebug } from "obug"; -const debug = createDebug("BuildAwesome:Util:ProjectTemplateFormats"); +import { createDebug } from "./DebugLogUtil.js"; + +const debug = createDebug("Util:ProjectTemplateFormats"); class ProjectTemplateFormats { #useAll = {}; diff --git a/src/Util/TemplateDepGraph.js b/src/Util/TemplateDepGraph.js index 7fb789107..8212644de 100644 --- a/src/Util/TemplateDepGraph.js +++ b/src/Util/TemplateDepGraph.js @@ -1,7 +1,7 @@ import { DepGraph as DependencyGraph } from "dependency-graph"; -import { createDebug } from "obug"; +import { createDebug } from "./DebugLogUtil.js"; -const debug = createDebug("BuildAwesome:TemplateDepGraph"); +const debug = createDebug("TemplateDepGraph"); const COLLECTION_PREFIX = "__collection:"; diff --git a/src/Util/TransformsUtil.js b/src/Util/TransformsUtil.js index cef23f41e..159b0b142 100644 --- a/src/Util/TransformsUtil.js +++ b/src/Util/TransformsUtil.js @@ -1,8 +1,9 @@ -import BaseError from "../Errors/BaseError.js"; import { isPlainObject } from "@11ty/eleventy-utils"; -import { createDebug } from "obug"; -const debug = createDebug("BuildAwesome:Transforms"); +import BaseError from "../Errors/BaseError.js"; +import { createDebug } from "./DebugLogUtil.js"; + +const debug = createDebug("Transforms"); class TransformError extends BaseError {} diff --git a/src/Watch.js b/src/Watch.js index aaac3613d..c1b8bdf41 100644 --- a/src/Watch.js +++ b/src/Watch.js @@ -1,11 +1,11 @@ -import { createDebug } from "obug"; import { TemplatePath } from "@11ty/eleventy-utils"; import chokidar from "chokidar"; +import { createDebug } from "./Util/DebugLogUtil.js"; import { isGlobMatch } from "./Util/GlobMatcher.js"; import { GlobStripper } from "./Util/GlobStripper.js"; -const debug = createDebug("BuildAwesome:Watch"); +const debug = createDebug("Watch"); export class Watch { /** @type {module:chokidar} */ From a028ad3a801c037f26e00c78318bcc3f0336c416 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 16 Jun 2026 09:39:49 -0500 Subject: [PATCH 49/53] Removes comment --- src/Core.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Core.js b/src/Core.js index 583a6713a..788f396b8 100644 --- a/src/Core.js +++ b/src/Core.js @@ -29,10 +29,6 @@ export default class Core extends CoreFs { #watchDelay; #interrupted = false; - // constructor(input, output, options = {}, eleventyConfig = null) { - // super(input, output, options, eleventyConfig); - // } - get watchQueue() { if (!this.#watchQueue) { this.#watchQueue = new WatchQueue(); From 2cf428050b85d9f8fca819aff112b37dd4df66da Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 16 Jun 2026 10:39:16 -0500 Subject: [PATCH 50/53] Error class rename --- src/Engines/Nunjucks.js | 21 ++++++++++++--------- test/TemplateRenderNunjucksTest.js | 8 ++++---- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Engines/Nunjucks.js b/src/Engines/Nunjucks.js index 62c8723ea..89c2c4922 100755 --- a/src/Engines/Nunjucks.js +++ b/src/Engines/Nunjucks.js @@ -14,7 +14,7 @@ import { createDebug } from "../Util/DebugLogUtil.js"; const debug = createDebug("Nunjucks"); -class EleventyNunjucksError extends BaseError {} +class BuildAwesomeNunjucksError extends BaseError {} export default class Nunjucks extends TemplateEngine { constructor(name, eleventyConfig) { @@ -152,7 +152,7 @@ export default class Nunjucks extends TemplateEngine { return fn.call(this, ...args); } catch (e) { - throw new EleventyNunjucksError( + throw new BuildAwesomeNunjucksError( `Error in Nunjucks Filter \`${name}\`${this.page ? ` (${this.page.inputPath})` : ""}`, e, ); @@ -257,7 +257,7 @@ export default class Nunjucks extends TemplateEngine { // #3286 error messaging when the shortcode is not a promise if (!ret?.then) { resolve( - new EleventyNunjucksError( + new BuildAwesomeNunjucksError( `Error with Nunjucks shortcode \`${shortcodeName}\`: it was defined as asynchronous but was actually synchronous. This is important for Nunjucks.`, ), ); @@ -269,7 +269,10 @@ export default class Nunjucks extends TemplateEngine { }, function (e) { resolve( - new EleventyNunjucksError(`Error with Nunjucks shortcode \`${shortcodeName}\``, e), + new BuildAwesomeNunjucksError( + `Error with Nunjucks shortcode \`${shortcodeName}\``, + e, + ), ); }, ); @@ -278,7 +281,7 @@ export default class Nunjucks extends TemplateEngine { let ret = shortcodeFn.call(Nunjucks.normalizeContext(context), ...argArray); return new NunjucksLib.runtime.SafeString("" + ret); } catch (e) { - throw new EleventyNunjucksError( + throw new BuildAwesomeNunjucksError( `Error with Nunjucks shortcode \`${shortcodeName}\``, e, ); @@ -313,7 +316,7 @@ export default class Nunjucks extends TemplateEngine { body(function (e, bodyContent) { if (e) { resolve( - new EleventyNunjucksError( + new BuildAwesomeNunjucksError( `Error with Nunjucks paired shortcode \`${shortcodeName}\``, e, ), @@ -328,7 +331,7 @@ export default class Nunjucks extends TemplateEngine { // #3286 error messaging when the shortcode is not a promise if (!ret?.then) { - throw new EleventyNunjucksError( + throw new BuildAwesomeNunjucksError( `Error with Nunjucks shortcode \`${shortcodeName}\`: it was defined as asynchronous but was actually synchronous. This is important for Nunjucks.`, ); } @@ -339,7 +342,7 @@ export default class Nunjucks extends TemplateEngine { }, function (e) { resolve( - new EleventyNunjucksError( + new BuildAwesomeNunjucksError( `Error with Nunjucks paired shortcode \`${shortcodeName}\``, e, ), @@ -371,7 +374,7 @@ export default class Nunjucks extends TemplateEngine { shortcodeFn.call(Nunjucks.normalizeContext(context), bodyContent, ...argArray), ); } catch (e) { - throw new EleventyNunjucksError( + throw new BuildAwesomeNunjucksError( `Error with Nunjucks paired shortcode \`${shortcodeName}\``, e, ); diff --git a/test/TemplateRenderNunjucksTest.js b/test/TemplateRenderNunjucksTest.js index c1f6156e8..80ed26288 100644 --- a/test/TemplateRenderNunjucksTest.js +++ b/test/TemplateRenderNunjucksTest.js @@ -381,7 +381,7 @@ test("Nunjucks sync function Shortcode (error throwing)", async (t) => { t.true( error.message.indexOf( - "EleventyNunjucksError: Error with Nunjucks shortcode `postfixWithZach`" + "BuildAwesomeNunjucksError: Error with Nunjucks shortcode `postfixWithZach`" ) > -1 ); t.true( @@ -411,7 +411,7 @@ test("Nunjucks Async function Shortcode (error throwing)", async (t) => { }); t.true( error.message.indexOf( - "EleventyNunjucksError: Error with Nunjucks shortcode `postfixWithZachError`" + "BuildAwesomeNunjucksError: Error with Nunjucks shortcode `postfixWithZachError`" ) > -1 ); t.true( @@ -446,7 +446,7 @@ test("Nunjucks sync function paired Shortcode (error throwing)", async (t) => { t.true( error.message.indexOf( - "EleventyNunjucksError: Error with Nunjucks paired shortcode `postfixWithZachError`" + "BuildAwesomeNunjucksError: Error with Nunjucks paired shortcode `postfixWithZachError`" ) > -1 ); t.true( @@ -481,7 +481,7 @@ test("Nunjucks Async function paired Shortcode (error throwing)", async (t) => { t.true( error.message.indexOf( - "EleventyNunjucksError: Error with Nunjucks paired shortcode `postfixWithZachError`" + "BuildAwesomeNunjucksError: Error with Nunjucks paired shortcode `postfixWithZachError`" ) > -1 ); t.true( From 792108c2d74bae9ddd2e097339f59222fe075b19 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 16 Jun 2026 10:41:00 -0500 Subject: [PATCH 51/53] Method rename --- src/Data/TemplateData.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/TemplateData.js b/src/Data/TemplateData.js index 45e1a0625..fedb4707e 100644 --- a/src/Data/TemplateData.js +++ b/src/Data/TemplateData.js @@ -519,7 +519,7 @@ class TemplateData { return this.config.dataExtensions && this.config.dataExtensions.size > 0; } - async _parseDataFile(path, parser, options = {}) { + async #parseDataFile(path, parser, options = {}) { let readFile = !("read" in options) || options.read === true; let rawInput; @@ -590,12 +590,12 @@ class TemplateData { // Other extensions let { parser, options } = this.getUserDataParser(extension); - let returnValue = this._parseDataFile(path, parser, options); + let returnValue = this.#parseDataFile(path, parser, options); return returnValue; } else if (extension === "json") { // File to string, parse with JSON (preprocess) - let returnValue = this._parseDataFile(path, (content) => JSON.parse(content)); + let returnValue = this.#parseDataFile(path, (content) => JSON.parse(content)); return returnValue; } else { From 2677949dff2dbafc41e08584d470c3c6fda78798 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 16 Jun 2026 12:34:46 -0500 Subject: [PATCH 52/53] Build Awesome package.json defaults --- packages/build-awesome/package.json | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/build-awesome/package.json b/packages/build-awesome/package.json index 3e2aff103..deafc019b 100644 --- a/packages/build-awesome/package.json +++ b/packages/build-awesome/package.json @@ -1,6 +1,6 @@ { "name": "@awesome.me/buildawesome", - "description": "Run Build Awesome (Eleventy) in your browser.", + "description": "A simpler way to build awesome web sites.", "version": "PRIVATE", "private": true, "publishConfig": { @@ -15,18 +15,14 @@ }, "./utils/git": "./src/Util/Git.js" }, + "scripts": { + "test": "" + }, "bin": { "buildawesome": "cmd.js" }, "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/11ty" - }, - "scripts": { - "test": "" - }, - "author": "Zach Leatherman (https://zachleat.com/)", + "author": "Zach Leatherman (https://zachleat.com/)", "repository": { "type": "git", "url": "git://github.com/11ty/buildawesome.git" From e000c353d8c07567db13df02350d73778ea3a4f8 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 16 Jun 2026 13:50:15 -0500 Subject: [PATCH 53/53] Whitespace normalization --- packages/build-awesome/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/build-awesome/package.json b/packages/build-awesome/package.json index deafc019b..afe22c01d 100644 --- a/packages/build-awesome/package.json +++ b/packages/build-awesome/package.json @@ -15,9 +15,9 @@ }, "./utils/git": "./src/Util/Git.js" }, - "scripts": { - "test": "" - }, + "scripts": { + "test": "" + }, "bin": { "buildawesome": "cmd.js" },