npm package diff

Package: @forge/cli-shared

Versions: 6.5.2-next.1 - 6.5.2-next.1-experimental-19bd64d

File: package/out/ui/text.js

Index: package/out/ui/text.js
===================================================================
--- package/out/ui/text.js
+++ package/out/ui/text.js
@@ -2,8 +2,9 @@
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.Text = exports.capitalise = void 0;
 const tslib_1 = require("tslib");
 const chalk_1 = tslib_1.__importDefault(require("chalk"));
+const yaml_1 = tslib_1.__importDefault(require("yaml"));
 const terminal_link_1 = tslib_1.__importDefault(require("terminal-link"));
 const case_1 = require("case");
 const log_symbols_1 = tslib_1.__importDefault(require("./log-symbols"));
 const log_color_1 = require("./log-color");
@@ -20,10 +21,10 @@
 const forge = (...args) => command('forge', ...args);
 const autoSpaceSentences = (...sentences) => sentences
     .filter((sentence) => sentence.length > 0)
     .join(' ');
-function itemList(items) {
-    return items.map((item) => ` - ${item}`).join('\n');
+function itemList(items, indent) {
+    return items.map((item) => `${indent ?? ' '}- ${item}`).join(`\n${indent ?? ''}`);
 }
 const fatalError = (message) => chalk_1.default.bold(chalk_1.default.red(message));
 const keytarAccessErrorBase = (message) => `Keytar error detected: ${message}`;
 const capitalise = (word) => word.charAt(0).toUpperCase() + word.slice(1);
@@ -472,8 +473,147 @@
                 }
             }
         }
     },
