expressjs project template

This commit is contained in:
2022-05-23 02:26:12 +00:00
parent 500dc831cb
commit e839349d3e
8 changed files with 82 additions and 1 deletions

View File

@@ -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<String>) {
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<String>) {
// `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,

View File

@@ -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"
}

View File

@@ -0,0 +1,3 @@
node_modules/
.haxelib/
index.js

View File

@@ -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

View File

@@ -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"
}
}

View File

@@ -0,0 +1,7 @@
package template;
import kiss.Kiss;
import kiss.Prelude;
@:build(kiss.Kiss.build())
class Main {}

View File

@@ -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")))

View File

@@ -0,0 +1,4 @@
#! /bin/bash
npm install .
haxe build.hxml