mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: added modules
This commit is contained in:
6
core/docs/.gitignore
vendored
Normal file
6
core/docs/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.idea
|
||||
node_modules
|
||||
dist
|
||||
build
|
||||
tmp
|
||||
yarn.lock
|
||||
10
core/docs/api/index.html
Normal file
10
core/docs/api/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!doctype html> <!-- Important: must specify -->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"> <!-- Important: rapi-doc uses utf8 characters -->
|
||||
<script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<rapi-doc spec-url="./openapi.yaml"></rapi-doc>
|
||||
</body>
|
||||
</html>
|
||||
4225
core/docs/api/openapi.yaml
Normal file
4225
core/docs/api/openapi.yaml
Normal file
File diff suppressed because it is too large
Load Diff
16
core/docs/package.json
Normal file
16
core/docs/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "docs",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"publish": "node scripts/publish.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"qiniu": "^7.4.0",
|
||||
"walk-sync": "^3.0.0"
|
||||
}
|
||||
}
|
||||
81
core/docs/scripts/publish.js
Normal file
81
core/docs/scripts/publish.js
Normal file
@@ -0,0 +1,81 @@
|
||||
const path = require('path')
|
||||
const qiniu = require('qiniu')
|
||||
const walkSync = require('walk-sync')
|
||||
const chalk = require('chalk')
|
||||
|
||||
// target directory
|
||||
const targetDir = './api'
|
||||
|
||||
// access key
|
||||
const accessKey = process.env.QINIU_ACCESS_KEY
|
||||
|
||||
// secret key
|
||||
const secretKey = process.env.QINIU_SECRET_KEY
|
||||
|
||||
// bucket
|
||||
const bucket = process.env.QINIU_BUCKET
|
||||
|
||||
// config
|
||||
const config = new qiniu.conf.Config()
|
||||
|
||||
// zone
|
||||
config.zone = qiniu.zone[process.env.QINIU_ZONE]
|
||||
|
||||
function uploadFile(localFile, key) {
|
||||
// options
|
||||
const options = {
|
||||
scope: `${bucket}:${key}`,
|
||||
}
|
||||
|
||||
// mac
|
||||
const mac = new qiniu.auth.digest.Mac(accessKey, secretKey)
|
||||
|
||||
// put policy
|
||||
const putPolicy = new qiniu.rs.PutPolicy(options)
|
||||
|
||||
// upload token
|
||||
const uploadToken = putPolicy.uploadToken(mac)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const formUploader = new qiniu.form_up.FormUploader(config)
|
||||
const putExtra = new qiniu.form_up.PutExtra()
|
||||
formUploader.putFile(uploadToken, key, localFile, putExtra, function (respErr, respBody, respInfo) {
|
||||
if (respErr) {
|
||||
throw respErr
|
||||
}
|
||||
if (respInfo.statusCode === 200) {
|
||||
console.log(`${chalk.green('uploaded')} ${localFile} => ${key}`)
|
||||
resolve()
|
||||
} else if (respInfo.statusCode === 614) {
|
||||
console.log(`${chalk.yellow('exists')} ${localFile} => ${key}`)
|
||||
resolve()
|
||||
} else {
|
||||
const errMsg = `${chalk.red('error[' + respInfo.statusCode + ']')} ${localFile} => ${key}`
|
||||
console.error(errMsg)
|
||||
reject(new Error(respBody))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// paths
|
||||
const paths = walkSync(targetDir, {
|
||||
includeBasePath: true, directories: false,
|
||||
})
|
||||
|
||||
// iterate paths
|
||||
for (const filePath of paths) {
|
||||
const localFile = path.resolve(filePath)
|
||||
const key = filePath.replace(targetDir + '/', '')
|
||||
try {
|
||||
await uploadFile(localFile, key)
|
||||
} finally {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await main()
|
||||
})()
|
||||
Reference in New Issue
Block a user