Skip to content

Commit

Permalink
Merge pull request #302 from NibiruChain/develop
Browse files Browse the repository at this point in the history
chore: develop -> main
  • Loading branch information
cgilbe27 authored Feb 5, 2024
2 parents f4ca6a2 + 4f93be8 commit 2d84236
Show file tree
Hide file tree
Showing 100 changed files with 1,449 additions and 1,083 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

21 changes: 0 additions & 21 deletions .eslintrc.js

This file was deleted.

16 changes: 16 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"env": {
"browser": true,
"es6": true,
"node": true,
"jest/globals": true
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "jest", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
]
}
28 changes: 20 additions & 8 deletions .github/workflows/test-ts-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,27 @@ jobs:
with:
cmd: build

- name: Run Nibiru network in the background (scripts/localnet.sh)
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: nibibot
password: ${{ secrets.NIBIBOT_GIT_TOKEN }}

- name: Checkout nibiru Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
repository: NibiruChain/nibiru
ref: main
path: "nibiru"
token: ${{ secrets.NIBIBOT_GIT_TOKEN }}

- name: Run Nibiru network in the background
run: |
# Install nibid CLI
# Use https://get.nibiru.fi/ to get the most recent release.
curl -s https://get.nibiru.fi/@v0.21.9! | bash
# Sanity check nibid CLI
nibid version
# Start local network
bash scripts/localnet.sh &
cd nibiru
make chaosnet
cd ..
- name: yarn test
uses: borales/actions-yarn@v4
Expand Down
19 changes: 12 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
reports
junit.xml
dist
temp
.build-cache
.DS_STORE
# Created by https://www.gitignore.io/api/node,intellij+all,visualstudiocode
# Edit at https://www.gitignore.io/?templates=node,intellij+all,visualstudiocode

