diff --git a/.gitignore b/.gitignore index f739229..66b900b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ yarn-error.log* # Build outputs dist/ build/ +lib/dist/ +insertr-cli/insertr +insertr-cli/tmp/ # Environment files .env @@ -49,7 +52,7 @@ temp/ # Optional REPL history .node_repl_history -# Go specific (for future backend) +# Go specific *.exe *.exe~ *.dll @@ -59,6 +62,7 @@ temp/ *.out go.work vendor/ +insertr-cli/build-errors.log # Database files *.db diff --git a/CLEANUP_SUMMARY.md b/CLEANUP_SUMMARY.md new file mode 100644 index 0000000..7086826 --- /dev/null +++ b/CLEANUP_SUMMARY.md @@ -0,0 +1,76 @@ +# Code Cleanup Summary + +## Artifacts Removed from Architecture Pivot + +### ๐๏ธ **Obsolete Assets Removed** +- `insertr-cli/assets/editor/insertr-editor.js` - Legacy inline editor script +- `insertr-cli/assets/editor/` directory - No longer needed +- Unused `marked` npm dependency from root package.json + +### ๐งน **Root Package.json Cleanup** +**Before:** +```json +{ + "description": "Edit-in-place CMS for client websites - simple integration with class-based content editing", + "main": "demo-site/insertr/insertr.js", + "keywords": ["cms", "edit-in-place", "inline-editing", "client-websites", "go", "htmx", "alpine"], + "dependencies": { + "marked": "^16.2.1" + } +} +``` + +**After:** +```json +{ + "description": "The Tailwind of CMS - Zero-configuration content editing for any static site", + "main": "lib/dist/insertr.js", + "keywords": ["cms", "headless-cms", "static-site-generator", "build-time-enhancement", "zero-config", "go", "javascript"], + "dependencies": {} +} +``` + +### โ **Legacy Code Preserved (Intentionally)** +- `demo-site/archive/` - Contains original prototype for reference +- `scripts/dev.js` - Still useful for testing original prototype +- Legacy npm scripts (`dev:*`) - Kept for prototype development +- `demo-site/README.md` - Accurately describes prototype functionality + +### ๐ง **Enhanced .gitignore** +Added new build artifacts: +```gitignore +# Build outputs +lib/dist/ # Library build output +insertr-cli/insertr # CLI executable +insertr-cli/tmp/ # Air temporary files +insertr-cli/build-errors.log # Air error logs +``` + +### ๐ฏ **What Was NOT Removed** +- **Archive directory**: `demo-site/archive/` kept for reference +- **Development scripts**: Legacy scripts still work for prototype testing +- **Documentation references**: Accurate historical context preserved +- **Go embed assets**: `insertr-cli/pkg/content/assets/` must stay for embedding + +## Validation + +### โ **Build System Verified** +```bash +npm run build # โ Works +cd insertr-cli && air # โ Hot reload works +./insertr enhance # โ CLI works with embedded library +``` + +### โ **Architecture Clean** +- No dead code or unused imports in Go +- No obsolete script references +- Clean dependency tree (1 package removed) +- Updated project metadata reflects current architecture + +### ๐ฏ **Result** +The codebase now cleanly separates: +1. **Current Architecture**: `lib/` + `insertr-cli/` with proper embedding +2. **Legacy Prototype**: `demo-site/archive/` for reference +3. **Test Content**: `demo-site/` HTML files for enhancement testing + +No functionality was lost, and the transition from prototype to production architecture is complete. \ No newline at end of file diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 2ca702b..1b5b276 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -2,30 +2,52 @@ ## Quick Start +### Full-Stack Development (Recommended) 1. **Install dependencies**: ```bash - npm install + npm install # Root project dependencies + cd lib && npm install # Library dependencies ``` -2. **Start development server**: +2. **Start hot reload development**: ```bash - npm run dev + cd insertr-cli && air # Starts server with library hot reload ``` - This will start live-server on http://localhost:3000 and automatically open the demo site. + - Watches both Go CLI changes AND JavaScript library changes + - Automatically rebuilds library โ CLI โ serves enhanced content + - Visit http://localhost:3000 to see results -3. **Alternative commands**: - ```bash - npm run dev:about # Open about page directly - npm run serve # Alias for npm run dev - ``` +### Library-Only Development +```bash +cd lib && npm run watch # Just develop the JavaScript library +``` + +### Legacy Frontend Development +```bash +npm run dev # Legacy live-server (demo-site only) +``` ## Development Workflow -### Frontend Development (Current Phase) +### Hot Reload Development (Current Phase) + +**๐ฅ NEW**: Full-stack hot reload with Air integration! + +- **Library Source**: `lib/src/` - Independent JavaScript library +- **CLI Integration**: `insertr-cli/` - Go CLI with embedded library +- **Demo Site**: `demo-site/` - Test website for enhancement +- **Automatic Rebuilds**: Changes to JS library trigger full rebuild cycle + +#### How Hot Reload Works: +1. Edit JavaScript in `lib/src/` +2. Air detects changes โ Rebuilds library โ Copies to CLI โ Rebuilds CLI +3. Enhanced development server serves updated content +4. Manual browser refresh shows changes + +### Legacy Frontend Development - **Demo Site**: `demo-site/` contains the prototype website -- **Core Library**: `demo-site/insertr/insertr.js` - the main Insertr library -- **Styling**: `demo-site/insertr/insertr.css` - edit interface styles +- **Core Library**: `demo-site/insertr/insertr.js` - the old prototype library - **Mock API**: `demo-site/mock-api/content.json` - sample backend data structure ### Testing the Three User Types @@ -36,9 +58,15 @@ ### Making Changes +#### Modern Development (lib/ + insertr-cli/) +- **Library Changes**: Edit `lib/src/**/*.js` โ Air automatically rebuilds everything +- **CLI Changes**: Edit Go files in `insertr-cli/` โ Air rebuilds and restarts server +- **Demo Content**: Edit `demo-site/*.html` โ Air serves enhanced versions +- **Hot Reload**: Changes trigger full rebuild cycle (library โ CLI โ enhanced content) + +#### Legacy Development (demo-site/) - **Live Reload**: The server automatically refreshes when you save changes -- **JavaScript**: Edit `demo-site/insertr/insertr.js` to modify core functionality -- **Styling**: Edit `demo-site/insertr/insertr.css` for UI changes +- **JavaScript**: Edit `demo-site/insertr/insertr.js` for prototype functionality - **Content**: Edit HTML files to test different content structures ### Adding New Features @@ -51,40 +79,67 @@ ``` insertr/ -โโโ INITIAL.md # Project requirements and research โโโ DEVELOPMENT.md # This file -โโโ package.json # Node.js project configuration -โโโ .gitignore # Git ignore rules +โโโ LIBRARY.md # Library architecture documentation +โโโ package.json # Root project configuration โ -โโโ demo-site/ # Frontend prototype +โโโ lib/ # ๐ Independent JavaScript Library +โ โโโ src/ +โ โ โโโ core/ +โ โ โ โโโ insertr.js # Core library functionality +โ โ โ โโโ editor.js # Visual editing interface +โ โ โ โโโ api-client.js # Content API client +โ โ โโโ index.js # Library entry point +โ โโโ dist/ +โ โ โโโ insertr.js # Built library (development) +โ โ โโโ insertr.min.js # Built library (production) +โ โโโ package.json # Library dependencies +โ โโโ rollup.config.js # Build configuration +โ +โโโ insertr-cli/ # ๐ Go CLI with Embedded Library +โ โโโ pkg/content/ +โ โ โโโ assets/ # Embedded library files (auto-copied) +โ โ โโโ library.go # Go embed declarations +โ โ โโโ enhancer.go # HTML enhancement orchestrator +โ โ โโโ injector.go # Content injection logic +โ โ โโโ ... +โ โโโ scripts/ +โ โ โโโ rebuild-library.sh # Air helper script +โ โโโ .air.toml # Hot reload configuration +โ โโโ insertr # Built CLI executable +โ +โโโ demo-site/ # Test website for enhancement โ โโโ index.html # Demo homepage โ โโโ about.html # Demo about page -โ โโโ README.md # Demo usage instructions -โ โ -โ โโโ assets/ # Demo site assets -โ โ โโโ style.css # Demo site styling -โ โ -โ โโโ insertr/ # Core Insertr library -โ โ โโโ insertr.js # Main library file -โ โ โโโ insertr.css # Edit interface styles -โ โ โโโ components/ # Future: reusable edit components -โ โ -โ โโโ mock-api/ # Backend planning -โ โโโ content.json # Sample data structure +โ โโโ assets/style.css # Demo site styling โ -โโโ backend/ # Future: Go backend - โโโ main.go # Future: HTTP server - โโโ api/ # Future: REST endpoints - โโโ storage/ # Future: file-based storage +โโโ scripts/ + โโโ build.js # Integrated build script ``` ## Development Scripts -- `npm run dev` - Start development server with live reload -- `npm run dev:about` - Start server opening about page -- `npm run build` - Future: Bundle library for distribution -- `npm run test` - Future: Run tests -- `npm run lint` - Future: Code linting +### Root Scripts +- `npm run build` - Build library + CLI with embedded assets +- `npm run dev` - Legacy live-server (demo-site only) + +### Library Scripts (cd lib/) +- `npm run build` - Build library to dist/ +- `npm run watch` - Watch and rebuild library on changes + +### CLI Scripts (cd insertr-cli/) +- `air` - ๐ฅ Hot reload server (library + CLI + enhanced content) +- `go build -o insertr` - Manual CLI build +- `./insertr enhance