apn-app-manager 2.1.1 → 2.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apn-app-manager",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
@@ -192,6 +192,7 @@ function executeClone() {
192
192
  // Prompts the user to tell us how to handle problem words
193
193
  addressProblemWords(function () {
194
194
  // These output files are helpful for debugging, and are used in tests
195
+ util.writeJson(path.resolve(cons.debugDir, `client-info.json`), util.clientInfo());
195
196
  util.writeJson(path.resolve(cons.debugDir, `objects.json`), objectMaps);
196
197
  util.writeJson(path.resolve(cons.debugDir, `not-cloned-uuids.json`), uuidCollector);
197
198
  util.writeJson(path.resolve(cons.debugDir, `namespaces.json`), context.namespaceMap);
package/src/index.js CHANGED
@@ -101,7 +101,7 @@ const options = {
101
101
  };
102
102
 
103
103
  // Check for a new version and displays it - skip if there are test overrides
104
- if (!testOverrides) {
104
+ if (!util.isTestMode()) {
105
105
  displayNewVersion();
106
106
  }
107
107
 
package/src/util.js CHANGED
@@ -14,7 +14,8 @@ const colorlog = require("node-color-log");
14
14
  const xmldom = require("@xmldom/xmldom").DOMParser;
15
15
  const xmlserializer = require("@xmldom/xmldom").XMLSerializer;
16
16
  const cons = require("./cons");
17
- const { matches } = require("lodash");
17
+ const os = require("os");
18
+ const pkg = require("../package.json");
18
19
 
19
20
  // Exports
20
21
  module.exports = {
@@ -375,6 +376,35 @@ module.exports = {
375
376
  const tLower = text.toLowerCase();
376
377
  return qWords.every(w => tLower.includes(w));
377
378
  },
379
+
380
+ // Returns a map of all client info (version, os, etc)
381
+ clientInfo: function () {
382
+ let testModeCheck = function (value) {
383
+ // If not test mode, return value as-is
384
+ if (!module.exports.isTestMode()) {
385
+ return value;
386
+ }
387
+ // If test mode and null, return "error"
388
+ if (isBlank(value)) {
389
+ return "ERROR - No value found";
390
+ }
391
+ // Otherwise return "" to ensure tests just check structure regardless of architecture running tests
392
+ return "";
393
+ };
394
+ return {
395
+ apn: testModeCheck(pkg.version),
396
+ npm: testModeCheck(outputCmd("npm --version")),
397
+ node: testModeCheck(process.versions.node),
398
+ os: {
399
+ platform: testModeCheck(os.platform()),
400
+ release: testModeCheck(os.release()),
401
+ arch: testModeCheck(os.arch()),
402
+ },
403
+ };
404
+ },
405
+
406
+ // Returns true if in test mode
407
+ isTestMode: isTestMode,
378
408
  };
379
409
 
380
410
  // ---------------------------------------------------
@@ -563,6 +593,11 @@ function outputCmd(cmd, cwd, args) {
563
593
  }
564
594
  }
565
595
 
596
+ // Returns true if in test mode (cli tests send env vars, menu tests override this method)
597
+ function isTestMode() {
598
+ return !!process.env.TEST_OVERRIDES;
599
+ }
600
+
566
601
  // Utility function to differenciate between debug logging and real logging
567
602
  function debug(input) {
568
603
  console.log(input);