datagrok-tools 4.14.4 → 4.14.5
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/api.js +6 -5
- package/package.json +1 -1
package/bin/commands/api.js
CHANGED
|
@@ -20,9 +20,7 @@ const srcDir = _path.default.join(curDir, 'src');
|
|
|
20
20
|
const funcFilePath = _path.default.join(_fs.default.existsSync(srcDir) ? srcDir : curDir, apiFile);
|
|
21
21
|
const packagePath = _path.default.join(curDir, 'package.json');
|
|
22
22
|
const names = new Set();
|
|
23
|
-
|
|
24
|
-
encoding: 'utf-8'
|
|
25
|
-
}));
|
|
23
|
+
let _package = {};
|
|
26
24
|
function generateQueryWrappers() {
|
|
27
25
|
const queriesDir = _path.default.join(curDir, 'queries');
|
|
28
26
|
if (!_fs.default.existsSync(queriesDir)) {
|
|
@@ -45,7 +43,7 @@ function generateQueryWrappers() {
|
|
|
45
43
|
const name = utils.getScriptName(q, utils.commentMap[utils.queryExtension]);
|
|
46
44
|
if (!name) continue;
|
|
47
45
|
checkNameColision(name);
|
|
48
|
-
const tb = new utils.TemplateBuilder(utils.queryWrapperTemplate).replace('FUNC_NAME', name).replace('FUNC_NAME_LOWERCASE', name).replace('PACKAGE_NAMESPACE', _package
|
|
46
|
+
const tb = new utils.TemplateBuilder(utils.queryWrapperTemplate).replace('FUNC_NAME', name).replace('FUNC_NAME_LOWERCASE', name).replace('PACKAGE_NAMESPACE', _package?.name ?? '');
|
|
49
47
|
const description = utils.getScriptDescription(q, utils.commentMap[utils.queryExtension]);
|
|
50
48
|
const inputs = utils.getScriptInputs(q, utils.commentMap[utils.queryExtension]);
|
|
51
49
|
const outputType = utils.getScriptOutputType(q, utils.commentMap[utils.queryExtension]);
|
|
@@ -109,7 +107,7 @@ function generateFunctionWrappers() {
|
|
|
109
107
|
outputType = utils.dgToTsTypeMap[outputAnnotation[1]] ?? 'any';
|
|
110
108
|
}
|
|
111
109
|
checkNameColision(name);
|
|
112
|
-
const tb = new utils.TemplateBuilder(utils.scriptWrapperTemplate).replace('FUNC_NAME', name).replace('FUNC_NAME_LOWERCASE', name).replace('PACKAGE_NAMESPACE', _package
|
|
110
|
+
const tb = new utils.TemplateBuilder(utils.scriptWrapperTemplate).replace('FUNC_NAME', name).replace('FUNC_NAME_LOWERCASE', name).replace('PACKAGE_NAMESPACE', _package?.name ?? '').replace('PARAMS_OBJECT', annotationInputs).replace('FUNC_DESCRIPTION', description).replace('TYPED_PARAMS', annotationInputs).replace('OUTPUT_TYPE', outputType);
|
|
113
111
|
wrappers.push(tb.build(1));
|
|
114
112
|
}
|
|
115
113
|
}
|
|
@@ -133,6 +131,9 @@ function checkNameColision(name) {
|
|
|
133
131
|
names.add(name);
|
|
134
132
|
}
|
|
135
133
|
function api(args) {
|
|
134
|
+
_package = JSON.parse(_fs.default.readFileSync(packagePath, {
|
|
135
|
+
encoding: 'utf-8'
|
|
136
|
+
}));
|
|
136
137
|
const nOptions = Object.keys(args).length - 1;
|
|
137
138
|
if (args['_'].length !== 1 || nOptions > 0) return false;
|
|
138
139
|
if (!utils.isPackageDir(process.cwd())) {
|
package/package.json
CHANGED