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.
Files changed (299) hide show
  1. package/.eslintignore +17 -0
  2. package/.eslintrc.js +11 -0
  3. package/.vscode/launch.json +199 -0
  4. package/.vscode/settings.json +2 -0
  5. package/.vscode/tasks.json +78 -0
  6. package/CONTRIBUTING.md +157 -0
  7. package/README.md +126 -0
  8. package/bin/hotstaq +3 -0
  9. package/bin/hotstaq.cmd +1 -0
  10. package/build/src/Hot.d.ts +167 -0
  11. package/build/src/Hot.d.ts.map +1 -0
  12. package/build/src/Hot.js +365 -0
  13. package/build/src/Hot.js.map +1 -0
  14. package/build/src/HotAPI.d.ts +130 -0
  15. package/build/src/HotAPI.d.ts.map +1 -0
  16. package/build/src/HotAPI.js +353 -0
  17. package/build/src/HotAPI.js.map +1 -0
  18. package/build/src/HotAgentAPI.d.ts +22 -0
  19. package/build/src/HotAgentAPI.d.ts.map +1 -0
  20. package/build/src/HotAgentAPI.js +85 -0
  21. package/build/src/HotAgentAPI.js.map +1 -0
  22. package/build/src/HotAgentRoute.d.ts +17 -0
  23. package/build/src/HotAgentRoute.d.ts.map +1 -0
  24. package/build/src/HotAgentRoute.js +109 -0
  25. package/build/src/HotAgentRoute.js.map +1 -0
  26. package/build/src/HotBuilder.d.ts +52 -0
  27. package/build/src/HotBuilder.d.ts.map +1 -0
  28. package/build/src/HotBuilder.js +239 -0
  29. package/build/src/HotBuilder.js.map +1 -0
  30. package/build/src/HotClient.d.ts +31 -0
  31. package/build/src/HotClient.d.ts.map +1 -0
  32. package/build/src/HotClient.js +19 -0
  33. package/build/src/HotClient.js.map +1 -0
  34. package/build/src/HotComponent.d.ts +118 -0
  35. package/build/src/HotComponent.d.ts.map +1 -0
  36. package/build/src/HotComponent.js +89 -0
  37. package/build/src/HotComponent.js.map +1 -0
  38. package/build/src/HotCreator.d.ts +92 -0
  39. package/build/src/HotCreator.d.ts.map +1 -0
  40. package/build/src/HotCreator.js +465 -0
  41. package/build/src/HotCreator.js.map +1 -0
  42. package/build/src/HotDB.d.ts +69 -0
  43. package/build/src/HotDB.d.ts.map +1 -0
  44. package/build/src/HotDB.js +29 -0
  45. package/build/src/HotDB.js.map +1 -0
  46. package/build/src/HotDBConnectionInterface.d.ts +40 -0
  47. package/build/src/HotDBConnectionInterface.d.ts.map +1 -0
  48. package/build/src/HotDBConnectionInterface.js +3 -0
  49. package/build/src/HotDBConnectionInterface.js.map +1 -0
  50. package/build/src/HotFile.d.ts +134 -0
  51. package/build/src/HotFile.d.ts.map +1 -0
  52. package/build/src/HotFile.js +454 -0
  53. package/build/src/HotFile.js.map +1 -0
  54. package/build/src/HotHTTPServer.d.ts +162 -0
  55. package/build/src/HotHTTPServer.d.ts.map +1 -0
  56. package/build/src/HotHTTPServer.js +863 -0
  57. package/build/src/HotHTTPServer.js.map +1 -0
  58. package/build/src/HotIO.d.ts +39 -0
  59. package/build/src/HotIO.d.ts.map +1 -0
  60. package/build/src/HotIO.js +195 -0
  61. package/build/src/HotIO.js.map +1 -0
  62. package/build/src/HotLog.d.ts +60 -0
  63. package/build/src/HotLog.d.ts.map +1 -0
  64. package/build/src/HotLog.js +126 -0
  65. package/build/src/HotLog.js.map +1 -0
  66. package/build/src/HotPage.d.ts +125 -0
  67. package/build/src/HotPage.d.ts.map +1 -0
  68. package/build/src/HotPage.js +178 -0
  69. package/build/src/HotPage.js.map +1 -0
  70. package/build/src/HotRoute.d.ts +82 -0
  71. package/build/src/HotRoute.d.ts.map +1 -0
  72. package/build/src/HotRoute.js +83 -0
  73. package/build/src/HotRoute.js.map +1 -0
  74. package/build/src/HotRouteMethod.d.ts +129 -0
  75. package/build/src/HotRouteMethod.d.ts.map +1 -0
  76. package/build/src/HotRouteMethod.js +84 -0
  77. package/build/src/HotRouteMethod.js.map +1 -0
  78. package/build/src/HotServer.d.ts +152 -0
  79. package/build/src/HotServer.d.ts.map +1 -0
  80. package/build/src/HotServer.js +109 -0
  81. package/build/src/HotServer.js.map +1 -0
  82. package/build/src/HotSetAsWeb.d.ts +2 -0
  83. package/build/src/HotSetAsWeb.d.ts.map +1 -0
  84. package/build/src/HotSetAsWeb.js +5 -0
  85. package/build/src/HotSetAsWeb.js.map +1 -0
  86. package/build/src/HotStaq.d.ts +601 -0
  87. package/build/src/HotStaq.d.ts.map +1 -0
  88. package/build/src/HotStaq.js +1258 -0
  89. package/build/src/HotStaq.js.map +1 -0
  90. package/build/src/HotStaqWeb.d.ts +18 -0
  91. package/build/src/HotStaqWeb.d.ts.map +1 -0
  92. package/build/src/HotStaqWeb.js +44 -0
  93. package/build/src/HotStaqWeb.js.map +1 -0
  94. package/build/src/HotTestDriver.d.ts +63 -0
  95. package/build/src/HotTestDriver.d.ts.map +1 -0
  96. package/build/src/HotTestDriver.js +187 -0
  97. package/build/src/HotTestDriver.js.map +1 -0
  98. package/build/src/HotTestElement.d.ts +71 -0
  99. package/build/src/HotTestElement.d.ts.map +1 -0
  100. package/build/src/HotTestElement.js +37 -0
  101. package/build/src/HotTestElement.js.map +1 -0
  102. package/build/src/HotTestMap.d.ts +83 -0
  103. package/build/src/HotTestMap.d.ts.map +1 -0
  104. package/build/src/HotTestMap.js +58 -0
  105. package/build/src/HotTestMap.js.map +1 -0
  106. package/build/src/HotTestSeleniumDriver.d.ts +82 -0
  107. package/build/src/HotTestSeleniumDriver.d.ts.map +1 -0
  108. package/build/src/HotTestSeleniumDriver.js +398 -0
  109. package/build/src/HotTestSeleniumDriver.js.map +1 -0
  110. package/build/src/HotTester.d.ts +188 -0
  111. package/build/src/HotTester.d.ts.map +1 -0
  112. package/build/src/HotTester.js +623 -0
  113. package/build/src/HotTester.js.map +1 -0
  114. package/build/src/HotTesterAPI.d.ts +15 -0
  115. package/build/src/HotTesterAPI.d.ts.map +1 -0
  116. package/build/src/HotTesterAPI.js +161 -0
  117. package/build/src/HotTesterAPI.js.map +1 -0
  118. package/build/src/HotTesterMocha.d.ts +50 -0
  119. package/build/src/HotTesterMocha.d.ts.map +1 -0
  120. package/build/src/HotTesterMocha.js +205 -0
  121. package/build/src/HotTesterMocha.js.map +1 -0
  122. package/build/src/HotTesterMochaSelenium.d.ts +70 -0
  123. package/build/src/HotTesterMochaSelenium.d.ts.map +1 -0
  124. package/build/src/HotTesterMochaSelenium.js +257 -0
  125. package/build/src/HotTesterMochaSelenium.js.map +1 -0
  126. package/build/src/HotTesterServer.d.ts +114 -0
  127. package/build/src/HotTesterServer.d.ts.map +1 -0
  128. package/build/src/HotTesterServer.js +575 -0
  129. package/build/src/HotTesterServer.js.map +1 -0
  130. package/build/src/api.d.ts +33 -0
  131. package/build/src/api.d.ts.map +1 -0
  132. package/build/src/api.js +78 -0
  133. package/build/src/api.js.map +1 -0
  134. package/build/src/cli.d.ts +2 -0
  135. package/build/src/cli.d.ts.map +1 -0
  136. package/build/src/cli.js +935 -0
  137. package/build/src/cli.js.map +1 -0
  138. package/build/src/schemas/HotDBInflux.d.ts +63 -0
  139. package/build/src/schemas/HotDBInflux.d.ts.map +1 -0
  140. package/build/src/schemas/HotDBInflux.js +239 -0
  141. package/build/src/schemas/HotDBInflux.js.map +1 -0
  142. package/build/src/schemas/HotDBMigration.d.ts +19 -0
  143. package/build/src/schemas/HotDBMigration.d.ts.map +1 -0
  144. package/build/src/schemas/HotDBMigration.js +15 -0
  145. package/build/src/schemas/HotDBMigration.js.map +1 -0
  146. package/build/src/schemas/HotDBMySQL.d.ts +65 -0
  147. package/build/src/schemas/HotDBMySQL.d.ts.map +1 -0
  148. package/build/src/schemas/HotDBMySQL.js +387 -0
  149. package/build/src/schemas/HotDBMySQL.js.map +1 -0
  150. package/build/src/schemas/HotDBSchema.d.ts +15 -0
  151. package/build/src/schemas/HotDBSchema.d.ts.map +1 -0
  152. package/build/src/schemas/HotDBSchema.js +19 -0
  153. package/build/src/schemas/HotDBSchema.js.map +1 -0
  154. package/build/src/schemas/influx/InfluxSchema.d.ts +14 -0
  155. package/build/src/schemas/influx/InfluxSchema.d.ts.map +1 -0
  156. package/build/src/schemas/influx/InfluxSchema.js +33 -0
  157. package/build/src/schemas/influx/InfluxSchema.js.map +1 -0
  158. package/build/src/schemas/mysql/MySQLSchema.d.ts +39 -0
  159. package/build/src/schemas/mysql/MySQLSchema.d.ts.map +1 -0
  160. package/build/src/schemas/mysql/MySQLSchema.js +151 -0
  161. package/build/src/schemas/mysql/MySQLSchema.js.map +1 -0
  162. package/build/src/schemas/mysql/MySQLSchemaField.d.ts +168 -0
  163. package/build/src/schemas/mysql/MySQLSchemaField.d.ts.map +1 -0
  164. package/build/src/schemas/mysql/MySQLSchemaField.js +260 -0
  165. package/build/src/schemas/mysql/MySQLSchemaField.js.map +1 -0
  166. package/build/src/schemas/mysql/MySQLSchemaTable.d.ts +49 -0
  167. package/build/src/schemas/mysql/MySQLSchemaTable.d.ts.map +1 -0
  168. package/build/src/schemas/mysql/MySQLSchemaTable.js +310 -0
  169. package/build/src/schemas/mysql/MySQLSchemaTable.js.map +1 -0
  170. package/build-web/HotStaq.js +2 -0
  171. package/build-web/HotStaq.min.js +125 -0
  172. package/builder/docker/Dockerfile.linux.gen +42 -0
  173. package/builder/docker/README.md +36 -0
  174. package/builder/docker/app/start.sh +8 -0
  175. package/builder/docker/dockerignore +3 -0
  176. package/builder/docker/scripts/build.bat +11 -0
  177. package/builder/docker/scripts/build.sh +11 -0
  178. package/builder/docker/scripts/start-app.bat +7 -0
  179. package/builder/docker/scripts/start-app.sh +7 -0
  180. package/builder/docker/scripts/stop-app.bat +5 -0
  181. package/builder/docker/scripts/stop-app.sh +5 -0
  182. package/builder/docker-compose/docker-compose.gen.yaml +41 -0
  183. package/builder/docker-compose/env-skeleton +4 -0
  184. package/creator/project/.vscode/launch.json +59 -0
  185. package/creator/project/README.md +20 -0
  186. package/creator/project/gitignore +118 -0
  187. package/creator/project/npmignore +118 -0
  188. package/creator/public/api-test.hott +28 -0
  189. package/creator/public/index.hott +12 -0
  190. package/creator/ts/src/AppAPI.ts +30 -0
  191. package/creator/ts/src/HelloWorld.ts +39 -0
  192. package/creator/ts/src/WebExport.ts +7 -0
  193. package/creator/ts/tsconfig-web.json +73 -0
  194. package/creator/ts/tsconfig.json +73 -0
  195. package/creator/ts/webpack-api.config.js +57 -0
  196. package/dbstart.sh +19 -0
  197. package/dbstop.sh +4 -0
  198. package/docs/.nojekyll +1 -0
  199. package/docs/README.md +128 -0
  200. package/docs/classes/Hot.md +477 -0
  201. package/docs/classes/HotAPI.md +369 -0
  202. package/docs/classes/HotClient.md +95 -0
  203. package/docs/classes/HotComponent.md +279 -0
  204. package/docs/classes/HotDB.md +247 -0
  205. package/docs/classes/HotDBInflux.md +404 -0
  206. package/docs/classes/HotDBMigration.md +80 -0
  207. package/docs/classes/HotDBMySQL.md +310 -0
  208. package/docs/classes/HotDBSchema.md +51 -0
  209. package/docs/classes/HotFile.md +353 -0
  210. package/docs/classes/HotHTTPServer.md +700 -0
  211. package/docs/classes/HotLog.md +162 -0
  212. package/docs/classes/HotPage.md +357 -0
  213. package/docs/classes/HotRoute.md +312 -0
  214. package/docs/classes/HotRouteMethod.md +271 -0
  215. package/docs/classes/HotServer.md +311 -0
  216. package/docs/classes/HotStaq.md +1153 -0
  217. package/docs/classes/HotTestDestination.md +58 -0
  218. package/docs/classes/HotTestDriver.md +332 -0
  219. package/docs/classes/HotTestElement.md +88 -0
  220. package/docs/classes/HotTestElementOptions.md +71 -0
  221. package/docs/classes/HotTestMap.md +92 -0
  222. package/docs/classes/HotTestSeleniumDriver.md +529 -0
  223. package/docs/classes/HotTester.md +653 -0
  224. package/docs/classes/HotTesterAPI.md +493 -0
  225. package/docs/classes/HotTesterMocha.md +843 -0
  226. package/docs/classes/HotTesterMochaSelenium.md +896 -0
  227. package/docs/classes/HotTesterServer.md +633 -0
  228. package/docs/classes/InfluxSchema.md +74 -0
  229. package/docs/classes/MySQLSchema.md +199 -0
  230. package/docs/classes/MySQLSchemaField.md +330 -0
  231. package/docs/classes/MySQLSchemaTable.md +176 -0
  232. package/docs/enums/ConnectionStatus.md +43 -0
  233. package/docs/enums/DeveloperMode.md +38 -0
  234. package/docs/enums/EventExecutionType.md +43 -0
  235. package/docs/enums/HTTPMethod.md +32 -0
  236. package/docs/enums/HotDBGenerationType.md +30 -0
  237. package/docs/enums/HotLogLevel.md +88 -0
  238. package/docs/interfaces/HotDBConnectionInterface.md +116 -0
  239. package/docs/interfaces/HotDestination.md +62 -0
  240. package/docs/interfaces/HotSite.md +187 -0
  241. package/docs/interfaces/HotSiteMapPath.md +37 -0
  242. package/docs/interfaces/HotSiteRoute.md +79 -0
  243. package/docs/interfaces/HotStartOptions.md +115 -0
  244. package/docs/interfaces/HotTestPage.md +44 -0
  245. package/docs/interfaces/HotTestStop.md +62 -0
  246. package/docs/interfaces/IHotComponent.md +135 -0
  247. package/docs/interfaces/IHotStaq.md +118 -0
  248. package/docs/interfaces/IHotTestElement.md +54 -0
  249. package/docs/interfaces/IHotTestElementOptions.md +43 -0
  250. package/docs/interfaces/MySQLResults.md +43 -0
  251. package/docs/interfaces/MySQLSchemaFieldResult.md +75 -0
  252. package/docs/modules.md +162 -0
  253. package/package.json +65 -0
  254. package/selenium-start.sh +7 -0
  255. package/selenium-stop.sh +3 -0
  256. package/src/Hot.ts +319 -0
  257. package/src/HotAPI.ts +378 -0
  258. package/src/HotAgentAPI.ts +43 -0
  259. package/src/HotAgentRoute.ts +44 -0
  260. package/src/HotBuilder.ts +221 -0
  261. package/src/HotClient.ts +40 -0
  262. package/src/HotComponent.ts +158 -0
  263. package/src/HotCreator.ts +482 -0
  264. package/src/HotDB.ts +79 -0
  265. package/src/HotDBConnectionInterface.ts +40 -0
  266. package/src/HotFile.ts +617 -0
  267. package/src/HotHTTPServer.ts +954 -0
  268. package/src/HotIO.ts +128 -0
  269. package/src/HotLog.ts +158 -0
  270. package/src/HotPage.ts +206 -0
  271. package/src/HotRoute.ts +137 -0
  272. package/src/HotRouteMethod.ts +216 -0
  273. package/src/HotServer.ts +211 -0
  274. package/src/HotSetAsWeb.ts +3 -0
  275. package/src/HotStaq.ts +1877 -0
  276. package/src/HotStaqWeb.ts +59 -0
  277. package/src/HotTestDriver.ts +172 -0
  278. package/src/HotTestElement.ts +97 -0
  279. package/src/HotTestMap.ts +130 -0
  280. package/src/HotTestSeleniumDriver.ts +374 -0
  281. package/src/HotTester.ts +697 -0
  282. package/src/HotTesterAPI.ts +126 -0
  283. package/src/HotTesterMocha.ts +133 -0
  284. package/src/HotTesterMochaSelenium.ts +189 -0
  285. package/src/HotTesterServer.ts +551 -0
  286. package/src/api.ts +102 -0
  287. package/src/cli.ts +1147 -0
  288. package/src/schemas/HotDBInflux.ts +211 -0
  289. package/src/schemas/HotDBMigration.ts +24 -0
  290. package/src/schemas/HotDBMySQL.ts +312 -0
  291. package/src/schemas/HotDBSchema.ts +21 -0
  292. package/src/schemas/influx/InfluxSchema.ts +19 -0
  293. package/src/schemas/mysql/MySQLSchema.ts +90 -0
  294. package/src/schemas/mysql/MySQLSchemaField.ts +408 -0
  295. package/src/schemas/mysql/MySQLSchemaTable.ts +353 -0
  296. package/tsconfig-web.json +74 -0
  297. package/tsconfig.json +73 -0
  298. package/webpack.config.js +51 -0
  299. package/webpack.config.tests.js +56 -0
