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

fix(cli): do not throw during migrate if project ID is passed through flag #7594

Merged
merged 2 commits into from
Oct 5, 2024

Conversation

ryanbonial
Copy link
Contributor

@ryanbonial ryanbonial commented Oct 4, 2024

Description

This PR sets the apiClient's requireProject to false and instead only throws an error if both the cli config and the --project option are missing

What to review

Verify that the change is as expected and that the wording of the error is correct.

Testing

  • create a simple migration script with sanity, sanity migration create and follow the prompt
    make sure there is no sanity.cli.js in your codebase

Next steps:

  • Open /code/migrations/migration_id/index.ts in your code editor and write the code for your migration.

  • Dry run the migration with:
    sanity migration run migration_id --project= --dataset

  • Run the migration against a dataset with:
    sanity migration run migration_id --project= --dataset --no-dry-run

  • edit the script and run it as:
    sanity migration run migration_id --project=real_project_id --dataset real_dataset

you should NOT get an error.

Test again without specifying a --project project ID, you should see an error.

Notes for release

None

@ryanbonial ryanbonial requested review from a team as code owners October 4, 2024 20:17
@ryanbonial ryanbonial requested review from rexxars and removed request for a team October 4, 2024 20:17
Copy link

vercel bot commented Oct 4, 2024

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

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 2:27pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 2:27pm
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 2:27pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 2:27pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 2:27pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Oct 5, 2024 2:27pm

…the --project option instead of the cli config
@ryanbonial ryanbonial changed the title Fix (CLI): Do not throw an error during migrate if the project ID is passed via the --project option instead of the cli config fix (CLI): Do not throw an error during migrate if the project ID is passed via the --project option instead of the cli config Oct 4, 2024
Copy link
Contributor

github-actions bot commented Oct 4, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented Oct 4, 2024

Component Testing Report Updated Oct 5, 2024 2:25 PM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 44s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 39s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 3m 0s 0 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 45s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 41s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 16s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 9s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 26s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 35s 12 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

@@ -164,9 +164,15 @@ const runMigrationCommand: CliCommandDefinition<CreateFlags> = {

const projectConfig = apiClient({
requireUser: true,
requireProject: true,
requireProject: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left this in as false instead of removing it so that it would indicate that false is intended here.

Copy link
Contributor

github-actions bot commented Oct 4, 2024

⚡️ Editor Performance Report

Updated Sat, 05 Oct 2024 14:37:11 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 16.4 efps (61ms) 16.4 efps (61ms) +0ms (-/-%)
article (body) 56.8 efps (18ms) 50.9 efps (20ms) +2ms (+11.6%)
article (string inside object) 18.3 efps (55ms) 17.2 efps (58ms) +4ms (+6.4%)
article (string inside array) 14.3 efps (70ms) 14.4 efps (70ms) -1ms (-0.7%)
recipe (name) 29.4 efps (34ms) 29.9 efps (34ms) -1ms (-1.5%)
recipe (description) 33.3 efps (30ms) 33.3 efps (30ms) +0ms (-/-%)
recipe (instructions) 99.9+ efps (7ms) 99.9+ efps (7ms) +0ms (-/-%)
synthetic (title) 14.2 efps (71ms) 14.3 efps (70ms) -1ms (-0.7%)
synthetic (string inside object) 14.9 efps (67ms) 15.0 efps (67ms) -1ms (-0.7%)

efps — editor "frames per second". The number of updates assumed to be possible within a second.

Derived from input latency. efps = 1000 / input_latency

Detailed information

🏠 Reference result

The performance result of sanity@latest

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 61ms 70ms 82ms 255ms 1396ms 14.3s
article (body) 18ms 20ms 27ms 171ms 333ms 6.0s
article (string inside object) 55ms 56ms 62ms 131ms 962ms 8.8s
article (string inside array) 70ms 74ms 85ms 217ms 1934ms 10.3s
recipe (name) 34ms 36ms 40ms 71ms 45ms 9.7s
recipe (description) 30ms 32ms 37ms 62ms 42ms 6.3s
recipe (instructions) 7ms 8ms 9ms 32ms 0ms 3.4s
synthetic (title) 71ms 76ms 82ms 348ms 2261ms 17.3s
synthetic (string inside object) 67ms 70ms 74ms 292ms 1887ms 10.4s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 61ms 68ms 117ms 225ms 1324ms 14.8s
article (body) 20ms 21ms 46ms 232ms 344ms 6.2s
article (string inside object) 58ms 63ms 79ms 196ms 1236ms 9.4s
article (string inside array) 70ms 74ms 83ms 223ms 1839ms 10.1s
recipe (name) 34ms 37ms 42ms 83ms 62ms 9.7s
recipe (description) 30ms 32ms 38ms 72ms 29ms 6.4s
recipe (instructions) 7ms 9ms 10ms 21ms 0ms 3.4s
synthetic (title) 70ms 73ms 84ms 331ms 2277ms 17.5s
synthetic (string inside object) 67ms 69ms 72ms 283ms 1926ms 10.2s

📚 Glossary

column definitions

  • benchmark — the name of the test, e.g. "article", followed by the label of the field being measured, e.g. "(title)".
  • latency — the time between when a key was pressed and when it was rendered. derived from a set of samples. the median (p50) is shown to show the most common latency.
  • p75 — the 75th percentile of the input latency in the test run. 75% of the sampled inputs in this benchmark were processed faster than this value. this provides insight into the upper range of typical performance.
  • p90 — the 90th percentile of the input latency in the test run. 90% of the sampled inputs were faster than this. this metric helps identify slower interactions that occurred less frequently during the benchmark.
  • p99 — the 99th percentile of the input latency in the test run. only 1% of sampled inputs were slower than this. this represents the worst-case scenarios encountered during the benchmark, useful for identifying potential performance outliers.
  • blocking time — the total time during which the main thread was blocked, preventing user input and UI updates. this metric helps identify performance bottlenecks that may cause the interface to feel unresponsive.
  • test duration — how long the test run took to complete.

@rexxars rexxars changed the title fix (CLI): Do not throw an error during migrate if the project ID is passed via the --project option instead of the cli config fix(cli): do not throw during migrate if project ID is passed through flag Oct 5, 2024
Co-authored-by: Espen Hovlandsdal <[email protected]>
@ryanbonial ryanbonial added this pull request to the merge queue Oct 5, 2024
Merged via the queue into next with commit caced3b Oct 5, 2024
63 checks passed
@ryanbonial ryanbonial deleted the SDK-6 branch October 5, 2024 15:12
bjoerge pushed a commit that referenced this pull request Oct 7, 2024
… flag (#7594)

### Description

This PR sets the `apiClient`'s `requireProject` to `false` and instead
only throws an error if both the cli config and the `--project` option
are missing

### What to review

Verify that the change is as expected and that the wording of the error
is correct.

### Testing
* create a simple migration script with sanity, `sanity migration
create` and follow the prompt
make sure there is no `sanity.cli.js` in your codebase

Next steps:
* Open /code/migrations/migration_id/index.ts in your code editor and
write the code for your migration.
* Dry run the migration with:
`sanity migration run migration_id --project= --dataset`
* Run the migration against a dataset with:
`sanity migration run migration_id --project= --dataset --no-dry-run`

* edit the script and run it as:
`sanity migration run migration_id --project=real_project_id --dataset
real_dataset`

you should NOT get an error. 

Test again without specifying a `--project` project ID, you should see
an error.

### Notes for release
None
<!--
Engineers do not need to worry about the final copy,
but they must provide the docs team with enough context on:

* What changed
* How does one use it (code snippets, etc)
* Are there limitations we should be aware of

If this is PR is a partial implementation of a feature and is not
enabled by default or if
this PR does not contain changes that needs mention in the release notes
(tooling chores etc),
please call this out explicitly by writing "Part of feature X" or "Not
required" in this section.
-->

---------

Co-authored-by: Espen Hovlandsdal <[email protected]>
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.

2 participants