hotstaq 0.5.24
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/.eslintignore +17 -0
- package/.eslintrc.js +11 -0
- package/.vscode/launch.json +199 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +78 -0
- package/CONTRIBUTING.md +157 -0
- package/README.md +126 -0
- package/bin/hotstaq +3 -0
- package/bin/hotstaq.cmd +1 -0
- package/build/src/Hot.d.ts +167 -0
- package/build/src/Hot.d.ts.map +1 -0
- package/build/src/Hot.js +365 -0
- package/build/src/Hot.js.map +1 -0
- package/build/src/HotAPI.d.ts +130 -0
- package/build/src/HotAPI.d.ts.map +1 -0
- package/build/src/HotAPI.js +353 -0
- package/build/src/HotAPI.js.map +1 -0
- package/build/src/HotAgentAPI.d.ts +22 -0
- package/build/src/HotAgentAPI.d.ts.map +1 -0
- package/build/src/HotAgentAPI.js +85 -0
- package/build/src/HotAgentAPI.js.map +1 -0
- package/build/src/HotAgentRoute.d.ts +17 -0
- package/build/src/HotAgentRoute.d.ts.map +1 -0
- package/build/src/HotAgentRoute.js +109 -0
- package/build/src/HotAgentRoute.js.map +1 -0
- package/build/src/HotBuilder.d.ts +52 -0
- package/build/src/HotBuilder.d.ts.map +1 -0
- package/build/src/HotBuilder.js +239 -0
- package/build/src/HotBuilder.js.map +1 -0
- package/build/src/HotClient.d.ts +31 -0
- package/build/src/HotClient.d.ts.map +1 -0
- package/build/src/HotClient.js +19 -0
- package/build/src/HotClient.js.map +1 -0
- package/build/src/HotComponent.d.ts +118 -0
- package/build/src/HotComponent.d.ts.map +1 -0
- package/build/src/HotComponent.js +89 -0
- package/build/src/HotComponent.js.map +1 -0
- package/build/src/HotCreator.d.ts +92 -0
- package/build/src/HotCreator.d.ts.map +1 -0
- package/build/src/HotCreator.js +465 -0
- package/build/src/HotCreator.js.map +1 -0
- package/build/src/HotDB.d.ts +69 -0
- package/build/src/HotDB.d.ts.map +1 -0
- package/build/src/HotDB.js +29 -0
- package/build/src/HotDB.js.map +1 -0
- package/build/src/HotDBConnectionInterface.d.ts +40 -0
- package/build/src/HotDBConnectionInterface.d.ts.map +1 -0
- package/build/src/HotDBConnectionInterface.js +3 -0
- package/build/src/HotDBConnectionInterface.js.map +1 -0
- package/build/src/HotFile.d.ts +134 -0
- package/build/src/HotFile.d.ts.map +1 -0
- package/build/src/HotFile.js +454 -0
- package/build/src/HotFile.js.map +1 -0
- package/build/src/HotHTTPServer.d.ts +162 -0
- package/build/src/HotHTTPServer.d.ts.map +1 -0
- package/build/src/HotHTTPServer.js +863 -0
- package/build/src/HotHTTPServer.js.map +1 -0
- package/build/src/HotIO.d.ts +39 -0
- package/build/src/HotIO.d.ts.map +1 -0
- package/build/src/HotIO.js +195 -0
- package/build/src/HotIO.js.map +1 -0
- package/build/src/HotLog.d.ts +60 -0
- package/build/src/HotLog.d.ts.map +1 -0
- package/build/src/HotLog.js +126 -0
- package/build/src/HotLog.js.map +1 -0
- package/build/src/HotPage.d.ts +125 -0
- package/build/src/HotPage.d.ts.map +1 -0
- package/build/src/HotPage.js +178 -0
- package/build/src/HotPage.js.map +1 -0
- package/build/src/HotRoute.d.ts +82 -0
- package/build/src/HotRoute.d.ts.map +1 -0
- package/build/src/HotRoute.js +83 -0
- package/build/src/HotRoute.js.map +1 -0
- package/build/src/HotRouteMethod.d.ts +129 -0
- package/build/src/HotRouteMethod.d.ts.map +1 -0
- package/build/src/HotRouteMethod.js +84 -0
- package/build/src/HotRouteMethod.js.map +1 -0
- package/build/src/HotServer.d.ts +152 -0
- package/build/src/HotServer.d.ts.map +1 -0
- package/build/src/HotServer.js +109 -0
- package/build/src/HotServer.js.map +1 -0
- package/build/src/HotSetAsWeb.d.ts +2 -0
- package/build/src/HotSetAsWeb.d.ts.map +1 -0
- package/build/src/HotSetAsWeb.js +5 -0
- package/build/src/HotSetAsWeb.js.map +1 -0
- package/build/src/HotStaq.d.ts +601 -0
- package/build/src/HotStaq.d.ts.map +1 -0
- package/build/src/HotStaq.js +1258 -0
- package/build/src/HotStaq.js.map +1 -0
- package/build/src/HotStaqWeb.d.ts +18 -0
- package/build/src/HotStaqWeb.d.ts.map +1 -0
- package/build/src/HotStaqWeb.js +44 -0
- package/build/src/HotStaqWeb.js.map +1 -0
- package/build/src/HotTestDriver.d.ts +63 -0
- package/build/src/HotTestDriver.d.ts.map +1 -0
- package/build/src/HotTestDriver.js +187 -0
- package/build/src/HotTestDriver.js.map +1 -0
- package/build/src/HotTestElement.d.ts +71 -0
- package/build/src/HotTestElement.d.ts.map +1 -0
- package/build/src/HotTestElement.js +37 -0
- package/build/src/HotTestElement.js.map +1 -0
- package/build/src/HotTestMap.d.ts +83 -0
- package/build/src/HotTestMap.d.ts.map +1 -0
- package/build/src/HotTestMap.js +58 -0
- package/build/src/HotTestMap.js.map +1 -0
- package/build/src/HotTestSeleniumDriver.d.ts +82 -0
- package/build/src/HotTestSeleniumDriver.d.ts.map +1 -0
- package/build/src/HotTestSeleniumDriver.js +398 -0
- package/build/src/HotTestSeleniumDriver.js.map +1 -0
- package/build/src/HotTester.d.ts +188 -0
- package/build/src/HotTester.d.ts.map +1 -0
- package/build/src/HotTester.js +623 -0
- package/build/src/HotTester.js.map +1 -0
- package/build/src/HotTesterAPI.d.ts +15 -0
- package/build/src/HotTesterAPI.d.ts.map +1 -0
- package/build/src/HotTesterAPI.js +161 -0
- package/build/src/HotTesterAPI.js.map +1 -0
- package/build/src/HotTesterMocha.d.ts +50 -0
- package/build/src/HotTesterMocha.d.ts.map +1 -0
- package/build/src/HotTesterMocha.js +205 -0
- package/build/src/HotTesterMocha.js.map +1 -0
- package/build/src/HotTesterMochaSelenium.d.ts +70 -0
- package/build/src/HotTesterMochaSelenium.d.ts.map +1 -0
- package/build/src/HotTesterMochaSelenium.js +257 -0
- package/build/src/HotTesterMochaSelenium.js.map +1 -0
- package/build/src/HotTesterServer.d.ts +114 -0
- package/build/src/HotTesterServer.d.ts.map +1 -0
- package/build/src/HotTesterServer.js +575 -0
- package/build/src/HotTesterServer.js.map +1 -0
- package/build/src/api.d.ts +33 -0
- package/build/src/api.d.ts.map +1 -0
- package/build/src/api.js +78 -0
- package/build/src/api.js.map +1 -0
- package/build/src/cli.d.ts +2 -0
- package/build/src/cli.d.ts.map +1 -0
- package/build/src/cli.js +935 -0
- package/build/src/cli.js.map +1 -0
- package/build/src/schemas/HotDBInflux.d.ts +63 -0
- package/build/src/schemas/HotDBInflux.d.ts.map +1 -0
- package/build/src/schemas/HotDBInflux.js +239 -0
- package/build/src/schemas/HotDBInflux.js.map +1 -0
- package/build/src/schemas/HotDBMigration.d.ts +19 -0
- package/build/src/schemas/HotDBMigration.d.ts.map +1 -0
- package/build/src/schemas/HotDBMigration.js +15 -0
- package/build/src/schemas/HotDBMigration.js.map +1 -0
- package/build/src/schemas/HotDBMySQL.d.ts +65 -0
- package/build/src/schemas/HotDBMySQL.d.ts.map +1 -0
- package/build/src/schemas/HotDBMySQL.js +387 -0
- package/build/src/schemas/HotDBMySQL.js.map +1 -0
- package/build/src/schemas/HotDBSchema.d.ts +15 -0
- package/build/src/schemas/HotDBSchema.d.ts.map +1 -0
- package/build/src/schemas/HotDBSchema.js +19 -0
- package/build/src/schemas/HotDBSchema.js.map +1 -0
- package/build/src/schemas/influx/InfluxSchema.d.ts +14 -0
- package/build/src/schemas/influx/InfluxSchema.d.ts.map +1 -0
- package/build/src/schemas/influx/InfluxSchema.js +33 -0
- package/build/src/schemas/influx/InfluxSchema.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchema.d.ts +39 -0
- package/build/src/schemas/mysql/MySQLSchema.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchema.js +151 -0
- package/build/src/schemas/mysql/MySQLSchema.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaField.d.ts +168 -0
- package/build/src/schemas/mysql/MySQLSchemaField.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaField.js +260 -0
- package/build/src/schemas/mysql/MySQLSchemaField.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.d.ts +49 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.js +310 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.js.map +1 -0
- package/build-web/HotStaq.js +2 -0
- package/build-web/HotStaq.min.js +125 -0
- package/builder/docker/Dockerfile.linux.gen +42 -0
- package/builder/docker/README.md +36 -0
- package/builder/docker/app/start.sh +8 -0
- package/builder/docker/dockerignore +3 -0
- package/builder/docker/scripts/build.bat +11 -0
- package/builder/docker/scripts/build.sh +11 -0
- package/builder/docker/scripts/start-app.bat +7 -0
- package/builder/docker/scripts/start-app.sh +7 -0
- package/builder/docker/scripts/stop-app.bat +5 -0
- package/builder/docker/scripts/stop-app.sh +5 -0
- package/builder/docker-compose/docker-compose.gen.yaml +41 -0
- package/builder/docker-compose/env-skeleton +4 -0
- package/creator/project/.vscode/launch.json +59 -0
- package/creator/project/README.md +20 -0
- package/creator/project/gitignore +118 -0
- package/creator/project/npmignore +118 -0
- package/creator/public/api-test.hott +28 -0
- package/creator/public/index.hott +12 -0
- package/creator/ts/src/AppAPI.ts +30 -0
- package/creator/ts/src/HelloWorld.ts +39 -0
- package/creator/ts/src/WebExport.ts +7 -0
- package/creator/ts/tsconfig-web.json +73 -0
- package/creator/ts/tsconfig.json +73 -0
- package/creator/ts/webpack-api.config.js +57 -0
- package/dbstart.sh +19 -0
- package/dbstop.sh +4 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +128 -0
- package/docs/classes/Hot.md +477 -0
- package/docs/classes/HotAPI.md +369 -0
- package/docs/classes/HotClient.md +95 -0
- package/docs/classes/HotComponent.md +279 -0
- package/docs/classes/HotDB.md +247 -0
- package/docs/classes/HotDBInflux.md +404 -0
- package/docs/classes/HotDBMigration.md +80 -0
- package/docs/classes/HotDBMySQL.md +310 -0
- package/docs/classes/HotDBSchema.md +51 -0
- package/docs/classes/HotFile.md +353 -0
- package/docs/classes/HotHTTPServer.md +700 -0
- package/docs/classes/HotLog.md +162 -0
- package/docs/classes/HotPage.md +357 -0
- package/docs/classes/HotRoute.md +312 -0
- package/docs/classes/HotRouteMethod.md +271 -0
- package/docs/classes/HotServer.md +311 -0
- package/docs/classes/HotStaq.md +1153 -0
- package/docs/classes/HotTestDestination.md +58 -0
- package/docs/classes/HotTestDriver.md +332 -0
- package/docs/classes/HotTestElement.md +88 -0
- package/docs/classes/HotTestElementOptions.md +71 -0
- package/docs/classes/HotTestMap.md +92 -0
- package/docs/classes/HotTestSeleniumDriver.md +529 -0
- package/docs/classes/HotTester.md +653 -0
- package/docs/classes/HotTesterAPI.md +493 -0
- package/docs/classes/HotTesterMocha.md +843 -0
- package/docs/classes/HotTesterMochaSelenium.md +896 -0
- package/docs/classes/HotTesterServer.md +633 -0
- package/docs/classes/InfluxSchema.md +74 -0
- package/docs/classes/MySQLSchema.md +199 -0
- package/docs/classes/MySQLSchemaField.md +330 -0
- package/docs/classes/MySQLSchemaTable.md +176 -0
- package/docs/enums/ConnectionStatus.md +43 -0
- package/docs/enums/DeveloperMode.md +38 -0
- package/docs/enums/EventExecutionType.md +43 -0
- package/docs/enums/HTTPMethod.md +32 -0
- package/docs/enums/HotDBGenerationType.md +30 -0
- package/docs/enums/HotLogLevel.md +88 -0
- package/docs/interfaces/HotDBConnectionInterface.md +116 -0
- package/docs/interfaces/HotDestination.md +62 -0
- package/docs/interfaces/HotSite.md +187 -0
- package/docs/interfaces/HotSiteMapPath.md +37 -0
- package/docs/interfaces/HotSiteRoute.md +79 -0
- package/docs/interfaces/HotStartOptions.md +115 -0
- package/docs/interfaces/HotTestPage.md +44 -0
- package/docs/interfaces/HotTestStop.md +62 -0
- package/docs/interfaces/IHotComponent.md +135 -0
- package/docs/interfaces/IHotStaq.md +118 -0
- package/docs/interfaces/IHotTestElement.md +54 -0
- package/docs/interfaces/IHotTestElementOptions.md +43 -0
- package/docs/interfaces/MySQLResults.md +43 -0
- package/docs/interfaces/MySQLSchemaFieldResult.md +75 -0
- package/docs/modules.md +162 -0
- package/package.json +65 -0
- package/selenium-start.sh +7 -0
- package/selenium-stop.sh +3 -0
- package/src/Hot.ts +319 -0
- package/src/HotAPI.ts +378 -0
- package/src/HotAgentAPI.ts +43 -0
- package/src/HotAgentRoute.ts +44 -0
- package/src/HotBuilder.ts +221 -0
- package/src/HotClient.ts +40 -0
- package/src/HotComponent.ts +158 -0
- package/src/HotCreator.ts +482 -0
- package/src/HotDB.ts +79 -0
- package/src/HotDBConnectionInterface.ts +40 -0
- package/src/HotFile.ts +617 -0
- package/src/HotHTTPServer.ts +954 -0
- package/src/HotIO.ts +128 -0
- package/src/HotLog.ts +158 -0
- package/src/HotPage.ts +206 -0
- package/src/HotRoute.ts +137 -0
- package/src/HotRouteMethod.ts +216 -0
- package/src/HotServer.ts +211 -0
- package/src/HotSetAsWeb.ts +3 -0
- package/src/HotStaq.ts +1877 -0
- package/src/HotStaqWeb.ts +59 -0
- package/src/HotTestDriver.ts +172 -0
- package/src/HotTestElement.ts +97 -0
- package/src/HotTestMap.ts +130 -0
- package/src/HotTestSeleniumDriver.ts +374 -0
- package/src/HotTester.ts +697 -0
- package/src/HotTesterAPI.ts +126 -0
- package/src/HotTesterMocha.ts +133 -0
- package/src/HotTesterMochaSelenium.ts +189 -0
- package/src/HotTesterServer.ts +551 -0
- package/src/api.ts +102 -0
- package/src/cli.ts +1147 -0
- package/src/schemas/HotDBInflux.ts +211 -0
- package/src/schemas/HotDBMigration.ts +24 -0
- package/src/schemas/HotDBMySQL.ts +312 -0
- package/src/schemas/HotDBSchema.ts +21 -0
- package/src/schemas/influx/InfluxSchema.ts +19 -0
- package/src/schemas/mysql/MySQLSchema.ts +90 -0
- package/src/schemas/mysql/MySQLSchemaField.ts +408 -0
- package/src/schemas/mysql/MySQLSchemaTable.ts +353 -0
- package/tsconfig-web.json +74 -0
- package/tsconfig.json +73 -0
- package/webpack.config.js +51 -0
- package/webpack.config.tests.js +56 -0
package/src/cli.ts
ADDED
|
@@ -0,0 +1,1147 @@
|
|
|
1
|
+
import * as ppath from "path";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
|
|
4
|
+
import * as commander from "commander";
|
|
5
|
+
|
|
6
|
+
import { HotStaq } from "./HotStaq";
|
|
7
|
+
import { HotHTTPServer } from "./HotHTTPServer";
|
|
8
|
+
import { HotLogLevel } from "./HotLog";
|
|
9
|
+
import { DeveloperMode } from "./Hot";
|
|
10
|
+
import { HotTesterServer } from "./HotTesterServer";
|
|
11
|
+
import { HotBuilder } from "./HotBuilder";
|
|
12
|
+
import { HotCreator } from "./HotCreator";
|
|
13
|
+
import { HotDBConnectionInterface } from "./HotDBConnectionInterface";
|
|
14
|
+
import { HotAPI } from "./HotAPI";
|
|
15
|
+
import { HotTesterMochaSelenium } from "./HotTesterMochaSelenium";
|
|
16
|
+
import { HotDBMySQL } from "./schemas/HotDBMySQL";
|
|
17
|
+
import { HotIO } from "./HotIO";
|
|
18
|
+
import { HotAgentAPI } from "./HotAgentAPI";
|
|
19
|
+
import { HotTester } from "./HotTester";
|
|
20
|
+
import { HotTesterMocha } from "./HotTesterMocha";
|
|
21
|
+
|
|
22
|
+
HotStaq.isWeb = false;
|
|
23
|
+
|
|
24
|
+
let VERSION: string = "";
|
|
25
|
+
let processor: HotStaq = new HotStaq ();
|
|
26
|
+
processor.logger.logLevel = HotLogLevel.All;
|
|
27
|
+
|
|
28
|
+
let hotsitePath: string = "";
|
|
29
|
+
let globalLogLevel: HotLogLevel = null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The API to load.
|
|
33
|
+
*/
|
|
34
|
+
type APItoLoad = {
|
|
35
|
+
exportedClassName: string;
|
|
36
|
+
path: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Start the API server.
|
|
41
|
+
*/
|
|
42
|
+
async function startAPIServer (server: HotHTTPServer, loadedAPI: APItoLoad, baseAPIUrl:
|
|
43
|
+
string, dbinfo: HotDBConnectionInterface, isAPIOnly: boolean): Promise<HotAPI>
|
|
44
|
+
{
|
|
45
|
+
process.chdir (process.cwd ());
|
|
46
|
+
let foundModulePath = require.resolve (loadedAPI.path, { paths: [process.cwd ()] });
|
|
47
|
+
let apiJS = require (foundModulePath);
|
|
48
|
+
let apiClass: any = apiJS[loadedAPI.exportedClassName];
|
|
49
|
+
let api: HotAPI = new apiClass (baseAPIUrl, server);
|
|
50
|
+
|
|
51
|
+
server.logger.info (`Loaded API class: ${loadedAPI.exportedClassName}`);
|
|
52
|
+
|
|
53
|
+
server.processor.api = api;
|
|
54
|
+
server.api = api;
|
|
55
|
+
|
|
56
|
+
if (isAPIOnly === true)
|
|
57
|
+
{
|
|
58
|
+
server.addRoute ("/", async (req: any, res: any) =>
|
|
59
|
+
{
|
|
60
|
+
res.json ({ "status": "ok" });
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (dbinfo != null)
|
|
65
|
+
{
|
|
66
|
+
let dbClass = null;
|
|
67
|
+
|
|
68
|
+
if (dbinfo.type === "mysql")
|
|
69
|
+
dbClass = HotDBMySQL;
|
|
70
|
+
|
|
71
|
+
api.db = new dbClass ();
|
|
72
|
+
await server.setAPI (api);
|
|
73
|
+
|
|
74
|
+
if (dbinfo.username === "")
|
|
75
|
+
throw new Error (`No database username provided!`);
|
|
76
|
+
|
|
77
|
+
if (dbinfo.password === "")
|
|
78
|
+
throw new Error (`No database password provided!`);
|
|
79
|
+
|
|
80
|
+
await api.db.connect (dbinfo);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return (api);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get a key/value pair from a string.
|
|
88
|
+
*/
|
|
89
|
+
function getKeyValuePair (str: string): { key: string; value: string; }
|
|
90
|
+
{
|
|
91
|
+
let pos: number = str.indexOf ("=");
|
|
92
|
+
let key: string = "";
|
|
93
|
+
let value: string = "";
|
|
94
|
+
|
|
95
|
+
if (pos > -1)
|
|
96
|
+
{
|
|
97
|
+
key = str.substr (0, pos);
|
|
98
|
+
value = str.substr (pos + 1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return ({ key: key, value: value });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Handle any build commands.
|
|
106
|
+
*/
|
|
107
|
+
async function handleBuildCommands (): Promise<commander.Command>
|
|
108
|
+
{
|
|
109
|
+
let builder: HotBuilder = null;
|
|
110
|
+
let createHotBuilder = () =>
|
|
111
|
+
{
|
|
112
|
+
if (builder == null)
|
|
113
|
+
builder = new HotBuilder ();
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const buildCmd: commander.Command = new commander.Command ("build");
|
|
117
|
+
buildCmd.description (`Build commands.`);
|
|
118
|
+
buildCmd.action (async () =>
|
|
119
|
+
{
|
|
120
|
+
createHotBuilder ();
|
|
121
|
+
|
|
122
|
+
if (hotsitePath === "")
|
|
123
|
+
{
|
|
124
|
+
let tempHotsitePath: string = ppath.normalize (`${process.cwd ()}/HotSite.json`);
|
|
125
|
+
|
|
126
|
+
/// @fixme Do this check without caps sensitivity.
|
|
127
|
+
if (await HotIO.exists (tempHotsitePath) === true)
|
|
128
|
+
hotsitePath = tempHotsitePath;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (hotsitePath === "")
|
|
132
|
+
throw new Error (`When building, you must specify a HotSite.json!`);
|
|
133
|
+
|
|
134
|
+
if (hotsitePath !== "")
|
|
135
|
+
await processor.loadHotSite (hotsitePath);
|
|
136
|
+
|
|
137
|
+
await builder.build ([processor.hotSite]);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
/*buildCmd.option ("--watch, -w", "Watch the associated files and rebuild when changes are detected.",
|
|
141
|
+
(arg: string, previous: any) =>
|
|
142
|
+
{
|
|
143
|
+
createHotBuilder ();
|
|
144
|
+
builder.api = true;
|
|
145
|
+
});*/
|
|
146
|
+
/*buildCmd.option ("--api", "Build the web client to be used in a web browser.",
|
|
147
|
+
(arg: string, previous: any) =>
|
|
148
|
+
{
|
|
149
|
+
createHotBuilder ();
|
|
150
|
+
builder.api = true;
|
|
151
|
+
});*/
|
|
152
|
+
buildCmd.option ("--docker", "Build Dockerfiles from the given HotSite.json. This will be the default option.",
|
|
153
|
+
(arg: string, previous: any) =>
|
|
154
|
+
{
|
|
155
|
+
createHotBuilder ();
|
|
156
|
+
builder.dockerFiles = true;
|
|
157
|
+
});
|
|
158
|
+
buildCmd.option ("--dont-get-hard", "Do not use the default security hardening when generating the docker image.",
|
|
159
|
+
(arg: string, previous: any) =>
|
|
160
|
+
{
|
|
161
|
+
createHotBuilder ();
|
|
162
|
+
builder.dockerHardenSecurity = true;
|
|
163
|
+
});
|
|
164
|
+
buildCmd.option ("--dont-append-readme", "Do not add the additional docker documentation to the existing README.md.",
|
|
165
|
+
(arg: string, previous: any) =>
|
|
166
|
+
{
|
|
167
|
+
createHotBuilder ();
|
|
168
|
+
builder.appendReadMe = true;
|
|
169
|
+
});
|
|
170
|
+
/*buildCmd.option ("--docker-compose", "Build the docker compose file from the given HotSite.json.",
|
|
171
|
+
(arg: string, previous: any) =>
|
|
172
|
+
{
|
|
173
|
+
createHotBuilder ();
|
|
174
|
+
builder.dockerCompose = true;
|
|
175
|
+
});
|
|
176
|
+
buildCmd.option ("--kubernetes", "Build a Kubernetes cluster from the given HotSite.json.",
|
|
177
|
+
(arg: string, previous: any) =>
|
|
178
|
+
{
|
|
179
|
+
createHotBuilder ();
|
|
180
|
+
builder.kubernetes = true;
|
|
181
|
+
});*/
|
|
182
|
+
buildCmd.option ("--output", "The directory path to place all files.",
|
|
183
|
+
(arg: string, previous: any) =>
|
|
184
|
+
{
|
|
185
|
+
createHotBuilder ();
|
|
186
|
+
builder.outputDir = arg;
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
return (buildCmd);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Handle create commands.
|
|
194
|
+
*/
|
|
195
|
+
async function handleCreateCommands (): Promise<commander.Command>
|
|
196
|
+
{
|
|
197
|
+
let creator: HotCreator = null;
|
|
198
|
+
let createHotCreator = () =>
|
|
199
|
+
{
|
|
200
|
+
if (creator == null)
|
|
201
|
+
creator = new HotCreator ();
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
let copyLibrariesPath: string = "";
|
|
205
|
+
const createCmd: commander.Command = new commander.Command ("create");
|
|
206
|
+
createCmd.description (`Create a new project.`);
|
|
207
|
+
createCmd.action (async (cmdr: any, args: string) =>
|
|
208
|
+
{
|
|
209
|
+
createHotCreator ();
|
|
210
|
+
|
|
211
|
+
if (copyLibrariesPath !== "")
|
|
212
|
+
{
|
|
213
|
+
await creator.copyLibraries (copyLibrariesPath);
|
|
214
|
+
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (args == null)
|
|
219
|
+
throw new Error (`You must supply an npm compatible project name!`);
|
|
220
|
+
|
|
221
|
+
if (args.length < 1)
|
|
222
|
+
throw new Error (`You must supply an npm compatible project name!`);
|
|
223
|
+
|
|
224
|
+
const name: string = args[0];
|
|
225
|
+
|
|
226
|
+
creator.name = name;
|
|
227
|
+
creator.outputDir = ppath.normalize (`${process.cwd ()}/${name}/`);
|
|
228
|
+
|
|
229
|
+
await creator.create ();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
createCmd.option (`--copy-libraries-to-location <path>`,
|
|
233
|
+
`Copy the latest HotStaq libraries to a specified location. This will not generate any projects.`,
|
|
234
|
+
(path: string, previous: any) =>
|
|
235
|
+
{
|
|
236
|
+
createHotCreator ();
|
|
237
|
+
copyLibrariesPath = path;
|
|
238
|
+
}, "");
|
|
239
|
+
createCmd.option (`--type <type>`,
|
|
240
|
+
`The type of app to create. Can be (web, web-api, api)`,
|
|
241
|
+
(type: string, previous: any) =>
|
|
242
|
+
{
|
|
243
|
+
createHotCreator ();
|
|
244
|
+
creator.type = type;
|
|
245
|
+
}, "web-api");
|
|
246
|
+
createCmd.option (`--code <language>`,
|
|
247
|
+
`Set the type of code output. Can be (ts, js) Default: ts`,
|
|
248
|
+
(language: string, previous: any) =>
|
|
249
|
+
{
|
|
250
|
+
createHotCreator ();
|
|
251
|
+
creator.language = language;
|
|
252
|
+
}, "ts");
|
|
253
|
+
createCmd.option (`--output <path>`,
|
|
254
|
+
`The directory path to place all the files.`,
|
|
255
|
+
(path: string, previous: any) =>
|
|
256
|
+
{
|
|
257
|
+
createHotCreator ();
|
|
258
|
+
creator.outputDir = path;
|
|
259
|
+
}, "");
|
|
260
|
+
createCmd.option (`--overwrite-cmd-create-init <value>`,
|
|
261
|
+
`Overwrite the create command for initalizing an app.`,
|
|
262
|
+
(value: string, previous: any) =>
|
|
263
|
+
{
|
|
264
|
+
createHotCreator ();
|
|
265
|
+
creator.createCommands.init = value;
|
|
266
|
+
}, "");
|
|
267
|
+
createCmd.option (`--overwrite-cmd-create-transpile <value>`,
|
|
268
|
+
`Overwrite the create command for transpiling.`,
|
|
269
|
+
(value: string, previous: any) =>
|
|
270
|
+
{
|
|
271
|
+
createHotCreator ();
|
|
272
|
+
creator.createCommands.transpileTS = value;
|
|
273
|
+
}, "");
|
|
274
|
+
createCmd.option (`--overwrite-cmd-npm-build-web-api <value>`,
|
|
275
|
+
`Overwrite the npm command for building the web api.`,
|
|
276
|
+
(value: string, previous: any) =>
|
|
277
|
+
{
|
|
278
|
+
createHotCreator ();
|
|
279
|
+
creator.npmCommands.buildWebAPI = value;
|
|
280
|
+
}, "");
|
|
281
|
+
createCmd.option (`--overwrite-cmd-npm-build-web-api-debug <value>`,
|
|
282
|
+
`Overwrite the npm command for building the debug script for web api.`,
|
|
283
|
+
(value: string, previous: any) =>
|
|
284
|
+
{
|
|
285
|
+
createHotCreator ();
|
|
286
|
+
creator.npmCommands.buildWebAPIDebug = value;
|
|
287
|
+
}, "");
|
|
288
|
+
createCmd.option (`--overwrite-cmd-npm-dev <value>`,
|
|
289
|
+
`Overwrite the npm command for building the development script.`,
|
|
290
|
+
(value: string, previous: any) =>
|
|
291
|
+
{
|
|
292
|
+
createHotCreator ();
|
|
293
|
+
creator.npmCommands.dev = value;
|
|
294
|
+
}, "");
|
|
295
|
+
createCmd.option (`--overwrite-cmd-npm-start <value>`,
|
|
296
|
+
`Overwrite the npm command for the start script.`,
|
|
297
|
+
(value: string, previous: any) =>
|
|
298
|
+
{
|
|
299
|
+
createHotCreator ();
|
|
300
|
+
creator.npmCommands.start = value;
|
|
301
|
+
}, "");
|
|
302
|
+
createCmd.option (`--overwrite-cmd-npm-test <value>`,
|
|
303
|
+
`Overwrite the npm command for the test script.`,
|
|
304
|
+
(value: string, previous: any) =>
|
|
305
|
+
{
|
|
306
|
+
createHotCreator ();
|
|
307
|
+
creator.npmCommands.test = value;
|
|
308
|
+
}, "");
|
|
309
|
+
|
|
310
|
+
return (createCmd);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Handle run commands.
|
|
315
|
+
*/
|
|
316
|
+
async function handleRunCommands (): Promise<commander.Command>
|
|
317
|
+
{
|
|
318
|
+
let webServer: HotHTTPServer = new HotHTTPServer (processor);
|
|
319
|
+
let apiServer: HotHTTPServer = new HotHTTPServer (processor);
|
|
320
|
+
let testerSettings: {
|
|
321
|
+
tester: string;
|
|
322
|
+
address: string;
|
|
323
|
+
browser: string;
|
|
324
|
+
openDevTools: boolean;
|
|
325
|
+
headless: boolean;
|
|
326
|
+
remoteServer: string;
|
|
327
|
+
http: number;
|
|
328
|
+
https: number;
|
|
329
|
+
} = {
|
|
330
|
+
tester: "HotTesterMochaSelenium",
|
|
331
|
+
address: "127.0.0.1",
|
|
332
|
+
browser: "chrome",
|
|
333
|
+
openDevTools: false,
|
|
334
|
+
headless: false,
|
|
335
|
+
remoteServer: "",
|
|
336
|
+
http: 8183,
|
|
337
|
+
https: 4143
|
|
338
|
+
};
|
|
339
|
+
let apis: APItoLoad[] = [];
|
|
340
|
+
let dbinfo: HotDBConnectionInterface = null;
|
|
341
|
+
let setupDB = () =>
|
|
342
|
+
{
|
|
343
|
+
if (dbinfo != null)
|
|
344
|
+
return;
|
|
345
|
+
|
|
346
|
+
dbinfo = {
|
|
347
|
+
"type": process.env["DATABASE_TYPE"] || "mysql",
|
|
348
|
+
"server": process.env["DATABASE_SERVER"] || "127.0.0.1",
|
|
349
|
+
"username": process.env["DATABASE_USERNAME"] || "",
|
|
350
|
+
"password": process.env["DATABASE_PASSWORD"] || "",
|
|
351
|
+
"org": process.env["DATABASE_ORG"] || "",
|
|
352
|
+
"token": process.env["DATABASE_TOKEN"] || "",
|
|
353
|
+
"port": 3306,
|
|
354
|
+
"database": process.env["DATABASE_SCHEMA"] || ""
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
if (process.env["DATABASE_PORT"] != null)
|
|
358
|
+
{
|
|
359
|
+
try
|
|
360
|
+
{
|
|
361
|
+
dbinfo.port = parseInt (process.env["DATABASE_PORT"]);
|
|
362
|
+
}
|
|
363
|
+
catch (ex)
|
|
364
|
+
{
|
|
365
|
+
throw new Error (`Unable to parse db port ${process.env["DATABASE_PORT"]}`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
let serverType: string = "web";
|
|
371
|
+
let baseWebUrl: string = "";
|
|
372
|
+
let baseAPIUrl: string = "";
|
|
373
|
+
let runWebTestMap: boolean = false;
|
|
374
|
+
let runAPITestMap: boolean = false;
|
|
375
|
+
|
|
376
|
+
const runCmd: commander.Command = new commander.Command ("run");
|
|
377
|
+
runCmd.description (`Run commands.`);
|
|
378
|
+
runCmd.action (async () =>
|
|
379
|
+
{
|
|
380
|
+
let runWebServer: boolean = false;
|
|
381
|
+
let runAPIServer: boolean = false;
|
|
382
|
+
let testerServer: HotTesterServer = null;
|
|
383
|
+
|
|
384
|
+
if (processor.mode === DeveloperMode.Development)
|
|
385
|
+
{
|
|
386
|
+
let serverStarter = await HotTesterServer.startServer (
|
|
387
|
+
`http://${testerSettings.address}:${testerSettings.http}`, testerSettings.http, testerSettings.https, processor);
|
|
388
|
+
testerServer = serverStarter.server;
|
|
389
|
+
|
|
390
|
+
let tester: HotTester = null;
|
|
391
|
+
|
|
392
|
+
if (testerSettings.tester === "HotTesterMocha")
|
|
393
|
+
{
|
|
394
|
+
let mochaTester: HotTesterMocha = new HotTesterMocha (
|
|
395
|
+
processor, "HotTesterMocha", baseWebUrl, null);
|
|
396
|
+
tester = mochaTester;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (testerSettings.tester === "HotTesterMochaSelenium")
|
|
400
|
+
{
|
|
401
|
+
let mochaSeleniumTester: HotTesterMochaSelenium = new HotTesterMochaSelenium (
|
|
402
|
+
processor, "HotTesterMochaSelenium", baseWebUrl);
|
|
403
|
+
mochaSeleniumTester.driver.browser = testerSettings.browser;
|
|
404
|
+
mochaSeleniumTester.driver.openDevTools = testerSettings.openDevTools;
|
|
405
|
+
mochaSeleniumTester.driver.headless = testerSettings.headless;
|
|
406
|
+
mochaSeleniumTester.driver.remoteServer = testerSettings.remoteServer;
|
|
407
|
+
tester = mochaSeleniumTester;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
testerServer.addTester (tester);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (hotsitePath !== "")
|
|
414
|
+
{
|
|
415
|
+
await processor.loadHotSite (hotsitePath);
|
|
416
|
+
|
|
417
|
+
if (processor.hotSite != null)
|
|
418
|
+
{
|
|
419
|
+
if (processor.hotSite.apis != null)
|
|
420
|
+
{
|
|
421
|
+
for (let key in processor.hotSite.apis)
|
|
422
|
+
{
|
|
423
|
+
let tempapi = processor.hotSite.apis[key];
|
|
424
|
+
|
|
425
|
+
if (tempapi.libraryName != null)
|
|
426
|
+
{
|
|
427
|
+
let path: string = tempapi.filepath;
|
|
428
|
+
|
|
429
|
+
let apiToLoad: APItoLoad = {
|
|
430
|
+
exportedClassName: tempapi.apiName,
|
|
431
|
+
path: path
|
|
432
|
+
};
|
|
433
|
+
apis.push (apiToLoad);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Setup the DB if it hasn't already been setup.
|
|
441
|
+
if (process.env["DATABASE_TYPE"] != null)
|
|
442
|
+
{
|
|
443
|
+
setupDB ();
|
|
444
|
+
dbinfo.type = process.env["DATABASE_TYPE"];
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (process.env["DATABASE_SERVER"] != null)
|
|
448
|
+
{
|
|
449
|
+
setupDB ();
|
|
450
|
+
dbinfo.server = process.env["DATABASE_SERVER"];
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (process.env["DATABASE_USERNAME"] != null)
|
|
454
|
+
{
|
|
455
|
+
setupDB ();
|
|
456
|
+
dbinfo.username = process.env["DATABASE_USERNAME"];
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
if (process.env["DATABASE_PASSWORD"] != null)
|
|
460
|
+
{
|
|
461
|
+
setupDB ();
|
|
462
|
+
dbinfo.password = process.env["DATABASE_PASSWORD"];
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (process.env["DATABASE_ORG"] != null)
|
|
466
|
+
{
|
|
467
|
+
setupDB ();
|
|
468
|
+
dbinfo.org = process.env["DATABASE_ORG"];
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (process.env["DATABASE_TOKEN"] != null)
|
|
472
|
+
{
|
|
473
|
+
setupDB ();
|
|
474
|
+
dbinfo.token = process.env["DATABASE_TOKEN"];
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (process.env["DATABASE_PORT"] != null)
|
|
478
|
+
{
|
|
479
|
+
setupDB ();
|
|
480
|
+
|
|
481
|
+
try
|
|
482
|
+
{
|
|
483
|
+
dbinfo.port = parseInt (process.env["DATABASE_PORT"]);
|
|
484
|
+
}
|
|
485
|
+
catch (ex)
|
|
486
|
+
{
|
|
487
|
+
throw new Error (`Unable to parse db port ${process.env["DATABASE_PORT"]}`);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if (process.env["DATABASE_SCHEMA"] != null)
|
|
492
|
+
{
|
|
493
|
+
setupDB ();
|
|
494
|
+
dbinfo.database = process.env["DATABASE_SCHEMA"];
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if (baseWebUrl === "")
|
|
498
|
+
{
|
|
499
|
+
let foundBaseUrl: string = HotStaq.getValueFromHotSiteObj (processor.hotSite, ["server", "url"]);
|
|
500
|
+
|
|
501
|
+
if (foundBaseUrl != null)
|
|
502
|
+
baseWebUrl = foundBaseUrl;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
if (baseWebUrl === "")
|
|
506
|
+
baseWebUrl = `http://127.0.0.1:${webServer.ports.http}`;
|
|
507
|
+
|
|
508
|
+
if ((serverType === "web") || (serverType === "web-api"))
|
|
509
|
+
{
|
|
510
|
+
if (processor.hotSite != null)
|
|
511
|
+
{
|
|
512
|
+
if (processor.hotSite.server != null)
|
|
513
|
+
processor.hotSite.server.url = baseWebUrl;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
runWebServer = true;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if ((serverType === "api") || (serverType === "web-api"))
|
|
520
|
+
runAPIServer = true;
|
|
521
|
+
|
|
522
|
+
/// @fixme Allow for multiple APIs to be loaded, and have their
|
|
523
|
+
/// servers start in the future.
|
|
524
|
+
let loadAPI = apis[0];
|
|
525
|
+
let getBaseUrlFromHotSite = () =>
|
|
526
|
+
{
|
|
527
|
+
let foundAPIUrl: string = null;
|
|
528
|
+
|
|
529
|
+
// Attempt to find the base url from the HotSite's API.
|
|
530
|
+
if (processor.hotSite != null)
|
|
531
|
+
{
|
|
532
|
+
if (processor.hotSite.apis != null)
|
|
533
|
+
{
|
|
534
|
+
for (let key in processor.hotSite.apis)
|
|
535
|
+
{
|
|
536
|
+
let tempAPI = processor.hotSite.apis[key];
|
|
537
|
+
|
|
538
|
+
if (tempAPI.apiName != null)
|
|
539
|
+
{
|
|
540
|
+
if (tempAPI.apiName === loadAPI.exportedClassName)
|
|
541
|
+
{
|
|
542
|
+
if (tempAPI.url != null)
|
|
543
|
+
foundAPIUrl = tempAPI.url;
|
|
544
|
+
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
if (foundAPIUrl != null)
|
|
553
|
+
baseAPIUrl = foundAPIUrl;
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
if (serverType === "api")
|
|
557
|
+
{
|
|
558
|
+
if (apis.length < 1)
|
|
559
|
+
throw new Error (`No APIs are loaded! Try using --api-load`);
|
|
560
|
+
|
|
561
|
+
if (baseAPIUrl === "")
|
|
562
|
+
getBaseUrlFromHotSite ();
|
|
563
|
+
|
|
564
|
+
if (baseAPIUrl === "")
|
|
565
|
+
baseAPIUrl = `http://127.0.0.1:${apiServer.ports.http}`;
|
|
566
|
+
|
|
567
|
+
// Only run the api server.
|
|
568
|
+
await startAPIServer (apiServer, loadAPI, baseAPIUrl, dbinfo, true);
|
|
569
|
+
|
|
570
|
+
if (globalLogLevel != null)
|
|
571
|
+
apiServer.logger.logLevel = globalLogLevel;
|
|
572
|
+
|
|
573
|
+
apiServer.serverType = "API Server";
|
|
574
|
+
await apiServer.listen ();
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (runWebServer === true)
|
|
578
|
+
{
|
|
579
|
+
if (runAPIServer === true)
|
|
580
|
+
{
|
|
581
|
+
if (apis.length < 1)
|
|
582
|
+
throw new Error (`No APIs are loaded! Try using --api-load`);
|
|
583
|
+
|
|
584
|
+
if (baseAPIUrl === "")
|
|
585
|
+
getBaseUrlFromHotSite ();
|
|
586
|
+
|
|
587
|
+
if (baseAPIUrl === "")
|
|
588
|
+
baseAPIUrl = `http://127.0.0.1:${webServer.ports.http}`;
|
|
589
|
+
|
|
590
|
+
await startAPIServer (webServer, loadAPI, baseAPIUrl, dbinfo, false);
|
|
591
|
+
webServer.serverType = "Web-API Server";
|
|
592
|
+
}
|
|
593
|
+
else
|
|
594
|
+
webServer.serverType = "Web Server";
|
|
595
|
+
|
|
596
|
+
if (globalLogLevel != null)
|
|
597
|
+
webServer.logger.logLevel = globalLogLevel;
|
|
598
|
+
|
|
599
|
+
await webServer.listen ();
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (runWebTestMap === true)
|
|
603
|
+
{
|
|
604
|
+
if (testerServer == null)
|
|
605
|
+
throw new Error (`Unable to execute tests! Is --development-mode missing?`);
|
|
606
|
+
|
|
607
|
+
await testerServer.executeAllWebTests (testerSettings.tester);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (runAPITestMap === true)
|
|
611
|
+
{
|
|
612
|
+
if (testerServer == null)
|
|
613
|
+
throw new Error (`Unable to execute tests! Is --development-mode missing?`);
|
|
614
|
+
|
|
615
|
+
await testerServer.executeAllAPITests (testerSettings.tester);
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
runCmd.option (`--tester-http-port <port>`,
|
|
620
|
+
`Set the tester HTTP port`,
|
|
621
|
+
(port: string, previous: any) =>
|
|
622
|
+
{
|
|
623
|
+
try
|
|
624
|
+
{
|
|
625
|
+
const tempPort: number = parseInt (port);
|
|
626
|
+
|
|
627
|
+
testerSettings.http = tempPort;
|
|
628
|
+
}
|
|
629
|
+
catch (ex)
|
|
630
|
+
{
|
|
631
|
+
processor.logger.error (`Unable to parse tester http port ${port}`);
|
|
632
|
+
}
|
|
633
|
+
}, testerSettings.http);
|
|
634
|
+
runCmd.option (`--tester-https-port <port>`,
|
|
635
|
+
`Set the tester HTTPS port`,
|
|
636
|
+
(port: string, previous: any) =>
|
|
637
|
+
{
|
|
638
|
+
if (port == null)
|
|
639
|
+
return;
|
|
640
|
+
|
|
641
|
+
if (port === "")
|
|
642
|
+
return;
|
|
643
|
+
|
|
644
|
+
try
|
|
645
|
+
{
|
|
646
|
+
const tempPort: number = parseInt (port);
|
|
647
|
+
|
|
648
|
+
testerSettings.https = tempPort;
|
|
649
|
+
}
|
|
650
|
+
catch (ex)
|
|
651
|
+
{
|
|
652
|
+
processor.logger.error (`Unable to parse tester https port ${port}`);
|
|
653
|
+
}
|
|
654
|
+
}, testerSettings.https);
|
|
655
|
+
runCmd.option (`--tester-type <tester>`,
|
|
656
|
+
`Set the tester to use. Can be: HotTesterMocha,HotTesterMochaSelenium`,
|
|
657
|
+
(tester: string, previous: any) =>
|
|
658
|
+
{
|
|
659
|
+
testerSettings.tester = tester;
|
|
660
|
+
}, "HotTesterMochaSelenium");
|
|
661
|
+
runCmd.option (`--tester-address <address>`,
|
|
662
|
+
`Set the tester address to listen on.`,
|
|
663
|
+
(address: string, previous: any) =>
|
|
664
|
+
{
|
|
665
|
+
testerSettings.address = address;
|
|
666
|
+
}, "127.0.0.1");
|
|
667
|
+
runCmd.option (`--tester-browser <browser>`,
|
|
668
|
+
`Set the tester browser to use. Can only be used with tester type: HotTesterMochaSelenium`,
|
|
669
|
+
(browser: string, previous: any) =>
|
|
670
|
+
{
|
|
671
|
+
testerSettings.browser = browser;
|
|
672
|
+
}, "chrome");
|
|
673
|
+
runCmd.option (`--tester-open-dev-tools`,
|
|
674
|
+
`Open the browsers dev tools on start. Can only be used with tester type: HotTesterMochaSelenium`,
|
|
675
|
+
(value: string, previous: any) =>
|
|
676
|
+
{
|
|
677
|
+
testerSettings.openDevTools = true;
|
|
678
|
+
}, "false");
|
|
679
|
+
runCmd.option (`--tester-headless`,
|
|
680
|
+
`Make the browser headless. Can only be used with tester type: HotTesterMochaSelenium`,
|
|
681
|
+
(value: string, previous: any) =>
|
|
682
|
+
{
|
|
683
|
+
testerSettings.headless = true;
|
|
684
|
+
}, "false");
|
|
685
|
+
runCmd.option (`--tester-remote-server <remote_server>`,
|
|
686
|
+
`Set the remote Selenium server to use for testing. Can only be used with tester type: HotTesterMochaSelenium`,
|
|
687
|
+
(remoteServer: string, previous: any) =>
|
|
688
|
+
{
|
|
689
|
+
testerSettings.remoteServer = remoteServer;
|
|
690
|
+
}, "");
|
|
691
|
+
|
|
692
|
+
const serverTypes: string[] = ["web", "api"];
|
|
693
|
+
|
|
694
|
+
for (let iIdx = 0; iIdx < serverTypes.length; iIdx++)
|
|
695
|
+
{
|
|
696
|
+
let currentServerType: string = serverTypes[iIdx];
|
|
697
|
+
let httpPort: number = 80;
|
|
698
|
+
let httpsPort: number = 443;
|
|
699
|
+
|
|
700
|
+
if (currentServerType === "api")
|
|
701
|
+
{
|
|
702
|
+
httpPort = 81;
|
|
703
|
+
httpsPort = 444;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
runCmd.option (`--${currentServerType}-base-url <url>`,
|
|
707
|
+
`Set the base ${currentServerType} server url.`,
|
|
708
|
+
(url: string, previous: any) =>
|
|
709
|
+
{
|
|
710
|
+
if (currentServerType === "web")
|
|
711
|
+
baseWebUrl = url;
|
|
712
|
+
else
|
|
713
|
+
baseAPIUrl = url;
|
|
714
|
+
}, "");
|
|
715
|
+
runCmd.option (`--${currentServerType}-http-port <port>`,
|
|
716
|
+
`Set the ${currentServerType} HTTP port`,
|
|
717
|
+
(port: string, previous: any) =>
|
|
718
|
+
{
|
|
719
|
+
try
|
|
720
|
+
{
|
|
721
|
+
const tempPort: number = parseInt (port);
|
|
722
|
+
|
|
723
|
+
if (currentServerType === "web")
|
|
724
|
+
webServer.ports.http = tempPort;
|
|
725
|
+
else
|
|
726
|
+
apiServer.ports.http = tempPort;
|
|
727
|
+
}
|
|
728
|
+
catch (ex)
|
|
729
|
+
{
|
|
730
|
+
processor.logger.error (`Unable to parse ${currentServerType} http port ${port}`);
|
|
731
|
+
}
|
|
732
|
+
}, httpPort);
|
|
733
|
+
runCmd.option (`--${currentServerType}-https-port [port]`,
|
|
734
|
+
`Set the ${currentServerType} HTTPS port`,
|
|
735
|
+
(port: string, previous: any) =>
|
|
736
|
+
{
|
|
737
|
+
if (port == null)
|
|
738
|
+
return;
|
|
739
|
+
|
|
740
|
+
if (port === "")
|
|
741
|
+
return;
|
|
742
|
+
|
|
743
|
+
try
|
|
744
|
+
{
|
|
745
|
+
const tempPort: number = parseInt (port);
|
|
746
|
+
|
|
747
|
+
if (currentServerType === "web")
|
|
748
|
+
webServer.ports.https = tempPort;
|
|
749
|
+
else
|
|
750
|
+
apiServer.ports.https = tempPort;
|
|
751
|
+
}
|
|
752
|
+
catch (ex)
|
|
753
|
+
{
|
|
754
|
+
processor.logger.error (`Unable to parse ${currentServerType} https port ${port}`);
|
|
755
|
+
}
|
|
756
|
+
}, httpsPort);
|
|
757
|
+
runCmd.option (`--${currentServerType}-dont-redirect-http-to-https`,
|
|
758
|
+
`Do not redirect ${currentServerType} HTTP traffic to HTTPS`,
|
|
759
|
+
(port: string, previous: any) =>
|
|
760
|
+
{
|
|
761
|
+
if (currentServerType === "web")
|
|
762
|
+
webServer.redirectHTTPtoHTTPS = false;
|
|
763
|
+
else
|
|
764
|
+
apiServer.redirectHTTPtoHTTPS = false;
|
|
765
|
+
});
|
|
766
|
+
runCmd.option (`--${currentServerType}-listen-address <address>`,
|
|
767
|
+
`Set the ${currentServerType} listen address`,
|
|
768
|
+
(address: string, previous: any) =>
|
|
769
|
+
{
|
|
770
|
+
if (currentServerType === "web")
|
|
771
|
+
webServer.listenAddress = address;
|
|
772
|
+
else
|
|
773
|
+
apiServer.listenAddress = address;
|
|
774
|
+
}, "0.0.0.0");
|
|
775
|
+
runCmd.option (`--${currentServerType}-ssl-cert <path>`,
|
|
776
|
+
`Set the path to the SSL cert for the ${currentServerType} server`,
|
|
777
|
+
(cert: string, previous: any) =>
|
|
778
|
+
{
|
|
779
|
+
if (currentServerType === "web")
|
|
780
|
+
webServer.ssl.cert = cert;
|
|
781
|
+
else
|
|
782
|
+
apiServer.ssl.cert = cert;
|
|
783
|
+
}, "");
|
|
784
|
+
runCmd.option (`--${currentServerType}-ssl-key <path>`,
|
|
785
|
+
`Set the path to the SSL key for the ${currentServerType} server`,
|
|
786
|
+
(key: string, previous: any) =>
|
|
787
|
+
{
|
|
788
|
+
if (currentServerType === "web")
|
|
789
|
+
webServer.ssl.key = key;
|
|
790
|
+
else
|
|
791
|
+
apiServer.ssl.key = key;
|
|
792
|
+
}, "");
|
|
793
|
+
runCmd.option (`--${currentServerType}-ssl-ca <path>`,
|
|
794
|
+
`Set the path to the SSL CA for the ${currentServerType} server`,
|
|
795
|
+
(ca: string, previous: any) =>
|
|
796
|
+
{
|
|
797
|
+
if (currentServerType === "web")
|
|
798
|
+
webServer.ssl.ca = ca;
|
|
799
|
+
else
|
|
800
|
+
apiServer.ssl.ca = ca;
|
|
801
|
+
}, "");
|
|
802
|
+
runCmd.option (`--${currentServerType}-log-level <level>`,
|
|
803
|
+
`Set the logging level for the ${currentServerType} server. Can be (info,warning,error,all,none)`,
|
|
804
|
+
(logLevel: string, previous: any) =>
|
|
805
|
+
{
|
|
806
|
+
let tempServer: HotHTTPServer = null;
|
|
807
|
+
|
|
808
|
+
if (logLevel === "")
|
|
809
|
+
return;
|
|
810
|
+
|
|
811
|
+
if (currentServerType === "web")
|
|
812
|
+
tempServer = webServer;
|
|
813
|
+
else
|
|
814
|
+
tempServer = apiServer;
|
|
815
|
+
|
|
816
|
+
if (logLevel === "info")
|
|
817
|
+
tempServer.logger.logLevel = HotLogLevel.Info;
|
|
818
|
+
|
|
819
|
+
if (logLevel === "warning")
|
|
820
|
+
tempServer.logger.logLevel = HotLogLevel.Warning;
|
|
821
|
+
|
|
822
|
+
if (logLevel === "error")
|
|
823
|
+
tempServer.logger.logLevel = HotLogLevel.Error;
|
|
824
|
+
|
|
825
|
+
if (logLevel === "verbose")
|
|
826
|
+
tempServer.logger.logLevel = HotLogLevel.Verbose;
|
|
827
|
+
|
|
828
|
+
if (logLevel === "all")
|
|
829
|
+
tempServer.logger.logLevel = HotLogLevel.All;
|
|
830
|
+
|
|
831
|
+
if (logLevel === "none")
|
|
832
|
+
tempServer.logger.logLevel = HotLogLevel.None;
|
|
833
|
+
}, "");
|
|
834
|
+
runCmd.option (`--${currentServerType}-test`,
|
|
835
|
+
`Execute all tests specified in HotSite.json. Must be used with --development-mode.`,
|
|
836
|
+
(map: string, previous: any) =>
|
|
837
|
+
{
|
|
838
|
+
if (currentServerType === "web")
|
|
839
|
+
runWebTestMap = true;
|
|
840
|
+
else
|
|
841
|
+
runAPITestMap = true;
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
if (currentServerType === "web")
|
|
845
|
+
{
|
|
846
|
+
runCmd.option (`--${currentServerType}-route <route_and_path>`,
|
|
847
|
+
`Add a static route in "key=path" format. Example: --${currentServerType}-route "/=/var/www"`,
|
|
848
|
+
(routeAndPath: string, previous: any) =>
|
|
849
|
+
{
|
|
850
|
+
let keyValuePair = getKeyValuePair (routeAndPath);
|
|
851
|
+
const route: string = keyValuePair.key;
|
|
852
|
+
const path: string = keyValuePair.value;
|
|
853
|
+
|
|
854
|
+
webServer.addStaticRoute (route, path);
|
|
855
|
+
});
|
|
856
|
+
runCmd.option (`--${currentServerType}-serve-hott-files`, "Serve Hott files",
|
|
857
|
+
(port: string, previous: any) =>
|
|
858
|
+
{
|
|
859
|
+
webServer.serveHottFiles = true;
|
|
860
|
+
});
|
|
861
|
+
runCmd.option (`--${currentServerType}-js-url <url>`, "The url to the HotStaq JS",
|
|
862
|
+
(url: string, previous: any) =>
|
|
863
|
+
{
|
|
864
|
+
webServer.hottFilesAssociatedInfo.jsSrcPath = url;
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
if (currentServerType === "api")
|
|
869
|
+
{
|
|
870
|
+
runCmd.option (`--${currentServerType}-load <exported_name_and_path>`,
|
|
871
|
+
`Load an API for use in "exported_name=path_to_js_file" format. Example: --${currentServerType}-load "FreeLightAPI=/app/FreeLight/build/src/FreeLightAPI.js"`,
|
|
872
|
+
(exported_name_and_path: string, previous: any) =>
|
|
873
|
+
{
|
|
874
|
+
let keyValuePair = getKeyValuePair (exported_name_and_path);
|
|
875
|
+
const exportedClassName: string = keyValuePair.key;
|
|
876
|
+
const path: string = keyValuePair.value;
|
|
877
|
+
|
|
878
|
+
apis.push ({ exportedClassName: exportedClassName, path: path });
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
runCmd.option (`--server-type <type>`,
|
|
884
|
+
`Set the type of server. Can be (web, api, web-api)`,
|
|
885
|
+
(type: string, previous: any) =>
|
|
886
|
+
{
|
|
887
|
+
serverType = type;
|
|
888
|
+
}, "web");
|
|
889
|
+
runCmd.option ("--db-type <type>", "The type of database to use. Can be (mysql, influx)",
|
|
890
|
+
(type: string, previous: any) =>
|
|
891
|
+
{
|
|
892
|
+
setupDB ();
|
|
893
|
+
dbinfo.type = type;
|
|
894
|
+
}, "mysql");
|
|
895
|
+
runCmd.option ("--db-server <address>", "The address to the database",
|
|
896
|
+
(address: string, previous: any) =>
|
|
897
|
+
{
|
|
898
|
+
setupDB ();
|
|
899
|
+
dbinfo.server = address;
|
|
900
|
+
}, "127.0.0.1");
|
|
901
|
+
runCmd.option ("--db-username <username>", "The database's username",
|
|
902
|
+
(username: string, previous: any) =>
|
|
903
|
+
{
|
|
904
|
+
setupDB ();
|
|
905
|
+
dbinfo.username = username;
|
|
906
|
+
});
|
|
907
|
+
runCmd.option ("--db-password <password>", "The database's password. This is insecure to use on the command line!",
|
|
908
|
+
(password: string, previous: any) =>
|
|
909
|
+
{
|
|
910
|
+
setupDB ();
|
|
911
|
+
dbinfo.password = password;
|
|
912
|
+
});
|
|
913
|
+
runCmd.option ("--db-port <port>", "The database's port",
|
|
914
|
+
(port: string, previous: any) =>
|
|
915
|
+
{
|
|
916
|
+
setupDB ();
|
|
917
|
+
|
|
918
|
+
try
|
|
919
|
+
{
|
|
920
|
+
dbinfo.port = parseInt (port);
|
|
921
|
+
}
|
|
922
|
+
catch (ex)
|
|
923
|
+
{
|
|
924
|
+
processor.logger.error (`Unable to parse db port ${port}`);
|
|
925
|
+
}
|
|
926
|
+
}, "3306");
|
|
927
|
+
runCmd.option ("--db-database <schema>", "The database's schema to select",
|
|
928
|
+
(schema: string, previous: any) =>
|
|
929
|
+
{
|
|
930
|
+
setupDB ();
|
|
931
|
+
dbinfo.database = schema;
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
return (runCmd);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Handle any agent commands.
|
|
939
|
+
*/
|
|
940
|
+
async function handleAgentCommands (): Promise<commander.Command>
|
|
941
|
+
{
|
|
942
|
+
let baseAPIUrl: string = "";
|
|
943
|
+
let agentKey: string = "";
|
|
944
|
+
let agentSecret: string = "";
|
|
945
|
+
let commands: { [name: string]: string } = {};
|
|
946
|
+
let listenAddr: string = "0.0.0.0";
|
|
947
|
+
let port: number = 5468;
|
|
948
|
+
|
|
949
|
+
const agentCmd: commander.Command = new commander.Command ("agent");
|
|
950
|
+
agentCmd.description (`Listen for commands on a port.`);
|
|
951
|
+
agentCmd.action (async () =>
|
|
952
|
+
{
|
|
953
|
+
let processor: HotStaq = new HotStaq ();
|
|
954
|
+
processor.logger.logLevel = HotLogLevel.Verbose;
|
|
955
|
+
|
|
956
|
+
let apiServer: HotHTTPServer = new HotHTTPServer (processor);
|
|
957
|
+
let api: HotAgentAPI = new HotAgentAPI (baseAPIUrl, apiServer);
|
|
958
|
+
api.key = agentKey;
|
|
959
|
+
api.secret = agentSecret;
|
|
960
|
+
apiServer.listenAddress = listenAddr;
|
|
961
|
+
apiServer.ports.http = port;
|
|
962
|
+
apiServer.processor.api = api;
|
|
963
|
+
apiServer.api = api;
|
|
964
|
+
await apiServer.setAPI (api);
|
|
965
|
+
|
|
966
|
+
await apiServer.listen ();
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
agentCmd.option ("--base_api_url <value>", "The key that must be given in order to execute the commands.",
|
|
970
|
+
(value: string, previous: any) =>
|
|
971
|
+
{
|
|
972
|
+
baseAPIUrl = value;
|
|
973
|
+
});
|
|
974
|
+
agentCmd.option ("--key <key>", "The key that must be given in order to execute the commands.",
|
|
975
|
+
(value: string, previous: any) =>
|
|
976
|
+
{
|
|
977
|
+
agentKey = value;
|
|
978
|
+
});
|
|
979
|
+
agentCmd.option ("--secret <secret>", "The secret key that must be given in order to execute the commands.",
|
|
980
|
+
(value: string, previous: any) =>
|
|
981
|
+
{
|
|
982
|
+
agentSecret = value;
|
|
983
|
+
});
|
|
984
|
+
agentCmd.option ("--file <key_filepath>", "The key and the associated NodeJS file to execute (key=path).",
|
|
985
|
+
(value: string, previous: any) =>
|
|
986
|
+
{
|
|
987
|
+
let key: string = "";
|
|
988
|
+
let filepath: string = "";
|
|
989
|
+
let pos: number = key.indexOf ("=");
|
|
990
|
+
|
|
991
|
+
if (pos < 0)
|
|
992
|
+
throw new Error (`key_filepath must be in the format (key=path)`);
|
|
993
|
+
|
|
994
|
+
key = value.substr (0, pos);
|
|
995
|
+
filepath = value.substr (pos + 1);
|
|
996
|
+
|
|
997
|
+
commands[key] = filepath;
|
|
998
|
+
});
|
|
999
|
+
agentCmd.option ("--listen-addr <addr>", "The address to listen on.",
|
|
1000
|
+
(value: string, previous: any) =>
|
|
1001
|
+
{
|
|
1002
|
+
listenAddr = value;
|
|
1003
|
+
});
|
|
1004
|
+
agentCmd.option ("--listen-port <port>", "The port to listen on.",
|
|
1005
|
+
(value: string, previous: any) =>
|
|
1006
|
+
{
|
|
1007
|
+
try
|
|
1008
|
+
{
|
|
1009
|
+
port = parseInt (value);
|
|
1010
|
+
}
|
|
1011
|
+
catch (ex)
|
|
1012
|
+
{
|
|
1013
|
+
throw new Error (`Unable to parse port ${value}`);
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
|
|
1017
|
+
return (agentCmd);
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* Check if the path exists.
|
|
1022
|
+
*/
|
|
1023
|
+
function checkIfPathExists (path: string): boolean
|
|
1024
|
+
{
|
|
1025
|
+
if (fs.existsSync (path) === true)
|
|
1026
|
+
return (true);
|
|
1027
|
+
|
|
1028
|
+
return (false);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Start the CLI app.
|
|
1033
|
+
*/
|
|
1034
|
+
async function start ()
|
|
1035
|
+
{
|
|
1036
|
+
try
|
|
1037
|
+
{
|
|
1038
|
+
let packagePath: string = ppath.normalize (`${__dirname}/../../package.json`);
|
|
1039
|
+
|
|
1040
|
+
if (checkIfPathExists (packagePath) === false)
|
|
1041
|
+
{
|
|
1042
|
+
packagePath = ppath.normalize (`${process.cwd ()}/package.json`);
|
|
1043
|
+
|
|
1044
|
+
if (checkIfPathExists (packagePath) === false)
|
|
1045
|
+
{
|
|
1046
|
+
console.error (`Unable to find path to HotStaq!`);
|
|
1047
|
+
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
let packageJSON: any = JSON.parse (fs.readFileSync (packagePath).toString ());
|
|
1053
|
+
VERSION = packageJSON.version;
|
|
1054
|
+
|
|
1055
|
+
const program: commander.Command = new commander.Command ("hotstaq");
|
|
1056
|
+
|
|
1057
|
+
program.description (`Copyright(c) 2021, FreeLight, Inc. Under the MIT License.`);
|
|
1058
|
+
let command: commander.Command = program.version (VERSION);
|
|
1059
|
+
|
|
1060
|
+
let hotsiteExists: boolean = false;
|
|
1061
|
+
let foundHotsitePath: string = "";
|
|
1062
|
+
|
|
1063
|
+
if (checkIfPathExists ("./HotSite.json") === true)
|
|
1064
|
+
{
|
|
1065
|
+
hotsiteExists = true;
|
|
1066
|
+
foundHotsitePath = ppath.normalize ("./HotSite.json");
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
if (checkIfPathExists ("./hotsite.json") === true)
|
|
1070
|
+
{
|
|
1071
|
+
hotsiteExists = true;
|
|
1072
|
+
foundHotsitePath = ppath.normalize ("./HotSite.json");
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
if (hotsiteExists === true)
|
|
1076
|
+
hotsitePath = foundHotsitePath;
|
|
1077
|
+
|
|
1078
|
+
command.option ("--cwd <path>", "Set the current working directory to use.",
|
|
1079
|
+
(path: string, previous: any) =>
|
|
1080
|
+
{
|
|
1081
|
+
process.chdir (path);
|
|
1082
|
+
});
|
|
1083
|
+
command.option ("-o, --hotsite <path>", "Specify the HotSite.json to use. This will look in the current directory to find one first.",
|
|
1084
|
+
(path: string, previous: any) =>
|
|
1085
|
+
{
|
|
1086
|
+
hotsitePath = path;
|
|
1087
|
+
}, foundHotsitePath);
|
|
1088
|
+
command.option ("--not-hot", "Do not use a HotSite.json.",
|
|
1089
|
+
(path: string, previous: any) =>
|
|
1090
|
+
{
|
|
1091
|
+
hotsitePath = "";
|
|
1092
|
+
});
|
|
1093
|
+
command.option ("--verbose", "Set the logging level to verbose.",
|
|
1094
|
+
(logLevel: string, previous: any) =>
|
|
1095
|
+
{
|
|
1096
|
+
if (logLevel === "verbose")
|
|
1097
|
+
globalLogLevel = HotLogLevel.Verbose;
|
|
1098
|
+
});
|
|
1099
|
+
command.option ("-l, --log-level <level>", "Set the logging level. Can be (info,warning,error,all,none)",
|
|
1100
|
+
(logLevel: string, previous: any) =>
|
|
1101
|
+
{
|
|
1102
|
+
if (logLevel === "info")
|
|
1103
|
+
globalLogLevel = HotLogLevel.Info;
|
|
1104
|
+
|
|
1105
|
+
if (logLevel === "warning")
|
|
1106
|
+
globalLogLevel = HotLogLevel.Warning;
|
|
1107
|
+
|
|
1108
|
+
if (logLevel === "error")
|
|
1109
|
+
globalLogLevel = HotLogLevel.Error;
|
|
1110
|
+
|
|
1111
|
+
if (logLevel === "verbose")
|
|
1112
|
+
globalLogLevel = HotLogLevel.Verbose;
|
|
1113
|
+
|
|
1114
|
+
if (logLevel === "all")
|
|
1115
|
+
globalLogLevel = HotLogLevel.All;
|
|
1116
|
+
|
|
1117
|
+
if (logLevel === "none")
|
|
1118
|
+
globalLogLevel = HotLogLevel.None;
|
|
1119
|
+
}, "");
|
|
1120
|
+
command.option ("--dev, --development-mode", "Set to execute in development mode. This will allow for testing data to be collected and executed",
|
|
1121
|
+
(value: string, previous: any) =>
|
|
1122
|
+
{
|
|
1123
|
+
processor.mode = DeveloperMode.Development;
|
|
1124
|
+
});
|
|
1125
|
+
|
|
1126
|
+
let createCmd: commander.Command = await handleCreateCommands ();
|
|
1127
|
+
command.addCommand (createCmd);
|
|
1128
|
+
|
|
1129
|
+
let runCmd: commander.Command = await handleRunCommands ();
|
|
1130
|
+
command.addCommand (runCmd);
|
|
1131
|
+
|
|
1132
|
+
let buildCmd: commander.Command = await handleBuildCommands ();
|
|
1133
|
+
command.addCommand (buildCmd);
|
|
1134
|
+
|
|
1135
|
+
let agentCmd: commander.Command = await handleAgentCommands ();
|
|
1136
|
+
command.addCommand (agentCmd);
|
|
1137
|
+
|
|
1138
|
+
if (process.argv.length > 2)
|
|
1139
|
+
program.parse (process.argv);
|
|
1140
|
+
}
|
|
1141
|
+
catch (ex)
|
|
1142
|
+
{
|
|
1143
|
+
processor.logger.error (ex.stack);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
start ();
|