Skip to content

Commit c501833

Browse files
committed
release v2.2.2
1 parent 1466cef commit c501833

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

client/src/upload_files.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,8 @@ async fn get_upload_version(api: &API, domain: &str, version: Option<u32>) -> an
195195
Ok(version)
196196
} else {
197197
let resp = api.get_upload_position(domain).await?;
198-
match resp.status {
199-
GetDomainPositionStatus::NewDomain => {
200-
println!("domain:{} is new in server!", domain);
201-
}
202-
_ => {}
198+
if resp.status == GetDomainPositionStatus::NewDomain {
199+
println!("domain:{} is new in server!", domain);
203200
};
204201
Ok(resp.version)
205202
}

docs/develop/change-log.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [x] fix: fix cors check for normal http request.
88
- [x] fix: update version of one SPA one domain would cause deadlock.
99
- [x] feat: support index.html alias "","/" for multiple SPA one domain.
10+
- [x] improve: JS SDK keep same logic with command line, and improve error information. release JS SDK 2.2.2
1011
- [x] improve: more integration tests.
1112

1213
### Version 2.2.1

jsclient/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "spa-client",
3-
"version": "2.0.0",
3+
"version": "2.2.2",
44
"description": "js sdk for spa-server",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

jsclient/src/index.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ export default class SPAClient {
5555
"Authorization": `Bearer ${config.authToken}`
5656
}
5757
})
58-
this.http.interceptors.response.use((resp) => resp,(error) => {
59-
return Promise.reject( error.cause)
58+
this.http.interceptors.response.use((resp) => resp, (error) => {
59+
return Promise.reject(error.cause)
6060
})
6161
}
6262

@@ -117,6 +117,10 @@ export default class SPAClient {
117117
if (!(fs.existsSync(absolutePath) && fs.statSync(absolutePath).isDirectory())) {
118118
throw `path:${path} is not directory or does not exists`
119119
}
120+
const files = await walkdir.async(absolutePath, {return_object: true})
121+
if (Object.keys(files).length == 0) {
122+
throw `path:${path} has no files`
123+
}
120124
let realVersion: number;
121125
if (!version) {
122126
const positionResp = await this.getUploadPosition(domain)
@@ -136,7 +140,6 @@ export default class SPAClient {
136140
result[item.path] = item
137141
return result
138142
}, {} as { [key: string]: ShortMetaData })
139-
const files = await walkdir.async(absolutePath, {return_object: true})
140143
const uploadingFiles = Object.keys(files).reduce((result, filePath) => {
141144
const fileStat = files[filePath]
142145
if (fileStat.isFile()) {
@@ -151,7 +154,9 @@ export default class SPAClient {
151154

152155
}, [] as { key: string, filePath: string }[])
153156
if (!uploadingFiles.length) {
154-
throw "There is no file to uploading"
157+
console.log(chalk.green("all files already upload"))
158+
await this.changeUploadingStatus(domain, realVersion, UploadingStatus.Finish)
159+
return
155160
}
156161
console.log(chalk.green(`there are ${uploadingFiles.length} files to upload`))
157162
await this.changeUploadingStatus(domain, realVersion, UploadingStatus.Uploading)

0 commit comments

Comments
 (0)