generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7945e98
Showing
24 changed files
with
6,234 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MY_SECRET="MY_SECRET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": ["./tsconfig.json"] | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/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 | ||
"@typescript-eslint/no-floating-promises": "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": "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"] } | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Deploy to Cloudflare Pages | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Conventional Commits"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
deploy-to-cloudflare: | ||
name: Deploy to Cloudflare Pages | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20.10.0" | ||
|
||
- name: Yarn Install | ||
run: yarn install | ||
|
||
- name: Build the project | ||
run: yarn build | ||
|
||
- name: Wrangler Install | ||
run: yarn add wrangler | ||
|
||
- name: Publish to Cloudflare | ||
env: | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
REPOSITORY: ${{ github.repository }} | ||
PRODUCTION_BRANCH: "development" | ||
OUTPUT_DIRECTORY: "static" | ||
run: | | ||
IFS='/' read -ra fields <<< "$REPOSITORY" | ||
projectName="${fields[1]}" | ||
echo $projectName | ||
yarn wrangler pages project list > project_list.txt | ||
if grep -q $projectName project_list.txt; then | ||
echo "Project found" | ||
else | ||
echo "Project not found" | ||
yarn wrangler pages project create "$projectName" --production-branch "$PRODUCTION_BRANCH" | ||
fi | ||
yarn wrangler pages publish "$OUTPUT_DIRECTORY" --project-name "$projectName" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Conventional Commits | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [development] | ||
|
||
jobs: | ||
conventional-commits: | ||
name: Conventional Commits | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ubiquity/action-conventional-commits@master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# macOS | ||
.DS_Store | ||
# node | ||
node_modules | ||
# yarn2 | ||
.yarn | ||
.pnp.cjs | ||
.pnp.loader.mjs | ||
static/dist | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v20.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": false, | ||
"printWidth": 160, | ||
"htmlWhitespaceSensitivity": "strict", | ||
"plugins": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodeLinker: node-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# `@ubiquity/ts-template` | ||
|
||
This template repository includes support for the following: | ||
|
||
- TypeScript | ||
- Environment Variables | ||
- Conventional Commits | ||
- Automatic publishing of pull requests to Cloudflare Pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import esbuild from "esbuild"; | ||
const typescriptEntries = ["static/main.ts"]; | ||
// const cssEntries = ["static/style.css"]; | ||
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/dist", | ||
}; | ||
|
||
esbuild | ||
.build(esBuildContext) | ||
.then(() => { | ||
console.log("\tesbuild complete"); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import esbuild from "esbuild"; | ||
import { esBuildContext } from "./esbuild-build"; | ||
|
||
(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}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"name": "ts-template", | ||
"version": "1.0.0", | ||
"description": "Template repository with TypeScript support.", | ||
"main": "build/index.ts", | ||
"author": "Ubiquity DAO", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=20.10.0" | ||
}, | ||
"scripts": { | ||
"start": "tsx build/esbuild-server.ts", | ||
"build": "tsx build/esbuild-build.ts", | ||
"format": "run-s format:prettier format:lint", | ||
"format:lint": "eslint --fix .", | ||
"format:prettier": "prettier --write .", | ||
"prepare": "husky install" | ||
}, | ||
"keywords": [ | ||
"typescript", | ||
"template", | ||
"dao", | ||
"ubiquity", | ||
"open-source" | ||
], | ||
"dependencies": { | ||
"dotenv": "^16.3.1" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^18.4.3", | ||
"@commitlint/config-conventional": "^18.4.3", | ||
"@types/node": "^20.10.0", | ||
"@typescript-eslint/eslint-plugin": "^6.13.1", | ||
"@typescript-eslint/parser": "^6.13.1", | ||
"esbuild": "^0.19.8", | ||
"eslint": "^8.54.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-prettier": "^5.0.1", | ||
"husky": "^8.0.3", | ||
"knip": "^3.3.0", | ||
"lint-staged": "^15.1.0", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^3.1.0", | ||
"tsx": "^4.6.0", | ||
"typescript": "^5.3.2" | ||
}, | ||
"lint-staged": { | ||
"*.ts": [ | ||
"yarn prettier --write", | ||
"eslint --fix" | ||
] | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Ubiquity TypeScript Template</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
<body> | ||
<h1>Ubiquity TypeScript Template</h1> | ||
<script type="module" src="dist/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export async function mainModule() { | ||
console.log(`Hello from mainModule`); | ||
} | ||
mainModule() | ||
.then(() => { | ||
console.log("mainModule loaded"); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
body { | ||
font-family: "Proxima Nova", "Ubiquity Nova", sans-serif; | ||
background-color: #06061aff; | ||
color: #fff; | ||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABYWlDQ1BrQ0dDb2xvclNwYWNlRGlzcGxheVAzAAAokWNgYFJJLCjIYWFgYMjNKykKcndSiIiMUmB/yMAOhLwMYgwKicnFBY4BAT5AJQwwGhV8u8bACKIv64LMOiU1tUm1XsDXYqbw1YuvRJsw1aMArpTU4mQg/QeIU5MLikoYGBhTgGzl8pICELsDyBYpAjoKyJ4DYqdD2BtA7CQI+whYTUiQM5B9A8hWSM5IBJrB+API1klCEk9HYkPtBQFul8zigpzESoUAYwKuJQOUpFaUgGjn/ILKosz0jBIFR2AopSp45iXr6SgYGRiaMzCAwhyi+nMgOCwZxc4gxJrvMzDY7v////9uhJjXfgaGjUCdXDsRYhoWDAyC3AwMJ3YWJBYlgoWYgZgpLY2B4dNyBgbeSAYG4QtAPdHFacZGYHlGHicGBtZ7//9/VmNgYJ/MwPB3wv//vxf9//93MVDzHQaGA3kAFSFl7jXH0fsAAAA4ZVhJZk1NACoAAAAIAAGHaQAEAAAAAQAAABoAAAAAAAKgAgAEAAAAAQAAABigAwAEAAAAAQAAABgAAAAAwf1XlwAAACNJREFUSA3t0IEAAAAMBKFHm7/UTaQQWnXDgAEDBgwYMGDgAXaJAz4RVVHYAAAAAElFTkSuQmCC"); | ||
} | ||
@font-face { | ||
font-family: "Ubiquity Nova"; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url(./fonts/ubiquity-nova-standard.eot); | ||
src: | ||
url(./fonts/ubiquity-nova-standard.eot#iefix) format("embedded-opentype"), | ||
url(./fonts/ubiquity-nova-standard.woff) format("woff"), | ||
url(./fonts/ubiquity-nova-standard.ttf) format("truetype"); | ||
} |
Oops, something went wrong.