@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
@@ -0,0 +1,61 @@
1
+ import { getPackager } from '@celljs/cli-common/lib/packager/utils';
2
+ import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
3
+ import { join } from 'path';
4
+ import { readJSON, existsSync, writeJSON } from 'fs-extra';
5
+ const updateNotifier = require('update-notifier');
6
+ const pkg = require('../../package.json');
7
+ const semver = require('semver');
8
+
9
+ export interface UpdateOptions {
10
+ version?: string;
11
+ distTag?: string;
12
+ skipIntallingComponent?: boolean;
13
+ }
14
+
15
+ async function updatePackage(version: string, skipIntallingComponent?: boolean) {
16
+ const packagePath = join(process.cwd(), 'package.json');
17
+ if (existsSync(packagePath)) {
18
+ const projectPkg = await readJSON(packagePath);
19
+ const dependencies = projectPkg.dependencies ?? {};
20
+ const devDependencies = projectPkg.devDependencies ?? {};
21
+ for (const name of Object.keys(dependencies)) {
22
+ if (name.startsWith('@celljs/')) {
23
+ dependencies[name] = version;
24
+ }
25
+ }
26
+
27
+ for (const name of Object.keys(devDependencies)) {
28
+ if (name.startsWith('@celljs/')) {
29
+ devDependencies[name] = version;
30
+ }
31
+ }
32
+ await writeJSON(packagePath, projectPkg, { spaces: 2 });
33
+ if (skipIntallingComponent) {
34
+ await getPackager().install();
35
+ }
36
+ }
37
+ }
38
+
39
+ export default async (ctx: CliContext, options: UpdateOptions) => {
40
+ try {
41
+ ctx.options = options;
42
+ const version = options.version;
43
+ if (version) {
44
+ if (version !== pkg.version) {
45
+ await updatePackage(version, options.skipIntallingComponent);
46
+ await getPackager('npm').add([`${pkg.name}@${version}`], { global: true });
47
+ }
48
+ } else {
49
+ const notifier = updateNotifier({ pkg, distTag: options.distTag });
50
+ const { latest, current } = await notifier.fetchInfo();
51
+ if (semver.gt(latest, current)) {
52
+ await updatePackage(latest, options.skipIntallingComponent);
53
+ await getPackager('npm').add([`${pkg.name}@${latest}`], { global: true });
54
+ }
55
+ }
56
+ } catch (error) {
57
+ console.error(error);
58
+ process.exit(-1);
59
+ }
60
+
61
+ };
@@ -0,0 +1,41 @@
1
+ import { Runtimes } from '@celljs/cli-runtime/lib/runtime-protocol';
2
+ import { Framework } from '@celljs/frameworks/lib/detector/detector-protocol';
3
+ import { Settings } from '@celljs/cli-common/lib/settings/settings-protocol';
4
+
5
+ const chalk = require('chalk');
6
+
7
+ export namespace BannerUtil {
8
+ export function print(version: string, settings: Settings, runtime?: string, framework?: Framework) {
9
+ let runtimeStrLine = '';
10
+ let runtimeStr = '';
11
+ if (runtime && runtime !== Runtimes.empty) {
12
+ runtimeStr = runtime;
13
+ if (framework) {
14
+ runtimeStr = runtime === Runtimes.default ? framework.name : `${runtime}.${framework.name}`;
15
+ }
16
+ runtimeStr = `Runtime<${runtimeStr}>`;
17
+ runtimeStrLine = '\n│';
18
+ runtimeStrLine += chalk.yellow.bold(runtimeStr.padStart(20 + Math.floor(runtimeStr.length / 2)).padEnd(40)) + '│';
19
+ }
20
+ const banner = process.env.MALAGU_BANNER || settings.banner;
21
+ if (banner) {
22
+ console.log(banner.replace('{ version }', version).replace('{ runtime }', runtimeStr));
23
+ } else {
24
+ const versionStr = `@celljs/cli@${version}`;
25
+ const versionStrLine = `\n│${chalk.yellow.bold(versionStr.padStart(20 + Math.floor(versionStr.length / 2)).padEnd(40))}│`;
26
+ console.log(`
27
+ ____ ___ ___
28
+ /\\ _\`\\ /\\_ \\ /\\_ \\
29
+ \\ \\ \\/\\_\\ __\\//\\ \\ \\//\\ \\
30
+ \\ \\ \\/_/_ /'__\`\\\\ \\ \\ \\ \\ \\
31
+ \\ \\ \\L\\ \\/\\ __/ \\_\\ \\_ \\_\\ \\_
32
+ \\ \\____/\\ \\____\\/\\____\\/\\____\\
33
+ \\/___/ \\/____/\\/____/\\/____/
34
+
35
+ ╭────────────────────────────────────────╮
36
+ │ Cell Development Framework │${versionStrLine}${runtimeStrLine}
37
+ ╰────────────────────────────────────────╯
38
+ `);
39
+ }
40
+ }
41
+ }
@@ -0,0 +1 @@
1
+ export * from './banner-util';
@@ -0,0 +1,92 @@
1
+ # 开发说明
2
+
3
+ ## 安装依赖
4
+
5
+ 以下使用 yarn 工具来说明,你也可以使用 npm。
6
+
7
+ ```bash
8
+ # 通过 cell init 初始化应用的时候已经自动安装了依赖,所以你只需要安装你额外需要的依赖即可
9
+
10
+ $ yarn add xxxx
11
+ ```
12
+
13
+ ## 本地运行
14
+
15
+ ```shell
16
+ # 启动本地服务,端口默认 3000
17
+ # 在终端中会输出本地服务的 URL 链接
18
+
19
+ $ yarn start # 或者执行 cell serve 命令
20
+ ```
21
+
22
+ ## 构建部署
23
+
24
+ 模板默认提供了四套隔离环境:本地(local)、测试(test)、预发(pre)、线上(prod)。每个环境对应着一个 cell 配置文件(可选),类似 cell-test.yml。而 cell.yml 文件一般用于放所有环境的公共配置。第一次部署的时候可能会提示你填写相关云厂商 ak 信息。如果是 Vercel 云平台的模板,会提示你需要登录到 Vercel 平台。你也可以在项目通过 .env 提供云厂商的 ak 信息。
25
+
26
+ ```bash
27
+
28
+ $ cell deploy -m scf # 部署到腾讯云函数测试环境
29
+ $ cell deploy -m scf -m test # 部署到腾讯云测试环境
30
+ $ cell deploy -m scf -m pre # 部署到腾讯云预发环境
31
+ $ cell deploy -m scf -m prod # 部署到腾讯云线上环境
32
+
33
+ ```
34
+
35
+ ## 关于 Cell Framework
36
+
37
+ Cell 是基于 TypeScript 的 Serverless First、组件化、平台无关的渐进式应用框架。
38
+
39
+ ## 特征
40
+
41
+ - 约定大于配置,零配置,开箱即用
42
+ - TypeScript 版 Spring Boot
43
+ - Serverless First
44
+ - 平台不锁定
45
+ - 支持前后端一体化,前端框架不锁定
46
+ - 支持微服务
47
+ - 组件化,渐进式
48
+ - 命令行工具插件化
49
+ - 依赖注入
50
+ - 面向切面编程(AOP)
51
+ - 集成了流行的 ORM 框架,使用装饰器声明式事务管理
52
+ - 支持 OIDC 认证
53
+ - 支持 OAuth2 授权
54
+ - 使用 rxjs 管理状态
55
+ - 提供 REST 和 RPC 两种接口风格
56
+
57
+ Cell 名字由来:在我的家乡,谐音“吗啦咕”是小石头的意思,小石头堆砌起来可以建成高楼大厦、道路桥梁,而 Cell 组件编排可以实现千变万化的应用。
58
+
59
+ ## 快速开始
60
+
61
+ ```bash
62
+ # 安装命令行工具
63
+ npm install -g @celljs/cli
64
+
65
+ # 初始化
66
+ cell init -o project-name
67
+ cd project-name # 进入项目根目录
68
+
69
+ # 运行
70
+ cell serve
71
+
72
+ # 部署
73
+ cell deploy
74
+ ```
75
+
76
+ [![Quick Start](https://asciinema.org/a/474104.svg)](https://asciinema.org/a/474104?speed=2.5&autoplay=1)
77
+
78
+ ### 文档
79
+
80
+ - [介绍](https://cell.cellbang.com/guide/%E4%BB%8B%E7%BB%8D)
81
+ - [创建第一个应用](https://cell.cellbang.com/guide/%E5%88%9B%E5%BB%BA%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8)
82
+ - [命令行工具](https://cell.cellbang.com/guide/%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%B7%A5%E5%85%B7)
83
+ - [控制器](https://cell.cellbang.com/guide/%E6%8E%A7%E5%88%B6%E5%99%A8)
84
+ - [数据库操作](https://cell.cellbang.com/guide/%E6%95%B0%E6%8D%AE%E5%BA%93typeorm)
85
+ - [微服务](https://cell.cellbang.com/dev/%E5%BE%AE%E6%9C%8D%E5%8A%A1)
86
+ - [认证与授权](https://cell.cellbang.com/guide/%E8%AE%A4%E8%AF%81%E4%B8%8E%E6%8E%88%E6%9D%83)
87
+ - [云平台适配](https://cell.cellbang.com/cloud/%E4%BA%91%E5%B9%B3%E5%8F%B0%E9%80%82%E9%85%8D)
88
+ - [依赖注入](https://cell.cellbang.com/guide/%E4%BE%9D%E8%B5%96%E6%B3%A8%E5%85%A5)
89
+ - [组件设计](https://cell.cellbang.com/guide/%E7%BB%84%E4%BB%B6%E8%AE%BE%E8%AE%A1)
90
+ - [前端架构](https://cell.cellbang.com/guide/%E5%89%8D%E7%AB%AF%E6%9E%B6%E6%9E%84)
91
+ - [React 开发](https://cell.cellbang.com/dev/react)
92
+ - [前后端一体化开发](https://cell.cellbang.com/dev/%E5%89%8D%E5%90%8E%E7%AB%AF%E4%B8%80%E4%BD%93%E5%8C%96%E5%BC%80%E5%8F%91)
@@ -0,0 +1,17 @@
1
+ cell:
2
+ typeorm:
3
+ ormConfig:
4
+ - type: better-sqlite3
5
+ database: mydb.sql
6
+ synchronize: true
7
+ logging: true
8
+ # cell:
9
+ # typeorm:
10
+ # ormConfig:
11
+ # - type: mysql
12
+ # host: localhost
13
+ # port: 3306
14
+ # synchronize: true
15
+ # username: root
16
+ # password: root
17
+ # database: test
@@ -0,0 +1,17 @@
1
+ frontend:
2
+ cell:
3
+ locales:
4
+ zh-CN:
5
+ label: 简体中文
6
+ messages:
7
+ accounts.login.label: 登录
8
+ accounts.logout.label: 登出
9
+ accounts.logo.label: 细胞矩阵
10
+ accounts.quick.login.label: 请选择快捷登录方式
11
+ en-US:
12
+ label: English
13
+ messages:
14
+ accounts.login.label: Login
15
+ accounts.logout.label: Logout
16
+ accounts.logo.label: Cellbang
17
+ accounts.quick.login.label: Please select Quick Login
@@ -0,0 +1,8 @@
1
+ cell:
2
+ oauth2:
3
+ client:
4
+ registrations:
5
+ github: # 仅仅提供测试使用,确保应用启动的地址为 http://localhost:3000,正式环境,请替换为自己的
6
+ clientName: Github
7
+ clientId: ${ '78c92fa811a8177acb42' | onTarget('backend') }
8
+ clientSecret: ${ 'e02ed015711aec29ecebfc4668e0b4c755212ef0' | onTarget('backend') }
@@ -0,0 +1,9 @@
1
+ frontend:
2
+ cell:
3
+ themes:
4
+ default:
5
+ label: 蓝色
6
+ props:
7
+ global:
8
+ colors:
9
+ brand: '#2d85f0'
@@ -0,0 +1,10 @@
1
+ mode: [ database, oauth2.0, locale, theme ]
2
+
3
+ accounts:
4
+ home:
5
+ url: https://www.cellbang.com
6
+ logo:
7
+ icon: Cellbang
8
+ cell:
9
+ serve-static:
10
+ apiPath: "*oauth2/*" # 确保 oauth2.0 相关的 url 不会被 server-static 组件识别为静态文件地址
Binary file
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "accounts",
3
+ "keywords": [
4
+ "cell-component"
5
+ ],
6
+ "version": "0.0.0",
7
+ "license": "MIT",
8
+ "files": [
9
+ "lib",
10
+ "src"
11
+ ],
12
+ "dependencies": {
13
+ "@celljs/core": "{{ version }}",
14
+ "@celljs/web": "{{ version }}",
15
+ "@celljs/grommet": "{{ version }}",
16
+ "@celljs/oauth2-client": "{{ version }}",
17
+ "@celljs/oauth2-core": "{{ version }}",
18
+ "@celljs/react": "{{ version }}",
19
+ "@celljs/rpc": "{{ version }}",
20
+ "@celljs/scf-adapter": "{{ version }}",
21
+ "@celljs/security": "{{ version }}",
22
+ "@celljs/serve-static": "{{ version }}",
23
+ "@celljs/typeorm": "{{ version }}",
24
+ "better-sqlite3": "^7.6.2",
25
+ "querystring": "^0.2.1",
26
+ "request-ip": "^3.3.0",
27
+ "grommet-icons": "^4.7.0",
28
+ "react": "^18.2.0",
29
+ "react-dom": "^18.2.0",
30
+ "react-intl": "^6.1.2",
31
+ "styled-components": "^5.3.5",
32
+ "grommet": "^2.25.1",
33
+ "typeorm": "^0.3.7",
34
+ "class-transformer": "^0.5.1"
35
+ },
36
+ "devDependencies": {
37
+ "@celljs/cli": "{{ version }}"
38
+ },
39
+ "scripts": {
40
+ "clean": "rimraf lib dist .cell",
41
+ "build": "cell build",
42
+ "start": "cell serve",
43
+ "deploy": "cell deploy -m scf -m test",
44
+ "deploy:test": "cell deploy -m scf -m test",
45
+ "deploy:pre": "cell deploy -m scf -m pre",
46
+ "deploy:prod": "cell deploy -m scf -m prod"
47
+ }
48
+ }
@@ -0,0 +1,86 @@
1
+ import * as React from 'react';
2
+ import { ConfigUtil, ContainerUtil } from '@celljs/core';
3
+ import { UserManager } from '@celljs/security/lib/browser';
4
+ import { View } from '@celljs/react';
5
+ import { LocaleMenu, Icon } from '@celljs/grommet';
6
+ import { useIntl } from 'react-intl';
7
+ import { Box, Button, Heading, ResponsiveContext, Avatar, Text} from 'grommet';
8
+ import { Logout } from 'grommet-icons';
9
+ import styled from 'styled-components';
10
+ import { User } from '@celljs/security';
11
+ const { useContext } = React;
12
+
13
+ const StyledWraper = styled.div`
14
+ position: absolute;
15
+ top: 0;
16
+ left: 0;
17
+ right: 0;
18
+ bottom: 0;
19
+ background-color: #fafafa;
20
+ `;
21
+
22
+ interface ContainerProps {
23
+ size: string;
24
+ };
25
+
26
+ const StyledContainer = styled.div<ContainerProps>`
27
+ width: ${props => props.size === 'small' ? '100%' : '340px'};
28
+ height: ${props => props.size === 'small' ? '100%' : '500px'};
29
+ position: absolute;
30
+ top: ${props => props.size === 'small' ? '0' : 'calc(50% - 250px)'};
31
+ left: ${props => props.size === 'small' ? '0' : 'calc(50% - 170px)'};
32
+ text-align: center;
33
+ background-color: #ffffff;
34
+ box-shadow: ${props => props.size === 'small' ? 'none' : '0px 0px 5px #e9e9e9'};
35
+ border-radius: ${props => props.size === 'small' ? '0' : '4px'};
36
+ `;
37
+
38
+ export function Home() {
39
+ const size = useContext(ResponsiveContext);
40
+ const intl = useIntl();
41
+
42
+ const loginUserManager = ContainerUtil.get<UserManager>(UserManager);
43
+ const [user, setUser] = React.useState<User | undefined>(loginUserManager.userInfoSubject.value);
44
+ React.useEffect(() => {
45
+ const subscription = loginUserManager.userInfoSubject.subscribe(u => setUser(u));
46
+ return () => subscription.unsubscribe();
47
+ }, []);
48
+
49
+ return (
50
+ <StyledWraper style={size === 'small' ? { top: 0, bottom: 0, right: 0, left: 0 } : undefined }>
51
+ <StyledContainer size={size}>
52
+ <Box direction="column" pad="large" align="center" background="brand" round={ size === 'small' ? undefined : { corner: 'top', size: '4px' } }>
53
+ <Button plain
54
+ href={ConfigUtil.get('accounts.home.url')}
55
+ icon={<Icon size="large" color="white" icon={ConfigUtil.get('accounts.logo.icon')}></Icon>}>
56
+ </Button>
57
+ <Heading level="4" color="white">{intl.formatMessage({ id: 'accounts.logo.label' })}</Heading>
58
+ </Box>
59
+ <Box direction="column" align="center" animation="slideDown" pad="large">
60
+ {user && (
61
+ <Box direction="column" align="center">
62
+ <Avatar
63
+ hoverIndicator title={user.nickname} src={user.avatar} margin="small">
64
+ </Avatar>
65
+ <Text>{user.nickname}</Text>
66
+ <Text style={{ opacity: .7, fontSize: '.8em' }} >{user.email}</Text>
67
+ <Button
68
+ title={intl.formatMessage({ id: 'accounts.logout.label' })}
69
+ margin='small'
70
+ hoverIndicator
71
+ icon={<Logout/>}
72
+ onClick={() => loginUserManager.logout()}>
73
+ </Button>
74
+ </Box>
75
+ )}
76
+ </Box>
77
+ <Box direction="column" fill="horizontal" style={ { position: 'absolute', bottom: 0 } } align="center">
78
+ <LocaleMenu size="small" fontSize="12px"/>
79
+ </Box>
80
+ </StyledContainer>
81
+ </StyledWraper>);
82
+
83
+ }
84
+ @View({ path: '/home', component: Home, })
85
+ @View({ path: '/', component: Home, })
86
+ export default class {}
@@ -0,0 +1,3 @@
1
+ export * from './login.view';
2
+ export * from './home.view';
3
+
@@ -0,0 +1,78 @@
1
+ import * as React from 'react';
2
+ import { useLocation } from 'react-router';
3
+ import { parse, stringify } from 'querystring';
4
+ import { ConfigUtil } from '@celljs/core';
5
+ import { View } from '@celljs/react';
6
+ import { LocaleMenu, Icon } from '@celljs/grommet';
7
+ import { useIntl } from 'react-intl';
8
+ import { Box, Button, Heading, ResponsiveContext, Nav } from 'grommet';
9
+ import styled from 'styled-components';
10
+ const { useContext } = React;
11
+
12
+ const StyledWraper = styled.div`
13
+ position: absolute;
14
+ top: 0;
15
+ left: 0;
16
+ right: 0;
17
+ bottom: 0;
18
+ background-color: #fafafa;
19
+ `;
20
+
21
+ interface ContainerProps {
22
+ size: string;
23
+ };
24
+
25
+ const StyledContainer = styled.div<ContainerProps>`
26
+ width: ${props => props.size === 'small' ? '100%' : '340px'};
27
+ height: ${props => props.size === 'small' ? '100%' : '500px'};
28
+ position: absolute;
29
+ top: ${props => props.size === 'small' ? '0' : 'calc(50% - 250px)'};
30
+ left: ${props => props.size === 'small' ? '0' : 'calc(50% - 170px)'};
31
+ text-align: center;
32
+ background-color: #ffffff;
33
+ box-shadow: ${props => props.size === 'small' ? 'none' : '0px 0px 5px #e9e9e9'};
34
+ border-radius: ${props => props.size === 'small' ? '0' : '4px'};
35
+ `;
36
+
37
+ export function Login() {
38
+ const location = useLocation();
39
+ const size = useContext(ResponsiveContext);
40
+ const intl = useIntl();
41
+ const targetUrlParameter = ConfigUtil.get<string>('cell.security.targetUrlParameter');
42
+ const registrations = ConfigUtil.get<{[key: string]: { icon?: string, clientName: string } }>('cell.oauth2.client.registrations');
43
+ const redirect = parse(location.search && location.search.substring(1))[targetUrlParameter];
44
+ const queryStr = redirect ? `?${stringify({ [targetUrlParameter]: redirect})}` : '';
45
+ return (
46
+ <StyledWraper style={size === 'small' ? { top: 0, bottom: 0, right: 0, left: 0 } : undefined }>
47
+ <StyledContainer size={size}>
48
+ <Box direction="column" pad="large" align="center" background="brand" round={ size === 'small' ? undefined : { corner: 'top', size: '4px' } }>
49
+ <Button plain
50
+ href={ConfigUtil.get('accounts.home.url')}
51
+ icon={<Icon size="large" color="white" icon={ConfigUtil.get('accounts.logo.icon')}></Icon>}>
52
+ </Button>
53
+ <Heading level="4" color="white">{intl.formatMessage({ id: 'accounts.logo.label' })}</Heading>
54
+ </Box>
55
+ <Box direction="column" align="center" animation="slideDown">
56
+ <Heading level="6">{intl.formatMessage({ id: 'accounts.quick.login.label' })}</Heading>
57
+ <Nav>
58
+ {
59
+ Object.keys(registrations).map(id => (
60
+ <Button
61
+ hoverIndicator
62
+ icon={<Icon icon={registrations[id].icon || registrations[id].clientName} size="large"></Icon>}
63
+ href={`/oauth2/authorization/${id}${queryStr}`}>
64
+ </Button>
65
+ ))
66
+ }
67
+ </Nav>
68
+ </Box>
69
+ <Box direction="column" fill="horizontal" style={ { position: 'absolute', bottom: 0 } } align="center">
70
+ <LocaleMenu size="small" fontSize="12px"/>
71
+ </Box>
72
+ </StyledContainer>
73
+ </StyledWraper>);
74
+
75
+ }
76
+
77
+ @View({ path: '/login', component: Login })
78
+ export default class {}
@@ -0,0 +1,3 @@
1
+ import { autoBind } from '@celljs/core';
2
+ import './index';
3
+ export default autoBind();
@@ -0,0 +1,7 @@
1
+ export interface BaseEntity {
2
+ id: number;
3
+
4
+ createdAt: Date;
5
+
6
+ updatedAt: Date;
7
+ }
@@ -0,0 +1 @@
1
+ export * from './entity-protocol';
@@ -0,0 +1,69 @@
1
+ import { Component, Autowired } from '@celljs/core';
2
+ import { User, UserType } from '@celljs/security';
3
+ import { Context } from '@celljs/web/lib/node';
4
+ import { AuthenticationSuccessHandler, Authentication, DefaultAuthenticationSuccessHandler } from '@celljs/security/lib/node';
5
+ import { ClientRegistrationManager } from '@celljs/oauth2-client/lib/node';
6
+ import { User as UserEntity, Identity } from '../entity';
7
+ import { UserRepository } from '../user';
8
+ const requestIp = require('request-ip');
9
+
10
+ @Component({ id: AuthenticationSuccessHandler, rebind: true })
11
+ export class OAuth2AuthenticationSuccessHandler extends DefaultAuthenticationSuccessHandler {
12
+
13
+ @Autowired(UserRepository)
14
+ protected userRepository: UserRepository;
15
+
16
+ @Autowired(ClientRegistrationManager)
17
+ protected readonly clientRegistrationManager: ClientRegistrationManager;
18
+
19
+ protected rebuildAuthentication(authentication: Authentication, userEntity: UserEntity) {
20
+ authentication.name = userEntity.id + '';
21
+ const principal = authentication.principal;
22
+ principal.username = userEntity.id + '';
23
+ principal.enabled = !!userEntity.blocked;
24
+ }
25
+
26
+ protected log(userEntity: UserEntity) {
27
+ userEntity.loginsCount += 1;
28
+ userEntity.lastLogin = new Date();
29
+ userEntity.lastIp = requestIp.getClientIp(Context.getRequest());
30
+ return this.userRepository.update(userEntity);
31
+ }
32
+
33
+ async onAuthenticationSuccess(authentication: Authentication): Promise<void> {
34
+
35
+ const principal = authentication.principal;
36
+ if (User.is(principal)) {
37
+ if (principal.type !== UserType.Memery && principal.type !== UserType.Database) {
38
+ let userEntity = await this.userRepository.getByConnectionAndIdentifier(principal.type, principal.username);
39
+ if (!userEntity) {
40
+ if (principal.email) {
41
+ userEntity = await this.userRepository.getByEmail(principal.email);
42
+ }
43
+ }
44
+ if (!userEntity) {
45
+ const registration = await this.clientRegistrationManager.get(principal.type);
46
+ userEntity = new UserEntity();
47
+ userEntity.username = principal.login;
48
+ userEntity.email = principal.email;
49
+ userEntity.emailVerified = !!principal.email;
50
+ userEntity.picture = principal.avatar;
51
+ userEntity.blocked = false;
52
+ userEntity.loginsCount = 0;
53
+ userEntity.nickname = principal.nickname || principal.login;
54
+
55
+ const identity = new Identity();
56
+ identity.connection = registration!.registrationId;
57
+ identity.identifier = principal.username;
58
+ identity.isSocial = true;
59
+ identity.provider = registration!.provider;
60
+ userEntity = await this.userRepository.create(userEntity, identity);
61
+ }
62
+ this.rebuildAuthentication(authentication, userEntity);
63
+ await this.log(userEntity);
64
+ }
65
+ }
66
+ await super.onAuthenticationSuccess(authentication);
67
+ }
68
+
69
+ }
@@ -0,0 +1 @@
1
+ export * from './authentication-success-handler';
@@ -0,0 +1,13 @@
1
+ import { CreateDateColumn, UpdateDateColumn, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ export abstract class BaseEntity {
4
+
5
+ @PrimaryGeneratedColumn()
6
+ id: number;
7
+
8
+ @CreateDateColumn()
9
+ createdAt: Date;
10
+
11
+ @UpdateDateColumn()
12
+ updatedAt: Date;
13
+ }
@@ -0,0 +1,52 @@
1
+ import {Entity, Column } from 'typeorm';
2
+ import { BaseEntity } from './base-entity';
3
+
4
+ export class Connection extends BaseEntity {
5
+
6
+ @Column()
7
+ name: string;
8
+
9
+ }
10
+
11
+ @Entity()
12
+ export class Database extends Connection {
13
+
14
+ @Column()
15
+ requiresUsername: boolean;
16
+
17
+ @Column()
18
+ usernameMaxLength: number;
19
+
20
+ @Column()
21
+ usernameMinLength: boolean;
22
+
23
+ @Column()
24
+ disableSignUps: boolean;
25
+
26
+ }
27
+
28
+ @Entity()
29
+ export class Social extends Connection {
30
+
31
+ @Column()
32
+ strategy: string;
33
+
34
+ @Column()
35
+ clientId: string;
36
+
37
+ @Column()
38
+ clientSecret: string;
39
+
40
+ @Column()
41
+ scopes: string[];
42
+
43
+ @Column()
44
+ redirectUri: string;
45
+
46
+ @Column()
47
+ authorizationGrantType: string;
48
+
49
+ @Column()
50
+ clientAuthenticationMethod: string;
51
+
52
+ }
@@ -0,0 +1 @@
1
+ export * from './user';