create-chasi-ts 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chasi.config.js +45 -0
- package/dist/chasi.js +27 -0
- package/dist/commands/create/Create.js +19 -0
- package/dist/commands/init/Init.js +91 -0
- package/dist/commands/init/create-app.js +107 -0
- package/dist/commands/kernel.js +30 -0
- package/dist/commands/loader.js +26 -0
- package/dist/init.js +4 -0
- package/dist/templates/Controller.js +46 -0
- package/dist/templates/Event.js +29 -0
- package/dist/templates/Middleware.js +5 -0
- package/dist/templates/Model.js +26 -0
- package/dist/templates/Provider.js +15 -0
- package/package.json +41 -0
- package/src/chasi.config.ts +47 -0
- package/src/chasi.ts +31 -0
- package/src/commands/create/Create.ts +15 -0
- package/src/commands/init/Init.ts +97 -0
- package/src/commands/init/create-app.ts +114 -0
- package/src/commands/kernel.ts +37 -0
- package/src/commands/loader.ts +27 -0
- package/src/init.ts +5 -0
- package/src/templates/Controller.ts +46 -0
- package/src/templates/Event.ts +29 -0
- package/src/templates/Middleware.ts +5 -0
- package/src/templates/Model.ts +27 -0
- package/src/templates/Provider.ts +15 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import controller from "./templates/Controller.js";
|
|
2
|
+
import model from "./templates/Model.js";
|
|
3
|
+
import event from "./templates/Event.js";
|
|
4
|
+
import middleware from "./templates/Middleware.js";
|
|
5
|
+
import provider from "./templates/Provider.js";
|
|
6
|
+
import path from "path";
|
|
7
|
+
Object.defineProperty(String.prototype, 'capitalize', {
|
|
8
|
+
value: function () {
|
|
9
|
+
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
10
|
+
},
|
|
11
|
+
enumerable: false
|
|
12
|
+
});
|
|
13
|
+
const defaults = {
|
|
14
|
+
controller: {
|
|
15
|
+
key: "Controller",
|
|
16
|
+
path: path.join(process.cwd(), "/src/container/controllers/"),
|
|
17
|
+
parseContent: controller,
|
|
18
|
+
},
|
|
19
|
+
event: {
|
|
20
|
+
key: "Event",
|
|
21
|
+
path: path.join(process.cwd(), "/src/container/events/"),
|
|
22
|
+
parseContent: event,
|
|
23
|
+
},
|
|
24
|
+
middleware: {
|
|
25
|
+
key: ".mw",
|
|
26
|
+
path: path.join(process.cwd(), "/src/container/middlewares/"),
|
|
27
|
+
parseContent: middleware,
|
|
28
|
+
},
|
|
29
|
+
provider: {
|
|
30
|
+
key: "ServiceProvider",
|
|
31
|
+
path: path.join(process.cwd(), "/src/container/services/"),
|
|
32
|
+
parseContent: provider,
|
|
33
|
+
},
|
|
34
|
+
model: {
|
|
35
|
+
key: "",
|
|
36
|
+
path: path.join(process.cwd(), "/src/container/models/"),
|
|
37
|
+
parseContent: model,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
export default {
|
|
41
|
+
defaults,
|
|
42
|
+
format: (option, name) => {
|
|
43
|
+
return name.capitalize() + defaults[option].key;
|
|
44
|
+
}
|
|
45
|
+
};
|
package/dist/chasi.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import Kernel from './commands/kernel.js';
|
|
4
|
+
const program = new Command();
|
|
5
|
+
program.name("chasis")
|
|
6
|
+
.description(`chasi cli tool`)
|
|
7
|
+
.version(`1.0.0`);
|
|
8
|
+
program
|
|
9
|
+
.command("create")
|
|
10
|
+
.description(`create new file[s] [controller, model, middleware, provider ]`)
|
|
11
|
+
.argument("<name>", "specifies the name to use.")
|
|
12
|
+
.option("-c , --controller", "creates a new controller")
|
|
13
|
+
.option("-m , --model", "creates a new model")
|
|
14
|
+
.option("-w , --middleware", "creates a new middleware")
|
|
15
|
+
.option("-p , --provider", "creates a new service provider")
|
|
16
|
+
.option("-e , --event", "creates a new event")
|
|
17
|
+
.action((name, options) => {
|
|
18
|
+
let kernel = new Kernel("create", options, name);
|
|
19
|
+
kernel.exec();
|
|
20
|
+
});
|
|
21
|
+
program.command('init')
|
|
22
|
+
.description(`initializes chasi boilerplate`)
|
|
23
|
+
.action(async () => {
|
|
24
|
+
let kernel = new Kernel("init");
|
|
25
|
+
kernel.exec();
|
|
26
|
+
});
|
|
27
|
+
program.parse();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import chasi from "../../chasi.config.js";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
export default (option, name) => {
|
|
4
|
+
let conf = chasi.defaults[option.toLowerCase()];
|
|
5
|
+
let module = chasi.format(option, name);
|
|
6
|
+
let content = conf.parseContent(module, name);
|
|
7
|
+
try {
|
|
8
|
+
let fullpath = `${conf.path}${module}.ts`;
|
|
9
|
+
if (!fs.existsSync(conf.path)) {
|
|
10
|
+
fs.mkdirSync(conf.path, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
if (fs.existsSync(fullpath))
|
|
13
|
+
throw Error(`[${module}] module already exist`);
|
|
14
|
+
fs.writeFileSync(fullpath, content);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
throw err;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import readline from "readline";
|
|
2
|
+
import createApp from "./create-app.js";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
const requestReadliner = () => {
|
|
5
|
+
return readline.createInterface({
|
|
6
|
+
input: process.stdin,
|
|
7
|
+
output: process.stdout
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const fields = {
|
|
11
|
+
name: {
|
|
12
|
+
value: '',
|
|
13
|
+
default: 'chasi',
|
|
14
|
+
label: ' > please provide a name for your project: ',
|
|
15
|
+
prompted: false,
|
|
16
|
+
prompt: (resolve, reject) => {
|
|
17
|
+
let readliner = requestReadliner();
|
|
18
|
+
readliner.question(chalk.magenta(fields.name.label), (answer) => {
|
|
19
|
+
fields.name.value = answer || fields.name.default;
|
|
20
|
+
console.log(chalk.gray(`\r - name: ${fields.name.value}`));
|
|
21
|
+
readliner.close();
|
|
22
|
+
resolve(answer);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
description: {
|
|
27
|
+
value: '',
|
|
28
|
+
default: 'A Chasi Project',
|
|
29
|
+
label: ' > short description for your app: ',
|
|
30
|
+
prompt: (resolve, reject) => {
|
|
31
|
+
let readliner = requestReadliner();
|
|
32
|
+
return readliner.question(chalk.magenta(fields.description.label), (answer) => {
|
|
33
|
+
fields.description.value = answer || fields.description.default;
|
|
34
|
+
console.log(chalk.gray(`\r - description: ${fields.description.value}`));
|
|
35
|
+
readliner.close();
|
|
36
|
+
resolve(answer);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
version: {
|
|
41
|
+
value: '',
|
|
42
|
+
default: '1.0.0',
|
|
43
|
+
label: ' > app version: ',
|
|
44
|
+
prompt: (resolve, reject) => {
|
|
45
|
+
let readliner = requestReadliner();
|
|
46
|
+
return readliner.question(chalk.magenta(fields.version.label), (answer) => {
|
|
47
|
+
fields.version.value = answer || fields.version.default;
|
|
48
|
+
console.log(chalk.gray(`\r - version: ${fields.version.value}`));
|
|
49
|
+
readliner.close();
|
|
50
|
+
resolve(answer);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
author: {
|
|
55
|
+
value: '',
|
|
56
|
+
default: 'n/a',
|
|
57
|
+
label: ' > project author: ',
|
|
58
|
+
prompt: (resolve, reject) => {
|
|
59
|
+
let readliner = requestReadliner();
|
|
60
|
+
return readliner.question(chalk.magenta(fields.author.label), (answer) => {
|
|
61
|
+
fields.author.value = answer || fields.author.default;
|
|
62
|
+
console.log(chalk.gray(`\r - author: ${fields.author.value}`));
|
|
63
|
+
readliner.close();
|
|
64
|
+
resolve(answer);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
email: {
|
|
69
|
+
value: '',
|
|
70
|
+
default: 'n/a',
|
|
71
|
+
label: ' > email: ',
|
|
72
|
+
prompt: (resolve, reject) => {
|
|
73
|
+
let readliner = requestReadliner();
|
|
74
|
+
return readliner.question(chalk.magenta(fields.email.label), (answer) => {
|
|
75
|
+
fields.email.value = answer || fields.email.default;
|
|
76
|
+
console.log(chalk.gray(`\r - email: ${fields.email.value}`));
|
|
77
|
+
readliner.close();
|
|
78
|
+
resolve(answer);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
export default async () => {
|
|
84
|
+
for (let field in fields) {
|
|
85
|
+
await new Promise((res, rej) => {
|
|
86
|
+
fields[field].prompt(res, rej);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
console.clear();
|
|
90
|
+
await createApp(fields);
|
|
91
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
3
|
+
import { loader } from "../loader.js";
|
|
4
|
+
import path from "path";
|
|
5
|
+
const giturl = 'https://github.com/rocketbean/chasi-ts.git';
|
|
6
|
+
const fieldLabel = (field, key) => {
|
|
7
|
+
return field[key].value || field[key].default;
|
|
8
|
+
};
|
|
9
|
+
const gitApp = async (props, send) => {
|
|
10
|
+
return await new Promise(async (res, rej) => {
|
|
11
|
+
try {
|
|
12
|
+
let message = '';
|
|
13
|
+
let git = await exec(`git clone --depth 1 ${giturl} ${props.name.value}`);
|
|
14
|
+
git.stdout.on("data", (gitData) => {
|
|
15
|
+
message += gitData;
|
|
16
|
+
send(gitData);
|
|
17
|
+
}).on("close", () => {
|
|
18
|
+
send(message);
|
|
19
|
+
res(true);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
rej(e);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const prepare = async (props, send) => {
|
|
28
|
+
return await new Promise(async (res, rej) => {
|
|
29
|
+
try {
|
|
30
|
+
let message = '';
|
|
31
|
+
let prep = await exec(`npm i`, {
|
|
32
|
+
cwd: path.join(process.cwd(), props.name.value)
|
|
33
|
+
});
|
|
34
|
+
prep.stdout.on("data", (data) => {
|
|
35
|
+
message += data;
|
|
36
|
+
}).on("close", () => {
|
|
37
|
+
res(message);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
rej(e);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const configurePackage = async (props, send) => {
|
|
46
|
+
return await new Promise(async (res, rej) => {
|
|
47
|
+
try {
|
|
48
|
+
let strpath = path.join(process.cwd(), props.name.value, "package.json");
|
|
49
|
+
let packageData = JSON.parse((await readFile(strpath)).toString());
|
|
50
|
+
packageData.name = props.name.value;
|
|
51
|
+
packageData.description = fieldLabel(props, "description");
|
|
52
|
+
packageData.version = fieldLabel(props, "version");
|
|
53
|
+
packageData.author = fieldLabel(props, "author");
|
|
54
|
+
packageData.email = fieldLabel(props, "email");
|
|
55
|
+
await writeFile(strpath, JSON.stringify(packageData, null, 2));
|
|
56
|
+
res(true);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
rej(e);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const sanitizeApp = async (props, send) => {
|
|
64
|
+
return await new Promise(async (res, rej) => {
|
|
65
|
+
try {
|
|
66
|
+
let message = '';
|
|
67
|
+
let prep = await exec(`rm -rf .git && ls -la`, {
|
|
68
|
+
cwd: path.join(process.cwd(), props.name.value)
|
|
69
|
+
});
|
|
70
|
+
prep.stdout.on("data", (data) => {
|
|
71
|
+
message += data;
|
|
72
|
+
}).on("close", () => {
|
|
73
|
+
res(message);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
rej(e);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
export default async (props) => {
|
|
82
|
+
const send = (message) => {
|
|
83
|
+
if (message)
|
|
84
|
+
console.log(`\x1b[33m ${message.padStart(10)} \x1b[0m`);
|
|
85
|
+
};
|
|
86
|
+
loader.start("setting up your project");
|
|
87
|
+
await gitApp(props, send).then(data => {
|
|
88
|
+
loader.stop('project setup.... OK');
|
|
89
|
+
});
|
|
90
|
+
loader.start("configuring package info");
|
|
91
|
+
await configurePackage(props, send).then(r => {
|
|
92
|
+
loader.stop('configuration setup.... OK');
|
|
93
|
+
});
|
|
94
|
+
loader.start("installing dependencies");
|
|
95
|
+
await prepare(props, send).then(data => {
|
|
96
|
+
loader.stop('installed dependecies.... OK');
|
|
97
|
+
if (data)
|
|
98
|
+
send(data);
|
|
99
|
+
});
|
|
100
|
+
loader.start("finishing setup");
|
|
101
|
+
await sanitizeApp(props, send).then(data => {
|
|
102
|
+
loader.stop('sanitation... OK');
|
|
103
|
+
if (data)
|
|
104
|
+
send(data);
|
|
105
|
+
});
|
|
106
|
+
return true;
|
|
107
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import create from "./create/Create.js";
|
|
2
|
+
import init from "./init/Init.js";
|
|
3
|
+
export default class Kernel {
|
|
4
|
+
command;
|
|
5
|
+
options;
|
|
6
|
+
args;
|
|
7
|
+
constructor(command, options, args) {
|
|
8
|
+
this.command = command;
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.args = args;
|
|
11
|
+
}
|
|
12
|
+
async create() {
|
|
13
|
+
Object.keys(this.options).forEach((key) => {
|
|
14
|
+
try {
|
|
15
|
+
let option = this.options[key];
|
|
16
|
+
if (option)
|
|
17
|
+
create(key, this.args);
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
console.error(e.message);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async init() {
|
|
25
|
+
init();
|
|
26
|
+
}
|
|
27
|
+
async exec() {
|
|
28
|
+
await this[this.command]();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import readline from "readline";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
export const loader = {
|
|
4
|
+
prop: null,
|
|
5
|
+
start: (message) => {
|
|
6
|
+
loader.prop = loader.load(message);
|
|
7
|
+
},
|
|
8
|
+
stop: (message) => {
|
|
9
|
+
readline.clearLine(process.stdout, 0);
|
|
10
|
+
readline.cursorTo(process.stdout, 0, null);
|
|
11
|
+
process.stdout.write(`\r > ${chalk.bgHex("484276").bold.white(message)}\n`);
|
|
12
|
+
clearInterval(loader.prop);
|
|
13
|
+
},
|
|
14
|
+
load: (message) => {
|
|
15
|
+
let h = ['|', '/', '-', '\\'];
|
|
16
|
+
let i = 0;
|
|
17
|
+
return setInterval(() => {
|
|
18
|
+
i = (i > 3) ? 0 : i;
|
|
19
|
+
let str = `\r > ${message}... ${h[i]}`;
|
|
20
|
+
readline.clearLine(process.stdout, 0);
|
|
21
|
+
readline.cursorTo(process.stdout, 0, null);
|
|
22
|
+
process.stdout.write(chalk.green(str));
|
|
23
|
+
i++;
|
|
24
|
+
}, 90);
|
|
25
|
+
}
|
|
26
|
+
};
|
package/dist/init.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default (name, key) => {
|
|
2
|
+
return `import Controller from "../../package/statics/Controller.js";
|
|
3
|
+
|
|
4
|
+
export default class ${name} extends Controller {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* creates (${key.capitalize()}) ObjectModel[index]
|
|
8
|
+
* @param {request} [ExpressRequest] Object
|
|
9
|
+
* @return {} translated as [ExpressResponse] Object
|
|
10
|
+
* */
|
|
11
|
+
async create(request, response) {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* refers to a single (${key.capitalize()}) ObjectModel[index]
|
|
16
|
+
* @param {request} [ExpressRequest] Object
|
|
17
|
+
* @return {Object} translated as [ExpressResponse] Object
|
|
18
|
+
* */
|
|
19
|
+
async index(request, response) {
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* lists a (${key.capitalize()}) ObjectModel[index]
|
|
24
|
+
* @param {request} [ExpressRequest] Object
|
|
25
|
+
* @return {Object} translated as [ExpressResponse] Object
|
|
26
|
+
*
|
|
27
|
+
* */
|
|
28
|
+
async list(request, response) {}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Delete/s a (${key.capitalize()}) ObjectModel[]
|
|
32
|
+
* @param {request} [ExpressRequest] Object
|
|
33
|
+
* @return {Bool} translated as [ExpressResponse] Object
|
|
34
|
+
*
|
|
35
|
+
* */
|
|
36
|
+
async delete(request, response) {}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Updates a (${key.capitalize()}) ObjectModel[]
|
|
40
|
+
* @param {request} [ExpressRequest] Object
|
|
41
|
+
* @return {Object} translated as [ExpressResponse] Object
|
|
42
|
+
* */
|
|
43
|
+
async update(request, response) {}
|
|
44
|
+
|
|
45
|
+
}`;
|
|
46
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default (name) => {
|
|
2
|
+
return `import Event, { EventInterface } from "../../package/Observer/Event.js";
|
|
3
|
+
|
|
4
|
+
export default class ${name} extends Event implements EventInterface {
|
|
5
|
+
/**
|
|
6
|
+
* @param {params} recieves the Event parameters
|
|
7
|
+
* declared when the event is emitted
|
|
8
|
+
* @param {next} [DO NOT FORGET TO CALL]
|
|
9
|
+
* next when validated
|
|
10
|
+
*/
|
|
11
|
+
async validate(params, next) {
|
|
12
|
+
// validate parameters here.
|
|
13
|
+
|
|
14
|
+
next();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* called when the event is emitted
|
|
19
|
+
* all through out the Chasi Instance
|
|
20
|
+
* @param {params}
|
|
21
|
+
* contains the property that have
|
|
22
|
+
* been passed on emit.
|
|
23
|
+
*/
|
|
24
|
+
async fire(params) {
|
|
25
|
+
// execute actions here...
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default (name) => {
|
|
2
|
+
return `import Model from "../../package/statics/Model.js";
|
|
3
|
+
import mongoose from "mongoose";
|
|
4
|
+
|
|
5
|
+
export interface ${name.capitalize()}Interface extends Document {
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ${name.capitalize()}Model extends mongoose.Model<${name.capitalize()}Interface> {}
|
|
10
|
+
|
|
11
|
+
var ${name.toLowerCase()}Schema = new mongoose.Schema<${name.capitalize()}Interface>({
|
|
12
|
+
name: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
trim: true,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
timestamps: true,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const ${name.capitalize()} = Model.connect<${name.capitalize()}Model>("${name.toLowerCase()}", ${name.toLowerCase()}Schema);
|
|
23
|
+
export type ModelType = ${name.capitalize()}Model;
|
|
24
|
+
export default ${name.capitalize()};
|
|
25
|
+
`;
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default (name) => {
|
|
2
|
+
return `import { ServiceProviderInterface } from "../../package/framework/Interfaces.js";
|
|
3
|
+
import Provider from "../../package/framework/Services/Provider.js";
|
|
4
|
+
|
|
5
|
+
export default class ${name}ServiceProvider extends Provider implements ServiceProviderInterface
|
|
6
|
+
{
|
|
7
|
+
constructor() {}
|
|
8
|
+
|
|
9
|
+
async boot() {
|
|
10
|
+
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
async beforeServerBoot() {}
|
|
14
|
+
}`;
|
|
15
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-chasi-ts",
|
|
3
|
+
"_id": "create-chasi-ts",
|
|
4
|
+
"version": "1.0.6",
|
|
5
|
+
"description": "chasi template",
|
|
6
|
+
"main": "dist/init.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"create-chasi-ts": "dist/init.js",
|
|
13
|
+
"chasi-ts": "./dist/init.js",
|
|
14
|
+
"create": "dist/init.js"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/rocketbean/create-chasi.git"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"chasi-cli",
|
|
25
|
+
"chasi"
|
|
26
|
+
],
|
|
27
|
+
"author": "nikko mesina",
|
|
28
|
+
"email": "buzzrocketbean@gmail.com",
|
|
29
|
+
"license": "ISC",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/rocketbean/chasis/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/rocketbean/chasis#readme",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@rocketbean/create-chasi": "^1.0.5",
|
|
36
|
+
"@types/chalk": "^2.2.0",
|
|
37
|
+
"@types/node": "^20.12.3",
|
|
38
|
+
"chalk": "^5.3.0",
|
|
39
|
+
"commander": "^12.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import controller from "./templates/Controller.js"
|
|
2
|
+
import model from "./templates/Model.js"
|
|
3
|
+
import event from "./templates/Event.js";
|
|
4
|
+
import middleware from "./templates/Middleware.js"
|
|
5
|
+
import provider from "./templates/Provider.js"
|
|
6
|
+
import path from "path"
|
|
7
|
+
Object.defineProperty(String.prototype, 'capitalize', {
|
|
8
|
+
value: function() {
|
|
9
|
+
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
10
|
+
},
|
|
11
|
+
enumerable: false
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const defaults = {
|
|
15
|
+
controller: {
|
|
16
|
+
key: "Controller",
|
|
17
|
+
path: path.join(process.cwd(), "/src/container/controllers/"),
|
|
18
|
+
parseContent: controller,
|
|
19
|
+
},
|
|
20
|
+
event: {
|
|
21
|
+
key: "Event",
|
|
22
|
+
path: path.join(process.cwd(), "/src/container/events/"),
|
|
23
|
+
parseContent: event,
|
|
24
|
+
},
|
|
25
|
+
middleware: {
|
|
26
|
+
key: ".mw",
|
|
27
|
+
path: path.join(process.cwd(), "/src/container/middlewares/"),
|
|
28
|
+
parseContent: middleware,
|
|
29
|
+
},
|
|
30
|
+
provider: {
|
|
31
|
+
key: "ServiceProvider",
|
|
32
|
+
path: path.join(process.cwd(), "/src/container/services/"),
|
|
33
|
+
parseContent: provider,
|
|
34
|
+
},
|
|
35
|
+
model: {
|
|
36
|
+
key: "",
|
|
37
|
+
path: path.join(process.cwd(), "/src/container/models/"),
|
|
38
|
+
parseContent: model,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default {
|
|
43
|
+
defaults,
|
|
44
|
+
format: (option: string, name: any ) => {
|
|
45
|
+
return name.capitalize() + defaults[option].key;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/chasi.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import Kernel, {createOptions} from './commands/kernel.js';
|
|
4
|
+
const program = new Command();
|
|
5
|
+
|
|
6
|
+
program.name("chasis")
|
|
7
|
+
.description(`chasi cli tool`)
|
|
8
|
+
.version(`1.0.0`);
|
|
9
|
+
|
|
10
|
+
program
|
|
11
|
+
.command("create")
|
|
12
|
+
.description(`create new file[s] [controller, model, middleware, provider ]`)
|
|
13
|
+
.argument("<name>", "specifies the name to use.")
|
|
14
|
+
.option("-c , --controller", "creates a new controller")
|
|
15
|
+
.option("-m , --model", "creates a new model")
|
|
16
|
+
.option("-w , --middleware", "creates a new middleware")
|
|
17
|
+
.option("-p , --provider", "creates a new service provider")
|
|
18
|
+
.option("-e , --event", "creates a new event")
|
|
19
|
+
.action((name: string, options: createOptions) => {
|
|
20
|
+
let kernel = new Kernel("create", options, name);
|
|
21
|
+
kernel.exec();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
program.command('init')
|
|
25
|
+
.description(`initializes chasi boilerplate`)
|
|
26
|
+
.action(async () => {
|
|
27
|
+
let kernel = new Kernel("init");
|
|
28
|
+
kernel.exec();
|
|
29
|
+
});
|
|
30
|
+
program.parse();
|
|
31
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import chasi from "../../chasi.config.js"
|
|
2
|
+
import fs from "fs"
|
|
3
|
+
export default (option: string, name: string) => {
|
|
4
|
+
let conf = chasi.defaults[option.toLowerCase()]
|
|
5
|
+
let module = chasi.format(option, name);
|
|
6
|
+
let content = conf.parseContent(module, name)
|
|
7
|
+
try {
|
|
8
|
+
let fullpath = `${conf.path}${module}.ts`
|
|
9
|
+
if (!fs.existsSync(conf.path)){
|
|
10
|
+
fs.mkdirSync(conf.path, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
if (fs.existsSync(fullpath)) throw Error(`[${module}] module already exist`)
|
|
13
|
+
fs.writeFileSync(fullpath, content);
|
|
14
|
+
} catch (err) { throw err; }
|
|
15
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import util from "util";
|
|
2
|
+
import {exec} from "child_process"
|
|
3
|
+
import readline from "readline"
|
|
4
|
+
import createApp from "./create-app.js";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
|
|
7
|
+
const requestReadliner = () => {
|
|
8
|
+
return readline.createInterface({
|
|
9
|
+
input: process.stdin,
|
|
10
|
+
output: process.stdout
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const fields = {
|
|
15
|
+
name: {
|
|
16
|
+
value: '',
|
|
17
|
+
default: 'chasi',
|
|
18
|
+
label: ' > please provide a name for your project: ',
|
|
19
|
+
prompted: false,
|
|
20
|
+
prompt: (resolve, reject)=> {
|
|
21
|
+
let readliner = requestReadliner();
|
|
22
|
+
readliner.question(chalk.magenta(fields.name.label), (answer) => {
|
|
23
|
+
fields.name.value = answer || fields.name.default
|
|
24
|
+
console.log(chalk.gray(`\r - name: ${fields.name.value}`))
|
|
25
|
+
readliner.close();
|
|
26
|
+
resolve(answer)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
description: {
|
|
31
|
+
value: '',
|
|
32
|
+
default: 'A Chasi Project',
|
|
33
|
+
label: ' > short description for your app: ',
|
|
34
|
+
prompt: (resolve, reject) => {
|
|
35
|
+
let readliner = requestReadliner();
|
|
36
|
+
return readliner.question(chalk.magenta(fields.description.label), (answer) => {
|
|
37
|
+
fields.description.value = answer || fields.description.default
|
|
38
|
+
console.log(chalk.gray(`\r - description: ${fields.description.value}`))
|
|
39
|
+
readliner.close();
|
|
40
|
+
resolve(answer)
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
version: {
|
|
45
|
+
value: '',
|
|
46
|
+
default: '1.0.0',
|
|
47
|
+
label: ' > app version: ',
|
|
48
|
+
prompt: (resolve, reject) => {
|
|
49
|
+
let readliner = requestReadliner();
|
|
50
|
+
return readliner.question(chalk.magenta(fields.version.label), (answer) => {
|
|
51
|
+
fields.version.value = answer || fields.version.default
|
|
52
|
+
console.log(chalk.gray(`\r - version: ${fields.version.value}`))
|
|
53
|
+
readliner.close();
|
|
54
|
+
resolve(answer)
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
author: {
|
|
59
|
+
value: '',
|
|
60
|
+
default: 'n/a',
|
|
61
|
+
label: ' > project author: ',
|
|
62
|
+
prompt: (resolve, reject) => {
|
|
63
|
+
let readliner = requestReadliner();
|
|
64
|
+
return readliner.question(chalk.magenta(fields.author.label), (answer) => {
|
|
65
|
+
fields.author.value = answer || fields.author.default
|
|
66
|
+
console.log(chalk.gray(`\r - author: ${fields.author.value}`))
|
|
67
|
+
readliner.close();
|
|
68
|
+
resolve(answer)
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
email: {
|
|
73
|
+
value: '',
|
|
74
|
+
default: 'n/a',
|
|
75
|
+
label: ' > email: ',
|
|
76
|
+
prompt: (resolve, reject) => {
|
|
77
|
+
let readliner = requestReadliner();
|
|
78
|
+
return readliner.question(chalk.magenta(fields.email.label), (answer) => {
|
|
79
|
+
fields.email.value = answer || fields.email.default
|
|
80
|
+
console.log(chalk.gray(`\r - email: ${fields.email.value}`))
|
|
81
|
+
readliner.close();
|
|
82
|
+
resolve(answer)
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default async () => {
|
|
89
|
+
for(let field in fields) {
|
|
90
|
+
await new Promise((res, rej) => {
|
|
91
|
+
fields[field].prompt(res, rej)
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
console.clear();
|
|
95
|
+
await createApp(fields);
|
|
96
|
+
|
|
97
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
|
|
2
|
+
import {exec} from "child_process"
|
|
3
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
4
|
+
import { loader } from "../loader.js";
|
|
5
|
+
import path from "path";
|
|
6
|
+
|
|
7
|
+
const giturl = 'https://github.com/rocketbean/chasi-ts.git'
|
|
8
|
+
|
|
9
|
+
const fieldLabel = (field: any, key: string): string => {
|
|
10
|
+
return field[key].value || field[key].default
|
|
11
|
+
}
|
|
12
|
+
const gitApp= async (props, send) => {
|
|
13
|
+
return await new Promise(async (res, rej) => {
|
|
14
|
+
try {
|
|
15
|
+
let message = '';
|
|
16
|
+
let git = await exec(`git clone --depth 1 ${giturl} ${props.name.value}`);
|
|
17
|
+
git.stdout.on("data", (gitData) => {
|
|
18
|
+
message += gitData;
|
|
19
|
+
send(gitData)
|
|
20
|
+
}).on("close", () => {
|
|
21
|
+
send(message)
|
|
22
|
+
res(true)
|
|
23
|
+
})
|
|
24
|
+
} catch (e) {
|
|
25
|
+
rej(e)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const prepare = async (props, send) => {
|
|
32
|
+
return await new Promise(async (res, rej) => {
|
|
33
|
+
try {
|
|
34
|
+
let message = '';
|
|
35
|
+
let prep = await exec(`npm i`, {
|
|
36
|
+
cwd: path.join(process.cwd(), props.name.value)
|
|
37
|
+
});
|
|
38
|
+
prep.stdout.on("data", (data) => {
|
|
39
|
+
message += data;
|
|
40
|
+
}).on("close", () => {
|
|
41
|
+
res(message)
|
|
42
|
+
})
|
|
43
|
+
} catch (e) {
|
|
44
|
+
rej(e)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const configurePackage = async (props, send) => {
|
|
50
|
+
return await new Promise(async (res, rej) => {
|
|
51
|
+
try {
|
|
52
|
+
let strpath: string = path.join(process.cwd(), props.name.value, "package.json")
|
|
53
|
+
let packageData = JSON.parse((await readFile(strpath)).toString());
|
|
54
|
+
packageData.name = props.name.value;
|
|
55
|
+
packageData.description = fieldLabel(props, "description")
|
|
56
|
+
packageData.version = fieldLabel(props, "version") ;
|
|
57
|
+
packageData.author = fieldLabel(props, "author") ;
|
|
58
|
+
packageData.email = fieldLabel(props, "email") ;
|
|
59
|
+
await writeFile(strpath, JSON.stringify(packageData, null, 2));
|
|
60
|
+
res(true)
|
|
61
|
+
}catch(e){
|
|
62
|
+
rej(e)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const sanitizeApp = async (props, send) => {
|
|
68
|
+
return await new Promise(async (res, rej) => {
|
|
69
|
+
try {
|
|
70
|
+
let message = '';
|
|
71
|
+
let prep = await exec(`rm -rf .git && ls -la`, {
|
|
72
|
+
cwd: path.join(process.cwd(), props.name.value)
|
|
73
|
+
});
|
|
74
|
+
prep.stdout.on("data", (data) => {
|
|
75
|
+
message += data
|
|
76
|
+
}).on("close", () => {
|
|
77
|
+
res(message)
|
|
78
|
+
})
|
|
79
|
+
} catch (e) {
|
|
80
|
+
rej(e)
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
export default async (props) => {
|
|
88
|
+
const send = (message) => {
|
|
89
|
+
if(message) console.log(`\x1b[33m ${message.padStart(10)} \x1b[0m`)
|
|
90
|
+
}
|
|
91
|
+
loader.start("setting up your project");
|
|
92
|
+
await gitApp(props, send).then(data => {
|
|
93
|
+
loader.stop('project setup.... OK');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
loader.start("configuring package info");
|
|
97
|
+
await configurePackage(props, send).then(r => {
|
|
98
|
+
loader.stop('configuration setup.... OK');
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
loader.start("installing dependencies");
|
|
102
|
+
await prepare(props, send).then(data => {
|
|
103
|
+
loader.stop('installed dependecies.... OK');
|
|
104
|
+
if(data) send(data);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
loader.start("finishing setup");
|
|
108
|
+
await sanitizeApp(props, send).then(data => {
|
|
109
|
+
loader.stop('sanitation... OK');
|
|
110
|
+
if(data) send(data);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import create from "./create/Create.js"
|
|
2
|
+
import init from "./init/Init.js"
|
|
3
|
+
export type createOptions = {
|
|
4
|
+
controller?: boolean;
|
|
5
|
+
model?: boolean;
|
|
6
|
+
provider?: boolean;
|
|
7
|
+
middleware?: boolean;
|
|
8
|
+
event?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type command = "create" | "init"
|
|
12
|
+
|
|
13
|
+
export default class Kernel {
|
|
14
|
+
constructor (
|
|
15
|
+
public command: command,
|
|
16
|
+
public options?: createOptions,
|
|
17
|
+
public args?: any) {}
|
|
18
|
+
|
|
19
|
+
async create () {
|
|
20
|
+
Object.keys(this.options).forEach((key: string) => {
|
|
21
|
+
try {
|
|
22
|
+
let option = this.options[key];
|
|
23
|
+
if(option) create(key, this.args)
|
|
24
|
+
} catch (e:any) {
|
|
25
|
+
console.error(e.message);
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async init () {
|
|
31
|
+
init()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async exec() {
|
|
35
|
+
await this[this.command]();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import readline from "readline";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
export const loader = {
|
|
4
|
+
prop: null,
|
|
5
|
+
start: (message: string) => {
|
|
6
|
+
loader.prop = loader.load(message)
|
|
7
|
+
},
|
|
8
|
+
stop: (message: string) => {
|
|
9
|
+
readline.clearLine(process.stdout, 0)
|
|
10
|
+
readline.cursorTo(process.stdout, 0, null)
|
|
11
|
+
process.stdout.write(`\r > ${chalk.bgHex("484276").bold.white(message)}\n`)
|
|
12
|
+
clearInterval(loader.prop);
|
|
13
|
+
},
|
|
14
|
+
load: (message) => {
|
|
15
|
+
let h = ['|', '/', '-', '\\'];
|
|
16
|
+
let i = 0;
|
|
17
|
+
|
|
18
|
+
return setInterval(() => {
|
|
19
|
+
i = (i > 3) ? 0 : i;
|
|
20
|
+
let str = `\r > ${message}... ${h[i]}`;
|
|
21
|
+
readline.clearLine(process.stdout, 0)
|
|
22
|
+
readline.cursorTo(process.stdout, 0, null)
|
|
23
|
+
process.stdout.write(chalk.green(str))
|
|
24
|
+
i++;
|
|
25
|
+
}, 90);
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/init.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default (name, key) => {
|
|
2
|
+
return `import Controller from "../../package/statics/Controller.js";
|
|
3
|
+
|
|
4
|
+
export default class ${name} extends Controller {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* creates (${key.capitalize()}) ObjectModel[index]
|
|
8
|
+
* @param {request} [ExpressRequest] Object
|
|
9
|
+
* @return {} translated as [ExpressResponse] Object
|
|
10
|
+
* */
|
|
11
|
+
async create(request, response) {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* refers to a single (${key.capitalize()}) ObjectModel[index]
|
|
16
|
+
* @param {request} [ExpressRequest] Object
|
|
17
|
+
* @return {Object} translated as [ExpressResponse] Object
|
|
18
|
+
* */
|
|
19
|
+
async index(request, response) {
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* lists a (${key.capitalize()}) ObjectModel[index]
|
|
24
|
+
* @param {request} [ExpressRequest] Object
|
|
25
|
+
* @return {Object} translated as [ExpressResponse] Object
|
|
26
|
+
*
|
|
27
|
+
* */
|
|
28
|
+
async list(request, response) {}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Delete/s a (${key.capitalize()}) ObjectModel[]
|
|
32
|
+
* @param {request} [ExpressRequest] Object
|
|
33
|
+
* @return {Bool} translated as [ExpressResponse] Object
|
|
34
|
+
*
|
|
35
|
+
* */
|
|
36
|
+
async delete(request, response) {}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Updates a (${key.capitalize()}) ObjectModel[]
|
|
40
|
+
* @param {request} [ExpressRequest] Object
|
|
41
|
+
* @return {Object} translated as [ExpressResponse] Object
|
|
42
|
+
* */
|
|
43
|
+
async update(request, response) {}
|
|
44
|
+
|
|
45
|
+
}`
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default (name) => {
|
|
2
|
+
return `import Event, { EventInterface } from "../../package/Observer/Event.js";
|
|
3
|
+
|
|
4
|
+
export default class ${name} extends Event implements EventInterface {
|
|
5
|
+
/**
|
|
6
|
+
* @param {params} recieves the Event parameters
|
|
7
|
+
* declared when the event is emitted
|
|
8
|
+
* @param {next} [DO NOT FORGET TO CALL]
|
|
9
|
+
* next when validated
|
|
10
|
+
*/
|
|
11
|
+
async validate(params, next) {
|
|
12
|
+
// validate parameters here.
|
|
13
|
+
|
|
14
|
+
next();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* called when the event is emitted
|
|
19
|
+
* all through out the Chasi Instance
|
|
20
|
+
* @param {params}
|
|
21
|
+
* contains the property that have
|
|
22
|
+
* been passed on emit.
|
|
23
|
+
*/
|
|
24
|
+
async fire(params) {
|
|
25
|
+
// execute actions here...
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
export default (name) => {
|
|
3
|
+
return `import Model from "../../package/statics/Model.js";
|
|
4
|
+
import mongoose from "mongoose";
|
|
5
|
+
|
|
6
|
+
export interface ${name.capitalize()}Interface extends Document {
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ${name.capitalize()}Model extends mongoose.Model<${name.capitalize()}Interface> {}
|
|
11
|
+
|
|
12
|
+
var ${name.toLowerCase()}Schema = new mongoose.Schema<${name.capitalize()}Interface>({
|
|
13
|
+
name: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true,
|
|
16
|
+
trim: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
timestamps: true,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const ${name.capitalize()} = Model.connect<${name.capitalize()}Model>("${name.toLowerCase()}", ${name.toLowerCase()}Schema);
|
|
24
|
+
export type ModelType = ${name.capitalize()}Model;
|
|
25
|
+
export default ${name.capitalize()};
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default (name) => {
|
|
2
|
+
return `import { ServiceProviderInterface } from "../../package/framework/Interfaces.js";
|
|
3
|
+
import Provider from "../../package/framework/Services/Provider.js";
|
|
4
|
+
|
|
5
|
+
export default class ${name}ServiceProvider extends Provider implements ServiceProviderInterface
|
|
6
|
+
{
|
|
7
|
+
constructor() {}
|
|
8
|
+
|
|
9
|
+
async boot() {
|
|
10
|
+
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
async beforeServerBoot() {}
|
|
14
|
+
}`;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"lib": ["DOM", "DOM.Iterable", "ScriptHost", "ESNext"],
|
|
5
|
+
"typeRoots": ["node_modules/@types", "node_modules/types"],
|
|
6
|
+
"allowJs": true,
|
|
7
|
+
"module": "NodeNext",
|
|
8
|
+
"moduleResolution": "NodeNext",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"rootDir": "./src",
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"removeComments": false,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
/* Type Checking */
|
|
15
|
+
"strict": true,
|
|
16
|
+
"strictNullChecks": false,
|
|
17
|
+
"noImplicitAny": false,
|
|
18
|
+
"noImplicitReturns": false,
|
|
19
|
+
"noEmitOnError": true,
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
"experimentalDecorators": true,
|
|
22
|
+
"types": ["node"],
|
|
23
|
+
},
|
|
24
|
+
"exclude": [
|
|
25
|
+
"dist",
|
|
26
|
+
"src/container/**/*.*",
|
|
27
|
+
"app"
|
|
28
|
+
]
|
|
29
|
+
}
|