datagrok-tools 4.11.0 → 4.11.2
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/help.js +1 -1
- package/bin/commands/init.js +25 -2
- package/bin/commands/test.js +28 -10
- package/bin/utils/test-utils.js +20 -1
- package/package.json +3 -2
package/bin/commands/help.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.help = void 0;
|
|
7
7
|
var HELP = "\nUsage: grok <command>\n\nDatagrok's package management tool\n\nCommands:\n add Add an object template\n api Create wrapper functions\n check Check package content (function signatures, etc.)\n config Create and manage config files\n create Create a package\n init Modify a package template\n link Link `datagrok-api` and libraries for local development\n publish Upload a package\n test Run package tests\n\nTo get help on a particular command, use:\n grok <command> --help\n\nRead more about the package development workflow:\nhttps://datagrok.ai/help/develop/develop\n";
|
|
8
8
|
var HELP_ADD = "\nUsage: grok add <entity> <name>\n\nAdd an object template to your package:\n\ngrok add app <name>\ngrok add connection <name>\ngrok add detector <semantic-type-name>\ngrok add function [tag] <name>\ngrok add query <name>\ngrok add script [tag] <language> <name>\ngrok add view <name>\ngrok add viewer <name>\ngrok add tests\n\nPlease note that entity names may only include letters and numbers\n\nSupported languages for scripts:\njavascript, julia, node, octave, python, r\n\nAvailable tags:\npanel, init\n";
|
|
9
|
-
var HELP_INIT = "\nUsage: grok init\n\nModify a package template by adding config files for linters, IDE, etc.\n\nOptions:\n[--eslint] [--ide] [--test] [--ts]\n\n--eslint Add a configuration for eslint\n--ide Add an IDE-specific configuration for debugging (vscode)\n--test Add tests support (TypeScript packages only)\n--ts Convert a JavaScript package to TypeScript\n";
|
|
9
|
+
var HELP_INIT = "\nUsage: grok init\n\nModify a package template by adding config files for linters, IDE, etc.\n\nOptions:\n[--eslint] [--ide] [--test] [--ts] [--git]\n\n--eslint Add a configuration for eslint\n--ide Add an IDE-specific configuration for debugging (vscode)\n--test Add tests support (TypeScript packages only)\n--ts Convert a JavaScript package to TypeScript\n--git Configure GIT and install commit linting tools.\n Read more: https://datagrok.ai/help/develop/advanced/git-policy\n";
|
|
10
10
|
var HELP_API = "\nUsage: grok api\n\nCreate wrapper functions for package scripts and queries\n";
|
|
11
11
|
var HELP_CONFIG = "\nUsage: grok config\n\nCreate or update a configuration file\n\nOptions:\n[--reset] [--server] [--alias] [-k | --key]\n\n--reset Restore the default config file template\n--server Use to add a server to the config (`grok config add --alias alias --server url --key key`)\n--alias Use in conjunction with the `server` option to set the server name\n--key Use in conjunction with the `server` option to set the developer key\n--default Use in conjunction with the `server` option to set the added server as default\n";
|
|
12
12
|
var HELP_CREATE = "\nUsage: grok create [name]\n\nCreate a package:\n\ngrok create Create a package in the current working directory\ngrok create <name> Create a package in a folder with the specified name\n\nPlease note that the package name may only include letters, numbers, underscores, or hyphens\n\nOptions:\n[--eslint] [--ide] [--js | --ts] [--test]\n\n--eslint Add a configuration for eslint\n--ide Add an IDE-specific configuration for debugging (vscode)\n--js Create a JavaScript package\n--ts Create a TypeScript package (default)\n--test Add tests support (TypeScript packages only)\n";
|
package/bin/commands/init.js
CHANGED
|
@@ -10,6 +10,7 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
10
10
|
var _os = _interopRequireDefault(require("os"));
|
|
11
11
|
var _path = _interopRequireDefault(require("path"));
|
|
12
12
|
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
13
|
+
var _child_process = require("child_process");
|
|
13
14
|
var utils = _interopRequireWildcard(require("../utils/utils"));
|
|
14
15
|
var color = _interopRequireWildcard(require("../utils/color-utils"));
|
|
15
16
|
var _configValidator = require("../validators/config-validator");
|
|
@@ -26,8 +27,8 @@ var packageJsonPath = _path["default"].join(curDir, 'package.json');
|
|
|
26
27
|
var tsConfigPath = _path["default"].join(curDir, 'tsconfig.json');
|
|
27
28
|
var webpackConfigPath = _path["default"].join(curDir, 'webpack.config.js');
|
|
28
29
|
var templateDir = _path["default"].join(_path["default"].dirname(_path["default"].dirname(__dirname)), 'package-template');
|
|
30
|
+
var options = ['ide', 'eslint', 'test', 'ts', 'git'];
|
|
29
31
|
function init(args) {
|
|
30
|
-
var options = ['ide', 'eslint', 'test', 'ts'];
|
|
31
32
|
var nOptions = Object.keys(args).length - 1;
|
|
32
33
|
var nArgs = args['_'].length;
|
|
33
34
|
if (nArgs > 1 || nOptions > options.length) {
|
|
@@ -54,7 +55,29 @@ function init(args) {
|
|
|
54
55
|
}
|
|
55
56
|
if (hasUnknownOpt) return false;
|
|
56
57
|
}
|
|
57
|
-
if (
|
|
58
|
+
if (args.git) {
|
|
59
|
+
(0, _child_process.exec)('git config --global pull.rebase false && ' + 'git config --global branch.master.rebase true && ' + 'git config --global branch.main.rebase true && ' + 'git config --global rebase.autostash true', function (err, stdout, stderr) {
|
|
60
|
+
color.info('Configuring rebase pull strategy...');
|
|
61
|
+
console.log('Read more: https://datagrok.ai/help/develop/advanced/git-policy');
|
|
62
|
+
if (err) throw err;else {
|
|
63
|
+
console.log(stderr, stdout);
|
|
64
|
+
color.success('GIT successfully configured\n');
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
(0, _child_process.exec)('npm install --location=global @commitlint/config-conventional @commitlint/cli', function (err, stdout, stderr) {
|
|
68
|
+
color.info('Installing @commitlint/config-conventional and @commitlint/cli...');
|
|
69
|
+
if (err) throw err;else console.log(stderr, stdout);
|
|
70
|
+
});
|
|
71
|
+
(0, _child_process.exec)('pip install pre-commit', function (err, stdout, stderr) {
|
|
72
|
+
color.info('Installing pre-commit...');
|
|
73
|
+
if (err) throw err;else console.log(stderr, stdout);
|
|
74
|
+
(0, _child_process.exec)('pre-commit install --install-hooks --hook-type pre-commit --hook-type commit-msg', function (err, stdout, stderr) {
|
|
75
|
+
color.info('Installing commit hooks...');
|
|
76
|
+
if (err) throw err;else console.log(stderr, stdout);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (!utils.isPackageDir(curDir) && (args.ts || args.ide || args.eslint || args.test)) {
|
|
58
81
|
color.error('File `package.json` not found. Run the command from the package directory');
|
|
59
82
|
return false;
|
|
60
83
|
}
|
package/bin/commands/test.js
CHANGED
|
@@ -13,6 +13,7 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
13
13
|
var _os = _interopRequireDefault(require("os"));
|
|
14
14
|
var _path = _interopRequireDefault(require("path"));
|
|
15
15
|
var _puppeteer = _interopRequireDefault(require("puppeteer"));
|
|
16
|
+
var _puppeteerScreenRecorder = require("puppeteer-screen-recorder");
|
|
16
17
|
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
17
18
|
var utils = _interopRequireWildcard(require("../utils/utils"));
|
|
18
19
|
var color = _interopRequireWildcard(require("../utils/color-utils"));
|
|
@@ -21,7 +22,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
21
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
23
|
function test(args) {
|
|
23
24
|
var options = Object.keys(args).slice(1);
|
|
24
|
-
var commandOptions = ['host', 'csv', 'gui', 'catchUnhandled', 'report', 'skip-build', 'skip-publish', 'category'];
|
|
25
|
+
var commandOptions = ['host', 'csv', 'gui', 'catchUnhandled', 'report', 'skip-build', 'skip-publish', 'category', 'record'];
|
|
25
26
|
var nArgs = args['_'].length;
|
|
26
27
|
var curDir = process.cwd();
|
|
27
28
|
var grokDir = _path["default"].join(_os["default"].homedir(), '.grok');
|
|
@@ -97,6 +98,7 @@ function test(args) {
|
|
|
97
98
|
var P_START_TIMEOUT = 3600000;
|
|
98
99
|
var browser;
|
|
99
100
|
var page;
|
|
101
|
+
var recorder;
|
|
100
102
|
function init(timeout) {
|
|
101
103
|
var params = Object.assign({}, testUtils.defaultLaunchParameters);
|
|
102
104
|
if (args.gui) params['headless'] = false;
|
|
@@ -113,18 +115,19 @@ function test(args) {
|
|
|
113
115
|
out = _context.sent;
|
|
114
116
|
browser = out.browser;
|
|
115
117
|
page = out.page;
|
|
116
|
-
|
|
118
|
+
recorder = new _puppeteerScreenRecorder.PuppeteerScreenRecorder(page, testUtils.recorderConfig);
|
|
119
|
+
_context.next = 12;
|
|
117
120
|
break;
|
|
118
|
-
case
|
|
119
|
-
_context.prev =
|
|
121
|
+
case 9:
|
|
122
|
+
_context.prev = 9;
|
|
120
123
|
_context.t0 = _context["catch"](0);
|
|
121
124
|
throw _context.t0;
|
|
122
|
-
case
|
|
125
|
+
case 12:
|
|
123
126
|
case "end":
|
|
124
127
|
return _context.stop();
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
|
-
}, _callee, null, [[0,
|
|
130
|
+
}, _callee, null, [[0, 9]]);
|
|
128
131
|
})));
|
|
129
132
|
}
|
|
130
133
|
function runTest(timeout) {
|
|
@@ -136,9 +139,16 @@ function test(args) {
|
|
|
136
139
|
while (1) {
|
|
137
140
|
switch (_context2.prev = _context2.next) {
|
|
138
141
|
case 0:
|
|
142
|
+
if (!options.record) {
|
|
143
|
+
_context2.next = 3;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
_context2.next = 3;
|
|
147
|
+
return recorder.start('./test-record.mp4');
|
|
148
|
+
case 3:
|
|
139
149
|
targetPackage = (_process$env$TARGET_P = process.env.TARGET_PACKAGE) !== null && _process$env$TARGET_P !== void 0 ? _process$env$TARGET_P : '#{PACKAGE_NAMESPACE}';
|
|
140
150
|
console.log("Testing ".concat(targetPackage, " package...\n"));
|
|
141
|
-
_context2.next =
|
|
151
|
+
_context2.next = 7;
|
|
142
152
|
return page.evaluate(function (targetPackage, options, testContext) {
|
|
143
153
|
return new Promise(function (resolve, reject) {
|
|
144
154
|
window.grok.functions.call("".concat(targetPackage, ":test"), {
|
|
@@ -190,10 +200,17 @@ function test(args) {
|
|
|
190
200
|
});
|
|
191
201
|
});
|
|
192
202
|
}, targetPackage, options, new testUtils.TestContext(options.catchUnhandled, options.report));
|
|
193
|
-
case
|
|
203
|
+
case 7:
|
|
194
204
|
r = _context2.sent;
|
|
205
|
+
if (!options.record) {
|
|
206
|
+
_context2.next = 11;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
_context2.next = 11;
|
|
210
|
+
return recorder.stop();
|
|
211
|
+
case 11:
|
|
195
212
|
return _context2.abrupt("return", r);
|
|
196
|
-
case
|
|
213
|
+
case 12:
|
|
197
214
|
case "end":
|
|
198
215
|
return _context2.stop();
|
|
199
216
|
}
|
|
@@ -224,7 +241,8 @@ function test(args) {
|
|
|
224
241
|
return runTest(7200000, {
|
|
225
242
|
category: args.category,
|
|
226
243
|
catchUnhandled: args.catchUnhandled,
|
|
227
|
-
report: args.report
|
|
244
|
+
report: args.report,
|
|
245
|
+
record: args.record
|
|
228
246
|
});
|
|
229
247
|
case 12:
|
|
230
248
|
r = _context3.sent;
|
package/bin/utils/test-utils.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.getBrowserPage = getBrowserPage;
|
|
|
11
11
|
exports.getDevKey = getDevKey;
|
|
12
12
|
exports.getToken = getToken;
|
|
13
13
|
exports.getWebUrl = getWebUrl;
|
|
14
|
+
exports.recorderConfig = void 0;
|
|
14
15
|
exports.runWithTimeout = runWithTimeout;
|
|
15
16
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
16
17
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
@@ -256,4 +257,22 @@ var TestContext = function TestContext(catchUnhandled, report) {
|
|
|
256
257
|
if (catchUnhandled !== undefined) this.catchUnhandled = catchUnhandled;
|
|
257
258
|
if (report !== undefined) this.report = report;
|
|
258
259
|
};
|
|
259
|
-
exports.TestContext = TestContext;
|
|
260
|
+
exports.TestContext = TestContext;
|
|
261
|
+
var recorderConfig = {
|
|
262
|
+
followNewTab: true,
|
|
263
|
+
fps: 25,
|
|
264
|
+
ffmpeg_Path: null,
|
|
265
|
+
videoFrame: {
|
|
266
|
+
width: 1024,
|
|
267
|
+
height: 768
|
|
268
|
+
},
|
|
269
|
+
videoCrf: 18,
|
|
270
|
+
videoCodec: 'libx264',
|
|
271
|
+
videoPreset: 'ultrafast',
|
|
272
|
+
videoBitrate: 1000,
|
|
273
|
+
autopad: {
|
|
274
|
+
color: 'black'
|
|
275
|
+
},
|
|
276
|
+
aspectRatio: '4:3'
|
|
277
|
+
};
|
|
278
|
+
exports.recorderConfig = recorderConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datagrok-tools",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.2",
|
|
4
4
|
"description": "Utility to upload and publish packages to Datagrok",
|
|
5
5
|
"homepage": "https://github.com/datagrok-ai/public/tree/master/tools#readme",
|
|
6
6
|
"dependencies": {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"node-recursive-directory": "^1.2.0",
|
|
19
19
|
"os": "^0.1.1",
|
|
20
20
|
"path": "^0.12.7",
|
|
21
|
-
"puppeteer": "^20.3.0"
|
|
21
|
+
"puppeteer": "^20.3.0",
|
|
22
|
+
"puppeteer-screen-recorder": "^2.1.2"
|
|
22
23
|
},
|
|
23
24
|
"scripts": {
|
|
24
25
|
"link": "npm link",
|