@celljs/cli 3.0.0

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 (384) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/bin/cell +2 -0
  4. package/lib/build/build-manager.d.ts +9 -0
  5. package/lib/build/build-manager.d.ts.map +1 -0
  6. package/lib/build/build-manager.js +41 -0
  7. package/lib/build/build-manager.js.map +1 -0
  8. package/lib/build/build.d.ts +6 -0
  9. package/lib/build/build.d.ts.map +1 -0
  10. package/lib/build/build.js +16 -0
  11. package/lib/build/build.js.map +1 -0
  12. package/lib/cell-main.d.ts +2 -0
  13. package/lib/cell-main.d.ts.map +1 -0
  14. package/lib/cell-main.js +110 -0
  15. package/lib/cell-main.js.map +1 -0
  16. package/lib/cell.d.ts +2 -0
  17. package/lib/cell.d.ts.map +1 -0
  18. package/lib/cell.js +190 -0
  19. package/lib/cell.js.map +1 -0
  20. package/lib/config/config.d.ts +12 -0
  21. package/lib/config/config.d.ts.map +1 -0
  22. package/lib/config/config.js +48 -0
  23. package/lib/config/config.js.map +1 -0
  24. package/lib/deploy/deploy.d.ts +7 -0
  25. package/lib/deploy/deploy.d.ts.map +1 -0
  26. package/lib/deploy/deploy.js +27 -0
  27. package/lib/deploy/deploy.js.map +1 -0
  28. package/lib/index.d.ts +1 -0
  29. package/lib/index.d.ts.map +1 -0
  30. package/lib/index.js +1 -0
  31. package/lib/index.js.map +1 -0
  32. package/lib/info/info.d.ts +6 -0
  33. package/lib/info/info.d.ts.map +1 -0
  34. package/lib/info/info.js +21 -0
  35. package/lib/info/info.js.map +1 -0
  36. package/lib/init/init-manager.d.ts +33 -0
  37. package/lib/init/init-manager.d.ts.map +1 -0
  38. package/lib/init/init-manager.js +138 -0
  39. package/lib/init/init-manager.js.map +1 -0
  40. package/lib/init/init.d.ts +4 -0
  41. package/lib/init/init.d.ts.map +1 -0
  42. package/lib/init/init.js +17 -0
  43. package/lib/init/init.js.map +1 -0
  44. package/lib/init/templates.d.ts +2 -0
  45. package/lib/init/templates.d.ts.map +1 -0
  46. package/lib/init/templates.js +25 -0
  47. package/lib/init/templates.js.map +1 -0
  48. package/lib/malagu-main.d.ts +2 -0
  49. package/lib/malagu-main.d.ts.map +1 -0
  50. package/lib/malagu-main.js +110 -0
  51. package/lib/malagu-main.js.map +1 -0
  52. package/lib/malagu.d.ts +2 -0
  53. package/lib/malagu.d.ts.map +1 -0
  54. package/lib/malagu.js +190 -0
  55. package/lib/malagu.js.map +1 -0
  56. package/lib/package.spec.d.ts +1 -0
  57. package/lib/package.spec.d.ts.map +1 -0
  58. package/lib/package.spec.js +4 -0
  59. package/lib/package.spec.js.map +1 -0
  60. package/lib/props/props.d.ts +9 -0
  61. package/lib/props/props.d.ts.map +1 -0
  62. package/lib/props/props.js +46 -0
  63. package/lib/props/props.js.map +1 -0
  64. package/lib/serve/serve-manager.d.ts +8 -0
  65. package/lib/serve/serve-manager.d.ts.map +1 -0
  66. package/lib/serve/serve-manager.js +44 -0
  67. package/lib/serve/serve-manager.js.map +1 -0
  68. package/lib/serve/serve.d.ts +7 -0
  69. package/lib/serve/serve.d.ts.map +1 -0
  70. package/lib/serve/serve.js +16 -0
  71. package/lib/serve/serve.js.map +1 -0
  72. package/lib/update/update.d.ts +9 -0
  73. package/lib/update/update.d.ts.map +1 -0
  74. package/lib/update/update.js +56 -0
  75. package/lib/update/update.js.map +1 -0
  76. package/lib/utils/banner-util.d.ts +6 -0
  77. package/lib/utils/banner-util.d.ts.map +1 -0
  78. package/lib/utils/banner-util.js +44 -0
  79. package/lib/utils/banner-util.js.map +1 -0
  80. package/lib/utils/index.d.ts +2 -0
  81. package/lib/utils/index.d.ts.map +1 -0
  82. package/lib/utils/index.js +18 -0
  83. package/lib/utils/index.js.map +1 -0
  84. package/package.json +63 -0
  85. package/src/build/build-manager.ts +50 -0
  86. package/src/build/build.ts +17 -0
  87. package/src/cell-main.ts +125 -0
  88. package/src/cell.ts +214 -0
  89. package/src/config/config.ts +56 -0
  90. package/src/deploy/deploy.ts +31 -0
  91. package/src/index.ts +0 -0
  92. package/src/info/info.ts +23 -0
  93. package/src/init/init-manager.ts +163 -0
  94. package/src/init/init.ts +15 -0
  95. package/src/init/templates.ts +21 -0
  96. package/src/package.spec.ts +4 -0
  97. package/src/props/props.ts +48 -0
  98. package/src/serve/serve-manager.ts +51 -0
  99. package/src/serve/serve.ts +19 -0
  100. package/src/update/update.ts +61 -0
  101. package/src/utils/banner-util.ts +41 -0
  102. package/src/utils/index.ts +1 -0
  103. package/templates/accounts/README.md +92 -0
  104. package/templates/accounts/cell-database.yml +17 -0
  105. package/templates/accounts/cell-locale.yml +17 -0
  106. package/templates/accounts/cell-oauth2.0.yml +8 -0
  107. package/templates/accounts/cell-theme.yml +9 -0
  108. package/templates/accounts/cell.yml +10 -0
  109. package/templates/accounts/favicon.ico +0 -0
  110. package/templates/accounts/package.json +48 -0
  111. package/templates/accounts/src/browser/home.view.tsx +86 -0
  112. package/templates/accounts/src/browser/index.ts +3 -0
  113. package/templates/accounts/src/browser/login.view.tsx +78 -0
  114. package/templates/accounts/src/browser/module.ts +3 -0
  115. package/templates/accounts/src/common/entity-protocol.ts +7 -0
  116. package/templates/accounts/src/common/index.ts +1 -0
  117. package/templates/accounts/src/node/authentication/authentication-success-handler.ts +69 -0
  118. package/templates/accounts/src/node/authentication/index.ts +1 -0
  119. package/templates/accounts/src/node/entity/base-entity.ts +13 -0
  120. package/templates/accounts/src/node/entity/connection.ts +52 -0
  121. package/templates/accounts/src/node/entity/index.ts +1 -0
  122. package/templates/accounts/src/node/entity/user.ts +73 -0
  123. package/templates/accounts/src/node/error/error.ts +14 -0
  124. package/templates/accounts/src/node/error/index.ts +1 -0
  125. package/templates/accounts/src/node/index.ts +2 -0
  126. package/templates/accounts/src/node/module.ts +9 -0
  127. package/templates/accounts/src/node/user/index.ts +4 -0
  128. package/templates/accounts/src/node/user/user-protocol.ts +19 -0
  129. package/templates/accounts/src/node/user/user-repository.ts +72 -0
  130. package/templates/accounts/src/node/user/user-service.ts +36 -0
  131. package/templates/accounts/tsconfig.json +29 -0
  132. package/templates/admin-app/.github/workflows/deploy.yml +25 -0
  133. package/templates/admin-app/.vscode/launch.json +23 -0
  134. package/templates/admin-app/README.md +92 -0
  135. package/templates/admin-app/cell-database.yml +7 -0
  136. package/templates/admin-app/cell.yml +93 -0
  137. package/templates/admin-app/package.json +37 -0
  138. package/templates/admin-app/src/browser/module.ts +3 -0
  139. package/templates/admin-app/src/browser/user.view.tsx +40 -0
  140. package/templates/admin-app/src/common/index.ts +1 -0
  141. package/templates/admin-app/src/common/user-protocol.ts +23 -0
  142. package/templates/admin-app/src/node/entity/index.ts +1 -0
  143. package/templates/admin-app/src/node/entity/user.ts +15 -0
  144. package/templates/admin-app/src/node/module.ts +8 -0
  145. package/templates/admin-app/src/node/user-service.ts +41 -0
  146. package/templates/admin-app/tsconfig.json +29 -0
  147. package/templates/backend-app/.github/workflows/deploy.yml +25 -0
  148. package/templates/backend-app/.vscode/launch.json +23 -0
  149. package/templates/backend-app/README.md +92 -0
  150. package/templates/backend-app/cell.yml +0 -0
  151. package/templates/backend-app/package.json +33 -0
  152. package/templates/backend-app/src/home-controller.ts +11 -0
  153. package/templates/backend-app/src/module.ts +4 -0
  154. package/templates/backend-app/src/user-controller.ts +48 -0
  155. package/templates/backend-app/test/home-controller.spec.ts +16 -0
  156. package/templates/backend-app/tsconfig.json +29 -0
  157. package/templates/cell-component/.eslintrc.js +10 -0
  158. package/templates/cell-component/README.md +36 -0
  159. package/templates/cell-component/cell.yml +0 -0
  160. package/templates/cell-component/package.json +29 -0
  161. package/templates/cell-component/src/echo-service.ts +16 -0
  162. package/templates/cell-component/src/index.ts +1 -0
  163. package/templates/cell-component/src/module.ts +4 -0
  164. package/templates/cell-component/src/package.spec.ts +4 -0
  165. package/templates/cell-component/tsconfig.json +11 -0
  166. package/templates/database-app/.github/workflows/deploy.yml +25 -0
  167. package/templates/database-app/.vscode/launch.json +23 -0
  168. package/templates/database-app/README.md +92 -0
  169. package/templates/database-app/cell.yml +17 -0
  170. package/templates/database-app/package.json +31 -0
  171. package/templates/database-app/src/entity/index.ts +1 -0
  172. package/templates/database-app/src/entity/user.ts +13 -0
  173. package/templates/database-app/src/home-controller.ts +11 -0
  174. package/templates/database-app/src/module.ts +8 -0
  175. package/templates/database-app/src/user-controller.ts +43 -0
  176. package/templates/database-app/tsconfig.json +29 -0
  177. package/templates/docker-app/.github/workflows/deploy.yml +25 -0
  178. package/templates/docker-app/.vscode/launch.json +23 -0
  179. package/templates/docker-app/Dockerfile +27 -0
  180. package/templates/docker-app/README.md +93 -0
  181. package/templates/docker-app/cell.yml +0 -0
  182. package/templates/docker-app/package.json +31 -0
  183. package/templates/docker-app/src/browser/assets/logo.png +0 -0
  184. package/templates/docker-app/src/browser/css-shims.d.ts +30 -0
  185. package/templates/docker-app/src/browser/hello.view.tsx +31 -0
  186. package/templates/docker-app/src/browser/module.ts +3 -0
  187. package/templates/docker-app/src/browser/style/hello.module.scss +4 -0
  188. package/templates/docker-app/src/common/welcome-protocol.ts +5 -0
  189. package/templates/docker-app/src/node/module.ts +3 -0
  190. package/templates/docker-app/src/node/welcome-server.ts +9 -0
  191. package/templates/docker-app/tsconfig.json +30 -0
  192. package/templates/file-service/.github/workflows/deploy.yml +25 -0
  193. package/templates/file-service/.vscode/launch.json +23 -0
  194. package/templates/file-service/README.md +92 -0
  195. package/templates/file-service/cell.yml +12 -0
  196. package/templates/file-service/package.json +34 -0
  197. package/templates/file-service/src/file-controller.ts +47 -0
  198. package/templates/file-service/src/home-controller.ts +11 -0
  199. package/templates/file-service/src/module.ts +5 -0
  200. package/templates/file-service/tsconfig.json +29 -0
  201. package/templates/jwt-app/.github/workflows/deploy.yml +25 -0
  202. package/templates/jwt-app/.vscode/launch.json +23 -0
  203. package/templates/jwt-app/README.md +92 -0
  204. package/templates/jwt-app/cell.yml +4 -0
  205. package/templates/jwt-app/package.json +36 -0
  206. package/templates/jwt-app/src/context.ts +16 -0
  207. package/templates/jwt-app/src/error-handler.ts +30 -0
  208. package/templates/jwt-app/src/error.ts +4 -0
  209. package/templates/jwt-app/src/home-controller.ts +23 -0
  210. package/templates/jwt-app/src/index.ts +5 -0
  211. package/templates/jwt-app/src/jwt-middleware.ts +36 -0
  212. package/templates/jwt-app/src/module.ts +3 -0
  213. package/templates/jwt-app/test/home-controller.spec.ts +16 -0
  214. package/templates/jwt-app/tsconfig.json +29 -0
  215. package/templates/koa-app/app.js +8 -0
  216. package/templates/koa-app/package.json +9 -0
  217. package/templates/microservice/.github/workflows/deploy.yml +28 -0
  218. package/templates/microservice/.vscode/launch.json +24 -0
  219. package/templates/microservice/README.md +92 -0
  220. package/templates/microservice/examples/backend-app/README.md +92 -0
  221. package/templates/microservice/examples/backend-app/cell-remote.yml +4 -0
  222. package/templates/microservice/examples/backend-app/cell.yml +3 -0
  223. package/templates/microservice/examples/backend-app/package.json +32 -0
  224. package/templates/microservice/examples/backend-app/src/api-controller.ts +31 -0
  225. package/templates/microservice/examples/backend-app/src/module.ts +3 -0
  226. package/templates/microservice/examples/backend-app/tsconfig.json +29 -0
  227. package/templates/microservice/lerna.json +19 -0
  228. package/templates/microservice/package.json +23 -0
  229. package/templates/microservice/packages/api/README.md +92 -0
  230. package/templates/microservice/packages/api/cell.yml +0 -0
  231. package/templates/microservice/packages/api/package.json +25 -0
  232. package/templates/microservice/packages/api/src/common/api-protocol.ts +10 -0
  233. package/templates/microservice/packages/api/src/common/index.ts +1 -0
  234. package/templates/microservice/packages/api/tsconfig.json +27 -0
  235. package/templates/microservice/packages/serviceA/.vscode/launch.json +23 -0
  236. package/templates/microservice/packages/serviceA/README.md +92 -0
  237. package/templates/microservice/packages/serviceA/cell.yml +6 -0
  238. package/templates/microservice/packages/serviceA/package.json +29 -0
  239. package/templates/microservice/packages/serviceA/src/node/module.ts +3 -0
  240. package/templates/microservice/packages/serviceA/src/node/service-a.ts +9 -0
  241. package/templates/microservice/packages/serviceA/tsconfig.json +27 -0
  242. package/templates/microservice/packages/serviceB/README.md +92 -0
  243. package/templates/microservice/packages/serviceB/cell.yml +5 -0
  244. package/templates/microservice/packages/serviceB/package.json +29 -0
  245. package/templates/microservice/packages/serviceB/src/node/module.ts +3 -0
  246. package/templates/microservice/packages/serviceB/src/node/service-b.ts +9 -0
  247. package/templates/microservice/packages/serviceB/tsconfig.json +27 -0
  248. package/templates/microservice/tsconfig.json +29 -0
  249. package/templates/monorepo/.editorconfig +12 -0
  250. package/templates/monorepo/.eslintrc.js +18 -0
  251. package/templates/monorepo/.yarnrc +1 -0
  252. package/templates/monorepo/CHANGELOG.md +5 -0
  253. package/templates/monorepo/README.md +0 -0
  254. package/templates/monorepo/apps/sample-app/cell.yml +0 -0
  255. package/templates/monorepo/apps/sample-app/package.json +33 -0
  256. package/templates/monorepo/apps/sample-app/src/browser/assets/logo.png +0 -0
  257. package/templates/monorepo/apps/sample-app/src/browser/css-shims.d.ts +30 -0
  258. package/templates/monorepo/apps/sample-app/src/browser/hello.view.tsx +31 -0
  259. package/templates/monorepo/apps/sample-app/src/browser/module.ts +3 -0
  260. package/templates/monorepo/apps/sample-app/src/browser/style/hello.module.scss +4 -0
  261. package/templates/monorepo/apps/sample-app/src/common/welcome-protocol.ts +5 -0
  262. package/templates/monorepo/apps/sample-app/src/node/module.ts +3 -0
  263. package/templates/monorepo/apps/sample-app/src/node/welcome-server.ts +9 -0
  264. package/templates/monorepo/apps/sample-app/tsconfig.json +30 -0
  265. package/templates/monorepo/configs/root-compilation.tsconfig.json +14 -0
  266. package/templates/monorepo/configs/typedoc-tsconfig.json +6 -0
  267. package/templates/monorepo/configs/typedoc.json +23 -0
  268. package/templates/monorepo/lerna.json +17 -0
  269. package/templates/monorepo/package.json +46 -0
  270. package/templates/monorepo/packages/core/.eslintrc.js +10 -0
  271. package/templates/monorepo/packages/core/README.md +1 -0
  272. package/templates/monorepo/packages/core/cell.yml +0 -0
  273. package/templates/monorepo/packages/core/compile.tsconfig.json +13 -0
  274. package/templates/monorepo/packages/core/package.json +40 -0
  275. package/templates/monorepo/packages/core/src/browser/index.ts +0 -0
  276. package/templates/monorepo/packages/core/src/browser/module.ts +4 -0
  277. package/templates/monorepo/packages/core/src/common/index.ts +0 -0
  278. package/templates/monorepo/packages/core/src/common/module.ts +4 -0
  279. package/templates/monorepo/packages/core/src/node/index.ts +0 -0
  280. package/templates/monorepo/packages/core/src/node/module.ts +4 -0
  281. package/templates/monorepo/packages/core/src/package.spec.ts +4 -0
  282. package/templates/monorepo/scripts/check-publish.js +40 -0
  283. package/templates/monorepo/scripts/compile-references.js +286 -0
  284. package/templates/monorepo/tsconfig.json +20 -0
  285. package/templates/monorepo/tsfmt.json +3 -0
  286. package/templates/mycli/.vscode/launch.json +33 -0
  287. package/templates/mycli/bin/mycli +2 -0
  288. package/templates/mycli/bin/mycli-deploy +2 -0
  289. package/templates/mycli/bin/mycli-init +2 -0
  290. package/templates/mycli/package.json +33 -0
  291. package/templates/mycli/src/bootstrap.ts +7 -0
  292. package/templates/mycli/src/constants.ts +1 -0
  293. package/templates/mycli/src/deploy/deploy-manager.ts +12 -0
  294. package/templates/mycli/src/deploy/deploy.ts +16 -0
  295. package/templates/mycli/src/deploy/index.ts +1 -0
  296. package/templates/mycli/src/index.ts +2 -0
  297. package/templates/mycli/src/init/index.ts +1 -0
  298. package/templates/mycli/src/init/init-manager.ts +85 -0
  299. package/templates/mycli/src/init/init.ts +25 -0
  300. package/templates/mycli/src/init/templates.ts +3 -0
  301. package/templates/mycli/src/module.ts +3 -0
  302. package/templates/mycli/src/mycli.ts +13 -0
  303. package/templates/mycli/templates/application-template/README.md +0 -0
  304. package/templates/mycli/tsconfig.json +29 -0
  305. package/templates/nest-app/.eslintrc.js +25 -0
  306. package/templates/nest-app/.prettierrc +4 -0
  307. package/templates/nest-app/README.md +73 -0
  308. package/templates/nest-app/nest-cli.json +8 -0
  309. package/templates/nest-app/package.json +69 -0
  310. package/templates/nest-app/src/app.controller.spec.ts +22 -0
  311. package/templates/nest-app/src/app.controller.ts +12 -0
  312. package/templates/nest-app/src/app.module.ts +10 -0
  313. package/templates/nest-app/src/app.service.ts +8 -0
  314. package/templates/nest-app/src/main.ts +8 -0
  315. package/templates/nest-app/test/app.e2e-spec.ts +24 -0
  316. package/templates/nest-app/test/jest-e2e.json +9 -0
  317. package/templates/nest-app/tsconfig.build.json +4 -0
  318. package/templates/nest-app/tsconfig.json +21 -0
  319. package/templates/nextjs-app/.eslintrc.json +3 -0
  320. package/templates/nextjs-app/README.md +34 -0
  321. package/templates/nextjs-app/next.config.js +6 -0
  322. package/templates/nextjs-app/package.json +20 -0
  323. package/templates/nextjs-app/pages/_app.js +7 -0
  324. package/templates/nextjs-app/pages/api/hello.js +5 -0
  325. package/templates/nextjs-app/pages/index.js +69 -0
  326. package/templates/nextjs-app/public/favicon.ico +0 -0
  327. package/templates/nextjs-app/public/vercel.svg +4 -0
  328. package/templates/nextjs-app/styles/Home.module.css +116 -0
  329. package/templates/nextjs-app/styles/globals.css +16 -0
  330. package/templates/puppeteer/.github/workflows/deploy.yml +25 -0
  331. package/templates/puppeteer/.vscode/launch.json +23 -0
  332. package/templates/puppeteer/README.md +92 -0
  333. package/templates/puppeteer/cell.yml +11 -0
  334. package/templates/puppeteer/package.json +31 -0
  335. package/templates/puppeteer/src/home-controller.ts +11 -0
  336. package/templates/puppeteer/src/module.ts +5 -0
  337. package/templates/puppeteer/src/puppeteer-controller.ts +26 -0
  338. package/templates/puppeteer/tsconfig.json +29 -0
  339. package/templates/sample-app/.github/workflows/deploy.yml +25 -0
  340. package/templates/sample-app/.vscode/launch.json +23 -0
  341. package/templates/sample-app/README.md +92 -0
  342. package/templates/sample-app/cell.yml +0 -0
  343. package/templates/sample-app/package.json +31 -0
  344. package/templates/sample-app/src/browser/assets/logo.png +0 -0
  345. package/templates/sample-app/src/browser/css-shims.d.ts +30 -0
  346. package/templates/sample-app/src/browser/hello.view.tsx +31 -0
  347. package/templates/sample-app/src/browser/module.ts +3 -0
  348. package/templates/sample-app/src/browser/style/hello.module.scss +4 -0
  349. package/templates/sample-app/src/common/welcome-protocol.ts +5 -0
  350. package/templates/sample-app/src/node/module.ts +3 -0
  351. package/templates/sample-app/src/node/welcome-server.ts +9 -0
  352. package/templates/sample-app/tsconfig.json +29 -0
  353. package/templates/schedule/.github/workflows/deploy.yml +25 -0
  354. package/templates/schedule/.vscode/launch.json +23 -0
  355. package/templates/schedule/README.md +92 -0
  356. package/templates/schedule/cell.yml +1 -0
  357. package/templates/schedule/package.json +29 -0
  358. package/templates/schedule/src/module.ts +3 -0
  359. package/templates/schedule/src/scheduler.ts +10 -0
  360. package/templates/schedule/tsconfig.json +29 -0
  361. package/templates/standalone-app/package.json +17 -0
  362. package/templates/standalone-app/src/app.service.ts +10 -0
  363. package/templates/standalone-app/src/main.ts +14 -0
  364. package/templates/standalone-app/src/module.ts +3 -0
  365. package/templates/standalone-app/tsconfig.json +27 -0
  366. package/templates/vue-app/.github/workflows/deploy.yml +25 -0
  367. package/templates/vue-app/.vscode/launch.json +23 -0
  368. package/templates/vue-app/README.md +92 -0
  369. package/templates/vue-app/cell.yml +0 -0
  370. package/templates/vue-app/package.json +32 -0
  371. package/templates/vue-app/src/browser/App.vue +32 -0
  372. package/templates/vue-app/src/browser/app.ts +7 -0
  373. package/templates/vue-app/src/browser/components/HelloWorld.vue +42 -0
  374. package/templates/vue-app/src/browser/declare.d.ts +7 -0
  375. package/templates/vue-app/src/browser/images/logo.png +0 -0
  376. package/templates/vue-app/src/browser/module.ts +3 -0
  377. package/templates/vue-app/src/browser/router.ts +13 -0
  378. package/templates/vue-app/src/browser/shims-vue.d.ts +5 -0
  379. package/templates/vue-app/src/browser/views/About.vue +5 -0
  380. package/templates/vue-app/src/browser/views/Root.vue +37 -0
  381. package/templates/vue-app/src/common/welcome-protocol.ts +5 -0
  382. package/templates/vue-app/src/node/module.ts +3 -0
  383. package/templates/vue-app/src/node/welcome-server.ts +9 -0
  384. package/templates/vue-app/tsconfig.json +30 -0
