feat(assets): add AssetManager and CDK scaffold templates#1809
feat(assets): add AssetManager and CDK scaffold templates#1809tejaskash wants to merge 2 commits into
Conversation
7a9663a to
15433db
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #1809 +/- ##
============================================
+ Coverage 93.94% 94.03% +0.08%
============================================
Files 122 125 +3
Lines 6462 6555 +93
============================================
+ Hits 6071 6164 +93
Misses 391 391 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Introduce the asset embedding + rendering subsystem: AssetManager renders asset trees from either Bun.embeddedFiles (compiled binary) or the source filesystem (dev/node), applying Handlebars templating with HTML escaping disabled and atomic writes. - src/fs/atomicWrite: central temp-file + rename write util - src/assetManager: AssetManager, types, barrel, tests, snapshot baseline - src/assets/cdk: CDK project scaffold templates (payload, not source) - tsconfig/bunfig/oxlint/prettier: exclude src/assets from all tooling - add handlebars dependency
Remove comment about directory injection for testability.
cafb131 to
356105c
Compare
|
|
||
| You typically don't need to interact with this directory directly. The AgentCore CLI handles synthesis and deployment: | ||
|
|
||
| ```bash |
There was a problem hiding this comment.
Should these commands include the new project prefix?
| }); | ||
| } | ||
|
|
||
| // Create payment infrastructure via CFN constructs |
There was a problem hiding this comment.
for my own understanding, what is special about payments that requires all this special logic?
| "prettier": "^3.4.2", | ||
| "typescript": "~5.9.3" | ||
| }, | ||
| "dependencies": { |
There was a problem hiding this comment.
I think @jesseturner21 has a recent PR that pinned these. Should we be building of that?
| return d; | ||
| } | ||
|
|
||
| test("writes contents and leaves no temp file", async () => { |
There was a problem hiding this comment.
do we think direct tests on atomicWrite are warranted? I believe the pattern so far has been to test as e2e as possible, and avoiding tests that couple to the current implementation. I also see how having these is valuable because there are properties we want to verify here (ex. doesn't leave the temp file behind). Curious to others' thoughts.
| relativePath: string; | ||
| text(): Promise<string>; | ||
| } | ||
| export interface EmbeddedFile { |
There was a problem hiding this comment.
is it worth adding some docstrings here to clarify the difference between an AssetFile and EmbeddedFile? Its not obvious to me atm.
| @@ -0,0 +1,108 @@ | |||
| import Handlebars from "handlebars"; | |||
There was a problem hiding this comment.
should the file name start with lowercase? My understanding was that only react components have upper case file names.
| } | ||
|
|
||
| const resolvedDestination = resolve(destination); | ||
| for (const file of assetFiles) { |
There was a problem hiding this comment.
should we treat the rendering of files as a transaction or is this up to the caller?
| return resolve(moduleDirectory, "../assets"); | ||
| } | ||
|
|
||
| export class AssetManager { |
There was a problem hiding this comment.
does it make sense to decouple template rendering from asset management? I'm wondering if we'll ever want to work with static assets that aren't part of our project templates.
Summary
Introduces the asset embedding + rendering subsystem — the foundation for project scaffolding.
AssetManagerrenders an asset tree from eitherBun.embeddedFiles(compiled standalone binary) or the source filesystem (dev / node distribution), applying Handlebars templating with HTML escaping disabled and writing each file atomically.This is PR 1 of 3 in a stacked series:
AssetManager,atomicWrite, CDK templates, tooling ignoresscripts/build.tsthat bundles/embeds assets (stacks on this)AssetManagerintoFsProjectManager(stacks on this)What's included
src/fs/atomicWrite— central temp-file +renamewrite util so a crashed render never leaves a half-written file behindsrc/assetManager—AssetManager, types, barrel, unit tests, snapshot baselineembeddedFiles.lengthnoEscape(assets are code/config, not HTML)gitignore.template/npmignore.template→.gitignore/.npmignoreon rendersrc/assets/cdk— CDK project scaffold templates (payload copied verbatim to generated projects, not CLI source)src/assetsfrom tsc,bun test, coverage, oxlint, prettier (the templates ship their own*.test.tsdepending on packages the CLI doesn't install)handlebarsdependencyTesting
bun run typecheck— cleanbun test— 266 pass, 1 snapshot