Bez popisu

update_d3flamegraph.sh 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. D3FLAMEGRAPH_DIR=third_party/d3flamegraph
  9. generate_d3flamegraph_go() {
  10. local d3_js=$(curl -s "${D3FLAMEGRAPH_REPO}/${D3FLAMEGRAPH_VERSION}/dist/${D3FLAMEGRAPH_JS}" | sed 's/`/`+"`"+`/g')
  11. local d3_css=$(curl -s "${D3FLAMEGRAPH_REPO}/${D3FLAMEGRAPH_VERSION}/dist/${D3FLAMEGRAPH_CSS}")
  12. cat <<-EOF > $D3FLAMEGRAPH_DIR/d3_flame_graph.go
  13. // A D3.js plugin that produces flame graphs from hierarchical data.
  14. // https://github.com/spiermar/d3-flame-graph
  15. // Version $D3FLAMEGRAPH_VERSION
  16. // See LICENSE file for license details
  17. package d3flamegraph
  18. // JSSource returns the $D3FLAMEGRAPH_JS file
  19. const JSSource = \`
  20. $d3_js
  21. \`
  22. // CSSSource returns the $D3FLAMEGRAPH_CSS file
  23. const CSSSource = \`
  24. $d3_css
  25. \`
  26. EOF
  27. gofmt -w $D3FLAMEGRAPH_DIR/d3_flame_graph.go
  28. }
  29. get_license() {
  30. curl -s -o $D3FLAMEGRAPH_DIR/LICENSE "${D3FLAMEGRAPH_REPO}/${D3FLAMEGRAPH_VERSION}/LICENSE"
  31. }
  32. mkdir -p $D3FLAMEGRAPH_DIR
  33. get_license
  34. generate_d3flamegraph_go