From de0a19367e95c3c172b18a687ff7574b96cea912 Mon Sep 17 00:00:00 2001 From: FND Date: Mon, 25 Apr 2022 09:54:35 +0200 Subject: [PATCH 01/14] switched to named instead of default exports see https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/ for details note that this constitutes a breaking change for developers --- bin/faucet | 6 +++--- lib/cli.js | 4 ++-- lib/config.js | 2 +- lib/index.js | 8 ++++---- lib/manager.js | 8 ++++---- lib/manifest.js | 6 +++--- lib/util/files/finder.js | 2 +- lib/util/files/index.js | 2 +- lib/util/resolve.js | 3 ++- lib/util/runner.js | 2 +- test/test_manager.js | 2 +- test/test_manifest.js | 2 +- test/test_runner.js | 2 +- test/test_util.js | 2 +- 14 files changed, 26 insertions(+), 25 deletions(-) diff --git a/bin/faucet b/bin/faucet index 6eb573c..08231b2 100755 --- a/bin/faucet +++ b/bin/faucet @@ -1,8 +1,8 @@ #!/usr/bin/env node "use strict"; -let faucet = require("../lib"); -let parseCLI = require("../lib/cli"); +let { faucetDispatch } = require("../lib"); +let { parseCLI } = require("../lib/cli"); let { referenceDir, config, options } = parseCLI(); -faucet(referenceDir, config, options); +faucetDispatch(referenceDir, config, options); diff --git a/lib/cli.js b/lib/cli.js index 8a0156d..6c84fe7 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -1,6 +1,6 @@ "use strict"; -let readConfig = require("./config"); +let { readConfig } = require("./config"); let { abort, repr } = require("./util"); let parseArgs = require("minimist"); @@ -27,7 +27,7 @@ Options: serve generated files via HTTP with live reloading `.trim(); -module.exports = function parseCLI(argv = process.argv.slice(2), help = HELP) { +exports.parseCLI = function parseCLI(argv = process.argv.slice(2), help = HELP) { argv = parseArgs(argv, { boolean: ["watch", "fingerprint", "sourcemaps", "compact"], alias: { diff --git a/lib/config.js b/lib/config.js index f585bc2..9bc7c3a 100644 --- a/lib/config.js +++ b/lib/config.js @@ -2,7 +2,7 @@ let path = require("path"); -module.exports = function readConfig(rootDir, filepath = "faucet.config.js") { +exports.readConfig = function readConfig(rootDir, filepath = "faucet.config.js") { let configPath = path.resolve(rootDir, filepath); return { referenceDir: path.dirname(configPath), diff --git a/lib/index.js b/lib/index.js index 16d19e3..b6bcca5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,13 +2,13 @@ let server = require("./server"); let { pluginsByBucket } = require("./plugins"); -let AssetManager = require("./manager"); -let resolvePath = require("./util/resolve"); +let { AssetManager } = require("./manager"); +let { resolvePath } = require("./util/resolve"); let { abort, repr } = require("./util"); -let SerializedRunner = require("./util/runner"); +let { SerializedRunner } = require("./util/runner"); let browserslist = require("browserslist"); -module.exports = async function faucetDispatch(referenceDir, config, +exports.faucetDispatch = async function faucetDispatch(referenceDir, config, { watch, fingerprint, sourcemaps, compact, serve, liveserve }) { config = await config; diff --git a/lib/manager.js b/lib/manager.js index 3630419..c75f97a 100644 --- a/lib/manager.js +++ b/lib/manager.js @@ -1,12 +1,12 @@ "use strict"; -let Manifest = require("./manifest"); -let createFile = require("./util/files"); -let resolvePath = require("./util/resolve"); +let { Manifest } = require("./manifest"); +let { createFile } = require("./util/files"); +let { resolvePath } = require("./util/resolve"); let { reportFileStatus, abort, generateFingerprint } = require("./util"); let path = require("path"); -module.exports = class AssetManager { +exports.AssetManager = class AssetManager { constructor(referenceDir, { manifestConfig, fingerprint, exitOnError } = {}) { this.referenceDir = referenceDir; this.fingerprint = fingerprint; diff --git a/lib/manifest.js b/lib/manifest.js index b7985a9..51db3ff 100644 --- a/lib/manifest.js +++ b/lib/manifest.js @@ -1,11 +1,11 @@ "use strict"; -let createFile = require("./util/files"); -let resolvePath = require("./util/resolve"); +let { createFile } = require("./util/files"); +let { resolvePath } = require("./util/resolve"); let { abort } = require("./util"); let path = require("path"); -module.exports = class Manifest { +exports.Manifest = class Manifest { constructor(referenceDir, { target, key, value, baseURI, webRoot } = {}) { if(value && (baseURI || webRoot)) { abort("ERROR: `value` must not be used with `baseURI` and/or `webRoot`"); diff --git a/lib/util/files/finder.js b/lib/util/files/finder.js index 5764be7..2cf86d9 100644 --- a/lib/util/files/finder.js +++ b/lib/util/files/finder.js @@ -1,7 +1,7 @@ let { readdir, stat } = require("fs/promises"); let path = require("path"); -module.exports = class FileFinder { +exports.FileFinder = class FileFinder { constructor(directory, { skipDotfiles, filter = () => true } = {}) { this.directory = directory; this.filter = filename => { diff --git a/lib/util/files/index.js b/lib/util/files/index.js index d067696..f2d8ef0 100644 --- a/lib/util/files/index.js +++ b/lib/util/files/index.js @@ -8,7 +8,7 @@ let KNOWN = new Set(); // avoids redundant `mkdir` invocations let LOCKS = new Map(); // avoids concurrent write operations and creates target directory if necessary -module.exports = function createFile(filepath, contents) { +exports.createFile = function createFile(filepath, contents) { let lock = LOCKS.get(filepath); if(lock) { // defer return lock.then(() => createFile(filepath, contents)); diff --git a/lib/util/resolve.js b/lib/util/resolve.js index 410e185..afb8124 100644 --- a/lib/util/resolve.js +++ b/lib/util/resolve.js @@ -4,7 +4,8 @@ let { abort, repr } = require("./"); let fs = require("fs"); let path = require("path"); -module.exports = function resolvePath(filepath, referenceDir, { enforceRelative } = {}) { +exports.resolvePath = function resolvePath(filepath, referenceDir, + { enforceRelative } = {}) { if(/^\.?\.\//.test(filepath)) { // starts with `./` or `../` return path.resolve(referenceDir, filepath); } else if(enforceRelative) { diff --git a/lib/util/runner.js b/lib/util/runner.js index d2ce80f..90ec0af 100644 --- a/lib/util/runner.js +++ b/lib/util/runner.js @@ -1,6 +1,6 @@ "use strict"; -module.exports = class SerializedRunner { +exports.SerializedRunner = class SerializedRunner { constructor(asyncOp) { this.asyncOp = asyncOp; } diff --git a/test/test_manager.js b/test/test_manager.js index 6375827..9966e48 100644 --- a/test/test_manager.js +++ b/test/test_manager.js @@ -1,7 +1,7 @@ /* global describe, before, after, it */ "use strict"; -let AssetManager = require("../lib/manager"); +let { AssetManager } = require("../lib/manager"); let path = require("path"); let assert = require("assert"); diff --git a/test/test_manifest.js b/test/test_manifest.js index 041cc36..e175209 100644 --- a/test/test_manifest.js +++ b/test/test_manifest.js @@ -1,7 +1,7 @@ /* global describe, before, after, it */ "use strict"; -let Manifest = require("../lib/manifest"); +let { Manifest } = require("../lib/manifest"); let path = require("path"); let assert = require("assert"); diff --git a/test/test_runner.js b/test/test_runner.js index 8297f70..bf5a621 100644 --- a/test/test_runner.js +++ b/test/test_runner.js @@ -1,7 +1,7 @@ /* global describe, it */ "use strict"; -let SerializedRunner = require("../lib/util/runner"); +let { SerializedRunner } = require("../lib/util/runner"); let { strictEqual: assertSame, deepStrictEqual: assertDeep } = require("assert"); describe("watch mode", () => { diff --git a/test/test_util.js b/test/test_util.js index ba36a99..06f06e0 100644 --- a/test/test_util.js +++ b/test/test_util.js @@ -2,7 +2,7 @@ "use strict"; let { generateFingerprint } = require("../lib/util"); -let FileFinder = require("../lib/util/files/finder"); +let { FileFinder } = require("../lib/util/files/finder"); let path = require("path"); let assert = require("assert"); From ae3f548eddf1e6156fb396a0fe5c36cc118f181b Mon Sep 17 00:00:00 2001 From: FND Date: Mon, 25 Apr 2022 10:33:57 +0200 Subject: [PATCH 02/14] ensured dynamic imports are asynchronous this is required in preparation of switching to ESM, where synchronous `require` will have to be replaced with dynamic `import` note that this constitutes a breaking change for developers --- bin/faucet | 6 +++-- lib/cli.js | 4 +-- lib/config.js | 4 +-- lib/index.js | 12 +++++---- lib/plugins.js | 43 ++++++++++++++++-------------- lib/server.js | 14 +++++----- lib/util/index.js | 8 +++--- test/test_plugins.js | 62 ++++++++++++++++++++++---------------------- 8 files changed, 79 insertions(+), 74 deletions(-) diff --git a/bin/faucet b/bin/faucet index 08231b2..79d8496 100755 --- a/bin/faucet +++ b/bin/faucet @@ -4,5 +4,7 @@ let { faucetDispatch } = require("../lib"); let { parseCLI } = require("../lib/cli"); -let { referenceDir, config, options } = parseCLI(); -faucetDispatch(referenceDir, config, options); +parseCLI(). + then(({ referenceDir, config, options }) => { + faucetDispatch(referenceDir, config, options); + }); diff --git a/lib/cli.js b/lib/cli.js index 6c84fe7..01dba5b 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -27,7 +27,7 @@ Options: serve generated files via HTTP with live reloading `.trim(); -exports.parseCLI = function parseCLI(argv = process.argv.slice(2), help = HELP) { +exports.parseCLI = async function parseCLI(argv = process.argv.slice(2), help = HELP) { argv = parseArgs(argv, { boolean: ["watch", "fingerprint", "sourcemaps", "compact"], alias: { @@ -56,6 +56,6 @@ exports.parseCLI = function parseCLI(argv = process.argv.slice(2), help = HELP) } let rootDir = process.cwd(); - let { referenceDir, config } = readConfig(rootDir, argv.config); + let { referenceDir, config } = await readConfig(rootDir, argv.config); return { referenceDir, config, options }; }; diff --git a/lib/config.js b/lib/config.js index 9bc7c3a..b87fa5c 100644 --- a/lib/config.js +++ b/lib/config.js @@ -2,10 +2,10 @@ let path = require("path"); -exports.readConfig = function readConfig(rootDir, filepath = "faucet.config.js") { +exports.readConfig = async function readConfig(rootDir, filepath = "faucet.config.js") { let configPath = path.resolve(rootDir, filepath); return { referenceDir: path.dirname(configPath), - config: require(configPath) + config: await require(configPath) }; }; diff --git a/lib/index.js b/lib/index.js index b6bcca5..6606d1f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -22,7 +22,7 @@ exports.faucetDispatch = async function faucetDispatch(referenceDir, config, browsers = [browsers]; } - let plugins = pluginsByBucket(config); + let plugins = await pluginsByBucket(config); // initialize plugins with corresponding configuration let buckets = Object.keys(plugins).reduce((memo, bucket) => { memo[bucket] = plugins[bucket].map(({ plugin, config }) => { @@ -40,8 +40,10 @@ exports.faucetDispatch = async function faucetDispatch(referenceDir, config, if(watch) { makeWatcher(config.watchDirs, referenceDir). - on("edit", filepaths => { - runner.rerun(filepaths); + then(watcher => { + watcher.on("edit", filepaths => { + runner.rerun(filepaths); + }); }); } @@ -60,8 +62,8 @@ function buildStep(plugins) { then(() => files); } -function makeWatcher(watchDirs, referenceDir) { - let niteOwl = require("nite-owl"); +async function makeWatcher(watchDirs, referenceDir) { + let niteOwl = await require("nite-owl"); if(watchDirs) { watchDirs = watchDirs.map(dir => resolvePath(dir, referenceDir, diff --git a/lib/plugins.js b/lib/plugins.js index 80805e8..b940706 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -33,47 +33,50 @@ module.exports = { // returns plugin functions grouped by bucket and filtered by relevance (based // on configuration) -function pluginsByBucket(config, defaults) { - let plugins = determinePlugins(config.plugins, defaults); +async function pluginsByBucket(config, defaults) { + let plugins = await determinePlugins(config.plugins, defaults); let buckets = [...BUCKETS].reduce((memo, bucket) => { memo[bucket] = []; return memo; }, {}); - Object.entries(plugins).forEach(([key, _plugin]) => { + for(let [key, _plugin] of Object.entries(plugins)) { let pluginConfig = config[key]; if(!pluginConfig) { - return; + continue; } let { bucket, plugin } = _plugin; + if(!plugin.call) { + ({ plugin } = await loadPlugin(plugin)); + } buckets[bucket].push({ - plugin: plugin.call ? plugin : loadPlugin(plugin).plugin, + plugin, config: pluginConfig }); - }); + } return buckets; } // `plugins` is an array of plugins, each either a package identifier or a // `{ key, bucket, plugin }` object`, with `key` being the configuration key and // `plugin` being either a function or a package identifier -function determinePlugins(plugins = [], defaults = DEFAULTS) { +async function determinePlugins(plugins = [], defaults = DEFAULTS) { let registry = {}; // NB: default plugins are resolved lazily because eager loading would // result in them becoming a hard dependency rather than a convenience // preset - however, that requires us to duplicate the respective // configuration keys and buckets here - defaults.forEach(plugin => { - registerPlugin(registry, plugin, false); - }); - plugins.forEach(plugin => { - registerPlugin(registry, plugin, true); - }); + for(let plugin of defaults) { + await registerPlugin(registry, plugin, false); + } + for(let plugin of plugins) { + await registerPlugin(registry, plugin, true); + } return registry; } -function registerPlugin(registry, _plugin, eager) { - let { key, bucket, plugin } = resolvePlugin(_plugin, eager); +async function registerPlugin(registry, _plugin, eager) { + let { key, bucket, plugin } = await resolvePlugin(_plugin, eager); // NB: default plugins may be overridden if(registry[key] && !DEFAULT_KEYS.has(key)) { abort(`ERROR: duplicate plugin key ${repr(key, false)}`); @@ -84,14 +87,14 @@ function registerPlugin(registry, _plugin, eager) { } } -function resolvePlugin(_plugin, eager) { +async function resolvePlugin(_plugin, eager) { if(_plugin.substr) { // package identifier - _plugin = loadPlugin(_plugin); + _plugin = await loadPlugin(_plugin); } let { key, bucket, plugin } = _plugin; if(eager && plugin.substr && (!key || !bucket)) { // auto-configuration - let _plugin = loadPlugin(plugin); + let _plugin = await loadPlugin(plugin); plugin = _plugin.plugin; // local configuration takes precedence key = key || _plugin.key; @@ -104,13 +107,13 @@ function resolvePlugin(_plugin, eager) { return { key, bucket, plugin }; } -function loadPlugin(pkg) { +async function loadPlugin(pkg) { let fail = prop => abort(`ERROR: invalid plugin ${repr(pkg)}; ` + `missing ${repr(prop, false)}`); let { key = fail("key"), bucket = fail("bucket"), plugin = fail("plugin") - } = loadExtension(pkg, "ERROR: missing plugin"); + } = await loadExtension(pkg, "ERROR: missing plugin"); return { key, bucket, plugin }; } diff --git a/lib/server.js b/lib/server.js index 7d3a961..9ecb696 100644 --- a/lib/server.js +++ b/lib/server.js @@ -5,18 +5,16 @@ let DEFAULTS = { port: 3000 }; -exports.static = (config, webroot) => { - let donny = loadExtension("donny", "failed to activate server"); +exports.static = async (config, webroot) => { + let donny = await loadExtension("donny", "failed to activate server"); let [host, port] = parseHost(config); - donny({ port, bind: host, webroot }). - then(() => { - console.error(`serving ${repr(webroot)} at http://${host}:${port}`); - }); + await donny({ port, bind: host, webroot }); + console.error(`serving ${repr(webroot)} at http://${host}:${port}`); }; -exports.live = (config, root) => { - let liveServer = loadExtension("live-server", "failed to activate live-server"); +exports.live = async (config, root) => { + let liveServer = await loadExtension("live-server", "failed to activate live-server"); let [host, port] = parseHost(config); liveServer.start({ port, host, root, open: false }); diff --git a/lib/util/index.js b/lib/util/index.js index cf619be..0698bc2 100644 --- a/lib/util/index.js +++ b/lib/util/index.js @@ -13,11 +13,11 @@ exports.reportFileStatus = (filepath, referenceDir, error) => { console.error(error ? `✗ ${ref}: ${error.message || error}` : `✓ ${ref}`); }; -// attempts to `require` a module, prompting the user to install the -// corresponding package if it is unavailable -exports.loadExtension = (pkg, errorMessage, supplier = pkg) => { +// attempts to load a module, prompting the user to install the corresponding +// package if it is unavailable +exports.loadExtension = async (pkg, errorMessage, supplier = pkg) => { try { - return require(pkg); + return await require(pkg); } catch(err) { if(err.code !== "MODULE_NOT_FOUND") { throw err; diff --git a/test/test_plugins.js b/test/test_plugins.js index 0d730a7..104631d 100644 --- a/test/test_plugins.js +++ b/test/test_plugins.js @@ -39,8 +39,8 @@ describe("plugin registration", () => { updateNodePath(NODE_PATH); }); - it("only loads default plugins referenced within configuration", () => { - let res = pluginsByBucket({ + it("only loads default plugins referenced within configuration", async () => { + let res = await pluginsByBucket({ js: [{ foo: "lorem" }] }); assertDeep(normalizeAll(res), { @@ -53,7 +53,7 @@ describe("plugin registration", () => { markup: [] }); - res = pluginsByBucket({ + res = await pluginsByBucket({ sass: [{ bar: "ipsum" }] }); assertDeep(normalizeAll(res), { @@ -66,7 +66,7 @@ describe("plugin registration", () => { markup: [] }); - res = pluginsByBucket({ + res = await pluginsByBucket({ js: [{ foo: "lorem" }], sass: [{ bar: "ipsum" }] }); @@ -84,8 +84,8 @@ describe("plugin registration", () => { }); }); - it("allows overriding default plugins", () => { - let res = pluginsByBucket({ + it("allows overriding default plugins", async () => { + let res = await pluginsByBucket({ js: [{ foo: "bar" }], plugins: [{ key: "js", @@ -120,12 +120,12 @@ describe("plugin resolution", () => { updateNodePath(NODE_PATH); }); - it("provides a default set of plugins", () => { - let res = _determinePlugins(); + it("provides a default set of plugins", async () => { + let res = await _determinePlugins(); assertDeep(normalizePlugins(res), DEFAULTS); }); - it("supports custom plugins", () => { + it("supports custom plugins", async () => { // plugin function within configuration let anon = () => {}; let config = [{ @@ -133,7 +133,7 @@ describe("plugin resolution", () => { bucket: "static", plugin: anon }]; - let res = _determinePlugins(config); + let res = await _determinePlugins(config); assertDeep(normalizePlugins(res), Object.assign({}, DEFAULTS, { dummy: { bucket: "static", @@ -144,7 +144,7 @@ describe("plugin resolution", () => { // nested package identifier let pkg = "faucet-pipeline-dummy"; config[0].plugin = pkg; - res = _determinePlugins(config); + res = await _determinePlugins(config); assertDeep(normalizePlugins(res), Object.assign({}, DEFAULTS, { dummy: { bucket: "static", @@ -154,7 +154,7 @@ describe("plugin resolution", () => { })); // simple package identifier - res = _determinePlugins([pkg]); + res = await _determinePlugins([pkg]); assertDeep(normalizePlugins(res), Object.assign({}, DEFAULTS, { dummy: { bucket: "static", @@ -163,12 +163,12 @@ describe("plugin resolution", () => { })); }); - it("allows overriding plugins' default configuration", () => { + it("allows overriding plugins' default configuration", async () => { let config = [{ key: "yummy", plugin: "faucet-pipeline-dummy" }]; - let res = _determinePlugins(config); + let res = await _determinePlugins(config); assertDeep(normalizePlugins(res), Object.assign({}, DEFAULTS, { yummy: { bucket: "static", @@ -177,7 +177,7 @@ describe("plugin resolution", () => { })); config[0].bucket = "styles"; - res = _determinePlugins(config); + res = await _determinePlugins(config); assertDeep(normalizePlugins(res), Object.assign({}, DEFAULTS, { yummy: { bucket: "styles", @@ -188,12 +188,12 @@ describe("plugin resolution", () => { }); it("balks at invalid package identifiers", () => { - assert.throws(() => { - _determinePlugins(["faucet-pipeline-yummy"]); + assert.rejects(async () => { + return _determinePlugins(["faucet-pipeline-yummy"]); }, /exit 1/); - assert.throws(() => { - _determinePlugins([{ + assert.rejects(() => { + return _determinePlugins([{ // NB: local configuration must not be comprehensive to ensure // plugin is loaded key: "yummy", @@ -203,8 +203,8 @@ describe("plugin resolution", () => { }); it("balks at duplicate configuration keys", () => { - assert.throws(() => { - _determinePlugins([{ + assert.rejects(() => { + return _determinePlugins([{ key: "dummy", bucket: "static", plugin: () => {} @@ -217,16 +217,16 @@ describe("plugin resolution", () => { }); it("balks at invalid plugins", () => { - assert.throws(() => { - _determinePlugins(["faucet-pipeline-invalid-a"]); + assert.rejects(() => { + return _determinePlugins(["faucet-pipeline-invalid-a"]); }, /exit 1/); - assert.throws(() => { - _determinePlugins(["faucet-pipeline-invalid-b"]); + assert.rejects(() => { + return _determinePlugins(["faucet-pipeline-invalid-b"]); }, /exit 1/); - assert.throws(() => { - _determinePlugins(["faucet-pipeline-invalid-c"]); + assert.rejects(() => { + return _determinePlugins(["faucet-pipeline-invalid-c"]); }, /exit 1/); }); @@ -237,14 +237,14 @@ describe("plugin resolution", () => { }; ["static", "scripts", "styles", "markup"].forEach(bucket => { plugin.bucket = bucket; - assert.doesNotThrow(() => { - _determinePlugins([plugin]); + assert.doesNotReject(() => { + return _determinePlugins([plugin]); }, /exit 1/); }); plugin.bucket = "dummy"; - assert.throws(() => { - _determinePlugins([plugin]); + assert.rejects(() => { + return _determinePlugins([plugin]); }, /exit 1/); }); }); From 94f4ff481e802789d24495600c837ec47992985a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:55:04 +0000 Subject: [PATCH 03/14] Bump actions/setup-node from 3 to 4 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 24b1358..5f28f5f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,7 +12,7 @@ jobs: - 19.x steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install-test From 950ba0e6a562c824ef69fb4da0bd8668b89ec341 Mon Sep 17 00:00:00 2001 From: Lucas Dohmen Date: Sun, 26 Jan 2025 18:51:02 +0100 Subject: [PATCH 04/14] Adjust Node support matrix --- .github/workflows/tests.yaml | 5 +++-- package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5f28f5f..6725f18 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -7,9 +7,10 @@ jobs: strategy: matrix: node-version: - - 14.x - 18.x - - 19.x + - 20.x + - 22.x + - 23.x steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v4 diff --git a/package.json b/package.json index 5bf5e23..eb31780 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "lint": "eslint --cache lib bin/* test test/bin/* && echo ✓" }, "engines": { - "node": ">= 12" + "node": ">= 18" }, "dependencies": { "browserslist": "~4.21.4", From 5663ceb84356b5bfa5919e8c5bdbe9556efcced2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 26 Jan 2025 20:05:41 +0000 Subject: [PATCH 05/14] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 6725f18..842fef5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,7 +12,7 @@ jobs: - 22.x - 23.x steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} From 60b3c5e474afedfd5bfe2760855c34ca0cbd3ae9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Sep 2023 12:57:13 +0000 Subject: [PATCH 06/14] Bump browserslist from 4.21.11 to 4.22.1 Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.21.11 to 4.22.1. - [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) - [Commits](https://github.com/browserslist/browserslist/compare/4.21.11...4.22.1) --- updated-dependencies: - dependency-name: browserslist dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eb31780..0d8e2e1 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "node": ">= 18" }, "dependencies": { - "browserslist": "~4.21.4", + "browserslist": "~4.22.1", "minimist": "~1.2.7", "nite-owl": "~5.0.5" }, From de93b2f7dcc49037581925d3484849a2e3f901da Mon Sep 17 00:00:00 2001 From: Lucas Dohmen Date: Sun, 26 Jan 2025 18:51:14 +0100 Subject: [PATCH 07/14] Remove mocha --- package.json | 5 ++--- test/test_manager.js | 2 +- test/test_manifest.js | 2 +- test/test_plugins.js | 31 ++++++++++++++++--------------- test/test_runner.js | 2 +- test/test_server.js | 2 +- test/test_util.js | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 0d8e2e1..c9c806d 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ }, "scripts": { "test": "npm-run-all --parallel lint test:unit", - "test:unit": "mocha test/test_*.js", - "lint": "eslint --cache lib bin/* test test/bin/* && echo ✓" + "test:unit": "node --test ./test/test_*.js", + "lint": "eslint --cache ./lib ./bin/* ./test ./test/bin/* && echo ✓" }, "engines": { "node": ">= 18" @@ -34,7 +34,6 @@ }, "devDependencies": { "eslint-config-fnd": "^1.13.0", - "mocha": "^10.2.0", "npm-run-all": "^4.1.5", "release-util-fnd": "^3.0.0" } diff --git a/test/test_manager.js b/test/test_manager.js index 9966e48..9ae62c2 100644 --- a/test/test_manager.js +++ b/test/test_manager.js @@ -1,7 +1,7 @@ -/* global describe, before, after, it */ "use strict"; let { AssetManager } = require("../lib/manager"); +let { describe, it, before, after } = require("node:test"); let path = require("path"); let assert = require("assert"); diff --git a/test/test_manifest.js b/test/test_manifest.js index e175209..07856ff 100644 --- a/test/test_manifest.js +++ b/test/test_manifest.js @@ -1,7 +1,7 @@ -/* global describe, before, after, it */ "use strict"; let { Manifest } = require("../lib/manifest"); +let { describe, it, before, after } = require("node:test"); let path = require("path"); let assert = require("assert"); diff --git a/test/test_plugins.js b/test/test_plugins.js index 104631d..637b3ab 100644 --- a/test/test_plugins.js +++ b/test/test_plugins.js @@ -1,7 +1,7 @@ -/* global describe, before, after, it */ "use strict"; let { pluginsByBucket, _determinePlugins } = require("../lib/plugins"); +let { describe, it, before, after } = require("node:test"); let path = require("path"); let assert = require("assert"); @@ -187,12 +187,12 @@ describe("plugin resolution", () => { })); }); - it("balks at invalid package identifiers", () => { - assert.rejects(async () => { + it("balks at invalid package identifiers", async () => { + await assert.rejects(async () => { return _determinePlugins(["faucet-pipeline-yummy"]); }, /exit 1/); - assert.rejects(() => { + await assert.rejects(() => { return _determinePlugins([{ // NB: local configuration must not be comprehensive to ensure // plugin is loaded @@ -202,8 +202,8 @@ describe("plugin resolution", () => { }, /exit 1/); }); - it("balks at duplicate configuration keys", () => { - assert.rejects(() => { + it("balks at duplicate configuration keys", async () => { + await assert.rejects(() => { return _determinePlugins([{ key: "dummy", bucket: "static", @@ -216,34 +216,35 @@ describe("plugin resolution", () => { }, /exit 1/); }); - it("balks at invalid plugins", () => { - assert.rejects(() => { + it("balks at invalid plugins", async () => { + await assert.rejects(() => { return _determinePlugins(["faucet-pipeline-invalid-a"]); }, /exit 1/); - assert.rejects(() => { + await assert.rejects(() => { return _determinePlugins(["faucet-pipeline-invalid-b"]); }, /exit 1/); - assert.rejects(() => { + await assert.rejects(() => { return _determinePlugins(["faucet-pipeline-invalid-c"]); }, /exit 1/); }); - it("balks at invalid buckets", () => { + it("balks at invalid buckets", async () => { let plugin = { key: "dummy", plugin: () => {} }; - ["static", "scripts", "styles", "markup"].forEach(bucket => { + const buckets = ["static", "scripts", "styles", "markup"]; + for(let bucket of buckets) { plugin.bucket = bucket; - assert.doesNotReject(() => { + await assert.doesNotReject(async () => { return _determinePlugins([plugin]); }, /exit 1/); - }); + } plugin.bucket = "dummy"; - assert.rejects(() => { + await assert.rejects(async () => { return _determinePlugins([plugin]); }, /exit 1/); }); diff --git a/test/test_runner.js b/test/test_runner.js index bf5a621..8a20d0f 100644 --- a/test/test_runner.js +++ b/test/test_runner.js @@ -1,7 +1,7 @@ -/* global describe, it */ "use strict"; let { SerializedRunner } = require("../lib/util/runner"); +let { describe, it } = require("node:test"); let { strictEqual: assertSame, deepStrictEqual: assertDeep } = require("assert"); describe("watch mode", () => { diff --git a/test/test_server.js b/test/test_server.js index e7f77a4..35467e1 100644 --- a/test/test_server.js +++ b/test/test_server.js @@ -1,7 +1,7 @@ -/* global describe, before, after, it */ "use strict"; let { _parseHost } = require("../lib/server"); +let { describe, it, before, after } = require("node:test"); let assert = require("assert"); let assertSame = assert.strictEqual; diff --git a/test/test_util.js b/test/test_util.js index 06f06e0..cad64c9 100644 --- a/test/test_util.js +++ b/test/test_util.js @@ -1,8 +1,8 @@ -/* global describe, it */ "use strict"; let { generateFingerprint } = require("../lib/util"); let { FileFinder } = require("../lib/util/files/finder"); +let { describe, it } = require("node:test"); let path = require("path"); let assert = require("assert"); From b163b4cdfe00d0b2f2eaf50a4feee47c34febc05 Mon Sep 17 00:00:00 2001 From: Lucas Dohmen Date: Sun, 26 Jan 2025 20:47:02 +0100 Subject: [PATCH 08/14] Remove minimist --- lib/cli.js | 62 ++++++++++++++++++++++++++++++++++++++-------------- package.json | 1 - 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 01dba5b..ae8713b 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -2,7 +2,7 @@ let { readConfig } = require("./config"); let { abort, repr } = require("./util"); -let parseArgs = require("minimist"); +let { parseArgs } = require("node:util"); let HELP = ` Usage: @@ -27,27 +27,55 @@ Options: serve generated files via HTTP with live reloading `.trim(); -exports.parseCLI = async function parseCLI(argv = process.argv.slice(2), help = HELP) { - argv = parseArgs(argv, { - boolean: ["watch", "fingerprint", "sourcemaps", "compact"], - alias: { - c: "config", - w: "watch", - h: "help" +exports.parseCLI = async function parseCLI() { + let { values } = parseArgs({ + options: { + help: { + type: "boolean", + short: "h", + default: false + }, + config: { + type: "string", + short: "c" + }, + watch: { + type: "boolean", + short: "w", + default: false + }, + fingerprint: { + type: "boolean", + default: false + }, + sourcemaps: { + type: "boolean", + default: false + }, + compact: { + type: "boolean", + default: false + }, + serve: { + type: "string" + }, + liveserve: { + type: "string" + } } }); - if(argv.help) { - abort(help, 0); + if(values.help) { + abort(HELP, 0); } let options = { - watch: argv.watch, - fingerprint: argv.fingerprint, - sourcemaps: argv.sourcemaps, - compact: argv.compact, - serve: argv.serve, - liveserve: argv.liveserve + watch: values.watch, + fingerprint: values.fingerprint, + sourcemaps: values.sourcemaps, + compact: values.compact, + serve: values.serve, + liveserve: values.liveserve }; if(options.watch && options.fingerprint) { // for convenience @@ -56,6 +84,6 @@ exports.parseCLI = async function parseCLI(argv = process.argv.slice(2), help = } let rootDir = process.cwd(); - let { referenceDir, config } = await readConfig(rootDir, argv.config); + let { referenceDir, config } = await readConfig(rootDir, values.config); return { referenceDir, config, options }; }; diff --git a/package.json b/package.json index c9c806d..7567ac3 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ }, "dependencies": { "browserslist": "~4.22.1", - "minimist": "~1.2.7", "nite-owl": "~5.0.5" }, "devDependencies": { From f87b0046334da252f4106be56815b73ec9756948 Mon Sep 17 00:00:00 2001 From: Lucas Dohmen Date: Mon, 27 Jan 2025 22:48:47 +0100 Subject: [PATCH 09/14] Remove npm-run-all --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 7567ac3..2241296 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "faucet": "bin/faucet" }, "scripts": { - "test": "npm-run-all --parallel lint test:unit", + "test": "npm run lint && npm run test:unit", "test:unit": "node --test ./test/test_*.js", "lint": "eslint --cache ./lib ./bin/* ./test ./test/bin/* && echo ✓" }, @@ -33,7 +33,6 @@ }, "devDependencies": { "eslint-config-fnd": "^1.13.0", - "npm-run-all": "^4.1.5", "release-util-fnd": "^3.0.0" } } From 40e96e81554b6ca2a058e7074ab5808441e5594c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:42:41 +0000 Subject: [PATCH 10/14] Bump browserslist from 4.22.3 to 4.24.4 Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.22.3 to 4.24.4. - [Release notes](https://github.com/browserslist/browserslist/releases) - [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) - [Commits](https://github.com/browserslist/browserslist/compare/4.22.3...4.24.4) --- updated-dependencies: - dependency-name: browserslist dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2241296..51485ee 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "node": ">= 18" }, "dependencies": { - "browserslist": "~4.22.1", + "browserslist": "~4.24.4", "nite-owl": "~5.0.5" }, "devDependencies": { From dae1cd5ec744e386118234afe72a536e158a9015 Mon Sep 17 00:00:00 2001 From: FND Date: Sun, 2 Mar 2025 17:00:00 +0100 Subject: [PATCH 11/14] v3.0.0 --- CHANGELOG.md | 23 +++++++++++++++++++++++ package.json | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb45425..b52517b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,29 @@ faucet-pipeline-core version history ==================================== +v3.0.0 +------ + +_2025-03-02_ + +notable changes for end users: + +* bumped Node requirement to v18 or later, dropping support for obsolete versions +* reduced number of dependencies + +notable changes for developers: + +* switched to named instead of default exports + + this might affect users of utilities like `resolvePath` and `FileFinder` + +* ensured dynamic imports are asynchronous + + this might affect users of utilities like `loadExtension` + +* `promisify` was removed entirely after being deprecated for a while + + v2.0.0 ------ diff --git a/package.json b/package.json index 51485ee..48bd905 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "faucet-pipeline-core", - "version": "2.0.0", + "version": "3.0.0", "description": "faucet-pipeline's core library", "author": "FND", "contributors": [ From eedf4aafe51ab499379bfc11cd513a629d75568e Mon Sep 17 00:00:00 2001 From: Lucas Dohmen Date: Sun, 26 Jan 2025 18:51:02 +0100 Subject: [PATCH 12/14] dropped support for Node v18 in the process, adjusted CI's Node support matrix --- .github/workflows/tests.yaml | 13 ++++++------- package.json | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 842fef5..f15e903 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,19 +1,18 @@ -name: tests on: - push + jobs: - build: + test: runs-on: ubuntu-latest strategy: matrix: node-version: - - 18.x - 20.x - - 22.x - - 23.x + - 24.x + - latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} - run: npm install-test diff --git a/package.json b/package.json index 48bd905..2bca3d0 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "lint": "eslint --cache ./lib ./bin/* ./test ./test/bin/* && echo ✓" }, "engines": { - "node": ">= 18" + "node": ">= 20" }, "dependencies": { "browserslist": "~4.24.4", From 15c13309267d691dd417f5b2790a25c5c0087ecc Mon Sep 17 00:00:00 2001 From: Lucas Dohmen Date: Thu, 23 Oct 2025 22:44:40 +0200 Subject: [PATCH 13/14] added support for faucet-pipeline-assets and faucet-pipeline-css NB: this was backported to a newly established v2 release branch and released as v2.1 --- CHANGELOG.md | 13 +++++++++++++ lib/plugins.js | 8 ++++++++ test/test_plugins.js | 8 ++++++++ 3 files changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b52517b..d144430 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,19 @@ notable changes for developers: * `promisify` was removed entirely after being deprecated for a while +v2.1.0 +------ + +_2025-10-26_ + +notable changes for end users: + +* added support for faucet-pipeline-assets and faucet-pipeline-css +* dropped support for Node 19 and below + +no significant changes for developers + + v2.0.0 ------ diff --git a/lib/plugins.js b/lib/plugins.js index b940706..29c894a 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -4,9 +4,17 @@ let { loadExtension, abort, repr } = require("./util"); // common plugins included for convenience let DEFAULTS = [{ + key: "assets", + bucket: "static", + plugin: "faucet-pipeline-assets" +}, { key: "js", bucket: "scripts", plugin: "faucet-pipeline-js" +}, { + key: "css", + bucket: "styles", + plugin: "faucet-pipeline-css" }, { key: "sass", bucket: "styles", diff --git a/test/test_plugins.js b/test/test_plugins.js index 637b3ab..8c9a0d9 100644 --- a/test/test_plugins.js +++ b/test/test_plugins.js @@ -9,10 +9,18 @@ let { deepStrictEqual: assertDeep } = assert; let ROOT = path.resolve(__dirname, "fixtures"); let DEFAULTS = { + assets: { + bucket: "static", + plugin: "faucet-pipeline-assets" + }, js: { bucket: "scripts", plugin: "faucet-pipeline-js" }, + css: { + bucket: "styles", + plugin: "faucet-pipeline-css" + }, sass: { bucket: "styles", plugin: "faucet-pipeline-sass" From fd1dfc271b6feabd75c39debf9caba2b07985ac8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Oct 2025 07:51:36 +0000 Subject: [PATCH 14/14] Bump browserslist from 4.24.5 to 4.27.0 Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.24.5 to 4.27.0. - [Release notes](https://github.com/browserslist/browserslist/releases) - [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) - [Commits](https://github.com/browserslist/browserslist/compare/4.24.5...4.27.0) --- updated-dependencies: - dependency-name: browserslist dependency-version: 4.27.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2bca3d0..5ffc748 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "node": ">= 20" }, "dependencies": { - "browserslist": "~4.24.4", + "browserslist": "~4.27.0", "nite-owl": "~5.0.5" }, "devDependencies": {