-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: add support for ignoring filepaths via micromatch globs #28
feature: add support for ignoring filepaths via micromatch globs #28
Conversation
960f6fd
to
3c64a7e
Compare
@@ -1,15 +1,18 @@ | |||
import fs from "fs"; | |||
import * as nodePath from 'path'; |
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.
Named nodePath
to avoid colliding with the existing usage of path
as a variable name.
@@ -18,19 +18,33 @@ Default: diagram.svg | |||
|
|||
## `excluded_paths` | |||
|
|||
A list of paths to exclude from the diagram, separated by commas. | |||
A list of paths to folders to exclude from the diagram, separated by commas. |
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.
Technically this also worked for paths but only if they were immediate children of root_dir
(this is why package.json
worked, but src/package.json
did not. Rather than explain this nuance, I think it'll be simpler to just only use this config for folders, and nudge people towards mostly using globs instead.
}, | ||
"dependencies": { | ||
"@actions/core": "^1.4.0", | ||
"@actions/exec": "^1.1.0", | ||
"d3": "^7.0.0", | ||
"esbuild": "^0.12.15", | ||
"husky": "^7.0.1", |
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.
I figured it was probably a typo to have 2 versions of the same library.
@@ -0,0 +1,19 @@ | |||
{ | |||
"compilerOptions": { |
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 is trimmed down from the defaults provided by tsc --init
, and was included for the benefit of the test-runner.
tsconfig.json
Outdated
|
||
/* Strict Type-Checking Options */ | ||
"strict": true, /* Enable all strict type-checking options. */ |
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 was too strict, having all of these on was catching 100s of errors.
@@ -22,14 +22,19 @@ const main = async () => { | |||
core.endGroup() | |||
|
|||
|
|||
const rootPath = core.getInput("root_path") || "./"; | |||
const rootPath = core.getInput("root_path") || ""; // Micro and minimatch do not support paths starting with ./ |
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.
we might want to also remove any leading ./
params, to prevent from breaking existing workflows
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.
I thought about this - what do you think about a choice between
- Quitting the script early if the path starts with
./
and asking the user to remove it - Quietly removing it if it's detected
I think doing 2 automatically is a smoother migration because it introduces a quiet side effect, but 1 is simpler for us to maintain. Otherwise, people may get confused when seeing some configs start with ./
and some without.
this is wonderful @hydrosquall, thanks for digging in here! One question: what's your reasoning behind having |
Hi, thank you! I had a few reasons for going with this
With all of that said, I would be in favor of using the glob param, assuming that
|
src/process-dir.js
Outdated
const children = []; | ||
|
||
for (const fileOrFolder of filesOrFolders) { | ||
const fullPath = nodePath.join(rootPath, fileOrFolder); |
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.
I think rootPath
needs to be path
, to include the parents recursively?
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.
You're absolutely right, that was a bug :)
I did some testing and made some small tweaks when running into bugs. It works, but ignores folders - I'm thinking because of the comment above. FYI you can test the Action by pointing it at any repo@branch: |
Thanks for fixing the yaml / repo-visualizer/src/process-dir.js Line 39 in 7916b59
Also, thanks for the tip about how to test github actions - I will use this to try out dev builds going forward. |
Wonderful, all looks great! Thanks! |
Motivation
minimatch
/micromatch
glob. You can debug/test the format hereChanges
excluded_paths
is Sort of Not Working #27 with a newexcluded_globs
option. Note that this can technically be used instead ofexcluded_paths
, but I didn't want to break anyone's existing workflow by modifying an existing option.;
as a delimiter since,
can show up in globs, and because github actions does not support arrayspath.join()
so that this will work on WindowsTesting
CONTRIBUTING.md
is a good one for the long term.index.js
was supposed to get checked into the repo, or gitignored, but recent PRs seem to be updating it so I left it as-is.Notes
minimatch
,micromatch
,picomatch
, andnanomatch
.nanomatch
was the only one that worked with the leading./
(minimatch, micromatch), but it was last updated in 2018, is not as performant, and is not as full featured as micromatch.relative paths
, since repositories shouldn't be ever trying to access parent directories, I think we'd rather use a more popular globbing library than use