@intelligentgraphics/ig.gfx.packager 2.1.4 → 2.3.0

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/build/index.js CHANGED
@@ -3265,6 +3265,157 @@ exports.WorkSlave = WorkSlave;
3265
3265
 
3266
3266
  /***/ }),
3267
3267
 
3268
+ /***/ "./src/assetService.ts":
3269
+ /*!*****************************!*\
3270
+ !*** ./src/assetService.ts ***!
3271
+ \*****************************/
3272
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3273
+
3274
+ "use strict";
3275
+
3276
+
3277
+ Object.defineProperty(exports, "__esModule", ({
3278
+ value: true
3279
+ }));
3280
+ exports.uploadPackage = exports.startSession = exports.closeSession = void 0;
3281
+
3282
+ __webpack_require__(/*! core-js/modules/es.promise.js */ "../../node_modules/core-js/modules/es.promise.js");
3283
+
3284
+ var _axios = _interopRequireDefault(__webpack_require__(/*! axios */ "axios"));
3285
+
3286
+ var fs = _interopRequireWildcard(__webpack_require__(/*! fs */ "fs"));
3287
+
3288
+ const _excluded = ["url", "authentication"];
3289
+
3290
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
3291
+
3292
+ 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; }
3293
+
3294
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3295
+
3296
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3297
+
3298
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3299
+
3300
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3301
+
3302
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
3303
+
3304
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
3305
+
3306
+ /**
3307
+ * Starts an asset service session and returns the sessionId
3308
+ *
3309
+ * @param {SessionStartParams} params
3310
+ * @returns
3311
+ */
3312
+ const startSession = async _ref => {
3313
+ let {
3314
+ url,
3315
+ authentication
3316
+ } = _ref,
3317
+ params = _objectWithoutProperties(_ref, _excluded);
3318
+
3319
+ const payload = _objectSpread(_objectSpread({}, params), {}, {
3320
+ user: undefined,
3321
+ password: undefined,
3322
+ license: undefined
3323
+ });
3324
+
3325
+ if (authentication.type === "credentials") {
3326
+ payload.user = authentication.username;
3327
+ payload.password = authentication.password;
3328
+ } else if (authentication.type === "license") {
3329
+ payload.license = authentication.license;
3330
+ }
3331
+
3332
+ const {
3333
+ data: {
3334
+ session: sessionId,
3335
+ state
3336
+ }
3337
+ } = await _axios.default.post(`Session/Start2`, JSON.stringify(payload), {
3338
+ baseURL: url
3339
+ });
3340
+
3341
+ if (state !== "SUCCESS") {
3342
+ throw new Error(`Could not start session: Asset server responded with ${state}`);
3343
+ }
3344
+
3345
+ return sessionId;
3346
+ };
3347
+
3348
+ exports.startSession = startSession;
3349
+
3350
+ const closeSession = async (url, sessionId) => {
3351
+ await _axios.default.get(`Session/Close/${sessionId}`, {
3352
+ baseURL: url
3353
+ });
3354
+ };
3355
+
3356
+ exports.closeSession = closeSession;
3357
+
3358
+ const uploadPackage = async (url, sessionId, packageName, zipFilePath) => {
3359
+ try {
3360
+ await uploadPackageToUrl(url, `UploadPackage/${sessionId}/${packageName}`, zipFilePath);
3361
+ } catch (err) {
3362
+ await uploadPackageToUrl(url, `UploadPackage/${sessionId}/${packageName}/`, zipFilePath);
3363
+ }
3364
+ };
3365
+
3366
+ exports.uploadPackage = uploadPackage;
3367
+
3368
+ const uploadPackageToUrl = (url, path, zipFilePath) => _axios.default.post(path, fs.createReadStream(zipFilePath), {
3369
+ baseURL: url
3370
+ }).then(({
3371
+ data,
3372
+ status
3373
+ }) => {
3374
+ let objectBody;
3375
+
3376
+ if (typeof data === "string") {
3377
+ try {
3378
+ objectBody = JSON.parse(data);
3379
+ } catch (err) {}
3380
+ } else if (typeof data === "object") {
3381
+ objectBody = data;
3382
+ }
3383
+
3384
+ if (objectBody !== undefined) {
3385
+ if ("state" in objectBody && objectBody.state !== "SUCCESS") {
3386
+ var _objectBody$response;
3387
+
3388
+ throw new Error((_objectBody$response = objectBody.response) !== null && _objectBody$response !== void 0 ? _objectBody$response : objectBody.state);
3389
+ }
3390
+ }
3391
+
3392
+ if (status >= 400) {
3393
+ if (objectBody !== undefined) {
3394
+ let text = "";
3395
+
3396
+ for (const key in objectBody) {
3397
+ text += key + ": \n";
3398
+
3399
+ if (typeof objectBody[key] === "object") {
3400
+ text += JSON.stringify(objectBody[key], undefined, 2);
3401
+ } else {
3402
+ text += objectBody[key];
3403
+ }
3404
+
3405
+ text += "\n\n";
3406
+ }
3407
+
3408
+ throw new Error(text);
3409
+ }
3410
+
3411
+ throw new Error(data);
3412
+ }
3413
+
3414
+ return data;
3415
+ });
3416
+
3417
+ /***/ }),
3418
+
3268
3419
  /***/ "./src/commands/build.ts":
