diff --git a/extensions/packageManager/src/node/feeds/nuget/nugetFeed.ts b/extensions/packageManager/src/node/feeds/nuget/nugetFeed.ts index 98f8ed9d3b..87f41627e5 100644 --- a/extensions/packageManager/src/node/feeds/nuget/nugetFeed.ts +++ b/extensions/packageManager/src/node/feeds/nuget/nugetFeed.ts @@ -38,7 +38,7 @@ export class NuGetFeed implements IFeed { // Is the seed data a search result? Note that ideally we want to remove this codepath since we cannot // do paging or other more advanced operations. Since this path is very inflexible, also // ignores the query provided in the package query. - // Example url that ends up in this path: https://azuresearch-usnc.nuget.org/query?q=Tags:%22bf-component%22&prerelease=true + // Example url that ends up in this path: https://azuresearch-usnc.nuget.org/query?q=Tags:%22msbot-component%22&prerelease=true const searchResult = this.data as INuGetSearchResult; if (searchResult.data) { return this.asPackageDefinition(searchResult); diff --git a/extensions/packageManager/src/node/index.ts b/extensions/packageManager/src/node/index.ts index 919ba15321..791d9395a3 100644 --- a/extensions/packageManager/src/node/index.ts +++ b/extensions/packageManager/src/node/index.ts @@ -4,6 +4,7 @@ import * as path from 'path'; import axios from 'axios'; +import formatMessage from 'format-message'; import { IExtensionRegistration } from '@botframework-composer/types'; import { SchemaMerger } from '@microsoft/bf-dialog/lib/library/schemaMerger'; @@ -57,47 +58,50 @@ export default async (composer: IExtensionRegistration): Promise => { } }, getFeeds: async function (req, res) { - // read the list of sources from the config file. - let packageSources: IPackageSource[] = composer.store.read('feeds') as IPackageSource[]; - - // if no sources are in the config file, set the default list to our 1st party feed. - if (!packageSources) { - packageSources = [ - // TODO: Re-enable the NPM feed when we have a JS runtime - // { - // key: 'npm', - // text: 'npm', - // url: 'https://registry.npmjs.org/-/v1/search?text=keywords:bf-component&size=100&from=0', - // searchUrl: 'https://registry.npmjs.org/-/v1/search?text={{keyword}}+keywords:bf-component&size=100&from=0', - // readonly: true, - // }, - { - key: 'nuget', - text: 'nuget', - url: 'https://api.nuget.org/v3/index.json', - readonly: true, - defaultQuery: { - prerelease: true, - semVerLevel: '2.0.0', - query: 'microsoft.bot.components+tags:bf-component', - }, - type: PackageSourceType.NuGet, + // Read the list of sources from the config file. + const userStoredSources: IPackageSource[] = composer.store.read('feeds') as IPackageSource[]; + + const botComponentTag = 'msbot-component'; + + // Default sources + let packageSources: IPackageSource[] = [ + { + key: 'nuget', + text: formatMessage('nuget'), + url: 'https://api.nuget.org/v3/index.json', + readonly: true, + defaultQuery: { + prerelease: true, + semVerLevel: '2.0.0', + query: `microsoft.bot.components+tags:${botComponentTag}`, }, - { - key: 'nuget-community', - text: 'community packages', - url: 'https://api.nuget.org/v3/index.json', - defaultQuery: { - prerelease: true, - semVerLevel: '2.0.0', - query: 'tags:bf-component', - }, - type: PackageSourceType.NuGet, + type: PackageSourceType.NuGet, + }, + { + key: 'nuget-community', + text: formatMessage('community packages'), + url: 'https://api.nuget.org/v3/index.json', + readonly: true, + defaultQuery: { + prerelease: true, + semVerLevel: '2.0.0', + query: `tags:${botComponentTag}`, }, - ]; - composer.store.write('feeds', packageSources); + type: PackageSourceType.NuGet, + }, + ]; + + // If there are package sources stored in the user profile + if (userStoredSources) { + // Extract list of read-only sources + const readOnlyKeys = packageSources.map((s) => s.key); + + // Add user sources to the package sources, excluding modifications of the read-only ones + packageSources = packageSources.concat(userStoredSources.filter((s) => !readOnlyKeys.includes(s.key))); } + composer.store.write('feeds', packageSources); + res.json(packageSources); }, updateFeeds: async function (req, res) { @@ -154,7 +158,7 @@ export default async (composer: IExtensionRegistration): Promise => { const packageQuery: IPackageQuery = { prerelease: true, semVerLevel: '2.0.0', - query: 'tags:bf-component', + query: 'tags:msbot-component', }; const packages = await feed.getPackages(packageSource.defaultQuery ?? packageQuery);