apn-app-manager 2.1.1 → 2.2.1
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 +1 -1
- package/src/actions/cloneAction.js +3 -2
- package/src/handlers/fileSelectHandler.js +1 -1
- package/src/index.js +1 -1
- package/src/util.js +42 -2
package/package.json
CHANGED
|
@@ -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);
|
|
@@ -365,11 +366,11 @@ function formatSelectedFilesLog() {
|
|
|
365
366
|
for (const key of Object.keys(context)) {
|
|
366
367
|
if (key.includes("Path") && !util.isBlank(context[key])) {
|
|
367
368
|
if (!Array.isArray(context[key])) {
|
|
368
|
-
selectedFilesMap[key] = path.relative(cons.curDir, context[key]);
|
|
369
|
+
selectedFilesMap[key] = util.normalizeFilePath(path.relative(cons.curDir, context[key]));
|
|
369
370
|
} else {
|
|
370
371
|
let filePaths = [];
|
|
371
372
|
context[key].forEach(filePath => {
|
|
372
|
-
filePaths.push(path.relative(cons.curDir, filePath));
|
|
373
|
+
filePaths.push(util.normalizeFilePath(path.relative(cons.curDir, filePath)));
|
|
373
374
|
});
|
|
374
375
|
selectedFilesMap[key] = lodash.sortBy(filePaths);
|
|
375
376
|
}
|
|
@@ -24,7 +24,7 @@ function selectFile(promptText, fileTypes, optional, multiple, ignoreFiles, leve
|
|
|
24
24
|
let files = [];
|
|
25
25
|
util.handleDirFiles(cons.curDir, fileTypes, levelsToParse, 1, function (filePath) {
|
|
26
26
|
if (!lodash.includes(ignoreFiles, filePath)) {
|
|
27
|
-
files.push(path.relative(cons.curDir, filePath));
|
|
27
|
+
files.push(util.normalizeFilePath(path.relative(cons.curDir, filePath)));
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
if (multiple) {
|
package/src/index.js
CHANGED
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
|
|
17
|
+
const os = require("os");
|
|
18
|
+
const pkg = require("../package.json");
|
|
18
19
|
|
|
19
20
|
// Exports
|
|
20
21
|
module.exports = {
|
|
@@ -375,6 +376,40 @@ 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,
|
|
408
|
+
|
|
409
|
+
// Normalizes a file path to always use forward slashes
|
|
410
|
+
normalizeFilePath: function (filePath) {
|
|
411
|
+
return filePath.replace(/\\/g, "/");
|
|
412
|
+
},
|
|
378
413
|
};
|
|
379
414
|
|
|
380
415
|
// ---------------------------------------------------
|
|
@@ -417,7 +452,7 @@ function str(strings, ...keys) {
|
|
|
417
452
|
|
|
418
453
|
// Loops through a directory with a callback function
|
|
419
454
|
function handleDir(dirName, filesOnly, fileTypes, levelsToParse, startAtLevel, parseLevel, callback) {
|
|
420
|
-
const contents = fs.readdirSync(dirName, "utf8", true);
|
|
455
|
+
const contents = fs.readdirSync(dirName, "utf8", true).sort();
|
|
421
456
|
contents.forEach(content => {
|
|
422
457
|
const contentPath = path.resolve(dirName, content);
|
|
423
458
|
const isFile = fs.statSync(contentPath).isFile();
|
|
@@ -563,6 +598,11 @@ function outputCmd(cmd, cwd, args) {
|
|
|
563
598
|
}
|
|
564
599
|
}
|
|
565
600
|
|
|
601
|
+
// Returns true if in test mode (cli tests send env vars, menu tests override this method)
|
|
602
|
+
function isTestMode() {
|
|
603
|
+
return !!process.env.TEST_OVERRIDES;
|
|
604
|
+
}
|
|
605
|
+
|
|
566
606
|
// Utility function to differenciate between debug logging and real logging
|
|
567
607
|
function debug(input) {
|
|
568
608
|
console.log(input);
|