-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utility to query Snaps for conditions. #520
Conversation
.eslintrc.js
Outdated
@@ -32,5 +32,6 @@ module.exports = { | |||
'dist/', | |||
'docs/', | |||
'.yarn/', | |||
'scripts/query/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Query uses fs
, path
and process
to manage local file writes, reads and env vars.
This violates the eslint rules. So we can either relax the eslint rules or we can ignore it for the Query files.
Please let me know if there is another option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change
files: ['*.js', 'scripts/*.ts'],
to
files: ['*.js', 'scripts/**/*.ts'],
a little further up in the config, and remove this line, most of the lint errors will be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
Fixed as per your suggestion. 👍
Co-authored-by: Maarten Zuidhoorn <[email protected]>
…registry into query-snaps-util
scripts/query/get-manifests.ts
Outdated
); | ||
|
||
const location = detectSnapLocation(snap.id, { | ||
versionRange: latestVersion as any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this type cast necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
scripts/query/query.ts
Outdated
@@ -0,0 +1,41 @@ | |||
import type { SnapManifest } from '@metamask/snaps-utils'; | |||
import fs from 'fs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you import from fs/promises
, you can just use fs.readFile
instead of fs.promises.readFile
.
import fs from 'fs'; | |
import fs from 'fs/promises'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Co-authored-by: Maarten Zuidhoorn <[email protected]>
Co-authored-by: Maarten Zuidhoorn <[email protected]>
This PR is for a Snap Query Utility.
Occasionally we have the need to query for Snaps that meet a condition or criteria - the main use-case being notifying a Snap Builder of an upcoming change or other reason.
The PR has 2 code files:
get-manifests.ts
: The code in this file is used to download the manifest files of all Snaps. This will get called the first time or when a refresh of the manifests are needed. All the Snap manifests are then saved to a local JSON file (./data.json
). Local storage is to avoid fetching Snap manifests every time we need to run a query.query.ts
: This file contains the query logic that we are interested in, and works on the./data.json
file.Usage: