Skip to content

Commit

Permalink
Add private property (required for workspaces with yarn)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloriestra committed Apr 14, 2023
1 parent ea71638 commit 86226dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
6 changes: 6 additions & 0 deletions packages/cli-kit/src/public/node/node-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ export interface PackageJson {
* The prettier attribute of the package.json
*/
prettier?: string

/**
* The private attribute of the package.json.
* https://docs.npmjs.com/cli/v9/configuring-npm/package-json#private
*/
private?: boolean
}

/**
Expand Down
31 changes: 17 additions & 14 deletions packages/create-app/src/services/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,26 @@ async function init(options: InitOptions) {
const packageJSON = (await findUpAndReadPackageJson(templateScaffoldDir)).content
packageJSON.name = hyphenizedName
packageJSON.author = (await username()) ?? ''
if (packageManager === 'pnpm') {
await writeFile(
joinPath(templateScaffoldDir, 'pnpm-workspace.yaml'),
`packages:\n - 'web'\n - 'web/frontend'\n - 'extensions/*'\n`,
)
} else {
packageJSON.workspaces = ['web', 'web/frontend', 'extensions/*']
packageJSON.private = true

switch (packageManager) {
case 'npm':
case 'yarn':
packageJSON.workspaces = ['web', 'web/frontend', 'extensions/*']
break
case 'pnpm':
await writeFile(
joinPath(templateScaffoldDir, 'pnpm-workspace.yaml'),
`packages:\n - 'web'\n - 'web/frontend'\n - 'extensions/*'\n`,
)
// Ensure that the installation of dependencies doesn't fail when using
// pnpm due to missing peerDependencies.
await appendFile(joinPath(templateScaffoldDir, '.npmrc'), `auto-install-peers=true\n`)
break
}
await updateCLIDependencies({packageJSON, local: options.local, directory: templateScaffoldDir})

await updateCLIDependencies({packageJSON, local: options.local, directory: templateScaffoldDir})
await writePackageJSON(templateScaffoldDir, packageJSON)

// Ensure that the installation of dependencies doesn't fail when using
// pnpm due to missing peerDependencies.
if (packageManager === 'pnpm') {
await appendFile(joinPath(templateScaffoldDir, '.npmrc'), `auto-install-peers=true\n`)
}
},
},
)
Expand Down

0 comments on commit 86226dd

Please sign in to comment.