Skip to content

Commit

Permalink
bug/issue 1349 handle false positive package.json files in packages w…
Browse files Browse the repository at this point in the history
…hen running walker package ranger (#1356)
  • Loading branch information
thescientist13 authored Dec 28, 2024
1 parent bda129f commit 95d8613
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"lit": "^3.1.0",
"lit-redux-router": "~0.20.0",
"lodash-es": "^4.17.20",
"luxon": "^3.5.0",
"postcss-nested": "^4.1.2",
"pwa-helpers": "^0.9.1",
"redux": "^5.0.1",
Expand Down
12 changes: 10 additions & 2 deletions packages/cli/src/lib/walker-package-ranger.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function resolveBareSpecifier(specifier) {
* {
* dependencyName: 'lit-html',
* resolved: 'file:///path/to/project/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/lit-html/node/lit-html.js',
* root: 'file:///path/to/project/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/lit-html/package.json'
* root: 'file:///path/to/project/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/lit-html/
* }
*/
function derivePackageRoot(resolved) {
Expand All @@ -52,7 +52,15 @@ function derivePackageRoot(resolved) {

for (const segment of segments.slice(1)) {
if (fs.existsSync(new URL('./package.json', root))) {
break;
// we have to check that this package.json actually has as a name AND version
// https://github.com/moment/luxon/issues/1543#issuecomment-2546858540
// https://github.com/ProjectEvergreen/greenwood/issues/1349
const resolvedPackageJson = JSON.parse(fs.readFileSync(new URL('./package.json', root), 'utf-8'));
const { name, version } = resolvedPackageJson;

if (name && version) {
break;
}
}

root = root.replace(`${segment}/`, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4149,5 +4149,7 @@
"binary-extensions": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/binary-extensions/index.js",
"readdirp": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/readdirp/index.js",
"immutable": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/immutable/dist/immutable.es.js",
"source-map-js": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/source-map-js/source-map.js"
"source-map-js": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/source-map-js/source-map.js",
"luxon": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/luxon/src/luxon.js",
"luxon/package.json": "/~/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/luxon/package.json"
}
3 changes: 2 additions & 1 deletion packages/cli/test/cases/develop.default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@spectrum-css/card": "^9.3.0",
"@spectrum-web-components/action-menu": "^1.0.1",
"@uswds/web-components": "^0.0.1-alpha",
"lit": "^3.1.0"
"lit": "^3.1.0",
"luxon": "^3.5.0"
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11918,6 +11918,11 @@ luxon@^3.2.1:
resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.3.0.tgz#d73ab5b5d2b49a461c47cedbc7e73309b4805b48"
integrity sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==

luxon@^3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.5.0.tgz#6b6f65c5cd1d61d1fd19dbf07ee87a50bf4b8e20"
integrity sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==

macos-release@^2.2.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.4.1.tgz#64033d0ec6a5e6375155a74b1a1eba8e509820ac"
Expand Down

0 comments on commit 95d8613

Please sign in to comment.