2017-09-22 16:05:15 +00:00
|
|
|
"use strict";
|
|
|
|
|
2017-04-13 18:00:55 +00:00
|
|
|
const webpack = require("webpack");
|
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
2018-12-25 23:58:00 +00:00
|
|
|
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
2018-03-26 22:14:23 +00:00
|
|
|
const glob = require("glob");
|
|
|
|
const path = require("path");
|
2016-12-14 16:39:17 +00:00
|
|
|
|
2022-01-31 10:31:19 +00:00
|
|
|
const nodeFlags = "--experimental-modules --experimental-json-modules --experimental-specifier-resolution=node --no-warnings --no-deprecation";
|
|
|
|
|
2017-07-03 22:15:57 +00:00
|
|
|
/**
|
|
|
|
* Grunt configuration for building the app in various formats.
|
|
|
|
*
|
|
|
|
* @author n1474335 [n1474335@gmail.com]
|
|
|
|
* @copyright Crown Copyright 2017
|
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2017-03-23 00:33:40 +00:00
|
|
|
module.exports = function (grunt) {
|
2016-11-28 10:42:58 +00:00
|
|
|
grunt.file.defaultEncoding = "utf8";
|
|
|
|
grunt.file.preserveBOM = false;
|
2016-12-14 16:39:17 +00:00
|
|
|
|
2016-11-28 10:42:58 +00:00
|
|
|
// Tasks
|
|
|
|
grunt.registerTask("dev",
|
|
|
|
"A persistent task which creates a development build whenever source files are modified.",
|
2018-08-29 18:21:46 +00:00
|
|
|
["clean:dev", "clean:config", "exec:generateConfig", "concurrent:dev"]);
|
2017-03-21 22:41:44 +00:00
|
|
|
|
2019-07-09 13:31:18 +00:00
|
|
|
grunt.registerTask("prod",
|
|
|
|
"Creates a production-ready build. Use the --msg flag to add a compile message.",
|
|
|
|
[
|
2019-11-21 14:13:36 +00:00
|
|
|
"eslint", "clean:prod", "clean:config", "exec:generateConfig", "findModules", "webpack:web",
|
2019-07-09 13:31:18 +00:00
|
|
|
"copy:standalone", "zip:standalone", "clean:standalone", "chmod"
|
|
|
|
]);
|
|
|
|
|
2017-03-21 22:41:44 +00:00
|
|
|
grunt.registerTask("node",
|
|
|
|
"Compiles CyberChef into a single NodeJS module.",
|
2019-07-09 13:31:18 +00:00
|
|
|
[
|
2019-07-19 12:14:32 +00:00
|
|
|
"clean:node", "clean:config", "clean:nodeConfig", "exec:generateConfig", "exec:generateNodeIndex"
|
2019-07-09 13:31:18 +00:00
|
|
|
]);
|
2016-12-14 16:39:17 +00:00
|
|
|
|
2020-03-13 14:59:48 +00:00
|
|
|
grunt.registerTask("configTests",
|
2020-03-17 08:40:15 +00:00
|
|
|
"A task which configures config files in preparation for tests to be run. Use `npm test` to run tests.",
|
2019-07-09 13:31:18 +00:00
|
|
|
[
|
2020-03-13 14:59:48 +00:00
|
|
|
"clean:config", "clean:nodeConfig", "exec:generateConfig", "exec:generateNodeIndex"
|
2019-07-09 13:31:18 +00:00
|
|
|
]);
|
2018-12-29 02:58:05 +00:00
|
|
|
|
|
|
|
grunt.registerTask("testui",
|
2018-12-30 00:26:28 +00:00
|
|
|
"A task which runs all the UI tests in the tests directory. The prod task must already have been run.",
|
2018-12-29 23:46:13 +00:00
|
|
|
["connect:prod", "exec:browserTests"]);
|
2016-12-14 16:39:17 +00:00
|
|
|
|
2019-08-02 10:10:15 +00:00
|
|
|
grunt.registerTask("testnodeconsumer",
|
|
|
|
"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"]);
|
|
|
|
|
2016-11-28 10:42:58 +00:00
|
|
|
grunt.registerTask("default",
|
2017-03-29 20:51:42 +00:00
|
|
|
"Lints the code base",
|
|
|
|
["eslint", "exec:repoSize"]);
|
2016-12-14 16:39:17 +00:00
|
|
|
|
|
|
|
grunt.registerTask("lint", "eslint");
|
|
|
|
|
2019-11-21 14:13:36 +00:00
|
|
|
grunt.registerTask("findModules",
|
|
|
|
"Finds all generated modules and updates the entry point list for Webpack",
|
|
|
|
function(arg1, arg2) {
|
|
|
|
const moduleEntryPoints = listEntryModules();
|
|
|
|
|
|
|
|
grunt.log.writeln(`Found ${Object.keys(moduleEntryPoints).length} modules.`);
|
|
|
|
|
|
|
|
grunt.config.set("webpack.web.entry",
|
|
|
|
Object.assign({
|
|
|
|
main: "./src/web/index.js"
|
|
|
|
}, moduleEntryPoints));
|
|
|
|
});
|
|
|
|
|
2016-12-14 16:39:17 +00:00
|
|
|
|
2016-11-28 10:42:58 +00:00
|
|
|
// Load tasks provided by each plugin
|
2016-12-14 16:39:17 +00:00
|
|
|
grunt.loadNpmTasks("grunt-eslint");
|
2017-03-27 15:08:36 +00:00
|
|
|
grunt.loadNpmTasks("grunt-webpack");
|
2016-11-28 10:42:58 +00:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-clean");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-copy");
|
2018-05-06 11:24:01 +00:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-watch");
|
2016-11-28 10:42:58 +00:00
|
|
|
grunt.loadNpmTasks("grunt-chmod");
|
|
|
|
grunt.loadNpmTasks("grunt-exec");
|
2017-09-17 12:47:33 +00:00
|
|
|
grunt.loadNpmTasks("grunt-concurrent");
|
2018-12-29 23:46:13 +00:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-connect");
|
2019-04-12 17:54:31 +00:00
|
|
|
grunt.loadNpmTasks("grunt-zip");
|
2016-12-14 16:39:17 +00:00
|
|
|
|
|
|
|
|
2017-03-27 15:08:36 +00:00
|
|
|
// Project configuration
|
2017-05-02 22:03:28 +00:00
|
|
|
const compileTime = grunt.template.today("UTC:dd/mm/yyyy HH:MM:ss") + " UTC",
|
2017-07-03 22:15:57 +00:00
|
|
|
pkg = grunt.file.readJSON("package.json"),
|
|
|
|
webpackConfig = require("./webpack.config.js"),
|
|
|
|
BUILD_CONSTANTS = {
|
|
|
|
COMPILE_TIME: JSON.stringify(compileTime),
|
|
|
|
COMPILE_MSG: JSON.stringify(grunt.option("compile-msg") || grunt.option("msg") || ""),
|
2017-09-19 23:37:57 +00:00
|
|
|
PKG_VERSION: JSON.stringify(pkg.version),
|
2017-08-09 19:09:23 +00:00
|
|
|
},
|
2019-08-02 10:10:15 +00:00
|
|
|
moduleEntryPoints = listEntryModules(),
|
2019-11-21 14:13:36 +00:00
|
|
|
nodeConsumerTestPath = "~/tmp-cyberchef",
|
|
|
|
/**
|
|
|
|
* Configuration for Webpack production build. Defined as a function so that it
|
|
|
|
* can be recalculated when new modules are generated.
|
|
|
|
*/
|
|
|
|
webpackProdConf = () => {
|
|
|
|
return {
|
|
|
|
mode: "production",
|
|
|
|
target: "web",
|
|
|
|
entry: Object.assign({
|
|
|
|
main: "./src/web/index.js"
|
|
|
|
}, moduleEntryPoints),
|
|
|
|
output: {
|
|
|
|
path: __dirname + "/build/prod",
|
|
|
|
filename: chunkData => {
|
|
|
|
return chunkData.chunk.name === "main" ? "assets/[name].js": "[name].js";
|
|
|
|
},
|
|
|
|
globalObject: "this"
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
"./config/modules/OpModules.mjs": "./config/modules/Default.mjs"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin(BUILD_CONSTANTS),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: "index.html",
|
|
|
|
template: "./src/web/html/index.html",
|
|
|
|
chunks: ["main"],
|
|
|
|
compileTime: compileTime,
|
|
|
|
version: pkg.version,
|
|
|
|
minify: {
|
|
|
|
removeComments: true,
|
|
|
|
collapseWhitespace: true,
|
|
|
|
minifyJS: true,
|
|
|
|
minifyCSS: true
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
new BundleAnalyzerPlugin({
|
|
|
|
analyzerMode: "static",
|
|
|
|
reportFilename: "BundleAnalyzerReport.html",
|
|
|
|
openAnalyzer: false
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
};
|
|
|
|
};
|
2016-11-28 10:42:58 +00:00
|
|
|
|
2016-12-14 16:39:17 +00:00
|
|
|
|
2017-08-09 19:09:23 +00:00
|
|
|
/**
|
|
|
|
* Generates an entry list for all the modules.
|
|
|
|
*/
|
|
|
|
function listEntryModules() {
|
2018-04-02 16:10:51 +00:00
|
|
|
const entryModules = {};
|
2017-08-09 19:09:23 +00:00
|
|
|
|
2018-03-26 22:14:23 +00:00
|
|
|
glob.sync("./src/core/config/modules/*.mjs").forEach(file => {
|
|
|
|
const basename = path.basename(file);
|
|
|
|
if (basename !== "Default.mjs" && basename !== "OpModules.mjs")
|
2019-04-12 17:54:31 +00:00
|
|
|
entryModules["modules/" + basename.split(".mjs")[0]] = path.resolve(file);
|
2017-08-09 19:09:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return entryModules;
|
|
|
|
}
|
|
|
|
|
2019-10-16 15:32:06 +00:00
|
|
|
/**
|
|
|
|
* Detects the correct delimiter to use to chain shell commands together
|
|
|
|
* based on the current OS.
|
|
|
|
*
|
|
|
|
* @param {string[]} cmds
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
function chainCommands(cmds) {
|
|
|
|
const win = process.platform === "win32";
|
|
|
|
if (!win) {
|
|
|
|
return cmds.join(";");
|
|
|
|
}
|
|
|
|
return cmds
|
|
|
|
// && means that subsequent commands will not be executed if the
|
|
|
|
// previous one fails. & would coninue on a fail
|
|
|
|
.join("&&")
|
|
|
|
// Windows does not support \n properly
|
2021-02-10 13:13:19 +00:00
|
|
|
.replace(/\n/g, "\\n");
|
2019-10-16 15:32:06 +00:00
|
|
|
}
|
|
|
|
|
2016-11-28 10:42:58 +00:00
|
|
|
grunt.initConfig({
|
2017-03-27 15:08:36 +00:00
|
|
|
clean: {
|
2018-03-26 21:25:36 +00:00
|
|
|
dev: ["build/dev/*"],
|
2018-03-26 22:14:23 +00:00
|
|
|
prod: ["build/prod/*"],
|
|
|
|
node: ["build/node/*"],
|
2019-07-09 13:31:18 +00:00
|
|
|
config: ["src/core/config/OperationConfig.json", "src/core/config/modules/*", "src/code/operations/index.mjs"],
|
|
|
|
nodeConfig: ["src/node/index.mjs", "src/node/config/OperationConfig.json"],
|
2019-04-12 17:54:31 +00:00
|
|
|
standalone: ["build/prod/CyberChef*.html"]
|
2017-03-27 15:08:36 +00:00
|
|
|
},
|
2016-12-14 16:39:17 +00:00
|
|
|
eslint: {
|
2018-12-29 23:46:13 +00:00
|
|
|
configs: ["*.{js,mjs}"],
|
2018-04-11 17:29:02 +00:00
|
|
|
core: ["src/core/**/*.{js,mjs}", "!src/core/vendor/**/*", "!src/core/operations/legacy/**/*"],
|
2019-03-27 23:02:10 +00:00
|
|
|
web: ["src/web/**/*.{js,mjs}", "!src/web/static/**/*"],
|
2018-03-26 22:14:23 +00:00
|
|
|
node: ["src/node/**/*.{js,mjs}"],
|
2018-12-28 21:49:40 +00:00
|
|
|
tests: ["tests/**/*.{js,mjs}"],
|
2016-11-28 10:42:58 +00:00
|
|
|
},
|
2017-03-21 22:41:44 +00:00
|
|
|
webpack: {
|
2017-07-03 22:15:57 +00:00
|
|
|
options: webpackConfig,
|
2019-11-21 14:13:36 +00:00
|
|
|
web: webpackProdConf(),
|
2017-03-21 22:41:44 +00:00
|
|
|
},
|
2017-07-03 22:15:57 +00:00
|
|
|
"webpack-dev-server": {
|
|
|
|
options: {
|
|
|
|
webpack: webpackConfig,
|
2017-09-22 16:05:15 +00:00
|
|
|
host: "0.0.0.0",
|
2020-01-27 18:55:50 +00:00
|
|
|
port: grunt.option("port") || 8080,
|
2017-09-22 16:05:15 +00:00
|
|
|
disableHostCheck: true,
|
2017-09-17 12:47:33 +00:00
|
|
|
overlay: true,
|
2017-09-22 16:05:15 +00:00
|
|
|
inline: false,
|
2017-09-17 12:47:33 +00:00
|
|
|
clientLogLevel: "error",
|
2017-07-03 22:15:57 +00:00
|
|
|
stats: {
|
|
|
|
children: false,
|
2017-09-17 12:47:33 +00:00
|
|
|
chunks: false,
|
|
|
|
modules: false,
|
2018-03-01 19:45:34 +00:00
|
|
|
entrypoints: false,
|
2018-10-10 15:49:07 +00:00
|
|
|
warningsFilter: [
|
|
|
|
/source-map/,
|
|
|
|
/dependency is an expression/,
|
2019-03-30 14:56:43 +00:00
|
|
|
/export 'default'/,
|
|
|
|
/Can't resolve 'sodium'/
|
2018-10-10 15:49:07 +00:00
|
|
|
],
|
2017-09-17 12:47:33 +00:00
|
|
|
}
|
2017-07-03 22:15:57 +00:00
|
|
|
},
|
|
|
|
start: {
|
|
|
|
webpack: {
|
2018-03-01 19:45:34 +00:00
|
|
|
mode: "development",
|
2017-07-03 22:15:57 +00:00
|
|
|
target: "web",
|
2017-08-09 19:09:23 +00:00
|
|
|
entry: Object.assign({
|
|
|
|
main: "./src/web/index.js"
|
|
|
|
}, moduleEntryPoints),
|
2017-08-24 23:25:49 +00:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
2019-07-09 12:42:42 +00:00
|
|
|
"./config/modules/OpModules.mjs": "./config/modules/Default.mjs"
|
2017-08-24 23:25:49 +00:00
|
|
|
}
|
|
|
|
},
|
2017-07-03 22:15:57 +00:00
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin(BUILD_CONSTANTS),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: "index.html",
|
|
|
|
template: "./src/web/html/index.html",
|
2017-08-09 19:09:23 +00:00
|
|
|
chunks: ["main"],
|
2017-07-03 22:15:57 +00:00
|
|
|
compileTime: compileTime,
|
|
|
|
version: pkg.version,
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-04-12 17:54:31 +00:00
|
|
|
zip: {
|
|
|
|
standalone: {
|
|
|
|
cwd: "build/prod/",
|
|
|
|
src: [
|
|
|
|
"build/prod/**/*",
|
|
|
|
"!build/prod/index.html",
|
|
|
|
"!build/prod/BundleAnalyzerReport.html",
|
|
|
|
],
|
|
|
|
dest: `build/prod/CyberChef_v${pkg.version}.zip`
|
|
|
|
}
|
|
|
|
},
|
2018-12-29 23:46:13 +00:00
|
|
|
connect: {
|
|
|
|
prod: {
|
|
|
|
options: {
|
2020-01-27 18:55:50 +00:00
|
|
|
port: grunt.option("port") || 8000,
|
2018-12-29 23:46:13 +00:00
|
|
|
base: "build/prod/"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2016-11-28 10:42:58 +00:00
|
|
|
copy: {
|
2017-01-31 18:24:56 +00:00
|
|
|
ghPages: {
|
2016-12-03 00:37:38 +00:00
|
|
|
options: {
|
2017-09-13 15:21:31 +00:00
|
|
|
process: function (content, srcpath) {
|
|
|
|
if (srcpath.indexOf("index.html") >= 0) {
|
2019-04-12 17:54:31 +00:00
|
|
|
// Add Google Analytics code to index.html
|
2017-09-13 15:21:31 +00:00
|
|
|
content = content.replace("</body></html>",
|
|
|
|
grunt.file.read("src/web/static/ga.html") + "</body></html>");
|
2019-04-12 17:54:31 +00:00
|
|
|
|
|
|
|
// Add Structured Data for SEO
|
|
|
|
content = content.replace("</head>",
|
|
|
|
"<script type='application/ld+json'>" +
|
2019-04-14 20:55:52 +00:00
|
|
|
JSON.stringify(JSON.parse(grunt.file.read("src/web/static/structuredData.json"))) +
|
|
|
|
"</script></head>");
|
2017-09-13 15:21:31 +00:00
|
|
|
return grunt.template.process(content, srcpath);
|
|
|
|
} else {
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
noProcess: ["**", "!**/*.html"]
|
2016-12-03 00:37:38 +00:00
|
|
|
},
|
2017-09-13 15:21:31 +00:00
|
|
|
files: [
|
|
|
|
{
|
2020-12-11 16:24:39 +00:00
|
|
|
src: ["build/prod/index.html"],
|
2017-09-13 15:21:31 +00:00
|
|
|
dest: "build/prod/index.html"
|
2019-08-28 17:48:31 +00:00
|
|
|
}
|
2017-09-13 15:21:31 +00:00
|
|
|
]
|
2019-04-12 17:54:31 +00:00
|
|
|
},
|
|
|
|
standalone: {
|
|
|
|
options: {
|
|
|
|
process: function (content, srcpath) {
|
|
|
|
if (srcpath.indexOf("index.html") >= 0) {
|
|
|
|
// Replace download link with version number
|
|
|
|
content = content.replace(/<a [^>]+>Download CyberChef.+?<\/a>/,
|
|
|
|
`<span>Version ${pkg.version}</span>`);
|
|
|
|
|
|
|
|
return grunt.template.process(content, srcpath);
|
|
|
|
} else {
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
noProcess: ["**", "!**/*.html"]
|
|
|
|
},
|
|
|
|
files: [
|
|
|
|
{
|
2020-12-11 16:24:39 +00:00
|
|
|
src: ["build/prod/index.html"],
|
2019-04-12 17:54:31 +00:00
|
|
|
dest: `build/prod/CyberChef_v${pkg.version}.html`
|
|
|
|
}
|
|
|
|
]
|
2016-11-28 10:42:58 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
chmod: {
|
|
|
|
build: {
|
|
|
|
options: {
|
|
|
|
mode: "755",
|
|
|
|
},
|
2017-03-27 15:08:36 +00:00
|
|
|
src: ["build/**/*", "build/"]
|
2016-11-28 10:42:58 +00:00
|
|
|
}
|
|
|
|
},
|
2018-05-06 11:24:01 +00:00
|
|
|
watch: {
|
|
|
|
config: {
|
|
|
|
files: ["src/core/operations/**/*", "!src/core/operations/index.mjs"],
|
2018-06-18 10:17:54 +00:00
|
|
|
tasks: ["exec:generateNodeIndex", "exec:generateConfig"]
|
2018-05-06 11:24:01 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
concurrent: {
|
|
|
|
dev: ["watch:config", "webpack-dev-server:start"],
|
|
|
|
options: {
|
|
|
|
logConcurrentOutput: true
|
|
|
|
}
|
|
|
|
},
|
2016-11-28 10:42:58 +00:00
|
|
|
exec: {
|
2017-01-31 18:24:56 +00:00
|
|
|
repoSize: {
|
2019-10-03 00:23:18 +00:00
|
|
|
command: chainCommands([
|
2016-12-14 16:39:17 +00:00
|
|
|
"git ls-files | wc -l | xargs printf '\n%b\ttracked files\n'",
|
|
|
|
"du -hs | egrep -o '^[^\t]*' | xargs printf '%b\trepository size\n'"
|
2019-10-03 00:23:18 +00:00
|
|
|
]),
|
2016-11-28 10:42:58 +00:00
|
|
|
stderr: false
|
|
|
|
},
|
2017-01-31 18:24:56 +00:00
|
|
|
cleanGit: {
|
2016-11-28 10:42:58 +00:00
|
|
|
command: "git gc --prune=now --aggressive"
|
|
|
|
},
|
2018-02-20 16:52:27 +00:00
|
|
|
sitemap: {
|
2022-01-31 11:39:17 +00:00
|
|
|
command: `node ${nodeFlags} src/web/static/sitemap.mjs > build/prod/sitemap.xml`,
|
2019-11-21 14:13:36 +00:00
|
|
|
sync: true
|
2018-03-26 22:14:23 +00:00
|
|
|
},
|
2018-04-11 18:08:42 +00:00
|
|
|
generateConfig: {
|
2019-10-03 00:23:18 +00:00
|
|
|
command: chainCommands([
|
2018-05-06 11:24:01 +00:00
|
|
|
"echo '\n--- Regenerating config files. ---'",
|
2019-02-11 18:44:41 +00:00
|
|
|
"echo [] > src/core/config/OperationConfig.json",
|
2022-01-31 11:39:17 +00:00
|
|
|
`node ${nodeFlags} src/core/config/scripts/generateOpsIndex.mjs`,
|
|
|
|
`node ${nodeFlags} src/core/config/scripts/generateConfig.mjs`,
|
2018-05-06 11:24:01 +00:00
|
|
|
"echo '--- Config scripts finished. ---\n'"
|
2019-11-21 14:13:36 +00:00
|
|
|
]),
|
|
|
|
sync: true
|
2018-04-11 18:08:42 +00:00
|
|
|
},
|
2018-06-06 08:13:26 +00:00
|
|
|
generateNodeIndex: {
|
2019-10-03 00:23:18 +00:00
|
|
|
command: chainCommands([
|
2018-06-06 08:13:26 +00:00
|
|
|
"echo '\n--- Regenerating node index ---'",
|
2022-01-31 11:39:17 +00:00
|
|
|
`node ${nodeFlags} src/node/config/scripts/generateNodeIndex.mjs`,
|
2018-06-19 07:53:29 +00:00
|
|
|
"echo '--- Node index generated. ---\n'"
|
2019-10-03 00:23:18 +00:00
|
|
|
]),
|
2019-11-21 14:13:36 +00:00
|
|
|
sync: true
|
2018-06-06 08:13:26 +00:00
|
|
|
},
|
2018-12-29 02:58:05 +00:00
|
|
|
browserTests: {
|
2019-04-12 17:54:31 +00:00
|
|
|
command: "./node_modules/.bin/nightwatch --env prod"
|
2019-01-04 09:27:32 +00:00
|
|
|
},
|
2019-08-02 10:10:15 +00:00
|
|
|
setupNodeConsumers: {
|
2019-10-03 00:23:18 +00:00
|
|
|
command: chainCommands([
|
2019-10-16 14:38:20 +00:00
|
|
|
"echo '\n--- Testing node consumers ---'",
|
2019-08-02 10:10:15 +00:00
|
|
|
"npm link",
|
|
|
|
`mkdir ${nodeConsumerTestPath}`,
|
|
|
|
`cp tests/node/consumers/* ${nodeConsumerTestPath}`,
|
|
|
|
`cd ${nodeConsumerTestPath}`,
|
|
|
|
"npm link cyberchef"
|
2019-10-03 00:23:18 +00:00
|
|
|
]),
|
2019-11-21 14:13:36 +00:00
|
|
|
sync: true
|
2019-08-02 10:10:15 +00:00
|
|
|
},
|
|
|
|
teardownNodeConsumers: {
|
2019-10-03 00:23:18 +00:00
|
|
|
command: chainCommands([
|
2019-08-02 10:10:15 +00:00
|
|
|
`rm -rf ${nodeConsumerTestPath}`,
|
|
|
|
"echo '\n--- Node consumer tests complete ---'"
|
2019-10-03 00:23:18 +00:00
|
|
|
]),
|
2019-08-02 10:10:15 +00:00
|
|
|
},
|
|
|
|
testCJSNodeConsumer: {
|
2019-10-03 00:23:18 +00:00
|
|
|
command: chainCommands([
|
2019-08-02 10:10:15 +00:00
|
|
|
`cd ${nodeConsumerTestPath}`,
|
2022-01-31 11:39:17 +00:00
|
|
|
`node ${nodeFlags} cjs-consumer.js`,
|
2019-10-03 00:23:18 +00:00
|
|
|
]),
|
2019-08-02 10:10:15 +00:00
|
|
|
stdout: false,
|
|
|
|
},
|
|
|
|
testESMNodeConsumer: {
|
2019-10-03 00:23:18 +00:00
|
|
|
command: chainCommands([
|
2019-08-02 10:10:15 +00:00
|
|
|
`cd ${nodeConsumerTestPath}`,
|
2022-01-31 11:39:17 +00:00
|
|
|
`node ${nodeFlags} esm-consumer.mjs`,
|
2019-10-03 00:23:18 +00:00
|
|
|
]),
|
2019-08-02 10:10:15 +00:00
|
|
|
stdout: false,
|
|
|
|
},
|
|
|
|
testESMDeepImportNodeConsumer: {
|
2019-10-03 00:23:18 +00:00
|
|
|
command: chainCommands([
|
2019-08-02 10:10:15 +00:00
|
|
|
`cd ${nodeConsumerTestPath}`,
|
2022-01-31 11:39:17 +00:00
|
|
|
`node ${nodeFlags} esm-deep-import-consumer.mjs`,
|
2019-10-03 00:23:18 +00:00
|
|
|
]),
|
2019-08-02 10:10:15 +00:00
|
|
|
stdout: false,
|
|
|
|
},
|
2021-02-03 19:07:39 +00:00
|
|
|
fixCryptoApiImports: {
|
|
|
|
command: [
|
|
|
|
`[[ "$OSTYPE" == "darwin"* ]]`,
|
|
|
|
"&&",
|
|
|
|
`find ./node_modules/crypto-api/src/ \\( -type d -name .git -prune \\) -o -type f -print0 | xargs -0 sed -i '' -e '/\\.mjs/!s/\\(from "\\.[^"]*\\)";/\\1.mjs";/g'`,
|
|
|
|
"||",
|
|
|
|
`find ./node_modules/crypto-api/src/ \\( -type d -name .git -prune \\) -o -type f -print0 | xargs -0 sed -i -e '/\\.mjs/!s/\\(from "\\.[^"]*\\)";/\\1.mjs";/g'`
|
|
|
|
].join(" "),
|
|
|
|
stdout: false
|
|
|
|
}
|
2017-02-28 17:08:36 +00:00
|
|
|
},
|
2016-11-28 10:42:58 +00:00
|
|
|
});
|
|
|
|
};
|