Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Conversation

@liweitian
Copy link
Contributor

@liweitian liweitian commented Nov 25, 2019

Description

Allow user to set default path as an environment variable. If the path is invalid, we still set it to path.join(os.homedir(), 'Documents', 'Composer').

Did a merge operation on data.json and data.template.json if it already exists.

Task Item

Closes #1610
Closes #1363

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have functionally tested my change

Screenshots

Please include screenshots or gifs if your PR include UX changes.

@liweitian liweitian changed the title Liweitian/update default folder feat: support default path environment variable Nov 25, 2019
@github-actions
Copy link

Coverage Status

Coverage increased (+0.08%) to 39.918% when pulling 96b8348 on liweitian/updateDefaultFolder into 9e70664 on master.

@liweitian
Copy link
Contributor Author

liweitian commented Nov 26, 2019

@a-b-r-o-w-n I changed the condition in the migration. The previous one would only check whether the data.json contain the defaultPath. But we still need to set it if the defaultPath changed by user.

And I added the following code.
let folder = process.env.COMPOSER_BOTS_FOLDER;
if (folder && folder.endsWith(':')) {
folder = folder + '/';
}

The issue is quite odd here: if user set the defaultPath as D: we use fs.existsSync('D:') in many places to check whether the path is valid, and it will return true. However, Path.resolve('D:') will return the current folder D:\BotFramework-Composer\Composer\packages\server>, which means for path module D: is invalid. I feel the fs and path module are not designed consistent. I searched online but cannot find an elegant way to solve this. I checked our code in the FileSelector.tsx we have itemPath = itemPath[itemPath.length - 1] === ':' ? ${itemPath}/ : itemPath;

it can be reproduced by setting the COMPOSER_BOTS_FOLDER D: and do the migration. Go to localhost:3000, click New, Click next. The location there is not D: but D:\BotFramework-Composer\Composer\packages\server>

add interface for settings to catch this at compile time
@a-b-r-o-w-n a-b-r-o-w-n merged commit 6c8b9cf into master Nov 26, 2019
@a-b-r-o-w-n a-b-r-o-w-n deleted the liweitian/updateDefaultFolder branch November 26, 2019 19:22
@lei9444 lei9444 mentioned this pull request Nov 28, 2019
9 tasks
@a-b-r-o-w-n a-b-r-o-w-n mentioned this pull request Dec 11, 2019
@a-b-r-o-w-n a-b-r-o-w-n mentioned this pull request Dec 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants