kasy-cli 1.2.1
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 +56 -0
- package/bin/kasy.js +529 -0
- package/docs/cli-reference.md +251 -0
- package/lib/commands/add.js +777 -0
- package/lib/commands/check.js +240 -0
- package/lib/commands/codemagic.js +161 -0
- package/lib/commands/deploy.js +257 -0
- package/lib/commands/docs.js +47 -0
- package/lib/commands/doctor.js +227 -0
- package/lib/commands/features.js +36 -0
- package/lib/commands/ios.js +206 -0
- package/lib/commands/new.js +1870 -0
- package/lib/commands/notifications.js +207 -0
- package/lib/commands/remove.js +466 -0
- package/lib/commands/run.js +75 -0
- package/lib/commands/update.js +382 -0
- package/lib/commands/validate.js +131 -0
- package/lib/scaffold/CHANGELOG.json +6 -0
- package/lib/scaffold/backends/api/.flutter-plugins-dependencies +1 -0
- package/lib/scaffold/backends/api/analysis_options.yaml +5 -0
- package/lib/scaffold/backends/api/generator.js +76 -0
- package/lib/scaffold/backends/api/patch/README.md +85 -0
- package/lib/scaffold/backends/api/patch/android/app/src/main/AndroidManifest.xml +87 -0
- package/lib/scaffold/backends/api/patch/ios/Runner/AppDelegate.swift +61 -0
- package/lib/scaffold/backends/api/patch/lib/core/data/api/meta_ads_api.dart +80 -0
- package/lib/scaffold/backends/api/patch/lib/core/data/api/storage_api.dart +117 -0
- package/lib/scaffold/backends/api/patch/lib/core/data/api/user_api.dart +148 -0
- package/lib/scaffold/backends/api/patch/lib/core/data/entities/json_converters.dart +35 -0
- package/lib/scaffold/backends/api/patch/lib/core/data/entities/user_entity.dart +48 -0
- package/lib/scaffold/backends/api/patch/lib/core/rating/widgets/review_popup.dart +211 -0
- package/lib/scaffold/backends/api/patch/lib/environnements.dart +151 -0
- package/lib/scaffold/backends/api/patch/lib/features/authentication/api/authentication_api.dart +303 -0
- package/lib/scaffold/backends/api/patch/lib/features/authentication/api/authentication_api_interface.dart +80 -0
- package/lib/scaffold/backends/api/patch/lib/features/authentication/repositories/authentication_repository.dart +406 -0
- package/lib/scaffold/backends/api/patch/lib/features/camera/xfile_extension.dart +6 -0
- package/lib/scaffold/backends/api/patch/lib/features/feedbacks/api/entities/feature_request_entity.dart +24 -0
- package/lib/scaffold/backends/api/patch/lib/features/feedbacks/api/entities/feature_vote_entity.dart +21 -0
- package/lib/scaffold/backends/api/patch/lib/features/feedbacks/api/feature_request_api.dart +52 -0
- package/lib/scaffold/backends/api/patch/lib/features/feedbacks/api/feature_vote_api.dart +60 -0
- package/lib/scaffold/backends/api/patch/lib/features/llm_chat/api/llm_chat_api.dart +58 -0
- package/lib/scaffold/backends/api/patch/lib/features/llm_chat/api/llm_chat_message_entity.dart +29 -0
- package/lib/scaffold/backends/api/patch/lib/features/notifications/api/device_api.dart +398 -0
- package/lib/scaffold/backends/api/patch/lib/features/notifications/api/entities/device_entity.dart +39 -0
- package/lib/scaffold/backends/api/patch/lib/features/notifications/api/entities/notifications_entity.dart +23 -0
- package/lib/scaffold/backends/api/patch/lib/features/notifications/api/notifications_api.dart +333 -0
- package/lib/scaffold/backends/api/patch/lib/features/notifications/providers/models/notification.dart +185 -0
- package/lib/scaffold/backends/api/patch/lib/features/onboarding/api/entities/user_info_entity.dart +26 -0
- package/lib/scaffold/backends/api/patch/lib/features/onboarding/api/user_infos_api.dart +107 -0
- package/lib/scaffold/backends/api/patch/lib/features/onboarding/models/user_info.dart +94 -0
- package/lib/scaffold/backends/api/patch/lib/features/onboarding/repositories/user_infos_repository.dart +29 -0
- package/lib/scaffold/backends/api/patch/lib/features/onboarding/ui/animations/movefade_anim.dart +34 -0
- package/lib/scaffold/backends/api/patch/lib/features/onboarding/ui/components/onboarding_att_setup.dart +66 -0
- package/lib/scaffold/backends/api/patch/lib/features/onboarding/ui/components/onboarding_notifications_setup.dart +73 -0
- package/lib/scaffold/backends/api/patch/lib/features/onboarding/ui/widgets/onboarding_radio_question.dart +173 -0
- package/lib/scaffold/backends/api/patch/lib/features/settings/ui/widgets/avatar_utils.dart +33 -0
- package/lib/scaffold/backends/api/patch/lib/features/subscription/api/entities/subscription_entity.dart +34 -0
- package/lib/scaffold/backends/api/patch/lib/features/subscription/api/subscription_api.dart +49 -0
- package/lib/scaffold/backends/api/patch/lib/features/subscription/shared/maybeshow_premium.dart +88 -0
- package/lib/scaffold/backends/api/patch/lib/main.dart +256 -0
- package/lib/scaffold/backends/api/patch/lib/router.dart +133 -0
- package/lib/scaffold/backends/api/pubspec.yaml.tpl +108 -0
- package/lib/scaffold/backends/firebase/deploy.js +1006 -0
- package/lib/scaffold/backends/firebase/generator.js +24 -0
- package/lib/scaffold/backends/firebase/setup-from-scratch.js +1008 -0
- package/lib/scaffold/backends/firebase/tokens.js +113 -0
- package/lib/scaffold/backends/supabase/.flutter-plugins-dependencies +1 -0
- package/lib/scaffold/backends/supabase/analysis_options.yaml +5 -0
- package/lib/scaffold/backends/supabase/config.toml +34 -0
- package/lib/scaffold/backends/supabase/deploy.js +485 -0
- package/lib/scaffold/backends/supabase/edge-functions/delete-user-account/README.md +15 -0
- package/lib/scaffold/backends/supabase/edge-functions/delete-user-account/index.ts +97 -0
- package/lib/scaffold/backends/supabase/edge-functions/llm-chat/index.ts +156 -0
- package/lib/scaffold/backends/supabase/edge-functions/meta-track-event/index.ts +292 -0
- package/lib/scaffold/backends/supabase/edge-functions/revenuecat-webhook/README.md +30 -0
- package/lib/scaffold/backends/supabase/edge-functions/revenuecat-webhook/index.ts +488 -0
- package/lib/scaffold/backends/supabase/edge-functions/send-push-notification/README.md +35 -0
- package/lib/scaffold/backends/supabase/edge-functions/send-push-notification/index.ts +314 -0
- package/lib/scaffold/backends/supabase/generator.js +108 -0
- package/lib/scaffold/backends/supabase/migrations/20240101000001_initial_schema.sql +149 -0
- package/lib/scaffold/backends/supabase/migrations/20240101000002_storage_bucket.sql +40 -0
- package/lib/scaffold/backends/supabase/migrations/20240101000005_vote_triggers.sql +34 -0
- package/lib/scaffold/backends/supabase/migrations/20240101000006_notification_webhook.sql +36 -0
- package/lib/scaffold/backends/supabase/migrations/20240101000007_welcome_notification.sql +64 -0
- package/lib/scaffold/backends/supabase/migrations/20240101000008_user_feature_requests.sql +2 -0
- package/lib/scaffold/backends/supabase/migrations/20240101000009_llm_messages.sql +22 -0
- package/lib/scaffold/backends/supabase/migrations/20240101000010_notification_image.sql +2 -0
- package/lib/scaffold/backends/supabase/patch/README.md +121 -0
- package/lib/scaffold/backends/supabase/patch/android/app/src/main/AndroidManifest.xml +87 -0
- package/lib/scaffold/backends/supabase/patch/ios/Runner/AppDelegate.swift +61 -0
- package/lib/scaffold/backends/supabase/patch/lib/core/data/api/meta_ads_api.dart +75 -0
- package/lib/scaffold/backends/supabase/patch/lib/core/data/api/storage_api.dart +83 -0
- package/lib/scaffold/backends/supabase/patch/lib/core/data/api/user_api.dart +143 -0
- package/lib/scaffold/backends/supabase/patch/lib/core/data/entities/json_converters.dart +35 -0
- package/lib/scaffold/backends/supabase/patch/lib/core/data/entities/user_entity.dart +48 -0
- package/lib/scaffold/backends/supabase/patch/lib/core/rating/widgets/review_popup.dart +211 -0
- package/lib/scaffold/backends/supabase/patch/lib/environnements.dart +149 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/authentication/api/authentication_api.dart +546 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/authentication/repositories/authentication_repository.dart +410 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/camera/xfile_extension.dart +6 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/feedbacks/api/entities/feature_request_entity.dart +25 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/feedbacks/api/entities/feature_vote_entity.dart +21 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/feedbacks/api/feature_request_api.dart +59 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/feedbacks/api/feature_vote_api.dart +85 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/feedbacks/ui/component/add_feature_form.dart +199 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/llm_chat/api/llm_chat_api.dart +47 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/llm_chat/api/llm_chat_message_entity.dart +30 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/llm_chat/providers/llm_chat_notifier.dart +266 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/notifications/api/device_api.dart +410 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/notifications/api/entities/device_entity.dart +51 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/notifications/api/entities/notifications_entity.dart +26 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/notifications/api/notifications_api.dart +317 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/notifications/providers/models/notification.dart +174 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/onboarding/api/entities/user_info_entity.dart +26 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/onboarding/api/user_infos_api.dart +90 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/onboarding/models/user_info.dart +94 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/onboarding/repositories/user_infos_repository.dart +29 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/onboarding/ui/animations/movefade_anim.dart +34 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/onboarding/ui/components/onboarding_att_setup.dart +66 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/onboarding/ui/components/onboarding_notifications_setup.dart +73 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/onboarding/ui/widgets/onboarding_radio_question.dart +173 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/settings/ui/widgets/avatar_utils.dart +35 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/subscription/api/entities/subscription_entity.dart +35 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/subscription/api/subscription_api.dart +44 -0
- package/lib/scaffold/backends/supabase/patch/lib/features/subscription/shared/maybeshow_premium.dart +85 -0
- package/lib/scaffold/backends/supabase/patch/lib/google_auth_options.dart +23 -0
- package/lib/scaffold/backends/supabase/patch/lib/main.dart +288 -0
- package/lib/scaffold/backends/supabase/patch/lib/router.dart +133 -0
- package/lib/scaffold/backends/supabase/pubspec.yaml.tpl +110 -0
- package/lib/scaffold/backends/supabase/tokens.js +9 -0
- package/lib/scaffold/catalog.js +177 -0
- package/lib/scaffold/engine.js +230 -0
- package/lib/scaffold/features/README.md +152 -0
- package/lib/scaffold/features/analytics/lib/core/data/api/analytics_api.dart +124 -0
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/BUG.es.md +35 -0
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/BUG.md +35 -0
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/BUG.pt.md +35 -0
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/feature_request.es.md +12 -0
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/feature_request.md +12 -0
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/feature_request.pt.md +12 -0
- package/lib/scaffold/features/ci/.github/PULL_REQUEST_TEMPLATE.es.md +17 -0
- package/lib/scaffold/features/ci/.github/PULL_REQUEST_TEMPLATE.md +17 -0
- package/lib/scaffold/features/ci/.github/PULL_REQUEST_TEMPLATE.pt.md +17 -0
- package/lib/scaffold/features/ci/.github/dependabot.yml +16 -0
- package/lib/scaffold/features/ci/.github/workflows/app.yml +20 -0
- package/lib/scaffold/features/ci/.gitlab/templates/deploy.yaml +14 -0
- package/lib/scaffold/features/ci/.gitlab/templates/dropbox.yaml +19 -0
- package/lib/scaffold/features/ci/.gitlab/templates/flutter.yaml +163 -0
- package/lib/scaffold/features/ci/.gitlab/templates/mailgun.yaml +28 -0
- package/lib/scaffold/features/ci/.gitlab-ci.yml +37 -0
- package/lib/scaffold/features/ci/codemagic.yaml +157 -0
- package/lib/scaffold/features/facebook/lib/core/data/api/tracking_api.dart +111 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/api/entities/feature_request_entity.dart +27 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/api/entities/feature_vote_entity.dart +27 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/api/feature_request_api.dart +50 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/api/feature_vote_api.dart +79 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/models/feature_requests.dart +48 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/models/feedback_state.dart +42 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/providers/feedback_page_notifier.dart +147 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/repositories/feature_request_repository.dart +95 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/ui/component/add_feature_form.dart +199 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/ui/feedback_page.dart +175 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/ui/widgets/add_feature_button.dart +76 -0
- package/lib/scaffold/features/feedback/lib/features/feedbacks/ui/widgets/feature_card.dart +279 -0
- package/lib/scaffold/features/ios-release/.kasy/apple.env.example +8 -0
- package/lib/scaffold/features/ios-release/.kasy/codemagic.env.example +7 -0
- package/lib/scaffold/features/ios-release/docs/codemagic-release.en.md +50 -0
- package/lib/scaffold/features/ios-release/docs/codemagic-release.es.md +50 -0
- package/lib/scaffold/features/ios-release/docs/codemagic-release.pt.md +50 -0
- package/lib/scaffold/features/ios-release/docs/ios-release.en.md +41 -0
- package/lib/scaffold/features/ios-release/docs/ios-release.es.md +41 -0
- package/lib/scaffold/features/ios-release/docs/ios-release.pt.md +41 -0
- package/lib/scaffold/features/ios-release/scripts/bump-ios-version.js +38 -0
- package/lib/scaffold/features/ios-release/scripts/release-ios.sh +137 -0
- package/lib/scaffold/features/llm_chat/lib/features/llm_chat/llm_chat_page.dart +301 -0
- package/lib/scaffold/features/local_notifications/lib/features/local_reminder/providers/reminder_notifier.dart +81 -0
- package/lib/scaffold/features/local_notifications/lib/features/local_reminder/repositories/reminder_preferences.dart +76 -0
- package/lib/scaffold/features/local_notifications/lib/features/local_reminder/ui/reminder_page.dart +282 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/api/entities/user_info_entity.dart +24 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/api/user_infos_api.dart +71 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/models/user_info.dart +92 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/providers/onboarding_model.dart +15 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/providers/onboarding_provider.dart +78 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/repositories/user_infos_repository.dart +29 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/animations/page_transitions.dart +30 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/components/onboarding_att_setup.dart +66 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/components/onboarding_features.dart +72 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/components/onboarding_loader.dart +92 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/components/onboarding_notifications_setup.dart +73 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/components/onboarding_questions.dart +89 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/onboarding_page.dart +94 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_background.dart +80 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_feature.dart +139 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_illustration_scaffold.dart +110 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_progress.dart +84 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_radio_question.dart +173 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_reassurance.dart +45 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_sticky_footer.dart +77 -0
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/selectable_row_tile.dart +392 -0
- package/lib/scaffold/features/revenuecat/lib/core/data/api/tracking_api.dart +116 -0
- package/lib/scaffold/features/revenuecat/lib/core/data/models/subscription.dart +322 -0
- package/lib/scaffold/features/revenuecat/lib/core/home_widgets/home_widget_background_task.dart +41 -0
- package/lib/scaffold/features/revenuecat/lib/core/states/user_state_notifier.dart +305 -0
- package/lib/scaffold/features/widget/lib/core/home_widgets/home_widget_background_task.dart +41 -0
- package/lib/scaffold/features/widget/lib/core/home_widgets/home_widget_mywidget_service.dart +57 -0
- package/lib/scaffold/features/widget/lib/core/home_widgets/home_widget_service.dart +54 -0
- package/lib/scaffold/features/widget/lib/features/settings/ui/components/admin/admin_home_widgets.dart +32 -0
- package/lib/scaffold/generate.js +370 -0
- package/lib/scaffold/patch.js +395 -0
- package/lib/scaffold/shared/backend-config.js +74 -0
- package/lib/scaffold/shared/fcm-service-account.js +126 -0
- package/lib/scaffold/shared/generator-utils.js +1664 -0
- package/lib/scaffold/shared/post-build.js +809 -0
- package/lib/scaffold/shared/template-strings.js +112 -0
- package/lib/utils/apple-release.js +273 -0
- package/lib/utils/checks.js +319 -0
- package/lib/utils/codemagic-release.js +127 -0
- package/lib/utils/fs.js +122 -0
- package/lib/utils/i18n.js +2123 -0
- package/lib/utils/license-gate.js +72 -0
- package/lib/utils/license.js +64 -0
- package/lib/utils/prompts.js +213 -0
- package/lib/utils/updates.js +97 -0
- package/package.json +55 -0
- package/templates/firebase/.env.example +24 -0
- package/templates/firebase/.firebaserc +5 -0
- package/templates/firebase/.kasy/apple.env.example +8 -0
- package/templates/firebase/.kasy/codemagic.env.example +7 -0
- package/templates/firebase/.metadata +30 -0
- package/templates/firebase/.windsurfrules +95 -0
- package/templates/firebase/Makefile +30 -0
- package/templates/firebase/README.en.md +180 -0
- package/templates/firebase/README.es.md +180 -0
- package/templates/firebase/README.md +180 -0
- package/templates/firebase/analysis_options.yaml +37 -0
- package/templates/firebase/android/app/build.gradle.kts +80 -0
- package/templates/firebase/android/app/src/debug/AndroidManifest.xml +7 -0
- package/templates/firebase/android/app/src/main/AndroidManifest.xml +93 -0
- package/templates/firebase/android/app/src/main/kotlin/com/aicrus/firebase/kit/MainActivity.kt +36 -0
- package/templates/firebase/android/app/src/main/kotlin/com/aicrus/firebase/kit/MyWidget.kt +50 -0
- package/templates/firebase/android/app/src/main/kotlin/com/aicrus/firebase/kit/MyWidgetReceiver.kt +7 -0
- package/templates/firebase/android/app/src/main/res/drawable/background.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable/launch_background.xml +9 -0
- package/templates/firebase/android/app/src/main/res/drawable-hdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-mdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-v21/background.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-v21/launch_background.xml +9 -0
- package/templates/firebase/android/app/src/main/res/drawable-xhdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-xxhdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-xxxhdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/templates/firebase/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/templates/firebase/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/templates/firebase/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/templates/firebase/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/templates/firebase/android/app/src/main/res/values/strings.xml +6 -0
- package/templates/firebase/android/app/src/main/res/values/styles.xml +22 -0
- package/templates/firebase/android/app/src/main/res/values-night/styles.xml +22 -0
- package/templates/firebase/android/app/src/main/res/values-night-v31/styles.xml +20 -0
- package/templates/firebase/android/app/src/main/res/values-v31/styles.xml +20 -0
- package/templates/firebase/android/app/src/main/res/xml/locales_config.xml +7 -0
- package/templates/firebase/android/app/src/main/res/xml/mywidget_info.xml +11 -0
- package/templates/firebase/android/app/src/profile/AndroidManifest.xml +7 -0
- package/templates/firebase/android/build.gradle.kts +28 -0
- package/templates/firebase/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/templates/firebase/android/gradle.properties +2 -0
- package/templates/firebase/android/settings.gradle.kts +29 -0
- package/templates/firebase/assets/icons/apple.png +0 -0
- package/templates/firebase/assets/icons/facebook.png +0 -0
- package/templates/firebase/assets/icons/google.png +0 -0
- package/templates/firebase/assets/icons/google_play_games.png +0 -0
- package/templates/firebase/assets/images/app_icon.png +0 -0
- package/templates/firebase/assets/images/empty_notifications.jpg +0 -0
- package/templates/firebase/assets/images/icon.png +0 -0
- package/templates/firebase/assets/images/onboarding/authentication-login-template.jpg +0 -0
- package/templates/firebase/assets/images/onboarding/img1.jpg +0 -0
- package/templates/firebase/assets/images/onboarding/img2.jpg +0 -0
- package/templates/firebase/assets/images/onboarding/img3.jpg +0 -0
- package/templates/firebase/assets/images/onboarding/notifications.png +0 -0
- package/templates/firebase/assets/images/onboarding/onboarding.png +0 -0
- package/templates/firebase/assets/images/onboarding/purchase.png +0 -0
- package/templates/firebase/assets/images/premium-bg.jpg +0 -0
- package/templates/firebase/assets/images/premium-switch-header.png +0 -0
- package/templates/firebase/assets/images/review.png +0 -0
- package/templates/firebase/assets/images/splashscreen.png +0 -0
- package/templates/firebase/assets/images/update.png +0 -0
- package/templates/firebase/build.yaml +13 -0
- package/templates/firebase/devtools_options.yaml +3 -0
- package/templates/firebase/docs/auth-setup.en.md +145 -0
- package/templates/firebase/docs/auth-setup.es.md +145 -0
- package/templates/firebase/docs/auth-setup.pt.md +145 -0
- package/templates/firebase/docs/codemagic-release.en.md +50 -0
- package/templates/firebase/docs/codemagic-release.es.md +50 -0
- package/templates/firebase/docs/codemagic-release.pt.md +50 -0
- package/templates/firebase/docs/ios-release.en.md +41 -0
- package/templates/firebase/docs/ios-release.es.md +41 -0
- package/templates/firebase/docs/ios-release.pt.md +54 -0
- package/templates/firebase/docs/navigation-transitions.md +80 -0
- package/templates/firebase/docs/revenuecat-setup.es.md +341 -0
- package/templates/firebase/docs/revenuecat-setup.pt.md +341 -0
- package/templates/firebase/firebase.json +1 -0
- package/templates/firebase/firestore.indexes.json +25 -0
- package/templates/firebase/firestore.rules +51 -0
- package/templates/firebase/functions/.eslintrc.js +45 -0
- package/templates/firebase/functions/jest.config.js +16 -0
- package/templates/firebase/functions/package-lock.json +6876 -0
- package/templates/firebase/functions/package.json +33 -0
- package/templates/firebase/functions/src/authentication/functions.ts +30 -0
- package/templates/firebase/functions/src/authentication/triggers.ts +103 -0
- package/templates/firebase/functions/src/core/api/meta_ads_api.ts +390 -0
- package/templates/firebase/functions/src/core/data/entities/entity_utils.ts +87 -0
- package/templates/firebase/functions/src/core/data/entities/notification_entity.ts +74 -0
- package/templates/firebase/functions/src/core/data/entities/page.ts +4 -0
- package/templates/firebase/functions/src/core/data/entities/subscription_entity.ts +76 -0
- package/templates/firebase/functions/src/core/data/entities/user_device_entity.ts +64 -0
- package/templates/firebase/functions/src/core/data/entities/user_entity.ts +43 -0
- package/templates/firebase/functions/src/core/data/repositories/repositories.ts +16 -0
- package/templates/firebase/functions/src/core/data/repositories/subscription_repository.ts +42 -0
- package/templates/firebase/functions/src/core/data/repositories/user_device_repository.ts +31 -0
- package/templates/firebase/functions/src/core/data/repositories/user_notifications_repository.ts +58 -0
- package/templates/firebase/functions/src/core/data/repositories/user_repository.ts +84 -0
- package/templates/firebase/functions/src/core/logger/logger.ts +13 -0
- package/templates/firebase/functions/src/core/storage/storage_manager.ts +52 -0
- package/templates/firebase/functions/src/core/utils/async_utils.ts +5 -0
- package/templates/firebase/functions/src/feature_requests/triggers.ts +3 -0
- package/templates/firebase/functions/src/index.ts +24 -0
- package/templates/firebase/functions/src/llm_chat/index.ts +181 -0
- package/templates/firebase/functions/src/notifications/admin_functions.ts +91 -0
- package/templates/firebase/functions/src/notifications/models/notification.ts +61 -0
- package/templates/firebase/functions/src/notifications/notifications_api.ts +147 -0
- package/templates/firebase/functions/src/notifications/triggers.ts +102 -0
- package/templates/firebase/functions/src/subscriptions/models/revenuecat_events.ts +162 -0
- package/templates/firebase/functions/src/subscriptions/models/subscription_status.ts +18 -0
- package/templates/firebase/functions/src/subscriptions/models/subscriptions.ts +173 -0
- package/templates/firebase/functions/src/subscriptions/subscriptions_functions.ts +135 -0
- package/templates/firebase/functions/src/subscriptions/triggers.ts +35 -0
- package/templates/firebase/functions/src/test/core/data/entities/entity_utils.spec.ts +44 -0
- package/templates/firebase/functions/tsconfig.dev.json +5 -0
- package/templates/firebase/functions/tsconfig.json +18 -0
- package/templates/firebase/home_widget_config.json +30 -0
- package/templates/firebase/ios/Flutter/AppFrameworkInfo.plist +24 -0
- package/templates/firebase/ios/Flutter/Debug.xcconfig +2 -0
- package/templates/firebase/ios/Flutter/Profile.xcconfig +2 -0
- package/templates/firebase/ios/Flutter/Release.xcconfig +2 -0
- package/templates/firebase/ios/HomeWidgetExtension/HomeWidgetBundle.swift +13 -0
- package/templates/firebase/ios/HomeWidgetExtension/Info.plist +29 -0
- package/templates/firebase/ios/HomeWidgetExtension/MyWidget.swift +86 -0
- package/templates/firebase/ios/HomeWidgetExtension.entitlements +10 -0
- package/templates/firebase/ios/NotificationService/Info.plist +31 -0
- package/templates/firebase/ios/NotificationService/NotificationService.swift +76 -0
- package/templates/firebase/ios/Podfile +111 -0
- package/templates/firebase/ios/Runner/AppDelegate.swift +75 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +1 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchBackground.imageset/Contents.json +21 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchBackground.imageset/background.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +23 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md +5 -0
- package/templates/firebase/ios/Runner/Base.lproj/LaunchScreen.storyboard +44 -0
- package/templates/firebase/ios/Runner/Base.lproj/Main.storyboard +26 -0
- package/templates/firebase/ios/Runner/Info.plist +132 -0
- package/templates/firebase/ios/Runner/Runner-Bridging-Header.h +1 -0
- package/templates/firebase/ios/Runner/Runner.entitlements +14 -0
- package/templates/firebase/ios/Runner/es.lproj/InfoPlist.strings +10 -0
- package/templates/firebase/ios/Runner/pt-BR.lproj/InfoPlist.strings +10 -0
- package/templates/firebase/ios/Runner/pt.lproj/InfoPlist.strings +10 -0
- package/templates/firebase/ios/Runner.xcodeproj/project.pbxproj +1108 -0
- package/templates/firebase/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/templates/firebase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/templates/firebase/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/templates/firebase/ios/Runner.xcodeproj/xcshareddata/xcschemes/NotificationService.xcscheme +58 -0
- package/templates/firebase/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +101 -0
- package/templates/firebase/ios/Runner.xcworkspace/contents.xcworkspacedata +10 -0
- package/templates/firebase/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/templates/firebase/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/templates/firebase/ios/RunnerTests/RunnerTests.swift +12 -0
- package/templates/firebase/lib/components/components.dart +27 -0
- package/templates/firebase/lib/components/kasy_accordion.dart +384 -0
- package/templates/firebase/lib/components/kasy_alert.dart +266 -0
- package/templates/firebase/lib/components/kasy_app_bar.dart +536 -0
- package/templates/firebase/lib/components/kasy_avatar.dart +549 -0
- package/templates/firebase/lib/components/kasy_avatar_presets.dart +104 -0
- package/templates/firebase/lib/components/kasy_badge.dart +278 -0
- package/templates/firebase/lib/components/kasy_bottom_sheet.dart +338 -0
- package/templates/firebase/lib/components/kasy_button.dart +926 -0
- package/templates/firebase/lib/components/kasy_card.dart +128 -0
- package/templates/firebase/lib/components/kasy_checkbox.dart +429 -0
- package/templates/firebase/lib/components/kasy_chip.dart +83 -0
- package/templates/firebase/lib/components/kasy_dialog.dart +789 -0
- package/templates/firebase/lib/components/kasy_otp_verification_bottom_sheet.dart +233 -0
- package/templates/firebase/lib/components/kasy_skeleton.dart +225 -0
- package/templates/firebase/lib/components/kasy_text_area.dart +392 -0
- package/templates/firebase/lib/components/kasy_text_field.dart +591 -0
- package/templates/firebase/lib/components/kasy_text_field_otp.dart +532 -0
- package/templates/firebase/lib/components/kasy_toast.dart +803 -0
- package/templates/firebase/lib/core/ads/ads_provider.dart +136 -0
- package/templates/firebase/lib/core/ads/ads_state.dart +15 -0
- package/templates/firebase/lib/core/animations/bottomfade_anim.dart +37 -0
- package/templates/firebase/lib/core/animations/movefade_anim.dart +34 -0
- package/templates/firebase/lib/core/animations/slideright_anim.dart +38 -0
- package/templates/firebase/lib/core/bottom_menu/bart_inner_paths.dart +5 -0
- package/templates/firebase/lib/core/bottom_menu/bottom_menu.dart +127 -0
- package/templates/firebase/lib/core/bottom_menu/bottom_router.dart +281 -0
- package/templates/firebase/lib/core/bottom_menu/kasy_bart_navigation.dart +22 -0
- package/templates/firebase/lib/core/bottom_menu/kasy_bottom_bar_factory.dart +127 -0
- package/templates/firebase/lib/core/bottom_menu/notification_bottom_item.dart +48 -0
- package/templates/firebase/lib/core/config/app_env.dart +100 -0
- package/templates/firebase/lib/core/config/features.dart +15 -0
- package/templates/firebase/lib/core/data/api/analytics_api.dart +124 -0
- package/templates/firebase/lib/core/data/api/base_api_exceptions.dart +28 -0
- package/templates/firebase/lib/core/data/api/firestore_retry.dart +29 -0
- package/templates/firebase/lib/core/data/api/http_client.dart +38 -0
- package/templates/firebase/lib/core/data/api/image.dart +52 -0
- package/templates/firebase/lib/core/data/api/remote_config_api.dart +170 -0
- package/templates/firebase/lib/core/data/api/storage_api.dart +115 -0
- package/templates/firebase/lib/core/data/api/tracking_api.dart +119 -0
- package/templates/firebase/lib/core/data/api/user_api.dart +115 -0
- package/templates/firebase/lib/core/data/entities/json_converters.dart +39 -0
- package/templates/firebase/lib/core/data/entities/upload_result.dart +48 -0
- package/templates/firebase/lib/core/data/entities/user_entity.dart +54 -0
- package/templates/firebase/lib/core/data/models/pageable.dart +12 -0
- package/templates/firebase/lib/core/data/models/subscription.dart +322 -0
- package/templates/firebase/lib/core/data/models/user.dart +107 -0
- package/templates/firebase/lib/core/data/repositories/user_repository.dart +130 -0
- package/templates/firebase/lib/core/dev_inspector/dev_inspector.dart +464 -0
- package/templates/firebase/lib/core/dev_inspector/dev_inspector_highlight.dart +88 -0
- package/templates/firebase/lib/core/dev_inspector/dev_inspector_info.dart +70 -0
- package/templates/firebase/lib/core/dev_inspector/dev_inspector_panel.dart +204 -0
- package/templates/firebase/lib/core/dev_inspector/dev_inspector_service.dart +321 -0
- package/templates/firebase/lib/core/extensions/date.ext.dart +32 -0
- package/templates/firebase/lib/core/guards/authenticated_guard.dart +37 -0
- package/templates/firebase/lib/core/guards/guard.dart +68 -0
- package/templates/firebase/lib/core/guards/user_info_guard.dart +55 -0
- package/templates/firebase/lib/core/haptics/haptic_feedback_notifier.dart +19 -0
- package/templates/firebase/lib/core/haptics/kasy_haptics.dart +27 -0
- package/templates/firebase/lib/core/home_widgets/home_widget_background_task.dart +41 -0
- package/templates/firebase/lib/core/home_widgets/home_widget_mywidget_service.dart +57 -0
- package/templates/firebase/lib/core/home_widgets/home_widget_service.dart +54 -0
- package/templates/firebase/lib/core/icons/kasy_icons.dart +86 -0
- package/templates/firebase/lib/core/initializer/models/run_state.dart +14 -0
- package/templates/firebase/lib/core/initializer/onstart_service.dart +38 -0
- package/templates/firebase/lib/core/initializer/onstart_widget.dart +83 -0
- package/templates/firebase/lib/core/initializer/pending_notification_handler.dart +48 -0
- package/templates/firebase/lib/core/keyboard_fix/keyboard_flicker_fix.dart +164 -0
- package/templates/firebase/lib/core/navigation/kasy_fade_page_transitions_builder.dart +34 -0
- package/templates/firebase/lib/core/navigation/kasy_material_page_route.dart +41 -0
- package/templates/firebase/lib/core/navigation/kasy_navigation_config.dart +29 -0
- package/templates/firebase/lib/core/navigation/kasy_page_transition.dart +40 -0
- package/templates/firebase/lib/core/navigation/kasy_route_transition.dart +68 -0
- package/templates/firebase/lib/core/navigation/kasy_transition_kind.dart +17 -0
- package/templates/firebase/lib/core/navigation/navigation.dart +6 -0
- package/templates/firebase/lib/core/rating/api/rating_api.dart +99 -0
- package/templates/firebase/lib/core/rating/models/rating.dart +52 -0
- package/templates/firebase/lib/core/rating/models/review.dart +70 -0
- package/templates/firebase/lib/core/rating/providers/rating_repository.dart +75 -0
- package/templates/firebase/lib/core/rating/widgets/rate_banner.dart +190 -0
- package/templates/firebase/lib/core/rating/widgets/rate_popup.dart +54 -0
- package/templates/firebase/lib/core/rating/widgets/review_popup.dart +175 -0
- package/templates/firebase/lib/core/security/biometric_copy_slot.dart +20 -0
- package/templates/firebase/lib/core/security/biometric_guard.dart +114 -0
- package/templates/firebase/lib/core/security/biometric_preference_notifier.dart +17 -0
- package/templates/firebase/lib/core/security/biometric_service.dart +79 -0
- package/templates/firebase/lib/core/security/biometric_ui_bundle.dart +136 -0
- package/templates/firebase/lib/core/security/secured_storage.dart +46 -0
- package/templates/firebase/lib/core/shared_preferences/shared_preferences.dart +70 -0
- package/templates/firebase/lib/core/sidebar/kasy_sidebar.dart +2021 -0
- package/templates/firebase/lib/core/states/components/maybe_ask_biometric_setup.dart +88 -0
- package/templates/firebase/lib/core/states/components/maybe_ask_rating.dart +49 -0
- package/templates/firebase/lib/core/states/components/maybe_show_update_bottom_sheet.dart +86 -0
- package/templates/firebase/lib/core/states/components/maybeshow_component.dart +110 -0
- package/templates/firebase/lib/core/states/events_dispatcher.dart +103 -0
- package/templates/firebase/lib/core/states/models/event_model.dart +118 -0
- package/templates/firebase/lib/core/states/models/user_state.dart +22 -0
- package/templates/firebase/lib/core/states/notifications_dispatcher.dart +81 -0
- package/templates/firebase/lib/core/states/translations.dart +11 -0
- package/templates/firebase/lib/core/states/user_state_notifier.dart +321 -0
- package/templates/firebase/lib/core/theme/colors.dart +262 -0
- package/templates/firebase/lib/core/theme/extensions/theme_extension.dart +48 -0
- package/templates/firebase/lib/core/theme/providers/kasy_theme.dart +76 -0
- package/templates/firebase/lib/core/theme/providers/theme_provider.dart +212 -0
- package/templates/firebase/lib/core/theme/radius.dart +33 -0
- package/templates/firebase/lib/core/theme/shadows.dart +64 -0
- package/templates/firebase/lib/core/theme/spacing.dart +44 -0
- package/templates/firebase/lib/core/theme/texts.dart +176 -0
- package/templates/firebase/lib/core/theme/theme.dart +24 -0
- package/templates/firebase/lib/core/theme/theme_data/theme_data.dart +32 -0
- package/templates/firebase/lib/core/theme/theme_data/theme_data_factory.dart +15 -0
- package/templates/firebase/lib/core/theme/universal_theme.dart +210 -0
- package/templates/firebase/lib/core/toast/toast_service.dart +55 -0
- package/templates/firebase/lib/core/ui/app_dialog.dart +26 -0
- package/templates/firebase/lib/core/web_device_preview/web_device_preview.dart +1126 -0
- package/templates/firebase/lib/core/widgets/debouncer.dart +31 -0
- package/templates/firebase/lib/core/widgets/kasy_hover.dart +166 -0
- package/templates/firebase/lib/core/widgets/kasy_pressable.dart +2 -0
- package/templates/firebase/lib/core/widgets/kasy_pressable_depth.dart +161 -0
- package/templates/firebase/lib/core/widgets/kasy_scroll_behavior.dart +17 -0
- package/templates/firebase/lib/core/widgets/keyboard_visibility.dart +75 -0
- package/templates/firebase/lib/core/widgets/page_background.dart +71 -0
- package/templates/firebase/lib/core/widgets/page_not_found.dart +15 -0
- package/templates/firebase/lib/core/widgets/responsive_layout.dart +215 -0
- package/templates/firebase/lib/core/widgets/update_bottom_sheet.dart +192 -0
- package/templates/firebase/lib/environnements.dart +160 -0
- package/templates/firebase/lib/features/authentication/api/authentication_api.dart +528 -0
- package/templates/firebase/lib/features/authentication/api/authentication_api_interface.dart +84 -0
- package/templates/firebase/lib/features/authentication/providers/models/email.dart +36 -0
- package/templates/firebase/lib/features/authentication/providers/models/password.dart +37 -0
- package/templates/firebase/lib/features/authentication/providers/models/phone_signin_state.dart +21 -0
- package/templates/firebase/lib/features/authentication/providers/models/recover_state.dart +21 -0
- package/templates/firebase/lib/features/authentication/providers/models/signin_state.dart +20 -0
- package/templates/firebase/lib/features/authentication/providers/models/signup_state.dart +20 -0
- package/templates/firebase/lib/features/authentication/providers/phone_auth_notifier.dart +132 -0
- package/templates/firebase/lib/features/authentication/providers/recover_provider.dart +51 -0
- package/templates/firebase/lib/features/authentication/providers/signin_state_provider.dart +166 -0
- package/templates/firebase/lib/features/authentication/providers/signup_state_provider.dart +67 -0
- package/templates/firebase/lib/features/authentication/repositories/authentication_repository.dart +399 -0
- package/templates/firebase/lib/features/authentication/repositories/exceptions/authentication_exceptions.dart +85 -0
- package/templates/firebase/lib/features/authentication/ui/components/apple_signin.dart +19 -0
- package/templates/firebase/lib/features/authentication/ui/components/facebook_signin.dart +19 -0
- package/templates/firebase/lib/features/authentication/ui/components/google_signin.dart +32 -0
- package/templates/firebase/lib/features/authentication/ui/components/otp_verification.dart +100 -0
- package/templates/firebase/lib/features/authentication/ui/components/phone_input.dart +109 -0
- package/templates/firebase/lib/features/authentication/ui/phone_auth_page.dart +60 -0
- package/templates/firebase/lib/features/authentication/ui/recover_password_page.dart +101 -0
- package/templates/firebase/lib/features/authentication/ui/signin_page.dart +321 -0
- package/templates/firebase/lib/features/authentication/ui/signup_page.dart +310 -0
- package/templates/firebase/lib/features/authentication/ui/widgets/auth_brand.dart +35 -0
- package/templates/firebase/lib/features/authentication/ui/widgets/auth_page_back_button.dart +149 -0
- package/templates/firebase/lib/features/authentication/ui/widgets/otp_input.dart +194 -0
- package/templates/firebase/lib/features/authentication/ui/widgets/recover_password_result.dart +62 -0
- package/templates/firebase/lib/features/authentication/ui/widgets/round_signin.dart +73 -0
- package/templates/firebase/lib/features/authentication/ui/widgets/social_separator.dart +26 -0
- package/templates/firebase/lib/features/dev/keyboard_test_page.dart +93 -0
- package/templates/firebase/lib/features/feedbacks/api/entities/feature_request_entity.dart +27 -0
- package/templates/firebase/lib/features/feedbacks/api/entities/feature_vote_entity.dart +27 -0
- package/templates/firebase/lib/features/feedbacks/api/feature_request_api.dart +51 -0
- package/templates/firebase/lib/features/feedbacks/api/feature_vote_api.dart +79 -0
- package/templates/firebase/lib/features/feedbacks/models/feature_requests.dart +48 -0
- package/templates/firebase/lib/features/feedbacks/models/feedback_state.dart +43 -0
- package/templates/firebase/lib/features/feedbacks/providers/feedback_page_notifier.dart +147 -0
- package/templates/firebase/lib/features/feedbacks/repositories/feature_request_repository.dart +92 -0
- package/templates/firebase/lib/features/feedbacks/ui/component/add_feature_form.dart +112 -0
- package/templates/firebase/lib/features/feedbacks/ui/feedback_page.dart +184 -0
- package/templates/firebase/lib/features/feedbacks/ui/widgets/add_feature_button.dart +66 -0
- package/templates/firebase/lib/features/feedbacks/ui/widgets/feature_card.dart +266 -0
- package/templates/firebase/lib/features/home/design_system_page.dart +552 -0
- package/templates/firebase/lib/features/home/home_components_page.dart +314 -0
- package/templates/firebase/lib/features/home/home_components_preview_page.dart +791 -0
- package/templates/firebase/lib/features/home/home_components_preview_registry.dart +7712 -0
- package/templates/firebase/lib/features/home/home_features_page.dart +207 -0
- package/templates/firebase/lib/features/home/home_page.dart +348 -0
- package/templates/firebase/lib/features/llm_chat/api/llm_chat_api.dart +50 -0
- package/templates/firebase/lib/features/llm_chat/api/llm_chat_message_entity.dart +35 -0
- package/templates/firebase/lib/features/llm_chat/llm_chat_page.dart +352 -0
- package/templates/firebase/lib/features/llm_chat/providers/llm_chat_notifier.dart +315 -0
- package/templates/firebase/lib/features/llm_chat/ui/widgets/llm_chat_avatars.dart +148 -0
- package/templates/firebase/lib/features/llm_chat/ui/widgets/llm_chat_composer.dart +124 -0
- package/templates/firebase/lib/features/local_reminder/providers/reminder_notifier.dart +81 -0
- package/templates/firebase/lib/features/local_reminder/repositories/reminder_preferences.dart +76 -0
- package/templates/firebase/lib/features/local_reminder/ui/reminder_page.dart +288 -0
- package/templates/firebase/lib/features/notifications/api/device_api.dart +433 -0
- package/templates/firebase/lib/features/notifications/api/entities/device_entity.dart +62 -0
- package/templates/firebase/lib/features/notifications/api/entities/notifications_entity.dart +35 -0
- package/templates/firebase/lib/features/notifications/api/local_notifier.dart +409 -0
- package/templates/firebase/lib/features/notifications/api/notifications_api.dart +319 -0
- package/templates/firebase/lib/features/notifications/providers/models/device.dart +27 -0
- package/templates/firebase/lib/features/notifications/providers/models/notification.dart +196 -0
- package/templates/firebase/lib/features/notifications/providers/models/notification_list.dart +38 -0
- package/templates/firebase/lib/features/notifications/providers/notifications_provider.dart +120 -0
- package/templates/firebase/lib/features/notifications/repositories/background_notification_handler.dart +13 -0
- package/templates/firebase/lib/features/notifications/repositories/device_repository.dart +137 -0
- package/templates/firebase/lib/features/notifications/repositories/notifications_repository.dart +214 -0
- package/templates/firebase/lib/features/notifications/shared/att_permission.dart +75 -0
- package/templates/firebase/lib/features/notifications/shared/notification_permission_bottom_sheet.dart +144 -0
- package/templates/firebase/lib/features/notifications/ui/components/notification_settings_sheet.dart +169 -0
- package/templates/firebase/lib/features/notifications/ui/components/notification_tile.dart +46 -0
- package/templates/firebase/lib/features/notifications/ui/components/notifications_header.dart +32 -0
- package/templates/firebase/lib/features/notifications/ui/components/push_notification_switcher.dart +106 -0
- package/templates/firebase/lib/features/notifications/ui/notifications_page.dart +202 -0
- package/templates/firebase/lib/features/notifications/ui/request_notification_permission.dart +84 -0
- package/templates/firebase/lib/features/notifications/ui/widgets/empty_notifications.dart +73 -0
- package/templates/firebase/lib/features/notifications/ui/widgets/notification_tile.dart +362 -0
- package/templates/firebase/lib/features/onboarding/api/entities/user_info_entity.dart +24 -0
- package/templates/firebase/lib/features/onboarding/api/user_infos_api.dart +71 -0
- package/templates/firebase/lib/features/onboarding/models/user_info.dart +92 -0
- package/templates/firebase/lib/features/onboarding/providers/onboarding_model.dart +15 -0
- package/templates/firebase/lib/features/onboarding/providers/onboarding_provider.dart +78 -0
- package/templates/firebase/lib/features/onboarding/repositories/user_infos_repository.dart +29 -0
- package/templates/firebase/lib/features/onboarding/ui/animations/page_transitions.dart +33 -0
- package/templates/firebase/lib/features/onboarding/ui/components/onboarding_att_setup.dart +66 -0
- package/templates/firebase/lib/features/onboarding/ui/components/onboarding_features.dart +76 -0
- package/templates/firebase/lib/features/onboarding/ui/components/onboarding_loader.dart +92 -0
- package/templates/firebase/lib/features/onboarding/ui/components/onboarding_notifications_setup.dart +76 -0
- package/templates/firebase/lib/features/onboarding/ui/components/onboarding_questions.dart +89 -0
- package/templates/firebase/lib/features/onboarding/ui/onboarding_page.dart +108 -0
- package/templates/firebase/lib/features/onboarding/ui/widgets/onboarding_background.dart +80 -0
- package/templates/firebase/lib/features/onboarding/ui/widgets/onboarding_feature.dart +145 -0
- package/templates/firebase/lib/features/onboarding/ui/widgets/onboarding_illustration_scaffold.dart +125 -0
- package/templates/firebase/lib/features/onboarding/ui/widgets/onboarding_progress.dart +84 -0
- package/templates/firebase/lib/features/onboarding/ui/widgets/onboarding_radio_question.dart +173 -0
- package/templates/firebase/lib/features/onboarding/ui/widgets/onboarding_reassurance.dart +44 -0
- package/templates/firebase/lib/features/onboarding/ui/widgets/onboarding_sticky_footer.dart +77 -0
- package/templates/firebase/lib/features/onboarding/ui/widgets/selectable_row_tile.dart +392 -0
- package/templates/firebase/lib/features/settings/settings_page.dart +460 -0
- package/templates/firebase/lib/features/settings/ui/components/admin/admin_bottom_sheet.dart +301 -0
- package/templates/firebase/lib/features/settings/ui/components/admin/admin_home_widgets.dart +38 -0
- package/templates/firebase/lib/features/settings/ui/components/admin/admin_paywalls.dart +53 -0
- package/templates/firebase/lib/features/settings/ui/components/admin/admin_routes.dart +22 -0
- package/templates/firebase/lib/features/settings/ui/components/admin/send_push_notification_page.dart +366 -0
- package/templates/firebase/lib/features/settings/ui/components/admin/send_push_notifier.dart +40 -0
- package/templates/firebase/lib/features/settings/ui/components/avatar_component.dart +430 -0
- package/templates/firebase/lib/features/settings/ui/components/delete_user_component.dart +28 -0
- package/templates/firebase/lib/features/settings/ui/components/language_switcher.dart +163 -0
- package/templates/firebase/lib/features/settings/ui/widgets/admin_card.dart +59 -0
- package/templates/firebase/lib/features/settings/ui/widgets/avatar_utils.dart +51 -0
- package/templates/firebase/lib/features/settings/ui/widgets/round_progress.dart +151 -0
- package/templates/firebase/lib/features/settings/ui/widgets/settings_bottom_sheet_option_tile.dart +52 -0
- package/templates/firebase/lib/features/settings/ui/widgets/settings_tile.dart +163 -0
- package/templates/firebase/lib/features/subscription/api/entities/subscription_entity.dart +40 -0
- package/templates/firebase/lib/features/subscription/api/inapp_subscription_api.dart +389 -0
- package/templates/firebase/lib/features/subscription/api/subscription_api.dart +39 -0
- package/templates/firebase/lib/features/subscription/providers/models/premium_state.dart +35 -0
- package/templates/firebase/lib/features/subscription/providers/premium_page_provider.dart +259 -0
- package/templates/firebase/lib/features/subscription/repositories/subscription_repository.dart +177 -0
- package/templates/firebase/lib/features/subscription/shared/maybeshow_premium.dart +85 -0
- package/templates/firebase/lib/features/subscription/ui/component/active_premium_content.dart +171 -0
- package/templates/firebase/lib/features/subscription/ui/component/paywall_minimal.dart +146 -0
- package/templates/firebase/lib/features/subscription/ui/component/paywall_row.dart +332 -0
- package/templates/firebase/lib/features/subscription/ui/component/paywall_with_switch.dart +207 -0
- package/templates/firebase/lib/features/subscription/ui/component/premium_content.dart +157 -0
- package/templates/firebase/lib/features/subscription/ui/component/premium_page_factory.dart +161 -0
- package/templates/firebase/lib/features/subscription/ui/premium_page.dart +139 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/comparison_table.dart +346 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/feature_line.dart +131 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/paywall_empty_state.dart +68 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/premium_background.dart +63 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/premium_background_gradient.dart +53 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/premium_banner.dart +80 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/premium_bottom_menu.dart +102 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/premium_card.dart +26 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/premium_close_button.dart +61 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/premium_feature.dart +39 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/selectable_col.dart +377 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/selectable_row.dart +436 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/trial_switcher.dart +85 -0
- package/templates/firebase/lib/features/subscription/ui/widgets/unsubscribe_feedback_popup.dart +123 -0
- package/templates/firebase/lib/firebase_options.dart +75 -0
- package/templates/firebase/lib/google_auth_options.dart +10 -0
- package/templates/firebase/lib/i18n/app_locale_display.dart +17 -0
- package/templates/firebase/lib/i18n/en.i18n.json +514 -0
- package/templates/firebase/lib/i18n/es.i18n.json +514 -0
- package/templates/firebase/lib/i18n/pt.i18n.json +514 -0
- package/templates/firebase/lib/i18n/widgets/locale_code_badge.dart +47 -0
- package/templates/firebase/lib/main.dart +263 -0
- package/templates/firebase/lib/router.dart +226 -0
- package/templates/firebase/login-redesign-preview.png +0 -0
- package/templates/firebase/pubspec.yaml +177 -0
- package/templates/firebase/scripts/bump-ios-version.js +38 -0
- package/templates/firebase/scripts/release-ios.sh +137 -0
- package/templates/firebase/slang.yaml +7 -0
- package/templates/firebase/storage.rules +12 -0
- package/templates/firebase/test/core/data/api/analytics_api_fake.dart +25 -0
- package/templates/firebase/test/core/data/api/fake_remote_config_api.dart +45 -0
- package/templates/firebase/test/core/data/api/storage_api_fake.dart +28 -0
- package/templates/firebase/test/core/data/models/subscription_test.dart +42 -0
- package/templates/firebase/test/core/data/repositories/user_repository_test.dart +56 -0
- package/templates/firebase/test/core/guards/guard_test.dart +78 -0
- package/templates/firebase/test/core/navigation/kasy_page_transition_test.dart +30 -0
- package/templates/firebase/test/core/onstart_service_test.dart +18 -0
- package/templates/firebase/test/core/rating/rating_api_fake.dart +58 -0
- package/templates/firebase/test/core/rating/rating_banner_test.dart +117 -0
- package/templates/firebase/test/core/rating/rating_test.dart +60 -0
- package/templates/firebase/test/core/security/secured_storage_fake.dart +33 -0
- package/templates/firebase/test/core/states/event_dispatcher_test.dart +269 -0
- package/templates/firebase/test/core/states/user_state_notifier_test.dart +244 -0
- package/templates/firebase/test/core/widgets/responsive_layout_test.dart +50 -0
- package/templates/firebase/test/device_test_utils.dart +98 -0
- package/templates/firebase/test/features/authentication/data/api/auth_api_fake.dart +169 -0
- package/templates/firebase/test/features/authentication/data/api/user_api_fake.dart +86 -0
- package/templates/firebase/test/features/authentication/lost_password_page_test.dart +59 -0
- package/templates/firebase/test/features/authentication/repositories/authentication_repository_test.dart +88 -0
- package/templates/firebase/test/features/authentication/signin_page_test.dart +133 -0
- package/templates/firebase/test/features/authentication/signup_page_test.dart +136 -0
- package/templates/firebase/test/features/notifications/data/device_api_fake.dart +66 -0
- package/templates/firebase/test/features/notifications/data/fake_facebook_api.dart +40 -0
- package/templates/firebase/test/features/notifications/data/local_notifier_fake.dart +59 -0
- package/templates/firebase/test/features/notifications/data/notifications_api_fake.dart +120 -0
- package/templates/firebase/test/features/notifications/data/notifications_settings_fake.dart +34 -0
- package/templates/firebase/test/features/notifications/providers/device_repository_test.dart +68 -0
- package/templates/firebase/test/features/notifications/providers/notifications_repository_test.dart +74 -0
- package/templates/firebase/test/features/notifications/ui/notifications_page_test.dart +69 -0
- package/templates/firebase/test/features/subscription/api/fake_inapp_subscription_api.dart +85 -0
- package/templates/firebase/test/features/subscription/api/fake_revenuecat_product.dart +186 -0
- package/templates/firebase/test/features/subscription/api/fake_subscription_api.dart +11 -0
- package/templates/firebase/test/features/subscription/subscription_page_test.dart +119 -0
- package/templates/firebase/test/firebase_test_utils.dart +25 -0
- package/templates/firebase/test/test_utils.dart +272 -0
- package/templates/firebase/web/favicon.png +0 -0
- package/templates/firebase/web/firebase-messaging-sw.js +27 -0
- package/templates/firebase/web/icons/Icon-192.png +0 -0
- package/templates/firebase/web/icons/Icon-512.png +0 -0
- package/templates/firebase/web/icons/Icon-maskable-192.png +0 -0
- package/templates/firebase/web/icons/Icon-maskable-512.png +0 -0
- package/templates/firebase/web/index.html +110 -0
- package/templates/firebase/web/local_notifications.js +31 -0
- package/templates/firebase/web/manifest.json +35 -0
- package/templates/firebase/web/splash/img/dark-1x.png +0 -0
- package/templates/firebase/web/splash/img/dark-2x.png +0 -0
- package/templates/firebase/web/splash/img/dark-3x.png +0 -0
- package/templates/firebase/web/splash/img/dark-4x.png +0 -0
- package/templates/firebase/web/splash/img/light-1x.png +0 -0
- package/templates/firebase/web/splash/img/light-2x.png +0 -0
- package/templates/firebase/web/splash/img/light-3x.png +0 -0
- package/templates/firebase/web/splash/img/light-4x.png +0 -0
|
@@ -0,0 +1,777 @@
|
|
|
1
|
+
const { exec } = require('node:child_process');
|
|
2
|
+
const { promisify } = require('node:util');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const os = require('node:os');
|
|
5
|
+
const fs = require('fs-extra');
|
|
6
|
+
const pkg = require('../../package.json');
|
|
7
|
+
const kleur = require('kleur');
|
|
8
|
+
const prompts = require('prompts');
|
|
9
|
+
const oraPackage = require('ora');
|
|
10
|
+
const { createTranslator, detectDefaultLanguage } = require('../utils/i18n');
|
|
11
|
+
const {
|
|
12
|
+
AVAILABLE_FEATURES,
|
|
13
|
+
FEATURES_PATCH_DIR,
|
|
14
|
+
normalizeFeature,
|
|
15
|
+
getVisibleFeatures,
|
|
16
|
+
} = require('../scaffold/catalog');
|
|
17
|
+
|
|
18
|
+
const KASY_AUDIENCE = process.env.KASY_INTERNAL === '1' ? 'internal' : 'public';
|
|
19
|
+
const { applyPatch } = require('../scaffold/engine');
|
|
20
|
+
const { writeRouter, writeNoOpAnalyticsApi, writeNoOpTrackingApi, writeNoOpAdminHomeWidgets, writeNoOpFeatureRequestRepository, writeMainDart, addPubspecDep, localizeReleaseDocs } = require('../scaffold/shared/generator-utils');
|
|
21
|
+
const { toPackageName, buildTokens } = require('../scaffold/backends/firebase/tokens');
|
|
22
|
+
|
|
23
|
+
const execAsync = promisify(exec);
|
|
24
|
+
const ora = oraPackage.default || oraPackage;
|
|
25
|
+
|
|
26
|
+
/** URL do endpoint LLM no app (espelha defineUpdates de llm_chat). */
|
|
27
|
+
function resolveLlmChatEndpoint(answers, kitSetup) {
|
|
28
|
+
if (kitSetup?.backendProvider === 'api') {
|
|
29
|
+
return answers.llmEndpoint || 'YOUR_LLM_ENDPOINT';
|
|
30
|
+
}
|
|
31
|
+
if (kitSetup?.backendProvider === 'supabase') {
|
|
32
|
+
const ref = kitSetup.supabaseProjectId || 'YOUR_PROJECT_REF';
|
|
33
|
+
return `https://${ref}.supabase.co/functions/v1/llm-chat`;
|
|
34
|
+
}
|
|
35
|
+
const projectId = kitSetup?.firebaseProjectId || 'YOUR_PROJECT_ID';
|
|
36
|
+
const region = kitSetup?.functionsRegion || 'us-central1';
|
|
37
|
+
return `https://${region}-${projectId}.cloudfunctions.net/llmChat`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Reconstruct active modules from kit_setup.json + features.dart.
|
|
44
|
+
*/
|
|
45
|
+
async function getActiveModules(kitSetup, projectDir) {
|
|
46
|
+
const modules = [];
|
|
47
|
+
if (kitSetup.useSentry) modules.push('sentry');
|
|
48
|
+
if (kitSetup.analyticsProvider === 'mixpanel') modules.push('analytics');
|
|
49
|
+
if (kitSetup.withFacebookPixel) modules.push('facebook');
|
|
50
|
+
if (kitSetup.subscriptionModule) modules.push('revenuecat');
|
|
51
|
+
if (kitSetup.withOnboarding) modules.push('onboarding');
|
|
52
|
+
if (kitSetup.webCompat) modules.push('web');
|
|
53
|
+
if (kitSetup.feedbackModule) modules.push('feedback');
|
|
54
|
+
|
|
55
|
+
const featuresPath = path.join(projectDir, 'lib', 'core', 'config', 'features.dart');
|
|
56
|
+
if (await fs.pathExists(featuresPath)) {
|
|
57
|
+
const content = await fs.readFile(featuresPath, 'utf8');
|
|
58
|
+
if (/const bool withLlmChat\s*=\s*true/.test(content)) modules.push('llm_chat');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (await fs.pathExists(path.join(projectDir, '.github', 'workflows'))) modules.push('ci');
|
|
62
|
+
if (await fs.pathExists(path.join(projectDir, 'lib', 'core', 'home_widgets', 'home_widget_service.dart'))) modules.push('widget');
|
|
63
|
+
|
|
64
|
+
return modules;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Toggle a single feature flag in features.dart (false → true).
|
|
69
|
+
* Only touches the specific flag — does not rewrite the whole file.
|
|
70
|
+
*/
|
|
71
|
+
async function enableFeatureFlag(projectDir, flag) {
|
|
72
|
+
const featuresPath = path.join(projectDir, 'lib', 'core', 'config', 'features.dart');
|
|
73
|
+
if (!(await fs.pathExists(featuresPath))) return;
|
|
74
|
+
let content = await fs.readFile(featuresPath, 'utf8');
|
|
75
|
+
content = content.replace(
|
|
76
|
+
new RegExp(`(const bool ${flag}\\s*=\\s*)false`, 'g'),
|
|
77
|
+
'$1true'
|
|
78
|
+
);
|
|
79
|
+
await fs.outputFile(featuresPath, content, 'utf8');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Add or update a dart-define in a launch.json args array.
|
|
84
|
+
* Preserves all other args. If the key already exists, replaces the value.
|
|
85
|
+
*/
|
|
86
|
+
function upsertDartDefine(args, key, value) {
|
|
87
|
+
const prefix = `--dart-define=${key}=`;
|
|
88
|
+
const filtered = args.filter((a) => !a.startsWith(prefix));
|
|
89
|
+
filtered.push(`${prefix}${value}`);
|
|
90
|
+
return filtered;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Add or update dart-define entries in the project Makefile.
|
|
95
|
+
* Only touches lines inside the DEFINES block; leaves everything else intact.
|
|
96
|
+
* If no DEFINES block exists (old project), appends one before .PHONY.
|
|
97
|
+
*/
|
|
98
|
+
async function ensureIosReleaseMakefile(projectDir) {
|
|
99
|
+
const makePath = path.join(projectDir, 'Makefile');
|
|
100
|
+
if (!(await fs.pathExists(makePath))) return;
|
|
101
|
+
let content = await fs.readFile(makePath, 'utf8');
|
|
102
|
+
if (content.includes('release-ios')) return;
|
|
103
|
+
content += `\n.PHONY: release-ios\nrelease-ios:\n\tbash scripts/release-ios.sh\n`;
|
|
104
|
+
await fs.outputFile(makePath, content, 'utf8');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function ensureGitignoreKasyEnv(projectDir) {
|
|
108
|
+
const giPath = path.join(projectDir, '.gitignore');
|
|
109
|
+
if (!(await fs.pathExists(giPath))) return;
|
|
110
|
+
let content = await fs.readFile(giPath, 'utf8');
|
|
111
|
+
for (const line of ['.kasy/apple.env', '.kasy/codemagic.env']) {
|
|
112
|
+
if (!content.includes(line)) {
|
|
113
|
+
content += `\n${line}\n`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
await fs.outputFile(giPath, content, 'utf8');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function updateMakefile(projectDir, defineUpdates) {
|
|
120
|
+
const makePath = path.join(projectDir, 'Makefile');
|
|
121
|
+
if (!(await fs.pathExists(makePath))) return;
|
|
122
|
+
let content = await fs.readFile(makePath, 'utf8');
|
|
123
|
+
|
|
124
|
+
for (const [key, value] of Object.entries(defineUpdates)) {
|
|
125
|
+
const flag = `--dart-define=${key}=`;
|
|
126
|
+
const lineRegex = new RegExp(`( ${flag.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})\\S*( \\\\)?`, 'g');
|
|
127
|
+
if (lineRegex.test(content)) {
|
|
128
|
+
// Replace existing value
|
|
129
|
+
content = content.replace(
|
|
130
|
+
new RegExp(`( ${flag.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})\\S*( \\\\)?`, 'g'),
|
|
131
|
+
(_, prefix, suffix) => `${prefix}${value}${suffix || ''}`
|
|
132
|
+
);
|
|
133
|
+
} else if (content.includes('DEFINES :=')) {
|
|
134
|
+
// Append inside existing DEFINES block — find last define line and add after
|
|
135
|
+
content = content.replace(
|
|
136
|
+
/(DEFINES :=[\s\S]*?)(\n\n\.PHONY)/,
|
|
137
|
+
(_, block, rest) => {
|
|
138
|
+
const trimmed = block.trimEnd().replace(/ \\$/, '');
|
|
139
|
+
return `${trimmed} \\\n ${flag}${value}${rest}`;
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
} else {
|
|
143
|
+
// No DEFINES block yet — insert before .PHONY
|
|
144
|
+
content = content.replace(
|
|
145
|
+
/^(\.PHONY:)/m,
|
|
146
|
+
`DEFINES := \\\n ${flag}${value}\n\n$1`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
await fs.outputFile(makePath, content, 'utf8');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Update .vscode/launch.json by adding/updating dart-defines for a module.
|
|
156
|
+
* Applies the same change to both dev and prod configurations.
|
|
157
|
+
*/
|
|
158
|
+
async function updateLaunchJson(projectDir, defineUpdates) {
|
|
159
|
+
const launchPath = path.join(projectDir, '.vscode', 'launch.json');
|
|
160
|
+
if (!(await fs.pathExists(launchPath))) return;
|
|
161
|
+
const launch = await fs.readJson(launchPath);
|
|
162
|
+
|
|
163
|
+
for (const config of launch.configurations || []) {
|
|
164
|
+
if (!Array.isArray(config.args)) continue;
|
|
165
|
+
for (const [key, value] of Object.entries(defineUpdates)) {
|
|
166
|
+
config.args = upsertDartDefine(config.args, key, value);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
await fs.outputFile(launchPath, JSON.stringify(launch, null, 2) + '\n', 'utf8');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Append module vars to .env.example (only if not already present).
|
|
175
|
+
*/
|
|
176
|
+
async function appendEnvExample(projectDir, lines) {
|
|
177
|
+
const envPath = path.join(projectDir, '.env.example');
|
|
178
|
+
if (!(await fs.pathExists(envPath))) return;
|
|
179
|
+
const existing = await fs.readFile(envPath, 'utf8');
|
|
180
|
+
const toAdd = lines.filter((l) => !existing.includes(l.split('=')[0]));
|
|
181
|
+
if (toAdd.length === 0) return;
|
|
182
|
+
await fs.appendFile(envPath, '\n' + toAdd.join('\n') + '\n', 'utf8');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Append module vars to .env (only if file exists and key is missing).
|
|
187
|
+
*/
|
|
188
|
+
async function appendEnvFile(projectDir, lines) {
|
|
189
|
+
const envPath = path.join(projectDir, '.env');
|
|
190
|
+
if (!(await fs.pathExists(envPath))) return;
|
|
191
|
+
const existing = await fs.readFile(envPath, 'utf8');
|
|
192
|
+
const toAdd = lines.filter((l) => !existing.includes(l.split('=')[0]));
|
|
193
|
+
if (toAdd.length === 0) return;
|
|
194
|
+
await fs.appendFile(envPath, '\n' + toAdd.join('\n') + '\n', 'utf8');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Update kit_setup.json flags for the newly added module.
|
|
199
|
+
*/
|
|
200
|
+
function applyKitSetupFlag(config, module, answers) {
|
|
201
|
+
switch (module) {
|
|
202
|
+
case 'sentry':
|
|
203
|
+
config.useSentry = true;
|
|
204
|
+
break;
|
|
205
|
+
case 'analytics':
|
|
206
|
+
config.analyticsProvider = 'mixpanel';
|
|
207
|
+
break;
|
|
208
|
+
case 'facebook':
|
|
209
|
+
config.withFacebookPixel = true;
|
|
210
|
+
break;
|
|
211
|
+
case 'revenuecat':
|
|
212
|
+
config.subscriptionModule = true;
|
|
213
|
+
if (answers.revenuecatWeb) config.revenuecatWeb = true;
|
|
214
|
+
break;
|
|
215
|
+
case 'onboarding':
|
|
216
|
+
config.withOnboarding = true;
|
|
217
|
+
break;
|
|
218
|
+
case 'web':
|
|
219
|
+
config.webCompat = true;
|
|
220
|
+
break;
|
|
221
|
+
case 'feedback':
|
|
222
|
+
config.feedbackModule = true;
|
|
223
|
+
break;
|
|
224
|
+
case 'llm_chat':
|
|
225
|
+
case 'widget':
|
|
226
|
+
case 'ci':
|
|
227
|
+
// controlled by features.dart / patch — no extra kit_setup flag needed
|
|
228
|
+
break;
|
|
229
|
+
default:
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ── Module definitions ────────────────────────────────────────────────────────
|
|
235
|
+
|
|
236
|
+
const MODULE_META = {
|
|
237
|
+
sentry: {
|
|
238
|
+
promptKeys: ['sentryDsn'],
|
|
239
|
+
defineUpdates: (a) => ({ SENTRY_DSN: a.sentryDsn || 'YOUR_SENTRY_DSN' }),
|
|
240
|
+
envLines: (a) => [`SENTRY_DSN=${a.sentryDsn || 'YOUR_SENTRY_DSN'}`],
|
|
241
|
+
featureFlag: null,
|
|
242
|
+
pubspecDeps: { 'sentry_flutter': '^9.14.0' },
|
|
243
|
+
},
|
|
244
|
+
analytics: {
|
|
245
|
+
promptKeys: ['mixpanelToken'],
|
|
246
|
+
defineUpdates: (a) => ({ MIXPANEL_TOKEN: a.mixpanelToken || 'YOUR_MIXPANEL_TOKEN' }),
|
|
247
|
+
envLines: (a) => [`MIXPANEL_TOKEN=${a.mixpanelToken || 'YOUR_MIXPANEL_TOKEN'}`],
|
|
248
|
+
featureFlag: null,
|
|
249
|
+
pubspecDeps: { 'mixpanel_flutter': '^2.5.0' },
|
|
250
|
+
},
|
|
251
|
+
facebook: {
|
|
252
|
+
promptKeys: [],
|
|
253
|
+
defineUpdates: () => ({}),
|
|
254
|
+
envLines: () => [],
|
|
255
|
+
featureFlag: null,
|
|
256
|
+
note: 'add.note.facebook',
|
|
257
|
+
pubspecDeps: { 'facebook_app_events': '^0.24.0', 'flutter_facebook_auth': '^7.1.5' },
|
|
258
|
+
},
|
|
259
|
+
revenuecat: {
|
|
260
|
+
promptKeys: ['rcAndroidKey', 'rcIosKey'],
|
|
261
|
+
defineUpdates: (a) => ({
|
|
262
|
+
RC_ANDROID_API_KEY: a.rcAndroidKey || 'YOUR_REVENUECAT_ANDROID_KEY',
|
|
263
|
+
RC_IOS_API_KEY: a.rcIosKey || 'YOUR_REVENUECAT_IOS_KEY',
|
|
264
|
+
}),
|
|
265
|
+
envLines: (a) => [
|
|
266
|
+
`RC_ANDROID_API_KEY=${a.rcAndroidKey || 'YOUR_REVENUECAT_ANDROID_KEY'}`,
|
|
267
|
+
`RC_IOS_API_KEY=${a.rcIosKey || 'YOUR_REVENUECAT_IOS_KEY'}`,
|
|
268
|
+
],
|
|
269
|
+
featureFlag: null,
|
|
270
|
+
pubspecDeps: {},
|
|
271
|
+
},
|
|
272
|
+
onboarding: {
|
|
273
|
+
promptKeys: [],
|
|
274
|
+
defineUpdates: () => ({}),
|
|
275
|
+
envLines: () => [],
|
|
276
|
+
featureFlag: 'withOnboarding',
|
|
277
|
+
pubspecDeps: {},
|
|
278
|
+
},
|
|
279
|
+
web: {
|
|
280
|
+
promptKeys: [],
|
|
281
|
+
defineUpdates: () => ({}),
|
|
282
|
+
envLines: () => [],
|
|
283
|
+
featureFlag: 'withWeb',
|
|
284
|
+
pubspecDeps: {},
|
|
285
|
+
},
|
|
286
|
+
feedback: {
|
|
287
|
+
promptKeys: [],
|
|
288
|
+
defineUpdates: () => ({}),
|
|
289
|
+
envLines: () => [],
|
|
290
|
+
featureFlag: 'withFeedback',
|
|
291
|
+
pubspecDeps: {},
|
|
292
|
+
},
|
|
293
|
+
llm_chat: {
|
|
294
|
+
promptKeys: ['llmProvider', 'llmSystemPrompt', 'llmApiKey'],
|
|
295
|
+
defineUpdates: (a, kitSetup) => ({
|
|
296
|
+
LLM_CHAT_ENDPOINT: resolveLlmChatEndpoint(a, kitSetup),
|
|
297
|
+
}),
|
|
298
|
+
envLines: (a, kitSetup) => [
|
|
299
|
+
`LLM_CHAT_ENDPOINT=${resolveLlmChatEndpoint(a, kitSetup)}`,
|
|
300
|
+
],
|
|
301
|
+
featureFlag: 'withLlmChat',
|
|
302
|
+
pubspecDeps: {},
|
|
303
|
+
},
|
|
304
|
+
widget: {
|
|
305
|
+
promptKeys: [],
|
|
306
|
+
defineUpdates: () => ({}),
|
|
307
|
+
envLines: () => [],
|
|
308
|
+
featureFlag: null,
|
|
309
|
+
pubspecDeps: { 'home_widget': '^0.9.0', 'background_fetch': '^1.5.0' },
|
|
310
|
+
},
|
|
311
|
+
ci: {
|
|
312
|
+
promptKeys: [],
|
|
313
|
+
defineUpdates: () => ({}),
|
|
314
|
+
envLines: () => [],
|
|
315
|
+
featureFlag: null,
|
|
316
|
+
pubspecDeps: {},
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const PROMPT_QUESTIONS = {
|
|
321
|
+
sentryDsn: (t) => ({
|
|
322
|
+
type: 'text',
|
|
323
|
+
name: 'sentryDsn',
|
|
324
|
+
message: t('add.prompt.sentryDsn'),
|
|
325
|
+
initial: '',
|
|
326
|
+
}),
|
|
327
|
+
mixpanelToken: (t) => ({
|
|
328
|
+
type: 'text',
|
|
329
|
+
name: 'mixpanelToken',
|
|
330
|
+
message: t('add.prompt.mixpanelToken'),
|
|
331
|
+
initial: '',
|
|
332
|
+
}),
|
|
333
|
+
rcAndroidKey: (t) => ({
|
|
334
|
+
type: 'text',
|
|
335
|
+
name: 'rcAndroidKey',
|
|
336
|
+
message: t('add.prompt.rcAndroidKey'),
|
|
337
|
+
initial: '',
|
|
338
|
+
}),
|
|
339
|
+
rcIosKey: (t) => ({
|
|
340
|
+
type: 'text',
|
|
341
|
+
name: 'rcIosKey',
|
|
342
|
+
message: t('add.prompt.rcIosKey'),
|
|
343
|
+
initial: '',
|
|
344
|
+
}),
|
|
345
|
+
llmProvider: (t) => ({
|
|
346
|
+
type: 'select',
|
|
347
|
+
name: 'llmProvider',
|
|
348
|
+
message: t('add.prompt.llmProvider'),
|
|
349
|
+
choices: [
|
|
350
|
+
{ title: 'OpenAI (gpt-4o-mini)', value: 'openai' },
|
|
351
|
+
{ title: 'Google Gemini (gemini-1.5-flash)', value: 'gemini' },
|
|
352
|
+
],
|
|
353
|
+
initial: 0,
|
|
354
|
+
}),
|
|
355
|
+
llmSystemPrompt: (t) => ({
|
|
356
|
+
type: 'text',
|
|
357
|
+
name: 'llmSystemPrompt',
|
|
358
|
+
message: t('add.prompt.llmSystemPrompt'),
|
|
359
|
+
initial: '',
|
|
360
|
+
}),
|
|
361
|
+
llmApiKey: (t) => ({
|
|
362
|
+
type: 'text',
|
|
363
|
+
name: 'llmApiKey',
|
|
364
|
+
message: t('add.prompt.llmApiKey'),
|
|
365
|
+
initial: '',
|
|
366
|
+
}),
|
|
367
|
+
llmEndpoint: (t) => ({
|
|
368
|
+
type: 'text',
|
|
369
|
+
name: 'llmEndpoint',
|
|
370
|
+
message: t('add.prompt.llmEndpoint'),
|
|
371
|
+
initial: '',
|
|
372
|
+
}),
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// ── LLM Chat post-add: copy edge function, set secrets, write functions/.env ──
|
|
376
|
+
|
|
377
|
+
const SUPABASE_EDGE_FUNCTIONS_SOURCE = path.join(
|
|
378
|
+
__dirname, '..', 'scaffold', 'backends', 'supabase', 'edge-functions'
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
async function postAddLlmChat(projectDir, kitSetup, answers, t) {
|
|
382
|
+
const backend = kitSetup?.backendProvider ?? 'firebase';
|
|
383
|
+
const apiKey = answers.llmApiKey?.trim() || '';
|
|
384
|
+
const provider = answers.llmProvider || 'openai';
|
|
385
|
+
const systemPrompt = answers.llmSystemPrompt?.trim() || '';
|
|
386
|
+
const projectRef = kitSetup?.supabaseProjectId || '';
|
|
387
|
+
|
|
388
|
+
// 1. Firebase: write functions/.env (non-secret vars read by Cloud Functions runtime)
|
|
389
|
+
if (backend === 'firebase') {
|
|
390
|
+
const envPath = path.join(projectDir, 'functions', '.env');
|
|
391
|
+
const lines = [`LLM_PROVIDER=${provider}`];
|
|
392
|
+
if (systemPrompt) lines.push(`LLM_SYSTEM_PROMPT=${systemPrompt}`);
|
|
393
|
+
const existing = (await fs.pathExists(envPath)) ? await fs.readFile(envPath, 'utf8') : '';
|
|
394
|
+
const toAdd = lines.filter((l) => !existing.includes(l.split('=')[0]));
|
|
395
|
+
if (toAdd.length > 0) {
|
|
396
|
+
await fs.appendFile(envPath, (existing ? '\n' : '') + toAdd.join('\n') + '\n', 'utf8');
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// 1b. Supabase: copy Edge Function file + set ALL vars as Supabase Secrets
|
|
401
|
+
// (Edge Functions deployed on Supabase read from Deno.env.get() = Supabase Secrets,
|
|
402
|
+
// NOT from local .env files — so LLM_PROVIDER and LLM_SYSTEM_PROMPT must be secrets too)
|
|
403
|
+
if (backend === 'supabase') {
|
|
404
|
+
// Copy llm-chat edge function into the project if not already present
|
|
405
|
+
const edgeFnSrc = path.join(SUPABASE_EDGE_FUNCTIONS_SOURCE, 'llm-chat');
|
|
406
|
+
const edgeFnDest = path.join(projectDir, 'supabase', 'functions', 'llm-chat');
|
|
407
|
+
if (await fs.pathExists(edgeFnSrc) && !(await fs.pathExists(edgeFnDest))) {
|
|
408
|
+
await fs.copy(edgeFnSrc, edgeFnDest);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// 2. Set API key as secret (skip if blank)
|
|
413
|
+
if (!apiKey) {
|
|
414
|
+
console.log(kleur.yellow(`\n ${t('add.llm_chat.skipSecret')}\n`));
|
|
415
|
+
return { deployOk: false, deployAttempted: false };
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
let secretsOk = false;
|
|
419
|
+
const refFlag = backend === 'supabase' && projectRef ? ` --project-ref ${projectRef}` : '';
|
|
420
|
+
|
|
421
|
+
if (backend === 'firebase') {
|
|
422
|
+
const spinner = ora(t('add.llm_chat.settingSecret')).start();
|
|
423
|
+
try {
|
|
424
|
+
// Write to temp file — avoids trailing newline (echo) and shell injection risks
|
|
425
|
+
const tmpFile = path.join(os.tmpdir(), `llm_api_key_${Date.now()}.tmp`);
|
|
426
|
+
await fs.outputFile(tmpFile, apiKey, 'utf8');
|
|
427
|
+
await execAsync(`firebase functions:secrets:set LLM_API_KEY --data-file="${tmpFile}"`, { cwd: projectDir });
|
|
428
|
+
await fs.remove(tmpFile);
|
|
429
|
+
spinner.succeed(t('add.llm_chat.secretSet'));
|
|
430
|
+
secretsOk = true;
|
|
431
|
+
} catch {
|
|
432
|
+
spinner.warn(t('add.llm_chat.secretFailed'));
|
|
433
|
+
console.log(kleur.dim(` Run manually: firebase functions:secrets:set LLM_API_KEY`));
|
|
434
|
+
}
|
|
435
|
+
} else if (backend === 'supabase') {
|
|
436
|
+
const spinner = ora(t('add.llm_chat.settingSecret')).start();
|
|
437
|
+
// Set LLM_API_KEY, LLM_PROVIDER and LLM_SYSTEM_PROMPT all as Supabase Secrets.
|
|
438
|
+
// Deployed Edge Functions read from Deno.env.get() = Supabase Secrets, NOT from .env files.
|
|
439
|
+
const esc = (v) => String(v).replace(/"/g, '\\"');
|
|
440
|
+
const toSet = [
|
|
441
|
+
{ name: 'LLM_API_KEY', value: apiKey },
|
|
442
|
+
{ name: 'LLM_PROVIDER', value: provider },
|
|
443
|
+
...(systemPrompt ? [{ name: 'LLM_SYSTEM_PROMPT', value: systemPrompt }] : []),
|
|
444
|
+
];
|
|
445
|
+
let allOk = true;
|
|
446
|
+
for (const { name, value } of toSet) {
|
|
447
|
+
const r = await execAsync(
|
|
448
|
+
`supabase secrets set ${name}="${esc(value)}"${refFlag}`,
|
|
449
|
+
{ cwd: projectDir }
|
|
450
|
+
).catch((e) => ({ ok: false, error: e.message }));
|
|
451
|
+
if (r && r.ok === false) allOk = false;
|
|
452
|
+
}
|
|
453
|
+
if (allOk) {
|
|
454
|
+
spinner.succeed(t('add.llm_chat.secretSet'));
|
|
455
|
+
secretsOk = true;
|
|
456
|
+
} else {
|
|
457
|
+
spinner.warn(t('add.llm_chat.secretFailed'));
|
|
458
|
+
console.log(kleur.dim(` Run manually: supabase secrets set LLM_API_KEY=YOUR_KEY LLM_PROVIDER=${provider}${refFlag}`));
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// 3. Deploy the LLM function automatically
|
|
463
|
+
if (backend === 'api') return { deployOk: false, deployAttempted: false };
|
|
464
|
+
|
|
465
|
+
const deploySpinner = ora(t('add.llm_chat.deploying')).start();
|
|
466
|
+
try {
|
|
467
|
+
if (backend === 'firebase') {
|
|
468
|
+
await execAsync('firebase deploy --only functions:llmChat', { cwd: projectDir, timeout: 180_000 });
|
|
469
|
+
} else if (backend === 'supabase') {
|
|
470
|
+
await execAsync(`supabase functions deploy llm-chat --no-verify-jwt${refFlag}`, { cwd: projectDir, timeout: 180_000 });
|
|
471
|
+
}
|
|
472
|
+
deploySpinner.succeed(t('add.llm_chat.deployed'));
|
|
473
|
+
return { deployOk: true, deployAttempted: true };
|
|
474
|
+
} catch {
|
|
475
|
+
deploySpinner.warn(t('add.llm_chat.deployFailed'));
|
|
476
|
+
if (backend === 'firebase') {
|
|
477
|
+
console.log(kleur.dim(` Run manually: firebase deploy --only functions:llmChat`));
|
|
478
|
+
} else {
|
|
479
|
+
console.log(kleur.dim(` Run manually: supabase functions deploy llm-chat --no-verify-jwt${refFlag}`));
|
|
480
|
+
}
|
|
481
|
+
return { deployOk: false, deployAttempted: true };
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// ── List command ──────────────────────────────────────────────────────────────
|
|
486
|
+
|
|
487
|
+
async function listModules(projectDir, t) {
|
|
488
|
+
console.log(kleur.bold(`\n${t('add.list.title')}\n`));
|
|
489
|
+
|
|
490
|
+
let activeModules = [];
|
|
491
|
+
const kitSetupPath = path.join(projectDir, 'kit_setup.json');
|
|
492
|
+
if (await fs.pathExists(kitSetupPath)) {
|
|
493
|
+
try {
|
|
494
|
+
const config = await fs.readJson(kitSetupPath);
|
|
495
|
+
activeModules = await getActiveModules(config, projectDir);
|
|
496
|
+
} catch {
|
|
497
|
+
// ignore
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
for (const feature of getVisibleFeatures({ audience: KASY_AUDIENCE })) {
|
|
502
|
+
const active = activeModules.includes(feature.id);
|
|
503
|
+
const badge = feature.status === 'internal' ? kleur.yellow(' [beta]') : '';
|
|
504
|
+
const icon = active ? kleur.green('✓') : kleur.dim('○');
|
|
505
|
+
const label = active ? kleur.green(feature.id) : kleur.white(feature.id);
|
|
506
|
+
console.log(` ${icon} ${label}${badge}`);
|
|
507
|
+
}
|
|
508
|
+
console.log('');
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// ── Main command ──────────────────────────────────────────────────────────────
|
|
512
|
+
|
|
513
|
+
async function runAdd(module, options = {}) {
|
|
514
|
+
const t = createTranslator(options.language || detectDefaultLanguage());
|
|
515
|
+
const projectDir = path.resolve(options.directory || '.');
|
|
516
|
+
|
|
517
|
+
// --list flag
|
|
518
|
+
if (options.list) {
|
|
519
|
+
await listModules(projectDir, t);
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (!module) {
|
|
524
|
+
console.log(kleur.yellow(t('add.error.noModule')));
|
|
525
|
+
await listModules(projectDir, t);
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// 1. Must be inside a kasy project
|
|
530
|
+
const kitSetupPath = path.join(projectDir, 'kit_setup.json');
|
|
531
|
+
if (!(await fs.pathExists(kitSetupPath))) {
|
|
532
|
+
throw new Error(t('add.error.notKasyProject'));
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const kitSetup = await fs.readJson(kitSetupPath);
|
|
536
|
+
try {
|
|
537
|
+
const kasyConfig = await fs.readJson(path.join(projectDir, '.kasy', 'config.json'));
|
|
538
|
+
if (kasyConfig.functionsRegion) kitSetup.functionsRegion = kasyConfig.functionsRegion;
|
|
539
|
+
} catch (_) {}
|
|
540
|
+
|
|
541
|
+
const moduleLower = String(module).trim().toLowerCase();
|
|
542
|
+
if (moduleLower === 'ios-release' || moduleLower === 'ios_release' || moduleLower === 'iosrelease') {
|
|
543
|
+
const scriptPath = path.join(projectDir, 'scripts', 'release-ios.sh');
|
|
544
|
+
if (await fs.pathExists(scriptPath)) {
|
|
545
|
+
console.log(kleur.yellow(`\n${t('add.iosRelease.already')}\n`));
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
const patchDir = path.join(FEATURES_PATCH_DIR, 'ios-release');
|
|
549
|
+
if (!(await fs.pathExists(patchDir))) {
|
|
550
|
+
throw new Error(t('add.error.unknownModule', { module, list: 'ios-release' }));
|
|
551
|
+
}
|
|
552
|
+
const { tokens, pathReplacements } = buildTokens({
|
|
553
|
+
appName: kitSetup.appName,
|
|
554
|
+
bundleId: kitSetup.bundleId,
|
|
555
|
+
});
|
|
556
|
+
await applyPatch(patchDir, projectDir, tokens, pathReplacements);
|
|
557
|
+
await localizeReleaseDocs(projectDir, options.language || detectDefaultLanguage());
|
|
558
|
+
await ensureIosReleaseMakefile(projectDir);
|
|
559
|
+
await ensureGitignoreKasyEnv(projectDir);
|
|
560
|
+
console.log(kleur.green(`\n✓ ${t('add.iosRelease.success')}\n`));
|
|
561
|
+
console.log(kleur.cyan(` kasy ios configure\n`));
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// 2. Validate module name
|
|
566
|
+
const normalized = normalizeFeature(module);
|
|
567
|
+
if (!normalized) {
|
|
568
|
+
throw new Error(
|
|
569
|
+
t('add.error.unknownModule', {
|
|
570
|
+
module,
|
|
571
|
+
list: getVisibleFeatures({ audience: KASY_AUDIENCE }).map((f) => f.id).join(', '),
|
|
572
|
+
})
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// 3. Check if already active
|
|
577
|
+
const activeModules = await getActiveModules(kitSetup, projectDir);
|
|
578
|
+
if (activeModules.includes(normalized)) {
|
|
579
|
+
// llm_chat can be re-run to reconfigure credentials even when already active
|
|
580
|
+
if (normalized !== 'llm_chat') {
|
|
581
|
+
console.log(kleur.yellow(`\n${t('add.alreadyActive', { module: normalized })}\n`));
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
console.log(kleur.yellow(`\n${t('add.llm_chat.reconfigure')}\n`));
|
|
585
|
+
// Skip to credential-only flow: prompt → postAdd → done
|
|
586
|
+
const answers = {};
|
|
587
|
+
if (!options.yes) {
|
|
588
|
+
console.log('');
|
|
589
|
+
for (const key of ['llmProvider', 'llmSystemPrompt', 'llmApiKey']) {
|
|
590
|
+
const question = PROMPT_QUESTIONS[key]?.(t);
|
|
591
|
+
if (!question) continue;
|
|
592
|
+
const response = await prompts(question, { onCancel: () => { throw new Error(t('add.cancelled')); } });
|
|
593
|
+
answers[key] = response[key] ?? '';
|
|
594
|
+
}
|
|
595
|
+
if (kitSetup.backendProvider === 'api') {
|
|
596
|
+
const response = await prompts(PROMPT_QUESTIONS.llmEndpoint(t), { onCancel: () => { throw new Error(t('add.cancelled')); } });
|
|
597
|
+
answers.llmEndpoint = response.llmEndpoint || '';
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const defines = MODULE_META.llm_chat.defineUpdates(answers, kitSetup);
|
|
601
|
+
if (Object.keys(defines).length > 0) {
|
|
602
|
+
await updateLaunchJson(projectDir, defines);
|
|
603
|
+
await updateMakefile(projectDir, defines);
|
|
604
|
+
const envLines = MODULE_META.llm_chat.envLines(answers, kitSetup);
|
|
605
|
+
if (envLines.length > 0) {
|
|
606
|
+
await appendEnvExample(projectDir, envLines);
|
|
607
|
+
await appendEnvFile(projectDir, envLines);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
const { deployOk, deployAttempted } = await postAddLlmChat(projectDir, kitSetup, answers, t);
|
|
611
|
+
const backend = kitSetup?.backendProvider ?? 'firebase';
|
|
612
|
+
const needsManualDeploy = deployAttempted && !deployOk;
|
|
613
|
+
if (backend === 'firebase') {
|
|
614
|
+
console.log(kleur.cyan(t(needsManualDeploy ? 'add.llm_chat.nextSteps.firebase.deployFailed' : 'add.llm_chat.nextSteps.firebase')));
|
|
615
|
+
} else if (backend === 'supabase') {
|
|
616
|
+
console.log(kleur.cyan(t(needsManualDeploy ? 'add.llm_chat.nextSteps.supabase.deployFailed' : 'add.llm_chat.nextSteps.supabase')));
|
|
617
|
+
} else {
|
|
618
|
+
console.log(kleur.cyan(t('add.llm_chat.nextSteps.api')));
|
|
619
|
+
}
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
const meta = MODULE_META[normalized] || { promptKeys: [], defineUpdates: () => ({}), envLines: () => [], featureFlag: null };
|
|
624
|
+
|
|
625
|
+
// 4. Prompt for API keys (skip if --yes)
|
|
626
|
+
const answers = {};
|
|
627
|
+
if (!options.yes && meta.promptKeys.length > 0) {
|
|
628
|
+
console.log('');
|
|
629
|
+
for (const key of meta.promptKeys) {
|
|
630
|
+
const question = PROMPT_QUESTIONS[key]?.(t);
|
|
631
|
+
if (!question) continue;
|
|
632
|
+
const response = await prompts(question, {
|
|
633
|
+
onCancel: () => { throw new Error(t('add.cancelled')); },
|
|
634
|
+
});
|
|
635
|
+
answers[key] = response[key] ?? '';
|
|
636
|
+
}
|
|
637
|
+
// Extra prompt for API backend (custom LLM endpoint)
|
|
638
|
+
if (normalized === 'llm_chat' && kitSetup.backendProvider === 'api') {
|
|
639
|
+
const response = await prompts(PROMPT_QUESTIONS.llmEndpoint(t), {
|
|
640
|
+
onCancel: () => { throw new Error(t('add.cancelled')); },
|
|
641
|
+
});
|
|
642
|
+
answers.llmEndpoint = response.llmEndpoint || '';
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
console.log(kleur.bold(`\n${t('add.applying', { module: normalized })}\n`));
|
|
647
|
+
|
|
648
|
+
// 5. Enable feature flag in features.dart
|
|
649
|
+
if (meta.featureFlag) {
|
|
650
|
+
await enableFeatureFlag(projectDir, meta.featureFlag);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// 6. Update .vscode/launch.json and Makefile dart-defines
|
|
654
|
+
const defines = meta.defineUpdates(answers, kitSetup);
|
|
655
|
+
if (Object.keys(defines).length > 0) {
|
|
656
|
+
await updateLaunchJson(projectDir, defines);
|
|
657
|
+
await updateMakefile(projectDir, defines);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// 7. Append to .env.example
|
|
661
|
+
const envLines = meta.envLines(answers, kitSetup);
|
|
662
|
+
if (envLines.length > 0) {
|
|
663
|
+
await appendEnvExample(projectDir, envLines);
|
|
664
|
+
await appendEnvFile(projectDir, envLines);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// 8. Apply patch if it exists under features/<module>/
|
|
668
|
+
const patchDir = path.join(FEATURES_PATCH_DIR, normalized);
|
|
669
|
+
if (await fs.pathExists(patchDir)) {
|
|
670
|
+
const spinner = ora(t('add.applyingPatch')).start();
|
|
671
|
+
try {
|
|
672
|
+
const { tokens: patchTokens, pathReplacements: patchPathReplacements } = buildTokens({
|
|
673
|
+
appName: kitSetup.appName,
|
|
674
|
+
bundleId: kitSetup.bundleId,
|
|
675
|
+
});
|
|
676
|
+
await applyPatch(patchDir, projectDir, patchTokens, patchPathReplacements);
|
|
677
|
+
spinner.succeed(t('add.patchApplied'));
|
|
678
|
+
} catch (err) {
|
|
679
|
+
spinner.fail(t('add.patchFailed'));
|
|
680
|
+
throw err;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// 8b. Add pubspec dependencies for this module
|
|
685
|
+
const pubspecDeps = meta.pubspecDeps || {};
|
|
686
|
+
if (Object.keys(pubspecDeps).length > 0) {
|
|
687
|
+
for (const [depName, depVersion] of Object.entries(pubspecDeps)) {
|
|
688
|
+
await addPubspecDep(projectDir, depName, depVersion);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// 9. Update kit_setup.json
|
|
693
|
+
applyKitSetupFlag(kitSetup, normalized, answers);
|
|
694
|
+
kitSetup.cliVersion = pkg.version;
|
|
695
|
+
await fs.outputFile(kitSetupPath, JSON.stringify(kitSetup, null, 2) + '\n', 'utf8');
|
|
696
|
+
|
|
697
|
+
// 9b. Regenerate router.dart with updated module list
|
|
698
|
+
try {
|
|
699
|
+
const updatedModules = await getActiveModules(kitSetup, projectDir);
|
|
700
|
+
const packageName = toPackageName(kitSetup.appName);
|
|
701
|
+
await writeRouter(projectDir, updatedModules, packageName);
|
|
702
|
+
} catch {
|
|
703
|
+
// Non-fatal: router regeneration failure does not block pub get
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// 9c. Regenerate main.dart and no-op stubs with updated module list
|
|
707
|
+
try {
|
|
708
|
+
const updatedModules = await getActiveModules(kitSetup, projectDir);
|
|
709
|
+
const packageName = toPackageName(kitSetup.appName);
|
|
710
|
+
if (!updatedModules.includes('analytics')) {
|
|
711
|
+
await writeNoOpAnalyticsApi(projectDir, packageName);
|
|
712
|
+
}
|
|
713
|
+
if (!updatedModules.includes('facebook')) {
|
|
714
|
+
await writeNoOpTrackingApi(projectDir, packageName);
|
|
715
|
+
}
|
|
716
|
+
if (!updatedModules.includes('feedback')) {
|
|
717
|
+
await writeNoOpFeatureRequestRepository(projectDir, packageName);
|
|
718
|
+
}
|
|
719
|
+
if (!updatedModules.includes('widget')) {
|
|
720
|
+
await writeNoOpAdminHomeWidgets(projectDir);
|
|
721
|
+
}
|
|
722
|
+
await writeMainDart(projectDir, kitSetup.backendProvider, updatedModules, packageName, {});
|
|
723
|
+
} catch {
|
|
724
|
+
// Non-fatal: main.dart regeneration failure does not block pub get
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// 10. flutter pub get
|
|
728
|
+
{
|
|
729
|
+
const spinner = ora(t('add.pubGet')).start();
|
|
730
|
+
try {
|
|
731
|
+
await execAsync('flutter pub get', { cwd: projectDir, timeout: 300_000 });
|
|
732
|
+
spinner.succeed(t('add.pubGetDone'));
|
|
733
|
+
} catch {
|
|
734
|
+
spinner.warn(t('add.pubGetFailed'));
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// 11. build_runner (only when needed: features with codegen)
|
|
739
|
+
const needsBuildRunner = ['revenuecat', 'analytics', 'sentry', 'onboarding', 'llm_chat', 'feedback'].includes(normalized);
|
|
740
|
+
if (needsBuildRunner) {
|
|
741
|
+
const spinner = ora(t('add.buildRunner')).start();
|
|
742
|
+
try {
|
|
743
|
+
await execAsync('dart run build_runner build --delete-conflicting-outputs', { cwd: projectDir, timeout: 600_000 });
|
|
744
|
+
spinner.succeed(t('add.buildRunnerDone'));
|
|
745
|
+
} catch {
|
|
746
|
+
spinner.warn(t('add.buildRunnerFailed'));
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// 12. LLM Chat: set secrets, write env vars, and deploy
|
|
751
|
+
let llmDeployResult = null;
|
|
752
|
+
if (normalized === 'llm_chat') {
|
|
753
|
+
llmDeployResult = await postAddLlmChat(projectDir, kitSetup, answers, t);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// Show note if any
|
|
757
|
+
if (meta.note) {
|
|
758
|
+
console.log(kleur.dim(`\n ${t(meta.note)}\n`));
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
console.log(kleur.green(`\n✓ ${t('add.success', { module: normalized })}\n`));
|
|
762
|
+
|
|
763
|
+
// LLM Chat: show next steps (adjust based on whether deploy succeeded)
|
|
764
|
+
if (normalized === 'llm_chat') {
|
|
765
|
+
const backend = kitSetup?.backendProvider ?? 'firebase';
|
|
766
|
+
const needsManualDeploy = llmDeployResult?.deployAttempted && !llmDeployResult?.deployOk;
|
|
767
|
+
if (backend === 'firebase') {
|
|
768
|
+
console.log(kleur.cyan(t(needsManualDeploy ? 'add.llm_chat.nextSteps.firebase.deployFailed' : 'add.llm_chat.nextSteps.firebase')));
|
|
769
|
+
} else if (backend === 'supabase') {
|
|
770
|
+
console.log(kleur.cyan(t(needsManualDeploy ? 'add.llm_chat.nextSteps.supabase.deployFailed' : 'add.llm_chat.nextSteps.supabase')));
|
|
771
|
+
} else {
|
|
772
|
+
console.log(kleur.cyan(t('add.llm_chat.nextSteps.api')));
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
module.exports = { runAdd };
|