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

Support Projects-compatible theme boilerplate #632

Merged
merged 2 commits into from
Jan 19, 2022

Conversation

brandenrodgers
Copy link
Contributor

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

) {
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}`;
Copy link
Contributor Author

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.

Copy link
Contributor

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!

Copy link
Contributor Author

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

Copy link
Contributor Author

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 => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@anthmatic anthmatic left a 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!

@brandenrodgers brandenrodgers merged commit 7389baa into master Jan 19, 2022
@brandenrodgers brandenrodgers deleted the support-project-compatible-theme-boilerplate branch January 19, 2022 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants