create-lupine 1.0.31 → 1.3.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 (269) hide show
  1. package/README.md +31 -0
  2. package/index.js +238 -112
  3. package/package.json +1 -1
  4. package/templates/common/.agents/skills/lupine-framework/SKILL.md +63 -0
  5. package/templates/common/.agents/skills/lupine-framework/references/backend-api.md +113 -0
  6. package/templates/common/.agents/skills/lupine-framework/references/icon-handling.md +71 -0
  7. package/templates/common/.agents/skills/lupine-framework/references/mobile-interactions.md +29 -0
  8. package/templates/common/.agents/skills/lupine-framework/references/native-apps.md +190 -0
  9. package/templates/common/.agents/skills/lupine-framework/references/navigation-and-routing.md +55 -0
  10. package/templates/common/.agents/skills/lupine-framework/references/reactivity-and-state.md +108 -0
  11. package/templates/common/.agents/skills/lupine-framework/references/styling-and-themes.md +121 -0
  12. package/templates/common/.env.mobile +4 -3
  13. package/templates/common/_env +10 -4
  14. package/templates/common/apps/server/README.md +10 -0
  15. package/templates/common/dev/cp-folder.js +9 -4
  16. package/templates/lupine-template-cv-starter/README.md +37 -0
  17. package/templates/lupine-template-cv-starter/app/package.json +20 -0
  18. package/templates/lupine-template-cv-starter/app/src/app.tsx +6 -0
  19. package/templates/lupine-template-cv-starter/app/src/index.native.tsx +4 -0
  20. package/templates/lupine-template-cv-starter/app/src/index.test.tsx +71 -0
  21. package/templates/lupine-template-cv-starter/app/src/index.web.tsx +28 -0
  22. package/templates/lupine-template-cv-starter/app/tsconfig.json +17 -0
  23. package/templates/lupine-template-cv-starter/lupine.json +8 -7
  24. package/templates/lupine-template-cv-starter/web/src/index.html +9 -2
  25. package/templates/lupine-template-cv-starter/web/src/index.tsx +9 -23
  26. package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.html +9 -2
  27. package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.tsx +4 -29
  28. package/templates/lupine-template-doc-starter/README.md +37 -0
  29. package/templates/lupine-template-doc-starter/app/package.json +20 -0
  30. package/templates/lupine-template-doc-starter/app/src/app.tsx +6 -0
  31. package/templates/lupine-template-doc-starter/app/src/index.native.tsx +4 -0
  32. package/templates/lupine-template-doc-starter/app/src/index.test.tsx +78 -0
  33. package/templates/lupine-template-doc-starter/app/src/index.web.tsx +28 -0
  34. package/templates/lupine-template-doc-starter/app/tsconfig.json +17 -0
  35. package/templates/lupine-template-doc-starter/lupine.json +8 -7
  36. package/templates/lupine-template-doc-starter/web/src/index.html +9 -2
  37. package/templates/lupine-template-doc-starter/web/src/index.tsx +9 -23
  38. package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.html +9 -2
  39. package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.tsx +4 -29
  40. package/templates/lupine-template-fullstack-note/README.md +83 -0
  41. package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/api/package.json +1 -1
  42. package/templates/lupine-template-fullstack-note/api/resources/install.mysql.sql +32 -0
  43. package/templates/lupine-template-fullstack-note/api/resources/install.sqlite.sql +27 -0
  44. package/templates/lupine-template-fullstack-note/api/src/service/answer.ts +39 -0
  45. package/templates/lupine-template-fullstack-note/api/src/service/api.ts +52 -0
  46. package/templates/lupine-template-fullstack-note/api/src/service/db.ts +78 -0
  47. package/templates/lupine-template-fullstack-note/api/src/service/notes-api.ts +86 -0
  48. package/templates/lupine-template-fullstack-note/api/src/service/root-api.ts +19 -0
  49. package/templates/lupine-template-fullstack-note/api/src/service/user-api.ts +182 -0
  50. package/templates/lupine-template-fullstack-note/app/package.json +19 -0
  51. package/templates/lupine-template-fullstack-note/app/src/app.tsx +75 -0
  52. package/templates/lupine-template-fullstack-note/app/src/index.native.tsx +4 -0
  53. package/templates/lupine-template-fullstack-note/app/src/index.test.tsx +373 -0
  54. package/templates/lupine-template-fullstack-note/app/src/index.web.tsx +20 -0
  55. package/templates/lupine-template-fullstack-note/app/src/pages/components.tsx +65 -0
  56. package/templates/lupine-template-fullstack-note/app/src/pages/details.tsx +38 -0
  57. package/templates/lupine-template-fullstack-note/app/src/pages/discover.tsx +25 -0
  58. package/templates/lupine-template-fullstack-note/app/src/pages/home.tsx +76 -0
  59. package/templates/lupine-template-fullstack-note/app/src/pages/inbox.tsx +49 -0
  60. package/templates/lupine-template-fullstack-note/app/src/pages/login.tsx +54 -0
  61. package/templates/lupine-template-fullstack-note/app/src/pages/me.tsx +32 -0
  62. package/templates/lupine-template-fullstack-note/app/src/pages/notes.tsx +128 -0
  63. package/templates/lupine-template-fullstack-note/app/src/pages/settings.tsx +45 -0
  64. package/templates/lupine-template-fullstack-note/app/src/shell/AppMenu.tsx +44 -0
  65. package/templates/lupine-template-fullstack-note/app/src/shell/api.ts +159 -0
  66. package/templates/lupine-template-fullstack-note/app/src/shell/data.ts +20 -0
  67. package/templates/lupine-template-fullstack-note/app/src/shell/locales/ja.ts +80 -0
  68. package/templates/lupine-template-fullstack-note/app/src/shell/locales/zh-CN.ts +80 -0
  69. package/templates/lupine-template-fullstack-note/app/src/shell/texts.ts +14 -0
  70. package/templates/lupine-template-fullstack-note/app/tsconfig.json +17 -0
  71. package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/lupine.json +4 -2
  72. package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/web/package.json +1 -1
  73. package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/web/src/index.html +10 -3
  74. package/templates/lupine-template-fullstack-note/web/src/index.tsx +15 -0
  75. package/templates/lupine-template-fullstack-starter/README.md +70 -0
  76. package/templates/lupine-template-fullstack-starter/api/package.json +10 -0
  77. package/templates/lupine-template-fullstack-starter/api/resources/install.mysql.sql +107 -0
  78. package/templates/lupine-template-fullstack-starter/api/resources/install.sqlite.sql +75 -0
  79. package/templates/lupine-template-fullstack-starter/api/src/lang/api-lang-en.ts +39 -0
  80. package/templates/lupine-template-fullstack-starter/api/src/lang/api-lang-zh-cn.ts +37 -0
  81. package/templates/lupine-template-fullstack-starter/api/src/service/admin-api.ts +139 -0
  82. package/templates/lupine-template-fullstack-starter/api/src/service/api.ts +111 -0
  83. package/templates/lupine-template-fullstack-starter/api/src/service/contact-api.ts +50 -0
  84. package/templates/lupine-template-fullstack-starter/api/src/service/file-api-base.ts +30 -0
  85. package/templates/lupine-template-fullstack-starter/api/src/service/root-api.ts +28 -0
  86. package/templates/lupine-template-fullstack-starter/api/src/service/send-email.ts +47 -0
  87. package/templates/lupine-template-fullstack-starter/api/src/service/setting-api.ts +60 -0
  88. package/templates/lupine-template-fullstack-starter/api/src/service/user-api.ts +1046 -0
  89. package/templates/lupine-template-fullstack-starter/app/assets/sample.png +0 -0
  90. package/templates/lupine-template-fullstack-starter/app/package.json +20 -0
  91. package/templates/lupine-template-fullstack-starter/app/src/app.tsx +76 -0
  92. package/templates/lupine-template-fullstack-starter/app/src/index.native.tsx +4 -0
  93. package/templates/lupine-template-fullstack-starter/app/src/index.test.tsx +276 -0
  94. package/templates/lupine-template-fullstack-starter/app/src/index.web.tsx +28 -0
  95. package/templates/lupine-template-fullstack-starter/app/src/pages/about.tsx +27 -0
  96. package/templates/lupine-template-fullstack-starter/app/src/pages/contact.tsx +41 -0
  97. package/templates/lupine-template-fullstack-starter/app/src/pages/favorite.tsx +27 -0
  98. package/templates/lupine-template-fullstack-starter/app/src/pages/home.tsx +63 -0
  99. package/templates/lupine-template-fullstack-starter/app/src/pages/login.tsx +63 -0
  100. package/templates/lupine-template-fullstack-starter/app/src/pages/mine.tsx +44 -0
  101. package/templates/lupine-template-fullstack-starter/app/src/pages/profile.tsx +58 -0
  102. package/templates/lupine-template-fullstack-starter/app/src/pages/register.tsx +48 -0
  103. package/templates/lupine-template-fullstack-starter/app/src/pages/reset-password.tsx +41 -0
  104. package/templates/lupine-template-fullstack-starter/app/src/pages/settings.tsx +33 -0
  105. package/templates/lupine-template-fullstack-starter/app/src/pages/story.tsx +46 -0
  106. package/templates/lupine-template-fullstack-starter/app/src/shell/api.ts +127 -0
  107. package/templates/lupine-template-fullstack-starter/app/src/shell/parts.tsx +100 -0
  108. package/templates/lupine-template-fullstack-starter/app/src/shell/stories.ts +65 -0
  109. package/templates/lupine-template-fullstack-starter/app/src/shell/texts.ts +79 -0
  110. package/templates/lupine-template-fullstack-starter/app/tsconfig.json +17 -0
  111. package/templates/lupine-template-fullstack-starter/lupine.json +31 -0
  112. package/templates/lupine-template-fullstack-starter/web/assets/android-chrome-192x192.png +0 -0
  113. package/templates/lupine-template-fullstack-starter/web/assets/apple-touch-icon.png +0 -0
  114. package/templates/lupine-template-fullstack-starter/web/assets/favicon-16x16.png +0 -0
  115. package/templates/lupine-template-fullstack-starter/web/assets/favicon-32x32.png +0 -0
  116. package/templates/lupine-template-fullstack-starter/web/assets/favicon.ico +0 -0
  117. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/License-carbon-icons.txt +71 -0
  118. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/License-material-design.txt +20 -0
  119. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/i-font.woff2 +0 -0
  120. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/sample.html +124 -0
  121. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/style.css +103 -0
  122. package/templates/lupine-template-fullstack-starter/web/assets/lupine-flower.png +0 -0
  123. package/templates/lupine-template-fullstack-starter/web/assets/lupine.svg +71 -0
  124. package/templates/lupine-template-fullstack-starter/web/assets/site.webmanifest +14 -0
  125. package/templates/lupine-template-fullstack-starter/web/icons-font.config.js +129 -0
  126. package/templates/{lupine-template-responsive-starter/api → lupine-template-fullstack-starter/web}/package.json +1 -1
  127. package/templates/lupine-template-fullstack-starter/web/src/admin/admin-patch.tsx +34 -0
  128. package/templates/lupine-template-fullstack-starter/web/src/admin/components/home-search-component.tsx +125 -0
  129. package/templates/lupine-template-fullstack-starter/web/src/admin/components/story-card.tsx +105 -0
  130. package/templates/lupine-template-fullstack-starter/web/src/admin/components/story-list.tsx +105 -0
  131. package/templates/lupine-template-fullstack-starter/web/src/admin/components/story-props.ts +34 -0
  132. package/templates/lupine-template-fullstack-starter/web/src/admin/index.html +23 -0
  133. package/templates/lupine-template-fullstack-starter/web/src/admin/index.tsx +49 -0
  134. package/templates/lupine-template-fullstack-starter/web/src/admin/pages/admin-cfg.tsx +144 -0
  135. package/templates/lupine-template-fullstack-starter/web/src/admin/pages/admin-item-edit.tsx +20 -0
  136. package/templates/lupine-template-fullstack-starter/web/src/admin/pages/admin-item-list.tsx +23 -0
  137. package/templates/lupine-template-fullstack-starter/web/src/admin/pages/admin-user.tsx +145 -0
  138. package/templates/lupine-template-fullstack-starter/web/src/index.html +28 -0
  139. package/templates/lupine-template-fullstack-starter/web/src/index.tsx +16 -0
  140. package/templates/lupine-template-fullstack-starter/web/src/services/fetch-data.ts +37 -0
  141. package/templates/lupine-template-fullstack-starter/web/src/styles/base-css.ts +14 -0
  142. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/global.css +10 -57
  143. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/theme.ts +2 -1
  144. package/templates/lupine-template-responsive-starter/README.md +51 -0
  145. package/templates/lupine-template-responsive-starter/app/package.json +19 -0
  146. package/templates/lupine-template-responsive-starter/app/src/app.tsx +80 -0
  147. package/templates/lupine-template-responsive-starter/app/src/index.native.tsx +4 -0
  148. package/templates/lupine-template-responsive-starter/app/src/index.test.tsx +283 -0
  149. package/templates/lupine-template-responsive-starter/app/src/index.web.tsx +31 -0
  150. package/templates/lupine-template-responsive-starter/app/src/pages/about.tsx +23 -0
  151. package/templates/lupine-template-responsive-starter/app/src/pages/finance.tsx +48 -0
  152. package/templates/lupine-template-responsive-starter/app/src/pages/mine.tsx +60 -0
  153. package/templates/lupine-template-responsive-starter/app/src/pages/not-found.tsx +9 -0
  154. package/templates/lupine-template-responsive-starter/app/src/pages/note-detail.tsx +43 -0
  155. package/templates/lupine-template-responsive-starter/app/src/pages/note-edit.tsx +45 -0
  156. package/templates/lupine-template-responsive-starter/app/src/pages/note-search.tsx +62 -0
  157. package/templates/lupine-template-responsive-starter/app/src/pages/notes.tsx +71 -0
  158. package/templates/lupine-template-responsive-starter/app/src/pages/settings.tsx +55 -0
  159. package/templates/lupine-template-responsive-starter/app/src/pages/tools.tsx +112 -0
  160. package/templates/lupine-template-responsive-starter/app/src/shell/icons.ts +7 -0
  161. package/templates/lupine-template-responsive-starter/app/src/shell/layout.ts +18 -0
  162. package/templates/lupine-template-responsive-starter/app/src/shell/locales/zh-CN.ts +89 -0
  163. package/templates/lupine-template-responsive-starter/app/src/shell/menu.tsx +81 -0
  164. package/templates/lupine-template-responsive-starter/app/src/shell/nav.ts +12 -0
  165. package/templates/lupine-template-responsive-starter/app/src/shell/store.ts +72 -0
  166. package/templates/lupine-template-responsive-starter/app/src/shell/texts.ts +11 -0
  167. package/templates/lupine-template-responsive-starter/app/tsconfig.json +17 -0
  168. package/templates/lupine-template-responsive-starter/lupine.json +7 -6
  169. package/templates/lupine-template-responsive-starter/web/src/index.html +9 -2
  170. package/templates/lupine-template-responsive-starter/web/src/index.tsx +9 -34
  171. package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.html +12 -6
  172. package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.tsx +12 -31
  173. package/templates/common/AI_CONTEXT.md +0 -1002
  174. package/templates/common/apps/server/src/app-loader.ts +0 -4
  175. package/templates/lupine-template-cv-starter/api/package.json +0 -6
  176. package/templates/lupine-template-cv-starter/api/resources/install.sqlite.sql +0 -4
  177. package/templates/lupine-template-cv-starter/api/src/index.ts +0 -15
  178. package/templates/lupine-template-cv-starter/web/src/styles/base-css.ts +0 -15
  179. package/templates/lupine-template-doc-starter/api/package.json +0 -6
  180. package/templates/lupine-template-doc-starter/api/resources/config_default.json +0 -6
  181. package/templates/lupine-template-doc-starter/api/resources/install.sqlite.sql +0 -4
  182. package/templates/lupine-template-doc-starter/api/src/index.ts +0 -15
  183. package/templates/lupine-template-doc-starter/api/src/resources/config_default.json +0 -6
  184. package/templates/lupine-template-doc-starter/api/src/resources/install.sqlite.sql +0 -4
  185. package/templates/lupine-template-doc-starter/web/src/client-env-keys.ts +0 -5
  186. package/templates/lupine-template-doc-starter/web/src/styles/base-css.ts +0 -15
  187. package/templates/lupine-template-hello-world/api/resources/config_default.json +0 -6
  188. package/templates/lupine-template-hello-world/api/resources/install.sqlite.sql +0 -4
  189. package/templates/lupine-template-hello-world/api/src/service/root-api.ts +0 -18
  190. package/templates/lupine-template-hello-world/web/src/index.tsx +0 -73
  191. package/templates/lupine-template-hello-world/web/src/styles/app.css +0 -0
  192. package/templates/lupine-template-hello-world/web/src/styles/base-css.ts +0 -1
  193. package/templates/lupine-template-responsive-starter/api/resources/config_default.json +0 -6
  194. package/templates/lupine-template-responsive-starter/api/resources/install.sqlite.sql +0 -4
  195. package/templates/lupine-template-responsive-starter/api/src/service/root-api.ts +0 -18
  196. package/templates/lupine-template-responsive-starter/web/src/app-icons.ts +0 -76
  197. package/templates/lupine-template-responsive-starter/web/src/components/input-history-component.tsx +0 -93
  198. package/templates/lupine-template-responsive-starter/web/src/components/mine-about-page.tsx +0 -86
  199. package/templates/lupine-template-responsive-starter/web/src/components/mine-premium-page.tsx +0 -80
  200. package/templates/lupine-template-responsive-starter/web/src/components/mine-settings-page.tsx +0 -220
  201. package/templates/lupine-template-responsive-starter/web/src/components/mobile-top-search-menu.tsx +0 -119
  202. package/templates/lupine-template-responsive-starter/web/src/components/note-detail.tsx +0 -116
  203. package/templates/lupine-template-responsive-starter/web/src/components/note-edit.tsx +0 -154
  204. package/templates/lupine-template-responsive-starter/web/src/components/note-search-page.tsx +0 -193
  205. package/templates/lupine-template-responsive-starter/web/src/components/search-input.tsx +0 -95
  206. package/templates/lupine-template-responsive-starter/web/src/components/side-menu-content.tsx +0 -182
  207. package/templates/lupine-template-responsive-starter/web/src/frames/app-responsive-frame.tsx +0 -52
  208. package/templates/lupine-template-responsive-starter/web/src/pages/about-page.tsx +0 -43
  209. package/templates/lupine-template-responsive-starter/web/src/pages/finance-page.tsx +0 -46
  210. package/templates/lupine-template-responsive-starter/web/src/pages/home-page.tsx +0 -452
  211. package/templates/lupine-template-responsive-starter/web/src/pages/mine-page.tsx +0 -325
  212. package/templates/lupine-template-responsive-starter/web/src/pages/tools-page.tsx +0 -46
  213. package/templates/lupine-template-responsive-starter/web/src/services/local-notes-service.ts +0 -87
  214. package/templates/lupine-template-responsive-starter/web/src/services/mine-service.ts +0 -45
  215. package/templates/lupine-template-responsive-starter/web/src/styles/app.css +0 -0
  216. package/templates/lupine-template-responsive-starter/web/src/styles/base-css.ts +0 -65
  217. package/templates/lupine-template-responsive-starter/web/src/styles/global.css +0 -2130
  218. package/templates/lupine-template-responsive-starter/web/src/styles/theme.ts +0 -16
  219. /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/01-experience/index.md +0 -0
  220. /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/02-projects/index.md +0 -0
  221. /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/03-skills/index.md +0 -0
  222. /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/04-education/index.md +0 -0
  223. /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/index.md +0 -0
  224. /package/templates/lupine-template-cv-starter/{web → app}/markdown/index.md +0 -0
  225. /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/01-experience/index.md +0 -0
  226. /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/02-projects/index.md +0 -0
  227. /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/03-skills/index.md +0 -0
  228. /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/04-education/index.md +0 -0
  229. /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/index.md +0 -0
  230. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/01-experience/index.html +0 -0
  231. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/02-projects/index.html +0 -0
  232. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/03-skills/index.html +0 -0
  233. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/04-education/index.html +0 -0
  234. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/index.html +0 -0
  235. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/index.html +0 -0
  236. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/markdown-config.ts +0 -0
  237. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/01-experience/index.html +0 -0
  238. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/02-projects/index.html +0 -0
  239. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/03-skills/index.html +0 -0
  240. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/04-education/index.html +0 -0
  241. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/index.html +0 -0
  242. /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/essentials/index.md +0 -0
  243. /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/essentials/list.md +0 -0
  244. /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/guide/install.md +0 -0
  245. /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/guide/started.md +0 -0
  246. /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/index.md +0 -0
  247. /package/templates/lupine-template-doc-starter/{web → app}/markdown/index.md +0 -0
  248. /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/essentials/index.md +0 -0
  249. /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/essentials/list.md +0 -0
  250. /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/guide/install.md +0 -0
  251. /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/guide/started.md +0 -0
  252. /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/index.md +0 -0
  253. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/essentials/index.html +0 -0
  254. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/essentials/list.html +0 -0
  255. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/guide/install.html +0 -0
  256. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/guide/started.html +0 -0
  257. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/index.html +0 -0
  258. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/index.html +0 -0
  259. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/markdown-config.ts +0 -0
  260. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/essentials/index.html +0 -0
  261. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/essentials/list.html +0 -0
  262. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/guide/install.html +0 -0
  263. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/guide/started.html +0 -0
  264. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/index.html +0 -0
  265. /package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/api/src/index.ts +0 -0
  266. /package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/web/assets/favicon.ico +0 -0
  267. /package/templates/{lupine-template-cv-starter → lupine-template-fullstack-starter}/api/resources/config_default.json +0 -0
  268. /package/templates/{lupine-template-responsive-starter → lupine-template-fullstack-starter}/api/src/index.ts +0 -0
  269. /package/templates/{lupine-template-cv-starter/web/src → lupine-template-fullstack-starter/web/src/models}/client-env-keys.ts +0 -0
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # create-lupine
2
+
3
+ Creates a new [lupine.js](https://github.com/uuware/lupine.js) project: an app for the web, iOS, Android, macOS and Windows from one code base (lupine.native), with its web site and server (lupine.web, lupine.api).
4
+
5
+ ```bash
6
+ npx create-lupine@latest my-app
7
+ cd my-app
8
+ npm install
9
+ npm run dev # the site, http://localhost:11080
10
+ npm run native -- macos --app=my-app --run # the app: ios, android, windows, web; test macos
11
+ ```
12
+
13
+ Templates to choose from:
14
+
15
+ | Template | |
16
+ | --- | --- |
17
+ | `doc-starter` | documentation from Markdown: sidebar, languages, themes; the server renders the pages; for GitHub Pages too |
18
+ | `cv-starter` | a CV from Markdown, in several languages; for GitHub Pages too |
19
+ | `responsive-starter-tabs`, `responsive-starter-sidemenu` | an app with tabs or a side menu: notes kept on the device, finance, tools, settings with themes and languages |
20
+ | `fullstack-note` | an app with tabs, a side menu, settings, themes and languages, sign-in and notes kept on the server (an API with a database) |
21
+ | `fullstack-starter` | the app with accounts (sign-in, codes by email, registration) talking to an API with a database, and an admin site |
22
+
23
+ A project has the app in `apps/my-app/app`, the page of the site in `apps/my-app/web` and, in the fullstack templates, the server in `apps/my-app/api` (the others use the default server of lupine-build); see the README in `apps/my-app`. An app that calls the server gets its address from `WEB.API_BASE_URL` of `.env.mobile`: `npm run native -- android --app=my-app --release --env=.env.mobile`. The apps for phones and desktops need their tools (Xcode, Android Studio, Visual Studio): `npx lupine-native doctor` tells what is missing. See [Getting started](https://uuware.github.io/lupine.js/en/native/started).
24
+
25
+ `npx create-lupine --update-version` brings the lupine packages of an existing project up to date.
26
+
27
+ `npx create-lupine --add-app <name>`, in the folder of a project, adds one more app from a template (`apps/<name>`, with its scripts `npm run <name>:run-mac` ...) and prints what to add to `.env` (`APPS`, `DOMAINS:<name>`); `.env` itself isn't changed.
28
+
29
+ The scripts of a new project: `npm run run-mac`, `run-ios`, `run-android`, `run-exe` (build and start the app), `build-android` (the apk for the store), `bump` (the next version), `icons` (the icons of the site from the icon of the app), `release` (a folder for the server in `dist/release/<name>`).
30
+
31
+ MIT.
package/index.js CHANGED
@@ -70,18 +70,13 @@ for (let i = 0; i < args.length; i++) {
70
70
  }
71
71
  const cwd = process.cwd();
72
72
 
73
+ // Every template is an app for the web, iOS, Android, macOS and Windows (lupine.native, in app/), with a site and
74
+ // a server (web/, api/: lupine.web, lupine.api).
73
75
  const TEMPLATES = [
74
- {
75
- name: 'hello-world',
76
- dir: 'lupine-template-hello-world',
77
- display: 'Hello World',
78
- itemType: 'frontend',
79
- color: green,
80
- },
81
76
  {
82
77
  name: 'doc-starter',
83
78
  dir: 'lupine-template-doc-starter',
84
- display: 'Documentation Starter',
79
+ display: 'Documentation Starter (Markdown, sidebar, languages)',
85
80
  itemType: 'frontend',
86
81
  color: green,
87
82
  needsPress: true,
@@ -89,7 +84,7 @@ const TEMPLATES = [
89
84
  {
90
85
  name: 'cv-starter',
91
86
  dir: 'lupine-template-cv-starter',
92
- display: 'CV Starter',
87
+ display: 'CV Starter (Markdown, languages)',
93
88
  itemType: 'frontend',
94
89
  color: green,
95
90
  needsPress: true,
@@ -98,7 +93,7 @@ const TEMPLATES = [
98
93
  name: 'responsive-starter-tabs',
99
94
  dir: 'lupine-template-responsive-starter',
100
95
  layout: 'tabs',
101
- display: 'Responsive Starter (tabs)',
96
+ display: 'App Starter with tabs (notes on the device, finance, tools, settings)',
102
97
  itemType: 'frontend',
103
98
  color: green,
104
99
  },
@@ -106,19 +101,225 @@ const TEMPLATES = [
106
101
  name: 'responsive-starter-sidemenu',
107
102
  dir: 'lupine-template-responsive-starter',
108
103
  layout: 'sidemenu',
109
- display: 'Responsive Starter (sidemenu)',
104
+ display: 'App Starter with a side menu (notes on the device, finance, tools, settings)',
105
+ itemType: 'frontend',
106
+ color: green,
107
+ },
108
+ {
109
+ name: 'fullstack-note',
110
+ dir: 'lupine-template-fullstack-note',
111
+ display: 'Full-stack Notes (the app with sign-in and notes on the server: tabs, side menu, settings)',
112
+ itemType: 'frontend',
113
+ color: green,
114
+ },
115
+ {
116
+ name: 'fullstack-starter',
117
+ dir: 'lupine-template-fullstack-starter',
118
+ display: 'Full-stack Starter (the app with accounts and an API, an admin site, a database)',
110
119
  itemType: 'frontend',
111
120
  color: green,
112
121
  },
113
122
  ];
114
123
 
124
+ const templatesRoot = () => path.resolve(fileURLToPath(import.meta.url), '../templates');
125
+
126
+ /** apps/<appName> from the template: names, the page for GitHub Pages, the id of the app. */
127
+ function scaffoldApp(root, appName, templateObj) {
128
+ const templateDir = path.join(templatesRoot(), templateObj.dir);
129
+ const appsDir = path.join(root, 'apps');
130
+ if (!fs.existsSync(appsDir)) {
131
+ fs.mkdirSync(appsDir);
132
+ }
133
+
134
+ const targetAppDir = path.join(appsDir, appName);
135
+
136
+ function replaceStr(filepath, fromToArr) {
137
+ let content = fs.readFileSync(filepath, 'utf-8');
138
+ for (const { from, to } of fromToArr) {
139
+ content = content.replace(new RegExp(from, 'g'), to);
140
+ }
141
+ fs.writeFileSync(filepath, content);
142
+ }
143
+
144
+ copyDir(templateDir, targetAppDir);
145
+ // if templateDir\web\src\appName exists, rename it to github-pj-name
146
+ const githubName = path.join(targetAppDir, `web/src/${templateObj?.dir}`);
147
+ if (templateObj?.dir && fs.existsSync(githubName)) {
148
+ fs.renameSync(githubName, path.join(targetAppDir, 'web/src/github-pj-name'));
149
+ replaceStr(path.join(targetAppDir, 'web/src/github-pj-name/index.tsx'), [
150
+ { from: `/${templateObj?.dir}`, to: '/github-pj-name' },
151
+ { from: `${templateObj?.dir}/`, to: 'github-pj-name/' },
152
+ ]);
153
+ replaceStr(path.join(targetAppDir, 'web/src/github-pj-name/index.html'), [
154
+ { from: `/${templateObj?.dir}`, to: '/github-pj-name' },
155
+ { from: `${templateObj?.dir}/`, to: 'github-pj-name/' },
156
+ // the web analytics of the template's own demo page
157
+ { from: '\\s*<!-- Remove Cloudflare Web Analytics[\\s\\S]*?<!-- End Cloudflare Web Analytics -->', to: '' },
158
+ ]);
159
+ replaceStr(path.join(targetAppDir, 'web/src/github-pj-name/404.html'), [
160
+ { from: `/${templateObj?.dir}`, to: '/github-pj-name' },
161
+ { from: `${templateObj?.dir}/`, to: 'github-pj-name/' },
162
+ ]);
163
+ replaceStr(path.join(targetAppDir, 'lupine.json'), [
164
+ { from: `/${templateObj?.dir}`, to: '/github-pj-name' },
165
+ { from: `${templateObj?.dir}/`, to: 'github-pj-name/' },
166
+ ]);
167
+ }
168
+
169
+ if (templateObj?.layout) {
170
+ const frameFile = path.join(targetAppDir, 'app/src/app.tsx');
171
+ if (fs.existsSync(frameFile)) {
172
+ let content = fs.readFileSync(frameFile, 'utf-8');
173
+ content = content.replace(/const DEFAULT_LAYOUT = '.*';/, `const DEFAULT_LAYOUT = '${templateObj.layout}';`);
174
+ fs.writeFileSync(frameFile, content);
175
+ }
176
+ }
177
+
178
+ changePkgName(path.join(targetAppDir, 'lupine.json'), appName);
179
+ changePkgName(path.join(targetAppDir, 'api', 'package.json'), appName + '-api');
180
+ changePkgName(path.join(targetAppDir, 'web', 'package.json'), appName + '-web');
181
+ // the app (lupine.native): its package, the name of the app and its id (com.example.myproject: change it to yours)
182
+ const appPkgPath = path.join(targetAppDir, 'app', 'package.json');
183
+ if (fs.existsSync(appPkgPath)) {
184
+ const appPkg = JSON.parse(fs.readFileSync(appPkgPath, 'utf-8'));
185
+ appPkg.name = appName + '-app';
186
+ if (appPkg.lupineNative) {
187
+ appPkg.lupineNative.name = appName.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((w) => w[0].toUpperCase() + w.slice(1)).join('') || 'App';
188
+ appPkg.lupineNative.id = `com.example.${appName.toLowerCase().replace(/[^a-z0-9]/g, '') || 'app'}`;
189
+ }
190
+ fs.writeFileSync(appPkgPath, JSON.stringify(appPkg, null, 2) + '\n');
191
+ }
192
+ // the name of the template in its README and in the code (commands, env keys, host names): the name of the project.
193
+ // The links to the template's repository and demo stay; its page for GitHub Pages is web/src/github-pj-name.
194
+ if (templateObj?.dir) {
195
+ const dir = templateObj.dir;
196
+ const rename = (file) => {
197
+ const content = fs.readFileSync(file, 'utf-8');
198
+ const renamed = content
199
+ .replace(new RegExp(`web/src/${dir}`, 'g'), 'web/src/github-pj-name')
200
+ .replace(new RegExp(`(?<!uuware/|github\\.io/)${dir}`, 'g'), appName);
201
+ if (renamed !== content) fs.writeFileSync(file, renamed);
202
+ };
203
+ const walk = (folder) => {
204
+ if (!fs.existsSync(folder)) return;
205
+ for (const entry of fs.readdirSync(folder, { withFileTypes: true })) {
206
+ const file = path.join(folder, entry.name);
207
+ if (entry.isDirectory()) {
208
+ if (entry.name !== 'node_modules' && entry.name !== 'markdown-built' && entry.name !== 'github-pj-name') walk(file);
209
+ } else if (/\.(ts|tsx)$/.test(entry.name)) rename(file);
210
+ }
211
+ };
212
+ const readme = path.join(targetAppDir, 'README.md');
213
+ if (fs.existsSync(readme)) {
214
+ // the pictures of the template (dev/screenshots.js) aren't in the package
215
+ fs.writeFileSync(readme, fs.readFileSync(readme, 'utf-8').replace(/<!-- screenshots[^>]*?-->[\s\S]*?<!-- \/screenshots -->\n*/, ''));
216
+ rename(readme);
217
+ }
218
+ ['app/src', 'web/src', 'api/src'].forEach((folder) => walk(path.join(targetAppDir, folder)));
219
+ }
220
+
221
+ return targetAppDir;
222
+ }
223
+
224
+ /** The scripts of an app: npm run <prefix>run-android ... (clickable in the NPM scripts of the editor). */
225
+ function appScripts(appName, prefix = '') {
226
+ const app = `--app=${appName}`;
227
+ return {
228
+ ...(prefix ? { [`${prefix}build`]: `lupine-build --env=.env.production --dev=0 --obfuscate=0 --apps=${appName}` } : {}),
229
+ [`${prefix}bump`]: `lupine-native bump ${app}`,
230
+ [`${prefix}icons`]: `lupine-native icons ${app}`,
231
+ [`${prefix}build-android`]: `lupine-native android --release ${app}`,
232
+ [`${prefix}run-android`]: `lupine-native android --install --run ${app}`,
233
+ [`${prefix}run-ios`]: `lupine-native ios --install --run ${app}`,
234
+ [`${prefix}run-mac`]: `lupine-native macos --run ${app}`,
235
+ [`${prefix}run-exe`]: `lupine-native windows --run ${app}`,
236
+ };
237
+ }
238
+
239
+ /** The template of --template=, otherwise asked. */
240
+ async function chooseTemplate(template) {
241
+ if (!template || !TEMPLATES.find((t) => t.name === template)) {
242
+ if (template && !TEMPLATES.find((t) => t.name === template)) {
243
+ console.log(`"${template}" isn't a valid template. Please choose from below:`);
244
+ } else {
245
+ console.log('Select a template:');
246
+ }
247
+
248
+ TEMPLATES.forEach((t, i) => {
249
+ console.log(` ${t.color(i + 1 + '. ' + (t.display || t.name))}`);
250
+ });
251
+
252
+ const templateIdx = await prompt(`Select a template (${green('1-' + TEMPLATES.length)}): `);
253
+ const selected = TEMPLATES[parseInt(templateIdx) - 1];
254
+ if (!selected) {
255
+ throw new Error(red('✖ Invalid template selected'));
256
+ }
257
+ template = selected.name;
258
+ }
259
+ return TEMPLATES.find((t) => t.name === template);
260
+ }
261
+
262
+
263
+ /**
264
+ * --add-app [name] [--template=...]: one more app in the project of this folder (apps/<name>, its scripts with the
265
+ * prefix "<name>:"). .env isn't changed (it has your comments and settings): what to add there is printed.
266
+ */
267
+ async function addApp(name, template, versions) {
268
+ const pkgPath = path.join(cwd, 'package.json');
269
+ const pkg = fs.existsSync(pkgPath) ? JSON.parse(fs.readFileSync(pkgPath, 'utf-8')) : null;
270
+ const isProject = pkg && fs.existsSync(path.join(cwd, 'apps')) && fs.existsSync(path.join(cwd, '.env')) && pkg.dependencies?.['lupine.api'];
271
+ if (!isProject) {
272
+ console.log(red('✖ Run it in the folder of a lupine project (package.json with lupine.api, apps/, .env).'));
273
+ return;
274
+ }
275
+ const valid = (n) => /^[a-z0-9][a-z0-9-]*$/.test(n) && !fs.existsSync(path.join(cwd, 'apps', n));
276
+ while (!name || !valid(name)) {
277
+ if (name) console.log(red(`✖ "${name}": lowercase letters, digits and -, and not a folder in apps/ yet.`));
278
+ name = await prompt('Name of the app (the folder in apps/): ');
279
+ }
280
+ const templateObj = await chooseTemplate(template);
281
+ console.log(`\nAdding apps/${name} (${templateObj.name})...`);
282
+ const appDir = scaffoldApp(cwd, name, templateObj);
283
+
284
+ // package.json: the scripts of the app ("<name>:run-android" ...), the packages of the template; nothing is replaced
285
+ pkg.scripts = pkg.scripts || {};
286
+ const scripts = appScripts(name, `${name}:`);
287
+ if (fs.existsSync(path.join(appDir, 'web/src/github-pj-name'))) {
288
+ scripts[`${name}:cp-docs`] = `node dev/cp-folder.js dist/server_root/${name}_web/github-pj-name docs`;
289
+ }
290
+ for (const [k, v] of Object.entries(scripts)) if (!pkg.scripts[k]) pkg.scripts[k] = v;
291
+ if (templateObj.needsPress) {
292
+ pkg.dependencies['lupine.press'] = pkg.dependencies['lupine.press'] || versions['lupine.press'];
293
+ pkg.devDependencies = pkg.devDependencies || {};
294
+ pkg.devDependencies['gray-matter'] = pkg.devDependencies['gray-matter'] || '^4.0.3';
295
+ pkg.devDependencies['marked'] = pkg.devDependencies['marked'] || '^17.0.1';
296
+ }
297
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
298
+
299
+ const apps = (fs.readFileSync(path.join(cwd, '.env'), 'utf-8').match(/^APPS=(.*)$/m)?.[1] || '').trim();
300
+ console.log(green(`\n✔ apps/${name}, and its scripts in package.json (npm run ${name}:run-mac ...)`));
301
+ console.log(`\nNext, by hand:\n`);
302
+ console.log(` 1. .env: add the app to APPS, and the domain the server knows it by (more than one: comma separated):`);
303
+ console.log(bold(` APPS=${apps ? apps + ',' : ''}${name}`));
304
+ console.log(bold(` DOMAINS:${name}=${name}.localhost`));
305
+ console.log(` (${name}.localhost: in the browser on this computer; add the real domain for the server.`);
306
+ console.log(` With SSL for this domain: SSL_KEY_PATH:${name}=... and SSL_CRT_PATH:${name}=...)`);
307
+ console.log(` 2. npm install`);
308
+ console.log(` 3. npm run dev, then http://${name}.localhost:<HTTP_PORT of .env>`);
309
+ console.log(` 4. the id of the app (com.example...): apps/${name}/app/package.json, lupineNative.id`);
310
+ console.log(``);
311
+ }
312
+
115
313
  async function init() {
116
314
  console.log('Fetching latest versions...');
117
315
  const versions = {
118
- 'lupine.api': getLatestVersion('lupine.api', '^1.0.1'),
119
- 'lupine.web': getLatestVersion('lupine.web', '^1.0.1'),
120
- 'lupine.components': getLatestVersion('lupine.components', '^1.0.1'),
121
- 'lupine.press': getLatestVersion('lupine.press', '^1.0.1')
316
+ 'lupine.api': getLatestVersion('lupine.api', '^1.2.42'),
317
+ 'lupine.web': getLatestVersion('lupine.web', '^1.3.0'),
318
+ 'lupine.core': getLatestVersion('lupine.core', '^1.1.1'),
319
+ 'lupine.web.components': getLatestVersion('lupine.web.components', '^1.3.1'),
320
+ 'lupine.native.core': getLatestVersion('lupine.native.core', '^1.1.0'),
321
+ 'lupine.native.components': getLatestVersion('lupine.native.components', '^1.1.1'),
322
+ 'lupine.press': getLatestVersion('lupine.press', '^1.3.0'),
122
323
  };
123
324
 
124
325
  if (argv['update-version']) {
@@ -162,6 +363,8 @@ async function init() {
162
363
  return;
163
364
  }
164
365
 
366
+ if (argv['add-app']) return addApp(argv._[0], argv.template || argv.t, versions);
367
+
165
368
  let targetDir = argv._[0];
166
369
  let template = argv.template || argv.t;
167
370
 
@@ -204,32 +407,8 @@ async function init() {
204
407
  fs.mkdirSync(root, { recursive: true });
205
408
  }
206
409
 
207
- if (!template || !TEMPLATES.find((t) => t.name === template)) {
208
- if (template && !TEMPLATES.find((t) => t.name === template)) {
209
- console.log(`"${template}" isn't a valid template. Please choose from below:`);
210
- } else {
211
- console.log('Select a template:');
212
- }
213
-
214
- TEMPLATES.forEach((t, i) => {
215
- console.log(` ${t.color(i + 1 + '. ' + (t.display || t.name))}`);
216
- });
217
-
218
- const templateIdx = await prompt(`Select a template (${green('1-' + TEMPLATES.length)}): `);
219
- const selected = TEMPLATES[parseInt(templateIdx) - 1];
220
- if (!selected) {
221
- throw new Error(red('✖ Invalid template selected'));
222
- }
223
- template = selected.name;
224
- }
225
-
226
- const templateObj = TEMPLATES.find((t) => t.name === template);
227
- const templateDirName = templateObj?.dir || template;
228
-
229
- const templateDir = path.resolve(fileURLToPath(import.meta.url), '../templates', templateDirName);
230
- const commonDir = path.resolve(fileURLToPath(import.meta.url), '../templates', 'common');
231
-
232
- // ... (copy logic remains same)
410
+ const templateObj = await chooseTemplate(template);
411
+ const commonDir = path.join(templatesRoot(), 'common');
233
412
 
234
413
  console.log(`\nScaffolding project in ${root}...`);
235
414
 
@@ -237,85 +416,34 @@ async function init() {
237
416
  fs.renameSync(path.join(root, '_gitignore'), path.join(root, '.gitignore'));
238
417
  fs.renameSync(path.join(root, '_env'), path.join(root, '.env'));
239
418
 
240
- const appsDir = path.join(root, 'apps');
241
- if (!fs.existsSync(appsDir)) {
242
- fs.mkdirSync(appsDir);
243
- }
244
-
245
419
  const appName = path.basename(root);
246
- const targetAppDir = path.join(appsDir, appName);
247
-
248
- function replaceStr(filepath, fromToArr) {
249
- let content = fs.readFileSync(filepath, 'utf-8');
250
- for (const { from, to } of fromToArr) {
251
- content = content.replace(new RegExp(from, 'g'), to);
252
- }
253
- fs.writeFileSync(filepath, content);
254
- }
255
-
256
- copyDir(templateDir, targetAppDir);
257
- // if templateDir\web\src\appName exists, rename it to github-pj-name
258
- const githubName = path.join(targetAppDir, `web/src/${templateObj?.dir}`);
259
- if (templateObj?.dir && fs.existsSync(githubName)) {
260
- fs.renameSync(githubName, path.join(targetAppDir, 'web/src/github-pj-name'));
261
- replaceStr(path.join(targetAppDir, 'web/src/github-pj-name/index.tsx'), [
262
- { from: `/${templateObj?.dir}`, to: '/github-pj-name' },
263
- { from: `${templateObj?.dir}/`, to: 'github-pj-name/' },
264
- ]);
265
- replaceStr(path.join(targetAppDir, 'web/src/github-pj-name/index.html'), [
266
- { from: `/${templateObj?.dir}`, to: '/github-pj-name' },
267
- { from: `${templateObj?.dir}/`, to: 'github-pj-name/' },
268
- ]);
269
- replaceStr(path.join(targetAppDir, 'web/src/github-pj-name/404.html'), [
270
- { from: `/${templateObj?.dir}`, to: '/github-pj-name' },
271
- { from: `${templateObj?.dir}/`, to: 'github-pj-name/' },
272
- ]);
273
- replaceStr(path.join(targetAppDir, 'lupine.json'), [
274
- { from: `/${templateObj?.dir}`, to: '/github-pj-name' },
275
- { from: `${templateObj?.dir}/`, to: 'github-pj-name/' },
276
- ]);
277
- }
278
-
279
- if (templateObj?.layout) {
280
- const frameFile = path.join(targetAppDir, 'web/src/frames/app-responsive-frame.tsx');
281
- if (fs.existsSync(frameFile)) {
282
- let content = fs.readFileSync(frameFile, 'utf-8');
283
- content = content.replace(/const DEFAULT_LAYOUT = '.*';/, `const DEFAULT_LAYOUT = '${templateObj.layout}';`);
284
- fs.writeFileSync(frameFile, content);
285
- }
286
- }
287
-
288
- changePkgName(path.join(targetAppDir, 'lupine.json'), appName);
289
- changePkgName(path.join(targetAppDir, 'api', 'package.json'), appName + '-api');
290
- changePkgName(path.join(targetAppDir, 'web', 'package.json'), appName + '-web');
420
+ const targetAppDir = scaffoldApp(root, appName, templateObj);
291
421
 
292
422
  const pkg = {
293
423
  name: appName,
294
424
  version: '0.0.0',
295
425
  private: true,
296
426
  workspaces: ['apps/*', 'apps/*/*', 'packages/*'],
297
- '//desktop': 'If you want to build desktop applications, please run `npm run add-electron` first.',
298
427
  scripts: {
299
- 'add-electron': 'npm install -D electron@^35.2.0 electron-builder@^26.0.12',
300
- 'app1:build-win': `electron-builder --win --config apps/${appName}/electron/builder.json`,
301
- 'app1:build-linux': `electron-builder --linux --config apps/${appName}/electron/builder.json`,
302
- 'app1:build-mac': `export CSC_IDENTITY_AUTO_DISCOVERY=true && electron-builder --mac --x64 --config apps/${appName}/electron/builder.json`,
303
- 'app1:unpack-mac': `npx asar extract dist/build/mac-arm64-unpacked/${appName}.app/Contents/Resources/app.asar dist/build/mac-arm64-unpacked/${appName}.app/Contents/Resources/app.asar-unpack`,
304
- 'app1:unpack-linux': `npx asar extract dist/build/linux-arm64-unpacked/resources/app.asar dist/build/linux-arm64-unpacked/resources/app.asar-unpack`,
305
- 'app1:unpack-win': `npx asar extract dist/build/win-unpacked/resources/app.asar dist/build/win-unpacked/resources/app.asar-unpack`,
306
- 'app1:desktop': `electron apps/${appName}/electron/main.js`,
307
- 'app1:sync': `npm run sync --workspace=${appName}-web`,
308
- 'app1:open-ios': `npm run open-ios --workspace=${appName}-web`,
309
- 'app1:open-android': `npm run open-android --workspace=${appName}-web`,
310
428
  dev: 'lupine-build --env=.env.development --dev=1 --cmd=start-dev',
311
429
  build: 'lupine-build --env=.env.production --dev=0 --obfuscate=0',
312
- 'build-mobile': 'lupine-build --env=.env.mobile --dev=0 --mobile=1',
313
430
  'start-dev': 'node dist/server_root/server/server-loader.js --env=.env.development',
314
431
  'start-production': 'node dist/server_root/server/server-loader.js --env=.env.production',
432
+ // the apps: npm run native -- macos --app=<the folder in apps/> --run (ios, android, windows, web; test macos)
433
+ native: 'lupine-native',
434
+ // the app: npm run run-android, run-ios, run-mac, run-exe, build-android, bump, icons
435
+ ...appScripts(appName),
436
+ // a folder with what the server needs (dist/release/<name>): copy it to the server
437
+ release: `lupine-build --env=.env.production --dev=0 --obfuscate=0 --release=dist/release/${appName}`,
315
438
  format: 'prettier --write "**/*.{js,json,css,scss,md,html,yaml,ts,jsx,tsx}"',
316
439
  },
317
440
  dependencies: {
318
- 'lupine.api': 'file:packages/lupine.api',
441
+ 'lupine.api': versions['lupine.api'],
442
+ 'lupine.core': versions['lupine.core'],
443
+ 'lupine.web': versions['lupine.web'],
444
+ 'lupine.web.components': versions['lupine.web.components'],
445
+ 'lupine.native.core': versions['lupine.native.core'],
446
+ 'lupine.native.components': versions['lupine.native.components'],
319
447
  },
320
448
  devDependencies: {
321
449
  typescript: '^5.7.2',
@@ -324,16 +452,13 @@ async function init() {
324
452
  },
325
453
  };
326
454
 
327
- pkg.dependencies = {
328
- 'lupine.api': versions['lupine.api'],
329
- 'lupine.components': versions['lupine.components'],
330
- 'lupine.web': versions['lupine.web'],
331
- };
332
-
333
455
  if (templateObj && templateObj.needsPress) {
334
456
  pkg.dependencies['lupine.press'] = versions['lupine.press'];
335
457
  pkg.devDependencies['gray-matter'] = '^4.0.3';
336
458
  pkg.devDependencies['marked'] = '^17.0.1';
459
+ }
460
+ // the page for GitHub Pages: npm run build, then npm run cp-docs
461
+ if (fs.existsSync(path.join(targetAppDir, 'web/src/github-pj-name'))) {
337
462
  pkg.scripts['cp-docs'] = `node dev/cp-folder.js dist/server_root/${appName}_web/github-pj-name docs`;
338
463
  }
339
464
 
@@ -362,7 +487,8 @@ async function init() {
362
487
  console.log(`\nDone. Now run:\n`);
363
488
  console.log(` cd ${targetDir}`);
364
489
  console.log(` npm install`);
365
- console.log(` npm run dev`);
490
+ console.log(` npm run dev # the site`);
491
+ console.log(` npm run run-mac # the app (run-ios, run-android, run-exe)`);
366
492
  console.log(``);
367
493
  }
368
494
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lupine",
3
- "version": "1.0.31",
3
+ "version": "1.3.0",
4
4
  "description": "Scaffolding tool for Lupine.js projects",
5
5
  "bin": {
6
6
  "create-lupine": "index.js"
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: lupine-framework
3
+ description: >-
4
+ How to write code for Lupine.js: web sites with lupine.web (TSX, signals, router, CSS-in-JS, SSR), Node back ends
5
+ with lupine.api, and native apps for iOS, Android, macOS, Windows and the web with lupine.native. Use it when writing,
6
+ changing or reviewing pages, components, routes, styles, API handlers or native screens of a Lupine.js project, or
7
+ when building, testing or running native apps with the lupine-native tool.
8
+ ---
9
+
10
+ # Lupine.js
11
+
12
+ One TypeScript code base for web sites, Node.js back ends and native apps. State is **signals**; a component function runs **once**; there is no virtual DOM, no compiler of its own and no React hooks.
13
+
14
+ ## Which package
15
+
16
+ | Writing | Import from | Never in that code |
17
+ | --- | --- | --- |
18
+ | a web page or web component | `lupine.web` (signals, `CssProps`, router, SSR, `Icon`, `Redirect`, themes), `lupine.web.components` (editors, PDF viewer), components of `lupine.native.components` (they work in web pages) | `lupine.native.*` (except as in references/native-apps.md, "native components in a web page") |
19
+ | a native screen (iOS, Android, macOS, Windows, web) | `lupine.native.core` (signals, View, Text, platform functions), `lupine.native.components` (themes, router, forms, overlays) | `document`, `window`, `localStorage`, `lupine.web`, `lupine.web.components`: there is no DOM. Only `src/index.web.tsx` may use the DOM |
20
+ | a back end | `lupine.api` | DOM, browser APIs |
21
+
22
+ Signals come from the framework package (`lupine.web` or `lupine.native.core`); both pass on all of `lupine.core`. Don't add `lupine.core` to an app.
23
+
24
+ ## The rules that matter most
25
+
26
+ 1. **State is a signal**: `const [count, setCount] = createSignal(0)`. Plain variables don't update the page.
27
+ 2. **Pass a function, not its result**: `{count}` or `{() => count() + 1}` is updated; `{count()}` is read once and never again. The same for props and styles: `class={() => (on() ? 'a' : 'b')}`, `style={{ opacity: () => (on() ? 1 : 0.5) }}`.
28
+ 3. **A component runs once**: no re-rendering, no dependency arrays. Derived values: `createMemo`. Side effects: `createEffect` (not on the server). Once, when shown: `onMount`. When removed: `onCleanup`. In an async component call them before the first `await`.
29
+ 4. **Lists and conditions**: `<For each={items}>{(item) => ...}</For>` keeps rows by identity; `<Show when={on} fallback={...}>`.
30
+ 5. **Look before you change**: read the file and the code around it first; change the smallest part that does the job; don't rewrite what you weren't asked to touch.
31
+
32
+ ## Web specifics (lupine.web)
33
+
34
+ - Styles: `css={...}` with `&` for the component's own class names (`class='&-title'`), theme variables instead of fixed colors. → references/styling-and-themes.md
35
+ - Pages: `PageRouter`, parameters `/:id`, optional `/?opt`, frames; links are `<a href>`, from code `initializePage(path)`. → references/navigation-and-routing.md
36
+ - **SSR**: pages are rendered on the server first. At the top of a module use `bindAppGlobalStyle`, not `bindGlobalStyle`; while rendering don't touch `window`, `document` or `localStorage` (check `isFrontEnd()` or do it in `onMount`).
37
+ - Phones in the browser: `ActionSheet.select`, `MessageBox`, `Toast` of lupine.native.components instead of `alert`/`confirm`. → references/mobile-interactions.md
38
+ - Icons: references/icon-handling.md
39
+
40
+ ## Native specifics (lupine.native)
41
+
42
+ - Components: `View`, `Text`, `TextInput`, `ScrollView`, `List`, `Image`, `Canvas`, `GL`; styles are objects (flexbox, top to bottom), each value may be a function; `onPress`, `gesture(...)`.
43
+ - Colors from the theme: `col('text')`; pages: `router` with `Pages`, `Screen`; messages: `Toast`, `ActionSheet`; put `<OverlayHost />` last.
44
+ - Build, run, test: `npx lupine-native <ios|android|macos|windows|web> --app=<dir> --run`, `npx lupine-native test <platform> --app=<dir>`, `npx lupine-native doctor`.
45
+ → references/native-apps.md
46
+
47
+ ## Back end (lupine.api)
48
+
49
+ API modules and routers, databases, SSR of the web pages, the admin console; writing routes are POST and check the session. → references/backend-api.md
50
+
51
+ ## References
52
+
53
+ | Topic | File |
54
+ | --- | --- |
55
+ | Signals, lifecycle, lists, forms, refs (web and native) | [reactivity-and-state.md](./references/reactivity-and-state.md) |
56
+ | CSS-in-JS, `&` classes, themes and dark mode (web) | [styling-and-themes.md](./references/styling-and-themes.md) |
57
+ | Router, parameters, SSR, environment and settings (web) | [navigation-and-routing.md](./references/navigation-and-routing.md) |
58
+ | action sheets, dialogs, sliding pages, the back button (web on phones) | [mobile-interactions.md](./references/mobile-interactions.md) |
59
+ | Icons (web, admin) | [icon-handling.md](./references/icon-handling.md) |
60
+ | Native apps: components, styles, navigation, platform functions, tests, the CLI | [native-apps.md](./references/native-apps.md) |
61
+ | Back end: apps, API routers, databases, security | [backend-api.md](./references/backend-api.md) |
62
+
63
+ Documentation: https://uuware.github.io/lupine.js/ (its Markdown is in `apps/doc/web/markdown/en` of the lupine.js repository).
@@ -0,0 +1,113 @@
1
+ # Back end (lupine.api)
2
+
3
+ A Node.js server for several apps: the domain chooses the app with its API module, web files and data. It also renders the web pages (SSR) and has an admin console. Documentation: https://uuware.github.io/lupine.js/en/lupine.api/index and https://uuware.github.io/lupine.js/en/essentials/ssr.
4
+
5
+ ## A project
6
+
7
+ ```text
8
+ .env, .env.development, .env.production APPS, DOMAINS:<app>, ports, DB_TYPE, WEB.* for the front end
9
+ apps/server/ starts the server (from the template, usually unchanged)
10
+ apps/my-app/lupine.json webEntryPoints, apiEntryPoint, copyFiles
11
+ apps/my-app/web/src/index.tsx front end (lupine.web)
12
+ apps/my-app/api/src/index.ts export const apiModule = new ApiModule(new RootApi())
13
+ ```
14
+
15
+ ```bash
16
+ npm run dev # lupine-build --dev=1, then the server: http://localhost:11080, rebuilds on change
17
+ npm run build # production build into dist/server_root: <app>_web, <app>_api, <app>_data (data isn't touched)
18
+ npm run release # lupine-build ... --release=dist/release/<name>: a folder for the server (dist/server_root, .env files,
19
+ # certificates, package.json); what is there already is kept; --set=KEY=VALUE changes its .env
20
+ ```
21
+
22
+ To a running server (its Release page endpoints; it only sends, the server is restarted by hand on its Release page):
23
+ `lupine-build --env=.env.production --deploy=https://<domain of the app> --app=<app> [--parts=web,api,server,env]`, or one
24
+ file: `--put=<file> --to=web:/path` (web, data, log; `--overwrite`). The key: `RELEASE_TOKEN` or `--token-file=` (a token of
25
+ its Tokens page, or `<DEV_ADMIN_USER>:<password>`), never on the command line.
26
+
27
+ A new app: `npx create-lupine --add-app <name>` (from a template, with scripts `<name>:run-mac` ...), then its name in `APPS`
28
+ and a `DOMAINS:<name>=...` line of `.env` (by hand).
29
+
30
+ ## The API module
31
+
32
+ ```ts
33
+ import { ApiHelper, ApiModule, ApiRouter, IApiBase, StaticServer } from 'lupine.api';
34
+
35
+ class RootApi implements IApiBase {
36
+ private router = new ApiRouter();
37
+ constructor() {
38
+ this.router.use('/api', new Api().getRouter());
39
+ // last: static files, otherwise the page is rendered by SSR
40
+ const staticServer = new StaticServer();
41
+ this.router.use('*', staticServer.processRequest.bind(staticServer));
42
+ }
43
+ getRouter() {
44
+ return this.router;
45
+ }
46
+ }
47
+ export const apiModule = new ApiModule(new RootApi());
48
+ ```
49
+
50
+ - `router.get`, `router.post`, `router.use` (all methods); paths like the page router: `/:id` required, `/?id` optional.
51
+ - A handler returns `true` when it has answered; `false` asks the next one. A handler may be another router; several handlers run in order (`use('/orders', checkUser, orders)`), so a check can stop the request.
52
+ - `setFilter(fn)` runs before all routes of a router.
53
+
54
+ ## Requests and answers
55
+
56
+ | | |
57
+ | --- | --- |
58
+ | `req.locals.json()` `text()` `formData()` | the body |
59
+ | `req.locals.query` | `URLSearchParams` |
60
+ | `req.locals.urlParameters.get('id', '')` | parameters of the path |
61
+ | `req.locals.cookies().get(name, '')`, `setCookie`, `clearCookie` | cookies |
62
+ | `ApiHelper.sendJson(req, res, data, status?)` | JSON; also `sendHtml`, `sendFile` |
63
+
64
+ Answers of the templates are `{ status: 'ok' | 'error', message, ... }`; texts for users come from `langHelper.getLang('shared:...')`.
65
+
66
+ ## Rules for handlers
67
+
68
+ - **What changes data is POST** and checks the user on the server first (in the templates `getUserFromCookie(req, res, ...)`, and its role for admin functions). Checks in the front end only decide what is shown.
69
+ - Check what was sent: types, lengths, and that an object isn't an array; skip keys like `__proto__` before copying keys into an object.
70
+ - SQL only with parameters (`?`), never with typed text in the string.
71
+ - File names from users: `isSafeFilename`, `resolveSafePath` (files stay inside the app's data folder). URLs the server fetches for users: `validateTargetUrl`.
72
+ - No secrets in the front end: only `.env` variables that start with `WEB.` reach it.
73
+
74
+ ## Databases
75
+
76
+ SQLite, MySQL, SQL Server and Oracle, chosen by `DB_TYPE` (also per app: `DB_TYPE:<app>`). `$__` becomes the table prefix.
77
+
78
+ ```ts
79
+ import { apiCache, ApiHelper, ApiRouter } from 'lupine.api';
80
+
81
+ const notes = new ApiRouter();
82
+ notes.get('/list', async (req, res) => {
83
+ const rows = await apiCache.getDb().select('SELECT id, title FROM $__note WHERE title LIKE ? ORDER BY id DESC', ['%a%']);
84
+ ApiHelper.sendJson(req, res, rows);
85
+ return true;
86
+ });
87
+ notes.post('/add', async (req, res) => {
88
+ const { title } = req.locals.json() as { title: string };
89
+ await apiCache.getDb().transaction(async (trx) => {
90
+ await trx.insertObject('$__note', { title });
91
+ });
92
+ ApiHelper.sendJson(req, res, { status: 'ok' });
93
+ return true;
94
+ });
95
+ ```
96
+
97
+ New tables go into the install scripts of the app (`api/resources/install.sqlite.sql`, `install.mysql.sql`, ...).
98
+
99
+ ## SSR and settings
100
+
101
+ - Every URL that no API and no file answers is rendered by the front end's `PageRouter` on the server (references/navigation-and-routing.md). Async page components load their data with `props.renderPageFunctions.fetchData(url)`, which on the server calls the API inside the process with the request's cookies.
102
+ - `apiStorage.setWeb(key, value)` + `apiStorage.save()` store settings that the front end reads with `WebConfig.get(key, default)`, without a new release.
103
+ - `apiStorage.setTemp(key, value, ttlSeconds = 3600)` / `getTemp(key)` (undefined when none or expired) / `getTempWithPrefix(prefix)`: strings for all workers, in memory of the primary process, never saved; at most `TEMP_MAX_ENTRIES` (10000) per app, the oldest go.
104
+
105
+ ## WebSockets
106
+
107
+ - `router.ws(path, ...handlers)` gets only upgrade requests; filters run on the way (refuse with an HTTP answer), functions of `use` don't. A handler takes the socket: `new MiniWebSocket(onText, onClose, { protocols, onBinary, pingInterval }).accept(req)`.
108
+ - A socket stays in its worker. For several people use `WsRooms` (the primary relays): `new WsRooms('name', { maxPerRoom, onMessage(client, text), onMembers(room, members) => text })`, `await rooms.join(req, room, info)`, `rooms.publish(room, text, exceptClient)`. A full room closes with 4013 'full'; app close codes are 4000-4999 (Apple's client turns 1012-3999 into 1005).
109
+ - Limits: `WS_MAX_CONNECTIONS` (200 per app), `WS_MAX_PER_IP` (20); a foreign `Origin` is refused (none is allowed: native apps). Example: `apps/native-demo/api/src/service/board-api.ts`.
110
+
111
+ ## Helpers
112
+
113
+ `lupine.api` passes on the helpers of `lupine.core` (`Logger`, dates, `formatBytes`, `SimpleStorage`, ...). Others: `langHelper`, `apiCache`, `apiStorage`, `ApiHelper`, `CryptoUtils`, `resolveSafePath`, `isSafeFilename`, `isSafeSqlIdentifier`, `validateTargetUrl` (no requests to private addresses), CSV and form data parsers; look in `packages/lupine.api/src` before writing one of your own.