Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Scope local storage to package name and branch name (#54)
- Loading branch information
1 parent
49ea258
commit 0dc59d3
Showing
7 changed files
with
86 additions
and
12 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
cypress/plugins/ | ||
cypress/fixtures/ | ||
node_modules | ||
dist |
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
beforeEach(() => { | ||
beforeEach(async () => { | ||
cy.visit('http://localhost:9000'); | ||
indexedDB.deleteDatabase('playroom'); | ||
|
||
const win = await cy.window(); | ||
const { storageKey } = win.__playroomConfig__; | ||
indexedDB.deleteDatabase(storageKey); | ||
}); |
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 |
---|---|---|
@@ -1,15 +1,12 @@ | ||
const start = require('./start'); | ||
const build = require('./build'); | ||
const provideDefaultConfig = require('./provideDefaultConfig'); | ||
|
||
const provideDefaults = config => ({ | ||
port: 9000, | ||
openBrowser: true, | ||
...config | ||
}); | ||
module.exports = userConfig => { | ||
const config = provideDefaultConfig(userConfig); | ||
|
||
module.exports = config => { | ||
return { | ||
start: callback => start(provideDefaults(config), callback), | ||
build: callback => build(provideDefaults(config), callback) | ||
start: callback => start(config, callback), | ||
build: callback => build(config, callback) | ||
}; | ||
}; |
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,20 @@ | ||
const readPackage = require('read-pkg-up'); | ||
const currentGitBranch = require('current-git-branch'); | ||
|
||
const generateStorageKey = () => { | ||
const pkg = readPackage.sync(); | ||
const packageName = (pkg && pkg.pkg && pkg.pkg.name) || null; | ||
const branchName = currentGitBranch(); | ||
|
||
const packageLabel = packageName ? `package:${packageName}` : null; | ||
const branchLabel = branchName ? `branch:${branchName}` : null; | ||
|
||
return ['playroom', packageLabel, branchLabel].filter(Boolean).join('__'); | ||
}; | ||
|
||
module.exports = ({ storageKey, ...restConfig }) => ({ | ||
port: 9000, | ||
openBrowser: true, | ||
storageKey: storageKey || generateStorageKey(), | ||
...restConfig | ||
}); |
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