Skip to content

Publish the samples as @cap2ui5/samples, a package a CAP project adds - #3

Merged
oblomov-dev merged 1 commit into
mainfrom
claude/tender-cannon-bm68wd
Sep 29, 2026
Merged

oblomov-dev merged 1 commit into
mainfrom
claude/tender-cannon-bm68wd

Conversation

@oblomov-dev

Copy link
Copy Markdown
Member

Summary

abap2UI5's samples run in any system they are pulled into, but these could only run as a project of their own. With cap2UI5/cap2UI5#90 the plugin loads the apps a dependency declares, and it is published as @cap2ui5/cds-plugin 0.3.0. So the samples become @cap2ui5/samples. Run npm add -D @cap2ui5/samples in a CAP project, and cds watch lists every sample beside the project's own apps.

  • package.json
    • Name, version 0.1.0, and the metadata npm shows.
    • files covers srv/apps, the README, the changelog and the license.
    • "cap2ui5": { "apps": "srv/apps" } tells the plugin where the apps are.
    • The plugin is a peer dependency (^0.3.0), so the samples run on the project's own plugin.
    • Everything the repository needs for itself is a devDependency.
  • srv/apps
    • Every sample now imports @cap2ui5/cds-plugin.
    • The 69 generated samples were regenerated by abap2js 0.3.0 from the pin; the import line is the only change.
    • The two hand-written samples were edited the same way.
    • generate and originals take abap2js and the runtime from the new name.
  • scripts/consumer-test.mjs (new)
    • Packs the samples as publish would, and installs the tarball and the plugin into a throwaway CAP project that has an app of its own.
    • Serves that project and checks three things: every sample loads from the package, a sample shows its view, and the project's app still answers.
    • --plugin <tarball> runs it before the plugin is on npm.
  • test.yml
    • Installs the plugin from npm, the way a project does.
    • Before, it packed cap2UI5's plugin from a branch that has since been deleted, so the workflow could not run any more.
    • Adds the consumer test, and can be called by release.yml.
  • release.yml (new)
    • A tag v<version> runs test.yml on the tagged commit and publishes by trusted publishing, as cap2UI5's own release.yml does.
  • README and CHANGELOG
    • The README says how to add the samples to a project and how to publish.
    • The note about installing the plugin from a branch is gone.
    • The changelog records 0.1.0.

Merge order: CI needs @cap2ui5/cds-plugin 0.3.0 on npm

test.yml installs @cap2ui5/cds-plugin@^0.3.0 from the registry. Until that version is published, npm install fails with ETARGET. The order is:

  1. Merge Publish the plugin as @cap2ui5/cds-plugin 0.3.0, and serve the apps a package brings cap2UI5#90 and publish the plugin (commands in that PR).
  2. Re-run CI here; it goes green.
  3. Merge.

After merging: the first publish

npm install && npm test && npm run consumer-test
npm login
npm publish --access public
npx -y npm@11 trust github @cap2ui5/samples --file release.yml --repo cap2UI5/samples --allow-publish
git tag v0.1.0 && git push origin v0.1.0   # release.yml finds 0.1.0 on npm and publishes nothing

Test plan

All of these ran locally against @cap2ui5/cds-plugin 0.3.0, packed from cap2UI5/cap2UI5#90.

  • npm test: 9 tests, every sample over the wire
  • npm run check:generated: srv/apps is what abap2js writes from the pin
  • The differential test: all 71 samples behave as their transpiled ABAP originals
  • npm run consumer-test: in a project that installed the tarball, 71 app modules load from @cap2ui5/samples
  • CI: green once the plugin is on npm (see above)

🤖 Generated with Claude Code

https://claude.ai/code/session_018bBcFp146qnMCmXWztQaH8


Generated by Claude Code

abap2UI5's samples run in any system they are pulled into; these ran only
as a project of their own. cap2UI5's plugin now loads the apps a
dependency declares (cap2UI5 "Serve the apps a package brings, beside the
project's own"), and it is published as @cap2ui5/cds-plugin 0.3.0. So the
samples become @cap2ui5/samples: `npm add -D @cap2ui5/samples` in a CAP
project, and cds watch lists every sample beside the project's own apps.

- package.json: the name, version 0.1.0 and what npm shows; files is
  srv/apps, the README, the changelog and the license; "cap2ui5":
  { "apps": "srv/apps" } is where the plugin finds the apps; the plugin
  is a peer dependency (^0.3.0), so the samples run on the project's
  own. Everything the repository needs for itself is a devDependency.
- srv/apps: every sample imports @cap2ui5/cds-plugin - the 69 generated
  ones regenerated by abap2js 0.3.0 from the pin (the import line is the
  only change), the two hand-written ones edited the same way; generate
  and originals take abap2js and the runtime from the new name.
- scripts/consumer-test.mjs: packs the samples as publish would, installs
  the tarball with the plugin into a throwaway CAP project that has an
  app of its own, serves it, and checks that the plugin loads every
  sample from the package, a sample shows its view and the project's app
  still answers. `--plugin <tarball>` runs it before the plugin is on npm.
- test.yml: the plugin from npm, as a project installs it - it used to
  pack cap2UI5's plugin from a branch that has since been deleted, so the
  workflow could not run any more - and the consumer test; callable by
  release.yml.
- release.yml: a tag v<version> runs test.yml on the tagged commit and
  publishes by trusted publishing, as cap2UI5's release.yml does; the
  first version is published by hand, and its header and the README say
  how, `npm trust` included.
- README: how to add the samples to a project, how to publish; the note
  about installing the plugin from a branch is gone. CHANGELOG: 0.1.0.

Tested against @cap2ui5/cds-plugin 0.3.0 packed from cap2UI5's branch:
npm test (9 tests, every sample over the wire), check:generated, the
differential test (all 71 behave as their ABAP originals), and the
consumer test - 71 app modules loaded from @cap2ui5/samples in a project
that installed the tarball. CI needs @cap2ui5/cds-plugin 0.3.0 on npm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018bBcFp146qnMCmXWztQaH8
@oblomov-dev
oblomov-dev merged commit 6d654b8 into main Sep 29, 2026
1 check failed
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.

2 participants