This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Improve UX: Support glob patterns in triple-slash comment #27
Open
YiranJing
wants to merge
4
commits into
canva-public:main
Choose a base branch
from
YiranJing:yiran-add-glob-pattern-directive
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Improve UX: Support glob patterns in triple-slash comment #27
YiranJing
wants to merge
4
commits into
canva-public:main
from
YiranJing:yiran-add-glob-pattern-directive
Conversation
This file contains 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
YiranJing
commented
Dec 3, 2022
Comment on lines
+94
to
+127
#### Example | ||
|
||
```bash | ||
root_dir/ | ||
|- index.js | ||
|- dep1.sh | ||
|- util.ts | ||
|- dir1/ | ||
|- dep5.py | ||
|- dir2/ | ||
|- dep6.md | ||
``` | ||
|
||
```typescript | ||
// root_dir/util.ts | ||
|
||
/// <dependency-tree depends-on="./dep1.sh" /> | ||
///<dependency-tree depends-on="./dir1/**/*" /> | ||
``` | ||
|
||
```typescript | ||
// index.js | ||
const dependencyTree = new DependencyTree(['root_dir']); | ||
const result = await dependencyTree.gather(); | ||
const dependencies = result.resolved; | ||
//{ | ||
// "root_dir/util.ts" => Set { | ||
// "root_dir/dep1.sh", | ||
// "root_dir/dir1/dep5.py", | ||
// "root_dir/dir1/dir2/dep6.md", | ||
// }, | ||
//} | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the readme with a complete example. (make it easier for new users to understand)
YiranJing
commented
Dec 3, 2022
Comment on lines
-168
to
+184
dependencyTree.transformReference(dependsOn, file), | ||
transformReference(dependsOn, file), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will block user provide their own custom transformReference
function.
🤔 but I don't think users need an extra transformer for the depend-on=xxx
scenario.
YiranJing
changed the title
Support default glob patterns in triple-slash comment
Improve UX: Support default glob patterns in triple-slash comment
Dec 3, 2022
YiranJing
changed the title
Improve UX: Support default glob patterns in triple-slash comment
Improve UX: Support glob patterns in triple-slash comment
Dec 3, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Motivation
The dependency-tree's directive can be the whole folder, not just the single file.
To detect the folder dependency, we want the glob patterns can be used in the triple-slash comment like
/// <dependency-tree depends-on="../../../../tools/build/python/lib/logs/**/*" />
The problem
The glob patterns detection isn't supported by default. To use it, users have to explicitly providing
ReferenceTransformFn
like https://github.com/Canva/canva/pull/325312/commits/0190fcbf2796c6b3bd9984d839683400eeb595f4, which isn't good user experience.Solution
Add a reference transformer as an automatic glob pattern detection.