Skip to content

Commit

Permalink
add typesafe env package
Browse files Browse the repository at this point in the history
use typsafe env in @stax/backend

add workflows for doing releases

use workspaces publish

change @Stax to @roninjin10

pnpm update -r

fix broken ci scripts

fix typesafe-env docs

private: true in root
  • Loading branch information
Will Cory authored and Will Cory committed Jan 7, 2023
1 parent a7ff567 commit 5b263ae
Show file tree
Hide file tree
Showing 27 changed files with 1,678 additions and 1,386 deletions.
13 changes: 0 additions & 13 deletions .github/actions/build/action.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/publish-dry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

name: Publish no push

jobs:
build:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive

- name: 'Setup'
uses: ./.github/actions/setup

- name: Run build
run: pnpm build:ci
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

- name: Simulating publish package on NPM 📦
run: pnpm release:dry
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
workflow_dispatch:
release:

name: Publish

jobs:
build:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive

- name: 'Setup'
uses: ./.github/actions/setup

- name: Run build
run: pnpm build:ci
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

- name: Publish package on NPM 📦
run: pnpm release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A node library for interacting with evm based chains using the native solidity p

#### packages/ts-sol-react

A wrapper around ts-solidity based on wagmi and @stax/ts-solidity
A wrapper around ts-solidity based on wagmi and @roninjin10/ts-solidity

#### packages/ts-sol-plugin

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
extends:
file: docker-compose.base.yml
service: base-app
command: pnpm nx serve @stax/example-ui
command: pnpm nx serve @roninjin10/example-ui
ports:
- 3000:3001

Expand All @@ -15,6 +15,6 @@ services:
extends:
file: docker-compose.base.yml
service: base-app
command: pnpm nx serve @stax/example-server
command: pnpm nx serve @roninjin10/example-server
ports:
- 7300:7301
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "stax",
"name": "roninjin10",
"version": "0.0.0",
"private": true,
"engines": {
Expand All @@ -15,36 +15,38 @@
"typecheck": "nx run-many --target=typecheck",
"typecheck:ci": "nx run-many --target=typecheck:ci --parallel=3",
"test": "nx run-many --target=test",
"test:ci": "nx run-many --target=test:ci --parallel=3",
"test:ci": "nx run-many --target=test --parallel=3",
"build": "nx run-many --target=build",
"serve": "nx run-many --target=serve",
"serve:docker": "docker-compose up",
"build:ci": "nx run-many --target=build:ci --parallel=3",
"build:ci": "nx run-many --target=build --parallel=3",
"lint": "nx run-many --target=lint",
"lint:ci": "nx run-many --target=lint:ci --parallel=3",
"postinstall": "forge install"
"postinstall": "forge install",
"release": "pnpm publish -r --access=public",
"release:dry": "pnpm publish -r --access=public --dry-run"
},
"license": "MIT",
"packageManager": "[email protected]",
"dependencies": {
"@nrwl/nx-cloud": "^15.0.2",
"dotenv": "^16.0.3",
"nx": "^15.4.2",
"prettier": "^2.8.1",
"nx": "^15.4.5",
"prettier": "^2.8.2",
"prettier-plugin-solidity": "^1.1.1",
"solhint": "^3.3.7",
"solhint-plugin-prettier": "^0.0.5",
"typescript": "^4.9.4"
},
"devDependencies": {
"@babel/core": "^7.20.7",
"@babel/core": "^7.20.12",
"@babel/preset-typescript": "^7.18.6",
"@types/node": "^18.11.18",
"@typescript-eslint/parser": "^5.47.1",
"@typescript-eslint/parser": "^5.48.0",
"babel": "^6.23.0",
"concurrently": "^7.6.0",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-jsdoc": "^39.6.4",
"eslint-plugin-simple-import-sort": "^8.0.0",
"ts-node": "^10.9.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "@stax/contracts",
"name": "@roninjin10/contracts",
"version": "0.0.0",
"main": "src/AppEntrypoint.sol",
"license": "MIT",
Expand Down
15 changes: 8 additions & 7 deletions packages/example-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@
"lint:ci": "eslint \"**/*.{ts,tsx}\" && prettier --check \"src/**/*.{ts,tsx}\""
},
"dependencies": {
"@preconstruct/cli": "^2.2.2",
"@prisma/client": "^4.6.1",
"@trpc/server": "^10.5.0",
"fastify": "^4.10.2",
"fastify-metrics": "^10.0.1",
"prisma": "^4.7.1",
"superjson": "^1.10.1",
"@prisma/client": "^4.8.1",
"@roninjin10/typesafe-env": "workspace:*",
"@trpc/server": "^10.8.1",
"fastify": "^4.11.0",
"fastify-metrics": "^10.0.2",
"prisma": "^4.8.1",
"superjson": "^1.12.1",
"trpc-playground": "^1.0.4",
"typescript": "^4.9.4",
"zod": "^3.20.2"
},
"devDependencies": {
"@preconstruct/cli": "^2.3.0",
"nodemon": "^2.0.20"
}
}
9 changes: 4 additions & 5 deletions packages/example-server/src/Env.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { generateEnvDocs, typesafeEnv } from '@roninjin10/typesafe-env'
import { z } from 'zod'

