Merge branch 'main' of github.com:Team-1280/eeXiv
This commit is contained in:
commit
784d75986d
3 changed files with 37 additions and 0 deletions
2
scripts/.gitignore
vendored
Normal file
2
scripts/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*.js
|
||||||
|
secret.txt
|
1
scripts/run.sh
Normal file
1
scripts/run.sh
Normal file
|
@ -0,0 +1 @@
|
||||||
|
npx tsc zenodo.ts && node zenodo.js $1 $2
|
34
scripts/zenodo.ts
Normal file
34
scripts/zenodo.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import { execSync } from 'child_process'
|
||||||
|
|
||||||
|
const TOKEN = process.env.ZENODO
|
||||||
|
const filename = process.argv[2]
|
||||||
|
const path = process.argv[3]
|
||||||
|
|
||||||
|
const run = (cmd: string): string | Buffer => {
|
||||||
|
try {
|
||||||
|
const output = execSync(cmd, { stdio: 'pipe' })
|
||||||
|
return output
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error executing shell script: ${error}`)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const out =
|
||||||
|
run(`curl --request POST 'https://zenodo.org/api/deposit/depositions?access_token=${TOKEN}' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-raw '{}'
|
||||||
|
`)
|
||||||
|
const json = JSON.parse(out.toString())
|
||||||
|
const doi = json.metadata.prereserve_doi.doi
|
||||||
|
const file = json.links.bucket
|
||||||
|
|
||||||
|
console.log('DOI: ' + doi)
|
||||||
|
console.log('File: ' + file)
|
||||||
|
|
||||||
|
const res = run(
|
||||||
|
`curl --upload-file ${path} --request PUT '${file}/${filename}?access_token=${TOKEN}'`
|
||||||
|
)
|
||||||
|
const resJSON = JSON.parse(res.toString())
|
||||||
|
|
||||||
|
console.log(resJSON)
|
Loading…
Reference in a new issue