Repository navigation
feat(schematics): set up ng deploy in ng add for Hosting or App Hosting - #3851
Open
armando-navarro wants to merge 1 commit into
Open
armando-navarro wants to merge 1 commit into
armando-navarro wants to merge 1 commit into
Conversation
ng add has written no deploy target since 17.1.0, so ng deploy had nothing to run until the user wrote the target by hand. ng add now asks how to deploy, or takes --deploy, and writes the deploy entry in angular.json with the matching entries in firebase.json and .firebaserc. Firebase Hosting: pick or create a site. The entry serves the build's client-side page. A server-rendered build gets a warning, since Hosting cannot run a server, and so does a localized build, which has no single index page. Firebase App Hosting: pick or create a backend. ng deploy uploads the workspace and App Hosting builds it. It needs firebase-tools 15.9.0, the oldest version that reports a failed rollout as a failure. When .firebaserc has the app's Hosting target under several Firebase projects, ng deploy took the first one listed. It now uses the firebaseProject option, asks at a terminal, or stops with instructions when there is no terminal. ng deploy now stops when the build fails. It used to go on and deploy. inquirer, fuzzy and jsonc-parser are imported in a form that also loads as an ES module, which is how the spec runner loads the schematics, so specs can cover the code that asks questions. Fixes angular#3546 Fixes angular#3676
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
ng deployinfinite setup loop #3546, ng deploy still doesn't work #3676ng deploydoes differently.yarn install,yarn testrun successfully?: node specs yes (npm run build, thennpm run build:jasmine && npm run test:node, 652 specs, 0 failures). The browser suite is left to CI.Description
Fixes #3546
Fixes #3676
ng add @angular/firehas written nodeploytarget since 17.1.0 (#3524). On a new app,ng deployfinds no target, offers to runng add @angular/fire, and exits without deploying. With this changeng addasks how to deploy and writes the target, song deployworks after it.The new question in
ng addng addasks "How do you want to deploy this app?" with three answers: Firebase App Hosting, Firebase Hosting, or no deploy setup.--deploy=apphosting,--deploy=hostingor--deploy=noneanswers it without a prompt.ng addstopped when no feature was selected.deploytarget that belongs to another builder is replaced only after the user agrees.Firebase Hosting
ng addasks which Hosting site to use, or creates one.deploytarget with"version": 2inangular.json, ahostingentry infirebase.json, and the site undertargetsin.firebaserc.hostingentry uploads the build's browser folder and serves the client-side page for every other URL, so the Angular router handles it. That page isindex.html, orindex.csr.htmlwhen the build prerenders or renders on a server.ng addand fromng deploy, because Hosting cannot run a server.localizeset gets a warning fromng add, because it has no single index page.Firebase App Hosting
ng addstates what App Hosting needs (the Blaze pricing plan, its Terms of Service accepted, and the Owner or IAM Admin role for the first deploy to a region), then asks which backend to use, or creates one from an id and a region.deploytarget with"version": 2andappHostingBackendinangular.json, and anapphostingentry infirebase.json.ng deployuploads the workspace to that backend, and App Hosting builds it in Google Cloud. Nothing is built locally, so--previewstops with an error.src/schematics/setup/appHostingRegions.ts, plus an entry for typing another one.npm run update-regionsrewrites the list from the App Hosting API.Behavior to know
.firebaserchas the app's Hosting target under more than one Firebase project,ng deployused to deploy to the first one listed, and afirebaseProjectoption that pointed at another one stopped with "in conflict". Nowng deploydeploys tofirebaseProjectwhen it is set, asks at a terminal, and with no terminal stops with an error that says how to set the option. An automated job with such a.firebasercand nofirebaseProjectfails until the option is added.ng deploystops when a build fails. It used to go on to the deploy step.ng deploy --previewprints a line that says to press Ctrl+C to stop the preview and choose whether to deploy.Tests
.firebasercreaders, whatng addwrites toangular.json,firebase.jsonand.firebaserc, the project choice inng deploy, the App Hosting deploy, and wholeng addruns against a stand-in for firebase-tools with scripted answers.--deploy=none, Hosting with a new site andng deploy, a secondng addthat changed no file, App Hosting with a new backend andng deploy, and a server-rendered app on Hosting with its warnings.inquirer,fuzzyandjsonc-parserare imported in a form that also loads as an ES module, which is how the spec runner loads the schematics. The published schematics are bundled as CommonJS, as before.Not in this pull request
firebaseProjectoption still does not accept a project alias, although its description says it does.ng deployis unchanged.Refs #3077. Of the two things that issue reports, choosing between Firebase projects with
firebaseProjectworks with this change when.firebaserchas the app's target under each project. AfirebaseHostingSitethat differs from.firebasercstill stops with "in conflict".Planned for 22.1.0, with a cherry-pick onto
21.1.x.22.0.0will be released from a22.0.xbranch that does not include this change.