Skip to content

Commit

Permalink
feat: Copy skill manifests to static files (#2865)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurnford authored May 3, 2020
1 parent cab8656 commit 28b129a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
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 @@ -61,6 +61,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 @@ -123,6 +124,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 @@ -178,6 +183,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

0 comments on commit 28b129a

Please sign in to comment.