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.
- package/bin/commands/add.js +96 -106
- package/bin/commands/api.js +65 -107
- package/bin/commands/check.js +264 -396
- package/bin/commands/config.js +82 -158
- package/bin/commands/create.js +65 -80
- package/bin/commands/help.js +194 -12
- package/bin/commands/init.js +73 -95
- package/bin/commands/link.js +70 -176
- package/bin/commands/publish.js +283 -484
- package/bin/commands/test-all.js +77 -291
- package/bin/commands/test.js +169 -391
- package/bin/utils/color-utils.js +8 -11
- package/bin/utils/ent-helpers.js +52 -42
- package/bin/utils/func-generation.js +25 -57
- package/bin/utils/interfaces.js +5 -1
- package/bin/utils/order-functions.js +47 -118
- package/bin/utils/test-utils.js +322 -750
- package/bin/utils/utils.js +123 -235
- package/bin/validators/config-validator.js +12 -14
- package/package.json +13 -4
package/bin/commands/check.js
CHANGED
|
@@ -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
|
|
26
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
37
|
+
const files = _ignoreWalk.default.sync({
|
|
45
38
|
path: packagePath,
|
|
46
39
|
ignoreFiles: ['.npmignore', '.gitignore']
|
|
47
40
|
});
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
56
|
+
const content = _fs.default.readFileSync(webpackConfigPath, {
|
|
66
57
|
encoding: 'utf-8'
|
|
67
58
|
});
|
|
68
59
|
externals = extractExternals(content);
|
|
69
|
-
if (externals) errors.push
|
|
60
|
+
if (externals) errors.push(...checkImportStatements(packagePath, jsTsFiles, externals));
|
|
70
61
|
}
|
|
71
|
-
errors.push
|
|
72
|
-
errors.push
|
|
73
|
-
warnings.push
|
|
74
|
-
errors.push
|
|
75
|
-
errors.push
|
|
76
|
-
isWebpack
|
|
77
|
-
externals
|
|
78
|
-
isReleaseCandidateVersion
|
|
79
|
-
}))
|
|
80
|
-
if (!isReleaseCandidateVersion) warnings.push
|
|
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(
|
|
73
|
+
console.log(`${_path.default.basename(packagePath)} warnings`);
|
|
83
74
|
warn(warnings);
|
|
84
75
|
}
|
|
85
76
|
if (errors.length) {
|
|
86
|
-
console.log(
|
|
77
|
+
console.log(`Checking package ${_path.default.basename(packagePath)}...`);
|
|
87
78
|
showError(errors);
|
|
88
|
-
if (json.version.startsWith('0') || errors.every(
|
|
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(
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
122
|
-
|
|
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
|
-
|
|
103
|
+
const externalStr = match[1].replace(/'/g, '"').replace(/\/\/.*(\r\n|\r|\n)/, '').replace(/(?<=[\S\s]),(?=\s*\})/, '');
|
|
126
104
|
try {
|
|
127
|
-
|
|
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
|
-
|
|
137
|
-
for (
|
|
138
|
-
modules.push(
|
|
139
|
-
if (
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
146
|
-
|
|
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
|
|
149
|
-
message
|
|
126
|
+
value,
|
|
127
|
+
message
|
|
150
128
|
};
|
|
151
129
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
app:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
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
|
|
204
|
-
message
|
|
164
|
+
value,
|
|
165
|
+
message
|
|
205
166
|
};
|
|
206
167
|
},
|
|
207
|
-
semTypeDetector:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
|
222
|
-
message
|
|
183
|
+
value,
|
|
184
|
+
message
|
|
223
185
|
};
|
|
224
186
|
},
|
|
225
|
-
cellRenderer:
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
|
240
|
-
message
|
|
202
|
+
value,
|
|
203
|
+
message
|
|
241
204
|
};
|
|
242
205
|
},
|
|
243
|
-
viewer:
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
|
258
|
-
message
|
|
221
|
+
value,
|
|
222
|
+
message
|
|
259
223
|
};
|
|
260
224
|
},
|
|
261
|
-
fileViewer:
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
|
281
|
-
message
|
|
245
|
+
value,
|
|
246
|
+
message
|
|
282
247
|
};
|
|
283
248
|
},
|
|
284
|
-
fileExporter:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
|
294
|
-
message
|
|
259
|
+
value,
|
|
260
|
+
message
|
|
295
261
|
};
|
|
296
262
|
},
|
|
297
|
-
packageSettingsEditor:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
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
|
|
307
|
-
message
|
|
273
|
+
value,
|
|
274
|
+
message
|
|
308
275
|
};
|
|
309
276
|
},
|
|
310
|
-
params:
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
|
347
|
-
message
|
|
296
|
+
value,
|
|
297
|
+
message
|
|
348
298
|
};
|
|
349
299
|
}
|
|
350
300
|
};
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
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
|
-
|
|
413
|
-
|
|
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
|
-
|
|
418
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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
|
-
|
|
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 (
|
|
476
|
-
|
|
477
|
-
for (
|
|
478
|
-
|
|
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 (
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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
|
-
|
|
505
|
-
|
|
411
|
+
const warnings = [];
|
|
412
|
+
let clf;
|
|
506
413
|
try {
|
|
507
|
-
clf = _fs
|
|
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
|
-
|
|
514
|
-
|
|
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
|
-
|
|
518
|
-
|
|
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
|
-
|
|
531
|
-
|
|
532
|
-
if (v1 !== json.version && v2 !== json.version) warnings.push(
|
|
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
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
if (_fs
|
|
541
|
-
|
|
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
|
-
|
|
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(
|
|
551
|
-
if (!_fs
|
|
552
|
-
if (!_fs
|
|
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
|
-
|
|
558
|
-
if (_path
|
|
559
|
-
|
|
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
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
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
|
-
|
|
470
|
+
const warnings = [];
|
|
583
471
|
try {
|
|
584
|
-
if (_fs
|
|
585
|
-
|
|
586
|
-
for (
|
|
587
|
-
|
|
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
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
entries.forEach(
|
|
600
|
-
|
|
601
|
-
|
|
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
|
-
|
|
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(
|
|
613
|
-
return color.error(w);
|
|
614
|
-
});
|
|
498
|
+
errors.forEach(w => color.error(w));
|
|
615
499
|
}
|
|
616
500
|
function warn(warnings) {
|
|
617
|
-
warnings.forEach(
|
|
618
|
-
return color.warn(w);
|
|
619
|
-
});
|
|
501
|
+
warnings.forEach(w => color.warn(w));
|
|
620
502
|
}
|
|
621
503
|
function getFuncMetadata(script, fileExtention) {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
504
|
+
const funcData = [];
|
|
505
|
+
let isHeader = false;
|
|
506
|
+
let data = {
|
|
625
507
|
name: '',
|
|
626
508
|
inputs: [],
|
|
627
509
|
outputs: []
|
|
628
510
|
};
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
if (!
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
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
|
-
});
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
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
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
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
|
}
|