Skip to content

Commit

Permalink
Update dependency algoliasearch to v5 (#566)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Karl Horky <karl.horky@gmail.com>
  • Loading branch information
renovate[bot] and karlhorky authored Aug 15, 2024
1 parent 71acfaf commit ba89fdf
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 125 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"dependencies": {
"@types/eslint": "9.6.0",
"algoliasearch": "4.24.0",
"algoliasearch": "5.0.0",
"chalk": "5.3.0",
"cheerio": "1.0.0-rc.12",
"depcheck": "1.4.7",
Expand Down
183 changes: 64 additions & 119 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/checks/noDependencyProblems/noDependenciesWithoutTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync, promises as fs } from 'node:fs';
import algoliasearch from 'algoliasearch';
import { algoliasearch } from 'algoliasearch';
import pReduce from 'p-reduce';
import { commandExample } from '../../util/commandExample';
import { projectPackageJson } from '../../util/packageJson';
Expand All @@ -11,7 +11,6 @@ const client = algoliasearch(
'OFCNCOG2CU', // Application ID
'ec73550aa8b2936dab436d4e02144784', // API Key
);
const index = client.initIndex('npm-search');

interface AlgoliaObj {
types?: {
Expand Down Expand Up @@ -64,11 +63,13 @@ export default async function noDependenciesWithoutTypes() {
let results: AlgoliaObj;

try {
results = await index.getObject<AlgoliaObj>(dependency, {
results = (await client.getObject({
indexName: 'npm-search',
objectID: dependency,
attributesToRetrieve: ['types'],
});
})) as AlgoliaObj;
} catch (error) {
// Show dependency name if Algolia's `index.getObject()` throws with an
// Show dependency name if Algolia's `client.getObject()` throws with an
// error message (such as the error message "ObjectID does not exist"
// when a package cannot be found in the index)
throw new Error(
Expand Down

0 comments on commit ba89fdf

Please sign in to comment.