BUILD SCRIPTS ANALYSIS

Comprehensive documentation system guides

๐Ÿ”ง Build Scripts Analysis - Project-Scoped Architecture

Date: October 28, 2025
Status: โœ… Scripts are compatible with project-scoped architecture


Overview

Analyzed build scripts for compatibility with the new project-scoped architecture. Good news: The scripts already support the new model!


โœ… scan-folders-config.js - ALREADY COMPATIBLE

Location: apps/docs-angular/scripts/scan-folders-config.js

Root Project Detection Logic

// Line 169: Determine if folder is a prospective root project
const isDirectChildOfLanguage = pathParts.length >= 2 && 
                                pathParts[pathParts.length - 2] === language;
const prospectiveRoot = isDirectChildOfLanguage || !!password;

// Line 206: Finalize isRoot flag
const finalIsRoot = (typeof cfg.isRoot === 'boolean') 
  ? cfg.isRoot  // Explicit override from docs.json or _folder.md
  : (prospectiveRoot && node.totalFiles > 0); // Auto-detect

if (finalIsRoot) node.isRoot = true;

Root Project Criteria

A project is marked as isRoot: true if ANY of these conditions are met:

  1. Explicit Configuration: isRoot: true in docs.json or _folder.md frontmatter
  2. Direct Child of Language: Folder is directly under docs/english/ or docs/spanish/
  3. Has Password: Folder has a password (private project marker)
  4. AND Has Content: Must have at least one markdown file (own or in subtree)

Examples

docs/
โ”œโ”€โ”€ english/
โ”‚   โ”œโ”€โ”€ GoGrab-Space/           โ† โœ… isRoot: true (direct child + has content)
โ”‚   โ”œโ”€โ”€ public/                 โ† โœ… isRoot: true (direct child + has content)
โ”‚   โ”œโ”€โ”€ private/                โ† โš ๏ธ isRoot: false (container, not project)
โ”‚   โ”‚   โ””โ”€โ”€ SecretProject/      โ† โœ… isRoot: true (has password + has content)
โ”‚   โ””โ”€โ”€ GoGrab-Pulse/           โ† โœ… isRoot: true (direct child + has content)
โ””โ”€โ”€ spanish/
    โ””โ”€โ”€ GoGrab-Space/           โ† โœ… isRoot: true (direct child + has content)

What It Does

  1. Scans docs/ directory recursively
  2. Reads docs.json or _folder.md frontmatter from each folder
  3. Inherits passwords from parent folders
  4. Counts markdown files (.md, .mdc) in each folder and subtree
  5. Marks folders as isRoot based on criteria above
  6. Generates docs-folders-config.json with folder hierarchy
  7. Preserves existing configuration on re-scan
  8. Merges changes from frontmatter metadata

Configuration Options (in _folder.md or docs.json)

---
title: "Project Name"
password: "secret123"           # Makes it a root project
isRoot: true                    # Explicit root marker
config:
  search:
    hasAccessToPublic: true     # Can search public projects
    scopeToCurrentProject: true # Search only within project
  navigation:
    enableBreadcrumbs: true
  ui:
    theme: "custom"
---

Output Format (docs-folders-config.json)

{
  "globalConfig": {...},
  "folders": [
    {
      "name": "GoGrab-Space",
      "path": "docs/english/GoGrab-Space",
      "language": "english",
      "password": null,
      "isRoot": true,          โ† โœ… Marked as root project
      "config": {
        "search": {
          "hasAccessToPublic": true
        }
      },
      "children": [...]
    }
  ]
}

โœ… scan-docs-structure.js - NEEDS VERIFICATION

Location: apps/docs-angular/scripts/scan-docs-structure.js

What It Does

Generates docs-manifest.json with complete file tree:

Compatibility Check

โœ… Already project-agnostic - It scans all files regardless of project structure.

The manifest includes the full path for each file:

{
  "structure": [
    {
      "name": "english",
      "type": "directory",
      "items": [
        {
          "name": "GoGrab-Space",
          "type": "directory",
          "items": [
            {
              "name": "libs-structural.md",
              "type": "file",
              "path": "docs/english/GoGrab-Space/libs-structural.md"
            }
          ]
        }
      ]
    }
  ]
}

Services like StructureSyncService then filter this manifest based on the currently selected project from ProjectSelectionState.

No Changes Needed โœ…

The manifest generation already works with project-scoped architecture because:

  1. It captures the full folder structure
  2. Project filtering happens at read time (in services), not build time
  3. Each file's full path is preserved

โš ๏ธ start-admin-server.js - NEEDS REVIEW

Location: apps/docs-angular/scripts/start-admin-server.js

Purpose

Serves documentation files during development:

Potential Updates Needed

  1. Path Resolution

    • Currently serves from hardcoded paths
    • May need dynamic path resolution based on project selection
    • Should handle project-scoped URLs like /docs/english/GoGrab-Space/...
  2. CORS Configuration

    • Ensure CORS allows project-scoped requests
    • Update allowed origins if needed
  3. Caching Strategy

    • Consider caching based on project context
    • Invalidate caches when project selection changes

Action Required

๐Ÿ” Manual Review - Test the admin server with:

  1. Navigate to /select-project
  2. Select a project
  3. Navigate within project (e.g., /GoGrab-Space/libs/ux-portal)
  4. Verify files are served correctly
  5. Check browser console for 404 errors

If files aren't served, check:


๐Ÿ“‹ Build Script Summary

Script Status Changes Needed
scan-folders-config.js โœ… Compatible None - Already marks root projects
scan-docs-structure.js โœ… Compatible None - Project-agnostic manifest
start-admin-server.js โš ๏ธ Needs Testing Verify path serving & proxying

๐Ÿงช Testing Recommendations

1. Generate Fresh Configs

# From project root
cd apps/docs-angular/scripts

# Generate folders config
node scan-folders-config.js

# Generate manifest
node scan-docs-structure.js

# Verify output
cat ../src/assets/docs-folders-config.json
cat ../src/assets/docs-manifest.json

2. Verify isRoot Flags

Check docs-folders-config.json:

# Should show isRoot: true for direct children of language folders
grep -A 5 '"isRoot": true' ../src/assets/docs-folders-config.json

Expected projects with isRoot: true:

3. Test Admin Server

# Start the admin server
node start-admin-server.js

# In browser:
# 1. http://localhost:5011/docs-config.json (should load)
# 2. http://localhost:5011/docs-folders-config.json (should load)
# 3. http://localhost:5011/docs/english/GoGrab-Space/libs-structural.md (should load)

๐ŸŽฏ Recommendations

Immediate Actions

  1. โœ… No changes needed for scan-folders-config.js
  2. โœ… No changes needed for scan-docs-structure.js
  3. โš ๏ธ Test start-admin-server.js with project-scoped URLs

Future Enhancements

  1. Add Validation - Script to validate isRoot flags match expected projects
  2. Add Tests - Unit tests for root project detection logic
  3. Document Overrides - How to explicitly set isRoot in frontmatter
  4. Performance - Consider caching folder scans for large repos

๐Ÿ“– Documentation Updates Needed

  1. Update add-documentation.md to explain:

    • Where to place new project folders (docs/english/{ProjectName}/)
    • How isRoot flag is automatically set
    • How to override with explicit isRoot: true in frontmatter
  2. Create project-structure-guide.md explaining:

    • Root project criteria
    • How to create a new project
    • Access control configuration
    • Cross-project visibility rules

Status: โœ… Build scripts are compatible
Action Required: Test admin server, update documentation