@eagleoutice/flowr 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/abstract-interpretation/processor.js +9 -3
- package/config.d.ts +16 -0
- package/config.js +75 -0
- package/core/input.d.ts +1 -1
- package/core/output.d.ts +1 -2
- package/core/print/parse-printer.d.ts +1 -2
- package/core/print/parse-printer.js +6 -4
- package/core/print/slice-diff-ansi.js +7 -7
- package/core/slicer.js +4 -8
- package/core/steps.d.ts +355 -31
- package/core/steps.js +7 -14
- package/dataflow/environments/environment.js +8 -0
- package/dataflow/environments/register.js +1 -0
- package/dataflow/extractor.d.ts +2 -2
- package/dataflow/extractor.js +10 -2
- package/dataflow/internal/process/functions/function-call.js +7 -1
- package/dataflow/internal/process/functions/source.d.ts +8 -0
- package/dataflow/internal/process/functions/source.js +81 -0
- package/dataflow/processor.d.ts +10 -1
- package/index.d.ts +0 -2
- package/index.js +0 -2
- package/package.json +75 -202
- package/r-bridge/lang-4.x/ast/index.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/index.js +3 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +6 -1
- package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +14 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +26 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +7 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +57 -0
- package/r-bridge/lang-4.x/ast/parser/xml/data.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/xml/index.d.ts +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/index.js +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +5 -1
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +7 -10
- package/r-bridge/lang-4.x/ast/parser/xml/internal/access.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.js +3 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.d.ts +6 -11
- package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.js +15 -23
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.js +6 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.js +3 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.js +4 -4
- package/r-bridge/lang-4.x/values.d.ts +0 -1
- package/r-bridge/lang-4.x/values.js +14 -6
- package/r-bridge/retriever.d.ts +25 -21
- package/r-bridge/retriever.js +73 -23
- package/r-bridge/shell-executor.d.ts +3 -17
- package/r-bridge/shell-executor.js +9 -78
- package/r-bridge/shell.d.ts +5 -27
- package/r-bridge/shell.js +31 -92
- package/{statistics/output → util}/ansi.js +1 -1
- package/util/args.d.ts +8 -4
- package/util/args.js +11 -4
- package/util/cfg/visitor.js +1 -1
- package/util/files.d.ts +6 -0
- package/util/files.js +11 -1
- package/util/log.js +3 -0
- package/util/{summarizer/summarizer.d.ts → summarizer.d.ts} +15 -1
- package/util/summarizer.js +37 -0
- package/util/version.d.ts +2 -0
- package/util/version.js +10 -0
- package/benchmark/index.d.ts +0 -3
- package/benchmark/index.js +0 -20
- package/benchmark/slicer.d.ts +0 -101
- package/benchmark/slicer.js +0 -225
- package/benchmark/stats/index.d.ts +0 -10
- package/benchmark/stats/index.js +0 -27
- package/benchmark/stats/print.d.ts +0 -7
- package/benchmark/stats/print.js +0 -157
- package/benchmark/stats/stats.d.ts +0 -41
- package/benchmark/stats/stats.js +0 -6
- package/benchmark/stopwatch.d.ts +0 -35
- package/benchmark/stopwatch.js +0 -79
- package/cli/benchmark-app.d.ts +0 -9
- package/cli/benchmark-app.js +0 -52
- package/cli/benchmark-helper-app.d.ts +0 -7
- package/cli/benchmark-helper-app.js +0 -60
- package/cli/common/features.d.ts +0 -3
- package/cli/common/features.js +0 -30
- package/cli/common/index.d.ts +0 -2
- package/cli/common/index.js +0 -19
- package/cli/common/options.d.ts +0 -20
- package/cli/common/options.js +0 -82
- package/cli/common/script.d.ts +0 -21
- package/cli/common/script.js +0 -61
- package/cli/common/scripts-info.d.ts +0 -24
- package/cli/common/scripts-info.js +0 -69
- package/cli/export-quads-app.d.ts +0 -7
- package/cli/export-quads-app.js +0 -46
- package/cli/repl/commands/cfg.d.ts +0 -3
- package/cli/repl/commands/cfg.js +0 -37
- package/cli/repl/commands/commands.d.ts +0 -11
- package/cli/repl/commands/commands.js +0 -103
- package/cli/repl/commands/dataflow.d.ts +0 -3
- package/cli/repl/commands/dataflow.js +0 -34
- package/cli/repl/commands/execute.d.ts +0 -4
- package/cli/repl/commands/execute.js +0 -27
- package/cli/repl/commands/index.d.ts +0 -2
- package/cli/repl/commands/index.js +0 -19
- package/cli/repl/commands/main.d.ts +0 -39
- package/cli/repl/commands/main.js +0 -14
- package/cli/repl/commands/normalize.d.ts +0 -3
- package/cli/repl/commands/normalize.js +0 -34
- package/cli/repl/commands/parse.d.ts +0 -2
- package/cli/repl/commands/parse.js +0 -109
- package/cli/repl/commands/quit.d.ts +0 -2
- package/cli/repl/commands/quit.js +0 -12
- package/cli/repl/commands/version.d.ts +0 -16
- package/cli/repl/commands/version.js +0 -33
- package/cli/repl/core.d.ts +0 -39
- package/cli/repl/core.js +0 -116
- package/cli/repl/execute.d.ts +0 -28
- package/cli/repl/execute.js +0 -79
- package/cli/repl/index.d.ts +0 -5
- package/cli/repl/index.js +0 -22
- package/cli/repl/prompt.d.ts +0 -2
- package/cli/repl/prompt.js +0 -9
- package/cli/repl/server/connection.d.ts +0 -21
- package/cli/repl/server/connection.js +0 -218
- package/cli/repl/server/messages/analysis.d.ts +0 -71
- package/cli/repl/server/messages/analysis.js +0 -21
- package/cli/repl/server/messages/error.d.ts +0 -11
- package/cli/repl/server/messages/error.js +0 -3
- package/cli/repl/server/messages/hello.d.ts +0 -20
- package/cli/repl/server/messages/hello.js +0 -3
- package/cli/repl/server/messages/index.d.ts +0 -1
- package/cli/repl/server/messages/index.js +0 -3
- package/cli/repl/server/messages/messages.d.ts +0 -35
- package/cli/repl/server/messages/messages.js +0 -40
- package/cli/repl/server/messages/repl.d.ts +0 -33
- package/cli/repl/server/messages/repl.js +0 -37
- package/cli/repl/server/messages/slice.d.ts +0 -25
- package/cli/repl/server/messages/slice.js +0 -37
- package/cli/repl/server/net.d.ts +0 -49
- package/cli/repl/server/net.js +0 -63
- package/cli/repl/server/send.d.ts +0 -4
- package/cli/repl/server/send.js +0 -18
- package/cli/repl/server/server.d.ts +0 -20
- package/cli/repl/server/server.js +0 -66
- package/cli/repl/server/validate.d.ts +0 -15
- package/cli/repl/server/validate.js +0 -34
- package/cli/slicer-app.d.ts +0 -11
- package/cli/slicer-app.js +0 -81
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -98
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -83
- package/cli/summarizer-app.d.ts +0 -18
- package/cli/summarizer-app.js +0 -67
- package/flowr.d.ts +0 -27
- package/flowr.js +0 -137
- package/r-bridge/lang-4.x/ast/parser/xml/config.d.ts +0 -25
- package/r-bridge/lang-4.x/ast/parser/xml/config.js +0 -16
- package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.d.ts +0 -9
- package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.js +0 -51
- package/r-bridge/lang-4.x/ast/parser/xml/parser.d.ts +0 -17
- package/r-bridge/lang-4.x/ast/parser/xml/parser.js +0 -30
- package/statistics/features/common-syntax-probability.d.ts +0 -31
- package/statistics/features/common-syntax-probability.js +0 -156
- package/statistics/features/feature.d.ts +0 -175
- package/statistics/features/feature.js +0 -30
- package/statistics/features/index.d.ts +0 -1
- package/statistics/features/index.js +0 -18
- package/statistics/features/post-processing.d.ts +0 -12
- package/statistics/features/post-processing.js +0 -21
- package/statistics/features/supported/assignments/assignments.d.ts +0 -11
- package/statistics/features/supported/assignments/assignments.js +0 -53
- package/statistics/features/supported/assignments/index.d.ts +0 -1
- package/statistics/features/supported/assignments/index.js +0 -6
- package/statistics/features/supported/assignments/post-process.d.ts +0 -3
- package/statistics/features/supported/assignments/post-process.js +0 -125
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -133
- package/statistics/features/supported/comments/index.d.ts +0 -1
- package/statistics/features/supported/comments/index.js +0 -6
- package/statistics/features/supported/comments/post-process.d.ts +0 -3
- package/statistics/features/supported/comments/post-process.js +0 -50
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -67
- package/statistics/features/supported/control-flow/index.d.ts +0 -1
- package/statistics/features/supported/control-flow/index.js +0 -6
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -3
- package/statistics/features/supported/control-flow/post-process.js +0 -65
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -118
- package/statistics/features/supported/data-access/index.d.ts +0 -1
- package/statistics/features/supported/data-access/index.js +0 -6
- package/statistics/features/supported/data-access/post-process.d.ts +0 -3
- package/statistics/features/supported/data-access/post-process.js +0 -107
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -35
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -139
- package/statistics/features/supported/defined-functions/index.d.ts +0 -1
- package/statistics/features/supported/defined-functions/index.js +0 -6
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -177
- package/statistics/features/supported/expression-list/expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/expression-list.js +0 -36
- package/statistics/features/supported/expression-list/index.d.ts +0 -1
- package/statistics/features/supported/expression-list/index.js +0 -6
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -3
- package/statistics/features/supported/expression-list/post-process.js +0 -44
- package/statistics/features/supported/index.d.ts +0 -10
- package/statistics/features/supported/index.js +0 -27
- package/statistics/features/supported/loops/index.d.ts +0 -1
- package/statistics/features/supported/loops/index.js +0 -6
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -79
- package/statistics/features/supported/loops/post-process.d.ts +0 -3
- package/statistics/features/supported/loops/post-process.js +0 -72
- package/statistics/features/supported/used-functions/index.d.ts +0 -1
- package/statistics/features/supported/used-functions/index.js +0 -6
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -179
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -95
- package/statistics/features/supported/used-packages/index.d.ts +0 -1
- package/statistics/features/supported/used-packages/index.js +0 -6
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -3
- package/statistics/features/supported/used-packages/post-process.js +0 -121
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -130
- package/statistics/features/supported/values/index.d.ts +0 -1
- package/statistics/features/supported/values/index.js +0 -6
- package/statistics/features/supported/values/post-process.d.ts +0 -3
- package/statistics/features/supported/values/post-process.js +0 -72
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -101
- package/statistics/features/supported/variables/index.d.ts +0 -1
- package/statistics/features/supported/variables/index.js +0 -6
- package/statistics/features/supported/variables/post-process.d.ts +0 -9
- package/statistics/features/supported/variables/post-process.js +0 -122
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -70
- package/statistics/index.d.ts +0 -6
- package/statistics/index.js +0 -24
- package/statistics/meta-statistics.d.ts +0 -33
- package/statistics/meta-statistics.js +0 -17
- package/statistics/output/file-provider.d.ts +0 -37
- package/statistics/output/file-provider.js +0 -97
- package/statistics/output/index.d.ts +0 -4
- package/statistics/output/index.js +0 -21
- package/statistics/output/print-stats.d.ts +0 -17
- package/statistics/output/print-stats.js +0 -69
- package/statistics/output/statistics-file.d.ts +0 -37
- package/statistics/output/statistics-file.js +0 -69
- package/statistics/statistics.d.ts +0 -24
- package/statistics/statistics.js +0 -109
- package/util/summarizer/auto-detect.d.ts +0 -2
- package/util/summarizer/auto-detect.js +0 -32
- package/util/summarizer/benchmark/data.d.ts +0 -66
- package/util/summarizer/benchmark/data.js +0 -13
- package/util/summarizer/benchmark/first-phase/input.d.ts +0 -2
- package/util/summarizer/benchmark/first-phase/input.js +0 -59
- package/util/summarizer/benchmark/first-phase/process.d.ts +0 -10
- package/util/summarizer/benchmark/first-phase/process.js +0 -208
- package/util/summarizer/benchmark/second-phase/graph.d.ts +0 -2
- package/util/summarizer/benchmark/second-phase/graph.js +0 -54
- package/util/summarizer/benchmark/second-phase/process.d.ts +0 -4
- package/util/summarizer/benchmark/second-phase/process.js +0 -89
- package/util/summarizer/benchmark/summarizer.d.ts +0 -35
- package/util/summarizer/benchmark/summarizer.js +0 -49
- package/util/summarizer/statistics/first-phase/process.d.ts +0 -6
- package/util/summarizer/statistics/first-phase/process.js +0 -81
- package/util/summarizer/statistics/post-process/clusterer.d.ts +0 -26
- package/util/summarizer/statistics/post-process/clusterer.js +0 -43
- package/util/summarizer/statistics/post-process/file-based-count.d.ts +0 -17
- package/util/summarizer/statistics/post-process/file-based-count.js +0 -49
- package/util/summarizer/statistics/post-process/histogram.d.ts +0 -59
- package/util/summarizer/statistics/post-process/histogram.js +0 -128
- package/util/summarizer/statistics/post-process/index.d.ts +0 -4
- package/util/summarizer/statistics/post-process/index.js +0 -21
- package/util/summarizer/statistics/post-process/post-process-output.d.ts +0 -16
- package/util/summarizer/statistics/post-process/post-process-output.js +0 -104
- package/util/summarizer/statistics/second-phase/process.d.ts +0 -11
- package/util/summarizer/statistics/second-phase/process.js +0 -117
- package/util/summarizer/statistics/summarizer.d.ts +0 -35
- package/util/summarizer/statistics/summarizer.js +0 -135
- package/util/summarizer/summarizer.js +0 -13
- /package/{statistics/output → util}/ansi.d.ts +0 -0
|
@@ -10,107 +10,38 @@ const child_process_1 = require("child_process");
|
|
|
10
10
|
const lang_4_x_1 = require("./lang-4.x");
|
|
11
11
|
const preload_1 = __importDefault(require("semver/preload"));
|
|
12
12
|
const log_1 = require("../util/log");
|
|
13
|
-
const
|
|
14
|
-
const retriever_1 = require("./retriever");
|
|
13
|
+
const executorLog = log_1.log.getSubLogger({ name: 'RShellExecutor' });
|
|
15
14
|
class RShellExecutor {
|
|
16
15
|
options;
|
|
17
|
-
log;
|
|
18
16
|
prerequisites = [];
|
|
19
17
|
constructor(options) {
|
|
20
18
|
this.options = (0, objects_1.deepMergeObject)(shell_1.DEFAULT_R_SHELL_OPTIONS, options);
|
|
21
|
-
this.log = log_1.log.getSubLogger({ name: 'RShellExecutor' });
|
|
22
19
|
}
|
|
23
20
|
continueOnError() {
|
|
24
|
-
|
|
21
|
+
executorLog.info('continue in case of Errors');
|
|
25
22
|
this.addPrerequisites('options(error=function() {})');
|
|
26
23
|
return this;
|
|
27
24
|
}
|
|
28
|
-
injectLibPaths(...paths) {
|
|
29
|
-
this.log.debug(`injecting lib paths ${JSON.stringify(paths)}`);
|
|
30
|
-
this.addPrerequisites(`.libPaths(c(.libPaths(), ${paths.map(lang_4_x_1.ts2r).join(',')}))`);
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
tryToInjectHomeLibPath() {
|
|
34
|
-
if (this.options.homeLibPath === undefined) {
|
|
35
|
-
this.log.debug('ensuring home lib path exists (automatic inject)');
|
|
36
|
-
this.addPrerequisites([
|
|
37
|
-
'if(!dir.exists(Sys.getenv("R_LIBS_USER"))) { dir.create(path=Sys.getenv("R_LIBS_USER"),showWarnings=FALSE,recursive=TRUE) }',
|
|
38
|
-
'.libPaths(c(.libPaths(), Sys.getenv("R_LIBS_USER")))'
|
|
39
|
-
]);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
this.injectLibPaths(this.options.homeLibPath);
|
|
43
|
-
}
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
25
|
addPrerequisites(commands) {
|
|
47
26
|
this.prerequisites.push(...(typeof commands == 'string' ? [commands] : commands));
|
|
48
27
|
return this;
|
|
49
28
|
}
|
|
50
29
|
usedRVersion() {
|
|
51
30
|
const version = this.run(`cat(paste0(R.version$major,".",R.version$minor), ${(0, lang_4_x_1.ts2r)(this.options.eol)})`);
|
|
52
|
-
|
|
31
|
+
executorLog.trace(`raw version: ${JSON.stringify(version)}`);
|
|
53
32
|
return preload_1.default.coerce(version);
|
|
54
33
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
isPackageInstalled(packageName) {
|
|
61
|
-
this.log.debug(`checking if package "${packageName}" is installed`);
|
|
62
|
-
return this.run(`cat(system.file(package="${packageName}")!="","${this.options.eol}")`) === 'TRUE';
|
|
63
|
-
}
|
|
64
|
-
ensurePackageInstalled(packageName, autoload = false, force = false) {
|
|
65
|
-
const packageExistedAlready = this.isPackageInstalled(packageName);
|
|
66
|
-
if (!force && packageExistedAlready) {
|
|
67
|
-
this.log.info(`package "${packageName}" is already installed`);
|
|
68
|
-
if (autoload)
|
|
69
|
-
this.addPrerequisites(`library(${(0, lang_4_x_1.ts2r)(packageName)})`);
|
|
70
|
-
return { packageName, packageExistedAlready };
|
|
34
|
+
run(command, returnErr = false) {
|
|
35
|
+
command += ';base::quit()';
|
|
36
|
+
if (executorLog.settings.minLevel >= 1 /* LogLevel.Trace */) {
|
|
37
|
+
executorLog.trace(`> ${JSON.stringify(command)}`);
|
|
71
38
|
}
|
|
72
|
-
const tempDir = this.obtainTempDir();
|
|
73
|
-
this.log.debug(`using temporary directory: "${tempDir}" to install package "${packageName}"`);
|
|
74
|
-
this.run(`install.packages(${(0, lang_4_x_1.ts2r)(packageName)},repos="https://cloud.r-project.org/",quiet=FALSE,lib=temp)`);
|
|
75
|
-
if (autoload)
|
|
76
|
-
this.addPrerequisites(`library(${(0, lang_4_x_1.ts2r)(packageName)},lib.loc=temp)`);
|
|
77
|
-
return { packageName, packageExistedAlready, libraryLocation: tempDir };
|
|
78
|
-
}
|
|
79
|
-
obtainTempDir() {
|
|
80
|
-
const tempDir = this.run([
|
|
81
|
-
'temp <- tempdir()',
|
|
82
|
-
`cat(temp, ${(0, lang_4_x_1.ts2r)(this.options.eol)})`
|
|
83
|
-
]);
|
|
84
|
-
log_1.log.info(`obtained temp dir ${tempDir}`);
|
|
85
|
-
const deleteOnExit = function () {
|
|
86
|
-
if (fs_1.default.existsSync(tempDir)) {
|
|
87
|
-
log_1.log.info(`deleting temp dir ${tempDir}`);
|
|
88
|
-
fs_1.default.rmSync(tempDir, { recursive: true, force: true });
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
process.on('SIGINT', deleteOnExit);
|
|
92
|
-
process.on('SIGTERM', deleteOnExit);
|
|
93
|
-
return tempDir;
|
|
94
|
-
}
|
|
95
|
-
getTokenMap() {
|
|
96
|
-
this.ensurePackageInstalled('xmlparsedata', true);
|
|
97
|
-
// we invert the token map to get a mapping back from the replacement
|
|
98
|
-
const parsed = (0, lang_4_x_1.parseCSV)(this.run('write.table(xmlparsedata::xml_parse_token_map,sep=",",col.names=FALSE)').split('\n'));
|
|
99
|
-
if (parsed.some(s => s.length !== 2))
|
|
100
|
-
throw new Error(`Expected two columns in token map, but got ${JSON.stringify(parsed)}`);
|
|
101
|
-
// we swap key and value to get the other direction, furthermore we remove quotes from keys if they are quoted
|
|
102
|
-
const ret = {};
|
|
103
|
-
for (const [key, value] of parsed)
|
|
104
|
-
ret[value] = (0, retriever_1.removeTokenMapQuotationMarks)(key);
|
|
105
|
-
return ret;
|
|
106
|
-
}
|
|
107
|
-
run(commands, returnErr = false) {
|
|
108
|
-
this.log.trace(`> ${JSON.stringify(commands)}`);
|
|
109
39
|
const returns = (0, child_process_1.spawnSync)(this.options.pathToRExecutable, this.options.commandLineOptions, {
|
|
110
40
|
env: this.options.env,
|
|
111
41
|
cwd: this.options.cwd,
|
|
42
|
+
windowsHide: true,
|
|
112
43
|
encoding: 'utf8',
|
|
113
|
-
input: [...this.prerequisites,
|
|
44
|
+
input: [...this.prerequisites, command].join(this.options.eol)
|
|
114
45
|
});
|
|
115
46
|
return (returnErr ? returns.stderr : returns.stdout).trim();
|
|
116
47
|
}
|
package/r-bridge/shell.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { type MergeableRecord } from '../util/objects';
|
|
3
3
|
import type { SemVer } from 'semver';
|
|
4
|
-
import type { TokenMap } from './retriever';
|
|
5
4
|
export type OutputStreamSelector = 'stdout' | 'stderr' | 'both';
|
|
6
5
|
export interface CollectorTimeout extends MergeableRecord {
|
|
7
6
|
/**
|
|
@@ -60,6 +59,7 @@ export interface RShellSessionOptions extends RShellExecutionOptions {
|
|
|
60
59
|
export interface RShellOptions extends RShellSessionOptions {
|
|
61
60
|
readonly sessionName: string;
|
|
62
61
|
}
|
|
62
|
+
export declare const DEFAULT_R_PATH: string;
|
|
63
63
|
export declare const DEFAULT_R_SHELL_EXEC_OPTIONS: RShellExecutionOptions;
|
|
64
64
|
export declare const DEFAULT_R_SHELL_OPTIONS: RShellOptions;
|
|
65
65
|
/**
|
|
@@ -75,7 +75,6 @@ export declare class RShell {
|
|
|
75
75
|
private session;
|
|
76
76
|
private readonly log;
|
|
77
77
|
private versionCache;
|
|
78
|
-
private tokenMapCache;
|
|
79
78
|
private tempDirs;
|
|
80
79
|
constructor(options?: Partial<RShellOptions>);
|
|
81
80
|
private revive;
|
|
@@ -85,13 +84,12 @@ export declare class RShell {
|
|
|
85
84
|
*/
|
|
86
85
|
sendCommand(command: string): void;
|
|
87
86
|
usedRVersion(): Promise<SemVer | null>;
|
|
87
|
+
injectLibPaths(...paths: string[]): void;
|
|
88
|
+
tryToInjectHomeLibPath(): void;
|
|
88
89
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @note For multiple calls, this makes use of caching
|
|
90
|
+
* checks if a given package is already installed on the system!
|
|
92
91
|
*/
|
|
93
|
-
|
|
94
|
-
private retrieveTokenMap;
|
|
92
|
+
isPackageInstalled(packageName: string): Promise<boolean>;
|
|
95
93
|
/**
|
|
96
94
|
* Send a command and collect the output
|
|
97
95
|
*
|
|
@@ -115,26 +113,6 @@ export declare class RShell {
|
|
|
115
113
|
* continue working!
|
|
116
114
|
*/
|
|
117
115
|
continueOnError(): void;
|
|
118
|
-
injectLibPaths(...paths: string[]): void;
|
|
119
|
-
tryToInjectHomeLibPath(): void;
|
|
120
|
-
/**
|
|
121
|
-
* checks if a given package is already installed on the system!
|
|
122
|
-
*/
|
|
123
|
-
isPackageInstalled(packageName: string): Promise<boolean>;
|
|
124
|
-
allInstalledPackages(): Promise<string[]>;
|
|
125
|
-
/**
|
|
126
|
-
* Installs the package using a temporary location
|
|
127
|
-
*
|
|
128
|
-
* @param packageName - The package to install
|
|
129
|
-
* @param autoload - If true, the package will be loaded after installation
|
|
130
|
-
* @param force - If true, the package will be installed no if it is already on the system and ready to be loaded
|
|
131
|
-
*/
|
|
132
|
-
ensurePackageInstalled(packageName: string, autoload?: boolean, force?: boolean): Promise<{
|
|
133
|
-
packageName: string;
|
|
134
|
-
packageExistedAlready: boolean;
|
|
135
|
-
/** the temporary directory used for the installation, undefined if none was used */
|
|
136
|
-
libraryLocation?: string;
|
|
137
|
-
}>;
|
|
138
116
|
/**
|
|
139
117
|
* Obtain the temporary directory used by R.
|
|
140
118
|
* Additionally, this marks the directory for removal when the shell exits.
|
package/r-bridge/shell.js
CHANGED
|
@@ -26,16 +26,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.RShell = exports.DEFAULT_R_SHELL_OPTIONS = exports.DEFAULT_R_SHELL_EXEC_OPTIONS = exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = void 0;
|
|
29
|
+
exports.RShell = exports.DEFAULT_R_SHELL_OPTIONS = exports.DEFAULT_R_SHELL_EXEC_OPTIONS = exports.DEFAULT_R_PATH = exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = void 0;
|
|
30
30
|
const child_process_1 = require("child_process");
|
|
31
31
|
const objects_1 = require("../util/objects");
|
|
32
|
-
const readline = __importStar(require("
|
|
32
|
+
const readline = __importStar(require("readline"));
|
|
33
33
|
const lang_4_x_1 = require("./lang-4.x");
|
|
34
34
|
const log_1 = require("../util/log");
|
|
35
35
|
const preload_1 = __importDefault(require("semver/preload"));
|
|
36
36
|
const os_1 = require("../util/os");
|
|
37
37
|
const fs_1 = __importDefault(require("fs"));
|
|
38
|
-
const
|
|
38
|
+
const config_1 = require("../config");
|
|
39
39
|
exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
|
|
40
40
|
from: 'stdout',
|
|
41
41
|
postamble: `🐧${'-'.repeat(5)}🐧`,
|
|
@@ -47,13 +47,14 @@ exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
|
|
|
47
47
|
automaticallyTrimOutput: true,
|
|
48
48
|
errorStopsWaiting: true
|
|
49
49
|
};
|
|
50
|
+
exports.DEFAULT_R_PATH = (0, os_1.getPlatform)() === 'windows' ? 'R.exe' : 'R';
|
|
50
51
|
exports.DEFAULT_R_SHELL_EXEC_OPTIONS = {
|
|
51
|
-
pathToRExecutable: (0,
|
|
52
|
+
pathToRExecutable: (0, config_1.getConfig)().rPath ?? exports.DEFAULT_R_PATH,
|
|
52
53
|
commandLineOptions: ['--vanilla', '--quiet', '--no-echo', '--no-save'],
|
|
53
54
|
cwd: process.cwd(),
|
|
54
55
|
env: process.env,
|
|
55
56
|
eol: '\n',
|
|
56
|
-
homeLibPath: (0, os_1.getPlatform)() === 'windows' ? undefined : '~/.r-libs'
|
|
57
|
+
homeLibPath: (0, os_1.getPlatform)() === 'windows' ? undefined : '~/.r-libs'
|
|
57
58
|
};
|
|
58
59
|
exports.DEFAULT_R_SHELL_OPTIONS = {
|
|
59
60
|
...exports.DEFAULT_R_SHELL_EXEC_OPTIONS,
|
|
@@ -74,7 +75,6 @@ class RShell {
|
|
|
74
75
|
session;
|
|
75
76
|
log;
|
|
76
77
|
versionCache = null;
|
|
77
|
-
tokenMapCache = null;
|
|
78
78
|
// should never be more than one, but let's be sure
|
|
79
79
|
tempDirs = new Set();
|
|
80
80
|
constructor(options) {
|
|
@@ -116,30 +116,28 @@ class RShell {
|
|
|
116
116
|
this.versionCache = preload_1.default.coerce(result[0]);
|
|
117
117
|
return result.length === 1 ? this.versionCache : null;
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* @note For multiple calls, this makes use of caching
|
|
123
|
-
*/
|
|
124
|
-
async tokenMap() {
|
|
125
|
-
if (this.tokenMapCache === null) {
|
|
126
|
-
this.tokenMapCache = await this.retrieveTokenMap();
|
|
127
|
-
}
|
|
128
|
-
return this.tokenMapCache;
|
|
119
|
+
injectLibPaths(...paths) {
|
|
120
|
+
this.log.debug(`injecting lib paths ${JSON.stringify(paths)}`);
|
|
121
|
+
this._sendCommand(`.libPaths(c(.libPaths(), ${paths.map(lang_4_x_1.ts2r).join(',')}))`);
|
|
129
122
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
123
|
+
tryToInjectHomeLibPath() {
|
|
124
|
+
// ensure the path exists first
|
|
125
|
+
if (this.options.homeLibPath === undefined) {
|
|
126
|
+
this.log.debug('ensuring home lib path exists (automatic inject)');
|
|
127
|
+
this.sendCommand('if(!dir.exists(Sys.getenv("R_LIBS_USER"))) { dir.create(path=Sys.getenv("R_LIBS_USER"),showWarnings=FALSE,recursive=TRUE) }');
|
|
128
|
+
this.sendCommand('.libPaths(c(.libPaths(), Sys.getenv("R_LIBS_USER")))');
|
|
136
129
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
for (const [key, value] of parsed) {
|
|
140
|
-
cache[value] = (0, retriever_1.removeTokenMapQuotationMarks)(key);
|
|
130
|
+
else {
|
|
131
|
+
this.injectLibPaths(this.options.homeLibPath);
|
|
141
132
|
}
|
|
142
|
-
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* checks if a given package is already installed on the system!
|
|
136
|
+
*/
|
|
137
|
+
async isPackageInstalled(packageName) {
|
|
138
|
+
this.log.debug(`checking if package "${packageName}" is installed`);
|
|
139
|
+
const result = await this.sendCommandWithOutput(`cat(system.file(package="${packageName}")!="","${this.options.eol}")`);
|
|
140
|
+
return result.length === 1 && result[0] === 'TRUE';
|
|
143
141
|
}
|
|
144
142
|
/**
|
|
145
143
|
* Send a command and collect the output
|
|
@@ -197,69 +195,6 @@ class RShell {
|
|
|
197
195
|
this.log.info('continue in case of Errors');
|
|
198
196
|
this._sendCommand('options(error=function() {})');
|
|
199
197
|
}
|
|
200
|
-
injectLibPaths(...paths) {
|
|
201
|
-
this.log.debug(`injecting lib paths ${JSON.stringify(paths)}`);
|
|
202
|
-
this._sendCommand(`.libPaths(c(.libPaths(), ${paths.map(lang_4_x_1.ts2r).join(',')}))`);
|
|
203
|
-
}
|
|
204
|
-
tryToInjectHomeLibPath() {
|
|
205
|
-
// ensure the path exists first
|
|
206
|
-
if (this.options.homeLibPath === undefined) {
|
|
207
|
-
this.log.debug('ensuring home lib path exists (automatic inject)');
|
|
208
|
-
this.sendCommand('if(!dir.exists(Sys.getenv("R_LIBS_USER"))) { dir.create(path=Sys.getenv("R_LIBS_USER"),showWarnings=FALSE,recursive=TRUE) }');
|
|
209
|
-
this.sendCommand('.libPaths(c(.libPaths(), Sys.getenv("R_LIBS_USER")))');
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
this.injectLibPaths(this.options.homeLibPath);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* checks if a given package is already installed on the system!
|
|
217
|
-
*/
|
|
218
|
-
async isPackageInstalled(packageName) {
|
|
219
|
-
this.log.debug(`checking if package "${packageName}" is installed`);
|
|
220
|
-
const result = await this.sendCommandWithOutput(`cat(system.file(package="${packageName}")!="","${this.options.eol}")`);
|
|
221
|
-
return result.length === 1 && result[0] === 'TRUE';
|
|
222
|
-
}
|
|
223
|
-
async allInstalledPackages() {
|
|
224
|
-
this.log.debug('getting all installed packages');
|
|
225
|
-
const [packages] = await this.sendCommandWithOutput(`cat(paste0(installed.packages()[,1], collapse=","),"${this.options.eol}")`);
|
|
226
|
-
return packages.split(',');
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Installs the package using a temporary location
|
|
230
|
-
*
|
|
231
|
-
* @param packageName - The package to install
|
|
232
|
-
* @param autoload - If true, the package will be loaded after installation
|
|
233
|
-
* @param force - If true, the package will be installed no if it is already on the system and ready to be loaded
|
|
234
|
-
*/
|
|
235
|
-
async ensurePackageInstalled(packageName, autoload = false, force = false) {
|
|
236
|
-
const packageExistedAlready = await this.isPackageInstalled(packageName);
|
|
237
|
-
if (!force && packageExistedAlready) {
|
|
238
|
-
this.log.info(`package "${packageName}" is already installed`);
|
|
239
|
-
if (autoload) {
|
|
240
|
-
this.sendCommand(`library(${(0, lang_4_x_1.ts2r)(packageName)})`);
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
packageName,
|
|
244
|
-
packageExistedAlready: true
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
// obtain a temporary directory
|
|
248
|
-
const tempdir = await this.obtainTmpDir();
|
|
249
|
-
this.log.debug(`using temporary directory: "${tempdir}" to install package "${packageName}"`);
|
|
250
|
-
await this.sendCommandWithOutput(`install.packages(${(0, lang_4_x_1.ts2r)(packageName)},repos="https://cloud.r-project.org/",quiet=FALSE,lib=temp)`, {
|
|
251
|
-
ms: 750_000,
|
|
252
|
-
resetOnNewData: true
|
|
253
|
-
});
|
|
254
|
-
if (autoload) {
|
|
255
|
-
this.sendCommand(`library(${(0, lang_4_x_1.ts2r)(packageName)},lib.loc=temp)`);
|
|
256
|
-
}
|
|
257
|
-
return {
|
|
258
|
-
packageName,
|
|
259
|
-
libraryLocation: tempdir,
|
|
260
|
-
packageExistedAlready
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
198
|
/**
|
|
264
199
|
* Obtain the temporary directory used by R.
|
|
265
200
|
* Additionally, this marks the directory for removal when the shell exits.
|
|
@@ -307,7 +242,9 @@ class RShellSession {
|
|
|
307
242
|
input: this.bareSession.stderr,
|
|
308
243
|
terminal: false
|
|
309
244
|
});
|
|
310
|
-
this.onExit(() => {
|
|
245
|
+
this.onExit(() => {
|
|
246
|
+
this.end();
|
|
247
|
+
});
|
|
311
248
|
this.options = options;
|
|
312
249
|
this.log = log;
|
|
313
250
|
this.setupRSessionLoggers();
|
|
@@ -351,7 +288,9 @@ class RShellSession {
|
|
|
351
288
|
this.collectionTimeout = makeTimer();
|
|
352
289
|
}
|
|
353
290
|
};
|
|
354
|
-
error = () => {
|
|
291
|
+
error = () => {
|
|
292
|
+
resolve(result);
|
|
293
|
+
};
|
|
355
294
|
this.onExit(error);
|
|
356
295
|
this.on(from, 'line', handler);
|
|
357
296
|
action?.();
|
package/util/args.d.ts
CHANGED
|
@@ -4,11 +4,15 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
* This splits an input string on the given split string (e.g., ` `) but checks if the string is quoted or escaped.
|
|
7
|
+
* This splits an input string on the given split string (e.g., ` `), but checks if the string is quoted or escaped.
|
|
8
8
|
*
|
|
9
|
-
* Given an input string like `a "b c" d
|
|
9
|
+
* Given an input string like `a "b c" d`, with a space character as split, and escapeQuote set to true,
|
|
10
|
+
* this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
|
|
11
|
+
*
|
|
12
|
+
* When escapeQuote is set to false instead, we keep quotation marks in the result (i.e., `a`, `"b c"`, and `d`.).
|
|
10
13
|
*
|
|
11
14
|
* @param inputString - The string to split
|
|
12
|
-
* @param
|
|
15
|
+
* @param escapeQuote - Keep quotes in args
|
|
16
|
+
* @param split - The **single** character to split on (can not be backslash or quote)
|
|
13
17
|
*/
|
|
14
|
-
export declare function splitAtEscapeSensitive(inputString: string, split?: string): string[];
|
|
18
|
+
export declare function splitAtEscapeSensitive(inputString: string, escapeQuote?: boolean, split?: string): string[];
|
package/util/args.js
CHANGED
|
@@ -7,14 +7,18 @@
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.splitAtEscapeSensitive = void 0;
|
|
9
9
|
/**
|
|
10
|
-
* This splits an input string on the given split string (e.g., ` `) but checks if the string is quoted or escaped.
|
|
10
|
+
* This splits an input string on the given split string (e.g., ` `), but checks if the string is quoted or escaped.
|
|
11
11
|
*
|
|
12
|
-
* Given an input string like `a "b c" d
|
|
12
|
+
* Given an input string like `a "b c" d`, with a space character as split, and escapeQuote set to true,
|
|
13
|
+
* this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
|
|
14
|
+
*
|
|
15
|
+
* When escapeQuote is set to false instead, we keep quotation marks in the result (i.e., `a`, `"b c"`, and `d`.).
|
|
13
16
|
*
|
|
14
17
|
* @param inputString - The string to split
|
|
15
|
-
* @param
|
|
18
|
+
* @param escapeQuote - Keep quotes in args
|
|
19
|
+
* @param split - The **single** character to split on (can not be backslash or quote)
|
|
16
20
|
*/
|
|
17
|
-
function splitAtEscapeSensitive(inputString, split = ' ') {
|
|
21
|
+
function splitAtEscapeSensitive(inputString, escapeQuote = true, split = ' ') {
|
|
18
22
|
const args = [];
|
|
19
23
|
let current = '';
|
|
20
24
|
let inQuotes = false;
|
|
@@ -50,6 +54,9 @@ function splitAtEscapeSensitive(inputString, split = ' ') {
|
|
|
50
54
|
}
|
|
51
55
|
else if (c === '"' || c === "'") {
|
|
52
56
|
inQuotes = !inQuotes;
|
|
57
|
+
if (!escapeQuote) {
|
|
58
|
+
current += c;
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
else if (c === '\\') {
|
|
55
62
|
escaped = true;
|
package/util/cfg/visitor.js
CHANGED
|
@@ -49,7 +49,7 @@ class ControlFlowGraphExecutionTraceVisitor {
|
|
|
49
49
|
return predecessors;
|
|
50
50
|
}
|
|
51
51
|
visit(cfg) {
|
|
52
|
-
const visited = new Set;
|
|
52
|
+
const visited = new Set();
|
|
53
53
|
for (const id of cfg.entryPoints) {
|
|
54
54
|
const node = cfg.graph.vertices().get(id);
|
|
55
55
|
(0, assert_1.guard)(node !== undefined, `Node with id ${id} not present`);
|
package/util/files.d.ts
CHANGED
|
@@ -52,3 +52,9 @@ export declare function readLineByLine(filePath: string, onLine: (line: Buffer,
|
|
|
52
52
|
* See {@link readLineByLine} for an asynchronous version.
|
|
53
53
|
*/
|
|
54
54
|
export declare function readLineByLineSync(filePath: string, onLine: (line: Buffer, lineNumber: number) => void): void;
|
|
55
|
+
/**
|
|
56
|
+
* Chops off the last part of the given directory path after a path separator, essentially returning the path's parent directory.
|
|
57
|
+
* If an absolute path is passed, the returned path is also absolute.
|
|
58
|
+
* @param directory - The directory whose parent to return
|
|
59
|
+
*/
|
|
60
|
+
export declare function getParentDirectory(directory: string): string;
|
package/util/files.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.readLineByLineSync = exports.readLineByLine = exports.writeTableAsCsv = exports.allRFilesFrom = exports.allRFiles = exports.getAllFiles = void 0;
|
|
29
|
+
exports.getParentDirectory = exports.readLineByLineSync = exports.readLineByLine = exports.writeTableAsCsv = exports.allRFilesFrom = exports.allRFiles = exports.getAllFiles = void 0;
|
|
30
30
|
const fs_1 = __importStar(require("fs"));
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const log_1 = require("./log");
|
|
@@ -141,4 +141,14 @@ function readLineByLineSync(filePath, onLine) {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
exports.readLineByLineSync = readLineByLineSync;
|
|
144
|
+
/**
|
|
145
|
+
* Chops off the last part of the given directory path after a path separator, essentially returning the path's parent directory.
|
|
146
|
+
* If an absolute path is passed, the returned path is also absolute.
|
|
147
|
+
* @param directory - The directory whose parent to return
|
|
148
|
+
*/
|
|
149
|
+
function getParentDirectory(directory) {
|
|
150
|
+
// apparently this is somehow the best way to do it in node, what
|
|
151
|
+
return directory.split(path_1.default.sep).slice(0, -1).join(path_1.default.sep);
|
|
152
|
+
}
|
|
153
|
+
exports.getParentDirectory = getParentDirectory;
|
|
144
154
|
//# sourceMappingURL=files.js.map
|
package/util/log.js
CHANGED
|
@@ -34,6 +34,9 @@ class FlowrLogger extends tslog_1.Logger {
|
|
|
34
34
|
exports.FlowrLogger = FlowrLogger;
|
|
35
35
|
function getActiveLog() {
|
|
36
36
|
return new FlowrLogger({
|
|
37
|
+
// set the default minimum level as Warn, and let all apps
|
|
38
|
+
// (like the REPL) update it to whatever they want it to be
|
|
39
|
+
minLevel: 4 /* LogLevel.Warn */,
|
|
37
40
|
type: 'pretty',
|
|
38
41
|
name: 'main',
|
|
39
42
|
stylePrettyLogs: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MergeableRecord } from '
|
|
1
|
+
import type { MergeableRecord } from './objects';
|
|
2
2
|
export declare const enum SummarizerType {
|
|
3
3
|
Benchmark = "benchmark",
|
|
4
4
|
Statistics = "statistics"
|
|
@@ -6,6 +6,17 @@ export declare const enum SummarizerType {
|
|
|
6
6
|
export interface CommonSummarizerConfiguration extends MergeableRecord {
|
|
7
7
|
logger: (message: string) => void;
|
|
8
8
|
}
|
|
9
|
+
export interface SummarizedMeasurement<T = number> {
|
|
10
|
+
min: T;
|
|
11
|
+
max: T;
|
|
12
|
+
median: T;
|
|
13
|
+
/** total may be useless for some measurements, especially if they are weighted before (it is just the sum...)*/
|
|
14
|
+
total: T;
|
|
15
|
+
/** average */
|
|
16
|
+
mean: number;
|
|
17
|
+
/** standard deviation */
|
|
18
|
+
std: number;
|
|
19
|
+
}
|
|
9
20
|
export declare abstract class Summarizer<Output, Configuration extends CommonSummarizerConfiguration> {
|
|
10
21
|
protected readonly config: Configuration;
|
|
11
22
|
protected readonly log: CommonSummarizerConfiguration['logger'];
|
|
@@ -23,3 +34,6 @@ export declare abstract class Summarizer<Output, Configuration extends CommonSum
|
|
|
23
34
|
*/
|
|
24
35
|
abstract summarizePhase(): Promise<Output>;
|
|
25
36
|
}
|
|
37
|
+
export declare function summarizedMeasurement2Csv(a: SummarizedMeasurement): string;
|
|
38
|
+
export declare function summarizedMeasurement2CsvHeader(prefix?: string): string;
|
|
39
|
+
export declare function summarizeMeasurement(data: number[], totalNumberOfDataPoints?: number): SummarizedMeasurement;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.summarizeMeasurement = exports.summarizedMeasurement2CsvHeader = exports.summarizedMeasurement2Csv = exports.Summarizer = void 0;
|
|
4
|
+
const arrays_1 = require("./arrays");
|
|
5
|
+
class Summarizer {
|
|
6
|
+
config;
|
|
7
|
+
log;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
this.log = this.config.logger;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.Summarizer = Summarizer;
|
|
14
|
+
function summarizedMeasurement2Csv(a) {
|
|
15
|
+
return `${a.min},${a.max},${a.median},${a.mean},${a.std},${a.total}`;
|
|
16
|
+
}
|
|
17
|
+
exports.summarizedMeasurement2Csv = summarizedMeasurement2Csv;
|
|
18
|
+
const summarizedKeys = ['min', 'max', 'median', 'mean', 'std', 'total'];
|
|
19
|
+
function summarizedMeasurement2CsvHeader(prefix) {
|
|
20
|
+
return summarizedKeys.map(k => prefix ? `${prefix}-${k}` : k).join(',');
|
|
21
|
+
}
|
|
22
|
+
exports.summarizedMeasurement2CsvHeader = summarizedMeasurement2CsvHeader;
|
|
23
|
+
function summarizeMeasurement(data, totalNumberOfDataPoints) {
|
|
24
|
+
// just to avoid in-place modification
|
|
25
|
+
const sorted = [...data].sort((a, b) => a - b);
|
|
26
|
+
const min = sorted[0];
|
|
27
|
+
const max = sorted[sorted.length - 1];
|
|
28
|
+
const median = sorted[Math.floor(sorted.length / 2)];
|
|
29
|
+
const total = (0, arrays_1.sum)(sorted);
|
|
30
|
+
const length = totalNumberOfDataPoints ?? sorted.length;
|
|
31
|
+
const mean = total / length;
|
|
32
|
+
// sqrt(sum(x-mean)^2 / n)
|
|
33
|
+
const std = Math.sqrt(sorted.map(x => (x - mean) ** 2).reduce((a, b) => a + b, 0) / length);
|
|
34
|
+
return { min, max, median, mean, std, total };
|
|
35
|
+
}
|
|
36
|
+
exports.summarizeMeasurement = summarizeMeasurement;
|
|
37
|
+
//# sourceMappingURL=summarizer.js.map
|
package/util/version.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flowrVersion = void 0;
|
|
4
|
+
const package_json_1 = require("../../package.json");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
function flowrVersion() {
|
|
7
|
+
return new semver_1.SemVer(package_json_1.version);
|
|
8
|
+
}
|
|
9
|
+
exports.flowrVersion = flowrVersion;
|
|
10
|
+
//# sourceMappingURL=version.js.map
|
package/benchmark/index.d.ts
DELETED
package/benchmark/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./stats"), exports);
|
|
18
|
-
__exportStar(require("./slicer"), exports);
|
|
19
|
-
__exportStar(require("./stopwatch"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|