| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
I like the idea here, but I'm not certain that this is safe as-is because it changes the returned value of deploy. If you check the output of deploy --json before and after, it must not be a breaking change (well, it can be, but that would require a different effort).
Sorry, something went wrong.
| [site: string]: { | ||
| [key: string]: string; | ||
| }; |
There was a problem hiding this comment.
Might the value of this map be the Release interface in hosting/api.ts? (I don't know off hand, but it would make for stronger typing)
Sorry, something went wrong.
There was a problem hiding this comment.
This is a great idea. It would require a bit more code changes to capture the payload returned by the hosting release api, but it makes more sense to me. Let me give it a try.
Sorry, something went wrong.
| const results = (await deploy(["hosting"], options, { | ||
| hostingChannel: channelId, | ||
| })) as DeployResult; |
There was a problem hiding this comment.
My TS-brain is rusty: could this be const results: DeployResult = await deploy() rather than using as?
Sorry, something went wrong.
There was a problem hiding this comment.
The method deploy() returns any since it is implemented in js. Without the as cast, eslint issues this warning: Unsafe assignment of an any value..
I'm fine with either construct. Please advise.
Sorry, something went wrong.
| if (siteDetails && siteKey in siteDetails) { | ||
| d.version = siteDetails[siteKey]["version"]; | ||
| } |
There was a problem hiding this comment.
What is the case where siteDetails is not defined?
Sorry, something went wrong.
There was a problem hiding this comment.
Good point. Removed.
Sorry, something went wrong.
| }); | ||
| const versionNames = context.hosting.deploys.map((deploy) => deploy.version); | ||
| return { hosting: versionNames.length === 1 ? versionNames[0] : versionNames }; | ||
| var siteDetails = {}; |
There was a problem hiding this comment.
| var siteDetails = {}; | |
| const siteDetails = {}; |
Sorry, something went wrong.
There was a problem hiding this comment.
I had const initially, but then noticed that this js file is using var everywhere else. I'd like to leave it as var if it is okay with you.
Sorry, something went wrong.
| return { hosting: versionNames.length === 1 ? versionNames[0] : versionNames }; | ||
| var siteDetails = {}; | ||
| context.hosting.deploys.forEach((deploy) => { | ||
| var version = deploy.version.replace(`sites/${deploy.site}/versions/`, ""); |
There was a problem hiding this comment.
I'm not actually sure we want to truncate the full name to just the version ID. If we wanted to only display that later, we can manipulate the name at that location.
Sorry, something went wrong.
There was a problem hiding this comment.
That's a good point. Will move that logic into host-channel-deploy.ts.
Sorry, something went wrong.
| var version = deploy.version.replace(`sites/${deploy.site}/versions/`, ""); | ||
| siteDetails[deploy.site] = { version }; | ||
| }); | ||
| return { hosting: siteDetails }; |
There was a problem hiding this comment.
This change may also have an effect on the output of deploy --json. Could you check the before/after of the behavior there?
Sorry, something went wrong.
There was a problem hiding this comment.
It looks compatible. The only new field is version.
Before:
{
"status": "success",
"result": {
"<site>": {
"site": "<site>",
"url": "https://<site>--slam-test-6161efgc.web.app",
"expireTime": "2021-03-02T19:40:07.615661137Z"
}
}
}
After:
{
"status": "success",
"result": {
"<site>": {
"site": "<site>",
"url": "https://<site>--slam-test-6161efgc.web.app",
"version": "09ef5462c91e2bba",
"expireTime": "2021-03-02T19:39:05.793378023Z"
}
}
}
Sorry, something went wrong.
There was a problem hiding this comment.
This makes sense to me because before this PR the return value of deploy() was not used anywhere:
Sorry, something went wrong.
|
@bkendall could you pls review again when you get a chance? |
Sorry, something went wrong.
It's been a month since I responded to the feedback. Is there anything else I could do to speed this up? |
Sorry, something went wrong.
|
Thanks for your patience. Unfortunately there's been other more pressing things on my plate recently, but I hope to come back around to this soon. |
Sorry, something went wrong.
|
When I do a normal deploy (firebase deploy --only hosting) on master, I get this output (with --json): {
"status": "success",
"result": {
"hosting": "sites/bkend-test-stuff/versions/db18ce3e1f438cb2"
}
}
Now I'm getting an object at that hosting key rather than a string (which is a breaking change): {
"status": "success",
"result": {
"hosting": {
"bkend-test-stuff": {
"release": {
"name": "sites/bkend-test-stuff/releases/1617216425557023",
"version": {
"name": "sites/bkend-test-stuff/versions/e23837c2b1183abb",
// Other fields trimmed for sanity
}
}
}
}
}
Checking on hosting:channel:deploy, it does look like only version is added, which is safe. Looking at the code, I think the version may be able to be pulled from the bit of code that gets/creates the channels before calling deploy. That would allow the version to be added into hosting:channel:deploy's output while not changing firebase deploy's output. What do you think? |
Sorry, something went wrong.
There was a problem hiding this comment.
(See previous comment regarding firebase deploy)
Sorry, something went wrong.
Thank you for the explanation and the example. I finally got it. Updated the code. Decided not to touch src/deploy/index.js at all, and limited all the changes to hosting:channel:deploy. |
Sorry, something went wrong.
There was a problem hiding this comment.
This looks great. Could you add an entry to the changelog?
- Adds the deployed version to the output when deploying to Firebase Hosting.LGTM otherwise! Thanks for being incredibly patient with me
Sorry, something went wrong.
| if (d.expireTime) { | ||
| expires = `[expires ${bold(datetimeString(new Date(d.expireTime)))}]`; | ||
| } | ||
| const versionPrefix = `sites/${d.target || d.site}/versions/`; |
There was a problem hiding this comment.
I tested this out with a test project that has two sites and deploy targets set up for them. This line ends up breaking because d.target isn't what d.site is (target is the local alias for it). I think .site is the only thing that's needed here.
| const versionPrefix = `sites/${d.target || d.site}/versions/`; | |
| const versionPrefix = `sites/${d.site}/versions/`; |
Could you double check this fix? I think it should be fine, but it'd be nice for you to test as well :)
Sorry, something went wrong.
There was a problem hiding this comment.
Good catch. version is empty:
$ firebase --debug hosting:channel:deploy t1-test --project slam-home-api --json --only t1
{
"status": "success",
"result": {
"t1": {
"site": "thing1",
"target": "t1",
"url": "https://thing1--t1-test-ltf4oe3y.web.app",
"version": "",
"expireTime": "2021-05-21T00:12:33.800426131Z"
}
}
}
Will fix.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed:
$ firebase --debug hosting:channel:deploy t1-test --project slam-home-api --json --only t1
{
"status": "success",
"result": {
"t1": {
"site": "thing1",
"target": "t1",
"url": "https://thing1--t1-test-ltf4oe3y.web.app",
"version": "9af1bb9abd9d5d01",
"expireTime": "2021-05-21T00:16:09.860986599Z"
}
}
}
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM. I may not merge it right this moment, but I'll do so soon! Thanks for the PR!
Sorry, something went wrong.
* Return version in `hosting:channel:deploy` * Improve text loggin * Incorporate review comments * Add version without changing the deploy output in json * Unroll even more changes * Add an entry to CHANGELOG.md * Fix a bug when target is specified Co-authored-by: Bryan Kendall <bkend@google.com>
| Back | FazBrowse Home | New Git URL |
Description
firebase hosting:clone accepts two forms of the source argument - site:channel and site@version. The second form allows cloning a specific version and is great for many companies that have a robust QA process to validate a preview build before promoting it to live.
However, there is currently no way to extract the version that was deployed. This PR adds the version info to the hosting:channel:deploy output.
Scenarios Tested
Run firebase hosting:channel:deploy <test-channel> with and without the --json option. Make sure the version info appears in both text and json outputs.
Sample Commands
Example output:
Text:
JSON:
{ "status": "success", "result": { "<site-name>": { "site": "<site-name>", "url": "https://<site-name>--<channel>-bf71pekc.web.app", "version": "a44e17f03a7e3c2c", "expireTime": "2021-03-01T00:25:13.973338740Z" } } }