diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml new file mode 100644 index 00000000..42c45f93 --- /dev/null +++ b/.github/actions/install-dependencies/action.yml @@ -0,0 +1,12 @@ +name: "Install dependencies" +description: "Prepare repository and all dependencies" + +runs: + using: "composite" + steps: + - name: Set up Bun + uses: oven-sh/setup-bun@v1 + + - name: Install dependencies + shell: bash + run: bun install \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..bc63aca3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'monthly' diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml new file mode 100644 index 00000000..63062818 --- /dev/null +++ b/.github/workflows/canary.yml @@ -0,0 +1,38 @@ +name: Release (Canary) +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + canary: + name: Release canary + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Install dependencies + uses: ./.github/actions/install-dependencies + + - name: Setup .npmrc file + uses: actions/setup-node@v3 + with: + registry-url: 'https://registry.npmjs.org' + + - name: Set version + run: | + jq --arg prop "workspaces" 'del(.[$prop])' package.json > package.tmp.json && rm package.json && cp package.tmp.json package.json && rm package.tmp.json + cd src + npm --no-git-tag-version version 0.0.0 + npm --no-git-tag-version version $(npm pkg get version | sed 's/"//g')-$(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//').$(date +'%Y%m%dT%H%M%S') + + - name: Build + run: bun run build + + - name: Publish to npm + run: cd src && npm publish --tag $(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//') + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/on-pull-request.yml b/.github/workflows/on-pull-request.yml new file mode 100644 index 00000000..0b555d2c --- /dev/null +++ b/.github/workflows/on-pull-request.yml @@ -0,0 +1,14 @@ +name: Pull request +on: + pull_request: + types: [opened, reopened, synchronize, ready_for_review] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + verify: + name: Verify + uses: ./.github/workflows/verify.yml + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/on-push-to-main.yml b/.github/workflows/on-push-to-main.yml new file mode 100644 index 00000000..470d0b80 --- /dev/null +++ b/.github/workflows/on-push-to-main.yml @@ -0,0 +1,41 @@ +name: Main +on: + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + verify: + name: Verify + uses: ./.github/workflows/verify.yml + secrets: inherit + + changesets: + name: Changesets + needs: verify + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Clone repository + uses: actions/checkout@v4 + with: + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits + fetch-depth: 0 + + - name: Install dependencies + uses: ./.github/actions/install-dependencies + + - name: Create version pull request or publish to npm + uses: changesets/action@v1 + with: + title: 'chore: version packages' + commit: 'chore: version packages' + publish: bun run changeset:release + version: bun run changeset:version + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 00000000..c50d8e5c --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,57 @@ +name: Verify +on: + workflow_call: + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Install dependencies + uses: ./.github/actions/install-dependencies + + - name: Lint code + run: bun run format && bun run lint + + - uses: stefanzweifel/git-auto-commit-action@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + commit_message: 'chore: format' + commit_user_name: 'github-actions[bot]' + commit_user_email: 'github-actions[bot]@users.noreply.github.com' + + types: + name: Types + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Install dependencies + uses: ./.github/actions/install-dependencies + + - name: Check types + run: bun run typecheck + + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Install dependencies + uses: ./.github/actions/install-dependencies + + - name: Build + run: bun run build + + - name: Run tests + run: bun run test \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..fc347eff --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.map +coverage +lib +node_modules +tsconfig.*.tsbuildinfo +tsconfig.tsbuildinfo \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..699ed733 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["biomejs.biome"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..223cd892 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,25 @@ +{ + "editor.defaultFormatter": "biomejs.biome", + "editor.formatOnSave": true, + "typescript.tsdk": "node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true, + "editor.codeActionsOnSave": { + "source.organizeImports.biome": "explicit" + }, + "[json]": { + "editor.defaultFormatter": "biomejs.biome" + }, + "[javascript]": { + "editor.defaultFormatter": "biomejs.biome" + }, + "[javascriptreact]": { + "editor.defaultFormatter": "biomejs.biome" + }, + "[typescript]": { + "editor.defaultFormatter": "biomejs.biome" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "biomejs.biome" + }, + "css.validate": false +} diff --git a/README.md b/README.md new file mode 100644 index 00000000..9a6bbc2e --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# π‘­π’“π’‚π’Žπ’†work + +A Framework for Farcaster Frames. \ No newline at end of file diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..64196dbd --- /dev/null +++ b/biome.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", + "files": { + "ignore": [ + "coverage", + "node_modules", + "src/vendor", + "tsconfig.json", + "tsconfig.*.json" + ] + }, + "organizeImports": { + "enabled": true + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 2 + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + } +} diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 00000000..a5cf57fb Binary files /dev/null and b/bun.lockb differ diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/example/README.md b/example/README.md new file mode 100644 index 00000000..6dd13e7c --- /dev/null +++ b/example/README.md @@ -0,0 +1,11 @@ +To install dependencies: +```sh +bun install +``` + +To run: +```sh +bun run dev +``` + +open http://localhost:3000 diff --git a/example/package.json b/example/package.json new file mode 100644 index 00000000..0adf2d2d --- /dev/null +++ b/example/package.json @@ -0,0 +1,11 @@ +{ + "scripts": { + "dev": "bun run --hot src/index.ts" + }, + "dependencies": { + "hono": "^3.12.8" + }, + "devDependencies": { + "@types/bun": "latest" + } +} diff --git a/example/src/index.ts b/example/src/index.ts new file mode 100644 index 00000000..9869eb80 --- /dev/null +++ b/example/src/index.ts @@ -0,0 +1,9 @@ +import { Hono } from "hono"; + +const app = new Hono(); + +app.get("/", (c) => { + return c.text("Hello Hono!"); +}); + +export default app; diff --git a/example/tsconfig.json b/example/tsconfig.json new file mode 100644 index 00000000..c442b33f --- /dev/null +++ b/example/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "strict": true, + "jsx": "react-jsx", + "jsxImportSource": "hono/jsx" + } +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..5452ac79 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "workspaces": ["src"], + "scripts": { + "build": "bun run clean && tsc --project ./tsconfig.build.json", + "changeset": "changeset", + "changeset:release": "bun run build && changeset publish", + "changeset:version": "changeset version && bun install --lockfile-only", + "clean": "rimraf src/index.js src/lib src/tsconfig.build.tsbuildinfo", + "format": "biome format . --write", + "lint": "biome check . --apply", + "test": "vitest", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "@biomejs/biome": "^1.5.3", + "@changesets/changelog-github": "^0.5.0", + "@changesets/cli": "^2.27.1", + "@types/bun": "latest", + "@vitest/coverage-v8": "^1.2.2", + "hono": "^3.12.8", + "rimraf": "^5.0.5", + "typescript": "^5.0.0", + "vitest": "^1.2.2" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 00000000..1e29c457 --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export const hello = "world"; diff --git a/src/package.json b/src/package.json new file mode 100644 index 00000000..87f254c4 --- /dev/null +++ b/src/package.json @@ -0,0 +1,12 @@ +{ + "name": "@wevm/framework", + "version": "0.0.0", + "type": "module", + "module": "lib/index.js", + "types": "lib/index.d.ts", + "typings": "lib/index.d.ts", + "sideEffects": false, + "peerDependencies": { + "hono": "^3" + } +} diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 00000000..ece0415b --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,39 @@ +{ + // This tsconfig file contains the shared config for the build (tsconfig.build.json) and type checking (tsconfig.json) config. + "include": [], + "compilerOptions": { + // Incremental builds + // NOTE: Enabling incremental builds speeds up `tsc`. Keep in mind though that it does not reliably bust the cache when the `tsconfig.json` file changes. + "incremental": true, + + // Type checking + "strict": true, + "useDefineForClassFields": true, // Not enabled by default in `strict` mode unless we bump `target` to ES2022. + "noFallthroughCasesInSwitch": true, // Not enabled by default in `strict` mode. + "noImplicitReturns": true, // Not enabled by default in `strict` mode. + "useUnknownInCatchVariables": true, // TODO: This would normally be enabled in `strict` mode but would require some adjustments to the codebase. + "noImplicitOverride": true, // Not enabled by default in `strict` mode. + "noUnusedLocals": true, // Not enabled by default in `strict` mode. + "noUnusedParameters": true, // Not enabled by default in `strict` mode. + + // JavaScript support + "allowJs": false, + "checkJs": false, + + // Interop constraints + "esModuleInterop": false, + "allowSyntheticDefaultImports": false, + "forceConsistentCasingInFileNames": true, + "verbatimModuleSyntax": true, + "importHelpers": true, // This is only used for build validation. Since we do not have `tslib` installed, this will fail if we accidentally make use of anything that'd require injection of helpers. + + // Language and environment + "moduleResolution": "NodeNext", + "module": "NodeNext", + "target": "ES2021", // Setting this to `ES2021` enables native support for `Node v16+`: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping. + "lib": ["ES2022", "DOM"], + + // Skip type checking for node modules + "skipLibCheck": true + } +} \ No newline at end of file diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 00000000..d8c2f06e --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,18 @@ +{ + // This file is used to compile the for cjs and esm (see package.json build scripts). It should exclude all test files. + "extends": "./tsconfig.base.json", + "include": ["src"], + "exclude": [ + "src/**/*.test.ts", + "src/**/*.test.tsx", + "src/**/*.test-d.ts", + "src/**/*.test-d.tsx" + ], + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "./src/lib", + "rootDir": "./src" + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..c9624a66 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,9 @@ +{ + // This configuration is used for local development and type checking. + "extends": "./tsconfig.base.json", + "include": ["src"], + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "hono/jsx" + } +} \ No newline at end of file