-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
32 lines (27 loc) · 891 Bytes
/
index.ts
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
import { list } from './themesList'
import axios from 'axios'
import * as dotenv from 'dotenv'
dotenv.config()
const { API_KEY, PASSWORD, SHOP } = process.env
const delay = async (ms: number) => {
return new Promise((resolve) => setTimeout(resolve, ms))
}
const removeTheme = async (themeId: Number) => {
try {
await delay(200)
console.log('Removing theme: ', themeId)
const addr = `https://${API_KEY}:${PASSWORD}@${SHOP}/admin/api/2021-04/themes/${themeId}.json`
const data = await axios.delete(addr)
data.statusText === 'OK' && console.log('Theme removed: ', themeId)
} catch (error) {
console.error('Unable to remove theme: ', error)
}
}
const main = () => {
console.log('Starting removal of themes...')
list.forEach((id, index) => {
removeTheme(id)
})
console.log('Removal complete.')
}
main()