tiun 0.0.2 → 0.1.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 +4 -4
- data/.forgejo/workflows/codeberg-tests.yml +226 -0
- data/.gitignore +7 -3
- data/.prettierrc.json +5 -0
- data/.rubocop.yml +221 -0
- data/AGENTS.md +132 -0
- data/Appraisals +18 -0
- data/CONTRIBUTING.md +80 -0
- data/CONTRIBUTING.ru.md +326 -0
- data/Gemfile +20 -1
- data/README.md +52 -23
- data/README.ru.md +72 -0
- data/Rakefile +10 -4
- data/TODO +2 -6
- data/bin/console +4 -3
- data/config/cucumber.yml +1 -0
- data/cucumber.mjs +6 -0
- data/docs/backend.md +73 -0
- data/docs/backend.ru.md +73 -0
- data/docs/components/approved.md +39 -0
- data/docs/components/approved.ru.md +39 -0
- data/docs/components/attachment-field.md +7 -0
- data/docs/components/attachment-field.ru.md +8 -0
- data/docs/components/attachment.md +48 -0
- data/docs/components/attachment.ru.md +48 -0
- data/docs/components/avatar.md +39 -0
- data/docs/components/avatar.ru.md +37 -0
- data/docs/components/chip.md +119 -0
- data/docs/components/chip.ru.md +99 -0
- data/docs/components/configuration.md +137 -0
- data/docs/components/configuration.ru.md +138 -0
- data/docs/components/daylight.md +41 -0
- data/docs/components/daylight.ru.md +41 -0
- data/docs/components/defaults.md +148 -0
- data/docs/components/defaults.ru.md +149 -0
- data/docs/components/documents.md +64 -0
- data/docs/components/documents.ru.md +64 -0
- data/docs/components/external-form-fields.ru.md +137 -0
- data/docs/components/external-renderers.md +50 -0
- data/docs/components/external-renderers.ru.md +51 -0
- data/docs/components/feedback.md +76 -0
- data/docs/components/feedback.ru.md +76 -0
- data/docs/components/footer.md +49 -0
- data/docs/components/footer.ru.md +49 -0
- data/docs/components/forms.md +177 -0
- data/docs/components/forms.ru.md +177 -0
- data/docs/components/images.md +111 -0
- data/docs/components/images.ru.md +111 -0
- data/docs/components/index.md +140 -0
- data/docs/components/index.ru.md +140 -0
- data/docs/components/intro.md +150 -0
- data/docs/components/intro.ru.md +150 -0
- data/docs/components/login.md +600 -0
- data/docs/components/login.ru.md +602 -0
- data/docs/components/methods.md +59 -0
- data/docs/components/methods.ru.md +59 -0
- data/docs/components/player.md +72 -0
- data/docs/components/player.ru.md +69 -0
- data/docs/components/profile.md +82 -0
- data/docs/components/profile.ru.md +82 -0
- data/docs/components/record-manager.md +69 -0
- data/docs/components/record-manager.ru.md +69 -0
- data/docs/components/row-column.ru.md +51 -0
- data/docs/components/rtfer.md +76 -0
- data/docs/components/rtfer.ru.md +76 -0
- data/docs/components/schema-calendar.md +86 -0
- data/docs/components/schema-calendar.ru.md +84 -0
- data/docs/components/schema-records.md +166 -0
- data/docs/components/schema-records.ru.md +166 -0
- data/docs/components/signup.md +194 -0
- data/docs/components/signup.ru.md +194 -0
- data/docs/components/slug-flow.md +97 -0
- data/docs/components/slug-flow.ru.md +59 -0
- data/docs/components/stockee.md +21 -0
- data/docs/components/stockee.ru.md +21 -0
- data/docs/components/text-views.md +64 -0
- data/docs/components/text-views.ru.md +57 -0
- data/docs/components/theme.md +212 -0
- data/docs/components/theme.ru.md +212 -0
- data/docs/components/tooltip.md +37 -0
- data/docs/components/tooltip.ru.md +30 -0
- data/docs/components/validation.md +153 -0
- data/docs/components/validation.ru.md +154 -0
- data/docs/components.md +31 -0
- data/docs/components.ru.md +31 -0
- data/docs/controller-names.md +23 -0
- data/docs/controller-names.ru.md +23 -0
- data/docs/examples/dneslov-frontend.md +38 -0
- data/docs/examples/dneslov-frontend.ru.md +39 -0
- data/docs/examples/dneslov-frontend.yaml +266 -0
- data/docs/frontend.md +316 -0
- data/docs/frontend.ru.md +332 -0
- data/docs/migrations/component-configuration.md +48 -0
- data/docs/migrations/component-configuration.ru.md +40 -0
- data/docs/migrations/component-shell-proposal.md +108 -0
- data/docs/migrations/component-shell-proposal.ru.md +150 -0
- data/docs/migrations/theme-layout.md +83 -0
- data/docs/migrations/theme-layout.ru.md +97 -0
- data/docs/reference.md +45 -0
- data/docs/reference.ru.md +1763 -0
- data/docs/resources.md +348 -0
- data/docs/resources.ru.md +349 -0
- data/docs/tasks/DNE-542.md +11 -0
- data/docs/tasks/DNE-566.md +8 -0
- data/docs/tasks/chip-segments.md +54 -0
- data/docs/tasks/configured-profile.md +73 -0
- data/docs/tasks/frontend/auth-form.md +7 -0
- data/docs/tasks/frontend/avatar.md +5 -0
- data/docs/tasks/frontend/component-removal.md +11 -0
- data/docs/tasks/frontend/dynamic-field.md +6 -0
- data/docs/tasks/frontend/field-caption.md +38 -0
- data/docs/tasks/frontend/form-core.md +65 -0
- data/docs/tasks/frontend/form-field-context.md +16 -0
- data/docs/tasks/frontend/form-session-renewal.md +58 -0
- data/docs/tasks/frontend/frontend-components.md +7 -0
- data/docs/tasks/frontend/frontend-docs.md +6 -0
- data/docs/tasks/frontend/frontend-layout.md +13 -0
- data/docs/tasks/frontend/frontend-methods.md +15 -0
- data/docs/tasks/frontend/frontend-other.md +13 -0
- data/docs/tasks/frontend/frontend-services.md +7 -0
- data/docs/tasks/frontend/fusion.md +22 -0
- data/docs/tasks/frontend/heading-core.md +5 -0
- data/docs/tasks/frontend/i18n-scope.md +37 -0
- data/docs/tasks/frontend/index-runtime.md +48 -0
- data/docs/tasks/frontend/inline-form.md +7 -0
- data/docs/tasks/frontend/intro-core.md +11 -0
- data/docs/tasks/frontend/login.md +8 -0
- data/docs/tasks/frontend/menu-branch.md +5 -0
- data/docs/tasks/frontend/paginator.md +7 -0
- data/docs/tasks/frontend/records-core.md +35 -0
- data/docs/tasks/frontend/resource-source-core.md +12 -0
- data/docs/tasks/frontend/signup.md +8 -0
- data/docs/tasks/frontend/span-body.md +16 -0
- data/docs/tasks/frontend/text-commonee.md +48 -0
- data/docs/tasks/frontend/theme-field.md +31 -0
- data/docs/tasks/frontend/theme-menu.md +8 -0
- data/docs/tasks/frontend/theme-settings.md +10 -0
- data/docs/tasks/frontend/view-content-core.md +12 -0
- data/docs/tasks/frontend/view-source-core.md +12 -0
- data/docs/tasks/ruby-extension-compatibility.ru.md +74 -0
- data/docs/tasks/todo-code-climate.md +8 -0
- data/docs/tasks/todo-compatibility.md +50 -0
- data/docs/tasks/todo-reek.md +5 -0
- data/docs/tasks/todo-yard-inch.md +7 -0
- data/eslint.config.mjs +15 -0
- data/exe/tiun +1 -0
- data/gemfiles/rails_7_0.gemfile +16 -0
- data/gemfiles/rails_7_2.gemfile +17 -0
- data/lib/config/locale/browser.en.yml +43 -0
- data/lib/config/locale/browser.ru.yml +35 -0
- data/lib/config/locale/confirmation.en.yml +16 -0
- data/lib/config/locale/confirmation.ru.yml +16 -0
- data/lib/config/locale/errors.en.yml +57 -0
- data/lib/config/locale/errors.ru.yml +47 -0
- data/lib/config/locale/form_delay.en.yml +11 -0
- data/lib/config/locale/form_delay.ru.yml +11 -0
- data/lib/config/locale/recovery.en.yml +14 -0
- data/lib/config/locale/ru.yml +272 -6
- data/lib/config/routes.rb +5 -11
- data/lib/tasks/tiun/translations.rake +12 -0
- data/lib/tiun/actor/validate.rb +3 -2
- data/lib/tiun/actor.rb +13 -10
- data/lib/tiun/api_not_found.rb +16 -0
- data/lib/tiun/attributes.rb +8 -7
- data/lib/tiun/auth/attribute_models.rb +32 -0
- data/lib/tiun/auth/controller/discord.rb +26 -0
- data/lib/tiun/auth/controller/facebook.rb +62 -0
- data/lib/tiun/auth/controller/github.rb +37 -0
- data/lib/tiun/auth/controller/kakao.rb +33 -0
- data/lib/tiun/auth/controller/oauth.rb +167 -0
- data/lib/tiun/auth/controller/ok.rb +8 -0
- data/lib/tiun/auth/controller/telegram.rb +188 -0
- data/lib/tiun/auth/controller/vk.rb +85 -0
- data/lib/tiun/auth/controller/wechat.rb +58 -0
- data/lib/tiun/auth/controller/weibo.rb +28 -0
- data/lib/tiun/auth/controller.rb +467 -150
- data/lib/tiun/auth/json_session.rb +19 -0
- data/lib/tiun/auth/token_identity.rb +37 -0
- data/lib/tiun/auth/user_identity.rb +27 -0
- data/lib/tiun/auth/views/oauth_address.html.erb +23 -0
- data/lib/tiun/auth.rb +184 -45
- data/lib/tiun/carrier_wave_store.rb +59 -0
- data/lib/tiun/cli.rb +52 -32
- data/lib/tiun/concern/resources.rb +85 -0
- data/lib/tiun/config_source.rb +52 -0
- data/lib/tiun/content_range.rb +123 -0
- data/lib/tiun/context/merge.rb +117 -0
- data/lib/tiun/context.rb +39 -0
- data/lib/tiun/controller/auth/identity.rb +201 -0
- data/lib/tiun/controller/auth/registration.rb +23 -0
- data/lib/tiun/controller/auth.rb +198 -0
- data/lib/tiun/controller/auto.rb.erb +10 -0
- data/lib/tiun/controller/base/actions.rb +156 -0
- data/lib/tiun/controller/base/assignment.rb +101 -0
- data/lib/tiun/controller/base/parameters.rb +198 -0
- data/lib/tiun/controller/base/params.rb +166 -0
- data/lib/tiun/controller/base/records.rb +107 -0
- data/lib/tiun/controller/base/representation.rb +97 -0
- data/lib/tiun/controller/base/scopes.rb +132 -0
- data/lib/tiun/controller/base.rb +52 -0
- data/lib/tiun/controller/component_assets.rb +96 -0
- data/lib/tiun/controller/meta.rb +248 -0
- data/lib/tiun/controller/translations.rb +22 -0
- data/lib/tiun/controller.rb +13 -0
- data/lib/tiun/core/boot.rb +210 -0
- data/lib/tiun/core/contexts.rb +53 -0
- data/lib/tiun/core/controller_contexts.rb +42 -0
- data/lib/tiun/core/defaults.rb +215 -0
- data/lib/tiun/core/evaluation.rb +105 -0
- data/lib/tiun/core/field_attributes.rb +78 -0
- data/lib/tiun/core/files.rb +153 -0
- data/lib/tiun/core/generation.rb +234 -0
- data/lib/tiun/core/methods.rb +104 -0
- data/lib/tiun/core/names.rb +140 -0
- data/lib/tiun/core/registry.rb +97 -0
- data/lib/tiun/core/reloading.rb +77 -0
- data/lib/tiun/core/resources.rb +308 -0
- data/lib/tiun/core/routing/forward.rb +206 -0
- data/lib/tiun/core/routing.rb +323 -0
- data/lib/tiun/core/types.rb +88 -0
- data/lib/tiun/core.rb +26 -0
- data/lib/tiun/core_helper.rb +85 -13
- data/lib/tiun/engine.rb +64 -20
- data/lib/tiun/error_handling.rb +121 -0
- data/lib/tiun/hooks.rb +131 -0
- data/lib/tiun/mailer/confirmation.rb +37 -0
- data/lib/tiun/mailer/recovery.rb +16 -0
- data/lib/tiun/migration.rb +72 -50
- data/lib/tiun/mixins.rb +128 -19
- data/lib/tiun/model/account/identity.rb +93 -0
- data/lib/tiun/model/account.rb +180 -7
- data/lib/tiun/model/auth/bcrypt.rb +47 -0
- data/lib/tiun/model/auth.rb +162 -36
- data/lib/tiun/model/auto.rb.erb +12 -0
- data/lib/tiun/model/me.rb +133 -0
- data/lib/tiun/model/settings.rb +186 -0
- data/lib/tiun/model/token/recovery.rb +48 -0
- data/lib/tiun/model/token.rb +37 -3
- data/lib/tiun/model.rb +82 -69
- data/lib/tiun/notification/service.rb +18 -0
- data/lib/tiun/notification.rb +6 -0
- data/lib/tiun/policy/default.rb +7 -0
- data/lib/tiun/policy.rb +84 -8
- data/lib/tiun/proceed/allowed_errors.rb +217 -0
- data/lib/tiun/proceed/auth.rb +50 -0
- data/lib/tiun/proceed/description.rb +89 -0
- data/lib/tiun/proceed/enums.rb +225 -0
- data/lib/tiun/proceed/hooks.rb +51 -0
- data/lib/tiun/proceed/pass_over_paths.rb +40 -0
- data/lib/tiun/proceed/policy.rb +172 -0
- data/lib/tiun/proceed/registration.rb +69 -0
- data/lib/tiun/proceed/schemas/component_nodes.rb +436 -0
- data/lib/tiun/proceed/schemas/constants.rb +116 -0
- data/lib/tiun/proceed/schemas/content.rb +68 -0
- data/lib/tiun/proceed/schemas/definitions.rb +181 -0
- data/lib/tiun/proceed/schemas/dictionary.rb +144 -0
- data/lib/tiun/proceed/schemas/fields.rb +182 -0
- data/lib/tiun/proceed/schemas/models.rb +50 -0
- data/lib/tiun/proceed/schemas/spans.rb +86 -0
- data/lib/tiun/proceed/schemas/values.rb +94 -0
- data/lib/tiun/proceed/schemas/view_paths.rb +86 -0
- data/lib/tiun/proceed/schemas/view_readiness.rb +51 -0
- data/lib/tiun/proceed/schemas/views.rb +192 -0
- data/lib/tiun/proceed/schemas.rb +137 -0
- data/lib/tiun/proceed/services.rb +79 -0
- data/lib/tiun/proceed/token_lifetimes.rb +49 -0
- data/lib/tiun/proceed/translations.rb +45 -0
- data/lib/tiun/proceed/versions.rb +315 -0
- data/lib/tiun/proceed.rb +23 -0
- data/lib/tiun/router.rb +40 -0
- data/lib/tiun/routes/mounts.rb +277 -0
- data/lib/tiun/routes.rb +150 -0
- data/lib/tiun/service/auto.rb.erb +5 -0
- data/lib/tiun/service/email_confirmation.rb +36 -0
- data/lib/tiun/service/job.rb +16 -0
- data/lib/tiun/service.rb +82 -0
- data/lib/tiun/services/translation.rb +297 -0
- data/lib/tiun/themes.rb +98 -0
- data/lib/tiun/translations/database.rb +72 -0
- data/lib/tiun/translations.rb +279 -0
- data/lib/tiun/version.rb +3 -3
- data/lib/tiun.rb +79 -486
- data/package-lock.json +4836 -0
- data/package.json +103 -0
- data/scripts/build-application.mjs +39 -0
- data/scripts/build-css.mjs +21 -0
- data/scripts/ci-badges.mjs +54 -0
- data/scripts/ci-badges.test.mjs +46 -0
- data/scripts/ci-coverage.mjs +26 -0
- data/scripts/ci-quality.mjs +80 -0
- data/scripts/ci-quality.sh +21 -0
- data/scripts/ci-quality.test.mjs +59 -0
- data/scripts/clean.mjs +3 -0
- data/scripts/publish-ci-badges.sh +45 -0
- data/src/auth/configuration.ts +50 -0
- data/src/browser/contracts.js +7 -0
- data/src/browser/mount.d.ts +26 -0
- data/src/browser/mount.jsx +1 -0
- data/src/browser/styles.js +17 -0
- data/src/browser/tiun.scss +23 -0
- data/src/browser/tiun.ts +1 -0
- data/src/calendar/configuration.ts +98 -0
- data/src/components/Avatar.tsx +45 -0
- data/src/components/Calendar.tsx +441 -0
- data/src/components/CatchWrapper.tsx +55 -0
- data/src/components/Chip.tsx +267 -0
- data/src/components/Column.tsx +13 -0
- data/src/components/Component.tsx +1039 -0
- data/src/components/Enum.tsx +142 -0
- data/src/components/Figure.tsx +11 -0
- data/src/components/FlexText.tsx +101 -0
- data/src/components/Footer.tsx +13 -0
- data/src/components/Grid.tsx +36 -0
- data/src/components/Heading.tsx +64 -0
- data/src/components/Image.tsx +168 -0
- data/src/components/Index.tsx +391 -0
- data/src/components/Intro.tsx +536 -0
- data/src/components/Loader.tsx +116 -0
- data/src/components/Lorem.tsx +379 -0
- data/src/components/Markdown.d.ts +17 -0
- data/src/components/Markdown.jsx +118 -0
- data/src/components/Menu.tsx +50 -0
- data/src/components/Modal.tsx +143 -0
- data/src/components/Paginator.tsx +265 -0
- data/src/components/Player.tsx +269 -0
- data/src/components/Records.tsx +1063 -0
- data/src/components/Row.tsx +193 -0
- data/src/components/Span.tsx +122 -0
- data/src/components/Step.tsx +19 -0
- data/src/components/Stockee.tsx +50 -0
- data/src/components/Toast.tsx +125 -0
- data/src/components/Tooltip.tsx +214 -0
- data/src/components/View.tsx +278 -0
- data/src/components/_palette.scss +26 -0
- data/src/components/calendar-browser.scss +133 -0
- data/src/components/calendar.scss +217 -0
- data/src/components/chip-browser.scss +270 -0
- data/src/components/chips.scss +95 -0
- data/src/components/column.scss +4 -0
- data/src/components/dashboard-browser.scss +81 -0
- data/src/components/dashboard.scss +117 -0
- data/src/components/description-browser.scss +112 -0
- data/src/components/document.scss +43 -0
- data/src/components/enum-browser.scss +33 -0
- data/src/components/enums.scss +56 -0
- data/src/components/footer.scss +51 -0
- data/src/components/form/ActionButton.tsx +66 -0
- data/src/components/form/Attachment.tsx +200 -0
- data/src/components/form/Block.tsx +55 -0
- data/src/components/form/BooleanBox.tsx +58 -0
- data/src/components/form/Collection.tsx +89 -0
- data/src/components/form/DynamicInput.tsx +806 -0
- data/src/components/form/ErrorSpan.tsx +17 -0
- data/src/components/form/ExternalField.tsx +554 -0
- data/src/components/form/FieldCaption.tsx +35 -0
- data/src/components/form/Form.tsx +407 -0
- data/src/components/form/HiddenField.tsx +10 -0
- data/src/components/form/JsonEditor.tsx +443 -0
- data/src/components/form/Login.tsx +381 -0
- data/src/components/form/NumberField.tsx +75 -0
- data/src/components/form/Pressee.tsx +101 -0
- data/src/components/form/RtferField.tsx +94 -0
- data/src/components/form/SelectField.tsx +73 -0
- data/src/components/form/SlugFlow.tsx +296 -0
- data/src/components/form/TextArea.tsx +5 -0
- data/src/components/form/TextField.tsx +6 -0
- data/src/components/form/Wye.tsx +67 -0
- data/src/components/form/auth.scss +366 -0
- data/src/components/form/changes.ts +239 -0
- data/src/components/form/context.ts +31 -0
- data/src/components/form/createForm.tsx +109 -0
- data/src/components/form/dynamic-field.scss +20 -0
- data/src/components/form/dynamicMatching.ts +44 -0
- data/src/components/form/form-browser.scss +106 -0
- data/src/components/form/forms.scss +1570 -0
- data/src/components/form/formsLib.ts +76 -0
- data/src/components/form/identity.ts +10 -0
- data/src/components/form/input.scss +37 -0
- data/src/components/form/layout.ts +72 -0
- data/src/components/form/login-browser.scss +30 -0
- data/src/components/form/render.tsx +94 -0
- data/src/components/form/resourceFields.ts +87 -0
- data/src/components/form/types.ts +214 -0
- data/src/components/form/values.ts +266 -0
- data/src/components/image.scss +67 -0
- data/src/components/intro-browser.scss +106 -0
- data/src/components/intro.scss +158 -0
- data/src/components/loader.scss +86 -0
- data/src/components/menu.scss +24 -0
- data/src/components/player.scss +48 -0
- data/src/components/records-browser.scss +62 -0
- data/src/components/records.scss +181 -0
- data/src/components/row.scss +31 -0
- data/src/components/stockee.scss +26 -0
- data/src/components/theme-palettes/compat.scss +15 -0
- data/src/components/theme-palettes/dark.scss +237 -0
- data/src/components/theme-palettes/light.scss +21 -0
- data/src/components/theme.scss +34 -0
- data/src/components/tiun_core.scss +9 -0
- data/src/components/toast.scss +63 -0
- data/src/components/tooltip.scss +22 -0
- data/src/components/view-browser.scss +321 -0
- data/src/components/view-controls.scss +385 -0
- data/src/concern/application.ts +56 -0
- data/src/concern/calendarViewProps.ts +28 -0
- data/src/concern/chipViewProps.ts +60 -0
- data/src/concern/documentHead.ts +66 -0
- data/src/concern/i18n.ts +70 -0
- data/src/concern/resourceRequest.ts +25 -0
- data/src/concern/schemaText.ts +6 -0
- data/src/concern/slugFlowProps.ts +76 -0
- data/src/concern/spanOptions.ts +37 -0
- data/src/concern/spansViewProps.tsx +103 -0
- data/src/concern/useFormAccess.ts +324 -0
- data/src/concern/useRecordsResource.ts +60 -0
- data/src/config/application.ts +57 -0
- data/src/config/componentDefaults.ts +106 -0
- data/src/config/components.ts +436 -0
- data/src/config/names.ts +72 -0
- data/src/config/records.ts +34 -0
- data/src/decorators/buttonBehaviours.tsx +46 -0
- data/src/decorators/configuration.ts +104 -0
- data/src/decorators/validation.ts +52 -0
- data/src/decorators/withAppearance.tsx +45 -0
- data/src/decorators/withCaption.tsx +21 -0
- data/src/decorators/withChildren.tsx +31 -0
- data/src/decorators/withClose.scss +37 -0
- data/src/decorators/withClose.tsx +44 -0
- data/src/decorators/withColumn.tsx +111 -0
- data/src/decorators/withDiscordAuth.tsx +4 -0
- data/src/decorators/withExternalAuth.tsx +50 -0
- data/src/decorators/withFacebookAuth.tsx +4 -0
- data/src/decorators/withField.tsx +91 -0
- data/src/decorators/withForm.tsx +365 -0
- data/src/decorators/withGithubAuth.tsx +4 -0
- data/src/decorators/withKakaoAuth.tsx +4 -0
- data/src/decorators/withMenuBranch.scss +45 -0
- data/src/decorators/withMenuBranch.tsx +109 -0
- data/src/decorators/withOkAuth.tsx +4 -0
- data/src/decorators/withPlayerList.tsx +77 -0
- data/src/decorators/withQuickLinkMark.ts +57 -0
- data/src/decorators/withRecordForm.tsx +561 -0
- data/src/decorators/withRequestActivity.scss +7 -0
- data/src/decorators/withRequestActivity.tsx +21 -0
- data/src/decorators/withRouter.tsx +395 -0
- data/src/decorators/withRouterLink.tsx +54 -0
- data/src/decorators/withTelegramAuth.tsx +4 -0
- data/src/decorators/withTextControl.tsx +194 -0
- data/src/decorators/withUnique.scss +39 -0
- data/src/decorators/withUnique.tsx +172 -0
- data/src/decorators/withUnsavedChanges.scss +39 -0
- data/src/decorators/withUnsavedChanges.tsx +312 -0
- data/src/decorators/withValidation.ts +38 -0
- data/src/decorators/withVkAuth.tsx +4 -0
- data/src/decorators/withWechatAuth.tsx +4 -0
- data/src/decorators/withWeiboAuth.tsx +4 -0
- data/src/intro/config.ts +72 -0
- data/src/intro/position.ts +70 -0
- data/src/layout/units.ts +21 -0
- data/src/records/types.ts +67 -0
- data/src/routing/nativePaths.ts +16 -0
- data/src/routing/routes.ts +337 -0
- data/src/schema/Schema.ts +2034 -0
- data/src/schema/dates.ts +17 -0
- data/src/schema.ts +274 -0
- data/src/services/Meta.ts +64 -0
- data/src/services/Resource.ts +480 -0
- data/src/services/Stock.ts +156 -0
- data/src/services/browser/requestActivity.d.ts +7 -0
- data/src/services/browser/requestActivity.js +119 -0
- data/src/services/browser/slugColor.js +13 -0
- data/src/services/calendar/clock.ts +169 -0
- data/src/services/calendar/dates.ts +127 -0
- data/src/services/calendar/daylight.ts +301 -0
- data/src/services/calendar/useCalendarDaylight.ts +76 -0
- data/src/services/calendar/utcTimeSource.ts +41 -0
- data/src/services/enumLookup.ts +96 -0
- data/src/services/form/blankCondition.ts +61 -0
- data/src/services/form/hoardValidation.ts +84 -0
- data/src/services/i18n/I18n.ts +227 -0
- data/src/services/i18n/messages.ts +185 -0
- data/src/services/load.ts +60 -0
- data/src/services/methods/aboutData.d.ts +9 -0
- data/src/services/methods/aboutData.js +32 -0
- data/src/services/methods/calendarChoices.d.ts +1 -0
- data/src/services/methods/calendarChoices.js +9 -0
- data/src/services/methods/eventDates.ts +96 -0
- data/src/services/methods/forms.ts +22 -0
- data/src/services/methods/mount.jsx +34 -0
- data/src/services/methods/paschal.ts +45 -0
- data/src/services/methods/prepared.ts +193 -0
- data/src/services/methods/query.ts +30 -0
- data/src/services/methods/registry.ts +22 -0
- data/src/services/methods/resolveReadResource.ts +57 -0
- data/src/services/methods.ts +156 -0
- data/src/services/records/range.ts +39 -0
- data/src/services/records/resource.ts +90 -0
- data/src/services/records/useRecordPages.ts +266 -0
- data/src/services/session/renewal.ts +394 -0
- data/src/services/textLink.ts +11 -0
- data/src/services/timer.ts +25 -0
- data/src/services/useAppearance.ts +496 -0
- data/src/services/useSwitch.ts +146 -0
- data/src/theme/cache.ts +88 -0
- data/src/theme/configuration.ts +261 -0
- data/src/theme/context.ts +48 -0
- data/src/theme/resource.ts +106 -0
- data/tiun.gemspec +53 -45
- data/tools/rubocop/compact_block_braces.rb +39 -0
- data/tools/rubocop/i18n_decorators.rb +15 -0
- data/tools/rubocop/spacing.rb +96 -0
- data/tsconfig.build.json +26 -0
- data/tsconfig.json +27 -0
- metadata +628 -72
- data/.rspec +0 -3
- data/.travis.yml +0 -7
- data/lib/tiun/autocontroller.rb.erb +0 -20
- data/lib/tiun/autolistserializer.rb.erb +0 -9
- data/lib/tiun/automodel.rb.erb +0 -10
- data/lib/tiun/autoserializer.rb.erb +0 -9
- data/lib/tiun/base.rb +0 -405
- data/lib/tiun/core_controller.rb +0 -6
- data/lib/tiun/list_serializer.rb +0 -20
- data/lib/tiun/meta_controller.rb +0 -13
- data/lib/tiun/serializer.rb +0 -31
- /data/lib/tiun/{automigration.rb.erb → migration/auto.rb.erb} +0 -0
- /data/lib/tiun/{autopolicy.rb.erb → policy/auto.rb.erb} +0 -0
data/package.json
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tiun",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript package for Tiun.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=16.20.2"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/schema.js",
|
|
11
|
+
"types": "./dist/schema.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/schema.d.ts",
|
|
15
|
+
"import": "./dist/schema.js"
|
|
16
|
+
},
|
|
17
|
+
"./forms.css": "./dist/components/form/forms.css",
|
|
18
|
+
"./column.css": "./dist/components/column.css",
|
|
19
|
+
"./row.css": "./dist/components/row.css",
|
|
20
|
+
"./records.css": "./dist/components/records.css",
|
|
21
|
+
"./intro.css": "./dist/components/intro.css",
|
|
22
|
+
"./calendar.css": "./dist/components/calendar.css",
|
|
23
|
+
"./toast.css": "./dist/components/toast.css",
|
|
24
|
+
"./dashboard.css": "./dist/components/dashboard.css",
|
|
25
|
+
"./enums.css": "./dist/components/enums.css",
|
|
26
|
+
"./tooltip.css": "./dist/components/tooltip.css",
|
|
27
|
+
"./chips.css": "./dist/components/chips.css",
|
|
28
|
+
"./loader.css": "./dist/components/loader.css",
|
|
29
|
+
"./footer.css": "./dist/components/footer.css",
|
|
30
|
+
"./player.css": "./dist/components/player.css",
|
|
31
|
+
"./image.css": "./dist/components/image.css",
|
|
32
|
+
"./document.css": "./dist/components/document.css",
|
|
33
|
+
"./theme.css": "./dist/components/theme.css",
|
|
34
|
+
"./auth.css": "./dist/components/form/auth.css",
|
|
35
|
+
"./browser": {
|
|
36
|
+
"types": "./dist/browser/mount.d.ts",
|
|
37
|
+
"default": "./dist/browser/mount.js"
|
|
38
|
+
},
|
|
39
|
+
"./browser/styles": "./dist/browser/styles.js",
|
|
40
|
+
"./browser/contracts": "./dist/browser/contracts.js"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"LICENSE.txt"
|
|
45
|
+
],
|
|
46
|
+
"sideEffects": [
|
|
47
|
+
"**/*.css",
|
|
48
|
+
"**/*.scss",
|
|
49
|
+
"./dist/browser/styles.js"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"clean": "node scripts/clean.mjs",
|
|
53
|
+
"build": "npm run clean && tsc -p tsconfig.build.json && node scripts/build-css.mjs && node scripts/build-application.mjs",
|
|
54
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
55
|
+
"lint": "eslint src \"features/**/*.ts\" scripts cucumber.mjs --max-warnings 0",
|
|
56
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx,scss}\" \"features/**/*.ts\" \"scripts/*.mjs\" cucumber.mjs eslint.config.mjs",
|
|
57
|
+
"test": "tsx node_modules/@cucumber/cucumber/bin/cucumber.js --config cucumber.mjs",
|
|
58
|
+
"check": "npm run typecheck && npm run build && npm test",
|
|
59
|
+
"prepack": "npm run build",
|
|
60
|
+
"prepare": "npm run build"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@cucumber/cucumber": "~9.6.0",
|
|
64
|
+
"@eslint/js": "10.0.1",
|
|
65
|
+
"@types/chai": "^4.3.0",
|
|
66
|
+
"@types/jsdom": "^21.1.7",
|
|
67
|
+
"@types/node": "^22.0.0",
|
|
68
|
+
"@types/react": "^19.0.0",
|
|
69
|
+
"@types/react-dom": "^19.0.0",
|
|
70
|
+
"@types/sinon": "^17.0.0",
|
|
71
|
+
"@types/sinon-chai": "^3.2.0",
|
|
72
|
+
"chai": "^4.5.0",
|
|
73
|
+
"esbuild": "0.18.20",
|
|
74
|
+
"eslint": "10.15.0",
|
|
75
|
+
"globals": "17.14.0",
|
|
76
|
+
"jsdom": "^22.1.0",
|
|
77
|
+
"prettier": "3.10.1",
|
|
78
|
+
"react": "^19.0.0",
|
|
79
|
+
"react-dom": "^19.0.0",
|
|
80
|
+
"sass": "1.99.0",
|
|
81
|
+
"sinon": "^17.0.0",
|
|
82
|
+
"sinon-chai": "^3.7.0",
|
|
83
|
+
"tsx": "~3.14.0",
|
|
84
|
+
"typescript": "~6.0.0",
|
|
85
|
+
"typescript-eslint": "8.73.0",
|
|
86
|
+
"yaml": "^2.9.1"
|
|
87
|
+
},
|
|
88
|
+
"repository": {
|
|
89
|
+
"type": "git",
|
|
90
|
+
"url": "git+https://codeberg.org/znamenica/tiun.git"
|
|
91
|
+
},
|
|
92
|
+
"publishConfig": {
|
|
93
|
+
"registry": "https://codeberg.org/api/packages/znamenica/npm/"
|
|
94
|
+
},
|
|
95
|
+
"peerDependencies": {
|
|
96
|
+
"react": "^17.0.2 || ^18.0.0 || ^19.0.0",
|
|
97
|
+
"react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0"
|
|
98
|
+
},
|
|
99
|
+
"dependencies": {
|
|
100
|
+
"axios": "^1.6.3",
|
|
101
|
+
"react-showdown": "^2.3.1"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cp, readdir } from "node:fs/promises";
|
|
2
|
+
import { build } from "esbuild";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Lists browser modules and stylesheet sources shipped with the package.
|
|
6
|
+
* @param {string} path Source directory.
|
|
7
|
+
* @returns {Promise<string[]>} JavaScript, JSX and SCSS files below the directory.
|
|
8
|
+
*/
|
|
9
|
+
const browserEntries = async (path) => {
|
|
10
|
+
const entries = await readdir(path, { withFileTypes: true });
|
|
11
|
+
return (
|
|
12
|
+
await Promise.all(
|
|
13
|
+
entries.map((entry) => {
|
|
14
|
+
const file = `${path}/${entry.name}`;
|
|
15
|
+
if (entry.isDirectory()) {
|
|
16
|
+
return browserEntries(file);
|
|
17
|
+
}
|
|
18
|
+
return [file].filter((name) => /\.(?:jsx?|scss)$/u.test(name));
|
|
19
|
+
}),
|
|
20
|
+
)
|
|
21
|
+
).flat();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const sources = await browserEntries("src");
|
|
25
|
+
await build({
|
|
26
|
+
entryPoints: sources.filter((path) => /\.jsx?$/u.test(path)),
|
|
27
|
+
format: "esm",
|
|
28
|
+
outbase: "src",
|
|
29
|
+
outdir: "dist",
|
|
30
|
+
sourcemap: true,
|
|
31
|
+
target: "es2019",
|
|
32
|
+
});
|
|
33
|
+
await Promise.all([
|
|
34
|
+
...sources
|
|
35
|
+
.filter((path) => path.endsWith(".scss"))
|
|
36
|
+
.map((path) => cp(path, path.replace(/^src\//u, "dist/"))),
|
|
37
|
+
cp("src/browser/mount.d.ts", "dist/browser/mount.d.ts"),
|
|
38
|
+
cp("src/components/Markdown.d.ts", "dist/components/Markdown.d.ts"),
|
|
39
|
+
]);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { compile as sassCompile } from "sass";
|
|
4
|
+
|
|
5
|
+
const manifestUrl = new URL("../package.json", import.meta.url),
|
|
6
|
+
packageManifest = JSON.parse(await readFile(manifestUrl, "utf8"));
|
|
7
|
+
|
|
8
|
+
for (const [name, path] of Object.entries(packageManifest.exports)) {
|
|
9
|
+
if (!name.endsWith(".css")) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (typeof path !== "string" || !/^\.\/dist\/.+\.css$/.test(path)) {
|
|
13
|
+
throw new TypeError(`Invalid stylesheet export ${name}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const source = new URL(path.replace(/^\.\/dist\//, "./src/").replace(/\.css$/, ".scss"), manifestUrl),
|
|
17
|
+
target = new URL(path, manifestUrl),
|
|
18
|
+
{ css } = sassCompile(fileURLToPath(source));
|
|
19
|
+
await mkdir(new URL("./", target), { recursive: true });
|
|
20
|
+
await writeFile(target, css);
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { measuredCoverage } from "./ci-coverage.mjs";
|
|
4
|
+
|
|
5
|
+
const states = {
|
|
6
|
+
cancelled: { color: "#6b7280", text: "cancelled" },
|
|
7
|
+
failure: { color: "#b42318", text: "failed" },
|
|
8
|
+
pending: { color: "#6b7280", text: "pending" },
|
|
9
|
+
skipped: { color: "#6b7280", text: "skipped" },
|
|
10
|
+
success: { color: "#17643b", text: "passing" },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Reads the measurements of a successful SimpleCov run.
|
|
15
|
+
* @param {string | undefined} report Path to the SimpleCov summary.
|
|
16
|
+
* @returns {string} Coverage measurements for the badge.
|
|
17
|
+
*/
|
|
18
|
+
function coverageText(report) {
|
|
19
|
+
const { branch, line } = measuredCoverage(report);
|
|
20
|
+
return `${line.toFixed(2)}% lines, ${branch.toFixed(2)}% branches`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Renders a label and check status as a self-contained SVG.
|
|
25
|
+
* @param {string} label Name of the check.
|
|
26
|
+
* @param {string} value Display value, from a state or verified percentages.
|
|
27
|
+
* @param {string} color Fill color of the value.
|
|
28
|
+
* @returns {string} Accessible SVG with no external dependencies.
|
|
29
|
+
*/
|
|
30
|
+
function badge(label, value, color) {
|
|
31
|
+
const labelWidth = label.length * 7 + 16;
|
|
32
|
+
const valueWidth = value.length * 7 + 16;
|
|
33
|
+
const width = labelWidth + valueWidth;
|
|
34
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="24" role="img" aria-label="${label}: ${value}">
|
|
35
|
+
<title>${label}: ${value}</title>
|
|
36
|
+
<rect width="${width}" height="24" rx="4" fill="#374151"/>
|
|
37
|
+
<path d="M${labelWidth} 0H${width - 4}Q${width} 0 ${width} 4V20Q${width} 24 ${width - 4} 24H${labelWidth}Z" fill="${color}"/>
|
|
38
|
+
<g fill="#fff" font-family="sans-serif" font-size="11" text-anchor="middle">
|
|
39
|
+
<text x="${labelWidth / 2}" y="16">${label}</text>
|
|
40
|
+
<text x="${labelWidth + valueWidth / 2}" y="16">${value}</text>
|
|
41
|
+
</g>
|
|
42
|
+
</svg>
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const [directory, quality, coverage, tests, report] = process.argv.slice(2);
|
|
47
|
+
if (!directory || ![quality, coverage, tests].every((value) => Object.hasOwn(states, value))) {
|
|
48
|
+
throw new Error("Usage: node scripts/ci-badges.mjs DIRECTORY QUALITY COVERAGE TESTS [SIMPLECOV_JSON]");
|
|
49
|
+
}
|
|
50
|
+
const cover = coverage === "success" ? coverageText(report) : states[coverage].text;
|
|
51
|
+
mkdirSync(directory, { recursive: true });
|
|
52
|
+
writeFileSync(join(directory, "quality.svg"), badge("Code quality", states[quality].text, states[quality].color));
|
|
53
|
+
writeFileSync(join(directory, "coverage.svg"), badge("Ruby coverage", cover, states[coverage].color));
|
|
54
|
+
writeFileSync(join(directory, "tests.svg"), badge("Tests", states[tests].text, states[tests].color));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { expect } from "chai";
|
|
8
|
+
|
|
9
|
+
const script = fileURLToPath(new URL("./ci-badges.mjs", import.meta.url));
|
|
10
|
+
const coverageScript = fileURLToPath(new URL("./ci-coverage.mjs", import.meta.url));
|
|
11
|
+
|
|
12
|
+
test("renders separate badges for quality, measured coverage and tests", () => {
|
|
13
|
+
const directory = mkdtempSync(join(tmpdir(), "tiun-badges-"));
|
|
14
|
+
const coverage = join(directory, "coverage.json");
|
|
15
|
+
writeFileSync(coverage, JSON.stringify({ result: { branch: 77.74, line: 93 } }));
|
|
16
|
+
|
|
17
|
+
const result = spawnSync(process.execPath, [script, directory, "success", "success", "failure", coverage]);
|
|
18
|
+
expect(result.status, result.stderr.toString()).to.equal(0);
|
|
19
|
+
expect(readFileSync(join(directory, "quality.svg"), "utf8")).to.include("Code quality: passing");
|
|
20
|
+
expect(readFileSync(join(directory, "coverage.svg"), "utf8")).to.include("93.00% lines, 77.74% branches");
|
|
21
|
+
expect(readFileSync(join(directory, "tests.svg"), "utf8")).to.include("Tests: failed");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("requires measured coverage for a successful coverage badge", () => {
|
|
25
|
+
const directory = mkdtempSync(join(tmpdir(), "tiun-badges-"));
|
|
26
|
+
const result = spawnSync(process.execPath, [script, directory, "success", "success", "success"]);
|
|
27
|
+
|
|
28
|
+
expect(result.status).to.equal(1);
|
|
29
|
+
expect(result.stderr.toString()).to.include("A successful coverage check requires its report");
|
|
30
|
+
expect(existsSync(join(directory, "coverage.svg"))).to.equal(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("checks line and branch coverage independently at the configured limits", () => {
|
|
34
|
+
const directory = mkdtempSync(join(tmpdir(), "tiun-coverage-"));
|
|
35
|
+
const coverage = join(directory, "coverage.json");
|
|
36
|
+
const examples = [
|
|
37
|
+
{ branch: 75, expectedStatus: 0, line: 90 },
|
|
38
|
+
{ branch: 75, expectedStatus: 1, line: 89.99 },
|
|
39
|
+
{ branch: 74.99, expectedStatus: 1, line: 90 },
|
|
40
|
+
];
|
|
41
|
+
for (const { branch, expectedStatus, line } of examples) {
|
|
42
|
+
writeFileSync(coverage, JSON.stringify({ result: { branch, line } }));
|
|
43
|
+
const result = spawnSync(process.execPath, [coverageScript, coverage]);
|
|
44
|
+
expect(result.status, result.stderr.toString()).to.equal(expectedStatus);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Reads line and branch measurements from SimpleCov.
|
|
7
|
+
* @param {string | undefined} report Path to the SimpleCov summary.
|
|
8
|
+
* @returns {{branch: number, line: number}} Valid coverage percentages.
|
|
9
|
+
*/
|
|
10
|
+
export function measuredCoverage(report) {
|
|
11
|
+
if (!report) throw new Error("A successful coverage check requires its report");
|
|
12
|
+
const { branch, line } = JSON.parse(readFileSync(report, "utf8")).result;
|
|
13
|
+
if (![branch, line].every((value) => Number.isFinite(value) && value >= 0 && value <= 100)) {
|
|
14
|
+
throw new Error("Expected line and branch coverage percentages");
|
|
15
|
+
}
|
|
16
|
+
return { branch, line };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
20
|
+
const { branch, line } = measuredCoverage(process.argv[2]);
|
|
21
|
+
console.log(`Ruby coverage: ${line}% lines, ${branch}% branches`);
|
|
22
|
+
if (line < 90 || branch < 75) {
|
|
23
|
+
console.error("Expected at least 90% line coverage and 75% branch coverage");
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join, relative, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
const [base, directory] = process.argv.slice(2);
|
|
6
|
+
if (!base || !directory || !/^[0-9a-f]{40}$/.test(base)) {
|
|
7
|
+
throw new Error("Usage: node scripts/ci-quality.mjs BASE_SHA REPORTS_DIRECTORY");
|
|
8
|
+
}
|
|
9
|
+
/** Runs Git with the supplied arguments and returns its UTF-8 output. */
|
|
10
|
+
const git = (...args) => execFileSync("git", args, { encoding: "utf8" });
|
|
11
|
+
const comparison = git("merge-base", base, "HEAD").trim();
|
|
12
|
+
const changed = new Set(git("diff", "--no-renames", "--name-only", "-z", comparison, "HEAD").split("\0"));
|
|
13
|
+
const source = /^(app|features|lib|src)\//;
|
|
14
|
+
const ranges = new Map();
|
|
15
|
+
const blockers = [];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Looks up the added or replaced lines in a changed, tracked file.
|
|
19
|
+
* @param {string} path Repository-relative path.
|
|
20
|
+
* @returns {Array<[number, number]>} Inclusive line intervals in HEAD.
|
|
21
|
+
*/
|
|
22
|
+
function changedRanges(path) {
|
|
23
|
+
if (!ranges.has(path)) {
|
|
24
|
+
const patch = git("diff", "--no-ext-diff", "--no-color", "--unified=0", comparison, "HEAD", "--", path);
|
|
25
|
+
const additions = [...patch.matchAll(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/gm)].map(([, first, count]) => [
|
|
26
|
+
Number(first),
|
|
27
|
+
Number(first) + Number(count ?? 1) - 1,
|
|
28
|
+
]);
|
|
29
|
+
ranges.set(path, additions);
|
|
30
|
+
}
|
|
31
|
+
return ranges.get(path);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Records a diagnostic and flags violations on changed source lines.
|
|
36
|
+
* @param {string} tool Name of the reporting tool.
|
|
37
|
+
* @param {string} file Path from the tool report.
|
|
38
|
+
* @param {number | undefined} line Position, or undefined for a whole-file diagnostic.
|
|
39
|
+
* @param {string} description Rule and message.
|
|
40
|
+
* @param {boolean} fatal Whether the tool failed to parse the code.
|
|
41
|
+
* @returns {void} Appends a blocking diagnostic when applicable.
|
|
42
|
+
*/
|
|
43
|
+
function record(tool, file, line, description, fatal = false) {
|
|
44
|
+
const path = relative(process.cwd(), resolve(file));
|
|
45
|
+
const message = `${tool} ${path}${line ? `:${line}` : ""} ${description}`;
|
|
46
|
+
const onChangedSource =
|
|
47
|
+
source.test(path) &&
|
|
48
|
+
changed.has(path) &&
|
|
49
|
+
(line === undefined || changedRanges(path).some(([first, last]) => first <= line && line <= last));
|
|
50
|
+
if (fatal || onChangedSource) blockers.push(message);
|
|
51
|
+
else console.log(message);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const eslint = JSON.parse(readFileSync(join(directory, "eslint.json"), "utf8"));
|
|
55
|
+
for (const { filePath, messages } of eslint) {
|
|
56
|
+
for (const { fatal, line, message, ruleId } of messages)
|
|
57
|
+
record("ESLint", filePath, line, `${ruleId ?? "parse"} ${message}`, fatal);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const rubocop = JSON.parse(readFileSync(join(directory, "rubocop.json"), "utf8"));
|
|
61
|
+
for (const { path, offenses } of rubocop.files) {
|
|
62
|
+
for (const { cop_name, location, message, severity } of offenses) {
|
|
63
|
+
record(
|
|
64
|
+
"RuboCop",
|
|
65
|
+
path,
|
|
66
|
+
location.start_line,
|
|
67
|
+
`${cop_name} ${message}`,
|
|
68
|
+
severity === "fatal" || cop_name === "Lint/Syntax",
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for (const path of readFileSync(join(directory, "prettier.txt"), "utf8").trim().split("\n").filter(Boolean)) {
|
|
74
|
+
record("Prettier", path, undefined, "Formatting differs");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (blockers.length) {
|
|
78
|
+
console.error(blockers.join("\n"));
|
|
79
|
+
process.exitCode = 1;
|
|
80
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
base=${1:?Provide the comparison commit}
|
|
5
|
+
reports=${2:?Provide the report directory}
|
|
6
|
+
mkdir -p "$reports"
|
|
7
|
+
rm -f -- "$reports/eslint.json" "$reports/rubocop.json" "$reports/prettier.txt"
|
|
8
|
+
|
|
9
|
+
# Runs a report command. Returns success for exit 1 findings and preserves other failures.
|
|
10
|
+
report() {
|
|
11
|
+
local status=0
|
|
12
|
+
"$@" || status=$?
|
|
13
|
+
if (( status > 1 )); then
|
|
14
|
+
return "$status"
|
|
15
|
+
fi
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
report npm run --silent lint -- --format json --output-file "$reports/eslint.json"
|
|
19
|
+
report bundle exec rubocop --format json --out "$reports/rubocop.json"
|
|
20
|
+
report npm exec -- prettier --list-different 'src/**/*.{ts,tsx,scss}' 'features/**/*.ts' 'scripts/*.mjs' cucumber.mjs eslint.config.mjs > "$reports/prettier.txt"
|
|
21
|
+
node scripts/ci-quality.mjs "$base" "$reports"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
2
|
+
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { expect } from "chai";
|
|
8
|
+
|
|
9
|
+
const script = fileURLToPath(new URL("./ci-quality.mjs", import.meta.url));
|
|
10
|
+
|
|
11
|
+
test("reports existing diagnostics and fails when a rule flags an added line", () => {
|
|
12
|
+
const cwd = mkdtempSync(join(tmpdir(), "tiun-quality-"));
|
|
13
|
+
mkdirSync(join(cwd, "src"));
|
|
14
|
+
const path = join(cwd, "src", "sample.js");
|
|
15
|
+
const git = (...args) => execFileSync("git", args, { cwd, encoding: "utf8" });
|
|
16
|
+
git("init", "-q");
|
|
17
|
+
git("config", "user.name", "CI test");
|
|
18
|
+
git("config", "user.email", "ci@example.org");
|
|
19
|
+
writeFileSync(path, "legacy();\n");
|
|
20
|
+
git("add", "src/sample.js");
|
|
21
|
+
git("commit", "-qm", "Baseline");
|
|
22
|
+
const base = git("rev-parse", "HEAD").trim();
|
|
23
|
+
writeFileSync(path, "legacy();\nadded();\n");
|
|
24
|
+
git("commit", "-qam", "Add call");
|
|
25
|
+
|
|
26
|
+
writeFileSync(join(cwd, "rubocop.json"), JSON.stringify({ files: [] }));
|
|
27
|
+
writeFileSync(join(cwd, "prettier.txt"), "");
|
|
28
|
+
const eslint = join(cwd, "eslint.json");
|
|
29
|
+
const diagnostic = (line) => ({ line, message: "Disallowed call", ruleId: "no-restricted-syntax", severity: 2 });
|
|
30
|
+
writeFileSync(eslint, JSON.stringify([{ filePath: path, messages: [diagnostic(1)] }]));
|
|
31
|
+
const check = () => spawnSync(process.execPath, [script, base, cwd], { cwd, encoding: "utf8" });
|
|
32
|
+
|
|
33
|
+
const existing = check();
|
|
34
|
+
expect(existing.status, existing.stderr).to.equal(0);
|
|
35
|
+
expect(existing.stdout).to.include("ESLint src/sample.js:1");
|
|
36
|
+
|
|
37
|
+
writeFileSync(eslint, JSON.stringify([{ filePath: path, messages: [diagnostic(1), diagnostic(2)] }]));
|
|
38
|
+
const regression = check();
|
|
39
|
+
expect(regression.status).to.equal(1);
|
|
40
|
+
expect(regression.stderr).to.include("ESLint src/sample.js:2");
|
|
41
|
+
|
|
42
|
+
writeFileSync(eslint, JSON.stringify([{ filePath: path, messages: [] }]));
|
|
43
|
+
writeFileSync(
|
|
44
|
+
join(cwd, "rubocop.json"),
|
|
45
|
+
JSON.stringify({
|
|
46
|
+
files: [
|
|
47
|
+
{
|
|
48
|
+
offenses: [
|
|
49
|
+
{ cop_name: "Lint/Syntax", location: { start_line: 1 }, message: "Syntax error", severity: "error" },
|
|
50
|
+
],
|
|
51
|
+
path,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
const syntax = check();
|
|
57
|
+
expect(syntax.status).to.equal(1);
|
|
58
|
+
expect(syntax.stderr).to.include("RuboCop src/sample.js:1 Lint/Syntax");
|
|
59
|
+
});
|
data/scripts/clean.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
badges=${1:?Provide the generated SVG directory}
|
|
5
|
+
revision=${FORGEJO_SHA:?A Forgejo revision is required}
|
|
6
|
+
token=${FORGEJO_TOKEN:?A Forgejo workflow token is required}
|
|
7
|
+
remote="${FORGEJO_SERVER_URL:?}/${FORGEJO_REPOSITORY:?}.git"
|
|
8
|
+
branch=refs/heads/ci-badges
|
|
9
|
+
|
|
10
|
+
authorization=$(printf 'x-access-token:%s' "$token" | base64 -w 0)
|
|
11
|
+
checkout=$(mktemp -d)
|
|
12
|
+
trap 'rm -rf -- "$checkout"' EXIT
|
|
13
|
+
git init --quiet --initial-branch ci-badges "$checkout"
|
|
14
|
+
|
|
15
|
+
# Runs an authenticated Git command in the badge clone and returns its exit status.
|
|
16
|
+
forge_git() {
|
|
17
|
+
git -C "$checkout" -c "http.extraHeader=Authorization: Basic $authorization" "$@"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
remote_status=0
|
|
21
|
+
forge_git ls-remote --exit-code "$remote" "$branch" > /dev/null || remote_status=$?
|
|
22
|
+
case "$remote_status" in
|
|
23
|
+
0)
|
|
24
|
+
forge_git fetch --quiet "$remote" "$branch"
|
|
25
|
+
git -C "$checkout" switch --quiet --force-create ci-badges FETCH_HEAD
|
|
26
|
+
;;
|
|
27
|
+
2) ;;
|
|
28
|
+
*) exit "$remote_status" ;;
|
|
29
|
+
esac
|
|
30
|
+
|
|
31
|
+
cp -- "$badges/quality.svg" "$badges/coverage.svg" "$badges/tests.svg" "$checkout/"
|
|
32
|
+
printf '%s\n' "$revision" > "$checkout/revision.txt"
|
|
33
|
+
git -C "$checkout" add quality.svg coverage.svg tests.svg revision.txt
|
|
34
|
+
if git -C "$checkout" diff --cached --quiet; then
|
|
35
|
+
exit 0
|
|
36
|
+
fi
|
|
37
|
+
git -C "$checkout" -c user.name='Tiun checks' -c user.email='actions@codeberg.org' \
|
|
38
|
+
commit --quiet -m "Update check badges for ${revision:0:12}"
|
|
39
|
+
|
|
40
|
+
tip=$(forge_git ls-remote --exit-code "$remote" refs/heads/master)
|
|
41
|
+
if [[ ${tip%%$'\t'*} != "$revision" ]]; then
|
|
42
|
+
printf 'Skipping badges for superseded master revision %s\n' "$revision"
|
|
43
|
+
exit 0
|
|
44
|
+
fi
|
|
45
|
+
forge_git push "$remote" "HEAD:$branch"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { FormData } from "../components/form/types.js";
|
|
2
|
+
import type { ServerMeta } from "../services/Meta.js";
|
|
3
|
+
import { findResource } from "../services/Resource.js";
|
|
4
|
+
export type LoginMode = "login" | "signup" | "recover";
|
|
5
|
+
export interface LoginOperation {
|
|
6
|
+
readonly resource?: string;
|
|
7
|
+
readonly method?: "post" | "put";
|
|
8
|
+
readonly form: string;
|
|
9
|
+
readonly root?: string;
|
|
10
|
+
readonly initial?: FormData;
|
|
11
|
+
readonly labels?: {
|
|
12
|
+
readonly title?: string;
|
|
13
|
+
readonly action?: string;
|
|
14
|
+
readonly success?: string;
|
|
15
|
+
readonly errors?: { readonly request?: string };
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface LoginConfiguration {
|
|
19
|
+
readonly session_resource?: string;
|
|
20
|
+
readonly user_view?: string;
|
|
21
|
+
readonly avatar_from?: string;
|
|
22
|
+
readonly modes?: Partial<Readonly<Record<LoginMode, LoginOperation>>>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const isObject = (value: unknown): value is Record<string, unknown> =>
|
|
26
|
+
Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the configured session resource and verifies that it exposes the requested method.
|
|
30
|
+
* @param meta Server metadata with resource declarations.
|
|
31
|
+
* @param name Configured name or version reference. When absent, uses fallback.
|
|
32
|
+
* @param method Required HTTP method.
|
|
33
|
+
* @param fallback Optional static SDK path used only when name is absent.
|
|
34
|
+
* @returns A verified static path. Throws if the path or method is unavailable.
|
|
35
|
+
*/
|
|
36
|
+
export function authResource(meta: ServerMeta, name: string | undefined, method: string, fallback?: string): string {
|
|
37
|
+
const configuredResource = name === undefined ? undefined : findResource(meta, name),
|
|
38
|
+
path =
|
|
39
|
+
name === undefined
|
|
40
|
+
? fallback
|
|
41
|
+
: isObject(configuredResource) &&
|
|
42
|
+
Array.isArray(configuredResource.methods) &&
|
|
43
|
+
configuredResource.methods.some((value: unknown) => isObject(value) && value.name === method)
|
|
44
|
+
? configuredResource.path
|
|
45
|
+
: undefined;
|
|
46
|
+
if (typeof path !== "string" || !path.startsWith("/") || path.startsWith("//") || /:[a-z_]+/i.test(path)) {
|
|
47
|
+
throw new TypeError("Auth resource unavailable");
|
|
48
|
+
}
|
|
49
|
+
return path;
|
|
50
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { aboutDone, aboutHistory, aboutPlanned } from '../services/methods/aboutData.js'
|
|
2
|
+
export { calendarChoices } from '../services/methods/calendarChoices.js'
|
|
3
|
+
export { resolveReadResource } from '../services/methods/resolveReadResource.js'
|
|
4
|
+
export { dateFromDay, memoDateLabel, nextMemoDay, referenceCalendarDay } from '../services/methods/eventDates.js'
|
|
5
|
+
export { filterValues, normalizeSearchText } from '../services/methods/query.js'
|
|
6
|
+
export { getSlugColor } from '../services/browser/slugColor.js'
|
|
7
|
+
export { default as MarkdownText } from '../components/Markdown.js'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { I18n } from "../services/i18n/I18n.js";
|
|
3
|
+
import type { IndexProps } from "../components/Index.js";
|
|
4
|
+
import type { SchemaRegistry } from "../schema/Schema.js";
|
|
5
|
+
import type { ServerMeta } from "../services/Meta.js";
|
|
6
|
+
import type { SessionUser } from "../services/session/renewal.js";
|
|
7
|
+
|
|
8
|
+
export interface BrowserBootstrap
|
|
9
|
+
extends Readonly<Record<string, unknown>>, Readonly<Partial<Record<"text_languages", readonly string[]>>> {
|
|
10
|
+
readonly bootstrap?: ServerMeta;
|
|
11
|
+
readonly initialUrl?: string;
|
|
12
|
+
readonly user?: SessionUser | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type ConfigureBrowserRegistry = (
|
|
16
|
+
meta: ServerMeta,
|
|
17
|
+
languages: readonly string[] | undefined,
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- Preserve the shared I18n instance and its registry methods.
|
|
19
|
+
i18n: I18n,
|
|
20
|
+
) => SchemaRegistry<unknown>;
|
|
21
|
+
|
|
22
|
+
export function mountApplication(
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- React owns the component reference and its static properties.
|
|
24
|
+
root?: ComponentType<BrowserBootstrap> | ComponentType<IndexProps<unknown, SessionUser>>,
|
|
25
|
+
configure?: ConfigureBrowserRegistry,
|
|
26
|
+
): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mountApplication } from '../services/methods/mount.js'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import 'tiun/calendar.css'
|
|
2
|
+
import 'tiun/records.css'
|
|
3
|
+
import 'tiun/column.css'
|
|
4
|
+
import 'tiun/row.css'
|
|
5
|
+
import 'tiun/image.css'
|
|
6
|
+
import 'tiun/forms.css'
|
|
7
|
+
import 'tiun/intro.css'
|
|
8
|
+
import 'tiun/chips.css'
|
|
9
|
+
import 'tiun/tooltip.css'
|
|
10
|
+
import 'tiun/loader.css'
|
|
11
|
+
import 'tiun/document.css'
|
|
12
|
+
import 'tiun/enums.css'
|
|
13
|
+
import 'tiun/dashboard.css'
|
|
14
|
+
import 'tiun/theme.css'
|
|
15
|
+
import 'tiun/footer.css'
|
|
16
|
+
import 'tiun/auth.css'
|
|
17
|
+
import './tiun.scss'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import "../components/palette";
|
|
2
|
+
@import "../components/form/form-browser";
|
|
3
|
+
@import "../components/form/dynamic-field";
|
|
4
|
+
@import "../components/tiun_core";
|
|
5
|
+
@import "../components/form/input";
|
|
6
|
+
@import "../components/description-browser";
|
|
7
|
+
@import "../components/view-controls";
|
|
8
|
+
@import "../components/calendar-browser";
|
|
9
|
+
@import "../components/intro-browser";
|
|
10
|
+
@import "../components/chip-browser";
|
|
11
|
+
@import "../components/stockee";
|
|
12
|
+
@import "../components/form/login-browser";
|
|
13
|
+
// external
|
|
14
|
+
@import "materialize-css/sass/materialize";
|
|
15
|
+
|
|
16
|
+
@import "../components/records-browser";
|
|
17
|
+
@import "../components/view-browser";
|
|
18
|
+
|
|
19
|
+
@import "../components/dashboard-browser";
|
|
20
|
+
@import "../components/theme-palettes/light";
|
|
21
|
+
@import "../components/theme-palettes/dark";
|
|
22
|
+
@import "../components/theme-palettes/compat";
|
|
23
|
+
@import "../components/enum-browser";
|
data/src/browser/tiun.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//= link_tree ../builds
|