Skip to content

Add BSP build, validation, and round-trip conversion tools#3

Open
oblomov-dev wants to merge 10 commits intomainfrom
claude/analyze-frontend-deployment-3G6uG
Open

Add BSP build, validation, and round-trip conversion tools#3
oblomov-dev wants to merge 10 commits intomainfrom
claude/analyze-frontend-deployment-3G6uG

Conversation

@oblomov-dev
Copy link
Copy Markdown
Member

Summary

Add three Node.js scripts and two GitHub Actions workflows to support building UI5 applications into abapGit-compatible BSP (Business Server Page) repositories and converting them back to UI5 webapp format.

Key Changes

Scripts

  • scripts/build-bsp.mjs: Converts UI5 build output (dist/) into an abapGit BSP layout with proper WAPA (Web Application) XML structure. Handles:

    • Filesystem-safe encoding of SAP object names (namespace handling, slash replacement)
    • WAPA page filename generation per abapGit serializer rules
    • Manifest.json patching to inject OData/REST URIs
    • Generation of .abapgit.xml, package.devc.xml, and *.wapa.xml metadata files
    • Alphabetical sorting of pages by PAGEKEY (matches abapGit serializer output)
  • scripts/validate-bsp.mjs: Validates a generated BSP layout against abapGit WAPA invariants:

    • Verifies .abapgit.xml structure and required fields
    • Checks package folder and WAPA index existence
    • Validates per-page metadata (PAGEKEY/PAGENAME consistency, PAGETYPE/MIMETYPE mutual exclusivity)
    • Ensures PAGES are sorted alphabetically
    • Detects duplicate PAGEKEYs and orphan files
    • Validates manifest.json JSON syntax and optional OData URI matching
    • Enforces index.html consistency (MIMETYPE, IS_START_PAGE)
  • scripts/bsp-to-ui5.mjs: Reverse converter that reconstructs the original UI5 webapp directory from a BSP repository:

    • Locates WAPA XML index and extracts APPLNAME
    • Restores files using PAGENAME entries (preserving original case)
    • Optionally patches manifest.json dataSource URIs for backend switching
    • Handles BOM stripping for proper JSON parsing

GitHub Actions Workflows

  • .github/workflows/build-bsp.yml: Orchestrates the full build pipeline:

    • Builds UI5 app with npm run build
    • Converts output to BSP layout
    • Validates generated BSP
    • Performs round-trip conversion (BSP → webapp) to verify encoding losslessness
    • Diffs restored webapp against original build output (excluding manifest.json)
    • Runs abaplint on generated repository
    • Uploads BSP and restored webapp as artifacts
  • .github/workflows/restore-ui5.yml: Standalone workflow to restore UI5 webapp from an existing BSP repository with optional OData URI rewriting

Notable Implementation Details

  • Encoding rules strictly follow abapGit source (zcl_abapgit_object_wapa, zcl_abapgit_folder_logic)
  • Page filenames split at first dot only; slashes in both parts replaced with _-
  • Namespace handling: /NS/NAME#ns#name in filenames (lowercase), but APPLNAME in XML preserves uppercase
  • XML output includes UTF-8 BOM for abapGit compatibility
  • Round-trip validation ensures lossless conversion (byte-identical except manifest.json formatting)
  • Supports both namespaced (/NAMESPACE/NAME) and non-namespaced (Z***) BSP application names

https://claude.ai/code/session_01SX6tjxKQXgdD5oJZWheWB3

oblomov-dev added 10 commits May 6, 2026 20:52
- Workflow `.github/workflows/build-bsp.yml` runs `ui5 build` then converts
  the output into an abapGit-compatible BSP layout, uploaded as artifact
- `scripts/build-bsp.mjs` implements the conversion:
  filename encoding (`/` -> `_-` in pagenames, `/` -> `#` in BSP/package
  names), subfolder layout with `FOLDER_LOGIC=FULL`, MIMETYPE/IS_START_PAGE
  for index.html, alphabetical PAGES sorting, manifest.json odata patching
- Encoding rules verified against the abapGit WAPA serializer source
scripts/validate-bsp.mjs checks the generated layout against the
abapGit WAPA invariants:
- .abapgit.xml present with required fields
- package folder + package.devc.xml present
- WAPA header ATTRIBUTES complete (APPLNAME, APPLCLAS, APPLEXT, ...)
- per-page: PAGEKEY = upper(PAGENAME), file exists at encoded name,
  exactly one of PAGETYPE/MIMETYPE, APPLNAME matches header
- PAGES sorted alphabetically (matches abapGit serializer)
- at most one IS_START_PAGE; index.html must be the start page
- no duplicate PAGEKEYs, no orphan files in package folder
- manifest.json valid JSON with patched odata URI

The workflow now runs the validator after the converter (hard fail)
and abaplint on the result for an additional XML/structural check
(non-blocking, warnings only).
scripts/bsp-to-ui5.mjs reads a generated/cloned BSP repo, locates
the *.wapa.xml index, and reconstructs the original webapp/ folder
by walking the PAGES list (PAGENAME holds the original path).

Auto-discovers STARTING_FOLDER from .abapgit.xml and finds the WAPA
file under it, so the same script works for any BSP repo regardless
of package layout (flat or subfolder, with or without namespace).

Optional --odata flag rewrites manifest.json dataSource URIs (useful
when round-tripping back from a SAP backend to a CAP/local one).
- New `.github/workflows/restore-ui5.yml`: workflow_dispatch that
  runs scripts/bsp-to-ui5.mjs against any BSP directory in the
  checked-out repo and uploads the reconstructed webapp as artifact.

- Update `.github/workflows/build-bsp.yml` to round-trip the freshly
  built BSP back to UI5 form and diff against the original ui5-build
  output. Catches lossy encoding / decoding regressions immediately.
  manifest.json is excluded from the byte-diff because it is
  re-serialized by JSON.stringify on both directions; the converter's
  semantic check on manifest.json is covered by validate-bsp.
- scripts/ui5-to-bsp.mjs (renamed from build-bsp.mjs, content unchanged)
- scripts/validate-ui5.mjs (new): checks manifest.json, Component.js,
  rootView resolution, view->controller wiring, css resources
- workflows updated to use the new script name and run validate-ui5
  on both the source webapp (build) and the restored webapp (build +
  restore round-trip)
Both workflows now expose:
- source_dir (default: input)
- result_dir (default: output)

build-bsp.yml: source_dir is the UI5 app directory (was 'app_v2_new'),
result_dir is the BSP output directory (was hardcoded 'result').

restore-ui5.yml: source_dir replaces bsp_dir (was 'result'),
result_dir replaces out_dir (was 'webapp_restored').

Generic defaults make the workflows reusable across repositories.
- Add layout entry for scripts/
- Add "BSP conversion scripts" section with per-script usage,
  flags table, customer-namespace example, and a round-trip
  verification recipe
- All four scripts are documented for direct manual use with `node`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant