Skip to content

Conversation

matthew-carroll
Copy link
Collaborator

@matthew-carroll matthew-carroll commented Aug 2, 2025

[Shock][CLI][Docs] - Load themes from git repositories (Resolves #213)

Git theme specification
A git theme is specified by a URL, and an optional path within the repository.

The path is important because it's very likely that a theme will be stored in a subdirectory so that it doesn't include things like the .gitignore file at the root. That said, a website could always use an Excluder to keep files like .gitignore out of the pipeline.

Git theme implementation
Based on initial research, it looks like Git doesn't support any standard repository directory traversal. My hope was that we could navigate the repo over HTTP and only pull down what's picked, but Git doesn't support that.

Instead, we clone the entire theme repository, but we tell git to only bring down the content at the given path. This should avoid excessive clone size for things like mono-repos.

The theme repo is cloned to the a new root level .shock/build/ build cache directory. It's contents are added as a source set so that its files can be picked, like the regular source set.

Infrastructure changes

  • Can add file sources that supplement the primary source directory.
  • Added a build cache that's placed in a .shock directory at the root of the project structure. I couldn't place it in /build because that directory is cleared on every build, and also it's meant to be directly deployable. I also didn't want to place it in /source because it isn't actually source.
    • Note: Based on previous work, specifically screenshots, the cache under /source/.shock/ is no longer git ignored. We commit it so that things like screenshots don't need to be regenerated in CI, or over time, if not desired.
  • Had to change uses of FileRelativePaths to SourceFiles because we no longer know that every file exists relative to the primary source directory.

componentContent.content ?? componentContent.value,
),
);
final sourceSets = {_sourceFiles, ..._sourceExtensions};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These should be ordered from extensions to source files so source files can overwrite extensions. We already do this in _pickAllSourceFiles(). We should probably create a central method that returns all source sets in that priority order.

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.

[Shock] - Let users load themes from a git repository
1 participant