datagrok-tools 4.12.18 → 4.12.20

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.
@@ -19,8 +19,8 @@ var _jsYaml = _interopRequireDefault(require("js-yaml"));
19
19
  var _check = require("./check");
20
20
  var utils = _interopRequireWildcard(require("../utils/utils"));
21
21
  var color = _interopRequireWildcard(require("../utils/color-utils"));
22
- 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); }
23
- 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; }
22
+ 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); }
23
+ 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; }
24
24
  // @ts-ignore
25
25
 
26
26
  // @ts-ignore
@@ -41,216 +41,212 @@ function _processPackage() {
41
41
  _processPackage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(debug, rebuild, host, devKey, packageName, suffix) {
42
42
  var timestamps, url, zip, localTimestamps, files, isWebpack, distFiles, contentValidationLog, checkStart, jsTsFiles, packageFilePath, json, webpackConfigPath, content, externals, importWarnings, funcFiles, funcWarnings, packageWarnings, changelogWarnings, uploadPromise, log;
43
43
  return _regenerator["default"].wrap(function _callee3$(_context3) {
44
- while (1) {
45
- switch (_context3.prev = _context3.next) {
46
- case 0:
47
- // Get the server timestamps
48
- timestamps = {};
49
- url = "".concat(host, "/packages/dev/").concat(devKey, "/").concat(packageName);
50
- if (!debug) {
51
- _context3.next = 18;
52
- break;
53
- }
54
- _context3.prev = 3;
55
- _context3.next = 6;
56
- return (0, _nodeFetch["default"])(url + '/timestamps');
57
- case 6:
58
- _context3.next = 8;
59
- return _context3.sent.json();
60
- case 8:
61
- timestamps = _context3.sent;
62
- if (!(timestamps['#type'] === 'ApiError')) {
63
- _context3.next = 12;
64
- break;
65
- }
66
- color.error(timestamps.message);
67
- return _context3.abrupt("return", 1);
68
- case 12:
44
+ while (1) switch (_context3.prev = _context3.next) {
45
+ case 0:
46
+ // Get the server timestamps
47
+ timestamps = {};
48
+ url = "".concat(host, "/packages/dev/").concat(devKey, "/").concat(packageName);
49
+ if (!debug) {
69
50
  _context3.next = 18;
70
51
  break;
71
- case 14:
72
- _context3.prev = 14;
73
- _context3.t0 = _context3["catch"](3);
74
- console.error(_context3.t0);
75
- return _context3.abrupt("return", 1);
76
- case 18:
77
- zip = (0, _archiverPromise["default"])('zip', {
78
- store: false
79
- }); // Gather the files
80
- localTimestamps = {};
81
- _context3.next = 22;
82
- return (0, _ignoreWalk["default"])({
83
- path: '.',
84
- ignoreFiles: ['.npmignore', '.gitignore', '.grokignore'],
85
- includeEmpty: false,
86
- follow: true
87
- });
88
- case 22:
89
- files = _context3.sent;
90
- isWebpack = _fs["default"].existsSync('webpack.config.js');
91
- if (!(!rebuild && isWebpack)) {
92
- _context3.next = 34;
93
- break;
94
- }
95
- if (!_fs["default"].existsSync('dist/package.js')) {
96
- _context3.next = 32;
97
- break;
98
- }
99
- _context3.next = 28;
100
- return (0, _ignoreWalk["default"])({
101
- path: './dist',
102
- ignoreFiles: [],
103
- includeEmpty: false,
104
- follow: true
105
- });
106
- case 28:
107
- distFiles = _context3.sent;
108
- distFiles.forEach(function (df) {
109
- files.push("dist/".concat(df));
110
- });
52
+ }
53
+ _context3.prev = 3;
54
+ _context3.next = 6;
55
+ return (0, _nodeFetch["default"])(url + '/timestamps');
56
+ case 6:
57
+ _context3.next = 8;
58
+ return _context3.sent.json();
59
+ case 8:
60
+ timestamps = _context3.sent;
61
+ if (!(timestamps['#type'] === 'ApiError')) {
62
+ _context3.next = 12;
63
+ break;
64
+ }
65
+ color.error(timestamps.message);
66
+ return _context3.abrupt("return", 1);
67
+ case 12:
68
+ _context3.next = 18;
69
+ break;
70
+ case 14:
71
+ _context3.prev = 14;
72
+ _context3.t0 = _context3["catch"](3);
73
+ console.error(_context3.t0);
74
+ return _context3.abrupt("return", 1);
75
+ case 18:
76
+ zip = (0, _archiverPromise["default"])('zip', {
77
+ store: false
78
+ }); // Gather the files
79
+ localTimestamps = {};
80
+ _context3.next = 22;
81
+ return (0, _ignoreWalk["default"])({
82
+ path: '.',
83
+ ignoreFiles: ['.npmignore', '.gitignore', '.grokignore'],
84
+ includeEmpty: false,
85
+ follow: true
86
+ });
87
+ case 22:
88
+ files = _context3.sent;
89
+ isWebpack = _fs["default"].existsSync('webpack.config.js');
90
+ if (!(!rebuild && isWebpack)) {
111
91
  _context3.next = 34;
112
92
  break;
113
- case 32:
114
- color.warn('File `dist/package.js` not found. Building the package on the server side...\n' + 'Next time, please build your package locally with Webpack beforehand\n' + 'or run `grok publish` with the `--rebuild` option');
115
- rebuild = true;
116
- case 34:
117
- contentValidationLog = '';
118
- console.log('Starting package checks...');
119
- checkStart = Date.now();
120
- jsTsFiles = files.filter(function (f) {
121
- return !f.startsWith('dist/') && (f.endsWith('.js') || f.endsWith('.ts'));
122
- });
123
- packageFilePath = _path["default"].join(curDir, 'package.json');
124
- json = JSON.parse(_fs["default"].readFileSync(packageFilePath, {
93
+ }
94
+ if (!_fs["default"].existsSync('dist/package.js')) {
95
+ _context3.next = 32;
96
+ break;
97
+ }
98
+ _context3.next = 28;
99
+ return (0, _ignoreWalk["default"])({
100
+ path: './dist',
101
+ ignoreFiles: [],
102
+ includeEmpty: false,
103
+ follow: true
104
+ });
105
+ case 28:
106
+ distFiles = _context3.sent;
107
+ distFiles.forEach(function (df) {
108
+ files.push("dist/".concat(df));
109
+ });
110
+ _context3.next = 34;
111
+ break;
112
+ case 32:
113
+ color.warn('File `dist/package.js` not found. Building the package on the server side...\n' + 'Next time, please build your package locally with Webpack beforehand\n' + 'or run `grok publish` with the `--rebuild` option');
114
+ rebuild = true;
115
+ case 34:
116
+ contentValidationLog = '';
117
+ console.log('Starting package checks...');
118
+ checkStart = Date.now();
119
+ jsTsFiles = files.filter(function (f) {
120
+ return !f.startsWith('dist/') && (f.endsWith('.js') || f.endsWith('.ts'));
121
+ });
122
+ packageFilePath = _path["default"].join(curDir, 'package.json');
123
+ json = JSON.parse(_fs["default"].readFileSync(packageFilePath, {
124
+ encoding: 'utf-8'
125
+ }));
126
+ if (isWebpack) {
127
+ webpackConfigPath = _path["default"].join(curDir, 'webpack.config.js');
128
+ content = _fs["default"].readFileSync(webpackConfigPath, {
125
129
  encoding: 'utf-8'
126
- }));
127
- if (isWebpack) {
128
- webpackConfigPath = _path["default"].join(curDir, 'webpack.config.js');
129
- content = _fs["default"].readFileSync(webpackConfigPath, {
130
- encoding: 'utf-8'
131
- });
132
- externals = (0, _check.extractExternals)(content);
133
- if (externals) {
134
- importWarnings = (0, _check.checkImportStatements)(curDir, jsTsFiles, externals);
135
- contentValidationLog += importWarnings.join('\n') + (importWarnings.length ? '\n' : '');
136
- }
137
- }
138
- funcFiles = jsTsFiles.filter(function (f) {
139
- return packageFiles.includes(f);
140
- });
141
- funcWarnings = (0, _check.checkFuncSignatures)(curDir, funcFiles);
142
- contentValidationLog += funcWarnings.join('\n') + (funcWarnings.length ? '\n' : '');
143
- packageWarnings = (0, _check.checkPackageFile)(curDir, json);
144
- contentValidationLog += packageWarnings.join('\n') + (packageWarnings.length ? '\n' : '');
145
- changelogWarnings = (0, _check.checkChangelog)(curDir, json);
146
- contentValidationLog += changelogWarnings.join('\n') + (packageWarnings.length ? '\n' : '');
147
- console.log("Checks finished in ".concat(Date.now() - checkStart, " ms"));
148
- files.forEach(function (file) {
149
- var fullPath = file;
150
- var relativePath = _path["default"].relative(curDir, fullPath);
151
- var canonicalRelativePath = relativePath.replace(/\\/g, '/');
152
- if (canonicalRelativePath.includes('/.')) return;
153
- if (canonicalRelativePath.startsWith('.')) return;
154
- if (relativePath.startsWith('node_modules')) return;
155
- if (relativePath.startsWith('dist') && rebuild) return;
156
- if (relativePath.startsWith('src') && !rebuild && isWebpack) {
157
- if (!relativePath.startsWith('src/package') && !relativePath.startsWith('src\\package')) return;
158
- }
159
- if (relativePath.startsWith('upload.keys.json')) return;
160
- if (relativePath === 'zip') return;
161
- if (!utils.checkScriptLocation(canonicalRelativePath)) {
162
- contentValidationLog += "Warning: file `".concat(canonicalRelativePath, "`") + " should be in directory `".concat(_path["default"].basename(curDir), "/scripts/`\n");
163
- }
164
- var t = _fs["default"].statSync(fullPath).mtime.toUTCString();
165
- localTimestamps[canonicalRelativePath] = t;
166
- if (debug && timestamps[canonicalRelativePath] === t) {
167
- console.log("Skipping ".concat(canonicalRelativePath));
168
- return;
169
- }
170
- zip.append(_fs["default"].createReadStream(fullPath), {
171
- name: relativePath
172
- });
173
- console.log("Adding ".concat(canonicalRelativePath, "..."));
174
130
  });
175
- zip.append(JSON.stringify(localTimestamps), {
176
- name: 'timestamps.json'
131
+ externals = (0, _check.extractExternals)(content);
132
+ if (externals) {
133
+ importWarnings = (0, _check.checkImportStatements)(curDir, jsTsFiles, externals);
134
+ contentValidationLog += importWarnings.join('\n') + (importWarnings.length ? '\n' : '');
135
+ }
136
+ }
137
+ funcFiles = jsTsFiles.filter(function (f) {
138
+ return packageFiles.includes(f);
139
+ });
140
+ funcWarnings = (0, _check.checkFuncSignatures)(curDir, funcFiles);
141
+ contentValidationLog += funcWarnings.join('\n') + (funcWarnings.length ? '\n' : '');
142
+ packageWarnings = (0, _check.checkPackageFile)(curDir, json);
143
+ contentValidationLog += packageWarnings.join('\n') + (packageWarnings.length ? '\n' : '');
144
+ changelogWarnings = (0, _check.checkChangelog)(curDir, json);
145
+ contentValidationLog += changelogWarnings.join('\n') + (packageWarnings.length ? '\n' : '');
146
+ console.log("Checks finished in ".concat(Date.now() - checkStart, " ms"));
147
+ files.forEach(function (file) {
148
+ var fullPath = file;
149
+ var relativePath = _path["default"].relative(curDir, fullPath);
150
+ var canonicalRelativePath = relativePath.replace(/\\/g, '/');
151
+ if (canonicalRelativePath.includes('/.')) return;
152
+ if (canonicalRelativePath.startsWith('.')) return;
153
+ if (relativePath.startsWith('node_modules')) return;
154
+ if (relativePath.startsWith('dist') && rebuild) return;
155
+ if (relativePath.startsWith('src') && !rebuild && isWebpack) {
156
+ if (!relativePath.startsWith('src/package') && !relativePath.startsWith('src\\package')) return;
157
+ }
158
+ if (relativePath.startsWith('upload.keys.json')) return;
159
+ if (relativePath === 'zip') return;
160
+ if (!utils.checkScriptLocation(canonicalRelativePath)) {
161
+ contentValidationLog += "Warning: file `".concat(canonicalRelativePath, "`") + " should be in directory `".concat(_path["default"].basename(curDir), "/scripts/`\n");
162
+ }
163
+ var t = _fs["default"].statSync(fullPath).mtime.toUTCString();
164
+ localTimestamps[canonicalRelativePath] = t;
165
+ if (debug && timestamps[canonicalRelativePath] === t) {
166
+ console.log("Skipping ".concat(canonicalRelativePath));
167
+ return;
168
+ }
169
+ zip.append(_fs["default"].createReadStream(fullPath), {
170
+ name: relativePath
177
171
  });
172
+ console.log("Adding ".concat(canonicalRelativePath, "..."));
173
+ });
174
+ zip.append(JSON.stringify(localTimestamps), {
175
+ name: 'timestamps.json'
176
+ });
178
177
 
179
- // Upload
180
- url += "?debug=".concat(debug.toString(), "&rebuild=").concat(rebuild.toString());
181
- if (suffix) url += "&suffix=".concat(suffix.toString());
182
- uploadPromise = new Promise(function (resolve, reject) {
183
- (0, _nodeFetch["default"])(url, {
184
- method: 'POST',
185
- body: zip
186
- }).then( /*#__PURE__*/function () {
187
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(body) {
188
- var response;
189
- return _regenerator["default"].wrap(function _callee2$(_context2) {
190
- while (1) {
191
- switch (_context2.prev = _context2.next) {
192
- case 0:
193
- _context2.prev = 0;
194
- _context2.next = 3;
195
- return body.text();
196
- case 3:
197
- response = _context2.sent;
198
- return _context2.abrupt("return", JSON.parse(response));
199
- case 7:
200
- _context2.prev = 7;
201
- _context2.t0 = _context2["catch"](0);
202
- console.error(response);
203
- case 10:
204
- case "end":
205
- return _context2.stop();
206
- }
207
- }
208
- }, _callee2, null, [[0, 7]]);
209
- }));
210
- return function (_x7) {
211
- return _ref2.apply(this, arguments);
212
- };
213
- }()).then(function (j) {
214
- return resolve(j);
215
- })["catch"](function (err) {
216
- reject(err);
217
- });
218
- })["catch"](function (error) {
219
- console.error(error);
178
+ // Upload
179
+ url += "?debug=".concat(debug.toString(), "&rebuild=").concat(rebuild.toString());
180
+ if (suffix) url += "&suffix=".concat(suffix.toString());
181
+ uploadPromise = new Promise(function (resolve, reject) {
182
+ (0, _nodeFetch["default"])(url, {
183
+ method: 'POST',
184
+ body: zip
185
+ }).then( /*#__PURE__*/function () {
186
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(body) {
187
+ var response;
188
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
189
+ while (1) switch (_context2.prev = _context2.next) {
190
+ case 0:
191
+ _context2.prev = 0;
192
+ _context2.next = 3;
193
+ return body.text();
194
+ case 3:
195
+ response = _context2.sent;
196
+ return _context2.abrupt("return", JSON.parse(response));
197
+ case 7:
198
+ _context2.prev = 7;
199
+ _context2.t0 = _context2["catch"](0);
200
+ console.error(response);
201
+ case 10:
202
+ case "end":
203
+ return _context2.stop();
204
+ }
205
+ }, _callee2, null, [[0, 7]]);
206
+ }));
207
+ return function (_x7) {
208
+ return _ref2.apply(this, arguments);
209
+ };
210
+ }()).then(function (j) {
211
+ return resolve(j);
212
+ })["catch"](function (err) {
213
+ reject(err);
220
214
  });
221
- _context3.next = 56;
222
- return zip.finalize();
223
- case 56:
224
- _context3.prev = 56;
225
- _context3.next = 59;
226
- return uploadPromise;
227
- case 59:
228
- log = _context3.sent;
229
- _fs["default"].unlinkSync('zip');
230
- if (!(log['#type'] === 'ApiError')) {
231
- _context3.next = 67;
232
- break;
233
- }
234
- color.error(log['message']);
235
- console.error(log['innerMessage']);
236
- return _context3.abrupt("return", 1);
237
- case 67:
238
- console.log(log);
239
- color.warn(contentValidationLog);
240
- case 69:
241
- _context3.next = 75;
215
+ })["catch"](function (error) {
216
+ console.error(error);
217
+ });
218
+ _context3.next = 56;
219
+ return zip.finalize();
220
+ case 56:
221
+ _context3.prev = 56;
222
+ _context3.next = 59;
223
+ return uploadPromise;
224
+ case 59:
225
+ log = _context3.sent;
226
+ _fs["default"].unlinkSync('zip');
227
+ if (!(log['#type'] === 'ApiError')) {
228
+ _context3.next = 67;
242
229
  break;
243
- case 71:
244
- _context3.prev = 71;
245
- _context3.t1 = _context3["catch"](56);
246
- console.error(_context3.t1);
247
- return _context3.abrupt("return", 1);
248
- case 75:
249
- return _context3.abrupt("return", 0);
250
- case 76:
251
- case "end":
252
- return _context3.stop();
253
- }
230
+ }
231
+ color.error(log['message']);
232
+ console.error(log['innerMessage']);
233
+ return _context3.abrupt("return", 1);
234
+ case 67:
235
+ console.log(log);
236
+ color.warn(contentValidationLog);
237
+ case 69:
238
+ _context3.next = 75;
239
+ break;
240
+ case 71:
241
+ _context3.prev = 71;
242
+ _context3.t1 = _context3["catch"](56);
243
+ console.error(_context3.t1);
244
+ return _context3.abrupt("return", 1);
245
+ case 75:
246
+ return _context3.abrupt("return", 0);
247
+ case 76:
248
+ case "end":
249
+ return _context3.stop();
254
250
  }
255
251
  }, _callee3, null, [[3, 14], [56, 71]]);
256
252
  }));
