diff --git a/kiss/build-scripts/dts2hx-externs/KillVersionReqs.hx b/kiss/build-scripts/dts2hx-externs/KillVersionReqs.hx new file mode 100644 index 00000000..babb6a4c --- /dev/null +++ b/kiss/build-scripts/dts2hx-externs/KillVersionReqs.hx @@ -0,0 +1,19 @@ +package; + +import sys.io.File; +import sys.FileSystem; +import haxe.Json; + +class KillVersionReqs { + static function main() { + var libs = FileSystem.readDirectory("libs"); + for (lib in libs) { + var haxelib = 'libs/$lib/$lib/haxelib.json'; + var json = Json.parse(File.getContent(haxelib)); + for (dependency => version in (json.dependencies : haxe.DynamicAccess)) { + json.dependencies[dependency] = ""; + } + File.saveContent(haxelib, Json.stringify(json)); + } + } +} \ No newline at end of file diff --git a/kiss/build-scripts/dts2hx-externs/regenerate.sh b/kiss/build-scripts/dts2hx-externs/regenerate.sh new file mode 100644 index 00000000..769248bd --- /dev/null +++ b/kiss/build-scripts/dts2hx-externs/regenerate.sh @@ -0,0 +1,33 @@ +#! /bin/bash + +if [ -d libs ]; then + rm -rf libs +fi + +if [ -d .haxelib ]; then + rm -rf .haxelib +fi + +mkdir libs +npm install . + +cd .haxelib + +libs=* +for lib in $libs; do + mv $lib ../libs/$lib +done + +cd .. +rm -rf .haxelib + +cd libs +libs=* +for lib in $libs; do + mv $lib/**/ $lib/$lib + haxelib dev $lib $lib/$lib/ +done +cd .. +cp $(haxelib libpath kiss)/build-scripts/dts2hx-externs/KillVersionReqs.hx ./ +haxe --main KillVersionReqs --interp +rm KillVersionReqs.hx \ No newline at end of file diff --git a/kiss/src/kiss/Main.hx b/kiss/src/kiss/Main.hx index 8c6cec09..e96e27de 100644 --- a/kiss/src/kiss/Main.hx +++ b/kiss/src/kiss/Main.hx @@ -181,7 +181,7 @@ class Main { } static function newExpressProject(args:Array) { - var title = promptFor("title"); + var title = promptFor("title (lower-case!)").toLowerCase(); var pkg = title.replace("-", "_"); var kissExpressLibPath = new Process("haxelib", ["libpath", "kiss-express"]).stdout.readAll().toString().trim(); var workingDir = Sys.args().pop(); diff --git a/projects/kiss-cli-tests/.gitignore b/projects/kiss-cli-tests/.gitignore index 583d10fd..62756758 100644 --- a/projects/kiss-cli-tests/.gitignore +++ b/projects/kiss-cli-tests/.gitignore @@ -1 +1,2 @@ TestNewProject/ +TestNewExpressProject/ diff --git a/projects/kiss-cli-tests/new-express-project-input.txt b/projects/kiss-cli-tests/new-express-project-input.txt new file mode 100644 index 00000000..1d3c4bd2 --- /dev/null +++ b/projects/kiss-cli-tests/new-express-project-input.txt @@ -0,0 +1 @@ +TestNewExpressProject \ No newline at end of file diff --git a/projects/kiss-cli-tests/test.sh b/projects/kiss-cli-tests/test.sh index bf26ca01..2a2bff1f 100755 --- a/projects/kiss-cli-tests/test.sh +++ b/projects/kiss-cli-tests/test.sh @@ -1,6 +1,15 @@ #! /bin/bash # Test kiss new-project command +if [ -d TestNewProject ]; then + rm -rf TestNewProject +fi cat new-project-input.txt | haxelib run kiss new-project && (cd TestNewProject && sh test.sh) +# Test kiss new-express-project command +if [ -d testnewexpressproject ]; then + rm -rf testnewexpressproject +fi +cat new-express-project-input.txt | haxelib run kiss new-express-project && (cd testnewexpressproject && sh test.sh) + # TODO test other kiss project templates diff --git a/projects/kiss-express/template/.gitignore b/projects/kiss-express/template/.gitignore index 86228f57..f04ac6e9 100644 --- a/projects/kiss-express/template/.gitignore +++ b/projects/kiss-express/template/.gitignore @@ -1,3 +1,4 @@ node_modules/ .haxelib/ +libs/ index.js \ No newline at end of file diff --git a/projects/kiss-express/template/src/template/Main.kiss b/projects/kiss-express/template/src/template/Main.kiss index c23d1c92..a602a1ca 100644 --- a/projects/kiss-express/template/src/template/Main.kiss +++ b/projects/kiss-express/template/src/template/Main.kiss @@ -1,5 +1,6 @@ (let [app (Express.call) port 3000] (app.get "/" ->[req res next] (res.send "Hello World!")) - (app.listen port ->(print "kiss-express listening at http://localhost:$port"))) + (#unless test + (app.listen port ->(print "kiss-express listening at http://localhost:$port")))) diff --git a/projects/kiss-express/template/test.sh b/projects/kiss-express/template/test.sh index e45e27d6..1a09f8bf 100755 --- a/projects/kiss-express/template/test.sh +++ b/projects/kiss-express/template/test.sh @@ -1,4 +1,7 @@ #! /bin/bash -npm install . -haxe build.hxml \ No newline at end of file +if [ ! -d node_modules ]; then + $(haxelib libpath kiss)/build-scripts/dts2hx-externs/regenerate.sh +fi + +haxe -D test build.hxml \ No newline at end of file diff --git a/projects/nat-globelet-playground/.gitignore b/projects/nat-globelet-playground/.gitignore index 86228f57..231a1c71 100644 --- a/projects/nat-globelet-playground/.gitignore +++ b/projects/nat-globelet-playground/.gitignore @@ -1,3 +1,4 @@ node_modules/ .haxelib/ -index.js \ No newline at end of file +libs/ +index.js diff --git a/projects/nat-globelet-playground/package.json b/projects/nat-globelet-playground/package.json index db1c9223..f7721437 100644 --- a/projects/nat-globelet-playground/package.json +++ b/projects/nat-globelet-playground/package.json @@ -10,8 +10,8 @@ "devDependencies": { "dts2hx": "^0.19.0" }, - "version": "0.0.0", "scripts": { "postinstall": "dts2hx --all" - } + }, + "version": "0.0.0" } \ No newline at end of file diff --git a/projects/nat-globelet-playground/test.sh b/projects/nat-globelet-playground/test.sh index 71247013..1a09f8bf 100755 --- a/projects/nat-globelet-playground/test.sh +++ b/projects/nat-globelet-playground/test.sh @@ -1,24 +1,7 @@ #! /bin/bash if [ ! -d node_modules ]; then - npm install . + $(haxelib libpath kiss)/build-scripts/dts2hx-externs/regenerate.sh fi -# npm install creates a .haxelib folder which needs to be pointed to the dependencies -if [ ! -d .haxelib/kiss ]; then - cp .haxelib/express/.current .haxelib/express/.current.tmp - (cp ../../kiss/build-scripts/common-args.hxml ./ && haxelib install all --always && rm common-args.hxml) - # install all introduces an out-of-date express haxelib - mv .haxelib/express/.current.tmp .haxelib/express/.current - haxelib dev kiss ../../kiss - projects=$(ls ..) - for project in $projects - do - if [ -e ../${project}/haxelib.json ] - then - haxelib dev $project ../$project - # the word project has lost all meaning at this point - fi - done -fi haxe -D test build.hxml \ No newline at end of file