@forge/cli 10.13.3-next.10 → 10.13.4-next.1-experimental-19bd64d
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/CHANGELOG.md +66 -0
- package/npm-shrinkwrap.json +73 -57
- package/out/autocomplete/autocomplete-config.json +8 -0
- package/out/command-line/controller/version-controller.d.ts +36 -0
- package/out/command-line/controller/version-controller.d.ts.map +1 -0
- package/out/command-line/controller/version-controller.js +121 -0
- package/out/command-line/dependency-injection.d.ts +2 -0
- package/out/command-line/dependency-injection.d.ts.map +1 -1
- package/out/command-line/dependency-injection.js +7 -1
- package/out/command-line/index.d.ts.map +1 -1
- package/out/command-line/index.js +2 -0
- package/out/command-line/register-version-commands.d.ts +4 -0
- package/out/command-line/register-version-commands.d.ts.map +1 -0
- package/out/command-line/register-version-commands.js +72 -0
- package/out/command-line/view/version-view.d.ts +26 -0
- package/out/command-line/view/version-view.d.ts.map +1 -0
- package/out/command-line/view/version-view.js +193 -0
- package/out/service/version-service.d.ts +74 -0
- package/out/service/version-service.d.ts.map +1 -0
- package/out/service/version-service.js +134 -0
- package/out/version/graphql-client.d.ts +27 -0
- package/out/version/graphql-client.d.ts.map +1 -0
- package/out/version/graphql-client.js +150 -0
- package/package.json +12 -9
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerCommands = exports.parseMajorVersion = void 0;
|
|
4
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
5
|
+
function parseMajorVersion(majorVersionStr, property) {
|
|
6
|
+
if (!/^\d+$/.test(majorVersionStr)) {
|
|
7
|
+
throw new cli_shared_1.ValidationError(cli_shared_1.Text.version.check.error.invalidMajorVersion(property));
|
|
8
|
+
}
|
|
9
|
+
return parseInt(majorVersionStr, 10);
|
|
10
|
+
}
|
|
11
|
+
exports.parseMajorVersion = parseMajorVersion;
|
|
12
|
+
const registerDetailsCommands = (parent, { controllers: { versionController } }) => {
|
|
13
|
+
parent
|
|
14
|
+
.command(cli_shared_1.Text.version.check.cmdName)
|
|
15
|
+
.description(cli_shared_1.Text.version.check.desc)
|
|
16
|
+
.requireAppId()
|
|
17
|
+
.environmentOption()
|
|
18
|
+
.nonInteractiveOption()
|
|
19
|
+
.option('-v, --major-version [version]', cli_shared_1.Text.version.check.option.majorVersion)
|
|
20
|
+
.option('--json', cli_shared_1.Text.version.check.option.json)
|
|
21
|
+
.option('-f, --out-file [outFile]', cli_shared_1.Text.version.check.option.outFile)
|
|
22
|
+
.action(async ({ environment, majorVersion, json, outFile, nonInteractive }) => {
|
|
23
|
+
const majorVersionInt = majorVersion ? parseMajorVersion(majorVersion) : undefined;
|
|
24
|
+
await versionController.getAppVersionDetails({
|
|
25
|
+
environment,
|
|
26
|
+
majorVersion: majorVersionInt,
|
|
27
|
+
json,
|
|
28
|
+
outFile,
|
|
29
|
+
nonInteractive
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const registerListCommands = (parent, { controllers: { versionController } }) => {
|
|
34
|
+
parent
|
|
35
|
+
.command(cli_shared_1.Text.version.list.cmdName)
|
|
36
|
+
.description(cli_shared_1.Text.version.list.desc)
|
|
37
|
+
.requireAppId()
|
|
38
|
+
.environmentOption()
|
|
39
|
+
.nonInteractiveOption()
|
|
40
|
+
.option('--json', cli_shared_1.Text.version.list.option.json)
|
|
41
|
+
.option('-f, --out-file [outFile]', cli_shared_1.Text.version.list.option.outFile)
|
|
42
|
+
.action(async ({ environment, json, outFile, nonInteractive }) => {
|
|
43
|
+
await versionController.getVersionList({ environment, json, outFile, nonInteractive });
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const registerDiffCommands = (parent, { controllers: { versionController } }) => {
|
|
47
|
+
parent
|
|
48
|
+
.command(cli_shared_1.Text.version.diff.cmdName)
|
|
49
|
+
.description(cli_shared_1.Text.version.diff.desc)
|
|
50
|
+
.requireAppId()
|
|
51
|
+
.environmentOption()
|
|
52
|
+
.nonInteractiveOption()
|
|
53
|
+
.option('-v1, --version1 [version]', cli_shared_1.Text.version.diff.option.version1)
|
|
54
|
+
.option('-v2, --version2 [version]', cli_shared_1.Text.version.diff.option.version2)
|
|
55
|
+
.option('-f, --out-file [outFile]', cli_shared_1.Text.version.diff.option.outFile)
|
|
56
|
+
.action(async ({ environment, version1, version2, outFile }) => {
|
|
57
|
+
if (!version1 || !version2) {
|
|
58
|
+
throw new cli_shared_1.ValidationError(cli_shared_1.Text.version.diff.error.noVersionProvided);
|
|
59
|
+
}
|
|
60
|
+
const version1Int = parseMajorVersion(version1, '--version1');
|
|
61
|
+
const version2Int = parseMajorVersion(version2, '--version2');
|
|
62
|
+
await versionController.getAppVersionDiff({ environment, version1: version1Int, version2: version2Int, outFile });
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const registerCommands = (deps) => {
|
|
66
|
+
const { cmd } = deps;
|
|
67
|
+
const version = cmd.command(cli_shared_1.Text.version.cmd.cmdName).description(cli_shared_1.Text.version.cmd.desc);
|
|
68
|
+
registerDetailsCommands(version, deps);
|
|
69
|
+
registerDiffCommands(version, deps);
|
|
70
|
+
registerListCommands(version, deps);
|
|
71
|
+
};
|
|
72
|
+
exports.registerCommands = registerCommands;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AppEnvironmentType, UI } from '@forge/cli-shared';
|
|
2
|
+
import { VersionDetails, VersionOverview } from '../../service/version-service';
|
|
3
|
+
import { Change } from 'diff';
|
|
4
|
+
export declare class VersionView {
|
|
5
|
+
private readonly ui;
|
|
6
|
+
constructor(ui: UI);
|
|
7
|
+
displayDetailsProgress(progress: () => Promise<VersionDetails>): Promise<VersionDetails>;
|
|
8
|
+
displayDiffProgress(progress: () => Promise<VersionDetails[]>): Promise<VersionDetails[]>;
|
|
9
|
+
displayListProgress(progress: () => Promise<VersionOverview[]>): Promise<VersionOverview[]>;
|
|
10
|
+
promptVersionDetailsProperties(): Promise<(keyof VersionDetails)[]>;
|
|
11
|
+
displayVersionDetailsBanner(appVersion: number, envKey: string, envType: AppEnvironmentType): void;
|
|
12
|
+
displayDetailsAsTable(details: VersionDetails): void;
|
|
13
|
+
displayDataInJson(data: VersionDetails): void;
|
|
14
|
+
displayDiffBanner(version1: number, version2: number, envKey: string, envType: AppEnvironmentType): void;
|
|
15
|
+
displayDiffAsTable(versions: {
|
|
16
|
+
v1: number;
|
|
17
|
+
v2: number;
|
|
18
|
+
}, input: {
|
|
19
|
+
key: string;
|
|
20
|
+
diff: Change[];
|
|
21
|
+
}[]): void;
|
|
22
|
+
displayListBanner(versions: number, envKey: string, envType: AppEnvironmentType): void;
|
|
23
|
+
displayWriteToFile(outFile: string): void;
|
|
24
|
+
displayVersionList(data: VersionOverview[]): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=version-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-view.d.ts","sourceRoot":"","sources":["../../../src/command-line/view/version-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAQ,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAG9B,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,EAAE;IAEtB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAIxF,mBAAmB,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAIzF,mBAAmB,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAI3F,8BAA8B,IAAI,OAAO,CAAC,CAAC,MAAM,cAAc,CAAC,EAAE,CAAC;IAsDzE,2BAA2B,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAMlG,qBAAqB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IA0DpD,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAI7C,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAMxG,kBAAkB,CAAC,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,GAAG,IAAI;IAkCxG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAMtF,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIzC,kBAAkB,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,IAAI;CAwBzD"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VersionView = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
class VersionView {
|
|
8
|
+
ui;
|
|
9
|
+
constructor(ui) {
|
|
10
|
+
this.ui = ui;
|
|
11
|
+
}
|
|
12
|
+
async displayDetailsProgress(progress) {
|
|
13
|
+
return this.ui.displayProgress(progress, cli_shared_1.Text.version.check.start, cli_shared_1.Text.version.check.end);
|
|
14
|
+
}
|
|
15
|
+
async displayDiffProgress(progress) {
|
|
16
|
+
return this.ui.displayProgress(progress, cli_shared_1.Text.version.diff.start, cli_shared_1.Text.version.diff.end);
|
|
17
|
+
}
|
|
18
|
+
async displayListProgress(progress) {
|
|
19
|
+
return this.ui.displayProgress(progress, cli_shared_1.Text.version.list.start, cli_shared_1.Text.version.list.end);
|
|
20
|
+
}
|
|
21
|
+
async promptVersionDetailsProperties() {
|
|
22
|
+
const propsOptions = [
|
|
23
|
+
{
|
|
24
|
+
names: ['License', cli_shared_1.Text.version.check.details.prompt.properties.descriptions.license],
|
|
25
|
+
property: 'requiresLicense'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
names: ['Scopes', cli_shared_1.Text.version.check.details.prompt.properties.descriptions.scopes],
|
|
29
|
+
property: 'scopes'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
names: ['Egress', cli_shared_1.Text.version.check.details.prompt.properties.descriptions.egress],
|
|
33
|
+
property: 'egresses'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
names: ['Policies', cli_shared_1.Text.version.check.details.prompt.properties.descriptions.policies],
|
|
37
|
+
property: 'policies'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
names: ['Connect Key', cli_shared_1.Text.version.check.details.prompt.properties.descriptions.connectKeys],
|
|
41
|
+
property: 'connectKeys'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
names: ['Functions', cli_shared_1.Text.version.check.details.prompt.properties.descriptions.functions],
|
|
45
|
+
property: 'functions'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
names: ['Modules', cli_shared_1.Text.version.check.details.prompt.properties.descriptions.modules],
|
|
49
|
+
property: 'modules'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
names: ['Remotes', cli_shared_1.Text.version.check.details.prompt.properties.descriptions.remotes],
|
|
53
|
+
property: 'remotes'
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
const allOrNot = await this.ui.promptForList(cli_shared_1.Text.version.check.details.prompt.options.banner, [
|
|
57
|
+
cli_shared_1.Text.version.check.details.prompt.options.choices.all,
|
|
58
|
+
cli_shared_1.Text.version.check.details.prompt.options.choices.manual
|
|
59
|
+
]);
|
|
60
|
+
if (allOrNot === cli_shared_1.Text.version.check.details.prompt.options.choices.manual) {
|
|
61
|
+
const choices = await this.ui.promptForTable(cli_shared_1.Text.version.check.details.prompt.properties.banner, cli_shared_1.Text.version.check.details.prompt.properties.info, cli_shared_1.Text.version.check.details.prompt.properties.headers, propsOptions);
|
|
62
|
+
return choices.map((index) => propsOptions[index].property);
|
|
63
|
+
}
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
displayVersionDetailsBanner(appVersion, envKey, envType) {
|
|
67
|
+
this.ui.emptyLine();
|
|
68
|
+
this.ui.info(cli_shared_1.Text.version.check.details.banner(envKey, envType, appVersion));
|
|
69
|
+
this.ui.emptyLine();
|
|
70
|
+
}
|
|
71
|
+
displayDetailsAsTable(details) {
|
|
72
|
+
this.ui.table([
|
|
73
|
+
['entry', 'Property'],
|
|
74
|
+
['details', 'Details']
|
|
75
|
+
], [
|
|
76
|
+
{
|
|
77
|
+
entry: 'deployment date',
|
|
78
|
+
details: cli_shared_1.Text.version.check.details.deploymentDate(details.deploymentDateTime),
|
|
79
|
+
property: 'deploymentDateTime'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
entry: 'functions',
|
|
83
|
+
details: cli_shared_1.Text.version.check.details.functions(details.functions || []),
|
|
84
|
+
property: 'functions'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
entry: 'modules',
|
|
88
|
+
details: cli_shared_1.Text.version.check.details.modules(details.modules || []),
|
|
89
|
+
property: 'modules'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
entry: 'license',
|
|
93
|
+
details: cli_shared_1.Text.version.check.details.license(details.requiresLicense),
|
|
94
|
+
property: 'requiresLicense'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
entry: 'scopes',
|
|
98
|
+
details: cli_shared_1.Text.version.check.details.scopes(details.scopes || []),
|
|
99
|
+
property: 'scopes'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
entry: 'egress',
|
|
103
|
+
details: cli_shared_1.Text.version.check.details.egress(details.egresses || []),
|
|
104
|
+
property: 'egresses'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
entry: 'policies',
|
|
108
|
+
details: cli_shared_1.Text.version.check.details.securityPolicies(details.policies || []),
|
|
109
|
+
property: 'policies'
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
entry: 'connect keys',
|
|
113
|
+
details: cli_shared_1.Text.version.check.details.connectKeys(details.connectKeys || []),
|
|
114
|
+
property: 'connectKeys'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
entry: 'remotes',
|
|
118
|
+
details: cli_shared_1.Text.version.check.details.remotes(details.remotes || []),
|
|
119
|
+
property: 'remotes'
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
.sort((a, b) => a.entry.localeCompare(b.entry))
|
|
123
|
+
.filter(({ property }) => Object.keys(details).includes(property)));
|
|
124
|
+
}
|
|
125
|
+
displayDataInJson(data) {
|
|
126
|
+
this.ui.info(JSON.stringify(data, null, 2));
|
|
127
|
+
}
|
|
128
|
+
displayDiffBanner(version1, version2, envKey, envType) {
|
|
129
|
+
this.ui.emptyLine();
|
|
130
|
+
this.ui.info(cli_shared_1.Text.version.diff.details.banner(envKey, envType, version1, version2));
|
|
131
|
+
this.ui.emptyLine();
|
|
132
|
+
}
|
|
133
|
+
displayDiffAsTable(versions, input) {
|
|
134
|
+
this.ui.table([
|
|
135
|
+
['entry', 'Property'],
|
|
136
|
+
['v1', `Version 1 [${versions.v1}]`],
|
|
137
|
+
['v2', `Version 2 [${versions.v2}]`]
|
|
138
|
+
], input
|
|
139
|
+
.filter(({ diff }) => diff.filter((change) => change.added || change.removed).length > 0)
|
|
140
|
+
.map(({ key, diff }) => ({
|
|
141
|
+
entry: key,
|
|
142
|
+
v1: diff
|
|
143
|
+
.filter((change) => !change.added)
|
|
144
|
+
.map((change) => {
|
|
145
|
+
if (!change.removed) {
|
|
146
|
+
return chalk_1.default.gray(change.value);
|
|
147
|
+
}
|
|
148
|
+
return change.value;
|
|
149
|
+
})
|
|
150
|
+
.join(''),
|
|
151
|
+
v2: diff
|
|
152
|
+
.filter((change) => !change.removed)
|
|
153
|
+
.map((change) => {
|
|
154
|
+
if (!change.added) {
|
|
155
|
+
return chalk_1.default.gray(change.value);
|
|
156
|
+
}
|
|
157
|
+
return change.value;
|
|
158
|
+
})
|
|
159
|
+
.join('')
|
|
160
|
+
}))
|
|
161
|
+
.sort((a, b) => a.entry.localeCompare(b.entry)));
|
|
162
|
+
}
|
|
163
|
+
displayListBanner(versions, envKey, envType) {
|
|
164
|
+
this.ui.emptyLine();
|
|
165
|
+
this.ui.info(cli_shared_1.Text.version.list.details.banner(envKey, envType, versions));
|
|
166
|
+
this.ui.emptyLine();
|
|
167
|
+
}
|
|
168
|
+
displayWriteToFile(outFile) {
|
|
169
|
+
this.ui.info(cli_shared_1.Text.version.check.details.writeToFile(outFile));
|
|
170
|
+
}
|
|
171
|
+
displayVersionList(data) {
|
|
172
|
+
this.ui.table([
|
|
173
|
+
['version', 'Major Versions'],
|
|
174
|
+
['deploymentDate', 'Deployment Date'],
|
|
175
|
+
['egresses', 'Egress'],
|
|
176
|
+
['policies', 'Policies'],
|
|
177
|
+
['scopes', 'Scopes'],
|
|
178
|
+
['connectKeys', 'Connect keys'],
|
|
179
|
+
['functions', 'Functions'],
|
|
180
|
+
['remotes', 'Remotes'],
|
|
181
|
+
['modules', 'Modules'],
|
|
182
|
+
['requiresLicense', 'License']
|
|
183
|
+
], data.map(({ version, egresses, modules, policies, deploymentDateTime, ...rest }) => ({
|
|
184
|
+
...rest,
|
|
185
|
+
version: version.toString(),
|
|
186
|
+
deploymentDate: cli_shared_1.Text.version.list.details.deploymentDate(deploymentDateTime),
|
|
187
|
+
egresses: cli_shared_1.Text.version.list.details.egresses(egresses),
|
|
188
|
+
policies: cli_shared_1.Text.version.list.details.policies(policies),
|
|
189
|
+
modules: cli_shared_1.Text.version.list.details.modules(modules)
|
|
190
|
+
})));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.VersionView = VersionView;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { AppConfigProvider, AppEnvironmentType } from '@forge/cli-shared';
|
|
2
|
+
import { AppVersionDetailsClient } from '../version/graphql-client';
|
|
3
|
+
export interface VersionDetails {
|
|
4
|
+
appVersion: number;
|
|
5
|
+
deploymentDateTime: Date;
|
|
6
|
+
environmentType: AppEnvironmentType;
|
|
7
|
+
functions: {
|
|
8
|
+
key: string;
|
|
9
|
+
runtimeName: string;
|
|
10
|
+
regions: string[];
|
|
11
|
+
handler: string;
|
|
12
|
+
}[] | undefined;
|
|
13
|
+
modules: {
|
|
14
|
+
type: string;
|
|
15
|
+
items: {
|
|
16
|
+
key: string;
|
|
17
|
+
properties: any;
|
|
18
|
+
}[];
|
|
19
|
+
}[];
|
|
20
|
+
requiresLicense: boolean;
|
|
21
|
+
egresses: {
|
|
22
|
+
type: string;
|
|
23
|
+
addresses: string[];
|
|
24
|
+
}[];
|
|
25
|
+
scopes: string[];
|
|
26
|
+
policies: {
|
|
27
|
+
type: string;
|
|
28
|
+
policies: string[];
|
|
29
|
+
}[];
|
|
30
|
+
connectKeys: {
|
|
31
|
+
product: string;
|
|
32
|
+
key: string;
|
|
33
|
+
}[] | undefined;
|
|
34
|
+
remotes: {
|
|
35
|
+
key: string;
|
|
36
|
+
baseUrl: string;
|
|
37
|
+
operations: string[];
|
|
38
|
+
}[] | undefined;
|
|
39
|
+
}
|
|
40
|
+
export interface VersionOverview {
|
|
41
|
+
version: number;
|
|
42
|
+
deploymentDateTime: Date;
|
|
43
|
+
environmentType: AppEnvironmentType;
|
|
44
|
+
egresses: {
|
|
45
|
+
type: string;
|
|
46
|
+
count: number;
|
|
47
|
+
}[];
|
|
48
|
+
policies: {
|
|
49
|
+
type: string;
|
|
50
|
+
count: number;
|
|
51
|
+
}[];
|
|
52
|
+
scopes: string;
|
|
53
|
+
connectKeys: string;
|
|
54
|
+
functions: string;
|
|
55
|
+
remotes: string;
|
|
56
|
+
modules: {
|
|
57
|
+
type: string;
|
|
58
|
+
count: number;
|
|
59
|
+
}[];
|
|
60
|
+
requiresLicense: boolean;
|
|
61
|
+
}
|
|
62
|
+
export declare class VersionService {
|
|
63
|
+
private readonly getAppConfig;
|
|
64
|
+
private readonly versionDetailsClient;
|
|
65
|
+
constructor(getAppConfig: AppConfigProvider, versionDetailsClient: AppVersionDetailsClient);
|
|
66
|
+
private getMajorVersion;
|
|
67
|
+
getAppVersionDetails(environmentKey: string, majorVersion?: number): Promise<VersionDetails>;
|
|
68
|
+
private getTypeFromPermissionType;
|
|
69
|
+
private getModulesGroupedByTypes;
|
|
70
|
+
private removeInternalPropertiesFromObject;
|
|
71
|
+
private getAppVersions;
|
|
72
|
+
getAppVersionOverviewList(environmentKey: string): Promise<VersionOverview[]>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=version-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-service.d.ts","sourceRoot":"","sources":["../../src/service/version-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAInB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAIpE,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,IAAI,CAAC;IACzB,eAAe,EAAE,kBAAkB,CAAC;IACpC,SAAS,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,SAAS,CAAC;IAClG,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,GAAG,CAAA;SAAE,EAAE,CAAA;KAAE,EAAE,CAAC;IACvE,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAClD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACjD,WAAW,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,SAAS,CAAC;IAC5D,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,GAAG,SAAS,CAAC;CAC/E;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,IAAI,CAAC;IACzB,eAAe,EAAE,kBAAkB,CAAC;IACpC,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,oBAAoB;gBADpB,YAAY,EAAE,iBAAiB,EAC/B,oBAAoB,EAAE,uBAAuB;IAGhE,OAAO,CAAC,eAAe;IAIV,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA+EzG,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,wBAAwB;IAwBhC,OAAO,CAAC,kCAAkC;YAM5B,cAAc;IAKf,yBAAyB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAsB3F"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VersionService = void 0;
|
|
4
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
5
|
+
const manifest_1 = require("@forge/manifest");
|
|
6
|
+
const arn_1 = require("@sandfox/arn");
|
|
7
|
+
class VersionService {
|
|
8
|
+
getAppConfig;
|
|
9
|
+
versionDetailsClient;
|
|
10
|
+
constructor(getAppConfig, versionDetailsClient) {
|
|
11
|
+
this.getAppConfig = getAppConfig;
|
|
12
|
+
this.versionDetailsClient = versionDetailsClient;
|
|
13
|
+
}
|
|
14
|
+
getMajorVersion(version) {
|
|
15
|
+
return parseInt(version.split('.')[0]);
|
|
16
|
+
}
|
|
17
|
+
async getAppVersionDetails(environmentKey, majorVersion) {
|
|
18
|
+
const { id: appId } = await this.getAppConfig();
|
|
19
|
+
const data = await this.versionDetailsClient.getVersionDetails(appId, environmentKey, majorVersion);
|
|
20
|
+
const functionModules = data.modules?.filter((mod) => mod?.extensionData.type === manifest_1.AllModuleTypes.CoreFunction);
|
|
21
|
+
const remoteModules = data.modules?.filter((mod) => mod?.extensionData.type === manifest_1.AllModuleTypes.CoreRemote);
|
|
22
|
+
const allModules = this.getModulesGroupedByTypes(data.modules);
|
|
23
|
+
return {
|
|
24
|
+
requiresLicense: data.requiresLicense,
|
|
25
|
+
egresses: data.permissions?.[0].egress
|
|
26
|
+
?.filter((entry) => entry !== undefined && entry !== null)
|
|
27
|
+
.filter((entry) => {
|
|
28
|
+
if (entry.type === 'FETCH_BACKEND_SIDE') {
|
|
29
|
+
entry.addresses = entry.addresses?.filter((address) => !remoteModules?.map((remote) => remote?.extensionData.baseUrl).includes(address));
|
|
30
|
+
}
|
|
31
|
+
return entry;
|
|
32
|
+
})
|
|
33
|
+
.filter((entry) => entry?.addresses?.length !== 0)
|
|
34
|
+
.map((entry) => ({
|
|
35
|
+
type: this.getTypeFromPermissionType(entry?.type),
|
|
36
|
+
addresses: entry.addresses
|
|
37
|
+
})) || [],
|
|
38
|
+
scopes: data.permissions?.[0].scopes.map((scope) => scope.key).sort() || [],
|
|
39
|
+
policies: data.permissions?.[0].securityPolicies
|
|
40
|
+
?.filter((entry) => entry.type !== undefined && entry.type !== null)
|
|
41
|
+
.map((entry) => ({
|
|
42
|
+
type: this.getTypeFromPermissionType(entry?.type),
|
|
43
|
+
policies: entry.policies
|
|
44
|
+
})) || [],
|
|
45
|
+
connectKeys: data.migrationKeys
|
|
46
|
+
? Object.keys(data.migrationKeys).map((key) => ({
|
|
47
|
+
product: key,
|
|
48
|
+
key: data.migrationKeys[key]
|
|
49
|
+
}))
|
|
50
|
+
: undefined,
|
|
51
|
+
appVersion: this.getMajorVersion(data.appVersion),
|
|
52
|
+
deploymentDateTime: data.deploymentDateTime,
|
|
53
|
+
environmentType: data.environmentType,
|
|
54
|
+
functions: functionModules?.map((entry) => ({
|
|
55
|
+
key: entry?.key || 'N/A',
|
|
56
|
+
runtimeName: (entry?.extensionData.functions?.[Object.keys(entry?.extensionData.functions || {})[0]]?.runtime
|
|
57
|
+
?.identifier ||
|
|
58
|
+
entry?.extensionData.runtime?.identifier ||
|
|
59
|
+
'sandbox')
|
|
60
|
+
.replace('provided.al2', 'sandbox')
|
|
61
|
+
.replace('provided', 'sandbox'),
|
|
62
|
+
regions: entry?.extensionData.functions
|
|
63
|
+
? Object.keys(entry?.extensionData.functions)
|
|
64
|
+
: [(0, arn_1.parse)(entry?.extensionData.functionName).region],
|
|
65
|
+
handler: entry?.extensionData.handler
|
|
66
|
+
})) || [],
|
|
67
|
+
modules: Object.keys(allModules)
|
|
68
|
+
.filter((type) => !['function', 'remote'].includes(type))
|
|
69
|
+
.map((type) => ({ type, items: allModules[type] })) || [],
|
|
70
|
+
remotes: remoteModules?.map((entry) => ({
|
|
71
|
+
key: entry?.key || 'N/A',
|
|
72
|
+
baseUrl: entry?.extensionData.baseUrl,
|
|
73
|
+
operations: entry?.extensionData.operations || []
|
|
74
|
+
})) || []
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
getTypeFromPermissionType(permissionType) {
|
|
78
|
+
switch (permissionType) {
|
|
79
|
+
case cli_shared_1.AppNetworkPermissionType.FetchBackendSide:
|
|
80
|
+
return 'fetch.backend';
|
|
81
|
+
case cli_shared_1.AppNetworkPermissionType.FetchClientSide:
|
|
82
|
+
return 'fetch.client';
|
|
83
|
+
default:
|
|
84
|
+
return permissionType?.toLowerCase().replaceAll('_', '.');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
getModulesGroupedByTypes(modules) {
|
|
88
|
+
const rawModules = modules
|
|
89
|
+
?.filter((mod) => manifest_1.SUPPORTED_MODULES.includes(mod?.extensionData.type))
|
|
90
|
+
?.filter((mod) => ![manifest_1.AllModuleTypes.CoreFunction, manifest_1.AllModuleTypes.CoreRemote].includes(mod?.extensionData.type))
|
|
91
|
+
.map((entry) => ({
|
|
92
|
+
key: entry?.key || 'N/A',
|
|
93
|
+
type: entry?.extensionData.type,
|
|
94
|
+
properties: {
|
|
95
|
+
...this.removeInternalPropertiesFromObject(entry?.extensionData)
|
|
96
|
+
}
|
|
97
|
+
})) || [];
|
|
98
|
+
return rawModules.reduce((acc, entry) => {
|
|
99
|
+
const type = (0, manifest_1.cleanKey)(entry.type);
|
|
100
|
+
if (acc[type] === undefined) {
|
|
101
|
+
acc[type] = [];
|
|
102
|
+
}
|
|
103
|
+
acc[type].push(entry);
|
|
104
|
+
return acc;
|
|
105
|
+
}, {});
|
|
106
|
+
}
|
|
107
|
+
removeInternalPropertiesFromObject(obj) {
|
|
108
|
+
const { type, functions, outboundAuthContainerId, resourceUploadId, key, ...rest } = obj || {};
|
|
109
|
+
return rest;
|
|
110
|
+
}
|
|
111
|
+
async getAppVersions(environmentKey) {
|
|
112
|
+
const { id: appId } = await this.getAppConfig();
|
|
113
|
+
return await this.versionDetailsClient.getVersionList(appId, environmentKey);
|
|
114
|
+
}
|
|
115
|
+
async getAppVersionOverviewList(environmentKey) {
|
|
116
|
+
const versions = await this.getAppVersions(environmentKey);
|
|
117
|
+
const majorVersions = versions.map((version) => this.getMajorVersion(version));
|
|
118
|
+
const versionDetails = await Promise.all(majorVersions.map(async (version) => await this.getAppVersionDetails(environmentKey, version)));
|
|
119
|
+
return versionDetails.map((entry) => ({
|
|
120
|
+
version: entry.appVersion,
|
|
121
|
+
deploymentDateTime: entry.deploymentDateTime,
|
|
122
|
+
environmentType: entry.environmentType,
|
|
123
|
+
egresses: entry.egresses.map((egress) => ({ type: egress.type, count: egress.addresses.length })),
|
|
124
|
+
policies: entry.policies.map((policy) => ({ type: policy.type, count: policy.policies.length })),
|
|
125
|
+
scopes: (entry.scopes.length || 0).toString(),
|
|
126
|
+
connectKeys: (entry.connectKeys?.length || 0).toString(),
|
|
127
|
+
functions: (entry.functions?.length || 0).toString(),
|
|
128
|
+
remotes: (entry.remotes?.length || 0).toString(),
|
|
129
|
+
modules: entry.modules.map((module) => ({ type: module.type, count: module.items.length })),
|
|
130
|
+
requiresLicense: entry.requiresLicense
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.VersionService = VersionService;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AppEnvironmentType, AppPermission, AppVersionExtension, GraphQLClient, Maybe, MigrationKeys, Storage, UserError } from '@forge/cli-shared';
|
|
2
|
+
export interface AppVersionDetailsData {
|
|
3
|
+
migrationKeys?: Maybe<MigrationKeys> | null;
|
|
4
|
+
permissions?: Array<AppPermission> | null;
|
|
5
|
+
modules: Array<AppVersionExtension | null> | null | undefined;
|
|
6
|
+
environmentType: AppEnvironmentType;
|
|
7
|
+
appVersion: string;
|
|
8
|
+
deploymentDateTime: Date;
|
|
9
|
+
requiresLicense: boolean;
|
|
10
|
+
storage: Storage;
|
|
11
|
+
}
|
|
12
|
+
export declare class MissingAppError extends UserError {
|
|
13
|
+
}
|
|
14
|
+
export declare class EnvironmentNotFoundError extends UserError {
|
|
15
|
+
constructor(environmentKey: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class MissingAppVersionError extends Error {
|
|
18
|
+
}
|
|
19
|
+
export declare class MissingAppEnvironmentError extends Error {
|
|
20
|
+
}
|
|
21
|
+
export declare class AppVersionDetailsClient {
|
|
22
|
+
private readonly graphqlClient;
|
|
23
|
+
constructor(graphqlClient: GraphQLClient);
|
|
24
|
+
getVersionDetails(appId: string, environmentKey: string, majorVersion?: number): Promise<AppVersionDetailsData>;
|
|
25
|
+
getVersionList(appId: string, environmentKey: string): Promise<string[]>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=graphql-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/version/graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,KAAK,EACL,aAAa,EAEb,OAAO,EAEP,SAAS,EACV,MAAM,mBAAmB,CAAC;AAS3B,MAAM,WAAW,qBAAqB;IACpC,aAAa,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IAC5C,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IAC1C,OAAO,EAAE,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9D,eAAe,EAAE,kBAAkB,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,IAAI,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,eAAgB,SAAQ,SAAS;CAAG;AAEjD,qBAAa,wBAAyB,SAAQ,SAAS;gBACzC,cAAc,EAAE,MAAM;CAGnC;AAED,qBAAa,sBAAuB,SAAQ,KAAK;CAAG;AAEpD,qBAAa,0BAA2B,SAAQ,KAAK;CAAG;AAExD,qBAAa,uBAAuB;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAE5C,iBAAiB,CAC5B,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,qBAAqB,CAAC;IAyFpB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAuDtF"}
|