Skip to content

feat: consume @platform/shell-contract from Nexus (drop the local copy)#7

Merged
klinux merged 1 commit into
mainfrom
feat/consume-shell-contract-from-nexus
Apr 23, 2026
Merged

feat: consume @platform/shell-contract from Nexus (drop the local copy)#7
klinux merged 1 commit into
mainfrom
feat/consume-shell-contract-from-nexus

Conversation

@klinux
Copy link
Copy Markdown
Contributor

@klinux klinux commented Apr 23, 2026

Summary

Replaces the hand-rolled src/lib/shell-contract.ts (a line-by-line copy of @platform/shell-contract) with a real dependency on the published package from the new dedicated Nexus repo.

Changes

  • .npmrc (new, repo root): @platform:registry=https://repos.cora.tools/repository/npm-backoffice-shell/ — anonymous read, no auth tokens in the file
  • package.json: declares @platform/shell-contract@^0.1.0
  • src/lib/shell-contract.ts deleted
  • 9 files updated from import ... from "@/lib/shell-contract"@platform/shell-contract

Why

The local copy had two problems: drift risk (somebody changes types in the shell, the copy goes stale) and a confusing DX (docstring literally said "Install: npm install @platform/shell-contract" but the code didn't). With the dedicated Nexus repo set up with anonymous read for the @platform scope, modules can consume the real package without every developer configuring ~/.npmrc.

Prerequisites

This PR cannot install until two things are true:

  1. platform-backoffice-shell#6 is merged — its publish pipeline lands @platform/shell-contract@0.1.0 in the new npm-backoffice-shell repo.
  2. Nexus anonymous read is fully effective on the new repo. Local npm install currently returns 401 Unable to authenticate, need: BASIC realm="Sonatype Nexus", which means the anonymous role doesn't yet have the right nx-repository-view-npm-npm-backoffice-shell-* privilege granted. Ask Infra/DevOps to verify the role in Nexus Admin → Security → Roles → anonymous.

Once both are resolved, npm install in this branch should succeed and CI can run green.

Test plan

After prerequisites:

  • rm -rf node_modules package-lock.json && npm install — resolves @platform/shell-contract from the new repo without auth
  • npm run build — green (imports type-check against the real package)
  • npm run test:run — green
  • npm run lint — green

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 23, 2026 15:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Este PR troca o contrato local do Shell por uma dependência publicada (@platform/shell-contract), removendo a cópia em src/lib/shell-contract.ts, e ajusta imports para consumir o pacote oficial. Em paralelo, adiciona estrutura de múltiplas páginas (Overview/Items/Settings), novos componentes UI (shadcn/Radix) e guardrails de lint para evitar tags nativas proibidas e cores hardcoded.

Changes:

  • Adiciona @platform/shell-contract como dependência e migra imports; remove src/lib/shell-contract.ts.
  • Implementa roteamento interno por sub-rota via useModuleRoute e cria páginas (Overview/Items/Settings) + testes.
  • Adiciona um baseline de componentes UI e reforça ESLint com no-restricted-syntax para tags nativas/cores.

Reviewed changes

Copilot reviewed 35 out of 36 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/test-utils.ts Atualiza import de ShellContext para o pacote publicado.
src/lib/shell-contract.ts Remove a cópia local do contrato do Shell.
src/index.ts Atualiza imports de tipos do contrato para @platform/shell-contract.
src/hooks/useShellTheme.ts Atualiza imports do contrato para @platform/shell-contract.
src/hooks/useModuleRoute.ts Adiciona hook de sub-rota baseado em popstate/pathname.
src/hooks/useBackendApi.ts Atualiza import de ShellContext para o pacote publicado.
src/hooks/useApi.ts Atualiza import de ShellContext para o pacote publicado.
src/components/ui/tooltip.tsx Adiciona primitiva Tooltip (Radix/shadcn).
src/components/ui/textarea.tsx Adiciona primitiva Textarea (shadcn).
src/components/ui/tabs.tsx Adiciona primitiva Tabs (Radix/shadcn).
src/components/ui/table.tsx Adiciona primitiva Table (shadcn).
src/components/ui/switch.tsx Adiciona primitiva Switch (Radix/shadcn).
src/components/ui/skeleton.tsx Adiciona primitiva Skeleton (shadcn).
src/components/ui/sheet.tsx Adiciona primitiva Sheet (Radix/shadcn).
src/components/ui/separator.tsx Adiciona primitiva Separator (Radix/shadcn).
src/components/ui/select.tsx Adiciona primitiva Select (Radix/shadcn).
src/components/ui/label.tsx Adiciona primitiva Label (Radix/shadcn).
src/components/ui/input.tsx Adiciona primitiva Input (shadcn).
src/components/ui/dropdown-menu.tsx Adiciona primitiva DropdownMenu (Radix/shadcn).
src/components/ui/dialog.tsx Adiciona primitiva Dialog (Radix/shadcn).
src/components/ui/checkbox.tsx Adiciona primitiva Checkbox (Radix/shadcn).
src/components/ui/badge.tsx Adiciona primitiva Badge (shadcn).
src/components/ui/alert-dialog.tsx Adiciona primitiva AlertDialog (Radix/shadcn).
src/components/pages/SettingsPage.tsx Nova página Settings (usa ShellContext/auditLog/notify).
src/components/pages/OverviewPage.tsx Nova página Overview (saudação, tema, ação).
src/components/pages/ItemsPage.tsx Nova página Items (exemplo com Table/Badge).
src/components/ExampleBackendCall.tsx Atualiza import do contrato e mantém exemplo de chamada ao backend.
src/components/App.tsx Refatora App para selecionar página por sub-rota; usa module.json.
src/components/App.test.tsx Expande testes para navegação por sub-rota + mocks necessários.
package.json Adiciona @platform/shell-contract e radix-ui como dependências.
package-lock.json Atualiza lockfile com novas dependências/transitivas.
module.json Expande navigation para Overview/Items/Settings com permissões distintas.
eslint.config.js Impõe restrições de tags nativas e cores hardcoded (com exceção em ui/*).
CLAUDE.md Documenta padrão de múltiplas páginas via navigation + useModuleRoute.
.npmrc Configura registry do escopo @platform no Nexus.
.claude/skills/sync-template/SKILL.md Atualiza skill para incluir o novo guardrail do ESLint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2 to +3

function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skeleton referencia React.ComponentProps mas o namespace React não é importado neste arquivo, o que quebra a compilação TypeScript. Importe * as React de "react" (como nos demais componentes UI) ou troque para ComponentProps importado via type.

Suggested change
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
import type { ComponentProps } from "react"
function Skeleton({ className, ...props }: ComponentProps<"div">) {

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +4
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { Slot } from "radix-ui"

Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O Badge está importando Slot de radix-ui, enquanto button.tsx usa Slot de @radix-ui/react-slot. Essa mistura tende a gerar inconsistência de API/tipagem e duplicação de dependências. Padronize os componentes para usar a mesma fonte (preferencialmente @radix-ui/react-slot, como o Button).

Copilot uses AI. Check for mistakes.
Comment thread package.json
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^1.8.0",
"radix-ui": "^1.4.3",
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A adição de radix-ui aqui pode causar duplicação/inconsistência porque o projeto já usa @radix-ui/react-slot diretamente (src/components/ui/button.tsx). Isso tende a puxar versões diferentes das libs Radix (via dependência direta + transitiva) e aumentar o bundle. Sugestão: padronizar em @radix-ui/react-* (shadcn default) e remover radix-ui, ou migrar todos os imports para uma única estratégia.

Suggested change
"radix-ui": "^1.4.3",

Copilot uses AI. Check for mistakes.
Comment thread src/hooks/useModuleRoute.ts Outdated
Comment on lines +34 to +36
const subPath = pathname.startsWith(basePath)
? pathname.slice(basePath.length).replace(/^\/+/, "")
: "";
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subPath é calculado com pathname.startsWith(basePath), o que também casa caminhos como /my-module-foo quando basePath é /my-module. Isso pode fazer o módulo interpretar sub-rotas incorretamente em casos de rotas com prefixo semelhante. Recomendo garantir boundary (pathname === basePath || pathname.startsWith(basePath + "/")) antes de fazer o slice.

Copilot uses AI. Check for mistakes.
...props
}: React.ComponentProps<"span"> &
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
const Comp = asChild ? Slot.Root : "span"
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No padrão do @radix-ui/react-slot, Slot é o componente (não existe Slot.Root). Do jeito atual, asChild ? Slot.Root : "span" provavelmente não compila/funciona. Troque para usar Slot diretamente (ou ajuste para a API correta do pacote Radix escolhido).

Suggested change
const Comp = asChild ? Slot.Root : "span"
const Comp = asChild ? Slot : "span"

Copilot uses AI. Check for mistakes.
Replaces the hand-rolled src/lib/shell-contract.ts — a duplicate of
the real package — with a dependency on @platform/shell-contract from
the dedicated npm-backoffice-shell Nexus repo (anonymous read scoped
to that repo only). Single source of truth.

- .npmrc at repo root: @platform:registry → npm-backoffice-shell repo
  (no auth tokens; anonymous read)
- package.json: declares @platform/shell-contract@^0.1.0
- src/lib/shell-contract.ts: removed
- 7 imports updated from @/lib/shell-contract → @platform/shell-contract

Prerequisites for `npm install` to succeed:
1. platform-backoffice-shell PR #6 merged — its publish pipeline lands
   @platform/shell-contract@0.1.0 in npm-backoffice-shell

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@klinux klinux force-pushed the feat/consume-shell-contract-from-nexus branch from 1973de6 to 32bd0f9 Compare April 23, 2026 19:05
@klinux
Copy link
Copy Markdown
Contributor Author

klinux commented Apr 23, 2026

Rebased onto current main (que agora inclui a PR #9 com multi-page routing + 16 primitivas shadcn).

Mudanças em cima do commit original:

Resultado final: zero ocorrências de @/lib/shell-contract no tree, src/lib/shell-contract.ts deletado, 9 arquivos consumindo o pacote. Stat do commit: 12 files changed, 11 insertions(+), 232 deletions(-).

Pré-requisitos do corpo original (shell#6 merged + Nexus anonymous read) continuam aplicáveis — se já foram resolvidos conforme o fix do contrato anterior sugeria, npm install deve passar no CI.

@klinux klinux merged commit 3abfd4c into main Apr 23, 2026
3 checks passed
@klinux klinux deleted the feat/consume-shell-contract-from-nexus branch April 23, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants