Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Copy skill manifests to static files #2865

Merged
merged 1 commit into from
May 3, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const actionType2ChangeType = {
[ActionTypes.UPDATE_LU]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Lu },
[ActionTypes.CREATE_LU]: { changeType: ChangeType.CREATE, fileExtension: FileExtensions.Lu },
[ActionTypes.REMOVE_LU]: { changeType: ChangeType.DELETE, fileExtension: FileExtensions.Lu },
[ActionTypes.CREATE_SKILL_MANIFEST]: { changeType: ChangeType.CREATE, fileType: FileExtensions.Manifest },
[ActionTypes.REMOVE_SKILL_MANIFEST]: { changeType: ChangeType.DELETE, fileType: FileExtensions.Manifest },
[ActionTypes.UPDATE_SKILL_MANIFEST]: { changeType: ChangeType.UPDATE, fileType: FileExtensions.Manifest },
[ActionTypes.CREATE_SKILL_MANIFEST]: { changeType: ChangeType.CREATE, fileExtension: FileExtensions.Manifest },
[ActionTypes.REMOVE_SKILL_MANIFEST]: { changeType: ChangeType.DELETE, fileExtension: FileExtensions.Manifest },
[ActionTypes.UPDATE_SKILL_MANIFEST]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Manifest },
};

class FilePersistence {
Expand Down
18 changes: 18 additions & 0 deletions Composer/plugins/localPublish/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class LocalPublisher implements PublishPlugin<PublishConfig> {
this.composer.log('Using managed runtime');
await this.initBot(botId);
await this.saveContent(botId, version, project.dataDir, user);
await this.saveSkillManifests(botId, project.dataDir);
} else if (!project.settings.runtime.path || !project.settings.runtime.command) {
return {
status: 400,
Expand Down Expand Up @@ -121,6 +122,10 @@ class LocalPublisher implements PublishPlugin<PublishConfig> {

private getHistoryDir = (botId: string) => path.resolve(this.getBotDir(botId), 'history');

private getManifestSrcDir = (srcDir: string) => path.resolve(srcDir, 'skill-manifests');

private getManifestDstDir = (botId: string) => path.resolve(this.getBotRuntimeDir(botId), 'wwwroot', 'skill-manifests');

private getDownloadPath = (botId: string, version: string) =>
path.resolve(this.getHistoryDir(botId), `${version}.zip`);

Expand Down Expand Up @@ -176,6 +181,19 @@ class LocalPublisher implements PublishPlugin<PublishConfig> {
await this.zipBot(dstPath, srcDir);
};

private saveSkillManifests = async (botId: string, srcDir: string) => {
const manifestSrcDir = this.getManifestSrcDir(srcDir);
const manifestDstDir = this.getManifestDstDir(botId);

if (await this.dirExist(manifestDstDir)) {
await rmDir(manifestDstDir);
}

if (await this.dirExist(manifestSrcDir)) {
this.copyDir(manifestSrcDir, manifestDstDir);
}
}

// start bot in current version
private setBot = async (botId: string, version: string, settings: any, project: any = undefined) => {
// get port, and stop previous bot if exist
Expand Down