datagrok-tools 4.8.0 → 4.8.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/check.js +58 -10
- package/bin/commands/link.js +32 -38
- package/bin/commands/test.js +33 -16
- package/bin/utils/test-utils.js +12 -4
- package/package-template/ts.webpack.config.js +1 -0
- package/package.json +1 -1
package/bin/commands/check.js
CHANGED
|
@@ -13,6 +13,8 @@ exports.checkImportStatements = checkImportStatements;
|
|
|
13
13
|
exports.checkPackageFile = checkPackageFile;
|
|
14
14
|
exports.extractExternals = extractExternals;
|
|
15
15
|
|
|
16
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
+
|
|
16
18
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
19
|
|
|
18
20
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
@@ -99,17 +101,22 @@ function check(args) {
|
|
|
99
101
|
|
|
100
102
|
var isWebpack = _fs["default"].existsSync(webpackConfigPath);
|
|
101
103
|
|
|
104
|
+
var externals = null;
|
|
105
|
+
|
|
102
106
|
if (isWebpack) {
|
|
103
107
|
var content = _fs["default"].readFileSync(webpackConfigPath, {
|
|
104
108
|
encoding: 'utf-8'
|
|
105
109
|
});
|
|
106
110
|
|
|
107
|
-
|
|
111
|
+
externals = extractExternals(content);
|
|
108
112
|
if (externals) warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkImportStatements(packagePath, jsTsFiles, externals)));
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkFuncSignatures(packagePath, funcFiles)));
|
|
112
|
-
warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkPackageFile(packagePath
|
|
116
|
+
warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkPackageFile(packagePath, {
|
|
117
|
+
isWebpack: isWebpack,
|
|
118
|
+
externals: externals
|
|
119
|
+
})));
|
|
113
120
|
|
|
114
121
|
if (warnings.length) {
|
|
115
122
|
console.log("Checking package ".concat(_path["default"].basename(packagePath), "..."));
|
|
@@ -121,12 +128,12 @@ function check(args) {
|
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
function extractExternals(config) {
|
|
124
|
-
var externalsRegex = /(?<=externals\s*:\s*
|
|
131
|
+
var externalsRegex = /(?<=externals)\s*:\s*(\{[\S\s]*?\})/;
|
|
125
132
|
var match = config.match(externalsRegex);
|
|
126
133
|
|
|
127
134
|
if (match) {
|
|
128
|
-
// Replace single quotes and a trailing comma to make a string JSON-like
|
|
129
|
-
var externalStr = match[1].replace(/'/g, '"').replace(/(?<=[\S\s]),(?=\s*\})/, '');
|
|
135
|
+
// Replace single quotes, comments, and a trailing comma to make a string JSON-like
|
|
136
|
+
var externalStr = match[1].replace(/'/g, '"').replace(/\/\/.*(\r\n|\r|\n)/, '').replace(/(?<=[\S\s]),(?=\s*\})/, '');
|
|
130
137
|
|
|
131
138
|
try {
|
|
132
139
|
var externals = JSON.parse(externalStr);
|
|
@@ -142,9 +149,9 @@ function extractExternals(config) {
|
|
|
142
149
|
function checkImportStatements(packagePath, files, externals) {
|
|
143
150
|
var modules = [];
|
|
144
151
|
|
|
145
|
-
for (var
|
|
146
|
-
modules.push(
|
|
147
|
-
if (
|
|
152
|
+
for (var _key in externals) {
|
|
153
|
+
modules.push(_key);
|
|
154
|
+
if (_key.includes('/')) modules.push(_key.split('/', 1)[0]);
|
|
148
155
|
}
|
|
149
156
|
|
|
150
157
|
var importRegex = new RegExp("^(?!\\/{2})\\s*import\\s+.*(".concat(modules.join('|'), ").*(?=\\s+?)"), 'g');
|
|
@@ -402,7 +409,25 @@ function checkFuncSignatures(packagePath, files) {
|
|
|
402
409
|
return warnings;
|
|
403
410
|
}
|
|
404
411
|
|
|
405
|
-
|
|
412
|
+
var sharedLibExternals = {
|
|
413
|
+
'common/html2canvas.min.js': {
|
|
414
|
+
'exceljs': 'ExcelJS'
|
|
415
|
+
},
|
|
416
|
+
'common/exceljs.min.js': {
|
|
417
|
+
'html2canvas': 'html2canvas'
|
|
418
|
+
},
|
|
419
|
+
'common/ngl_viewer/ngl.js': {
|
|
420
|
+
'NGL': 'NGL'
|
|
421
|
+
},
|
|
422
|
+
'common/openchemlib-full.js': {
|
|
423
|
+
'openchemlib/full': 'OCL'
|
|
424
|
+
},
|
|
425
|
+
'common/codemirror/codemirror.js': {
|
|
426
|
+
'codemirror': 'CodeMirror'
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
function checkPackageFile(packagePath, options) {
|
|
406
431
|
var warnings = [];
|
|
407
432
|
|
|
408
433
|
var packageFilePath = _path["default"].join(packagePath, 'package.json');
|
|
@@ -440,7 +465,30 @@ function checkPackageFile(packagePath) {
|
|
|
440
465
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
441
466
|
var source = _step7.value;
|
|
442
467
|
if (typeof source !== 'string') warnings.push("File \"package.json\": Only file paths and URLs are allowed in sources. Modify the source ".concat(source));
|
|
443
|
-
if (
|
|
468
|
+
if (utils.absUrlRegex.test(source)) continue;
|
|
469
|
+
|
|
470
|
+
if (source.startsWith('common/')) {
|
|
471
|
+
if (options !== null && options !== void 0 && options.isWebpack && source.endsWith('.js')) {
|
|
472
|
+
if (options !== null && options !== void 0 && options.externals) {
|
|
473
|
+
if (source in sharedLibExternals) {
|
|
474
|
+
var _Object$entries$ = (0, _slicedToArray2["default"])(Object.entries(sharedLibExternals[source])[0], 2),
|
|
475
|
+
_lib = _Object$entries$[0],
|
|
476
|
+
name = _Object$entries$[1];
|
|
477
|
+
|
|
478
|
+
if (!(_lib in options.externals && options.externals[_lib] === name)) {
|
|
479
|
+
warnings.push("Webpack config parsing: Consider adding source \"".concat(source, "\" to webpack externals:\n") + "'".concat(_lib, "': '").concat(name, "'\n"));
|
|
480
|
+
}
|
|
481
|
+
} else {
|
|
482
|
+
warnings.push("File \"package.json\": source \"".concat(source, "\" not in the list of shared libraries"));
|
|
483
|
+
}
|
|
484
|
+
} else {
|
|
485
|
+
warnings.push('Webpack config parsing: External modules not found.\n' + "Consider adding source \"".concat(source, "\" to webpack externals") + (source in sharedLibExternals ? ':\n' + "'".concat(Object.keys(sharedLibExternals[source])[0], "': '").concat(Object.values(sharedLibExternals[source])[0], "'\n") : ''));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
|
|
444
492
|
if (source.startsWith('src/') && _fs["default"].existsSync(_path["default"].join(packagePath, 'webpack.config.js'))) warnings.push('File "package.json": Sources cannot include files from the \`src/\` directory. ' + "Move file ".concat(source, " to another folder."));
|
|
445
493
|
if (!_fs["default"].existsSync(_path["default"].join(packagePath, source))) warnings.push("Source ".concat(source, " not found in the package."));
|
|
446
494
|
}
|
package/bin/commands/link.js
CHANGED
|
@@ -121,16 +121,15 @@ function link(args) {
|
|
|
121
121
|
var lib = _step2.value;
|
|
122
122
|
|
|
123
123
|
if ("".concat(libScope, "/").concat(lib.name) in dependencies) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
124
|
+
var libPath = _path["default"].join(paths[libScope], lib.name);
|
|
125
|
+
|
|
126
|
+
var isLinked = lib.isSymbolicLink();
|
|
127
|
+
console.log(isLinked ? "Package \"".concat(lib.name, "\" is linked. Updating dependencies and running the build script...") : "Linking \"".concat(lib.name, "\"..."));
|
|
128
|
+
(0, _child_process.exec)(isLinked ? 'npm update && npm run build' : 'npm install && npm run build && npm link', {
|
|
129
|
+
cwd: libPath
|
|
130
|
+
}, function (err, stdout, stderr) {
|
|
131
|
+
if (err) throw err;else console.log(stderr, stdout);
|
|
132
|
+
});
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
135
|
} catch (err) {
|
|
@@ -145,43 +144,38 @@ function link(args) {
|
|
|
145
144
|
return m.name === 'utils';
|
|
146
145
|
}), 1)[0];
|
|
147
146
|
|
|
148
|
-
|
|
149
|
-
console.log("Package \"".concat(utilsModule.name, "\" is linked. Skipping..."));
|
|
150
|
-
} else {
|
|
151
|
-
console.log("Linking \"".concat(utilsModule.name, "\"..."));
|
|
152
|
-
(0, _child_process.exec)('npm install && npm run build && npm link', {
|
|
153
|
-
cwd: _path["default"].join(paths[libScope], 'utils')
|
|
154
|
-
}, function (err, stdout, stderr) {
|
|
155
|
-
if (err) throw err;else {
|
|
156
|
-
console.log(stderr, stdout);
|
|
157
|
-
f();
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
f();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
147
|
+
var libPath = _path["default"].join(paths[libScope], 'utils');
|
|
165
148
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
} else {
|
|
171
|
-
console.log("Linking \"".concat(apiModule.name, "\"..."));
|
|
172
|
-
(0, _child_process.exec)("npm install && npm run build && npm link", {
|
|
173
|
-
cwd: paths[apiPackageName]
|
|
149
|
+
var isLinked = utilsModule.isSymbolicLink();
|
|
150
|
+
console.log(isLinked ? "Package \"".concat(utilsModule.name, "\" is linked. Updating dependencies and running the build script...") : "Linking \"".concat(utilsModule.name, "\"..."));
|
|
151
|
+
(0, _child_process.exec)(isLinked ? 'npm update && npm run build' : 'npm install && npm run build && npm link', {
|
|
152
|
+
cwd: libPath
|
|
174
153
|
}, function (err, stdout, stderr) {
|
|
175
154
|
if (err) throw err;else {
|
|
176
155
|
console.log(stderr, stdout);
|
|
177
|
-
|
|
178
|
-
var packageNames = Object.keys(dependencies).join(' ');
|
|
179
|
-
(0, _child_process.exec)("npm link ".concat(packageNames));
|
|
156
|
+
f();
|
|
180
157
|
}
|
|
181
158
|
});
|
|
159
|
+
} else {
|
|
160
|
+
f();
|
|
182
161
|
}
|
|
183
162
|
}
|
|
184
163
|
|
|
164
|
+
if (apiModule != null) {
|
|
165
|
+
var isLinked = apiModule.isSymbolicLink();
|
|
166
|
+
console.log(isLinked ? "Package \"".concat(apiModule.name, "\" is linked. Updating dependencies and running the build script...") : "Linking \"".concat(apiModule.name, "\"..."));
|
|
167
|
+
(0, _child_process.exec)(isLinked ? "npm update && npm run build" : "npm install && npm run build && npm link", {
|
|
168
|
+
cwd: paths[apiPackageName]
|
|
169
|
+
}, function (err, stdout, stderr) {
|
|
170
|
+
if (err) throw err;else {
|
|
171
|
+
console.log(stderr, stdout);
|
|
172
|
+
installLibs(libs);
|
|
173
|
+
var packageNames = Object.keys(dependencies).join(' ');
|
|
174
|
+
(0, _child_process.exec)("npm link ".concat(packageNames));
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
185
179
|
return true;
|
|
186
180
|
}
|
|
187
181
|
/** Unlinks local packages and runs `npm i`. */
|
package/bin/commands/test.js
CHANGED
|
@@ -138,21 +138,28 @@ function test(args) {
|
|
|
138
138
|
while (1) {
|
|
139
139
|
switch (_context.prev = _context.next) {
|
|
140
140
|
case 0:
|
|
141
|
-
_context.
|
|
141
|
+
_context.prev = 0;
|
|
142
|
+
_context.next = 3;
|
|
142
143
|
return testUtils.getBrowserPage(_puppeteer["default"], params);
|
|
143
144
|
|
|
144
|
-
case
|
|
145
|
+
case 3:
|
|
145
146
|
out = _context.sent;
|
|
146
147
|
browser = out.browser;
|
|
147
148
|
page = out.page;
|
|
148
|
-
|
|
149
|
+
_context.next = 11;
|
|
150
|
+
break;
|
|
149
151
|
|
|
150
|
-
case
|
|
152
|
+
case 8:
|
|
153
|
+
_context.prev = 8;
|
|
154
|
+
_context.t0 = _context["catch"](0);
|
|
155
|
+
throw _context.t0;
|
|
156
|
+
|
|
157
|
+
case 11:
|
|
151
158
|
case "end":
|
|
152
159
|
return _context.stop();
|
|
153
160
|
}
|
|
154
161
|
}
|
|
155
|
-
}, _callee);
|
|
162
|
+
}, _callee, null, [[0, 8]]);
|
|
156
163
|
})));
|
|
157
164
|
}
|
|
158
165
|
|
|
@@ -235,21 +242,31 @@ function test(args) {
|
|
|
235
242
|
}
|
|
236
243
|
|
|
237
244
|
(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
238
|
-
var
|
|
245
|
+
var r;
|
|
239
246
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
240
247
|
while (1) {
|
|
241
248
|
switch (_context3.prev = _context3.next) {
|
|
242
249
|
case 0:
|
|
243
|
-
_context3.
|
|
250
|
+
_context3.prev = 0;
|
|
251
|
+
_context3.next = 3;
|
|
244
252
|
return init(P_START_TIMEOUT);
|
|
245
253
|
|
|
246
|
-
case
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return runTest(7200000);
|
|
254
|
+
case 3:
|
|
255
|
+
color.success('Initialization completed.');
|
|
256
|
+
_context3.next = 10;
|
|
257
|
+
break;
|
|
251
258
|
|
|
252
259
|
case 6:
|
|
260
|
+
_context3.prev = 6;
|
|
261
|
+
_context3.t0 = _context3["catch"](0);
|
|
262
|
+
color.error('Initialization failed.');
|
|
263
|
+
throw _context3.t0;
|
|
264
|
+
|
|
265
|
+
case 10:
|
|
266
|
+
_context3.next = 12;
|
|
267
|
+
return runTest(7200000);
|
|
268
|
+
|
|
269
|
+
case 12:
|
|
253
270
|
r = _context3.sent;
|
|
254
271
|
|
|
255
272
|
if (r.csv && args.csv) {
|
|
@@ -272,19 +289,19 @@ function test(args) {
|
|
|
272
289
|
|
|
273
290
|
|
|
274
291
|
if (!(browser != null)) {
|
|
275
|
-
_context3.next =
|
|
292
|
+
_context3.next = 20;
|
|
276
293
|
break;
|
|
277
294
|
}
|
|
278
295
|
|
|
279
|
-
_context3.next =
|
|
296
|
+
_context3.next = 20;
|
|
280
297
|
return browser.close();
|
|
281
298
|
|
|
282
|
-
case
|
|
299
|
+
case 20:
|
|
283
300
|
case "end":
|
|
284
301
|
return _context3.stop();
|
|
285
302
|
}
|
|
286
303
|
}
|
|
287
|
-
}, _callee3);
|
|
304
|
+
}, _callee3, null, [[0, 6]]);
|
|
288
305
|
}))();
|
|
289
306
|
}
|
|
290
307
|
|
package/bin/utils/test-utils.js
CHANGED
|
@@ -266,20 +266,28 @@ function runWithTimeout(timeout, f) {
|
|
|
266
266
|
timeoutId = setTimeout(function () {
|
|
267
267
|
return reject("Timeout exceeded: ".concat(timeout, " ms"));
|
|
268
268
|
}, timeout);
|
|
269
|
-
_context.
|
|
269
|
+
_context.prev = 1;
|
|
270
|
+
_context.next = 4;
|
|
270
271
|
return f();
|
|
271
272
|
|
|
272
|
-
case
|
|
273
|
+
case 4:
|
|
273
274
|
resolveValue = _context.sent;
|
|
274
275
|
clearTimeout(timeoutId);
|
|
275
276
|
resolve(resolveValue);
|
|
277
|
+
_context.next = 12;
|
|
278
|
+
break;
|
|
279
|
+
|
|
280
|
+
case 9:
|
|
281
|
+
_context.prev = 9;
|
|
282
|
+
_context.t0 = _context["catch"](1);
|
|
283
|
+
reject(_context.t0);
|
|
276
284
|
|
|
277
|
-
case
|
|
285
|
+
case 12:
|
|
278
286
|
case "end":
|
|
279
287
|
return _context.stop();
|
|
280
288
|
}
|
|
281
289
|
}
|
|
282
|
-
}, _callee);
|
|
290
|
+
}, _callee, null, [[1, 9]]);
|
|
283
291
|
}));
|
|
284
292
|
|
|
285
293
|
return function (_x6, _x7) {
|
package/package.json
CHANGED