Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add preDeployPreview hook #3966

Closed

Conversation

maxerbox
Copy link

@maxerbox maxerbox commented Jun 30, 2020

Close #3964

Summary

Allow better preview url customization
The base url was not editable with the config

Test plan

Tested with a local build, working fine :

Code used :

CMS.registerEventListener({
  name: 'preDeployPreview',
  handler: ({ deploy, ...all }) => {
    console.log(deploy.get('url'), all)
    return 'https://reddit.com'
  },
})

A picture of a cute animal (not mandatory but encouraged)

image

@maxerbox maxerbox requested a review from a team June 30, 2020 15:27
@erezrokah erezrokah added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Jun 30, 2020
@erquhart
Copy link
Contributor

erquhart commented Jul 1, 2020

@maxerbox thanks for this! I do think adding support for your use case makes sense, but I'm not sure an event is the right entry point. This is not an event driven transformation, so it would be better to find a more suitable API surface.

The right primitive in the context of our current API is probably registerDeployPreviewUrlFormatter(). Yes this is a long and terrible name, can't think of a great way to shorten.

Let me know what you think and whether you're up for implementing. I'd also recommend waiting for a thumbs up from @erezrokah before doing so, in case he has other thoughts.

@erezrokah
Copy link
Contributor

erezrokah commented Jul 2, 2020

Agree with @erquhart and sorry for taking a long time to respond. I wanted to make sure I give it some thought.

It would be great if we could leverage the existing method of configuring preview urls, to avoid having two ways of doing the same thing, but I wasn't able to think of anything yet.

Maybe preview_url_formatter: ['regex', 'replacer'].
Since you can reference regex groups in replacer that would resolve the issue and resembles the existing API.
WDYT?

@erquhart
Copy link
Contributor

erquhart commented Jul 2, 2020

I was also trying to think of way to handle it through static config, agreed it would be ideal but couldn't find a suitable approach - this could work really well.

@maxerbox your use case would look something like this:

preview_url_formatter: ["([\w-]+)\/(\w{9})$", "https://{{$2}}-{{$1}}.xxxx.app"]

@erezrokah
Copy link
Contributor

Closing as we would like to see this implemented as preview_url_formatter: ['regex', 'replacer']

We would be happy to accept a new PR for this, have this one modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow formatting the entire preview url and not just the path
3 participants