mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 09:25:54 +00:00
fix(nitro): resolve firebase package versions with pkg-types
(#1490)
Co-authored-by: pooya parsa <pyapar@gmail.com>
This commit is contained in:
parent
0520db6b22
commit
07ad7254e6
@ -56,6 +56,7 @@
|
||||
"ora": "^6.0.1",
|
||||
"p-debounce": "^4.0.0",
|
||||
"pathe": "^0.2.0",
|
||||
"pkg-types": "^0.3.1",
|
||||
"pretty-bytes": "^5.6.0",
|
||||
"rollup": "^2.58.3",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
|
@ -3,8 +3,8 @@ import { join, relative, resolve } from 'pathe'
|
||||
import fse from 'fs-extra'
|
||||
import consola from 'consola'
|
||||
import globby from 'globby'
|
||||
|
||||
import { readPackageJson, writeFile } from '../utils'
|
||||
import { readPackageJSON } from 'pkg-types'
|
||||
import { writeFile } from '../utils'
|
||||
import { NitroPreset, NitroContext } from '../context'
|
||||
|
||||
export const firebase: NitroPreset = {
|
||||
@ -17,7 +17,7 @@ export const firebase: NitroPreset = {
|
||||
}
|
||||
}
|
||||
|
||||
async function writeRoutes ({ output: { publicDir, serverDir }, _nuxt: { rootDir } }: NitroContext) {
|
||||
async function writeRoutes ({ output: { publicDir, serverDir }, _nuxt: { rootDir, modulesDir } }: NitroContext) {
|
||||
if (!fse.existsSync(join(rootDir, 'firebase.json'))) {
|
||||
const firebase = {
|
||||
functions: {
|
||||
@ -61,6 +61,11 @@ async function writeRoutes ({ output: { publicDir, serverDir }, _nuxt: { rootDir
|
||||
}
|
||||
} catch {}
|
||||
|
||||
const getPackageVersion = async (id) => {
|
||||
const pkg = await readPackageJSON(id, { url: modulesDir })
|
||||
return pkg.version
|
||||
}
|
||||
|
||||
await writeFile(
|
||||
resolve(serverDir, 'package.json'),
|
||||
JSON.stringify(
|
||||
@ -71,8 +76,8 @@ async function writeRoutes ({ output: { publicDir, serverDir }, _nuxt: { rootDir
|
||||
dependencies,
|
||||
devDependencies: {
|
||||
'firebase-functions-test': 'latest',
|
||||
'firebase-admin': readPackageJson('firebase-admin', _require).version,
|
||||
'firebase-functions': readPackageJson('firebase-functions', _require).version
|
||||
'firebase-admin': await getPackageVersion('firebase-admin'),
|
||||
'firebase-functions': await getPackageVersion('firebase-functions')
|
||||
},
|
||||
engines: { node: nodeVersion }
|
||||
},
|
||||
|
19
yarn.lock
19
yarn.lock
@ -2679,6 +2679,7 @@ __metadata:
|
||||
ora: ^6.0.1
|
||||
p-debounce: ^4.0.0
|
||||
pathe: ^0.2.0
|
||||
pkg-types: ^0.3.1
|
||||
pretty-bytes: ^5.6.0
|
||||
rollup: ^2.58.3
|
||||
rollup-plugin-terser: ^7.0.2
|
||||
@ -13339,6 +13340,13 @@ fsevents@~2.3.2:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mlly@npm:^0.3.6":
|
||||
version: 0.3.7
|
||||
resolution: "mlly@npm:0.3.7"
|
||||
checksum: f9118c57ab4436b38e385000a99adfd5e4472a03c977c6bad3070660152fffd6d05dd741c324b2c81d72d35fb852048aa5e969b7a001b720bd8ff2e09ef262b3
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mocha@npm:^9.1.3":
|
||||
version: 9.1.3
|
||||
resolution: "mocha@npm:9.1.3"
|
||||
@ -14994,6 +15002,17 @@ fsevents@~2.3.2:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"pkg-types@npm:^0.3.1":
|
||||
version: 0.3.1
|
||||
resolution: "pkg-types@npm:0.3.1"
|
||||
dependencies:
|
||||
jsonc-parser: ^3.0.0
|
||||
mlly: ^0.3.6
|
||||
pathe: ^0.2.0
|
||||
checksum: 47624bbac446dd77bc91e58aeca0e9c1779b4c3b6991edd72b64c10b8571938cdd0e752b6fdbc0ebe274ccddfcbb6a98d6ac9051dc993614421ad5889a789f20
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"pluralize@npm:^8.0.0":
|
||||
version: 8.0.0
|
||||
resolution: "pluralize@npm:8.0.0"
|
||||
|
Loading…
Reference in New Issue
Block a user