Skip to content

Commit

Permalink
Merge branch 'main' into sorgh/fd_view_dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
hatpick authored Nov 24, 2020
2 parents 76cd50f + 0907221 commit bb786b8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Composer/packages/server/src/models/bot/botProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ export class BotProject implements IBotProject {
luResource.forEach(({ id, isEmpty }) => {
const fileName = `${id}.lu`;
const f = this.files.get(fileName);
if (f && !isEmpty) {
if (f) {
luFiles.push(f);
}
});
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/server/src/models/bot/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const GENERATEDFOLDER = 'generated';
const SETTINGS = 'settings';
const INTERRUPTION = 'interruption';
const SAMPLE_SIZE_CONFIGURATION = 2;
const CrossTrainConfigName = 'cross-train.config';
const CrossTrainConfigName = 'cross-train.config.json';

export type SingleConfig = {
rootDialog: boolean;
Expand Down
39 changes: 28 additions & 11 deletions extensions/packageManager/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,15 @@ export default async (composer: IExtensionRegistration): Promise<void> => {
mergeErrors.push(msg);
};

if (currentProject.settings?.runtime?.customRuntime && currentProject.settings?.runtime?.path) {
const manifestFile = runtime.identifyManifest(currentProject.settings?.runtime?.path);


let runtimePath = currentProject.settings?.runtime?.path;
if (runtimePath && !path.isAbsolute(runtimePath)) {
runtimePath = path.resolve(currentProject.dir, runtimePath)
}

if (currentProject.settings?.runtime?.customRuntime && runtimePath) {
const manifestFile = runtime.identifyManifest(runtimePath);

const dryrun = new SchemaMerger(
[manifestFile],
Expand Down Expand Up @@ -118,16 +125,21 @@ export default async (composer: IExtensionRegistration): Promise<void> => {
mergeErrors.push(msg);
};

if (packageName && currentProject.settings?.runtime?.path) {
let runtimePath = currentProject.settings?.runtime?.path;
if (runtimePath && !path.isAbsolute(runtimePath)) {
runtimePath = path.resolve(currentProject.dir, runtimePath)
}

if (packageName && runtimePath) {
try {
// Call the runtime's component install mechanism.
const installOutput = await runtime.installComponent(
currentProject.settings?.runtime?.path || '',
runtimePath,
packageName,
version
);

const manifestFile = runtime.identifyManifest(currentProject.settings?.runtime?.path);
const manifestFile = runtime.identifyManifest(runtimePath);

// call do a dry run on the dialog merge
const dryrun = new SchemaMerger(
Expand Down Expand Up @@ -199,20 +211,20 @@ export default async (composer: IExtensionRegistration): Promise<void> => {
} catch (err) {
composer.log('Error in import', { message: err.message });
try {
await runtime.uninstallComponent(currentProject.settings.runtime.path, packageName);
await runtime.uninstallComponent(runtimePath, packageName);
} catch (err) {
composer.log('Error uninstalling', err);
}
// if packageName is in the github form <username/package> remove the first part, because otherwise the unisntall doesn't work
if (packageName.match(/.*\/.*/)) {
const [user, realPackageName] = packageName.split(/\//);
if (!user.match(/^@/)) {
await runtime.uninstallComponent(currentProject.settings.runtime.path, realPackageName);
await runtime.uninstallComponent(runtimePath, realPackageName);
}
}
res.status(500).json({ success: false, message: err.message });
}
} else if (!currentProject.settings?.runtime?.path) {
} else if (!runtimePath) {
res.status(500).json({ message: 'Please eject your runtime before installing a package.' });
} else {
res.status(500).json({ message: 'Please specify a package name or git url to import.' });
Expand All @@ -230,13 +242,18 @@ export default async (composer: IExtensionRegistration): Promise<void> => {
mergeErrors.push(msg);
};

let runtimePath = currentProject.settings?.runtime?.path;
if (runtimePath && !path.isAbsolute(runtimePath)) {
runtimePath = path.resolve(currentProject.dir, runtimePath)
}

// get URL or package name
const packageName = req.body.package;
if (packageName && currentProject.settings?.runtime?.path) {
if (packageName && runtimePath) {
try {
const output = await runtime.uninstallComponent(currentProject.settings.runtime.path, packageName);
const output = await runtime.uninstallComponent(runtimePath, packageName);

const manifestFile = runtime.identifyManifest(currentProject.settings?.runtime?.path);
const manifestFile = runtime.identifyManifest(runtimePath);

// call do a dry run on the dialog merge
const merger = new SchemaMerger(
Expand Down

0 comments on commit bb786b8

Please sign in to comment.