-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move things around for easier publishing.
Getting ready to release.
- Loading branch information
John Vilk
committed
Feb 20, 2018
1 parent
468e440
commit f7127ca
Showing
18 changed files
with
171 additions
and
24 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
build | ||
*.yml | ||
paper.pdf | ||
rollup.config.js | ||
tsconfig.json | ||
tsconfig.node.json | ||
yarn.lock | ||
/bleak | ||
/benchmarks |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
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,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(); | ||
} |
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