This repository was developed to help determine best practices and configuration for building BigCommerce apps with the Gadget platform.
- Aligent standard static analysis setup (tsconfig, eslint, prettier, editorconfig)
- Some deviations:
- tsconfig is declared inline as Gadget does not support
extends
configuration no-unused-vars
rule loosened to make working with Gadget actions easierno-console
added as Gadget provides alogger
object.gadget.ts
files are ignored because the Gadget server has a tendency to reformat them
- tsconfig is declared inline as Gadget does not support
- Some deviations:
.yarn
added to.ignore
and.gitignore
(not strictly necessary as yarn classic doesn't create this folder)
- Develop locally in an IDE
- Git repository is source of truth for code, not Gadget server
- Exceptions to the above are
.gadget.ts
files (schemas etc.), which are easier to work with in the Gadget editor
- Exceptions to the above are
- Sync code with a separate environment, and test in a separate app linked to that environment
- When ready to promote to development, make a pull request
Important
Gadget requires Yarn Classic. Corepack should detect this from the packageManager
property in package.json
- Open the Gadget Editor:
https://<your-app-name>.gadget.app/edit/development
- Create a new development environment, cloning
development
(Gadget documentation) - Clone this repository and sync local files with the server:
git clone https://github.com/aligent/gadget-bigcommerce-typescript-template.git app-name
cd ./app-name
yarn gadget:link app-name environment-name
Tip
If prompted about conflicts, choose these options:
- Merge local and environment's changes
- Keep local conflicting changes
Caution
Outright discarding files from the Gadget environment can leave it in an unusable state. If this happens you will need to push up a working app to the environment.
run yarn lint --fix
in another terminal to identify (if possible) fix any linting errors in pulled down files
- Open
Settings > Plugins > BigCommerce
in the Gadget Editor with your environment selected - Follow the instructions under
Create a single-click BigCommerce app
, taking care to:- Create a new app in the BigCommerce Developer Portal
- Fill in all the callback URLs (Make sure to click
Show all URLs
in Gadget)
- Open
Apps > My Apps > My Draft Apps
in the BigCommerce Admin and install your app
Important
If multiple versions of an app are installed in one BigCommerce stores their processes may conflict. It's recommended to have different stores for testing each environment.
- Create a feature branch from development
- Make code changes with
ggt dev
running, test in connected environment - Commit changes to feature branch and PR back to
development
- When PR is accepted, sync
development
branch and environment on Gadget:
npx ggt push --env development
Read our gadget-specific development notes.
Local development
package.json
contains scripts for standard tasks - linting, testing, checking typescript compilation- Each of these is run as a pre-commit hook.
- Automated testing is currently stubbed.
Source control
- A pipeline runs linting and testing on Pull Requests.
- Types are not checked because they rely on type declarations in the
.gadget
folder which we do not commit to source control.
- Work out how to protect
development
environment (or equivalentstaging
environment) so it is only modified by PR + pipeline - Set up automated testing