Ingen beskrivning

update_d3flamegraph.sh 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. set -eu
  3. set -o pipefail
  4. D3FLAMEGRAPH_REPO="https://raw.githubusercontent.com/spiermar/d3-flame-graph"
  5. D3FLAMEGRAPH_VERSION="2.0.0-alpha4"
  6. D3FLAMEGRAPH_JS="d3-flamegraph.js"
  7. D3FLAMEGRAPH_CSS="d3-flamegraph.css"
  8. cd $(dirname $0)
  9. D3FLAMEGRAPH_DIR=d3flamegraph
  10. generate_d3flamegraph_go() {
  11. local d3_js=$(curl -s "${D3FLAMEGRAPH_REPO}/${D3FLAMEGRAPH_VERSION}/dist/${D3FLAMEGRAPH_JS}" | sed 's/`/`+"`"+`/g')
  12. local d3_css=$(curl -s "${D3FLAMEGRAPH_REPO}/${D3FLAMEGRAPH_VERSION}/dist/${D3FLAMEGRAPH_CSS}")
  13. cat <<-EOF > $D3FLAMEGRAPH_DIR/d3_flame_graph.go
  14. // A D3.js plugin that produces flame graphs from hierarchical data.
  15. // https://github.com/spiermar/d3-flame-graph
  16. // Version $D3FLAMEGRAPH_VERSION
  17. // See LICENSE file for license details
  18. package d3flamegraph
  19. // JSSource returns the $D3FLAMEGRAPH_JS file
  20. const JSSource = \`
  21. $d3_js
  22. \`
  23. // CSSSource returns the $D3FLAMEGRAPH_CSS file
  24. const CSSSource = \`
  25. $d3_css
  26. \`
  27. EOF
  28. gofmt -w $D3FLAMEGRAPH_DIR/d3_flame_graph.go
  29. }
  30. get_license() {
  31. curl -s -o $D3FLAMEGRAPH_DIR/LICENSE "${D3FLAMEGRAPH_REPO}/${D3FLAMEGRAPH_VERSION}/LICENSE"
  32. }
  33. mkdir -p $D3FLAMEGRAPH_DIR
  34. get_license
  35. generate_d3flamegraph_go