@webtypen/webframez-core 0.0.19 → 0.0.20
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/lib/Commands/BuildFinishCommand.d.ts +6 -0
- package/lib/Commands/BuildFinishCommand.js +50 -0
- package/lib/Commands/ConsoleCommand.d.ts +5 -0
- package/lib/Commands/ConsoleCommand.js +18 -0
- package/lib/ConsoleApplication.d.ts +6 -0
- package/lib/ConsoleApplication.js +46 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +2 -1
- package/src/Commands/BuildFinishCommand.ts +38 -0
- package/src/Commands/ConsoleCommand.ts +6 -0
- package/src/ConsoleApplication.ts +38 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BuildFinishCommand = void 0;
|
|
16
|
+
const child_process_1 = require("child_process");
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
18
|
+
const ConsoleCommand_1 = require("./ConsoleCommand");
|
|
19
|
+
class BuildFinishCommand extends ConsoleCommand_1.ConsoleCommand {
|
|
20
|
+
handle() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const buildDir = process.cwd() + "/build";
|
|
23
|
+
const nodeModulesDir = process.cwd() + "/node_modules";
|
|
24
|
+
if (!fs_1.default.existsSync(buildDir)) {
|
|
25
|
+
throw new Error("Missing build folder `" + buildDir + "` ...");
|
|
26
|
+
}
|
|
27
|
+
if (!fs_1.default.existsSync(nodeModulesDir)) {
|
|
28
|
+
throw new Error("Missing node_modules folder `" + nodeModulesDir + "` ...");
|
|
29
|
+
}
|
|
30
|
+
// Prepare node_modules/
|
|
31
|
+
if (fs_1.default.existsSync(buildDir + "/node_modules")) {
|
|
32
|
+
(0, child_process_1.execSync)("rm -rf " + buildDir + "/node_modules");
|
|
33
|
+
}
|
|
34
|
+
(0, child_process_1.execSync)("cp -r " + nodeModulesDir + " " + buildDir + "/node_modules");
|
|
35
|
+
// Prepare files
|
|
36
|
+
const copyFiles = [".env", "package.json", "package-lock.json", "README.md", ".gitignore"];
|
|
37
|
+
for (let file of copyFiles) {
|
|
38
|
+
if (fs_1.default.existsSync(buildDir + "/" + file)) {
|
|
39
|
+
(0, child_process_1.execSync)("rm " + buildDir + "/" + file);
|
|
40
|
+
}
|
|
41
|
+
if (fs_1.default.existsSync(buildDir + "/" + file)) {
|
|
42
|
+
(0, child_process_1.execSync)("cp " + process.cwd() + "/" + file + " " + buildDir + "/" + file);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.BuildFinishCommand = BuildFinishCommand;
|
|
49
|
+
BuildFinishCommand.signature = "build";
|
|
50
|
+
BuildFinishCommand.description = "Creates a new production-build";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ConsoleCommand = void 0;
|
|
13
|
+
class ConsoleCommand {
|
|
14
|
+
handle() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ConsoleCommand = ConsoleCommand;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ConsoleApplication = void 0;
|
|
13
|
+
const { Command } = require("commander");
|
|
14
|
+
const Config_1 = require("./Config");
|
|
15
|
+
const BuildFinishCommand_1 = require("./Commands/BuildFinishCommand");
|
|
16
|
+
class ConsoleApplication {
|
|
17
|
+
/**
|
|
18
|
+
* Init the routes and start the http-server
|
|
19
|
+
*/
|
|
20
|
+
boot(options) {
|
|
21
|
+
if (options && options.config) {
|
|
22
|
+
for (let key in options.config) {
|
|
23
|
+
Config_1.Config.register(key, options.config[key]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const program = new Command();
|
|
27
|
+
program.name("webframez console").description("CLI to some JavaScript string utilities").version("0.0.1");
|
|
28
|
+
const systemCommands = [BuildFinishCommand_1.BuildFinishCommand];
|
|
29
|
+
for (let command of systemCommands) {
|
|
30
|
+
if (!command.signature) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const consoleCommand = new Command(command.signature);
|
|
34
|
+
if (command.description && command.description.trim() !== "") {
|
|
35
|
+
consoleCommand.description(command.description);
|
|
36
|
+
}
|
|
37
|
+
consoleCommand.action(() => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const service = yield new command();
|
|
39
|
+
return yield service.handle();
|
|
40
|
+
}));
|
|
41
|
+
program.addCommand(consoleCommand);
|
|
42
|
+
}
|
|
43
|
+
program.parse();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ConsoleApplication = ConsoleApplication;
|
package/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./BaseKernelWeb";
|
|
|
3
3
|
export * from "./BaseKernelConsole";
|
|
4
4
|
export * from "./Controller/Controller";
|
|
5
5
|
export * from "./Database/Model";
|
|
6
|
+
export * from "./ConsoleApplication";
|
|
6
7
|
export * from "./WebApplication";
|
|
7
8
|
export * from "./Router/Route";
|
|
8
9
|
export * from "./Router/Request";
|
package/lib/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./BaseKernelWeb"), exports);
|
|
|
19
19
|
__exportStar(require("./BaseKernelConsole"), exports);
|
|
20
20
|
__exportStar(require("./Controller/Controller"), exports);
|
|
21
21
|
__exportStar(require("./Database/Model"), exports);
|
|
22
|
+
__exportStar(require("./ConsoleApplication"), exports);
|
|
22
23
|
__exportStar(require("./WebApplication"), exports);
|
|
23
24
|
__exportStar(require("./Router/Route"), exports);
|
|
24
25
|
__exportStar(require("./Router/Request"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webtypen/webframez-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "The core package of the typescript based webframez (web-framework) by webtypen.de",
|
|
5
5
|
"homepage": "https://webtypen.de/",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"dotenv": "^8.2.0",
|
|
33
33
|
"lodash": "^4.17.20",
|
|
34
|
+
"commander": "^9.4.1",
|
|
34
35
|
"qs": "^6.11.0"
|
|
35
36
|
}
|
|
36
37
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { exec, execSync } from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { ConsoleCommand } from "./ConsoleCommand";
|
|
4
|
+
|
|
5
|
+
export class BuildFinishCommand extends ConsoleCommand {
|
|
6
|
+
static signature = "build";
|
|
7
|
+
static description = "Creates a new production-build";
|
|
8
|
+
|
|
9
|
+
async handle() {
|
|
10
|
+
const buildDir = process.cwd() + "/build";
|
|
11
|
+
const nodeModulesDir = process.cwd() + "/node_modules";
|
|
12
|
+
if (!fs.existsSync(buildDir)) {
|
|
13
|
+
throw new Error("Missing build folder `" + buildDir + "` ...");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (!fs.existsSync(nodeModulesDir)) {
|
|
17
|
+
throw new Error("Missing node_modules folder `" + nodeModulesDir + "` ...");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Prepare node_modules/
|
|
21
|
+
if (fs.existsSync(buildDir + "/node_modules")) {
|
|
22
|
+
execSync("rm -rf " + buildDir + "/node_modules");
|
|
23
|
+
}
|
|
24
|
+
execSync("cp -r " + nodeModulesDir + " " + buildDir + "/node_modules");
|
|
25
|
+
|
|
26
|
+
// Prepare files
|
|
27
|
+
const copyFiles = [".env", "package.json", "package-lock.json", "README.md", ".gitignore"];
|
|
28
|
+
for (let file of copyFiles) {
|
|
29
|
+
if (fs.existsSync(buildDir + "/" + file)) {
|
|
30
|
+
execSync("rm " + buildDir + "/" + file);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (fs.existsSync(buildDir + "/" + file)) {
|
|
34
|
+
execSync("cp " + process.cwd() + "/" + file + " " + buildDir + "/" + file);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const { Command } = require("commander");
|
|
2
|
+
import { Config } from "./Config";
|
|
3
|
+
import { BuildFinishCommand } from "./Commands/BuildFinishCommand";
|
|
4
|
+
|
|
5
|
+
export class ConsoleApplication {
|
|
6
|
+
/**
|
|
7
|
+
* Init the routes and start the http-server
|
|
8
|
+
*/
|
|
9
|
+
boot(options?: any) {
|
|
10
|
+
if (options && options.config) {
|
|
11
|
+
for (let key in options.config) {
|
|
12
|
+
Config.register(key, options.config[key]);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const program = new Command();
|
|
17
|
+
program.name("webframez console").description("CLI to some JavaScript string utilities").version("0.0.1");
|
|
18
|
+
|
|
19
|
+
const systemCommands = [BuildFinishCommand];
|
|
20
|
+
for (let command of systemCommands) {
|
|
21
|
+
if (!command.signature) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const consoleCommand = new Command(command.signature);
|
|
26
|
+
if (command.description && command.description.trim() !== "") {
|
|
27
|
+
consoleCommand.description(command.description);
|
|
28
|
+
}
|
|
29
|
+
consoleCommand.action(async () => {
|
|
30
|
+
const service = await new command();
|
|
31
|
+
return await service.handle();
|
|
32
|
+
});
|
|
33
|
+
program.addCommand(consoleCommand);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
program.parse();
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./BaseKernelWeb";
|
|
|
3
3
|
export * from "./BaseKernelConsole";
|
|
4
4
|
export * from "./Controller/Controller";
|
|
5
5
|
export * from "./Database/Model";
|
|
6
|
+
export * from "./ConsoleApplication";
|
|
6
7
|
export * from "./WebApplication";
|
|
7
8
|
export * from "./Router/Route";
|
|
8
9
|
export * from "./Router/Request";
|