Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Changes from all 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
54 changes: 44 additions & 10 deletions Composer/packages/server/src/models/bot/botProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export class BotProject {
}

const fileList: FileInfo[] = [];
const patterns = ['**/*.dialog', '**/*.lg', '**/*.lu', '**/*.schema'];
const patterns = ['**/*.dialog', '**/*.lg', '**/*.lu'];
for (const pattern of patterns) {
// load only from the data dir, otherwise may get "build" versions from
// deployment process
Expand All @@ -494,22 +494,56 @@ export class BotProject {

for (const filePath of paths.sort()) {
const realFilePath: string = Path.join(root, filePath);
// skip lg files for now
if ((await this.fileStorage.stat(realFilePath)).isFile) {
const content: string = await this.fileStorage.readFile(realFilePath);
fileList.push({
name: Path.basename(filePath),
content: content,
path: realFilePath,
relativePath: Path.relative(this.dir, realFilePath),
});
const fileInfo = await this._getFileInfo(realFilePath);
if (fileInfo) {
fileList.push(fileInfo);
}
}
}

const schemas = await this._getSchemas();
fileList.push(...schemas);

return fileList;
};

private _getSchemas = async (): Promise<FileInfo[]> => {
if (!(await this.exists())) {
throw new Error(`${this.dir} is not a valid path`);
}

const schemasDir = Path.join(this.dir, 'Schemas');

if (!(await this.fileStorage.exists(schemasDir))) {
debug('No schemas directory found.');
return [];
}

const schemas: FileInfo[] = [];
const paths = await this.fileStorage.glob('*.schema', schemasDir);

for (const path of paths) {
const fileInfo = await this._getFileInfo(Path.join(schemasDir, path));
if (fileInfo) {
schemas.push(fileInfo);
}
}

return schemas;
};

private _getFileInfo = async (path: string): Promise<FileInfo | undefined> => {
if ((await this.fileStorage.stat(path)).isFile) {
const content: string = await this.fileStorage.readFile(path);
return {
name: Path.basename(path),
content: content,
path: path,
relativePath: Path.relative(this.dir, path),
};
}
};

// check project stracture is valid or not, if not, try fix it.
private _checkProjectStructure = async () => {
const dialogs: DialogInfo[] = this.dialogs;
Expand Down