Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
Sync template (manual resolution required) (#1)
Browse files Browse the repository at this point in the history
* feat: initial commit

* feat: add TS support

* feat: add conventional commits

* feat: add dotenv

* docs: add readme

* feat: add pull request template

* Create cloudflare-deploy

* feat: create helloWorld index.html

* feat: push action for development branch

* feat: update readme

* Update cloudflare-deploy.yml

* fix: rename pull_request_template

* Update conventional-commits.yml

Use our version which supports GitHub UI updates.

* chore: update dependencies and prettier

* chore: update package json

* Update conventional-commits.yml

* Update cloudflare-deploy.yml

Had to fix because `.nvmrc` is not compatible 

```
error telegram-ubiquibot@1.0.0: The engine "node" is incompatible with this module. Expected version ">=v20.3.0". Got "18.14.1"
```

* Update cloudflare-deploy.yml

* feat: format on lint-staged

* fix: commit-msg script and add lint-staged command

* feat: prefer named functions

* feat: add naming conventions rule

* feat: easy ui support

* feat: easy ui support

* fix: prettier for css

* chore: add .env file to .gitignore

* fix: lint staged

* fix: lint staged

* chore: remove tabs

ubiquity-os/ubiquity-os-kernel#2 (comment)

* feat: reusable deploy script

* feat: ban non null assertions

resolves ubiquity/ts-template#7

* Update README.md

* feat: spell check on commit

* feat: copy typescript rules

https://github.com/krzkaczor/TypeStrict.git
thanks @krzkaczor

* chore: remove no unnecessary condition for false positives

* fix: forgot to include cspell

* fix: cspell ci

* fix(ci): cspell

* chore: remove deprecated

* feat(cspell): support colors

* fix(ci): cspell

* feat: production deploys

related ubiquity/pay.ubq.fi#153

* chore: set up build for cd

* chore(deps): upgrade all

* chore: test on another brnach

* chore: bump ci

* chore: bump ci

* chore: bump ci

* chore: bump ci

* chore: bump ci

* chore: bump ci

* feat: workflow dispatch

* Merge branch 'test/cd'

* chore: debug cd

* chore: debug cd

* chore: debug cd

* chore: debug cd

* feat: add knip CI configuration

Resolves: ubiquity/ts-template#12

* feat: commit or pr

* feat: workflow dispatch

* chore: test env vars

* Squashed commit of the following:

commit 1dcef50
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 06:52:34 2024 +0900

    chore: test env vars

commit 126e819
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 06:51:03 2024 +0900

    feat: workflow dispatch

commit dbec9e3
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 06:39:04 2024 +0900

    feat: commit or pr

commit d61f01e
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 04:18:18 2024 +0900

    chore: debug cd

commit 9a8fc77
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 04:07:39 2024 +0900

    chore: debug cd

commit ea72c5e
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 04:06:43 2024 +0900

    chore: debug cd

commit de20331
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 04:01:17 2024 +0900

    chore: debug cd

commit dc336a9
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 03:46:41 2024 +0900

    feat: workflow dispatch

commit 0002fec
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 03:41:18 2024 +0900

    chore: bump ci

commit 56a8cf8
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 03:34:16 2024 +0900

    chore: bump ci

commit ad2564c
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 03:33:38 2024 +0900

    chore: bump ci

commit 3ad759b
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 03:20:33 2024 +0900

    chore: bump ci

commit 8b25785
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Tue Feb 20 01:46:52 2024 +0900

    chore: bump ci

commit d117e10
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Mon Feb 19 23:33:58 2024 +0900

    chore: bump ci

commit d3b5d08
Author: アレクサンダー.eth <gpg@pavlovcik.com>
Date:   Mon Feb 19 21:46:37 2024 +0900

    chore: test on another brnach

* fix: whitespace

* fix: transport secrets

* fix: app installation if

* feat: new github env style

* chore: update Knip yaml actions

As suggested during pull request review.

* chore: update supabase key name

ref: ubiquity/pay.ubq.fi#164 (comment)

* fix(ci): on prs

* fix: change dist to static

untested but in a rush and i think this is correct

* Update esbuild-server.ts

* fix: gitignore

* fix: commit sha

* feat: default Jest testing configuration

* Update .github/workflows/jest-testing.yml

* chore: moved jest config from js to ts

* chore: removed unused check to trigger Jest Action

* feat: cypress testing suite

* feat: default Jest testing configuration (ubiquity#19)

* feat: default Jest testing configuration

* Update .github/workflows/jest-testing.yml

* chore: moved jest config from js to ts

* chore: removed unused check to trigger Jest Action

---------

Co-authored-by: アレクサンダー.eth <4975670+pavlovcik@users.noreply.github.com>

* chore: updated yarn.lock

* chore: removed checks for warn messages in the console

* fix: disabled comments on every push, and added default value for coverage

* chore: moved knip configuration

* chore: workflow dispatch for knip

* chore: workflow dispatch for knip

* chore: changed action target to pull_request_target

* chore: added test section to README.md

* ci(cspell): fix

* Create CODEOWNERS

Congratulations on the promotion @FernandVEYRIER

* chore: added missing dep

* chore: added ignore rules to knip

* chore: removed ts-node dep and changed jest config

* chore: added ternary rules for eslint

* chore: fixed trailing space in conf

* ci: add init workflow

* feat: release please Action

* chore: changed release to target default branch

* chore: changed release to target default branch

* chore: added permissions to release please

* chore: removed npm env variable

* Update release-please.yml

* Update CODEOWNERS

* ci: pass cloudflare credentials

* ci: add reusable cloudflare deploy

* ci: use single action

* ci: update deploy.yml

* chore: add pascal case linter to enforce Erc20Permit and Erc721Permit naming conventions

* chore: enable StrictPascalCase on all Identifiers

* chore: undo unnecessary changes

* chore: add eslint-filename plugin

* revert camelCase deletions and change to strictCamelCase

* fix: use regex and ignore e2e.ts

* chore: eslint config type inference

* chore: update knip configuration in the template to run on pull_request

* fix: moved eslint from js to json and accept numbers in file names

* fix: workflow release please

* fix: workflow cypress

* chore: test reporting lib

* chore: test reporting lib

* chore: test reporting lib

* chore: test reporting lib

* Update jest-testing.yml

* chore: find PR number

* chore: remove event

* chore: test pr number

* chore: test pr number

* chore: test pr number

* chore: test comment

* chore: test comment

* chore: revert default branch for release-please.yml

* chore: revert default branch for release-please.yml

* fix: fixed conflicts

---------

Co-authored-by: rndquu <rndquu@gmail.com>
Co-authored-by: アレクサンダー.eth <gpg@pavlovcik.com>
Co-authored-by: 0xCodercrane <108444211+0xcodercrane@users.noreply.github.com>
Co-authored-by: アレクサンダー.eth <4975670+pavlovcik@users.noreply.github.com>
Co-authored-by: rndquu <119500907+rndquu@users.noreply.github.com>
Co-authored-by: Korrrba <gitcoiner@gmail.com>
Co-authored-by: Fernando <fernand.veyrier@epitech.eu>
Co-authored-by: Fernand <FernandVEYRIER@users.noreply.github.com>
Co-authored-by: jordan-ae <arreyetta1jnr@gmail.com>
Co-authored-by: jordan-ae <arreyetta1jrn@gmail.com>
Co-authored-by: Keyrxng <106303466+Keyrxng@users.noreply.github.com>
Co-authored-by: アレクサンダー.eth <4975670+0x4007@users.noreply.github.com>
Co-authored-by: Mentlegen <9807008+gentlementlegen@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Aries Gunawan <aries.thio@hotmail.com>
  • Loading branch information
16 people authored Oct 13, 2024
1 parent 83e44bd commit 98a4480
Show file tree
Hide file tree
Showing 29 changed files with 4,186 additions and 1,364 deletions.
9 changes: 8 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"words": ["devpool", "octocat", "ratelimit", "supabase", "UBIQUIBOT"]
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir", "octocat", "ratelimit", "supabase", "UBIQUIBOT", "greyscale", "devrel", "fract", "VZLJ", "localstorage"],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
}
56 changes: 41 additions & 15 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,53 @@
"parserOptions": {
"project": ["./tsconfig.json"]
},
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"plugins": ["@typescript-eslint", "sonarjs", "filename-rules"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"],
"ignorePatterns": ["**/*.js"],
"rules": {
"prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }], // Disallow arrow functions as expressions
"func-style": ["warn", "declaration", { "allowArrowFunctions": false }], // Disallow the use of function expressions
"filename-rules/match": [2, "/^(e2e\\.ts$|.*\/e2e\\.ts$|[a-z0-9]+(?:[-._a-z0-9]+)*\\.ts|\\.[a-z0-9]+)$/"],
"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",
"no-unneeded-ternary": "error",
"no-nested-ternary": "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": "typeLike", "format": ["PascalCase"] },
{ "selector": "variableLike", "format": ["camelCase"] },
{ "selector": "memberLike", "modifiers": ["private"], "format": ["camelCase"], "leadingUnderscore": "require" },
{ "selector": "variable", "types": ["boolean"], "format": ["PascalCase"], "prefix": ["is", "should", "has", "can", "did", "will"] },
{ "selector": "variable", "format": ["camelCase", "UPPER_CASE"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" },
{ "selector": "typeParameter", "format": ["PascalCase"], "prefix": ["T"] },
{ "selector": "interface", "format": ["PascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } },
{ "selector": ["function", "variable"], "format": ["camelCase"] },
{ "selector": "interface", "format": ["StrictPascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } },
{ "selector": "memberLike", "modifiers": ["private"], "format": ["strictCamelCase"], "leadingUnderscore": "require" },
{ "selector": "typeLike", "format": ["StrictPascalCase"] },
{ "selector": "typeParameter", "format": ["StrictPascalCase"], "prefix": ["T"] },
{ "selector": "variable", "format": ["strictCamelCase", "UPPER_CASE"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" },
{ "selector": "variable", "format": ["strictCamelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" },
{ "selector": "variable", "modifiers": ["destructured"], "format": null },
{ "selector": "variable", "format": ["camelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" },
{ "selector": "variable", "types": ["boolean"], "format": ["PascalCase"], "prefix": ["is", "has", "should", "can", "did", "will"] }
{ "selector": "variable", "types": ["boolean"], "format": ["StrictPascalCase"], "prefix": ["is", "should", "has", "can", "did", "will", "does"] },
{ "selector": "variableLike", "format": ["strictCamelCase"] },
{ "selector": ["function", "variable"], "format": ["strictCamelCase"] }
]
}
}
}
13 changes: 13 additions & 0 deletions .github/knip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { KnipConfig } from "knip";

const config: KnipConfig = {
entry: ["build/index.ts"],
project: ["src/**/*.ts"],
ignore: ["src/types/config.ts", "**/__mocks__/**", "**/__fixtures__/**"],
ignoreExportsUsedInFile: true,
// eslint can also be safely ignored as per the docs: https://knip.dev/guides/handling-issues#eslint--jest
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "@types/jest", "@mswjs/data"],
eslint: true,
};

export default config;
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
11 changes: 5 additions & 6 deletions .github/workflows/cypress-testing.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Run Cypress testing suite
on:
workflow_dispatch:
pull_request:
workflow_run:
workflows: ["Build"]
types:
- completed

jobs:
cypress-run:
Expand All @@ -18,12 +21,8 @@ jobs:
build: yarn run build
start: yarn start
env:
NODE_ENV: "test"
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Values are set because the code requires them, but they are not actually used.
SUPABASE_URL: "https://wfzpewmlyiozupulbuur.supabase.co"
SUPABASE_ANON_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndmenBld21seWlvenVwdWxidXVyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTU2NzQzMzksImV4cCI6MjAxMTI1MDMzOX0.SKIL3Q0NOBaMehH0ekFspwgcu3afp3Dl9EDzPqs1nKs"
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand All @@ -35,4 +34,4 @@ jobs:
with:
name: cypress-videos
path: cypress/videos
if-no-files-found: ignore
if-no-files-found: ignore
31 changes: 31 additions & 0 deletions .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Run Jest testing suite
on:
workflow_dispatch:
workflow_run:
workflows: ["Build"]
types:
- completed

env:
NODE_ENV: "test"

jobs:
testing:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: "20.10.0"

- uses: actions/checkout@master
with:
fetch-depth: 0

- name: Jest With Coverage Comment
# Ensures this step is run even on previous step failure (e.g. test failed)
if: always()
uses: ArtiomTr/jest-coverage-report-action@v2
with:
package-manager: yarn
prnumber: ${{ github.event.pull_request.number || github.event.workflow_run.pull_requests[0].number }}
38 changes: 38 additions & 0 deletions .github/workflows/knip-reporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Knip-reporter

on:
workflow_run:
workflows: ["Knip"]
types:
- completed

jobs:
knip-reporter:
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: knip-results
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Read pr number
id: pr-number
uses: juliangruber/read-file-action@v1
with:
path: ./pr-number.txt
trim: true

- name: Report knip results to pull request
if: ${{ github.event.workflow_run.conclusion != 'success' }}
uses: gitcoindev/knip-reporter@main
with:
verbose: true
comment_id: ${{ github.workflow }}-reporter
command_script_name: knip-ci
annotations: true
ignore_results: false
json_input: true
json_input_file_name: knip-results.json
pull_request_number: ${{ steps.pr-number.outputs.content }}
token: ${{ secrets.GITHUB_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Knip

on:
pull_request:

jobs:
run-knip:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

# needed to use yarn v4
- name: Enable corepack
run: corepack enable

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.10.0

- name: Install toolchain
run: yarn install

- name: Store PR number
run: echo ${{ github.event.number }} > pr-number.txt

- name: Run Knip
run: yarn knip --no-exit-code || yarn knip --reporter json > knip-results.json
env: # Set environment variables for the build
SUPABASE_URL: "https://wfzpewmlyiozupulbuur.supabase.co"
SUPABASE_ANON_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndmenBld21seWlvenVwdWxidXVyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTU2NzQzMzksImV4cCI6MjAxMTI1MDMzOX0.SKIL3Q0NOBaMehH0ekFspwgcu3afp3Dl9EDzPqs1nKs"

- name: Upload knip result
if: failure()
uses: actions/upload-artifact@v4
with:
name: knip-results
path: |
knip-results.json
pr-number.txt
26 changes: 26 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: release-please

on:
workflow_dispatch:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: node
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.10.0"
registry-url: https://registry.npmjs.org/
- run: |
yarn install --immutable --immutable-cache --check-cache
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ node_modules
.pnp.loader.mjs
static/dist
.env

coverage
junit.xml
cypress/screenshots
cypress/videos
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit "$1"
yarn lint-staged
yarn lint-staged
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
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"singleQuote": false,
"printWidth": 160,
"htmlWhitespaceSensitivity": "strict",
"plugins": []
"plugins": [],
"useTabs": false
}
5 changes: 3 additions & 2 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ function createEnvDefines(environmentVariables: string[], generatedAtBuild: Reco
throw new Error(`Missing environment variable: ${name}`);
}
}
for (const key in generatedAtBuild) {
// for (const key in generatedAtBuild) {
Object.keys(generatedAtBuild).forEach((key) => {
if (Object.prototype.hasOwnProperty.call(generatedAtBuild, key)) {
defines[key] = JSON.stringify(generatedAtBuild[key]);
}
}
});
return defines;
}

Expand Down
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");
11 changes: 11 additions & 0 deletions cypress/e2e/main.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe("Homepage tests", () => {
it("Console is cleared of errors and warnings", () => {
cy.visit("/", {
onBeforeLoad(win) {
cy.stub(win.console, "error").as("consoleError");
},
});
cy.get("@consoleError").should("not.be.called");
cy.get("body").should("exist");
});
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
Loading

0 comments on commit 98a4480

Please sign in to comment.