datagrok-tools
v4.14.69
Published
Utility to upload and publish packages to Datagrok
Keywords
Readme
Datagrok-tools
Utility to upload and publish packages to Datagrok.
Installation
npm install datagrok-tools -gUsage
Configure your environment with the following command:
grok configEnter developer keys and set the default server. The developer key can be retrieved from your user profile (for example, see https://public.datagrok.ai/u).
Create a new package by running this command:
grok create <package-name>A new folder
<package-name>will be created automatically as well as its contents.Run
npm installin your package directory to get the required dependencies (the command is called automatically after package creation, if it ran successfully, skip this step).Start working on the functionality of your package. Use
grok addto create function templates.Once you have completed the work on your package, upload it by running:
grok publish
Run grok for instructions and grok <command> --help to get help on a particular command.
Read more about package development in Datagrok's documentation.
Commands
configcreates or updates a configuration file. The command shows the location of the config file with the developer keys and offers to interactively change them. It is also possible to reset the current configuration.createadds a package template to the current working directory when used without thenameargument. The directory must be empty:grok createWhen called with an argument, the command creates a package in a folder with the specified name:
grok create <package-name>Package name may only include letters, numbers, underscores, or hyphens. Read more about naming conventions here. Options:
--eslintadds a basic configuration foreslint--ideadds an IDE-specific configuration for debugging (vscode)--jscreates a JavaScript package template--tscreates a TypeScript package template (default)--testadds tests support to package
addputs an object template to your package:cd <package-name> grok add app <name> grok add connection <name> grok add detector <semantic-type-name> grok add function [tag] <name> grok add query <name> grok add script [tag] <language> <name> grok add view <name> grok add viewer <name> grok add testsIn general, entity names follow naming rules for functions. Views and viewers should have class names, we recommend that you postfix them with 'View' and 'Viewer' respectively. Supported languages for scripts are
javascript,julia,node,octave,python,r. Available function tags:panel,init.apicreates wrapper functions for package scripts and queries. The output is stored in files/src/scripts-api.tsand/src/queries-api.tsrespectively.publishuploads a package to the specified server (pass either a URL or a server alias from theconfig.yamlfile). Additionally, you can use placeholders in JSON files under the/connectionsfolder to substitute environment variables. For more information on configuring connections, refer to the Connections article.cd <package-name> grok publish [host]Options:
--buildor--rebuild: boolean flags that indicate whether a local webpack bundle should be used or it should be generated on the server side--debugor--release: boolean flags that determine whether to publish a debug version of the package visible only to the developer or a release version accessible by all eligible users and user groups--key: a string containing a developer key that is not listed in the config file, e.g., the key for a new server--suffix: a string containing package version hash
Running
grok publishis the same as runninggrok publish defaultHost --build --debug.checkchecks package content (function signatures, import statements of external modules, etc.). The check is also run during package publication.initmodifies a package template by adding config files for linters, IDE, and so on (applies the same options ascreate).testruns package tests. First, it builds a package and publishes it (these steps can be skipped with flags--skip-buildand--skip-publishcorrespondingly). Also, it can be used to debug tests by using(guianddebugflags).testallruns tests from the packages directory. It works similarly totest, but this function allows tests to run from different packages in a specified order.cd <package-name> grok testThe default host from the
config.yamlfile is used. You can specify another server alias via the--hostoption (e.g.,grok test --host=dev). The results are printed to the terminal. To see tests execution, pass the--guiflag that disables the headless browser mode. If you want to save a test run result, add the--csvflag (the report will be saved in a CSV file in the package folder). You can find more details in local package testing instructions.Table with all available flags: | Flag | Description | |----------------|---------------------------------------------------------------------------------------------------------------------------------------| | catchUnhandled | Whether or not to catch unhandled exceptions during tests | | category | Runs tests of a specific category | | csv | Saves tests run results as a CSV file in the package folder | | gui | Disables the headless browser mode | | host | Specify server alias | | record | Records the test execution process in mp4 format | | report | Sends a report on test results | | skip-build | Skips package build step | | skip-publish | Skips package publish step | | verbose | Prints detailed information about passed and skipped tests in the console | | platform | Runs only platform tests (applicable for ApiTests package only) | | core | Runs package & core tests & autotests | | debug | Sets a debug breakpoint before each test execution, allowing you to debug the test. Only works in
guimode |linkcommand is used for public plugins development to linkdatagrok-apiand libraries.
