This guide explains how to extract your debug library into an independent repository that can be managed separately but works seamlessly with your main project using git submodules.
- Reusability: Use the debug library across multiple projects
- Version Control: Independent versioning and releases
- Team Collaboration: Separate team can maintain debug tools
- Clean Architecture: Keep main project focused on business logic
- Easy Updates: Pull latest debug features without affecting main codebase
# Make sure you're in your main project directory
./setup-debug-library.shImportant: Before running, update the GitHub username in the script:
# Edit the script and change this line:
GITHUB_USERNAME="your-actual-github-username"- Go to GitHub and create a new repository named
agritech-debug-tracker - Don't initialize with README (the script creates one)
- Copy the repository URL
# Navigate to the debug library directory
cd ../agritech-debug-tracker
# Add GitHub remote
git remote add origin https://github.com/YOUR-USERNAME/agritech-debug-tracker.git
# Push to GitHub
git push -u origin main# Go back to main project
cd /path/to/AgriTechBlog
# Update submodule to use GitHub URL
git submodule set-url lib/debug-tracker https://github.com/YOUR-USERNAME/agritech-debug-tracker.gitAfter setup, update your imports from:
// Old imports
import DebugTracker from './lib/debug-tracker';
import DebugFlowVisualizer from './components/debug-flow-visualizer';To:
// New imports using the independent library
import {
DebugTracker,
DebugFlowVisualizer,
initializeDebugSystem
} from '@agritech/debug-tracker';// In your main App.tsx or main.tsx
import { initializeDebugSystem } from '@agritech/debug-tracker';
// Initialize once at app startup
if (process.env.NODE_ENV === 'development') {
const debugTracker = initializeDebugSystem();
}import { DebugFlowVisualizer } from '@agritech/debug-tracker';
import { useLocation } from 'react-router-dom';
function App() {
const location = useLocation();
const isAdminPage = ['/admin', '/create-post', '/edit-post'].some(path =>
location.pathname.includes(path)
);
return (
<div>
{/* Your app content */}
{/* Debug visualizer - only on admin pages in development */}
{process.env.NODE_ENV === 'development' && isAdminPage && (
<DebugFlowVisualizer />
)}
</div>
);
}When you want to add features to the debug library:
# 1. Go to debug library directory
cd lib/debug-tracker
# 2. Make your changes
# Edit files in src/
# 3. Build the library
npm run build
# 4. Commit and push changes
git add .
git commit -m "feat: add new debugging feature"
git push origin main
# 5. Update version in package.json if needed
npm version patch # or minor/major
git push --tagsWhen the debug library has updates:
# 1. Update the submodule
git submodule update --remote lib/debug-tracker
# 2. Reinstall the local dependency
npm install ./lib/debug-tracker
# 3. Commit the submodule update
git add lib/debug-tracker
git commit -m "chore: update debug library to latest version"# Clone both repositories for development
git clone https://github.com/YOUR-USERNAME/AgriTechBlog.git
git clone https://github.com/YOUR-USERNAME/agritech-debug-tracker.git
# Link them for development
cd AgriTechBlog
npm link ../agritech-debug-tracker
# Now changes in debug library are immediately available# In debug library directory
npm run dev # Watch mode
# In main project directory (separate terminal)
npm run dev # Your main app with live debug library updatesThe enhanced deployment script now generates intelligent commit messages based on your changes:
feat(api): enhance API endpoints and server functionality - production readyfix: resolve application issues and bugs - staging deploymentrefactor(ui): improve user interface and components across multiple moduleschore(config): update project configurationdocs: update documentation
# Use generated smart commit message
npm run deploy
# Use custom commit message
npm run deploy production "feat: implement advanced search functionality"The script analyzes:
- File types: Frontend, backend, config, documentation
- Change patterns: New features, bug fixes, UI changes, API updates
- Scale of changes: Number of files, insertions, deletions
- Deployment context: Production vs staging vs preview
If you want to place the debug library elsewhere:
# Edit setup-debug-library.sh
DEBUG_LIB_DIR="/custom/path/agritech-debug-tracker"# In another project
git submodule add https://github.com/YOUR-USERNAME/agritech-debug-tracker.git lib/debug-tracker
npm install ./lib/debug-tracker# In debug library directory
npm login
npm publish
# Then use in any project
npm install @agritech/debug-tracker# Reset submodule
git submodule deinit lib/debug-tracker
git rm lib/debug-tracker
git submodule add https://github.com/YOUR-USERNAME/agritech-debug-tracker.git lib/debug-tracker
# Clone with submodules
git clone --recursive https://github.com/YOUR-USERNAME/AgriTechBlog.gitIf imports fail after setup:
- Ensure the debug library is built:
cd lib/debug-tracker && npm run build - Reinstall:
npm install ./lib/debug-tracker - Check import paths match the exported names
# In debug library directory
rm -rf node_modules dist
npm install
npm run build- Enhanced deployment script installed
- Debug library extracted to independent repository
- GitHub repository created and connected
- Submodule configured in main project
- Imports updated in main project
- Debug system initialization added
- Debug visualizer restricted to admin pages
- Both repositories tested and working
- Team members have access to debug library repository
β
Professional Commit Messages: Automatic intelligent commit message generation
β
Independent Debug Library: Reusable across projects
β
Clean Architecture: Separation of concerns
β
Easy Updates: Pull debug improvements independently
β
Team Collaboration: Dedicated repository for debug tools
β
Version Control: Independent versioning for debug features
Your debug library is now a professional, independent tool that can evolve separately from your main project while integrating seamlessly!