Skip to content

Commit

Permalink
Add components field to migrated settings. Guard against missing fiel…
Browse files Browse the repository at this point in the history
…d during component merge (microsoft#7674)

Co-authored-by: Dong Lei <donglei@microsoft.com>
Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
  • Loading branch information
3 people committed May 7, 2021
1 parent ee41c54 commit a84b3b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions Composer/packages/server/src/services/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ export class BotProjectService {
const newSettings: DialogSetting = {
...currentProject.settings,
runtimeSettings: {
components: [],
features: {
showTyping: originalProject.settings?.feature?.UseShowTypingMiddleware || false,
useInspection: originalProject.settings?.feature?.UseInspectionMiddleware || false,
Expand Down
14 changes: 9 additions & 5 deletions extensions/packageManager/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,6 @@ export default async (composer: IExtensionRegistration): Promise<void> => {

const installedComponents = await loadPackageAssets(mergeResults.components.filter(isAdaptiveComponent));
if (mergeResults) {
res.json({
success: true,
components: installedComponents,
});

let runtimeLanguage = 'c#';
if (
currentProject.settings.runtime.key === 'node-azurewebapp' ||
Expand All @@ -387,18 +382,27 @@ export default async (composer: IExtensionRegistration): Promise<void> => {
!currentProject.settings.runtimeSettings?.components?.find((p) => p.name === newlyInstalledPlugin.name)
) {
const newSettings = await currentProject.getEnvSettings();
// guard against missing settings keys
if (!newSettings.runtimeSettings) {
newSettings.runtimeSettings = {
components: [],
};
}
if (!newSettings.runtimeSettings.components) {
newSettings.runtimeSettings.components = [];
}
newSettings.runtimeSettings.components.push({
name: newlyInstalledPlugin.name,
settingsPrefix: newlyInstalledPlugin.name,
});
currentProject.updateEnvSettings(newSettings);
}
updateRecentlyUsed(installedComponents, runtimeLanguage);

res.json({
success: true,
components: installedComponents,
});
} else {
res.json({
success: false,
Expand Down

0 comments on commit a84b3b9

Please sign in to comment.