datagrok-tools 4.13.75 → 4.13.76

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,17 +4,199 @@ 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 init Modify a package template\n link Link `datagrok-api` and libraries for local development\n publish Upload a package\n test Run package tests\n testall Run packages 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
- 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
- var HELP_INIT = "\nUsage: grok init\n\nModify a package template by adding config files for linters, IDE, etc.\n\nOptions:\n[--eslint] [--ide] [--test] [--ts] [--git]\n\n--eslint Add a configuration for eslint\n--ide Add an IDE-specific configuration for debugging (vscode)\n--test Add tests support (TypeScript packages only)\n--ts Convert a JavaScript package to TypeScript\n--git Configure GIT and install commit linting tools.\n Read more: https://datagrok.ai/help/develop/advanced/git-policy\n";
10
- var HELP_API = "\nUsage: grok api\n\nCreate wrapper functions for package scripts and queries\n";
11
- var HELP_CONFIG = "\nUsage: grok config\n\nCreate or update a configuration file\n\nOptions:\n[--reset] [--server] [--alias] [-k | --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";
12
- 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] [--test]\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--test Add tests support (TypeScript packages only)\n";
13
- var HELP_PUBLISH = "\nUsage: grok publish [host]\n\nUpload a package\n\nOptions:\n[--build|--rebuild] [--debug|--release] [-k | --key] [--suffix] [--all] [--refresh] [--link]\n\n--all Publish all available packages \n--refresh Publish all available already loaded packages \n--link \t Link the package to local utils\n\nRunning `grok publish` is the same as running `grok publish defaultHost --build --debug`\n";
14
- var HELP_CHECK = "\nUsage: grok check\n\nOptions:\n[-r | --recursive]\n\n--recursive Check all packages in the current directory\n\nCheck package content (function signatures, import statements of external modules, etc.)\n";
15
- var HELP_TEST = "\nUsage: grok test\n\nOptions:\n[--package] [--category] [--test] [--host] [--csv] [--gui] [--skip-build] [--skip-publish] [--link] [--catchUnhandled] [--report] [--record] [--verbose] [--platform] [--benchmark] [--stress-test] --[debug]\n\n--package Specify a package name to run tests for\n--category Specify a category name to run tests for\n--test Specify a test name to run \n--host Host alias as in the config file\n--csv Save the test report in a CSV file\n--gui Launch graphical interface (non-headless mode)\n--debug Enables debug point on tests run (useless without gui mode) \n--catchUnhandled Catch unhandled exceptions during test execution (default=true)\n--report Report failed tests to audit, notifies package author (default=false)\n--skip-build Skip the package build step\n--skip-publish Skip the package publication step\n--link \t Link the package to local utils\n--record Records the test execution process in mp4 format\n--verbose Prints detailed information about passed and skipped tests in the console\n--platform Runs only platform tests (applicable for ApiTests package only)\n--core Runs package & auto tests & core tests (core tests run only from DevTools package)\n--benchmark \t Runs tests in benchmark mode\n--stress-test Runs shuffled stress-test only\n \nRun package tests\n\nSee instructions:\nhttps://datagrok.ai/help/develop/how-to/test-packages#local-testing\n";
16
- var HELP_TESTALL = "\nUsage: grok testall\n\nOptions:\n[--packages] [--host] [--csv] [--gui] [--skip-build] [--skip-publish] [--link-package] [--catchUnhandled] [--report] [--record] [--verbose] [--benchmark] [--stress-test] [--order] [--tags] [--testRepeat] [--browsers-count] [--debug]\n\n--packages Specify a packages names to run tests for\n--host Host alias as in the config file\n--csv Save the test report in a CSV file\n--gui Launch graphical interface (non-headless mode)\n--debug Enables debug point on tests run (useless without gui mode) \n--catchUnhandled Catch unhandled exceptions during test execution (default=true)\n--report Report failed tests to audit, notifies packages author (default=false)\n--skip-build Skip the packages build step\n--skip-publish Skip the packages publication step\n--link-package \t Link the packages to local utils\n--record Records the test execution process in mp4 format\n--verbose Prints detailed information about passed and skipped tests in the console\n--core Runs packages & core tests (applicable for DevTools packages only)\n--benchmark \t Runs tests in benchmark mode\n--stress-test Runs shuffled stress-test only\n--order Specify order for tests invocation\n--tags Filter tests by tag name for run\n--testRepeat Set amount of tests repeats\n--browsers-count Set amount of browsers for tests run\n\nRun tests of all or specified packages \n\nSee instructions:\nhttps://datagrok.ai/help/develop/how-to/test-packages#local-testing\n";
17
- var HELP_LINK = "\nUsage: grok link\n\nLink `datagrok-api` and libraries for local development\n\nOptions:\n--dev Links also dev dependencies\n--verbose Prints detailed information about linked packages \n";
7
+ const HELP = `
8
+ Usage: grok <command>
9
+
10
+ Datagrok's package management tool
11
+
12
+ Commands:
13
+ add Add an object template
14
+ api Create wrapper functions
15
+ check Check package content (function signatures, etc.)
16
+ config Create and manage config files
17
+ create Create a package
18
+ init Modify a package template
19
+ link Link \`datagrok-api\` and libraries for local development
20
+ publish Upload a package
21
+ test Run package tests
22
+ testall Run packages tests
23
+
24
+ To get help on a particular command, use:
25
+ grok <command> --help
26
+
27
+ Read more about the package development workflow:
28
+ https://datagrok.ai/help/develop/develop
29
+ `;
30
+ const HELP_ADD = `
31
+ Usage: grok add <entity> <name>
32
+
33
+ Add an object template to your package:
34
+
35
+ grok add app <name>
36
+ grok add connection <name>
37
+ grok add detector <semantic-type-name>
38
+ grok add function [tag] <name>
39
+ grok add query <name>
40
+ grok add script [tag] <language> <name>
41
+ grok add view <name>
42
+ grok add viewer <name>
43
+ grok add tests
44
+
45
+ Please note that entity names may only include letters and numbers
46
+
47
+ Supported languages for scripts:
48
+ javascript, julia, node, octave, python, r
49
+
50
+ Available tags:
51
+ panel, init
52
+ `;
53
+ const HELP_INIT = `
54
+ Usage: grok init
55
+
56
+ Modify a package template by adding config files for linters, IDE, etc.
57
+
58
+ Options:
59
+ [--eslint] [--ide] [--test] [--ts] [--git]
60
+
61
+ --eslint Add a configuration for eslint
62
+ --ide Add an IDE-specific configuration for debugging (vscode)
63
+ --test Add tests support (TypeScript packages only)
64
+ --ts Convert a JavaScript package to TypeScript
65
+ --git Configure GIT and install commit linting tools.
66
+ Read more: https://datagrok.ai/help/develop/advanced/git-policy
67
+ `;
68
+ const HELP_API = `
69
+ Usage: grok api
70
+
71
+ Create wrapper functions for package scripts and queries
72
+ `;
73
+ const HELP_CONFIG = `
74
+ Usage: grok config
75
+
76
+ Create or update a configuration file
77
+
78
+ Options:
79
+ [--reset] [--server] [--alias] [-k | --key]
80
+
81
+ --reset Restore the default config file template
82
+ --server Use to add a server to the config (\`grok config add --alias alias --server url --key key\`)
83
+ --alias Use in conjunction with the \`server\` option to set the server name
84
+ --key Use in conjunction with the \`server\` option to set the developer key
85
+ --default Use in conjunction with the \`server\` option to set the added server as default
86
+ `;
87
+ const HELP_CREATE = `
88
+ Usage: grok create [name]
89
+
90
+ Create a package:
91
+
92
+ grok create Create a package in the current working directory
93
+ grok create <name> Create a package in a folder with the specified name
94
+
95
+ Please note that the package name may only include letters, numbers, underscores, or hyphens
96
+
97
+ Options:
98
+ [--eslint] [--ide] [--js | --ts] [--test]
99
+
100
+ --eslint Add a configuration for eslint
101
+ --ide Add an IDE-specific configuration for debugging (vscode)
102
+ --js Create a JavaScript package
103
+ --ts Create a TypeScript package (default)
104
+ --test Add tests support (TypeScript packages only)
105
+ `;
106
+ const HELP_PUBLISH = `
107
+ Usage: grok publish [host]
108
+
109
+ Upload a package
110
+
111
+ Options:
112
+ [--build|--rebuild] [--debug|--release] [-k | --key] [--suffix] [--all] [--refresh] [--link]
113
+
114
+ --all Publish all available packages
115
+ --refresh Publish all available already loaded packages
116
+ --link Link the package to local utils
117
+
118
+ Running \`grok publish\` is the same as running \`grok publish defaultHost --build --debug\`
119
+ `;
120
+ const HELP_CHECK = `
121
+ Usage: grok check
122
+
123
+ Options:
124
+ [-r | --recursive]
125
+
126
+ --recursive Check all packages in the current directory
127
+
128
+ Check package content (function signatures, import statements of external modules, etc.)
129
+ `;
130
+ const HELP_TEST = `
131
+ Usage: grok test
132
+
133
+ Options:
134
+ [--package] [--category] [--test] [--host] [--csv] [--gui] [--skip-build] [--skip-publish] [--link] [--catchUnhandled] [--report] [--record] [--verbose] [--platform] [--benchmark] [--stress-test] --[debug]
135
+
136
+ --package Specify a package name to run tests for
137
+ --category Specify a category name to run tests for
138
+ --test Specify a test name to run
139
+ --host Host alias as in the config file
140
+ --csv Save the test report in a CSV file
141
+ --gui Launch graphical interface (non-headless mode)
142
+ --debug Enables debug point on tests run (useless without gui mode)
143
+ --catchUnhandled Catch unhandled exceptions during test execution (default=true)
144
+ --report Report failed tests to audit, notifies package author (default=false)
145
+ --skip-build Skip the package build step
146
+ --skip-publish Skip the package publication step
147
+ --link Link the package to local utils
148
+ --record Records the test execution process in mp4 format
149
+ --verbose Prints detailed information about passed and skipped tests in the console
150
+ --platform Runs only platform tests (applicable for ApiTests package only)
151
+ --core Runs package & auto tests & core tests (core tests run only from DevTools package)
152
+ --benchmark Runs tests in benchmark mode
153
+ --stress-test Runs shuffled stress-test only
154
+
155
+ Run package tests
156
+
157
+ See instructions:
158
+ https://datagrok.ai/help/develop/how-to/test-packages#local-testing
159
+ `;
160
+ const HELP_TESTALL = `
161
+ Usage: grok testall
162
+
163
+ Options:
164
+ [--packages] [--host] [--csv] [--gui] [--skip-build] [--skip-publish] [--link-package] [--catchUnhandled] [--report] [--record] [--verbose] [--benchmark] [--stress-test] [--order] [--tags] [--testRepeat] [--browsers-count] [--debug]
165
+
166
+ --packages Specify a packages names to run tests for
167
+ --host Host alias as in the config file
168
+ --csv Save the test report in a CSV file
169
+ --gui Launch graphical interface (non-headless mode)
170
+ --debug Enables debug point on tests run (useless without gui mode)
171
+ --catchUnhandled Catch unhandled exceptions during test execution (default=true)
172
+ --report Report failed tests to audit, notifies packages author (default=false)
173
+ --skip-build Skip the packages build step
174
+ --skip-publish Skip the packages publication step
175
+ --link-package Link the packages to local utils
176
+ --record Records the test execution process in mp4 format
177
+ --verbose Prints detailed information about passed and skipped tests in the console
178
+ --core Runs packages & core tests (applicable for DevTools packages only)
179
+ --benchmark Runs tests in benchmark mode
180
+ --stress-test Runs shuffled stress-test only
181
+ --order Specify order for tests invocation
182
+ --tags Filter tests by tag name for run
183
+ --testRepeat Set amount of tests repeats
184
+ --browsers-count Set amount of browsers for tests run
185
+
186
+ Run tests of all or specified packages
187
+
188
+ See instructions:
189
+ https://datagrok.ai/help/develop/how-to/test-packages#local-testing
190
+ `;
191
+ const HELP_LINK = `
192
+ Usage: grok link
193
+
194
+ Link \`datagrok-api\` and libraries for local development
195
+
196
+ Options:
197
+ --dev Links also dev dependencies
198
+ --verbose Prints detailed information about linked packages
199
+ `;
18
200
 
