-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(agoric-cli): Fully generalize package name extractor from zip fil…
…es (#9669) ## Description Following #9667 we learn that the bundle analyzer needs to understand exotic package names that include `-dev$hash` and such. To that end, this change fully generalizes the package name detector based on the `@` prefix distinguishing a package name with two path components. ### Security Considerations None. ### Scaling Considerations None. ### Documentation Considerations None. ### Testing Considerations None. ### Upgrade Considerations None.
- Loading branch information
Showing
2 changed files
with
42 additions
and
2 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
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,39 @@ | ||
import test from 'ava'; | ||
import { PACKAGE_NAME_RE } from '../src/lib/bundles.js'; | ||
|
||
const goodPatterns = [ | ||
['@agoric/assert-v0.6.0'], | ||
['@agoric/base-zone-v0.1.0/', '@agoric/base-zone-v0.1.0'], | ||
['@endo/base64-v1.0.5-n1/index.js', '@endo/base64-v1.0.5-n1'], | ||
['@endo/base64-v1.0.5-n1/decode.js', '@endo/base64-v1.0.5-n1'], | ||
[ | ||
'@agoric/store-v0.9.3-dev-37ec151.0+37ec151/src/legacy/legacyWeakMap.js', | ||
'@agoric/store-v0.9.3-dev-37ec151.0+37ec151', | ||
], | ||
[ | ||
'calypso-contract-v0.1.0/src/proposals/core-proposal.js', | ||
'calypso-contract-v0.1.0', | ||
], | ||
['/index.js', undefined], | ||
['/src', undefined], | ||
]; | ||
|
||
test('simple positive', t => { | ||
for (const pattern of goodPatterns) { | ||
const name = pattern[0]; | ||
const expected = pattern.length === 2 ? pattern[1] : pattern[0]; | ||
|
||
t.is(name.match(PACKAGE_NAME_RE)?.[0], expected); | ||
} | ||
}); | ||
|
||
const badPatterns = [ | ||
'/user/name/sdk/node_modules/@agoric/assert-v0.6.0', | ||
'/random/@agoric/base-zone-v0.1.0/', | ||
]; | ||
|
||
test('simple negative', t => { | ||
for (const pattern of badPatterns) { | ||
t.falsy(pattern.match(PACKAGE_NAME_RE)?.[0], `expected ${pattern} to fail`); | ||
} | ||
}); |