Skip to content

Commit 355983e

Browse files
committed
jssdk fix import
1 parent cea5ba8 commit 355983e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

jsclient/src/command.ts

+15-14
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from "cmd-ts";
1717
import {ExistingPath} from 'cmd-ts/batteries/fs';
1818
import {version as Version} from '../package.json'
19+
import chalk from "chalk";
1920

2021
export const Integer: Type<string, number> = extendType(number, {
2122
async from(n) {
@@ -38,25 +39,25 @@ const domain = positional({type: string, displayName: 'domain'})
3839
const version = positional({type: Integer, displayName: 'version'});
3940
const versionOptional = positional({type: optional(Integer), displayName: 'version'});
4041

41-
async function getClient(configPath:string|undefined){
42+
async function getClient(configPath: string | undefined) {
4243
//load config
4344
const hocon = configPath ? await parse({url: configPath}) : {}
4445
// address: string
4546
// authToken: string
46-
const address: string|undefined = hocon?.server?.address ?? process.env.SPA_SERVER_ADDRESS
47-
const authToken: string|undefined = hocon?.server?.auth_token ?? process.env.SPA_SERVER_AUTH_TOKEN
47+
const address: string | undefined = hocon?.server?.address ?? process.env.SPA_SERVER_ADDRESS
48+
const authToken: string | undefined = hocon?.server?.auth_token ?? process.env.SPA_SERVER_AUTH_TOKEN
4849

49-
if(!address) {
50+
if (!address) {
5051
return Promise.reject("server.address could not get")
5152
}
52-
if(!authToken) {
53+
if (!authToken) {
5354
return Promise.reject("server.auth_token could not get")
5455
}
5556
return new SPAClient({address, authToken})
5657
}
5758

58-
function writeResult(func:() => Promise<any>) {
59-
func().then((v) => console.log(chalk.green(v))).catch((e) =>{
59+
function writeResult(func: () => Promise<any>) {
60+
func().then((v) => console.log(chalk.green(v))).catch((e) => {
6061
console.error(e)
6162
process.exit(-1)
6263
})
@@ -81,15 +82,15 @@ const upload = command({
8182
args: {
8283
path: positional({type: ExistingPath, displayName: 'path'}),
8384
domain,
84-
version:versionOptional,
85+
version: versionOptional,
8586
parallel: option({type: optional(Integer), short: 'p', long: 'parallel'}),
8687
config: configDirOption,
8788
},
8889
handler({path, domain, version, parallel, config}) {
8990
writeResult(async () => {
9091
const client = await getClient(config)
91-
const parallelParam = parallel ?? (process.env.SPA_UPLOAD_PARALLEL ? Number(process.env.SPA_UPLOAD_PARALLEL): undefined) ?? 3
92-
await client.uploadFilesParallel(domain,version, path, parallelParam)
92+
const parallelParam = parallel ?? (process.env.SPA_UPLOAD_PARALLEL ? Number(process.env.SPA_UPLOAD_PARALLEL) : undefined) ?? 3
93+
await client.uploadFilesParallel(domain, version, path, parallelParam)
9394
return "upload files finish"
9495
})
9596
}
@@ -102,7 +103,7 @@ const release = command({
102103
config: configDirOption,
103104
},
104105
handler({domain, version, config}) {
105-
writeResult(async() => {
106+
writeResult(async () => {
106107
const client = await getClient(config)
107108
return await client.releaseDomainVersion(domain, version)
108109
})
@@ -113,7 +114,7 @@ const reload = command({
113114
name: 'reload',
114115
args: {config: configDirOption,},
115116
handler({config}) {
116-
writeResult(async() => {
117+
writeResult(async () => {
117118
const client = await getClient(config)
118119
await client.reloadSPAServer()
119120
return "reload successful"
@@ -128,7 +129,7 @@ const deleteCmd = command({
128129
config: configDirOption,
129130
},
130131
handler({domain, maxReserve, config}) {
131-
writeResult(async() => {
132+
writeResult(async () => {
132133
const client = await getClient(config)
133134
await client.removeFiles(domain, maxReserve)
134135
return "delete successful"
@@ -143,7 +144,7 @@ const revokeVersionCmd = command({
143144
config: configDirOption
144145
},
145146
handler({domain, version, config}) {
146-
writeResult(async() => {
147+
writeResult(async () => {
147148
const client = await getClient(config)
148149
await client.revokeVersion(domain, version)
149150
return "revoke successful"

0 commit comments

Comments
 (0)