datagrok-tools 4.13.74 → 4.13.76

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.
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof3 = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -13,25 +12,19 @@ exports.checkNpmIgnore = checkNpmIgnore;
13
12
  exports.checkPackageFile = checkPackageFile;
14
13
  exports.checkSourceMap = checkSourceMap;
15
14
  exports.extractExternals = extractExternals;
16
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
18
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
19
15
  var _fs = _interopRequireDefault(require("fs"));
20
16
  var _path = _interopRequireDefault(require("path"));
21
17
  var _ignoreWalk = _interopRequireDefault(require("ignore-walk"));
22
18
  var utils = _interopRequireWildcard(require("../utils/utils"));
23
19
  var color = _interopRequireWildcard(require("../utils/color-utils"));
24
20
  var testUtils = _interopRequireWildcard(require("../utils/test-utils"));
25
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
26
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
27
- 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; } } }; }
28
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
29
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
30
- var warns = ['Latest package version', 'Datagrok API version should contain'];
21
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
22
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
+ const warns = ['Latest package version', 'Datagrok API version should contain'];
31
24
  function check(args) {
32
- var nOptions = Object.keys(args).length - 1;
25
+ const nOptions = Object.keys(args).length - 1;
33
26
  if (args['_'].length !== 1 || nOptions > 2 || nOptions > 0 && !args.r && !args.recursive) return false;
34
- var curDir = process.cwd();
27
+ const curDir = process.cwd();
35
28
  if (args.recursive) return runChecksRec(curDir);else {
36
29
  if (!utils.isPackageDir(curDir)) {
37
30
  color.error('File `package.json` not found. Run the command from the package directory');
@@ -41,90 +34,75 @@ function check(args) {
41
34
  }
42
35
  }
43
36
  function runChecks(packagePath) {
44
- var files = _ignoreWalk["default"].sync({
37
+ const files = _ignoreWalk.default.sync({
45
38
  path: packagePath,
46
39
  ignoreFiles: ['.npmignore', '.gitignore']
47
40
  });
48
- var jsTsFiles = files.filter(function (f) {
49
- return !f.startsWith('dist/') && (f.endsWith('.js') || f.endsWith('.ts') || f.endsWith('.sql') || f.endsWith('.py'));
50
- });
51
- var packageFiles = ['src/package.ts', 'src/detectors.ts', 'src/package.js', 'src/detectors.js', 'src/package-test.ts', 'src/package-test.js', 'package.js', 'detectors.js'];
41
+ const jsTsFiles = files.filter(f => !f.startsWith('dist/') && (f.endsWith('.js') || f.endsWith('.ts') || f.endsWith('.sql') || f.endsWith('.py')));
42
+ const packageFiles = ['src/package.ts', 'src/detectors.ts', 'src/package.js', 'src/detectors.js', 'src/package-test.ts', 'src/package-test.js', 'package.js', 'detectors.js'];
52
43
  // const funcFiles = jsTsFiles.filter((f) => packageFiles.includes(f));
53
- var errors = [];
54
- var warnings = [];
55
- var packageFilePath = _path["default"].join(packagePath, 'package.json');
56
- var json = JSON.parse(_fs["default"].readFileSync(packageFilePath, {
44
+ const errors = [];
45
+ const warnings = [];
46
+ const packageFilePath = _path.default.join(packagePath, 'package.json');
47
+ const json = JSON.parse(_fs.default.readFileSync(packageFilePath, {
57
48
  encoding: 'utf-8'
58
49
  }));
59
- var webpackConfigPath = _path["default"].join(packagePath, 'webpack.config.js');
60
- var isWebpack = _fs["default"].existsSync(webpackConfigPath);
61
- var isReleaseCandidateVersion = false;
62
- var externals = null;
50
+ const webpackConfigPath = _path.default.join(packagePath, 'webpack.config.js');
51
+ const isWebpack = _fs.default.existsSync(webpackConfigPath);
52
+ let isReleaseCandidateVersion = false;
53
+ let externals = null;
63
54
  if (/\d+.\d+.\d+-rc(.[A-Za-z0-9]*.[A-Za-z0-9]*)?/.test(json.version)) isReleaseCandidateVersion = true;
64
55
  if (isWebpack) {
65
- var content = _fs["default"].readFileSync(webpackConfigPath, {
56
+ const content = _fs.default.readFileSync(webpackConfigPath, {
66
57
  encoding: 'utf-8'
67
58
  });
68
59
  externals = extractExternals(content);
69
- if (externals) errors.push.apply(errors, (0, _toConsumableArray2["default"])(checkImportStatements(packagePath, jsTsFiles, externals)));
60
+ if (externals) errors.push(...checkImportStatements(packagePath, jsTsFiles, externals));
70
61
  }
71
- errors.push.apply(errors, (0, _toConsumableArray2["default"])(checkSourceMap(packagePath)));
72
- errors.push.apply(errors, (0, _toConsumableArray2["default"])(checkNpmIgnore(packagePath)));
73
- warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkScriptNames(packagePath)));
74
- errors.push.apply(errors, (0, _toConsumableArray2["default"])(checkFuncSignatures(packagePath, jsTsFiles)));
75
- errors.push.apply(errors, (0, _toConsumableArray2["default"])(checkPackageFile(packagePath, json, {
76
- isWebpack: isWebpack,
77
- externals: externals,
78
- isReleaseCandidateVersion: isReleaseCandidateVersion
79
- })));
80
- if (!isReleaseCandidateVersion) warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkChangelog(packagePath, json)));
62
+ errors.push(...checkSourceMap(packagePath));
63
+ errors.push(...checkNpmIgnore(packagePath));
64
+ warnings.push(...checkScriptNames(packagePath));
65
+ errors.push(...checkFuncSignatures(packagePath, jsTsFiles));
66
+ errors.push(...checkPackageFile(packagePath, json, {
67
+ isWebpack,
68
+ externals,
69
+ isReleaseCandidateVersion
70
+ }));
71
+ if (!isReleaseCandidateVersion) warnings.push(...checkChangelog(packagePath, json));
81
72
  if (warnings.length) {
82
- console.log("".concat(_path["default"].basename(packagePath), " warnings"));
73
+ console.log(`${_path.default.basename(packagePath)} warnings`);
83
74
  warn(warnings);
84
75
  }
85
76
  if (errors.length) {
86
- console.log("Checking package ".concat(_path["default"].basename(packagePath), "..."));
77
+ console.log(`Checking package ${_path.default.basename(packagePath)}...`);
87
78
  showError(errors);
88
- if (json.version.startsWith('0') || errors.every(function (w) {
89
- return warns.some(function (ww) {
90
- return w.includes(ww);
91
- });
92
- })) return true;
79
+ if (json.version.startsWith('0') || errors.every(w => warns.some(ww => w.includes(ww)))) return true;
93
80
  testUtils.exitWithCode(1);
94
81
  }
95
- console.log("Checking package ".concat(_path["default"].basename(packagePath), "...\t\t\t\u2713 OK"));
82
+ console.log(`Checking package ${_path.default.basename(packagePath)}...\t\t\t\u2713 OK`);
96
83
  return true;
97
84
  }
98
85
  function runChecksRec(dir) {
99
- var files = _fs["default"].readdirSync(dir);
100
- var _iterator = _createForOfIteratorHelper(files),
101
- _step;
102
- try {
103
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
104
- var file = _step.value;
105
- var filepath = _path["default"].join(dir, file);
106
- var stats = _fs["default"].statSync(filepath);
107
- if (stats.isDirectory()) {
108
- if (utils.isPackageDir(filepath)) return runChecks(filepath);else {
109
- if (file !== 'node_modules' && !file.startsWith('.')) runChecksRec(_path["default"].join(dir, file));
110
- }
86
+ const files = _fs.default.readdirSync(dir);
87
+ for (const file of files) {
88
+ const filepath = _path.default.join(dir, file);
89
+ const stats = _fs.default.statSync(filepath);
90
+ if (stats.isDirectory()) {
91
+ if (utils.isPackageDir(filepath)) return runChecks(filepath);else {
92
+ if (file !== 'node_modules' && !file.startsWith('.')) runChecksRec(_path.default.join(dir, file));
111
93
  }
112
94
  }
113
- } catch (err) {
114
- _iterator.e(err);
115
- } finally {
116
- _iterator.f();
117
95
  }
118
96
  return false;
119
97
  }
120
98
  function extractExternals(config) {
121
- var externalsRegex = /(?<=externals)\s*:\s*(\{[\S\s]*?\})/;
122
- var match = config.match(externalsRegex);
99
+ const externalsRegex = /(?<=externals)\s*:\s*(\{[\S\s]*?\})/;
100
+ const match = config.match(externalsRegex);
123
101
  if (match) {
124
102
  // Replace single quotes, comments, and a trailing comma to make a string JSON-like
125
- var externalStr = match[1].replace(/'/g, '"').replace(/\/\/.*(\r\n|\r|\n)/, '').replace(/(?<=[\S\s]),(?=\s*\})/, '');
103
+ const externalStr = match[1].replace(/'/g, '"').replace(/\/\/.*(\r\n|\r|\n)/, '').replace(/(?<=[\S\s]),(?=\s*\})/, '');
126
104
  try {
127
- var externals = JSON.parse(externalStr);
105
+ const externals = JSON.parse(externalStr);
128
106
  return externals;
129
107
  } catch (e) {
130
108
  return null;
@@ -133,63 +111,46 @@ function extractExternals(config) {
133
111
  return null;
134
112
  }
135
113
  function checkImportStatements(packagePath, files, externals) {
136
- var modules = [];
137
- for (var _key in externals) {
138
- modules.push(_key);
139
- if (_key.includes('/')) modules.push(_key.split('/', 1)[0]);
114
+ const modules = [];
115
+ for (const key in externals) {
116
+ modules.push(key);
117
+ if (key.includes('/')) modules.push(key.split('/', 1)[0]);
140
118
  }
141
- var importRegex = new RegExp("^(?!\\/{2})\\s*import\\s+.*(".concat(modules.join('|'), ").*(?=\\s+?)"), 'g');
142
- var validImportRegex = new RegExp("import\\s+.*(".concat(Object.keys(externals).join('|'), ")['\"]{1}"));
143
- var warnings = [];
119
+ const importRegex = new RegExp(`^(?!\\/{2})\\s*import\\s+.*(${modules.join('|')}).*(?=\\s+?)`, 'g');
120
+ const validImportRegex = new RegExp(`import\\s+.*(${Object.keys(externals).join('|')})['"]{1}`);
121
+ const warnings = [];
144
122
  function validateImport(file, s) {
145
- var value = validImportRegex.test(s);
146
- var message = value ? '' : 'Pay attention to file ' + file + ': import statement `' + s + '` differs from the path given in the webpack config as an external module. ' + 'It can increase the bundle size.';
123
+ const value = validImportRegex.test(s);
124
+ const message = value ? '' : 'Pay attention to file ' + file + ': import statement `' + s + '` differs from the path given in the webpack config as an external module. ' + 'It can increase the bundle size.';
147
125
  return {
148
- value: value,
149
- message: message
126
+ value,
127
+ message
150
128
  };
151
129
  }
152
- var _iterator2 = _createForOfIteratorHelper(files),
153
- _step2;
154
- try {
155
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
156
- var file = _step2.value;
157
- var content = _fs["default"].readFileSync(_path["default"].join(packagePath, file), {
158
- encoding: 'utf-8'
159
- });
160
- var matchedImports = content.match(importRegex);
161
- if (matchedImports) {
162
- var _iterator3 = _createForOfIteratorHelper(matchedImports),
163
- _step3;
164
- try {
165
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
166
- var match = _step3.value;
167
- var vr = validateImport(file, match);
168
- if (!vr.value) warnings.push(vr.message);
169
- }
170
- } catch (err) {
171
- _iterator3.e(err);
172
- } finally {
173
- _iterator3.f();
174
- }
130
+ for (const file of files) {
131
+ const content = _fs.default.readFileSync(_path.default.join(packagePath, file), {
132
+ encoding: 'utf-8'
133
+ });
134
+ const matchedImports = content.match(importRegex);
135
+ if (matchedImports) {
136
+ for (const match of matchedImports) {
137
+ const vr = validateImport(file, match);
138
+ if (!vr.value) warnings.push(vr.message);
175
139
  }
176
140
  }
177
- } catch (err) {
178
- _iterator2.e(err);
179
- } finally {
180
- _iterator2.f();
181
141
  }
182
142
  return warnings;
183
143
  }
184
144
  function checkFuncSignatures(packagePath, files) {
185
- var warnings = [];
186
- var checkFunctions = {
187
- app: function app(_ref) {
188
- var name = _ref.name;
189
- var value = true;
190
- var message = '';
145
+ const warnings = [];
146
+ const checkFunctions = {
147
+ app: ({
148
+ name
149
+ }) => {
150
+ let value = true;
151
+ let message = '';
191
152
  if (name && typeof name === 'string') {
192
- var lowerCaseName = name.toLocaleLowerCase();
153
+ const lowerCaseName = name.toLocaleLowerCase();
193
154
  if (lowerCaseName.startsWith('app')) {
194
155
  value = false;
195
156
  message += 'Prefix "App" is not needed. Consider removing it.\n';
@@ -200,15 +161,16 @@ function checkFuncSignatures(packagePath, files) {
200
161
  }
201
162
  }
202
163
  return {
203
- value: value,
204
- message: message
164
+ value,
165
+ message
205
166
  };
206
167
  },
207
- semTypeDetector: function semTypeDetector(_ref2) {
208
- var inputs = _ref2.inputs,
209
- outputs = _ref2.outputs;
210
- var value = true;
211
- var message = '';
168
+ semTypeDetector: ({
169
+ inputs,
170
+ outputs
171
+ }) => {
172
+ let value = true;
173
+ let message = '';
212
174
  if (inputs.length !== 1 || inputs[0].type !== 'column') {
213
175
  value = false;
214
176
  message += 'Semantic type detectors must have one input of type "column"\n';
@@ -218,15 +180,16 @@ function checkFuncSignatures(packagePath, files) {
218
180
  message += 'Semantic type detectors must have one output of type "string"\n';
219
181
  }
220
182
  return {
221
- value: value,
222
- message: message
183
+ value,
184
+ message
223
185
  };
224
186
  },
225
- cellRenderer: function cellRenderer(_ref3) {
226
- var inputs = _ref3.inputs,
227
- outputs = _ref3.outputs;
228
- var value = true;
229
- var message = '';
187
+ cellRenderer: ({
188
+ inputs,
189
+ outputs
190
+ }) => {
191
+ let value = true;
192
+ let message = '';
230
193
  if (inputs.length !== 0) {
231
194
  value = false;
232
195
  message += 'Cell renderer functions should take no arguments\n';
@@ -236,15 +199,16 @@ function checkFuncSignatures(packagePath, files) {
236
199
  message += 'Cell renderer functions must have one output of type "grid_cell_renderer"\n';
237
200
  }
238
201
  return {
239
- value: value,
240
- message: message
202
+ value,
203
+ message
241
204
  };
242
205
  },
243
- viewer: function viewer(_ref4) {
244
- var inputs = _ref4.inputs,
245
- outputs = _ref4.outputs;
246
- var value = true;
247
- var message = '';
206
+ viewer: ({
207
+ inputs,
208
+ outputs
209
+ }) => {
210
+ let value = true;
211
+ let message = '';
248
212
  if (inputs.length !== 0) {
249
213
  value = false;
250
214
  message += 'Viewer functions should take no arguments\n';
@@ -254,16 +218,17 @@ function checkFuncSignatures(packagePath, files) {
254
218
  message += 'Viewers must have one output of type "viewer"\n';
255
219
  }
256
220
  return {
257
- value: value,
258
- message: message
221
+ value,
222
+ message
259
223
  };
260
224
  },
261
- fileViewer: function fileViewer(_ref5) {
262
- var inputs = _ref5.inputs,
263
- outputs = _ref5.outputs,
264
- tags = _ref5.tags;
265
- var value = true;
266
- var message = '';
225
+ fileViewer: ({
226
+ inputs,
227
+ outputs,
228
+ tags
229
+ }) => {
230
+ let value = true;
231
+ let message = '';
267
232
  if (tags == null || tags.length !== 1 && tags[0] !== 'fileViewer') {
268
233
  value = false;
269
234
  message += 'File viewers must have only one tag: "fileViewer"\n';
@@ -277,118 +242,86 @@ function checkFuncSignatures(packagePath, files) {
277
242
  message += 'File viewers must have one output of type "view"\n';
278
243
  }
279
244
  return {
280
- value: value,
281
- message: message
245
+ value,
246
+ message
282
247
  };
283
248
  },
284
- fileExporter: function fileExporter(_ref6) {
285
- var description = _ref6.description;
286
- var value = true;
287
- var message = '';
249
+ fileExporter: ({
250
+ description
251
+ }) => {
252
+ let value = true;
253
+ let message = '';
288
254
  if (description == null || description === '') {
289
255
  value = false;
290
256
  message += 'File exporters should have a description parameter\n';
291
257
  }
292
258
  return {
293
- value: value,
294
- message: message
259
+ value,
260
+ message
295
261
  };
296
262
  },
297
- packageSettingsEditor: function packageSettingsEditor(_ref7) {
298
- var outputs = _ref7.outputs;
299
- var value = true;
300
- var message = '';
263
+ packageSettingsEditor: ({
264
+ outputs
265
+ }) => {
266
+ let value = true;
267
+ let message = '';
301
268
  if (!(outputs.length === 1 && outputs[0].type === 'widget')) {
302
269
  value = false;
303
270
  message += 'Package settings editors must have one output of type "widget"\n';
304
271
  }
305
272
  return {
306
- value: value,
307
- message: message
273
+ value,
274
+ message
308
275
  };
309
276
  },
310
- params: function params(_ref8) {
311
- var inputs = _ref8.inputs,
312
- outputs = _ref8.outputs;
313
- var value = true;
314
- var message = '';
315
- var _iterator4 = _createForOfIteratorHelper(inputs),
316
- _step4;
317
- try {
318
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
319
- var input = _step4.value;
320
- if (!(input.name && input.type)) {
321
- value = false;
322
- message += "Function has no name or type of input parameter\n";
323
- }
277
+ params: ({
278
+ inputs,
279
+ outputs
280
+ }) => {
281
+ let value = true;
282
+ let message = '';
283
+ for (const input of inputs) {
284
+ if (!(input.name && input.type)) {
285
+ value = false;
286
+ message += `Function has no name or type of input parameter\n`;
324
287
  }
325
- } catch (err) {
326
- _iterator4.e(err);
327
- } finally {
328
- _iterator4.f();
329
288
  }
330
- var _iterator5 = _createForOfIteratorHelper(outputs),
331
- _step5;
332
- try {
333
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
334
- var output = _step5.value;
335
- if (!(output.name && output.type)) {
336
- value = false;
337
- message += "Function has no name or type of output parameter\n";
338
- }
289
+ for (const output of outputs) {
290
+ if (!(output.name && output.type)) {
291
+ value = false;
292
+ message += `Function has no name or type of output parameter\n`;
339
293
  }
340
- } catch (err) {
341
- _iterator5.e(err);
342
- } finally {
343
- _iterator5.f();
344
294
  }
345
295
  return {
346
- value: value,
347
- message: message
296
+ value,
297
+ message
348
298
  };
349
299
  }
350
300
  };
351
- var functionRoles = Object.keys(checkFunctions);
352
- var _iterator6 = _createForOfIteratorHelper(files),
353
- _step6;
354
- try {
355
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
356
- var _file$split$pop;
357
- var file = _step6.value;
358
- var content = _fs["default"].readFileSync(_path["default"].join(packagePath, file), {
359
- encoding: 'utf-8'
360
- });
361
- var functions = getFuncMetadata(content, (_file$split$pop = file.split('.').pop()) !== null && _file$split$pop !== void 0 ? _file$split$pop : 'ts');
362
- var _loop = function _loop() {
363
- var f = _functions[_i];
364
- var paramsCheck = checkFunctions.params(f);
365
- if (!paramsCheck.value) warnings.push("File ".concat(file, ", function ").concat(f.name, ":\n").concat(paramsCheck.message));
366
- var roles = functionRoles.filter(function (role) {
367
- var _f$tags;
368
- return (_f$tags = f.tags) === null || _f$tags === void 0 ? void 0 : _f$tags.includes(role);
369
- });
370
- if (roles.length > 1) warnings.push("File ".concat(file, ", function ").concat(f.name, ": several function roles are used (").concat(roles.join(', '), ")"));else if (roles.length === 1) {
371
- var vr = checkFunctions[roles[0]](f);
372
- if (!vr.value) {
373
- warnings.push("File ".concat(file, ", function ").concat(f.name, ":\n").concat(vr.message));
374
- }
301
+ const functionRoles = Object.keys(checkFunctions);
302
+ for (const file of files) {
303
+ const content = _fs.default.readFileSync(_path.default.join(packagePath, file), {
304
+ encoding: 'utf-8'
305
+ });
306
+ const functions = getFuncMetadata(content, file.split('.').pop() ?? 'ts');
307
+ for (const f of functions) {
308
+ const paramsCheck = checkFunctions.params(f);
309
+ if (!paramsCheck.value) warnings.push(`File ${file}, function ${f.name}:\n${paramsCheck.message}`);
310
+ const roles = functionRoles.filter(role => f.tags?.includes(role));
311
+ if (roles.length > 1) warnings.push(`File ${file}, function ${f.name}: several function roles are used (${roles.join(', ')})`);else if (roles.length === 1) {
312
+ const vr = checkFunctions[roles[0]](f);
313
+ if (!vr.value) {
314
+ warnings.push(`File ${file}, function ${f.name}:\n${vr.message}`);
375
315
  }
376
- if (f.isInvalidateOnWithoutCache) warnings.push("File ".concat(file, ", function ").concat(f.name, ": Can't use invalidateOn without cache, please follow this example: 'meta.cache.invalidateOn'"));
377
- if (f.cache) if (!utils.cahceValues.includes(f.cache)) warnings.push("File ".concat(file, ", function ").concat(f.name, ": unsupposed variable for cache : ").concat(f.cache));
378
- if (f.invalidateOn) if (!utils.isValidCron(f.invalidateOn)) warnings.push("File ".concat(file, ", function ").concat(f.name, ": unsupposed variable for invalidateOn : ").concat(f.invalidateOn));
379
- };
380
- for (var _i = 0, _functions = functions; _i < _functions.length; _i++) {
381
- _loop();
382
316
  }
317
+ if (f.isInvalidateOnWithoutCache) warnings.push(`File ${file}, function ${f.name}: Can't use invalidateOn without cache, please follow this example: 'meta.cache.invalidateOn'`);
318
+ if (f.cache) if (!utils.cahceValues.includes(f.cache)) warnings.push(`File ${file}, function ${f.name}: unsupposed variable for cache : ${f.cache}`);
319
+ if (f.invalidateOn) if (!utils.isValidCron(f.invalidateOn)) warnings.push(`File ${file}, function ${f.name}: unsupposed variable for invalidateOn : ${f.invalidateOn}`);
383
320
  }
384
- } catch (err) {
385
- _iterator6.e(err);
386
- } finally {
387
- _iterator6.f();
388
321
  }
389
322
  return warnings;
390
323
  }
391
- var sharedLibExternals = {
324
+ const sharedLibExternals = {
392
325
  'common/html2canvas.min.js': {
393
326
  'exceljs': 'ExcelJS'
394
327
  },
@@ -409,86 +342,61 @@ var sharedLibExternals = {
409
342
  }
410
343
  };
411
344
  function checkPackageFile(packagePath, json, options) {
412
- var _json$dependencies, _json$devDependencies, _json$devDependencies2, _json$dependencies2;
413
- var warnings = [];
414
- var isPublicPackage = _path["default"].basename(_path["default"].dirname(packagePath)) === 'packages' && _path["default"].basename(_path["default"].dirname(_path["default"].dirname(packagePath))) === 'public';
345
+ const warnings = [];
346
+ const isPublicPackage = _path.default.basename(_path.default.dirname(packagePath)) === 'packages' && _path.default.basename(_path.default.dirname(_path.default.dirname(packagePath))) === 'public';
415
347
  if (!json.description) warnings.push('File "package.json": "description" field is empty. Provide a package description.');
416
348
  if (Array.isArray(json.properties) && json.properties.length > 0) {
417
- var _iterator7 = _createForOfIteratorHelper(json.properties),
418
- _step7;
419
- try {
420
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
421
- var propInfo = _step7.value;
422
- 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, "."));
423
- }
424
- } catch (err) {
425
- _iterator7.e(err);
426
- } finally {
427
- _iterator7.f();
349
+ for (const propInfo of json.properties) {
350
+ if (typeof 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 ${propInfo.name}.`);
428
351
  }
429
352
  }
430
353
  if (json.repository == null && isPublicPackage) warnings.push('File "package.json": add the "repository" field.');
431
354
  if (json.author == null && isPublicPackage) warnings.push('File "package.json": add the "author" field.');
432
355
  if (json.version.includes('beta') && isPublicPackage) warnings.push('File "package.json": public package cannot be beta version.');
433
- var api = (_json$dependencies = json.dependencies) === null || _json$dependencies === void 0 ? void 0 : _json$dependencies['datagrok-api'];
356
+ const api = json.dependencies?.['datagrok-api'];
434
357
  if (api) {
435
- if (api === '../../js-api') {} else if (api === 'latest') warnings.push('File "package.json": you should specify Datagrok API version constraint (for example ^1.16.0, >=1.16.0).');else if ((options === null || options === void 0 ? void 0 : options.isReleaseCandidateVersion) === false && !/^(\^|>|<|~).+/.test(api)) warnings.push('File "package.json": Datagrok API version should starts with > | >= | ~ | ^ | < | <=');
358
+ if (api === '../../js-api') {} else if (api === 'latest') warnings.push('File "package.json": you should specify Datagrok API version constraint (for example ^1.16.0, >=1.16.0).');else if (options?.isReleaseCandidateVersion === false && !/^(\^|>|<|~).+/.test(api)) warnings.push('File "package.json": Datagrok API version should starts with > | >= | ~ | ^ | < | <=');
436
359
  }
437
- var dt = (_json$devDependencies = (_json$devDependencies2 = json.devDependencies) === null || _json$devDependencies2 === void 0 ? void 0 : _json$devDependencies2['datagrok-tools']) !== null && _json$devDependencies !== void 0 ? _json$devDependencies : (_json$dependencies2 = json.dependencies) === null || _json$dependencies2 === void 0 ? void 0 : _json$dependencies2['datagrok-tools'];
360
+ const dt = json.devDependencies?.['datagrok-tools'] ?? json.dependencies?.['datagrok-tools'];
438
361
  if (dt && dt !== 'latest') warnings.push('File "package.json": "datagrok-tools" dependency must be "latest" version.');
439
362
  if (Array.isArray(json.sources) && json.sources.length > 0) {
440
- var _iterator8 = _createForOfIteratorHelper(json.sources),
441
- _step8;
442
- try {
443
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
444
- var source = _step8.value;
445
- if (typeof source !== 'string') warnings.push("File \"package.json\": Only file paths and URLs are allowed in sources. Modify the source ".concat(source));
446
- if (utils.absUrlRegex.test(source)) continue;
447
- if (source.startsWith('common/')) {
448
- if (options !== null && options !== void 0 && options.isWebpack && source.endsWith('.js')) {
449
- if (options !== null && options !== void 0 && options.externals) {
450
- if (source in sharedLibExternals) {
451
- var _Object$entries$ = (0, _slicedToArray2["default"])(Object.entries(sharedLibExternals[source])[0], 2),
452
- _lib = _Object$entries$[0],
453
- name = _Object$entries$[1];
454
- if (!(_lib in options.externals && options.externals[_lib] === name)) {
455
- warnings.push("Webpack config parsing: Consider adding source \"".concat(source, "\" to webpack externals:\n") + "'".concat(_lib, "': '").concat(name, "'\n"));
456
- }
457
- } else warnings.push("File \"package.json\": source \"".concat(source, "\" not in the list of shared libraries"));
458
- } else {
459
- 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") : ''));
460
- }
363
+ for (const source of json.sources) {
364
+ if (typeof source !== 'string') warnings.push(`File "package.json": Only file paths and URLs are allowed in sources. Modify the source ${source}`);
365
+ if (utils.absUrlRegex.test(source)) continue;
366
+ if (source.startsWith('common/')) {
367
+ if (options?.isWebpack && source.endsWith('.js')) {
368
+ if (options?.externals) {
369
+ if (source in sharedLibExternals) {
370
+ const [lib, name] = Object.entries(sharedLibExternals[source])[0];
371
+ if (!(lib in options.externals && options.externals[lib] === name)) {
372
+ warnings.push(`Webpack config parsing: Consider adding source "${source}" to webpack externals:\n` + `'${lib}': '${name}'\n`);
373
+ }
374
+ } else warnings.push(`File "package.json": source "${source}" not in the list of shared libraries`);
375
+ } else {
376
+ warnings.push('Webpack config parsing: External modules not found.\n' + `Consider adding source "${source}" to webpack externals` + (source in sharedLibExternals ? ':\n' + `'${Object.keys(sharedLibExternals[source])[0]}': '${Object.values(sharedLibExternals[source])[0]}'\n` : ''));
461
377
  }
462
- continue;
463
378
  }
464
- if (source.startsWith('src/') && _fs["default"].existsSync(_path["default"].join(packagePath, 'webpack.config.js'))) {
465
- warnings.push('File "package.json": Sources cannot include files from the \`src/\` directory. ' + "Move file ".concat(source, " to another folder."));
466
- }
467
- if (!_fs["default"].existsSync(_path["default"].join(packagePath, source))) warnings.push("Source ".concat(source, " not found in the package."));
379
+ continue;
380
+ }
381
+ if (source.startsWith('src/') && _fs.default.existsSync(_path.default.join(packagePath, 'webpack.config.js'))) {
382
+ warnings.push('File "package.json": Sources cannot include files from the \`src/\` directory. ' + `Move file ${source} to another folder.`);
468
383
  }
469
- } catch (err) {
470
- _iterator8.e(err);
471
- } finally {
472
- _iterator8.f();
384
+ if (!_fs.default.existsSync(_path.default.join(packagePath, source))) warnings.push(`Source ${source} not found in the package.`);
473
385
  }
474
386
  }
475
- if ((options === null || options === void 0 ? void 0 : options.isReleaseCandidateVersion) === true) {
476
- var hasRCDependency = false;
477
- for (var _i2 = 0, _Object$keys = Object.keys((_json$dependencies3 = json.dependencies) !== null && _json$dependencies3 !== void 0 ? _json$dependencies3 : {}); _i2 < _Object$keys.length; _i2++) {
478
- var _json$dependencies3, _json$dependencies4;
479
- var dependency = _Object$keys[_i2];
480
- if (/\d+.\d+.\d+-rc(.[A-Za-z0-9]*.[A-Za-z0-9]*)?/.test(((_json$dependencies4 = json.dependencies) !== null && _json$dependencies4 !== void 0 ? _json$dependencies4 : {})[dependency])) {
387
+ if (options?.isReleaseCandidateVersion === true) {
388
+ let hasRCDependency = false;
389
+ for (let dependency of Object.keys(json.dependencies ?? {})) {
390
+ if (/\d+.\d+.\d+-rc(.[A-Za-z0-9]*.[A-Za-z0-9]*)?/.test((json.dependencies ?? {})[dependency])) {
481
391
  hasRCDependency = true;
482
392
  break;
483
393
  }
484
394
  }
485
395
  if (!hasRCDependency) {
486
- for (var _i3 = 0, _Object$keys2 = Object.keys((_json$dependencies5 = json.dependencies) !== null && _json$dependencies5 !== void 0 ? _json$dependencies5 : {}); _i3 < _Object$keys2.length; _i3++) {
487
- var _json$dependencies5, _json$dependencies6, _json$devDependencies3;
488
- var _dependency = _Object$keys2[_i3];
489
- console.log(_dependency);
490
- console.log(((_json$dependencies6 = json.dependencies) !== null && _json$dependencies6 !== void 0 ? _json$dependencies6 : {})[_dependency]);
491
- if (/\d+.\d+.\d+-rc(.[A-Za-z0-9]*.[A-Za-z0-9]*)?/.test(((_json$devDependencies3 = json.devDependencies) !== null && _json$devDependencies3 !== void 0 ? _json$devDependencies3 : {})[_dependency])) {
396
+ for (let dependency of Object.keys(json.dependencies ?? {})) {
397
+ console.log(dependency);
398
+ console.log((json.dependencies ?? {})[dependency]);
399
+ if (/\d+.\d+.\d+-rc(.[A-Za-z0-9]*.[A-Za-z0-9]*)?/.test((json.devDependencies ?? {})[dependency])) {
492
400
  hasRCDependency = true;
493
401
  break;
494
402
  }
@@ -499,185 +407,145 @@ function checkPackageFile(packagePath, json, options) {
499
407
  return warnings;
500
408
  }
501
409
  function checkChangelog(packagePath, json) {
502
- var _h2$0$match, _h2$;
503
410
  if (json.servicePackage) return [];
504
- var warnings = [];
505
- var clf;
411
+ const warnings = [];
412
+ let clf;
506
413
  try {
507
- clf = _fs["default"].readFileSync(_path["default"].join(packagePath, 'CHANGELOG.md'), {
414
+ clf = _fs.default.readFileSync(_path.default.join(packagePath, 'CHANGELOG.md'), {
508
415
  encoding: 'utf-8'
509
416
  });
510
417
  } catch (e) {
511
418
  return ['CHANGELOG.md file does not exist\n'];
512
419
  }
513
- var regex = /^##[^#].*$/gm;
514
- var h2 = clf.match(regex);
420
+ let regex = /^##[^#].*$/gm;
421
+ const h2 = clf.match(regex);
515
422
  if (!h2) return ['No versions found in CHANGELOG.md\n'];
516
423
  regex = /^## \d+\.\d+\.\d+ \((\d{4}-\d{2}-\d{2}|WIP)\)$/;
517
- var _iterator9 = _createForOfIteratorHelper(h2),
518
- _step9;
519
- try {
520
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
521
- var h = _step9.value;
522
- if (!regex.test(h)) warnings.push("CHANGELOG: '".concat(h, "' does not match the h2 format, expected: ## <version> (<yyyy-mm-dd> | WIP)\n"));
523
- }
524
- } catch (err) {
525
- _iterator9.e(err);
526
- } finally {
527
- _iterator9.f();
424
+ for (const h of h2) {
425
+ if (!regex.test(h)) warnings.push(`CHANGELOG: '${h}' does not match the h2 format, expected: ## <version> (<yyyy-mm-dd> | WIP)\n`);
528
426
  }
529
427
  regex = /^## (\d+\.\d+\.\d+)/;
530
- var v1 = (_h2$0$match = h2[0].match(regex)) === null || _h2$0$match === void 0 ? void 0 : _h2$0$match[1];
531
- var v2 = (_h2$ = h2[1]) === null || _h2$ === void 0 || (_h2$ = _h2$.match(regex)) === null || _h2$ === void 0 ? void 0 : _h2$[1];
532
- if (v1 !== json.version && v2 !== json.version) warnings.push("Latest package version (".concat(json.version, ") is not in CHANGELOG\n"));
428
+ const v1 = h2[0].match(regex)?.[1];
429
+ const v2 = h2[1]?.match(regex)?.[1];
430
+ if (v1 !== json.version && v2 !== json.version) warnings.push(`Latest package version (${json.version}) is not in CHANGELOG\n`);
533
431
  if (warnings.length) warnings.push('Changelog guideline: https://datagrok.ai/help/develop/dev-process/changelog-policy#changelog-guideline');
534
432
  return warnings;
535
433
  }
536
434
  function checkSourceMap(packagePath) {
537
- var warnings = [];
538
- var tsconfigFilePath = _path["default"].join(packagePath, 'tsconfig.json');
539
- var webpackConfigFilePath = _path["default"].join(packagePath, 'webpack.config.js');
540
- if (_fs["default"].existsSync(tsconfigFilePath) && _fs["default"].existsSync(webpackConfigFilePath)) {
541
- var configJson = _fs["default"].readFileSync(tsconfigFilePath, {
435
+ const warnings = [];
436
+ const tsconfigFilePath = _path.default.join(packagePath, 'tsconfig.json');
437
+ const webpackConfigFilePath = _path.default.join(packagePath, 'webpack.config.js');
438
+ if (_fs.default.existsSync(tsconfigFilePath) && _fs.default.existsSync(webpackConfigFilePath)) {
439
+ const configJson = _fs.default.readFileSync(tsconfigFilePath, {
542
440
  encoding: 'utf-8'
543
441
  }); // cant convert to json because file contains comments
544
442
 
545
443
  if (!new RegExp('"sourceMap"\\s*:\\s*true').test(configJson)) warnings.push('ts config doesnt contain source map');
546
- var webpackConfigJson = _fs["default"].readFileSync(webpackConfigFilePath, {
444
+ const webpackConfigJson = _fs.default.readFileSync(webpackConfigFilePath, {
547
445
  encoding: 'utf-8'
548
446
  }); // cant convert to json because file contains comments
549
447
 
550
- if (!new RegExp("devtool\\s*:\\s*(([^\\n]*?[^\\n]*source-map[^\\n]*:[^\\n]*source-map[^\\n]*)|('(inline-)?source-map'))\\s*").test(webpackConfigJson)) warnings.push('webpack config doesnt contain source map');
551
- if (!_fs["default"].existsSync(packagePath + '/dist/package.js')) warnings.push('dist\\package.js file doesnt exists');
552
- if (!_fs["default"].existsSync(packagePath + '/dist/package-test.js')) warnings.push('dist\\package-test.js file doesnt exists');
448
+ if (!new RegExp(`devtool\\s*:\\s*(([^\\n]*?[^\\n]*source-map[^\\n]*:[^\\n]*source-map[^\\n]*)|('(inline-)?source-map'))\\s*`).test(webpackConfigJson)) warnings.push('webpack config doesnt contain source map');
449
+ if (!_fs.default.existsSync(packagePath + '/dist/package.js')) warnings.push('dist\\package.js file doesnt exists');
450
+ if (!_fs.default.existsSync(packagePath + '/dist/package-test.js')) warnings.push('dist\\package-test.js file doesnt exists');
553
451
  }
554
452
  return warnings;
555
453
  }
556
454
  function checkNpmIgnore(packagePath) {
557
- var warnings = [];
558
- if (_path["default"].join.apply(_path["default"], [packagePath, '.npmignore'])) {
559
- var npmIgnoreContent = _fs["default"].readFileSync(_path["default"].join.apply(_path["default"], [packagePath, '.npmignore']), {
455
+ const warnings = [];
456
+ if (_path.default.join(...[packagePath, '.npmignore'])) {
457
+ const npmIgnoreContent = _fs.default.readFileSync(_path.default.join(...[packagePath, '.npmignore']), {
560
458
  encoding: 'utf-8'
561
459
  });
562
- var _iterator10 = _createForOfIteratorHelper(npmIgnoreContent.split('\n')),
563
- _step10;
564
- try {
565
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
566
- var _row$match;
567
- var row = _step10.value;
568
- if ((((_row$match = row.match(new RegExp('\\s*dist\\/?\\s*$'))) === null || _row$match === void 0 ? void 0 : _row$match.length) || -1) > 0) {
569
- warnings.push('there is dist directory in .npmignore');
570
- break;
571
- }
460
+ for (const row of npmIgnoreContent.split('\n')) {
461
+ if ((row.match(new RegExp('\\s*dist\\/?\\s*$'))?.length || -1) > 0) {
462
+ warnings.push('there is dist directory in .npmignore');
463
+ break;
572
464
  }
573
- } catch (err) {
574
- _iterator10.e(err);
575
- } finally {
576
- _iterator10.f();
577
465
  }
578
466
  } else warnings.push('.npmignore doesnt exists');
579
467
  return warnings;
580
468
  }
581
469
  function checkScriptNames(packagePath) {
582
- var warnings = [];
470
+ const warnings = [];
583
471
  try {
584
- if (_fs["default"].existsSync(packagePath)) {
585
- var filesInDirectory = getAllFilesInDirectory(packagePath);
586
- for (var _i4 = 0, _filesInDirectory = filesInDirectory; _i4 < _filesInDirectory.length; _i4++) {
587
- var _fileName$match;
588
- var fileName = _filesInDirectory[_i4];
589
- if (((_fileName$match = fileName.match(new RegExp('^[A-Za-z0-9._-]*$'))) === null || _fileName$match === void 0 ? void 0 : _fileName$match.length) !== 1) warnings.push("".concat(fileName, ": file name contains inappropriate symbols"));
472
+ if (_fs.default.existsSync(packagePath)) {
473
+ const filesInDirectory = getAllFilesInDirectory(packagePath);
474
+ for (const fileName of filesInDirectory) {
475
+ if (fileName.match(new RegExp('^[A-Za-z0-9._-]*$'))?.length !== 1) warnings.push(`${fileName}: file name contains inappropriate symbols`);
590
476
  }
591
477
  }
592
478
  } catch (err) {}
593
479
  return warnings;
594
480
  }
595
481
  function getAllFilesInDirectory(directoryPath) {
596
- var excludedFilesToCheck = ['node_modules', 'dist'];
597
- var fileNames = [];
598
- var entries = _fs["default"].readdirSync(directoryPath);
599
- entries.forEach(function (entry) {
600
- var entryPath = _path["default"].join(directoryPath, entry);
601
- var stat = _fs["default"].statSync(entryPath);
482
+ const excludedFilesToCheck = ['node_modules', 'dist'];
483
+ let fileNames = [];
484
+ const entries = _fs.default.readdirSync(directoryPath);
485
+ entries.forEach(entry => {
486
+ const entryPath = _path.default.join(directoryPath, entry);
487
+ const stat = _fs.default.statSync(entryPath);
602
488
  if (stat.isFile()) {
603
489
  fileNames.push(entry);
604
490
  } else if (stat.isDirectory() && !excludedFilesToCheck.includes(entry)) {
605
- var subDirectoryFiles = getAllFilesInDirectory(entryPath);
491
+ const subDirectoryFiles = getAllFilesInDirectory(entryPath);
606
492
  fileNames = fileNames.concat(subDirectoryFiles);
607
493
  }
608
494
  });
609
495
  return fileNames;
610
496
  }
611
497
  function showError(errors) {
612
- errors.forEach(function (w) {
613
- return color.error(w);
614
- });
498
+ errors.forEach(w => color.error(w));
615
499
  }
616
500
  function warn(warnings) {
617
- warnings.forEach(function (w) {
618
- return color.warn(w);
619
- });
501
+ warnings.forEach(w => color.warn(w));
620
502
  }
621
503
  function getFuncMetadata(script, fileExtention) {
622
- var funcData = [];
623
- var isHeader = false;
624
- var data = {
504
+ const funcData = [];
505
+ let isHeader = false;
506
+ let data = {
625
507
  name: '',
626
508
  inputs: [],
627
509
  outputs: []
628
510
  };
629
- var _iterator11 = _createForOfIteratorHelper(script.split('\n')),
630
- _step11;
631
- try {
632
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
633
- var line = _step11.value;
634
- if (!line) continue;
635
- //@ts-ignore
636
- var match = line.match(utils.fileParamRegex[fileExtention]);
637
- if (match) {
638
- var _line$match;
639
- if (!isHeader) isHeader = true;
640
- var param = match[1];
641
- if (param === 'name') data.name = (_line$match = line.match(utils.nameAnnRegex)) === null || _line$match === void 0 ? void 0 : _line$match[2];else if (param === 'description') data.description = match[2];else if (param === 'input') {
642
- data.inputs.push({
643
- type: match[2],
644
- name: match[3]
645
- });
646
- } else if (param === 'output') data.outputs.push({
511
+ for (const line of script.split('\n')) {
512
+ if (!line) continue;
513
+ //@ts-ignore
514
+ const match = line.match(utils.fileParamRegex[fileExtention]);
515
+ if (match) {
516
+ if (!isHeader) isHeader = true;
517
+ const param = match[1];
518
+ if (param === 'name') data.name = line.match(utils.nameAnnRegex)?.[2];else if (param === 'description') data.description = match[2];else if (param === 'input') {
519
+ data.inputs.push({
647
520
  type: match[2],
648
521
  name: match[3]
649
- });else if (param === 'tags') {
650
- data.tags = match.input && match[3] ? match.input.split(':')[1].split(',').map(function (t) {
651
- return t.trim();
652
- }) : [match[2]];
653
- } else if (param === 'meta.cache') {
654
- var _line$split$pop;
655
- data.cache = (_line$split$pop = line.split(':').pop()) === null || _line$split$pop === void 0 ? void 0 : _line$split$pop.trim();
656
- } else if (param === 'meta.cache.invalidateOn') {
657
- var _line$split$pop2;
658
- data.invalidateOn = (_line$split$pop2 = line.split(':').pop()) === null || _line$split$pop2 === void 0 ? void 0 : _line$split$pop2.trim();
659
- } else if (param === 'meta.invalidateOn') {
660
- data.isInvalidateOnWithoutCache = true;
661
- }
522
+ });
523
+ } else if (param === 'output') data.outputs.push({
524
+ type: match[2],
525
+ name: match[3]
526
+ });else if (param === 'tags') {
527
+ data.tags = match.input && match[3] ? match.input.split(':')[1].split(',').map(t => t.trim()) : [match[2]];
528
+ } else if (param === 'meta.cache') {
529
+ data.cache = line.split(':').pop()?.trim();
530
+ } else if (param === 'meta.cache.invalidateOn') {
531
+ data.invalidateOn = line.split(':').pop()?.trim();
532
+ } else if (param === 'meta.invalidateOn') {
533
+ data.isInvalidateOnWithoutCache = true;
662
534
  }
663
- if (isHeader) {
664
- var nm = line.match(utils.nameRegex);
665
- if (nm && !match) {
666
- data.name = data.name || nm[1];
667
- funcData.push(data);
668
- data = {
669
- name: '',
670
- inputs: [],
671
- outputs: []
672
- };
673
- isHeader = false;
674
- }
535
+ }
536
+ if (isHeader) {
537
+ const nm = line.match(utils.nameRegex);
538
+ if (nm && !match) {
539
+ data.name = data.name || nm[1];
540
+ funcData.push(data);
541
+ data = {
542
+ name: '',
543
+ inputs: [],
544
+ outputs: []
545
+ };
546
+ isHeader = false;
675
547
  }
676
548
  }
677
- } catch (err) {
678
- _iterator11.e(err);
679
- } finally {
680
- _iterator11.f();
681
549
  }
682
550
  return funcData;
683
551
  }