@sap-ux/telemetry 0.4.24 → 0.4.26

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.
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.spawnCommand = exports.getCommonProperties = exports.processToolsSuiteTelemetry = void 0;
16
16
  const btp_utils_1 = require("@sap-ux/btp-utils");
17
+ const ui5_config_1 = require("@sap-ux/ui5-config");
17
18
  const axios_1 = __importDefault(require("axios"));
18
19
  const fs_1 = __importDefault(require("fs"));
19
20
  const path_1 = __importDefault(require("path"));
@@ -120,7 +121,7 @@ function getAppProperties(appPath) {
120
121
  if (applicationType === 'Fiori Reuse') {
121
122
  odataSource = types_1.ODataSource.UNKNOWN;
122
123
  }
123
- const sourceTemplate = yield getManifestSourceTemplate(appPath);
124
+ const sourceTemplate = yield getSourceTemplate(appPath);
124
125
  const appProgrammingLanguage = yield (0, info_1.getAppProgrammingLanguage)(appPath);
125
126
  const output = {};
126
127
  output[types_1.CommonProperties.TemplateType] = templateType;
@@ -277,33 +278,53 @@ function getInternalVsExternal() {
277
278
  return config_state_1.ToolingTelemetrySettings.internalFeature ? 'internal' : 'external';
278
279
  }
279
280
  /**
280
- * Read the manifest.json for the app and locate the tools id.
281
+ * Retrieves the source template configuration from either the standard manifest.json or
282
+ * the ui5.yaml based on the project type.
281
283
  *
282
- * @param appPath appPath Root folder path of Fiori app
283
- * @returns sourceTemplate section of data from manifest.json
284
+ * @param {string} appPath - The file system path to the application directory.
285
+ * @returns {Promise<SourceTemplate>} A promise that resolves to the source template configuration object.
284
286
  */
285
- function getManifestSourceTemplate(appPath) {
286
- var _a, _b, _c, _d;
287
+ function getSourceTemplate(appPath) {
288
+ var _a, _b, _c;
287
289
  return __awaiter(this, void 0, void 0, function* () {
288
- let sourceTemplate = {};
290
+ const paths = {
291
+ manifest: path_1.default.join(appPath, 'webapp', 'manifest.json'),
292
+ appdescr: path_1.default.join(appPath, 'webapp', 'manifest.appdescr_variant'),
293
+ ui5Yaml: path_1.default.join(appPath, 'ui5.yaml')
294
+ };
289
295
  try {
290
- const manifestPath = path_1.default.join(appPath, 'webapp', 'manifest.json');
291
- if (fs_1.default.existsSync(manifestPath)) {
292
- const manifestStr = yield fs_1.default.promises.readFile(manifestPath, 'utf-8');
296
+ if (fs_1.default.existsSync(paths.manifest)) {
297
+ const manifestStr = yield fs_1.default.promises.readFile(paths.manifest, 'utf-8');
293
298
  const manifest = JSON.parse(manifestStr);
294
- sourceTemplate = (_a = manifest['sap.app']) === null || _a === void 0 ? void 0 : _a.sourceTemplate;
299
+ return populateSourceTemplate((_b = (_a = manifest['sap.app']) === null || _a === void 0 ? void 0 : _a.sourceTemplate) !== null && _b !== void 0 ? _b : {});
300
+ }
301
+ if (fs_1.default.existsSync(paths.appdescr) && fs_1.default.existsSync(paths.ui5Yaml)) {
302
+ const baseUi5ConfigContent = yield fs_1.default.promises.readFile(paths.ui5Yaml, 'utf-8');
303
+ const ui5Config = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
304
+ const adp = ui5Config.getCustomConfiguration('adp');
305
+ return populateSourceTemplate((_c = adp === null || adp === void 0 ? void 0 : adp.support) !== null && _c !== void 0 ? _c : {});
295
306
  }
296
307
  }
297
- catch (_e) {
298
- // Failed to read manifest.json
308
+ catch (_d) {
309
+ // Failed to read manifest.json or manifest.appdescr_variant
299
310
  }
300
- sourceTemplate = sourceTemplate !== null && sourceTemplate !== void 0 ? sourceTemplate : {};
301
- sourceTemplate.id = (_b = sourceTemplate.id) !== null && _b !== void 0 ? _b : '';
302
- sourceTemplate.version = (_c = sourceTemplate.version) !== null && _c !== void 0 ? _c : '';
303
- sourceTemplate.toolsId = (_d = sourceTemplate.toolsId) !== null && _d !== void 0 ? _d : types_1.ToolsId.NO_TOOLS_ID;
304
- return sourceTemplate;
311
+ return populateSourceTemplate({});
305
312
  });
306
313
  }
314
+ /**
315
+ * Populates default values for the source template if not specified.
316
+ *
317
+ * @param {SourceTemplate} sourceTemplate - Source template object potentially lacking defaults.
318
+ * @returns {SourceTemplate} Source template with defaults populated.
319
+ */
320
+ function populateSourceTemplate(sourceTemplate) {
321
+ var _a, _b, _c;
322
+ return {
323
+ id: (_a = sourceTemplate.id) !== null && _a !== void 0 ? _a : '',
324
+ version: (_b = sourceTemplate.version) !== null && _b !== void 0 ? _b : '',
325
+ toolsId: (_c = sourceTemplate.toolsId) !== null && _c !== void 0 ? _c : types_1.ToolsId.NO_TOOLS_ID
326
+ };
327
+ }
307
328
  /**
308
329
  * Get node.js runtime version.
309
330
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/telemetry",
3
- "version": "0.4.24",
3
+ "version": "0.4.26",
4
4
  "description": "Library for sending usage telemetry data",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "performance-now": "2.1.0",
20
20
  "yaml": "2.3.3",
21
21
  "@sap-ux/store": "0.5.0",
22
- "@sap-ux/project-access": "1.20.1",
22
+ "@sap-ux/project-access": "1.20.2",
23
23
  "@sap-ux/btp-utils": "0.14.4",
24
24
  "@sap-ux/ui5-config": "0.22.5",
25
25
  "@sap-ux/logger": "0.5.1"