diff --git a/.eleventy.js b/.eleventy.js index 2f1b471..c0f8ae6 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -15,7 +15,8 @@ module.exports = function(eleventyConfig) { console.log(chalk.blue(`[${pkg.name}] ---`)); // Full list of issues: https://github.com/11ty/eleventy/issues?q=milestone%3A%22Eleventy+3.0.0%22+is%3Aclosed+label%3Abreaking-change - eleventyConfig.addPlugin(require("./src/node-version")); + eleventyConfig.addPlugin(require("./src/node-version.js")); + eleventyConfig.addPlugin(require("./src/explicit-config-file.js")); eleventyConfig.on("eleventy.after", () => { console.log(chalk.blue(`[${pkg.name}] This plugin is intended for temporary use: once you’re satisfied please remove this plugin from your project!`)); diff --git a/package.json b/package.json index 3d7ef9d..ad128f1 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "homepage": "https://www.11ty.dev/", "dependencies": { "kleur": "^4.1.5", + "minimist": "^1.2.8", "semver": "^7.6.3" }, "11ty": { diff --git a/src/explicit-config-file.js b/src/explicit-config-file.js new file mode 100644 index 0000000..2fb6f54 --- /dev/null +++ b/src/explicit-config-file.js @@ -0,0 +1,20 @@ +const fs = require("node:fs"); +const chalk = require("kleur"); +const pkg = require("../package.json"); + +const minimist = require("minimist"); + +const argv = minimist(process.argv.slice(2), { + string: ["config"] +}); + +module.exports = function(eleventyConfig) { + let type = chalk.blue("NOTICE"); + + if(argv.config && !fs.existsSync(argv.config)) { + // We’ll never get here because the configuration file has to work to run the upgrade plugin. + type = chalk.red("ERROR"); + } + + console.log(chalk.blue(`[${pkg.name}]`), type, `Eleventy will fail with an error when you point \`--config\` to a configuration file that does not exist. Previous versions ran as-is (without application configuration). Read more: https://github.com/11ty/eleventy/issues/3373`); +}; \ No newline at end of file