expressjs project template
This commit is contained in:
@@ -36,6 +36,8 @@ class Main {
|
|||||||
newProject(args);
|
newProject(args);
|
||||||
case "new-flixel-project":
|
case "new-flixel-project":
|
||||||
newFlixelProject(args);
|
newFlixelProject(args);
|
||||||
|
case "new-express-project":
|
||||||
|
newExpressProject(args);
|
||||||
case "implement":
|
case "implement":
|
||||||
// kiss implement [type] [fromLib]
|
// kiss implement [type] [fromLib]
|
||||||
var _pwd = args.pop();
|
var _pwd = args.pop();
|
||||||
@@ -169,7 +171,6 @@ class Main {
|
|||||||
firstWindowElement.set("background", background);
|
firstWindowElement.set("background", background);
|
||||||
|
|
||||||
File.saveContent(Path.join([workingDir, title, 'Project.xml']), projectXml.toString());
|
File.saveContent(Path.join([workingDir, title, 'Project.xml']), projectXml.toString());
|
||||||
|
|
||||||
var makeFileForNewProject:haxe.Constraints.Function = _makeFileForNewProject.bind(kissFlixelLibPath, _, workingDir, title, "");
|
var makeFileForNewProject:haxe.Constraints.Function = _makeFileForNewProject.bind(kissFlixelLibPath, _, workingDir, title, "");
|
||||||
var makeFolderForNewProject:haxe.Constraints.Function = _makeFolderForNewProject.bind(kissFlixelLibPath, _, workingDir, title, "");
|
var makeFolderForNewProject:haxe.Constraints.Function = _makeFolderForNewProject.bind(kissFlixelLibPath, _, workingDir, title, "");
|
||||||
makeFolderForNewProject([".vscode"]);
|
makeFolderForNewProject([".vscode"]);
|
||||||
@@ -179,6 +180,27 @@ class Main {
|
|||||||
makeFileForNewProject([".gitignore"]);
|
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>) {
|
static function convert(args:Array<String>) {
|
||||||
// `kiss convert` converts its stdin input to Haxe expressions.
|
// `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,
|
// with --all, it reads everything from stdin at once (for piping). Without --all, it acts as a repl,
|
||||||
|
16
projects/kiss-express/haxelib.json
Normal file
16
projects/kiss-express/haxelib.json
Normal 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"
|
||||||
|
}
|
3
projects/kiss-express/template/.gitignore
vendored
Normal file
3
projects/kiss-express/template/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
node_modules/
|
||||||
|
.haxelib/
|
||||||
|
index.js
|
8
projects/kiss-express/template/build.hxml
Normal file
8
projects/kiss-express/template/build.hxml
Normal 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
|
16
projects/kiss-express/template/package.json
Normal file
16
projects/kiss-express/template/package.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
7
projects/kiss-express/template/src/template/Main.hx
Normal file
7
projects/kiss-express/template/src/template/Main.hx
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package template;
|
||||||
|
|
||||||
|
import kiss.Kiss;
|
||||||
|
import kiss.Prelude;
|
||||||
|
|
||||||
|
@:build(kiss.Kiss.build())
|
||||||
|
class Main {}
|
5
projects/kiss-express/template/src/template/Main.kiss
Normal file
5
projects/kiss-express/template/src/template/Main.kiss
Normal 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")))
|
||||||
|
|
4
projects/kiss-express/template/test.sh
Normal file
4
projects/kiss-express/template/test.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
npm install .
|
||||||
|
haxe build.hxml
|
Reference in New Issue
Block a user