Translate 69 abap2UI5 samples with cap2ui5 abap2js, texts 1:1 - #2
Merged
Merged
Conversation
The samples are no longer ported by hand: scripts/generate.mjs reads each class from abap2UI5/samples at the commit in ABAP2UI5_SAMPLES_PIN and writes what cap2ui5's abap2js makes of it into srv/apps/<class>.js - the same class name, the original's lines, comments and texts, all of them, the page title "abap2UI5 - ..." included. scripts/samples.json lists the 69 generated samples and the two abap2js still refuses, ported by hand the way it writes the rest, comments and texts 1:1 as well: 011 (LOOP AT ... REFERENCE INTO writes through the row, DELETE ... WHERE) and 488 (ASSIGN ... ->* TO FIELD-SYMBOL( )). Generated files are never edited by hand; `npm run check:generated` fails when one is not what the translation writes. test/differential.mjs holds every sample to its ABAP original: scripts/originals.mjs transpiles the originals with the transpiler the runtime was built with, renamed ZABAP_SMP_APP_nnn, and both are served in one cap2UI5 server; every event the original's first view wires is fired on a fresh start of each and the views, the model the original sends, the other actions and the target app are compared. 71 samples, 239 roundtrips, no difference; one known on purpose (122: CONV string( ) of a number keeps ABAP's sign position). CI runs both against the pinned samples checkout and packs cap2ui5 from the cap2UI5 branch that adds abap2js until it is on main. The samples test now expects the original's page title, and 186 showing no view on its first roundtrip, as its original does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012kUq3QqNUmt3WugBL5rLc7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The samples were ported by hand, nine so far. cap2ui5's new
abap2js(cap2UI5/cap2UI5#89) translates an abap2UI5 app class line for line, so the samples are now translated, not ported. Every sample keeps the original's lines, comments and texts, all of them, the page title "abap2UI5 - …" included.What changes
scripts/generate.mjsreads each class thatscripts/samples.jsonlists undergeneratedfrom abap2UI5/samples at the commit inABAP2UI5_SAMPLES_PIN(cdd5c8b), and writes it tosrv/apps/<class>.js. These files are never edited by hand: a change goes into the ABAP sample, the pin moves, and the script runs again.npm run check:generatedfails when a file is not what the translation writes.LOOP AT … REFERENCE INTO,DELETE … WHERE) and 488 (ASSIGN … ->* TO FIELD-SYMBOL( )).scripts/originals.mjstranspiles the originals with the transpiler the runtime was built with (@abaplint/transpiler 2.13.91, against the runtime'sdownport/), renamedZABAP_SMP_APP_nnn.test/differential.mjsserves both in one cap2UI5 server, fires every event the original's first view wires on a fresh start of each, and compares the views, the model the original sends, the other actions and the app that has the screen.npm test. It packs cap2ui5 from cap2UI5's branchclaude/absp2ui5-cap2ui5-transfer-7pg6dguntil npx cap2ui5 abap2js: an abap2UI5 app class, translated into a cap2UI5 app line for line cap2UI5#89 is on itsmain; then thatref:line goes.test/samples.test.mjsexpects the original's page title, and expects 186 to show no view on its first roundtrip, as its original does.Tests
npm test: 9/9.node scripts/generate.mjs --check: 69 samples, 0 to regenerate, 0 refused.npm run differential: 71 samples in 239 roundtrips, no difference. One difference is known and left on purpose: in 122,CONV string( )of a number keeps ABAP's trailing sign position ("0 "), and JavaScript'sString( )does not.no-undef,no-unused-varsandno-case-declarations.Depends on cap2UI5/cap2UI5#89 (abap2js, and
t.numc( )for 067). The other 58 samples follow as abap2js learns their constructs.🤖 Generated with Claude Code
https://claude.ai/code/session_012kUq3QqNUmt3WugBL5rLc7
Generated by Claude Code