Skip to content

Commit

Permalink
Merge branch 'ubiquity:development' into improve-page-load
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Feb 19, 2024
1 parent 4184e42 commit 32e523d
Show file tree
Hide file tree
Showing 60 changed files with 5,563 additions and 1,420 deletions.
39 changes: 38 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
{
"words": ["WXDAI"]
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"useGitignore": true,
"language": "en",
"words": [
"binkey",
"binsec",
"cirip",
"dataurl",
"devpool",
"ethersproject",
"fract",
"gnosisscan",
"godb",
"greyscale",
"IERC",
"keccak",
"keypair",
"libsodium",
"Numberish",
"outdir",
"Rpcs",
"scalarmult",
"servedir",
"sonarjs",
"typebox",
"TYPEHASH",
"ubiquibot",
"UBIQUIBOT",
"URLSAFE",
"WXDAI",
"XDAI",
"xmark"
],
"dictionaries": ["typescript", "node", "software-terms", "html"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
}
108 changes: 108 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["./tsconfig.json"]
},
"plugins": ["@typescript-eslint", "sonarjs"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"],
"ignorePatterns": ["**/*.js"],
"rules": {
"prefer-arrow-callback": [
"warn",
{
"allowNamedFunctions": true
}
],
"func-style": [
"warn",
"declaration",
{
"allowArrowFunctions": false
}
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"constructor-super": "error",
"no-invalid-this": "off",
"@typescript-eslint/no-invalid-this": ["error"],
"no-restricted-syntax": ["error", "ForInStatement"],
"use-isnan": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
"args": "after-used",
"ignoreRestSiblings": true,
"vars": "all",
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"sonarjs/no-all-duplicated-branches": "error",
"sonarjs/no-collection-size-mischeck": "error",
"sonarjs/no-duplicated-branches": "error",
"sonarjs/no-element-overwrite": "error",
"sonarjs/no-identical-conditions": "error",
"sonarjs/no-identical-expressions": "error",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "interface",
"format": ["PascalCase"],
"custom": {
"regex": "^I[A-Z]",
"match": false
}
},
{
"selector": "memberLike",
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "require"
},
{
"selector": "typeLike",
"format": ["PascalCase"]
},
{
"selector": "typeParameter",
"format": ["PascalCase"],
"prefix": ["T"]
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow"
},
{
"selector": "variable",
"format": ["camelCase"],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow"
},
{
"selector": "variable",
"modifiers": ["destructured"],
"format": null
},
{
"selector": "variable",
"types": ["boolean"],
"format": ["PascalCase"],
"prefix": ["is", "should", "has", "can", "did", "will", "does"]
},
{
"selector": "variableLike",
"format": ["camelCase"]
},
{
"selector": ["function", "variable"],
"format": ["camelCase"]
}
]
}
}
6 changes: 6 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Resolves #

<!--
- You must link the issue number e.g. "Resolves #1234"
- Please do not replace the keyword "Resolves" https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->
31 changes: 31 additions & 0 deletions .github/workflows/cloudflare-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy to Cloudflare Pages

on:
push:

jobs:
deploy-to-cloudflare:
name: Deploy to Cloudflare Pages
runs-on: ubuntu-22.04
permissions:
contents: read

