datagrok-tools 4.14.7 → 4.14.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/CHANGELOG.md +16 -0
- package/bin/commands/api.js +25 -19
- package/bin/commands/check.js +1 -3
- package/bin/commands/publish.js +22 -17
- package/bin/utils/utils.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Datagrok-tools changelog
|
|
2
2
|
|
|
3
|
+
## 4.14.9 (2025-06-06)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* Grok Check added soft mode
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 4.14.8 (2025-06-06)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* Grok Check added collision checks
|
|
15
|
+
* Grok Publish runs check before invocation
|
|
16
|
+
* Grok Api creates api for the scripts in the python directory.
|
|
17
|
+
|
|
18
|
+
|
|
3
19
|
## 4.14.6 (2025-05-29)
|
|
4
20
|
|
|
5
21
|
### Features
|
package/bin/commands/api.js
CHANGED
|
@@ -55,31 +55,37 @@ function generateQueryWrappers() {
|
|
|
55
55
|
}
|
|
56
56
|
function generateScriptWrappers() {
|
|
57
57
|
const scriptsDir = _path.default.join(curDir, 'scripts');
|
|
58
|
+
const pythonDir = _fs.default.existsSync(srcDir) ? _path.default.join(srcDir, 'python') : _path.default.join(curDir, 'python');
|
|
58
59
|
if (!_fs.default.existsSync(scriptsDir)) {
|
|
59
60
|
color.warn(`Directory ${scriptsDir} not found`);
|
|
60
61
|
console.log('Skipping API generation for scripts...');
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
|
-
const files = _ignoreWalk.default.sync({
|
|
64
|
-
path: scriptsDir,
|
|
65
|
-
ignoreFiles: ['.npmignore', '.gitignore']
|
|
66
|
-
});
|
|
67
64
|
const wrappers = [];
|
|
68
|
-
for (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
65
|
+
for (let dir of [scriptsDir, pythonDir]) {
|
|
66
|
+
const files = _ignoreWalk.default.sync({
|
|
67
|
+
path: dir,
|
|
68
|
+
ignoreFiles: ['.npmignore', '.gitignore']
|
|
69
|
+
});
|
|
70
|
+
console.log(files);
|
|
71
|
+
for (const file of files) {
|
|
72
|
+
let extension;
|
|
73
|
+
if (!utils.scriptExtensions.some(ext => (extension = ext, file.endsWith(ext)))) continue;
|
|
74
|
+
const filepath = _path.default.join(dir, file);
|
|
75
|
+
const script = _fs.default.readFileSync(filepath, 'utf8');
|
|
76
|
+
if (!script) continue;
|
|
77
|
+
console.log(filepath);
|
|
78
|
+
console.log(script);
|
|
79
|
+
const name = utils.getScriptName(script, utils.commentMap[extension]);
|
|
80
|
+
if (!name) continue;
|
|
81
|
+
const description = utils.getScriptDescription(script);
|
|
82
|
+
checkNameColision(name);
|
|
83
|
+
const tb = new utils.TemplateBuilder(utils.scriptWrapperTemplate).replace('FUNC_NAME', name).replace('FUNC_NAME_LOWERCASE', name).replace('PACKAGE_NAMESPACE', _package.name);
|
|
84
|
+
const inputs = utils.getScriptInputs(script);
|
|
85
|
+
const outputType = utils.getScriptOutputType(script);
|
|
86
|
+
tb.replace('PARAMS_OBJECT', inputs).replace('TYPED_PARAMS', inputs).replace('FUNC_DESCRIPTION', description).replace('OUTPUT_TYPE', outputType);
|
|
87
|
+
wrappers.push(tb.build(1));
|
|
88
|
+
}
|
|
83
89
|
}
|
|
84
90
|
saveWrappersToFile('scripts', wrappers);
|
|
85
91
|
}
|
package/bin/commands/check.js
CHANGED
|
@@ -25,7 +25,7 @@ const forbiddenNames = ['function', 'class', 'export'];
|
|
|
25
25
|
const namesInFiles = new Map();
|
|
26
26
|
function check(args) {
|
|
27
27
|
const nOptions = Object.keys(args).length - 1;
|
|
28
|
-
if (args['_'].length !== 1 || nOptions > 2
|
|
28
|
+
if (args['_'].length !== 1 || nOptions > 2) return false;
|
|
29
29
|
const curDir = process.cwd();
|
|
30
30
|
if (args.recursive) return runChecksRec(curDir, args.soft ?? false);else {
|
|
31
31
|
if (!utils.isPackageDir(curDir)) {
|
|
@@ -318,7 +318,6 @@ function checkFuncSignatures(packagePath, files) {
|
|
|
318
318
|
}
|
|
319
319
|
let wrongInputNames = f.inputs.filter(e => forbiddenNames.includes(e?.name ?? ''));
|
|
320
320
|
if (f.name) {
|
|
321
|
-
console.log(f);
|
|
322
321
|
if (namesInFiles.has(f.name)) namesInFiles.get(f.name)?.push(file);else namesInFiles.set(f.name, [file]);
|
|
323
322
|
}
|
|
324
323
|
if (wrongInputNames.length > 0) warnings.push(`File ${file}, function ${f.name}: Wrong input names: (${wrongInputNames.map(e => e.name).join(', ')})`);
|
|
@@ -527,7 +526,6 @@ function getFuncMetadata(script, fileExtention) {
|
|
|
527
526
|
if (match) {
|
|
528
527
|
if (!isHeader) isHeader = true;
|
|
529
528
|
const param = match[1];
|
|
530
|
-
console.log(param);
|
|
531
529
|
if (param === 'name') data.name = line.match(utils.nameAnnRegex)?.[2]?.toLocaleLowerCase();else if (param === 'description') data.description = match[2];else if (param === 'input') {
|
|
532
530
|
data.inputs.push({
|
|
533
531
|
type: match[2],
|
package/bin/commands/publish.js
CHANGED
|
@@ -14,9 +14,9 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
14
14
|
var _ignoreWalk = _interopRequireDefault(require("ignore-walk"));
|
|
15
15
|
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
16
16
|
var _testUtils = require("../utils/test-utils");
|
|
17
|
-
var _check = require("./check");
|
|
18
17
|
var utils = _interopRequireWildcard(require("../utils/utils"));
|
|
19
18
|
var color = _interopRequireWildcard(require("../utils/color-utils"));
|
|
19
|
+
var _check = require("./check");
|
|
20
20
|
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); }
|
|
21
21
|
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; }
|
|
22
22
|
// @ts-ignore
|
|
@@ -81,7 +81,8 @@ async function processPackage(debug, rebuild, host, devKey, packageName, suffix)
|
|
|
81
81
|
rebuild = true;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
|
|
85
|
+
// let contentValidationLog = '';
|
|
85
86
|
console.log('Starting package checks...');
|
|
86
87
|
const checkStart = Date.now();
|
|
87
88
|
const jsTsFiles = files.filter(f => !f.startsWith('dist/') && (f.endsWith('.js') || f.endsWith('.ts')));
|
|
@@ -94,19 +95,19 @@ async function processPackage(debug, rebuild, host, devKey, packageName, suffix)
|
|
|
94
95
|
const content = _fs.default.readFileSync(webpackConfigPath, {
|
|
95
96
|
encoding: 'utf-8'
|
|
96
97
|
});
|
|
97
|
-
const externals =
|
|
98
|
-
if (externals) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
98
|
+
// const externals = extractExternals(content);
|
|
99
|
+
// if (externals) {
|
|
100
|
+
// const importWarnings = checkImportStatements(curDir, jsTsFiles, externals);
|
|
101
|
+
// contentValidationLog += importWarnings.join('\n') + (importWarnings.length ? '\n' : '');
|
|
102
|
+
// }
|
|
102
103
|
}
|
|
103
104
|
const funcFiles = jsTsFiles.filter(f => packageFiles.includes(f));
|
|
104
|
-
const funcWarnings =
|
|
105
|
-
contentValidationLog += funcWarnings.join('\n') + (funcWarnings.length ? '\n' : '');
|
|
106
|
-
const packageWarnings =
|
|
107
|
-
contentValidationLog += packageWarnings.join('\n') + (packageWarnings.length ? '\n' : '');
|
|
108
|
-
const changelogWarnings =
|
|
109
|
-
contentValidationLog += changelogWarnings.join('\n') +
|
|
105
|
+
// const funcWarnings = checkFuncSignatures(curDir, funcFiles);
|
|
106
|
+
// contentValidationLog += funcWarnings.join('\n') + (funcWarnings.length ? '\n' : '');
|
|
107
|
+
// const packageWarnings = checkPackageFile(curDir, json);
|
|
108
|
+
// contentValidationLog += packageWarnings.join('\n') + (packageWarnings.length ? '\n' : '');
|
|
109
|
+
// const changelogWarnings = checkChangelog(curDir, json);
|
|
110
|
+
// contentValidationLog += changelogWarnings.join('\n') + '';
|
|
110
111
|
console.log(`Checks finished in ${Date.now() - checkStart} ms`);
|
|
111
112
|
const reg = new RegExp(/\${(\w*)}/g);
|
|
112
113
|
const errs = [];
|
|
@@ -123,9 +124,10 @@ async function processPackage(debug, rebuild, host, devKey, packageName, suffix)
|
|
|
123
124
|
}
|
|
124
125
|
if (relativePath.startsWith('upload.keys.json')) return;
|
|
125
126
|
if (relativePath === 'zip') return;
|
|
126
|
-
if (!utils.checkScriptLocation(canonicalRelativePath)) {
|
|
127
|
-
|
|
128
|
-
}
|
|
127
|
+
// if (!utils.checkScriptLocation(canonicalRelativePath)) {
|
|
128
|
+
// contentValidationLog += `Warning: file \`${canonicalRelativePath}\`` +
|
|
129
|
+
// ` should be in directory \`${path.basename(curDir)}/scripts/\`\n`;
|
|
130
|
+
// }
|
|
129
131
|
const t = _fs.default.statSync(fullPath).mtime.toUTCString();
|
|
130
132
|
localTimestamps[canonicalRelativePath] = t;
|
|
131
133
|
if (debug && timestamps[canonicalRelativePath] === t) {
|
|
@@ -196,7 +198,7 @@ async function processPackage(debug, rebuild, host, devKey, packageName, suffix)
|
|
|
196
198
|
return 1;
|
|
197
199
|
} else {
|
|
198
200
|
console.log(log);
|
|
199
|
-
color.warn(contentValidationLog);
|
|
201
|
+
// color.warn(contentValidationLog);
|
|
200
202
|
}
|
|
201
203
|
} catch (error) {
|
|
202
204
|
console.error(error);
|
|
@@ -205,6 +207,9 @@ async function processPackage(debug, rebuild, host, devKey, packageName, suffix)
|
|
|
205
207
|
return 0;
|
|
206
208
|
}
|
|
207
209
|
async function publish(args) {
|
|
210
|
+
if (!args['skip-check']) (0, _check.check)({
|
|
211
|
+
_: ['check']
|
|
212
|
+
});
|
|
208
213
|
config = _jsYaml.default.load(_fs.default.readFileSync(confPath, {
|
|
209
214
|
encoding: 'utf-8'
|
|
210
215
|
}));
|
package/bin/utils/utils.js
CHANGED
|
@@ -149,7 +149,7 @@ const queryExtension = exports.queryExtension = '.sql';
|
|
|
149
149
|
const jsExtention = exports.jsExtention = '.js';
|
|
150
150
|
const scriptExtensions = exports.scriptExtensions = ['.jl', '.m', '.py', '.R'];
|
|
151
151
|
function checkScriptLocation(filepath) {
|
|
152
|
-
if (!(filepath.startsWith('scripts/') || filepath.startsWith('projects/') || filepath.startsWith('dockerfiles/')) && scriptExtensions.some(ext => filepath.endsWith(ext))) return false;
|
|
152
|
+
if (!(filepath.startsWith('scripts/') || filepath.startsWith('projects/') || filepath.startsWith('dockerfiles/') || filepath.startsWith('python/')) && scriptExtensions.some(ext => filepath.endsWith(ext))) return false;
|
|
153
153
|
return true;
|
|
154
154
|
}
|
|
155
155
|
;
|
package/package.json
CHANGED