-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support default path environment variable (#1652)
* save tmp code * save tmp code * save current path in data.json * initialize default path according to OS * use default path if current path does not work * fix bug about updating last accessed path * create default folder * handle comments * handle comments * fix lint error * fix test case * fix test case * merge data.json and data.template.json and support defautlpath environment variable * resolve default path * use warped path utility * remove console.log * fix bug * fix bug when user set default path as D: rather than D:/ * add debug logger * add COMPOSER_BOTS_FOLDER to env settings * resolve default path in settings * log all settings in debug mode * use default path from settings * move setting default bots folder to settings * run migrations on start up * use TestBots directory for e2e tests * create COMPOSER_BOTS_FOLDER if it doesn't exist * use debug log when creating new bots * fix bugs * fix issue accessing defaultFolder from development settings add interface for settings to catch this at compile time
- Loading branch information
1 parent
32ce909
commit 6c8b9cf
Showing
20 changed files
with
177 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ junit.xml | |
cypress/screenshots | ||
cypress/results | ||
cypress/videos | ||
|
||
TestBots/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import debug from 'debug'; | ||
|
||
export default debug('composer'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import os from 'os'; | ||
|
||
import { Path } from '../utility/path'; | ||
|
||
import { botsFolder } from './env'; | ||
|
||
export default { | ||
development: { | ||
botAdminEndpoint: 'http://localhost:3979', | ||
botEndpoint: 'http://localhost:3979', | ||
assetsLibray: Path.resolve('./assets'), | ||
runtimeFolder: Path.resolve('../../../BotProject/Templates'), | ||
botsFolder: botsFolder || Path.join(os.homedir(), 'Documents', 'Composer'), | ||
}, | ||
container: { | ||
botAdminEndpoint: 'http://botruntime:80', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
import get from 'lodash/get'; | ||
import set from 'lodash/set'; | ||
|
||
import log from '../logger'; | ||
import settings from '../settings'; | ||
|
||
interface Migration { | ||
/** | ||
* Migration label. Will be printed to the console in debug. | ||
* @example 'Update Designer to Composer' | ||
*/ | ||
name: string; | ||
/** | ||
* Use to check if a condition exists that requires migration. | ||
* @example data => data.name === 'Designer'; | ||
*/ | ||
condition: (data: any) => boolean; | ||
/** | ||
* Data transform to run if condition is met. | ||
* @example data => ({ ...data, name: 'Composer' }); | ||
*/ | ||
run: (data: any) => any; | ||
} | ||
|
||
const migrations: Migration[] = [ | ||
{ | ||
name: 'Add defaultPath', | ||
condition: data => get(data, 'storageConnections.0.defaultPath') !== settings.botsFolder, | ||
run: data => set(data, 'storageConnections[0].defaultPath', settings.botsFolder), | ||
}, | ||
]; | ||
|
||
export function runMigrations(initialData: any): any { | ||
const migrationsToRun: Migration[] = migrations.filter(m => m.condition(initialData)); | ||
if (migrationsToRun.length > 0) { | ||
log('migration: running migrations...'); | ||
|
||
const data = migrationsToRun.reduce((data, m, i) => { | ||
log('migration: %s (%d / %d)', m.name, i + 1, migrationsToRun.length); | ||
return m.run(data); | ||
}, initialData); | ||
|
||
log('migration: done!'); | ||
|
||
return data; | ||
} | ||
|
||
return initialData; | ||
} |
Oops, something went wrong.