6.1 KiB
6.1 KiB
41. Cleanup — Remove Legacy packages/, services/, and server/ Directories
meta: id: shieldai-unified-restructure-41 feature: shieldai-unified-restructure priority: P0 depends_on: [shieldai-unified-restructure-26, shieldai-unified-restructure-27] tags: [cleanup, infrastructure, migration]
objective:
- Safely remove all legacy directories that are no longer needed after the unified restructure. Ensure no functionality is lost and all important code has been migrated to the new monolithic architecture.
deliverables:
- Archived legacy code (optional but recommended):
- Git branch
archive/legacy-pre-restructurecontaining full state before cleanup - Or tar.gz archive in
archives/directory
- Git branch
- Removed directories:
packages/— all subdirectories (api, core, correlation, db, extension, integration-tests, jobs, mobile, mobile-api-client, monitoring, report, shared-analytics, shared-auth, shared-billing, shared-db, shared-notifications, shared-ui, shared-utils, types, web)services/— all subdirectories (darkwatch, hometitle, removebrokers, spamshield, voiceprint)server/— alerts and webrtc subdirectoriesinfra/— infrastructure configs (if not moved to web/ or docs/)load-tests/— load testing scripts (if not moved)docs/— evaluate and either move toweb/docs/or archive
- Updated root configuration:
package.jsonwith clean scripts referencing onlyweb/andbrowser-ext/pnpm-workspace.yamlwith onlywebandbrowser-extturbo.jsonwith only relevant tasks.gitignorecleaned of legacy entriesREADME.mdupdated to reflect new architecture
- Verification checklist confirming:
- All Fastify routes migrated to tRPC routers
- All service logic migrated to
web/src/server/services/ - All Prisma schema migrated to Drizzle
- All web pages migrated to new
web/app - All extension code migrated to
browser-ext/ - No broken imports or references to removed directories
steps:
- Create archive:
git branch archive/legacy-pre-restructure(from current HEAD)- Or
tar -czf archives/legacy-$(date +%Y%m%d).tar.gz packages/ services/ server/ infra/ load-tests/
- Verify migration completeness:
- Checklist: go through each legacy directory and confirm its contents have been migrated
packages/api/src/routes/→web/src/server/api/routers/packages/db/prisma/schema.prisma→web/src/server/db/schema.tspackages/web/src/→web/src/(pages, components, hooks)packages/extension/src/→browser-ext/src/services/*/src/→web/src/server/services/*/packages/jobs/src/→web/src/server/jobs/packages/shared-*/src/→ merged intoweb/src/server/services/orweb/src/lib/
- Remove directories:
rm -rf packages/rm -rf services/rm -rf server/rm -rf infra/(or move relevant files)rm -rf load-tests/(or move relevant files)rm -rf docs/(or move toweb/docs/)
- Clean root files:
- Remove
check-identity.js,test-classifier.ts,test-maxpayload.ts,test-ws-maxpayload*.js(if not moved) - Remove
docker-compose.yml,docker-compose.prod.yml,Dockerfile(will be recreated in task 42) - Remove
vite.config.tsat root (only needed inweb/) - Remove
vitest.config.tsat root (only needed inweb/) - Remove
tsconfig.base.json,tsconfig.jsonat root (only needed inweb/)
- Remove
- Update root configs:
package.json: update scripts, remove legacy dependenciespnpm-workspace.yaml: confirm onlywebandbrowser-extturbo.json: update tasks for new structure.gitignore: remove entries for deleted directories
- Update
README.md:- New architecture diagram (unified monolith)
- Updated directory structure
- Updated setup instructions
- Migration notes
- Run full verification:
pnpm installfrom rootpnpm devstarts web apppnpm buildinweb/succeedspnpm testinweb/passescd browser-ext && pnpm buildsucceeds- No references to
packages/,services/, orserver/in any file
- Commit cleanup with clear message.
steps:
- Integration:
pnpm installcompletes without errors - Integration:
pnpm devstarts unified web app - Integration:
pnpm buildproduces valid output - Integration:
pnpm testpasses all tests - Search:
grep -r "packages/\|services/\|server/" --include="*.ts" --include="*.tsx" --include="*.json" --include="*.md" .returns only expected references (e.g., in README migration notes)
acceptance_criteria:
- Legacy directories are removed from working tree
- Archive branch or tar.gz exists with full legacy state
- Root
package.jsononly referencesweb/andbrowser-ext/ pnpm-workspace.yamlonly includeswebandbrowser-extpnpm installresolves dependencies cleanlypnpm devstarts the unified app without errorspnpm buildsucceeds for web apppnpm testpasses for web app- No broken imports or references to removed directories
- README is updated with new architecture and setup instructions
validation:
ls packages/ services/ server/→ "No such file or directory"git branch -a | grep archive→ shows archive branchpnpm install && pnpm dev→ web app starts on localhost:3000cd web && pnpm build→ completes successfullycd web && pnpm test→ all tests passgrep -r "@shieldai/" --include="*.ts" --include="*.tsx" .→ no references to old workspace packages
notes:
- Do NOT delete git history. The archive branch preserves everything.
- If any legacy file is discovered to be needed after cleanup, it can be retrieved from the archive branch.
- The
docs/directory may contain valuable documentation. Review contents before deleting — move relevant docs toweb/docs/or rootREADME. examples/andassets/at root should also be reviewed and either moved or deleted.- This is a destructive operation. Double-check the migration checklist before executing.
- Consider keeping
plans/directory if it contains active project plans. Move todocs/plans/if needed.