mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
Remove stale code & old migration (#176828)
* Remove stale code & old migration * Removes browserNlsMetadataPath everywhere which was the old attempt to localize the web * Removes an old migration * js file
This commit is contained in:
committed by
GitHub
parent
92c68760f2
commit
bc392ac9ff
File diff suppressed because one or more lines are too long
@@ -416,7 +416,6 @@ export interface IScannedBuiltinExtension {
|
||||
extensionPath: string;
|
||||
packageJSON: any;
|
||||
packageNLS?: any;
|
||||
browserNlsMetadataPath?: string;
|
||||
readmePath?: string;
|
||||
changelogPath?: string;
|
||||
}
|
||||
@@ -441,13 +440,6 @@ export function scanBuiltinExtensions(extensionsRoot: string, exclude: string[]
|
||||
const children = fs.readdirSync(path.join(extensionsRoot, extensionFolder));
|
||||
const packageNLSPath = children.filter(child => child === 'package.nls.json')[0];
|
||||
const packageNLS = packageNLSPath ? JSON.parse(fs.readFileSync(path.join(extensionsRoot, extensionFolder, packageNLSPath)).toString()) : undefined;
|
||||
let browserNlsMetadataPath: string | undefined;
|
||||
if (packageJSON.browser) {
|
||||
const browserEntrypointFolderPath = path.join(extensionFolder, path.dirname(packageJSON.browser));
|
||||
if (fs.existsSync(path.join(extensionsRoot, browserEntrypointFolderPath, 'nls.metadata.json'))) {
|
||||
browserNlsMetadataPath = path.join(browserEntrypointFolderPath, 'nls.metadata.json');
|
||||
}
|
||||
}
|
||||
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
|
||||
const changelog = children.filter(child => /^changelog(\.txt|\.md|)$/i.test(child))[0];
|
||||
|
||||
@@ -455,7 +447,6 @@ export function scanBuiltinExtensions(extensionsRoot: string, exclude: string[]
|
||||
extensionPath: extensionFolder,
|
||||
packageJSON,
|
||||
packageNLS,
|
||||
browserNlsMetadataPath,
|
||||
readmePath: readme ? path.join(extensionFolder, readme) : undefined,
|
||||
changelogPath: changelog ? path.join(extensionFolder, changelog) : undefined,
|
||||
});
|
||||
|
||||
@@ -321,7 +321,6 @@ export interface IExtension {
|
||||
readonly changelogUrl?: URI;
|
||||
readonly isValid: boolean;
|
||||
readonly validations: readonly [Severity, string][];
|
||||
readonly browserNlsBundleUris?: { [language: string]: URI };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,7 +453,6 @@ export interface IRelaxedExtensionDescription extends IRelaxedExtensionManifest
|
||||
isUserBuiltin: boolean;
|
||||
isUnderDevelopment: boolean;
|
||||
extensionLocation: URI;
|
||||
browserNlsBundleUris?: { [language: string]: URI };
|
||||
}
|
||||
|
||||
export type IExtensionDescription = Readonly<IRelaxedExtensionDescription>;
|
||||
|
||||
@@ -276,18 +276,10 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
|
||||
|
||||
public async getExtension(extensionId: string): Promise<IExtensionDescription | undefined> {
|
||||
const ext = await this._mainThreadExtensionsProxy.$getExtension(extensionId);
|
||||
let browserNlsBundleUris: { [language: string]: URI } | undefined;
|
||||
if (ext?.browserNlsBundleUris) {
|
||||
browserNlsBundleUris = {};
|
||||
for (const language of Object.keys(ext.browserNlsBundleUris)) {
|
||||
browserNlsBundleUris[language] = URI.revive(ext.browserNlsBundleUris[language]);
|
||||
}
|
||||
}
|
||||
return ext && {
|
||||
...ext,
|
||||
identifier: new ExtensionIdentifier(ext.identifier.value),
|
||||
extensionLocation: URI.revive(ext.extensionLocation),
|
||||
browserNlsBundleUris
|
||||
extensionLocation: URI.revive(ext.extensionLocation)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -184,11 +184,6 @@ export class ExtensionHostMain {
|
||||
private static _transform(initData: IExtensionHostInitData, rpcProtocol: RPCProtocol): IExtensionHostInitData {
|
||||
initData.allExtensions.forEach((ext) => {
|
||||
(<Mutable<IRelaxedExtensionDescription>>ext).extensionLocation = URI.revive(rpcProtocol.transformIncomingURIs(ext.extensionLocation));
|
||||
const browserNlsBundleUris: { [language: string]: URI } = {};
|
||||
if (ext.browserNlsBundleUris) {
|
||||
Object.keys(ext.browserNlsBundleUris).forEach(lang => browserNlsBundleUris[lang] = URI.revive(rpcProtocol.transformIncomingURIs(ext.browserNlsBundleUris![lang])));
|
||||
(<Mutable<IRelaxedExtensionDescription>>ext).browserNlsBundleUris = browserNlsBundleUris;
|
||||
}
|
||||
});
|
||||
initData.environment.appRoot = URI.revive(rpcProtocol.transformIncomingURIs(initData.environment.appRoot));
|
||||
const extDevLocs = initData.environment.extensionDevelopmentLocationURI;
|
||||
|
||||
@@ -20,7 +20,6 @@ interface IBundledExtension {
|
||||
extensionPath: string;
|
||||
packageJSON: IExtensionManifest;
|
||||
packageNLS?: any;
|
||||
browserNlsMetadataPath?: string;
|
||||
readmePath?: string;
|
||||
changelogPath?: string;
|
||||
}
|
||||
@@ -67,19 +66,11 @@ export class BuiltinExtensionsScannerService implements IBuiltinExtensionsScanne
|
||||
|
||||
this.builtinExtensionsPromises = bundledExtensions.map(async e => {
|
||||
const id = getGalleryExtensionId(e.packageJSON.publisher, e.packageJSON.name);
|
||||
const browserNlsBundleUris: { [language: string]: URI } = {};
|
||||
if (e.browserNlsMetadataPath) {
|
||||
if (this.nlsUrl) {
|
||||
browserNlsBundleUris[Language.value()] = uriIdentityService.extUri.joinPath(this.nlsUrl, id, 'main');
|
||||
}
|
||||
browserNlsBundleUris.en = uriIdentityService.extUri.resolvePath(builtinExtensionsServiceUrl!, e.browserNlsMetadataPath);
|
||||
}
|
||||
return {
|
||||
identifier: { id },
|
||||
location: uriIdentityService.extUri.joinPath(builtinExtensionsServiceUrl!, e.extensionPath),
|
||||
type: ExtensionType.System,
|
||||
isBuiltin: true,
|
||||
browserNlsBundleUris,
|
||||
manifest: e.packageNLS ? await this.localizeManifest(id, e.packageJSON, e.packageNLS) : e.packageJSON,
|
||||
readmeUrl: e.readmePath ? uriIdentityService.extUri.joinPath(builtinExtensionsServiceUrl!, e.readmePath) : undefined,
|
||||
changelogUrl: e.changelogPath ? uriIdentityService.extUri.joinPath(builtinExtensionsServiceUrl!, e.changelogPath) : undefined,
|
||||
|
||||
@@ -79,7 +79,6 @@ interface IWebExtension {
|
||||
// deprecated in favor of packageNLSUris & fallbackPackageNLSUri
|
||||
packageNLSUri?: URI;
|
||||
packageNLSUris?: Map<string, URI>;
|
||||
bundleNLSUris?: Map<string, URI>;
|
||||
fallbackPackageNLSUri?: URI;
|
||||
defaultManifestTranslations?: ITranslations | null;
|
||||
metadata?: Metadata;
|
||||
@@ -441,7 +440,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
|
||||
}
|
||||
|
||||
async addExtension(location: URI, metadata: Metadata, profileLocation: URI): Promise<IScannedExtension> {
|
||||
const webExtension = await this.toWebExtension(location, undefined, undefined, undefined, undefined, undefined, undefined, metadata);
|
||||
const webExtension = await this.toWebExtension(location, undefined, undefined, undefined, undefined, undefined, metadata);
|
||||
const extension = await this.toScannedExtension(webExtension, false);
|
||||
await this.addToInstalledExtensions([webExtension], profileLocation);
|
||||
return extension;
|
||||
@@ -569,7 +568,6 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
|
||||
extensionLocation = galleryExtension.properties.targetPlatform === TargetPlatform.WEB ? extensionLocation.with({ query: `${extensionLocation.query ? `${extensionLocation.query}&` : ''}target=${galleryExtension.properties.targetPlatform}` }) : extensionLocation;
|
||||
const extensionResources = await this.listExtensionResources(extensionLocation);
|
||||
const packageNLSResources = this.getPackageNLSResourceMapFromResources(extensionResources);
|
||||
const bundleNLSResources = this.getBundleNLSResourceMapFromResources(extensionResources);
|
||||
|
||||
// The fallback, in English, will fill in any gaps missing in the localized file.
|
||||
const fallbackPackageNLSResource = extensionResources.find(e => basename(e) === 'package.nls.json');
|
||||
@@ -577,7 +575,6 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
|
||||
extensionLocation,
|
||||
galleryExtension.identifier,
|
||||
packageNLSResources,
|
||||
bundleNLSResources,
|
||||
fallbackPackageNLSResource ? URI.parse(fallbackPackageNLSResource) : null,
|
||||
galleryExtension.assets.readme ? URI.parse(galleryExtension.assets.readme.uri) : undefined,
|
||||
galleryExtension.assets.changelog ? URI.parse(galleryExtension.assets.changelog.uri) : undefined,
|
||||
@@ -596,22 +593,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
|
||||
return packageNLSResources;
|
||||
}
|
||||
|
||||
private getBundleNLSResourceMapFromResources(extensionResources: string[]): Map<string, URI> {
|
||||
const bundleNLSResources = new Map<string, URI>();
|
||||
extensionResources.forEach(e => {
|
||||
// Grab all nls.bundle.{language}.json files
|
||||
const regexResult = /nls\.bundle\.([\w-]+)\.json/.exec(basename(e));
|
||||
if (regexResult?.[1]) {
|
||||
bundleNLSResources.set(regexResult[1], URI.parse(e));
|
||||
}
|
||||
if (basename(e) === 'nls.metadata.json') {
|
||||
bundleNLSResources.set('en', URI.parse(e));
|
||||
}
|
||||
});
|
||||
return bundleNLSResources;
|
||||
}
|
||||
|
||||
private async toWebExtension(extensionLocation: URI, identifier?: IExtensionIdentifier, packageNLSUris?: Map<string, URI>, bundleNLSUris?: Map<string, URI>, fallbackPackageNLSUri?: URI | null, readmeUri?: URI, changelogUri?: URI, metadata?: Metadata): Promise<IWebExtension> {
|
||||
private async toWebExtension(extensionLocation: URI, identifier?: IExtensionIdentifier, packageNLSUris?: Map<string, URI>, fallbackPackageNLSUri?: URI | null, readmeUri?: URI, changelogUri?: URI, metadata?: Metadata): Promise<IWebExtension> {
|
||||
let manifest: IExtensionManifest;
|
||||
try {
|
||||
manifest = await this.getExtensionManifest(extensionLocation);
|
||||
@@ -633,21 +615,6 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
|
||||
}
|
||||
const defaultManifestTranslations: ITranslations | null | undefined = fallbackPackageNLSUri ? await this.getTranslations(fallbackPackageNLSUri) : null;
|
||||
|
||||
if (bundleNLSUris === undefined && manifest.browser) {
|
||||
const englishStringsUri = joinPath(
|
||||
this.uriIdentityService.extUri.dirname(joinPath(extensionLocation, manifest.browser)),
|
||||
'nls.metadata.json'
|
||||
);
|
||||
|
||||
try {
|
||||
await this.extensionResourceLoaderService.readExtensionResource(englishStringsUri);
|
||||
bundleNLSUris = new Map();
|
||||
bundleNLSUris.set('en', englishStringsUri);
|
||||
} catch (error) {
|
||||
// noop if file doesn't exist
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
identifier: { id: getGalleryExtensionId(manifest.publisher, manifest.name), uuid: identifier?.uuid },
|
||||
version: manifest.version,
|
||||
@@ -656,7 +623,6 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
|
||||
readmeUri,
|
||||
changelogUri,
|
||||
packageNLSUris,
|
||||
bundleNLSUris,
|
||||
fallbackPackageNLSUri: fallbackPackageNLSUri ? fallbackPackageNLSUri : undefined,
|
||||
defaultManifestTranslations,
|
||||
metadata,
|
||||
@@ -705,20 +671,12 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
|
||||
}
|
||||
}
|
||||
|
||||
const browserNlsBundleUris: { [language: string]: URI } = {};
|
||||
if (webExtension.bundleNLSUris) {
|
||||
for (const [language, uri] of webExtension.bundleNLSUris) {
|
||||
browserNlsBundleUris[language] = uri;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
identifier: { id: webExtension.identifier.id, uuid: webExtension.identifier.uuid || uuid },
|
||||
location: webExtension.location,
|
||||
manifest,
|
||||
type,
|
||||
isBuiltin,
|
||||
browserNlsBundleUris,
|
||||
readmeUrl: webExtension.readmeUri,
|
||||
changelogUrl: webExtension.changelogUri,
|
||||
metadata: webExtension.metadata,
|
||||
@@ -749,29 +707,6 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
|
||||
return manifest;
|
||||
}
|
||||
|
||||
// TODO: @TylerLeonhardt/@Sandy081: Delete after 6 months
|
||||
private _migratePackageNLSUrisPromise: Promise<void> | undefined;
|
||||
private migratePackageNLSUris(): Promise<void> {
|
||||
if (!this._migratePackageNLSUrisPromise) {
|
||||
this._migratePackageNLSUrisPromise = (async () => {
|
||||
const webExtensions = await this.withWebExtensions(this.userDataProfilesService.defaultProfile.extensionsResource);
|
||||
if (webExtensions.some(e => !e.packageNLSUris && e.packageNLSUri)) {
|
||||
const migratedExtensions = await Promise.all(webExtensions.map(async e => {
|
||||
if (!e.packageNLSUris && e.packageNLSUri) {
|
||||
e.fallbackPackageNLSUri = e.packageNLSUri;
|
||||
const extensionResources = await this.listExtensionResources(e.location);
|
||||
e.packageNLSUris = this.getPackageNLSResourceMapFromResources(extensionResources);
|
||||
e.packageNLSUri = undefined;
|
||||
}
|
||||
return e;
|
||||
}));
|
||||
await this.withWebExtensions(this.userDataProfilesService.defaultProfile.extensionsResource, () => migratedExtensions);
|
||||
}
|
||||
})();
|
||||
}
|
||||
return this._migratePackageNLSUrisPromise;
|
||||
}
|
||||
|
||||
private async getExtensionManifest(location: URI): Promise<IExtensionManifest> {
|
||||
const url = joinPath(location, 'package.json');
|
||||
const content = await this.extensionResourceLoaderService.readExtensionResource(url);
|
||||
@@ -789,9 +724,6 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
|
||||
}
|
||||
|
||||
private async readInstalledExtensions(profileLocation: URI): Promise<IWebExtension[]> {
|
||||
if (this.uriIdentityService.extUri.isEqual(profileLocation, this.userDataProfilesService.defaultProfile.extensionsResource)) {
|
||||
await this.migratePackageNLSUris();
|
||||
}
|
||||
return this.withWebExtensions(profileLocation);
|
||||
}
|
||||
|
||||
|
||||
@@ -480,8 +480,7 @@ export function toExtensionDescription(extension: IExtension, isUnderDevelopment
|
||||
extensionLocation: extension.location,
|
||||
...extension.manifest,
|
||||
uuid: extension.identifier.uuid,
|
||||
targetPlatform: extension.targetPlatform,
|
||||
browserNlsBundleUris: extension.browserNlsBundleUris
|
||||
targetPlatform: extension.targetPlatform
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user