Skip to content

Commit

Permalink
fix: yarn berry support (#4586)
Browse files Browse the repository at this point in the history
  • Loading branch information
rault-a authored May 23, 2024
1 parent a508bb0 commit bdda97a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class Add extends BaseCommand {
declare verbose?: boolean

@flags.string({ description: 'Select the package manager you want to use' })
declare packageManager?: 'npm' | 'pnpm' | 'yarn'
declare packageManager?: 'npm' | 'pnpm' | 'yarn' | 'yarn@berry'

@flags.boolean({ description: 'Should we install the package as a dev dependency', alias: 'D' })
declare dev?: boolean
Expand All @@ -45,8 +45,8 @@ export default class Add extends BaseCommand {
const pkgManager =
this.packageManager || (await detectPackageManager(this.app.makePath())) || 'npm'

if (['npm', 'pnpm', 'yarn'].includes(pkgManager)) {
return pkgManager as 'npm' | 'pnpm' | 'yarn'
if (['npm', 'pnpm', 'yarn', 'yarn@berry'].includes(pkgManager)) {
return pkgManager as 'npm' | 'pnpm' | 'yarn' | 'yarn@berry'
}

throw new Error('Invalid package manager. Must be one of npm, pnpm or yarn')
Expand Down
2 changes: 1 addition & 1 deletion commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class Build extends BaseCommand {
@flags.string({
description: 'Define the package manager to copy the appropriate lock file',
})
declare packageManager?: 'npm' | 'pnpm' | 'yarn' | 'bun'
declare packageManager?: 'npm' | 'pnpm' | 'yarn' | 'yarn@berry' | 'bun'

@flags.boolean({
description: 'Build frontend assets',
Expand Down
1 change: 1 addition & 0 deletions modules/ace/codemods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class Codemods extends EventEmitter {

switch (packageManager) {
case 'yarn':
case 'yarn@berry':
return `${colors.yellow(`yarn add${devFlag}`)} ${packages.join(' ')}`
case 'pnpm':
return `${colors.yellow(`pnpm add${devFlag}`)} ${packages.join(' ')}`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"index:commands": "node --loader=ts-node/esm toolkit/main.js index build/commands"
},
"devDependencies": {
"@adonisjs/assembler": "^7.5.1",
"@adonisjs/assembler": "^7.6.1",
"@adonisjs/eslint-config": "^1.3.0",
"@adonisjs/prettier-config": "^1.3.0",
"@adonisjs/tsconfig": "^1.3.0",
Expand Down
4 changes: 2 additions & 2 deletions tests/commands/add.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ const VERBOSE = !!process.env.CI
/**
* Setup a fake adonis project in the file system
*/
async function setupProject(fs: FileSystem, pkgManager?: 'npm' | 'pnpm' | 'yarn') {
async function setupProject(fs: FileSystem, pkgManager?: 'npm' | 'pnpm' | 'yarn' | 'yarn@berry') {
await fs.create(
'package.json',
JSON.stringify({ type: 'module', name: 'test', dependencies: {} })
)

if (pkgManager === 'pnpm') {
await fs.create('pnpm-lock.yaml', '')
} else if (pkgManager === 'yarn') {
} else if (pkgManager === 'yarn' || pkgManager === 'yarn@berry') {
await fs.create('yarn.lock', '')
} else {
await fs.create('package-lock.json', '')
Expand Down

0 comments on commit bdda97a

Please sign in to comment.