3269
3420
  /*!*******************************!*\
3270
3421
  !*** ./src/commands/build.ts ***!
@@ -3429,6 +3580,270 @@ const buildSortedPackageMap = folders => {
3429
3580
 
3430
3581
  /***/ }),
3431
3582
 
3583
+ /***/ "./src/commands/generate.ts":
3584
+ /*!**********************************!*\
3585
+ !*** ./src/commands/generate.ts ***!
3586
+ \**********************************/
3587
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3588
+
3589
+ "use strict";
3590
+
3591
+
3592
+ Object.defineProperty(exports, "__esModule", ({
3593
+ value: true
3594
+ }));
3595
+ exports.extract = extract;
3596
+
3597
+ var fs = _interopRequireWildcard(__webpack_require__(/*! fs-extra */ "fs-extra"));
3598
+
3599
+ var _path = _interopRequireDefault(__webpack_require__(/*! path */ "path"));
3600
+
3601
+ var ts = _interopRequireWildcard(__webpack_require__(/*! typescript */ "typescript"));
3602
+
3603
+ var _tsc = __webpack_require__(/*! ../tsc */ "./src/tsc.ts");
3604
+
3605
+ var _os = _interopRequireDefault(__webpack_require__(/*! os */ "os"));
3606
+
3607
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3608
+
3609
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
3610
+
3611
+ 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; }
3612
+
3613
+ function findTsNode(node, callback) {
3614
+ let result;
3615
+ ts.forEachChild(node, child => {
3616
+ if (callback(child)) {
3617
+ result = child;
3618
+ return true;
3619
+ }
3620
+ });
3621
+ return result;
3622
+ }
3623
+
3624
+ function getParamsFromJsDoc(text) {
3625
+ let lines = text.split(_os.default.EOL);
3626
+ let splitLines = lines.map(line => line.split(":").map(s => s.trim()));
3627
+ let params = {};
3628
+ splitLines.filter(line => line.length > 1).forEach(line => {
3629
+ params[line[0]] = line[1];
3630
+ });
3631
+ return params;
3632
+ }
3633
+
3634
+ function getDescFromJsDoc(text) {
3635
+ let lines = text.split(_os.default.EOL);
3636
+ let splitLines = lines.map(line => line.split(":").map(s => s.trim()));
3637
+ let desc = "";
3638
+ splitLines.filter(line => line.length == 1).forEach((line, i) => {
3639
+ desc += (i == 0 ? "" : " ") + line[0];
3640
+ });
3641
+ return desc.substring(0, 98);
3642
+ }
3643
+
3644
+ function capitalizeFirstLetter(string) {
3645
+ return (string === null || string === void 0 ? void 0 : string.charAt(0).toUpperCase()) + (string === null || string === void 0 ? void 0 : string.slice(1));
3646
+ }
3647
+
3648
+ function parseDefault(value, type) {
3649
+ const uType = capitalizeFirstLetter(type);
3650
+ if (value === "null") return null;
3651
+
3652
+ switch (uType) {
3653
+ case "LengthM":
3654
+ case "ArcDEG":
3655
+ case "Float":
3656
+ return parseFloat(value);
3657
+
3658
+ case "Integer":
3659
+ case "Int":
3660
+ return parseInt(value);
3661
+
3662
+ case "Boolean":
3663
+ case "Bool":
3664
+ return value === "true";
3665
+
3666
+ case "Material":
3667
+ case "String":
3668
+ default:
3669
+ return value.replace(/^"/, '').replace(/"$/, '');
3670
+ }
3671
+ }
3672
+
3673
+ function findEvaluatorNode(node) {
3674
+ if (ts.isModuleDeclaration(node) && node.body && ts.isModuleDeclaration(node.body) && node.body.body) {
3675
+ const classDeclaration = findTsNode(node.body.body, child => {
3676
+ var _child$heritageClause;
3677
+
3678
+ if (!ts.isClassDeclaration(child)) {
3679
+ return false;
3680
+ }
3681
+
3682
+ const isEvaluator = (_child$heritageClause = child.heritageClauses) === null || _child$heritageClause === void 0 ? void 0 : _child$heritageClause.some(clause => {
3683
+ if (clause.token !== ts.SyntaxKind.ExtendsKeyword) {
3684
+ return false;
3685
+ }
3686
+
3687
+ return clause.types.some(type => type.getText().includes("Evaluator"));
3688
+ });
3689
+ return isEvaluator !== null && isEvaluator !== void 0 ? isEvaluator : false;
3690
+ });
3691
+ return classDeclaration;
3692
+ }
3693
+ }
3694
+
3695
+ function getParameter(evaluatorNode) {
3696
+ var _evaluatorNode$member;
3697
+
3698
+ let memb = (_evaluatorNode$member = evaluatorNode.members) === null || _evaluatorNode$member === void 0 ? void 0 : _evaluatorNode$member.find(member => {
3699
+ var _member$name;
3700
+
3701
+ return (member === null || member === void 0 ? void 0 : (_member$name = member.name) === null || _member$name === void 0 ? void 0 : _member$name.getText().toLowerCase()) == "create";
3702
+ });
3703
+
3704
+ if (ts.isMethodDeclaration(memb)) {
3705
+ return memb.parameters.find(para => para.name.getText().toLowerCase() == "parameters");
3706
+ }
3707
+ }
3708
+
3709
+ function findParametersInterface(node, interfaceName) {
3710
+ if (ts.isModuleDeclaration(node) && node.body && ts.isModuleDeclaration(node.body) && node.body.body) {
3711
+ const interfaceDeclaration = findTsNode(node.body.body, child => ts.isInterfaceDeclaration(child) && child.name.getText() == interfaceName);
3712
+ return interfaceDeclaration;
3713
+ }
3714
+
3715
+ return undefined;
3716
+ }
3717
+
3718
+ function getModuleName(sourceFile) {
3719
+ let fullName = "";
3720
+
3721
+ if (ts.isModuleDeclaration(sourceFile)) {
3722
+ fullName += sourceFile.name.getText();
3723
+ let packageB = sourceFile.body;
3724
+
3725
+ if (ts.isModuleDeclaration(packageB)) {
3726
+ fullName += "." + packageB.name.getText();
3727
+ }
3728
+ }
3729
+
3730
+ return fullName;
3731
+ }
3732
+
3733
+ function genParameters(interfac) {
3734
+ return interfac.members.map((member, i) => {
3735
+ let para = {};
3736
+ para.Name = member.name.getText();
3737
+ if (para.Name.length > 45) throw new Error(`Parameter name length >45 '${para.Name}'`);
3738
+ let rawDocTags = ts.getJSDocTags(member);
3739
+
3740
+ if (rawDocTags.length) {
3741
+ let dict = getTagDict(rawDocTags);
3742
+ if (dict.summary) para.Description = dict.summary;
3743
+ if (dict.creatorType) para.Type = dict.creatorType;
3744
+ if (dict.default && dict.creatorType) para.Default = parseDefault(dict.default, dict.creatorType);
3745
+ para.DisplayIndex = i + 1;
3746
+ }
3747
+
3748
+ return para;
3749
+ });
3750
+ }
3751
+
3752
+ function getTagDict(tags) {
3753
+ let dict = {};
3754
+ tags.forEach(tag => {
3755
+ dict[tag.tagName.text] = tag.comment;
3756
+ });
3757
+ return dict;
3758
+ }
3759
+
3760
+ function findParametersInterfaceInFiles(program, fileList, name) {
3761
+ for (const file of fileList) {
3762
+ const sourceFile = program.getSourceFile(file);
3763
+
3764
+ if (sourceFile === undefined) {
3765
+ throw new Error(`Expected a source file to exist for file name "${file}"`);
3766
+ }
3767
+
3768
+ let interfaceDeclaration;
3769
+ ts.forEachChild(sourceFile, node => {
3770
+ interfaceDeclaration = findParametersInterface(node, name);
3771
+ return interfaceDeclaration !== undefined;
3772
+ });
3773
+
3774
+ if (interfaceDeclaration !== undefined) {
3775
+ return interfaceDeclaration;
3776
+ }
3777
+ }
3778
+
3779
+ return undefined;
3780
+ }
3781
+ /**
3782
+ * Extracts and returns script array for _Index.json from a src folder
3783
+ *
3784
+ * @param folderPath path to a src folder
3785
+ */
3786
+
3787
+
3788
+ function extract(folderPath, ignore = []) {
3789
+ const files = (0, _tsc.findTypescriptFiles)(_path.default.join(folderPath, "src"));
3790
+ const filtered = files.filter(path => {
3791
+ return !ignore.some(suffix => path.endsWith(suffix));
3792
+ });
3793
+ let arr = new Array();
3794
+ let program = ts.createProgram(filtered, {
3795
+ allowJs: true
3796
+ });
3797
+ program.getTypeChecker();
3798
+ filtered.forEach(file => {
3799
+ // Create a Program to represent the project, then pull out the
3800
+ // source file to parse its AST.
3801
+ const sourceFile = program.getSourceFile(file); // Loop through the root AST nodes of the file
3802
+
3803
+ ts.forEachChild(sourceFile, node => {
3804
+ let obj = {};
3805
+ const evalNode = findEvaluatorNode(node);
3806
+
3807
+ if (evalNode === undefined) {
3808
+ return;
3809
+ }
3810
+
3811
+ let moduleName = getModuleName(node);
3812
+
3813
+ if (evalNode.name === undefined) {
3814
+ throw new Error(`Expected evaluator class to have a name`);
3815
+ }
3816
+
3817
+ obj.Name = moduleName + "." + evalNode.name.getText();
3818
+ if (obj.Name.length > 45) throw new Error(`Package name length >45 '${obj.Name}'`);
3819
+ let para = getParameter(evalNode);
3820
+ let paraName = para === null || para === void 0 ? void 0 : para.type.typeName.getText();
3821
+ let interfac = findParametersInterfaceInFiles(program, filtered, paraName);
3822
+
3823
+ if (interfac === undefined) {
3824
+ throw new Error(`Failed to find parameters type declaration for evaluator ${evalNode.name.getText()}`);
3825
+ }
3826
+
3827
+ let rawDocTags = ts.getJSDocTags(evalNode);
3828
+
3829
+ if (rawDocTags.length) {
3830
+ let dict = getTagDict(rawDocTags);
3831
+ if (dict.summary) obj.Description = dict.summary;
3832
+ if (dict.creatorType) obj.Type = dict.creatorType;
3833
+ }
3834
+
3835
+ obj.Parameters = genParameters(interfac);
3836
+ arr.push(obj);
3837
+ });
3838
+ });
3839
+
3840
+ let pathX = _path.default.join(folderPath, "_Index.json");
3841
+
3842
+ fs.writeFileSync(pathX, JSON.stringify(arr, null, 4));
3843
+ }
3844
+
3845
+ /***/ }),
3846
+
3432
3847
  /***/ "./src/commands/release.ts":
3433
3848
  /*!*********************************!*\
3434
3849
  !*** ./src/commands/release.ts ***!
@@ -3545,8 +3960,7 @@ const releaseFolder = async (folderPath, options) => {
3545
3960
  cwd: options.cwd,
3546
3961
  upload: !options.noUpload,
3547
3962
  service: options.service,
3548
- user: options.user,
3549
- password: options.password,
3963
+ authentication: options.authentication,
3550
3964
  folderPath,
3551
3965
  pushOnly: options.pushOnly
3552
3966
  });
@@ -3569,10 +3983,10 @@ const releaseFolder = async (folderPath, options) => {
3569
3983
  fs.ensureDirSync(releasesPath);
3570
3984
  fs.copyFileSync(path.join(options.cwd, "bin", zipFileName), path.join(releasesPath, zipFileName));
3571
3985
  }
3572
- }; //https://regex101.com/r/VfoI7n/1
3986
+ }; // https://regex101.com/r/LtGAu5/1
3573
3987
 
3574
3988
 
3575
- const logRegex = /console\.log\(\s*"([\w\s\.\(\)]+)\ *Copyright[\w\s\(\)\.]+(\d{4}|\d{4} - \d{4})([\w\s\(\)\.]+)?"\)/i;
3989
+ const logRegex = /console\.log\(\s*"([\w\s\.\(\)]+)\ *Copyright[\w\s\(\)\.]+(\d{4}|\d{4} - \d{4})([\w\s\(\)\.]+)?",?\s*\)/i;
3576
3990
  const currentYear = new Date(Date.now()).getFullYear();
3577
3991
 
3578
3992
  const getVersionFile = folder => {
@@ -3622,7 +4036,7 @@ const getVersionFile = folder => {
3622
4036
  return invalidVersionFile();
3623
4037
  }
3624
4038
 
3625
- const [, description, copyright, copyrightStuff] = match;
4039
+ const [_full, _description, copyright, copyrightStuff] = match;
3626
4040
  const copyrightYears = copyright.match(/^(\d+)( ?- ?(\d+))?$/);
3627
4041
  let years;
3628
4042
 
@@ -3633,7 +4047,6 @@ const getVersionFile = folder => {
3633
4047
  }
3634
4048
 
3635
4049
  return {
3636
- version: parseVersion(description),
3637
4050
  write: createVersionFileWriter(years, copyrightStuff),
3638
4051
  reset: () => {
3639
4052
  _igTools.FileUtil.writeFile(filePath, versionFile);
@@ -3835,6 +4248,8 @@ var _igTools = __webpack_require__(/*! @intelligentgraphics/ig.tools.core */ "..
3835
4248
 
