@forge/cli-shared 8.24.0-next.7 → 8.24.0-next.7-experimental-a344346
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 +22 -0
- package/out/apps/template-module.d.ts +12 -9
- package/out/apps/template-module.d.ts.map +1 -1
- package/out/apps/template-module.js +62 -25
- package/out/config/config-file.d.ts +1 -0
- package/out/config/config-file.d.ts.map +1 -1
- package/out/config/config-file.js +33 -4
- package/out/graphql/graphql-types.d.ts +530 -86
- package/out/graphql/graphql-types.d.ts.map +1 -1
- package/out/graphql/graphql-types.js +111 -44
- package/out/ui/text.d.ts +53 -2
- package/out/ui/text.d.ts.map +1 -1
- package/out/ui/text.js +56 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @forge/cli-shared
|
|
2
2
|
|
|
3
|
+
## 8.24.0-next.7-experimental-a344346
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2415638: Prerelease of forge module add command
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 22145f6: Surfacing error messages in the Forge CLI for apps that are missing billing information
|
|
12
|
+
- 8f4ff0a: Remove forge-cli-enable-developer-space-flow feature flag and GA developer space selection. The feature is now always enabled except in FedRAMP environments.
|
|
13
|
+
- 5bc8d8f: Including remote baseUrl hostnames in fetch_backend egress permissions to ensure egress checking is consistent with backend (cs-apps)
|
|
14
|
+
- Updated dependencies [ccdcfc3]
|
|
15
|
+
- Updated dependencies [8197e66]
|
|
16
|
+
- Updated dependencies [723fab8]
|
|
17
|
+
- Updated dependencies [4493006]
|
|
18
|
+
- Updated dependencies [5beb8ad]
|
|
19
|
+
- Updated dependencies [f1f11f0]
|
|
20
|
+
- Updated dependencies [b7b1f36]
|
|
21
|
+
- Updated dependencies [ee691bf]
|
|
22
|
+
- Updated dependencies [9f3add6]
|
|
23
|
+
- @forge/manifest@12.9.0-next.5-experimental-a344346
|
|
24
|
+
|
|
3
25
|
## 8.24.0-next.7
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -15,11 +15,12 @@ export interface ModuleTemplateMeta {
|
|
|
15
15
|
category?: string;
|
|
16
16
|
uiFramework?: UIFramework;
|
|
17
17
|
moduleKey: string;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
manifestPath?: string;
|
|
19
|
+
dependencies?: Record<string, string>;
|
|
20
|
+
devDependencies?: Record<string, string>;
|
|
20
21
|
frontend?: {
|
|
21
|
-
dependencies?: string
|
|
22
|
-
devDependencies?: string
|
|
22
|
+
dependencies?: Record<string, string>;
|
|
23
|
+
devDependencies?: Record<string, string>;
|
|
23
24
|
};
|
|
24
25
|
customUiDependencies?: string[];
|
|
25
26
|
customUiDevDependencies?: string[];
|
|
@@ -33,11 +34,11 @@ export interface ModuleTemplateMeta {
|
|
|
33
34
|
}>;
|
|
34
35
|
variants?: Record<UIFramework, {
|
|
35
36
|
manifestPath?: string;
|
|
36
|
-
dependencies?: Record<string, string
|
|
37
|
-
devDependencies?: Record<string, string
|
|
37
|
+
dependencies?: Record<string, string>;
|
|
38
|
+
devDependencies?: Record<string, string>;
|
|
38
39
|
frontend?: {
|
|
39
|
-
dependencies?: string
|
|
40
|
-
devDependencies?: string
|
|
40
|
+
dependencies?: Record<string, string>;
|
|
41
|
+
devDependencies?: Record<string, string>;
|
|
41
42
|
};
|
|
42
43
|
variables?: TemplateVariableDef[];
|
|
43
44
|
fileOperations?: Array<{
|
|
@@ -56,7 +57,9 @@ export declare class TemplateModuleServices {
|
|
|
56
57
|
getAvailableModules(product: string): Promise<ModuleTemplateMeta[]>;
|
|
57
58
|
private fetchModuleTemplates;
|
|
58
59
|
fetchManifestFragment(manifestPath: string): Promise<string>;
|
|
59
|
-
|
|
60
|
+
applyVariant(template: ModuleTemplateMeta, uiFramework?: UIFramework): ModuleTemplateMeta;
|
|
61
|
+
prepareModuleMetadata(template: ModuleTemplateMeta, uiFramework?: UIFramework): Promise<ModuleTemplateMeta>;
|
|
62
|
+
downloadModuleBundle(template: ModuleTemplateMeta, uiFramework?: UIFramework): Promise<void>;
|
|
60
63
|
cleanupCache(cacheDir: string): void;
|
|
61
64
|
}
|
|
62
65
|
//# sourceMappingURL=template-module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-module.d.ts","sourceRoot":"","sources":["../../src/apps/template-module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"template-module.d.ts","sourceRoot":"","sources":["../../src/apps/template-module.ts"],"names":[],"mappings":"AAWA,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED,oBAAY,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEjD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAElB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C,C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CAAC,EAAE,MAAM;IAIf,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;YAOlE,oBAAoB;IAsBrB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYlE,YAAY,CAAC,QAAQ,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,kBAAkB;IAqBnF,qBAAqB,CAChC,QAAQ,EAAE,kBAAkB,EAC5B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,kBAAkB,CAAC;IAajB,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IA2ClG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAO5C"}
|
|
@@ -7,6 +7,7 @@ const path_1 = tslib_1.__importDefault(require("path"));
|
|
|
7
7
|
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
8
8
|
const os_1 = tslib_1.__importDefault(require("os"));
|
|
9
9
|
const url_1 = require("url");
|
|
10
|
+
const adm_zip_1 = tslib_1.__importDefault(require("adm-zip"));
|
|
10
11
|
const text_1 = require("../ui/text");
|
|
11
12
|
const BIFROST_BASE_URL = 'https://forge-templates-bifrost.ddev.frontend.public.atl-paas.net/assets/';
|
|
12
13
|
const MODULE_INDEX_FILE = 'template-modules.json';
|
|
@@ -52,41 +53,77 @@ class TemplateModuleServices {
|
|
|
52
53
|
}
|
|
53
54
|
return await res.text();
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
throw new Error(text_1.Text.module.add.errorInvalidUIFramework(uiFramework, template.moduleKey));
|
|
62
|
-
}
|
|
63
|
-
if (variantData?.manifestPath) {
|
|
64
|
-
manifestFragment = await this.fetchManifestFragment(variantData.manifestPath);
|
|
65
|
-
}
|
|
66
|
-
const cacheDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'forge-module-'));
|
|
67
|
-
if (manifestFragment) {
|
|
68
|
-
fs_1.default.writeFileSync(path_1.default.join(cacheDir, 'manifest-fragment.yml'), manifestFragment);
|
|
56
|
+
applyVariant(template, uiFramework) {
|
|
57
|
+
if (!uiFramework)
|
|
58
|
+
return { ...template };
|
|
59
|
+
const variantData = template.variants?.[uiFramework];
|
|
60
|
+
if (!variantData) {
|
|
61
|
+
throw new Error(text_1.Text.module.add.errorInvalidUIFramework(uiFramework, template.moduleKey));
|
|
69
62
|
}
|
|
70
63
|
return {
|
|
71
64
|
...template,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
fileOperations: variantData.fileOperations ?? template.fileOperations
|
|
80
|
-
}
|
|
81
|
-
: {}),
|
|
82
|
-
cacheDir
|
|
65
|
+
uiFramework,
|
|
66
|
+
manifestPath: variantData.manifestPath ?? template.manifestPath,
|
|
67
|
+
dependencies: variantData.dependencies ?? template.dependencies,
|
|
68
|
+
devDependencies: variantData.devDependencies ?? template.devDependencies,
|
|
69
|
+
frontend: variantData.frontend ?? template.frontend,
|
|
70
|
+
variables: variantData.variables ?? template.variables,
|
|
71
|
+
fileOperations: variantData.fileOperations ?? template.fileOperations
|
|
83
72
|
};
|
|
84
73
|
}
|
|
74
|
+
async prepareModuleMetadata(template, uiFramework) {
|
|
75
|
+
const resolved = this.applyVariant(template, uiFramework);
|
|
76
|
+
const cacheDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'forge-module-'));
|
|
77
|
+
if (resolved.manifestPath) {
|
|
78
|
+
const manifestFragment = await this.fetchManifestFragment(resolved.manifestPath);
|
|
79
|
+
fs_1.default.writeFileSync(path_1.default.join(cacheDir, 'manifest-fragment.yml'), manifestFragment);
|
|
80
|
+
}
|
|
81
|
+
return { ...resolved, cacheDir };
|
|
82
|
+
}
|
|
83
|
+
async downloadModuleBundle(template, uiFramework) {
|
|
84
|
+
if (!template.fileOperations?.length) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (!template.cacheDir) {
|
|
88
|
+
throw new Error(text_1.Text.module.add.errorCacheDirMissing(template.moduleKey));
|
|
89
|
+
}
|
|
90
|
+
const rel = uiFramework ? `${template.moduleKey}/${uiFramework}/bundle.zip` : `${template.moduleKey}/bundle.zip`;
|
|
91
|
+
const url = `${this.baseUrl}${rel}`;
|
|
92
|
+
let res;
|
|
93
|
+
try {
|
|
94
|
+
res = await (0, node_fetch_1.default)(url);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
98
|
+
throw new Error(text_1.Text.module.add.errorFailedToDownloadBundle(template.moduleKey, message), { cause: err });
|
|
99
|
+
}
|
|
100
|
+
if (!res.ok) {
|
|
101
|
+
throw new BifrostFetchError(`${text_1.Text.module.errors.bifrostZipFetchFailed(template.moduleKey, res.status, res.statusText)} (last URL: ${url})`);
|
|
102
|
+
}
|
|
103
|
+
const arrayBuffer = await res.arrayBuffer();
|
|
104
|
+
const zipPath = path_1.default.join(template.cacheDir, 'bundle.zip');
|
|
105
|
+
fs_1.default.writeFileSync(zipPath, Buffer.from(arrayBuffer));
|
|
106
|
+
try {
|
|
107
|
+
new adm_zip_1.default(zipPath).extractAllTo(template.cacheDir, true);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
throw new BifrostFetchError(text_1.Text.module.add.errorZipExtractionFailed(template.moduleKey, err.message));
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
try {
|
|
114
|
+
fs_1.default.rmSync(zipPath, { force: true });
|
|
115
|
+
}
|
|
116
|
+
catch (cleanupErr) {
|
|
117
|
+
console.warn(`${text_1.Text.module.add.errorZipCleanupFailed(template.moduleKey)}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
85
121
|
cleanupCache(cacheDir) {
|
|
86
122
|
try {
|
|
87
123
|
fs_1.default.rmSync(cacheDir, { recursive: true, force: true });
|
|
88
124
|
}
|
|
89
125
|
catch {
|
|
126
|
+
throw new Error(text_1.Text.module.add.errorCacheCleanupFailed(cacheDir));
|
|
90
127
|
}
|
|
91
128
|
}
|
|
92
129
|
}
|
|
@@ -37,6 +37,7 @@ export declare class ConfigFile implements ConfigReader, ConfigWriter, ConfigInt
|
|
|
37
37
|
private assertNoMissingResources;
|
|
38
38
|
private getRemoteFromEgressPermission;
|
|
39
39
|
private instanceOfRemote;
|
|
40
|
+
private getRemoteBaseUrlHostnames;
|
|
40
41
|
getEgressPermissions(): Promise<{
|
|
41
42
|
type: string;
|
|
42
43
|
domains: string[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-file.d.ts","sourceRoot":"","sources":["../../src/config/config-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAoB,MAAM,IAAI,CAAC;AAGlE,OAAO,EACL,OAAO,EACP,cAAc,EACd,SAAS,EAOV,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAQ,MAAM,WAAW,CAAC;AAE7D,qBAAa,oBAAqB,SAAQ,eAAe;;CAIxD;AAED,qBAAa,8BAA+B,SAAQ,SAAS;gBAC/C,SAAS,EAAE,MAAM,EAAE;CAGhC;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;CAC3C;AAED,oBAAY,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,C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AM,EAAE,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAe1G,OAAO,CAAC,wBAAwB;IAKhC,OAAO,CAAC,wBAAwB;IAkBhC,OAAO,CAAC,6BAA6B;IAkBrC,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,yBAAyB;IAsBpB,oBAAoB,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,EAAE,CAAC;IA+ClF,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAe1E,YAAY,CAAC,aAAa,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAsB1E,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKzD,OAAO,CAAC,eAAe;CAkCxB"}
|
|
@@ -211,13 +211,31 @@ class ConfigFile {
|
|
|
211
211
|
instanceOfRemote(remote) {
|
|
212
212
|
return typeof remote !== 'string' && 'remote' in remote;
|
|
213
213
|
}
|
|
214
|
+
getRemoteBaseUrlHostnames(remotes) {
|
|
215
|
+
if (!remotes) {
|
|
216
|
+
return [];
|
|
217
|
+
}
|
|
218
|
+
return remotes.flatMap((remote) => {
|
|
219
|
+
const baseUrlField = remote.baseUrl;
|
|
220
|
+
if (!baseUrlField) {
|
|
221
|
+
return [];
|
|
222
|
+
}
|
|
223
|
+
const urls = typeof baseUrlField === 'string' ? [baseUrlField] : Object.values(baseUrlField);
|
|
224
|
+
return urls.flatMap((url) => {
|
|
225
|
+
try {
|
|
226
|
+
return [new url_1.URL(url).hostname];
|
|
227
|
+
}
|
|
228
|
+
catch (e) {
|
|
229
|
+
return [];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
214
234
|
async getEgressPermissions() {
|
|
215
235
|
const { permissions, remotes } = await this.readConfig();
|
|
216
236
|
const egressPermissions = permissions?.external;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
const { fetch: fetchEgress, ...otherEgress } = egressPermissions;
|
|
237
|
+
const remoteBaseUrlHostnames = this.getRemoteBaseUrlHostnames(remotes);
|
|
238
|
+
const { fetch: fetchEgress, ...otherEgress } = egressPermissions ?? {};
|
|
221
239
|
const getDomainsFromPermissions = (input, typePrefix = undefined) => Object.entries(input)
|
|
222
240
|
.filter((entry) => Array.isArray(entry[1]))
|
|
223
241
|
.map((entry) => ({
|
|
@@ -237,6 +255,17 @@ class ConfigFile {
|
|
|
237
255
|
}));
|
|
238
256
|
const egressUrls = getDomainsFromPermissions(otherEgress);
|
|
239
257
|
const fetchUrls = fetchEgress ? getDomainsFromPermissions(fetchEgress, 'fetch') : [];
|
|
258
|
+
const existingHostnames = new Set([...egressUrls, ...fetchUrls].flatMap(({ domains }) => domains ?? []));
|
|
259
|
+
const additionalRemoteHostnames = [...new Set(remoteBaseUrlHostnames)].filter((hostname) => !existingHostnames.has(hostname));
|
|
260
|
+
if (additionalRemoteHostnames.length > 0) {
|
|
261
|
+
const existingFetchBackend = fetchUrls.find(({ type }) => type === 'fetch_backend');
|
|
262
|
+
if (existingFetchBackend) {
|
|
263
|
+
existingFetchBackend.domains = [...(existingFetchBackend.domains ?? []), ...additionalRemoteHostnames];
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
fetchUrls.push({ type: 'fetch_backend', domains: additionalRemoteHostnames });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
240
269
|
return [...egressUrls, ...fetchUrls];
|
|
241
270
|
}
|
|
242
271
|
async getAuthProviders() {
|