From 2874ecf5fc4cfcf9e3b4ccb9dd3219b04212e810 Mon Sep 17 00:00:00 2001 From: RheeseyB <1044774+Rheeseyb@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:32:09 +0100 Subject: [PATCH] Fix an issue with updatePackageJsonInEditorState (#6333) **Problem:** `updatePackageJsonInEditorState` was providing incorrect arguments to the `codeFile` factory function when updating the package.json file. **Fix:** Fix it. **Side note:** IMO the `codeFile` function should always be `RevisionsState.CodeAheadButPleaseTellVSCodeAboutIt` by default, since it is typically used as a convenient way to create a new `TextFile` from the design side of Utopia. However, I tried making that change and it broke far too much of the editor, somehow resulting in the project contents being entirely wiped, so I'd rather just leave it be for the moment. **Manual Tests:** I hereby swear that: - [x] I opened a hydrogen project and it loaded - [x] I could navigate to various routes in Preview mode Fixes #6328 --- editor/src/components/editor/store/editor-state.ts | 5 ++++- editor/src/components/editor/store/editor-update.spec.tsx | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/editor/src/components/editor/store/editor-state.ts b/editor/src/components/editor/store/editor-state.ts index b874154f03d2..aa3231f356da 100644 --- a/editor/src/components/editor/store/editor-state.ts +++ b/editor/src/components/editor/store/editor-state.ts @@ -3278,14 +3278,17 @@ export function updatePackageJsonInEditorState( // There is a package.json file, we should update it. updatedPackageJsonFile = codeFile( transformPackageJson(packageJsonFile.fileContents.code), - RevisionsState.CodeAhead, + null, packageJsonFile.versionNumber + 1, + RevisionsState.CodeAheadButPleaseTellVSCodeAboutIt, ) } else { // There is something else called package.json, we should bulldoze over it. updatedPackageJsonFile = codeFile( transformPackageJson(JSON.stringify(DefaultPackageJson)), null, + 0, + RevisionsState.CodeAheadButPleaseTellVSCodeAboutIt, ) } } diff --git a/editor/src/components/editor/store/editor-update.spec.tsx b/editor/src/components/editor/store/editor-update.spec.tsx index 62d35e4ec115..855542efe4d1 100644 --- a/editor/src/components/editor/store/editor-update.spec.tsx +++ b/editor/src/components/editor/store/editor-update.spec.tsx @@ -1030,7 +1030,7 @@ describe('updating package.json', () => { "parsed": Object { "type": "UNPARSED", }, - "revisionsState": "CODE_AHEAD", + "revisionsState": "CODE_AHEAD_BUT_PLEASE_TELL_VSCODE_ABOUT_IT", } `) }