Skip to content

Commit

Permalink
Was missing some awaits. Also, add checking of root package.json when…
Browse files Browse the repository at this point in the history
… installing packages
  • Loading branch information
arimendelow committed Oct 8, 2024
1 parent c784247 commit e7c3219
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions packages/cli/src/commands/setup/ui/libraries/redwoodui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class RWUIInstallHandler {
'web/src/lib/uiUtils.ts',
)) as string

this._addFileAndInstallPackages(
await this._addFileAndInstallPackages(
task,
rwuiUtilsContent,
projectRWUIUtilsPath,
Expand Down Expand Up @@ -601,12 +601,12 @@ class RWUIInstallHandler {
return
}

this._addFileAndInstallPackages(
await this._addFileAndInstallPackages(
task,
newSBMainContent,
this.projectStorybookMainPath as string,
)
this._addFileAndInstallPackages(
await this._addFileAndInstallPackages(
task,
newSBPreviewContent,
this.projectStorybookPreviewPath || 'web/.storybook/preview.ts',
Expand Down Expand Up @@ -728,15 +728,24 @@ class RWUIInstallHandler {
return // skip to next iteration
}

// ARI YOU ARE HERE:
// - also look in root package.json for installed packages
// - figure out why the dev dep packages aren't being installed
const projectPackageJsonPath = path.join(
// Even though RWUI should only use dependencies in web/package.json,
// we still want to check the root one of the project just in case something
// was previously installed that way.
// Also, we do want to run this on every file because of possible shared dependencies between files
// (aka, the project's package.json files are subject to change).
const projectRootPackageJsonPath = path.join(
this.rwPaths.base,
'package.json',
)
const projectWebPackageJsonPath = path.join(
this.rwPaths.web.base,
'package.json',
)
const projectPackageJson = JSON.parse(
fs.readFileSync(projectPackageJsonPath, 'utf-8'),
const projectRootPackageJson = JSON.parse(
fs.readFileSync(projectRootPackageJsonPath, 'utf-8'),
)
const projectWebPackageJson = JSON.parse(
fs.readFileSync(projectWebPackageJsonPath, 'utf-8'),
)

const getMajorVersion = (version: string) => {
Expand All @@ -745,8 +754,10 @@ class RWUIInstallHandler {
}

const projectDeps = {
...projectPackageJson.dependencies,
...projectPackageJson.devDependencies,
...projectRootPackageJson.dependencies,
...projectRootPackageJson.devDependencies,
...projectWebPackageJson.dependencies,
...projectWebPackageJson.devDependencies,
}

const projectVersion = projectDeps[matchedPkg]
Expand Down

0 comments on commit e7c3219

Please sign in to comment.