Skip to content

Instantly share code, notes, and snippets.

@scottrippey
Created July 5, 2019 20:19
Show Gist options
  • Save scottrippey/a08305e64ffd5d88e807299697333edf to your computer and use it in GitHub Desktop.
Save scottrippey/a08305e64ffd5d88e807299697333edf to your computer and use it in GitHub Desktop.
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);
});
#!/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