Skip to content
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

feat(codegen): add groq finder methods. #5980

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

sgulseth
Copy link
Member

@sgulseth sgulseth commented Mar 12, 2024

Description

This PR adds babel runtime capabilities to scan a given source file for groq queries.
It checks for GROQ tagged template literal that's assigned to a variable, and tries to extract the value. It tries to follow variable references through resolving file local variables, but also imports/exports.

What to review

  • Correctness: Are we missing any critical functionality when parsing the source?
  • Code quality: This has been a long running branch. Any suggestion on improving quality of life for the code is very welcome!

Testing

We've added the tests for the most expected code paths, but more suggestions are also welcome.
We don't test the custom resolver now, as it's deemed best effort...

Notes for release

N/A - No notes needed.

Copy link

vercel bot commented Mar 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Mar 19, 2024 3:07pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 3:07pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Mar 19, 2024 3:07pm

@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_codegen_skeleton_package branch from 95449ab to aaa72e0 Compare March 12, 2024 14:20
Copy link
Contributor

github-actions bot commented Mar 12, 2024

Package Documentation Change
@sanity/codegen +Infinity%
Full Report
@sanity/codegen
This branch Next branch
3 documented 0 documented
0 not documented 1 not documented
@sanity/migrate
This branch Next branch
17 documented 17 documented
70 not documented 59 not documented
sanity
This branch Next branch
179 documented 179 documented
860 not documented 875 not documented
@sanity/diff
This branch Next branch
13 documented 13 documented
16 not documented 16 not documented
@sanity/block-tools
This branch Next branch
4 documented 4 documented
9 not documented 9 not documented
@sanity/types
This branch Next branch
55 documented 55 documented
234 not documented 240 not documented
sanity/desk
This branch Next branch
84 documented 84 documented
64 not documented 64 not documented
@sanity/portable-text-editor
This branch Next branch
23 documented 23 documented
44 not documented 44 not documented
@sanity/mutator
This branch Next branch
7 documented 7 documented
4 not documented 4 not documented
@sanity/cli
This branch Next branch
1 documented 1 documented
31 not documented 31 not documented
sanity/structure
This branch Next branch
2 documented 2 documented
8 not documented 8 not documented
@sanity/util/concurrency-limiter
This branch Next branch
1 documented 1 documented
0 not documented 0 not documented
@sanity/util/legacyDateFormat
This branch Next branch
0 documented 0 documented
4 not documented 5 not documented
@sanity/schema/_internal
This branch Next branch
0 documented 0 documented
13 not documented 13 not documented
@sanity/util/paths
This branch Next branch
1 documented 1 documented
15 not documented 15 not documented
sanity/router
This branch Next branch
17 documented 17 documented
26 not documented 26 not documented
@sanity/schema
This branch Next branch
0 documented 0 documented
2 not documented 2 not documented
sanity/cli
This branch Next branch
2 documented 2 documented
0 not documented 0 not documented
@sanity/vision
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
@sanity/util/fs
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
sanity/_internal
This branch Next branch
0 documented 0 documented
1 not documented 1 not documented
@sanity/util/client
This branch Next branch
1 documented 1 documented
0 not documented 0 not documented
@sanity/util/createSafeJsonParser
This branch Next branch
1 documented 1 documented
0 not documented 0 not documented
sanity/_internalBrowser
This branch Next branch
0 documented 0 documented
4 not documented 4 not documented
@sanity/util/content
This branch Next branch
1 documented 1 documented
5 not documented 5 not documented

Copy link
Contributor

github-actions bot commented Mar 12, 2024

Component Testing Report Updated Mar 19, 2024 3:10 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 33s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 12s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 32s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 0s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 1s 18 0 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 20s 9 0 0

@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_codegen_skeleton_package branch from aaa72e0 to 2715130 Compare March 12, 2024 14:29
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_groq_finder_methods branch from eebcae8 to e133519 Compare March 12, 2024 14:29
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_codegen_skeleton_package branch from 2715130 to dff8b1b Compare March 12, 2024 14:34
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_groq_finder_methods branch from e133519 to f222a5c Compare March 12, 2024 14:34
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_codegen_skeleton_package branch from dff8b1b to 030c196 Compare March 12, 2024 18:14
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_groq_finder_methods branch from f222a5c to 16f66a4 Compare March 12, 2024 18:14
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_codegen_skeleton_package branch from 030c196 to 09ffc07 Compare March 12, 2024 18:42
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_groq_finder_methods branch from 16f66a4 to 3d97029 Compare March 12, 2024 18:43
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_groq_finder_methods branch from 3d97029 to 2f8abf0 Compare March 12, 2024 19:32
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_codegen_skeleton_package branch from 09ffc07 to 3ebeed1 Compare March 12, 2024 19:33
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_groq_finder_methods branch from 2f8abf0 to c245d16 Compare March 12, 2024 19:33
@sgulseth sgulseth marked this pull request as ready for review March 12, 2024 19:42
@sgulseth sgulseth requested a review from a team as a code owner March 12, 2024 19:42
@sgulseth sgulseth removed the request for review from a team March 12, 2024 19:42
)
}

function resolveClass({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did I remember you saying you removed support for classes? Is this the right code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great catch! forgot this one 🙃

@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_codegen_skeleton_package branch from ebb4619 to 6a7b5b0 Compare March 18, 2024 09:44
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_groq_finder_methods branch from c15fbbd to 0d3d984 Compare March 18, 2024 09:44
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_codegen_skeleton_package branch from 6a7b5b0 to f221971 Compare March 18, 2024 21:46
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_groq_finder_methods branch from 0d3d984 to 2a71264 Compare March 18, 2024 21:46
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_codegen_skeleton_package branch from f221971 to f6fc884 Compare March 19, 2024 14:07
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_groq_finder_methods branch from 2a71264 to 0d83227 Compare March 19, 2024 14:07
Base automatically changed from 03-12-feat_codegen_add_codegen_skeleton_package to next March 19, 2024 15:00
Adds methods that parses a js/ts source file and returns all groq queries.

co-authored-by: Tonina Zhelyazkova <[email protected]>
@sgulseth sgulseth force-pushed the 03-12-feat_codegen_add_groq_finder_methods branch from 0d83227 to fbab4df Compare March 19, 2024 15:01
@sgulseth sgulseth added this pull request to the merge queue Mar 19, 2024
Merged via the queue into next with commit 7addeef Mar 19, 2024
41 of 44 checks passed
@sgulseth sgulseth deleted the 03-12-feat_codegen_add_groq_finder_methods branch March 19, 2024 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants