feat: add JavaScript/JSX asset handler#370
Conversation
lrasmus
left a comment
There was a problem hiding this comment.
The code looks good - I have a few requests for additional unit tests. The code appears to handle these scenarios, I just want to ensure we have test cases to show they work.
lrasmus
left a comment
There was a problem hiding this comment.
Wonderful job with all the new added tests - it uncovered something I hadn't detected in code review. Please see the note about one of the tests currently failing, and let me know if you're seeing something different on your end.
|
the require regex was missing the ^[^/]*? guard that the import regexes had. Fixed that, and also corrected the Windows path test to use single backslashes. All 31 tests passing now. |
lrasmus
left a comment
There was a problem hiding this comment.
Perfect, thank you SO much for this implementation, and for the quick changes on the unit tests!
Summary
Adds a
JavaScriptHandlerto detect libraries, inputs, and outputs in JavaScript files, closing #362.Files changed:
app/services/assets/handlers/javascript.js— new handler supporting.js,.jsx,.mjs,.cjsfilesapp/constants/assets-config.js— registers JavaScript extensionsapp/preload.js— instantiatesJavaScriptHandlerapp/utils/workflow.js— registers handler ingetAssetType,getAllDependencies,getLibraryDependenciesapp/images/js.svg— JavaScript icon for the dependency graphapp/components/Workflow/DependencyGraph/CustomNodes/Code/CodeNode.js— icon entry for JS nodesapp/components/Workflow/DependencyGraph/DependencyGraphEChart.js— icon entry for JS nodesdocs/Assets.md— documents what the handler detectstest/services/assets/handlers/javascript.spec.js— 20 unit tests for the handlertest/services/assets/asset.spec.js— extension detection teststest/utils/workflow.spec.js— dependency and asset type testsDetection coverage:
import x from 'y', named, namespace, side-effect) and CommonJSrequire('y')fs.readFileSync,fs.readFile,fs.createReadStreamfs.writeFileSync,fs.writeFile,fs.appendFile,fs.appendFileSync,fs.createWriteStream