@gameroom/cli
Version:
A command line tool for Gameroom
25 lines (23 loc) • 1.11 kB
JavaScript
const cosmetic = require('cosmetic'),
{ models: { Address, Store } } = require('@gameroom/kit'),
{ grGreen, timeout } = require('../helpers'),
{ ShopifyV2 } = require('../models'),
{ config, memory, spinner } = require('../refs')
module.exports = async (options) => {
// store addresses
spinner.text = `getting ${grGreen('addresses')}`
const addresses = await Address.getAll({ filter: { key: 'addressable_type', value: 'Store' }})
spinner.info(`got ${addresses.length} ${grGreen('addresses')}`)
// shopify locations
spinner.text = `getting ${cosmetic.green('locations')}`
const locations = await ShopifyV2.Location.get()
spinner.info(`got ${locations.length} ${cosmetic.green('locations')}`)
// stores
spinner.text = `getting ${grGreen('stores')}`
const stores = await Store.getAll()
// get shopify location on
stores.map(i => i.shopify_id = locations.find(l => l.address1?.includes(addresses.find(a => a.addressable_id === i.id)?.street1.split(' ')[0]))?.id)
options.stores = stores
memory.stores = stores
spinner.info(`got ${stores.length} ${grGreen('stores')}`)
}