datagrok-tools 4.4.4 → 4.5.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.
- package/README.md +35 -20
- package/bin/commands/create.js +11 -8
- package/bin/commands/help.js +1 -1
- package/bin/utils/ent-helpers.js +2 -3
- package/package-template/package.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,27 +4,33 @@ Utility to upload and publish [packages](https://datagrok.ai/help/develop/develo
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
```
|
|
7
|
+
```shell
|
|
8
8
|
npm install datagrok-tools -g
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
1. Configure your environment with the following command:
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
```shell
|
|
15
16
|
grok config
|
|
16
17
|
```
|
|
18
|
+
|
|
17
19
|
Enter developer keys and set the default server. The developer key can be retrieved from your user profile (for
|
|
18
20
|
example, see https://public.datagrok.ai/u).
|
|
19
21
|
2. Create a new package by running this command:
|
|
20
|
-
|
|
22
|
+
|
|
23
|
+
```shell
|
|
21
24
|
grok create <package-name>
|
|
22
25
|
```
|
|
26
|
+
|
|
23
27
|
A new folder `<package-name>` will be created automatically as well as its contents.
|
|
24
|
-
3. Run `npm install` in your package directory to get the required dependencies
|
|
25
|
-
|
|
28
|
+
3. Run `npm install` in your package directory to get the required dependencies (the command is called
|
|
29
|
+
automatically after package creation, if it ran successfully, skip this step).
|
|
30
|
+
4. Start working on the functionality of your package. Use `grok add` to create function templates.
|
|
26
31
|
5. Once you have completed the work on your package, upload it by running:
|
|
27
|
-
|
|
32
|
+
|
|
33
|
+
```shell
|
|
28
34
|
grok publish
|
|
29
35
|
```
|
|
30
36
|
|
|
@@ -38,21 +44,27 @@ Read more about package development in [Datagrok's documentation](https://datagr
|
|
|
38
44
|
keys and offers to interactively change them. It is also possible to reset the current configuration.
|
|
39
45
|
- `create` adds a package template to the current working directory when used without the `name` argument. The directory
|
|
40
46
|
must be empty:
|
|
41
|
-
|
|
47
|
+
|
|
48
|
+
```shell
|
|
42
49
|
grok create
|
|
43
50
|
```
|
|
51
|
+
|
|
44
52
|
When called with an argument, the command creates a package in a folder with the specified name:
|
|
45
|
-
|
|
53
|
+
|
|
54
|
+
```shell
|
|
46
55
|
grok create <package-name>
|
|
47
56
|
```
|
|
57
|
+
|
|
48
58
|
Package name may only include letters, numbers, underscores, or hyphens. Read more about naming
|
|
49
59
|
conventions [here](https://datagrok.ai/help/develop/develop#naming-conventions). Options:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
- `--eslint` adds a basic configuration for `eslint`
|
|
61
|
+
- `--ide` adds an IDE-specific configuration for debugging (vscode)
|
|
62
|
+
- `--js` creates a JavaScript package template
|
|
63
|
+
- `--ts` creates a TypeScript package template (default)
|
|
64
|
+
- `--jest` adds a basic configuration for `jest`
|
|
54
65
|
- `add` puts an object template to your package:
|
|
55
|
-
|
|
66
|
+
|
|
67
|
+
```shell
|
|
56
68
|
cd <package-name>
|
|
57
69
|
grok add app <name>
|
|
58
70
|
grok add connection <name>
|
|
@@ -63,22 +75,25 @@ Read more about package development in [Datagrok's documentation](https://datagr
|
|
|
63
75
|
grok add view <name>
|
|
64
76
|
grok add viewer <name>
|
|
65
77
|
```
|
|
78
|
+
|
|
66
79
|
In general, entity names follow naming rules for functions. Views and viewers should have class names, we recommend
|
|
67
80
|
that you postfix them with 'View' and 'Viewer' respectively. Supported languages for scripts are `javascript`, `julia`
|
|
68
81
|
, `node`, `octave`, `python`, `r`. Available function tags: `panel`, `init`.
|
|
69
82
|
- `api` creates wrapper functions for package scripts and queries. The output is stored in files `/src/scripts-api.ts`
|
|
70
83
|
and `/src/queries-api.ts` respectively.
|
|
71
84
|
- `publish` uploads a package to the specified server (pass either a URL or a server alias from the `config.yaml` file).
|
|
72
|
-
|
|
85
|
+
|
|
86
|
+
```shell
|
|
73
87
|
cd <package-name>
|
|
74
88
|
grok publish [host]
|
|
75
89
|
```
|
|
90
|
+
|
|
76
91
|
Options:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
- `--build` or `--rebuild`: boolean flags that indicate whether a local webpack bundle should be used or it should
|
|
93
|
+
be generated on the server side
|
|
94
|
+
- `--debug` or `--release`: boolean flags that determine whether to publish a debug version of the package visible
|
|
95
|
+
only to the developer or a release version accessible by all eligible users and user groups
|
|
96
|
+
- `--key`: a string containing a developer key that is not listed in the config file, e.g., the key for a new server
|
|
97
|
+
- `--suffix`: a string containing package version hash
|
|
83
98
|
|
|
84
99
|
Running `grok publish` is the same as running `grok publish defaultHost --build --debug`.
|
package/bin/commands/create.js
CHANGED
|
@@ -55,7 +55,7 @@ var dependencies = [];
|
|
|
55
55
|
|
|
56
56
|
function createDirectoryContents(name, config, templateDir, packageDir) {
|
|
57
57
|
var ide = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
|
|
58
|
-
var ts = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] :
|
|
58
|
+
var ts = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
59
59
|
var eslint = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
60
60
|
var jest = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
61
61
|
|
|
@@ -90,8 +90,8 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
|
|
|
90
90
|
|
|
91
91
|
for (var server in config.servers) {
|
|
92
92
|
if (server === config["default"]) continue;
|
|
93
|
-
_package['scripts']["debug-".concat(name.toLowerCase(), "-").concat(server)] = "grok publish ".concat(server
|
|
94
|
-
_package['scripts']["release-".concat(name.toLowerCase(), "-").concat(server)] = "grok publish ".concat(server, " --
|
|
93
|
+
_package['scripts']["debug-".concat(name.toLowerCase(), "-").concat(server)] = "webpack && grok publish ".concat(server);
|
|
94
|
+
_package['scripts']["release-".concat(name.toLowerCase(), "-").concat(server)] = "webpack && grok publish ".concat(server, " --release");
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
if (ts) Object.assign(_package.devDependencies, {
|
|
@@ -177,12 +177,14 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
function create(args) {
|
|
180
|
+
var options = ['ide', 'js', 'ts', 'eslint', 'jest'];
|
|
180
181
|
var nOptions = Object.keys(args).length - 1;
|
|
181
182
|
var nArgs = args['_'].length;
|
|
182
|
-
if (nArgs > 2 || nOptions >
|
|
183
|
+
if (nArgs > 2 || nOptions > 4) return false;
|
|
183
184
|
if (nOptions && !Object.keys(args).slice(1).every(function (op) {
|
|
184
|
-
return
|
|
185
|
-
})) return false;
|
|
185
|
+
return options.includes(op);
|
|
186
|
+
})) return false;
|
|
187
|
+
if (args.js && args.ts) return color.error('Incompatible options: --js and --ts'); // Create `config.yaml` if it doesn't exist yet
|
|
186
188
|
|
|
187
189
|
if (!_fs["default"].existsSync(grokDir)) _fs["default"].mkdirSync(grokDir);
|
|
188
190
|
if (!_fs["default"].existsSync(confPath)) _fs["default"].writeFileSync(confPath, _jsYaml["default"].dump(confTemplate));
|
|
@@ -253,8 +255,9 @@ function create(args) {
|
|
|
253
255
|
|
|
254
256
|
process.exit();
|
|
255
257
|
});
|
|
256
|
-
createDirectoryContents(name, config, templateDir, packageDir, args.ide, args.ts, args.eslint, args.jest);
|
|
257
|
-
|
|
258
|
+
createDirectoryContents(name, config, templateDir, packageDir, args.ide, !!args.ts, !!args.eslint, !!args.jest);
|
|
259
|
+
color.success('Successfully created package ' + name);
|
|
260
|
+
console.log(_entHelpers.help["package"](!!args.ts));
|
|
258
261
|
console.log("\nThe package has the following dependencies:\n".concat(dependencies.join(' '), "\n"));
|
|
259
262
|
console.log('Running `npm install` to get the required dependencies...\n');
|
|
260
263
|
(0, _child_process.exec)('npm install', {
|
package/bin/commands/help.js
CHANGED
|
@@ -8,7 +8,7 @@ var HELP = "\nUsage: grok <command>\n\nDatagrok's package management tool\n\nCom
|
|
|
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>\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
|
-
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] [--ts] [--jest]\n\n--eslint Add a configuration for eslint\n--ide Add an IDE-specific configuration for debugging (vscode)\n--ts Create a TypeScript package\n--jest Add a configuration for jest\n";
|
|
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_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";
|
|
14
14
|
var help = {
|
package/bin/utils/ent-helpers.js
CHANGED
|
@@ -38,9 +38,8 @@ var viewer = function viewer(viewerName) {
|
|
|
38
38
|
return "\nThe viewer ".concat(viewerName, " has been added successfully\nRead more at https://datagrok.ai/help/develop/how-to/develop-custom-viewer\nSee examples at https://github.com/datagrok-ai/public/tree/master/packages/Viewers,\nhttps://public.datagrok.ai/js/samples/functions/custom-viewers/viewers");
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
var _package = function _package(
|
|
42
|
-
|
|
43
|
-
return "\nSuccessfully created package `".concat(name, "`").concat(ts ? '' : '\nConsider TypeScript as a language for package development, to start over, run `grok create` with the `--ts` flag', "\nLikely next steps: `grok add` to add functionality, `grok publish` to upload the package");
|
|
41
|
+
var _package = function _package(ts) {
|
|
42
|
+
return ts ? '' : 'Consider TypeScript as a language for package development, to start over, run `grok create` with the `--ts` flag\n' + 'Likely next steps: `grok add` to add functionality, `grok publish` to upload the package';
|
|
44
43
|
};
|
|
45
44
|
|
|
46
45
|
var help = {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"link-all": "",
|
|
19
|
-
"debug-#{PACKAGE_NAME_LOWERCASE}": "webpack && grok publish
|
|
19
|
+
"debug-#{PACKAGE_NAME_LOWERCASE}": "webpack && grok publish",
|
|
20
20
|
"release-#{PACKAGE_NAME_LOWERCASE}": "webpack && grok publish --release",
|
|
21
21
|
"build-#{PACKAGE_NAME_LOWERCASE}": "webpack",
|
|
22
22
|
"build": "webpack"
|
package/package.json
CHANGED