import { getEnvSchema, getTypesafeEnv } from './lib/TypesafeEnv'

/**
* A typesafe wrapper around process.env
*/
export class Env {
public static getEnv() {
return getTypesafeEnv(Env.validators)
return typesafeEnv(Env.validators)
}

public static getEnvSchema() {
return getEnvSchema(Env.validators)
return generateEnvDocs(Env.validators)
}

private static readonly validators = {
HOST: z.string().default('localhost')
.describe(`HOST server should connect to
.describe(`HOST server should connect to
Must be set to 0.0.0.0 in a docker container`),

PORT: z
Expand Down
4 changes: 2 additions & 2 deletions packages/example-ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ RUN pnpm i --frozen-lockfile --ignore-scripts

COPY ./ /app

RUN pnpm nx build @stax/example-ui
RUN pnpm nx build @roninjin10/example-ui
# server build needs to run after client build because the client build using Vite
# removes the dist/ folder before compiling its code

EXPOSE 3000

CMD ["pnpm", "nx", "serve", "@stax/example-ui"]
CMD ["pnpm", "nx", "serve", "@roninjin10/example-ui"]
26 changes: 13 additions & 13 deletions packages/example-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@stax/example-ui",
"name": "@roninjin10/example-ui",
"version": "0.0.1",
"private": true,
"scripts": {
Expand All @@ -11,34 +11,34 @@
"preview": "vite preview"
},
"dependencies": {
"@babel/core": "^7.20.5",
"@tanstack/query-core": "^4.20.4",
"@tanstack/react-query": "^4.20.4",
"@babel/core": "^7.20.12",
"@tanstack/query-core": "^4.20.9",
"@tanstack/react-query": "^4.20.9",
"buffer": "^6.0.3",
"connectkit": "^1.1.1",
"eslint": "^8.30.0",
"eslint": "^8.31.0",
"ethers": "^5.7.2",
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"util": "^0.12.4",
"wagmi": "~0.9.0"
"util": "^0.12.5",
"wagmi": "~0.9.6"
},
"devDependencies": {
"@babel/plugin-syntax-flow": "^7.18.6",
"@babel/plugin-transform-react-jsx": "^7.20.7",
"@playwright/test": "^1.29.0",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.3",
"@playwright/test": "^1.29.2",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@types/react-helmet": "^6.1.6",
"@vitejs/plugin-react": "^2.1.0",
"@vitejs/plugin-react": "^2.2.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-react-query": "^1.3.0",
"prettier": "^2.8.1",
"prettier": "^2.8.2",
"react-helmet": "^6.1.0",
"serve": "^14.1.2",
"typescript": "^4.9.4",
"vite": "^3.1.8"
"vite": "^3.2.5"
}
}
3 changes: 3 additions & 0 deletions packages/typesafe-env/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["../../.eslintrc.js"],
};
49 changes: 49 additions & 0 deletions packages/typesafe-env/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.env

cache
forge-artifacts
broadcast

# compiled output
dist
packages/*/dist
tmp
/out-tsc
**/tsconfig.tsbuildinfo

# dependencies
node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

**/lcov.info

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

# My personal files
.zshrc
1 change: 1 addition & 0 deletions packages/typesafe-env/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.12.1
7 changes: 7 additions & 0 deletions packages/typesafe-env/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": false,
"singleQuote": true,
"jsxSingleQuote": false,
"trailingComma": "all",
"arrowParens": "always"
}
22 changes: 22 additions & 0 deletions packages/typesafe-env/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright 2020-2022 Optimism

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 5b263ae

Please sign in to comment.