Build System: - Replace Grunt with npm scripts and Node.js helper scripts - Remove worker-loader, use native Webpack 5 worker syntax - Add Rspack config as faster alternative bundler (5-23x faster) - Replace platform-specific sed postinstall hacks with cross-platform Node.js script - Update browser targets from Chrome 50/Firefox 38 to Chrome 80/Firefox 78/Safari 14 - Fix import assertions (assert -> with) for Node 24 compatibility Dependencies: - Replace deprecated crypto-js with native RC4 implementation and @noble/hashes EVP KDF - Replace blakejs with @noble/hashes/blake2b and blake2s - Add @noble/hashes for MD5, SHA1/2/3, RIPEMD160, HMAC, HKDF (crypto-api fallback for legacy algos) - Replace lodash with native CaseConvert.mjs utility - Replace moment.js in web layer with date-fns - Add date-fns and date-fns-tz dependencies - Remove jquery, snackbarjs, arrive, bootstrap-colorpicker, bootstrap-material-design, popper.js v1, lodash, blakejs, crypto-js UI Modernization: - Upgrade Bootstrap 4.6.2 to Bootstrap 5.3 (87 data attribute renames) - Remove bootstrap-material-design (unmaintained) - Remove jQuery dependency entirely (38 calls replaced with native DOM + BS5 JS API) - Add custom Snackbar.mjs notification utility (replaces snackbarjs) - Replace bootstrap-colorpicker with native HTML color input Testing: - Add Vitest config and adapter for running existing TestRegister tests - Add Playwright config and E2E test replacing Nightwatch - Update CI workflows to use npm scripts and Playwright
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
/**
|
|
* Tests that CyberChef can be consumed as both CJS and ESM modules.
|
|
* Replaces Grunt exec:setupNodeConsumers, testCJSNodeConsumer, testESMNodeConsumer, teardownNodeConsumers.
|
|
*
|
|
* @author CyberChef Modernization
|
|
* @copyright Crown Copyright 2017
|
|
* @license Apache-2.0
|
|
*/
|
|
|
|
import { execSync } from "child_process";
|
|
import { mkdirSync, cpSync, rmSync, existsSync } from "fs";
|
|
import { join } from "path";
|
|
import { homedir } from "os";
|
|
|
|
const testPath = join(homedir(), "tmp-cyberchef");
|
|
const nodeFlags = "--no-warnings --no-deprecation";
|
|
|
|
try {
|
|
console.log("\n--- Testing node consumers ---");
|
|
|
|
// Setup
|
|
execSync("npm link", { stdio: "inherit" });
|
|
mkdirSync(testPath, { recursive: true });
|
|
|
|
// Copy consumer test files
|
|
const consumersDir = "tests/node/consumers";
|
|
cpSync(consumersDir, testPath, { recursive: true });
|
|
|
|
// Link cyberchef in the test directory
|
|
execSync("npm link cyberchef", { cwd: testPath, stdio: "inherit" });
|
|
|
|
// Test CJS consumer
|
|
console.log("Testing CJS consumer...");
|
|
execSync(`node ${nodeFlags} cjs-consumer.js`, { cwd: testPath, stdio: "pipe" });
|
|
console.log("CJS consumer test passed.");
|
|
|
|
// Test ESM consumer
|
|
console.log("Testing ESM consumer...");
|
|
execSync(`node ${nodeFlags} esm-consumer.mjs`, { cwd: testPath, stdio: "pipe" });
|
|
console.log("ESM consumer test passed.");
|
|
|
|
console.log("\n--- Node consumer tests complete ---");
|
|
} catch (e) {
|
|
console.error("Node consumer test failed:", e.message);
|
|
process.exitCode = 1;
|
|
} finally {
|
|
// Teardown
|
|
if (existsSync(testPath)) {
|
|
rmSync(testPath, { recursive: true, force: true });
|
|
}
|
|
}
|