Skip to content

Commit

Permalink
feat(cli,app-vite,app-webpack): add bun.lock support (#17775)
Browse files Browse the repository at this point in the history
* feat(cli): detect bun.lock for the "upgrade" cmd

* mention bun.lock in upgrade guide
  • Loading branch information
Dustin-Z authored Feb 24, 2025
1 parent f17d7ea commit 0ad237f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions app-vite/lib/cache/module.nodePackager.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PackageManager {
* To be declared by subclasses
*/
name = 'unknown'
lockFile = 'unknown'
lockFiles = [ 'unknown' ]

getInstallParams (_env) {
return []
Expand Down Expand Up @@ -110,7 +110,7 @@ class PackageManager {

class Npm extends PackageManager {
name = 'npm'
lockFile = 'package-lock.json'
lockFiles = [ 'package-lock.json' ]

getInstallParams (env) {
if (env === 'development') {
Expand All @@ -137,7 +137,7 @@ class Npm extends PackageManager {

class Yarn extends PackageManager {
name = 'yarn'
lockFile = 'yarn.lock'
lockFiles = [ 'yarn.lock' ]

getInstallParams (env) {
if (env === 'development') {
Expand Down Expand Up @@ -172,7 +172,7 @@ class Yarn extends PackageManager {

class Pnpm extends PackageManager {
name = 'pnpm'
lockFile = 'pnpm-lock.yaml'
lockFiles = [ 'pnpm-lock.yaml' ]

getInstallParams (env) {
return env === 'development'
Expand All @@ -195,7 +195,7 @@ class Pnpm extends PackageManager {

class Bun extends PackageManager {
name = 'bun'
lockFile = 'bun.lockb'
lockFiles = [ 'bun.lock', 'bun.lockb' ]

getInstallParams (env) {
return env === 'development'
Expand Down Expand Up @@ -224,7 +224,7 @@ function getProjectPackageManager (packageManagersList, dir) {
// the dir tree up to the root
while (dir.length && dir[ dir.length - 1 ] !== sep) {
for (const pm of packageManagersList) {
if (fs.existsSync(join(dir, pm.lockFile))) {
if (pm.lockFiles.some(lockFile => fs.existsSync(join(dir, lockFile)))) {
return pm
}
}
Expand Down
12 changes: 6 additions & 6 deletions app-webpack/lib/cache/module.nodePackager.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PackageManager {
* To be declared by subclasses
*/
name = 'unknown'
lockFile = 'unknown'
lockFiles = [ 'unknown' ]

getInstallParams (_env) {
return []
Expand Down Expand Up @@ -110,7 +110,7 @@ class PackageManager {

class Npm extends PackageManager {
name = 'npm'
lockFile = 'package-lock.json'
lockFiles = [ 'package-lock.json' ]

getInstallParams (env) {
if (env === 'development') {
Expand All @@ -137,7 +137,7 @@ class Npm extends PackageManager {

class Yarn extends PackageManager {
name = 'yarn'
lockFile = 'yarn.lock'
lockFiles = [ 'yarn.lock' ]

getInstallParams (env) {
if (env === 'development') {
Expand Down Expand Up @@ -172,7 +172,7 @@ class Yarn extends PackageManager {

class Pnpm extends PackageManager {
name = 'pnpm'
lockFile = 'pnpm-lock.yaml'
lockFiles = [ 'pnpm-lock.yaml' ]

getInstallParams (env) {
return env === 'development'
Expand All @@ -195,7 +195,7 @@ class Pnpm extends PackageManager {

class Bun extends PackageManager {
name = 'bun'
lockFile = 'bun.lockb'
lockFiles = [ 'bun.lock', 'bun.lockb' ]

getInstallParams (env) {
return env === 'development'
Expand Down Expand Up @@ -224,7 +224,7 @@ function getProjectPackageManager (packageManagersList, dir) {
// the dir tree up to the root
while (dir.length && dir[ dir.length - 1 ] !== sep) {
for (const pm of packageManagersList) {
if (fs.existsSync(join(dir, pm.lockFile))) {
if (pm.lockFiles.some(lockFile => fs.existsSync(join(dir, lockFile)))) {
return pm
}
}
Expand Down
12 changes: 6 additions & 6 deletions cli/lib/node-packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class PackageManager {
* To be declared by subclasses
*/
name = 'unknown'
lockFile = 'unknown'
lockFiles = [ 'unknown' ]

getInstallParams (_env) {
return []
Expand Down Expand Up @@ -202,7 +202,7 @@ class PackageManager {

class Npm extends PackageManager {
name = 'npm'
lockFile = 'package-lock.json'
lockFiles = [ 'package-lock.json' ]

getInstallParams (env) {
if (env === 'development') {
Expand All @@ -229,7 +229,7 @@ class Npm extends PackageManager {

class Yarn extends PackageManager {
name = 'yarn'
lockFile = 'yarn.lock'
lockFiles = [ 'yarn.lock' ]

getInstallParams (env) {
if (env === 'development') {
Expand Down Expand Up @@ -264,7 +264,7 @@ class Yarn extends PackageManager {

class Pnpm extends PackageManager {
name = 'pnpm'
lockFile = 'pnpm-lock.yaml'
lockFiles = [ 'pnpm-lock.yaml' ]

getInstallParams (env) {
return env === 'development'
Expand All @@ -287,7 +287,7 @@ class Pnpm extends PackageManager {

class Bun extends PackageManager {
name = 'bun'
lockFile = 'bun.lockb'
lockFiles = [ 'bun.lock', 'bun.lockb' ]

getInstallParams (env) {
return env === 'development'
Expand Down Expand Up @@ -323,7 +323,7 @@ function getProjectPackageManager (folder) {
// the folder tree up to the root
while (folder.length && folder[ folder.length - 1 ] !== sep) {
for (const pm of packageManagersList) {
if (fs.existsSync(join(folder, pm.lockFile))) {
if (pm.lockFiles.some(lockFile => fs.existsSync(join(folder, lockFile)))) {
return pm
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/start/upgrade-guide/upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ Before starting, it is highly suggested to make a copy of your current working p
$ bun add --dev @quasar/app-webpack@3
$ bun add quasar@2 vue@3 vue-router@4
```
7) **Remove** `.quasar` and `node_modules` folders, and `package-lock.json` / `yarn.lock` / `pnpm-lock.yaml` / `bun.lockb` file, then run `yarn/npm/pnpm/bun install` to regenerate the lock file. This forces the upgrade of the whole dependency graph (deep dependencies included) and avoids troubles with mismatching packages, especially webpack 5 related ones.
7) **Remove** `.quasar` and `node_modules` folders, and `package-lock.json` / `yarn.lock` / `pnpm-lock.yaml` / `bun.lock` / `bun.lockb` file, then run `yarn/npm/pnpm/bun install` to regenerate the lock file. This forces the upgrade of the whole dependency graph (deep dependencies included) and avoids troubles with mismatching packages, especially webpack 5 related ones.
8) If you are using ESLint, then edit `/.eslintrc.cjs` (also rename from `/.eslintrc.js`):
```js
// old way
Expand Down

0 comments on commit 0ad237f

Please sign in to comment.