supporting sql built-in extensions (#890)

* supporting sql built-in extensions
This commit is contained in:
Leila Lali
2018-03-12 11:02:47 -07:00
committed by GitHub
parent e79e3bdf1d
commit 66f39fd3eb
5 changed files with 74 additions and 6 deletions

View File

@@ -67,6 +67,13 @@ const excludedExtensions = [
'vscode-colorize-tests'
];
// {{SQL CARBON EDIT}}
const vsce = require('vsce');
const sqlBuiltInExtensions = [
// Add SQL built-in extensions here.
// the extension will be excluded from SQLOps package and will have separate vsix packages
];
const vscodeEntryPoints = _.flatten([
buildfile.entrypoint('vs/workbench/workbench.main'),
buildfile.base,
@@ -242,6 +249,26 @@ function computeChecksum(filename) {
return hash;
}
function packageBuiltInExtensions() {
const sqlBuiltInLocalExtensionDescriptions = glob.sync('extensions/*/package.json')
.map(manifestPath => {
const extensionPath = path.dirname(path.join(root, manifestPath));
const extensionName = path.basename(extensionPath);
return { name: extensionName, path: extensionPath };
})
.filter(({ name }) => excludedExtensions.indexOf(name) === -1)
.filter(({ name }) => builtInExtensions.every(b => b.name !== name))
.filter(({ name }) => sqlBuiltInExtensions.indexOf(name) >= 0);
sqlBuiltInLocalExtensionDescriptions.forEach(element => {
const packagePath = path.join(path.dirname(root), element.name + '.vsix');
console.info('Creating vsix for ' + element.path + ' result:' + packagePath);
vsce.createVSIX({
cwd: element.path,
packagePath: packagePath
});
});
}
function packageTask(platform, arch, opts) {
opts = opts || {};
@@ -271,7 +298,10 @@ function packageTask(platform, arch, opts) {
return { name: extensionName, path: extensionPath };
})
.filter(({ name }) => excludedExtensions.indexOf(name) === -1)
.filter(({ name }) => builtInExtensions.every(b => b.name !== name));
.filter(({ name }) => builtInExtensions.every(b => b.name !== name))
// {{SQL CARBON EDIT}}
.filter(({ name }) => sqlBuiltInExtensions.indexOf(name) === -1);
packageBuiltInExtensions();
const localExtensions = es.merge(...localExtensionDescriptions.map(extension => {
const nlsFilter = filter('**/*.nls.json', { restore: true });

View File

@@ -32,7 +32,6 @@
"extensionsGallery": {
"serviceUrl":"https://raw.githubusercontent.com/Microsoft/sqlopsstudio/release/extensions/extensionsGallery.json"
},
"extensionTips": {
"TestExtension": "{**/*.*}"
}
"recommendedExtensions": [
]
}

View File

@@ -156,6 +156,8 @@ class Query {
get sortBy(): number { return this.state.sortBy; }
get sortOrder(): number { return this.state.sortOrder; }
get flags(): number { return this.state.flags; }
// {{SQL CARBON EDIT}}
get criteria(): ICriterium[] { return this.state.criteria ? this.state.criteria : []; }
withPage(pageNumber: number, pageSize: number = this.state.pageSize): Query {
return new Query(assign({}, this.state, { pageNumber, pageSize }));
@@ -439,6 +441,30 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
});
}
// {{SQL CARBON EDIT}}
/**
* The result of querying the gallery returns all the extensions because it's only reading a static file.
* So this method should apply all the filters and return the actual result
* @param query
* @param galleryExtensions
*/
private createQueryResult(query: Query, galleryExtensions: IRawGalleryExtension[]): { galleryExtensions: IRawGalleryExtension[], total: number; } {
let filteredExtensions = galleryExtensions;
if (query.criteria) {
const ids = query.criteria.filter(x => x.filterType === FilterType.ExtensionId).map(v => v.value.toLocaleLowerCase());
if (ids && ids.length > 0) {
filteredExtensions = filteredExtensions.filter(e => e.extensionId && ids.includes(e.extensionId.toLocaleLowerCase()));
}
const names = query.criteria.filter(x => x.filterType === FilterType.ExtensionName).map(v => v.value.toLocaleLowerCase());
if (names && names.length > 0) {
filteredExtensions = filteredExtensions.filter(e => e.extensionName && e.publisher.publisherName && names.includes(`${e.publisher.publisherName.toLocaleLowerCase()}.${e.extensionName.toLocaleLowerCase()}`));
}
}
let actualTotal = filteredExtensions.length;
return { galleryExtensions: filteredExtensions, total: actualTotal };
}
private queryGallery(query: Query): TPromise<{ galleryExtensions: IRawGalleryExtension[], total: number; }> {
return this.commonHeadersPromise.then(commonHeaders => {
const data = JSON.stringify(query.raw);
@@ -467,7 +493,10 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
const resultCount = r.resultMetadata && r.resultMetadata.filter(m => m.metadataType === 'ResultCount')[0];
const total = resultCount && resultCount.metadataItems.filter(i => i.name === 'TotalCount')[0].count || 0;
return { galleryExtensions, total };
// {{SQL CARBON EDIT}}
let filteredExtensionsResult = this.createQueryResult(query, galleryExtensions);
return { galleryExtensions: filteredExtensionsResult.galleryExtensions, total: filteredExtensionsResult.total };
});
});
});

View File

@@ -28,6 +28,8 @@ export interface IProductConfiguration {
controlUrl: string;
};
extensionTips: { [id: string]: string; };
// {{SQL CARBON EDIT}}
recommendedExtensions: string[];
extensionImportantTips: { [id: string]: { name: string; pattern: string; }; };
exeBasedExtensionTips: { [id: string]: any; };
extensionKeywords: { [extension: string]: string[]; };

View File

@@ -41,6 +41,8 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
_serviceBrand: any;
private _fileBasedRecommendations: { [id: string]: number; } = Object.create(null);
// {{SQL CARBON EDIT}}
private _recommendations: string[] = Object.create(null);
private _exeBasedRecommendations: { [id: string]: string; } = Object.create(null);
private _availableRecommendations: { [pattern: string]: string[] } = Object.create(null);
private importantRecommendations: { [id: string]: { name: string; pattern: string; } } = Object.create(null);
@@ -83,6 +85,8 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
let output: { [id: string]: string; } = Object.create(null);
Object.keys(this._fileBasedRecommendations).forEach(x => output[x.toLowerCase()] = localize('fileBasedRecommendation', "This extension is recommended based on the files you recently opened."));
this._allWorkspaceRecommendedExtensions.forEach(x => output[x.toLowerCase()] = localize('workspaceRecommendation', "This extension is recommended by users of the current workspace."));
// {{SQL CARBON EDIT}}
this._recommendations.forEach(x => output[x.toLowerCase()] = localize('defaultRecommendations', "This extension is recommended by Sql Ops Studio."));
forEach(this._exeBasedRecommendations, entry => output[entry.key.toLowerCase()] = localize('exeBasedRecommendation', "This extension is recommended because you have {0} installed.", entry.value));
return output;
}
@@ -150,7 +154,9 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
}
getOtherRecommendations(): string[] {
return Object.keys(this._exeBasedRecommendations);
// {{SQL CARBON EDIT}}
let recommendations = Object.keys(this._exeBasedRecommendations);
return recommendations.concat(this._recommendations);
}
@@ -161,6 +167,8 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
private _suggestTips() {
const extensionTips = product.extensionTips;
// {{SQL CARBON EDIT}}
this._recommendations = product.recommendedExtensions;
if (!extensionTips) {
return;
}