Skip to content

Commit

Permalink
Fix an issue with updatePackageJsonInEditorState (#6333)
Browse files Browse the repository at this point in the history
**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
  • Loading branch information
Rheeseyb authored and liady committed Dec 13, 2024
1 parent bd5fcce commit 2874ecf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion editor/src/components/editor/store/editor-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion editor/src/components/editor/store/editor-update.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ describe('updating package.json', () => {
"parsed": Object {
"type": "UNPARSED",
},
"revisionsState": "CODE_AHEAD",
"revisionsState": "CODE_AHEAD_BUT_PLEASE_TELL_VSCODE_ABOUT_IT",
}
`)
}
Expand Down

0 comments on commit 2874ecf

Please sign in to comment.