@@ -0,0 +1,40 @@
1
+ import { HotStaq } from "./HotStaq";
2
+ import { HotAPI } from "./HotAPI";
3
+ import { HotServerType } from "./HotServer";
4
+ import { HotLog } from "./HotLog";
5
+
6
+ /**
7
+ * A client connected to a server.
8
+ */
9
+ export class HotClient
10
+ {
11
+ /**
12
+ * The processor to use.
13
+ */
14
+ processor: HotStaq;
15
+ /**
16
+ * The API to use.
17
+ */
18
+ api: HotAPI;
19
+ /**
20
+ * The tester API to use.
21
+ */
22
+ testerAPI: HotAPI;
23
+ /**
24
+ * The type of server.
25
+ */
26
+ type: HotServerType;
27
+ /**
28
+ * The logger.
29
+ */
30
+ logger: HotLog;
31
+
32
+ constructor (processor: HotStaq)
33
+ {
34
+ this.processor = processor;
35
+ this.api = null;
36
+ this.testerAPI = null;
37
+ this.type = HotServerType.HTTP;
38
+ this.logger = processor.logger;
39
+ }
40
+ }
@@ -0,0 +1,158 @@
1
+ import { HotAPI } from "./HotAPI";
2
+ import { HotStaq } from "./HotStaq";
3
+
4
+ /**
5
+ * A component to preprocess.
6
+ */
7
+ export interface IHotComponent
8
+ {
9
+ /**
10
+ * The processor to use.
11
+ */
12
+ processor: HotStaq;
13
+ /**
14
+ * The associated HTMLElement.
15
+ */
16
+ htmlElement?: HTMLElement;
17
+ /**
18
+ * The name of the page.
19
+ */
20
+ name?: string;
21
+ /**
22
+ * The name of the tag.
23
+ */
24
+ tag?: string;
25
+ /**
26
+ * The connected API.
27
+ */
28
+ api?: HotAPI;
29
+ /**
30
+ * The options to include with registering this component.
31
+ */
32
+ elementOptions?: ElementDefinitionOptions;
33
+ /**
34
+ * The type of component.
35
+ */
36
+ type?: string;
37
+ /**
38
+ * The value of the component.
39
+ */
40
+ value?: any;
41
+ /**
42
+ * The events to trigger.
43
+ */
44
+ events?: {
45
+ [name: string]: {
46
+ type: string;
47
+ func: Function;
48
+ options?: any;
49
+ }
50
+ };
51
+ }
52
+
53
+ /**
54
+ * A component to preprocess.
55
+ */
56
+ export abstract class HotComponent implements IHotComponent
57
+ {
58
+ /**
59
+ * The processor to use.
60
+ */
61
+ processor: HotStaq;
62
+ /**
63
+ * The associated HTMLElement.
64
+ */
65
+ htmlElement: HTMLElement;
66
+ /**
67
+ * The name of the component.
68
+ */
69
+ name: string;
70
+ /**
71
+ * The name of the tag.
72
+ */
73
+ tag: string;
74
+ /**
75
+ * The connected API.
76
+ */
77
+ api: HotAPI;
78
+ /**
79
+ * The options to include with registering this component.
80
+ */
81
+ elementOptions: ElementDefinitionOptions;
82
+ /**
83
+ * The type of component.
84
+ */
85
+ type: string;
86
+ /**
87
+ * The value of the component.
88
+ */
89
+ value: any;
90
+ /**
91
+ * The events to trigger.
92
+ */
93
+ events: {
94
+ [name: string]: {
95
+ type: string;
96
+ func: Function;
97
+ options: any;
98
+ }
99
+ };
100
+
101
+ constructor (copy: IHotComponent | HotStaq, api: HotAPI = null)
102
+ {
103
+ if (copy instanceof HotStaq)
104
+ {
105
+ this.processor = copy;
106
+ this.htmlElement = null;
107
+ this.name = "";
108
+ this.tag = "";
109
+ this.api = null;
110
+ this.elementOptions = undefined;
111
+ this.type = "";
112
+ this.value = null;
113
+ this.events = {};
114
+ }
115
+ else
116
+ {
117
+ this.processor = copy.processor;
118
+ this.htmlElement = copy.htmlElement || null;
119
+ this.name = copy.name || "";
120
+ this.tag = copy.tag || this.name;
121
+ this.api = copy.api || null;
122
+ this.elementOptions = copy.elementOptions || undefined;
123
+ this.type = copy.type || "";
124
+ this.value = copy.value || null;
125
+ this.events = {};
126
+ }
127
+
128
+ if (api != null)
129
+ this.api = api;
130
+ }
131
+
132
+ /**
133
+ * Event that's called when this component is created. This is
134
+ * called before output is called. Right after this is called,
135
+ * the attributes from the HTMLElement will be processed. If
136
+ * the functionality of the attributes processing need to be
137
+ * overwritten, use the handleAttributes method to handle them.
138
+ */
139
+ async onCreated (element: HTMLElement): Promise<any>
140
+ {
141
+ return (element);
142
+ }
143
+
144
+ /**
145
+ * Handle the attributes manually.
146
+ */
147
+ async handleAttributes? (attributes: NamedNodeMap): Promise<void>;
148
+
149
+ /**
150
+ * Handle a click event.
151
+ */
152
+ abstract click (): Promise<void>;
153
+
154
+ /**
155
+ * Output the component.
156
+ */
157
+ abstract output (): Promise<string>;
158
+ }
@@ -0,0 +1,482 @@
1
+ import * as ppath from "path";
2
+ const util = require ("util");
3
+ const asyncExec = util.promisify (require ("child_process").exec);
4
+
5
+ import { HotIO } from "./HotIO";
6
+ import { HotStaq, HotSite } from "./HotStaq";
7
+ import { HotLog } from "./HotLog";
8
+
9
+ /**
10
+ * Creates stuff for the CLI.
11
+ */
12
+ export class HotCreator
13
+ {
14
+ /**
15
+ * The name of the app to create.
16
+ */
17
+ name: string;
18
+ /**
19
+ * The type of project to create. Can be:
20
+ * * web
21
+ * * web-api
22
+ * * api
23
+ */
24
+ type: string;
25
+ /**
26
+ * The language to use when creating. Default is "ts". Can be:
27
+ * * ts
28
+ */
29
+ language: string;
30
+ /**
31
+ * The output directory.
32
+ */
33
+ outputDir: string;
34
+ /**
35
+ * The logger.
36
+ */
37
+ logger: HotLog;
38
+ /**
39
+ * The commands used while creating the app.
40
+ */
41
+ createCommands: {
42
+ /**
43
+ * The init command to use after the project has been created.
44
+ */
45
+ init: string;
46
+ /**
47
+ * The transpile command to use after the project has been initialized.
48
+ */
49
+ transpileTS: string;
50
+ };
51
+ /**
52
+ * The NPM commands used.
53
+ */
54
+ npmCommands: {
55
+ /**
56
+ * The start command to use.
57
+ */
58
+ start: string;
59
+ /**
60
+ * The dev start command to use.
61
+ */
62
+ dev: string;
63
+ /**
64
+ * The test command to use.
65
+ */
66
+ test: string;
67
+ /**
68
+ * The build command to use.
69
+ */
70
+ build: string;
71
+ /**
72
+ * The web api build command to use.
73
+ */
74
+ buildWebAPI: string;
75
+ /**
76
+ * The debug web api build command to use.
77
+ */
78
+ buildWebAPIDebug: string;
79
+ };
80
+
81
+ constructor (name: string = "", logger: HotLog = new HotLog ())
82
+ {
83
+ this.name = name;
84
+ this.type = "web-api";
85
+ this.language = "ts";
86
+ this.outputDir = "";
87
+ this.logger = logger;
88
+ this.createCommands = {
89
+ init: "git init && npm install",
90
+ transpileTS: "npm run build"
91
+ };
92
+ this.npmCommands = {
93
+ start: "",
94
+ dev: "",
95
+ test: "hotstaq test",
96
+ build: "",
97
+ buildWebAPI: "",
98
+ buildWebAPIDebug: ""
99
+ };
100
+ }
101
+
102
+ /**
103
+ * Execute a command.
104
+ */
105
+ protected static async exec (cmd: string): Promise<string>
106
+ {
107
+ let output = await asyncExec (cmd);
108
+
109
+ return (output.stdout);
110
+ }
111
+
112
+ /**
113
+ * Copy the libraries over to a new location.
114
+ */
115
+ async copyLibraries (location: string): Promise<void>
116
+ {
117
+ const buildWebDir: string = ppath.normalize (`${__dirname}/../../build-web`);
118
+
119
+ await HotIO.copyFiles (buildWebDir, ppath.normalize (location));
120
+ }
121
+
122
+ /**
123
+ * Create an app.
124
+ */
125
+ async create (): Promise<void>
126
+ {
127
+ this.logger.info (`Creating "${this.name}" of type ${this.type} for language ${this.language}...`);
128
+
129
+ HotStaq.checkHotSiteName (this.name, true);
130
+
131
+ this.outputDir = ppath.normalize (`${this.outputDir}`);
132
+ await HotIO.mkdir (ppath.join (this.outputDir, "/public/js/"));
133
+ await HotIO.mkdir (ppath.join (this.outputDir, "/.vscode/"));
134
+ await HotIO.mkdir (ppath.join (this.outputDir, "/src/"));
135
+
136
+ let readMeBuildSteps: string = "";
137
+
138
+ if (this.language === "ts")
139
+ {
140
+ readMeBuildSteps = `
141
+ npm run build
142
+
143
+ This will transpile the TypeScript into ES6 JavaScript by default. After this is done building, enter:
144
+ `;
145
+ }
146
+
147
+ let packageJSON: any = {
148
+ "name": this.name,
149
+ "description": "",
150
+ "version": "1.0.0",
151
+ "main": "index.js",
152
+ "scripts": {
153
+ },
154
+ "keywords": [],
155
+ "author": "",
156
+ "license": "ISC",
157
+ "dependencies": {
158
+ "hotstaq": "^0.5.23",
159
+ "copy-webpack-plugin": "^6.0.3"
160
+ }
161
+ };
162
+
163
+ if (this.npmCommands.start === "")
164
+ this.npmCommands.start = `hotstaq --hotsite ./HotSite.json run --server-type ${this.type}`;
165
+
166
+ if (this.npmCommands.start !== "")
167
+ packageJSON.scripts["start"] = this.npmCommands.start;
168
+
169
+ if (this.npmCommands.dev === "")
170
+ this.npmCommands.dev = `hotstaq --hotsite ./HotSite.json --development-mode run --server-type ${this.type} --web-http-port 8080`;
171
+
172
+ if (this.npmCommands.dev !== "")
173
+ packageJSON.scripts["dev"] = this.npmCommands.dev;
174
+
175
+ if (this.npmCommands.test !== "")
176
+ packageJSON.scripts["test"] = this.npmCommands.test;
177
+
178
+ if (this.npmCommands.build === "")
179
+ {
180
+ if (this.language === "ts")
181
+ this.npmCommands.build = "tsc --build ./tsconfig.json";
182
+ }
183
+
184
+ if (this.npmCommands.build !== "")
185
+ packageJSON.scripts["build"] = this.npmCommands.build;
186
+
187
+ if (this.npmCommands.buildWebAPI === "")
188
+ {
189
+ if (this.language === "ts")
190
+ this.npmCommands.buildWebAPI = "webpack --mode=production --config ./webpack-api.config.js";
191
+ }
192
+
193
+ if (this.npmCommands.buildWebAPI !== "")
194
+ packageJSON.scripts["build-web"] = this.npmCommands.buildWebAPI;
195
+
196
+ if (this.npmCommands.buildWebAPIDebug === "")
197
+ {
198
+ if (this.language === "ts")
199
+ this.npmCommands.buildWebAPIDebug = "webpack --mode=development --debug --config ./webpack-api.config.js";
200
+ }
201
+
202
+ if (this.npmCommands.buildWebAPIDebug !== "")
203
+ packageJSON.scripts["build-web-debug"] = this.npmCommands.buildWebAPIDebug;
204
+
205
+ // If this is a web only build, remove the build web scripts from packageJSON.
206
+ if (this.type === "web")
207
+ {
208
+ if (packageJSON.scripts["build-web"] != null)
209
+ delete packageJSON.scripts["build-web"];
210
+
211
+ if (packageJSON.scripts["build-web-debug"] != null)
212
+ delete packageJSON.scripts["build-web-debug"];
213
+ }
214
+
215
+ if (this.language === "ts")
216
+ packageJSON.main = "build/AppAPI.js";
217
+
218
+ let packageJSONstr: string = JSON.stringify (packageJSON, null, 2);
219
+ await HotIO.writeTextFile (ppath.normalize (`${this.outputDir}/package.json`), packageJSONstr);
220
+
221
+ let hotSiteJSON: HotSite = {
222
+ name: this.name,
223
+ server: {
224
+ globalApi: "AppAPI",
225
+ serveDirectories: [{
226
+ route: "/",
227
+ localPath: "./public/"
228
+ }]
229
+ },
230
+ testing: {
231
+ web: {
232
+ tester: "HotTesterMochaSelenium",
233
+ testerAPIUrl: "http://127.0.0.1:8183"
234
+ }
235
+ }
236
+ };
237
+
238
+ if (this.language === "ts")
239
+ {
240
+ if ((this.type === "web-api") || (this.type === "api"))
241
+ {
242
+ hotSiteJSON.apis = {};
243
+ hotSiteJSON.apis["AppAPI"] = {
244
+ "jsapi": `./js/${this.name}.js`,
245
+ "libraryName": `${this.name}Web`,
246
+ "apiName": "AppAPI",
247
+ "filepath": "./build/AppAPI.js"
248
+ };
249
+ }
250
+ }
251
+
252
+ let hotSiteJSONstr: string = JSON.stringify (hotSiteJSON, null, "\t");
253
+ await HotIO.writeTextFile (ppath.normalize (`${this.outputDir}/HotSite.json`), hotSiteJSONstr);
254
+
255
+ this.logger.info (`Copying files...`);
256
+
257
+ const projectDir: string = ppath.normalize (`${__dirname}/../../creator/project`);
258
+ await HotIO.copyFiles (projectDir, ppath.normalize (`${this.outputDir}/`));
259
+ await HotIO.moveFile (`${this.outputDir}/gitignore`, `${this.outputDir}/.gitignore`);
260
+ await HotIO.moveFile (`${this.outputDir}/npmignore`, `${this.outputDir}/.npmignore`);
261
+
262
+ await this.replaceKeysInFile (ppath.normalize (`${this.outputDir}/README.md`), {
263
+ "APPNAME": this.name,
264
+ "BUILDSTEPS": readMeBuildSteps
265
+ });
266
+
267
+ if ((this.type === "web") || (this.type === "web-api"))
268
+ {
269
+ const publicDir: string = ppath.normalize (`${__dirname}/../../creator/public`);
270
+ await HotIO.copyFiles (publicDir, ppath.normalize (`${this.outputDir}/public/`));
271
+ }
272
+
273
+ if (this.language === "ts")
274
+ {
275
+ if ((this.type === "web-api") || (this.type === "api"))
276
+ {
277
+ const filesDir: string = ppath.normalize (`${__dirname}/../../creator/ts`);
278
+ await HotIO.copyFiles (filesDir, ppath.normalize (`${this.outputDir}/`));
279
+
280
+ await this.replaceKeysInFile (ppath.normalize (`${this.outputDir}/webpack-api.config.js`), {
281
+ "APPNAME": this.name
282
+ });
283
+ }
284
+ }
285
+
286
+ this.logger.info (`Finished copying files...`);
287
+
288
+ this.logger.info (`Copying HotStaq JS files...`);
289
+ const buildWebDir: string = ppath.normalize (`${__dirname}/../../build-web`);
290
+
291
+ await HotIO.copyFiles (buildWebDir, ppath.normalize (`${this.outputDir}/public/js/`));
292
+ this.logger.info (`Finished copying public files...`);
293
+
294
+ this.logger.info (`Creating VSCode files...`);
295
+
296
+ let launchJSON: any = {
297
+ "version": "0.2.0",
298
+ "configurations": [
299
+ {
300
+ "type": "node",
301
+ "request": "launch",
302
+ "name": "Debug Web Server",
303
+ "program": "${workspaceFolder}/node_modules/hotstaq/build/src/cli.js",
304
+ "skipFiles": [
305
+ "<node_internals>/**"
306
+ ],
307
+ "outputCapture": "std",
308
+ "args": [
309
+ "--development-mode",
310
+ "--hotsite",
311
+ "./HotSite.json",
312
+ "run",
313
+ "--web-http-port",
314
+ "8080"
315
+ ],
316
+ "env": {
317
+ }
318
+ }
319
+ ]
320
+ };
321
+
322
+ if (this.language === "ts")
323
+ {
324
+ if ((this.type === "web-api") || (this.type === "api"))
325
+ {
326
+ launchJSON["configurations"].push (
327
+ {
328
+ "type": "node",
329
+ "request": "launch",
330
+ "name": "Debug Web/API Server",
331
+ "program": "${workspaceFolder}/node_modules/hotstaq/build/src/cli.js",
332
+ "skipFiles": [
333
+ "<node_internals>/**"
334
+ ],
335
+ "outputCapture": "std",
336
+ "args": [
337
+ "--development-mode",
338
+ "--hotsite",
339
+ "./HotSite.json",
340
+ "run",
341
+ "--server-type",
342
+ "web-api",
343
+ "--web-http-port",
344
+ "8080",
345
+ "--api-http-port",
346
+ "8081"
347
+ ],
348
+ "env": {
349
+ }
350
+ },
351
+ {
352
+ "type": "node",
353
+ "request": "launch",
354
+ "name": "Debug API Server",
355
+ "program": "${workspaceFolder}/node_modules/hotstaq/build/src/cli.js",
356
+ "skipFiles": [
357
+ "<node_internals>/**"
358
+ ],
359
+ "outputCapture": "std",
360
+ "args": [
361
+ "--development-mode",
362
+ "--hotsite",
363
+ "./HotSite.json",
364
+ "run",
365
+ "--server-type",
366
+ "api",
367
+ "--api-http-port",
368
+ "8081"
369
+ ],
370
+ "env": {
371
+ }
372
+ });
373
+ }
374
+ }
375
+
376
+ launchJSON["configurations"].push (
377
+ {
378
+ "type": "node",
379
+ "request": "launch",
380
+ "name": "Run Web Tests",
381
+ "skipFiles": [
382
+ "<node_internals>/**"
383
+ ],
384
+ "program": "${workspaceFolder}/node_modules/hotstaq/build/src/cli.js",
385
+ "args": [
386
+ "--development-mode",
387
+ "--hotsite",
388
+ "./HotSite.json",
389
+ "test",
390
+ "--web-http-port",
391
+ "8080"
392
+ ],
393
+ "env": {
394
+ }
395
+ });
396
+ launchJSON["configurations"].push (
397
+ {
398
+ "type": "pwa-node",
399
+ "request": "attach",
400
+ "name": "Remote Debugger",
401
+ "skipFiles": [
402
+ "<node_internals>/**"
403
+ ],
404
+ "localRoot": "${workspaceFolder}",
405
+ "address": "127.0.0.1",
406
+ "port": 9229,
407
+ "remoteRoot": `/app/${this.name}`
408
+ });
409
+
410
+ let launchJSONstr: string = JSON.stringify (launchJSON, null, "\t");
411
+ await HotIO.writeTextFile (ppath.normalize (`${this.outputDir}/.vscode/launch.json`), launchJSONstr);
412
+ let tasksJSON: any = {
413
+ "version": "2.0.0",
414
+ "tasks": []
415
+ };
416
+
417
+ if (this.language === "ts")
418
+ {
419
+ if ((this.type === "web-api") || (this.type === "api"))
420
+ {
421
+ tasksJSON["tasks"].push (
422
+ {
423
+ "type": "shell",
424
+ "group": "build",
425
+ "runOptions": {
426
+ "instanceLimit": 1
427
+ },
428
+ "problemMatcher": [],
429
+ "label": "Build Web API Debug",
430
+ "command": "npx webpack --mode=development --config=webpack-api.config.js --debug --watch"
431
+ },
432
+ {
433
+ "type": "typescript",
434
+ "tsconfig": "tsconfig.json",
435
+ "option": "watch",
436
+ "problemMatcher": [
437
+ "$tsc-watch"
438
+ ],
439
+ "group": "build",
440
+ "runOptions": {
441
+ "instanceLimit": 1
442
+ },
443
+ "label": "Build Server"
444
+ });
445
+ }
446
+ }
447
+
448
+ let tasksJSONstr: string = JSON.stringify (tasksJSON, null, "\t");
449
+ await HotIO.writeTextFile (ppath.normalize (`${this.outputDir}/.vscode/tasks.json`), tasksJSONstr);
450
+ this.logger.info (`Finished creating VSCode files...`);
451
+
452
+ this.logger.info (`Creating git repo and installing modules...`);
453
+ await HotCreator.exec (`cd ${this.outputDir} && ${this.createCommands.init}`);
454
+ this.logger.info (`Finished creating git repo and installing modules...`);
455
+
456
+ if (this.language === "ts")
457
+ {
458
+ this.logger.info (`Transpiling TypeScript...`);
459
+ await HotCreator.exec (`cd ${this.outputDir} && ${this.createCommands.transpileTS}`);
460
+ this.logger.info (`Finished transpiling TypeScript...`);
461
+ }
462
+
463
+ this.logger.info (`Finished creating "${this.name}"...`);
464
+ }
465
+
466
+ /**
467
+ * Replace keys in a file.
468
+ */
469
+ protected async replaceKeysInFile (filepath: string, keys: { [name: string]: string; }): Promise<void>
470
+ {
471
+ let contents: string = await HotIO.readTextFile (filepath);
472
+
473
+ for (let key in keys)
474
+ {
475
+ let value: string = keys[key];
476
+
477
+ contents = HotStaq.replaceKey (contents, key, value);
478
+ }
479
+
480
+ await HotIO.writeTextFile (filepath, contents);
481
+ }
482
+ }