|
1 | 1 | # Migration Guidance |
2 | 2 |
|
3 | | -This file describes a safe refactor path from the current `content/` layout to a cleaner `src/` + `dist/` repository structure. |
| 3 | +This file describes the actual migration performed on the RingID codebase from legacy tooling to modern tooling. |
4 | 4 |
|
5 | | -## Current state |
| 5 | +## Migration Completed (2026-05-01) |
6 | 6 |
|
7 | | -- `content/` contains application source, static HTML pages, generated assets, and legacy files mixed together. |
8 | | -- `config/` contains server configuration. |
9 | | -- There is no root-level source tree for active frontend code. |
| 7 | +### From → To |
| 8 | +- **Bower → pnpm** (with workspaces) |
| 9 | +- **Grunt → Vite** (with HMR and fast builds) |
| 10 | +- **Legacy structure → Monorepo** (apps/ + packages/) |
10 | 11 |
|
11 | | -## Goal state |
| 12 | +## Final Structure |
12 | 13 |
|
13 | | -- `src/` contains all active application source files. |
14 | | -- `dist/` contains generated production assets. |
15 | | -- `legacy/` holds archived or deprecated content pending cleanup. |
16 | | -- `content/` can be removed or kept as a migration fallback until the transition is complete. |
17 | | - |
18 | | -## Recommended structure |
19 | | - |
20 | | -```text |
| 14 | +``` |
21 | 15 | /README.md |
22 | 16 | /package.json |
23 | | -/.gitignore |
24 | | -/bower.json |
25 | | -/config/ |
26 | | -/src/ |
27 | | - /app/ |
28 | | - /pages/ |
29 | | - /styles/ |
30 | | - /scripts/ |
31 | | - /images/ |
32 | | - /templates/ |
33 | | - /apidocfiles/ |
34 | | -/legacy/ |
35 | | -/dist/ |
36 | | - /downloads/ |
37 | | - /scripts/dist/ |
38 | | -/tests/ |
39 | | - /testmedia/ |
| 17 | +/pnpm-workspace.yaml |
| 18 | +/.npmrc |
| 19 | +/eslint.config.js |
| 20 | +/.prettierrc |
| 21 | +/.husky/ |
| 22 | +/apps/ |
| 23 | + /main-app/ # Main AngularJS application |
| 24 | +/packages/ |
| 25 | + /scripts/ # Shared JavaScript utilities |
| 26 | + /styles/ # Shared CSS styles |
| 27 | + /templates/ # Shared HTML templates |
| 28 | + /common/ # Common resources |
| 29 | + /resources/ # Shared resources |
| 30 | +/config/ # Server configurations |
| 31 | +/tests/ # Test files |
| 32 | +/scripts/ # Migration scripts |
40 | 33 | ``` |
41 | 34 |
|
42 | | -## Safe migration steps |
43 | | - |
44 | | -1. Inventory current application source under `content/`. |
45 | | - - `content/app/`, `content/styles/`, `content/templates/`, `content/images/`, `content/fonts/` |
46 | | - - `content/js/`, `content/css/` |
47 | | - - `content/pages/`, `content/error/`, `content/mobile/`, `content/newsportal/`, `content/player/`, `content/webapp/` |
48 | | - - `content/chatwindow.js`, `content/utils_script.js` |
49 | | - - `content/*.html`, `content/*.xhtml` |
50 | | - |
51 | | -2. Create the new `src/` tree and move active source files there. |
52 | | - - Move only active source files first; leave legacy content in `content/`. |
53 | | - - Update any build or runtime paths before removing the original files. |
54 | | - |
55 | | -3. Move generated build artifacts into `dist/`. |
56 | | - - `content/build/` → `dist/` |
57 | | - - `content/css/` → `dist/css/`, `content/js/` → `dist/js/` |
58 | | - - `content/scripts/dist/` → `dist/scripts/dist/` |
59 | | - - hashed bundles and minified assets from `content/` |
60 | | - |
61 | | -4. Move top-level HTML and XHTML pages and shared scripts into `src/`. |
62 | | - - Root-level `content/*.html` and `content/*.xhtml` pages → `src/pages/` |
63 | | - - `content/chatwindow.js` → `src/scripts/chatwindow.js` |
64 | | - - `content/utils_script.js` → `src/scripts/utils_script.js` |
65 | | - |
66 | | -5. Move API documentation and test files. |
67 | | - - `content/apidocfiles/` → `src/apidocfiles/` |
68 | | - - `content/apidoc.json` → `src/apidocfiles/apidoc.json` |
69 | | - - `content/tests/` → `tests/` |
70 | | - - `content/karma.conf.js` → `tests/karma.conf.js` |
71 | | - - `content/testmedia/` → `tests/testmedia/` |
72 | | - |
73 | | -6. Move downloadable binaries and archives. |
74 | | - - `content/ringID*.exe`, `content/ringID*.zip` → `dist/downloads/` |
75 | | - |
76 | | -7. Move root-level static files. |
77 | | - - `content/robots.txt` → `robots.txt` |
78 | | - - `content/sitemap.xml` → `sitemap.xml` |
79 | | - |
80 | | -8. Archive backup/legacy files. |
81 | | - - `content/*.backup`, `content/*_old*.html`, `content/index_old_file_important.html` |
82 | | - - `content/privacy_old_important.html` → `legacy/` |
83 | | - - `content/ringidUpdate.txt` → `legacy/` |
84 | | - |
85 | | -9. Use the provided script |
86 | | - - Run `npm run migrate` from the repository root |
87 | | - - This moves safe source directories into `src/`, generated assets into `dist/`, test files into `tests/`, and archives legacy files into `legacy/` |
88 | | - |
89 | | -10. Update repository tooling. |
90 | | - - `content/bower.json` → `bower.json` (root level) |
91 | | - - Merge `content/.gitignore` entries into root `.gitignore` |
92 | | - - Merge `content/README.md` into root `README.md` |
93 | | - - Modify any server or deployment references to point to `src/` and `dist/`. |
94 | | - |
95 | | -11. Validate the refactor. |
96 | | - - Run the application and confirm builds still work. |
97 | | - - Remove `content/index.html` if it is just a redirect duplicate. |
98 | | - - Keep `content/` as fallback until the migration is fully verified. |
99 | | - |
100 | | -## Notes |
101 | | - |
102 | | -- Do not delete files until the new structure is confirmed working. |
103 | | -- Use the `legacy/` folder for any content that is preserved for later review. |
| 35 | +## What Was Done |
| 36 | + |
| 37 | +### 1. Package Manager Migration |
| 38 | +- Deleted `bower.json`, `.bowerrc` |
| 39 | +- Created `pnpm-workspace.yaml` |
| 40 | +- Migrated all dependencies to `package.json` files |
| 41 | +- Used pnpm workspaces for monorepo management |
| 42 | + |
| 43 | +### 2. Build System Migration |
| 44 | +- Deleted `Gruntfile.js` |
| 45 | +- Created `vite.config.js` with: |
| 46 | + - AngularJS support |
| 47 | + - Template alias (`@templates/` → `packages/templates/`) |
| 48 | + - Proxy for API requests |
| 49 | + - Build optimization |
| 50 | + |
| 51 | +### 3. Code Quality Setup |
| 52 | +- Added ESLint with AngularJS globals |
| 53 | +- Added Prettier for formatting |
| 54 | +- Set up Husky + lint-staged for pre-commit hooks |
| 55 | +- Created `.editorconfig` for consistency |
| 56 | + |
| 57 | +### 4. Template Consolidation |
| 58 | +- Moved all templates to `packages/templates/` |
| 59 | +- Deleted `apps/main-app/templates/` |
| 60 | +- Updated 161 template URLs to use `@templates/` alias |
| 61 | +- Created `template-loader.js` for Vite compatibility |
| 62 | + |
| 63 | +### 5. CI/CD Setup |
| 64 | +- Created `.github/workflows/ci.yml` |
| 65 | +- Added GitHub Actions workflow for: |
| 66 | + - Install (pnpm) |
| 67 | + - Lint (ESLint) |
| 68 | + - Build (Vite) |
| 69 | + - Security audit |
| 70 | + |
| 71 | +### 6. Cleanup |
| 72 | +- Removed legacy files: `.jshintrc`, `.tern-project`, `.eslintrc.json` |
| 73 | +- Deleted backup files (`*_old*`, `*_backup*`) |
| 74 | +- Flattened nested package directories |
| 75 | +- Added `package.json` to all workspace packages |
| 76 | + |
| 77 | +### 7. Documentation |
| 78 | +- Updated `README.md` with pnpm commands |
| 79 | +- Created `CONTRIBUTING.md` |
| 80 | +- Created `CHANGELOG.md` |
| 81 | +- Created `ARCHITECTURE.md` |
| 82 | +- Created `TODO.md` with gap analysis |
| 83 | + |
| 84 | +## Migration Script |
| 85 | + |
| 86 | +The original migration script (`scripts/migrate-to-src.js`) is obsolete. The actual migration was done manually with these steps: |
| 87 | + |
| 88 | +1. Set up pnpm workspace |
| 89 | +2. Configure Vite for AngularJS |
| 90 | +3. Move files to monorepo structure |
| 91 | +4. Update all references and imports |
| 92 | +5. Add modern tooling (ESLint, Prettier, Husky) |
| 93 | +6. Create CI/CD pipeline |
| 94 | +7. Document everything |
| 95 | + |
| 96 | +## Lessons Learned |
| 97 | + |
| 98 | +- **Incremental migration works better** than big-bang changes |
| 99 | +- **Template URLs need careful handling** — sed replacements can break strings |
| 100 | +- **AngularJS globals must be configured** in ESLint |
| 101 | +- **Git lock files** can be an issue in containerized environments |
| 102 | +- **pnpm workspaces** are excellent for monorepo management |
| 103 | + |
| 104 | +## Future Migrations |
| 105 | + |
| 106 | +### AngularJS → Modern Framework |
| 107 | +See `TODO.md` for the long-term migration strategy to Angular/React/Vue. |
| 108 | + |
| 109 | +Recommended approach: |
| 110 | +1. Research and prototype (1-2 weeks) |
| 111 | +2. Incremental migration using micro-frontends (3-6 months) |
| 112 | +3. Sunset AngularJS version |
| 113 | + |
| 114 | +### Security Updates |
| 115 | +- Upgrade AngularJS 1.3.15 → Latest 1.x (or migrate framework) |
| 116 | +- Upgrade Bootstrap 3.3.5 → 4.x/5.x or Tailwind |
| 117 | +- Fix known XSS vulnerabilities |
0 commit comments