docs/
src/protojs/
proto/
src/indexer-nibi/gql/
src/gql/utils/generated.ts
src/gql/utils/schema.graphql
dist
**/node_modules/*
nibiru/


reports
junit.xml
temp
.build-cache
.DS_STORE

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
Expand Down
4 changes: 0 additions & 4 deletions .prettierrc.js

This file was deleted.

4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": false,
"endOfLine": "lf"
}
2 changes: 1 addition & 1 deletion barrelsby.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory": ["./src/sdk", "./src/indexer-nibi"]
"directory": ["./src/sdk", "./src/gql"]
}
30 changes: 15 additions & 15 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Config } from "jest"
const { pathsToModuleNameMapper } = require("ts-jest")

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { compilerOptions } = require("./tsconfig")

// For a detailed explanation regarding each configuration property, visit:
Expand All @@ -9,24 +10,29 @@ const config: Config = {
verbose: true,
collectCoverage: true,
collectCoverageFrom: [
"src/**/*.{js,jsx,ts,tsx}",
"**/*.{js,jsx,ts,tsx}",
"!**/docs/**",
"!**/node_modules/**",
"!**/coverage/**",
"!**/dist/**",
"!**/nibiru/**",
"!**/index.*.ts",
"!**/index.ts",
"!**/sdk/test/helpers.ts",
"!**/src/protojs/**",
"!jest.config.ts",
"!**/src/gql/utils/generated.ts",
"!**/src/sdk/utils/testutil.ts",
],
coveragePathIgnorePatterns: ["/node_modules/", "/dist/", "/src/protojs/"],
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
coverageReporters: ["json-summary", "text", "html", "lcov"],
coverageThreshold: {
global: {
branches: 75,
functions: 75,
lines: 75,
statements: 75,
branches: 85,
functions: 85,
lines: 85,
statements: 85,
},
},
coverageProvider: "v8",
globals: {
window: {
location: {},
Expand All @@ -35,16 +41,10 @@ const config: Config = {
moduleDirectories: ["<rootDir>", "node_modules", "src"],
moduleFileExtensions: ["js", "jsx", "ts", "tsx"],
modulePaths: [compilerOptions.baseUrl], // <-- This will be set to 'baseUrl' value
moduleNameMapper: {
"~/(.*)": "<rootDir>/src/$1",
...pathsToModuleNameMapper(compilerOptions.paths),
},
roots: ["<rootDir>"],
modulePathIgnorePatterns: ["examples"],
preset: "ts-jest",
testEnvironment: "node",
reporters: ["default"],
testPathIgnorePatterns: ["/node_modules/", "/build/", "/coverage/", "/dist/"],
testTimeout: 120000,
}

Expand Down
1 change: 0 additions & 1 deletion nibiru
Submodule nibiru deleted from 3aba36
46 changes: 21 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,30 @@
"dist"
],
"scripts": {
"generate-barrels": "barrelsby -c barrelsby.json --delete -l all -s flat -S -e \".test.ts|.config.ts|.codegen.ts\"",
"generate-barrels": "barrelsby -c barrelsby.json --delete -l all -S -e \".test.ts|.config.ts|.codegen.ts\"",
"build": "bash ./scripts/build.sh",
"build:tsc": "rm -rf dist && tsc --build",
"build:watch": "tsc --build --watch",
"docgen": "yarn run typedoc --tsconfig tsconfig.json --plugin typedoc-plugin-markdown --plugin typedoc-plugin-missing-exports",
"docgen:changes": "git diff-index --name-only origin/HEAD -- | grep -q \"src\" && yarn docgen || true",
"clean": "tsc --clean",
"commit": "cz",
"gql-generate": "rm -rf src/indexer-nibi/gql && graphql-code-generator --config codegen.ts",
"gql-generate": "graphql-code-generator --config ./src/gql/graphql-codegen/codegen.ts",
"test": "jest",
"test:verbose": "jest --verbose --detectOpenHandles",
"test:watch": "jest --watch",
"coverage": "jest --coverage",
"lint": "eslint -c './.eslintrc.js' './**/*.{ts,js}'",
"lint": "eslint -c .eslintrc.json './**/*.{ts,js}'",
"lint:ci": "yarn lint . --format junit",
"lint:md": "markdownlint --ignore node_modules --ignore .git",
"localnet": "bash scripts/localnet.sh",
"format": "yarn lint --fix",
"format:md": "yarn lint:md --fix",
"proto-gen": "bash ./scripts/protocgen.sh",
"prettier": "prettier --write . --ignore-path .gitignore",
"prepare": "husky install",
"semantic-release": "semantic-release"
},
"lint-staged": {
"*.{js,ts}": [
"eslint --fix",
"prettier --write . --ignore-path .gitignore",
"git add ."
],
"*.json": [
"prettier --write . --ignore-path .gitignore",
"git add ."
]
"eslint": "eslint --fix . --ignore-path .gitignore",
"semantic-release": "semantic-release",
"prepare": "husky install"
},
"dependencies": {
"@cosmjs/cosmwasm-stargate": "^0.31.0",
Expand All @@ -55,8 +45,7 @@
"@cosmjs/tendermint-rpc": "^0.31.0",
"bignumber.js": "^9.1.1",
"cross-fetch": "4.0.0",
"graphql-ws": "^5.14.0",
"long": "^5.2.0"
"graphql-ws": "^5.14.0"
},
"peerDependencies": {
"@cosmjs/cosmwasm-stargate": "^0.31.0",
Expand All @@ -71,18 +60,15 @@
"@graphql-codegen/cli": "^4.0.1",
"@graphql-codegen/client-preset": "^4.0.1",
"@graphql-codegen/typescript": "^4.0.1",
"@keplr-wallet/types": "^0.12.12",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@types/jest": "^29.1.2",
"@types/long": "^4.0.0",
"@types/node": "^16.11.7",
"@types/node-fetch": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.30.7",
"barrelsby": "^2.8.1",
"commitizen": "^4.2.4",
"cosmjs-types": "^0.8.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
Expand All @@ -91,12 +77,11 @@
"graphql": "^16.7.1",
"husky": "^7.0.2",
"jest": "^29.0.0",
"jest-junit": "^12.2.0",
"lint-staged": "^13.2.2",
"long": "^5.2.0",
"markdownlint-cli": "^0.28.1",
"prettier": "^2.4.1",
"semantic-release": "19.0.5",
"semantic-release-monorepo": "^7.0.5",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typedoc": "^0.24.8",
Expand All @@ -105,6 +90,17 @@
"typescript": "^4.4.3",
"ws": "^8.14.1"
},
"lint-staged": {
"*.{js,ts}": [
"eslint --fix . --ignore-path .gitignore",
"prettier --write . --ignore-path .gitignore",
"git add ."
],
"*.json": [
"prettier --write . --ignore-path .gitignore",
"git add ."
]
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
Expand All @@ -115,10 +111,10 @@
"tag": "latest",
"access": "public"
},
"gitHead": "bac1729be8575a9e75bf9e04447a63c45e227c8c",
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
}
},
"gitHead": "bac1729be8575a9e75bf9e04447a63c45e227c8c"
}
28 changes: 15 additions & 13 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/bin/bash
set -e

# TODO: This assumes nibiru is a relative path in the current working directory, but this doesn't work locally
cd nibiru
git checkout releases/v0.21.x
cd ..
yarn gql-generate
yarn proto-gen
yarn build:tsc

echo "Fix path resolution"
dist_folder="./dist"
# Go through all ts and js files in the dist folder
find "$dist_folder" -type f \( -name "*.ts" -o -name "*.js" \) -exec sed -i 's|require("@/|require("src/|g' {} +
# Test for ./nibiru/ directory
if [ -d "./nibiru/" ]; then
echo "The ./nibiru/ directory exists."
cd nibiru
git checkout releases/v0.21.x
cd ..
else
cd ../nibiru
git checkout releases/v0.21.x
git pull
cd ../ts-sdk
fi

# yarn docgen
yarn gql-generate & yarn proto-gen
yarn build:tsc
yarn docgen
Loading

1 comment on commit 2d84236

@github-actions
Copy link

Choose a reason for hiding this comment

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

Lines Statements Branches Functions
Coverage: 93%
94.62% (1197/1265) 87.82% (541/616) 88.03% (309/351)

Please sign in to comment.