hotstaq 0.5.3

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