datagrok-tools 4.6.0 → 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/commands/check.js
CHANGED
|
@@ -31,44 +31,66 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
31
31
|
|
|
32
32
|
function check(args) {
|
|
33
33
|
var nOptions = Object.keys(args).length - 1;
|
|
34
|
-
if (args['_'].length !== 1 || nOptions >
|
|
34
|
+
if (args['_'].length !== 1 || nOptions > 1 && (!args.dir || typeof args.dir !== 'string') || nOptions > 2) return false;
|
|
35
35
|
var curDir = process.cwd();
|
|
36
36
|
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
if (args.dir && typeof args.dir === 'string') {
|
|
38
|
+
var packagesDir = _path["default"].isAbsolute(args.dir) ? args.dir : _path["default"].join(curDir, args.dir);
|
|
39
|
+
|
|
40
|
+
_fs["default"].readdirSync(packagesDir).forEach(function (file) {
|
|
41
|
+
var filepath = _path["default"].join(packagesDir, file);
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
ignoreFiles: ['.npmignore', '.gitignore']
|
|
44
|
-
});
|
|
43
|
+
var stats = _fs["default"].statSync(filepath);
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
if (stats.isDirectory() && utils.isPackageDir(filepath)) {
|
|
46
|
+
console.log("Checking package ".concat(file, "..."));
|
|
47
|
+
runChecks(filepath);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
if (!utils.isPackageDir(curDir)) {
|
|
52
|
+
color.error('File `package.json` not found. Run the command from the package directory');
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
console.log("Checking package ".concat(_path["default"].basename(curDir), "..."));
|
|
57
|
+
runChecks(curDir);
|
|
58
|
+
}
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
function runChecks(packagePath) {
|
|
61
|
+
var files = _ignoreWalk["default"].sync({
|
|
62
|
+
path: packagePath,
|
|
63
|
+
ignoreFiles: ['.npmignore', '.gitignore']
|
|
64
|
+
});
|
|
57
65
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
var jsTsFiles = files.filter(function (f) {
|
|
67
|
+
return !f.startsWith('dist/') && (f.endsWith('.js') || f.endsWith('.ts'));
|
|
68
|
+
});
|
|
69
|
+
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'];
|
|
70
|
+
var funcFiles = jsTsFiles.filter(function (f) {
|
|
71
|
+
return packageFiles.includes(f);
|
|
61
72
|
});
|
|
62
73
|
|
|
63
|
-
var
|
|
64
|
-
|
|
74
|
+
var webpackConfigPath = _path["default"].join(packagePath, 'webpack.config.js');
|
|
75
|
+
|
|
76
|
+
var isWebpack = _fs["default"].existsSync(webpackConfigPath);
|
|
77
|
+
|
|
78
|
+
if (isWebpack) {
|
|
79
|
+
var content = _fs["default"].readFileSync(webpackConfigPath, {
|
|
80
|
+
encoding: 'utf-8'
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
var externals = extractExternals(content);
|
|
84
|
+
if (externals) checkImportStatements(packagePath, jsTsFiles, externals).forEach(function (warning) {
|
|
85
|
+
return color.warn(warning);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
checkFuncSignatures(packagePath, funcFiles).forEach(function (warning) {
|
|
65
90
|
return color.warn(warning);
|
|
66
91
|
});
|
|
67
92
|
}
|
|
68
93
|
|
|
69
|
-
checkFuncSignatures(funcFiles).forEach(function (warning) {
|
|
70
|
-
return color.warn(warning);
|
|
71
|
-
});
|
|
72
94
|
return true;
|
|
73
95
|
}
|
|
74
96
|
|
|
@@ -91,7 +113,7 @@ function extractExternals(config) {
|
|
|
91
113
|
return null;
|
|
92
114
|
}
|
|
93
115
|
|
|
94
|
-
function checkImportStatements(files, externals) {
|
|
116
|
+
function checkImportStatements(packagePath, files, externals) {
|
|
95
117
|
var modules = [];
|
|
96
118
|
|
|
97
119
|
for (var key in externals) {
|
|
@@ -119,7 +141,7 @@ function checkImportStatements(files, externals) {
|
|
|
119
141
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
120
142
|
var file = _step.value;
|
|
121
143
|
|
|
122
|
-
var content = _fs["default"].readFileSync(_path["default"].join(
|
|
144
|
+
var content = _fs["default"].readFileSync(_path["default"].join(packagePath, file), {
|
|
123
145
|
encoding: 'utf-8'
|
|
124
146
|
});
|
|
125
147
|
|
|
@@ -151,7 +173,7 @@ function checkImportStatements(files, externals) {
|
|
|
151
173
|
return warnings;
|
|
152
174
|
}
|
|
153
175
|
|
|
154
|
-
function checkFuncSignatures(files) {
|
|
176
|
+
function checkFuncSignatures(packagePath, files) {
|
|
155
177
|
var warnings = [];
|
|
156
178
|
var checkFunctions = {
|
|
157
179
|
semTypeDetector: function semTypeDetector(_ref) {
|
|
@@ -162,12 +184,12 @@ function checkFuncSignatures(files) {
|
|
|
162
184
|
|
|
163
185
|
if (inputs.length !== 1 || inputs[0].type !== 'column') {
|
|
164
186
|
value = false;
|
|
165
|
-
message += 'Semantic type detectors must have one input of type "column"';
|
|
187
|
+
message += 'Semantic type detectors must have one input of type "column"\n';
|
|
166
188
|
}
|
|
167
189
|
|
|
168
190
|
if (outputs.length !== 1 || outputs[0].type !== 'string') {
|
|
169
191
|
value = false;
|
|
170
|
-
message += 'Semantic type detectors must have one output of type "string"';
|
|
192
|
+
message += 'Semantic type detectors must have one output of type "string"\n';
|
|
171
193
|
}
|
|
172
194
|
|
|
173
195
|
return {
|
|
@@ -183,12 +205,12 @@ function checkFuncSignatures(files) {
|
|
|
183
205
|
|
|
184
206
|
if (inputs.length !== 0) {
|
|
185
207
|
value = false;
|
|
186
|
-
message += 'Cell renderer functions should take no arguments';
|
|
208
|
+
message += 'Cell renderer functions should take no arguments\n';
|
|
187
209
|
}
|
|
188
210
|
|
|
189
211
|
if (outputs.length !== 1 || outputs[0].type !== 'grid_cell_renderer') {
|
|
190
212
|
value = false;
|
|
191
|
-
message += 'Cell renderer functions must have one output of type "grid_cell_renderer"';
|
|
213
|
+
message += 'Cell renderer functions must have one output of type "grid_cell_renderer"\n';
|
|
192
214
|
}
|
|
193
215
|
|
|
194
216
|
return {
|
|
@@ -207,17 +229,17 @@ function checkFuncSignatures(files) {
|
|
|
207
229
|
return t.startsWith('fileViewer');
|
|
208
230
|
}).length < 2) {
|
|
209
231
|
value = false;
|
|
210
|
-
message += 'File viewers must have at least two special tags: "fileViewer" and "fileViewer-<extension>"';
|
|
232
|
+
message += 'File viewers must have at least two special tags: "fileViewer" and "fileViewer-<extension>"\n';
|
|
211
233
|
}
|
|
212
234
|
|
|
213
235
|
if (inputs.length !== 1 || inputs[0].type !== 'file') {
|
|
214
236
|
value = false;
|
|
215
|
-
message += 'File viewers must have one input of type "file"';
|
|
237
|
+
message += 'File viewers must have one input of type "file"\n';
|
|
216
238
|
}
|
|
217
239
|
|
|
218
240
|
if (outputs.length !== 1 || outputs[0].type !== 'view') {
|
|
219
241
|
value = false;
|
|
220
|
-
message += 'File viewers must have one output of type "view"';
|
|
242
|
+
message += 'File viewers must have one output of type "view"\n';
|
|
221
243
|
}
|
|
222
244
|
|
|
223
245
|
return {
|
|
@@ -232,7 +254,7 @@ function checkFuncSignatures(files) {
|
|
|
232
254
|
|
|
233
255
|
if (description == null || description === '') {
|
|
234
256
|
value = false;
|
|
235
|
-
message += 'File exporters should have a description parameter';
|
|
257
|
+
message += 'File exporters should have a description parameter\n';
|
|
236
258
|
}
|
|
237
259
|
|
|
238
260
|
return {
|
|
@@ -247,7 +269,7 @@ function checkFuncSignatures(files) {
|
|
|
247
269
|
|
|
248
270
|
if (outputs.length === 1 && outputs[0].type === 'widget') {
|
|
249
271
|
value = false;
|
|
250
|
-
message += 'Package settings editors must have one output of type "widget"';
|
|
272
|
+
message += 'Package settings editors must have one output of type "widget"\n';
|
|
251
273
|
}
|
|
252
274
|
|
|
253
275
|
return {
|
|
@@ -265,7 +287,7 @@ function checkFuncSignatures(files) {
|
|
|
265
287
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
266
288
|
var file = _step3.value;
|
|
267
289
|
|
|
268
|
-
var content = _fs["default"].readFileSync(_path["default"].join(
|
|
290
|
+
var content = _fs["default"].readFileSync(_path["default"].join(packagePath, file), {
|
|
269
291
|
encoding: 'utf-8'
|
|
270
292
|
});
|
|
271
293
|
|
package/bin/commands/help.js
CHANGED
|
@@ -10,7 +10,7 @@ var HELP_API = "\nUsage: grok api\n\nCreate wrapper functions for package script
|
|
|
10
10
|
var HELP_CONFIG = "\nUsage: grok config\n\nCreate or update a configuration file\n\nOptions:\n[--reset] [--server] [--alias] [--key]\n\n--reset Restore the default config file template\n--server Use to add a server to the config (`grok config add --alias alias --server url --key key`)\n--alias Use in conjunction with the `server` option to set the server name\n--key Use in conjunction with the `server` option to set the developer key\n--default Use in conjunction with the `server` option to set the added server as default\n";
|
|
11
11
|
var HELP_CREATE = "\nUsage: grok create [name]\n\nCreate a package:\n\ngrok create Create a package in the current working directory\ngrok create <name> Create a package in a folder with the specified name\n\nPlease note that the package name may only include letters, numbers, underscores, or hyphens\n\nOptions:\n[--eslint] [--ide] [--js|--ts] [--jest]\n\n--eslint Add a configuration for eslint\n--ide Add an IDE-specific configuration for debugging (vscode)\n--js Create a JavaScript package\n--ts Create a TypeScript package (default)\n--jest Add a configuration for jest\n";
|
|
12
12
|
var HELP_PUBLISH = "\nUsage: grok publish [host]\n\nUpload a package\n\nOptions:\n[--build|--rebuild] [--debug|--release] [--key] [--suffix]\n\nRunning `grok publish` is the same as running `grok publish defaultHost --build --debug`\n";
|
|
13
|
-
var HELP_CHECK = "\nUsage: grok check\n\nCheck package content (function signatures, import statements of external modules, etc.)\n";
|
|
13
|
+
var HELP_CHECK = "\nUsage: grok check\n\nOptions:\n[--dir]\n\n--dir Check all packages in a specified directory\n\nCheck package content (function signatures, import statements of external modules, etc.)\n";
|
|
14
14
|
var HELP_MIGRATE = "\nUsage: grok migrate\n\nSwitch to `grok` tools by copying your keys to the config\nfile and converting your scripts in the `package.json` file\n";
|
|
15
15
|
var help = {
|
|
16
16
|
add: HELP_ADD,
|
package/package.json
CHANGED