package/src/cell.ts ADDED
@@ -0,0 +1,214 @@
1
+ const leven = require('leven');
2
+ import * as ora from 'ora';
3
+ import { HookExecutor, HookStage } from '@celljs/cli-common/lib/hook/hook-executor';
4
+ import { CommandUtil } from '@celljs/cli-common/lib/utils/command-util';
5
+ import { program, Command } from '@celljs/cli-common/lib/command/command-protocol';
6
+ import { BannerUtil } from './utils/banner-util';
7
+ import build from './build/build';
8
+ import serve from './serve/serve';
9
+ import deploy from './deploy/deploy';
10
+ const chalk = require('chalk');
11
+ const updateNotifier = require('update-notifier');
12
+ const pkg = require('../package.json');
13
+
14
+ const version = pkg.version;
15
+ updateNotifier({ pkg }).notify();
16
+
17
+ const spinner = ora({ text: chalk.italic.gray('loading command line context...\n'), discardStdin: false });
18
+
19
+ (async () => {
20
+ const { runtime, framework, settings } = JSON.parse(process.env.MALAGU_RFS!);
21
+ BannerUtil.print(version, settings, runtime, framework);
22
+
23
+ spinner.start();
24
+ const context = await CommandUtil.loadContext(settings, framework, runtime, undefined, spinner);
25
+ await new HookExecutor().executeHooks(context, 'cliHooks', HookStage.before);
26
+ const { componentPackages, configHookModules, webpackHookModules, serveHookModules, buildHookModules, deployHookModules, infoHookModules, propsHookModules } = context.pkg;
27
+
28
+ if (CommandUtil.includesCommand(context.args, settings.compileCommands)) {
29
+ process.send!({
30
+ type: 'cliContext',
31
+ data: {
32
+ components: componentPackages.map(c => c.cellComponent),
33
+ configHookModules,
34
+ webpackHookModules,
35
+ serveHookModules,
36
+ buildHookModules,
37
+ deployHookModules,
38
+ infoHookModules,
39
+ propsHookModules
40
+ }
41
+ });
42
+ }
43
+
44
+ program
45
+ .version(version, '-V, --version', 'version for cell')
46
+ .option('-t, --targets [targets]', 'targets for cell', value => value ? value.split(',') : [])
47
+ .option('-m, --mode [mode]', 'mode for cell', value => value ? value.split(',') : [])
48
+ .option('--props-dir [propsDir]', 'props directory for cell')
49
+ .option('--props-file [propsFile]', 'props file for cell')
50
+ .option('--skip-auto-install [skipAutoInstall]', 'skip automatic installation of components for cell')
51
+ .usage('<command> [options]');
52
+
53
+ program
54
+ .command('init [template]')
55
+ .option('-o, --output-dir [path]', 'output directory')
56
+ .option('-p --packager [packager]', 'package manager(pnpm, yarn, npm)')
57
+ .description('init a application')
58
+ .action((template, options) => {
59
+ require('./init/init').default({ template, ...options });
60
+ });
61
+
62
+ program
63
+ .command('serve')
64
+ .option('-p, --port [port]', 'port used by the server')
65
+ .description('serve a applicaton')
66
+ .action((entry, options) => {
67
+ serve(context, { entry, ...options });
68
+ });
69
+
70
+ program
71
+ .command('build')
72
+ .description('build a application')
73
+ .action((entry, options) => {
74
+ build(context, { entry, ...options });
75
+ });
76
+
77
+ program
78
+ .command('deploy')
79
+ .option('-s, --skip-build [skipBuild]', 'skip the build process')
80
+ .description('deploy a applicaton')
81
+ .action((entry, options) => {
82
+ deploy(context, { entry, ...options });
83
+ });
84
+
85
+ program
86
+ .command('props')
87
+ .description('display properties about application')
88
+ .option('-n, --name [name]', 'get the property value of the specified name')
89
+ .option('-f, --frontend [frontend]', 'frontend properties')
90
+ .option('-b, --backend [backend]', 'backend properties')
91
+ .action(options => {
92
+ require('./props/props').default(context, { ...options });
93
+ });
94
+ program
95
+ .command('info')
96
+ .description('display information about application')
97
+ .action(options => {
98
+ require('./info/info').default(context, { ...options });
99
+ });
100
+
101
+ program
102
+ .command('config')
103
+ .option('--default-runtime [defaultRuntime]', 'default runtime')
104
+ .option('--default-mode [defaultMode]', 'default mode', value => value ? value.split(',') : [])
105
+ .option('--frameworks-url [frameworksUrl]', 'frameworks url')
106
+ .option('--frameworks-upstream-url [frameworksUpStreamUrl]', 'frameworks upstream url')
107
+ .option('--config-file-alias [configFileAlias]', 'config file alias')
108
+ .option('--show [show]', 'show properties for the application')
109
+ .description('configure properties for the application')
110
+ .action(options => {
111
+ require('./config/config').default(context, { ...options });
112
+ });
113
+
114
+ program
115
+ .command('update')
116
+ .option('-v, --version [version]', 'version for cell')
117
+ .option('-d, --dist-tag [distTag]', 'Which dist-tag to use to find the latest version')
118
+ .option('-s, --skip-installing-component [skipIntallingComponent]', 'skip installing components')
119
+ .description('update cell cli and current project\'s cell components')
120
+ .action(options => {
121
+ require('./update/update').default(context, { ...options });
122
+ });
123
+
124
+ const runtimeCmd = program
125
+ .command('runtime [command]')
126
+ .alias('r')
127
+ .description('management runtime');
128
+ runtimeCmd
129
+ .command('install [runtime] [alias]')
130
+ .alias('i')
131
+ .description('install a runtime')
132
+ .option('-f, --force-installing-component [forceInstallingComponent]', 'force installing component')
133
+ .option('-o, --overwrite [overwrite]', 'overwrite existing runtime')
134
+ .option('-v, --version [version]', 'specify runtime version', 'latest')
135
+ .action((r, alias, options) => {
136
+ require('@celljs/cli-runtime/lib/install/install').default({ runtime: r, alias, ...options });
137
+ });
138
+ runtimeCmd
139
+ .command('use [runtime]')
140
+ .description('use a runtime')
141
+ .action(r => {
142
+ require('@celljs/cli-runtime/lib/use/use').default({ runtime: r });
143
+ });
144
+
145
+ runtimeCmd
146
+ .command('list')
147
+ .alias('ls')
148
+ .description('list all runtimes')
149
+ .action(() => {
150
+ require('@celljs/cli-runtime/lib/list/list').default({});
151
+ });
152
+
153
+ runtimeCmd
154
+ .command('uninstall [runtime]')
155
+ .alias('u')
156
+ .description('uninstall a runtime')
157
+ .action(r => {
158
+ require('@celljs/cli-runtime/lib/uninstall/uninstall').default({ runtime: r });
159
+ });
160
+
161
+ await new HookExecutor().executeHooks(context, 'cliHooks');
162
+ spinner.stop();
163
+
164
+ program
165
+ .arguments('[command]')
166
+ .action(cmd => {
167
+ program.outputHelp();
168
+ if (cmd) {
169
+ console.log();
170
+ console.log(chalk.red(`Unknown command ${chalk.yellow(cmd)}.`));
171
+ console.log();
172
+ suggestCommands(cmd, program);
173
+ }
174
+
175
+ });
176
+
177
+ runtimeCmd
178
+ .arguments('[command]')
179
+ .action(cmd => {
180
+ runtimeCmd.outputHelp();
181
+ if (cmd) {
182
+ console.log();
183
+ console.log(chalk.red(`Unknown command ${chalk.yellow(cmd)}.`));
184
+ console.log();
185
+ suggestCommands(cmd, runtimeCmd);
186
+ }
187
+
188
+ });
189
+ program.addHelpText('after', '\nUse "cell [command] --help" for more information about a command.');
190
+ program.parse(process.argv);
191
+
192
+ })().catch(error => {
193
+ spinner.stop();
194
+ console.error(error);
195
+ process.exit(-1);
196
+ });
197
+
198
+ function suggestCommands(unknownCommand: string, main: Command) {
199
+ const availableCommands = main.commands.map((cmd: Command) => cmd.name());
200
+
201
+ let suggestion: string = '';
202
+
203
+ availableCommands.forEach((cmd: string) => {
204
+ const isBestMatch = leven(cmd, unknownCommand) < leven(suggestion, unknownCommand);
205
+ if (leven(cmd, unknownCommand) <= 3 && isBestMatch) {
206
+ suggestion = cmd;
207
+ }
208
+ });
209
+
210
+ if (suggestion) {
211
+ console.log(` ${chalk.yellow(`Did you mean ${chalk.green(suggestion)}?`)}`);
212
+ }
213
+ }
214
+
@@ -0,0 +1,56 @@
1
+
2
+ import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
3
+ import { HookExecutor, HookStage } from '@celljs/cli-common/lib/hook/hook-executor';
4
+ import { SettingsUtil } from '@celljs/cli-common/lib/settings/settings-util';
5
+
6
+ import { dump } from 'js-yaml';
7
+
8
+ export interface ConfigOptions {
9
+ frameworksUrl?: string;
10
+ frameworksUpstreamUrl?: boolean;
11
+ configFileAlias?: string;
12
+ defaultMode?: string[];
13
+ defaultRuntime?: string[];
14
+ show?: boolean;
15
+ }
16
+
17
+ export default async (ctx: CliContext, options: ConfigOptions) => {
18
+ try {
19
+ ctx.options = options;
20
+ const hookExecutor = new HookExecutor();
21
+ await hookExecutor.executeConfigHooks(ctx, HookStage.before);
22
+ if (options.defaultMode?.length) {
23
+ SettingsUtil.updateSettings({
24
+ defaultMode: options.defaultMode
25
+ });
26
+ }
27
+ if (options.defaultRuntime) {
28
+ SettingsUtil.updateSettings({
29
+ defaultRuntime: options.defaultRuntime
30
+ });
31
+ }
32
+ if (options.frameworksUpstreamUrl || options.frameworksUrl) {
33
+ SettingsUtil.updateSettings({
34
+ frameworks: {
35
+ url: options.frameworksUrl,
36
+ upstreamUrl: options.frameworksUpstreamUrl
37
+ }
38
+ });
39
+ }
40
+ if (options.configFileAlias) {
41
+ SettingsUtil.updateSettings({
42
+ configFileAlias: options.configFileAlias
43
+ });
44
+ }
45
+ if (options.show) {
46
+ ctx.output.settings = SettingsUtil.getSettings();
47
+ }
48
+ await hookExecutor.executeConfigHooks(ctx);
49
+ if (options.show) {
50
+ console.log(dump(ctx.output));
51
+ }
52
+ } catch (error) {
53
+ console.error(error);
54
+ process.exit(-1);
55
+ }
56
+ };
@@ -0,0 +1,31 @@
1
+
2
+ import build from '../build/build';
3
+ import { HookExecutor, HookStage } from '@celljs/cli-common/lib/hook/hook-executor';
4
+ import { CliContext, ContextUtils } from '@celljs/cli-common/lib/context/context-protocol';
5
+ import { CommandUtil, CommandType, CommandStage } from '@celljs/cli-common/lib/utils/command-util';
6
+
7
+ export interface DeplyOptions {
8
+ skipBuild?: boolean;
9
+ }
10
+
11
+ export default async (ctx: CliContext, options: DeplyOptions) => {
12
+ try {
13
+ ctx.options = options;
14
+ ctx = ContextUtils.mergeContext(ctx, options);
15
+ const hookExecutor = new HookExecutor();
16
+ await CommandUtil.executeCommand(ctx, CommandType.DeployCommand, CommandStage.before);
17
+ await hookExecutor.executeDeployHooks(ctx, HookStage.before);
18
+ if (!options.skipBuild) {
19
+ await build(ctx, options);
20
+ }
21
+
22
+ await CommandUtil.executeCommand(ctx, CommandType.DeployCommand);
23
+
24
+ await hookExecutor.executeDeployHooks(ctx);
25
+ await hookExecutor.executeDeployHooks(ctx, HookStage.after);
26
+ await CommandUtil.executeCommand(ctx, CommandType.DeployCommand, CommandStage.after);
27
+ } catch (error) {
28
+ console.error(error);
29
+ process.exit(-1);
30
+ }
31
+ };
package/src/index.ts ADDED
File without changes
@@ -0,0 +1,23 @@
1
+ import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
2
+ import { HookExecutor, HookStage } from '@celljs/cli-common/lib/hook/hook-executor';
3
+ import { LoggerUtil } from '@celljs/cli-common/lib/utils/logger-util';
4
+
5
+ export interface InfoOptions {}
6
+
7
+ export default async (ctx: CliContext, options: InfoOptions) => {
8
+ try {
9
+ ctx.options = options;
10
+ const hookExecutor = new HookExecutor();
11
+ await hookExecutor.executeInfoHooks(ctx, HookStage.before);
12
+
13
+ LoggerUtil.printStage(ctx);
14
+ LoggerUtil.printMode(ctx);
15
+ LoggerUtil.printTargets(ctx);
16
+ LoggerUtil.printComponents(ctx);
17
+
18
+ await hookExecutor.executeInfoHooks(ctx);
19
+ } catch (error) {
20
+ console.error(error);
21
+ process.exit(-1);
22
+ }
23
+ };
@@ -0,0 +1,163 @@
1
+ import { resolve, basename, relative, join } from 'path';
2
+ import { existsSync, copy, readFile, writeJSON } from 'fs-extra';
3
+ import { templates } from './templates';
4
+ import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
5
+ import { getPackager, spawnProcess } from '@celljs/cli-common/lib/packager/utils';
6
+ import { HookExecutor } from '@celljs/cli-common/lib/hook/hook-executor';
7
+ import { CommandUtil } from '@celljs/cli-common/lib/utils/command-util';
8
+ import { prompts } from 'prompts';
9
+ import * as ora from 'ora';
10
+ const rimraf = require('rimraf');
11
+ const chalk = require('chalk');
12
+ import { ok } from 'assert';
13
+ import { RuntimeUtil } from '@celljs/cli-runtime';
14
+ const version = require('../../package.json').version;
15
+
16
+ const PLACEHOLD = '{{ templatePath }}';
17
+
18
+ const remoteTemplateRegex = /^(https?:|git@)/i;
19
+
20
+ export interface Template {
21
+ name: string;
22
+ location: string;
23
+ }
24
+
25
+ export interface InitOptions {
26
+ template?: string;
27
+ packager?: 'pnpm' | 'yarn' | 'npm';
28
+ outputDir: string;
29
+ }
30
+
31
+ export class InitManager {
32
+
33
+ protected source: any[];
34
+ protected templateName: string;
35
+ protected location: string;
36
+ protected cliContext: CliContext;
37
+ constructor(protected readonly opts: InitOptions) {
38
+
39
+ }
40
+
41
+ async output(): Promise<void> {
42
+ await this.selectTemplate();
43
+ await this.checkOutputDir();
44
+ await this.doOutput();
45
+ }
46
+
47
+ async render(): Promise<void> {
48
+ const packageJsonPath = resolve(this.outputDir, 'package.json');
49
+ if (existsSync(packageJsonPath)) {
50
+ let packageJsonStr = await readFile(packageJsonPath, { encoding: 'utf8' });
51
+ packageJsonStr = packageJsonStr.replace(/{{\s*version\s*}}/g, version);
52
+ const packageJson = JSON.parse(packageJsonStr);
53
+ packageJson.name = basename(this.outputDir);
54
+ await writeJSON(packageJsonPath, packageJson, { encoding: 'utf8', spaces: 2 });
55
+ }
56
+ }
57
+
58
+ async install(): Promise<void> {
59
+ const pkg = CommandUtil.getPkg(undefined, this.outputDir);
60
+ const packager = this.opts.packager || pkg.rootComponentPackage.cellComponent?.packager;
61
+
62
+ await getPackager(packager, this.outputDir).install({}, this.outputDir);
63
+ }
64
+
65
+ async executeHooks(): Promise<void> {
66
+ const outputDir = this.outputDir;
67
+ const initContext = await this.getCliContext();
68
+ await new HookExecutor().executeHooks(initContext, 'initHooks');
69
+ console.log(chalk`{bold.green Success!} Initialized "${ this.templateName }" example in {bold.blue ${outputDir}}.`);
70
+ process.exit(0);
71
+ }
72
+
73
+ protected async getCliContext(): Promise<CliContext> {
74
+ if (!this.cliContext) {
75
+ this.cliContext = await RuntimeUtil.initRuntimeAndLoadContext(this.outputDir);
76
+ this.cliContext.location = this.realLocation;
77
+ this.cliContext.outputDir = this.outputDir;
78
+ }
79
+ return this.cliContext;
80
+ }
81
+
82
+ protected get outputDir(): string {
83
+ return resolve(process.cwd(), this.opts.outputDir ? this.opts.outputDir : this.location.split('/').pop()!.replace('.git', ''));
84
+ }
85
+
86
+ protected async checkOutputDir(): Promise<void> {
87
+ if (existsSync(this.outputDir)) {
88
+ // eslint-disable-next-line @typescript-eslint/await-thenable
89
+ await prompts.confirm({
90
+ name: 'remove',
91
+ type: 'confirm',
92
+ message: `App already exists, remove the app (dir: ${join(relative(process.cwd(), this.outputDir))})`,
93
+ onState: ({ value }) => {
94
+ if (value === true) {
95
+ rimraf.sync(this.outputDir);
96
+ } else {
97
+ process.exit(0);
98
+ }
99
+ }
100
+ });
101
+ }
102
+ }
103
+
104
+ protected toOfficialTemplate(name: string, location: string): any {
105
+ return { title: `${name} ${chalk.italic.gray('Official')}`, value: { location, name} };
106
+ }
107
+
108
+ protected toThirdPartyTemplate(item: any): any {
109
+ return { title: `${item.name} ${chalk.italic.gray(item.stargazers_count + '⭑')}`, value: { location: item.clone_url, name: item.name }};
110
+ }
111
+
112
+ protected async selectTemplate(): Promise<void> {
113
+ const { template } = this.opts;
114
+ if (template) {
115
+ this.templateName = template;
116
+ if (remoteTemplateRegex.test(template)) {
117
+ this.location = template;
118
+ } else {
119
+ Object.keys(templates).forEach(key => {
120
+ if (key === template) {
121
+ this.location = templates[key];
122
+ }
123
+ });
124
+ ok(this.location, `"${template}" template not found`);
125
+ }
126
+ return;
127
+ }
128
+ const spinner = ora({ text: 'loading...', discardStdin: false }).start();
129
+ const officialTemplates = Object.keys(templates).map(key => this.toOfficialTemplate(key, templates[key]));
130
+ const choices = officialTemplates;
131
+ spinner.stop();
132
+ const answer = await prompts.autocomplete({
133
+ type: 'autocomplete',
134
+ name: 'template',
135
+ limit: 12,
136
+ message: 'Select a template to init',
137
+ choices,
138
+ suggest: async input => choices.filter(item => !input || item.title.toLowerCase().includes(input.toLowerCase()))
139
+ });
140
+ this.templateName = answer.name;
141
+ this.location = answer.location;
142
+ }
143
+
144
+ protected get realLocation() {
145
+ return this.location.replace(PLACEHOLD, resolve(__dirname, '..', '..', 'templates'));
146
+ }
147
+
148
+ protected async doOutput(): Promise<void> {
149
+ if (remoteTemplateRegex.test(this.location)) {
150
+ await this.outputRemoteTempate();
151
+ } else {
152
+ await this.outputLocalTemplate();
153
+ }
154
+ }
155
+ protected async outputLocalTemplate(): Promise<void> {
156
+ await copy(this.realLocation, this.outputDir);
157
+ }
158
+
159
+ protected outputRemoteTempate(): Promise<any> {
160
+ const dir = this.opts.outputDir ? [ this.opts.outputDir ] : [];
161
+ return spawnProcess('git', [ 'clone', '--depth=1', this.location, ...dir ], { stdio: 'inherit' });
162
+ }
163
+ }
@@ -0,0 +1,15 @@
1
+ import { InitManager, InitOptions } from './init-manager';
2
+
3
+ export default async (options: InitOptions) => {
4
+ try {
5
+ const initManager = new InitManager(options);
6
+ await initManager.output();
7
+ await initManager.render();
8
+ await initManager.install();
9
+ await initManager.executeHooks();
10
+ } catch (error) {
11
+ console.error(error);
12
+ process.exit(-1);
13
+ }
14
+
15
+ };
@@ -0,0 +1,21 @@
1
+ export const templates: any = {
2
+ 'backend-app': '{{ templatePath }}/backend-app',
3
+ 'sample-app': '{{ templatePath }}/sample-app',
4
+ 'cell-component': '{{ templatePath }}/cell-component',
5
+ 'docker-app': '{{ templatePath }}/docker-app',
6
+ 'monorepo': '{{ templatePath }}/monorepo',
7
+ 'nest-app': '{{ templatePath }}/nest-app',
8
+ 'nextjs-app': '{{ templatePath }}/nextjs-app',
9
+ 'koa-app': '{{ templatePath }}/koa-app',
10
+ 'vue-app': '{{ templatePath }}/vue-app',
11
+ 'database-app': '{{ templatePath }}/database-app',
12
+ 'jwt-app': '{{ templatePath }}/jwt-app',
13
+ 'accounts': '{{ templatePath }}/accounts',
14
+ 'schedule': '{{ templatePath }}/schedule',
15
+ 'admin-app': '{{ templatePath }}/admin-app',
16
+ 'microservice': '{{ templatePath }}/microservice',
17
+ 'standalone-app': '{{ templatePath }}/standalone-app',
18
+ 'file-service': '{{ templatePath }}/file-service',
19
+ 'puppeteer': '{{ templatePath }}/puppeteer',
20
+ 'mycli': '{{ templatePath }}/mycli'
21
+ };
@@ -0,0 +1,4 @@
1
+ describe('cli package', () => {
2
+
3
+ it('support code coverage statistics', () => {});
4
+ });
@@ -0,0 +1,48 @@
1
+ import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
2
+ import { ConfigUtil } from '@celljs/cli-common/lib/utils/config-util';
3
+ import { dump } from 'js-yaml';
4
+ import * as traverse from 'traverse';
5
+ const chalk = require('chalk');
6
+
7
+ export interface PropsOptions {
8
+ backend?: boolean;
9
+ frontend?: boolean;
10
+ name?: string;
11
+ }
12
+
13
+ export default async (ctx: CliContext, options: PropsOptions) => {
14
+ try {
15
+ ctx.options = options;
16
+ let backendProps: any;
17
+ let frontendProps: any;
18
+
19
+ if (options.frontend) {
20
+ frontendProps = ConfigUtil.getFrontendConfig(ctx.cfg);
21
+ } else if (options.backend) {
22
+ backendProps = ConfigUtil.getBackendConfig(ctx.cfg);
23
+ } else {
24
+ frontendProps = ConfigUtil.getFrontendConfig(ctx.cfg);
25
+ backendProps = ConfigUtil.getBackendConfig(ctx.cfg);
26
+ }
27
+
28
+ if (frontendProps) {
29
+ console.log(chalk`{bold.magenta - Frontend: }`);
30
+ if (options.name) {
31
+ console.log(`${options.name}: ${traverse(frontendProps).get(options.name.split('.'))}`);
32
+ } else {
33
+ console.log(dump(ConfigUtil.getFrontendConfig(ctx.cfg), { skipInvalid: true }));
34
+ }
35
+ }
36
+ if (backendProps) {
37
+ console.log(chalk`{bold.magenta - Backend: }`);
38
+ if (options.name) {
39
+ console.log(`${options.name}: ${traverse(backendProps).get(options.name.split('.'))}`);
40
+ } else {
41
+ console.log(dump(ConfigUtil.getBackendConfig(ctx.cfg), { skipInvalid: true }));
42
+ }
43
+ }
44
+ } catch (error) {
45
+ console.error(error);
46
+ process.exit(-1);
47
+ }
48
+ };
@@ -0,0 +1,51 @@
1
+ import { LoggerUtil } from '@celljs/cli-common/lib/utils/logger-util';
2
+ import { CommandUtil, CommandType, CommandStage } from '@celljs/cli-common/lib/utils/command-util';
3
+ import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
4
+ import { HookExecutor, HookStage } from '@celljs/cli-common/lib/hook/hook-executor';
5
+ import { ConfigUtil } from '@celljs/cli-common/lib/utils';
6
+
7
+ export class ServeManager {
8
+
9
+ constructor(
10
+ protected readonly context: CliContext) {
11
+ }
12
+
13
+ protected log() {
14
+ LoggerUtil.printStage(this.context);
15
+ LoggerUtil.printMode(this.context);
16
+ LoggerUtil.printTargets(this.context);
17
+ LoggerUtil.printComponents(this.context);
18
+ }
19
+
20
+ async start() {
21
+
22
+ this.log();
23
+
24
+ const commandRender = async (command: string, target: string) => {
25
+ const { cfg, port } = this.context;
26
+ const realPort = ConfigUtil.getPort(cfg, target, port);
27
+ return command
28
+ .replace(/\$PATH/g, ConfigUtil.getCellConfig(cfg, target).server?.path)
29
+ .replace(/\$PORT/g, realPort);
30
+ };
31
+
32
+ const hookExecutor = new HookExecutor();
33
+ await CommandUtil.executeCommand(this.context, CommandType.CompileCommand, CommandStage.before);
34
+ await hookExecutor.executeCompileHooks(this.context, HookStage.before);
35
+
36
+ await CommandUtil.executeCommand(this.context, CommandType.CompileCommand);
37
+ await hookExecutor.executeCompileHooks(this.context);
38
+
39
+ await hookExecutor.executeCompileHooks(this.context, HookStage.after);
40
+ await CommandUtil.executeCommand(this.context, CommandType.CompileCommand, CommandStage.after);
41
+
42
+ await CommandUtil.executeCommand(this.context, CommandType.ServeCommand, CommandStage.before, commandRender);
43
+ await hookExecutor.executeServeHooks(this.context, HookStage.before);
44
+
45
+ await CommandUtil.executeCommand(this.context, CommandType.ServeCommand, CommandStage.on, commandRender);
46
+ await hookExecutor.executeServeHooks(this.context);
47
+
48
+ await hookExecutor.executeServeHooks(this.context, HookStage.after);
49
+ await CommandUtil.executeCommand(this.context, CommandType.ServeCommand, CommandStage.after, commandRender);
50
+ }
51
+ }
@@ -0,0 +1,19 @@
1
+
2
+ import { ServeManager } from './serve-manager';
3
+ import { CliContext, ContextUtils } from '@celljs/cli-common/lib/context/context-protocol';
4
+
5
+ export interface ServeOptions {
6
+ port?: string;
7
+ }
8
+
9
+ export default async (ctx: CliContext, options: ServeOptions) => {
10
+ try {
11
+ ctx.options = options;
12
+ ctx = ContextUtils.mergeContext(ctx, { dev: true, ...options });
13
+ await new ServeManager(ctx).start();
14
+ } catch (error) {
15
+ console.error(error);
16
+ process.exit(-1);
17
+ }
18
+
19
+ };