Function deployment not uploading referenced package.json file when built with @angular/fire:deploy
- Ngôn ngữ chính
- TypeScript
- Star
- 7.8k
- Fork
- 2.2k
- Merge trung bình
- 22 giờ 28 phút
- Pull request đã merge (30 ngày)
- 6
Mô tả
### Version info
**Angular:** 14.2.0
**Firebase:** 11.15.0
**AngularFire:** 7.4.1
**Other (e.g. Ionic/Cordova, Node, browser, operating system):**
### How to reproduce these conditions
Use `@angular/fire:deploy` for an Angular Universal app
**Failing test unit, Stackblitz demonstrating the problem**
**Steps to set up and reproduce**
Use an Nx workspace and add Angular Universal, then include `@angular/fire:deploy` builder (in Nx terms "executor") in `project.json`:
```json
"deploy": {
"executor": "@angular/fire:deploy",
"options": {
"ssr": true,
"firebaseProject": "my-project",
"functionsNodeVersion": 16,
"firebaseHostingSite": "my-site"
},
"configurations": {
"production": {
"browserTarget": "my-app:build:production",
"serverTarget": "my-app:server:production"
}
}
},
```
This generates a production build in the `dist` folder with the following structure:
```
dist /
my-app /
dist /
my-app /
browser
server
node_modules /
index.js
package.json
package-lock.json
```
In the `package.json` file that resides in the `dist` folder is a reference like so:
```
{
// [...]
"my-app": "file:../.."
}
```
The firebase configuration is set up like so:
```json
{
"functions": [
{
"source": "dist/my-app",
"codebase": "default",
"ignore": ["node_modules"]
}
]
}
```
Upon running `firebase deploy --only functions` it errors out (see section below for logs). It seems files outside the `source` are not uploaded to firebase functions and so `@angular/fire:deploy` can't be used to deploy functions.
I can confirm this with the following steps. I remove the line `"my-app": "file:../.."` from the generated `package.json` and remove the `node_modules` and `package-lock.json` in the `dist` folder. Then I run `npm install` in the `dist` folder. When done, I run `firebase deploy --only functions` and it works.
**Sample data and security rules**
### Debug output
** Errors in the JavaScript console **
When running `firebase deploy --only functions` the following output is generated:
```
Build failed: npm ERR! code EUSAGE
npm ERR!
npm ERR! The `npm ci` command can only install with an existing package-lock.json or
npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm ERR! later to generate a package-lock.json file, then try again.
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
npm ERR! [--script-shell ]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm ERR! A complete log of this run can be found in:
npm ERR!
Functions deploy had errors with the following functions:
ssr(us-central1)
i functions: cleaning up build files...
Error: There was an error deploying functions
```
** Output from `firebase.database().enableLogging(true);` **
** Screenshots **
### Expected behavior
`@angular/fire:deploy` should generate output that can be uploaded to functions as is.
### Actual behavior
Functions cannot be deployed because the reference in the generated `package.json` is outside the `source` folder.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với cấu hình builder @angular/fire:deploy trong project.json và kiểm tra dist/my-app/package.json được tạo ra, đặc biệt là tham chiếu file:../.. của nó. Tái hiện bằng firebase deploy --only functions và xác minh rằng đầu ra được tạo ra có thể được triển khai mà không tham chiếu đến các tệp bên ngoài source functions đã cấu hình.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, firebase, node.js, typescript
- Lĩnh vực
- backend, cloud, devops
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100