datagrok-tools 4.6.4 → 4.7.0

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.
@@ -4,13 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.help = void 0;
7
- var HELP = "\nUsage: grok <command>\n\nDatagrok's package management tool\n\nCommands:\n add Add an object template\n api Create wrapper functions\n check Check package content (function signatures, etc.)\n config Create and manage config files\n create Create a package\n publish Upload a package\n\nTo get help on a particular command, use:\n grok <command> --help\n\nRead more about the package development workflow:\nhttps://datagrok.ai/help/develop/develop\n";
7
+ var HELP = "\nUsage: grok <command>\n\nDatagrok's package management tool\n\nCommands:\n add Add an object template\n api Create wrapper functions\n check Check package content (function signatures, etc.)\n config Create and manage config files\n create Create a package\n publish Upload a package\n test Run package tests\n\nTo get help on a particular command, use:\n grok <command> --help\n\nRead more about the package development workflow:\nhttps://datagrok.ai/help/develop/develop\n";
8
8
  var HELP_ADD = "\nUsage: grok add <entity> <name>\n\nAdd an object template to your package:\n\ngrok add app <name>\ngrok add connection <name>\ngrok add detector <semantic-type-name>\ngrok add function [tag] <name>\ngrok add query <name>\ngrok add script [tag] <language> <name>\ngrok add view <name>\ngrok add viewer <name>\ngrok add tests\n\nPlease note that entity names may only include letters and numbers\n\nSupported languages for scripts:\njavascript, julia, node, octave, python, r\n\nAvailable tags:\npanel, init\n";
9
9
  var HELP_API = "\nUsage: grok api\n\nCreate wrapper functions for package scripts and queries\n";
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
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
+ var HELP_TEST = "\nUsage: grok test\n\nOptions:\n[--host]\n\n--host Host alias as in the config file\n\nRun package tests\n\nSee instructions:\nhttps://datagrok.ai/help/develop/how-to/test-packages#local-testing\n";
14
15
  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
16
  var help = {
16
17
  add: HELP_ADD,
@@ -19,6 +20,7 @@ var help = {
19
20
  config: HELP_CONFIG,
20
21
  create: HELP_CREATE,
21
22
  publish: HELP_PUBLISH,
23
+ test: HELP_TEST,
22
24
  help: HELP
23
25
  };
24
26
  exports.help = help;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.test = test;
11
+
12
+ var _child_process = require("child_process");
13
+
14
+ var _fs = _interopRequireDefault(require("fs"));
15
+
16
+ var _os = _interopRequireDefault(require("os"));
17
+
18
+ var _path = _interopRequireDefault(require("path"));
19
+
20
+ var _jsYaml = _interopRequireDefault(require("js-yaml"));
21
+
22
+ var utils = _interopRequireWildcard(require("../utils/utils"));
23
+
24
+ var color = _interopRequireWildcard(require("../utils/color-utils"));
25
+
26
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
+
28
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
+
30
+ function test(args) {
31
+ var options = Object.keys(args).slice(1);
32
+ var nArgs = args['_'].length;
33
+ var curDir = process.cwd();
34
+
35
+ var grokDir = _path["default"].join(_os["default"].homedir(), '.grok');
36
+
37
+ var confPath = _path["default"].join(grokDir, 'config.yaml');
38
+
39
+ if (nArgs > 1 || options.length > 1 || options.length === 1 && options[0] !== 'host') return false;
40
+
41
+ if (!utils.isPackageDir(curDir)) {
42
+ color.error('File `package.json` not found. Run the command from the package directory');
43
+ return false;
44
+ }
45
+
46
+ if (!_fs["default"].existsSync(confPath)) {
47
+ color.error("File `".concat(confPath, "` not found. Run `grok config` to set up the config file"));
48
+ return false;
49
+ }
50
+
51
+ var config = _jsYaml["default"].load(_fs["default"].readFileSync(confPath, {
52
+ encoding: 'utf-8'
53
+ }));
54
+
55
+ if (args.host) {
56
+ if (args.host in config.servers) {
57
+ process.env.HOST = args.host;
58
+ console.log('Environment variable `HOST` is set to', args.host);
59
+ } else {
60
+ color.error("Unknown server alias. Please add it to ".concat(confPath));
61
+ return false;
62
+ }
63
+ } else if (config["default"]) {
64
+ process.env.HOST = config["default"];
65
+ console.log('Environment variable `HOST` is set to', config["default"]);
66
+ }
67
+
68
+ var packageData = JSON.parse(_fs["default"].readFileSync(_path["default"].join(curDir, 'package.json'), {
69
+ encoding: 'utf-8'
70
+ }));
71
+ var fullName = packageData.friendlyName || packageData.fullName;
72
+
73
+ if (fullName) {
74
+ process.env.TARGET_PACKAGE = fullName;
75
+ console.log('Environment variable `TARGET_PACKAGE` is set to', process.env.TARGET_PACKAGE);
76
+ } else {
77
+ color.error('Invalid full package name. Set `friendlyName` or `fullName` field in `package.json`');
78
+ return false;
79
+ }
80
+
81
+ color.info("Publishing package \"".concat(process.env.TARGET_PACKAGE, "\" to ").concat(process.env.HOST, "..."));
82
+ (0, _child_process.exec)("grok publish ".concat(process.platform === 'win32' ? '%HOST%' : '${HOST}'), function (err, stdout, stderr) {
83
+ if (err) throw err;else {
84
+ console.log(stdout);
85
+ color.error(stderr);
86
+ }
87
+ color.info('Starting tests...');
88
+ (0, _child_process.exec)('npm run test', function (err, stdout, stderr) {
89
+ if (err) throw err;else {
90
+ console.log(stdout);
91
+ console.log(stderr);
92
+ }
93
+ });
94
+ });
95
+ return true;
96
+ }
package/bin/grok.js CHANGED
@@ -9,6 +9,7 @@ const commands = {
9
9
  config: require('./commands/config').config,
10
10
  create: require('./commands/create').create,
11
11
  publish: require('./commands/publish').publish,
12
+ test: require('./commands/test').test,
12
13
  };
13
14
 
14
15
  const command = argv['_'][0];
@@ -9,4 +9,8 @@ category('Examples', () => {
9
9
  test('Fail', () => {
10
10
  throw 'Exception';
11
11
  });
12
+
13
+ test('Skipped', async () => {
14
+ expect(1 === 1 , false);
15
+ }, {skipReason: 'TASK-ID'});
12
16
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datagrok-tools",
3
- "version": "4.6.4",
3
+ "version": "4.7.0",
4
4
  "description": "Utility to upload and publish packages to Datagrok",
5
5
  "homepage": "https://github.com/datagrok-ai/public/tree/master/tools#readme",
6
6
  "dependencies": {