Add support for customizing the extension install registry URL (#4503)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-12-17 10:28:59 -05:00
1 parent a711499bb6
commit 78678bdf2f
8 files changed
+208 -32

No files matched your search

@@ -306,6 +306,36 @@ const updateChannel: PreferenceDescription<string> = {
},
};
export enum ExtensionRegistryLocation {
DEFAULT = "default",
NPMRC = "npmrc",
CUSTOM = "custom",
}
export type ExtensionRegistry = {
location: ExtensionRegistryLocation.DEFAULT | ExtensionRegistryLocation.NPMRC;
customUrl?: undefined;
} | {
location: ExtensionRegistryLocation.CUSTOM,
customUrl: string;
};
export const defaultExtensionRegistryUrl = "https://registry.npmjs.org";
const extensionRegistryUrl: PreferenceDescription<ExtensionRegistry> = {
fromStore(val) {
return val ?? {
location: ExtensionRegistryLocation.DEFAULT,
};
},
toStore(val) {
if (val.location === ExtensionRegistryLocation.DEFAULT) {
return undefined;
}
return val;
},
};
type PreferencesModelType<field extends keyof typeof DESCRIPTORS> = typeof DESCRIPTORS[field] extends PreferenceDescription<infer T, any> ? T : never;
type UserStoreModelType<field extends keyof typeof DESCRIPTORS> = typeof DESCRIPTORS[field] extends PreferenceDescription<any, infer T> ? T : never;
@@ -335,6 +365,7 @@ export const DESCRIPTORS = {
editorConfiguration,
terminalCopyOnSelect,
updateChannel,
extensionRegistryUrl,
};
export const CONSTANTS = {