Skip to content

Commit

Permalink
Converted the core to ES modules
Browse files Browse the repository at this point in the history
  • Loading branch information
n1474335 committed Mar 26, 2018
1 parent c1bb93e commit 9b4fc3d
Show file tree
Hide file tree
Showing 154 changed files with 1,894 additions and 2,216 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Expand Up @@ -5,7 +5,7 @@
"chrome": 40,
"firefox": 35,
"edge": 14,
"node": "6.5",
"node": "6.5"
},
"modules": false,
"useBuiltIns": true
Expand Down
3 changes: 1 addition & 2 deletions .eslintignore
@@ -1,2 +1 @@
src/core/lib/**
src/core/config/MetaConfig.js
src/core/vendor/**
1 change: 0 additions & 1 deletion .eslintrc.json
Expand Up @@ -89,7 +89,6 @@
"globals": {
"$": false,
"jQuery": false,
"moment": false,
"log": false,

"COMPILE_TIME": false,
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Expand Up @@ -5,5 +5,4 @@ build
docs/*
!docs/*.conf.json
!docs/*.ico
.vscode
src/core/config/MetaConfig.js
.vscode
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "8.4"
- node
install: npm install
before_script:
- npm install -g grunt
Expand Down
92 changes: 26 additions & 66 deletions Gruntfile.js
Expand Up @@ -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.
Expand All @@ -21,23 +22,23 @@ 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.",
["clean:docs", "jsdoc", "chmod:docs"]);

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",
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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"],
},
Expand All @@ -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: {
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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: [
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -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"
},
});
};
63 changes: 6 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Expand Up @@ -41,12 +41,10 @@
"grunt": ">=1.0.2",
"grunt-accessibility": "~6.0.0",
"grunt-chmod": "~1.1.1",
"grunt-concurrent": "^2.3.1",
"grunt-contrib-clean": "~1.1.0",
"grunt-contrib-copy": "~1.0.0",
"grunt-eslint": "^20.1.0",
"grunt-exec": "~3.0.0",
"grunt-execute": "^0.2.2",
"grunt-jsdoc": "^2.2.1",
"grunt-webpack": "^3.0.2",
"html-webpack-plugin": "^3.0.4",
Expand All @@ -61,11 +59,11 @@
"sitemap": "^1.13.0",
"style-loader": "^0.20.2",
"url-loader": "^0.6.2",
"val-loader": "^1.1.0",
"web-resource-inliner": "^4.2.1",
"webpack": "^4.0.1",
"webpack-dev-server": "^3.1.0",
"webpack-node-externals": "^1.6.0",
"webpack-shell-plugin": "^0.5.0",
"worker-loader": "^1.1.1"
},
"dependencies": {
Expand Down

0 comments on commit 9b4fc3d

Please sign in to comment.