datagrok-tools 4.7.7 → 4.7.9
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 +76 -21
- package/bin/commands/publish.js +18 -16
- package/bin/utils/interfaces.js +1 -0
- package/bin/utils/utils.js +13 -2
- package/package.json +1 -1
package/bin/commands/check.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
@@ -10,8 +10,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
10
10
|
exports.check = check;
|
|
11
11
|
exports.checkFuncSignatures = checkFuncSignatures;
|
|
12
12
|
exports.checkImportStatements = checkImportStatements;
|
|
13
|
+
exports.checkPackageFile = checkPackageFile;
|
|
13
14
|
exports.extractExternals = extractExternals;
|
|
14
15
|
|
|
16
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
|
+
|
|
15
18
|
var _fs = _interopRequireDefault(require("fs"));
|
|
16
19
|
|
|
17
20
|
var _path = _interopRequireDefault(require("path"));
|
|
@@ -24,7 +27,7 @@ var color = _interopRequireWildcard(require("../utils/color-utils"));
|
|
|
24
27
|
|
|
25
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
26
29
|
|
|
27
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
|
|
28
31
|
|
|
29
32
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
30
33
|
|
|
@@ -34,7 +37,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
34
37
|
|
|
35
38
|
function check(args) {
|
|
36
39
|
var nOptions = Object.keys(args).length - 1;
|
|
37
|
-
if (args['_'].length !== 1 || nOptions >
|
|
40
|
+
if (args['_'].length !== 1 || nOptions > 0 && (!args.dir || typeof args.dir !== 'string') || nOptions > 1) return false;
|
|
38
41
|
var curDir = process.cwd();
|
|
39
42
|
|
|
40
43
|
if (args.dir && typeof args.dir === 'string') {
|
|
@@ -84,14 +87,11 @@ function check(args) {
|
|
|
84
87
|
});
|
|
85
88
|
|
|
86
89
|
var externals = extractExternals(content);
|
|
87
|
-
if (externals) checkImportStatements(packagePath, jsTsFiles, externals)
|
|
88
|
-
return color.warn(warning);
|
|
89
|
-
});
|
|
90
|
+
if (externals) warn(checkImportStatements(packagePath, jsTsFiles, externals));
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
checkFuncSignatures(packagePath, funcFiles)
|
|
93
|
-
|
|
94
|
-
});
|
|
93
|
+
warn(checkFuncSignatures(packagePath, funcFiles));
|
|
94
|
+
warn(checkPackageFile(packagePath));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
return true;
|
|
@@ -334,11 +334,66 @@ function checkFuncSignatures(packagePath, files) {
|
|
|
334
334
|
return warnings;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
function checkPackageFile(packagePath) {
|
|
338
|
+
var warnings = [];
|
|
339
|
+
|
|
340
|
+
var packageFilePath = _path["default"].join(packagePath, 'package.json');
|
|
341
|
+
|
|
342
|
+
var json = JSON.parse(_fs["default"].readFileSync(packageFilePath, {
|
|
343
|
+
encoding: 'utf-8'
|
|
344
|
+
}));
|
|
345
|
+
var isPublicPackage = _path["default"].basename(_path["default"].dirname(packagePath)) === 'packages' && _path["default"].basename(_path["default"].dirname(_path["default"].dirname(packagePath))) === 'public';
|
|
346
|
+
if (!json.description) warnings.push('File "package.json": "description" field is empty. Provide a package description.');
|
|
347
|
+
|
|
348
|
+
if (Array.isArray(json.properties) && json.properties.length > 0) {
|
|
349
|
+
var _iterator5 = _createForOfIteratorHelper(json.properties),
|
|
350
|
+
_step5;
|
|
351
|
+
|
|
352
|
+
try {
|
|
353
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
354
|
+
var propInfo = _step5.value;
|
|
355
|
+
if ((0, _typeof2["default"])(propInfo) !== 'object') warnings.push('File "package.json": Invalid property annotation in the "properties" field.');else if (!propInfo.name) warnings.push('File "package.json": Add a property name for each property in the "properties" field.');else if (!utils.propertyTypes.includes(propInfo.propertyType)) warnings.push("File \"package.json\": Invalid property type for property ".concat(propInfo.name, "."));
|
|
356
|
+
}
|
|
357
|
+
} catch (err) {
|
|
358
|
+
_iterator5.e(err);
|
|
359
|
+
} finally {
|
|
360
|
+
_iterator5.f();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (json.repository == null && isPublicPackage) warnings.push('File "package.json": add the "repository" field.');
|
|
365
|
+
if (json.author == null && isPublicPackage) warnings.push('File "package.json": add the "author" field.');
|
|
366
|
+
|
|
367
|
+
if (Array.isArray(json.sources) && json.sources.length > 0) {
|
|
368
|
+
var _iterator6 = _createForOfIteratorHelper(json.sources),
|
|
369
|
+
_step6;
|
|
370
|
+
|
|
371
|
+
try {
|
|
372
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
373
|
+
var source = _step6.value;
|
|
374
|
+
if (typeof source !== 'string') warnings.push("File \"package.json\": Only file paths and URLs are allowed in sources. Modify the source ".concat(source));
|
|
375
|
+
if (source.startsWith('common/') || utils.absUrlRegex.test(source)) continue;
|
|
376
|
+
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."));
|
|
377
|
+
if (!_fs["default"].existsSync(_path["default"].join(packagePath, source))) warnings.push("Source ".concat(source, " not found in the package."));
|
|
378
|
+
}
|
|
379
|
+
} catch (err) {
|
|
380
|
+
_iterator6.e(err);
|
|
381
|
+
} finally {
|
|
382
|
+
_iterator6.f();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
return warnings;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function warn(warnings) {
|
|
390
|
+
warnings.forEach(function (w) {
|
|
391
|
+
return color.warn(w);
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
337
395
|
function getFuncMetadata(script) {
|
|
338
396
|
var funcData = [];
|
|
339
|
-
var headerTags = ['name', 'description', 'help-url', 'input', 'output', 'tags', 'sample', 'language', 'returns', 'test', 'sidebar', 'condition', 'top-menu', 'environment', 'require', 'editor-for', 'schedule', 'reference', 'editor'];
|
|
340
|
-
var paramRegex = new RegExp("//\\s*(".concat(headerTags.join('|'), "|meta\\.[^:]*): *(\\S+) ?(\\S+)?"));
|
|
341
|
-
var nameRegex = /(?:|static|export\s+function|export\s+async\s+function)\s+([a-zA-Z_][a-zA-Z0-9_$]*)\s*\((.*?)\).*/;
|
|
342
397
|
var isHeader = false;
|
|
343
398
|
var data = {
|
|
344
399
|
name: '',
|
|
@@ -346,14 +401,14 @@ function getFuncMetadata(script) {
|
|
|
346
401
|
outputs: []
|
|
347
402
|
};
|
|
348
403
|
|
|
349
|
-
var
|
|
350
|
-
|
|
404
|
+
var _iterator7 = _createForOfIteratorHelper(script.split('\n')),
|
|
405
|
+
_step7;
|
|
351
406
|
|
|
352
407
|
try {
|
|
353
|
-
for (
|
|
354
|
-
var line =
|
|
408
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
409
|
+
var line = _step7.value;
|
|
355
410
|
if (!line) continue;
|
|
356
|
-
var match = line.match(paramRegex);
|
|
411
|
+
var match = line.match(utils.paramRegex);
|
|
357
412
|
|
|
358
413
|
if (match) {
|
|
359
414
|
if (!isHeader) isHeader = true;
|
|
@@ -368,9 +423,9 @@ function getFuncMetadata(script) {
|
|
|
368
423
|
}
|
|
369
424
|
|
|
370
425
|
if (isHeader) {
|
|
371
|
-
var nm = line.match(nameRegex);
|
|
426
|
+
var nm = line.match(utils.nameRegex);
|
|
372
427
|
|
|
373
|
-
if (nm && !line.match(paramRegex)) {
|
|
428
|
+
if (nm && !line.match(utils.paramRegex)) {
|
|
374
429
|
data.name = data.name || nm[1];
|
|
375
430
|
funcData.push(data);
|
|
376
431
|
data = {
|
|
@@ -383,9 +438,9 @@ function getFuncMetadata(script) {
|
|
|
383
438
|
}
|
|
384
439
|
}
|
|
385
440
|
} catch (err) {
|
|
386
|
-
|
|
441
|
+
_iterator7.e(err);
|
|
387
442
|
} finally {
|
|
388
|
-
|
|
443
|
+
_iterator7.f();
|
|
389
444
|
}
|
|
390
445
|
|
|
391
446
|
return funcData;
|
package/bin/commands/publish.js
CHANGED
|
@@ -62,7 +62,7 @@ function processPackage(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
|
62
62
|
|
|
63
63
|
function _processPackage() {
|
|
64
64
|
_processPackage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(debug, rebuild, host, devKey, packageName, suffix) {
|
|
65
|
-
var timestamps, url, zip, localTimestamps, files, isWebpack, distFiles, contentValidationLog, checkStart, jsTsFiles, webpackConfigPath, content, externals, importWarnings, funcFiles, funcWarnings, uploadPromise, log;
|
|
65
|
+
var timestamps, url, zip, localTimestamps, files, isWebpack, distFiles, contentValidationLog, checkStart, jsTsFiles, webpackConfigPath, content, externals, importWarnings, funcFiles, funcWarnings, packageWarnings, uploadPromise, log;
|
|
66
66
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
67
67
|
while (1) {
|
|
68
68
|
switch (_context3.prev = _context3.next) {
|
|
@@ -179,6 +179,8 @@ function _processPackage() {
|
|
|
179
179
|
});
|
|
180
180
|
funcWarnings = (0, _check.checkFuncSignatures)(curDir, funcFiles);
|
|
181
181
|
contentValidationLog += funcWarnings.join('\n') + (funcWarnings.length ? '\n' : '');
|
|
182
|
+
packageWarnings = (0, _check.checkPackageFile)(curDir);
|
|
183
|
+
contentValidationLog += packageWarnings.join('\n') + (packageWarnings.length ? '\n' : '');
|
|
182
184
|
console.log("Checks finished in ".concat(Date.now() - checkStart, " ms"));
|
|
183
185
|
files.forEach(function (file) {
|
|
184
186
|
var fullPath = file;
|
|
@@ -265,21 +267,21 @@ function _processPackage() {
|
|
|
265
267
|
})["catch"](function (error) {
|
|
266
268
|
console.error(error);
|
|
267
269
|
});
|
|
268
|
-
_context3.next =
|
|
270
|
+
_context3.next = 52;
|
|
269
271
|
return zip.finalize();
|
|
270
272
|
|
|
271
|
-
case
|
|
272
|
-
_context3.prev =
|
|
273
|
-
_context3.next =
|
|
273
|
+
case 52:
|
|
274
|
+
_context3.prev = 52;
|
|
275
|
+
_context3.next = 55;
|
|
274
276
|
return uploadPromise;
|
|
275
277
|
|
|
276
|
-
case
|
|
278
|
+
case 55:
|
|
277
279
|
log = _context3.sent;
|
|
278
280
|
|
|
279
281
|
_fs["default"].unlinkSync('zip');
|
|
280
282
|
|
|
281
283
|
if (!(log['#type'] === 'ApiError')) {
|
|
282
|
-
_context3.next =
|
|
284
|
+
_context3.next = 63;
|
|
283
285
|
break;
|
|
284
286
|
}
|
|
285
287
|
|
|
@@ -287,29 +289,29 @@ function _processPackage() {
|
|
|
287
289
|
console.error(log['innerMessage']);
|
|
288
290
|
return _context3.abrupt("return", 1);
|
|
289
291
|
|
|
290
|
-
case
|
|
292
|
+
case 63:
|
|
291
293
|
console.log(log);
|
|
292
294
|
color.warn(contentValidationLog);
|
|
293
295
|
|
|
294
|
-
case
|
|
295
|
-
_context3.next =
|
|
296
|
+
case 65:
|
|
297
|
+
_context3.next = 71;
|
|
296
298
|
break;
|
|
297
299
|
|
|
298
|
-
case
|
|
299
|
-
_context3.prev =
|
|
300
|
-
_context3.t1 = _context3["catch"](
|
|
300
|
+
case 67:
|
|
301
|
+
_context3.prev = 67;
|
|
302
|
+
_context3.t1 = _context3["catch"](52);
|
|
301
303
|
console.error(_context3.t1);
|
|
302
304
|
return _context3.abrupt("return", 1);
|
|
303
305
|
|
|
304
|
-
case
|
|
306
|
+
case 71:
|
|
305
307
|
return _context3.abrupt("return", 0);
|
|
306
308
|
|
|
307
|
-
case
|
|
309
|
+
case 72:
|
|
308
310
|
case "end":
|
|
309
311
|
return _context3.stop();
|
|
310
312
|
}
|
|
311
313
|
}
|
|
312
|
-
}, _callee3, null, [[3, 14], [
|
|
314
|
+
}, _callee3, null, [[3, 14], [52, 67]]);
|
|
313
315
|
}));
|
|
314
316
|
return _processPackage.apply(this, arguments);
|
|
315
317
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/bin/utils/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.TemplateBuilder = void 0;
|
|
8
|
+
exports.absUrlRegex = exports.TemplateBuilder = void 0;
|
|
9
9
|
exports.camelCaseToKebab = camelCaseToKebab;
|
|
10
10
|
exports.checkScriptLocation = checkScriptLocation;
|
|
11
11
|
exports.dgToTsTypeMap = exports.dgImports = exports.commentMap = void 0;
|
|
@@ -14,11 +14,12 @@ exports.getParam = getParam;
|
|
|
14
14
|
exports.getScriptInputs = getScriptInputs;
|
|
15
15
|
exports.getScriptName = getScriptName;
|
|
16
16
|
exports.getScriptOutputType = getScriptOutputType;
|
|
17
|
+
exports.headerTags = void 0;
|
|
17
18
|
exports.isEmpty = isEmpty;
|
|
18
19
|
exports.isPackageDir = isPackageDir;
|
|
19
20
|
exports.kebabToCamelCase = kebabToCamelCase;
|
|
20
21
|
exports.mapURL = mapURL;
|
|
21
|
-
exports.queryWrapperTemplate = exports.queryExtension = exports.namespaceTemplate = void 0;
|
|
22
|
+
exports.queryWrapperTemplate = exports.queryExtension = exports.propertyTypes = exports.paramRegex = exports.namespaceTemplate = exports.nameRegex = void 0;
|
|
22
23
|
exports.removeScope = removeScope;
|
|
23
24
|
exports.scriptWrapperTemplate = exports.scriptLangExtMap = exports.scriptExtensions = exports.replacers = void 0;
|
|
24
25
|
exports.spaceToCamelCase = spaceToCamelCase;
|
|
@@ -264,6 +265,16 @@ var dgToTsTypeMap = {
|
|
|
264
265
|
file: 'DG.FileInfo'
|
|
265
266
|
};
|
|
266
267
|
exports.dgToTsTypeMap = dgToTsTypeMap;
|
|
268
|
+
var propertyTypes = ['bool', 'int', 'float', 'string', 'datetime', 'object', 'column', 'dataframe', 'bitset', 'cell', 'string_list', 'map'];
|
|
269
|
+
exports.propertyTypes = propertyTypes;
|
|
270
|
+
var headerTags = ['name', 'description', 'help-url', 'input', 'output', 'tags', 'sample', 'language', 'returns', 'test', 'sidebar', 'condition', 'top-menu', 'environment', 'require', 'editor-for', 'schedule', 'reference', 'editor'];
|
|
271
|
+
exports.headerTags = headerTags;
|
|
272
|
+
var paramRegex = new RegExp("//\\s*(".concat(headerTags.join('|'), "|meta\\.[^:]*): *(\\S+) ?(\\S+)?"));
|
|
273
|
+
exports.paramRegex = paramRegex;
|
|
274
|
+
var nameRegex = /(?:|static|export\s+function|export\s+async\s+function)\s+([a-zA-Z_][a-zA-Z0-9_$]*)\s*\((.*?)\).*/;
|
|
275
|
+
exports.nameRegex = nameRegex;
|
|
276
|
+
var absUrlRegex = new RegExp('^(?:[a-z+]+:)?//', 'i');
|
|
277
|
+
exports.absUrlRegex = absUrlRegex;
|
|
267
278
|
|
|
268
279
|
function getScriptOutputType(script) {
|
|
269
280
|
var comment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '#';
|
package/package.json
CHANGED