-
Notifications
You must be signed in to change notification settings - Fork 250
Upload settings_schema.json before validator-consumer assets #7481
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
Open
NathanPJF
wants to merge
2
commits into
main
Choose a base branch
from
fix/theme-push-fresh-dynamic-source-defaults
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@shopify/theme': patch | ||
| --- | ||
|
|
||
| Upload `config/settings_schema.json` before any other theme file. Fixes `theme push` failing on the first push when blocks or sections reference a `color_palette` theme setting. |
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
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,7 +20,7 @@ interface UploadOptions { | |||||
| multiEnvironment?: boolean | ||||||
| } | ||||||
|
|
||||||
| type ChecksumWithSize = Checksum & {size: number} | ||||||
| export type ChecksumWithSize = Checksum & {size: number} | ||||||
| type FileBatch = ChecksumWithSize[] | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -213,7 +213,9 @@ function orderFilesToBeDeleted(files: Checksum[]): Checksum[] { | |||||
| ...fileSets.blockLiquidFiles, | ||||||
| ...fileSets.layoutFiles, | ||||||
| ...fileSets.otherLiquidFiles, | ||||||
| ...fileSets.configFiles, | ||||||
| // Inverse of the upload order: data first (consumes schema), then schema. | ||||||
| ...fileSets.configDataFile, | ||||||
| ...fileSets.configSchemaFile, | ||||||
| ...fileSets.staticAssetFiles, | ||||||
| ] | ||||||
| } | ||||||
|
|
@@ -311,21 +313,34 @@ function selectUploadableFiles(themeFileSystem: ThemeFileSystem, remoteChecksums | |||||
| * We use this 2d array to batch files of the same type together | ||||||
| * while maintaining the order between file types. The files with | ||||||
| * dependencies we have are: | ||||||
| * 1. Layout files don't necessarily need to be the first, but they must uploaded before templates. | ||||||
| * 2. Liquid blocks need to be uploaded before sections | ||||||
| * 3. Liquid sections need to be uploaded afterwards | ||||||
| * 4. JSON sections need to be uploaded after sections | ||||||
| * 5. JSON templates need to be uploaded after all sections and layouts | ||||||
| * 6. Contextualized templates should be uploaded after as they are variations of templates | ||||||
| * 7. Config files must be the last ones, but we need to upload config/settings_schema.json first, followed by config/settings_data.json | ||||||
| * | ||||||
| * 1. config/settings_schema.json must be uploaded FIRST. It declares the | ||||||
| * theme-level settings that block / section / section-group / template | ||||||
| * validators resolve dynamic-source defaults against (e.g. defaults of | ||||||
| * the form {{ settings.<theme_setting>.<property> }}). On a fresh | ||||||
| * theme the stored schema is empty, so any later asset whose schema | ||||||
| * references a not-yet-declared theme setting fails server-side | ||||||
| * validation. Uploading the schema first primes those references. | ||||||
| * 2. Layout files don't necessarily need to be the first, but they must be | ||||||
| * uploaded before templates. | ||||||
| * 3. Liquid blocks need to be uploaded before sections | ||||||
| * 4. Liquid sections need to be uploaded afterwards | ||||||
| * 5. JSON sections need to be uploaded after sections | ||||||
| * 6. JSON templates need to be uploaded after all sections and layouts | ||||||
| * 7. Contextualized templates should be uploaded after as they are | ||||||
| * variations of templates | ||||||
| * 8. config/settings_data.json must be uploaded LAST. Its current and | ||||||
| * presets are validated against the freshly-uploaded | ||||||
| * settings_schema.json, and presets can reference sections and | ||||||
| * templates uploaded in earlier steps. | ||||||
| * | ||||||
| * The files with no dependencies we have are: | ||||||
| * - The other Liquid files (for example, snippets, and liquid templates) | ||||||
| * - The other JSON files (for example, locales) | ||||||
| * - The static assets | ||||||
| * | ||||||
| */ | ||||||
| function orderFilesToBeUploaded(files: ChecksumWithSize[]): { | ||||||
| export function orderFilesToBeUploaded(files: ChecksumWithSize[]): { | ||||||
| independentFiles: ChecksumWithSize[][] | ||||||
| dependentFiles: ChecksumWithSize[][] | ||||||
| } { | ||||||
|
|
@@ -336,13 +351,18 @@ function orderFilesToBeUploaded(files: ChecksumWithSize[]): { | |||||
| independentFiles: [fileSets.otherLiquidFiles, fileSets.otherJsonFiles, fileSets.staticAssetFiles], | ||||||
| // Follow order of dependencies: | ||||||
| dependentFiles: [ | ||||||
| // Theme setting declarations must land before any asset that may | ||||||
| // reference them via dynamic-source defaults. See header comment. | ||||||
|
Comment on lines
+354
to
+355
Contributor
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. Already have sufficient description in the header
Suggested change
|
||||||
| fileSets.configSchemaFile, | ||||||
| fileSets.layoutFiles, | ||||||
| fileSets.blockLiquidFiles, | ||||||
| fileSets.sectionLiquidFiles, | ||||||
| fileSets.sectionJsonFiles, | ||||||
| fileSets.templateJsonFiles, | ||||||
| fileSets.contextualizedJsonFiles, | ||||||
| fileSets.configFiles, | ||||||
| // Settings values reference the schema we just uploaded, plus any | ||||||
| // sections / templates referenced by presets. | ||||||
|
Comment on lines
+363
to
+364
Contributor
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.
Suggested change
|
||||||
| fileSets.configDataFile, | ||||||
| ], | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
Oops, something went wrong.
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.
I have no idea what this test is doing. Is there another way we could show this?