Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ versions [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

- The differential test transpiles the originals against open-abap-core at the
commit `@abap2ui5/node-runtime` records in its `package.json`
(`abap2ui5.openAbapCore`) instead of HEAD, so the original runs on the
open-abap-core the translation runs on; a runtime that does not record it
(1.145.0) still gets HEAD, with a warning.

## [0.2.0] - 2026-09-30

For `@cap2ui5/cds-plugin` 0.4.0, whose model carries only the fields an app
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@ sends, every other action and which app has the screen - today 71 samples in
`Z2UI5_CL_SMP_APP_122` prints a number with `CONV string( )`, which keeps ABAP's
trailing sign position (`"0 "`) and JavaScript's `String( )` does not.

It needs the network once (open-abap-core is cloned into `.deps/`) and
`@abaplint/transpiler-cli` at the runtime's version, a devDependency.
It needs the network once (open-abap-core is fetched into `.deps/` at the
commit @abap2ui5/node-runtime was built against - its `package.json` records
it as `abap2ui5.openAbapCore` - so that the original runs on the open-abap-core
the translation runs on) and `@abaplint/transpiler-cli` at the runtime's
version, a devDependency.

## What a translated sample looks like

Expand Down
26 changes: 22 additions & 4 deletions scripts/originals.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// The runtime's own transpiler output is what cap2UI5 hosts, so the original
// runs on exactly the framework the translation runs on.
//
// Needs the network once: open-abap-core is cloned into .deps/.
// Needs the network once: open-abap-core is fetched into .deps/ - at the commit
// @abap2ui5/node-runtime was built against, which its package.json records.
import { execFileSync } from "node:child_process";
import fs from "node:fs";
import { createRequire } from "node:module";
Expand All @@ -34,16 +35,33 @@ if (head !== pin) throw new Error(`${checkout} is at ${head}, ABAP2UI5_SAMPLES_P

// the transpiler the runtime was built with: its output is tied to the runtime
const runtimeDir = path.dirname(require.resolve("@abap2ui5/node-runtime/package.json", { paths: [require.resolve("@cap2ui5/cds-plugin")] }));
const wanted = JSON.parse(fs.readFileSync(path.join(runtimeDir, "package.json"), "utf8")).abap2ui5?.transpiler;
const built = JSON.parse(fs.readFileSync(path.join(runtimeDir, "package.json"), "utf8")).abap2ui5 ?? {};
const wanted = built.transpiler;
const have = JSON.parse(fs.readFileSync(require.resolve("@abaplint/transpiler-cli/package.json"), "utf8")).version;
if (wanted && wanted !== have) {
throw new Error(`@abaplint/transpiler-cli ${have} is installed, @abap2ui5/node-runtime was built with ${wanted} - ` +
`npm i -D --save-exact @abaplint/transpiler-cli@${wanted}`);
}

// open-abap-core at the commit the runtime was built against (abap2ui5.openAbapCore),
// so that the original is transpiled against the open-abap-core the runtime hosts
// it on - a clone of HEAD would run the original on a newer one than the translation.
// git clone takes no commit, so: init, fetch the one commit, check it out.
const deps = path.join(ROOT, ".deps", "open-abap-core");
if (!fs.existsSync(deps)) {
execFileSync("git", ["clone", "--depth", "1", "https://github.com/open-abap/open-abap-core", deps], { stdio: "inherit" });
const core = "https://github.com/open-abap/open-abap-core";
const checkedOut = fs.existsSync(deps) ? execFileSync("git", ["-C", deps, "rev-parse", "HEAD"], { encoding: "utf8" }).trim() : null;
if (built.openAbapCore) {
if (checkedOut !== built.openAbapCore) {
fs.rmSync(deps, { recursive: true, force: true });
fs.mkdirSync(deps, { recursive: true });
execFileSync("git", ["init", "-q", deps], { stdio: "inherit" });
execFileSync("git", ["-C", deps, "fetch", "-q", "--depth", "1", core, built.openAbapCore], { stdio: "inherit" });
execFileSync("git", ["-C", deps, "checkout", "-q", "FETCH_HEAD"], { stdio: "inherit" });
}
} else if (!checkedOut) {
// node-runtime 1.145.0 and older did not record the commit
console.warn("originals: @abap2ui5/node-runtime does not record its open-abap-core commit (abap2ui5.openAbapCore) - cloning HEAD");
execFileSync("git", ["clone", "--depth", "1", core, deps], { stdio: "inherit" });
}

const work = fs.mkdtempSync(path.join(os.tmpdir(), "originals-"));
Expand Down
Loading