datagrok-tools 4.12.17 → 4.12.19

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/.eslintrc.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es2022": true
5
+ },
6
+ "extends": [
7
+ "google"
8
+ ],
9
+ "parser": "@typescript-eslint/parser",
10
+ "parserOptions": {
11
+ "ecmaVersion": 12,
12
+ "sourceType": "module"
13
+ },
14
+ "plugins": ["@typescript-eslint"],
15
+ "rules": {
16
+ "no-trailing-spaces": "off",
17
+ "indent": [
18
+ "error",
19
+ 2
20
+ ],
21
+ "max-len": [
22
+ "error",
23
+ 140
24
+ ],
25
+ "padded-blocks": "off",
26
+ "require-jsdoc": "off",
27
+ "spaced-comment": "off",
28
+ "linebreak-style": "off",
29
+ "guard-for-in": "off",
30
+ "curly": [
31
+ "error",
32
+ "multi-or-nest"
33
+ ],
34
+ "brace-style": [
35
+ "error",
36
+ "1tbs",
37
+ {
38
+ "allowSingleLine": true
39
+ }
40
+ ],
41
+ "block-spacing": 2
42
+ }
43
+ }
@@ -5,7 +5,7 @@ const yaml = require('js-yaml');
5
5
  const utils = require('../utils/utils.js');
6
6
 
7
7
  module.exports = {
8
- migrate: migrate
8
+ migrate: migrate,
9
9
  };
10
10
 
11
11
  const curDir = process.cwd();
@@ -21,10 +21,10 @@ const grokMap = {
21
21
  'debug': '',
22
22
  'deploy': '--release',
23
23
  'build': '',
24
- 'rebuild': '--rebuild'
24
+ 'rebuild': '--rebuild',
25
25
  };
26
26
 
27
- const replRegExp = new RegExp(Object.keys(grokMap).join("|"), "g");
27
+ const replRegExp = new RegExp(Object.keys(grokMap).join('|'), 'g');
28
28
 
