chore(cli): decouple cdktn bin entry point from build output#232
Draft
X-Guardian wants to merge 3 commits into
Draft
chore(cli): decouple cdktn bin entry point from build output#232X-Guardian wants to merge 3 commits into
X-Guardian wants to merge 3 commits into
Conversation
d1dab61 to
0a5c9b3
Compare
0a5c9b3 to
c068b74
Compare
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.
Description
Two changes to how
cdktn-clibuilds. The CLI launcher moves out of the build output into a committedbin/cdktn, and the esbuild build config compiles into a gitignoredbuild-config/directory instead of next to its source. No user-facing CLI behaviour changes — samecdktncommand, same flags.Why
Previously the
binfield pointed atbundle/bin/cdktn, a file that only exists afterbuild.tscopies it in (fs.copySync("src/bin/cdktn", "./bundle/bin/cdktn")). That means thebintarget is absent until a build runs. yarn 1 tolerates this, but stricter package managers validatebintargets when linking workspace packages, so abinpointing at a not-yet-built path breaksinstall. Committing a stable top-level launcher that lazilyrequires the bundle makes thebintarget always present — before any build — and removes a build-time copy step.This is a prerequisite for #170.
Approach:
packages/cdktn-cli/bin/cdktn—#!/usr/bin/env node+require("../bundle/bin/cdktn.js"). Thebinfield inpackage.jsonnow points here (bin/cdktn) instead ofbundle/bin/cdktn.src/bin/cdktnand drop thefs.copySync("src/bin/cdktn", "./bundle/bin/cdktn")step frombuild.ts— the launcher is no longer generated as build output.build-config/:compile-build-confignow runstsc build.ts --outDir build-config, andpostbuild/watchinvokenode build-config/build.js. Keeps a stray compiledbuild.jsout of the package root;build-configis added to.gitignore.package.json:convert.test.tsandinit.test.tsnow readcdktnCliPkg.bin.cdktnand resolve it against the package root, rather than hardcodingbundle/bin/cdktn— one source of truth that tracks thebinfield.let t: numberin the rebuild-log plugin: also a consequence of (3) — compilingbuild.tsnow type-checks it, and the barelet t;lefttimplicitlyany. The annotation makesDate.now() - twell-typed.build.tsto knip's cdktn-clientrylist: also a consequence of (3) — knip can no longer traceesbuildthroughpostbuild(now a gitignoredbuild-config/build.js) and flags it unused. Listingbuild.tsmakes knip parse theimport * as esbuilddirectly.Checklist