Skip to content

Commit 9b4fc3d

Browse files
committed
Converted the core to ES modules
1 parent c1bb93e commit 9b4fc3d

File tree

154 files changed

+1894
-2216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+1894
-2216
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"chrome": 40,
66
"firefox": 35,
77
"edge": 14,
8-
"node": "6.5",
8+
"node": "6.5"
99
},
1010
"modules": false,
1111
"useBuiltIns": true

.eslintignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
src/core/lib/**
2-
src/core/config/MetaConfig.js
1+
src/core/vendor/**

.eslintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
"globals": {
9090
"$": false,
9191
"jQuery": false,
92-
"moment": false,
9392
"log": false,
9493

9594
"COMPILE_TIME": false,

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ build
55
docs/*
66
!docs/*.conf.json
77
!docs/*.ico
8-
.vscode
9-
src/core/config/MetaConfig.js
8+
.vscode

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- "8.4"
3+
- node
44
install: npm install
55
before_script:
66
- npm install -g grunt

Gruntfile.js

Lines changed: 26 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ const webpack = require("webpack");
44
const HtmlWebpackPlugin = require("html-webpack-plugin");
55
const NodeExternals = require("webpack-node-externals");
66
const Inliner = require("web-resource-inliner");
7-
const fs = require("fs");
7+
const glob = require("glob");
8+
const path = require("path");
89

910
/**
1011
* Grunt configuration for building the app in various formats.
@@ -21,23 +22,23 @@ module.exports = function (grunt) {
2122
// Tasks
2223
grunt.registerTask("dev",
2324
"A persistent task which creates a development build whenever source files are modified.",
24-
["clean:dev", "concurrent:dev"]);
25+
["clean:dev", "clean:config", "webpack-dev-server:start"]);
2526

2627
grunt.registerTask("node",
2728
"Compiles CyberChef into a single NodeJS module.",
28-
["clean:node", "webpack:metaConf", "webpack:node", "chmod:build"]);
29+
["clean:node", "clean:config", "webpack:node", "chmod:build"]);
2930

3031
grunt.registerTask("test",
3132
"A task which runs all the tests in test/tests.",
32-
["clean:test", "webpack:metaConf", "webpack:tests", "execute:test"]);
33+
["exec:tests"]);
3334

3435
grunt.registerTask("docs",
3536
"Compiles documentation in the /docs directory.",
3637
["clean:docs", "jsdoc", "chmod:docs"]);
3738

3839
grunt.registerTask("prod",
3940
"Creates a production-ready build. Use the --msg flag to add a compile message.",
40-
["eslint", "clean:prod", "webpack:metaConf", "webpack:web", "inline", "chmod"]);
41+
["eslint", "clean:prod", "clean:config", "webpack:web", "inline", "chmod"]);
4142

4243
grunt.registerTask("default",
4344
"Lints the code base",
@@ -62,9 +63,7 @@ module.exports = function (grunt) {
6263
grunt.loadNpmTasks("grunt-contrib-copy");
6364
grunt.loadNpmTasks("grunt-chmod");
6465
grunt.loadNpmTasks("grunt-exec");
65-
grunt.loadNpmTasks("grunt-execute");
6666
grunt.loadNpmTasks("grunt-accessibility");
67-
grunt.loadNpmTasks("grunt-concurrent");
6867

6968

7069
// Project configuration
@@ -118,12 +117,12 @@ module.exports = function (grunt) {
118117
* Generates an entry list for all the modules.
119118
*/
120119
function listEntryModules() {
121-
const path = "./src/core/config/modules/";
122120
let entryModules = {};
123121

124-
fs.readdirSync(path).forEach(file => {
125-
if (file !== "Default.js" && file !== "OpModules.js")
126-
entryModules[file.split(".js")[0]] = path + file;
122+
glob.sync("./src/core/config/modules/*.mjs").forEach(file => {
123+
const basename = path.basename(file);
124+
if (basename !== "Default.mjs" && basename !== "OpModules.mjs")
125+
entryModules[basename.split(".mjs")[0]] = path.resolve(file);
127126
});
128127

129128
return entryModules;
@@ -132,9 +131,9 @@ module.exports = function (grunt) {
132131
grunt.initConfig({
133132
clean: {
134133
dev: ["build/dev/*"],
135-
prod: ["build/prod/*", "src/core/config/MetaConfig.js"],
136-
test: ["build/test/*", "src/core/config/MetaConfig.js"],
137-
node: ["build/node/*", "src/core/config/MetaConfig.js"],
134+
prod: ["build/prod/*"],
135+
node: ["build/node/*"],
136+
config: ["src/core/config/OperationConfig.json", "src/core/config/modules/*"],
138137
docs: ["docs/*", "!docs/*.conf.json", "!docs/*.ico", "!docs/*.png"],
139138
inlineScripts: ["build/prod/scripts.js"],
140139
},
@@ -143,10 +142,10 @@ module.exports = function (grunt) {
143142
configFile: "./.eslintrc.json"
144143
},
145144
configs: ["Gruntfile.js"],
146-
core: ["src/core/**/*.js", "!src/core/lib/**/*", "!src/core/config/MetaConfig.js"],
147-
web: ["src/web/**/*.js"],
148-
node: ["src/node/**/*.js"],
149-
tests: ["test/**/*.js"],
145+
core: ["src/core/**/*.{js,mjs}", "!src/core/vendor/**/*"],
146+
web: ["src/web/**/*.{js,mjs}"],
147+
node: ["src/node/**/*.{js,mjs}"],
148+
tests: ["test/**/*.{js,mjs}"],
150149
},
151150
jsdoc: {
152151
options: {
@@ -159,17 +158,11 @@ module.exports = function (grunt) {
159158
all: {
160159
src: [
161160
"src/**/*.js",
162-
"!src/core/lib/**/*",
163-
"!src/core/config/MetaConfig.js"
161+
"src/**/*.mjs",
162+
"!src/core/vendor/**/*"
164163
],
165164
}
166165
},
167-
concurrent: {
168-
options: {
169-
logConcurrentOutput: true
170-
},
171-
dev: ["webpack:metaConfDev", "webpack-dev-server:start"]
172-
},
173166
accessibility: {
174167
options: {
175168
accessibilityLevel: "WCAG2A",
@@ -184,39 +177,6 @@ module.exports = function (grunt) {
184177
},
185178
webpack: {
186179
options: webpackConfig,
187-
metaConf: {
188-
mode: "production",
189-
target: "node",
190-
entry: [
191-
"babel-polyfill",
192-
"./src/core/config/OperationConfig.js"
193-
],
194-
output: {
195-
filename: "MetaConfig.js",
196-
path: __dirname + "/src/core/config/",
197-
library: "MetaConfig",
198-
libraryTarget: "commonjs2",
199-
libraryExport: "default"
200-
},
201-
externals: [NodeExternals()],
202-
},
203-
metaConfDev: {
204-
mode: "development",
205-
target: "node",
206-
entry: [
207-
"babel-polyfill",
208-
"./src/core/config/OperationConfig.js"
209-
],
210-
output: {
211-
filename: "MetaConfig.js",
212-
path: __dirname + "/src/core/config/",
213-
library: "MetaConfig",
214-
libraryTarget: "commonjs2",
215-
libraryExport: "default"
216-
},
217-
externals: [NodeExternals()],
218-
watch: true
219-
},
220180
web: {
221181
mode: "production",
222182
target: "web",
@@ -229,7 +189,7 @@ module.exports = function (grunt) {
229189
},
230190
resolve: {
231191
alias: {
232-
"./config/modules/OpModules.js": "./config/modules/Default.js"
192+
"./config/modules/OpModules": "./config/modules/Default"
233193
}
234194
},
235195
plugins: [
@@ -279,7 +239,7 @@ module.exports = function (grunt) {
279239
tests: {
280240
mode: "development",
281241
target: "node",
282-
entry: "./test/index.js",
242+
entry: "./test/index.mjs",
283243
externals: [NodeExternals()],
284244
output: {
285245
filename: "index.js",
@@ -292,7 +252,7 @@ module.exports = function (grunt) {
292252
node: {
293253
mode: "production",
294254
target: "node",
295-
entry: "./src/node/index.js",
255+
entry: "./src/node/index.mjs",
296256
externals: [NodeExternals()],
297257
output: {
298258
filename: "CyberChef.js",
@@ -330,7 +290,7 @@ module.exports = function (grunt) {
330290
}, moduleEntryPoints),
331291
resolve: {
332292
alias: {
333-
"./config/modules/OpModules.js": "./config/modules/Default.js"
293+
"./config/modules/OpModules": "./config/modules/Default"
334294
}
335295
},
336296
plugins: [
@@ -401,10 +361,10 @@ module.exports = function (grunt) {
401361
},
402362
sitemap: {
403363
command: "node build/prod/sitemap.js > build/prod/sitemap.xml"
364+
},
365+
tests: {
366+
command: "node --experimental-modules test/index.mjs"
404367
}
405368
},
406-
execute: {
407-
test: "build/test/index.js"
408-
},
409369
});
410370
};

package-lock.json

Lines changed: 6 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@
4141
"grunt": ">=1.0.2",
4242
"grunt-accessibility": "~6.0.0",
4343
"grunt-chmod": "~1.1.1",
44-
"grunt-concurrent": "^2.3.1",
4544
"grunt-contrib-clean": "~1.1.0",
4645
"grunt-contrib-copy": "~1.0.0",
4746
"grunt-eslint": "^20.1.0",
4847
"grunt-exec": "~3.0.0",
49-
"grunt-execute": "^0.2.2",
5048
"grunt-jsdoc": "^2.2.1",
5149
"grunt-webpack": "^3.0.2",
5250
"html-webpack-plugin": "^3.0.4",
@@ -61,11 +59,11 @@
6159
"sitemap": "^1.13.0",
6260
"style-loader": "^0.20.2",
6361
"url-loader": "^0.6.2",
64-
"val-loader": "^1.1.0",
6562
"web-resource-inliner": "^4.2.1",
6663
"webpack": "^4.0.1",
6764
"webpack-dev-server": "^3.1.0",
6865
"webpack-node-externals": "^1.6.0",
66+
"webpack-shell-plugin": "^0.5.0",
6967
"worker-loader": "^1.1.1"
7068
},
7169
"dependencies": {

0 commit comments

Comments
 (0)