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

Pass template context to validate #117

Merged
merged 8 commits into from
Sep 14, 2021

Conversation

anthmatic
Copy link
Contributor

Different validations apply to different template types. This PR allows parses the filepath and annotations (if they exist) to pass extra context along to the validate endpoint.

Note: this relies on future additions to cli-lib

@@ -2,7 +2,7 @@
"name": "hubl",
"displayName": "HubSpot VS Code Extension",
"description": "HubSpot CMS Hub support for VS Code",
"version": "0.11.0",
"version": "0.13.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm.

package.json Outdated
@@ -186,7 +186,8 @@
}
},
"dependencies": {
"@hubspot/cli-lib": "3.0.4",
"@hubspot/cli": "^3.0.7-beta.5",
"@hubspot/cli-lib": "^3.0.7-beta.5",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When https://github.com/HubSpot/hubspot-cli/pull/534/files is merged, will pin to newest release

Comment on lines 68 to 72
is_available_for_new_content:
getAnnotationValue(
annotations,
ANNOTATION_KEYS.isAvailableForNewContent
) != 'false',
Copy link
Contributor

Choose a reason for hiding this comment

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

Code looks solid and makes sense, just wondering if we can improve the way that getAnnotationValue works to make usage a bit cleaner 🤔

Choose a reason for hiding this comment

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

Yeah, I never really loved my implementation of that one. I just had one idea though, what if instead of getAnnotationsFromSource, we had something like buildAnnotationValueGetter. Basically the output would be a getAnnotationValue function that doesn't require the annotations to be passed into it.
For example:

const getAnnotationsFromSource = source => {
const annotations = //blah blah blah
return (...args) => getAnnotationValue(annotations, ...args);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats a cool idea. Changed that up here HubSpot/hubspot-cli@42459f3

@anthmatic anthmatic merged commit 24f8262 into master Sep 14, 2021
@anthmatic anthmatic deleted the pass-template-context-to-validate branch September 14, 2021 14:43
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.

3 participants