29
29
  function migrate(args) {
30
30
  const nOptions = Object.keys(args).length - 1;
@@ -36,13 +36,13 @@ function migrate(args) {
36
36
  if (!fs.existsSync(grokDir)) fs.mkdirSync(grokDir);
37
37
  if (!fs.existsSync(confPath)) fs.writeFileSync(confPath, yaml.dump(confTemplate));
38
38
 
39
- let config = yaml.load(fs.readFileSync(confPath));
39
+ const config = yaml.load(fs.readFileSync(confPath));
40
40
 
41
41
  // Copy keys to the `config.yaml` file
42
42
  if (fs.existsSync(keysDir)) {
43
43
  try {
44
44
  const keys = JSON.parse(fs.readFileSync(keysDir));
45
- let urls = utils.mapURL(config);
45
+ const urls = utils.mapURL(config);
46
46
  for (const url in keys) {
47
47
  try {
48
48
  let hostname = (new URL(url)).hostname;
@@ -61,15 +61,15 @@ function migrate(args) {
61
61
  } catch (error) {
62
62
  console.error(error);
63
63
  }
64
- } else {
64
+ } else
65
65
  console.log('Unable to locate `upload.keys.json`');
66
- }
66
+
67
67
 
68
68
  // Rewrite scripts in `package.json`
69
69
  if (!fs.existsSync(packDir)) return console.log('`package.json` doesn\'t exist');
70
70
  try {
71
- let _package = JSON.parse(fs.readFileSync(packDir));
72
- for (let script in _package.scripts) {
71
+ const _package = JSON.parse(fs.readFileSync(packDir));
72
+ for (const script in _package.scripts) {
73
73
  if (!_package['scripts'][script].includes('datagrok-upload')) continue;
74
74
  _package['scripts'][script] = _package['scripts'][script].replace(replRegExp, (match) => grokMap[match]);
75
75
  }
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  const argv = require('minimist')(process.argv.slice(2));
3
- const getFiles = require('node-recursive-directory');
3
+ // const getFiles = require('node-recursive-directory');
4
4
  const fs = require('fs');
5
5
  const fetch = require('node-fetch');
6
6
  const path = require('path');
7
7
  const archiver = require('archiver-promise');
8
- const walk = require('ignore-walk')
8
+ const walk = require('ignore-walk');
9
9
 
10
10
  // The script is no longer supported
11
11
  console.log(`\`datagrok-upload\` is not available, please use \`grok publish\` instead.
@@ -13,27 +13,27 @@ Run \`grok migrate\` to convert your scripts in \`package.json\` and to copy you
13
13
  console.log(`Exiting with code 1`);
14
14
  process.exit(1);
15
15
 
16
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
16
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
17
17
 
18
- let mode = argv['_'][1];
19
- let host = argv['_'][0];
20
- let rebuild = argv['_'].includes('rebuild');
18
+ const mode = argv['_'][1];
19
+ const host = argv['_'][0];
20
+ const rebuild = argv['_'].includes('rebuild');
21
21
 
22
22
  if (mode !== 'debug' && mode !== 'deploy')
23
23
  return console.log('Mode must be either debug or deploy');
24
24
 
25
- let debug = mode === 'debug';
25
+ const debug = mode === 'debug';
26
26
 
27
27
  let keys = {
28
- [host]: ''
28
+ [host]: '',
29
29
  };
30
30
 
31
31
  //get key from keys file
32
- if (fs.existsSync('upload.keys.json')) {
32
+ if (fs.existsSync('upload.keys.json'))
33
33
  keys = JSON.parse(fs.readFileSync('upload.keys.json'));
34
- } else {
34
+ else
35
35
  fs.writeFileSync('upload.keys.json', JSON.stringify(keys));
36
- }
36
+
37
37
  let devKey = keys[host];
38
38
  if (devKey === undefined) {
39
39
  devKey = '';
@@ -50,14 +50,14 @@ let packageName = '';
50
50
  if (!fs.existsSync('package.json'))
51
51
  return console.log('package.js doesn\'t exists');
52
52
  else {
53
- let packageJson = JSON.parse(fs.readFileSync('package.json'));
53
+ const packageJson = JSON.parse(fs.readFileSync('package.json'));
54
54
  packageName = packageJson['name'];
55
55
  }
56
56
 
57
57
  process.on('beforeExit', async () => {
58
58
  let code = 0;
59
59
  try {
60
- code = await processPackage()
60
+ code = await processPackage();
61
61
 
62
62
  } catch (err) {
63
63
  console.log(err);
@@ -83,15 +83,15 @@ async function processPackage() {
83
83
  }
84
84
  }
85
85
 
86
- let zip = archiver('zip', {store: false});
86
+ const zip = archiver('zip', {store: false});
87
87
 
88
- //gather files
89
- let localTimestamps = {};
90
- let files = await walk({
88
+ //gather files
89
+ const localTimestamps = {};
90
+ const files = await walk({
91
91
  path: '.',
92
92
  ignoreFiles: ['.npmignore', '.gitignore'],
93
93
  includeEmpty: true,
94
- follow: true
94
+ follow: true,
95
95
  });
96
96
 
97
97
  if (!rebuild) {
@@ -99,16 +99,16 @@ async function processPackage() {
99
99
  path: './dist',
100
100
  ignoreFiles: [],
101
101
  includeEmpty: true,
102
- follow: true
102
+ follow: true,
103
103
  });
104
104
  distFiles.forEach((df) => {
105
105
  files.push(`dist/${df}`);
106
- })
106
+ });
107
107
  }
108
108
  files.forEach((file) => {
109
- let fullPath = file;
110
- let relativePath = path.relative(process.cwd(), fullPath);
111
- let canonicalRelativePath = relativePath.replace(/\\/g, '/');
109
+ const fullPath = file;
110
+ const relativePath = path.relative(process.cwd(), fullPath);
111
+ const canonicalRelativePath = relativePath.replace(/\\/g, '/');
112
112
  if (canonicalRelativePath.includes('/.'))
113
113
  return;
114
114
  if (canonicalRelativePath.startsWith('.'))
@@ -121,7 +121,7 @@ async function processPackage() {
121
121
  return;
122
122
  if (relativePath === 'zip')
123
123
  return;
124
- let t = fs.statSync(fullPath).mtime.toUTCString();
124
+ const t = fs.statSync(fullPath).mtime.toUTCString();
125
125
  localTimestamps[canonicalRelativePath] = t;
126
126
  if (debug && timestamps[canonicalRelativePath] === t) {
127
127
  console.log(`Skipping ${canonicalRelativePath}`);
@@ -132,20 +132,20 @@ async function processPackage() {
132
132
  });
133
133
  zip.append(JSON.stringify(localTimestamps), {name: 'timestamps.json'});
134
134
 
135
- //upload
136
- let uploadPromise = new Promise((resolve, reject) => {
137
- fetch(`${host}/packages/dev/${devKey}/${packageName}?debug=${debug.toString()}&rebuild=${rebuild.toString()}`, {
138
- method: 'POST',
139
- body: zip
140
- }).then(body => body.json()).then(j => resolve(j)).catch(err => {
141
- reject(err);
142
- });
143
- }
144
- )
135
+ //upload
136
+ const uploadPromise = new Promise((resolve, reject) => {
137
+ fetch(`${host}/packages/dev/${devKey}/${packageName}?debug=${debug.toString()}&rebuild=${rebuild.toString()}`, {
138
+ method: 'POST',
139
+ body: zip,
140
+ }).then((body) => body.json()).then((j) => resolve(j)).catch((err) => {
141
+ reject(err);
142
+ });
143
+ },
144
+ );
145
145
  await zip.finalize();
146
146
 
147
147
  try {
148
- let log = await uploadPromise;
148
+ const log = await uploadPromise;
149
149
 
150
150
  fs.unlinkSync('zip');
151
151
  if (log['#type'] === 'ApiError') {
@@ -159,4 +159,4 @@ async function processPackage() {
159
159
  return 1;
160
160
  }
161
161
  return 0;
162
- }
162
+ }
@@ -11,8 +11,8 @@ var _path = _interopRequireDefault(require("path"));
11
11
  var _entHelpers = require("../utils/ent-helpers");
12
12
  var utils = _interopRequireWildcard(require("../utils/utils"));
13
13
  var color = _interopRequireWildcard(require("../utils/color-utils"));
14
- 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); }
15
- 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; }
14
+ 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); }
15
+ 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; }
16
16
  function add(args) {
17
17
  var nOptions = Object.keys(args).length - 1;
18
18
  var nArgs = args['_'].length;
@@ -35,7 +35,7 @@ function add(args) {
35
35
  // Package directory check
36
36
  if (!_fs["default"].existsSync(packagePath)) return color.error('`package.json` not found');
37
37
  try {
38
- var _package = JSON.parse(_fs["default"].readFileSync(packagePath, {
38
+ JSON.parse(_fs["default"].readFileSync(packagePath, {
39
39
  encoding: 'utf-8'
40
40
  }));
41
41
  } catch (error) {
@@ -48,9 +48,7 @@ function add(args) {
48
48
  var packageEntry = ts ? tsPath : jsPath;
49
49
  var ext = ts ? '.ts' : '.js';
50
50
  function validateName(name) {
51
- if (!/^([A-Za-z])+([A-Za-z\d])*$/.test(name)) {
52
- return color.error('The name may only include letters and numbers. It cannot start with a digit');
53
- }
51
+ if (!/^([A-Za-z])+([A-Za-z\d])*$/.test(name)) return color.error('The name may only include letters and numbers. It cannot start with a digit');
54
52
  return true;
55
53
  }
56
54
  function insertName(name, data) {
@@ -94,9 +92,7 @@ function add(args) {
94
92
  // Create the folder `scripts` if it doesn't exist yet
95
93
  if (!_fs["default"].existsSync(scriptsDir)) _fs["default"].mkdirSync(scriptsDir);
96
94
  var scriptPath = _path["default"].join(scriptsDir, name + '.' + utils.scriptLangExtMap[lang]);
97
- if (_fs["default"].existsSync(scriptPath)) {
98
- return color.error("The file with the script already exists: ".concat(scriptPath));
99
- }
95
+ if (_fs["default"].existsSync(scriptPath)) return color.error("The file with the script already exists: ".concat(scriptPath));
100
96
 
101
97
  // Copy the script template
102
98
  var templatePath = _path["default"].join(templateDir, 'script-template');
@@ -134,9 +130,7 @@ function add(args) {
134
130
  name = args['_'][3];
135
131
  }
136
132
  if (!validateName(name)) return false;
137
- if (tag && tag !== 'panel' && tag !== 'init') {
138
- return color.error('Currently, you can only add the `panel` or `init` tag');
139
- }
133
+ if (tag && tag !== 'panel' && tag !== 'init') return color.error('Currently, you can only add the `panel` or `init` tag');
140
134
 
141
135
  // Create src/package.js if it doesn't exist yet
142
136
  createPackageEntryFile();
@@ -157,9 +151,7 @@ function add(args) {
157
151
  // Create the `connections` folder if it doesn't exist yet
158
152
  if (!_fs["default"].existsSync(connectDir)) _fs["default"].mkdirSync(connectDir);
159
153
  var connectPath = _path["default"].join(connectDir, "".concat(name, ".json"));
160
- if (_fs["default"].existsSync(connectPath)) {
161
- return color.error("The connection file already exists: ".concat(connectPath));
162
- }
154
+ if (_fs["default"].existsSync(connectPath)) return color.error("The connection file already exists: ".concat(connectPath));
163
155
  var connectionTemplate = _fs["default"].readFileSync(_path["default"].join(templateDir, 'entity-template', 'connection.json'), 'utf8');
164
156
  _fs["default"].writeFileSync(connectPath, insertName(name, connectionTemplate), 'utf8');
165
157
  console.log(_entHelpers.help.connection(name));
@@ -201,18 +193,14 @@ function add(args) {
201
193
  // View name check
202
194
  name = args['_'][2];
203
195
  if (!validateName(name)) return false;
204
- if (!name.endsWith('View')) {
205
- color.warn("For consistency reasons, we recommend postfixing classes with 'View'");
206
- }
196
+ if (!name.endsWith('View')) color.warn('For consistency reasons, we recommend postfixing classes with \'View\'');
207
197
 
208
198
  // Create src/package.js if it doesn't exist yet
209
199
  createPackageEntryFile();
210
200
 
211
201
  // Add a new JS file with a view class
212
202
  var viewPath = _path["default"].join(srcDir, utils.camelCaseToKebab(name) + ext);
213
- if (_fs["default"].existsSync(viewPath)) {
214
- return color.error("The view file already exists: ".concat(viewPath));
215
- }
203
+ if (_fs["default"].existsSync(viewPath)) return color.error("The view file already exists: ".concat(viewPath));
216
204
  var viewClass = _fs["default"].readFileSync(_path["default"].join(templateDir, 'entity-template', 'view-class' + ext), 'utf8');
217
205
  _fs["default"].writeFileSync(viewPath, insertName(name, viewClass), 'utf8');
218
206
 
@@ -230,18 +218,14 @@ function add(args) {
230
218
  // Viewer name check
231
219
  name = args['_'][2];
232
220
  if (!validateName(name)) return false;
233
- if (!name.endsWith('Viewer')) {
234
- color.warn("For consistency reasons, we recommend postfixing classes with 'Viewer'");
235
- }
221
+ if (!name.endsWith('Viewer')) color.warn('For consistency reasons, we recommend postfixing classes with \'Viewer\'');
236
222
 
237
223
  // Create src/package.js if it doesn't exist yet
238
224
  createPackageEntryFile();
239
225
 
240
226
  // Add a new JS file with a viewer class
241
227
  var viewerPath = _path["default"].join(srcDir, utils.camelCaseToKebab(name) + ext);
242
- if (_fs["default"].existsSync(viewerPath)) {
243
- return color.error("The viewer file already exists: ".concat(viewerPath));
244
- }
228
+ if (_fs["default"].existsSync(viewerPath)) return color.error("The viewer file already exists: ".concat(viewerPath));
245
229
  var viewerClass = _fs["default"].readFileSync(_path["default"].join(templateDir, 'entity-template', 'viewer-class' + ext), 'utf8');
246
230
  _fs["default"].writeFileSync(viewerPath, insertName(name, viewerClass), 'utf8');
247
231
 
@@ -258,6 +242,7 @@ function add(args) {
258
242
  name = args['_'][2];
259
243
  if (!_fs["default"].existsSync(detectorsPath)) {
260
244
  var temp = _fs["default"].readFileSync(_path["default"].join(templateDir, 'package-template', 'detectors.js'), 'utf8');
245
+ // eslint-disable-next-line new-cap
261
246
  temp = utils.replacers['PACKAGE_DETECTORS_NAME'](temp, curFolder);
262
247
  _fs["default"].writeFileSync(detectorsPath, temp, 'utf8');
263
248
  }
@@ -286,7 +271,7 @@ function add(args) {
286
271
  if (!/(?<=entry:\s*{\s*(\r\n|\r|\n))[^}]*test:/.test(config)) {
287
272
  var entryIdx = config.search(/(?<=entry:\s*{\s*(\r\n|\r|\n)).*/);
288
273
  if (entryIdx === -1) return color.error('Entry point not found during config parsing');
289
- var testEntry = " test: {filename: 'package-test.js', library: " + "{type: 'var', name:`${packageName}_test`}, import: './src/package-test.ts'},";
274
+ var testEntry = ' test: {filename: \'package-test.js\', library: ' + '{type: \'var\', name:`${packageName}_test`}, import: \'./src/package-test.ts\'},';
290
275
  _fs["default"].writeFileSync(webpackConfigPath, config.slice(0, entryIdx) + testEntry + config.slice(entryIdx), 'utf8');
291
276
  }
292
277
  var packageObj = JSON.parse(_fs["default"].readFileSync(packagePath, 'utf8'));
@@ -298,7 +283,9 @@ function add(args) {
298
283
  });
299
284
  _fs["default"].writeFileSync(packagePath, JSON.stringify(packageObj, null, 2), 'utf8');
300
285
  var packageTestPath = _path["default"].join(srcDir, 'package-test.ts');
301
- if (!_fs["default"].existsSync(packageTestPath)) _fs["default"].writeFileSync(packageTestPath, _fs["default"].readFileSync(_path["default"].join(templateDir, 'package-template', 'src', 'package-test.ts')));
286
+ if (!_fs["default"].existsSync(packageTestPath)) {
287
+ _fs["default"].writeFileSync(packageTestPath, _fs["default"].readFileSync(_path["default"].join(templateDir, 'package-template', 'src', 'package-test.ts')));
288
+ }
302
289
  var testsDir = _path["default"].join(srcDir, 'tests');
303
290
  if (!_fs["default"].existsSync(testsDir)) _fs["default"].mkdirSync(testsDir);
304
291
  _fs["default"].writeFileSync(_path["default"].join(testsDir, 'test-examples.ts'), _fs["default"].readFileSync(_path["default"].join(templateDir, 'entity-template', 'test.ts')));
@@ -11,11 +11,11 @@ var _path = _interopRequireDefault(require("path"));
11
11
  var _ignoreWalk = _interopRequireDefault(require("ignore-walk"));
12
12
  var utils = _interopRequireWildcard(require("../utils/utils"));
13
13
  var color = _interopRequireWildcard(require("../utils/color-utils"));
14
- 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); }
15
- 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; }
14
+ 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); }
15
+ 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; }
16
16
  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; } } }; }
17
17
  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); }
18
- 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; }
18
+ 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; }
19
19
  function generateQueryWrappers() {
20
20
  var curDir = process.cwd();
21
21
  var queriesDir = _path["default"].join(curDir, 'queries');
@@ -105,25 +105,26 @@ function generateScriptWrappers() {
105
105
  _step3;
106
106
  try {
107
107
  var _loop = function _loop() {
108
- var file = _step3.value;
109
- var extension = void 0;
110
- if (!utils.scriptExtensions.some(function (ext) {
111
- return extension = ext, file.endsWith(ext);
112
- })) return "continue";
113
- var filepath = _path["default"].join(scriptsDir, file);
114
- var script = _fs["default"].readFileSync(filepath, 'utf8');
115
- if (!script) return "continue";
116
- var name = utils.getScriptName(script, utils.commentMap[extension]);
117
- if (!name) return "continue";
118
- var tb = new utils.TemplateBuilder(utils.scriptWrapperTemplate).replace('FUNC_NAME', name).replace('FUNC_NAME_LOWERCASE', name).replace('PACKAGE_NAMESPACE', _package.name);
119
- var inputs = utils.getScriptInputs(script);
120
- var outputType = utils.getScriptOutputType(script);
121
- tb.replace('PARAMS_OBJECT', inputs).replace('TYPED_PARAMS', inputs).replace('OUTPUT_TYPE', outputType);
122
- wrappers.push(tb.build(1));
123
- };
108
+ var file = _step3.value;
109
+ var extension;
110
+ if (!utils.scriptExtensions.some(function (ext) {
111
+ return extension = ext, file.endsWith(ext);
112
+ })) return 0; // continue
113
+ var filepath = _path["default"].join(scriptsDir, file);
114
+ var script = _fs["default"].readFileSync(filepath, 'utf8');
115
+ if (!script) return 0; // continue
116
+ var name = utils.getScriptName(script, utils.commentMap[extension]);
117
+ if (!name) return 0; // continue
118
+ var tb = new utils.TemplateBuilder(utils.scriptWrapperTemplate).replace('FUNC_NAME', name).replace('FUNC_NAME_LOWERCASE', name).replace('PACKAGE_NAMESPACE', _package.name);
119
+ var inputs = utils.getScriptInputs(script);
120
+ var outputType = utils.getScriptOutputType(script);
121
+ tb.replace('PARAMS_OBJECT', inputs).replace('TYPED_PARAMS', inputs).replace('OUTPUT_TYPE', outputType);
122
+ wrappers.push(tb.build(1));
123
+ },
124
+ _ret;
124
125
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
125
- var _ret = _loop();
126
- if (_ret === "continue") continue;
126
+ _ret = _loop();
127
+ if (_ret === 0) continue;
127
128
  }
128
129
  } catch (err) {
129
130
  _iterator3.e(err);
@@ -20,11 +20,11 @@ var _ignoreWalk = _interopRequireDefault(require("ignore-walk"));
20
20
  var utils = _interopRequireWildcard(require("../utils/utils"));
21
21
  var color = _interopRequireWildcard(require("../utils/color-utils"));
22
22
  var testUtils = _interopRequireWildcard(require("../utils/test-utils"));
23
- 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); }
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
23
+ 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); }
24
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(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; }
25
25
  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; } } }; }
26
26
  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); }
27
- 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; }
27
+ 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; }
28
28
  function check(args) {
29
29
  var nOptions = Object.keys(args).length - 1;
30
30
  if (args['_'].length !== 1 || nOptions > 2 || nOptions > 0 && !args.r && !args.recursive) return false;
@@ -357,9 +357,7 @@ function checkFuncSignatures(packagePath, files) {
357
357
  var _f$tags;
358
358
  return (_f$tags = f.tags) === null || _f$tags === void 0 ? void 0 : _f$tags.includes(role);
359
359
  });
360
- if (roles.length > 1) {
361
- warnings.push("File ".concat(file, ", function ").concat(f.name, ": several function roles are used (").concat(roles.join(', '), ")"));
362
- } else if (roles.length === 1) {
360
+ if (roles.length > 1) warnings.push("File ".concat(file, ", function ").concat(f.name, ": several function roles are used (").concat(roles.join(', '), ")"));else if (roles.length === 1) {
363
361
  var vr = checkFunctions[roles[0]](f);
364
362
  if (!vr.value) warnings.push("File ".concat(file, ", function ").concat(f.name, ":\n").concat(vr.message));
365
363
  }
@@ -438,16 +436,16 @@ function checkPackageFile(packagePath, json, options) {
438
436
  if (!(_lib in options.externals && options.externals[_lib] === name)) {
439
437
  warnings.push("Webpack config parsing: Consider adding source \"".concat(source, "\" to webpack externals:\n") + "'".concat(_lib, "': '").concat(name, "'\n"));
440
438
  }
441
- } else {
442
- warnings.push("File \"package.json\": source \"".concat(source, "\" not in the list of shared libraries"));
443
- }
439
+ } else warnings.push("File \"package.json\": source \"".concat(source, "\" not in the list of shared libraries"));
444
440
  } else {
445
441
  warnings.push('Webpack config parsing: External modules not found.\n' + "Consider adding source \"".concat(source, "\" to webpack externals") + (source in sharedLibExternals ? ':\n' + "'".concat(Object.keys(sharedLibExternals[source])[0], "': '").concat(Object.values(sharedLibExternals[source])[0], "'\n") : ''));
446
442
  }
447
443
  }
448
444
  continue;
449
445
  }
450
- if (source.startsWith('src/') && _fs["default"].existsSync(_path["default"].join(packagePath, 'webpack.config.js'))) warnings.push('File "package.json": Sources cannot include files from the \`src/\` directory. ' + "Move file ".concat(source, " to another folder."));
446
+ if (source.startsWith('src/') && _fs["default"].existsSync(_path["default"].join(packagePath, 'webpack.config.js'))) {
447
+ warnings.push('File "package.json": Sources cannot include files from the \`src/\` directory. ' + "Move file ".concat(source, " to another folder."));
448
+ }
451
449
  if (!_fs["default"].existsSync(_path["default"].join(packagePath, source))) warnings.push("Source ".concat(source, " not found in the package."));
452
450
  }
453
451
  } catch (err) {
@@ -459,7 +457,7 @@ function checkPackageFile(packagePath, json, options) {
459
457
  return warnings;
460
458
  }
461
459
  function checkChangelog(packagePath, json) {
462
- var _h2$0$match, _h2$, _h2$$match;
460
+ var _h2$0$match, _h2$;
463
461
  if (json.servicePackage) return [];
464
462
  var warnings = [];
465
463
  var clf;
@@ -488,7 +486,7 @@ function checkChangelog(packagePath, json) {
488
486
  }
489
487
  regex = /^## (\d+\.\d+\.\d+)/;
490
488
  var v1 = (_h2$0$match = h2[0].match(regex)) === null || _h2$0$match === void 0 ? void 0 : _h2$0$match[1];
491
- var v2 = (_h2$ = h2[1]) === null || _h2$ === void 0 ? void 0 : (_h2$$match = _h2$.match(regex)) === null || _h2$$match === void 0 ? void 0 : _h2$$match[1];
489
+ var v2 = (_h2$ = h2[1]) === null || _h2$ === void 0 || (_h2$ = _h2$.match(regex)) === null || _h2$ === void 0 ? void 0 : _h2$[1];
492
490
  if (v1 !== json.version && v2 !== json.version) warnings.push("Latest package version (".concat(json.version, ") is not in CHANGELOG\n"));
493
491
  return warnings;
494
492
  }