From 9f0dec1c133976baba965fe919a8d0e78360141a Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Sun, 1 Dec 2024 18:49:38 -0800 Subject: [PATCH] Add pre-commit hook to prevent references to kolibri-common package in published packages. Add pre-commit hook to rebuild kolibri package. Fix all flagged issues. --- .pre-commit-config.yaml | 14 ++++++++ .../assets/src/views/DeviceInfoPage.vue | 2 +- .../views/DataPage/SyncInterface/index.vue | 4 +-- .../src/views/BrowseResourceMetadata.vue | 2 +- .../views/ChannelRenderer/ContentModal.vue | 2 +- .../views/CurrentlyViewedResourceMetadata.vue | 2 +- .../HybridLearningFooter.vue | 4 +-- .../assets/src/views/LearningActivityBar.vue | 4 +-- .../src/views/ResourceSyncingUiAlert.vue | 2 +- .../assets/src/views/StorageNotification.vue | 2 +- .../assets/src/views/TopicsContentPage.vue | 4 +-- .../perseus_viewer/assets/src/views/Tex.js | 2 +- .../assets/src/views/OnboardingStepBase.vue | 2 +- .../PersonalDataConsentForm.vue | 2 +- .../onboarding-forms/SettingUpKolibri.vue | 2 +- .../user_auth/assets/src/views/AuthBase.vue | 2 +- .../assets/src/views/UserAuthLayout.vue | 4 +-- .../components/CoreMenu/CoreMenuDivider.vue | 33 ------------------ .../__tests__/CoreMenuDivider.spec.js | 10 ------ .../components/SidePanelModal/index.vue | 2 +- .../userAccounts/PrivacyLinkAndModal.vue | 2 +- packages/kolibri-tools/lib/moduleMapping.js | 13 ++++--- .../components/Backdrop.vue | 0 .../components/CoreMenu/CoreMenuOption.vue | 0 .../CoreMenu/__tests__/CoreMenuOption.spec.js | 0 .../components/CoreMenu/index.vue | 0 .../components/DownloadButton.vue | 4 +-- .../components/GlobalSnackbar/index.vue | 2 +- .../GlobalSnackbar/internal}/CoreSnackbar.vue | 2 +- .../components/PrivacyInfoModal.vue | 0 .../__tests__/DownloadButton.spec.js | 0 .../__tests__/download-button.spec.js | 0 .../components/error/AppError.vue} | 0 .../components/error}/ReportErrorModal.vue | 0 .../components/error}/TechnicalTextBlock.vue | 0 .../error/__tests__}/AppError.spec.js | 2 +- .../components/error}/app-error-bird.png | Bin .../ContentRenderer/ContentRendererError.vue | 6 ++-- .../__tests__/contentViewer.spec.js | 7 +--- .../internal/ContentRenderer/index.js | 7 +--- .../internal/ContentRenderer/mixin.js | 2 +- .../internal/ContentRenderer/utils.js} | 0 .../components/internal}/filePresetStrings.js | 0 .../components/pages/AppBarPage/index.vue | 2 +- .../pages/AppBarPage/internal/SideNav.vue | 10 +++--- .../AppBarPage/internal/SideNavDivider.vue | 25 +++++++++---- .../pages/NotificationsRoot/index.vue | 8 ++--- .../PingbackNotificationDismissedResource.js | 0 .../internal}/PingbackNotificationResource.js | 0 .../pages/__tests__/NotificationsRoot.spec.js | 4 +-- .../internal}/UserProgressResource.js | 0 .../kolibri/composables/useTotalProgress.js | 2 +- .../composables/useUserSyncStatus.js | 6 +++- packages/kolibri/internal/apiSpec.js | 11 ++++++ packages/kolibri/internal/pluginMediator.js | 2 +- packages/kolibri/package.json | 11 ++++++ .../utils/scriptLoader.js | 0 57 files changed, 113 insertions(+), 116 deletions(-) delete mode 100644 packages/kolibri-common/components/CoreMenu/CoreMenuDivider.vue delete mode 100644 packages/kolibri-common/components/CoreMenu/__tests__/CoreMenuDivider.spec.js rename packages/{kolibri-common => kolibri}/components/Backdrop.vue (100%) rename packages/{kolibri-common => kolibri}/components/CoreMenu/CoreMenuOption.vue (100%) rename packages/{kolibri-common => kolibri}/components/CoreMenu/__tests__/CoreMenuOption.spec.js (100%) rename packages/{kolibri-common => kolibri}/components/CoreMenu/index.vue (100%) rename packages/{kolibri-common => kolibri}/components/DownloadButton.vue (94%) rename packages/{kolibri-common => kolibri}/components/GlobalSnackbar/index.vue (96%) rename packages/{kolibri-common/components/GlobalSnackbar => kolibri/components/GlobalSnackbar/internal}/CoreSnackbar.vue (98%) rename packages/{kolibri-common => kolibri}/components/PrivacyInfoModal.vue (100%) rename packages/{kolibri-common => kolibri}/components/__tests__/DownloadButton.spec.js (100%) rename packages/{kolibri-common => kolibri}/components/__tests__/download-button.spec.js (100%) rename packages/{kolibri-common/components/AppError/index.vue => kolibri/components/error/AppError.vue} (100%) rename packages/{kolibri-common/components/AppError => kolibri/components/error}/ReportErrorModal.vue (100%) rename packages/{kolibri-common/components/AppError => kolibri/components/error}/TechnicalTextBlock.vue (100%) rename packages/{kolibri-common/components/AppError/__test__ => kolibri/components/error/__tests__}/AppError.spec.js (97%) rename packages/{kolibri-common/components/AppError => kolibri/components/error}/app-error-bird.png (100%) rename packages/{kolibri-common/utils => kolibri/components/internal/ContentRenderer}/__tests__/contentViewer.spec.js (96%) rename packages/{kolibri-common/utils/contentViewer.js => kolibri/components/internal/ContentRenderer/utils.js} (100%) rename packages/{kolibri-common/uiText => kolibri/components/internal}/filePresetStrings.js (100%) rename packages/{kolibri-common/apiResources => kolibri/components/pages/NotificationsRoot/internal}/PingbackNotificationDismissedResource.js (100%) rename packages/{kolibri-common/apiResources => kolibri/components/pages/NotificationsRoot/internal}/PingbackNotificationResource.js (100%) rename packages/{kolibri-common/apiResources => kolibri/composables/internal}/UserProgressResource.js (100%) rename packages/{kolibri-common => kolibri}/composables/useUserSyncStatus.js (95%) rename packages/{kolibri-common => kolibri}/utils/scriptLoader.js (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d7782dcc211..e01aa0412e3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,6 +29,14 @@ repos: entry: yarn run lint-frontend:format language: system files: \.(js|vue|scss|css)$ +- repo: local + hooks: + - id: core-js-api + name: Rebuild kolibri package + description: Rebuilds kolibri package on changes to core js api + entry: yarn run build-kolibri-tools + language: system + files: ^packages/kolibri/.*\.(js|vue)$ - repo: local hooks: - id: no-auto-migrations @@ -75,6 +83,12 @@ repos: entry: settings\.AUTH_USER_MODEL language: pygrep files: migrations/.*\.py$ + - id: no-kolibri-common-imports + name: No imports from kolibri-common (which is unpublished) in any other packages + entry: kolibri-common + language: pygrep + exclude: (^packages/kolibri-common/|moduleMapping\.js|test/fixtures) + files: ^packages/.*\.(js|vue)$ - repo: https://github.com/isidentical/teyit rev: 0.4.3 hooks: diff --git a/kolibri/plugins/device/assets/src/views/DeviceInfoPage.vue b/kolibri/plugins/device/assets/src/views/DeviceInfoPage.vue index 7e058809359..0ca95550775 100644 --- a/kolibri/plugins/device/assets/src/views/DeviceInfoPage.vue +++ b/kolibri/plugins/device/assets/src/views/DeviceInfoPage.vue @@ -81,7 +81,7 @@ - - - diff --git a/packages/kolibri-common/components/CoreMenu/__tests__/CoreMenuDivider.spec.js b/packages/kolibri-common/components/CoreMenu/__tests__/CoreMenuDivider.spec.js deleted file mode 100644 index 650b1feb9b4..00000000000 --- a/packages/kolibri-common/components/CoreMenu/__tests__/CoreMenuDivider.spec.js +++ /dev/null @@ -1,10 +0,0 @@ -import { render, screen } from '@testing-library/vue'; -import CoreMenuDivider from '../CoreMenuDivider.vue'; - -describe('CoreMenuDivider', () => { - test('renders the component', () => { - render(CoreMenuDivider); - - expect(screen.getByRole('listitem')).toBeInTheDocument(); - }); -}); diff --git a/packages/kolibri-common/components/SidePanelModal/index.vue b/packages/kolibri-common/components/SidePanelModal/index.vue index 6dfd0da30cd..978faf87e51 100644 --- a/packages/kolibri-common/components/SidePanelModal/index.vue +++ b/packages/kolibri-common/components/SidePanelModal/index.vue @@ -67,7 +67,7 @@ - + diff --git a/packages/kolibri/components/pages/NotificationsRoot/index.vue b/packages/kolibri/components/pages/NotificationsRoot/index.vue index 19189f95ce6..e99d96d6297 100644 --- a/packages/kolibri/components/pages/NotificationsRoot/index.vue +++ b/packages/kolibri/components/pages/NotificationsRoot/index.vue @@ -44,15 +44,15 @@ import { mapState } from 'vuex'; import Lockr from 'lockr'; - import PingbackNotificationResource from 'kolibri-common/apiResources/PingbackNotificationResource'; - import PingbackNotificationDismissedResource from 'kolibri-common/apiResources/PingbackNotificationDismissedResource'; import { UPDATE_MODAL_DISMISSED } from 'kolibri/constants'; import { currentLanguage, defaultLanguage } from 'kolibri/utils/i18n'; import AuthMessage from 'kolibri/components/AuthMessage'; import AppBarPage from 'kolibri/components/pages/AppBarPage'; - import AppError from 'kolibri-common/components/AppError'; - import GlobalSnackbar from 'kolibri-common/components/GlobalSnackbar'; + import AppError from 'kolibri/components/error/AppError'; + import GlobalSnackbar from 'kolibri/components/GlobalSnackbar'; import useUser from 'kolibri/composables/useUser'; + import PingbackNotificationDismissedResource from './internal/PingbackNotificationDismissedResource'; + import PingbackNotificationResource from './internal/PingbackNotificationResource'; import UpdateNotification from './internal/UpdateNotification'; export default { diff --git a/packages/kolibri-common/apiResources/PingbackNotificationDismissedResource.js b/packages/kolibri/components/pages/NotificationsRoot/internal/PingbackNotificationDismissedResource.js similarity index 100% rename from packages/kolibri-common/apiResources/PingbackNotificationDismissedResource.js rename to packages/kolibri/components/pages/NotificationsRoot/internal/PingbackNotificationDismissedResource.js diff --git a/packages/kolibri-common/apiResources/PingbackNotificationResource.js b/packages/kolibri/components/pages/NotificationsRoot/internal/PingbackNotificationResource.js similarity index 100% rename from packages/kolibri-common/apiResources/PingbackNotificationResource.js rename to packages/kolibri/components/pages/NotificationsRoot/internal/PingbackNotificationResource.js diff --git a/packages/kolibri/components/pages/__tests__/NotificationsRoot.spec.js b/packages/kolibri/components/pages/__tests__/NotificationsRoot.spec.js index e56b26a2c56..080c6d2e292 100644 --- a/packages/kolibri/components/pages/__tests__/NotificationsRoot.spec.js +++ b/packages/kolibri/components/pages/__tests__/NotificationsRoot.spec.js @@ -6,8 +6,8 @@ import { coreStoreFactory as makeStore } from '../../../store'; import coreModule from '../../../../../kolibri/core/assets/src/state/modules/core'; jest.mock('kolibri/composables/useUser'); -jest.mock('kolibri-common/apiResources/PingbackNotificationResource'); -jest.mock('kolibri-common/apiResources/PingbackNotificationDismissedResource'); +jest.mock('../NotificationsRoot/internal/PingbackNotificationResource'); +jest.mock('../NotificationsRoot/internal/PingbackNotificationDismissedResource'); function makeWrapper(useUserMockObj = null) { const store = makeStore(); diff --git a/packages/kolibri-common/apiResources/UserProgressResource.js b/packages/kolibri/composables/internal/UserProgressResource.js similarity index 100% rename from packages/kolibri-common/apiResources/UserProgressResource.js rename to packages/kolibri/composables/internal/UserProgressResource.js diff --git a/packages/kolibri/composables/useTotalProgress.js b/packages/kolibri/composables/useTotalProgress.js index a5abc46fc57..b44276f09d5 100644 --- a/packages/kolibri/composables/useTotalProgress.js +++ b/packages/kolibri/composables/useTotalProgress.js @@ -1,8 +1,8 @@ import { ref, computed } from 'vue'; import { get, set } from '@vueuse/core'; import useUser from 'kolibri/composables/useUser'; -import UserProgressResource from 'kolibri-common/apiResources/UserProgressResource'; import { MaxPointsPerContent } from 'kolibri/constants'; +import UserProgressResource from './internal/UserProgressResource'; const totalProgress = ref(null); diff --git a/packages/kolibri-common/composables/useUserSyncStatus.js b/packages/kolibri/composables/useUserSyncStatus.js similarity index 95% rename from packages/kolibri-common/composables/useUserSyncStatus.js rename to packages/kolibri/composables/useUserSyncStatus.js index 3869c21f2c9..953ccb539da 100644 --- a/packages/kolibri-common/composables/useUserSyncStatus.js +++ b/packages/kolibri/composables/useUserSyncStatus.js @@ -1,10 +1,14 @@ import { ref, onMounted, onUnmounted, computed } from 'vue'; -import UserSyncStatusResource from 'kolibri-common/apiResources/UserSyncStatusResource'; +import { Resource } from 'kolibri/apiResource'; import store from 'kolibri/store'; import { SyncStatus } from 'kolibri/constants'; import { get, useTimeoutPoll } from '@vueuse/core'; import useUser from 'kolibri/composables/useUser'; +const UserSyncStatusResource = new Resource({ + name: 'usersyncstatus', +}); + const { isLearnerOnlyImport, isUserLoggedIn, currentUserId } = useUser(); const status = ref(SyncStatus.NOT_CONNECTED); diff --git a/packages/kolibri/internal/apiSpec.js b/packages/kolibri/internal/apiSpec.js index 1748254f346..47cb0d762bd 100644 --- a/packages/kolibri/internal/apiSpec.js +++ b/packages/kolibri/internal/apiSpec.js @@ -9,12 +9,21 @@ export default { 'kolibri/apiResources/TaskResource': require('kolibri/apiResources/TaskResource'), 'kolibri/client': require('kolibri/client'), 'kolibri/components/AuthMessage': require('kolibri/components/AuthMessage'), + 'kolibri/components/Backdrop': require('kolibri/components/Backdrop'), 'kolibri/components/BottomAppBar': require('kolibri/components/BottomAppBar'), 'kolibri/components/CoreLogo': require('kolibri/components/CoreLogo'), + 'kolibri/components/CoreMenu': require('kolibri/components/CoreMenu'), + 'kolibri/components/CoreMenu/CoreMenuOption': require('kolibri/components/CoreMenu/CoreMenuOption'), 'kolibri/components/CoreTable': require('kolibri/components/CoreTable'), + 'kolibri/components/DownloadButton': require('kolibri/components/DownloadButton'), 'kolibri/components/FilterTextbox': require('kolibri/components/FilterTextbox'), + 'kolibri/components/GlobalSnackbar': require('kolibri/components/GlobalSnackbar'), + 'kolibri/components/PrivacyInfoModal': require('kolibri/components/PrivacyInfoModal'), 'kolibri/components/SkipNavigationLink': require('kolibri/components/SkipNavigationLink'), 'kolibri/components/SyncStatusDisplay': require('kolibri/components/SyncStatusDisplay'), + 'kolibri/components/error/AppError': require('kolibri/components/error/AppError'), + 'kolibri/components/error/ReportErrorModal': require('kolibri/components/error/ReportErrorModal'), + 'kolibri/components/error/TechnicalTextBlock': require('kolibri/components/error/TechnicalTextBlock'), 'kolibri/components/language-switcher/LanguageSwitcherList': require('kolibri/components/language-switcher/LanguageSwitcherList'), 'kolibri/components/language-switcher/LanguageSwitcherModal': require('kolibri/components/language-switcher/LanguageSwitcherModal'), 'kolibri/components/pages/AppBarPage': require('kolibri/components/pages/AppBarPage'), @@ -27,6 +36,7 @@ export default { 'kolibri/composables/useSnackbar': require('kolibri/composables/useSnackbar'), 'kolibri/composables/useTotalProgress': require('kolibri/composables/useTotalProgress'), 'kolibri/composables/useUser': require('kolibri/composables/useUser'), + 'kolibri/composables/useUserSyncStatus': require('kolibri/composables/useUserSyncStatus'), 'kolibri/constants': require('kolibri/constants'), 'kolibri/heartbeat': require('kolibri/heartbeat'), 'kolibri/router': require('kolibri/router'), @@ -44,6 +54,7 @@ export default { 'kolibri/utils/i18n': require('kolibri/utils/i18n'), 'kolibri/utils/objectSpecs': require('kolibri/utils/objectSpecs'), 'kolibri/utils/redirectBrowser': require('kolibri/utils/redirectBrowser'), + 'kolibri/utils/scriptLoader': require('kolibri/utils/scriptLoader'), 'kolibri/utils/serverClock': require('kolibri/utils/serverClock'), 'kolibri/utils/validators': require('kolibri/utils/validators'), 'kolibri-logging': require('kolibri-logging'), diff --git a/packages/kolibri/internal/pluginMediator.js b/packages/kolibri/internal/pluginMediator.js index a5dd4b6dd96..c4303716515 100644 --- a/packages/kolibri/internal/pluginMediator.js +++ b/packages/kolibri/internal/pluginMediator.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import logging from 'kolibri-logging'; -import scriptLoader from 'kolibri-common/utils/scriptLoader'; +import scriptLoader from 'kolibri/utils/scriptLoader'; import { RENDERER_SUFFIX } from 'kolibri/constants'; import { languageDirection, languageDirections, currentLanguage } from 'kolibri/utils/i18n'; import contentRendererMixin from '../components/internal/ContentRenderer/mixin'; diff --git a/packages/kolibri/package.json b/packages/kolibri/package.json index 24c118272af..c00f0ff1a58 100644 --- a/packages/kolibri/package.json +++ b/packages/kolibri/package.json @@ -16,12 +16,21 @@ "./apiResources/TaskResource": "./apiResources/TaskResource", "./client": "./client", "./components/AuthMessage": "./components/AuthMessage", + "./components/Backdrop": "./components/Backdrop", "./components/BottomAppBar": "./components/BottomAppBar", "./components/CoreLogo": "./components/CoreLogo", + "./components/CoreMenu": "./components/CoreMenu", + "./components/CoreMenu/CoreMenuOption": "./components/CoreMenu/CoreMenuOption", "./components/CoreTable": "./components/CoreTable", + "./components/DownloadButton": "./components/DownloadButton", "./components/FilterTextbox": "./components/FilterTextbox", + "./components/GlobalSnackbar": "./components/GlobalSnackbar", + "./components/PrivacyInfoModal": "./components/PrivacyInfoModal", "./components/SkipNavigationLink": "./components/SkipNavigationLink", "./components/SyncStatusDisplay": "./components/SyncStatusDisplay", + "./components/error/AppError": "./components/error/AppError", + "./components/error/ReportErrorModal": "./components/error/ReportErrorModal", + "./components/error/TechnicalTextBlock": "./components/error/TechnicalTextBlock", "./components/language-switcher/LanguageSwitcherList": "./components/language-switcher/LanguageSwitcherList", "./components/language-switcher/LanguageSwitcherModal": "./components/language-switcher/LanguageSwitcherModal", "./components/pages/AppBarPage": "./components/pages/AppBarPage", @@ -34,6 +43,7 @@ "./composables/useSnackbar": "./composables/useSnackbar", "./composables/useTotalProgress": "./composables/useTotalProgress", "./composables/useUser": "./composables/useUser", + "./composables/useUserSyncStatus": "./composables/useUserSyncStatus", "./constants": "./constants", "./heartbeat": "./heartbeat", "./router": "./router", @@ -51,6 +61,7 @@ "./utils/i18n": "./utils/i18n", "./utils/objectSpecs": "./utils/objectSpecs", "./utils/redirectBrowser": "./utils/redirectBrowser", + "./utils/scriptLoader": "./utils/scriptLoader", "./utils/serverClock": "./utils/serverClock", "./utils/validators": "./utils/validators" }, diff --git a/packages/kolibri-common/utils/scriptLoader.js b/packages/kolibri/utils/scriptLoader.js similarity index 100% rename from packages/kolibri-common/utils/scriptLoader.js rename to packages/kolibri/utils/scriptLoader.js