3836
4249
  var _util2 = __webpack_require__(/*! ./util */ "./src/util.ts");
3837
4250
 
4251
+ var AssetService = _interopRequireWildcard(__webpack_require__(/*! ./assetService */ "./src/assetService.ts"));
4252
+
3838
4253
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3839
4254
 
3840
4255
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -3949,9 +4364,26 @@ const buildArchive = async ({
3949
4364
  continue;
3950
4365
  }
3951
4366
 
3952
- const content = _igTools.FileUtil.readFile(path.join(primaryScriptDir, scriptFile));
4367
+ const scriptFilePath = path.join(primaryScriptDir, scriptFile);
4368
+
4369
+ const content = _igTools.FileUtil.readFile(scriptFilePath);
4370
+
4371
+ let data;
4372
+
4373
+ try {
4374
+ data = JSON.parse(content);
4375
+ } catch (err) {
4376
+ const relativePath = path.relative(cwd, scriptFilePath);
4377
+
4378
+ if (err instanceof SyntaxError) {
4379
+ throw new Error(`Encountered invalid syntax in file "${relativePath}": ${String(err)}`);
4380
+ }
4381
+
4382
+ throw new Error(`Encountered an unexpected error while parsing animation json file at path "${relativePath}"`, {
4383
+ cause: err
4384
+ });
4385
+ }
3953
4386
 
3954
- const data = JSON.parse(content);
3955
4387
  validateSchema(data);
3956
4388
  animations.set(data.Id, JSON.stringify(data));
3957
4389
  }