@@ -307,33 +303,31 @@ function publish(args) {
307
303
  var packageName = _package.name;
308
304
 
309
305
  // Upload the package
310
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
306
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
311
307
  process.on('beforeExit', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
312
308
  var code;
313
309
  return _regenerator["default"].wrap(function _callee$(_context) {
314
- while (1) {
315
- switch (_context.prev = _context.next) {
316
- case 0:
317
- code = 0;
318
- _context.prev = 1;
319
- _context.next = 4;
320
- return processPackage(!args.release, Boolean(args.rebuild), url, key, packageName, args.suffix);
321
- case 4:
322
- code = _context.sent;
323
- _context.next = 11;
324
- break;
325
- case 7:
326
- _context.prev = 7;
327
- _context.t0 = _context["catch"](1);
328
- console.error(_context.t0);
329
- code = 1;
330
- case 11:
331
- console.log("Exiting with code ".concat(code));
332
- process.exit(code);
333
- case 13:
334
- case "end":
335
- return _context.stop();
336
- }
310
+ while (1) switch (_context.prev = _context.next) {
311
+ case 0:
312
+ code = 0;
313
+ _context.prev = 1;
314
+ _context.next = 4;
315
+ return processPackage(!args.release, Boolean(args.rebuild), url, key, packageName, args.suffix);
316
+ case 4:
317
+ code = _context.sent;
318
+ _context.next = 11;
319
+ break;
320
+ case 7:
321
+ _context.prev = 7;
322
+ _context.t0 = _context["catch"](1);
323
+ console.error(_context.t0);
324
+ code = 1;
325
+ case 11:
326
+ console.log("Exiting with code ".concat(code));
327
+ process.exit(code);
328
+ case 13:
329
+ case "end":
330
+ return _context.stop();
337
331
  }
338
332
  }, _callee, null, [[1, 7]]);
339
333
  })));