roda-gen 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +94 -0
- data/bin/roda +11 -0
- data/lib/roda-gen.rb +3 -0
- data/lib/roda_gen/app_name.rb +29 -0
- data/lib/roda_gen/cli.rb +122 -0
- data/lib/roda_gen/generators/daemon.rb +78 -0
- data/lib/roda_gen/generators/migration.rb +68 -0
- data/lib/roda_gen/generators/migration_numbering.rb +21 -0
- data/lib/roda_gen/generators/model.rb +75 -0
- data/lib/roda_gen/generators/project.rb +145 -0
- data/lib/roda_gen/generators/route.rb +71 -0
- data/lib/roda_gen/generators/templates/daemon/bin/%daemon_name%.tt +13 -0
- data/lib/roda_gen/generators/templates/daemon/lib/daemon/%daemon_name%.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/daemon/spec/daemons/%daemon_name%_spec.rb.tt +18 -0
- data/lib/roda_gen/generators/templates/migration/db/migrate/%migration_filename%.rb.tt +6 -0
- data/lib/roda_gen/generators/templates/model/db/migrate/%migration_filename%.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/model/models/%resource_name%.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/model/spec/models/%resource_name%_spec.rb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/%app_name%.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/.bundle/config.tt +3 -0
- data/lib/roda_gen/generators/templates/project/.erb_lint.yml.tt +29 -0
- data/lib/roda_gen/generators/templates/project/.gitignore.tt +19 -0
- data/lib/roda_gen/generators/templates/project/.reek.yml.tt +45 -0
- data/lib/roda_gen/generators/templates/project/.rspec.tt +4 -0
- data/lib/roda_gen/generators/templates/project/.rubocop.yml.tt +119 -0
- data/lib/roda_gen/generators/templates/project/.ruby-version.tt +1 -0
- data/lib/roda_gen/generators/templates/project/.rubycritic.yml.tt +15 -0
- data/lib/roda_gen/generators/templates/project/Gemfile.tt +109 -0
- data/lib/roda_gen/generators/templates/project/Procfile.dev.tt +7 -0
- data/lib/roda_gen/generators/templates/project/README.md.tt +891 -0
- data/lib/roda_gen/generators/templates/project/Rakefile.tt +3 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/admin.js.tt +84 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/app.js.tt +29 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/push.js.tt +53 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/upload.js.tt +200 -0
- data/lib/roda_gen/generators/templates/project/assets/stylesheets/app.css.tt +52 -0
- data/lib/roda_gen/generators/templates/project/assets/stylesheets/typography.css.tt +85 -0
- data/lib/roda_gen/generators/templates/project/bin/console.tt +2 -0
- data/lib/roda_gen/generators/templates/project/bin/dev.tt +8 -0
- data/lib/roda_gen/generators/templates/project/bin/gdpr_worker.tt +13 -0
- data/lib/roda_gen/generators/templates/project/bin/push_sender.tt +13 -0
- data/lib/roda_gen/generators/templates/project/bin/setup.tt +224 -0
- data/lib/roda_gen/generators/templates/project/bin/shrine_clean_cache.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/boot.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/config/console.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/database.rb.tt +45 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/00_environments.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/01_logger.rb.tt +46 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/02_app_config.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/10_database.rb.tt +3 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/15_mail.rb.tt +53 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/20_redis.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/25_rack_attack.rb.tt +96 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/30_i18n.rb.tt +37 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/35_listen_job.rb.tt +4 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/37_shrine.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/40_routing.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/41_render.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/43_static.rb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/44_sessions.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/45_security.rb.tt +49 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/46_flash.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/47_json.rb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/48_errors.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/49_misc.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/50_mailer.rb.tt +52 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/51_locale_kit.rb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/52_consent_kit.rb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/55_audit_log.rb.tt +16 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/56_form_helper.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/57_rodauth.rb.tt +304 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/60_web_push.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/61_flipper.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/62_split.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/config/puma.rb.tt +24 -0
- data/lib/roda_gen/generators/templates/project/config/settings/development.yml.tt +9 -0
- data/lib/roda_gen/generators/templates/project/config/settings/production.yml.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/settings/test.yml.tt +9 -0
- data/lib/roda_gen/generators/templates/project/config/settings.yml.tt +45 -0
- data/lib/roda_gen/generators/templates/project/config.ru.tt +36 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_account_profiles.rb.tt +66 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_accounts.rb.tt +70 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_audit_log.rb.tt +185 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_authorization.rb.tt +68 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_countries.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_calling_codes.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_exit_codes.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_languages.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_time_zones.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_currencies.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_gdpr_requests.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_languages.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_push_subscriptions.rb.tt +16 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_rodauth_features.rb.tt +105 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_settings.rb.tt +60 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_countries.csv.tt +250 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_currencies.csv.tt +162 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_languages.csv.tt +144 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_calling_codes.csv.tt +237 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_exit_codes.csv.tt +239 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_languages.csv.tt +226 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_time_zones.csv.tt +369 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/03_setting_system_defaults.yml.tt +35 -0
- data/lib/roda_gen/generators/templates/project/db/seeds.rb.tt +69 -0
- data/lib/roda_gen/generators/templates/project/deploy/Caddyfile.tt +69 -0
- data/lib/roda_gen/generators/templates/project/deploy/logrotate/%app_name%-caddy.tt +11 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-audit-partition.service.tt +21 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-audit-partition.timer.tt +16 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-gdpr-worker.service.tt +25 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-push-sender.service.tt +25 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-shrine-cleanup.service.tt +21 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-shrine-cleanup.timer.tt +16 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%.service.tt +36 -0
- data/lib/roda_gen/generators/templates/project/helpers/audit_helper.rb.tt +59 -0
- data/lib/roda_gen/generators/templates/project/helpers/authorization_helper.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/helpers/current_account_helper.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/helpers/feature_flag_helper.rb.tt +34 -0
- data/lib/roda_gen/generators/templates/project/helpers/form_helper.rb.tt +50 -0
- data/lib/roda_gen/generators/templates/project/helpers/http_cache_helper.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/helpers/logger_helper.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/helpers/split_helper.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/lib/audit_context.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/lib/audit_lookup.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/base.rb.tt +104 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/gdpr_worker.rb.tt +53 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/push_sender.rb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/shrine_cache_cleaner.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/lib/deploy_check.rb.tt +96 -0
- data/lib/roda_gen/generators/templates/project/lib/filtered_logger.rb.tt +54 -0
- data/lib/roda_gen/generators/templates/project/lib/gdpr.rb.tt +106 -0
- data/lib/roda_gen/generators/templates/project/lib/rbac_audit.rb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/.rubocop.yml.tt +4 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/audit.rake.tt +85 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/console.rake.tt +8 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/db.rake.tt +104 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/deploy.rake.tt +38 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/flags.rake.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/gdpr.rake.tt +31 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/parser_current_shim.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/quality.rake.tt +84 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/secrets.rake.tt +154 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/spec.rake.tt +136 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/split.rake.tt +27 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/tailwind.rake.tt +35 -0
- data/lib/roda_gen/generators/templates/project/locales/de.yml.tt +325 -0
- data/lib/roda_gen/generators/templates/project/locales/en.yml.tt +321 -0
- data/lib/roda_gen/generators/templates/project/locales/es.yml.tt +326 -0
- data/lib/roda_gen/generators/templates/project/locales/fr.yml.tt +329 -0
- data/lib/roda_gen/generators/templates/project/locales/it.yml.tt +325 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/de.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/en.yml.tt +6 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/es.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/fr.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/it.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/sv.yml.tt +274 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/tru.yml.tt +274 -0
- data/lib/roda_gen/generators/templates/project/locales/sv.yml.tt +319 -0
- data/lib/roda_gen/generators/templates/project/locales/tru.yml.tt +294 -0
- data/lib/roda_gen/generators/templates/project/log/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/models/account.rb.tt +50 -0
- data/lib/roda_gen/generators/templates/project/models/account_privilege.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/models/account_profile.rb.tt +115 -0
- data/lib/roda_gen/generators/templates/project/models/account_role.rb.tt +14 -0
- data/lib/roda_gen/generators/templates/project/models/audit_action.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/models/audit_actor_type.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/models/audit_log.rb.tt +257 -0
- data/lib/roda_gen/generators/templates/project/models/audit_status.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/models/country.rb.tt +17 -0
- data/lib/roda_gen/generators/templates/project/models/country_calling_code.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/country_exit_code.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/country_language.rb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/models/country_time_zone.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/currency.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/gdpr_request.rb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/models/gender.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/language.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/models/privilege.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/models/push_subscription.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/models/role.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/models/role_privilege.rb.tt +14 -0
- data/lib/roda_gen/generators/templates/project/models/setting_system_default.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/models/setting_user_value.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/models/settings.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/models/signup_form_data.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/models.rb.tt +6 -0
- data/lib/roda_gen/generators/templates/project/package.json.tt +13 -0
- data/lib/roda_gen/generators/templates/project/public/apple-touch-icon.png +0 -0
- data/lib/roda_gen/generators/templates/project/public/favicon.ico +0 -0
- data/lib/roda_gen/generators/templates/project/public/favicon.svg.tt +5 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/JetBrainsMono-Italic-Variable.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/JetBrainsMono-Variable.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-BoldItalic.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Italic.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NOTICE.md +17 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriac-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriac-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriacWestern-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriacWestern-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/manifest.webmanifest.tt +12 -0
- data/lib/roda_gen/generators/templates/project/public/robots.txt.tt +4 -0
- data/lib/roda_gen/generators/templates/project/public/service-worker.js.tt +27 -0
- data/lib/roda_gen/generators/templates/project/routes/account.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/routes/admin.rb.tt +118 -0
- data/lib/roda_gen/generators/templates/project/routes/gdpr.rb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/routes/heartbeat.rb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/routes/legal.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/routes/profile.rb.tt +56 -0
- data/lib/roda_gen/generators/templates/project/routes/push.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/role_boundary_spec.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/spec_helper.rb.tt +146 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/support/auth_helpers.rb.tt +71 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/auth_spec.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/consent_nojs_spec.rb.tt +60 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/create_account_form_spec.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/otp_lifecycle_spec.rb.tt +67 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/profile_form_spec.rb.tt +17 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/upload_spec.rb.tt +102 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/wcag/auth_pages_spec.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/wcag/legal_pages_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/base_spec.rb.tt +106 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/gdpr_worker_spec.rb.tt +72 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/push_sender_spec.rb.tt +74 -0
- data/lib/roda_gen/generators/templates/project/spec/locale_parity_spec.rb.tt +58 -0
- data/lib/roda_gen/generators/templates/project/spec/models/account_profile_spec.rb.tt +180 -0
- data/lib/roda_gen/generators/templates/project/spec/models/account_spec.rb.tt +104 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_actor_type_spec.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_log_spec.rb.tt +398 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_status_spec.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/spec/models/authorization_spec.rb.tt +82 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_calling_code_spec.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_exit_code_spec.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_language_spec.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_spec.rb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_time_zone_spec.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/spec/models/currency_spec.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/spec/models/deploy_check_spec.rb.tt +143 -0
- data/lib/roda_gen/generators/templates/project/spec/models/gdpr_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/models/language_spec.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/spec/models/rbac_audit_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/models/setting_system_default_spec.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/spec/models/setting_user_value_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/models/settings_spec.rb.tt +63 -0
- data/lib/roda_gen/generators/templates/project/spec/models/signup_form_data_spec.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/spec/spec_helper.rb.tt +93 -0
- data/lib/roda_gen/generators/templates/project/spec/support/audit_log_helpers.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/support/audit_lookup_shared_examples.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/spec/support/auth_helpers.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/support/faker.rb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/spec/web/admin_spec.rb.tt +155 -0
- data/lib/roda_gen/generators/templates/project/spec/web/audit_log_spec.rb.tt +159 -0
- data/lib/roda_gen/generators/templates/project/spec/web/auth_spec.rb.tt +492 -0
- data/lib/roda_gen/generators/templates/project/spec/web/authorization_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/web/boot_spec.rb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/spec/web/consent_banner_spec.rb.tt +46 -0
- data/lib/roda_gen/generators/templates/project/spec/web/feature_flag_helper_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/web/flags_spec.rb.tt +67 -0
- data/lib/roda_gen/generators/templates/project/spec/web/gdpr_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/heartbeat_spec.rb.tt +65 -0
- data/lib/roda_gen/generators/templates/project/spec/web/host_allowlist_spec.rb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/spec/web/legal_spec.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/spec/web/locale_resolver_spec.rb.tt +34 -0
- data/lib/roda_gen/generators/templates/project/spec/web/logger_helper_spec.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/spec/web/logger_spec.rb.tt +82 -0
- data/lib/roda_gen/generators/templates/project/spec/web/otp_audit_spec.rb.tt +147 -0
- data/lib/roda_gen/generators/templates/project/spec/web/profile_spec.rb.tt +97 -0
- data/lib/roda_gen/generators/templates/project/spec/web/push_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rack_attack_runtime_spec.rb.tt +52 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rack_attack_spec.rb.tt +81 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rbac_audit_spec.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/web/request_id_spec.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/web/role_boundary_spec.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/web/session_skip_spec.rb.tt +74 -0
- data/lib/roda_gen/generators/templates/project/spec/web/split_helper_spec.rb.tt +38 -0
- data/lib/roda_gen/generators/templates/project/spec/web/type_routing_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/upload_zone_spec.rb.tt +91 -0
- data/lib/roda_gen/generators/templates/project/tmp/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/vendor/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/views/403.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/404.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/500.erb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/views/_head_meta.erb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/views/_impersonate_picker.erb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/views/_language_switcher.erb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/views/_locked_accounts.erb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/views/_upload_zone.erb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/views/account/profile.erb.tt +149 -0
- data/lib/roda_gen/generators/templates/project/views/admin/flags.erb.tt +51 -0
- data/lib/roda_gen/generators/templates/project/views/consent_kit/_banner.erb.tt +59 -0
- data/lib/roda_gen/generators/templates/project/views/consent_kit/_preferences.erb.tt +87 -0
- data/lib/roda_gen/generators/templates/project/views/gdpr/erased.erb.tt +6 -0
- data/lib/roda_gen/generators/templates/project/views/gdpr/index.erb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/views/layout.erb.tt +112 -0
- data/lib/roda_gen/generators/templates/project/views/legal/contact.erb.tt +44 -0
- data/lib/roda_gen/generators/templates/project/views/legal/cookies.erb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/views/legal/disclaimer.erb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/views/legal/privacy.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/account_unlocked.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/data_erased.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/data_export.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/add-recovery-codes.erb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/change-login.erb.tt +44 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/change-password.erb.tt +41 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/close-account.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/confirm-password.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/create-account.erb.tt +183 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/login.erb.tt +51 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/logout.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-auth.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-disable.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-setup.erb.tt +48 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-unlock-not-available.erb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-unlock.erb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/recovery-auth.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/recovery-codes.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/remember.erb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/reset-password-request.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/reset-password.erb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-auth.erb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-disable.erb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-manage.erb.tt +36 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/unlock-account-request.erb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/unlock-account.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-account-resend.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-account.erb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-login-change.erb.tt +8 -0
- data/lib/roda_gen/generators/templates/route/routes/%plural%.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/route/spec/web/%plural%_spec.rb.tt +36 -0
- data/lib/roda_gen/generators/templates/route/views/%plural%/index.erb.tt +11 -0
- data/lib/roda_gen/generators/templates/route/views/%plural%/show.erb.tt +7 -0
- data/lib/roda_gen/generators/templates/upload/db/migrate/%migration_filename%.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/upload/helpers/upload_serving.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/upload/models/%resource_name%.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/upload/models/%resource_name%_uploader.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/upload/routes/%plural%.rb.tt +44 -0
- data/lib/roda_gen/generators/templates/upload/spec/web/%plural%_spec.rb.tt +56 -0
- data/lib/roda_gen/generators/templates/upload/views/%plural%/index.erb.tt +18 -0
- data/lib/roda_gen/generators/upload.rb +83 -0
- data/lib/roda_gen/project_context.rb +30 -0
- data/lib/roda_gen/version.rb +5 -0
- data/lib/roda_gen.rb +16 -0
- metadata +497 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
def boot_app_for_flags(env)
|
|
4
|
+
ENV['RACK_ENV'] = env || ENV['RACK_ENV'] || 'development'
|
|
5
|
+
ENV['DATABASE_ROLE'] = 'app'
|
|
6
|
+
require_relative '../../config/boot'
|
|
7
|
+
require_relative '../../config/database'
|
|
8
|
+
require_relative '../../<%= @app.snake %>'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
namespace :flags do
|
|
12
|
+
desc 'List every known feature flag and its state'
|
|
13
|
+
task :list, [:env] do |_t, args|
|
|
14
|
+
boot_app_for_flags(args[:env])
|
|
15
|
+
features = Flipper.features.sort_by(&:key)
|
|
16
|
+
if features.empty?
|
|
17
|
+
puts 'No flags yet. Create one by enabling it: rake flags:enable[my_flag]'
|
|
18
|
+
else
|
|
19
|
+
features.each { |f| puts format('%-30<key>s %<state>s', key: f.key, state: f.state) }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc 'Enable a feature flag fully (boolean gate)'
|
|
24
|
+
task :enable, %i[key env] do |_t, args|
|
|
25
|
+
abort 'Usage: rake flags:enable[key]' if args[:key].to_s.empty?
|
|
26
|
+
boot_app_for_flags(args[:env])
|
|
27
|
+
Flipper.enable(args[:key])
|
|
28
|
+
puts "Enabled #{args[:key]}."
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc 'Disable a feature flag'
|
|
32
|
+
task :disable, %i[key env] do |_t, args|
|
|
33
|
+
abort 'Usage: rake flags:disable[key]' if args[:key].to_s.empty?
|
|
34
|
+
boot_app_for_flags(args[:env])
|
|
35
|
+
Flipper.disable(args[:key])
|
|
36
|
+
puts "Disabled #{args[:key]}."
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
desc 'Roll a flag out to N% of actors (deterministic per account via flipper_id)'
|
|
40
|
+
task :percentage, %i[key n env] do |_t, args|
|
|
41
|
+
abort 'Usage: rake flags:percentage[key,N]' if args[:key].to_s.empty? || args[:n].to_s.empty?
|
|
42
|
+
boot_app_for_flags(args[:env])
|
|
43
|
+
pct = args[:n].to_i.clamp(0, 100)
|
|
44
|
+
Flipper.enable_percentage_of_actors(args[:key], pct)
|
|
45
|
+
puts "#{args[:key]} → #{pct}% of actors."
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Staff-run counterparts to the self-service /account/gdpr flow.
|
|
4
|
+
# App role since Gdpr reads and redacts audit_log
|
|
5
|
+
namespace :gdpr do
|
|
6
|
+
desc "GDPR Art. 15/20: print an account's data export as JSON"
|
|
7
|
+
task :export, %i[account_id env] do |_t, args|
|
|
8
|
+
abort 'Usage: rake gdpr:export[account_id]' if args[:account_id].to_s.empty?
|
|
9
|
+
ENV['RACK_ENV'] = args[:env] || ENV['RACK_ENV'] || 'development'
|
|
10
|
+
ENV['DATABASE_ROLE'] = 'app'
|
|
11
|
+
require_relative '../../<%= @app.snake %>'
|
|
12
|
+
require_relative '../../lib/gdpr'
|
|
13
|
+
|
|
14
|
+
account = Account[args[:account_id].to_i] || abort("No account #{args[:account_id]}.")
|
|
15
|
+
puts Gdpr.export(account).to_json
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
desc 'GDPR Art. 17: erase an account (anonymize + retain) and email confirmation'
|
|
19
|
+
task :erase, %i[account_id env] do |_t, args|
|
|
20
|
+
abort 'Usage: rake gdpr:erase[account_id]' if args[:account_id].to_s.empty?
|
|
21
|
+
ENV['RACK_ENV'] = args[:env] || ENV['RACK_ENV'] || 'development'
|
|
22
|
+
ENV['DATABASE_ROLE'] = 'app'
|
|
23
|
+
require_relative '../../<%= @app.snake %>'
|
|
24
|
+
require_relative '../../lib/gdpr'
|
|
25
|
+
|
|
26
|
+
account = Account[args[:account_id].to_i] || abort("No account #{args[:account_id]}.")
|
|
27
|
+
locale = (account.profile&.language || I18n.default_locale).to_s
|
|
28
|
+
<%= @app.camel %>Mailer.sendmail('/data-erased', Gdpr.erase!(account), locale)
|
|
29
|
+
puts "Erased account #{account.id}."
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# parser/current is frozen at Ruby 3.3 grammar and warns on every newer
|
|
4
|
+
# interpreter. Its README says to use prism's translation layer instead,
|
|
5
|
+
# but better_html (under erb_lint) passes a custom AST builder that the
|
|
6
|
+
# translation does not thread through, so its linters crash on plain
|
|
7
|
+
# AST::Node. Next best: declare the newest grammar the parser gem ships
|
|
8
|
+
# as current and mark parser/current loaded, then its version lookup, the
|
|
9
|
+
# ruby33 fallback and the warning never run.
|
|
10
|
+
require 'parser/ruby34'
|
|
11
|
+
|
|
12
|
+
Parser::CurrentRuby = Parser::Ruby34
|
|
13
|
+
$LOADED_FEATURES << File.join(Gem.loaded_specs['parser'].full_gem_path, 'lib', 'parser', 'current.rb')
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :quality do
|
|
4
|
+
begin
|
|
5
|
+
require 'rubocop/rake_task'
|
|
6
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
|
7
|
+
# --ignore-parent-exclusion: an ancestor directory's .rubocop.yml
|
|
8
|
+
# Exclude (a checkout under tmp/, a monorepo) must not blank this
|
|
9
|
+
# project's file discovery
|
|
10
|
+
t.options = ['--display-cop-names', '--ignore-parent-exclusion']
|
|
11
|
+
end
|
|
12
|
+
rescue LoadError
|
|
13
|
+
# Production bundle has no rubocop, the Rakefile must still load
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc 'Lint ERB views (erb_lint: project RuboCop on embedded Ruby + view checks)'
|
|
17
|
+
task :erb do
|
|
18
|
+
sh parser_shim_env, 'bundle exec erb_lint --lint-all'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc 'Generate a browsable code-quality report in tmp/rubycritic'
|
|
22
|
+
task :rubycritic do
|
|
23
|
+
merge_coverage_suites!
|
|
24
|
+
sh parser_shim_env, 'bundle exec rubycritic --coverage-path tmp/coverage/merged'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
desc 'Scan Gemfile.lock for known-vulnerable gem versions (offline)'
|
|
28
|
+
task :audit do
|
|
29
|
+
sh 'bundle exec bundle-audit check'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
namespace :audit do
|
|
33
|
+
desc 'Refresh the ruby-advisory-db, then scan'
|
|
34
|
+
task :update do
|
|
35
|
+
sh 'bundle exec bundle-audit check --update'
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
desc 'Run the quality suite: rubocop + erb_lint + bundler-audit gate, then the rubycritic report'
|
|
40
|
+
task all: %w[quality:rubocop quality:erb quality:audit quality:rubycritic]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# RubyCritic reads only the first suite in SimpleCov's resultset
|
|
44
|
+
# (results.first), so with tiered suites its coverage tab shows one
|
|
45
|
+
# tier's numbers as the whole truth. Collapse the suites into a single
|
|
46
|
+
# merged resultset in a side directory for rubycritic's eyes only: the
|
|
47
|
+
# merged entry holds no branch data, written into the live resultset it
|
|
48
|
+
# would poison the next report's branch totals.
|
|
49
|
+
# Preloads parser_current_shim.rb into tools that load parser/current,
|
|
50
|
+
# see the comment there
|
|
51
|
+
def parser_shim_env
|
|
52
|
+
{ 'RUBYOPT' => "#{ENV['RUBYOPT']} -r#{File.expand_path('parser_current_shim', __dir__)}".strip }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def merge_coverage_suites!
|
|
56
|
+
path = 'tmp/coverage/.resultset.json'
|
|
57
|
+
return unless File.exist?(path)
|
|
58
|
+
|
|
59
|
+
require 'json'
|
|
60
|
+
require 'fileutils'
|
|
61
|
+
suites = JSON.parse(File.read(path))
|
|
62
|
+
|
|
63
|
+
merged = {}
|
|
64
|
+
suites.each_value do |data|
|
|
65
|
+
data['coverage'].each do |file, cov|
|
|
66
|
+
lines = cov.is_a?(Hash) ? cov['lines'] : cov
|
|
67
|
+
merged[file] = merge_line_hits(merged[file], lines)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
coverage = merged.transform_values { |lines| { 'lines' => lines } }
|
|
72
|
+
FileUtils.mkdir_p('tmp/coverage/merged')
|
|
73
|
+
File.write('tmp/coverage/merged/.resultset.json',
|
|
74
|
+
JSON.generate('RSpec:merged' => { 'coverage' => coverage, 'timestamp' => Time.now.to_i }))
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# A line stays nil only while every suite skips it, otherwise hits add up
|
|
78
|
+
def merge_line_hits(target, lines)
|
|
79
|
+
target ||= Array.new(lines.length)
|
|
80
|
+
lines.each_with_index do |hits, i|
|
|
81
|
+
target[i] = hits.nil? && target[i].nil? ? nil : (target[i] || 0) + (hits || 0)
|
|
82
|
+
end
|
|
83
|
+
target
|
|
84
|
+
end
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'securerandom'
|
|
5
|
+
require 'web-push'
|
|
6
|
+
|
|
7
|
+
DEV_LOCAL_PATH = 'config/settings/development.local.yml'
|
|
8
|
+
TEST_LOCAL_PATH = 'config/settings/test.local.yml'
|
|
9
|
+
|
|
10
|
+
# Only secrets here, non-secret config (redis, site.domain) lives in settings/<env>.yml
|
|
11
|
+
SECRET_TEMPLATE = <<~YML
|
|
12
|
+
database:
|
|
13
|
+
url: "postgres://<%= @app.snake %>_web:replace_me_with_securerandom_urlsafe_base64_32@localhost:5432/<%= @app.snake %>_development"
|
|
14
|
+
app_url: "postgres://<%= @app.snake %>_app:replace_me_with_securerandom_urlsafe_base64_32@localhost:5432/<%= @app.snake %>_development"
|
|
15
|
+
|
|
16
|
+
rodauth:
|
|
17
|
+
hmac_secret: "replace_me_with_securerandom_hex_32"
|
|
18
|
+
argon2_secret: "replace_me_with_securerandom_hex_32"
|
|
19
|
+
|
|
20
|
+
consent:
|
|
21
|
+
signing_key: "replace_me_with_securerandom_hex_64"
|
|
22
|
+
ip_hash_salt: "replace_me_with_securerandom_hex_32"
|
|
23
|
+
|
|
24
|
+
mail:
|
|
25
|
+
accounts:
|
|
26
|
+
default:
|
|
27
|
+
smtp:
|
|
28
|
+
address: "smtp.office365.com"
|
|
29
|
+
port: 587
|
|
30
|
+
user_name: ""
|
|
31
|
+
password: ""
|
|
32
|
+
authentication: "login"
|
|
33
|
+
enable_starttls_auto: true
|
|
34
|
+
|
|
35
|
+
web_push:
|
|
36
|
+
public_key: "replace_me_with_vapid_public_key"
|
|
37
|
+
private_key: "replace_me_with_vapid_private_key"
|
|
38
|
+
YML
|
|
39
|
+
|
|
40
|
+
DEV_HEADER = <<~YML
|
|
41
|
+
# Dev secrets, gitignored. Written by rake secrets:install, rotate select keys with rake secrets:rotate
|
|
42
|
+
|
|
43
|
+
YML
|
|
44
|
+
|
|
45
|
+
TEST_HEADER = <<~YML
|
|
46
|
+
# Test secrets, gitignored. Same postgres roles as dev, DB name _test
|
|
47
|
+
|
|
48
|
+
YML
|
|
49
|
+
|
|
50
|
+
PROD_HEADER = <<~YML
|
|
51
|
+
# Production secrets, write to config/settings/production.local.yml on the server at mode 0600.
|
|
52
|
+
# Set the SMTP credentials and the prod DB host before deploy, never reuse dev or test values
|
|
53
|
+
|
|
54
|
+
YML
|
|
55
|
+
|
|
56
|
+
# Regex over Psych since the AST emitter strips comments on round-trip
|
|
57
|
+
ROTATABLE = [
|
|
58
|
+
['signing_key', 64],
|
|
59
|
+
['ip_hash_salt', 32]
|
|
60
|
+
].freeze
|
|
61
|
+
|
|
62
|
+
def render_secrets(header:, web_pass:, app_pass:, db_env:)
|
|
63
|
+
vapid = WebPush.generate_key
|
|
64
|
+
body = SECRET_TEMPLATE
|
|
65
|
+
.gsub('_development"', %(_#{db_env}"))
|
|
66
|
+
.gsub(/(_web):replace_me_with_securerandom_urlsafe_base64_32/) { "#{Regexp.last_match(1)}:#{web_pass}" }
|
|
67
|
+
.gsub(/(_app):replace_me_with_securerandom_urlsafe_base64_32/) { "#{Regexp.last_match(1)}:#{app_pass}" }
|
|
68
|
+
.gsub('replace_me_with_securerandom_hex_64') { SecureRandom.hex(64) }
|
|
69
|
+
.gsub('replace_me_with_securerandom_hex_32') { SecureRandom.hex(32) }
|
|
70
|
+
.gsub('replace_me_with_vapid_public_key') { vapid.public_key }
|
|
71
|
+
.gsub('replace_me_with_vapid_private_key') { vapid.private_key }
|
|
72
|
+
header + body
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def write_unless_exists(path, content)
|
|
76
|
+
if File.exist?(path)
|
|
77
|
+
puts "→ #{path} already exists; skipping"
|
|
78
|
+
return
|
|
79
|
+
end
|
|
80
|
+
FileUtils.mkdir_p(File.dirname(path))
|
|
81
|
+
File.write(path, content)
|
|
82
|
+
puts "→ wrote #{path}"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def rotate_yaml(path)
|
|
86
|
+
abort "missing #{path} — run `rake secrets:install`" unless File.exist?(path)
|
|
87
|
+
|
|
88
|
+
content = File.read(path)
|
|
89
|
+
replaced = []
|
|
90
|
+
|
|
91
|
+
ROTATABLE.each do |key, bytes|
|
|
92
|
+
value = SecureRandom.hex(bytes)
|
|
93
|
+
# Single-line match, defends against unquoted lines
|
|
94
|
+
next unless content.sub!(/^(\s*#{Regexp.escape(key)}:\s*)"[^"\n]*"/, "\\1\"#{value}\"")
|
|
95
|
+
|
|
96
|
+
replaced << key
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
replaced.concat(rotate_vapid_pair(content))
|
|
100
|
+
|
|
101
|
+
File.write(path, content)
|
|
102
|
+
report_rotation(path, replaced)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# VAPID keys only work as a matched pair, so both regenerate together.
|
|
106
|
+
# sub! mutates content in place
|
|
107
|
+
def rotate_vapid_pair(content)
|
|
108
|
+
vapid = WebPush.generate_key
|
|
109
|
+
public_ok = content.sub!(/^(\s*public_key:\s*)"[^"\n]*"/) { "#{Regexp.last_match(1)}\"#{vapid.public_key}\"" }
|
|
110
|
+
private_ok = content.sub!(/^(\s*private_key:\s*)"[^"\n]*"/) { "#{Regexp.last_match(1)}\"#{vapid.private_key}\"" }
|
|
111
|
+
public_ok && private_ok ? ['web_push keypair'] : []
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def report_rotation(path, replaced)
|
|
115
|
+
if replaced.empty?
|
|
116
|
+
puts "no rotatable keys found in #{path}"
|
|
117
|
+
else
|
|
118
|
+
puts "rotated in #{path}: #{replaced.join(', ')}"
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
namespace :secrets do
|
|
123
|
+
desc 'Generate gitignored settings/{development,test}.local.yml (idempotent)'
|
|
124
|
+
task :install do
|
|
125
|
+
# Dev and test share the <%= @app.snake %>_web / _app roles, so same passwords
|
|
126
|
+
web_pass = SecureRandom.urlsafe_base64(32)
|
|
127
|
+
app_pass = SecureRandom.urlsafe_base64(32)
|
|
128
|
+
|
|
129
|
+
write_unless_exists(
|
|
130
|
+
DEV_LOCAL_PATH,
|
|
131
|
+
render_secrets(header: DEV_HEADER, web_pass: web_pass, app_pass: app_pass, db_env: 'development')
|
|
132
|
+
)
|
|
133
|
+
write_unless_exists(
|
|
134
|
+
TEST_LOCAL_PATH,
|
|
135
|
+
render_secrets(header: TEST_HEADER, web_pass: web_pass, app_pass: app_pass, db_env: 'test')
|
|
136
|
+
)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
desc 'Rotate consent keys + the web_push VAPID keypair in the local secret files (invalidates push subscriptions)'
|
|
140
|
+
task :rotate do
|
|
141
|
+
rotate_yaml(DEV_LOCAL_PATH)
|
|
142
|
+
rotate_yaml(TEST_LOCAL_PATH) if File.exist?(TEST_LOCAL_PATH)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
desc 'Print production secrets (config/settings/production.local.yml) to stdout for provisioning'
|
|
146
|
+
task :print do
|
|
147
|
+
puts render_secrets(
|
|
148
|
+
header: PROD_HEADER,
|
|
149
|
+
web_pass: SecureRandom.urlsafe_base64(32),
|
|
150
|
+
app_pass: SecureRandom.urlsafe_base64(32),
|
|
151
|
+
db_env: 'production'
|
|
152
|
+
)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
# Path must match spec/spec_helper.rb
|
|
6
|
+
SPEC_SUMMARY_DIR = 'tmp/spec_summary'
|
|
7
|
+
|
|
8
|
+
def rspec(spec_path)
|
|
9
|
+
sh "bundle exec rspec #{spec_path}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
namespace :test do
|
|
13
|
+
desc 'Bootstrap the test DB: createdb + bounce + seed + audit partitions'
|
|
14
|
+
# RACK_ENV first, config/database freezes the connection at first load
|
|
15
|
+
task :db do
|
|
16
|
+
ENV['RACK_ENV'] = 'test'
|
|
17
|
+
Rake::Task['db:create'].invoke('test')
|
|
18
|
+
Rake::Task['db:bounce'].invoke('test')
|
|
19
|
+
Rake::Task['db:seed'].invoke('test')
|
|
20
|
+
# Without partitions audit rows land in audit_log_default and partition grants stay untested
|
|
21
|
+
Rake::Task['audit:add_next'].invoke('5', '', 'test')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc 'Run model specs'
|
|
25
|
+
task model: 'test:db' do
|
|
26
|
+
# Set explicitly, spec_helper's ||= would keep the leftover from test:db
|
|
27
|
+
ENV['DATABASE_ROLE'] = 'app'
|
|
28
|
+
rspec('spec/models')
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc 'Run web specs'
|
|
32
|
+
task web: 'test:db' do
|
|
33
|
+
ENV['DATABASE_ROLE'] = 'web'
|
|
34
|
+
rspec('spec/web')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
desc 'Run daemon specs'
|
|
38
|
+
task daemon: 'test:db' do
|
|
39
|
+
ENV['DATABASE_ROLE'] = 'app'
|
|
40
|
+
rspec('spec/daemons')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
desc 'Run locale parity check (pure YAML structural check, no DB)'
|
|
44
|
+
task :locale do
|
|
45
|
+
rspec('spec/locale_parity_spec.rb')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
desc 'Run all browser specs, `rake test:browser[chromium]` picks the engine (firefox default)'
|
|
49
|
+
task :browser, %i[browser] => 'test:db' do |_, args|
|
|
50
|
+
ENV['DATABASE_ROLE'] = 'web'
|
|
51
|
+
ENV['PLAYWRIGHT_BROWSER'] = (args[:browser] || 'firefox').to_s
|
|
52
|
+
rspec('spec/browser')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
namespace :browser do
|
|
56
|
+
desc 'Run WCAG axe checks (always firefox, axe rules are browser-independent)'
|
|
57
|
+
task wcag: 'test:db' do
|
|
58
|
+
ENV['DATABASE_ROLE'] = 'web'
|
|
59
|
+
ENV['PLAYWRIGHT_BROWSER'] = 'firefox'
|
|
60
|
+
rspec('spec/browser/wcag')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
desc 'Run UAT specs, `rake test:browser:uat[chromium]` picks the engine (firefox default)'
|
|
64
|
+
task :uat, %i[browser] => 'test:db' do |_, args|
|
|
65
|
+
ENV['DATABASE_ROLE'] = 'web'
|
|
66
|
+
ENV['PLAYWRIGHT_BROWSER'] = (args[:browser] || 'firefox').to_s
|
|
67
|
+
rspec('spec/browser/uat')
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
desc '(internal) Print the end-of-run summary (suites + coverage + rubycritic)'
|
|
72
|
+
task :summary do
|
|
73
|
+
suites = []
|
|
74
|
+
if Dir.exist?(SPEC_SUMMARY_DIR)
|
|
75
|
+
Dir["#{SPEC_SUMMARY_DIR}/*.json"].each do |path|
|
|
76
|
+
s = JSON.parse(File.read(path)).fetch('summary')
|
|
77
|
+
parts = ["#{s['example_count']} examples", "#{s['failure_count']} failures"]
|
|
78
|
+
parts << "#{s['pending_count']} pending" if s['pending_count'].to_i.positive?
|
|
79
|
+
suites << [File.basename(path, '.json'), parts.join(', ')]
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
metrics = []
|
|
84
|
+
require 'simplecov'
|
|
85
|
+
# This rake process never ran SimpleCov.start, point it at the suite's dir
|
|
86
|
+
SimpleCov.coverage_dir 'tmp/coverage'
|
|
87
|
+
# Toggle branch coverage BEFORE reading, else only line totals come back
|
|
88
|
+
SimpleCov.enable_coverage :branch
|
|
89
|
+
if (result = SimpleCov::ResultMerger.merged_result) && !result.total_lines.zero?
|
|
90
|
+
cov = ["lines #{result.covered_percent.round(2)}% (#{result.covered_lines}/#{result.total_lines})"]
|
|
91
|
+
if (b = result.coverage_statistics[:branch])
|
|
92
|
+
cov << "branches #{b.percent.round(2)}% (#{b.covered}/#{b.total})"
|
|
93
|
+
end
|
|
94
|
+
metrics << ['coverage', cov.join(', ')]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
report = 'tmp/rubycritic/report.json'
|
|
98
|
+
if File.exist?(report) && (rc = JSON.parse(File.read(report))) && rc['score']
|
|
99
|
+
modules = rc['analysed_modules'] || []
|
|
100
|
+
smells = modules.sum { |m| (m['smells'] || []).size }
|
|
101
|
+
unit = smells == 1 ? 'smell' : 'smells'
|
|
102
|
+
detail = "score #{rc['score'].round(2)}, #{smells} #{unit} in #{modules.size} files"
|
|
103
|
+
metrics << ['rubycritic', "#{detail} (report: tmp/rubycritic/overview.html)"]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
next if suites.empty? && metrics.empty?
|
|
107
|
+
|
|
108
|
+
width = (suites + metrics).map { |label, _| label.length }.max
|
|
109
|
+
puts "\nSummary:"
|
|
110
|
+
suites.each { |label, value| puts " #{label.ljust(width)} #{value}" }
|
|
111
|
+
puts unless suites.empty? || metrics.empty?
|
|
112
|
+
metrics.each { |label, value| puts " #{label.ljust(width)} #{value}" }
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
desc 'Full release gate: all RSpec suites + quality (rubocop, erb_lint, bundler-audit, rubycritic) + coverage'
|
|
116
|
+
task :all do
|
|
117
|
+
FileUtils.rm_rf(SPEC_SUMMARY_DIR)
|
|
118
|
+
Rake::Task['test:db'].invoke
|
|
119
|
+
|
|
120
|
+
failed = []
|
|
121
|
+
%w[
|
|
122
|
+
test:model test:web test:daemon test:locale test:browser
|
|
123
|
+
quality:rubocop quality:erb quality:audit quality:rubycritic
|
|
124
|
+
].each do |t|
|
|
125
|
+
Rake::Task[t].invoke
|
|
126
|
+
rescue StandardError
|
|
127
|
+
failed << t
|
|
128
|
+
ensure
|
|
129
|
+
Rake::Task[t].reenable
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
Rake::Task['test:summary'].invoke
|
|
133
|
+
|
|
134
|
+
abort "\ntest:all FAILED: #{failed.join(', ')}" if failed.any?
|
|
135
|
+
end
|
|
136
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :split do
|
|
4
|
+
desc 'Print A/B experiment results (participants + conversions) from Redis, replaces Split::Dashboard'
|
|
5
|
+
task :results, [:env] do |_t, args|
|
|
6
|
+
ENV['RACK_ENV'] = args[:env] || ENV['RACK_ENV'] || 'development'
|
|
7
|
+
ENV['DATABASE_ROLE'] = 'app'
|
|
8
|
+
require_relative '../../config/boot'
|
|
9
|
+
require_relative '../../config/database'
|
|
10
|
+
require_relative '../../<%= @app.snake %>'
|
|
11
|
+
|
|
12
|
+
experiments = Split::ExperimentCatalog.all
|
|
13
|
+
if experiments.empty?
|
|
14
|
+
puts 'No experiments recorded yet.'
|
|
15
|
+
next
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
experiments.each do |experiment|
|
|
19
|
+
puts experiment.name
|
|
20
|
+
experiment.alternatives.each do |alt|
|
|
21
|
+
puts format(' %-20<name>s participants=%<participants>-8d completed=%<completed>-8d rate=%<rate>.2f%%',
|
|
22
|
+
name: alt.name, participants: alt.participant_count,
|
|
23
|
+
completed: alt.completed_count, rate: alt.conversion_rate * 100)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :tailwind do
|
|
4
|
+
desc 'Build all CSS bundles via the @tailwindcss/cli npm binary'
|
|
5
|
+
task :build do
|
|
6
|
+
require_relative '../../config/boot'
|
|
7
|
+
require 'roda'
|
|
8
|
+
|
|
9
|
+
# Only 43_static.rb for the bundle list, a full boot opens a DB connection that
|
|
10
|
+
# doesn't exist yet during bin/setup. Its configure block needs :environments
|
|
11
|
+
unless defined?(<%= @app.camel %>)
|
|
12
|
+
klass = Class.new(Roda)
|
|
13
|
+
klass.plugin :environments
|
|
14
|
+
Object.const_set(:<%= @app.camel %>, klass)
|
|
15
|
+
load File.expand_path('../../config/initializers/43_static.rb', __dir__)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
cli = File.expand_path('../../node_modules/.bin/tailwindcss', __dir__)
|
|
19
|
+
unless File.executable?(cli)
|
|
20
|
+
abort "→ #{cli} not found. Run `npm install` (bin/setup does this) before building CSS."
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
minify = ENV['RACK_ENV'] == 'production'
|
|
24
|
+
<%= @app.camel %>.assets_opts[:css].each_key do |bundle|
|
|
25
|
+
input = "assets/stylesheets/#{bundle}.css"
|
|
26
|
+
output = "assets/stylesheets/.compiled/#{bundle}.css"
|
|
27
|
+
next unless File.exist?(input)
|
|
28
|
+
|
|
29
|
+
mkdir_p File.dirname(output)
|
|
30
|
+
args = [cli, '-i', input, '-o', output]
|
|
31
|
+
args << '--minify' if minify
|
|
32
|
+
sh(*args)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|