json pack URL

This commit is contained in:
Jake Bolam
2018-04-24 09:47:35 -04:00
parent 0ef18e1517
commit 8ebee32ac2
3 changed files with 12 additions and 2 deletions

View File

@@ -38,6 +38,7 @@
"github-build": "^1.2.0",
"glob": "^7.1.2",
"gzip-size": "^4.0.0",
"jsonpack": "^1.1.5",
"lodash.merge": "^4.6.1",
"read-pkg-up": "^3.0.0"
},

View File

@@ -1,8 +1,10 @@
import jsonpack from 'jsonpack/main'
const createURL = ({ results, bundlesizeServiceHost }) => {
// TODO strip out data, etc
// TODO 'minify' data
// TODO url shortern service?
const urlResultData = encodeURIComponent(JSON.stringify(results))
const packedJSON = jsonpack.pack(results)
const urlResultData = encodeURIComponent(packedJSON)
const url = `${bundlesizeServiceHost}/results?d=${urlResultData}`
return url
}

View File

@@ -35,6 +35,13 @@ const main = async () => {
if (config.files && config.files.length > 0) {
const results = await bundlesizeApi(config)
if (results.url) {
logger.log('')
logger.log(
`${chalk.cyanBright('Result breakdown at:')} ${results.url}`,
)
}
prettyPrintResults(results.fullResults)
if (results.isFail) {