@@ -4052,8 +4484,7 @@ const uploadArchive = async ({
4052
4484
  version,
4053
4485
  service,
4054
4486
  upload,
4055
- user,
4056
- password
4487
+ authentication
4057
4488
  }, zipFilePath, packageName, logStep) => {
4058
4489
  const resolvedTargetDomain = targetDomain && targetDomain !== domain ? targetDomain : domain;
4059
4490
  const resolvedTargetSubdomain = targetSubdomain && targetSubdomain !== subdomain ? targetSubdomain : subdomain;
@@ -4065,88 +4496,22 @@ const uploadArchive = async ({
4065
4496
  return;
4066
4497
  }
4067
4498
 
4068
- const startPayload = {
4499
+ if (!authentication) {
4500
+ throw new Error(`Expected authentication to be available`);
4501
+ }
4502
+
4503
+ logStep(`Opening connection to asset server`);
4504
+ const sessionId = await AssetService.startSession({
4505
+ url: service,
4069
4506
  plugin: PLUGIN_ID,
4070
4507
  address: resolvedAddress,
4071
4508
  domain: resolvedTargetDomain,
4072
4509
  subDomain: resolvedTargetSubdomain,
4073
- user,
4074
- password
4075
- };
4076
- logStep(`Opening connection to bridge server`);
4077
- const {
4078
- data: {
4079
- session: sessionId,
4080
- state
4081
- }
4082
- } = await _axios.default.post(`Session/Start2`, JSON.stringify(startPayload), {
4083
- baseURL: service
4510
+ authentication
4084
4511
  });
4085
-
4086
- if (state !== "SUCCESS") {
4087
- throw new Error(`Could not start session: Bridge server responded with ${state}`);
4088
- }
4089
-
4090
- const uploadPackage = relativePath => _axios.default.post(relativePath, fs.readFileSync(zipFilePath), {
4091
- baseURL: service
4092
- }).then(({
4093
- data,
4094
- status
4095
- }) => {
4096
- let objectBody;
4097
-
4098
- if (typeof data === "string") {
4099
- try {
4100
- objectBody = JSON.parse(data);
4101
- } catch (err) {}
4102
- } else if (typeof data === "object") {
4103
- objectBody = data;
4104
- }
4105
-
4106
- if (objectBody !== undefined) {
4107
- if ("state" in objectBody && objectBody.state !== "SUCCESS") {
4108
- var _objectBody$response;
4109
-
4110
- throw new Error((_objectBody$response = objectBody.response) !== null && _objectBody$response !== void 0 ? _objectBody$response : objectBody.state);
4111
- }
4112
- }
4113
-
4114
- if (status >= 400) {
4115
- if (objectBody !== undefined) {
4116
- let text = "";
4117
-
4118
- for (const key in objectBody) {
4119
- text += key + ": \n";
4120
-
4121
- if (typeof objectBody[key] === "object") {
4122
- text += JSON.stringify(objectBody[key], undefined, 2);
4123
- } else {
4124
- text += objectBody[key];
4125
- }
4126
-
4127
- text += "\n\n";
4128
- }
4129
-
4130
- throw new Error(text);
4131
- }
4132
-
4133
- throw new Error(data);
4134
- }
4135
-
4136
- return data;
4137
- });
4138
-
4139
4512
  logStep(`Uploading package to ${resolvedTargetDomain}.${resolvedTargetSubdomain}`);
4140
-
4141
- try {
4142
- await uploadPackage(`UploadPackage/${sessionId}/${packageName}`);
4143
- } catch (err) {
4144
- await uploadPackage(`UploadPackage/${sessionId}/${packageName}/`);
4145
- }
4146
-
4147
- await _axios.default.get(`Session/Close/${sessionId}`, {
4148
- baseURL: service
4149
- });
4513
+ await AssetService.uploadPackage(service, sessionId, packageName, zipFilePath);
4514
+ await AssetService.closeSession(service, sessionId);
4150
4515
  };
4151
4516
 
4152
4517
  /***/ }),
@@ -4834,8 +5199,10 @@ module.exports = function (O, key, value, options) {
4834
5199
  if (simple) O[key] = value;
4835
5200
  else defineGlobalProperty(key, value);
4836
5201
  } else {
4837
- if (!options.unsafe) delete O[key];
4838
- else if (O[key]) simple = true;
5202
+ try {
5203
+ if (!options.unsafe) delete O[key];
5204
+ else if (O[key]) simple = true;
5205
+ } catch (error) { /* empty */ }
4839
5206
  if (simple) O[key] = value;
4840
5207
  else definePropertyModule.f(O, key, {
4841
5208
  value: value,
@@ -4917,6 +5284,18 @@ module.exports = function (it) {
4917
5284
  module.exports = typeof window == 'object' && typeof Deno != 'object';
4918
5285
 
4919
5286
 
5287
+ /***/ }),
5288
+
5289
+ /***/ "../../node_modules/core-js/internals/engine-is-deno.js":
5290
+ /*!**************************************************************!*\
5291
+ !*** ../../node_modules/core-js/internals/engine-is-deno.js ***!
5292
+ \**************************************************************/
5293
+ /***/ ((module) => {
5294
+
5295
+ /* global Deno -- Deno case */
5296
+ module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
5297
+
5298
+
4920
5299
  /***/ }),
4921
5300
 
4922
5301
  /***/ "../../node_modules/core-js/internals/engine-is-ios-pebble.js":
@@ -5779,6 +6158,7 @@ var ResultPrototype = Result.prototype;
5779
6158
  module.exports = function (iterable, unboundFunction, options) {
5780
6159
  var that = options && options.that;
5781
6160
  var AS_ENTRIES = !!(options && options.AS_ENTRIES);
6161
+ var IS_RECORD = !!(options && options.IS_RECORD);
5782
6162
  var IS_ITERATOR = !!(options && options.IS_ITERATOR);
5783
6163
  var INTERRUPTED = !!(options && options.INTERRUPTED);
5784
6164
  var fn = bind(unboundFunction, that);
@@ -5796,7 +6176,9 @@ module.exports = function (iterable, unboundFunction, options) {
5796
6176
  } return INTERRUPTED ? fn(value, stop) : fn(value);
5797
6177
  };
5798
6178
 
5799
- if (IS_ITERATOR) {
6179
+ if (IS_RECORD) {
6180
+ iterator = iterable.iterator;
6181
+ } else if (IS_ITERATOR) {
5800
6182
  iterator = iterable;
5801
6183
  } else {
5802
6184
  iterFn = getIteratorMethod(iterable);
@@ -5811,7 +6193,7 @@ module.exports = function (iterable, unboundFunction, options) {
5811
6193
  iterator = getIterator(iterable, iterFn);
5812
6194
  }
5813
6195
 
5814
- next = iterator.next;
6196
+ next = IS_RECORD ? iterable.next : iterator.next;
5815
6197
  while (!(step = call(next, iterator)).done) {
5816
6198
  try {
5817
6199
  result = callFn(step.value);
@@ -5918,7 +6300,8 @@ var makeBuiltIn = module.exports = function (value, name, options) {
5918
6300
  if (options && options.getter) name = 'get ' + name;
5919
6301
  if (options && options.setter) name = 'set ' + name;
5920
6302
  if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
5921
- defineProperty(value, 'name', { value: name, configurable: true });
6303
+ if (DESCRIPTORS) defineProperty(value, 'name', { value: name, configurable: true });
6304
+ else value.name = name;
5922
6305
  }
5923
6306
  if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
5924
6307
  defineProperty(value, 'length', { value: options.arity });
@@ -6431,6 +6814,7 @@ var isForced = __webpack_require__(/*! ../internals/is-forced */ "../../node_mod
6431
6814
  var inspectSource = __webpack_require__(/*! ../internals/inspect-source */ "../../node_modules/core-js/internals/inspect-source.js");
6432
6815
  var wellKnownSymbol = __webpack_require__(/*! ../internals/well-known-symbol */ "../../node_modules/core-js/internals/well-known-symbol.js");
6433
6816
  var IS_BROWSER = __webpack_require__(/*! ../internals/engine-is-browser */ "../../node_modules/core-js/internals/engine-is-browser.js");
6817
+ var IS_DENO = __webpack_require__(/*! ../internals/engine-is-deno */ "../../node_modules/core-js/internals/engine-is-deno.js");
6434
6818
  var IS_PURE = __webpack_require__(/*! ../internals/is-pure */ "../../node_modules/core-js/internals/is-pure.js");
6435
6819
  var V8_VERSION = __webpack_require__(/*! ../internals/engine-v8-version */ "../../node_modules/core-js/internals/engine-v8-version.js");
6436
6820
 
@@ -6451,18 +6835,18 @@ var FORCED_PROMISE_CONSTRUCTOR = isForced('Promise', function () {
6451
6835
  // We can't use @@species feature detection in V8 since it causes
6452
6836
  // deoptimization and performance degradation
6453
6837
  // https://github.com/zloirock/core-js/issues/679
6454
- if (V8_VERSION >= 51 && /native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) return false;
6455
- // Detect correctness of subclassing with @@species support
6456
- var promise = new NativePromiseConstructor(function (resolve) { resolve(1); });
6457
- var FakePromise = function (exec) {
6458
- exec(function () { /* empty */ }, function () { /* empty */ });
6459
- };
6460
- var constructor = promise.constructor = {};
6461
- constructor[SPECIES] = FakePromise;
6462
- SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
6463
- if (!SUBCLASSING) return true;
6838
+ if (V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) {
6839
+ // Detect correctness of subclassing with @@species support
6840
+ var promise = new NativePromiseConstructor(function (resolve) { resolve(1); });
6841
+ var FakePromise = function (exec) {
6842
+ exec(function () { /* empty */ }, function () { /* empty */ });
6843
+ };
6844
+ var constructor = promise.constructor = {};
6845
+ constructor[SPECIES] = FakePromise;
6846
+ SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
6847
+ if (!SUBCLASSING) return true;
6464
6848
  // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
6465
- return !GLOBAL_CORE_JS_PROMISE && IS_BROWSER && !NATIVE_PROMISE_REJECTION_EVENT;
6849
+ } return !GLOBAL_CORE_JS_PROMISE && (IS_BROWSER || IS_DENO) && !NATIVE_PROMISE_REJECTION_EVENT;
6466
6850
  });
6467
6851
 
6468
6852
  module.exports = {
@@ -6676,10 +7060,10 @@ var store = __webpack_require__(/*! ../internals/shared-store */ "../../node_mod
6676
7060
  (module.exports = function (key, value) {
6677
7061
  return store[key] || (store[key] = value !== undefined ? value : {});
6678
7062
  })('versions', []).push({
6679
- version: '3.23.2',
7063
+ version: '3.24.0',
6680
7064
  mode: IS_PURE ? 'pure' : 'global',
6681
7065
  copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
6682
- license: 'https://github.com/zloirock/core-js/blob/v3.23.2/LICENSE',
7066
+ license: 'https://github.com/zloirock/core-js/blob/v3.24.0/LICENSE',
6683
7067
  source: 'https://github.com/zloirock/core-js'
6684
7068
  });
6685
7069
 
@@ -7961,7 +8345,7 @@ module.exports = require("util");
7961
8345
  /***/ ((module) => {
7962
8346
 
7963
8347
  "use strict";
7964
- module.exports = JSON.parse('{"name":"@intelligentgraphics/ig.gfx.packager","version":"2.1.4","description":"IG.GFX.Packager 2.1.4 (2.1.4.100)","main":"build/index.js","private":false,"publishConfig":{"access":"public"},"bin":{"packager":"./build/index.js"},"files":["build","locales","scripts"],"scripts":{"dist":"webpack","clean":"rimraf build *.tsbuildinfo","prepublishOnly":"yarn clean && yarn dist","test":"jest","_postinstall":"node scripts/postinstall.js"},"author":"Michael Beier <mb@intelligentgraphics.biz>","dependencies":{"ajv":"^8.6.2","axios":"^0.21.1","core-js":"^3.16.0","execa":"^5.1.1","fs-extra":"^10.0.0","glob":"^7.1.4","jszip":"^3.10.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","terser":"^4.8.0","typedoc":"~0.23.2","typescript":"~4.7.4","update-notifier":"^5.1.0","v8-compile-cache":"^2.1.1","y18n":"^5.0.8","yargs":"^17.0.1"},"devDependencies":{"@babel/plugin-proposal-class-properties":"^7.14.5","@babel/plugin-proposal-object-rest-spread":"^7.14.7","@babel/preset-env":"^7.14.9","@intelligentgraphics/ig.tools.core":"^1.5.1","@intelligentgraphics/ig.utilities":"^1.6.6","@types/archiver":"^5.1.1","@types/fs-extra":"^9.0.12","@types/glob":"^7.1.4","@types/node":"^16.4.11","@types/rimraf":"^3.0.1","@types/update-notifier":"^5.1.0","@types/yargs":"^17.0.2","babel-loader":"^8.1.0","jest":"^28.1.1","ts-jest":"^28.0.5","ts-loader":"^9.2.5","ts-node":"^10.1.0","webpack":"^5.64.4","webpack-cli":"^4.7.2"},"jest":{"transform":{"\\\\.tsx?$":"ts-jest"},"testRegex":"(.*\\\\.(test))\\\\.(ts|tsx)$","moduleFileExtensions":["ts","tsx","js","json"],"moduleNameMapper":{"^~/(.*)":"<rootDir>/src/$1"},"testEnvironmentOptions":{"url":"http://localhost/"}}}');
8348
+ module.exports = JSON.parse('{"name":"@intelligentgraphics/ig.gfx.packager","version":"2.3.0","description":"IG.GFX.Packager 2.3.0 (2.3.0.100)","author":"Michael Beier <mb@intelligentgraphics.biz>","main":"build/index.js","private":false,"publishConfig":{"access":"public"},"engines":{"node":">=14.0.0"},"bin":{"packager":"./build/index.js"},"files":["build","locales","scripts"],"scripts":{"dist":"webpack","clean":"rimraf build *.tsbuildinfo","prepublishOnly":"yarn clean && yarn dist","test":"jest","_postinstall":"node scripts/postinstall.js","format":"prettier --write \\"**/*.{ts,tsx,json}\\""},"dependencies":{"ajv":"^8.6.2","axios":"^0.21.1","core-js":"^3.16.0","execa":"^5.1.1","fs-extra":"^10.0.0","glob":"^7.1.4","jszip":"^3.10.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","terser":"^4.8.0","typedoc":"~0.23.2","typescript":"~4.7.4","update-notifier":"^5.1.0","v8-compile-cache":"^2.1.1","y18n":"^5.0.8","yargs":"^17.0.1"},"devDependencies":{"@babel/plugin-proposal-class-properties":"^7.18.6","@babel/plugin-proposal-object-rest-spread":"^7.18.9","@babel/preset-env":"^7.18.9","@intelligentgraphics/ig.tools.core":"^1.5.1","@intelligentgraphics/ig.utilities":"^1.6.6","@types/fs-extra":"^9.0.12","@types/glob":"^7.1.4","@types/node":"^16.4.11","@types/rimraf":"^3.0.1","@types/update-notifier":"^5.1.0","@types/yargs":"^17.0.2","babel-loader":"^8.1.0","ts-loader":"^9.2.5","ts-node":"^10.1.0","webpack":"^5.64.4","webpack-cli":"^4.7.2"}}');
7965
8349
 
7966
8350
  /***/ })
7967
8351
 
@@ -8007,9 +8391,9 @@ __webpack_require__(/*! v8-compile-cache */ "v8-compile-cache");
8007
8391
 
8008
8392
  var _updateNotifier = _interopRequireDefault(__webpack_require__(/*! update-notifier */ "update-notifier"));
8009
8393
 
8010
- var yargs = _interopRequireWildcard(__webpack_require__(/*! yargs */ "yargs"));
8394
+ var fs = _interopRequireWildcard(__webpack_require__(/*! fs */ "fs"));
8011
8395
 
8012
- var _util = __webpack_require__(/*! util */ "util");
8396
+ var yargs = _interopRequireWildcard(__webpack_require__(/*! yargs */ "yargs"));
8013
8397
 
8014
8398
  var _igTools = __webpack_require__(/*! @intelligentgraphics/ig.tools.core */ "../core/build/index.js");
8015
8399
 
@@ -8017,8 +8401,10 @@ var _localization = __webpack_require__(/*! ./localization */ "./src/localizatio
8017
8401
 
8018
8402
  var _build = __webpack_require__(/*! ./commands/build */ "./src/commands/build.ts");
8019
8403
 
8404
+ var _generate = __webpack_require__(/*! ./commands/generate */ "./src/commands/generate.ts");
8405
+
8020
8406
  const _excluded = ["directories"],
8021
- _excluded2 = ["directory", "user", "password", "service"];
8407
+ _excluded2 = ["directory", "user", "password", "service", "license"];
8022
8408
 
8023
8409
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8024
8410
 
@@ -8057,7 +8443,7 @@ const applyBuildOptions = argv => argv.options({
8057
8443
  description: (0, _localization.translate)("options.outDir.description"),
8058
8444
  type: "string",
8059
8445
  default: "bin",
8060
- coerce: input => (0, _util.isNullOrUndefined)(input) ? input : _igTools.PathUtil.ensureAbsolute(input, process.cwd())
8446
+ coerce: input => input === undefined || input === null ? undefined : _igTools.PathUtil.ensureAbsolute(input, process.cwd())
8061
8447
  },
8062
8448
  minimize: {
8063
8449
  description: (0, _localization.translate)("options.minimize.description"),
@@ -8147,6 +8533,11 @@ yargs.command({
8147
8533
  type: "boolean",
8148
8534
  default: false,
8149
8535
  description: (0, _localization.translate)("options.pushOnly.description")
8536
+ },
8537
+ license: {
8538
+ type: "string",
8539
+ description: (0, _localization.translate)("options.license.description"),
8540
+ default: process.env.IG_GFX_LICENSE
8150
8541
  }
8151
8542
  }),
8152
8543
  handler: async _ref2 => {
@@ -8154,7 +8545,8 @@ yargs.command({
8154
8545
  directory,
8155
8546
  user,
8156
8547
  password,
8157
- service
8548
+ service,
8549
+ license
8158
8550
  } = _ref2,
8159
8551
  options = _objectWithoutProperties(_ref2, _excluded2);
8160
8552
 
@@ -8162,32 +8554,79 @@ yargs.command({
8162
8554
 
8163
8555
  if (!options.noUpload) {
8164
8556
  if (!service) {
8165
- missing.push((0, _localization.translate)("options.service.demands", "IG_GFX_ASSET_SERVICE"));
8557
+ captureError(new Error((0, _localization.translate)("options.service.demands", "IG_GFX_ASSET_SERVICE")));
8558
+ return;
8166
8559
  }
8167
8560
 
8168
- if (!user) {
8169
- missing.push((0, _localization.translate)("options.user.demands", "IG_GFX_USER"));
8561
+ if (!license && (!user || !password)) {
8562
+ captureError(new Error(`Expected authentication to be provided through either of the following methods:
8563
+ - as a path to a license file using the --license option or the IG_GFX_LICENSE environment variable
8564
+ - as a username and password using the --user and --password options, or the IG_GFX_USER and IG_GFX_PWD environment variables`));
8565
+ return;
8170
8566
  }
8171
8567
 
8172
- if (!password) {
8173
- missing.push((0, _localization.translate)("options.password.demands", "IG_GFX_PWD"));
8568
+ if (license && !license.endsWith(".iglic")) {
8569
+ captureError(new Error(`Expected the license path to end with the extension .iglic. Received the path "${license}". You may need to reload your environment variables by restarting the program you're using to execute the packager.`));
8570
+ return;
8174
8571
  }
8572
+ }
8573
+
8574
+ let authentication;
8175
8575
 
8176
- if (missing.length > 0) {
8177
- const message = (0, _localization.translate)("messages.missingUploadArgs") + "\n\n" + missing.join("\n");
8178
- return captureError(new Error(message));
8576
+ if (license) {
8577
+ const fullLicensePath = _igTools.PathUtil.ensureAbsolute(license, process.cwd());
8578
+
8579
+ try {
8580
+ const content = fs.readFileSync(fullLicensePath);
8581
+ authentication = {
8582
+ type: "license",
8583
+ license: content.toString("base64")
8584
+ };
8585
+ } catch (err) {
8586
+ if ((err === null || err === void 0 ? void 0 : err.code) === "ENOENT") {
8587
+ captureError(new Error(`Expected to find a license file at path: ${fullLicensePath}`));
8588
+ return;
8589
+ }
8590
+
8591
+ captureError(new Error(`Failed to read license file at path: ${fullLicensePath}`));
8592
+ return;
8179
8593
  }
8594
+ } else if (user && password) {
8595
+ console.log(`Detected usage of username and password authentication. Please migrate to the new license file based authentication.`);
8596
+ authentication = {
8597
+ type: "credentials",
8598
+ username: user,
8599
+ password
8600
+ };
8180
8601
  }
8181
8602
 
8182
8603
  const {
8183
8604
  releaseFolders
8184
8605
  } = await Promise.resolve().then(() => _interopRequireWildcard(__webpack_require__(/*! ./commands/release */ "./src/commands/release.ts")));
8185
- releaseFolders(_objectSpread(_objectSpread({}, options), {}, {
8186
- user: user,
8187
- password: password,
8606
+
8607
+ const fullOptions = _objectSpread(_objectSpread({}, options), {}, {
8608
+ authentication,
8188
8609
  service: service,
8189
8610
  directories: [directory]
8190
- })).catch(captureError);
8611
+ });
8612
+
8613
+ releaseFolders(fullOptions).catch(captureError);
8614
+ }
8615
+ });
8616
+ yargs.command({
8617
+ command: "generateIndex [directory]",
8618
+ builder: argv => {
8619
+ return argv.option("ignore", {
8620
+ type: "array",
8621
+ default: [],
8622
+ description: (0, _localization.translate)("options.ignore.description")
8623
+ });
8624
+ },
8625
+ handler: ({
8626
+ directory,
8627
+ ignore
8628
+ }) => {
8629
+ (0, _generate.extract)(directory, ignore);
8191
8630
  }
8192
8631
  });
8193
8632
  yargs.demandCommand().pkgConf("packager").showHelpOnFail(false).version().argv;