datagrok-tools 4.12.22 → 4.12.24

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
@@ -83,6 +83,8 @@ Read more about package development in [Datagrok's documentation](https://datagr
83
83
  - `api` creates wrapper functions for package scripts and queries. The output is stored in files `/src/scripts-api.ts`
84
84
  and `/src/queries-api.ts` respectively.
85
85
  - `publish` uploads a package to the specified server (pass either a URL or a server alias from the `config.yaml` file).
86
+ Additionally, you can use placeholders in JSON files under the `/connections` folder to substitute environment variables.
87
+ For more information on configuring connections, refer to the [Connections](https://datagrok.ai/help/develop#connections) article.
86
88
 
87
89
  ```shell
88
90
  cd <package-name>
@@ -488,6 +488,7 @@ function checkChangelog(packagePath, json) {
488
488
  var v1 = (_h2$0$match = h2[0].match(regex)) === null || _h2$0$match === void 0 ? void 0 : _h2$0$match[1];
489
489
  var v2 = (_h2$ = h2[1]) === null || _h2$ === void 0 || (_h2$ = _h2$.match(regex)) === null || _h2$ === void 0 ? void 0 : _h2$[1];
490
490
  if (v1 !== json.version && v2 !== json.version) warnings.push("Latest package version (".concat(json.version, ") is not in CHANGELOG\n"));
491
+ if (warnings.length) warnings.push('Changelog guideline: https://datagrok.ai/help/develop/dev-process/changelog-policy#changelog-guideline');
491
492
  return warnings;
492
493
  }
493
494
  function warn(warnings) {
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.processPackage = processPackage;
9
9
  exports.publish = publish;
10
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
13
  var _archiverPromise = _interopRequireDefault(require("archiver-promise"));
13
14
  var _fs = _interopRequireDefault(require("fs"));
@@ -21,10 +22,10 @@ var utils = _interopRequireWildcard(require("../utils/utils"));
21
22
  var color = _interopRequireWildcard(require("../utils/color-utils"));
22
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); }
23
24
  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; }
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
+ 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; } // @ts-ignore
24
28
  // @ts-ignore
25
-
26
- // @ts-ignore
27
-
28
29
  var grokDir = _path["default"].join(_os["default"].homedir(), '.grok');
29
30
  var confPath = _path["default"].join(grokDir, 'config.yaml');
30
31
  var confTemplateDir = _path["default"].join(_path["default"].dirname(_path["default"].dirname(__dirname)), 'config-template.yaml');
@@ -39,7 +40,7 @@ function processPackage(_x, _x2, _x3, _x4, _x5, _x6) {
39
40
  }
40
41
  function _processPackage() {
41
42
  _processPackage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(debug, rebuild, host, devKey, packageName, suffix) {
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
+ var timestamps, url, zip, localTimestamps, files, isWebpack, distFiles, contentValidationLog, checkStart, jsTsFiles, packageFilePath, json, webpackConfigPath, content, externals, importWarnings, funcFiles, funcWarnings, packageWarnings, changelogWarnings, reg, errs, uploadPromise, log;
43
44
  return _regenerator["default"].wrap(function _callee3$(_context3) {
44
45
  while (1) switch (_context3.prev = _context3.next) {
45
46
  case 0:
@@ -144,6 +145,8 @@ function _processPackage() {
144
145
  changelogWarnings = (0, _check.checkChangelog)(curDir, json);
145
146
  contentValidationLog += changelogWarnings.join('\n') + (packageWarnings.length ? '\n' : '');
146
147
  console.log("Checks finished in ".concat(Date.now() - checkStart, " ms"));
148
+ reg = new RegExp(/\${(\w*)}/g);
149
+ errs = [];
147
150
  files.forEach(function (file) {
148
151
  var fullPath = file;
149
152
  var relativePath = _path["default"].relative(curDir, fullPath);
@@ -166,11 +169,48 @@ function _processPackage() {
166
169
  console.log("Skipping ".concat(canonicalRelativePath));
167
170
  return;
168
171
  }
172
+ if (canonicalRelativePath.startsWith('connections/')) {
173
+ var f = _fs["default"].readFileSync(fullPath, {
174
+ encoding: 'utf-8'
175
+ });
176
+ var matches = (0, _toConsumableArray2["default"])(f.matchAll(reg));
177
+ var _iterator = _createForOfIteratorHelper(matches),
178
+ _step;
179
+ try {
180
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
181
+ var m = _step.value;
182
+ var envVar = process.env[m[1]];
183
+ if (!envVar) {
184
+ errs.push("".concat(canonicalRelativePath, ": cannot find environment variable \"").concat(m[1], "\""));
185
+ continue;
186
+ }
187
+ f = f.replace(m[0], envVar);
188
+ }
189
+ } catch (err) {
190
+ _iterator.e(err);
191
+ } finally {
192
+ _iterator.f();
193
+ }
194
+ zip.append(f, {
195
+ name: relativePath
196
+ });
197
+ console.log("Adding ".concat(canonicalRelativePath, "..."));
198
+ return;
199
+ }
169
200
  zip.append(_fs["default"].createReadStream(fullPath), {
170
201
  name: relativePath
171
202
  });
172
203
  console.log("Adding ".concat(canonicalRelativePath, "..."));
173
204
  });
205
+ if (!errs.length) {
206
+ _context3.next = 55;
207
+ break;
208
+ }
209
+ errs.forEach(function (e) {
210
+ return color.error(e);
211
+ });
212
+ return _context3.abrupt("return", 1);
213
+ case 55:
174
214
  zip.append(JSON.stringify(localTimestamps), {
175
215
  name: 'timestamps.json'
176
216
  });
@@ -215,40 +255,41 @@ function _processPackage() {
215
255
  })["catch"](function (error) {
216
256
  console.error(error);
217
257
  });
218
- _context3.next = 56;
258
+ _context3.next = 61;
219
259
  return zip.finalize();
220
- case 56:
221
- _context3.prev = 56;
222
- _context3.next = 59;
260
+ case 61:
261
+ _context3.prev = 61;
262
+ _context3.next = 64;
223
263
  return uploadPromise;
224
- case 59:
264
+ case 64:
225
265
  log = _context3.sent;
226
266
  _fs["default"].unlinkSync('zip');
227
267
  if (!(log['#type'] === 'ApiError')) {
228
- _context3.next = 67;
268
+ _context3.next = 73;
229
269
  break;
230
270
  }
231
271
  color.error(log['message']);
232
272
  console.error(log['innerMessage']);
273
+ console.log(log);
233
274
  return _context3.abrupt("return", 1);
234
- case 67:
275
+ case 73:
235
276
  console.log(log);
236
277
  color.warn(contentValidationLog);
237
- case 69:
238
- _context3.next = 75;
278
+ case 75:
279
+ _context3.next = 81;
239
280
  break;
240
- case 71:
241
- _context3.prev = 71;
242
- _context3.t1 = _context3["catch"](56);
281
+ case 77:
282
+ _context3.prev = 77;
283
+ _context3.t1 = _context3["catch"](61);
243
284
  console.error(_context3.t1);
244
285
  return _context3.abrupt("return", 1);
245
- case 75:
286
+ case 81:
246
287
  return _context3.abrupt("return", 0);
247
- case 76:
288
+ case 82:
248
289
  case "end":
249
290
  return _context3.stop();
250
291
  }
251
- }, _callee3, null, [[3, 14], [56, 71]]);
292
+ }, _callee3, null, [[3, 14], [61, 77]]);
252
293
  }));
253
294
  return _processPackage.apply(this, arguments);
254
295
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datagrok-tools",
3
- "version": "4.12.22",
3
+ "version": "4.12.24",
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": {