-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: --upload report to persistent public store
- Loading branch information
Showing
8 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const fs = require('fs'); | ||
const axios = require('axios'); | ||
|
||
module.exports = async (jsonPath, options) => { | ||
const data = fs.readFileSync(jsonPath, 'utf8'); | ||
// const raw = JSON.stringify(data); | ||
|
||
const date = new Date().toISOString().replace('T', '-').replace('Z', ''); | ||
// const dateStr = date.slice(0,10); | ||
const name = jsonPath.replace(/[^0-9a-zа-я_.]/ig, ""); | ||
const uploadName = date + '-' + name; | ||
|
||
console.log('Uploading to https://site-audit.viasite.ru...'); | ||
const res = await axios.post('https://site-audit.viasite.ru/upload/', { | ||
name: uploadName, | ||
data: data | ||
}); | ||
|
||
if (res.status !== 200 || !res.data.url) { | ||
console.error('Failed to upload file!'); | ||
return jsonPath; | ||
} | ||
return res.data.url; | ||
} |