@kabmo-labs/kabmo 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -421
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +426 -413
- package/dist/client/static/js/{index-amss8pge.js → index-0smc9gm2.js} +1123 -747
- package/dist/client/static/js/index-shexbk5f.css +1 -0
- package/marketplace/marketplace.json +13 -3
- package/marketplace/plugins/command-runner/package.json +4 -2
- package/marketplace/plugins/git-forge/README.md +219 -0
- package/marketplace/plugins/git-forge/icon.svg +20 -0
- package/marketplace/plugins/git-forge/package.json +56 -0
- package/marketplace/plugins/git-forge/src/app.tsx +82 -0
- package/marketplace/plugins/git-forge/src/command.test.ts +181 -0
- package/marketplace/plugins/git-forge/src/command.ts +119 -0
- package/marketplace/plugins/git-forge/src/header.tsx +87 -0
- package/marketplace/plugins/git-forge/src/panel/Badge.tsx +76 -0
- package/marketplace/plugins/git-forge/src/panel/Change.tsx +150 -0
- package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +51 -0
- package/marketplace/plugins/git-forge/src/panel/Credential.tsx +107 -0
- package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +70 -0
- package/marketplace/plugins/git-forge/src/panel/Header.tsx +255 -0
- package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +198 -0
- package/marketplace/plugins/git-forge/src/panel/List.tsx +89 -0
- package/marketplace/plugins/git-forge/src/panel/Row.tsx +68 -0
- package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +94 -0
- package/marketplace/plugins/git-forge/src/panel/Write.tsx +236 -0
- package/marketplace/plugins/git-forge/src/panel/format.ts +78 -0
- package/marketplace/plugins/git-forge/src/panel/index.test.tsx +344 -0
- package/marketplace/plugins/git-forge/src/panel/index.tsx +193 -0
- package/marketplace/plugins/git-forge/src/panel/use-forge.ts +250 -0
- package/marketplace/plugins/git-forge/src/panel/write.test.tsx +269 -0
- package/marketplace/plugins/git-forge/src/protocol.ts +308 -0
- package/marketplace/plugins/git-forge/src/server/adapters.test.ts +274 -0
- package/marketplace/plugins/git-forge/src/server/bitbucket.ts +307 -0
- package/marketplace/plugins/git-forge/src/server/capabilities.test.ts +116 -0
- package/marketplace/plugins/git-forge/src/server/capabilities.ts +105 -0
- package/marketplace/plugins/git-forge/src/server/ci.test.ts +88 -0
- package/marketplace/plugins/git-forge/src/server/ci.ts +118 -0
- package/marketplace/plugins/git-forge/src/server/context.ts +76 -0
- package/marketplace/plugins/git-forge/src/server/diff.test.ts +127 -0
- package/marketplace/plugins/git-forge/src/server/diff.ts +120 -0
- package/marketplace/plugins/git-forge/src/server/filters.test.ts +138 -0
- package/marketplace/plugins/git-forge/src/server/filters.ts +138 -0
- package/marketplace/plugins/git-forge/src/server/forges.test.ts +235 -0
- package/marketplace/plugins/git-forge/src/server/gitea.ts +296 -0
- package/marketplace/plugins/git-forge/src/server/github-extras.ts +92 -0
- package/marketplace/plugins/git-forge/src/server/github.ts +320 -0
- package/marketplace/plugins/git-forge/src/server/gitlab-detail.ts +207 -0
- package/marketplace/plugins/git-forge/src/server/gitlab.test.ts +195 -0
- package/marketplace/plugins/git-forge/src/server/gitlab.ts +176 -0
- package/marketplace/plugins/git-forge/src/server/http.test.ts +270 -0
- package/marketplace/plugins/git-forge/src/server/http.ts +329 -0
- package/marketplace/plugins/git-forge/src/server/map.ts +120 -0
- package/marketplace/plugins/git-forge/src/server/registry.ts +47 -0
- package/marketplace/plugins/git-forge/src/server/remote.test.ts +146 -0
- package/marketplace/plugins/git-forge/src/server/remote.ts +188 -0
- package/marketplace/plugins/git-forge/src/server/scope-probe.test.ts +98 -0
- package/marketplace/plugins/git-forge/src/server/scope-probe.ts +128 -0
- package/marketplace/plugins/git-forge/src/server/scope.ts +66 -0
- package/marketplace/plugins/git-forge/src/server/test-context.ts +67 -0
- package/marketplace/plugins/git-forge/src/server/test-host.ts +51 -0
- package/marketplace/plugins/git-forge/src/server/token.test.ts +107 -0
- package/marketplace/plugins/git-forge/src/server/token.ts +139 -0
- package/marketplace/plugins/git-forge/src/server/write-http.test.ts +127 -0
- package/marketplace/plugins/git-forge/src/server/write-http.ts +110 -0
- package/marketplace/plugins/git-forge/src/server/writes.test.ts +218 -0
- package/marketplace/plugins/git-forge/src/server/writes.ts +313 -0
- package/marketplace/plugins/git-forge/src/server.ts +284 -0
- package/marketplace/plugins/git-forge/tsconfig.json +16 -0
- package/marketplace/plugins/session-info/package.json +4 -2
- package/marketplace/plugins/stats/package.json +4 -2
- package/package.json +6 -1
- package/src/client/components/common/code-surface/blame-hover.ts +188 -0
- package/src/client/components/common/code-surface/blame-panel.test.ts +304 -0
- package/src/client/components/common/code-surface/blame-panel.ts +306 -0
- package/src/client/components/common/code-surface/blame.test.ts +303 -0
- package/src/client/components/common/code-surface/blame.ts +227 -0
- package/src/client/components/common/code-surface/conflict-markers.test.ts +135 -0
- package/src/client/components/common/code-surface/conflict-markers.ts +144 -0
- package/src/client/components/common/code-surface/documents.ts +48 -1
- package/src/client/components/common/code-surface/extensions.test.ts +4 -0
- package/src/client/components/common/code-surface/extensions.ts +44 -0
- package/src/client/components/common/code-surface/fold-stack.test.ts +4 -0
- package/src/client/components/common/code-surface/indent.test.ts +5 -0
- package/src/client/components/common/code-surface/index.tsx +16 -2
- package/src/client/components/common/code-surface/lint-parsers.test.ts +109 -0
- package/src/client/components/common/code-surface/lint-parsers.ts +134 -0
- package/src/client/components/common/code-surface/lint.test.ts +101 -0
- package/src/client/components/common/code-surface/lint.ts +85 -0
- package/src/client/components/common/code-surface/props.ts +17 -0
- package/src/client/components/common/code-surface/surface-failures.test.ts +132 -0
- package/src/client/components/common/code-surface/theme.ts +71 -0
- package/src/client/components/common/header-controls/index.test.tsx +1 -1
- package/src/client/components/common/header-controls/plugin-entry.test.tsx +1 -1
- package/src/client/components/common/header-controls/shell-chrome.test.tsx +1 -1
- package/src/client/components/common/provider-icon/Plate.tsx +88 -0
- package/src/client/components/common/provider-icon/index.tsx +55 -11
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +5 -2
- package/src/client/components/mobile/SessionSidebar.tsx +2 -10
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +6 -0
- package/src/client/components/mobile/mobile-right-sidebar/StatusBar.tsx +8 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +3 -0
- package/src/client/components/settings/categories/ProviderSettings.tsx +43 -41
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +97 -0
- package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +106 -54
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +14 -1
- package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +39 -150
- package/src/client/components/settings/categories/panel-plugins/Meta.test.tsx +143 -0
- package/src/client/components/settings/categories/panel-plugins/Meta.tsx +157 -0
- package/src/client/components/settings/categories/panel-plugins/Placement.test.tsx +149 -0
- package/src/client/components/settings/categories/panel-plugins/Placement.tsx +99 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +270 -0
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +11 -3
- package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +25 -0
- package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +135 -80
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +51 -21
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +175 -0
- package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +275 -0
- package/src/client/components/settings/categories/provider-settings/Header.tsx +40 -9
- package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +142 -160
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +84 -46
- package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +217 -102
- package/src/client/components/settings/categories/provider-settings/PresetPicker.tsx +5 -2
- package/src/client/components/settings/categories/provider-settings/SidebarList.plugin.test.ts +3 -3
- package/src/client/components/settings/categories/provider-settings/SidebarList.tsx +158 -102
- package/src/client/components/settings/categories/provider-settings/auth-section.test.tsx +135 -0
- package/src/client/components/settings/categories/provider-settings/groups.test.ts +98 -0
- package/src/client/components/settings/categories/provider-settings/groups.ts +108 -0
- package/src/client/components/settings/categories/provider-settings/layout.test.tsx +325 -0
- package/src/client/components/settings/categories/provider-settings/model-dialogs.test.tsx +135 -0
- package/src/client/components/settings/categories/provider-settings/preset-picker.test.tsx +73 -0
- package/src/client/components/settings/categories/usage-settings/ProviderCard.tsx +22 -2
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +2 -0
- package/src/client/components/settings/categories/usage-settings/SidebarList.tsx +16 -6
- package/src/client/components/settings/categories/usage-settings/providers.ts +3 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +19 -0
- package/src/client/components/settings/categories/usage-settings/usage-icons.test.tsx +143 -0
- package/src/client/components/workspace/chat-timeline/MinimapShortcuts.test.ts +2 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +23 -19
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +23 -19
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +20 -18
- package/src/client/components/workspace/chat-timeline/chat-input/compact.test.tsx +19 -6
- package/src/client/components/workspace/chat-timeline/index.tsx +7 -16
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +100 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +3 -47
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +8 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-test-util.ts +62 -0
- package/src/client/components/workspace/diff-panel/HunkStepper.tsx +62 -0
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +29 -0
- package/src/client/components/workspace/diff-panel/Toolbar.tsx +32 -1
- package/src/client/components/workspace/diff-panel/changes.ts +69 -0
- package/src/client/components/workspace/diff-panel/chunks.ts +85 -0
- package/src/client/components/workspace/diff-panel/index.tsx +21 -1
- package/src/client/components/workspace/diff-panel/merge.test.ts +145 -0
- package/src/client/components/workspace/diff-panel/merge.ts +63 -68
- package/src/client/components/workspace/editor/EditorDropOverlay.tsx +6 -1
- package/src/client/components/workspace/editor/FileDocument.tsx +51 -1
- package/src/client/components/workspace/editor/FilePane.tsx +25 -1
- package/src/client/components/workspace/editor/StatusBar.tsx +19 -0
- package/src/client/components/workspace/editor/Toolbar.tsx +29 -5
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +86 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +48 -16
- package/src/client/components/workspace/editor/viewers/bytes.ts +16 -0
- package/src/client/components/workspace/git-panel/index.test.ts +46 -1
- package/src/client/components/workspace/git-panel/index.tsx +11 -38
- package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +66 -0
- package/src/client/components/workspace/model-dropdown/Item.tsx +71 -62
- package/src/client/components/workspace/model-dropdown/Section.tsx +31 -14
- package/src/client/components/workspace/model-dropdown/collapsed.ts +72 -0
- package/src/client/components/workspace/model-dropdown/index.tsx +42 -19
- package/src/client/components/workspace/model-dropdown/refresh.test.tsx +260 -0
- package/src/client/components/workspace/model-dropdown/trigger.test.ts +34 -0
- package/src/client/components/workspace/model-dropdown/use-catalog.ts +13 -2
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +19 -3
- package/src/client/hooks/chat/omp/folder-auto-expand.ts +113 -0
- package/src/client/hooks/chat/omp/index.ts +20 -0
- package/src/client/hooks/chat/omp/pending-rows.ts +21 -0
- package/src/client/hooks/chat/omp/pending-sessions.test.ts +16 -1
- package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +102 -0
- package/src/client/hooks/chat/omp/session-sidebar-controller.ts +21 -1
- package/src/client/hooks/chat/omp/stream.ts +8 -1
- package/src/client/hooks/chat/timeline/index.ts +1 -1
- package/src/client/hooks/chat/timeline/new-chat-open.ts +60 -0
- package/src/client/hooks/editor/blame-settings.ts +67 -0
- package/src/client/hooks/editor/blame.test.ts +272 -0
- package/src/client/hooks/editor/blame.ts +232 -0
- package/src/client/hooks/editor/file-editor-types.ts +23 -0
- package/src/client/hooks/editor/save-file.test.ts +20 -0
- package/src/client/hooks/editor/use-editor-drop.test-util.ts +198 -0
- package/src/client/hooks/editor/use-editor-drop.test.ts +70 -175
- package/src/client/hooks/editor/use-editor-drop.ts +19 -36
- package/src/client/hooks/editor/use-file-editor.ts +7 -1
- package/src/client/hooks/settings/providers/actions.ts +90 -194
- package/src/client/hooks/settings/providers/api.ts +7 -1
- package/src/client/hooks/settings/providers/index.ts +171 -59
- package/src/client/hooks/settings/providers/login.test.ts +79 -0
- package/src/client/hooks/settings/providers/login.ts +276 -0
- package/src/client/hooks/settings/providers/messages.ts +28 -0
- package/src/client/hooks/settings/providers/model-actions.ts +178 -0
- package/src/client/hooks/ui/editor-error-toast.ts +47 -0
- package/src/client/hooks/ui/open-file.ts +7 -0
- package/src/client/hooks/ui/toasts.ts +7 -0
- package/src/client/hooks/workspace/file-tabs.ts +4 -1
- package/src/client/hooks/workspace/folder-expansion.test.ts +62 -0
- package/src/client/hooks/workspace/folder-expansion.ts +33 -0
- package/src/client/hooks/workspace/git-action-outcome.ts +86 -0
- package/src/client/hooks/workspace/git-actions.ts +29 -2
- package/src/client/hooks/workspace/plugin-contributions.test.ts +117 -0
- package/src/client/hooks/workspace/plugin-contributions.ts +146 -0
- package/src/client/lib/editor-errors.test.ts +85 -0
- package/src/client/lib/editor-errors.ts +71 -0
- package/src/client/lib/fs/resolve-open.test.ts +125 -0
- package/src/client/lib/fs/resolve-open.ts +90 -0
- package/src/client/lib/git/action-message.test.ts +82 -0
- package/src/client/lib/git/action-message.ts +160 -0
- package/src/client/lib/launch/device-files.test.ts +160 -0
- package/src/client/lib/launch/device-files.ts +197 -0
- package/src/client/lib/native/open-paths.test.ts +140 -0
- package/src/client/lib/native/open-paths.ts +157 -0
- package/src/client/lib/plugins/bootstrap.test.ts +1 -1
- package/src/client/main.tsx +20 -0
- package/src/server/db.server.test.ts +39 -0
- package/src/server/db.server.ts +21 -2
- package/src/server/lib/db/schema.ts +2 -0
- package/src/server/lib/fs/external-roots.test.ts +100 -0
- package/src/server/lib/fs/external-roots.ts +101 -0
- package/src/server/lib/fs/git-actions-branch.ts +15 -2
- package/src/server/lib/fs/git-actions-shared.ts +24 -0
- package/src/server/lib/fs/git-actions-sync.test.ts +18 -7
- package/src/server/lib/fs/git-actions-worktree.ts +5 -1
- package/src/server/lib/fs/git-blame.test.ts +206 -0
- package/src/server/lib/fs/git-blame.ts +189 -0
- package/src/server/lib/fs/root.ts +14 -0
- package/src/server/lib/http/same-origin.ts +28 -7
- package/src/server/lib/models/catalog.server.ts +230 -0
- package/src/server/lib/models/catalog.test.ts +83 -0
- package/src/server/lib/models/credential-origin.server.ts +108 -0
- package/src/server/lib/models/credential-origin.test.ts +132 -0
- package/src/server/lib/models/provider-icon-fetch.ts +115 -0
- package/src/server/lib/models/provider-icon-parse.test.ts +134 -0
- package/src/server/lib/models/provider-icon-parse.ts +139 -0
- package/src/server/lib/models/provider-icon-store.server.ts +118 -0
- package/src/server/lib/models/provider-icon-store.test.ts +107 -0
- package/src/server/lib/models/provider-icon.server.ts +209 -0
- package/src/server/lib/models/provider-items.server.ts +211 -37
- package/src/server/lib/models/provider-items.test.ts +201 -0
- package/src/server/lib/models/provider-registry.server.test.ts +27 -9
- package/src/server/lib/models/provider-registry.server.ts +160 -67
- package/src/server/lib/models/registry.server.test.ts +3 -3
- package/src/server/lib/models/registry.server.ts +8 -0
- package/src/server/lib/omp/config/definitions.test.ts +5 -4
- package/src/server/lib/omp/config/models-config.ts +42 -0
- package/src/server/lib/omp/config/provider-entry.test.ts +205 -0
- package/src/server/lib/omp/config/provider-entry.ts +197 -0
- package/src/server/lib/omp/config/provider-seeds.ts +10 -0
- package/src/server/lib/omp/core/models-json.ts +69 -0
- package/src/server/lib/omp/session/messages.ts +17 -3
- package/src/server/lib/omp/session/sidebar-data.canonical.test.ts +13 -3
- package/src/server/lib/panels/bundled-catalog.server.ts +7 -0
- package/src/server/lib/panels/catalog-offers.server.ts +68 -0
- package/src/server/lib/panels/git-update.server.test.ts +14 -0
- package/src/server/lib/panels/git-update.server.ts +63 -1
- package/src/server/lib/panels/manifest.test.ts +65 -0
- package/src/server/lib/panels/manifest.ts +55 -1
- package/src/server/lib/panels/offers.server.test.ts +191 -0
- package/src/server/lib/panels/offers.server.ts +108 -0
- package/src/server/lib/panels/registry.server.test.ts +35 -1
- package/src/server/lib/panels/registry.server.ts +51 -142
- package/src/server/lib/panels/scan.server.ts +162 -0
- package/src/server/lib/route-adapter.ts +13 -2
- package/src/server/lib/tray/tray.test.ts +2 -1
- package/src/server/lib/usage/providers.server.ts +4 -1
- package/src/server/routes/chat/session.ts +7 -1
- package/src/server/routes/fs/git-blame-loader.test.ts +146 -0
- package/src/server/routes/fs/git.ts +17 -0
- package/src/server/routes/fs/grant.test.ts +135 -0
- package/src/server/routes/fs/grant.ts +79 -0
- package/src/server/routes/fs/index.ts +2 -0
- package/src/server/routes/fs/scope.ts +34 -17
- package/src/server/routes/omp/login.ts +41 -14
- package/src/server/routes/omp/routes.test.ts +23 -10
- package/src/server/routes/settings/index.ts +8 -0
- package/src/server/routes/settings/provider-entry.ts +108 -0
- package/src/server/routes/settings/provider-icon.ts +99 -0
- package/src/server/routes/settings/provider-model.ts +4 -1
- package/src/server/routes/settings/provider-refresh.ts +87 -0
- package/src/server/routes/settings/providers.ts +31 -2
- package/src/shared/lib/chat/omp/fold.test.ts +34 -0
- package/src/shared/lib/chat/omp/tool-frames.test.ts +20 -0
- package/src/shared/lib/chat/omp/tool-frames.ts +5 -1
- package/src/shared/lib/chat/omp/tool-results.ts +29 -3
- package/src/shared/lib/chat/tool/wait-facts.ts +4 -0
- package/src/shared/lib/fs/git-blame.test.ts +266 -0
- package/src/shared/lib/fs/git-blame.ts +246 -0
- package/src/shared/lib/git/url.ts +18 -0
- package/src/shared/lib/markdown/sanitize.test.ts +57 -0
- package/src/shared/lib/markdown/sanitize.ts +30 -7
- package/src/shared/lib/models/provider/connection.ts +135 -0
- package/src/shared/lib/models/provider/dialect.test.ts +4 -2
- package/src/shared/lib/models/provider/dialect.ts +76 -6
- package/src/shared/lib/models/provider/models.ts +2 -0
- package/src/shared/lib/models/provider/origin.ts +94 -0
- package/src/shared/lib/models/provider/provider-ui.test.ts +7 -0
- package/src/shared/lib/models/server-cache.ts +8 -3
- package/src/shared/lib/omp/session/messages-map-pending.test.ts +110 -0
- package/src/shared/lib/omp/session/messages-map.ts +34 -2
- package/src/shared/lib/omp/session/prewarm-misc.test.ts +7 -90
- package/src/shared/lib/omp/session/prewarm.test.ts +133 -0
- package/src/shared/lib/omp/session/prewarm.ts +23 -1
- package/src/shared/lib/omp/session/wait.test.ts +28 -0
- package/src/shared/lib/omp/session/wait.ts +38 -3
- package/src/shared/lib/panels/slot-labels.test.ts +61 -0
- package/src/shared/lib/panels/slot-labels.ts +133 -0
- package/src/shared/lib/workspace/panel-ids.ts +11 -0
- package/src/shared/types/fs.ts +6 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/models.ts +12 -0
- package/src/shared/types/panels-registry.ts +277 -0
- package/src/shared/types/panels.ts +46 -213
- package/src/shared/types/settings/provider.ts +58 -0
- package/src/shared/types/settings/usage.ts +10 -0
- package/src/test-support/pristine-globals.ts +7 -0
- package/dist/client/static/js/index-bq6qeayr.css +0 -1
- package/src/client/components/settings/categories/provider-settings/ReconnectModal.tsx +0 -184
|
@@ -47,6 +47,13 @@ export async function readBundledCatalog(bundledRoot: string, installed: Readonl
|
|
|
47
47
|
// directory, which the routes resolve through the same registry.
|
|
48
48
|
...(manifest.icon ? { iconUrl: await iconUrl(pluginDir, manifest.icon) } : {}),
|
|
49
49
|
...(await readmeUrlFor(pluginDir, manifest)),
|
|
50
|
+
...(manifest.author ? { author: manifest.author } : {}),
|
|
51
|
+
...(manifest.homepage ? { homepage: manifest.homepage } : {}),
|
|
52
|
+
...(manifest.slots ? { slots: manifest.slots } : {}),
|
|
53
|
+
// A store card names where the code will come from, because a bundled
|
|
54
|
+
// install and a cloned one behave differently afterwards: one is kept
|
|
55
|
+
// current by Kabmo's own sync, the other is the user's clone.
|
|
56
|
+
origin: 'bundled',
|
|
50
57
|
installed: installed.has(manifest.id),
|
|
51
58
|
});
|
|
52
59
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The plugins a `marketplace.json` OFFERS without holding them.
|
|
8
|
+
*
|
|
9
|
+
* A catalog entry's `source` is normally a directory inside the marketplace, and
|
|
10
|
+
* the scan reads that directory. It may also be a REMOTE git URL, and then there
|
|
11
|
+
* is nothing to scan: the entry is an offer, and installing it is a clone
|
|
12
|
+
* exactly like a URL typed into the install form. That is what lets one catalog
|
|
13
|
+
* curate plugins that live in their own repositories — the case a marketplace
|
|
14
|
+
* owner has no way to express otherwise, short of vendoring a copy.
|
|
15
|
+
*
|
|
16
|
+
* Read from BOTH catalogs, for two different reasons: the working marketplace's
|
|
17
|
+
* own file (the user curated a list), and the bundled one (Kabmo ships a curated
|
|
18
|
+
* list). They merge into the pane's single "Available" grid, so a reader does
|
|
19
|
+
* not have to know which file an offer came from.
|
|
20
|
+
*
|
|
21
|
+
* A remote offer carries no icon and no README: both are files inside the
|
|
22
|
+
* plugin's directory, and the directory does not exist until the clone. The card
|
|
23
|
+
* falls back to the plugin's initials and offers no reader, which is the honest
|
|
24
|
+
* answer rather than a broken image.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { dirname } from 'path';
|
|
28
|
+
import type { PanelCatalogEntry } from '@/shared/types';
|
|
29
|
+
import { readJsonBody } from '@/server/lib/panels/files.server';
|
|
30
|
+
import { toMarketplaceCatalog } from '@/server/lib/panels/manifest';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Every remote offer in one catalog file.
|
|
34
|
+
*
|
|
35
|
+
* `installed` compares the catalog's own `name` against the installed ids: a
|
|
36
|
+
* remote entry names no manifest id (the manifest lives in a repository nobody
|
|
37
|
+
* has cloned), so the catalog name is the only key available — and it is the
|
|
38
|
+
* name the pane shows. A mismatch after an install would show the offer again,
|
|
39
|
+
* which is a duplicate row rather than a wrong action.
|
|
40
|
+
*/
|
|
41
|
+
export async function readRemoteOffers(
|
|
42
|
+
catalogPath: string,
|
|
43
|
+
installed: ReadonlySet<string>,
|
|
44
|
+
): Promise<PanelCatalogEntry[]> {
|
|
45
|
+
const read = await readJsonBody(catalogPath);
|
|
46
|
+
if (read.kind !== 'body') return [];
|
|
47
|
+
const catalog = toMarketplaceCatalog(read.value, dirname(catalogPath));
|
|
48
|
+
if ('error' in catalog) return [];
|
|
49
|
+
const offers: PanelCatalogEntry[] = [];
|
|
50
|
+
for (const entry of catalog.plugins ?? []) {
|
|
51
|
+
if (!entry.remote) continue;
|
|
52
|
+
offers.push({
|
|
53
|
+
pluginId: entry.name,
|
|
54
|
+
name: entry.name,
|
|
55
|
+
// A catalog entry states the version it publishes, or states nothing. The
|
|
56
|
+
// clone's own manifest is authoritative once installed, and the card says
|
|
57
|
+
// "unversioned" rather than inventing one.
|
|
58
|
+
version: entry.version ?? '',
|
|
59
|
+
...(entry.description ? { description: entry.description } : {}),
|
|
60
|
+
...(entry.author ? { author: entry.author } : {}),
|
|
61
|
+
...(entry.homepage ? { homepage: entry.homepage } : {}),
|
|
62
|
+
origin: 'git',
|
|
63
|
+
url: entry.source,
|
|
64
|
+
installed: installed.has(entry.name),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return offers;
|
|
68
|
+
}
|
|
@@ -138,6 +138,20 @@ describe('probeGitUpdate', () => {
|
|
|
138
138
|
const status = await probeGitUpdate('from-git');
|
|
139
139
|
expect(status.updateAvailable).toBe(true);
|
|
140
140
|
expect(status.current).not.toBe(status.latest);
|
|
141
|
+
// The VERSION the remote publishes rides along, read from the remote's own
|
|
142
|
+
// manifest — a commit pair answers "is this behind", never "which release".
|
|
143
|
+
expect(status.latestVersion).toBe('2.0.0');
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test.skipIf(!hasGit)('an up-to-date clone carries no remote version, and pays no fetch', async () => {
|
|
147
|
+
const repo = makeRepo();
|
|
148
|
+
await installPanelPluginFromGit(repo);
|
|
149
|
+
|
|
150
|
+
const status = await probeGitUpdate('from-git');
|
|
151
|
+
expect(status.updateAvailable).toBe(false);
|
|
152
|
+
// Absent, not equal: a clone with nothing to fetch never reads the remote's
|
|
153
|
+
// tree, so the card shows the installed version alone.
|
|
154
|
+
expect(status.latestVersion).toBeUndefined();
|
|
141
155
|
});
|
|
142
156
|
|
|
143
157
|
test.skipIf(!hasGit)('an unreachable remote is reported, not thrown', async () => {
|
|
@@ -37,6 +37,7 @@ import { getMarketplacePluginsDir, invalidatePanelScan } from '@/server/lib/pane
|
|
|
37
37
|
import { readGitOrigin } from '@/server/lib/panels/git-clone.server';
|
|
38
38
|
import { readPluginManifest } from '@/server/lib/panels/files.server';
|
|
39
39
|
import { toManifest } from '@/server/lib/panels/manifest';
|
|
40
|
+
import { isRecord } from '@/shared/lib/util/guards';
|
|
40
41
|
import { buildPanelPlugin } from '@/server/lib/panels/build.server';
|
|
41
42
|
import type { PanelGitStatus } from '@/shared/types';
|
|
42
43
|
|
|
@@ -73,6 +74,40 @@ async function readLocalHead(dir: string): Promise<string | null> {
|
|
|
73
74
|
return result.exitCode === 0 ? asSha(result.stdout) : null;
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
/**
|
|
78
|
+
* The version the remote's manifest declares, read at the commit just fetched.
|
|
79
|
+
*
|
|
80
|
+
* Requires `FETCH_HEAD` to be current — the caller fetches first, and only when
|
|
81
|
+
* the clone is BEHIND, so an up-to-date clone pays no extra round trip. The two
|
|
82
|
+
* files a manifest can live in are tried in the same order the scan uses
|
|
83
|
+
* (`package.json`'s `kabmo`/`pi` key, then a standalone `kabmo.json`), through
|
|
84
|
+
* the same `toManifest`, so the version shown is the one the install would
|
|
85
|
+
* produce rather than a second parse of the same file.
|
|
86
|
+
*
|
|
87
|
+
* `undefined` when the remote's tree cannot be read — a repository whose
|
|
88
|
+
* manifest sits in a subdirectory, a private remote that answered the ref but
|
|
89
|
+
* not the blob. The card then shows the installed version alone; inventing one
|
|
90
|
+
* would be worse than saying nothing.
|
|
91
|
+
*/
|
|
92
|
+
async function readRemoteVersion(dir: string): Promise<string | undefined> {
|
|
93
|
+
for (const file of ['package.json', 'kabmo.json']) {
|
|
94
|
+
const show = await gitRun(['show', `FETCH_HEAD:${file}`], { cwd: dir, timeoutMs: PROBE_TIMEOUT_MS });
|
|
95
|
+
if (show.exitCode !== 0) continue;
|
|
96
|
+
let body: unknown;
|
|
97
|
+
try {
|
|
98
|
+
body = JSON.parse(show.stdout);
|
|
99
|
+
} catch {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const record = isRecord(body) ? body : {};
|
|
103
|
+
const raw = file === 'package.json' ? (record.kabmo ?? record.pi) : body;
|
|
104
|
+
const manifest = toManifest(raw, dir);
|
|
105
|
+
if ('error' in manifest) continue;
|
|
106
|
+
return manifest.version;
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
|
|
76
111
|
/** Whether the clone has uncommitted work that an update would discard. */
|
|
77
112
|
async function isDirty(dir: string): Promise<boolean> {
|
|
78
113
|
const result = await gitRun(['status', '--porcelain'], { cwd: dir, timeoutMs: PROBE_TIMEOUT_MS });
|
|
@@ -108,7 +143,34 @@ export async function probeGitUpdate(pluginId: string): Promise<PanelGitStatus>
|
|
|
108
143
|
if (remote.sha === null) {
|
|
109
144
|
return { current, latest: null, updateAvailable: false, checkedAt, ...(remote.error ? { error: remote.error } : {}) };
|
|
110
145
|
}
|
|
111
|
-
|
|
146
|
+
const updateAvailable = current !== null && current !== remote.sha;
|
|
147
|
+
// The version only means anything when the two sides DIFFER, and reading it
|
|
148
|
+
// needs the remote's tree — so the fetch happens here, on the one branch where
|
|
149
|
+
// the answer is worth a round trip. An up-to-date clone pays nothing extra.
|
|
150
|
+
const latestVersion = updateAvailable ? await readRemoteVersionAfterFetch(dir) : undefined;
|
|
151
|
+
return {
|
|
152
|
+
current,
|
|
153
|
+
latest: remote.sha,
|
|
154
|
+
updateAvailable,
|
|
155
|
+
checkedAt,
|
|
156
|
+
...(latestVersion ? { latestVersion } : {}),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Fetch the remote's HEAD, then read the version its manifest declares.
|
|
162
|
+
*
|
|
163
|
+
* A shallow single-ref fetch of objects only: the working tree is untouched, so
|
|
164
|
+
* a probe never changes what the plugin's directory holds — that is `update`'s
|
|
165
|
+
* job, and it is the one that refuses a dirty tree.
|
|
166
|
+
*/
|
|
167
|
+
async function readRemoteVersionAfterFetch(dir: string): Promise<string | undefined> {
|
|
168
|
+
const fetch = await gitRun(['fetch', '--depth', '1', '--quiet', 'origin', 'HEAD'], {
|
|
169
|
+
cwd: dir,
|
|
170
|
+
timeoutMs: FETCH_TIMEOUT_MS,
|
|
171
|
+
});
|
|
172
|
+
if (fetch.exitCode !== 0) return undefined;
|
|
173
|
+
return readRemoteVersion(dir);
|
|
112
174
|
}
|
|
113
175
|
|
|
114
176
|
export interface GitUpdateResult {
|
|
@@ -23,6 +23,9 @@ const ROOT = '/market/plugins/demo';
|
|
|
23
23
|
|
|
24
24
|
const MANIFEST = { id: 'demo', name: 'Demo', version: '1.0.0', app: 'dist/app.js' };
|
|
25
25
|
|
|
26
|
+
/** What the minimal manifest parses to — a body with nothing optional added. */
|
|
27
|
+
const MANIFEST_EXPECTED = { ...MANIFEST };
|
|
28
|
+
|
|
26
29
|
describe('toManifest', () => {
|
|
27
30
|
test('accepts a minimal manifest and keeps its optional fields', () => {
|
|
28
31
|
expect(toManifest({ ...MANIFEST, description: 'A demo', icon: 'icon.svg' }, ROOT)).toEqual({
|
|
@@ -155,6 +158,34 @@ describe('toManifest', () => {
|
|
|
155
158
|
error: expect.stringContaining('no label'),
|
|
156
159
|
});
|
|
157
160
|
});
|
|
161
|
+
|
|
162
|
+
test('reads an author given as a name, and as an object with a URL', () => {
|
|
163
|
+
expect(toManifest({ ...MANIFEST, author: 'Ada Lovelace' }, ROOT)).toMatchObject({
|
|
164
|
+
author: { name: 'Ada Lovelace' },
|
|
165
|
+
});
|
|
166
|
+
expect(
|
|
167
|
+
toManifest({ ...MANIFEST, author: { name: 'Acme', url: 'https://acme.example', email: 'a@acme.example' } }, ROOT),
|
|
168
|
+
).toMatchObject({ author: { name: 'Acme', url: 'https://acme.example', email: 'a@acme.example' } });
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test('drops an author with no usable name instead of refusing the plugin', () => {
|
|
172
|
+
// A credit is not a requirement: a malformed one must not cost the user a
|
|
173
|
+
// plugin that works.
|
|
174
|
+
expect(toManifest({ ...MANIFEST, author: { email: 'nobody@example' } }, ROOT)).toEqual(MANIFEST_EXPECTED);
|
|
175
|
+
expect(toManifest({ ...MANIFEST, author: ' ' }, ROOT)).toEqual(MANIFEST_EXPECTED);
|
|
176
|
+
expect(toManifest({ ...MANIFEST, author: 42 }, ROOT)).toEqual(MANIFEST_EXPECTED);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('keeps declared slots in the canonical order and drops unknown names', () => {
|
|
180
|
+
// Order is the table's, so the same plugin cannot list its slots two ways
|
|
181
|
+
// depending on how its manifest happened to be written.
|
|
182
|
+
expect(toManifest({ ...MANIFEST, slots: ['headerPanel', 'rightPanel', 'nope'] }, ROOT)).toMatchObject({
|
|
183
|
+
slots: ['rightPanel', 'headerPanel'],
|
|
184
|
+
});
|
|
185
|
+
// A declaration that names nothing real is absent, not an empty array.
|
|
186
|
+
expect(toManifest({ ...MANIFEST, slots: ['nope'] }, ROOT)).not.toHaveProperty('slots');
|
|
187
|
+
expect(toManifest({ ...MANIFEST, slots: 'rightPanel' }, ROOT)).not.toHaveProperty('slots');
|
|
188
|
+
});
|
|
158
189
|
});
|
|
159
190
|
|
|
160
191
|
describe('toMarketplaceCatalog', () => {
|
|
@@ -187,6 +218,40 @@ describe('toMarketplaceCatalog', () => {
|
|
|
187
218
|
});
|
|
188
219
|
});
|
|
189
220
|
|
|
221
|
+
test('accepts a REMOTE git source and marks it, without an escape check', () => {
|
|
222
|
+
// There is no root to escape: the entry is an offer, and the installer
|
|
223
|
+
// clones the URL. Reading it as a relative path is the failure this pins.
|
|
224
|
+
const result = toMarketplaceCatalog(
|
|
225
|
+
{
|
|
226
|
+
plugins: [
|
|
227
|
+
{ name: 'acme', source: 'https://github.com/acme/panels.git', version: '1.4.0' },
|
|
228
|
+
{ name: 'gitlab', source: 'git@gitlab.example:team/panels.git' },
|
|
229
|
+
{ name: 'local', source: 'plugins/local' },
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
ROOT,
|
|
233
|
+
);
|
|
234
|
+
expect(result).toMatchObject({
|
|
235
|
+
plugins: [
|
|
236
|
+
{ name: 'acme', source: 'https://github.com/acme/panels.git', remote: true, version: '1.4.0' },
|
|
237
|
+
{ name: 'gitlab', remote: true },
|
|
238
|
+
{ name: 'local', source: 'plugins/local' },
|
|
239
|
+
],
|
|
240
|
+
});
|
|
241
|
+
// A directory source carries no marker at all — absence is "a directory".
|
|
242
|
+
if ('error' in result) throw new Error(result.error);
|
|
243
|
+
expect(result.plugins?.[2]?.remote).toBeUndefined();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test('carries an entry author and homepage through', () => {
|
|
247
|
+
expect(
|
|
248
|
+
toMarketplaceCatalog(
|
|
249
|
+
{ plugins: [{ name: 'demo', source: 'plugins/demo', author: { name: 'Acme' }, homepage: 'https://acme.example' }] },
|
|
250
|
+
ROOT,
|
|
251
|
+
),
|
|
252
|
+
).toMatchObject({ plugins: [{ author: { name: 'Acme' }, homepage: 'https://acme.example' }] });
|
|
253
|
+
});
|
|
254
|
+
|
|
190
255
|
test('refuses a non-array plugins field', () => {
|
|
191
256
|
expect(toMarketplaceCatalog({ plugins: 'x' }, ROOT)).toMatchObject({
|
|
192
257
|
error: expect.stringContaining('must be an array'),
|
|
@@ -22,11 +22,15 @@
|
|
|
22
22
|
import type {
|
|
23
23
|
PanelMarketplaceManifest,
|
|
24
24
|
PanelMarketplacePluginEntry,
|
|
25
|
+
PanelPluginAuthor,
|
|
25
26
|
PanelPluginManifest,
|
|
27
|
+
PanelSlotName,
|
|
26
28
|
} from '@/shared/types';
|
|
29
|
+
import { PANEL_SLOT_NAMES } from '@/shared/types';
|
|
27
30
|
import type { PluginSettingDefinition } from '@kabmo-labs/kabmo-sdk';
|
|
28
31
|
import { isRecord } from '@/shared/lib/util/guards';
|
|
29
32
|
import { isValidRange } from '@/shared/lib/updates/semver';
|
|
33
|
+
import { isRemoteGitUrl } from '@/shared/lib/git/url';
|
|
30
34
|
import { resolveInsideRoot } from '@/shared/lib/panels/resolve-asset';
|
|
31
35
|
|
|
32
36
|
/** An id segment: what a plugin id may look like. */
|
|
@@ -90,6 +94,8 @@ export function toManifest(raw: unknown, root: string): PanelPluginManifest | {
|
|
|
90
94
|
if ('error' in capabilities) return capabilities;
|
|
91
95
|
const settings = toSettings(raw.settings);
|
|
92
96
|
if ('error' in settings) return settings;
|
|
97
|
+
const author = toAuthor(raw.author);
|
|
98
|
+
const slots = toSlots(raw.slots);
|
|
93
99
|
|
|
94
100
|
return {
|
|
95
101
|
id,
|
|
@@ -106,6 +112,8 @@ export function toManifest(raw: unknown, root: string): PanelPluginManifest | {
|
|
|
106
112
|
...(icon ? { icon } : {}),
|
|
107
113
|
...(readme ? { readme } : {}),
|
|
108
114
|
...(branding ? { branding: { icon: branding } } : {}),
|
|
115
|
+
...(author ? { author } : {}),
|
|
116
|
+
...(slots ? { slots } : {}),
|
|
109
117
|
};
|
|
110
118
|
}
|
|
111
119
|
|
|
@@ -154,6 +162,40 @@ function toCapabilities(raw: unknown): { value?: string[] } | { error: string }
|
|
|
154
162
|
return value.length > 0 ? { value } : {};
|
|
155
163
|
}
|
|
156
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Parse `author`: a name string, or an object carrying a name.
|
|
167
|
+
*
|
|
168
|
+
* Both spellings are accepted because both are in the wild — `package.json`
|
|
169
|
+
* conventionally holds `{ name, email }`, while a hand-written `kabmo.json`
|
|
170
|
+
* usually names one person. A value with no usable name is dropped rather than
|
|
171
|
+
* refused: an author is a credit, not a requirement, and refusing a plugin for
|
|
172
|
+
* a malformed credit would hide a working plugin over a cosmetic field.
|
|
173
|
+
*/
|
|
174
|
+
function toAuthor(raw: unknown): PanelPluginAuthor | undefined {
|
|
175
|
+
const name = typeof raw === 'string' ? trimmed(raw) : isRecord(raw) ? trimmed(raw.name) : undefined;
|
|
176
|
+
if (!name) return undefined;
|
|
177
|
+
const record = isRecord(raw) ? raw : {};
|
|
178
|
+
const email = trimmed(record.email);
|
|
179
|
+
const url = trimmed(record.url);
|
|
180
|
+
return { name, ...(email ? { email } : {}), ...(url ? { url } : {}) };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Parse `slots`: the positional slots the plugin DECLARES it contributes.
|
|
185
|
+
*
|
|
186
|
+
* Unknown names are dropped rather than refused, and so is a non-array: the
|
|
187
|
+
* declaration is advisory (the live registrations are authoritative), so a
|
|
188
|
+
* stale or over-eager value must not cost the user a plugin that works. The
|
|
189
|
+
* order is the canonical one, so a card cannot list the same plugin's slots two
|
|
190
|
+
* ways depending on how its manifest happened to be written.
|
|
191
|
+
*/
|
|
192
|
+
function toSlots(raw: unknown): PanelSlotName[] | undefined {
|
|
193
|
+
if (!Array.isArray(raw)) return undefined;
|
|
194
|
+
const declared = new Set(raw.filter((entry): entry is string => typeof entry === 'string'));
|
|
195
|
+
const slots = PANEL_SLOT_NAMES.filter((slot) => declared.has(slot));
|
|
196
|
+
return slots.length > 0 ? slots : undefined;
|
|
197
|
+
}
|
|
198
|
+
|
|
157
199
|
/** Whether a value is one of the three primitives a setting may hold. */
|
|
158
200
|
function isSettingValue(value: unknown): value is string | number | boolean {
|
|
159
201
|
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
@@ -213,6 +255,13 @@ function toSettings(raw: unknown): { value?: Record<string, PluginSettingDefinit
|
|
|
213
255
|
* optional is a catalog entry's `source` — it is the key that binds an entry to
|
|
214
256
|
* a directory, and an entry whose source escapes the marketplace root would let
|
|
215
257
|
* the catalog point at anything.
|
|
258
|
+
*
|
|
259
|
+
* A `source` may be a REMOTE git URL instead of a path. That entry is an OFFER
|
|
260
|
+
* with no directory behind it: nothing is scanned for it and nothing is built
|
|
261
|
+
* until the user installs it, at which point the installer clones it exactly as
|
|
262
|
+
* it clones a URL typed into the form. The escape check does not apply — there
|
|
263
|
+
* is no root to escape — so the two shapes are separated before it runs, which
|
|
264
|
+
* is what stops a `git@host:repo` string from being read as a relative path.
|
|
216
265
|
*/
|
|
217
266
|
export function toMarketplaceCatalog(raw: unknown, root: string): PanelMarketplaceManifest | { error: string } {
|
|
218
267
|
if (!isRecord(raw)) return { error: 'marketplace.json is not an object' };
|
|
@@ -226,15 +275,20 @@ export function toMarketplaceCatalog(raw: unknown, root: string): PanelMarketpla
|
|
|
226
275
|
const source = trimmed(item.source);
|
|
227
276
|
if (!name) return { error: 'a marketplace plugin entry has no name' };
|
|
228
277
|
if (!source) return { error: `marketplace plugin "${name}" has no source` };
|
|
229
|
-
|
|
278
|
+
const remote = isRemoteGitUrl(source);
|
|
279
|
+
if (!remote && !resolveInsideRoot(root, source)) {
|
|
230
280
|
return { error: `marketplace plugin "${name}" source "${source}" escapes the marketplace directory` };
|
|
231
281
|
}
|
|
282
|
+
const author = toAuthor(item.author);
|
|
232
283
|
entries.push({
|
|
233
284
|
name,
|
|
234
285
|
source,
|
|
235
286
|
description: trimmed(item.description),
|
|
236
287
|
version: trimmed(item.version),
|
|
237
288
|
category: trimmed(item.category),
|
|
289
|
+
...(author ? { author } : {}),
|
|
290
|
+
...(trimmed(item.homepage) ? { homepage: trimmed(item.homepage) } : {}),
|
|
291
|
+
...(remote ? { remote: true } : {}),
|
|
238
292
|
});
|
|
239
293
|
}
|
|
240
294
|
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The catalogs' OFFERS, and the origin every install gets from them.
|
|
8
|
+
*
|
|
9
|
+
* Two questions answered here, and both are easy to answer wrongly in a way that
|
|
10
|
+
* looks right on screen:
|
|
11
|
+
*
|
|
12
|
+
* - a REMOTE offer (a `marketplace.json` entry whose `source` is a git URL) is a
|
|
13
|
+
* plugin the user can install without the marketplace holding it. Losing it
|
|
14
|
+
* makes a curated catalog look empty; counting it twice makes one plugin look
|
|
15
|
+
* like two;
|
|
16
|
+
* - an install's ORIGIN decides who keeps it current — Kabmo's sync, the user's
|
|
17
|
+
* own `git pull`, or nobody — so a wrong value is a promise the pane cannot
|
|
18
|
+
* keep.
|
|
19
|
+
*
|
|
20
|
+
* `applySources` mutates the payload's own rows, which is what keeps one answer
|
|
21
|
+
* per question: the alternative is a second list that can disagree with the one
|
|
22
|
+
* the pane renders.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
26
|
+
import fs from 'node:fs';
|
|
27
|
+
import { tmpdir } from 'node:os';
|
|
28
|
+
import { join } from 'node:path';
|
|
29
|
+
|
|
30
|
+
import { applySources, assembleCatalog } from '@/server/lib/panels/offers.server';
|
|
31
|
+
import type { PanelPluginStatus } from '@/shared/types';
|
|
32
|
+
import { removeDir } from '@/test-support/remove-dir';
|
|
33
|
+
|
|
34
|
+
let root = '';
|
|
35
|
+
let bundled = '';
|
|
36
|
+
|
|
37
|
+
/** Write a catalog body at a path, creating its parent directory. */
|
|
38
|
+
function writeCatalog(path: string, body: unknown): string {
|
|
39
|
+
fs.mkdirSync(join(path, '..'), { recursive: true });
|
|
40
|
+
fs.writeFileSync(path, JSON.stringify(body));
|
|
41
|
+
return path;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A store plugin directory, with the manifest `kabmo.json` the scan reads. */
|
|
45
|
+
function writeStorePlugin(dirName: string, manifest: Record<string, unknown>): void {
|
|
46
|
+
const dir = join(bundled, 'plugins', dirName);
|
|
47
|
+
fs.mkdirSync(join(dir, 'dist'), { recursive: true });
|
|
48
|
+
fs.writeFileSync(join(dir, 'kabmo.json'), JSON.stringify({ app: 'dist/app.js', ...manifest }));
|
|
49
|
+
fs.writeFileSync(join(dir, 'dist', 'app.js'), 'export default {};');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A status row with everything the card needs, as the scan builds one. */
|
|
53
|
+
function status(overrides: Partial<PanelPluginStatus> = {}): PanelPluginStatus {
|
|
54
|
+
return {
|
|
55
|
+
pluginId: 'demo',
|
|
56
|
+
name: 'Demo',
|
|
57
|
+
version: '1.0.0',
|
|
58
|
+
isPackage: false,
|
|
59
|
+
built: true,
|
|
60
|
+
enabled: true,
|
|
61
|
+
bundled: false,
|
|
62
|
+
origin: 'local',
|
|
63
|
+
gitOrigin: null,
|
|
64
|
+
settingsCount: 0,
|
|
65
|
+
...overrides,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
root = fs.mkdtempSync(join(tmpdir(), 'kabmo-offers-'));
|
|
71
|
+
bundled = fs.mkdtempSync(join(tmpdir(), 'kabmo-store-'));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
afterEach(() => {
|
|
75
|
+
removeDir(root);
|
|
76
|
+
removeDir(bundled);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('assembleCatalog', () => {
|
|
80
|
+
test('lists a store offer and a remote offer side by side', async () => {
|
|
81
|
+
writeStorePlugin('session-info', { id: 'session-info', name: 'Session Info', version: '0.1.0' });
|
|
82
|
+
const workingCatalog = writeCatalog(join(root, 'marketplace.json'), {
|
|
83
|
+
plugins: [{ name: 'acme-panels', source: 'https://github.com/acme/panels.git', version: '1.4.0' }],
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const catalog = await assembleCatalog({
|
|
87
|
+
workingCatalogPath: workingCatalog,
|
|
88
|
+
bundledRoot: bundled,
|
|
89
|
+
installed: new Set(),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(catalog.map((entry) => `${entry.origin}:${entry.pluginId}`)).toEqual([
|
|
93
|
+
'bundled:session-info',
|
|
94
|
+
'git:acme-panels',
|
|
95
|
+
]);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('a store offer wins over a remote one for the same id', async () => {
|
|
99
|
+
// The store's directory is on disk, so it can draw an icon and a README, and
|
|
100
|
+
// both rows would install the same id — two cards for one plugin.
|
|
101
|
+
writeStorePlugin('demo', { id: 'demo', name: 'Demo', version: '1.0.0' });
|
|
102
|
+
const workingCatalog = writeCatalog(join(root, 'marketplace.json'), {
|
|
103
|
+
plugins: [{ name: 'demo', source: 'https://github.com/acme/demo.git' }],
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const catalog = await assembleCatalog({
|
|
107
|
+
workingCatalogPath: workingCatalog,
|
|
108
|
+
bundledRoot: bundled,
|
|
109
|
+
installed: new Set(),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
expect(catalog).toHaveLength(1);
|
|
113
|
+
expect(catalog[0]).toMatchObject({ pluginId: 'demo', origin: 'bundled' });
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('a remote offer reports itself installed once its id is on disk', async () => {
|
|
117
|
+
// The row STAYS with `installed: true` — the pane filters on that flag, and
|
|
118
|
+
// dropping it would make "an offer you already installed" and "no offer at
|
|
119
|
+
// all" indistinguishable.
|
|
120
|
+
const workingCatalog = writeCatalog(join(root, 'marketplace.json'), {
|
|
121
|
+
plugins: [{ name: 'demo', source: 'https://github.com/acme/demo.git' }],
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const catalog = await assembleCatalog({
|
|
125
|
+
workingCatalogPath: workingCatalog,
|
|
126
|
+
bundledRoot: bundled,
|
|
127
|
+
installed: new Set(['demo']),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
expect(catalog).toEqual([expect.objectContaining({ pluginId: 'demo', installed: true })]);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('a catalog that is not there contributes no offers', async () => {
|
|
134
|
+
const catalog = await assembleCatalog({
|
|
135
|
+
workingCatalogPath: join(root, 'missing.json'),
|
|
136
|
+
bundledRoot: bundled,
|
|
137
|
+
installed: new Set(),
|
|
138
|
+
});
|
|
139
|
+
expect(catalog).toEqual([]);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('applySources', () => {
|
|
144
|
+
test('a plugin the store publishes is bundled, and carries the store version', async () => {
|
|
145
|
+
const plugins = [status({ pluginId: 'session-info', version: '0.0.1' })];
|
|
146
|
+
const catalog = [
|
|
147
|
+
{
|
|
148
|
+
pluginId: 'session-info',
|
|
149
|
+
name: 'Session Info',
|
|
150
|
+
version: '0.2.0',
|
|
151
|
+
origin: 'bundled' as const,
|
|
152
|
+
installed: true,
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
applySources(plugins, catalog, {});
|
|
156
|
+
expect(plugins[0]).toMatchObject({
|
|
157
|
+
bundled: true,
|
|
158
|
+
origin: 'bundled',
|
|
159
|
+
latestVersion: '0.2.0',
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test('a clone is NEVER bundled, however its id reads', async () => {
|
|
164
|
+
// The store offers this id, but the directory on disk is the user's own
|
|
165
|
+
// repository — attributing it to the store would overwrite it on the next
|
|
166
|
+
// boot, because the sync selects on this same flag.
|
|
167
|
+
const plugins = [status({ pluginId: 'demo', gitOrigin: 'https://github.com/acme/demo.git' })];
|
|
168
|
+
const catalog = [
|
|
169
|
+
{ pluginId: 'demo', name: 'Demo', version: '9.9.9', origin: 'bundled' as const, installed: true },
|
|
170
|
+
];
|
|
171
|
+
applySources(plugins, catalog, {});
|
|
172
|
+
expect(plugins[0]).toMatchObject({ bundled: false, origin: 'git' });
|
|
173
|
+
// And it takes no version from the store: its source is its own remote.
|
|
174
|
+
expect(plugins[0]?.latestVersion).toBeUndefined();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('a git clone takes the version the freshness probe read', async () => {
|
|
178
|
+
const plugins = [status({ pluginId: 'demo', gitOrigin: 'https://github.com/acme/demo.git' })];
|
|
179
|
+
applySources(plugins, [], {
|
|
180
|
+
demo: { current: 'aaa', latest: 'bbb', updateAvailable: true, checkedAt: 1, latestVersion: '2.0.0' },
|
|
181
|
+
});
|
|
182
|
+
expect(plugins[0]?.latestVersion).toBe('2.0.0');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test('a directory nobody published stays LOCAL, with no version to offer', async () => {
|
|
186
|
+
const plugins = [status()];
|
|
187
|
+
applySources(plugins, [], {});
|
|
188
|
+
expect(plugins[0]).toMatchObject({ bundled: false, origin: 'local' });
|
|
189
|
+
expect(plugins[0]?.latestVersion).toBeUndefined();
|
|
190
|
+
});
|
|
191
|
+
});
|