Skip to content

Commit

Permalink
Merge pull request #117 from lishaduck/fix-monorepos
Browse files Browse the repository at this point in the history
Fix monorepos including projects with unpublished npm package names 🤣
  • Loading branch information
jeffijoe committed Jul 17, 2024
2 parents 0aa02b3 + 3451dd2 commit 7aecb96
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ module.exports = {
// and coming up with clever typings may break for consumers.
'@typescript-eslint/no-explicit-any': 'off',
// We use `require` for loading the `package.json` file.
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-var-requires': [
'error',
{ allow: ['/package\\.json$'] },
],
},
},
// Tests
Expand Down
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
"node_modules": true,
"coverage": true,
"lib": true
}
},
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.useFlatConfig": false
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@
"tsx",
"js"
]
}
},
"packageManager": "[email protected]"
}
18 changes: 8 additions & 10 deletions src/package-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ export function createPackageSource(): IPackageSource {
* Fetches info about a package, or `null` if not found.
*/
fetch: async (name) => {
const response = await fetch(encodeURIComponent(name)).catch(
(err: any) => {
if (err.statusCode === 404) {
return null
}
const response = await fetch(encodeURI(name)).catch((err: any) => {
if (err.statusCode === 404) {
return null
}

/* istanbul ignore next */
throw err
},
)
/* istanbul ignore next */
throw err
})

const data = await response?.json()

if (!data) {
if (!data?.versions) {
return null
}

Expand Down
2 changes: 0 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function shrinkObject<T extends object>(source: T): Required<T> {
const object: any = {}

for (const key in source) {
// tslint:disable-next-line
if (typeof source[key] !== 'undefined') {
object[key] = source[key]
}
Expand Down Expand Up @@ -193,7 +192,6 @@ export function ensureWorkspacesArray(
return ensureWorkspacesArray(data.packages)
}

// tslint:disable-next-line
if (!data.every((s) => typeof s === 'string')) {
return []
}
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"compileOnSave": false,
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"module": "Node16",
"moduleResolution": "Node16",
"target": "es2021",
"outDir": "lib",
"strict": true,
"esModuleInterop": true,
"noImplicitAny": true,
"skipLibCheck": true,
"lib": ["es2016"]
"lib": ["es2021"]
}
}

0 comments on commit 7aecb96

Please sign in to comment.