1
1
import axios , { AxiosInstance } from 'axios'
2
+ import chalk from 'chalk'
2
3
import FormData from 'form-data'
3
4
import { createReadStream , existsSync , readdirSync , readFileSync } from 'fs'
4
5
import fs from 'fs-extra'
@@ -14,19 +15,21 @@ export interface WebOptions {
14
15
}
15
16
16
17
export const defaultWebDir = 'web'
17
- export const defaultApiUrl = 'https://pack .macarena.ceo/api'
18
+ export const defaultApiUrl = 'https://packs .macarena.ceo/api'
18
19
19
20
export default class WebService {
20
21
private readonly api : AxiosInstance
21
22
private readonly dir : string
23
+ private readonly baseUrl : string
22
24
23
- constructor ( private readonly options : Readonly < WebOptions > ) {
25
+ constructor ( options : Readonly < WebOptions > ) {
24
26
if ( ! options . webToken ) throw new Error ( 'Web Token missing' )
25
27
26
28
this . dir = options . webDir ?? defaultWebDir
29
+ this . baseUrl = options . apiUrl ?? defaultApiUrl
27
30
28
31
this . api = axios . create ( {
29
- baseURL : options . apiUrl ?? defaultApiUrl ,
32
+ baseURL : this . baseUrl ,
30
33
headers : {
31
34
'Content-Type' : 'application/json' ,
32
35
Authorization : `Bearer ${ options . webToken } ` ,
@@ -40,7 +43,7 @@ export default class WebService {
40
43
}
41
44
42
45
async updateWeb ( ) {
43
- console . group ( ' Updating web' )
46
+ console . group ( ` Updating web at ${ chalk . underline ( this . baseUrl ) } ` )
44
47
45
48
await Promise . all ( [ ...this . updatePages ( ) , this . updateData ( ) , this . updateAssets ( ) ] )
46
49
0 commit comments