Skip to content

Commit

Permalink
Move things around for easier publishing.
Browse files Browse the repository at this point in the history
Getting ready to release.
  • Loading branch information
John Vilk committed Feb 20, 2018
1 parent 468e440 commit f7127ca
Show file tree
Hide file tree
Showing 18 changed files with 171 additions and 24 deletions.
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build
*.yml
paper.pdf
rollup.config.js
tsconfig.json
tsconfig.node.json
yarn.lock
/bleak
/benchmarks
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# <img src="favicon.svg" alt="BLeak" height="24px" /> BLeak
# <img src="html/favicon.svg" alt="BLeak" height="24px" /> BLeak

[![Build Status](https://travis-ci.org/plasma-umass/BLeak.svg?branch=master)](https://travis-ci.org/plasma-umass/BLeak)
[![Build status](https://ci.appveyor.com/api/projects/status/b92sknh0pu38943q/branch/master?svg=true)](https://ci.appveyor.com/project/jvilk/bleak/branch/master)
Expand Down
7 changes: 7 additions & 0 deletions html/bootstrap.min.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions html/bootstrap.min.js

Large diffs are not rendered by default.

File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
14 changes: 7 additions & 7 deletions index.html → html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<title>BLeak Results Viewer</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="bootstrap.min.css">

<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="node_modules/react-treeview/react-treeview.css">
<link rel="stylesheet" type="text/css" href="react-treeview.css">

<link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16" />
Expand All @@ -23,10 +23,10 @@
<p>BLeak's icon is a modified version of the <a href="https://thenounproject.com/term/leaky-faucet/192019/">"Leaky Faucet"</a> icon by Yazmin Alanis from <a href="http://thenounproject.com/">the Noun Project</a>.</p>
</div>
</footer>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="node_modules/d3/build/d3.min.js"></script>
<script src="build/browser/viewer.js" type="text/javascript"></script>
<script src="jquery-3.2.1.slim.min.js" type="text/javascript"></script>
<script src="popper.min.js" type="text/javascript"></script>
<script src="bootstrap.min.js" type="text/javascript"></script>
<script src="d3.min.js" type="text/javascript"></script>
<script src="viewer.js" type="text/javascript"></script>
</body>
</html>
4 changes: 4 additions & 0 deletions html/jquery-3.2.1.slim.min.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions html/popper.min.js

Large diffs are not rendered by default.

File renamed without changes.
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
"name": "bleak-detector",
"version": "1.0.0",
"description": "Automatically finds memory leaks in single page web applications.",
"main": "dist/index.js",
"bin": {
"bleak": "node dist/node/cli/bleak.js"
},
"scripts": {
"build": "npm-run-all -p build:node build:viewer -s rollup:viewer",
"build": "npm-run-all -p build:node build:viewer -s rollup:viewer make_dist",
"build:node": "tsc -p tsconfig.node.json",
"build:viewer": "tsc",
"rollup:viewer": "rollup -c",
"test": "npm-run-all -s build nyc:test",
"nyc:test": "nyc mocha --require source-map-support/register build/node/test",
"watch": "npm-run-all -p build:node build:viewer -p tsc:viewer:watch tsc:watch rollup:viewer:watch",
"watch": "npm-run-all -s build -p tsc:viewer:watch tsc:watch rollup:viewer:watch make_dist:watch",
"tsc:watch": "tsc -w",
"tsc:viewer:watch": "tsc -w -p tsconfig.node.json",
"rollup:viewer:watch": "rollup -w -c",
"benchmark": "npm-run-all build:node -s run:benchmark",
"run:benchmark": "node --max-old-space-size=8192 build/node/benchmarks/benchmark.js"
"run:benchmark": "node --max-old-space-size=8192 build/node/benchmarks/benchmark.js",
"make_dist": "node build/node/scripts/make_dist.js",
"make_dist:watch": "node build/node/scripts/make_dist.js --watch",
"prepare": "npm-run-all build"
},
"repository": {
"type": "git",
Expand All @@ -39,20 +44,16 @@
"@types/ace": "^0.0.36",
"@types/babel-core": "^6.25.1",
"@types/benchmark": "^1.0.30",
"@types/body-parser": "^1.16.5",
"@types/bootstrap": "^3.3.37",
"@types/d3": "^4.12.0",
"@types/error-stack-parser": "^1.3.18",
"@types/esprima": "^2.1.33",
"@types/estree": "0.0.34",
"@types/express": "^4.0.37",
"@types/extract-zip": "^1.6.2",
"@types/glob": "^5.0.30",
"@types/htmlparser2": "^3.7.29",
"@types/jquery": "^3.3.0",
"@types/mocha": "^2.2.40",
"@types/node": "^7.0.12",
"@types/papaparse": "^4.1.30",
"@types/progress": "^2.0.1",
"@types/react": "^16.0.36",
"@types/react-dom": "^16.0.3",
Expand All @@ -61,7 +62,7 @@
"benchmark": "^2.1.4",
"brace": "^0.11.0",
"d3": "^4.13.0",
"glob": "^7.1.2",
"microtime": "^2.1.6",
"mocha": "^3.2.0",
"npm-run-all": "^4.0.2",
"nyc": "^10.2.0",
Expand Down Expand Up @@ -91,12 +92,9 @@
"error-stack-parser": "^2.0.1",
"esprima": "^4.0.0",
"express": "^4.15.4",
"extract-zip": "^1.6.0",
"htmlparser2": "^3.9.2",
"locate-java-home": "^0.1.6",
"microtime": "^2.1.6",
"mitmproxy": "~1.7.1",
"papaparse": "^4.3.6",
"progress": "^2.0.0",
"source-map": "~0.6.0",
"tslib": "^1.9.0",
Expand Down
117 changes: 117 additions & 0 deletions scripts/make_dist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/usr/bin/env node
/**
* Assembles the 'dist' folder for BLeak.
*/
import * as fs from 'fs';
import * as path from 'path';
import * as rimraf from 'rimraf';

const shouldWatch = process.argv.indexOf("--watch") !== -1;
const buildFolder = path.resolve('build');
const distFolder = path.resolve('dist');
const htmlFolder = path.resolve('html');
if (!fs.existsSync(buildFolder)) {
console.error("Cannot find build folder! Make sure you run this script from the root folder.");
process.exit(1);
}

function mkdir(dir: string): void {
try {
fs.mkdirSync(dir, 0o755);
} catch(e) {
if (e.code !== "EEXIST") {
throw e;
}
}
}

async function copyDir(src: string, dest: string): Promise<void> {
mkdir(dest);
const files = fs.readdirSync(src);
let promises: Promise<void>[] = [];
for (const file of files) {
const from = path.join(src, file);
const to = path.join(dest, file);
const current = fs.lstatSync(from);
if (current.isDirectory()) {
promises.push(copyDir(from, to));
} else if (current.isSymbolicLink()) {
const symlink = fs.readlinkSync(from);
fs.symlinkSync(symlink, to);
} else {
promises.push(copy(from, to));
}
}
return Promise.all(promises) as Promise<any>;
}

async function copy(src: string, dest: string): Promise<void> {
return new Promise<void>((resolve, reject) => {
const oldFile = fs.createReadStream(src);
const newFile = fs.createWriteStream(dest);
oldFile.pipe(newFile).on('close', resolve).on('error', reject);
});
}

async function main(): Promise<void> {
return new Promise<void>((resolve, reject) => {
rimraf(distFolder, (err) => {
if (err) {
console.error(`Error removing existing dist folder:`);
console.error(err);
return reject(err);
}
mkdir(distFolder);
const promises: Promise<void>[] = [];
promises.push(copyDir(path.join(buildFolder, 'node', 'src'), path.join(distFolder, 'node')));
promises.push(copyDir(htmlFolder, path.join(distFolder, 'viewer')));

const viewerSrcFolder = path.join(buildFolder, 'browser');
['viewer.js', 'viewer.js.map'].forEach((file) => {
promises.push(copy(path.join(viewerSrcFolder, file), path.join(distFolder, 'viewer', file)));
});
promises.push(copy(path.resolve('node_modules', 'd3', 'build', 'd3.min.js'), path.join(distFolder, 'viewer', 'd3.min.js')));
promises.push(copy(path.resolve('node_modules', 'react-treeview', 'react-treeview.css'), path.join(distFolder, 'viewer', 'react-treeview.css')));
promises.push(copyDir(path.resolve('node_modules', 'chrome-devtools-frontend'), path.join(distFolder, 'viewer', 'chrome-devtools-frontend')));

resolve(Promise.all(promises) as Promise<any>);
});
});
}

const WATCH_GRANULARITY = 500;
function watch(): void {
let lastChangeTimestamp = 0;
let isBuilding = false;
let timer: NodeJS.Timer = null;
function resetBuilding() {
console.log(`[make_dist] Finished!`);
isBuilding = false;
}
function timerFunction(timestamp: number) {
if (lastChangeTimestamp !== timestamp || isBuilding) {
timer = setTimeout(timerFunction, WATCH_GRANULARITY, lastChangeTimestamp);
} else {
timer = null;
isBuilding = true;
console.log(`[make_dist] Change detected! Copying files to dist...`)
main().then(resetBuilding).catch(resetBuilding);
}
}

fs.watch(buildFolder, {
recursive: true
}, function() {
lastChangeTimestamp = Date.now();
if (!timer) {
timer = setTimeout(timerFunction, WATCH_GRANULARITY, lastChangeTimestamp);
}
});
timerFunction(lastChangeTimestamp);
}

if (shouldWatch) {
watch();
} else {
main();
}
4 changes: 2 additions & 2 deletions src/cli/commands/viewer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CommandModule} from 'yargs';
import * as express from 'express';
import {createServer} from 'http';
import {resolve} from 'path';
import {resolve, join} from 'path';
import {existsSync, readFileSync} from 'fs';

interface CommandLineArgs {
Expand Down Expand Up @@ -29,7 +29,7 @@ function findPath(): string {
}
p = resolve(p, '..');
}
return p;
return join(p, 'dist', 'viewer');
}

const Viewer: CommandModule = {
Expand Down
4 changes: 2 additions & 2 deletions src/viewer/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default class FormatWorker {
private _w: Worker;
private _queue: PendingFormatRequest[] = [];
private constructor(ready: (worker: FormatWorker) => void) {
// Use the original, unmodified worker code.
this._w = new Worker("node_modules/chrome-devtools-frontend/front_end/formatter_worker.js");
// Use the original, unmodified worker code from Chrome devtools.
this._w = new Worker("chrome-devtools-frontend/front_end/formatter_worker.js");
this._w.onmessage = (e) => {
if (e.data === "workerReady") {
return ready(this);
Expand Down

0 comments on commit f7127ca

Please sign in to comment.