npm package diff
Package: @forge/cli
Versions: 11.3.0-next.4-experimental-e92a337 - 11.3.0-next.5
File: package/out/command-line/view/version-view.js
Index: package/out/command-line/view/version-view.js
===================================================================
--- package/out/command-line/view/version-view.js
+++ package/out/command-line/view/version-view.js
@@ -1,10 +1,121 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.VersionView = void 0;
+exports.VersionView = exports.getDetailsTable = void 0;
const tslib_1 = require("tslib");
const cli_shared_1 = require("@forge/cli-shared");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
+const getDetailsTable = ({ formatKeyValueList, formatYamlProperties }, details) => {
+ const deploymentDate = (date) => `${date.toISOString()}`;
+ const scopes = (scopes) => `${(0, cli_shared_1.itemList)(scopes, '')}`;
+ const egress = (egresses) => {
+ const egressItems = egresses.map((egress) => ({
+ key: egress.type,
+ value: (0, cli_shared_1.itemList)(egress.addresses, ' ')
+ }));
+ return formatKeyValueList(egressItems, '', true);
+ };
+ const securityPolicies = (policies) => {
+ const policyItems = policies.map((policy) => ({
+ key: policy.type,
+ value: policy.policies.join(', ')
+ }));
+ return formatKeyValueList(policyItems);
+ };
+ const connectKeys = (keys) => {
+ const keyItems = keys.map((key) => ({
+ key: key.product,
+ value: key.key
+ }));
+ return formatKeyValueList(keyItems, '');
+ };
+ const functions = (functions) => {
+ const functionItems = functions.map((func) => {
+ const properties = {
+ runtime: func.runtimeName,
+ handler: func.handler
+ };
+ return formatYamlProperties(properties, func.key);
+ });
+ return (0, cli_shared_1.itemList)(functionItems, '');
+ };
+ const modules = (modules) => {
+ return modules
+ .map((mod) => {
+ const items = mod.items.map((item) => formatYamlProperties(item.properties, item.key));
+ return `${chalk_1.default.bold(mod.type)}\n${(0, cli_shared_1.itemList)(items, '')}`;
+ })
+ .join('\n');
+ };
+ const remotes = (remotes) => {
+ const remoteItems = remotes.map((remote) => {
+ const properties = {
+ baseUrl: remote.baseUrl,
+ operations: remote.operations
+ };
+ return formatYamlProperties(properties, remote.key);
+ });
+ return (0, cli_shared_1.itemList)(remoteItems, '');
+ };
+ const tableData = [
+ {
+ entry: 'deployment date',
+ detailsFn: deploymentDate,
+ property: 'deploymentDateTime'
+ },
+ {
+ entry: 'functions',
+ detailsFn: functions,
+ property: 'functions'
+ },
+ {
+ entry: 'modules',
+ detailsFn: modules,
+ property: 'modules'
+ },
+ {
+ entry: 'license',
+ detailsFn: cli_shared_1.Text.version.check.details.license,
+ property: 'requiresLicense'
+ },
+ {
+ entry: 'scopes',
+ detailsFn: scopes,
+ property: 'scopes'
+ },
+ {
+ entry: 'egress',
+ detailsFn: egress,
+ property: 'egresses'
+ },
+ {
+ entry: 'policies',
+ detailsFn: securityPolicies,
+ property: 'policies'
+ },
+ {
+ entry: 'connect keys',
+ detailsFn: connectKeys,
+ property: 'connectKeys'
+ },
+ {
+ entry: 'remotes',
+ detailsFn: remotes,
+ property: 'remotes'
+ }
+ ];
+ return tableData
+ .filter(({ property }) => details[property] !== undefined)
+ .map(({ entry, detailsFn, property }) => ({
+ entry,
+ details: detailsFn(details[property]),
+ property
+ }));
+};
+exports.getDetailsTable = getDetailsTable;
+const getPropertySummary = (property) => {
+ return property.map((item) => `${item.type}: ${item.count}`).join('\n');
+};
class VersionView {
ui;
constructor(ui) {
this.ui = ui;
@@ -66,67 +177,13 @@
this.ui.info(cli_shared_1.Text.version.check.details.banner(envKey, envType, appVersion));
this.ui.emptyLine();
}
displayDetailsAsTable(details) {
- const tableData = [
- {
- entry: 'deployment date',
- detailsFn: cli_shared_1.Text.version.check.details.deploymentDate,
- property: 'deploymentDateTime'
- },
- {
- entry: 'functions',
- detailsFn: cli_shared_1.Text.version.check.details.functions,
- property: 'functions'
- },
- {
- entry: 'modules',
- detailsFn: cli_shared_1.Text.version.check.details.modules,
- property: 'modules'
- },
- {
- entry: 'license',
- detailsFn: cli_shared_1.Text.version.check.details.license,
- property: 'requiresLicense'
- },
- {
- entry: 'scopes',
- detailsFn: cli_shared_1.Text.version.check.details.scopes,
- property: 'scopes'
- },
- {
- entry: 'egress',
- detailsFn: cli_shared_1.Text.version.check.details.egress,
- property: 'egresses'
- },
- {
- entry: 'policies',
- detailsFn: cli_shared_1.Text.version.check.details.securityPolicies,
- property: 'policies'
- },
- {
- entry: 'connect keys',
- detailsFn: cli_shared_1.Text.version.check.details.connectKeys,
- property: 'connectKeys'
- },
- {
- entry: 'remotes',
- detailsFn: cli_shared_1.Text.version.check.details.remotes,
- property: 'remotes'
- }
- ];
- const filteredData = [...tableData]
- .sort((a, b) => a.entry.localeCompare(b.entry))
- .filter(({ property }) => details[property] !== undefined)
- .map(({ entry, detailsFn, property }) => ({
- entry,
- details: detailsFn(details[property]),
- property
- }));
+ const tableData = [...(0, exports.getDetailsTable)(this.ui, details)].sort((a, b) => a.entry.localeCompare(b.entry));
this.ui.table([
['entry', 'Property'],
['details', 'Details']
- ], filteredData);
+ ], tableData);
}
displayDataInJson(data) {
this.ui.info(JSON.stringify(data, null, 2));
}
@@ -187,12 +244,12 @@
['requiresLicense', 'License']
], data.map(({ version, egresses, modules, policies, deploymentDateTime, ...rest }) => ({
...rest,
version: version.toString(),
- deploymentDate: cli_shared_1.Text.version.list.details.deploymentDate(deploymentDateTime),
- egresses: cli_shared_1.Text.version.list.details.egresses(egresses),
- policies: cli_shared_1.Text.version.list.details.policies(policies),
- modules: cli_shared_1.Text.version.list.details.modules(modules)
+ deploymentDate: deploymentDateTime.toISOString(),
+ egresses: getPropertySummary(egresses),
+ policies: getPropertySummary(policies),
+ modules: getPropertySummary(modules)
})));
}
}
exports.VersionView = VersionView;