From 2237e9f213f9f9fe3863f791daf6e6653c542108 Mon Sep 17 00:00:00 2001 From: Chad Wilson Date: Tue, 25 Jun 2024 15:03:47 +0800 Subject: [PATCH] Migrate to use of ES Modules (#667) - Moves minimum node version to v18 (latest LTS at time of PR) - Changes gauge-js to an ES module, removing all use of CommonJS requires - Prefers use of node: prefixed imports - Upgrades and de-duplicates dependencies to latest ---- Signed-off-by: Chad Wilson Signed-off-by: Zabil Cheriya Maliackal Co-authored-by: Zabil Cheriya Maliackal --- README.md | 3 +- eslint.config.mjs => eslint.config.js | 2 +- examples/tests/step_implementation.js | 5 +- examples/tests/vowels.js | 14 +- index.js | 66 ++- js.json | 2 +- package-lock.json | 721 ++++++++++++++---------- package.json | 8 +- scripts/install.js | 45 +- skel/step_implementation.js | 2 +- src/custom-message-registry.js | 2 +- src/custom-screenshot-registry.js | 4 +- src/data-store-factory.js | 2 +- src/executor.js | 23 +- src/file-util.js | 28 +- src/gauge-global.js | 22 +- src/gauge.js | 90 +-- src/hook-registry.js | 2 +- src/impl-loader.js | 6 +- src/logger.js | 4 +- src/message-processor.js | 156 +++-- src/refactor.js | 14 +- src/req-manager.js | 80 ++- src/response-factory.js | 26 +- src/screenshot.js | 11 +- src/serviceHandlers.js | 4 +- src/static-loader.js | 17 +- src/step-parser.js | 10 +- src/step-registry.js | 6 +- src/table.js | 2 +- src/test.js | 6 +- src/vm.js | 14 +- test/custom-message-registry-test.js | 4 +- test/custom-screenshot-registry-test.js | 12 +- test/data-store-factory-test.js | 6 +- test/executor-test.js | 8 +- test/file-util-test.js | 145 +++-- test/gauge-global-test.js | 10 +- test/hook-registry-test.js | 6 +- test/lsp-server-test.js | 15 +- test/message-processor-test.js | 31 +- test/package-test.js | 7 +- test/refactor-test.js | 13 +- test/screenshot-test.js | 15 +- test/static-loader-test.js | 6 +- test/step-parser-test.js | 4 +- test/step-registry-test.js | 4 +- test/table.js | 6 +- test/test.js | 6 +- test/vm-test.js | 14 +- 50 files changed, 979 insertions(+), 730 deletions(-) rename eslint.config.mjs => eslint.config.js (96%) diff --git a/README.md b/README.md index be4e4225..d157f22a 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,7 @@ The plugin is authored in [Javascript](https://en.wikipedia.org/wiki/JavaScript) Gauge is authored in golang. These are independent processes talking to each other over TCP on port GAUGE_INTERNAL_PORT (env variable) using [Protobuf](https://github.com/getgauge/gauge-proto). ##### Pre-Requisites -* [Node.js](https://nodejs.org/en/) - Version >= 16 -* [Npm](https://www.npmjs.com/get-npm) +* [Node.js](https://nodejs.org/en/) - Version >= 18 ##### Compiling ``` diff --git a/eslint.config.mjs b/eslint.config.js similarity index 96% rename from eslint.config.mjs rename to eslint.config.js index d608ad5e..44c0fdd2 100644 --- a/eslint.config.mjs +++ b/eslint.config.js @@ -6,7 +6,7 @@ export default [ mocha }, languageOptions: { - ecmaVersion: 8, + ecmaVersion: 11, globals: { node: true, es6: true, diff --git a/examples/tests/step_implementation.js b/examples/tests/step_implementation.js index 29af5e12..eede5889 100644 --- a/examples/tests/step_implementation.js +++ b/examples/tests/step_implementation.js @@ -5,13 +5,12 @@ /** * Loads the `assert` module provided by NodeJS */ -var assert = require("assert"); - +import assert from "node:assert"; /** * Loads the local `vowels.js` module present in this directory */ -var vowels = require("./vowels"); +import vowels from "./vowels.js"; // -------------------------- diff --git a/examples/tests/vowels.js b/examples/tests/vowels.js index 6129c28e..26740241 100644 --- a/examples/tests/vowels.js +++ b/examples/tests/vowels.js @@ -1,15 +1,13 @@ -/** - * Use `module.exports` to export an object which can be used with a `require()` on this file. - */ +const vowelList = ["a", "e", "i", "o", "u"]; -var vowelList = ["a", "e", "i", "o", "u"]; - -var numVowels = function (word) { - var vowelArr = word.split("").filter(function (elem) { return vowelList.indexOf(elem) > -1; }); +const numVowels = function (word) { + const vowelArr = word.split("").filter(function (elem) { + return vowelList.indexOf(elem) > -1; + }); return vowelArr.length; }; -module.exports = { +export default { vowelList: vowelList, numVowels: numVowels }; diff --git a/index.js b/index.js index eca7ebc4..af656df0 100755 --- a/index.js +++ b/index.js @@ -1,63 +1,75 @@ #! /usr/bin/env node -var version = process.versions.node.split("."); -if (parseInt(version[0]) < 16) { - throw new Error("gauge-js requires Node.js version 16+. Current version: " + process.versions.node); +const minNodeVersion = 18; +const version = process.versions.node.split("."); +if (Number.parseInt(version[0]) < minNodeVersion) { + throw new Error( + `gauge-js requires Node.js version ${minNodeVersion}+. Current version: ${process.versions.node}`, + ); } -var fs = require("fs"), - path = require("path"), - child_process = require("child_process"); +import child_process from "node:child_process"; +import fs from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); -var skeldir = path.join(__dirname, "skel"), - srcdir = path.join(process.env.GAUGE_PROJECT_ROOT, "tests"), - envdir = path.join(process.env.GAUGE_PROJECT_ROOT, "env", "default"), - testCode = "step_implementation.js", - jsPropertyFile = "js.properties"; -if (process.argv[2] === "--init") { +const skeldir = path.join(__dirname, "skel"); +const srcdir = path.join(process.env.GAUGE_PROJECT_ROOT, "tests"); +const envdir = path.join(process.env.GAUGE_PROJECT_ROOT, "env", "default"); +const testCode = "step_implementation.js"; +const jsPropertyFile = "js.properties"; +if (process.argv[2] === "--init") { console.log("Initialising Gauge JavaScript project"); - fs.mkdir(srcdir, 484, function (err) { + fs.mkdir(srcdir, 484, (err) => { if (err && err.code !== "EEXIST") { console.error(err); } else { - fs.createReadStream(path.join(skeldir, testCode)) - .pipe(fs.createWriteStream(path.join(srcdir, testCode))); + fs.createReadStream(path.join(skeldir, testCode)).pipe( + fs.createWriteStream(path.join(srcdir, testCode)), + ); } }); - fs.mkdir(path.dirname(envdir), 484, function (err) { + fs.mkdir(path.dirname(envdir), 484, (err) => { if (err && err.code !== "EEXIST") { console.error(err); } else { - fs.mkdir(envdir, 484, function (err) { + fs.mkdir(envdir, 484, (err) => { if (err && err.code !== "EEXIST") { console.error(err); } else { - fs.createReadStream(path.join(skeldir, jsPropertyFile)) - .pipe(fs.createWriteStream(path.join(envdir, jsPropertyFile))); + fs.createReadStream(path.join(skeldir, jsPropertyFile)).pipe( + fs.createWriteStream(path.join(envdir, jsPropertyFile)), + ); } }); } }); -} - -else if (process.argv[2] === "--start") { - var args = ["./src/gauge.js", "--run"]; +} else if (process.argv[2] === "--start") { + let args = ["./src/gauge.js", "--run"]; if (process.env.gauge_nodejs_args) { args = process.env.gauge_nodejs_args.split(" ").concat(args); } - var cmd = process.env.gauge_nodejs_bin || "node"; - var runner = child_process.spawn(cmd, args, { env: process.env, silent: false, stdio: "inherit" }); + const cmd = process.env.gauge_nodejs_bin || "node"; + const runner = child_process.spawn(cmd, args, { + env: process.env, + silent: false, + stdio: "inherit", + }); process.on("beforeExit", (code) => { try { - if (!runner.killed) { runner.kill("SIGINT"); } + if (!runner.killed) { + runner.kill("SIGINT"); + } } finally { process.exit(code); } }); - runner.on("error", function (err) { + runner.on("error", (err) => { console.trace(err.stack); }); } diff --git a/js.json b/js.json index 2e2778f3..169ea12d 100644 --- a/js.json +++ b/js.json @@ -51,7 +51,7 @@ "--init" ] }, - "version": "4.0.1", + "version": "5.0.0", "gaugeVersionSupport": { "minimum": "1.0.7", "maximum": "" diff --git a/package-lock.json b/package-lock.json index 18c29262..f53216d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gauge-js", - "version": "4.0.1", + "version": "5.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gauge-js", - "version": "4.0.1", + "version": "5.0.0", "license": "MIT", "dependencies": { "@grpc/grpc-js": "^1.10.9", @@ -20,7 +20,7 @@ }, "devDependencies": { "archiver": "^7.0.1", - "chai": "^4.4.1", + "chai": "^5.1.1", "check-if-windows": "^1.0.0", "eslint": "^9.5.0", "eslint-plugin-mocha": "^10.4.3", @@ -28,15 +28,9 @@ "mocha": "^10.4.0", "mock-tmp": "^0.0.4", "sinon": "^18.0.0" - } - }, - "node_modules/@aashutoshrathi/word-wrap": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", - "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", - "dev": true, + }, "engines": { - "node": ">=0.10.0" + "node": ">=18" } }, "node_modules/@eslint-community/eslint-utils": { @@ -54,10 +48,22 @@ "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/@eslint-community/regexpp": { - "version": "4.10.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", - "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.1.tgz", + "integrity": "sha512-Zm2NGpWELsQAD1xsJzGQpYfvICSsFkEpU0jxBjfdC6uNEWXcHnfs9hScFWtXVDVl+rBQJGrl4g1vcKIejpH9dA==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" @@ -100,18 +106,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", - "dev": true, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@eslint/js": { "version": "9.5.0", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.5.0.tgz", @@ -214,41 +208,6 @@ "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "node_modules/@isaacs/cliui/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true - }, - "node_modules/@isaacs/cliui/node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@isaacs/cliui/node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", @@ -264,23 +223,6 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, - "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, "node_modules/@js-sdsl/ordered-map": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/@js-sdsl/ordered-map/-/ordered-map-4.4.2.tgz", @@ -434,9 +376,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.11.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.4.tgz", - "integrity": "sha512-6I0fMH8Aoy2lOejL3s4LhyIYX34DPwY8bl5xlNjBvUEk8OHrcuzsFt+Ied4LvJihbtXPM+8zUqdydfIti86v9g==", + "version": "20.14.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.7.tgz", + "integrity": "sha512-uTr2m2IbJJucF3KUxgnGOZvYbN0QgkGyWxG6973HCpMYFy2KfcgYuIwkJQMQkt1VbBMlvWRbpshFTLxnxCZjKQ==", "dependencies": { "undici-types": "~5.26.4" } @@ -454,9 +396,9 @@ } }, "node_modules/acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", + "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -570,52 +512,6 @@ "node": ">= 14" } }, - "node_modules/archiver-utils/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/archiver-utils/node_modules/glob": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", - "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", - "dev": true, - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", - "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/archiver-utils/node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -623,12 +519,12 @@ "dev": true }, "node_modules/assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", "dev": true, "engines": { - "node": "*" + "node": ">=12" } }, "node_modules/async": { @@ -638,9 +534,9 @@ "dev": true }, "node_modules/b4a": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.4.tgz", - "integrity": "sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", + "integrity": "sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==", "dev": true }, "node_modules/balanced-match": { @@ -649,6 +545,13 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "node_modules/bare-events": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.4.2.tgz", + "integrity": "sha512-qMKFd2qG/36aA4GwvKq8MxnPgCQAmBWmSyLWsJcbn8v03wvIPQ/hG1Ms8bPzndZxMDoHpxez5VOS+gC9Yi24/Q==", + "dev": true, + "optional": true + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -670,12 +573,15 @@ ] }, "node_modules/binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", "dev": true, "engines": { "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/brace-expansion": { @@ -761,21 +667,19 @@ } }, "node_modules/chai": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", - "integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.1.tgz", + "integrity": "sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==", "dev": true, "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.3", - "deep-eql": "^4.1.3", - "get-func-name": "^2.0.2", - "loupe": "^2.3.6", - "pathval": "^1.1.1", - "type-detect": "^4.0.8" + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" }, "engines": { - "node": ">=4" + "node": ">=12" } }, "node_modules/chalk": { @@ -795,15 +699,12 @@ } }, "node_modules/check-error": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", - "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", "dev": true, - "dependencies": { - "get-func-name": "^2.0.2" - }, "engines": { - "node": "*" + "node": ">= 16" } }, "node_modules/check-if-windows": { @@ -867,6 +768,40 @@ "node": ">=12" } }, + "node_modules/cliui/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -951,9 +886,9 @@ } }, "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -980,13 +915,10 @@ } }, "node_modules/deep-eql": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", - "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", "dev": true, - "dependencies": { - "type-detect": "^4.0.0" - }, "engines": { "node": ">=6" } @@ -1013,14 +945,15 @@ "dev": true }, "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", "engines": { "node": ">=6" } @@ -1125,6 +1058,21 @@ "eslint": ">=7.0.0" } }, + "node_modules/eslint-plugin-mocha/node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/eslint-scope": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.1.tgz", @@ -1169,18 +1117,6 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint/node_modules/eslint-visitor-keys": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", @@ -1193,12 +1129,12 @@ } }, "node_modules/espree": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.0.1.tgz", - "integrity": "sha512-MWkrWZbJsL2UwnjxTX3gG8FneachS/Mwg7tdGXce011sJd5b0JG54vat5KHnfSBODZ3Wvzd2WnjxyzsRoVv+ww==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", "dev": true, "dependencies": { - "acorn": "^8.11.3", + "acorn": "^8.12.0", "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^4.0.0" }, @@ -1209,18 +1145,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", - "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", - "dev": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", @@ -1316,9 +1240,9 @@ "dev": true }, "node_modules/fastq": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz", - "integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -1393,9 +1317,9 @@ "dev": true }, "node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", + "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", "dev": true, "dependencies": { "cross-spawn": "^7.0.0", @@ -1460,19 +1384,23 @@ } }, "node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", + "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", "dev": true, "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" }, "engines": { - "node": ">=12" + "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -1500,27 +1428,27 @@ } }, "node_modules/glob/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=10" + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, "engines": { - "node": ">=8" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -1607,6 +1535,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", "dev": true, "dependencies": { "once": "^1.3.0", @@ -1724,9 +1653,9 @@ "dev": true }, "node_modules/jackspeak": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", - "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.0.tgz", + "integrity": "sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==", "dev": true, "dependencies": { "@isaacs/cliui": "^8.0.2" @@ -1921,18 +1850,18 @@ "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==" }, "node_modules/loupe": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", - "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.1.tgz", + "integrity": "sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==", "dev": true, "dependencies": { "get-func-name": "^2.0.1" } }, "node_modules/lru-cache": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", - "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz", + "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", "dev": true, "engines": { "node": "14 || >=16.14" @@ -1951,9 +1880,9 @@ } }, "node_modules/minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "dev": true, "engines": { "node": ">=16 || 14 >=14.17" @@ -1994,6 +1923,15 @@ "node": ">= 14.0.0" } }, + "node_modules/mocha/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "node_modules/mocha/node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -2005,6 +1943,55 @@ "wrap-ansi": "^7.0.0" } }, + "node_modules/mocha/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mocha/node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/mocha/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/mocha/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/mocha/node_modules/minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", @@ -2017,21 +2004,26 @@ "node": ">=10" } }, - "node_modules/mocha/node_modules/minimatch/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, "node_modules/mocha/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/mocha/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/mocha/node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -2047,6 +2039,23 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/mocha/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/mocha/node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -2118,17 +2127,17 @@ } }, "node_modules/optionator": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", - "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "dependencies": { - "@aashutoshrathi/word-wrap": "^1.2.3", "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", - "type-check": "^0.4.0" + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" }, "engines": { "node": ">= 0.8.0" @@ -2164,6 +2173,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", + "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", + "dev": true + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -2195,16 +2210,16 @@ } }, "node_modules/path-scurry": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz", - "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", "dev": true, "dependencies": { - "lru-cache": "^9.1.1 || ^10.0.0", + "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -2217,12 +2232,12 @@ "dev": true }, "node_modules/pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", "dev": true, "engines": { - "node": "*" + "node": ">= 14.16" } }, "node_modules/picomatch": { @@ -2297,6 +2312,7 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", + "deprecated": "You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.\n\n(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)", "engines": { "node": ">=0.6.0", "teleport": ">=0.2.0" @@ -2550,13 +2566,17 @@ } }, "node_modules/streamx": { - "version": "2.15.6", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.6.tgz", - "integrity": "sha512-q+vQL4AAz+FdfT137VF69Cc/APqUbxy+MDOImRrMvchJpigHj9GksgDU2LYbO9rx7RX6osWgxJB2WxhYv4SZAw==", + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.18.0.tgz", + "integrity": "sha512-LLUC1TWdjVdn1weXGcSxyTR3T4+acB6tVGXT95y0nGbca4t4o/ng1wKAGTljm9VicuCVLvRlqFYXYy5GwgM7sQ==", "dev": true, "dependencies": { - "fast-fifo": "^1.1.0", - "queue-tick": "^1.0.1" + "fast-fifo": "^1.3.2", + "queue-tick": "^1.0.1", + "text-decoder": "^1.1.0" + }, + "optionalDependencies": { + "bare-events": "^2.2.0" } }, "node_modules/string_decoder": { @@ -2569,16 +2589,20 @@ } }, "node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" }, "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/string-width-cjs": { @@ -2596,6 +2620,39 @@ "node": ">=8" } }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/string-width/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/string-width/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -2645,9 +2702,9 @@ } }, "node_modules/tar-stream": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.6.tgz", - "integrity": "sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg==", + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", + "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", "dev": true, "dependencies": { "b4a": "^1.6.4", @@ -2655,6 +2712,15 @@ "streamx": "^2.15.0" } }, + "node_modules/text-decoder": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.1.0.tgz", + "integrity": "sha512-TmLJNj6UgX8xcUZo4UDStGQtDiTzF7BzWlzn9g7UWrjkpHr5uJTK1ld16wZ3LXb2vb6jH8qU89dW5whuMdXYdw==", + "dev": true, + "dependencies": { + "b4a": "^1.6.4" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -2756,6 +2822,15 @@ "node": ">= 8" } }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/workerpool": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", @@ -2763,16 +2838,17 @@ "dev": true }, "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" }, "engines": { - "node": ">=10" + "node": ">=12" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" @@ -2796,6 +2872,65 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -2851,6 +2986,24 @@ "node": ">=10" } }, + "node_modules/yargs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/yargs/node_modules/yargs-parser": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", diff --git a/package.json b/package.json index 267bf817..03eae404 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,10 @@ { "name": "gauge-js", - "version": "4.0.1", + "version": "5.0.0", + "type": "module", + "engines": { + "node": ">=18" + }, "description": "JavaScript runner for Gauge", "main": "index.js", "scripts": { @@ -35,7 +39,7 @@ }, "devDependencies": { "archiver": "^7.0.1", - "chai": "^4.4.1", + "chai": "^5.1.1", "check-if-windows": "^1.0.0", "eslint": "^9.5.0", "eslint-plugin-mocha": "^10.4.3", diff --git a/scripts/install.js b/scripts/install.js index 1cad474c..e3f864ec 100644 --- a/scripts/install.js +++ b/scripts/install.js @@ -1,15 +1,16 @@ -var fs = require("fs-extra"), - path = require("path"), - archiver = require("archiver"), - child_process = require("child_process"), - CWD = process.cwd(); - -var localPath = (relativePath) => +import { readFileSync } from "node:fs"; +import fs from "fs-extra"; +import path from "node:path"; +import archiver from "archiver"; +import child_process from "node:child_process"; +const CWD = process.cwd(); + +const localPath = (relativePath) => relativePath ? path.resolve(CWD, relativePath) : path.resolve(CWD); -var plugin = require(localPath("./js.json")); +const plugin = JSON.parse(readFileSync(localPath("./js.json"), "utf8")); -var cleanDir = (dirPath) => { +const cleanDir = (dirPath) => { try { fs.removeSync(dirPath); } catch (err) { @@ -17,7 +18,7 @@ var cleanDir = (dirPath) => { } }; -var createDir = (dirPath) => { +const createDir = (dirPath) => { try { fs.ensureDirSync(dirPath); } catch (err) { @@ -25,13 +26,13 @@ var createDir = (dirPath) => { } }; -var recreateDir = (dirPath) => { +const recreateDir = (dirPath) => { cleanDir(dirPath); createDir(dirPath); }; -var prepareFiles = () => { - var buildDir = localPath("build"), +const prepareFiles = () => { + const buildDir = localPath("build"), copyList = [ "gauge-proto", "src", @@ -48,7 +49,7 @@ var prepareFiles = () => { try { console.log("Installing dependencies..."); fs.removeSync("./node_modules"); - child_process.execSync("npm install --omit=dev", { cwd: localPath() }); + child_process.execSync("npm install --omit=dev", {cwd: localPath()}); } catch (err) { console.error("Error installing dependencies: %s", err.toString()); console.error(err.stack); @@ -91,18 +92,19 @@ var prepareFiles = () => { } }; -var createPackage = (callback) => { - var zip = archiver("zip"), +const createPackage = (callback) => { + const zip = archiver("zip"), deployDir = localPath("deploy"), buildDir = localPath("build"), packageFile = `gauge-${plugin.id}-${plugin.version}.zip`; - callback = callback || (() => { }); + callback = callback || (() => { + }); recreateDir(deployDir); prepareFiles(); - var packageStream = fs.createWriteStream(path.join(deployDir, packageFile)); + const packageStream = fs.createWriteStream(path.join(deployDir, packageFile)); zip.on("error", (err) => { throw err; @@ -114,8 +116,7 @@ var createPackage = (callback) => { "To install this plugin, run:\n\t$ gauge install js --file %s", path.join("deploy", packageFile), ); - typeof callback == "function" && - callback(path.join(deployDir, packageFile)); + typeof callback == "function" && callback(path.join(deployDir, packageFile)); }); zip.pipe(packageStream); @@ -123,9 +124,9 @@ var createPackage = (callback) => { zip.directory(buildDir, "/").finalize(); }; -var installPluginFiles = () => { +const installPluginFiles = () => { createPackage((packageFilePath) => { - var log; + let log; try { log = child_process.execSync( diff --git a/skel/step_implementation.js b/skel/step_implementation.js index 00e44663..7a84c1c7 100644 --- a/skel/step_implementation.js +++ b/skel/step_implementation.js @@ -2,7 +2,7 @@ "use strict"; -var assert = require("assert"); +import assert from "node:assert"; var vowels = ["a", "e", "i", "o", "u"]; diff --git a/src/custom-message-registry.js b/src/custom-message-registry.js index 64afe849..730b1627 100644 --- a/src/custom-message-registry.js +++ b/src/custom-message-registry.js @@ -16,4 +16,4 @@ CustomMessageRegistry.prototype.clear = function () { return this.messages; }; -module.exports = new CustomMessageRegistry(); +export default new CustomMessageRegistry(); diff --git a/src/custom-screenshot-registry.js b/src/custom-screenshot-registry.js index 447fff5a..0cd74862 100644 --- a/src/custom-screenshot-registry.js +++ b/src/custom-screenshot-registry.js @@ -1,4 +1,4 @@ -var screenshot = require("./screenshot"); +import screenshot from "./screenshot.js"; var ScreenshotFactory = function () { this.screenshots = []; @@ -17,4 +17,4 @@ ScreenshotFactory.prototype.clear = function () { this.screenshots = []; }; -module.exports = new ScreenshotFactory(); +export default new ScreenshotFactory(); diff --git a/src/data-store-factory.js b/src/data-store-factory.js index 55d697b5..7fad5cb4 100644 --- a/src/data-store-factory.js +++ b/src/data-store-factory.js @@ -22,4 +22,4 @@ var DataStoreFactory = function () { }; -module.exports = new DataStoreFactory(); +export default new DataStoreFactory(); diff --git a/src/executor.js b/src/executor.js index ef5735d0..a734cc87 100644 --- a/src/executor.js +++ b/src/executor.js @@ -1,14 +1,13 @@ -var Q = require("q"); -var Table = require("./table"); - -var factory = require("./response-factory"), - Test = require("./test"), - screenshot = require("./screenshot"), - stepRegistry = require("./step-registry"), - hookRegistry = require("./hook-registry"), - customScreenshotRegistry = require("./custom-screenshot-registry"), - customMessageRegistry = require("./custom-message-registry"), - logger = require("./logger"); +import Q from "q"; +import Table from "./table.js"; +import factory from "./response-factory.js"; +import Test from "./test.js"; +import screenshot from "./screenshot.js"; +import stepRegistry from "./step-registry.js"; +import hookRegistry from "./hook-registry.js"; +import customScreenshotRegistry from "./custom-screenshot-registry.js"; +import customMessageRegistry from "./custom-message-registry.js"; +import logger from "./logger.js"; /* If test_timeout env variable is not available set the default to 1000ms */ @@ -137,7 +136,7 @@ var executeHook = function (hookLevel, currentExecutionInfo) { }; -module.exports = { +export default { step: executeStep, hook: executeHook }; diff --git a/src/file-util.js b/src/file-util.js index f951d489..cfe39a79 100644 --- a/src/file-util.js +++ b/src/file-util.js @@ -1,7 +1,7 @@ -var fs = require("fs"); -var path = require("path"); -var klawSync = require("klaw-sync"); -var logger = require("./logger"); +import fs from "node:fs"; +import path from "node:path"; +import klawSync from "klaw-sync"; +import logger from "./logger.js"; function isJSFile(file) { return path.extname(file) === ".js"; @@ -25,14 +25,13 @@ function getImplDirs() { function getListOfFiles() { - var results = getImplDirs().reduce(function (files, dir) { + return getImplDirs().reduce(function (files, dir) { if (!fs.existsSync(dir)) { logger.info("Failed to load implementations from " + dir); return files; } return files.concat(collectFilesIn(dir)); }, []); - return results; } function isSameFilePath(filePath1, filePath2) { @@ -40,8 +39,8 @@ function isSameFilePath(filePath1, filePath2) { } function getFileName(dir, counter = 0) { - var tmpl = counter && "step_implementation_" + counter + ".js" || "step_implementation.js"; - var fileName = path.join(dir, tmpl); + const tmpl = counter && "step_implementation_" + counter + ".js" || "step_implementation.js"; + const fileName = path.join(dir, tmpl); if (!fs.existsSync(fileName)) { return fileName; } @@ -56,11 +55,20 @@ function isInImplDir(filePath) { }) !== -1; } -module.exports = { +function parseJsonFileSyncSafe(filePath, encoding) { + try { + return JSON.parse(fs.readFileSync(filePath, encoding || "utf8")); + } catch (e) { + return {}; + } +} + +export default { getImplDirs: getImplDirs, getListOfFiles: getListOfFiles, isSameFilePath: isSameFilePath, getFileName: getFileName, isJSFile: isJSFile, - isInImplDir: isInImplDir + isInImplDir: isInImplDir, + parseJsonFileSyncSafe: parseJsonFileSyncSafe, }; diff --git a/src/gauge-global.js b/src/gauge-global.js index c4212316..c0d9cb10 100644 --- a/src/gauge-global.js +++ b/src/gauge-global.js @@ -1,21 +1,21 @@ -var hookRegistry = require("./hook-registry"), - customMessageRegistry = require("./custom-message-registry"), - dataStore = require("./data-store-factory"), - stepRegistry = require("./step-registry"), - customScreenshotFactory = require("./custom-screenshot-registry"); +import hookRegistry from "./hook-registry.js"; +import customMessageRegistry from "./custom-message-registry.js"; +import dataStore from "./data-store-factory.js"; +import stepRegistry from "./step-registry.js"; +import customScreenshotFactory from "./custom-screenshot-registry.js"; -var gauge = { hooks: {}, dataStore: dataStore }; +const gauge = {hooks: {}, dataStore: dataStore}; -var step = function (stepName, options, stepFunction) { +export const step = function (stepName, options, stepFunction) { if (!stepName || !stepName.length) { throw new Error("Step text cannot be empty"); } if (typeof options === "function" && !!options.call && !!options.apply) { stepFunction = options; - options = { continueOnFailure: false }; + options = {continueOnFailure: false}; } - var filepath = process.env.GAUGE_STEPFILEPATH; + const filepath = process.env.GAUGE_STEPFILEPATH; if (typeof stepName === "object" && !!stepName.length) { stepRegistry.addAlias(stepName, stepFunction, filepath, {}, options); } else if (typeof stepName === "string") { @@ -23,7 +23,7 @@ var step = function (stepName, options, stepFunction) { } }; -var hooks = {}; +const hooks = {}; hookRegistry.types.forEach(function (type) { hooks[type] = function (fn, options) { @@ -44,7 +44,7 @@ gauge.screenshot = function() { customScreenshotFactory.add(); }; -module.exports = { +export default { gauge: gauge, step: step, hooks: hooks, diff --git a/src/gauge.js b/src/gauge.js index 01361687..777ed22e 100755 --- a/src/gauge.js +++ b/src/gauge.js @@ -1,55 +1,75 @@ -const gaugeGlobal = require("./gauge-global"); -const protobuf = require("protobufjs"); -const protoLoader = require("@grpc/proto-loader"); -const path = require("path"); -const loader = require("./static-loader"); -const PROTO_PATH = __dirname + "/../gauge-proto/services.proto"; -const grpc = require("@grpc/grpc-js"); +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import protoLoader from "@grpc/proto-loader"; +import protobuf from "protobufjs"; +import gaugeGlobal from "./gauge-global.js"; +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +import loader from "./static-loader.js"; +const PROTO_PATH = `${__dirname}/../gauge-proto/services.proto`; +import grpc from "@grpc/grpc-js"; const packageDefinition = protoLoader.loadSync(PROTO_PATH, { keepCase: true, longs: String, enums: String, defaults: true, - oneofs: true + oneofs: true, }); -const servicesProto = grpc.loadPackageDefinition(packageDefinition).gauge.messages; +const servicesProto = + grpc.loadPackageDefinition(packageDefinition).gauge.messages; -var ServiceHandlers = require("./serviceHandlers"); -var logger = require("./logger"); +import logger from "./logger.js"; +import ServiceHandlers from "./serviceHandlers.js"; function run() { global.gauge = gaugeGlobal.gauge; - protobuf.load(path.resolve("gauge-proto/messages.proto")).then(function (root) { - var errorType = root.lookupEnum("gauge.messages.StepValidateResponse.ErrorType"); - var fileStatus = root.lookupEnum("gauge.messages.CacheFileRequest.FileStatus"); - return { errorType: errorType, fileStatus: fileStatus }; - }).catch(function (e) { - logger.error("Failed while loading runner.\n" + e); - process.exit(); - }).then(function (types) { - loader.load(); - var server = new grpc.Server(); - server.addService(servicesProto.Runner.service, new ServiceHandlers(server, types)); - server.bindAsync("127.0.0.1:0", grpc.ServerCredentials.createInsecure(), (err, port) => { - if (!err) { - logger.info("Listening on port:" + port); - server.start(); - } else { - logger.error(err); - process.exit(); - } + protobuf + .load(path.resolve("gauge-proto/messages.proto")) + .then((root) => { + const errorType = root.lookupEnum( + "gauge.messages.StepValidateResponse.ErrorType", + ); + const fileStatus = root.lookupEnum( + "gauge.messages.CacheFileRequest.FileStatus", + ); + return { errorType: errorType, fileStatus: fileStatus }; + }) + .catch((e) => { + logger.error(`Failed while loading runner.\n${e}`); + process.exit(); + }) + .then((types) => { + loader.load(); + const server = new grpc.Server(); + server.addService( + servicesProto.Runner.service, + new ServiceHandlers(server, types), + ); + server.bindAsync( + "127.0.0.1:0", + grpc.ServerCredentials.createInsecure(), + (err, port) => { + if (!err) { + logger.info(`Listening on port:${port}`); + server.start(); + } else { + logger.error(err); + process.exit(); + } + }, + ); + }) + .catch((e) => { + logger.error(`${e.message}\n${e.stack}`); }); - }).catch(function (e) { - logger.error(`${e.message}\n${e.stack}`); - }); } if (process.argv[2] === "--run") { run(); } -module.exports = { - run: run +export default { + run: run, }; diff --git a/src/hook-registry.js b/src/hook-registry.js index 10f97552..1b69ea21 100644 --- a/src/hook-registry.js +++ b/src/hook-registry.js @@ -39,4 +39,4 @@ HookRegistry.prototype.clear = function () { this.registry = {}; }; -module.exports = new HookRegistry(); +export default new HookRegistry(); diff --git a/src/impl-loader.js b/src/impl-loader.js index 33744d0c..4d2c7251 100644 --- a/src/impl-loader.js +++ b/src/impl-loader.js @@ -1,5 +1,5 @@ -var fileUtil = require("./file-util"), - VM = require("./vm"); +import fileUtil from "./file-util.js"; +import VM from "./vm.js"; var loaded = false; function loadImpl(stepRegistry) { @@ -17,6 +17,6 @@ function loadImpl(stepRegistry) { }); } -module.exports= { +export default { load: loadImpl }; diff --git a/src/logger.js b/src/logger.js index 7aa6aaa6..f99b4ea1 100644 --- a/src/logger.js +++ b/src/logger.js @@ -20,6 +20,6 @@ function fatal(message) { process.exit(1); } -module.exports = { +export default { debug: debug, info: info, error: error, fatal: fatal -}; \ No newline at end of file +}; diff --git a/src/message-processor.js b/src/message-processor.js index 5884cfd2..35d9e871 100644 --- a/src/message-processor.js +++ b/src/message-processor.js @@ -1,50 +1,49 @@ -var fs = require("fs"); -var path = require("path"); - -var config = require("../package.json").config || {}; -var factory = require("./response-factory"); -var stepRegistry = require("./step-registry"); -var customMessageRegistry = require("./custom-message-registry"); -var executor = require("./executor"); -var refactor = require("./refactor"); -var dataStore = require("./data-store-factory"); -var impl_loader = require("./impl-loader"); -var loader = require("./static-loader"); -var inspector = require("inspector"); -var fileUtil = require("./file-util"); -var customScreenshotRegistry = require("./custom-screenshot-registry"); -var logger = require("./logger"); +import fs from "node:fs"; +import path from "node:path"; +import factory from "./response-factory.js"; +import stepRegistry from "./step-registry.js"; +import customMessageRegistry from "./custom-message-registry.js"; +import executor from "./executor.js"; +import refactor from "./refactor.js"; +import dataStore from "./data-store-factory.js"; +import impl_loader from "./impl-loader.js"; +import loader from "./static-loader.js"; +import inspector from "node:inspector"; +import fileUtil from "./file-util.js"; +import customScreenshotRegistry from "./custom-screenshot-registry.js"; +import logger from "./logger.js"; + +const config = fileUtil.parseJsonFileSyncSafe("./package.json", "utf8"); const ATTACH_DEBUGGER_EVENT = "Runner Ready for Debugging"; -var GAUGE_PROJECT_ROOT = process.env.GAUGE_PROJECT_ROOT; +const GAUGE_PROJECT_ROOT = process.env.GAUGE_PROJECT_ROOT; -var processCustomMessages = function (response) { - var msgs = customMessageRegistry.get(); +export const processCustomMessages = function (response) { + const msgs = customMessageRegistry.get(); response.executionResult.message = response.executionResult.message.concat(msgs); customMessageRegistry.clear(); return response; }; -var processScreenshots = function (response) { - var screenshotPromises = customScreenshotRegistry.get(); +export const processScreenshots = function (response) { + const screenshotPromises = customScreenshotRegistry.get(); return screenshotPromises.then(function (screenshotFiles) { response.executionResult.screenshotFiles = response.executionResult.screenshotFiles.concat(screenshotFiles); customScreenshotRegistry.clear(); }); }; -function executionResponse(isFailed, executionTime) { +export function executionResponse(isFailed, executionTime) { return factory.createExecutionStatusResponse(isFailed, executionTime); } -function successExecutionStatus() { - var response = executionResponse(false, 0); - return response; +export function successExecutionStatus() { + return executionResponse(false, 0); } -function executeStep(request, callback) { - var promise = executor.step(request); +export function executeStep(request, callback) { + const promise = executor.step(request); promise.then( function (value) { callback(value); @@ -55,8 +54,8 @@ function executeStep(request, callback) { ); } -function executeHook(hookName, currentExecutionInfo, callback) { - var promise = executor.hook(hookName, currentExecutionInfo); +export function executeHook(hookName, currentExecutionInfo, callback) { + const promise = executor.hook(hookName, currentExecutionInfo); promise.then( function (response) { processCustomMessages(response); @@ -73,38 +72,38 @@ function executeHook(hookName, currentExecutionInfo, callback) { ); } -function startExecution(executionStartingRequest, callback) { +export function startExecution(executionStartingRequest, callback) { impl_loader.load(stepRegistry).then(() => { executeHook("beforeSuite", executionStartingRequest.currentExecutionInfo, callback); }); } -function executeBeforeSuiteHook(executionStartingRequest, callback) { +export function executeBeforeSuiteHook(executionStartingRequest, callback) { if (process.env.DEBUGGING) { - var port = parseInt(process.env.DEBUG_PORT); + const port = parseInt(process.env.DEBUG_PORT); logger.info(ATTACH_DEBUGGER_EVENT); inspector.open(port, "127.0.0.1", true); - var inspectorWaitTime = 1000; + const inspectorWaitTime = 1000; setTimeout(function () { startExecution(executionStartingRequest, callback); }, inspectorWaitTime); } else { startExecution(executionStartingRequest, callback); } } -function executeBeforeSpecHook(specExecutionStartingRequest, callback) { +export function executeBeforeSpecHook(specExecutionStartingRequest, callback) { executeHook("beforeSpec", specExecutionStartingRequest.currentExecutionInfo, callback); } -function executeBeforeScenarioHook(scenarioExecutionStartingRequest, callback) { +export function executeBeforeScenarioHook(scenarioExecutionStartingRequest, callback) { executeHook("beforeScenario", scenarioExecutionStartingRequest.currentExecutionInfo, callback); } -function executeBeforeStepHook(stepExecutionStartingRequest, callback) { +export function executeBeforeStepHook(stepExecutionStartingRequest, callback) { customMessageRegistry.clear(); executeHook("beforeStep", stepExecutionStartingRequest.currentExecutionInfo, callback); } -function executeAfterSuiteHook(executionEndingRequest, callback) { +export function executeAfterSuiteHook(executionEndingRequest, callback) { executeHook("afterSuite", executionEndingRequest.currentExecutionInfo, function (data) { dataStore.suiteStore.clear(); callback(data); @@ -114,60 +113,61 @@ function executeAfterSuiteHook(executionEndingRequest, callback) { } } -function executeAfterSpecHook(specExecutionEndingRequest, callback) { +export function executeAfterSpecHook(specExecutionEndingRequest, callback) { executeHook("afterSpec", specExecutionEndingRequest.currentExecutionInfo, function (data) { dataStore.specStore.clear(); callback(data); }); } -function executeAfterScenarioHook(scenarioExecutionEndingRequest, callback) { +export function executeAfterScenarioHook(scenarioExecutionEndingRequest, callback) { executeHook("afterScenario", scenarioExecutionEndingRequest.currentExecutionInfo, function (data) { dataStore.scenarioStore.clear(); callback(data); }); } -function executeAfterStepHook(stepExecutionEndingRequest, callback) { +export function executeAfterStepHook(stepExecutionEndingRequest, callback) { executeHook("afterStep", stepExecutionEndingRequest.currentExecutionInfo, callback); } -var getParamsList = function (params) { +export const getParamsList = function (params) { return params.map(function (p, i) { return "arg" + i.toString(); }).join(", "); }; -var generateImplStub = function (stepValue) { - var argCount = 0; - var stepText = stepValue.stepValue.replace(/{}/g, function () { return ""; }); +export const generateImplStub = function (stepValue) { + let argCount = 0; + const stepText = stepValue.stepValue.replace(/{}/g, function () { + return ""; + }); return "step(\"" + stepText + "\", async function(" + getParamsList(stepValue.parameters) + ") {\n\t" + "throw 'Unimplemented Step';\n" + "});"; }; -var getSuggestionFor = function (request, validated) { +export const getSuggestionFor = function (request, validated) { if (validated.reason !== "notfound") { return ""; } return generateImplStub(request.stepValue); }; -var stepValidateResponse = function (stepValidateRequest, errorType) { - var validated = stepRegistry.validate(stepValidateRequest.stepText); - var suggestion = getSuggestionFor(stepValidateRequest, validated); - var response = factory.createStepValidateResponse(errorType, validated, suggestion); - return response; +export const stepValidateResponse = function (stepValidateRequest, errorType) { + const validated = stepRegistry.validate(stepValidateRequest.stepText); + const suggestion = getSuggestionFor(stepValidateRequest, validated); + return factory.createStepValidateResponse(errorType, validated, suggestion); }; -var stepNamesResponse = function () { +export const stepNamesResponse = function () { return factory.createStepNamesResponse(stepRegistry.getStepTexts()); }; -var stepNameResponse = function (stepNameRequest) { - var stepValue = stepNameRequest.stepValue; - var response = factory.createStepNameResponse(); - var step = stepRegistry.get(stepValue); +export const stepNameResponse = function (stepNameRequest) { + const stepValue = stepNameRequest.stepValue; + const response = factory.createStepNameResponse(); + const step = stepRegistry.get(stepValue); if (step) { response.stepNameResponse.stepName = step.aliases; response.stepNameResponse.hasAlias = step.hasAlias; @@ -178,28 +178,26 @@ var stepNameResponse = function (stepNameRequest) { return response; }; -var stepPositions = function (stepPositionsRequest) { - var filepath = stepPositionsRequest.filePath; - var response = factory.createStepPositionsResponse(stepRegistry.getStepPositions(filepath)); - return response; +export const stepPositions = function (stepPositionsRequest) { + const filepath = stepPositionsRequest.filePath; + return factory.createStepPositionsResponse(stepRegistry.getStepPositions(filepath)); }; -var implementationFiles = function () { - var response = factory.createImplementationFileListResponse(fileUtil.getListOfFiles()); - return response; +export const implementationFiles = function () { + return factory.createImplementationFileListResponse(fileUtil.getListOfFiles()); }; -var implementStubResponse = function (stubImplementationCodeRequest) { - var response = factory.createFileDiff(); - var filePath = stubImplementationCodeRequest.implementationFilePath; - var codes = stubImplementationCodeRequest.codes; +export const implementStubResponse = function (stubImplementationCodeRequest) { + const response = factory.createFileDiff(); + let filePath = stubImplementationCodeRequest.implementationFilePath; + const codes = stubImplementationCodeRequest.codes; - var reducer = function (accumulator, currentValue) { + const reducer = function (accumulator, currentValue) { return accumulator + "\n" + currentValue; }; - var content = codes.reduce(reducer); + let content = codes.reduce(reducer); - var fileLineCount = 0; + let fileLineCount = 0; if (fs.existsSync(filePath)) { let fileContent = fs.readFileSync(filePath, "utf8").replace("\r\n", "\n"); if (fileContent.trim().split("\n").length == fileContent.split("\n").length) { @@ -213,25 +211,25 @@ var implementStubResponse = function (stubImplementationCodeRequest) { filePath = fileUtil.getFileName(fileUtil.getImplDirs(GAUGE_PROJECT_ROOT)[0]); } - var span = { start: fileLineCount, end: fileLineCount, startChar: 0, endChar: 0 }; - var textDiffs = [{ span: span, content: content }]; + const span = {start: fileLineCount, end: fileLineCount, startChar: 0, endChar: 0}; + const textDiffs = [{span: span, content: content}]; response.fileDiff.filePath = filePath; response.fileDiff.textDiffs = textDiffs; return response; }; -var refactorResponse = function (request) { - var response = factory.createRefactorResponse(); +export const refactorResponse = function (request) { + let response = factory.createRefactorResponse(); response = refactor(request, response); return response; }; -var cacheFileResponse = function (cacheFileRequest, fileStatus) { +export const cacheFileResponse = function (cacheFileRequest, fileStatus) { const filePath = cacheFileRequest.filePath; if (!fileUtil.isJSFile(filePath) || !fileUtil.isInImplDir(filePath)) { return; } - var CHANGED, OPENED, CLOSED, CREATED; + let CHANGED, OPENED, CLOSED, CREATED; if (config.hasPureJsGrpc) { CHANGED = fileStatus.values.CHANGED; OPENED = fileStatus.values.OPENED; @@ -259,16 +257,16 @@ var cacheFileResponse = function (cacheFileRequest, fileStatus) { } }; -var implementationGlobPatternResponse = function () { - var globPatterns = []; +export const implementationGlobPatternResponse = function () { + const globPatterns = []; fileUtil.getImplDirs().forEach((dir) => { globPatterns.push(dir.split(path.sep).join("/") + "/**/*.js"); }); - var response = factory.createImplementationFileGlobPatternResponse(globPatterns); + const response = factory.createImplementationFileGlobPatternResponse(globPatterns); return response; }; -module.exports = { +export default { stepNamesResponse: stepNamesResponse, cacheFileResponse: cacheFileResponse, stepPositions: stepPositions, diff --git a/src/refactor.js b/src/refactor.js index 821b32e1..64462c9d 100644 --- a/src/refactor.js +++ b/src/refactor.js @@ -1,9 +1,9 @@ -var fs = require("fs"), - esprima = require("esprima"), - estraverse = require("estraverse"), - escodegen = require("escodegen"), - stepRegistry = require("./step-registry"), - stepParser = require("./step-parser"); +import fs from "node:fs"; +import esprima from "esprima"; +import estraverse from "estraverse"; +import escodegen from "escodegen"; +import stepRegistry from "./step-registry.js"; +import stepParser from "./step-parser.js"; var isArrowFunction = function (node) { return node.type === "ArrowFunctionExpression"; @@ -137,4 +137,4 @@ var refactor = function (refactorRequest, response) { return response; }; -module.exports = refactor; +export default refactor; diff --git a/src/req-manager.js b/src/req-manager.js index 97fbe67f..9574cca7 100644 --- a/src/req-manager.js +++ b/src/req-manager.js @@ -1,41 +1,65 @@ -var mod = require("module"), - path = require("path"), - fs = require("fs"), - logger = require("./logger"); +import fs from "node:fs"; +import mod from "node:module"; +import path from "node:path"; +import logger from "./logger.js"; -var Req = function (filepath, root) { +const require = mod.createRequire(import.meta.url); + +const Req = function(filepath, root) { this.Module = mod.Module; this.root = root; this.filepath = filepath || null; this.nativeModules = [ - "assert", "buffer", "child_process", "constants", "crypto", "tls", "dgram", "dns", "http", "https", - "net", "querystring", "url", "domain", "events", "fs", "path", "os", "punycode", "stream", "string_decoder", - "timers", "tty", "util", "sys", "vm", "zlib" + "assert", + "buffer", + "child_process", + "constants", + "crypto", + "tls", + "dgram", + "dns", + "http", + "https", + "net", + "querystring", + "url", + "domain", + "events", + "fs", + "path", + "os", + "punycode", + "stream", + "string_decoder", + "timers", + "tty", + "util", + "sys", + "vm", + "zlib", ]; }; -Req.prototype.load = function (modname) { - var self = this; - - var cachedModule = self.Module._cache[self.filepath]; +Req.prototype.load = function(modname) { + const cachedModule = this.Module._cache[this.filepath]; if (cachedModule) { return cachedModule.exports; } - return (function (self, mod, modname) { + return ((self, mod, modname) => { if (!modname.startsWith("./") && self.nativeModules.indexOf(modname) < 0) { modname = path.normalize(modname); } - var m = new mod.Module(self.filepath, mod.Module); + const m = new mod.Module(self.filepath, mod.Module); m.paths = [ path.dirname(self.filepath), - path.join(self.root, "node_modules") - ].concat(module.paths.filter(function (p) { return p.indexOf(".gauge") < 0; })); + path.join(self.root, "node_modules"), + ].concat(require.resolve.paths("").filter((p) => p.indexOf(".gauge") < 0)); try { if (modname === path.basename(modname)) { return m.require(modname); } - let relativePath = path.join(path.dirname(self.filepath), modname); + const relativePath = path.join(path.dirname(self.filepath), modname); if (fs.existsSync(relativePath)) { return m.require(relativePath); } @@ -44,24 +68,24 @@ Req.prototype.load = function (modname) { } return m.require(modname); } catch (e) { - logger.error("Unable to require module '" + modname + "' in " + self.filepath + "\n" + e.stack); + logger.error( + `Unable to require module '${modname}' in ${self.filepath}\n${e.stack}`, + ); return null; } - })(self, mod, modname); + })(this, mod, modname); }; -var reqman = function (filepath, root) { - - var req = new Req(filepath, root); +const reqman = (filepath, root) => { + const req = new Req(filepath, root); return { mod: req.Module, exports: req.Module.exports || {}, - fn: (function (req) { - return function (modname) { - return req.load(modname); - }; - })(req) + fn: ( + (req) => (modname) => + req.load(modname) + )(req), }; }; -module.exports = reqman; +export default reqman; diff --git a/src/response-factory.js b/src/response-factory.js index e060c139..e767650f 100644 --- a/src/response-factory.js +++ b/src/response-factory.js @@ -1,6 +1,4 @@ -exports = module.exports; - -exports.createStepNamesResponse = function (steps) { +export const createStepNamesResponse = function (steps) { return { stepNamesResponse: { @@ -10,7 +8,7 @@ exports.createStepNamesResponse = function (steps) { }; -exports.createStepNameResponse = function () { +export const createStepNameResponse = function () { return { stepNameResponse: { @@ -24,7 +22,7 @@ exports.createStepNameResponse = function () { }; -exports.createRefactorResponse = function () { +export const createRefactorResponse = function () { return { refactorResponse: { @@ -37,7 +35,7 @@ exports.createRefactorResponse = function () { }; -exports.createStepValidateResponse = function (errorType, validated, suggestion) { +export const createStepValidateResponse = function (errorType, validated, suggestion) { if (validated.valid) { return { @@ -70,7 +68,7 @@ exports.createStepValidateResponse = function (errorType, validated, suggestion) }; }; -exports.createExecutionStatusResponse = function (isFailed, executionTime, err, msg, failureScreenshotFile, recoverable, screenshotFiles) { +export const createExecutionStatusResponse = function (isFailed, executionTime, err, msg, failureScreenshotFile, recoverable, screenshotFiles) { return { executionResult: { failed: isFailed, @@ -86,7 +84,7 @@ exports.createExecutionStatusResponse = function (isFailed, executionTime, err, }; -exports.createStepPositionsResponse = function (stepPositions) { +export const createStepPositionsResponse = function (stepPositions) { return { stepPositionsResponse: { @@ -97,9 +95,7 @@ exports.createStepPositionsResponse = function (stepPositions) { }; - - -exports.createImplementationFileListResponse = function (files) { +export const createImplementationFileListResponse = function (files) { return { implementationFileListResponse: { implementationFilePaths: files @@ -107,7 +103,7 @@ exports.createImplementationFileListResponse = function (files) { }; }; -exports.createImplementationFileGlobPatternResponse = function (globPatterns) { +export const createImplementationFileGlobPatternResponse = function (globPatterns) { return { implementationFileGlobPatternResponse: { globPatterns: globPatterns @@ -115,9 +111,11 @@ exports.createImplementationFileGlobPatternResponse = function (globPatterns) { }; }; -exports.createFileDiff = function () { +export const createFileDiff = function () { return { fileDiff: {} }; -}; \ No newline at end of file +}; + +export default { createStepNamesResponse, createStepNameResponse, createRefactorResponse, createStepValidateResponse, createExecutionStatusResponse, createStepPositionsResponse, createImplementationFileListResponse, createImplementationFileGlobPatternResponse, createFileDiff }; diff --git a/src/screenshot.js b/src/screenshot.js index ad53a0e0..77358e0a 100644 --- a/src/screenshot.js +++ b/src/screenshot.js @@ -1,7 +1,8 @@ -const path = require("path"), - fs = require("fs"), - child_process = require("child_process"); -var logger = require("./logger"); +import path from "node:path"; +import fs from "node:fs"; +import child_process from "node:child_process"; +import logger from "./logger.js"; + const SCREENSHOTS_DIR_ENV = "gauge_screenshots_dir"; var defaultScreenshotWriter = function () { @@ -74,4 +75,4 @@ function capture() { return screenshotFn(); } -module.exports = { capture: capture }; +export default { capture: capture }; diff --git a/src/serviceHandlers.js b/src/serviceHandlers.js index 6df2a7c5..fbc6fc49 100644 --- a/src/serviceHandlers.js +++ b/src/serviceHandlers.js @@ -1,4 +1,4 @@ -var processors = require("./message-processor"); +import processors from "./message-processor.js"; class ServiceHandlers { constructor(server, options) { @@ -137,4 +137,4 @@ class ServiceHandlers { } } -module.exports = ServiceHandlers; +export default ServiceHandlers; diff --git a/src/static-loader.js b/src/static-loader.js index d7cb6b52..1b0f571a 100644 --- a/src/static-loader.js +++ b/src/static-loader.js @@ -1,11 +1,10 @@ -var fs = require("fs"); -var esprima = require("esprima"); -var estraverse = require("estraverse"); - -var fileUtil = require("./file-util"); -var stepRegistry = require("./step-registry"); -var stepParser = require("./step-parser"); -var logger = require("./logger"); +import fs from "node:fs"; +import esprima from "esprima"; +import estraverse from "estraverse"; +import fileUtil from "./file-util.js"; +import stepRegistry from "./step-registry.js"; +import stepParser from "./step-parser.js"; +import logger from "./logger.js"; function hasAliases(node) { return node.type === "ArrayExpression" && !!node.elements.length; @@ -82,7 +81,7 @@ function reloadFile(filePath, content) { } } -module.exports = { +export default { load: loadFiles, reloadFile: reloadFile, unloadFile: unloadFile diff --git a/src/step-parser.js b/src/step-parser.js index 4ef35cf8..462b7ca4 100644 --- a/src/step-parser.js +++ b/src/step-parser.js @@ -1,5 +1,3 @@ -exports = module.exports; - /** * Returns the generalised form of a step description. * Example: @@ -8,16 +6,16 @@ exports = module.exports; * @param {[String]} stepName Description of the step. * @return {[String]} Generalised form of the step. */ -exports.generalise = function(stepName) { +export const generalise = function(stepName) { return stepName.replace(/(<.*?>)/g, "{}"); }; -exports.getParams = function(step) { +export const getParams = function(step) { var matches = step.match(/(<.*?>)/g); return (matches === null) ? [] : matches.map(function(item) { return item.substring(1, item.length-1); }); }; -exports.isStepNode = function(node) { +export const isStepNode = function(node) { var isGaugeStepFunction = function (node) { return node.callee.object && node.callee.object.name === "gauge" && node.callee.property && node.callee.property.name === "step"; }; @@ -26,3 +24,5 @@ exports.isStepNode = function(node) { }; return (node && node.type === "CallExpression" && (isGaugeStepFunction(node) || isGlobalStepFunction(node))); }; + +export default { generalise, getParams, isStepNode }; diff --git a/src/step-registry.js b/src/step-registry.js index d156c4ed..9e53a44c 100644 --- a/src/step-registry.js +++ b/src/step-registry.js @@ -1,5 +1,5 @@ -var fileUtil = require("./file-util"); -var stepParser = require("./step-parser"); +import fileUtil from "./file-util.js"; +import stepParser from "./step-parser.js"; var StepRegistry = function () { this.registry = {}; @@ -151,4 +151,4 @@ StepRegistry.prototype.isFileCached = function (filePath) { return false; }; -module.exports = new StepRegistry(); +export default new StepRegistry(); diff --git a/src/table.js b/src/table.js index 36b0a1af..c567aa9f 100644 --- a/src/table.js +++ b/src/table.js @@ -16,4 +16,4 @@ var Table = function (protoTable) { }; }; -module.exports = Table; +export default Table; diff --git a/src/test.js b/src/test.js index 8b02b539..e7f21a8b 100644 --- a/src/test.js +++ b/src/test.js @@ -1,5 +1,5 @@ -var Q = require("q"); -var path = require("path"); +import Q from "q"; +import path from "node:path"; var Test = function (fn, params, ms) { this.fn = fn; @@ -109,4 +109,4 @@ Test.prototype.run = function () { return this.deferred.promise; }; -module.exports = Test; +export default Test; diff --git a/src/vm.js b/src/vm.js index b8205ab2..a600a16c 100644 --- a/src/vm.js +++ b/src/vm.js @@ -1,9 +1,9 @@ -var vm = require("vm"), - fs = require("fs"), - path = require("path"), - reqman = require("./req-manager"), - gaugeGlobal = require("./gauge-global"); -var logger = require("./logger"); +import vm from "node:vm"; +import fs from "node:fs"; +import path from "node:path"; +import reqman from "./req-manager.js"; +import gaugeGlobal from "./gauge-global.js"; +import logger from "./logger.js"; var VM = function () { var self = this; @@ -73,4 +73,4 @@ VM.prototype.runFile = function (filePath) { this.run(fs.readFileSync(filePath, "utf8")); }; -module.exports = VM; +export default VM; diff --git a/test/custom-message-registry-test.js b/test/custom-message-registry-test.js index a36e94d3..3217b885 100644 --- a/test/custom-message-registry-test.js +++ b/test/custom-message-registry-test.js @@ -1,5 +1,5 @@ -var assert = require("chai").assert; -var customMessageRegistry = require("../src/custom-message-registry"); +import { assert } from "chai"; +import customMessageRegistry from "../src/custom-message-registry.js"; describe("Custom Message registry", function () { diff --git a/test/custom-screenshot-registry-test.js b/test/custom-screenshot-registry-test.js index 670c6cc2..d837d523 100644 --- a/test/custom-screenshot-registry-test.js +++ b/test/custom-screenshot-registry-test.js @@ -1,7 +1,9 @@ -var assert = require("chai").assert; -var sandbox = require("sinon").createSandbox(); -var screenshot = require("../src/screenshot"); -var customScreenshotRegistry = require("../src/custom-screenshot-registry"); +import { assert } from "chai"; +import sinon from "sinon"; +import screenshot from "../src/screenshot.js"; +import customScreenshotRegistry from "../src/custom-screenshot-registry.js"; + +const sandbox = sinon.createSandbox(); describe("Custom Screenshot Registry", () => { beforeEach(() => { @@ -30,4 +32,4 @@ describe("Custom Screenshot Registry", () => { done(); }); }); -}); \ No newline at end of file +}); diff --git a/test/data-store-factory-test.js b/test/data-store-factory-test.js index 59a91a6f..ce4dd109 100644 --- a/test/data-store-factory-test.js +++ b/test/data-store-factory-test.js @@ -1,5 +1,5 @@ -var assert = require("chai").assert; -var dataStoreFactory = require("../src/data-store-factory"); +import { assert } from "chai"; +import dataStoreFactory from "../src/data-store-factory.js"; describe("DataStoreFactory", function () { describe("get data from datastore", function () { @@ -36,4 +36,4 @@ describe("DataStoreFactory", function () { assert.equal(data, 0); }); }); -}); \ No newline at end of file +}); diff --git a/test/executor-test.js b/test/executor-test.js index b2d26398..d32482ab 100644 --- a/test/executor-test.js +++ b/test/executor-test.js @@ -1,7 +1,7 @@ -var expect = require("chai").expect; -var sinon = require("sinon"); -var executor = require("../src/executor"); -var stepRegistry = require("../src/step-registry"); +import { expect } from "chai"; +import sinon from "sinon"; +import executor from "../src/executor.js"; +import stepRegistry from "../src/step-registry.js"; describe("Executing steps", function () { diff --git a/test/file-util-test.js b/test/file-util-test.js index c7feedf4..9c24c039 100644 --- a/test/file-util-test.js +++ b/test/file-util-test.js @@ -1,112 +1,119 @@ -var assert = require("chai").assert; -var path = require("path"); -var fileUtil = require("../src/file-util"); -var isWindows = require("check-if-windows"); -var mock = require("mock-tmp"); - -describe("File util functions", function () { - describe("isSameFilePath", function () { - it("Should return true when given paths are same windows", function () { +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { assert } from "chai"; +import isWindows from "check-if-windows"; +import mock from "mock-tmp"; +import fileUtil from "../src/file-util.js"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +describe("File util functions", () => { + describe("isSameFilePath", () => { + it("Should return true when given paths are same windows", function() { if (!isWindows) { this.skip(); } else { - var path1 = "c:/Users/user_name/test_js/tests/step_implementation.js"; - var path2 = "C:/Users/user_name/test_js/tests/step_implementation.js"; + const path1 = "c:/Users/user_name/test_js/tests/step_implementation.js"; + const path2 = "C:/Users/user_name/test_js/tests/step_implementation.js"; assert.isTrue(fileUtil.isSameFilePath(path1, path2)); } }); - it("Should return true when given paths are with different fileseperator ", function () { + it("Should return true when given paths are with different fileseperator ", function() { if (!isWindows) { this.skip(); } else { - var path1 = "c:\\Users\\user_name\\test_js\\tests\\step_implementation.js"; - var path2 = "c:/Users/user_name/test_js/tests/step_implementation.js"; + const path1 = + "c:\\Users\\user_name\\test_js\\tests\\step_implementation.js"; + const path2 = "c:/Users/user_name/test_js/tests/step_implementation.js"; assert.isTrue(fileUtil.isSameFilePath(path1, path2)); } }); - it("Should return true when given paths are same and has space ", function () { - var path1 = "/Users/test_js/tests/Step implementation.js"; - var path2 = "/Users/test_js/tests/Step implementation.js"; + it("Should return true when given paths are same and has space ", () => { + const path1 = "/Users/test_js/tests/Step implementation.js"; + const path2 = "/Users/test_js/tests/Step implementation.js"; assert.isTrue(fileUtil.isSameFilePath(path1, path2)); }); - - it("Should return true when given paths are same on linux ", function () { - var path1 = "/Users/test_js/tests/Step_implementation.js"; - var path2 = "/Users/test_js/tests/Step_implementation.js"; + it("Should return true when given paths are same on linux ", () => { + const path1 = "/Users/test_js/tests/Step_implementation.js"; + const path2 = "/Users/test_js/tests/Step_implementation.js"; assert.isTrue(fileUtil.isSameFilePath(path1, path2)); }); - it("Should return false when given paths are not different", function () { - var path1 = "/Users/test_js/tests/Step_implementation.js"; - var path2 = "/Users/test_js/tests1/step_implementation.js"; + it("Should return false when given paths are not different", () => { + const path1 = "/Users/test_js/tests/Step_implementation.js"; + const path2 = "/Users/test_js/tests1/step_implementation.js"; assert.isFalse(fileUtil.isSameFilePath(path1, path2)); }); }); - describe("getListOfFiles", function () { - it("should get all the js file", function () { + describe("getListOfFiles", () => { + it("should get all the js file", () => { process.env.GAUGE_PROJECT_ROOT = path.join(__dirname, "testdata"); - var files = fileUtil.getListOfFiles(); + const files = fileUtil.getListOfFiles(); assert.equal(files.length, 2); }); - it("should get only js file", function () { + it("should get only js file", () => { process.env.GAUGE_PROJECT_ROOT = path.join(__dirname, "testdata"); - var files = fileUtil.getListOfFiles(); + const files = fileUtil.getListOfFiles(); assert.equal(files.length, 2); }); - it("should get scan only tests dir by default", function () { - process.env.GAUGE_PROJECT_ROOT = path.join(__dirname, "testdata", "custom"); - var files = fileUtil.getListOfFiles(); + it("should get scan only tests dir by default", () => { + process.env.GAUGE_PROJECT_ROOT = path.join( + __dirname, + "testdata", + "custom", + ); + const files = fileUtil.getListOfFiles(); assert.equal(files.length, 0); }); - it("should get scan only dir specified as STEP_IMPL_DIR env", function () { + it("should get scan only dir specified as STEP_IMPL_DIR env", () => { process.env.STEP_IMP_DIR = "custom"; process.env.GAUGE_PROJECT_ROOT = path.join(__dirname, "testdata"); - var files = fileUtil.getListOfFiles(); + const files = fileUtil.getListOfFiles(); assert.equal(files.length, 2); }); }); - - describe("getFileName", function () { - afterEach(function () { + describe("getFileName", () => { + afterEach(() => { mock.reset(); }); - it("should give default file name does not exist", function () { + it("should give default file name does not exist", () => { const tmp = mock({ - "tests": {}, + tests: {}, }); - var file = fileUtil.getFileName(path.join(tmp, "tests")); + const file = fileUtil.getFileName(path.join(tmp, "tests")); assert.equal(path.basename(file), "step_implementation.js"); }); - it("should give file name with increment if default exists", function () { - var tmp = mock({ - "tests": { - "step_implementation.js": "foo" + it("should give file name with increment if default exists", () => { + let tmp = mock({ + tests: { + "step_implementation.js": "foo", }, }); - var file = fileUtil.getFileName(path.join(tmp, "tests")); + let file = fileUtil.getFileName(path.join(tmp, "tests")); assert.equal(path.basename(file), "step_implementation_1.js"); mock.reset(); tmp = mock({ - "tests": { + tests: { "step_implementation.js": "foo", "step_implementation_1.js": "something", }, @@ -117,40 +124,46 @@ describe("File util functions", function () { }); }); - describe("isInImplDir", function () { - afterEach(function () { + describe("isInImplDir", () => { + afterEach(() => { process.env.GAUGE_PROJECT_ROOT = process.cwd(); mock.reset(); }); - it("should be true if file is under implementation dir", function () { + it("should be true if file is under implementation dir", () => { const tmp = mock({ - "tests": { - "step_impl.js": "file content" + tests: { + "step_impl.js": "file content", }, }); process.env.GAUGE_PROJECT_ROOT = tmp; - assert.isTrue(fileUtil.isInImplDir(path.join(tmp, "tests", "step_impl.js"))); + assert.isTrue( + fileUtil.isInImplDir(path.join(tmp, "tests", "step_impl.js")), + ); }); - it("should be true if file in nested dir under implementation dir", function () { + it("should be true if file in nested dir under implementation dir", () => { const tmp = mock({ - "tests": { + tests: { "inner-dir": { "step_impl.js": "file content", - } + }, }, }); process.env.GAUGE_PROJECT_ROOT = tmp; - assert.isTrue(fileUtil.isInImplDir(path.join(tmp, "tests", "inner-dir", "step_impl.js"))); + assert.isTrue( + fileUtil.isInImplDir( + path.join(tmp, "tests", "inner-dir", "step_impl.js"), + ), + ); }); - it("should be false if file is not under implementation dir", function () { + it("should be false if file is not under implementation dir", () => { const tmp = mock({ - "tests": { + tests: { "inner-dir": { "step_impl.js": "file content", - } + }, }, }); process.env.GAUGE_PROJECT_ROOT = tmp; @@ -158,10 +171,20 @@ describe("File util functions", function () { }); }); - describe("isJSFile", function () { - it("should check for js file extensions", function () { + describe("isJSFile", () => { + it("should check for js file extensions", () => { assert.isTrue(fileUtil.isJSFile("step_impl.js")); assert.isFalse(fileUtil.isJSFile("step_impl.java")); }); }); + + describe("parseJsonFileSyncSafe", () => { + it("should parse a json file that exists", () => { + assert.equal(fileUtil.parseJsonFileSyncSafe("./package.json").name, "gauge-js"); + }); + + it("should default to empty object if json file does not exist", () => { + assert.deepStrictEqual(fileUtil.parseJsonFileSyncSafe("./not-here.json"), {}); + }); + }); }); diff --git a/test/gauge-global-test.js b/test/gauge-global-test.js index b5362593..587c0e01 100644 --- a/test/gauge-global-test.js +++ b/test/gauge-global-test.js @@ -1,8 +1,8 @@ -var assert = require("chai").assert; -var sinon = require("sinon"); -var stepRegistry = require("../src/step-registry"); -var stepParser = require("../src/step-parser"); -var step = require("../src/gauge-global").step; +import { assert } from "chai"; +import sinon from "sinon"; +import stepRegistry from "../src/step-registry.js"; +import stepParser from "../src/step-parser.js"; +import { step } from "../src/gauge-global.js"; describe("Calling global gauge.step()", function() { diff --git a/test/hook-registry-test.js b/test/hook-registry-test.js index e67ce0d1..cb3ed359 100644 --- a/test/hook-registry-test.js +++ b/test/hook-registry-test.js @@ -1,6 +1,6 @@ -var assert = require("chai").assert; -var hookRegistry = require("../src/hook-registry"); -var sinon = require("sinon"); +import { assert } from "chai"; +import hookRegistry from "../src/hook-registry.js"; +import sinon from "sinon"; describe("Hook registry", function () { diff --git a/test/lsp-server-test.js b/test/lsp-server-test.js index bdbdc1cc..bfaf2160 100644 --- a/test/lsp-server-test.js +++ b/test/lsp-server-test.js @@ -1,11 +1,10 @@ -var path = require("path"); -var protobuf = require("protobufjs"); -var mock = require("mock-tmp"); -var assert = require("chai").assert; - -var ServiceHandlers = require("../src/serviceHandlers"); -var registry = require("../src/step-registry"); -var loader = require("../src/static-loader"); +import path from "node:path"; +import protobuf from "protobufjs"; +import mock from "mock-tmp"; +import { assert } from "chai"; +import ServiceHandlers from "../src/serviceHandlers.js"; +import registry from "../src/step-registry.js"; +import loader from "../src/static-loader.js"; describe("ServiceHandlers", function () { var options = null; diff --git a/test/message-processor-test.js b/test/message-processor-test.js index a84ceb1e..471e8d0d 100644 --- a/test/message-processor-test.js +++ b/test/message-processor-test.js @@ -1,13 +1,24 @@ -var assert = require("chai").assert; -var sinon = require("sinon"); -var protobuf = require("protobufjs"); -var stepRegistry = require("../src/step-registry"); -var hookRegistry = require("../src/hook-registry"); -var loader = require("../src/static-loader"); -var dataStore = require("../src/data-store-factory"); -var { executeBeforeSuiteHook, executeBeforeSpecHook, executeBeforeScenarioHook, stepValidateResponse, stepNameResponse, stepPositions, cacheFileResponse, implementationGlobPatternResponse } = require("../src/message-processor"); -var mock = require("mock-tmp"); -var path = require("path"); +import { assert } from "chai"; +import sinon from "sinon"; +import protobuf from "protobufjs"; +import stepRegistry from "../src/step-registry.js"; +import hookRegistry from "../src/hook-registry.js"; +import loader from "../src/static-loader.js"; +import dataStore from "../src/data-store-factory.js"; + +import { + executeBeforeSuiteHook, + executeBeforeSpecHook, + executeBeforeScenarioHook, + stepValidateResponse, + stepNameResponse, + stepPositions, + cacheFileResponse, + implementationGlobPatternResponse, +} from "../src/message-processor.js"; + +import mock from "mock-tmp"; +import path from "node:path"; describe("Step Validate Request Processing", function () { let stepValidateRequests = []; diff --git a/test/package-test.js b/test/package-test.js index 1a7fe321..ed9a3952 100644 --- a/test/package-test.js +++ b/test/package-test.js @@ -1,9 +1,10 @@ -var assert = require("chai").assert; +import { assert } from "chai"; +import { readFileSync } from "node:fs"; describe("Package", function () { - var packageJSON = require("../package.json"), - jsJSON = require("../js.json"); + const packageJSON = JSON.parse(readFileSync("./package.json")); + const jsJSON = JSON.parse(readFileSync("./js.json")); describe("version", function () { diff --git a/test/refactor-test.js b/test/refactor-test.js index 60d6090b..2657161e 100644 --- a/test/refactor-test.js +++ b/test/refactor-test.js @@ -1,10 +1,9 @@ -var assert = require("chai").assert; -var stepRegistry = require("../src/step-registry"); - -var refactor = require("../src/refactor"); -var factory = require("../src/response-factory"); -var fs = require("fs"); -var sinon = require("sinon"); +import { assert } from "chai"; +import stepRegistry from "../src/step-registry.js"; +import refactor from "../src/refactor.js"; +import factory from "../src/response-factory.js"; +import fs from "node:fs"; +import sinon from "sinon"; var sandbox, request, response; var contentInput, contentOutput, info; diff --git a/test/screenshot-test.js b/test/screenshot-test.js index 024c1f90..589629cf 100644 --- a/test/screenshot-test.js +++ b/test/screenshot-test.js @@ -1,9 +1,10 @@ -const expect = require("chai").expect; -const screenshot = require("../src/screenshot"); -const child_process = require("child_process"); -const fs = require("fs"); -const path = require("path"); -const sandbox = require("sinon").createSandbox(); +import { expect } from "chai"; +import screenshot from "../src/screenshot.js"; +import child_process from "node:child_process"; +import fs from "node:fs"; +import path from "node:path"; +import sinon from "sinon"; +const sandbox = sinon.createSandbox(); function screenshotFunction() { @@ -170,4 +171,4 @@ describe("screentshot.capture", function () { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/static-loader-test.js b/test/static-loader-test.js index d83c78f2..3c4d63d3 100644 --- a/test/static-loader-test.js +++ b/test/static-loader-test.js @@ -1,6 +1,6 @@ -var assert = require("chai").assert; -var loader = require("../src/static-loader"); -var stepRegistry = require("../src/step-registry"); +import { assert } from "chai"; +import loader from "../src/static-loader.js"; +import stepRegistry from "../src/step-registry.js"; describe("Static loader", function () { beforeEach(function () { diff --git a/test/step-parser-test.js b/test/step-parser-test.js index 03132ed5..b89ede8d 100644 --- a/test/step-parser-test.js +++ b/test/step-parser-test.js @@ -1,5 +1,5 @@ -var assert = require("chai").assert; -var stepParser = require("../src/step-parser"); +import { assert } from "chai"; +import stepParser from "../src/step-parser.js"; describe("Parsing steps", function() { diff --git a/test/step-registry-test.js b/test/step-registry-test.js index 1534ac5b..89917473 100644 --- a/test/step-registry-test.js +++ b/test/step-registry-test.js @@ -1,5 +1,5 @@ -var assert = require("chai").assert; -var stepRegistry = require("../src/step-registry"); +import { assert } from "chai"; +import stepRegistry from "../src/step-registry.js"; describe("Store and retrieve steps", function () { var sampleFunction; diff --git a/test/table.js b/test/table.js index 211a637e..d91bad67 100644 --- a/test/table.js +++ b/test/table.js @@ -1,6 +1,6 @@ -var Table = require("../src/table"); -var expect = require("chai").expect; -const util = require("util"); +import Table from "../src/table.js"; +import { expect } from "chai"; +import util from "node:util"; const setTimeoutPromise = util.promisify(setTimeout); describe("ProtoTable parsing", function() { diff --git a/test/test.js b/test/test.js index 4c20ff14..2373bbb3 100644 --- a/test/test.js +++ b/test/test.js @@ -1,6 +1,6 @@ -var Test = require("../src/test"); -var expect = require("chai").expect; -var sinon = require("sinon"); +import Test from "../src/test.js"; +import { expect } from "chai"; +import sinon from "sinon"; describe("Test function execution", function () { diff --git a/test/vm-test.js b/test/vm-test.js index f52f994e..addc3140 100644 --- a/test/vm-test.js +++ b/test/vm-test.js @@ -1,10 +1,10 @@ -var assert = require("chai").assert, - nodevm = require("vm"), - sinon = require("sinon"), - fs = require("fs"), - VM = require("../src/vm"), - path = require("path"), - hookRegistry = require("../src/hook-registry"); +import { assert } from "chai"; +import nodevm from "node:vm"; +import sinon from "sinon"; +import fs from "node:fs"; +import VM from "../src/vm.js"; +import path from "node:path"; +import hookRegistry from "../src/hook-registry.js"; describe("VM", function () {