@shift-code/cli
Version:
Redeem Gearbox SHiFT codes automatically
27 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.migrateOldCache = migrateOldCache;
const api_1 = require("@shift-code/api");
const _1 = require(".");
const store_1 = require("./store");
async function migrateOldCache() {
if (await (0, _1.metaCacheExists)()) {
return;
}
const codes = await (0, store_1.loadContents)('', store_1.CACHE_FILE, []);
const session = await (0, store_1.loadContents)('', store_1.SESSION_FILE, {});
const user = await (0, api_1.account)(session)
.catch(() => null);
if (user) {
await (0, _1.saveMetaAccount)(user.id);
await (0, _1.saveMetaActiveAccount)(user.id);
await (0, _1.saveAccountSession)(user.id, session);
await (0, _1.saveAccount)(user.id, user);
await (0, _1.saveCodeCache)(user.id, codes);
}
await Promise.all([
(0, store_1.deleteStoreFile)('', store_1.SESSION_FILE),
(0, store_1.deleteStoreFile)('', store_1.CACHE_FILE)
]);
}
//# sourceMappingURL=migrate.js.map