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.
- package/README.md +31 -0
- package/index.js +238 -112
- package/package.json +1 -1
- package/templates/common/.agents/skills/lupine-framework/SKILL.md +63 -0
- package/templates/common/.agents/skills/lupine-framework/references/backend-api.md +113 -0
- package/templates/common/.agents/skills/lupine-framework/references/icon-handling.md +71 -0
- package/templates/common/.agents/skills/lupine-framework/references/mobile-interactions.md +29 -0
- package/templates/common/.agents/skills/lupine-framework/references/native-apps.md +190 -0
- package/templates/common/.agents/skills/lupine-framework/references/navigation-and-routing.md +55 -0
- package/templates/common/.agents/skills/lupine-framework/references/reactivity-and-state.md +108 -0
- package/templates/common/.agents/skills/lupine-framework/references/styling-and-themes.md +121 -0
- package/templates/common/.env.mobile +4 -3
- package/templates/common/_env +10 -4
- package/templates/common/apps/server/README.md +10 -0
- package/templates/common/dev/cp-folder.js +9 -4
- package/templates/lupine-template-cv-starter/README.md +37 -0
- package/templates/lupine-template-cv-starter/app/package.json +20 -0
- package/templates/lupine-template-cv-starter/app/src/app.tsx +6 -0
- package/templates/lupine-template-cv-starter/app/src/index.native.tsx +4 -0
- package/templates/lupine-template-cv-starter/app/src/index.test.tsx +71 -0
- package/templates/lupine-template-cv-starter/app/src/index.web.tsx +28 -0
- package/templates/lupine-template-cv-starter/app/tsconfig.json +17 -0
- package/templates/lupine-template-cv-starter/lupine.json +8 -7
- package/templates/lupine-template-cv-starter/web/src/index.html +9 -2
- package/templates/lupine-template-cv-starter/web/src/index.tsx +9 -23
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.html +9 -2
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.tsx +4 -29
- package/templates/lupine-template-doc-starter/README.md +37 -0
- package/templates/lupine-template-doc-starter/app/package.json +20 -0
- package/templates/lupine-template-doc-starter/app/src/app.tsx +6 -0
- package/templates/lupine-template-doc-starter/app/src/index.native.tsx +4 -0
- package/templates/lupine-template-doc-starter/app/src/index.test.tsx +78 -0
- package/templates/lupine-template-doc-starter/app/src/index.web.tsx +28 -0
- package/templates/lupine-template-doc-starter/app/tsconfig.json +17 -0
- package/templates/lupine-template-doc-starter/lupine.json +8 -7
- package/templates/lupine-template-doc-starter/web/src/index.html +9 -2
- package/templates/lupine-template-doc-starter/web/src/index.tsx +9 -23
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.html +9 -2
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.tsx +4 -29
- package/templates/lupine-template-fullstack-note/README.md +83 -0
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/api/package.json +1 -1
- package/templates/lupine-template-fullstack-note/api/resources/install.mysql.sql +32 -0
- package/templates/lupine-template-fullstack-note/api/resources/install.sqlite.sql +27 -0
- package/templates/lupine-template-fullstack-note/api/src/service/answer.ts +39 -0
- package/templates/lupine-template-fullstack-note/api/src/service/api.ts +52 -0
- package/templates/lupine-template-fullstack-note/api/src/service/db.ts +78 -0
- package/templates/lupine-template-fullstack-note/api/src/service/notes-api.ts +86 -0
- package/templates/lupine-template-fullstack-note/api/src/service/root-api.ts +19 -0
- package/templates/lupine-template-fullstack-note/api/src/service/user-api.ts +182 -0
- package/templates/lupine-template-fullstack-note/app/package.json +19 -0
- package/templates/lupine-template-fullstack-note/app/src/app.tsx +75 -0
- package/templates/lupine-template-fullstack-note/app/src/index.native.tsx +4 -0
- package/templates/lupine-template-fullstack-note/app/src/index.test.tsx +373 -0
- package/templates/lupine-template-fullstack-note/app/src/index.web.tsx +20 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/components.tsx +65 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/details.tsx +38 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/discover.tsx +25 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/home.tsx +76 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/inbox.tsx +49 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/login.tsx +54 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/me.tsx +32 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/notes.tsx +128 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/settings.tsx +45 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/AppMenu.tsx +44 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/api.ts +159 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/data.ts +20 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/locales/ja.ts +80 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/locales/zh-CN.ts +80 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/texts.ts +14 -0
- package/templates/lupine-template-fullstack-note/app/tsconfig.json +17 -0
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/lupine.json +4 -2
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/web/package.json +1 -1
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/web/src/index.html +10 -3
- package/templates/lupine-template-fullstack-note/web/src/index.tsx +15 -0
- package/templates/lupine-template-fullstack-starter/README.md +70 -0
- package/templates/lupine-template-fullstack-starter/api/package.json +10 -0
- package/templates/lupine-template-fullstack-starter/api/resources/install.mysql.sql +107 -0
- package/templates/lupine-template-fullstack-starter/api/resources/install.sqlite.sql +75 -0
- package/templates/lupine-template-fullstack-starter/api/src/lang/api-lang-en.ts +39 -0
- package/templates/lupine-template-fullstack-starter/api/src/lang/api-lang-zh-cn.ts +37 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/admin-api.ts +139 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/api.ts +111 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/contact-api.ts +50 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/file-api-base.ts +30 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/root-api.ts +28 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/send-email.ts +47 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/setting-api.ts +60 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/user-api.ts +1046 -0
- package/templates/lupine-template-fullstack-starter/app/assets/sample.png +0 -0
- package/templates/lupine-template-fullstack-starter/app/package.json +20 -0
- package/templates/lupine-template-fullstack-starter/app/src/app.tsx +76 -0
- package/templates/lupine-template-fullstack-starter/app/src/index.native.tsx +4 -0
- package/templates/lupine-template-fullstack-starter/app/src/index.test.tsx +276 -0
- package/templates/lupine-template-fullstack-starter/app/src/index.web.tsx +28 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/about.tsx +27 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/contact.tsx +41 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/favorite.tsx +27 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/home.tsx +63 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/login.tsx +63 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/mine.tsx +44 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/profile.tsx +58 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/register.tsx +48 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/reset-password.tsx +41 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/settings.tsx +33 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/story.tsx +46 -0
- package/templates/lupine-template-fullstack-starter/app/src/shell/api.ts +127 -0
- package/templates/lupine-template-fullstack-starter/app/src/shell/parts.tsx +100 -0
- package/templates/lupine-template-fullstack-starter/app/src/shell/stories.ts +65 -0
- package/templates/lupine-template-fullstack-starter/app/src/shell/texts.ts +79 -0
- package/templates/lupine-template-fullstack-starter/app/tsconfig.json +17 -0
- package/templates/lupine-template-fullstack-starter/lupine.json +31 -0
- package/templates/lupine-template-fullstack-starter/web/assets/android-chrome-192x192.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/apple-touch-icon.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/favicon-16x16.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/favicon-32x32.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/favicon.ico +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/icons-font/License-carbon-icons.txt +71 -0
- package/templates/lupine-template-fullstack-starter/web/assets/icons-font/License-material-design.txt +20 -0
- package/templates/lupine-template-fullstack-starter/web/assets/icons-font/i-font.woff2 +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/icons-font/sample.html +124 -0
- package/templates/lupine-template-fullstack-starter/web/assets/icons-font/style.css +103 -0
- package/templates/lupine-template-fullstack-starter/web/assets/lupine-flower.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/lupine.svg +71 -0
- package/templates/lupine-template-fullstack-starter/web/assets/site.webmanifest +14 -0
- package/templates/lupine-template-fullstack-starter/web/icons-font.config.js +129 -0
- package/templates/{lupine-template-responsive-starter/api → lupine-template-fullstack-starter/web}/package.json +1 -1
- package/templates/lupine-template-fullstack-starter/web/src/admin/admin-patch.tsx +34 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin/components/home-search-component.tsx +125 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin/components/story-card.tsx +105 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin/components/story-list.tsx +105 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin/components/story-props.ts +34 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin/index.html +23 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin/index.tsx +49 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin/pages/admin-cfg.tsx +144 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin/pages/admin-item-edit.tsx +20 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin/pages/admin-item-list.tsx +23 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin/pages/admin-user.tsx +145 -0
- package/templates/lupine-template-fullstack-starter/web/src/index.html +28 -0
- package/templates/lupine-template-fullstack-starter/web/src/index.tsx +16 -0
- package/templates/lupine-template-fullstack-starter/web/src/services/fetch-data.ts +37 -0
- package/templates/lupine-template-fullstack-starter/web/src/styles/base-css.ts +14 -0
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/global.css +10 -57
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/theme.ts +2 -1
- package/templates/lupine-template-responsive-starter/README.md +51 -0
- package/templates/lupine-template-responsive-starter/app/package.json +19 -0
- package/templates/lupine-template-responsive-starter/app/src/app.tsx +80 -0
- package/templates/lupine-template-responsive-starter/app/src/index.native.tsx +4 -0
- package/templates/lupine-template-responsive-starter/app/src/index.test.tsx +283 -0
- package/templates/lupine-template-responsive-starter/app/src/index.web.tsx +31 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/about.tsx +23 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/finance.tsx +48 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/mine.tsx +60 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/not-found.tsx +9 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/note-detail.tsx +43 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/note-edit.tsx +45 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/note-search.tsx +62 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/notes.tsx +71 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/settings.tsx +55 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/tools.tsx +112 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/icons.ts +7 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/layout.ts +18 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/locales/zh-CN.ts +89 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/menu.tsx +81 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/nav.ts +12 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/store.ts +72 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/texts.ts +11 -0
- package/templates/lupine-template-responsive-starter/app/tsconfig.json +17 -0
- package/templates/lupine-template-responsive-starter/lupine.json +7 -6
- package/templates/lupine-template-responsive-starter/web/src/index.html +9 -2
- package/templates/lupine-template-responsive-starter/web/src/index.tsx +9 -34
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.html +12 -6
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.tsx +12 -31
- package/templates/common/AI_CONTEXT.md +0 -1002
- package/templates/common/apps/server/src/app-loader.ts +0 -4
- package/templates/lupine-template-cv-starter/api/package.json +0 -6
- package/templates/lupine-template-cv-starter/api/resources/install.sqlite.sql +0 -4
- package/templates/lupine-template-cv-starter/api/src/index.ts +0 -15
- package/templates/lupine-template-cv-starter/web/src/styles/base-css.ts +0 -15
- package/templates/lupine-template-doc-starter/api/package.json +0 -6
- package/templates/lupine-template-doc-starter/api/resources/config_default.json +0 -6
- package/templates/lupine-template-doc-starter/api/resources/install.sqlite.sql +0 -4
- package/templates/lupine-template-doc-starter/api/src/index.ts +0 -15
- package/templates/lupine-template-doc-starter/api/src/resources/config_default.json +0 -6
- package/templates/lupine-template-doc-starter/api/src/resources/install.sqlite.sql +0 -4
- package/templates/lupine-template-doc-starter/web/src/client-env-keys.ts +0 -5
- package/templates/lupine-template-doc-starter/web/src/styles/base-css.ts +0 -15
- package/templates/lupine-template-hello-world/api/resources/config_default.json +0 -6
- package/templates/lupine-template-hello-world/api/resources/install.sqlite.sql +0 -4
- package/templates/lupine-template-hello-world/api/src/service/root-api.ts +0 -18
- package/templates/lupine-template-hello-world/web/src/index.tsx +0 -73
- package/templates/lupine-template-hello-world/web/src/styles/app.css +0 -0
- package/templates/lupine-template-hello-world/web/src/styles/base-css.ts +0 -1
- package/templates/lupine-template-responsive-starter/api/resources/config_default.json +0 -6
- package/templates/lupine-template-responsive-starter/api/resources/install.sqlite.sql +0 -4
- package/templates/lupine-template-responsive-starter/api/src/service/root-api.ts +0 -18
- package/templates/lupine-template-responsive-starter/web/src/app-icons.ts +0 -76
- package/templates/lupine-template-responsive-starter/web/src/components/input-history-component.tsx +0 -93
- package/templates/lupine-template-responsive-starter/web/src/components/mine-about-page.tsx +0 -86
- package/templates/lupine-template-responsive-starter/web/src/components/mine-premium-page.tsx +0 -80
- package/templates/lupine-template-responsive-starter/web/src/components/mine-settings-page.tsx +0 -220
- package/templates/lupine-template-responsive-starter/web/src/components/mobile-top-search-menu.tsx +0 -119
- package/templates/lupine-template-responsive-starter/web/src/components/note-detail.tsx +0 -116
- package/templates/lupine-template-responsive-starter/web/src/components/note-edit.tsx +0 -154
- package/templates/lupine-template-responsive-starter/web/src/components/note-search-page.tsx +0 -193
- package/templates/lupine-template-responsive-starter/web/src/components/search-input.tsx +0 -95
- package/templates/lupine-template-responsive-starter/web/src/components/side-menu-content.tsx +0 -182
- package/templates/lupine-template-responsive-starter/web/src/frames/app-responsive-frame.tsx +0 -52
- package/templates/lupine-template-responsive-starter/web/src/pages/about-page.tsx +0 -43
- package/templates/lupine-template-responsive-starter/web/src/pages/finance-page.tsx +0 -46
- package/templates/lupine-template-responsive-starter/web/src/pages/home-page.tsx +0 -452
- package/templates/lupine-template-responsive-starter/web/src/pages/mine-page.tsx +0 -325
- package/templates/lupine-template-responsive-starter/web/src/pages/tools-page.tsx +0 -46
- package/templates/lupine-template-responsive-starter/web/src/services/local-notes-service.ts +0 -87
- package/templates/lupine-template-responsive-starter/web/src/services/mine-service.ts +0 -45
- package/templates/lupine-template-responsive-starter/web/src/styles/app.css +0 -0
- package/templates/lupine-template-responsive-starter/web/src/styles/base-css.ts +0 -65
- package/templates/lupine-template-responsive-starter/web/src/styles/global.css +0 -2130
- package/templates/lupine-template-responsive-starter/web/src/styles/theme.ts +0 -16
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/01-experience/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/02-projects/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/03-skills/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/04-education/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/01-experience/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/02-projects/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/03-skills/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/04-education/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/01-experience/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/02-projects/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/03-skills/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/04-education/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/markdown-config.ts +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/01-experience/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/02-projects/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/03-skills/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/04-education/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/index.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/essentials/index.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/essentials/list.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/guide/install.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/guide/started.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/index.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/index.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/essentials/index.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/essentials/list.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/guide/install.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/guide/started.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/index.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/essentials/index.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/essentials/list.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/guide/install.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/guide/started.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/index.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/index.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/markdown-config.ts +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/essentials/index.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/essentials/list.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/guide/install.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/guide/started.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/index.html +0 -0
- /package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/api/src/index.ts +0 -0
- /package/templates/{lupine-template-hello-world → lupine-template-fullstack-note}/web/assets/favicon.ico +0 -0
- /package/templates/{lupine-template-cv-starter → lupine-template-fullstack-starter}/api/resources/config_default.json +0 -0
- /package/templates/{lupine-template-responsive-starter → lupine-template-fullstack-starter}/api/src/index.ts +0 -0
- /package/templates/{lupine-template-cv-starter/web/src → lupine-template-fullstack-starter/web/src/models}/client-env-keys.ts +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lupine-template-fullstack-starter-app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "The app of the full-stack starter: stories, sign-in, the user's pages, settings. One code base for iOS, Android, macOS, Windows and the web.",
|
|
6
|
+
"lupineNative": {
|
|
7
|
+
"name": "LupineFullstack",
|
|
8
|
+
"title": "Lupine Full-stack",
|
|
9
|
+
"id": "com.uuware.lupine.fullstack",
|
|
10
|
+
"entry": {
|
|
11
|
+
"native": "src/index.native.tsx",
|
|
12
|
+
"test": "src/index.test.tsx",
|
|
13
|
+
"web": "src/index.web.tsx"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"lupine.native.components": "^1.1.0",
|
|
18
|
+
"lupine.native.core": "^1.1.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import './shell/texts';
|
|
2
|
+
import { createEffect, onBack, onMount, Text, untrack, View } from 'lupine.native.core';
|
|
3
|
+
import { col, Icon, NavBar, NavItem, OverlayHost, Pages, router, syncAppearance, t, Toast, tr, val } from 'lupine.native.components';
|
|
4
|
+
import * as icons from 'lupine.core/icons';
|
|
5
|
+
import { api } from './shell/api';
|
|
6
|
+
import { About, NotFound } from './pages/about';
|
|
7
|
+
import { Contact } from './pages/contact';
|
|
8
|
+
import { Favorite } from './pages/favorite';
|
|
9
|
+
import { Home } from './pages/home';
|
|
10
|
+
import { Login } from './pages/login';
|
|
11
|
+
import { Mine } from './pages/mine';
|
|
12
|
+
import { Profile } from './pages/profile';
|
|
13
|
+
import { Register } from './pages/register';
|
|
14
|
+
import { ResetPassword } from './pages/reset-password';
|
|
15
|
+
import { Settings } from './pages/settings';
|
|
16
|
+
import { StoryPage } from './pages/story';
|
|
17
|
+
|
|
18
|
+
const items: NavItem[] = [
|
|
19
|
+
{ key: '/', label: tr('nav.home', 'Stories'), icon: icons.home, testID: 'tab-home' },
|
|
20
|
+
{ key: '/favorite', label: tr('nav.favorite', 'Favorites'), icon: icons.heart, testID: 'tab-favorite' },
|
|
21
|
+
{ key: '/mine', label: tr('nav.mine', 'Mine'), icon: icons.user, testID: 'tab-mine' },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
// the title of the browser's tab (the window on desktops) while a tab is shown; pages over the tabs: the name of the app
|
|
25
|
+
const appName = () => t('app.name', 'Lupine Full-stack');
|
|
26
|
+
const tabTitle = (key: string) => () => (key === '/' ? appName() : `${val(items.find((i) => i.key === key)?.label ?? '')} | ${appName()}`);
|
|
27
|
+
|
|
28
|
+
/** Phones: a tab bar at the bottom, pushed pages cover it. Wide windows: the menu stays on the left. */
|
|
29
|
+
export const App = () => {
|
|
30
|
+
untrack(syncAppearance); // before the first control is created
|
|
31
|
+
createEffect(syncAppearance);
|
|
32
|
+
// who is signed in; not while a server renders the page
|
|
33
|
+
onMount(() => void api.refresh());
|
|
34
|
+
let last = 0;
|
|
35
|
+
onBack(() => {
|
|
36
|
+
if (Date.now() - last < 2000) return false;
|
|
37
|
+
last = Date.now();
|
|
38
|
+
Toast.info(t('ln.pressAgainToExit', 'Press back again to exit'));
|
|
39
|
+
});
|
|
40
|
+
return (
|
|
41
|
+
<View style={{ flex: 1, backgroundColor: col('bg') }}>
|
|
42
|
+
<Pages
|
|
43
|
+
side={240}
|
|
44
|
+
title={appName}
|
|
45
|
+
tabs={[
|
|
46
|
+
{ path: '/', page: Home, title: tabTitle('/') },
|
|
47
|
+
{ path: '/favorite', page: Favorite, title: tabTitle('/favorite') },
|
|
48
|
+
{ path: '/mine', page: Mine, title: tabTitle('/mine') },
|
|
49
|
+
]}
|
|
50
|
+
routes={[
|
|
51
|
+
{ path: '/story/:id', page: ({ id }) => <StoryPage id={id} /> },
|
|
52
|
+
{ path: '/login', page: ({ email, mode }) => <Login email={email} mode={mode} /> },
|
|
53
|
+
{ path: '/register', page: () => <Register /> },
|
|
54
|
+
{ path: '/reset-password', page: ({ email }) => <ResetPassword email={email} /> },
|
|
55
|
+
{ path: '/profile', page: () => <Profile /> },
|
|
56
|
+
{ path: '/contact', page: () => <Contact /> },
|
|
57
|
+
{ path: '/settings', page: () => <Settings /> },
|
|
58
|
+
{ path: '/about', page: () => <About /> },
|
|
59
|
+
]}
|
|
60
|
+
notFound={() => <NotFound />}
|
|
61
|
+
>
|
|
62
|
+
{/* one menu: a tab bar at the bottom on phones, a column on the left on wide windows (css, also on the server) */}
|
|
63
|
+
<NavBar
|
|
64
|
+
items={items} active={router.tab} onPress={router.navigate} width={240}
|
|
65
|
+
header={
|
|
66
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10, padding: 18 }}>
|
|
67
|
+
<Icon name={icons.logo} size={26} color={col('primary')} />
|
|
68
|
+
<Text style={{ fontSize: 17, fontWeight: '700', color: col('text') }}>{tr('app.name', 'Lupine Full-stack')}</Text>
|
|
69
|
+
</View>
|
|
70
|
+
}
|
|
71
|
+
/>
|
|
72
|
+
</Pages>
|
|
73
|
+
<OverlayHost />
|
|
74
|
+
</View>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/// <reference path="../../../../node_modules/lupine.native.core/src/native-globals.d.ts" />
|
|
2
|
+
// Walks through the app inside a native shell built with --test: presses the real views, types into the real fields.
|
|
3
|
+
// There is no server: first the API is an address where nobody answers (the app shows that, it doesn't break), then
|
|
4
|
+
// fetch is a small fake of the API, to sign in and out.
|
|
5
|
+
import { Platform, storage, windowInfo } from 'lupine.native.core';
|
|
6
|
+
import { isWide, setLang, setThemePref } from 'lupine.native.components';
|
|
7
|
+
import { runApp } from 'lupine.native.core/native';
|
|
8
|
+
import { App } from './app';
|
|
9
|
+
import { api, setServerAddress } from './shell/api';
|
|
10
|
+
import { favorites } from './shell/stories';
|
|
11
|
+
|
|
12
|
+
const native = globalThis.__lupine;
|
|
13
|
+
const act = (id: string, action: string, arg?: unknown) => native.test!(id, action, arg);
|
|
14
|
+
const text = (id: string) => act(id, 'text');
|
|
15
|
+
const sleep = (ms: number) => new Promise<void>((done) => setTimeout(done, ms));
|
|
16
|
+
const exists = (id: string) => act(id, 'x') !== '<missing>';
|
|
17
|
+
|
|
18
|
+
let passed = 0;
|
|
19
|
+
let failed = 0;
|
|
20
|
+
const check = (name: string, actual: unknown, expected: unknown) => {
|
|
21
|
+
const ok = actual === expected;
|
|
22
|
+
if (ok) passed++;
|
|
23
|
+
else failed++;
|
|
24
|
+
console.log(`TEST ${ok ? 'ok ' : 'FAIL'} ${name}${ok ? '' : ` -> ${JSON.stringify(actual)}, expected ${JSON.stringify(expected)}`}`);
|
|
25
|
+
};
|
|
26
|
+
/** The script that runs the test takes a picture; desktops do it themselves. */
|
|
27
|
+
const shot = async (name: string) => {
|
|
28
|
+
await sleep(250);
|
|
29
|
+
if (Platform.OS === 'macos' || Platform.OS === 'windows') act('', 'screenshot', `shot-${name}.png`);
|
|
30
|
+
console.log(`SHOT ${name}`);
|
|
31
|
+
await sleep(Platform.OS === 'macos' || Platform.OS === 'windows' ? 50 : 2500);
|
|
32
|
+
};
|
|
33
|
+
const press = async (id: string, wait = 600) => {
|
|
34
|
+
check(`press ${id}`, exists(id) && act(id, 'click'), true);
|
|
35
|
+
await sleep(wait);
|
|
36
|
+
};
|
|
37
|
+
const type = async (id: string, value: string) => {
|
|
38
|
+
act(id, 'focus');
|
|
39
|
+
await sleep(200);
|
|
40
|
+
act(id, 'type', value);
|
|
41
|
+
await sleep(200);
|
|
42
|
+
};
|
|
43
|
+
const toast = () => (exists('toast-text') ? text('toast-text') : '');
|
|
44
|
+
/** the toast, when it comes (on Windows an address where nobody answers takes about 2 s to fail) */
|
|
45
|
+
const toastSoon = async (ms = 6000) => {
|
|
46
|
+
for (let t = 0; t < ms && !toast(); t += 100) await sleep(100);
|
|
47
|
+
return toast();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// The fake API: what the app sends, and the answers of api/src/service/user-api.ts
|
|
51
|
+
const realFetch = globalThis.fetch;
|
|
52
|
+
const TOKEN = 'token+1/='; // as CryptoUtils.encrypt makes them: base64
|
|
53
|
+
const sent: { path: string; cookie: string; body: any }[] = [];
|
|
54
|
+
const fakeFetch = async (url: string, init: { headers?: { [name: string]: string }; body?: string } = {}) => {
|
|
55
|
+
const path = url.replace(/^\w+:\/\/[^/]+/, '');
|
|
56
|
+
const cookie: string = init.headers?.Cookie || '';
|
|
57
|
+
const body = init.body ? JSON.parse(init.body) : undefined;
|
|
58
|
+
sent.push({ path, cookie, body });
|
|
59
|
+
const json = (value: object) => ({ ok: true, status: 200, statusText: '', url, headers: new Headers(), text: async () => JSON.stringify(value), json: async () => value, arrayBuffer: async () => new ArrayBuffer(0) });
|
|
60
|
+
const session = cookie.includes(`_token=${encodeURIComponent(TOKEN)}`);
|
|
61
|
+
if (path === '/api/login') return json(body.p === 'secret1' ? { status: 'ok', message: 'Login success', result: TOKEN, user: { nickname: 'ada', u: 'ada', t: 'user' } } : { status: 'error', message: 'Wrong user name or password' });
|
|
62
|
+
if (path === '/api/user-info') return json(session ? { status: 'ok', results: { id: 7, email: 'ada@example.com', username: 'ada@example.com', nickname: 'Ada', usertype: 'user' } } : { status: 'error', message: 'Not logged in' });
|
|
63
|
+
if (path === '/api/user-profile') return json(session ? { status: 'ok', message: 'Profile updated' } : { status: 'error', message: 'Permission denied.' });
|
|
64
|
+
if (path === '/api/logout') return json({ status: 'ok', message: 'Logged out.' });
|
|
65
|
+
return json({ status: 'error', message: `no ${path}` });
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// a known start: nobody answers at port 9
|
|
69
|
+
setThemePref('light');
|
|
70
|
+
setLang('en');
|
|
71
|
+
api.forget();
|
|
72
|
+
setServerAddress('http://127.0.0.1:9');
|
|
73
|
+
|
|
74
|
+
const started = Date.now();
|
|
75
|
+
runApp(App);
|
|
76
|
+
console.log(`TEST mounted in ${Date.now() - started} ms, window ${JSON.stringify(windowInfo())}`);
|
|
77
|
+
|
|
78
|
+
const main = async () => {
|
|
79
|
+
for (let i = 0; i < 100 && !(act('page-home', 'width') > 0); i++) await sleep(100);
|
|
80
|
+
await sleep(500);
|
|
81
|
+
const left = isWide() ? 240 : 0;
|
|
82
|
+
check('home fills the window', Math.round(act('page-home', 'width')), Math.round(windowInfo().width - left));
|
|
83
|
+
|
|
84
|
+
// the stories: search, categories, more, a story
|
|
85
|
+
check('stories', text('home-count'), '100 stories');
|
|
86
|
+
check('the first page of them', exists('story-20') && !exists('story-21'), true);
|
|
87
|
+
await shot('1-home');
|
|
88
|
+
await press('home-more', 400);
|
|
89
|
+
check('more', exists('story-40') && !exists('story-41'), true);
|
|
90
|
+
await type('home-search', 'title 7');
|
|
91
|
+
check('search: the words', text('home-count'), '19 stories');
|
|
92
|
+
await shot('2-search');
|
|
93
|
+
await press('home-search-clear', 300);
|
|
94
|
+
check('search cleared', text('home-count'), '100 stories');
|
|
95
|
+
await press('home-cat-europe', 300);
|
|
96
|
+
check('category', text('home-count'), '17 stories');
|
|
97
|
+
check('category: the stories', exists('story-2') && !exists('story-1'), true);
|
|
98
|
+
await press('home-cat-all', 300);
|
|
99
|
+
await press('story-3', 800);
|
|
100
|
+
check('the page of a story', text('story-title'), 'Title 3');
|
|
101
|
+
await press('story-favorite');
|
|
102
|
+
check('favorites need a sign-in', text('dialog-text'), 'Sign in to keep your favorites');
|
|
103
|
+
await shot('3-story');
|
|
104
|
+
await press('dialog-cancel');
|
|
105
|
+
check('dialog closed', exists('dialog'), false);
|
|
106
|
+
await press('header-back', 800);
|
|
107
|
+
check('back on the list', exists('page-story'), false);
|
|
108
|
+
|
|
109
|
+
// without a sign-in
|
|
110
|
+
await press('tab-favorite');
|
|
111
|
+
check('favorites: sign in first', exists('favorite-signin'), true);
|
|
112
|
+
await press('tab-mine');
|
|
113
|
+
check('guest', text('mine-name'), 'Guest');
|
|
114
|
+
check('no admin pages', exists('mine-admin'), false);
|
|
115
|
+
await shot('4-mine');
|
|
116
|
+
|
|
117
|
+
// sign-in: the checks of the form, and no server
|
|
118
|
+
await press('mine-signin', 800);
|
|
119
|
+
await press('login-submit', 300);
|
|
120
|
+
check('user name required', text('login-user-error'), 'Required');
|
|
121
|
+
check('password required', text('login-password-error'), 'Required');
|
|
122
|
+
await shot('5-login-checks');
|
|
123
|
+
await type('login-user', 'ada');
|
|
124
|
+
await type('login-password', 'secret1');
|
|
125
|
+
check('no errors now', exists('login-user-error') || exists('login-password-error'), false);
|
|
126
|
+
await press('login-submit', 300);
|
|
127
|
+
check('no server: a message', await toastSoon(), 'The server cannot be reached');
|
|
128
|
+
check('still on the page', exists('page-login'), true);
|
|
129
|
+
check('not signed in', api.user(), null);
|
|
130
|
+
await shot('6-login-offline');
|
|
131
|
+
// with a code of the e-mail
|
|
132
|
+
await press('login-mode-code', 400);
|
|
133
|
+
check('code mode: no password', exists('login-password'), false);
|
|
134
|
+
await press('login-submit', 300);
|
|
135
|
+
check('code required', text('login-code-error'), 'Required');
|
|
136
|
+
await type('login-code', '12ab');
|
|
137
|
+
check('code: digits', text('login-code-error'), 'The code of the e-mail: digits only');
|
|
138
|
+
await press('login-send-code', 300);
|
|
139
|
+
check('send code: no server', await toastSoon(), 'The server cannot be reached');
|
|
140
|
+
await shot('7-login-code');
|
|
141
|
+
await press('login-mode-password', 400);
|
|
142
|
+
|
|
143
|
+
// a new account: the checks (each field is typed into once: a new page for the second round)
|
|
144
|
+
await press('login-register', 800);
|
|
145
|
+
await press('register-submit', 300);
|
|
146
|
+
check('e-mail required', text('register-email-error'), 'Required');
|
|
147
|
+
check('name required', text('register-name-error'), 'Required');
|
|
148
|
+
check('gender required', text('register-sex-error'), 'Choose one');
|
|
149
|
+
await type('register-email', 'ada');
|
|
150
|
+
check('e-mail address', text('register-email-error'), 'Enter a valid e-mail address');
|
|
151
|
+
await type('register-password', '12345');
|
|
152
|
+
check('password length', text('register-password-error'), 'At least 6 characters');
|
|
153
|
+
await type('register-password2', '1');
|
|
154
|
+
check('passwords differ', text('register-password2-error'), 'The two passwords differ');
|
|
155
|
+
await shot('8-register-checks');
|
|
156
|
+
await press('header-back', 800);
|
|
157
|
+
await press('login-register', 800);
|
|
158
|
+
await type('register-email', 'ada@example.com');
|
|
159
|
+
await type('register-password', '123456');
|
|
160
|
+
await type('register-password2', '123456');
|
|
161
|
+
await type('register-name', 'Ada');
|
|
162
|
+
await press('register-sex-female', 300);
|
|
163
|
+
await press('register-submit', 1500);
|
|
164
|
+
check('no errors', ['email', 'password', 'password2', 'name', 'sex'].some((f) => exists(`register-${f}-error`)), false);
|
|
165
|
+
check('register: no server', await toastSoon(), 'The server cannot be reached');
|
|
166
|
+
await press('header-back', 800);
|
|
167
|
+
// a new password
|
|
168
|
+
await press('login-forgot', 800);
|
|
169
|
+
check('the e-mail goes along', text('reset-email'), 'ada');
|
|
170
|
+
await press('reset-submit', 300);
|
|
171
|
+
check('code required', text('reset-code-error'), 'Required');
|
|
172
|
+
check('new password required', text('reset-password-error'), 'Required');
|
|
173
|
+
await press('header-back', 800);
|
|
174
|
+
await press('header-back', 800);
|
|
175
|
+
|
|
176
|
+
// the contact form
|
|
177
|
+
await press('mine-contact', 800);
|
|
178
|
+
await press('contact-send', 300);
|
|
179
|
+
check('name required', text('contact-name-error'), 'Required');
|
|
180
|
+
await type('contact-name', 'Ada');
|
|
181
|
+
await type('contact-email', 'ada@example.com');
|
|
182
|
+
await type('contact-subject', 'Hello');
|
|
183
|
+
await type('contact-message', 'A message 你好 😀');
|
|
184
|
+
check('message typed', text('contact-message'), 'A message 你好 😀');
|
|
185
|
+
await press('contact-send', 300);
|
|
186
|
+
check('contact: no server', await toastSoon(), 'The server cannot be reached');
|
|
187
|
+
await shot('9-contact');
|
|
188
|
+
await press('header-back', 800);
|
|
189
|
+
|
|
190
|
+
// settings: theme, language
|
|
191
|
+
await press('mine-settings', 800);
|
|
192
|
+
check('the page slid in', Math.round(act('page-settings', 'screenX')), left);
|
|
193
|
+
check('theme', text('settings-theme-value'), 'Light');
|
|
194
|
+
check('the server of the app', text('settings-server-value'), 'http://127.0.0.1:9');
|
|
195
|
+
await press('settings-theme');
|
|
196
|
+
await shot('10-theme-sheet');
|
|
197
|
+
await press('option-dark');
|
|
198
|
+
check('sheet closed', exists('sheet'), false);
|
|
199
|
+
check('dark', text('settings-theme-value'), 'Dark');
|
|
200
|
+
await shot('11-dark');
|
|
201
|
+
await press('settings-language');
|
|
202
|
+
await press('option-zh-CN');
|
|
203
|
+
check('Chinese', text('settings-language-value'), '简体中文');
|
|
204
|
+
check('Chinese: the theme', text('settings-theme-value'), '深色');
|
|
205
|
+
await shot('12-chinese');
|
|
206
|
+
await press('header-back', 800);
|
|
207
|
+
check('Chinese: guest', text('mine-name'), '游客');
|
|
208
|
+
await press('mine-settings', 800);
|
|
209
|
+
await press('settings-language');
|
|
210
|
+
await press('option-en');
|
|
211
|
+
await press('settings-theme');
|
|
212
|
+
await press('option-light');
|
|
213
|
+
check('back to English and light', `${text('settings-language-value')} ${text('settings-theme-value')}`, 'English Light');
|
|
214
|
+
await press('settings-about', 800);
|
|
215
|
+
check('about', exists('page-about'), true);
|
|
216
|
+
await press('header-back', 800);
|
|
217
|
+
await press('header-back', 800);
|
|
218
|
+
|
|
219
|
+
// a server (the fake): sign in, the session, favorites, profile, sign out
|
|
220
|
+
(globalThis as any).fetch = fakeFetch;
|
|
221
|
+
await press('mine-signin', 800);
|
|
222
|
+
await type('login-user', 'ada');
|
|
223
|
+
await type('login-password', 'wrong!');
|
|
224
|
+
await press('login-submit', 800);
|
|
225
|
+
check('the message of the API', toast(), 'Wrong user name or password');
|
|
226
|
+
check('the language of the API', sent[0]?.cookie, 'lang=en');
|
|
227
|
+
await press('header-back', 800);
|
|
228
|
+
await press('mine-signin', 800);
|
|
229
|
+
await type('login-user', 'ada');
|
|
230
|
+
await type('login-password', 'secret1');
|
|
231
|
+
await press('login-submit', 1200);
|
|
232
|
+
check('signed in', text('mine-name'), 'Ada');
|
|
233
|
+
check('the token is kept', storage.get('session'), TOKEN);
|
|
234
|
+
check('and sent as the cookie', sent.find((s) => s.path === '/api/user-info')?.cookie, `lang=en; _token=${encodeURIComponent(TOKEN)}`);
|
|
235
|
+
await shot('13-signed-in');
|
|
236
|
+
// the favorites of this user from an earlier run stay on the device
|
|
237
|
+
favorites.clear();
|
|
238
|
+
await press('tab-home');
|
|
239
|
+
await press('story-5', 800);
|
|
240
|
+
await press('story-favorite');
|
|
241
|
+
check('favorite', toast(), 'Added to your favorites');
|
|
242
|
+
await press('header-back', 800);
|
|
243
|
+
await press('tab-favorite');
|
|
244
|
+
check('in the favorites', exists('fav-5'), true);
|
|
245
|
+
await shot('14-favorites');
|
|
246
|
+
await press('tab-mine');
|
|
247
|
+
await press('mine-profile', 800);
|
|
248
|
+
check('profile: e-mail', text('profile-email-value'), 'ada@example.com');
|
|
249
|
+
check('profile: name', text('profile-nickname'), 'Ada');
|
|
250
|
+
await type('profile-password', '12345');
|
|
251
|
+
await type('profile-password2', '1');
|
|
252
|
+
await press('profile-save', 300);
|
|
253
|
+
check('profile: password length', text('profile-password-error'), 'At least 6 characters');
|
|
254
|
+
check('profile: passwords differ', text('profile-password2-error'), 'The two passwords differ');
|
|
255
|
+
await shot('15-profile');
|
|
256
|
+
await press('header-back', 800);
|
|
257
|
+
await press('mine-profile', 800);
|
|
258
|
+
await type('profile-password', '123456');
|
|
259
|
+
await type('profile-password2', '123456');
|
|
260
|
+
await press('profile-save', 1200);
|
|
261
|
+
check('profile: sent', JSON.stringify(sent[sent.length - 2]?.body), JSON.stringify({ nickname: 'Ada', password: '123456' }));
|
|
262
|
+
check('profile: saved', toast(), 'Profile updated');
|
|
263
|
+
await press('header-back', 800);
|
|
264
|
+
await press('mine-signout');
|
|
265
|
+
check('sign out?', text('dialog-text'), 'Sign out on this device?');
|
|
266
|
+
await shot('16-sign-out');
|
|
267
|
+
await press('dialog-ok', 800);
|
|
268
|
+
check('signed out', text('mine-name'), 'Guest');
|
|
269
|
+
check('told the API', sent[sent.length - 1]?.path, '/api/logout');
|
|
270
|
+
check('the token is gone', storage.get('session'), null);
|
|
271
|
+
check('a page of the user again', exists('mine-signout'), false);
|
|
272
|
+
(globalThis as any).fetch = realFetch;
|
|
273
|
+
console.log(`TEST RESULT ${failed ? 'FAILED' : 'PASSED'} ${passed} ok, ${failed} failed`);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
main().catch((e) => console.log(`TEST RESULT FAILED ${e && e.stack}`));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { onCleanup, serverRequest, View } from 'lupine.native.core';
|
|
2
|
+
import { router } from 'lupine.native.components';
|
|
3
|
+
import { runApp } from 'lupine.native.core/web';
|
|
4
|
+
import { App } from './app';
|
|
5
|
+
|
|
6
|
+
/** The app follows the address: the address bar shows its page (/story/3), and the buttons of the browser go back and forward in it. */
|
|
7
|
+
export const followAddress = () => router.followUrl();
|
|
8
|
+
|
|
9
|
+
/** The app as a page of the site (web/src/index.tsx: in the frame of a router); in the browser it follows the address. */
|
|
10
|
+
export const AppPage = () => {
|
|
11
|
+
if (!serverRequest()) onCleanup(followAddress());
|
|
12
|
+
return (
|
|
13
|
+
<View style={{ height: '100%' }}>
|
|
14
|
+
<App />
|
|
15
|
+
</View>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// The web version without the site: lupine-native web starts it in document.body. (The page of the site, web/src/index.tsx,
|
|
20
|
+
// has the app as a component.)
|
|
21
|
+
export const start = (container: HTMLElement) => {
|
|
22
|
+
const stop = followAddress();
|
|
23
|
+
const dispose = runApp(App, container);
|
|
24
|
+
return () => {
|
|
25
|
+
dispose();
|
|
26
|
+
stop();
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Platform, View } from 'lupine.native.core';
|
|
2
|
+
import { Button, col, EmptyView, Icon, router, Screen, T, tr } from 'lupine.native.components';
|
|
3
|
+
import * as icons from 'lupine.core/icons';
|
|
4
|
+
import { back } from '../shell/parts';
|
|
5
|
+
|
|
6
|
+
const edition = Platform.select({ ios: 'iOS', android: 'Android', macos: 'macOS', windows: 'Windows', web: 'Web' });
|
|
7
|
+
|
|
8
|
+
export const About = () => (
|
|
9
|
+
<Screen title={tr('nav.about', 'About')} onBack={back} testID='page-about'>
|
|
10
|
+
<View style={{ alignItems: 'center', padding: 32, gap: 12 }}>
|
|
11
|
+
<Icon name={icons.logo} size={64} color={col('primary')} />
|
|
12
|
+
<T kind='title'>{tr('app.name', 'Lupine Full-stack')}</T>
|
|
13
|
+
<T kind='secondary' style={{ textAlign: 'center' }}>{tr('about.tagline', 'The app on every platform, the admin pages on the web, one API')}</T>
|
|
14
|
+
<T style={{ textAlign: 'center', marginTop: 12 }}>{tr('about.text', 'Built with lupine.native (the app), lupine.web (the admin pages) and lupine.api (the server).')}</T>
|
|
15
|
+
<T kind='caption' testID='about-edition'>{`${edition} · ${APP_VERSION}`}</T>
|
|
16
|
+
</View>
|
|
17
|
+
</Screen>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export const NotFound = () => (
|
|
21
|
+
<Screen title='404' onBack={back} testID='page-not-found'>
|
|
22
|
+
<EmptyView icon={icons.search} title={tr('app.notFound', 'Page not found')} />
|
|
23
|
+
<View style={{ alignItems: 'center' }}>
|
|
24
|
+
<Button title={tr('nav.home', 'Stories')} kind='primary' onPress={() => router.navigate('/')} />
|
|
25
|
+
</View>
|
|
26
|
+
</Screen>
|
|
27
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createSignal, untrack, View } from 'lupine.native.core';
|
|
2
|
+
import { Button, createForm, rules, Screen, T, t, TextField, tr } from 'lupine.native.components';
|
|
3
|
+
import * as icons from 'lupine.core/icons';
|
|
4
|
+
import { api } from '../shell/api';
|
|
5
|
+
import { back, report } from '../shell/parts';
|
|
6
|
+
|
|
7
|
+
/** The contact form: to the address of the site (siteEmail of the admin's settings). The API takes five an hour from an address. */
|
|
8
|
+
export const Contact = () => {
|
|
9
|
+
const [busy, setBusy] = createSignal(false);
|
|
10
|
+
const user = untrack(api.user);
|
|
11
|
+
const form = createForm(
|
|
12
|
+
{ name: user?.nickname || '', email: user?.email || '', subject: '', message: '' },
|
|
13
|
+
{
|
|
14
|
+
name: rules.required(),
|
|
15
|
+
email: [rules.required(), rules.email(t('auth.emailInvalid', 'Enter a valid e-mail address'))],
|
|
16
|
+
subject: rules.required(),
|
|
17
|
+
message: [rules.required(), rules.max(5000)],
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
const send = async () => {
|
|
21
|
+
if (busy() || !form.validate()) return;
|
|
22
|
+
setBusy(true);
|
|
23
|
+
const v = form.values();
|
|
24
|
+
const answer = await api.contact({ name: v.name.trim(), email: v.email.trim(), subject: v.subject.trim(), message: v.message });
|
|
25
|
+
setBusy(false);
|
|
26
|
+
// empty again (the name and the e-mail of the user stay)
|
|
27
|
+
if (report(answer, t('contact.sent', 'Thank you, your message was sent'))) form.reset();
|
|
28
|
+
};
|
|
29
|
+
return (
|
|
30
|
+
<Screen title={tr('mine.contact', 'Contact us')} onBack={back} testID='page-contact'>
|
|
31
|
+
<View style={{ padding: 20, gap: 14, width: '100%', maxWidth: 520, alignSelf: 'center' }}>
|
|
32
|
+
<TextField label={tr('contact.name', 'Your name')} icon={icons.user} {...form.text('name')} testID='contact-name' />
|
|
33
|
+
<TextField label={tr('auth.email', 'E-mail')} icon={icons.mail} keyboardType='email' {...form.text('email')} testID='contact-email' />
|
|
34
|
+
<TextField label={tr('contact.subject', 'Subject')} {...form.text('subject')} testID='contact-subject' />
|
|
35
|
+
<TextField label={tr('contact.message', 'Message')} multiline style={{ height: 120, paddingVertical: 8 }} {...form.text('message')} testID='contact-message' />
|
|
36
|
+
<Button title={tr('contact.send', 'Send')} kind='primary' block loading={busy} onPress={send} icon={icons.mail} testID='contact-send' />
|
|
37
|
+
<T kind='caption' style={{ textAlign: 'center' }}>{tr('contact.hint', 'We answer by e-mail.')}</T>
|
|
38
|
+
</View>
|
|
39
|
+
</Screen>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { For, Show, View } from 'lupine.native.core';
|
|
2
|
+
import { Button, EmptyView, Header, router, Screen, tr } from 'lupine.native.components';
|
|
3
|
+
import * as icons from 'lupine.core/icons';
|
|
4
|
+
import { api } from '../shell/api';
|
|
5
|
+
import { SignInFirst, StoryRow } from '../shell/parts';
|
|
6
|
+
import { favorites } from '../shell/stories';
|
|
7
|
+
|
|
8
|
+
/** The favorites of the user (the heart on the page of a story). */
|
|
9
|
+
export const Favorite = () => (
|
|
10
|
+
<Screen header={<Header title={tr('nav.favorite', 'Favorites')} />} testID='page-favorite'>
|
|
11
|
+
<View style={{ padding: 16, gap: 10, width: '100%', maxWidth: 720, alignSelf: 'center' }}>
|
|
12
|
+
<Show when={api.user} fallback={<SignInFirst title={tr('favorite.signIn', 'Sign in to see your favorites')} testID='favorite-signin' />}>
|
|
13
|
+
<For
|
|
14
|
+
each={favorites.stories}
|
|
15
|
+
fallback={
|
|
16
|
+
<View style={{ alignItems: 'center', gap: 4 }}>
|
|
17
|
+
<EmptyView icon={icons.heart} title={tr('favorite.none', 'No favorites yet: the heart on a story keeps it here')} />
|
|
18
|
+
<Button title={tr('favorite.browse', 'Browse the stories')} kind='primary' onPress={() => router.navigate('/')} testID='favorite-browse' />
|
|
19
|
+
</View>
|
|
20
|
+
}
|
|
21
|
+
>
|
|
22
|
+
{(story) => <StoryRow story={story} testID={`fav-${story.id}`} />}
|
|
23
|
+
</For>
|
|
24
|
+
</Show>
|
|
25
|
+
</View>
|
|
26
|
+
</Screen>
|
|
27
|
+
);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createMemo, createSignal, For, media, Show, View } from 'lupine.native.core';
|
|
2
|
+
import { Button, Chips, EmptyView, Header, IconButton, router, Screen, SearchInput, T, t, tr } from 'lupine.native.components';
|
|
3
|
+
import * as icons from 'lupine.core/icons';
|
|
4
|
+
import { categories, searchStories } from '../shell/stories';
|
|
5
|
+
import { categoryName, StoryCard } from '../shell/parts';
|
|
6
|
+
|
|
7
|
+
const PAGE = 20;
|
|
8
|
+
|
|
9
|
+
/** The stories: search, categories, a grid; more at the end, pull to refresh. */
|
|
10
|
+
export const Home = () => {
|
|
11
|
+
const [text, setText] = createSignal('');
|
|
12
|
+
const [category, setCategory] = createSignal('all');
|
|
13
|
+
const [shown, setShown] = createSignal(PAGE);
|
|
14
|
+
const [refreshing, setRefreshing] = createSignal(false);
|
|
15
|
+
const found = createMemo(() => searchStories(text(), category()));
|
|
16
|
+
const visible = createMemo(() => found().slice(0, shown()));
|
|
17
|
+
// 2, 3 or 4 in a row; by css on the web, so the page of the server is right at once
|
|
18
|
+
const width = media<`${number}%`>({ base: '50%', mobileAbove: '33.33%', tabletAbove: '25%' });
|
|
19
|
+
const refresh = () => {
|
|
20
|
+
setRefreshing(true);
|
|
21
|
+
// a real app loads the list again here
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
setShown(PAGE);
|
|
24
|
+
setRefreshing(false);
|
|
25
|
+
}, 600);
|
|
26
|
+
};
|
|
27
|
+
return (
|
|
28
|
+
<Screen
|
|
29
|
+
header={<Header title={tr('app.name', 'Lupine Full-stack')} right={<IconButton name={icons.settings} onPress={() => router.push('/settings')} testID='home-settings' />} />}
|
|
30
|
+
refreshing={refreshing} onRefresh={refresh} testID='page-home'
|
|
31
|
+
>
|
|
32
|
+
<View style={{ padding: 16, gap: 12 }}>
|
|
33
|
+
<SearchInput
|
|
34
|
+
value={text} placeholder={tr('home.search', 'Search titles and authors')} testID='home-search'
|
|
35
|
+
onChangeText={(v) => {
|
|
36
|
+
setText(v);
|
|
37
|
+
setShown(PAGE);
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
<Chips
|
|
41
|
+
options={categories.map((c) => ({ label: () => categoryName(c), value: c }))} value={category} testID='home-cat'
|
|
42
|
+
onChange={(c) => {
|
|
43
|
+
setCategory(c);
|
|
44
|
+
setShown(PAGE);
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
<T kind='caption' testID='home-count'>{() => t('home.count', '{n} stories', { n: found().length })}</T>
|
|
48
|
+
<View style={{ flexDirection: 'row', flexWrap: 'wrap', marginHorizontal: -6 }}>
|
|
49
|
+
<For each={visible} fallback={<View style={{ width: '100%' }}><EmptyView icon={icons.search} title={tr('home.none', 'No stories found')} /></View>}>
|
|
50
|
+
{(story) => (
|
|
51
|
+
<View style={{ width, padding: 6 }}>
|
|
52
|
+
<StoryCard story={story} />
|
|
53
|
+
</View>
|
|
54
|
+
)}
|
|
55
|
+
</For>
|
|
56
|
+
</View>
|
|
57
|
+
<Show when={() => found().length > shown()}>
|
|
58
|
+
<Button title={tr('home.more', 'Show more')} onPress={() => setShown(shown() + PAGE)} testID='home-more' />
|
|
59
|
+
</Show>
|
|
60
|
+
</View>
|
|
61
|
+
</Screen>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createSignal, Show, View } from 'lupine.native.core';
|
|
2
|
+
import { Button, createForm, PasswordField, router, rules, Screen, SegmentedControl, T, t, TextField, Toast, tr } from 'lupine.native.components';
|
|
3
|
+
import * as icons from 'lupine.core/icons';
|
|
4
|
+
import { api } from '../shell/api';
|
|
5
|
+
import { back, CodeButton } from '../shell/parts';
|
|
6
|
+
|
|
7
|
+
type Mode = 'password' | 'code';
|
|
8
|
+
|
|
9
|
+
/** Sign in with the password, or with a code that the API sends by e-mail (which also activates a new account). */
|
|
10
|
+
export const Login = (p: { email?: string; mode?: string }) => {
|
|
11
|
+
const [mode, setMode] = createSignal<Mode>(p.mode === 'code' ? 'code' : 'password');
|
|
12
|
+
const [busy, setBusy] = createSignal(false);
|
|
13
|
+
const required = rules.required();
|
|
14
|
+
const form = createForm(
|
|
15
|
+
{ u: p.email || '', p: '', c: '' },
|
|
16
|
+
{
|
|
17
|
+
u: required,
|
|
18
|
+
p: (v) => mode() === 'password' && required(v),
|
|
19
|
+
c: (v) => mode() === 'code' && (required(v) || (!/^\d{6,}$/.test(v.trim()) && t('auth.codeInvalid', 'The code of the e-mail: digits only'))),
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
const submit = async () => {
|
|
23
|
+
if (busy() || !form.validate()) return;
|
|
24
|
+
setBusy(true);
|
|
25
|
+
const v = form.values();
|
|
26
|
+
const answer = mode() === 'password' ? await api.login(v.u.trim(), v.p) : await api.loginWithCode(v.u.trim(), v.c.trim());
|
|
27
|
+
setBusy(false);
|
|
28
|
+
if (answer.status === 'ok') {
|
|
29
|
+
Toast.success(t('auth.welcome', 'Welcome, {name}', { name: api.user()?.nickname || v.u }));
|
|
30
|
+
return back();
|
|
31
|
+
}
|
|
32
|
+
// a new account: the code of the e-mail activates it
|
|
33
|
+
if (answer.action === 'activate') {
|
|
34
|
+
setMode('code');
|
|
35
|
+
return Toast.info(t('auth.activate', 'Activate your account: send a code to your e-mail and sign in with it'));
|
|
36
|
+
}
|
|
37
|
+
Toast.error(answer.message || t('api.failed', 'Something went wrong'));
|
|
38
|
+
};
|
|
39
|
+
return (
|
|
40
|
+
<Screen title={tr('auth.signIn', 'Sign in')} onBack={back} testID='page-login'>
|
|
41
|
+
<View style={{ padding: 20, gap: 14, width: '100%', maxWidth: 420, alignSelf: 'center' }}>
|
|
42
|
+
<SegmentedControl
|
|
43
|
+
options={[{ label: tr('auth.withPassword', 'Password'), value: 'password' as Mode }, { label: tr('auth.withCode', 'Code by e-mail'), value: 'code' as Mode }]}
|
|
44
|
+
value={mode} onChange={setMode} testID='login-mode'
|
|
45
|
+
/>
|
|
46
|
+
<TextField label={tr('auth.user', 'E-mail or user name')} icon={icons.user} keyboardType='email' {...form.text('u')} testID='login-user' />
|
|
47
|
+
<Show when={() => mode() === 'password'}>
|
|
48
|
+
<PasswordField label={tr('auth.password', 'Password')} {...form.text('p')} onSubmit={submit} testID='login-password' />
|
|
49
|
+
</Show>
|
|
50
|
+
<Show when={() => mode() === 'code'}>
|
|
51
|
+
<CodeButton email={() => form.value('u').trim()} ready={() => !!form.value('u').trim()} onInvalid={() => form.set('u', form.value('u'))} testID='login-send-code' />
|
|
52
|
+
<TextField label={tr('auth.code', 'Code of the e-mail')} keyboardType='number' {...form.text('c')} onSubmit={submit} testID='login-code' />
|
|
53
|
+
</Show>
|
|
54
|
+
<Button title={tr('auth.signIn', 'Sign in')} kind='primary' block loading={busy} onPress={submit} testID='login-submit' />
|
|
55
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between', flexWrap: 'wrap', gap: 8 }}>
|
|
56
|
+
<Button title={tr('auth.forgot', 'Forgot the password?')} kind='ghost' size='small' onPress={() => router.push('/reset-password', { email: form.value('u').trim() })} testID='login-forgot' />
|
|
57
|
+
<Button title={tr('auth.noAccount', 'Create an account')} kind='ghost' size='small' onPress={() => router.push('/register')} testID='login-register' />
|
|
58
|
+
</View>
|
|
59
|
+
<T kind='caption' style={{ textAlign: 'center' }}>{tr('auth.adminHint', 'The admin of .env (ADMIN_USER) signs in here, too; the admin pages are on the web site (/admin).')}</T>
|
|
60
|
+
</View>
|
|
61
|
+
</Screen>
|
|
62
|
+
);
|
|
63
|
+
};
|