Skip to content

fix(cli): preserve symlinks in the standalone cli zip - #2192

Merged
aws-cdk-automation merged 2 commits into
mainfrom
sai/standalone-zip-symlinks
Dec 2, 2026
Merged

aws-cdk-automation merged 2 commits into
mainfrom
sai/standalone-zip-symlinks

Conversation

@sai-ray

@sai-ray sai-ray commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Users without npm access (e.g. in ADC regions) can install the CLI from the standalone aws-cdk-cli.zip. After unzipping it, ./node_modules/.bin/cdk --version fails with Cannot find module '../lib'.

yarn install creates node_modules/.bin/cdk as a symlink to ../aws-cdk/bin/cdk, but by default zip follows symlinks and stores a copy of the target file. The script does require('../lib'), which resolves relative to the file's own location, so from the copy in .bin it looks for node_modules/lib, which doesn't exist.

This PR adds -y to the zip command in projenrc/build-standalone-zip.task.ts, so symlinks are stored as links. .bin/cdk is the only symlink in the zip, so nothing else changes.

Before (Built and then unzipped)

$ ls -l node_modules/.bin/cdk
-rwxr-xr-x  153  node_modules/.bin/cdk
$ ./node_modules/.bin/cdk --version
Error: Cannot find module '../lib'

After

$ ls -l node_modules/.bin/cdk
lrwxr-xr-x   18  node_modules/.bin/cdk -> ../aws-cdk/bin/cdk
$ ./node_modules/.bin/cdk --version
0.0.0 (build 45c3650)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@sai-ray
sai-ray requested a review from a team December 1, 2026 22:33
@github-actions github-actions Bot added the p2 label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@maintainer-for-aws

maintainer-for-aws Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Automated review

A maintainer will still review this — treat the notes below as a starting point.

📌 Commit cc6251f

This PR fixes the standalone aws-cdk-cli.zip built for users without npm access. It adds -y to the zip command in projenrc/build-standalone-zip.task.ts, so node_modules/.bin/cdk is stored as a symlink to ../aws-cdk/bin/cdk instead of a copy of that file. Before this change, the copy's require("../lib") looked for ../lib next to the copy in .bin and failed. Keeping the link makes it look next to the real bin/cdk inside the aws-cdk package, where it resolves. The change is minimal and matches the cause the PR describes. I found no issues in it.

Open findings: 🔴 0 blocking · 🟡 0 recommended · ⚪ 0 optional.


Generated automatically. React 👍 or 👎 to tell us whether this review helped, so we can improve these reviews.

@codecov-commenter

codecov-commenter commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.52%. Comparing base (f7c9dca) to head (cc6251f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2192      +/-   ##
==========================================
- Coverage   92.55%   92.52%   -0.04%     
==========================================
  Files          81       81              
  Lines       13224    13224              
  Branches     1917     1914       -3     
==========================================
- Hits        12240    12236       -4     
- Misses        946      950       +4     
  Partials       38       38              
Flag Coverage Δ
suite.unit 92.52% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation
aws-cdk-automation added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 66286b8 Dec 2, 2026
82 of 84 checks passed
@aws-cdk-automation
aws-cdk-automation deleted the sai/standalone-zip-symlinks branch December 2, 2026 12:59

This branch was previously deployed

3 inactive (1 outdated) deployments
run-tests — cc6251f7 Deployed Dec 2, 2026 by sai-ray via integ_init-templates (init-typescript-app, 22) #7827
no-approval — cc6251f7 Deployed Dec 2, 2026 by sai-ray via prepare #7827
automation — 01679811 Deployed Dec 1, 2026 by sai-ray via Set AutoQueue on PR #2192 #4067
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants