Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Composer/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@bfc/extensions": "*",
"@bfc/indexers": "*",
"@bfc/shared": "*",
"@bfcomposer/bf-lu": "^1.1.8",
"@bfcomposer/bf-lu": "^1.2.0",
"@emotion/core": "^10.0.7",
"@reach/router": "^1.2.1",
"axios": "^0.18.0",
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/lib/indexers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@bfc/shared": "*",
"@bfcomposer/bf-lu": "^1.1.8",
"@bfcomposer/bf-lu": "^1.2.0",
"botbuilder-lg": "4.7.0-preview.93464",
"botframework-expressions": "4.7.0-preview.93464",
"lodash": "^4.17.15"
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@bfc/lg-languageserver": "*",
"@bfc/lu-languageserver": "*",
"@bfc/shared": "*",
"@bfcomposer/lubuild": "1.1.2-preview",
"@bfcomposer/bf-lu": "^1.2.0",
"archiver": "^3.0.0",
"axios": "^0.18.0",
"azure-storage": "^2.10.3",
Expand Down
66 changes: 34 additions & 32 deletions Composer/packages/server/src/models/bot/luPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Licensed under the MIT License.

import isEqual from 'lodash/isEqual';
import { runBuild } from '@bfcomposer/lubuild';
import { luBuild } from '@bfcomposer/bf-lu/lib/parser/luBuild';
import { LuFile } from '@bfc/indexers';

import { Path } from './../../utility/path';
import { IFileStorage } from './../storage/interface';
import { ILuisConfig, LuisStatus, FileUpdateType } from './interface';

const GENERATEDFOLDER = 'ComposerDialogs/generated';
const LU_STATUS_FILE = 'luis.status.json';
const DEFAULT_STATUS = {
Expand Down Expand Up @@ -81,23 +82,24 @@ export class LuPublisher {

public publish = async (luFiles: LuFile[]) => {
const config = this._getConfig(luFiles);
if (config.models.length === 0) {
throw new Error('No luis file exist');
}
// if (config.models.length === 0) {
Comment thread
lei9444 marked this conversation as resolved.
Outdated
// throw new Error('No luis file exist');
// }
const curTime = Date.now();
try {
await runBuild(config);
const builder = new luBuild.Builder(console);
await builder.build(config);

// update pubish status after sucessfully published
luFiles.forEach(f => {
this.status[f.relativePath].lastPublishTime = curTime;
});
await this.saveStatus();
} catch (error) {
throw new Error(error?.body?.error?.message ?? 'Error publishing to LUIS.');
throw new Error(error.body?.error?.message || error.message || 'Error publishing to LUIS.');
}

await this._copyDialogsToTargetFolder(config);
//await this._copyDialogsToTargetFolder(config);
};

public getUnpublisedFiles = (files: LuFile[]) => {
Expand Down Expand Up @@ -147,33 +149,33 @@ export class LuPublisher {
}
}

private _copyDialogsToTargetFolder = async (config: any) => {
const defaultLanguage = config.defaultLanguage;
await config.models.forEach(async (filePath: string) => {
const baseName = Path.basename(filePath, '.lu');
const rootPath = Path.dirname(filePath);
const currentPath = `${filePath}.dialog`;
const targetPath = Path.join(this.generatedFolderPath, `${baseName}.lu.dialog`);
const currentVariantPath = Path.join(rootPath, `${baseName}.${defaultLanguage}.lu.dialog`);
const targetVariantPath = Path.join(this.generatedFolderPath, `${baseName}.${defaultLanguage}.lu.dialog`);
await this.storage.copyFile(currentPath, targetPath);
await this.storage.copyFile(currentVariantPath, targetVariantPath);
await this.storage.removeFile(currentPath);
await this.storage.removeFile(currentVariantPath);
});
};
// private _copyDialogsToTargetFolder = async (config: any) => {
// const defaultLanguage = config.defaultLanguage;
// await config.models.forEach(async (filePath: string) => {
// const baseName = Path.basename(filePath, '.lu');
// const rootPath = Path.dirname(filePath);
// const currentPath = `${filePath}.dialog`;
// const targetPath = Path.join(this.generatedFolderPath, `${baseName}.lu.dialog`);
// const currentVariantPath = Path.join(rootPath, `${baseName}.${defaultLanguage}.lu.dialog`);
// const targetVariantPath = Path.join(this.generatedFolderPath, `${baseName}.${defaultLanguage}.lu.dialog`);
// await this.storage.copyFile(currentPath, targetPath);
// await this.storage.copyFile(currentVariantPath, targetVariantPath);
// await this.storage.removeFile(currentPath);
// await this.storage.removeFile(currentVariantPath);
// });
// };

private _getConfig = (luFiles: LuFile[]) => {
const luConfig: any = { ...this.config };
luConfig.models = [];
luConfig.autodelete = true;
luConfig.dialogs = true;
luConfig.force = false;
luConfig.folder = this.generatedFolderPath;
luFiles.forEach(file => {
luConfig.models.push(Path.resolve(this.botDir, file.relativePath));
});

const luConfig = {
out: this.generatedFolderPath,
in: this.botDir,
dialog: true,
force: false,
authoringKey: this.config?.authoringKey,
region: this.config?.authoringRegion,
botName: this.config?.name,
suffix: this.config?.environment,
};
return luConfig;
};
}
11 changes: 11 additions & 0 deletions Composer/packages/server/src/types/bf-lu.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

declare module '@bfcomposer/bf-lu/lib/parser/luBuild' {
namespace luBuild {
class Builder {
constructor(logger);
build(flags: any): any;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@microsoft/bf-cli-command": "https://botbuilder.myget.org/F/botbuilder-declarative/npm/@microsoft/bf-cli-command/-/@microsoft/bf-cli-command-1.0.0.tgz",
"@bfcomposer/bf-lu": "https://botbuilder.myget.org/F/botbuilder-declarative/npm/@bfcomposer/bf-lu/-/@bfcomposer/bf-lu-1.1.8.tgz",
"@bfcomposer/bf-lu": "^1.2.0",
"@types/node": "^12.0.4",
"express": "^4.15.2",
"monaco-editor-core": "^0.17.0",
Expand Down
Loading