diff --git a/kiss/src/kiss/Main.hx b/kiss/src/kiss/Main.hx index 06c4764c..11fb7838 100644 --- a/kiss/src/kiss/Main.hx +++ b/kiss/src/kiss/Main.hx @@ -36,6 +36,8 @@ class Main { newProject(args); case "new-flixel-project": newFlixelProject(args); + case "new-express-project": + newExpressProject(args); case "implement": // kiss implement [type] [fromLib] var _pwd = args.pop(); @@ -169,7 +171,6 @@ class Main { firstWindowElement.set("background", background); File.saveContent(Path.join([workingDir, title, 'Project.xml']), projectXml.toString()); - var makeFileForNewProject:haxe.Constraints.Function = _makeFileForNewProject.bind(kissFlixelLibPath, _, workingDir, title, ""); var makeFolderForNewProject:haxe.Constraints.Function = _makeFolderForNewProject.bind(kissFlixelLibPath, _, workingDir, title, ""); makeFolderForNewProject([".vscode"]); @@ -179,6 +180,27 @@ class Main { makeFileForNewProject([".gitignore"]); } + static function newExpressProject(args:Array) { + var title = promptFor("title"); + var pkg = title.replace("-", "_"); + var kissExpressLibPath = new Process("haxelib", ["libpath", "kiss-express"]).stdout.readAll().toString().trim(); + var workingDir = Sys.args().pop(); + var projectDir = Path.join([workingDir, title]); + FileSystem.createDirectory(projectDir); + + var makeFileForNewProject:haxe.Constraints.Function = _makeFileForNewProject.bind(kissExpressLibPath, _, workingDir, title, pkg); + var makeFolderForNewProject:haxe.Constraints.Function = _makeFolderForNewProject.bind(kissExpressLibPath, _, workingDir, title, pkg); + makeFolderForNewProject(["src", "template"]); + makeFileForNewProject([".gitignore"]); + makeFileForNewProject(["build.hxml"]); + makeFileForNewProject(["package.json"]); + var packageFile = Path.join([projectDir, "package.json"]); + var packageJson = Json.parse(File.getContent(packageFile)); + packageJson.title = title; + File.saveContent(packageFile, Json.stringify(packageJson, null, "\t")); + makeFileForNewProject(["test.sh"]); + } + static function convert(args:Array) { // `kiss convert` converts its stdin input to Haxe expressions. // with --all, it reads everything from stdin at once (for piping). Without --all, it acts as a repl, diff --git a/projects/kiss-express/haxelib.json b/projects/kiss-express/haxelib.json new file mode 100644 index 00000000..ffc6033d --- /dev/null +++ b/projects/kiss-express/haxelib.json @@ -0,0 +1,16 @@ +{ + "name": "kiss-express", + "description": "Make ExpressJS websites with Kisslang", + "classPath": "src/", + "dependencies": { + "kiss": "" + }, + "url": "https://github.com/NQNStudios/kisslang", + "contributors": [ + "NQNStudios" + ], + "version": "0.0.0", + "releasenote": "", + "tags": [], + "license": "LGPL" +} \ No newline at end of file diff --git a/projects/kiss-express/template/.gitignore b/projects/kiss-express/template/.gitignore new file mode 100644 index 00000000..86228f57 --- /dev/null +++ b/projects/kiss-express/template/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +.haxelib/ +index.js \ No newline at end of file diff --git a/projects/kiss-express/template/build.hxml b/projects/kiss-express/template/build.hxml new file mode 100644 index 00000000..67010461 --- /dev/null +++ b/projects/kiss-express/template/build.hxml @@ -0,0 +1,8 @@ +-lib kiss +-lib express +-lib kiss-express +-cp src +--macro kiss.Kiss.setup() +--main template.Main +--js index.js +--cmd node index.js \ No newline at end of file diff --git a/projects/kiss-express/template/package.json b/projects/kiss-express/template/package.json new file mode 100644 index 00000000..544ce283 --- /dev/null +++ b/projects/kiss-express/template/package.json @@ -0,0 +1,16 @@ +{ + "name": "template", + "version": "0.0.0", + "description": "An ExpressJS website made with Kisslang", + "main": "index.js", + "scripts": { + "postinstall": "dts2hx --all" + }, + "dependencies": { + "@types/express": "^4.17.13", + "express": "^4.18.1" + }, + "devDependencies": { + "dts2hx": "^0.19.0" + } +} diff --git a/projects/kiss-express/template/src/template/Main.hx b/projects/kiss-express/template/src/template/Main.hx new file mode 100644 index 00000000..e38e7391 --- /dev/null +++ b/projects/kiss-express/template/src/template/Main.hx @@ -0,0 +1,7 @@ +package template; + +import kiss.Kiss; +import kiss.Prelude; + +@:build(kiss.Kiss.build()) +class Main {} diff --git a/projects/kiss-express/template/src/template/Main.kiss b/projects/kiss-express/template/src/template/Main.kiss new file mode 100644 index 00000000..c23d1c92 --- /dev/null +++ b/projects/kiss-express/template/src/template/Main.kiss @@ -0,0 +1,5 @@ +(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"))) + diff --git a/projects/kiss-express/template/test.sh b/projects/kiss-express/template/test.sh new file mode 100644 index 00000000..e45e27d6 --- /dev/null +++ b/projects/kiss-express/template/test.sh @@ -0,0 +1,4 @@ +#! /bin/bash + +npm install . +haxe build.hxml \ No newline at end of file