-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for yarn-berry lockfiles (#28)
* Add support for yarn-berry lockfiles * use @yarnpkg/parsers to parse lockfile * Update docs * Update package.json Co-authored-by: Joel Arvidsson <[email protected]> * update lockfile --------- Co-authored-by: Mike Duminy <[email protected]> Co-authored-by: Joel Arvidsson <[email protected]>
- Loading branch information
1 parent
e18680c
commit 5908131
Showing
16 changed files
with
812 additions
and
41 deletions.
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
# Generated files | ||
*.log | ||
node_modules/ | ||
.yarn/ |
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
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
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,46 @@ | ||
/** | ||
* A regular expression for parsing a yarn berry descriptor. | ||
*/ | ||
const PARSE_REGEX = /(^@?[^/]+?\/?[^@/]+?)@(?:.*:)*(.+)/; | ||
|
||
/** | ||
* @typedef {Object} ParsedDescriptor | ||
* @property {string} packageName | ||
* @property {string} version | ||
*/ | ||
|
||
/** | ||
* Parses a yarn descriptor into an object. | ||
* Handles both yarn v1 and yarn berry descriptors. | ||
* | ||
* Supported formats: | ||
* - "package@version" | ||
* - "@scope/package@version" | ||
* - "package@protocol:version" | ||
* - "@scope/package@protocol:version" | ||
* | ||
* Examples: | ||
* - yarn v1: "@material/[email protected]" | ||
* - yarn berry: "@material/ripple@npm:1.0.0" | ||
* | ||
* Both will be parsed to: | ||
* ``` | ||
* { | ||
* package: '@material/ripple', | ||
* version: '1.0.0', | ||
* } | ||
* ``` | ||
* | ||
* @param {string} descriptor - The yarn descriptor to parse. | ||
* @returns {ParsedDescriptor} The parsed descriptor. | ||
*/ | ||
function parseYarnDescriptor(descriptor) { | ||
const result = PARSE_REGEX.exec(descriptor); | ||
if (!result) { | ||
throw new Error(`Unable to parse descriptor: ${descriptor}`); | ||
} | ||
const [, packageName, version] = result; | ||
return { packageName, version }; | ||
} | ||
|
||
module.exports = parseYarnDescriptor; |
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 @@ | ||
nodeLinker: node-modules |
Oops, something went wrong.