steps:
- name: Check Cloudflare API Token
run: |
if [[ -z "${{ secrets.CLOUDFLARE_API_TOKEN }}" ]]; then
echo "CLOUDFLARE_API_TOKEN secret must be set" >&2
exit 1
fi
- name: Deploy to Cloudflare
uses: ubiquity/cloudflare-deploy-action@main
with:
cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
repository: ${{ github.repository }}
production_branch: ${{ github.event.repository.default_branch }}
output_directory: "static"
is_production: ${{ github.event_name == 'push' && github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' }}
# env:
# Add any environment variables you need to pass along here
# SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
# SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
12 changes: 12 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Conventional Commits

on:
push:

jobs:
conventional-commits:
name: Conventional Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ubiquity/action-conventional-commits@master
24 changes: 24 additions & 0 deletions .github/workflows/cspell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Spell Check

on:
push:

jobs:
spellcheck:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.10.0"

- name: Install cspell
run: yarn add cspell

- name: Run cspell
run: yarn format:cspell
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ out
.yarn
.DS_Store
commit.txt
# macOS
# node
# yarn2
.pnp.cjs
.pnp.loader.mjs
static/dist
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
12 changes: 5 additions & 7 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"useTabs": false,
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "avoid",
"singleQuote": false,
"printWidth": 160,
"proseWrap": "preserve",
"tabWidth": 2,
"htmlWhitespaceSensitivity": "strict",
"singleQuote": false
"plugins": [],
"useTabs": false
}
36 changes: 34 additions & 2 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
import esbuild from "esbuild";
import { esBuildContext } from "./esbuild-config";
esbuild.build(esBuildContext);
const typescriptEntries = [
"static/scripts/rewards/index.ts",
"static/scripts/audit-report/audit.ts",
"static/scripts/onboarding/onboarding.ts",
"static/scripts/key-generator/keygen.ts",
];
const cssEntries = ["static/styles/rewards/rewards.css", "static/styles/audit-report/audit.css", "static/styles/onboarding/onboarding.css"];
export const entries = [...typescriptEntries, ...cssEntries];

export const esBuildContext: esbuild.BuildOptions = {
sourcemap: true,
entryPoints: entries,
bundle: true,
minify: false,
loader: {
".png": "dataurl",
".woff": "dataurl",
".woff2": "dataurl",
".eot": "dataurl",
".ttf": "dataurl",
".svg": "dataurl",
},
outdir: "static/out",
};

esbuild
.build(esBuildContext)
.then(() => {
console.log("\tesbuild complete");
})
.catch((err) => {
console.error(err);
process.exit(1);
});
27 changes: 0 additions & 27 deletions build/esbuild-config.ts

This file was deleted.

17 changes: 12 additions & 5 deletions build/esbuild-server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import esbuild from "esbuild";
import { esBuildContext } from "./esbuild-config";
import { esBuildContext } from "./esbuild-build";

async function server() {
const ctx = await esbuild.context(esBuildContext);
const { host, port } = await ctx.serve({
(async () => {
await server();
})().catch((error) => {
console.error("Unhandled error:", error);
process.exit(1);
});

export async function server() {
const _context = await esbuild.context(esBuildContext);
const { port } = await _context.serve({
servedir: "static",
port: 8080,
});
console.log(`http://localhost:${port}`);
}
server();
4 changes: 4 additions & 0 deletions build/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as dotenv from "dotenv";
// load environment variables (if you have them)
dotenv.config();
console.log("Welcome to ts-template");
4 changes: 2 additions & 2 deletions build/plugins/invert-colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import path, { basename, dirname } from "path";
export const invertColors: esbuild.Plugin = {
name: "invert-colors",
setup(build) {
build.onEnd(async result => {
build.onEnd(async (result) => {
console.log(result);
});
build.onLoad({ filter: /\.css$/ }, async args => {
build.onLoad({ filter: /\.css$/ }, async (args) => {
const contents = await fs.promises.readFile(args.path, "utf8");

const updatedContents = contents.replace(/prefers-color-scheme: dark/g, "prefers-color-scheme: light");
Expand Down
6 changes: 3 additions & 3 deletions globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export interface EthereumIsh {
isMetaMask?: boolean;
isStatus?: boolean;
networkVersion: string;
selectedAddress: any;
selectedAddress: string;

on(event: "close" | "accountsChanged" | "chainChanged" | "networkChanged", callback: (payload: any) => void): void;
once(event: "close" | "accountsChanged" | "chainChanged" | "networkChanged", callback: (payload: any) => void): void;
on(event: "close" | "accountsChanged" | "chainChanged" | "networkChanged", callback: (payload: unknown) => void): void;
once(event: "close" | "accountsChanged" | "chainChanged" | "networkChanged", callback: (payload: unknown) => void): void;
}

declare global {
Expand Down
Loading

0 comments on commit 32e523d

Please sign in to comment.