datagrok-tools 5.1.5 → 5.1.7
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/bin/commands/test.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.test = test;
|
|
8
|
+
var _child_process = require("child_process");
|
|
8
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
10
|
var _os = _interopRequireDefault(require("os"));
|
|
10
11
|
var _path = _interopRequireDefault(require("path"));
|
|
@@ -24,12 +25,78 @@ const grokDir = _path.default.join(_os.default.homedir(), '.grok');
|
|
|
24
25
|
const confPath = _path.default.join(grokDir, 'config.yaml');
|
|
25
26
|
const consoleLogOutputDir = _path.default.join(curDir, 'test-console-output.log');
|
|
26
27
|
const csvReportDir = _path.default.join(curDir, 'test-report.csv');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Detects if the current directory is within a Dart library folder (d4, xamgle, ddt, dml)
|
|
31
|
+
* and returns the appropriate test category to use.
|
|
32
|
+
* @returns The category string (e.g., "Core: d4") or undefined if not in a recognized Dart folder
|
|
33
|
+
*/
|
|
34
|
+
function detectDartLibraryCategory() {
|
|
35
|
+
const normalizedPath = curDir.replace(/\\/g, '/');
|
|
36
|
+
if (normalizedPath.includes('/d4/') || normalizedPath.endsWith('/d4')) return 'Core: d4';
|
|
37
|
+
if (normalizedPath.includes('/xamgle/') || normalizedPath.endsWith('/xamgle')) return 'Core: xamgle';
|
|
38
|
+
if (normalizedPath.includes('/ddt/') || normalizedPath.endsWith('/ddt')) return 'Core: ddt';
|
|
39
|
+
if (normalizedPath.includes('/dml/') || normalizedPath.endsWith('/dml')) return 'Core: dml';
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Traverses up from startDir to find the git repository root (.git directory).
|
|
45
|
+
*/
|
|
46
|
+
function findGitRoot(startDir) {
|
|
47
|
+
let current = startDir;
|
|
48
|
+
while (true) {
|
|
49
|
+
if (_fs.default.existsSync(_path.default.join(current, '.git'))) return current;
|
|
50
|
+
const parent = _path.default.dirname(current);
|
|
51
|
+
if (parent === current) return undefined;
|
|
52
|
+
current = parent;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
27
55
|
async function test(args) {
|
|
28
56
|
const config = _jsYaml.default.load(_fs.default.readFileSync(confPath, {
|
|
29
57
|
encoding: 'utf-8'
|
|
30
58
|
}));
|
|
31
59
|
isArgsValid(args);
|
|
32
60
|
utils.setHost(args.host, config);
|
|
61
|
+
|
|
62
|
+
// If running from a core Dart library directory, delegate to DevTools package
|
|
63
|
+
if (!args.package) {
|
|
64
|
+
const detectedCategory = detectDartLibraryCategory();
|
|
65
|
+
if (detectedCategory) {
|
|
66
|
+
const category = args.category ?? detectedCategory;
|
|
67
|
+
const gitRoot = findGitRoot(curDir);
|
|
68
|
+
const devToolsDir = gitRoot ? _path.default.join(gitRoot, 'public', 'packages', 'DevTools') : undefined;
|
|
69
|
+
if (!devToolsDir || !_fs.default.existsSync(devToolsDir)) {
|
|
70
|
+
color.error(`Cannot run core tests from this directory: DevTools package not found.`);
|
|
71
|
+
color.error(`Run 'grok test --category="${category}"' from 'public/packages/DevTools' instead.`);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
color.info(`Detected core library directory. Delegating to DevTools with category: "${category}"`);
|
|
75
|
+
const cmdArgs = ['test', `--category=${category}`];
|
|
76
|
+
if (args.host) cmdArgs.push(`--host=${args.host}`);
|
|
77
|
+
if (args.test) cmdArgs.push(`--test=${args.test}`);
|
|
78
|
+
if (args.csv) cmdArgs.push('--csv');
|
|
79
|
+
if (args.gui) cmdArgs.push('--gui');
|
|
80
|
+
if (args.verbose) cmdArgs.push('--verbose');
|
|
81
|
+
if (args.benchmark) cmdArgs.push('--benchmark');
|
|
82
|
+
if (args['stress-test']) cmdArgs.push('--stress-test');
|
|
83
|
+
if (args['skip-build']) cmdArgs.push('--skip-build');
|
|
84
|
+
if (args['skip-publish']) cmdArgs.push('--skip-publish');
|
|
85
|
+
if (args.link) cmdArgs.push('--link');
|
|
86
|
+
if (args.record) cmdArgs.push('--record');
|
|
87
|
+
if (args.catchUnhandled) cmdArgs.push('--catchUnhandled');
|
|
88
|
+
if (args.report) cmdArgs.push('--report');
|
|
89
|
+
if (args.debug) cmdArgs.push('--debug');
|
|
90
|
+
if (args['ci-cd']) cmdArgs.push('--ci-cd');
|
|
91
|
+
if (args['no-retry']) cmdArgs.push('--no-retry');
|
|
92
|
+
const grokScript = _path.default.resolve(__dirname, '..', 'grok.js');
|
|
93
|
+
const result = (0, _child_process.spawnSync)(process.execPath, [grokScript, ...cmdArgs], {
|
|
94
|
+
cwd: devToolsDir,
|
|
95
|
+
stdio: 'inherit'
|
|
96
|
+
});
|
|
97
|
+
process.exit(result.status ?? 1);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
33
100
|
let packageJsonData = undefined;
|
|
34
101
|
if (!args.package) packageJsonData = JSON.parse(_fs.default.readFileSync(_path.default.join(curDir, 'package.json'), {
|
|
35
102
|
encoding: 'utf-8'
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const
|
|
2
|
+
const {execSync} = require('child_process');
|
|
3
3
|
const packageName = path.parse(require('./package.json').name).name.toLowerCase().replace(/-/g, '');
|
|
4
4
|
|
|
5
|
+
function getDatagrokTools() {
|
|
6
|
+
const pluginPath = 'datagrok-tools/plugins/func-gen-plugin';
|
|
7
|
+
try {
|
|
8
|
+
return require(pluginPath);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
try {
|
|
11
|
+
const globalPath = execSync('npm root -g').toString().trim();
|
|
12
|
+
return require(path.join(globalPath, pluginPath));
|
|
13
|
+
} catch (globalErr) {
|
|
14
|
+
console.error('\n' + '='.repeat(60));
|
|
15
|
+
console.error('ERROR: datagrok-tools not found!');
|
|
16
|
+
console.error('To fix this, please install the tools globally by running:');
|
|
17
|
+
console.error('\n npm install -g datagrok-tools\n');
|
|
18
|
+
console.error('='.repeat(60) + '\n');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const FuncGeneratorPlugin = getDatagrokTools();
|
|
25
|
+
|
|
5
26
|
module.exports = {
|
|
6
27
|
cache: {
|
|
7
28
|
type: 'filesystem',
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const {execSync} = require('child_process');
|
|
2
3
|
const packageName = path.parse(require('./package.json').name).name.toLowerCase().replace(/-/g, '');
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
function getDatagrokTools() {
|
|
6
|
+
const pluginPath = 'datagrok-tools/plugins/func-gen-plugin';
|
|
7
|
+
try {
|
|
8
|
+
return require(pluginPath);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
try {
|
|
11
|
+
const globalPath = execSync('npm root -g').toString().trim();
|
|
12
|
+
return require(path.join(globalPath, pluginPath));
|
|
13
|
+
} catch (globalErr) {
|
|
14
|
+
console.error('\n' + '='.repeat(60));
|
|
15
|
+
console.error('ERROR: datagrok-tools not found!');
|
|
16
|
+
console.error('To fix this, please install the tools globally by running:');
|
|
17
|
+
console.error('\n npm install -g datagrok-tools\n');
|
|
18
|
+
console.error('='.repeat(60) + '\n');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const FuncGeneratorPlugin = getDatagrokTools();
|
|
4
25
|
module.exports = {
|
|
5
26
|
cache: {
|
|
6
27
|
type: 'filesystem',
|
package/package.json
CHANGED