Skip to content

Commit 5f08208

Browse files
test
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
1 parent e972a72 commit 5f08208

2 files changed

Lines changed: 43 additions & 4 deletions

File tree

launcher/src/openvsix-registry.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ export class OpenVSIXRegistry {
5858

5959
const serviceURL = productJSON.getExtensionsGalleryServiceURL();
6060
const itemURL = productJSON.getExtensionsGalleryItemURL();
61+
const extensionUrlTemplate = productJSON.getExtensionUrlTemplate();
6162

6263
const newServiceURL = `${openvsxURL}/gallery`;
6364
const newItemURL = `${openvsxURL}/item`;
65+
const newExtensionUrlTemplate = `${openvsxURL}/vscode/gallery/{publisher}/{name}/latest`;
6466

6567
productJSON.setExtensionsGalleryServiceURL(newServiceURL);
6668
productJSON.setExtensionsGalleryItemURL(newItemURL);
@@ -71,7 +73,17 @@ export class OpenVSIXRegistry {
7173
console.error('newServiceURL ', newServiceURL);
7274
console.error('itemURL ', itemURL);
7375
console.error('newItemURL ', newItemURL);
74-
await this.update(FILE_WORKBENCH, serviceURL, newServiceURL, itemURL, newItemURL);
76+
console.error('extensionUrlTemplate ', extensionUrlTemplate);
77+
console.error('newExtensionUrlTemplate ', newExtensionUrlTemplate);
78+
await this.update(
79+
FILE_WORKBENCH,
80+
serviceURL,
81+
newServiceURL,
82+
itemURL,
83+
newItemURL,
84+
extensionUrlTemplate,
85+
newExtensionUrlTemplate
86+
);
7587
} catch (err) {
7688
console.error(`${err.message} Failure to configure OpenVSIX registry.`);
7789
}
@@ -82,12 +94,14 @@ export class OpenVSIXRegistry {
8294
currentServiceURL: string,
8395
newServiceURL: string,
8496
currentItemURL: string,
85-
newItemURL: string
97+
newItemURL: string,
98+
currentExtensionUrlTemplate: string,
99+
newExtensionUrlTemplate: string
86100
): Promise<void> {
87101
const content = await fs.readFile(file);
88102
const newContent = content.replace(
89-
`extensionsGallery:{serviceUrl:"${currentServiceURL}",itemUrl:"${currentItemURL}"}`,
90-
`extensionsGallery:{serviceUrl:"${newServiceURL}",itemUrl:"${newItemURL}"}`
103+
`extensionsGallery:{serviceUrl:"${currentServiceURL}",itemUrl:"${currentItemURL}",extensionUrlTemplate:"${currentExtensionUrlTemplate}"}`,
104+
`extensionsGallery:{serviceUrl:"${newServiceURL}",itemUrl:"${newItemURL}",extensionUrlTemplate:"${newExtensionUrlTemplate}"}`
91105
);
92106
await fs.writeFile(file, newContent);
93107
}

launcher/src/product-json.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,31 @@ export class ProductJSON {
100100
gallery.itemUrl = url;
101101
}
102102

103+
getExtensionUrlTemplate(): string {
104+
const gallery = this.product.extensionsGallery;
105+
if (!gallery) {
106+
throw new Error('Failure to find .extensionsGallery.serviceUrl in product.json.');
107+
}
108+
109+
const template = gallery.extensionUrlTemplate;
110+
111+
if (!template) {
112+
throw new Error('Failure to find .extensionsGallery.extensionUrlTemplate in product.json.');
113+
}
114+
115+
return template;
116+
}
117+
118+
setExtensionUrlTemplate(template: string): void {
119+
let gallery = this.product.extensionsGallery;
120+
if (!gallery) {
121+
gallery = {};
122+
this.product.extensionsGallery = gallery;
123+
}
124+
125+
gallery.extensionUrlTemplate = template;
126+
}
127+
103128
getTrustedExtensionAuthAccess(): string[] | Record | undefined {
104129
return this.product.trustedExtensionAuthAccess;
105130
}

0 commit comments

Comments
 (0)