From 5b9b4f274cdec8d138e4f9a052ce9a3e6058ec93 Mon Sep 17 00:00:00 2001 From: sinclairzx81 Date: Sat, 19 Aug 2017 20:13:43 +1200 Subject: [PATCH] travis artifacts --- .gitignore | 3 ++- .npmignore | 2 ++ .travis.yml | 5 +++++ package.json | 24 +++++++++++++++------ src/tsconfig.json | 10 +++++++++ tasks.js | 54 +++++++++++++++++++++++++--------------------- test/index.ts | 4 +++- test/tsconfig.json | 10 +++++++++ 8 files changed, 78 insertions(+), 34 deletions(-) create mode 100644 .npmignore create mode 100644 .travis.yml create mode 100644 src/tsconfig.json create mode 100644 test/tsconfig.json diff --git a/.gitignore b/.gitignore index dc574e0..e1754e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -target/ \ No newline at end of file +index.js +test.js \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..eb5b7ff --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +src/ +test/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9d0daac --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "7" +before_script: + - npm install \ No newline at end of file diff --git a/package.json b/package.json index a397cec..f5a5fbe 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,27 @@ { - "name": "typebox", - "version": "0.9.0", - "description": "A runtime type system for javascript.", - "main": "./target/index.js", - "test": "node ./target/test.js", + "name": "project-name", + "version": "1.0.0", + "description": "project-name", + "test": "node test", + "scripts": { + "clean": "node tasks clean", + "start": "node tasks start", + "build": "node tasks build", + "test": "node tasks test" + }, "repository": { "type": "git", - "url": "https://github.com/sinclairzx81/typebox" + "url": "https://github.com/sinclairzx81/project-name" }, "author": "sinclairzx81", "license": "MIT", "devDependencies": { "@types/mocha": "^2.2.41", - "@types/node": "^8.0.7" + "@types/node": "^8.0.7", + "fsrun": "^0.9.4", + "mocha": "^3.5.0", + "shx": "^0.2.2", + "typescript": "^2.4.2", + "typescript-bundle": "^0.8.6" } } diff --git a/src/tsconfig.json b/src/tsconfig.json new file mode 100644 index 0000000..743e900 --- /dev/null +++ b/src/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "module" : "amd", + "outFile" : "../index.js", + "removeComments": true, + "lib" : ["es2015","dom"] + }, "files" : [ + "index.ts" + ] +} \ No newline at end of file diff --git a/tasks.js b/tasks.js index 2b94d68..1d9fa36 100644 --- a/tasks.js +++ b/tasks.js @@ -1,6 +1,7 @@ //------------------------------------------------------ // task helper scripts: //------------------------------------------------------ + const shell = (command) => new Promise((resolve, reject) => { const { spawn } = require('child_process') const windows = /^win/.test(process.platform) @@ -10,6 +11,7 @@ const shell = (command) => new Promise((resolve, reject) => { ls.stderr.pipe(process.stderr) ls.on('close', (code) => resolve(code)) }) + const watch = (directory, func) => new Promise((resolve, reject) => { const fs = require("fs") const path = require("path") @@ -19,6 +21,7 @@ const watch = (directory, func) => new Promise((resolve, reject) => { const dirs = stats.filter(stat => stat.stat.isDirectory()) return Promise.all([dirs.map(dir => watch(dir.path, func))]) }) + const cli = async (args, tasks) => { const task = (args.length === 3) ? args[2] : "none" const func = (tasks[task]) ? tasks[task] : () => { @@ -30,47 +33,48 @@ const cli = async (args, tasks) => { //------------------------------------------------------ // constants: //------------------------------------------------------ -const TYPESCRIPT_INDEX = "tsc-bundle ./src/index.ts ./target/index.js --lib es2015,dom --removeComments" -const TYPESCRIPT_TEST = "tsc-bundle ./test/index.ts ./target/test.js --lib es2015,dom --removeComments" + +const TYPESCRIPT_SOURCE = "tsc-bundle --project ./src/tsconfig.json" +const TYPESCRIPT_TEST = "tsc-bundle --project ./test/tsconfig.json" //------------------------------------------------------ // tasks: //------------------------------------------------------ + const clean = async () => { - await shell("shx rm -rf ./node_modules"), - await shell("shx rm -rf ./target") + await shell("shx rm -rf ./index.js") + await shell("shx rm -rf ./test.js") + await shell("shx rm -rf ./node_modules") } -const install = async () => { - await shell("npm install shx -g") - await shell("npm install typescript -g") - await shell("npm install typescript-bundle -g") - await shell("npm install fsrun -g") - await shell("npm install mocha -g") +const start = async () => { + await shell("npm install") + await shell(`${TYPESCRIPT_SOURCE}`) + await Promise.all([ + shell(`${TYPESCRIPT_SOURCE} --watch > /dev/null`), + shell("fsrun ./index.js [node index.js]") + ]) +} + +const test = async () => { + await shell("npm install") + await shell(`${TYPESCRIPT_TEST}`) + await shell(`${TYPESCRIPT_SOURCE}`) + await shell("mocha ./test.js") + await clean() } const build = async () => { await shell("npm install") - await shell("shx mkdir -p ./target") - await shell(`${TYPESCRIPT_INDEX}`) -} - -const run = async () => { - await shell("npm install") - await shell("shx mkdir -p ./target") - await shell(`${TYPESCRIPT_TEST}`) - await Promise.all([ - shell(`${TYPESCRIPT_TEST} --watch > /dev/null`), - shell("fsrun ./target [mocha target/test]") - ]) + await shell(`${TYPESCRIPT_SOURCE}`) } //------------------------------------------------------ // cli: //------------------------------------------------------ cli(process.argv, { - install, clean, - build, - run, + start, + test, + build }).catch(console.log) diff --git a/test/index.ts b/test/index.ts index b7f99f5..ac58c50 100644 --- a/test/index.ts +++ b/test/index.ts @@ -26,6 +26,8 @@ THE SOFTWARE. ---------------------------------------------------------------------------*/ +import * as typebox from "../src/index" + //------------------------------- // tests //------------------------------- @@ -36,7 +38,7 @@ import "./tests/reflect" import "./tests/infer" import "./tests/check" -import * as typebox from "../src/index" + diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000..5519327 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "module" : "amd", + "outFile" : "../test.js", + "removeComments": true, + "lib" : ["es2015","dom"] + }, "files" : [ + "index.ts" + ] +} \ No newline at end of file