-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor Hash Property Parsing for DSM Variants #334
Conversation
This commit refactors DsmParser to offer extensibility when parsing for site/product specific hash properties. By default no parsing is done, but subclasses of DsmParser can now provide an implementation to have this parsing done if necessary on the initial page, product pages, or both Additionally, the file is moved to a new folder where all dsm parser variants can live.
This commit implements a specific DsmParser variant for the US Site. This includes parsing a product page for a specific hash property that is within a binary encoded string in a script attached to the product page.
This commit implements a specific DsmParser variant for the UK Site. This includes parsing for a custom.js sourced script in both the initial page and product pages head element. The script is then fetched and its contents are parsed to find the included hash property. If the hash property is found on the initial page, the parsing for the hash property on the product page is skipped -- this prevents an unnecessary additional request.
This commit updates the getSpecialParser method to include the refactored DsmParser as well as the new variants for specific sites. The specialParser is also updated slightly to allow for asynchronous implementations when parsing the initial/product pages. This allows the DsmUkParser to function properly since it has to fetch the custom.js file for parsing the hash property.
This commit fixes some small lints to remove all lint errors/warnings in the task runner package.
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.
Great job man! Love the splitting of the classes 🔥 Just one small typo change, otherwise, really good job seriously!
packages/task-runner/src/shopify/classes/parsers/dsm/dsmUkParser.js
Outdated
Show resolved
Hide resolved
Co-Authored-By: pr1sm <dhanwada.dev@gmail.com>
@walmat I think this is ready for testing now |
packages/task-runner/src/shopify/classes/parsers/dsm/dsmParser.js
Outdated
Show resolved
Hide resolved
This commit finishes an incomplete doc comment.
Going through tests now. Working on |
All manual tests passed. 🔥 |
merging... |
Changes
DsmParser
to accept optionally parsing for hash properties on the initial/product pagesDsmUsParser
to handle parsing for a hash property when using theDSM US
siteDsmParser
before it was refactoredDsmUkParser
to handle parsing for a hash property when using theDSM UK
sitecustom.js
source and fetches the content, then parses for hash propertyspecialParser
to allow for asynchronous page parsingDsmUkParser
to fetch thecustom.js
file for further parsingChecks
DsmParser
implementation works and finds product correctlycustom.js
script tag so it points to a broken link and ensure the product page is used to parse the hashcustom.js
script tag from the response of the initial page and ensure the product page is used to parse the hashUsing Mock Server to Test
The Mock server can be used, but there are a couple of setup steps that need to be performed before testing:
siteOptions.js
file to set the Mock Server'sspecial
attribute.env.dev
file to set theNEBULA_RUNNER_MOCK_SPECIAL_PARSER
env var to the correct sitefixes #314