Skip to content

Commit ba8e14a

Browse files
omarqureshiclaude
andcommitted
chore(ruby): local dev scripts to link the fork rosetta
Building pacmak's ruby target needs a jsii-rosetta with TargetLanguage.RUBY. The committed pin here is upstream + a stopgap patch that lacks it (deliberate: the real build happens in the blog publish-packages pipeline, which injects the fork rosetta at build time), so a clean `yarn build` of the ruby target fails to compile and the ruby-runtime fixtures can't be regenerated locally. dev-link-rosetta.sh mirrors what the pipeline does: builds ../jsii-rosetta into a tgz and pins jsii-rosetta to it via a root resolution, so the ruby target compiles and generate.sh produces current fixtures. dev-unlink-rosetta.sh restores the committed pin. These live on -self-publish rather than ruby-language-bindings because that is the only branch that builds the ruby target — the base branch is the upstream-facing review artifact and depends on the fork @jsii/spec that upstream has not released. Verified: link -> pacmak compiles -> generate.sh -> 250 examples, 0 failures. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e102ea8 commit ba8e14a

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

scripts/dev-link-rosetta.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
#------------------------------------------------------------------------
3+
# Links the local Ruby-target jsii-rosetta fork into this repo for local dev.
4+
#
5+
# The committed self-publish branch pins jsii-rosetta to upstream + a stopgap
6+
# patch that has no TargetLanguage.RUBY, so a clean `yarn build` of pacmak's
7+
# ruby target fails to compile. That is deliberate: the real build happens in
8+
# the blog `publish-packages` pipeline, which injects the fork rosetta at build
9+
# time (resolutions["jsii-rosetta"] = file:.../jsii-rosetta-0.0.0.tgz).
10+
#
11+
# This does the same thing locally, so pacmak's ruby target compiles and the
12+
# ruby-runtime fixtures can be regenerated (otherwise the compliance suite runs
13+
# against stale, months-old generated code and reports phantom failures).
14+
#
15+
# It modifies package.json + yarn.lock -- DO NOT COMMIT them. Run
16+
# scripts/dev-unlink-rosetta.sh to restore the committed pins.
17+
#
18+
# Usage: scripts/dev-link-rosetta.sh [path-to-jsii-rosetta-fork]
19+
# (default: ../jsii-rosetta, the sibling checkout the pipeline assumes)
20+
#------------------------------------------------------------------------
21+
set -euo pipefail
22+
23+
here="$(cd "$(dirname "$0")/.." && pwd)"
24+
fork="$(cd "${1:-$here/../jsii-rosetta}" && pwd)"
25+
tgz_path="$fork/dist/js/jsii-rosetta-0.0.0.tgz"
26+
27+
echo "Fork rosetta: $fork"
28+
29+
# 1. Build + pack the fork. lib/ is a gitignored build artifact; only recompile
30+
# when it is missing or older than a source file, to keep the fork pristine.
31+
( cd "$fork"
32+
if [ ! -f lib/index.js ] || [ -n "$(find src -name '*.ts' -newer lib/index.js -print -quit 2>/dev/null)" ]; then
33+
echo "Compiling fork rosetta..."
34+
[ -d node_modules ] || yarn install --no-immutable
35+
npx projen pre-compile
36+
npx projen compile
37+
else
38+
echo "Fork build is current; skipping compile."
39+
fi
40+
mkdir -p dist/js
41+
npm pack --pack-destination dist/js >/dev/null
42+
echo "Packed $(basename "$tgz_path")"
43+
)
44+
45+
# 2. Point jsii-rosetta at the fork tgz and install. A ROOT resolution overrides
46+
# the stopgap patch for every consumer, pacmak included. Relative path so it
47+
# matches what the pipeline writes.
48+
cd "$here"
49+
rel="$(realpath --relative-to="$here" "$tgz_path")"
50+
echo "Pinning jsii-rosetta -> file:$rel"
51+
jq --arg t "file:$rel" '.resolutions["jsii-rosetta"] = $t' package.json > package.json.tmp
52+
mv package.json.tmp package.json
53+
yarn install --no-immutable
54+
55+
cat <<EOF
56+
57+
Linked. pacmak's ruby target now compiles against the fork.
58+
59+
Rebuild pacmak + get a trustworthy compliance run:
60+
(cd packages/jsii-pacmak && npx tsc --build)
61+
(cd packages/@jsii/ruby-runtime-test && bash generate.sh && bundle exec rspec)
62+
63+
Restore the committed pins when done:
64+
scripts/dev-unlink-rosetta.sh
65+
EOF

scripts/dev-unlink-rosetta.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
#------------------------------------------------------------------------
3+
# Reverts scripts/dev-link-rosetta.sh: restores the committed jsii-rosetta pin
4+
# (upstream + stopgap patch) and reinstalls, leaving the branch clean.
5+
#
6+
# After this, pacmak's ruby target will no longer compile locally -- that is the
7+
# committed state by design; the real build happens in the publish pipeline.
8+
#------------------------------------------------------------------------
9+
set -euo pipefail
10+
11+
here="$(cd "$(dirname "$0")/.." && pwd)"
12+
cd "$here"
13+
14+
git checkout -- package.json yarn.lock
15+
yarn install --no-immutable
16+
17+
echo "Restored committed jsii-rosetta pin; working tree clean."

0 commit comments

Comments
 (0)