19
201
  // const HELP_MIGRATE = `
20
202
  // Usage: grok migrate
@@ -23,7 +205,7 @@ var HELP_LINK = "\nUsage: grok link\n\nLink `datagrok-api` and libraries for loc
23
205
  // file and converting your scripts in the \`package.json\` file
24
206
  // `;
25
207
 
26
- var help = exports.help = {
208
+ const help = exports.help = {
27
209
  add: HELP_ADD,
28
210
  api: HELP_API,
29
211
  check: HELP_CHECK,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -14,49 +13,37 @@ var _child_process = require("child_process");
14
13
  var utils = _interopRequireWildcard(require("../utils/utils"));
15
14
  var color = _interopRequireWildcard(require("../utils/color-utils"));
16
15
  var _configValidator = require("../validators/config-validator");
17
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
18
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
19
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
20
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
22
- var curDir = process.cwd();
23
- var platform = _os["default"].platform();
24
- var grokDir = _path["default"].join(_os["default"].homedir(), '.grok');
25
- var confPath = _path["default"].join(grokDir, 'config.yaml');
26
- var packageJsonPath = _path["default"].join(curDir, 'package.json');
27
- var tsConfigPath = _path["default"].join(curDir, 'tsconfig.json');
28
- var webpackConfigPath = _path["default"].join(curDir, 'webpack.config.js');
29
- var templateDir = _path["default"].join(_path["default"].dirname(_path["default"].dirname(__dirname)), 'package-template');
30
- var options = ['ide', 'eslint', 'test', 'ts', 'git'];
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ const curDir = process.cwd();
19
+ const platform = _os.default.platform();
20
+ const grokDir = _path.default.join(_os.default.homedir(), '.grok');
21
+ const confPath = _path.default.join(grokDir, 'config.yaml');
22
+ const packageJsonPath = _path.default.join(curDir, 'package.json');
23
+ const tsConfigPath = _path.default.join(curDir, 'tsconfig.json');
24
+ const webpackConfigPath = _path.default.join(curDir, 'webpack.config.js');
25
+ const templateDir = _path.default.join(_path.default.dirname(_path.default.dirname(__dirname)), 'package-template');
26
+ const options = ['ide', 'eslint', 'test', 'ts', 'git'];
31
27
  function init(args) {
32
- var nOptions = Object.keys(args).length - 1;
33
- var nArgs = args['_'].length;
28
+ const nOptions = Object.keys(args).length - 1;
29
+ const nArgs = args['_'].length;
34
30
  if (nArgs > 1 || nOptions > options.length) {
35
31
  color.error('Incorrect number of arguments and options.');
36
32
  return false;
37
33
  }
38
- var passedOptions = Object.keys(args).slice(1);
34
+ const passedOptions = Object.keys(args).slice(1);
39
35
  if (nOptions) {
40
- var hasUnknownOpt = false;
41
- var _iterator = _createForOfIteratorHelper(passedOptions),
42
- _step;
43
- try {
44
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
45
- var op = _step.value;
46
- if (!options.includes(op)) {
47
- if (op !== 'h' && op !== 'help') color.error("Unknown option: ".concat(op));
48
- hasUnknownOpt = true;
49
- }
36
+ let hasUnknownOpt = false;
37
+ for (const op of passedOptions) {
38
+ if (!options.includes(op)) {
39
+ if (op !== 'h' && op !== 'help') color.error(`Unknown option: ${op}`);
40
+ hasUnknownOpt = true;
50
41
  }
51
- } catch (err) {
52
- _iterator.e(err);
53
- } finally {
54
- _iterator.f();
55
42
  }
56
43
  if (hasUnknownOpt) return false;
57
44
  }
58
45
  if (args.git) {
59
- (0, _child_process.exec)('git config --global pull.rebase false && ' + 'git config --global branch.master.rebase true && ' + 'git config --global branch.main.rebase true && ' + 'git config --global rebase.autostash true', function (err, stdout, stderr) {
46
+ (0, _child_process.exec)('git config --global pull.rebase false && ' + 'git config --global branch.master.rebase true && ' + 'git config --global branch.main.rebase true && ' + 'git config --global rebase.autostash true', (err, stdout, stderr) => {
60
47
  color.info('Configuring rebase pull strategy...');
61
48
  console.log('Read more: https://datagrok.ai/help/develop/advanced/git-policy');
62
49
  if (err) throw err;else {
@@ -64,14 +51,14 @@ function init(args) {
64
51
  color.success('GIT successfully configured\n');
65
52
  }
66
53
  });
67
- (0, _child_process.exec)('npm install --location=global @commitlint/config-conventional @commitlint/cli', function (err, stdout, stderr) {
54
+ (0, _child_process.exec)('npm install --location=global @commitlint/config-conventional @commitlint/cli', (err, stdout, stderr) => {
68
55
  color.info('Installing @commitlint/config-conventional and @commitlint/cli...');
69
56
  if (err) throw err;else console.log(stderr, stdout);
70
57
  });
71
- (0, _child_process.exec)('pip install pre-commit', function (err, stdout, stderr) {
58
+ (0, _child_process.exec)('pip install pre-commit', (err, stdout, stderr) => {
72
59
  color.info('Installing pre-commit...');
73
60
  if (err) throw err;else console.log(stderr, stdout);
74
- (0, _child_process.exec)('pre-commit install --install-hooks --hook-type pre-commit --hook-type commit-msg', function (err, stdout, stderr) {
61
+ (0, _child_process.exec)('pre-commit install --install-hooks --hook-type pre-commit --hook-type commit-msg', (err, stdout, stderr) => {
75
62
  color.info('Installing commit hooks...');
76
63
  if (err) throw err;else console.log(stderr, stdout);
77
64
  });
@@ -82,11 +69,11 @@ function init(args) {
82
69
  return false;
83
70
  }
84
71
  if (args.ts) {
85
- _fs["default"].writeFileSync(webpackConfigPath, _fs["default"].readFileSync(_path["default"].join(templateDir, 'ts.webpack.config.js')));
86
- _fs["default"].writeFileSync(tsConfigPath, _fs["default"].readFileSync(_path["default"].join(templateDir, 'tsconfig.json')));
87
- var packageJsPath = _path["default"].join(curDir, 'src', 'package.js');
88
- _fs["default"].writeFileSync(_path["default"].join(curDir, 'src', 'package.ts'), _fs["default"].existsSync(packageJsPath) ? _fs["default"].readFileSync(packageJsPath) : _fs["default"].readFileSync(_path["default"].join(templateDir, 'src', 'package.ts')));
89
- var packageData = JSON.parse(_fs["default"].readFileSync(packageJsonPath, 'utf-8'));
72
+ _fs.default.writeFileSync(webpackConfigPath, _fs.default.readFileSync(_path.default.join(templateDir, 'ts.webpack.config.js')));
73
+ _fs.default.writeFileSync(tsConfigPath, _fs.default.readFileSync(_path.default.join(templateDir, 'tsconfig.json')));
74
+ const packageJsPath = _path.default.join(curDir, 'src', 'package.js');
75
+ _fs.default.writeFileSync(_path.default.join(curDir, 'src', 'package.ts'), _fs.default.existsSync(packageJsPath) ? _fs.default.readFileSync(packageJsPath) : _fs.default.readFileSync(_path.default.join(templateDir, 'src', 'package.ts')));
76
+ const packageData = JSON.parse(_fs.default.readFileSync(packageJsonPath, 'utf-8'));
90
77
  Object.assign(packageData.devDependencies, {
91
78
  'ts-loader': 'latest',
92
79
  'typescript': 'latest'
@@ -97,97 +84,88 @@ function init(args) {
97
84
  '@typescript-eslint/parser': 'latest'
98
85
  });
99
86
  }
100
- _fs["default"].writeFileSync(packageJsonPath, JSON.stringify(packageData, null, 2), 'utf-8');
87
+ _fs.default.writeFileSync(packageJsonPath, JSON.stringify(packageData, null, 2), 'utf-8');
101
88
  color.success('TypeScript support has been added.');
102
89
  }
103
90
  if (args.ide) {
104
- var config = _jsYaml["default"].load(_fs["default"].readFileSync(confPath, {
91
+ const config = _jsYaml.default.load(_fs.default.readFileSync(confPath, {
105
92
  encoding: 'utf-8'
106
93
  }));
107
- var confTest = (0, _configValidator.validateConf)(config);
94
+ const confTest = (0, _configValidator.validateConf)(config);
108
95
  if (!confTest.value) {
109
96
  color.warn('Invalid configuration. Skipping `ide`...');
110
97
  color.error(confTest.message);
111
98
  }
112
99
  if (args.ide === 'vscode') {
113
- var ideConfPath = _path["default"].join(curDir, '.vscode');
114
- var templateConfPath = _path["default"].join(templateDir, '.vscode');
115
- if (!_fs["default"].existsSync(ideConfPath)) _fs["default"].mkdirSync(ideConfPath);
116
- var files = _fs["default"].readdirSync(templateConfPath);
117
- var _iterator2 = _createForOfIteratorHelper(files),
118
- _step2;
119
- try {
120
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
121
- var file = _step2.value;
122
- var contents = _fs["default"].readFileSync(_path["default"].join(templateConfPath, file), 'utf-8');
123
- if (file === 'tasks.json' && platform !== 'win32') contents = contents.replace(/(?<="command": ").*(?=")/, 'webpack && grok publish #{GROK_HOST_ALIAS}');
124
- contents = contents.replace(/#{GROK_HOST_ALIAS}/g, config["default"]);
125
- contents = contents.replace(/#{GROK_HOST}/g, /localhost|127\.0\.0\.1/.test(config['servers'][config["default"]]['url']) ? 'http://localhost:63343/login.html' : new URL(config['servers'][config["default"]]['url']).origin);
126
- _fs["default"].writeFileSync(_path["default"].join(ideConfPath, file), contents, 'utf-8');
127
- }
128
- } catch (err) {
129
- _iterator2.e(err);
130
- } finally {
131
- _iterator2.f();
100
+ const ideConfPath = _path.default.join(curDir, '.vscode');
101
+ const templateConfPath = _path.default.join(templateDir, '.vscode');
102
+ if (!_fs.default.existsSync(ideConfPath)) _fs.default.mkdirSync(ideConfPath);
103
+ const files = _fs.default.readdirSync(templateConfPath);
104
+ for (const file of files) {
105
+ let contents = _fs.default.readFileSync(_path.default.join(templateConfPath, file), 'utf-8');
106
+ if (file === 'tasks.json' && platform !== 'win32') contents = contents.replace(/(?<="command": ").*(?=")/, 'webpack && grok publish #{GROK_HOST_ALIAS}');
107
+ contents = contents.replace(/#{GROK_HOST_ALIAS}/g, config.default);
108
+ contents = contents.replace(/#{GROK_HOST}/g, /localhost|127\.0\.0\.1/.test(config['servers'][config.default]['url']) ? 'http://localhost:63343/login.html' : new URL(config['servers'][config.default]['url']).origin);
109
+ _fs.default.writeFileSync(_path.default.join(ideConfPath, file), contents, 'utf-8');
132
110
  }
133
111
  color.success('IDE configuration has been added.');
134
112
  }
135
113
  }
136
114
  if (args.eslint) {
137
- var _packageData = JSON.parse(_fs["default"].readFileSync(packageJsonPath, 'utf-8'));
138
- Object.assign(_packageData.devDependencies, {
115
+ const packageData = JSON.parse(_fs.default.readFileSync(packageJsonPath, 'utf-8'));
116
+ Object.assign(packageData.devDependencies, {
139
117
  'eslint': 'latest',
140
118
  'eslint-config-google': 'latest'
141
119
  });
142
- var ts = _fs["default"].existsSync(tsConfigPath);
120
+ const ts = _fs.default.existsSync(tsConfigPath);
143
121
  if (ts) {
144
- Object.assign(_packageData.devDependencies, {
122
+ Object.assign(packageData.devDependencies, {
145
123
  '@typescript-eslint/eslint-plugin': 'latest',
146
124
  '@typescript-eslint/parser': 'latest'
147
125
  });
148
126
  }
149
- Object.assign(_packageData.scripts, {
150
- 'lint': "eslint src".concat(ts ? ' --ext .ts' : ''),
151
- 'lint-fix': "eslint src".concat(ts ? ' --ext .ts' : '', " --fix")
127
+ Object.assign(packageData.scripts, {
128
+ 'lint': `eslint src${ts ? ' --ext .ts' : ''}`,
129
+ 'lint-fix': `eslint src${ts ? ' --ext .ts' : ''} --fix`
152
130
  });
153
- _fs["default"].writeFileSync(packageJsonPath, JSON.stringify(_packageData, null, 2), 'utf-8');
154
- var eslintConfigPath = _path["default"].join(curDir, '.eslintrc.json');
155
- var eslintTemplatePath = _path["default"].join(templateDir, '.eslintrc.json');
131
+ _fs.default.writeFileSync(packageJsonPath, JSON.stringify(packageData, null, 2), 'utf-8');
132
+ const eslintConfigPath = _path.default.join(curDir, '.eslintrc.json');
133
+ const eslintTemplatePath = _path.default.join(templateDir, '.eslintrc.json');
156
134
  if (ts) {
157
- var _contents = _fs["default"].readFileSync(eslintTemplatePath, 'utf-8');
158
- var eslintConf = JSON.parse(_contents);
135
+ let contents = _fs.default.readFileSync(eslintTemplatePath, 'utf-8');
136
+ const eslintConf = JSON.parse(contents);
159
137
  eslintConf.parser = '@typescript-eslint/parser';
160
138
  eslintConf.plugins = ['@typescript-eslint'];
161
- _contents = JSON.stringify(eslintConf, null, 2);
162
- _fs["default"].writeFileSync(eslintConfigPath, _contents, 'utf-8');
163
- } else _fs["default"].writeFileSync(eslintConfigPath, eslintTemplatePath);
139
+ contents = JSON.stringify(eslintConf, null, 2);
140
+ _fs.default.writeFileSync(eslintConfigPath, contents, 'utf-8');
141
+ } else _fs.default.writeFileSync(eslintConfigPath, eslintTemplatePath);
164
142
  color.success('Linter configuration has been added.');
165
143
  }
166
144
  if (args.test) {
167
- var tsPath = _path["default"].join(curDir, 'src', 'package.ts');
168
- if (!_fs["default"].existsSync(tsPath)) color.warn('Tests can only be added to TypeScript packages. Skipping `test`...');else if (!_fs["default"].existsSync(webpackConfigPath)) color.warn('Webpack configuration not found. Skipping `test`...');else {
169
- var _config = _fs["default"].readFileSync(webpackConfigPath, 'utf-8');
170
- if (!/(?<=entry:\s*{\s*(\r\n|\r|\n))[^}]*test:/.test(_config)) {
171
- var entryIdx = _config.search(/(?<=entry:\s*{\s*(\r\n|\r|\n)).*/);
145
+ const tsPath = _path.default.join(curDir, 'src', 'package.ts');
146
+ if (!_fs.default.existsSync(tsPath)) color.warn('Tests can only be added to TypeScript packages. Skipping `test`...');else if (!_fs.default.existsSync(webpackConfigPath)) color.warn('Webpack configuration not found. Skipping `test`...');else {
147
+ const config = _fs.default.readFileSync(webpackConfigPath, 'utf-8');
148
+ if (!/(?<=entry:\s*{\s*(\r\n|\r|\n))[^}]*test:/.test(config)) {
149
+ const entryIdx = config.search(/(?<=entry:\s*{\s*(\r\n|\r|\n)).*/);
172
150
  if (entryIdx === -1) color.error('Entry point not found during webpack config parsing');else {
173
- var testEntry = ' test: {filename: \'package-test.js\', library: ' + '{type: \'var\', name:`${packageName}_test`}, import: \'./src/package-test.ts\'},';
174
- _fs["default"].writeFileSync(webpackConfigPath, _config.slice(0, entryIdx) + testEntry + _config.slice(entryIdx), 'utf-8');
151
+ const testEntry = ' test: {filename: \'package-test.js\', library: ' + '{type: \'var\', name:`${packageName}_test`}, import: \'./src/package-test.ts\'},';
152
+ _fs.default.writeFileSync(webpackConfigPath, config.slice(0, entryIdx) + testEntry + config.slice(entryIdx), 'utf-8');
175
153
  }
176
154
  }
177
- var _packageData2 = JSON.parse(_fs["default"].readFileSync(packageJsonPath, 'utf-8'));
178
- Object.assign(_packageData2.dependencies, {
155
+ const packageData = JSON.parse(_fs.default.readFileSync(packageJsonPath, 'utf-8'));
156
+ Object.assign(packageData.dependencies, {
179
157
  '@datagrok-libraries/utils': 'latest'
180
158
  });
181
- Object.assign(_packageData2.scripts, {
159
+ Object.assign(packageData.scripts, {
182
160
  'test': 'grok test'
183
161
  });
184
- _fs["default"].writeFileSync(packageJsonPath, JSON.stringify(_packageData2, null, 2), 'utf-8');
185
- var packageTestPath = _path["default"].join(curDir, 'src', 'package-test.ts');
186
- if (!_fs["default"].existsSync(packageTestPath)) _fs["default"].writeFileSync(packageTestPath, _fs["default"].readFileSync(_path["default"].join(templateDir, 'src', 'package-test.ts')));
187
- var testsDir = _path["default"].join(curDir, 'src', 'tests');
188
- if (!_fs["default"].existsSync(testsDir)) _fs["default"].mkdirSync(testsDir);
189
- _fs["default"].writeFileSync(_path["default"].join(testsDir, 'test-examples.ts'), _fs["default"].readFileSync(_path["default"].join(_path["default"].dirname(templateDir), 'entity-template', 'test.ts')));
190
- _fs["default"].writeFileSync(packageTestPath, "import './tests/test-examples';\n" + _fs["default"].readFileSync(packageTestPath, 'utf-8'), 'utf-8');
162
+ _fs.default.writeFileSync(packageJsonPath, JSON.stringify(packageData, null, 2), 'utf-8');
163
+ const packageTestPath = _path.default.join(curDir, 'src', 'package-test.ts');
164
+ if (!_fs.default.existsSync(packageTestPath)) _fs.default.writeFileSync(packageTestPath, _fs.default.readFileSync(_path.default.join(templateDir, 'src', 'package-test.ts')));
165
+ const testsDir = _path.default.join(curDir, 'src', 'tests');
166
+ if (!_fs.default.existsSync(testsDir)) _fs.default.mkdirSync(testsDir);
167
+ _fs.default.writeFileSync(_path.default.join(testsDir, 'test-examples.ts'), _fs.default.readFileSync(_path.default.join(_path.default.dirname(templateDir), 'entity-template', 'test.ts')));
168
+ _fs.default.writeFileSync(packageTestPath, `import './tests/test-examples';\n` + _fs.default.readFileSync(packageTestPath, 'utf-8'), 'utf-8');
191
169
  color.success('Tests support has been added.');
192
170
  }
193
171
  }