-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (53 loc) · 2.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const { program } = require('commander');
require('dotenv').config()
const Translator = require('./translator')
program.version('1.0.0');
program
.option('--all', 'Migrate everything')
.option('--products', 'Run the translator for products')
.option('--collections', 'Run the translator for collections')
.option('--articles', 'Run the translator for articles')
.option('--blogs', 'Run the translator for blogs')
.option('--collections', 'Run the translator for collections')
.option('--sections', 'Run the translator for sections')
.option('--pages', 'Run the translator for pages')
.option('--links', 'Run the translator for links (navigation)')
.option('-v, --verbosity', 'Verbosity level. Defaults to 4, as talkative as my MIL.')
.option('--shop', 'Shopify instance. ex: your-store')
.option('--key', 'Shopify API key')
.option('--password', 'Shopify API password')
.option('--locale', 'Locale to update/create')
.option('--langify', 'Langify ID to migrate. ex: ly123456')
.option('-v, --verbosity', 'Verbosity level. Defaults to 4, as talkative as my MIL.')
program.parse(process.argv);
const config = {
shop: program.shop || process.env.SHOPIFY_STORE ,
key: program.key || process.env.SHOPIFY_API_KEY,
password: program.password || process.env.SHOPIFY_API_PASSWORD,
locale: program.locale || process.env.SHOPIFY_LOCALE,
langifyId: program.langify || process.env.SHOPIFY_LANGIFY_ID,
verbosity: (program.verbosity && program.verbosity * 1)|| 4
}
const translator = new Translator(config)
const start = async () => {
if (program.all || program.pages) {
await translator.migratePages()
}
if (program.all || program.links) {
await translator.migrateLinks()
}
if (program.all || program.articles) {
await translator.migrateArticles()
}
if (program.all || program.products) {
await translator.migrateProducts()
}
if (program.all || program.sections) {
await translator.migrateSections()
}
if (program.all || program.collections) {
await translator.migrateSmartCollections()
await translator.migrateCustomCollections()
}
}
start()