+    version: {
+        cmd: {
+            cmdName: 'version',
+            desc: 'app version information'
+        },
+        diff: {
+            cmdName: 'compare',
+            error: {
+                noVersionProvided: 'Please provide 2 versions to compare'
+            },
+            option: {
+                version1: '1st version to compare',
+                version2: '2nd version to compare',
+                outFile: 'specify a file to output the results'
+            },
+            desc: `returns the details of two versions of the app for comparison. Details include:\n${itemList([
+                'deployment date',
+                'egress',
+                'policies',
+                'scopes',
+                'connect keys',
+                'functions',
+                'remotes',
+                'modules',
+                'license'
+            ])}`,
+            start: 'Comparing app versions...',
+            end: 'Comparing app versions...',
+            details: {
+                banner: (envKey, envType, version1, version2) => `${log_symbols_1.default.info} Comparison between app versions [${chalk_1.default.bold(version1)} and ${chalk_1.default.bold(version2)}] in [${exports.Text.env.displayEnvironment(envKey, envType)}] is shown below:`
+            }
+        },
+        check: {
+            cmdName: 'details',
+            option: {
+                majorVersion: 'specify a major version',
+                json: 'output results in JSON format',
+                outFile: 'specify a file to output the results'
+            },
+            error: {
+                invalidMajorVersion: (property) => `Invalid major version number${property ? ` for ${property}` : ''}`
+            },
+            desc: `returns the details of a specific version of the app. Details include:\n${itemList([
+                'egress',
+                'policies',
+                'scopes',
+                'connect keys',
+                'functions',
+                'remotes',
+                'modules',
+                'license'
+            ])}`,
+            start: 'Getting app version details...',
+            end: 'Getting app version details...',
+            details: {
+                banner: (envKey, envType, version) => `${log_symbols_1.default.info} App [${version}] in [${exports.Text.env.displayEnvironment(envKey, envType)}] includes the following:`,
+                prompt: {
+                    options: {
+                        banner: 'Select option:',
+                        choices: {
+                            all: 'Show all properties',
+                            manual: 'Manual selection'
+                        }
+                    },
+                    properties: {
+                        banner: 'Select properties that you are interested in:',
+                        info: 'Note: Changes to the properties below may trigger major version updates in Atlassian systems.\n',
+                        headers: ['Property', 'Description'],
+                        descriptions: {
+                            scopes: 'Product scopes that the app has access to',
+                            egress: 'Network permissions',
+                            policies: 'Content security policies (Custom UI)',
+                            functions: 'Function modules used by the app',
+                            modules: 'Modules used by the app (other than functions & remotes)',
+                            remotes: 'Remote modules used by the app (Remote backend, Connect or External Auth)',
+                            connectKeys: 'Connect on Forge',
+                            license: 'Does the app require a license?'
+                        }
+                    }
+                },
+                writeToFile: (file) => `Writing to file: ${file}`,
+                deploymentDate: (date) => `${date.toISOString()}`,
+                scopes: (scopes) => `${itemList(scopes, '')}`,
+                egress: (egresses) => `${itemList(egresses.map((egress) => `[${chalk_1.default.cyan(egress.type)}]: \n ${itemList(egress.addresses, ' ')}`), '')}`,
+                securityPolicies: (policies) => `${itemList(policies.map((policy) => `[${chalk_1.default.cyan(policy.type)}]: ${policy.policies.join(', ')}`))}`,
+                license: (requiresLicense) => `${requiresLicense ? 'Yes' : 'No'}`,
+                connectKeys: (keys) => `${itemList(keys.map((key) => `[${chalk_1.default.cyan(key.product)}]: ${key.key}`), '')}`,
+                storage: (storages) => `${itemList(storages.map((storage) => `[${chalk_1.default.cyan(storage.type)}]: ${storage.store.map((store) => `${store.baseUrl} (${store.locations.join(', ')})`).join(', ')}`))}`,
+                functions: (functions) => `${itemList(functions.map((func) => `[${chalk_1.default.cyan(func.key)}]: is configured with the following properties: \n  ${yaml_1.default.stringify({
+                    runtime: `${func.runtimeName}`,
+                    handler: `${func.handler}`,
+                    dataResidency: `available in ${func.regions.length} regions`
+                }, undefined, '   ').replaceAll('\n', '\n  ')}`), '')}`,
+                modules: (modules) => {
+                    return `${modules
+                        .map((mod) => `${chalk_1.default.bold(mod.type)}\n${itemList(mod.items.map((item) => `[${chalk_1.default.cyan(item.key)}]: is configured with the following properties:\n  ${yaml_1.default.stringify(item.properties, undefined, '   ').replaceAll('\n', '\n  ')}`), '')}`)
+                        .join('\n')}`;
+                },
+                remotes: (remotes) => `${itemList(remotes.map((remote) => `[${chalk_1.default.cyan(remote.key)}]: is configured with the following properties: \n  ${yaml_1.default.stringify({
+                    baseUrl: remote.baseUrl,
+                    operations: remote.operations
+                }, undefined, '   ').replaceAll('\n', '\n  ')}`), '')}`
+            }
+        },
+        list: {
+            cmdName: 'list',
+            option: {
+                json: 'output results in JSON format',
+                outFile: 'specify a file to output the results'
+            },
+            desc: `returns a summary of all major versions of the app. Summary includes:\n${itemList([
+                'version number',
+                'deployment date',
+                'egress',
+                'policies',
+                'scopes',
+                'connect keys',
+                'functions',
+                'remotes',
+                'modules',
+                'license'
+            ])}`,
+            start: 'Getting app version list...',
+            end: 'Getting app version list...',
+            details: {
+                banner: (envKey, envType, versions) => `${log_symbols_1.default.info} Details of a total of [${versions} major versions] in [${exports.Text.env.displayEnvironment(envKey, envType)}] can be seen below:`,
+                deploymentDate: (date) => exports.Text.version.check.details.deploymentDate(date),
+                egresses: (egresses) => {
+                    return egresses.map((egress) => `${egress.type}: ${egress.count}`).join('\n');
+                },
+                policies: (policies) => {
+                    return policies.map((policy) => `${policy.type}: ${policy.count}`).join('\n');
+                },
+                modules: (modules) => {
+                    return modules.map((module) => `${module.type}: ${module.count}`).join('\n');
+                }
+            }
+        }
+    },
     deploy: {
         cmd: {
             desc: 'deploy your app to an environment',
             start1: (envKey, envType) => `Deploying your app to the ${exports.Text.env.displayEnvironment(envKey, envType)} environment.\n${ctrlC}\n`,