Skip to content

Add API version update utilities #613

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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

davejcameron
Copy link
Contributor

This PR adds utilities for managing API versions and function schemas:

Changes

  • Add @shopify/toml-patch for robust TOML manipulation
  • Create update-api-version.js to automatically update API versions
  • Add configure-extension-directories.js to manage app extension config
  • Add update-schemas.js for updating function schemas with CLI
  • Add convenient yarn scripts for these utilities
  • Update README with simplified instructions
  • Add .gitignore entry for shopify.app.toml

Benefits

  • Enables automated API version updates across all extensions
  • Uses reliable toml-patch library instead of regex for TOML handling
  • Properly handles Liquid templates in TOML files
  • Simplifies maintenance of function examples
  • Improves developer experience

- Add @shopify/toml-patch for TOML manipulation
- Create utilities for API version management and schema updates
- Add check-api-version.js to auto-update extension API versions
- Add configure-extension-directories.js to manage app config
- Add update-schemas.js script for schema updates with CLI
- Update README with simplified instructions
- Add yarn commands for API version maintenance
- Add .gitignore entry for shopify.app.toml
- Rename script file to better reflect its actual function
- Update package.json script reference
Comment on lines +12 to +14
const date = dayjs();
const year = date.year();
const month = date.month();
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use JS dates directly instead of bringing in a new dependency.

Suggested change
const date = dayjs();
const year = date.year();
const month = date.month();
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth();

import { updateTomlValues } from '@shopify/toml-patch';

const ROOT_DIR = '.';
const FILE_PATTERN = '**/shopify.extension.toml.liquid';
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we only want to update the versions for Liquid files? This would exclude the sample apps.

console.log(`Updated API version in ${filePath} to ${latestVersion}`);

} catch (error) {
console.error(`Error updating API version in ${filePath}:`, error.message);
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like some functions run into this error because the liquid placeholder logic doesn't create a valid TOML file. For example order-routing/rust/location-rules/default/shopify.extension.toml.liquid:

{% if uid %}uid = "{{ uid }}"{% endif %}

Maybe we need a different approach that doesn't really expect a valid TOML file. Perhaps a simple find/replace would be sufficient here (assuming nobody does any Liquid shenanigans with the API version).

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