Skip to content

Commit

Permalink
Add a local development flake and contributing instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
airhorns committed Nov 27, 2024
1 parent 1da300e commit fcdd3e0
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use flake

source_env_if_exists .envrc.local
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
*.js
!shopify.js
!gitpkg.config.js
dist/
dist/
.direnv
14 changes: 14 additions & 0 deletions Contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Development environment

We use nix to manage the development environment for this package. Run `direnv allow` to load the devshell, with node and other utilities ready to go.

Then, run `pnpm install` to install the dependencies.

See the readme for instructions on re-scraping the schemas from Shopify's docs.

# Releasing

Releases are managed automatically by Github Actions. To create a new release, follow these steps:

1. Run `npm version minor|major|patch`. This will change the version in the package.json and create a new git commit changing it.
2. Push this commit to the `main` branch. CI will run the tests, then run the release workflow, which publishes to NPM, create a Github release, and creates a git tag for the version.
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
description = "shopify-webhook-schemas development environment";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};

outputs = { self, flake-utils, nixpkgs }:
(flake-utils.lib.eachSystem [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(system: nixpkgs.lib.fix (flake:
let
pkgs = nixpkgs.legacyPackages.${system};
in
rec {

packages =
rec {
bash = pkgs.bash;
nodejs = pkgs.nodejs_22;
corepack = pkgs.corepack;
};

devShell = pkgs.mkShell {
packages = builtins.attrValues packages;
};
}
)));
}
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/scrape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ const docsWebhooksPageForVersion = (version: string) => `https://shopify.dev/doc
let warnings = 0;
let errors = 0;

const sortStringArrays = (obj: Object) => {
const sortStringArrays = (obj: Record<string, any>) => {
return cloneDeepWith(obj, (value) => {
if (Array.isArray(value) && value.every((item) => typeof item === "string")) {
return value.sort();
}
});
};

const getDeterministicObject = (obj: Object): Object => {
const getDeterministicObject = (obj: Record<string, any>): Record<string, any> => {
const stableString = stringify(sortStringArrays(obj));
return JSON.parse(stableString!);
};
Expand Down

0 comments on commit fcdd3e0

Please sign in to comment.