Skip to content

Commit

Permalink
feat: easy ui support
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Nov 29, 2023
1 parent f3997c9 commit 805224f
Show file tree
Hide file tree
Showing 17 changed files with 2,108 additions and 1,133 deletions.
3 changes: 0 additions & 3 deletions .commitlintrc

This file was deleted.

1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"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
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/cloudflare-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20.3.0"
node-version: "20.10.0"

- name: Yarn Install
run: yarn install

- name: Build the project
run: yarn build

- name: Wrangler Install
run: npm install -g wrangler
run: yarn add wrangler

- name: Publish to Cloudflare
env:
Expand All @@ -38,11 +41,11 @@ jobs:
IFS='/' read -ra fields <<< "$REPOSITORY"
projectName="${fields[1]}"
echo $projectName
wrangler pages project list > project_list.txt
yarn wrangler pages project list > project_list.txt
if grep -q $projectName project_list.txt; then
echo "Project found"
else
echo "Project not found"
wrangler pages project create "$projectName" --production-branch "$PRODUCTION_BRANCH"
yarn wrangler pages project create "$projectName" --production-branch "$PRODUCTION_BRANCH"
fi
wrangler pages publish "$OUTPUT_DIRECTORY" --project-name "$projectName"
yarn wrangler pages publish "$OUTPUT_DIRECTORY" --project-name "$projectName"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
.yarn
.pnp.cjs
.pnp.loader.mjs
static/dist
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.3.0
v20.10.0
33 changes: 33 additions & 0 deletions build/esbuild-build.ts
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);
});
18 changes: 18 additions & 0 deletions build/esbuild-server.ts
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}`);
}
File renamed without changes.
41 changes: 27 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
"name": "ts-template",
"version": "1.0.0",
"description": "Template repository with TypeScript support.",
"main": "index.ts",
"main": "build/index.ts",
"author": "Ubiquity DAO",
"license": "MIT",
"engines": {
"node": ">=v20.3.0"
"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 ."
"format:prettier": "prettier --write .",
"prepare": "husky install"
},
"keywords": [
"typescript",
Expand All @@ -24,20 +27,30 @@
"dotenv": "^16.3.1"
},
"devDependencies": {
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@types/node": "^20.3.2",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"eslint": "^8.43.0",
"@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",
"husky": "^8.0.3",
"knip": "^3.3.0",
"lint-staged": "^15.1.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"tsx": "^3.12.7",
"typescript": "^5.1.0"
"prettier": "^3.1.0",
"tsx": "^4.6.0",
"typescript": "^5.3.2"
},
"lint-staged": {
"*.ts": "yarn format"
"*.ts": [
"yarn format:prettier --write",
"yarn format:lint --fix"
]
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
}
}
}
Binary file added static/fonts/ubiquity-nova-standard.eot
Binary file not shown.
Binary file added static/fonts/ubiquity-nova-standard.ttf
Binary file not shown.
Binary file added static/fonts/ubiquity-nova-standard.woff
Binary file not shown.
10 changes: 7 additions & 3 deletions static/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<title>Hello, world!</title>
<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>Hello, world!</h1>
<h1>Ubiquity TypeScript Template</h1>
<script type="module" src="dist/main.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions static/main.ts
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);
});
14 changes: 14 additions & 0 deletions static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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");
}
26 changes: 16 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
Expand All @@ -25,17 +25,22 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
"resolveJsonModule": true /* Enable importing .json files. */,
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

/* JavaScript Support */
Expand All @@ -48,6 +53,7 @@
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
Expand All @@ -57,7 +63,6 @@
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
Expand All @@ -70,13 +75,14 @@

/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -98,6 +104,6 @@

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
Loading

0 comments on commit 805224f

Please sign in to comment.