Skip to content

Commit

Permalink
feat(sdk): init sdk package with biome and a precommit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ga-reth committed Dec 3, 2024
1 parent 24a42cc commit e3fb674
Show file tree
Hide file tree
Showing 14 changed files with 1,168 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,11 @@ repos:
entry: .pre-commit/run_solhint.sh
types: [ file, solidity ]
require_serial: true

- id: run-sdk-checks
name: run-sdk-checks
language: script
entry: .pre-commit/run_sdk_checks.sh
files: ^sdk/.*\.(ts|tsx)$
types: [ file, ts ]
pass_filenames: true
30 changes: 30 additions & 0 deletions .pre-commit/run_sdk_checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# get dir
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# nav to sdk dir
SDK_DIR="$SCRIPT_DIR/../sdk"

# when running pre-commit, files are passed as args
# when running git hook, find ourselves
if [ $# -eq 0 ]; then
TS_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep "^sdk.*\.\(ts\|tsx\)$" || true)
else
TS_FILES="$@"
fi

if [ -n "$TS_FILES" ]; then
echo "Running SDK checks..."
cd "$SDK_DIR"

# clean + build
echo "Building SDK..."
pnpm build:clean

# precommit checks (Biome)
echo "Running SDK checks..."
pnpm precommit

echo "SDK checks completed..."
fi
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ We are open to contributions, but don't currently have a formal process for cont
Follow these steps to set up a functional development environment:

1. Install Docker Desktop.
2. [Create a PGP key pair](https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key) and [add the public key to Github](https://docs.github.com/en/authentication/managing-commit-signature-verification/adding-a-gpg-key-to-your-github-account).
2. Setup commit signing:
2a. [Create a PGP key pair](https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key)
2b. [Add the public key to Github](https://docs.github.com/en/authentication/managing-commit-signature-verification/adding-a-gpg-key-to-your-github-account).
2c. [Enabled commit signing](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)
3. Run `make setup` to initialize your dev environment. See `Makefile` for details.

## Security
Expand Down
7 changes: 7 additions & 0 deletions sdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
cache
node_modules
tsconfig.build.tsbuildinfo

# compiled output
/lib
5 changes: 5 additions & 0 deletions sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Omni SDK

## Overview

The Omni SDK is a TypeScript library for interfacing with the Omni network.
35 changes: 35 additions & 0 deletions sdk/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": ["dist", "tsconfig.json", "tsconfig.*.json"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"formatWithErrors": false,
"indentWidth": 2,
"lineWidth": 80
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"trailingCommas": "all",
"semicolons": "asNeeded"
}
}
}
22 changes: 22 additions & 0 deletions sdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "omni-sdk",
"version": "0.0.1",
"type": "module",
"license": "GPL-3.0-only",
"packageManager": "[email protected]",
"sideEffects": false,
"scripts": {
"clean": "rm -rf dist",
"build": "tsc -p tsconfig.build.json",
"build:clean": "pnpm clean && pnpm build",
"precommit": "biome check --write"
},
"files": ["src/*", "dist/*"],
"engines": {
"node": "22.x"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"typescript": "5.7.2"
}
}
121 changes: 121 additions & 0 deletions sdk/pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./types/index.js"
Loading

0 comments on commit e3fb674

Please sign in to comment.