diff --git a/package.json b/package.json index 0f997d0d..af3f894b 100644 --- a/package.json +++ b/package.json @@ -15,26 +15,22 @@ "scripts": { "build": "npm run increment-ts && rm -rf build && npm run ts:build && npm run webpack:build", "codecov": "codecov", - "collect": "npm run collect:deps", - "collect:deps": "node scripts/collect_deps.js", - "collect:tests": "cross-var node scripts/collect_tests.js --file $npm_config_file --dir $npm_config_dir", "docs": "node scripts/generate_docs.js", "docs:json": "cross-var typedoc --options \"./scripts/typedoc.json\" --json \"$npm_config_docs_json\"", "increment": "node scripts/increment_version.js", "increment-ts": "node scripts/increment_version_ts.js", - "karma": "cross-var karma start scripts/karma.conf.js --single-run --file $npm_config_file --dir $npm_config_dir", - "karma:browser": "cross-var karma start scripts/karma.conf.js --auto-watch --browsers OnlineChrome --file $npm_config_file --dir $npm_config_dir", - "karma:watch": "cross-var karma start scripts/karma.conf.js --auto-watch --file $npm_config_file --dir $npm_config_dir", + "karma": "cross-var karma start ./test/karma.conf.js --single-run --file $npm_config_file --dir $npm_config_dir", + "karma:browser": "cross-var karma start ./test/karma.conf.js --auto-watch --browsers OnlineChrome --file $npm_config_file --dir $npm_config_dir", + "karma:watch": "cross-var karma start ./test/karma.conf.js --auto-watch --file $npm_config_file --dir $npm_config_dir", "lint": "eslint --ignore-pattern ./Tone/**/*.test.ts --ext ts ./Tone", "lint:fix": "eslint --ext ts --fix ./Tone", "scratch": "webpack -w --env.scratch --mode=development", "test": "npm run karma", - "test:watch": "npm run collect:tests && npm run karma:watch", "test:browser": "npm run karma:browser", + "test:examples": "node ./test/scripts/test_examples", + "test:node": "node ./test/scripts/node_test.js", "test:travis": "npm run build && npm run lint && npm run test", - "test:examples": "node scripts/test_examples", - "test:html": "mocha ./test/html/testHTML.js --timeout 30000", - "test:node": "node ./test/html/node_test.js", + "test:watch": "npm run collect:tests && npm run karma:watch", "ts:build": "tsc --project ./scripts/tsconfig.build.json", "watch": "tsc --watch", "webpack:watch": "webpack -w --env.production --mode=development", diff --git a/scripts/collect_deps.js b/scripts/collect_deps.js deleted file mode 100644 index 1ae33355..00000000 --- a/scripts/collect_deps.js +++ /dev/null @@ -1,23 +0,0 @@ -const glob = require("glob"); -const { posix } = require("path"); -const fs = require("fs"); - -/** - * COLLECT DEPENDENCIES - */ -function collectDependencies(){ - const files = glob.sync(posix.resolve(__dirname, "../Tone/!(shim)/!(Tone).js")); - const modules = files.map(f => f.slice(0, -3)); - let reqString = modules.map(r => { - const relativePath = posix.relative(posix.resolve(__dirname, "../Tone"), r); - // const exportName = r.split("/")[r.split("/").length - 1]; - // return `export { default as ${exportName} } from "./${relativePath}";`; - // return `import "./${relativePath}";`; - return `require("./${relativePath}");`; - }).join("\n"); - // reqString += "\nexport { default } from \"./core/Tone\";\n"; - reqString += "\nmodule.exports = require(\"./core/Tone\").default;\n"; - fs.writeFileSync(posix.resolve(__dirname, "../Tone/index.js"), reqString); -} - -collectDependencies(); diff --git a/scripts/collect_tests.js b/scripts/collect_tests.js deleted file mode 100644 index be15c50e..00000000 --- a/scripts/collect_tests.js +++ /dev/null @@ -1,24 +0,0 @@ -const glob = require("glob"); -const fs = require("fs"); -const { posix } = require("path"); -const argv = require("yargs") - .alias("i", "file") - .alias("d", "dir") - .argv; - -/** - * COLLECT TESTS - */ -function collectTests(){ - var tests = "../test/!(helper|deps|examples|html)/*.js"; - if (typeof argv.file === "string"){ - tests = `../test/*/${argv.file}.js`; - } else if (typeof argv.dir === "string"){ - tests = `../test/${argv.dir}/*.js`; - } - const files = glob.sync(posix.resolve(__dirname, tests)); - var reqString = files.map(r => `import "${r}";`).join("\n"); - fs.writeFileSync(posix.resolve(__dirname, "../test/test.js"), reqString); -} - -collectTests(); diff --git a/scripts/increment_version.js b/scripts/increment_version.js deleted file mode 100644 index 8857fd44..00000000 --- a/scripts/increment_version.js +++ /dev/null @@ -1,36 +0,0 @@ -const fs = require("fs"); -const semver = require("semver"); -const { resolve } = require("path"); -const child_process = require("child_process"); - -const devVersion = child_process.execSync("npm show tone@next version").toString(); -const masterVersion = child_process.execSync("npm show tone version").toString(); - -//go with whichever is the latest version -let version = masterVersion; -if (semver.gt(devVersion, masterVersion)){ - version = devVersion; -} - -//increment the patch -version = semver.inc(version, "patch"); - -//write it to the package.json -const packageFile = resolve(__dirname, "../package.json"); -const packageObj = JSON.parse(fs.readFileSync(packageFile, "utf-8")); - -//if the package version if the latest, go with that one -if (semver.gt(packageObj.version, version)){ - version = packageObj.version; -} - -console.log(`incrementing to version ${version}`); -packageObj.version = version; -//only if it's travis, update the package.json -if (process.env.TRAVIS){ - fs.writeFileSync(packageFile, JSON.stringify(packageObj, undefined, " ")); - - //write a version file - var versionFile = `export default ${JSON.stringify(version)};\n`; - fs.writeFileSync(resolve(__dirname, "../Tone/version.js"), versionFile); -} diff --git a/scripts/increment_version_ts.js b/scripts/increment_version_ts.js index 6b604093..cda436d5 100644 --- a/scripts/increment_version_ts.js +++ b/scripts/increment_version_ts.js @@ -1,37 +1,39 @@ +/* eslint-disable no-console */ +/* eslint-disable @typescript-eslint/no-var-requires */ const fs = require("fs"); const semver = require("semver"); const { resolve } = require("path"); -const child_process = require("child_process"); +const { execSync } = require("child_process"); -const tsVersion = child_process.execSync("npm show tone@typescript version").toString(); -const masterVersion = child_process.execSync("npm show tone version").toString(); +const tsVersion = execSync("npm show tone@typescript version").toString(); +const masterVersion = execSync("npm show tone version").toString(); -//go with whichever is the latest version +// go with whichever is the latest version let version = masterVersion; -if (tsVersion && semver.gt(tsVersion, masterVersion)){ +if (tsVersion && semver.gt(tsVersion, masterVersion)) { version = tsVersion; } -//increment the patch +// increment the patch version = semver.inc(version, "patch"); -//write it to the package.json +// write it to the package.json const packageFile = resolve(__dirname, "../package.json"); const packageObj = JSON.parse(fs.readFileSync(packageFile, "utf-8")); -//if the package version if the latest, go with that one -if (semver.gt(packageObj.version, version)){ +// if the package version if the latest, go with that one +if (semver.gt(packageObj.version, version)) { version = packageObj.version; } console.log(`incrementing to version ${version}`); packageObj.version = version; -//only if it's travis, update the package.json -if (process.env.TRAVIS){ +// only if it's travis, update the package.json +if (process.env.TRAVIS) { fs.writeFileSync(packageFile, JSON.stringify(packageObj, undefined, " ")); - //write a version file - var versionFile = `export const version: string = ${JSON.stringify(version)};\n`; + // write a version file + let versionFile = `export const version: string = ${JSON.stringify(version)};\n`; fs.writeFileSync(resolve(__dirname, "../Tone/version.ts"), versionFile); } diff --git a/test/html/multiple_instances.html b/test/html/multiple_instances.html deleted file mode 100644 index 7622a5f4..00000000 --- a/test/html/multiple_instances.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - TWO CONTEXTS RUNNING AT ONCE - - - - - - - - - - - - \ No newline at end of file diff --git a/test/html/same_transport.html b/test/html/same_transport.html deleted file mode 100644 index a4b2a673..00000000 --- a/test/html/same_transport.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - SAME TRANSPORT - - - - - - - - \ No newline at end of file diff --git a/test/html/testHTML.js b/test/html/testHTML.js deleted file mode 100644 index 1cc5794b..00000000 --- a/test/html/testHTML.js +++ /dev/null @@ -1,57 +0,0 @@ -const puppeteer = require("puppeteer"); -const { resolve } = require("path"); -const fs = require("fs"); -const { spawn } = require("child_process"); - -function runPage(name){ - return new Promise(async (done, error) => { - const browser = await puppeteer.launch({ args : ["--no-sandbox"] }); - const page = await browser.newPage(); - page.on("pageerror", e => error(e)); - await page.goto(`http://localhost:9999/examples/${name}`, { waitFor : "networkidle0" }); - await browser.close(); - done(); - }); -} - -describe("TEST", () => { - - let serverProcess = null; - - before((done) => { - const serverCommand = resolve(__dirname, "../../node_modules/.bin/http-server"); - serverProcess = spawn(serverCommand, ["-p", "9999"]); - //give it a second for the server to start - setTimeout(() => done(), 1000); - }); - - after(() => { - serverProcess.kill(); - }); - - context("HTML Tests", () => { - - it("can run multiple contexts at once", () => { - return runPage("../test/html/multiple_instances.html"); - }); - - it("has the same transport after offline test", () => { - return runPage("../test/html/same_transport.html"); - }); - - }); - - context("Examples", () => { - - const exampleDir = resolve(__dirname, "../../examples/"); - - const files = fs.readdirSync(exampleDir).filter(f => f.endsWith(".html")); - - files.forEach(f => { - it(`can run example ${f}`, () => { - return runPage(f); - }); - }); - }); -}); - diff --git a/test/index.html b/test/index.html deleted file mode 100644 index 67ddc556..00000000 --- a/test/index.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - TESTS - - - - -
- - - diff --git a/scripts/karma.conf.js b/test/karma.conf.js similarity index 100% rename from scripts/karma.conf.js rename to test/karma.conf.js diff --git a/test/html/node_test.js b/test/scripts/node_test.js similarity index 100% rename from test/html/node_test.js rename to test/scripts/node_test.js diff --git a/scripts/test_examples.js b/test/scripts/test_examples.js similarity index 100% rename from scripts/test_examples.js rename to test/scripts/test_examples.js