Skip to content

Add utilities for schema management and dependency updates #611

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

Closed
wants to merge 6 commits into from

Conversation

davejcameron
Copy link
Contributor

Schema and API Version Automation Utilities

What's Changed

This PR adds automation utilities that make it easier to maintain function examples:

  • API Version Management: Added check-api-version.js to automatically update API versions across all extensions based on the current date
  • Schema Generation: Added generate-app.js and update-schemas.js to automate schema updates using Shopify CLI
  • Dependency Management: Added utilities to check and update JavaScript and Rust dependencies
    • check-js-dependencies.js for updating npm packages in package.json.liquid files
    • check-rust-dependencies.js for updating crates in Cargo.toml and Cargo.toml.liquid files
  • Documentation: Updated README.md with comprehensive instructions for all maintenance utilities
  • Improved Liquid Handling: Updated expand-liquid.js to handle extension handles more robustly

Why

These tools help address several maintenance challenges:

  1. Keeping API versions up-to-date across dozens of function examples
  2. Regenerating schemas when new API features are released
  3. Keeping dependencies up-to-date with security patches and new features
  4. Documenting maintenance workflows for contributors

How to Test

  1. Clone this branch
  2. Run yarn generate-app to create the shopify.app.toml file
  3. Run shopify app config link to link the app to a Shopify dev store
  4. Run yarn update-api-version to update API versions and schemas
  5. Run yarn check-js-dependencies or yarn check-rust-dependencies to update dependencies

Additional Notes

The key workflows are documented in the README under the following sections:

  • "Update API Versions and Function Schemas"
  • "Update Dependencies"

- Add check-api-version.js to automatically update API versions based on current date
- Add generate-app.js to manage shopify.app.toml configuration
- Add update-schemas.js to automate schema updates using Shopify CLI
- Update expand-liquid.js to handle extension handles more robustly
- Update README.md with comprehensive instructions
- Add npm scripts and required dependencies

This facilitates automatic updating of schemas and API versions across all
function examples, making maintenance easier.
Add instructions for using:
- check-js-dependencies to update JavaScript/TypeScript dependencies
- check-rust-dependencies to update Rust crate dependencies
@andrewhassan andrewhassan requested review from a team, makrisoft, mkcny, lopert and andrewhassan and removed request for a team and makrisoft April 29, 2025 13:45

const updateDependencyVersion = async (dependencies) => {
for (const [name, currentVersion] of Object.entries(dependencies)) {
const latestVersion = await getLatestVersion(name);
Copy link
Contributor

Choose a reason for hiding this comment

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

How can we ensure that it's safe to update to the latest version? For example, if there's a major version bump. Are we relying on tests to tell us that something is wrong?

});
}

async function checkAndUpdateDependencies(filePath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing this, can't we transform the Liquid files to TOML files, run cargo update, and then map back to Liquid (if applicable, like what you did in this file)?

Similarly, could we do that for JS too?

- Added @shopify/toml-patch package as a dependency
- Replaced brittle manual TOML parsing in check-rust-dependencies.js
- Updated check-api-version.js to use the more robust TOML patch library
- Added proper handling of Liquid templates during TOML manipulation
- Improved error handling and reporting
- Replace manual string manipulation with @shopify/toml-patch for TOML operations
- Simplify directory listing handling with automatic array formatting
- Remove unneeded formatDirectoriesForToml helper function
- Add validation to ensure shopify.app.toml exists before updating
- Error with instructions to run 'shopify app config link' if file is missing
- Replace manual regex-based TOML parsing with @iarna/toml library
- Simplify extension directory extraction logic
- Add warning for directories specified in config that don't exist
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.

2 participants