-
Notifications
You must be signed in to change notification settings - Fork 60
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
Support Projects-compatible theme boilerplate #632
Support Projects-compatible theme boilerplate #632
Conversation
packages/cli-lib/projects.js
Outdated
) { | ||
try { | ||
let zipUrl; | ||
if (releaseType === GITHUB_RELEASE_TYPES.REPOSITORY) { | ||
logger.log(`Fetching ${releaseType} with name ${repoName}...`); | ||
zipUrl = `https://api.github.com/repos/HubSpot/${repoName}/zipball`; | ||
zipUrl = `https://api.github.com/repos/HubSpot/${repoName}/zipball/${ref}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The github api supports passing in a branch name to specify which branch to download (it defaults to "main" or "master" I think). That means we won't be using any sort of published release when we download the project-compatible version of the boilerplate. Whatever is currently in that branch will get downloaded.
The alternative route is to create a separate repo for the project-compatible version of the boilerplate, with its own release. IMO downloading the branch should be okay, but I figured I should still mention the alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should account for ref = undefined
when building this string. Otherwise, you get a 404 running hs create api-sample
.
Otherwise, I think this approach works!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, updated in fe42874
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking more into this, and realized there's another option. We could tag the latest commit in the boilerplate branch (w/out linking it to a new release), and then the CLI would download that specific tagged commit. I still think what we have in place now is totally fine since it will be easier to iterate on the boilerplate project. Maybe down the road we could update the flow to use a tagged commit if we're running into issues.
@@ -69,14 +69,24 @@ const writeProjectConfig = (configPath, config) => { | |||
} | |||
}; | |||
|
|||
const getProjectConfig = async _dir => { | |||
const getIsInProject = async _dir => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code lgtm and tested old v. new flow, works good!
Description and Context
Relevant cms-theme-boilerplate branch: HubSpot/cms-theme-boilerplate#404
This updates the
hs create website-theme
command to dynamically download the Projects-compatible version of the theme boilerplate repo if the destination folder is within a Project.I also added a
getIsInProject
util because I think that will be useful to have.Screenshots
TODO
Who to Notify
cc/ @jasonnrosa