-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
fix!: correctly detect if file is outside base path on Windows #59
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2b5a704
fix: correctly detect is file is outside base path on Windows
fasttime 8e3ac11
`toNamespacedPath` fallback to identity, use `process.cwd`, improve c…
fasttime 47386e1
Add generic `toNamespacedPath` polyfill
fasttime efacd06
link to Node.js license
fasttime ad9d95e
select `path` implementations depending on base path
fasttime f47909a
fix for `isDirectoryIgnored` when no base path specified
fasttime 90ed296
simplify selection of path-handling implementations
fasttime f4dd522
download `@std/path` package from tarball URL
fasttime 0cad743
use pre-bundled versions of `@jsr/std__path`
fasttime face4eb
update jsr.json in `config-array`
fasttime ae5b89a
fix unit tests in `compat`
fasttime 6140189
throw an error if a path is not absolute
fasttime c8d62a3
allow relative paths
fasttime ba5056e
don't resolve relative paths in tests
fasttime 6eaced9
default `basePath` to `"/"`
fasttime 6fd825b
revert changes in `compat` tests
fasttime 98efade
use private fields
fasttime 3b90297
resolve paths to `@jsr/std__path` dependency exports
fasttime 882c3ec
use non-capturing group
fasttime 606adcf
fix typos
fasttime ab61572
annotate types of private fields
fasttime d72dd7d
add dot
fasttime 4ed3c1c
disallow empty strings for `basePath`
fasttime 8c30779
update docs
fasttime fb712b1
improve basePath validation
fasttime 949b364
remove unnecessary `async` keword from test functions
fasttime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
package-lock = false | ||
@jsr:registry=https://npm.jsr.io | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Replace import specifiers in "dist" modules to use the bundled versions of "@jsr/std__path". | ||
* | ||
* In "dist/cjs/index.cjs": | ||
* - '@jsr/std__path/posix' → './std__path/posix.cjs' | ||
* - '@jsr/std__path/windows' → './std__path/windows.cjs' | ||
* | ||
* In "dist/esm/index.js": | ||
* - '@jsr/std__path/posix' → './std__path/posix.js' | ||
* - '@jsr/std__path/windows' → './std__path/windows.js' | ||
*/ | ||
|
||
import { readFile, writeFile } from "node:fs/promises"; | ||
|
||
async function replaceInFile(file, search, replacement) { | ||
let text = await readFile(file, "utf-8"); | ||
text = text.replace(search, replacement); | ||
await writeFile(file, text); | ||
} | ||
|
||
const SEARCH_REGEXP = /'@jsr\/std__path\/(.+?)'/gu; | ||
|
||
await Promise.all([ | ||
replaceInFile("dist/cjs/index.cjs", SEARCH_REGEXP, "'./std__path/$1.cjs'"), | ||
replaceInFile("dist/esm/index.js", SEARCH_REGEXP, "'./std__path/$1.js'"), | ||
]); |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { createRequire } from "node:module"; | ||
|
||
const { resolve } = createRequire(import.meta.url); | ||
|
||
export default [ | ||
{ | ||
input: resolve("@jsr/std__path/posix"), | ||
output: [ | ||
{ | ||
file: "./dist/cjs/std__path/posix.cjs", | ||
format: "cjs", | ||
}, | ||
{ | ||
file: "./dist/esm/std__path/posix.js", | ||
format: "esm", | ||
}, | ||
], | ||
}, | ||
{ | ||
input: resolve("@jsr/std__path/windows"), | ||
output: [ | ||
{ | ||
file: "./dist/cjs/std__path/windows.cjs", | ||
format: "cjs", | ||
}, | ||
{ | ||
file: "./dist/esm/std__path/windows.js", | ||
format: "esm", | ||
}, | ||
], | ||
}, | ||
]; |
Oops, something went wrong.
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.
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.
Would end users need to add this to their
.npmrc
files?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've tried using
npm pack
-ed version of config-array from this branch in eslint/eslint, andnpm install
fails 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.
I don't think we can expect users to change their npm settings so that they can download packages from JSR. We could distribute
@std/path
in a separate directory insideconfig-array
and import it from there. Or we could use the URL of the tarball from JSR to specify the dependecy in package.json:Either way, we will lose the magic of the caret
^
to pick newer versions automatically. I checked the JSR docs at https://jsr.io/docs/using-packages but I didn't find any recommendations on how to use their packages with npm apart from registering JSR in .npmrc.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.
Can one of you open an issue on JSR for this? I can't imagine they didn't encounter this before, but before we spin our wheels, it would be nice to verify if we're doing things the right way.
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 opened a discussion here: jsr-io/jsr#701