1.0.3 • Published 3 months ago

shopify-scopes-sync v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

npm monthly downloads current version npm

Shopify Scopes Sync

The shopify-scopes-sync package ensures that the Shopify access scopes specified in your project's shopify.app.toml file are automatically synchronized with the SCOPES variable in your .env file. This synchronization helps maintain consistency in your development and deployment environments, reducing the risk of scope-related errors in your Shopify applications.

Background: Authentication Works In Local Dev Mode But Not In Production (AWS EC2)

At Site Chat, we wrapped our site and service into a Shopify App using its Remix template. When migrating from local testing to AWS EC2, authentication and billing APIs stopped working, even though they ran fine on a local machine. If you've encountered a similar issue as described on Shopify Community and Shopify Github, the root cause might be that the API access scopes are out of sync in the .env file (production deployment) and the shopify.app.toml (local test). This problem led to the creation of a solution to smoothly sync scopes.

Installation

To install shopify-scopes-sync, run the following command in your project directory:

npm install shopify-scopes-sync --save

or

yarn add shopify-scopes-sync -D -W

This command adds shopify-scopes-sync to your project's dependencies.

Usage

After installing shopify-scopes-sync, you need to add a script to your package.json to run the synchronization process. Here's how to set it up:

  1. Open your project's package.json file.
  2. Add a new script named predeploy in the scripts section:
  3. Update your deploy command to ensure that scope is synced.
"scripts": {
  "predeploy": "shopify-scopes-sync",
  "deploy": "npm run predeploy && shopify app deploy",
}
  1. Save the changes to your package.json file.

Now, you can run the following command to synchronize your Shopify access scopes:

npm run sync-scopes

or

npm run deploy

This script executes shopify-scopes-sync, which reads the scopes from your shopify.app.toml and updates the SCOPES variable in your .env file accordingly.

Custom Usage

If your .env or shopify.app.toml files are located in non-standard locations, you can pass the paths to these files as arguments to the script:

"scripts": {
  "sync-scopes": "shopify-scopes-sync --env ./path/to/.env --toml ./path/to/shopify.app.toml"
}

Replace ./path/to/.env and ./path/to/shopify.app.toml with the actual paths to your files.

Contributing

We welcome contributions to shopify-scopes-sync! If you have suggestions for improvements or encounter any issues, please open an issue or submit a pull request on our GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

1.0.3

3 months ago

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago