Skip to content

Commit

Permalink
Closes #2451 - add a step to copy shared boilerplate material into al…
Browse files Browse the repository at this point in the history
…l new projects.

this will include the provisioning script and a readme file
  • Loading branch information
benbrown committed Apr 29, 2020
1 parent fe192c6 commit ada8e71
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Composer/packages/server/assets/shared/README.md
@@ -0,0 +1,6 @@
This folder contains a Bot Project created with Bot Framework Composer.

The full documentation for Composer lives here:
https://github.com/microsoft/botframework-composer

To test this bot locally, open this folder in Composer, then click "Start Bot"
1 change: 1 addition & 0 deletions Composer/packages/server/assets/shared/scripts/test.js
@@ -0,0 +1 @@
console.log('hello world');
4 changes: 4 additions & 0 deletions Composer/packages/server/src/controllers/project.ts
Expand Up @@ -48,6 +48,10 @@ async function createProject(req: Request, res: Response) {
const newProjRef = await AssectService.manager.copyProjectTemplateTo(templateId, locationRef, user);
const id = await BotProjectService.openProject(newProjRef, user);
const currentProject = await BotProjectService.getProjectById(id, user);

// inject shared content into every new project. this comes from assets/shared
await AssectService.manager.copyBoilerplate(currentProject.dataDir, currentProject.fileStorage);

if (currentProject !== undefined) {
await currentProject.updateBotInfo(name, description);
if (schemaUrl) {
Expand Down
9 changes: 9 additions & 0 deletions Composer/packages/server/src/models/asset/assetManager.ts
Expand Up @@ -160,6 +160,15 @@ export class AssetManager {
return output;
}

// Copy material from the boilerplate into the project
// This is used to copy shared content into every new project
public async copyBoilerplate(dstDir: string, dstStorage: IFileStorage) {
const boilerplatePath = Path.join(this.assetsLibraryPath, 'shared');
if (await this.templateStorage.exists(boilerplatePath)) {
await copyDir(boilerplatePath, this.templateStorage, dstDir, dstStorage);
}
}

public async copyDataFilesTo(templateId: string, dstDir: string, dstStorage: IFileStorage) {
const template = find(this.projectTemplates, { id: templateId });
if (template === undefined || template.path === undefined) {
Expand Down

0 comments on commit ada8e71

Please sign in to comment.