-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
146 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ node_modules | |
.cache | ||
dist | ||
.idea | ||
coverage | ||
coverage |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Fail on first error | ||
set -e | ||
OUTDIR=`pwd`/dist/release | ||
|
||
# Typecheck | ||
node_modules/.bin/tsc --noEmit | ||
|
||
# Clean out the release directory | ||
rm -rf "$OUTDIR" | ||
mkdir -p "$OUTDIR" | ||
|
||
# Place info about the current commit into the build dir to easily identify releases | ||
date > "$OUTDIR"/release.txt | ||
git rev-parse HEAD >> "$OUTDIR"/release.txt | ||
|
||
# Place a json schema for the file format into the build directory too | ||
node generate-file-format-schema-json.js > "$OUTDIR"/file-format-schema.json | ||
|
||
# Build the compiled assets | ||
node_modules/.bin/parcel build index.html --no-cache --out-dir "$OUTDIR" --public-url "./" --detailed-report |
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 |
---|---|---|
@@ -1,2 +1,74 @@ | ||
#!/usr/bin/env node | ||
console.log('Coming soon!') | ||
const path = require('path') | ||
const fs = require('fs') | ||
const os = require('os') | ||
const opn = require('opn') | ||
|
||
const helpString = ` | ||
Usage: speedscope [filepath] | ||
If invoked with no arguments, will open a local copy of speedscope in your default browser. | ||
Once open, you can browse for a profile to import. | ||
` | ||
|
||
if (process.argv.includes('--help') || process.argv.includes('-h')) { | ||
console.log(helpString) | ||
process.exit(0) | ||
} | ||
|
||
if (process.argv.includes('--version') || process.argv.includes('-v')) { | ||
console.log('v' + require('./package.json').version) | ||
process.exit(0) | ||
} | ||
|
||
if (process.argv.length > 3) { | ||
console.log('At most one argument expected') | ||
console.log(helpString) | ||
process.exit(1) | ||
} | ||
|
||
let urlToOpen = 'file://' + path.resolve(__dirname, './dist/release/index.html') | ||
|
||
if (process.argv.length === 3) { | ||
const absPath = path.resolve(process.cwd(), process.argv[2]) | ||
let sourceBuffer | ||
try { | ||
sourceBuffer = fs.readFileSync(absPath) | ||
} catch (e) { | ||
console.log(e) | ||
console.log(helpString) | ||
process.exit(1) | ||
} | ||
const filename = path.basename(absPath) | ||
const sourceBase64 = sourceBuffer.toString('base64') | ||
const jsSource = `Speedscope.loadFileFromBase64(${JSON.stringify(filename)}, ${JSON.stringify( | ||
sourceBase64, | ||
)})` | ||
|
||
const filePrefix = `speedscope-${+new Date()}-${process.pid}` | ||
const jsPath = path.join(os.tmpdir(), `${filePrefix}.js`) | ||
console.log(`Creating temp file ${jsPath}`) | ||
fs.writeFileSync(jsPath, jsSource) | ||
urlToOpen += `#localProfilePath=${jsPath}` | ||
|
||
// For some silly reason, the OS X open command ignores any query parameters or hash parameters | ||
// passed as part of the URL. To get around this weird issue, we'll create a local HTML file | ||
// that just redirects. | ||
const htmlPath = path.join(os.tmpdir(), `${filePrefix}.html`) | ||
console.log(`Creating temp file ${htmlPath}`) | ||
fs.writeFileSync(htmlPath, `<script>window.location=${JSON.stringify(urlToOpen)}</script>`) | ||
|
||
urlToOpen = `file://${htmlPath}` | ||
} | ||
|
||
console.log('Opening', urlToOpen, 'in your default browser') | ||
|
||
opn(urlToOpen, {wait: false}).then( | ||
() => { | ||
process.exit(0) | ||
}, | ||
err => { | ||
console.error(err) | ||
console.exit(1) | ||
}, | ||
) |
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
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