datagrok-tools 4.4.4 → 4.5.2

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 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
- 4. Start working on the functionality of your package. Use ` grok add` to create function templates.
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
- - `--eslint` adds a basic configuration for `eslint`
51
- - `--ide` adds an IDE-specific configuration for debugging (vscode)
52
- - `--ts` creates a TypeScript package template
53
- - `--jest` adds a basic configuration for `jest`
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
- - `--build` or `--rebuild`: boolean flags that indicate whether a local webpack bundle should be used or it should
78
- be generated on the server side
79
- - `--debug` or `--release`: boolean flags that determine whether to publish a debug version of the package visible
80
- only to the developer or a release version accessible by all eligible users and user groups
81
- - `--key`: a string containing a developer key that is not listed in the config file, e.g., the key for a new server
82
- - `--suffix`: a string containing package version hash
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`.
@@ -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] : false;
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, " --rebuild");
94
- _package['scripts']["release-".concat(name.toLowerCase(), "-").concat(server)] = "grok publish ".concat(server, " --rebuild --release");
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, {
@@ -117,7 +117,11 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
117
117
  Object.assign(_package.devDependencies, {
118
118
  'jest-html-reporter': '^3.5.0',
119
119
  'jest': '^27.0.0',
120
- '@types/jest': '^27.0.0'
120
+ '@types/jest': '^27.0.0',
121
+ 'js-yaml': '^4.1.0',
122
+ '@types/js-yaml': "^4.0.5",
123
+ '@types/node-fetch': '^2.6.2',
124
+ 'node-fetch': '^2.6.7'
121
125
  }, ts ? {
122
126
  'ts-jest': '^27.0.0',
123
127
  'puppeteer': '^13.7.0'
@@ -164,6 +168,10 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
164
168
  if (ts) contents += '\n# Emitted *.js files\nsrc/**/*.js\n';
165
169
  }
166
170
 
171
+ if (file === 'npmignore') {
172
+ copyFilePath = _path["default"].join(packageDir, '.npmignore');
173
+ }
174
+
167
175
  _fs["default"].writeFileSync(copyFilePath, contents, 'utf8');
168
176
  } else if (stats.isDirectory()) {
169
177
  if (file === '.vscode' && !(ide == 'vscode' && platform == 'win32')) return;
@@ -177,12 +185,14 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
177
185
  }
178
186
 
179
187
  function create(args) {
188
+ var options = ['ide', 'js', 'ts', 'eslint', 'jest'];
180
189
  var nOptions = Object.keys(args).length - 1;
181
190
  var nArgs = args['_'].length;
182
- if (nArgs > 2 || nOptions > 3) return false;
191
+ if (nArgs > 2 || nOptions > 4) return false;
183
192
  if (nOptions && !Object.keys(args).slice(1).every(function (op) {
184
- return ['ide', 'ts', 'eslint', 'jest'].includes(op);
185
- })) return false; // Create `config.yaml` if it doesn't exist yet
193
+ return options.includes(op);
194
+ })) return false;
195
+ if (args.js && args.ts) return color.error('Incompatible options: --js and --ts'); // Create `config.yaml` if it doesn't exist yet
186
196
 
187
197
  if (!_fs["default"].existsSync(grokDir)) _fs["default"].mkdirSync(grokDir);
188
198
  if (!_fs["default"].existsSync(confPath)) _fs["default"].writeFileSync(confPath, _jsYaml["default"].dump(confTemplate));
@@ -253,8 +263,9 @@ function create(args) {
253
263
 
254
264
  process.exit();
255
265
  });
256
- createDirectoryContents(name, config, templateDir, packageDir, args.ide, args.ts, args.eslint, args.jest);
257
- console.log(_entHelpers.help["package"](name, args.ts));
266
+ createDirectoryContents(name, config, templateDir, packageDir, args.ide, !!args.ts, !!args.eslint, !!args.jest);
267
+ color.success('Successfully created package ' + name);
268
+ console.log(_entHelpers.help["package"](!!args.ts));
258
269
  console.log("\nThe package has the following dependencies:\n".concat(dependencies.join(' '), "\n"));
259
270
  console.log('Running `npm install` to get the required dependencies...\n');
260
271
  (0, _child_process.exec)('npm install', {
@@ -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 = {
@@ -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(name) {
42
- var ts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
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 = {
@@ -220,7 +220,7 @@ var scriptExtensions = ['.jl', '.m', '.py', '.R'];
220
220
  exports.scriptExtensions = scriptExtensions;
221
221
 
222
222
  function checkScriptLocation(filepath) {
223
- if (!filepath.startsWith('scripts/') && scriptExtensions.some(function (ext) {
223
+ if (!(filepath.startsWith('scripts/') || filepath.startsWith('projects/')) && scriptExtensions.some(function (ext) {
224
224
  return filepath.endsWith(ext);
225
225
  })) {
226
226
  return false;
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "#{PACKAGE_NAME_LOWERCASE}",
3
- "beta": true,
4
3
  "friendlyName": "#{PACKAGE_NAME}",
5
4
  "version": "0.0.1",
6
5
  "description": "",
@@ -16,7 +15,7 @@
16
15
  },
17
16
  "scripts": {
18
17
  "link-all": "",
19
- "debug-#{PACKAGE_NAME_LOWERCASE}": "webpack && grok publish ",
18
+ "debug-#{PACKAGE_NAME_LOWERCASE}": "webpack && grok publish",
20
19
  "release-#{PACKAGE_NAME_LOWERCASE}": "webpack && grok publish --release",
21
20
  "build-#{PACKAGE_NAME_LOWERCASE}": "webpack",
22
21
  "build": "webpack"
@@ -5,7 +5,7 @@
5
5
  import * as utils from './test-node';
6
6
  import puppeteer from 'puppeteer';
7
7
 
8
- const P_START_TIMEOUT: number = 100000;
8
+ const P_START_TIMEOUT: number = 3600000;
9
9
  let browser: puppeteer.Browser;
10
10
  let page: puppeteer.Page;
11
11
 
@@ -46,4 +46,4 @@ it('TEST', async () => {
46
46
  console.log(r.report);
47
47
  // @ts-ignore
48
48
  expect(r.failed).toBe(false);
49
- }, 100000);
49
+ }, 3600000);
@@ -68,14 +68,15 @@ export async function getBrowserPage(puppeteer: any): Promise<{browser: any, pag
68
68
 
69
69
  let page = await browser.newPage();
70
70
  await page.goto(`${url}/oauth/`);
71
+ await page.setDefaultNavigationTimeout(0);
71
72
  await page.setCookie({name: 'auth', value: token});
72
73
  await page.evaluate((token: any) => {
73
74
  window.localStorage.setItem('auth', token);
74
75
  }, token);
75
76
  await page.goto(url);
76
77
  try {
77
- await page.waitForSelector('.grok-preloader');
78
- await page.waitForFunction(() => document.querySelector('.grok-preloader') == null, {timeout: 100000});
78
+ await page.waitForSelector('.grok-preloader', { timeout: 1800000 });
79
+ await page.waitForFunction(() => document.querySelector('.grok-preloader') == null, {timeout: 3600000});
79
80
  } catch (error) {
80
81
  throw error;
81
82
  }
@@ -26,6 +26,7 @@ module.exports = {
26
26
  'cash-dom': '$',
27
27
  'dayjs': 'dayjs',
28
28
  'wu': 'wu',
29
+ 'exceljs': 'ExcelJS',
29
30
  },
30
31
  output: {
31
32
  filename: '[name].js',
@@ -17,6 +17,7 @@ module.exports = {
17
17
  'cash-dom': '$',
18
18
  'dayjs': 'dayjs',
19
19
  'wu': 'wu',
20
+ 'exceljs': 'ExcelJS',
20
21
  },
21
22
  output: {
22
23
  filename: '[name].js',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datagrok-tools",
3
- "version": "4.4.4",
3
+ "version": "4.5.2",
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": {