feat: Ask user to send Discord message when score is missing from dataset

Merge pull request #110 from PeterNjeim/master
This commit is contained in:
Wenzheng Tang 2021-03-12 21:24:54 -05:00 committed by GitHub
commit 49aef0ccf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 13 deletions

26
package-lock.json generated
View File

@ -709,18 +709,26 @@
} }
}, },
"elliptic": { "elliptic": {
"version": "6.5.3", "version": "6.5.4",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"bn.js": "^4.4.0", "bn.js": "^4.11.9",
"brorand": "^1.0.1", "brorand": "^1.1.0",
"hash.js": "^1.0.0", "hash.js": "^1.0.0",
"hmac-drbg": "^1.0.0", "hmac-drbg": "^1.0.1",
"inherits": "^2.0.1", "inherits": "^2.0.4",
"minimalistic-assert": "^1.0.0", "minimalistic-assert": "^1.0.1",
"minimalistic-crypto-utils": "^1.0.0" "minimalistic-crypto-utils": "^1.0.1"
},
"dependencies": {
"bn.js": {
"version": "4.12.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==",
"dev": true
}
} }
}, },
"emoji-regex": { "emoji-regex": {

View File

@ -88,7 +88,7 @@ void (async () => {
if (!confirmed) return if (!confirmed) return
// initiate LibreScore link request // initiate LibreScore link request
librescoreLink = getLibreScoreLink(scoreinfo) librescoreLink = getLibreScoreLink(scoreinfo, true)
// print a blank line to the terminal // print a blank line to the terminal
console.log() console.log()
@ -133,6 +133,8 @@ void (async () => {
spinner.info('Score loaded by webmscore') spinner.info('Score loaded by webmscore')
} catch (err) { } catch (err) {
spinner.fail(err.message) spinner.fail(err.message)
spinner.info(
"Send your URL to the #dataset-bugs channel in the LibreScore Community Discord server:\n https://discord.gg/kTyx6nUjMv");
return return
} }
spinner.succeed('OK\n') spinner.succeed('OK\n')

View File

@ -6,7 +6,7 @@ const _getLink = (scorepack: string) => {
return `https://librescore.org/score/${scorepack}` return `https://librescore.org/score/${scorepack}`
} }
export const getLibreScoreLink = async (scoreinfo: ScoreInfo, _fetch = getFetch()): Promise<string> => { export const getLibreScoreLink = async (scoreinfo: ScoreInfo, isMsdl: boolean, _fetch = getFetch()): Promise<string> => {
const mainCid = await getMainCid(scoreinfo, _fetch) const mainCid = await getMainCid(scoreinfo, _fetch)
const ref = scoreinfo.getScorepackRef(mainCid) const ref = scoreinfo.getScorepackRef(mainCid)
const url = `https://ipfs.infura.io:5001/api/v0/dag/get?arg=${ref}` const url = `https://ipfs.infura.io:5001/api/v0/dag/get?arg=${ref}`
@ -16,7 +16,7 @@ export const getLibreScoreLink = async (scoreinfo: ScoreInfo, _fetch = getFetch(
assertRes(r0) assertRes(r0)
} }
const res: { Message: string } | string = await r0.json() const res: { Message: string } | string = await r0.json()
if (typeof res !== 'string') { if (typeof res !== 'string' && !isMsdl) {
// read further error msg // read further error msg
throw new Error(res.Message) throw new Error(res.Message)
} }

View File

@ -48,7 +48,7 @@ export const loadMsczUrl = async (scoreinfo: ScoreInfo, _fetch = getFetch()): Pr
// read further error msg // read further error msg
const err = cidRes.Message const err = cidRes.Message
if (err.includes('no link named')) { // file not found if (err.includes('no link named')) { // file not found
throw new Error('score not in dataset') throw new Error('Score not in dataset')
} else { } else {
throw new Error(err) throw new Error(err)
} }