mirror of
https://github.com/gchq/CyberChef
synced 2024-12-29 14:03:10 +00:00
Improve CJS and ESM module support #1037
This commit is contained in:
parent
78a1827af8
commit
75dba51f56
6 changed files with 29 additions and 47 deletions
|
@ -50,7 +50,7 @@ module.exports = function (grunt) {
|
||||||
|
|
||||||
grunt.registerTask("testnodeconsumer",
|
grunt.registerTask("testnodeconsumer",
|
||||||
"A task which checks whether consuming CJS and ESM apps work with the CyberChef build",
|
"A task which checks whether consuming CJS and ESM apps work with the CyberChef build",
|
||||||
["exec:setupNodeConsumers", "exec:testCJSNodeConsumer", "exec:testESMNodeConsumer", "exec:testESMDeepImportNodeConsumer", "exec:teardownNodeConsumers"]);
|
["exec:setupNodeConsumers", "exec:testCJSNodeConsumer", "exec:testESMNodeConsumer", "exec:teardownNodeConsumers"]);
|
||||||
|
|
||||||
grunt.registerTask("default",
|
grunt.registerTask("default",
|
||||||
"Lints the code base",
|
"Lints the code base",
|
||||||
|
@ -403,13 +403,6 @@ module.exports = function (grunt) {
|
||||||
]),
|
]),
|
||||||
stdout: false,
|
stdout: false,
|
||||||
},
|
},
|
||||||
testESMDeepImportNodeConsumer: {
|
|
||||||
command: chainCommands([
|
|
||||||
`cd ${nodeConsumerTestPath}`,
|
|
||||||
`node ${nodeFlags} esm-deep-import-consumer.mjs`,
|
|
||||||
]),
|
|
||||||
stdout: false,
|
|
||||||
},
|
|
||||||
fixCryptoApiImports: {
|
fixCryptoApiImports: {
|
||||||
command: [
|
command: [
|
||||||
`[[ "$OSTYPE" == "darwin"* ]]`,
|
`[[ "$OSTYPE" == "darwin"* ]]`,
|
||||||
|
|
11
package.json
11
package.json
|
@ -27,13 +27,10 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/gchq/CyberChef/"
|
"url": "https://github.com/gchq/CyberChef/"
|
||||||
},
|
},
|
||||||
"main": "src/node/cjs.js",
|
"main": "src/node/wrapper.js",
|
||||||
"module": "src/node/index.mjs",
|
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
"import": "./src/node/index.mjs",
|
||||||
"require": "./src/node/cjs.js",
|
"require": "./src/node/wrapper.js"
|
||||||
"import": "./src/node/index.mjs"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"bugs": "https://github.com/gchq/CyberChef/issues",
|
"bugs": "https://github.com/gchq/CyberChef/issues",
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
|
@ -174,7 +171,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npx grunt dev",
|
"start": "npx grunt dev",
|
||||||
"build": "npx grunt prod",
|
"build": "npx grunt prod",
|
||||||
"repl": "node src/node/repl.js",
|
"repl": "node --experimental-modules --experimental-json-modules --experimental-specifier-resolution=node --no-warnings src/node/repl.mjs",
|
||||||
"test": "npx grunt configTests && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/node/index.mjs && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/operations/index.mjs",
|
"test": "npx grunt configTests && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/node/index.mjs && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/operations/index.mjs",
|
||||||
"test-node-consumer": "npx grunt testnodeconsumer",
|
"test-node-consumer": "npx grunt testnodeconsumer",
|
||||||
"testui": "npx grunt testui",
|
"testui": "npx grunt testui",
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const chef = require("./cjs.js");
|
import chef from "./index.mjs";
|
||||||
const repl = require("repl");
|
import repl from "repl";
|
||||||
|
|
||||||
|
|
||||||
/* eslint no-console: ["off"] */
|
/* eslint no-console: ["off"] */
|
|
@ -7,8 +7,28 @@
|
||||||
*/
|
*/
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import chef from "cyberchef";
|
import chef from "cyberchef";
|
||||||
|
import { bake, toHex, reverse, unique, multiply } from "cyberchef";
|
||||||
|
|
||||||
const d = chef.bake("Testing, 1 2 3", [
|
const a = bake("Testing, 1 2 3", [
|
||||||
|
toHex,
|
||||||
|
reverse,
|
||||||
|
{
|
||||||
|
op: unique,
|
||||||
|
args: {
|
||||||
|
delimiter: "Space",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
op: multiply,
|
||||||
|
args: {
|
||||||
|
delimiter: "Space",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert.equal(a.value, "630957449041920");
|
||||||
|
|
||||||
|
const b = chef.bake("Testing, 1 2 3", [
|
||||||
chef.toHex,
|
chef.toHex,
|
||||||
chef.reverse,
|
chef.reverse,
|
||||||
{
|
{
|
||||||
|
@ -25,4 +45,4 @@ const d = chef.bake("Testing, 1 2 3", [
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert.equal(d.value, "630957449041920");
|
assert.equal(b.value, "630957449041920");
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
/**
|
|
||||||
* Tests to ensure that a consuming app can use named imports from deep import patch
|
|
||||||
*
|
|
||||||
* @author d98762625 [d98762625@gmail.com]
|
|
||||||
* @copyright Crown Copyright 2019
|
|
||||||
* @license Apache-2.0
|
|
||||||
*/
|
|
||||||
import assert from "assert";
|
|
||||||
import { bake, toHex, reverse, unique, multiply } from "cyberchef";
|
|
||||||
|
|
||||||
const d = bake("Testing, 1 2 3", [
|
|
||||||
toHex,
|
|
||||||
reverse,
|
|
||||||
{
|
|
||||||
op: unique,
|
|
||||||
args: {
|
|
||||||
delimiter: "Space",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
op: multiply,
|
|
||||||
args: {
|
|
||||||
delimiter: "Space",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
assert.equal(d.value, "630957449041920");
|
|
Loading…
Reference in a new issue