Created
July 5, 2019 20:19
-
-
Save scottrippey/a08305e64ffd5d88e807299697333edf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
async function main() { | |
// Do the thing: | |
console.log(` | |
This script copies settings and sign-in creds from prod to dev. | |
It should prompt you for your system creds (twice), to access the prod creds. | |
`); | |
await copyPassword('credentials', 'InVision Studio', 'InVision Studio (Dev)'); | |
await copyAppDataFolder('InVision Studio', 'InVision Studio (Dev)'); | |
console.log('Copied credentials successfully!'); | |
} | |
async function copyAppDataFolder(src, dest) { | |
const electron = require('electron'); | |
const fse = require('fs-extra'); | |
const appData = electron.app.getPath('appData'); | |
console.log(`Copying '${appData}/${src}' to '${dest}'...`); | |
await fse.rmdir(`${appData}/${dest}`).catch(err => null); | |
await fse.copy(`${appData}/${src}`, `${appData}/${dest}`); | |
} | |
async function copyPassword(key, source, dest) { | |
const keytar = require('keytar'); | |
console.log(`Copying '${key}' from '${source}' to '${dest}'...`); | |
const value = await keytar.getPassword(source, key); | |
await keytar.setPassword(dest, key, value); | |
} | |
main().then(() => { | |
process.exit(0); | |
}, (err) => { | |
console.error(err); | |
process.exit(1); | |
}); |
This file contains hidden or 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
#!/bin/bash | |
npx electron ./test-migration.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment