-
Notifications
You must be signed in to change notification settings - Fork 66
Support Projects-compatible theme boilerplate #632
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
Merged
brandenrodgers
merged 2 commits into
master
from
support-project-compatible-theme-boilerplate
Jan 19, 2022
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
const { createProject } = require('@hubspot/cli-lib/projects'); | ||
const { GITHUB_RELEASE_TYPES } = require('@hubspot/cli-lib/lib/constants'); | ||
const { getIsInProject } = require('../../lib/projects'); | ||
|
||
const PROJECT_BOILERPLATE_REF = 'cms-boilerplate-developer-projects'; | ||
|
||
module.exports = { | ||
dest: ({ name, assetType }) => name || assetType, | ||
execute: ({ dest, assetType, options }) => { | ||
execute: async ({ dest, assetType, options }) => { | ||
const isInProject = await getIsInProject(dest); | ||
|
||
if (isInProject) { | ||
options.ref = PROJECT_BOILERPLATE_REF; | ||
// releaseType has to be 'REPOSITORY' to download a specific branch | ||
options.releaseType = GITHUB_RELEASE_TYPES.REPOSITORY; | ||
} | ||
createProject(dest, assetType, 'cms-theme-boilerplate', 'src', options); | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
const configPath = await getProjectConfigPath(_dir); | ||
return !!configPath; | ||
}; | ||
|
||
const getProjectConfigPath = async _dir => { | ||
const projectDir = _dir ? path.resolve(getCwd(), _dir) : getCwd(); | ||
|
||
const configPath = findup(PROJECT_CONFIG_FILE, { | ||
cwd: projectDir, | ||
nocase: true, | ||
}); | ||
|
||
return configPath; | ||
}; | ||
|
||
const getProjectConfig = async _dir => { | ||
const configPath = await getProjectConfigPath(_dir); | ||
if (!configPath) { | ||
return { projectConfig: null, projectDir: null }; | ||
} | ||
|
@@ -381,6 +391,7 @@ const makeGetTaskStatus = taskType => { | |
module.exports = { | ||
writeProjectConfig, | ||
getProjectConfig, | ||
getIsInProject, | ||
createProjectConfig, | ||
validateProjectConfig, | ||
showWelcomeMessage, | ||
|
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.
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 runninghs 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.