mirror of
https://github.com/gchq/CyberChef.git
synced 2025-06-17 03:35:07 -04:00
Converted the core to ES modules
This commit is contained in:
parent
c1bb93eec1
commit
9b4fc3d3aa
154 changed files with 1901 additions and 2223 deletions
92
Gruntfile.js
92
Gruntfile.js
|
@ -4,7 +4,8 @@ const webpack = require("webpack");
|
|||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const NodeExternals = require("webpack-node-externals");
|
||||
const Inliner = require("web-resource-inliner");
|
||||
const fs = require("fs");
|
||||
const glob = require("glob");
|
||||
const path = require("path");
|
||||
|
||||
/**
|
||||
* Grunt configuration for building the app in various formats.
|
||||
|
@ -21,15 +22,15 @@ module.exports = function (grunt) {
|
|||
// Tasks
|
||||
grunt.registerTask("dev",
|
||||
"A persistent task which creates a development build whenever source files are modified.",
|
||||
["clean:dev", "concurrent:dev"]);
|
||||
["clean:dev", "clean:config", "webpack-dev-server:start"]);
|
||||
|
||||
grunt.registerTask("node",
|
||||
"Compiles CyberChef into a single NodeJS module.",
|
||||
["clean:node", "webpack:metaConf", "webpack:node", "chmod:build"]);
|
||||
["clean:node", "clean:config", "webpack:node", "chmod:build"]);
|
||||
|
||||
grunt.registerTask("test",
|
||||
"A task which runs all the tests in test/tests.",
|
||||
["clean:test", "webpack:metaConf", "webpack:tests", "execute:test"]);
|
||||
["exec:tests"]);
|
||||
|
||||
grunt.registerTask("docs",
|
||||
"Compiles documentation in the /docs directory.",
|
||||
|
@ -37,7 +38,7 @@ module.exports = function (grunt) {
|
|||
|
||||
grunt.registerTask("prod",
|
||||
"Creates a production-ready build. Use the --msg flag to add a compile message.",
|
||||
["eslint", "clean:prod", "webpack:metaConf", "webpack:web", "inline", "chmod"]);
|
||||
["eslint", "clean:prod", "clean:config", "webpack:web", "inline", "chmod"]);
|
||||
|
||||
grunt.registerTask("default",
|
||||
"Lints the code base",
|
||||
|
@ -62,9 +63,7 @@ module.exports = function (grunt) {
|
|||
grunt.loadNpmTasks("grunt-contrib-copy");
|
||||
grunt.loadNpmTasks("grunt-chmod");
|
||||
grunt.loadNpmTasks("grunt-exec");
|
||||
grunt.loadNpmTasks("grunt-execute");
|
||||
grunt.loadNpmTasks("grunt-accessibility");
|
||||
grunt.loadNpmTasks("grunt-concurrent");
|
||||
|
||||
|
||||
// Project configuration
|
||||
|
@ -118,12 +117,12 @@ module.exports = function (grunt) {
|
|||
* Generates an entry list for all the modules.
|
||||
*/
|
||||
function listEntryModules() {
|
||||
const path = "./src/core/config/modules/";
|
||||
let entryModules = {};
|
||||
|
||||
fs.readdirSync(path).forEach(file => {
|
||||
if (file !== "Default.js" && file !== "OpModules.js")
|
||||
entryModules[file.split(".js")[0]] = path + file;
|
||||
glob.sync("./src/core/config/modules/*.mjs").forEach(file => {
|
||||
const basename = path.basename(file);
|
||||
if (basename !== "Default.mjs" && basename !== "OpModules.mjs")
|
||||
entryModules[basename.split(".mjs")[0]] = path.resolve(file);
|
||||
});
|
||||
|
||||
return entryModules;
|
||||
|
@ -132,9 +131,9 @@ module.exports = function (grunt) {
|
|||
grunt.initConfig({
|
||||
clean: {
|
||||
dev: ["build/dev/*"],
|
||||
prod: ["build/prod/*", "src/core/config/MetaConfig.js"],
|
||||
test: ["build/test/*", "src/core/config/MetaConfig.js"],
|
||||
node: ["build/node/*", "src/core/config/MetaConfig.js"],
|
||||
prod: ["build/prod/*"],
|
||||
node: ["build/node/*"],
|
||||
config: ["src/core/config/OperationConfig.json", "src/core/config/modules/*"],
|
||||
docs: ["docs/*", "!docs/*.conf.json", "!docs/*.ico", "!docs/*.png"],
|
||||
inlineScripts: ["build/prod/scripts.js"],
|
||||
},
|
||||
|
@ -143,10 +142,10 @@ module.exports = function (grunt) {
|
|||
configFile: "./.eslintrc.json"
|
||||
},
|
||||
configs: ["Gruntfile.js"],
|
||||
core: ["src/core/**/*.js", "!src/core/lib/**/*", "!src/core/config/MetaConfig.js"],
|
||||
web: ["src/web/**/*.js"],
|
||||
node: ["src/node/**/*.js"],
|
||||
tests: ["test/**/*.js"],
|
||||
core: ["src/core/**/*.{js,mjs}", "!src/core/vendor/**/*"],
|
||||
web: ["src/web/**/*.{js,mjs}"],
|
||||
node: ["src/node/**/*.{js,mjs}"],
|
||||
tests: ["test/**/*.{js,mjs}"],
|
||||
},
|
||||
jsdoc: {
|
||||
options: {
|
||||
|
@ -159,17 +158,11 @@ module.exports = function (grunt) {
|
|||
all: {
|
||||
src: [
|
||||
"src/**/*.js",
|
||||
"!src/core/lib/**/*",
|
||||
"!src/core/config/MetaConfig.js"
|
||||
"src/**/*.mjs",
|
||||
"!src/core/vendor/**/*"
|
||||
],
|
||||
}
|
||||
},
|
||||
concurrent: {
|
||||
options: {
|
||||
logConcurrentOutput: true
|
||||
},
|
||||
dev: ["webpack:metaConfDev", "webpack-dev-server:start"]
|
||||
},
|
||||
accessibility: {
|
||||
options: {
|
||||
accessibilityLevel: "WCAG2A",
|
||||
|
@ -184,39 +177,6 @@ module.exports = function (grunt) {
|
|||
},
|
||||
webpack: {
|
||||
options: webpackConfig,
|
||||
metaConf: {
|
||||
mode: "production",
|
||||
target: "node",
|
||||
entry: [
|
||||
"babel-polyfill",
|
||||
"./src/core/config/OperationConfig.js"
|
||||
],
|
||||
output: {
|
||||
filename: "MetaConfig.js",
|
||||
path: __dirname + "/src/core/config/",
|
||||
library: "MetaConfig",
|
||||
libraryTarget: "commonjs2",
|
||||
libraryExport: "default"
|
||||
},
|
||||
externals: [NodeExternals()],
|
||||
},
|
||||
metaConfDev: {
|
||||
mode: "development",
|
||||
target: "node",
|
||||
entry: [
|
||||
"babel-polyfill",
|
||||
"./src/core/config/OperationConfig.js"
|
||||
],
|
||||
output: {
|
||||
filename: "MetaConfig.js",
|
||||
path: __dirname + "/src/core/config/",
|
||||
library: "MetaConfig",
|
||||
libraryTarget: "commonjs2",
|
||||
libraryExport: "default"
|
||||
},
|
||||
externals: [NodeExternals()],
|
||||
watch: true
|
||||
},
|
||||
web: {
|
||||
mode: "production",
|
||||
target: "web",
|
||||
|
@ -229,7 +189,7 @@ module.exports = function (grunt) {
|
|||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"./config/modules/OpModules.js": "./config/modules/Default.js"
|
||||
"./config/modules/OpModules": "./config/modules/Default"
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
|
@ -279,7 +239,7 @@ module.exports = function (grunt) {
|
|||
tests: {
|
||||
mode: "development",
|
||||
target: "node",
|
||||
entry: "./test/index.js",
|
||||
entry: "./test/index.mjs",
|
||||
externals: [NodeExternals()],
|
||||
output: {
|
||||
filename: "index.js",
|
||||
|
@ -292,7 +252,7 @@ module.exports = function (grunt) {
|
|||
node: {
|
||||
mode: "production",
|
||||
target: "node",
|
||||
entry: "./src/node/index.js",
|
||||
entry: "./src/node/index.mjs",
|
||||
externals: [NodeExternals()],
|
||||
output: {
|
||||
filename: "CyberChef.js",
|
||||
|
@ -330,7 +290,7 @@ module.exports = function (grunt) {
|
|||
}, moduleEntryPoints),
|
||||
resolve: {
|
||||
alias: {
|
||||
"./config/modules/OpModules.js": "./config/modules/Default.js"
|
||||
"./config/modules/OpModules": "./config/modules/Default"
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
|
@ -401,10 +361,10 @@ module.exports = function (grunt) {
|
|||
},
|
||||
sitemap: {
|
||||
command: "node build/prod/sitemap.js > build/prod/sitemap.xml"
|
||||
},
|
||||
tests: {
|
||||
command: "node --experimental-modules test/index.mjs"
|
||||
}
|
||||
},
|
||||
execute: {
|
||||
test: "build/test/index.js"
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue