Skip to content

Commit

Permalink
Modernize package setup (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiodxa authored Jun 3, 2024
1 parent 4916ae8 commit d211497
Show file tree
Hide file tree
Showing 16 changed files with 218 additions and 35 deletions.
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2

updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
reviewers:
- "sergiodxa"
assignees:
- "sergiodxa"

- package-ecosystem: npm
directory: /
schedule:
interval: "weekly"
reviewers:
- "sergiodxa"
assignees:
- "sergiodxa"
14 changes: 10 additions & 4 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
changelog:
categories:
- title: Documentation Changes
labels:
- documentation
- title: New Features
labels:
- enhancement
- title: Documentation Changes
labels:
- documentation
- title: Bug Fixes
labels:
- bug
- title: Example
labels:
- example
- title: Deprecations
labels:
- deprecated
- title: Other Changes
labels:
- "*"
- "*"
5 changes: 3 additions & 2 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
version:
description: "Semver type of new version (major / minor / patch)"
description: "Type of version to bump"
required: true
type: choice
options:
Expand All @@ -22,7 +22,7 @@ jobs:
ssh-key: ${{ secrets.DEPLOY_KEY }}

- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun install --frozen-lockfile

- uses: actions/setup-node@v4
with:
Expand All @@ -33,4 +33,5 @@ jobs:
git config user.email '[email protected]'
- run: npm version ${{ github.event.inputs.version }}
- run: bun run quality:fix
- run: git push origin main --follow-tags
26 changes: 22 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ name: CI
on: [push]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install --frozen-lockfile
- run: bun run build

typecheck:
name: Typechecker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun install --frozen-lockfile
- run: bun run typecheck

quality:
Expand All @@ -18,14 +27,23 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bunx biome ci .
- run: bun install --frozen-lockfile
- run: bun run quality

test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun install --frozen-lockfile
- run: bun test

exports:
name: Verify Exports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install --frozen-lockfile
- run: bun run exports
24 changes: 24 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Enable auto-merge for Dependabot PRs

on:
pull_request:
types: opened

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
33 changes: 33 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy Documentation

on:
push:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "docs"
cancel-in-progress: false

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install --frozen-lockfile
- run: bunx typedoc
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: "./docs"
- uses: actions/deploy-pages@v4
id: deployment
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun install --frozen-lockfile
- run: bun run build
- run: npx exports

- uses: actions/setup-node@v4
with:
Expand Down
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/node_modules
/build
/coverage

*.log
.DS_Store
/docs
/node_modules
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Run `bun install` to install the dependencies.

Run the tests with `bun test`.

Run the linter with `bun run lint`.
Run the code quality checker with `bun run quality`.

Run the typechecker with `bun run typecheck`.

Run the exports checker with `bun run exports`.
Binary file modified bun.lockb
Binary file not shown.
55 changes: 38 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,52 @@
{
"name": "remix-auth-form",
"version": "1.5.0",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"type": "commonjs",
"description": "A Remix Auth strategy to work with any form",
"license": "MIT",
"funding": ["https://github.com/sponsors/sergiodxa"],
"author": {
"name": "Sergio Xalambrí",
"email": "[email protected]",
"url": "https://sergiodxa.com"
},
"repository": {
"type": "git",
"url": "https://github.com/sergiodxa/remix-auth-form"
},
"homepage": "https://sergiodxa.github.io/remix-auth-form",
"bugs": {
"url": "https://github.com/sergiodxa/remix-auth-form/issues"
},
"scripts": {
"prepare": "bun run build",
"build": "tsc --project tsconfig.json",
"typecheck": "tsc --project tsconfig.json --noEmit",
"check": "biome check .",
"lint": "biome lint --apply .",
"format": "biome format --write ."
"build": "tsc",
"typecheck": "tsc --noEmit",
"quality": "biome check .",
"quality:fix": "biome check . --apply-unsafe",
"exports": "bun run ./scripts/exports.ts"
},
"sideEffects": false,
"type": "module",
"engines": {
"node": ">=20.0.0"
},
"keywords": ["remix", "remix-auth", "auth", "authentication", "strategy"],
"license": "MIT",
"files": ["build", "package.json", "README.md"],
"exports": {
".": "./build/index.js",
"./package.json": "./package.json"
},
"peerDependencies": {
"@remix-run/server-runtime": "^1.0.0 || ^2.0.0",
"remix-auth": "^3.6.0"
},
"devDependencies": {
"@biomejs/biome": "^1.7.1",
"@remix-run/node": "2.9.1",
"@remix-run/server-runtime": "2.9.1",
"@types/bun": "^1.1.0",
"remix-auth": "3.6.0",
"typescript": "5.4.5"
"@arethetypeswrong/cli": "^0.15.3",
"@biomejs/biome": "^1.7.2",
"@remix-run/node": "^2.9.2",
"@types/bun": "^1.1.1",
"consola": "^3.2.3",
"remix-auth": "^3.7.0",
"typedoc": "^0.25.13",
"typedoc-plugin-mdn-links": "^3.1.23",
"typescript": "^5.4.5"
}
}
48 changes: 48 additions & 0 deletions scripts/exports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { file, spawn } from "bun";
import { consola } from "consola";

let proc = spawn([
"bunx",
"attw",
"-f",
"table-flipped",
"--no-emoji",
"--no-color",
"--pack",
]);

let text = await new Response(proc.stdout).text();

let entrypointLines = text
.slice(text.indexOf('"remix-utils/'))
.split("\n")
.filter(Boolean)
.filter((line) => !line.includes("─"))
.map((line) =>
line
.replaceAll(/[^\d "()/A-Za-z│-]/g, "")
.replaceAll("90m│39m", "│")
.replaceAll(/^│/g, "")
.replaceAll(/│$/g, ""),
);

let pkg = await file("package.json").json();
let entrypoints = entrypointLines.map((entrypointLine) => {
let [entrypoint, ...resolutionColumns] = entrypointLine.split("│");
return {
entrypoint: entrypoint.replace(pkg.name, ".").trim(),
esm: resolutionColumns[2].trim(),
bundler: resolutionColumns[3].trim(),
};
});

let entrypointsWithProblems = entrypoints.filter(
(item) => item.esm.includes("fail") || item.bundler.includes("fail"),
);

if (entrypointsWithProblems.length > 0) {
consola.error("Entrypoints with problems:");
process.exit(1);
} else {
consola.success("All entrypoints are valid!");
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppLoadContext, SessionStorage } from "@remix-run/server-runtime";
import type { AppLoadContext, SessionStorage } from "@remix-run/server-runtime";
import { AuthenticateOptions, Strategy } from "remix-auth";

export interface FormStrategyVerifyParams {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"lib": ["ESNext"],
"esModuleInterop": true,
"moduleResolution": "NodeNext",
"module": "NodeNext",
Expand Down
10 changes: 10 additions & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://typedoc.org/schema.json",
"includeVersion": true,
"entryPoints": ["./src/index.ts"],
"out": "docs",
"json": "docs/index.json",
"cleanOutputDir": true,
"plugin": ["typedoc-plugin-mdn-links"],
"categorizeByGroup": false
}

0 comments on commit d211497

Please sign in to comment.