Skip to content

Commit 185404f

Browse files
committed
feat: prepare for public
1 parent ad48dae commit 185404f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1761
-914
lines changed

.changeset/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"linked": [],
77
"access": "public",
88
"updateInternalDependencies": "patch",
9-
"ignore": ["@acme/docs"]
9+
"baseBranch": "main",
10+
"ignore": ["@ajel/docs", "@ajel/benchmarks"]
1011
}

.github/workflows/docs.yml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Sample workflow for building and deploying a Next.js site to GitHub Pages
2+
#
3+
# To get started with Next.js see: https://nextjs.org/docs/getting-started
4+
#
5+
name: Deploy Next.js site to Pages
6+
7+
on:
8+
# Runs on pushes targeting the default branch
9+
push:
10+
branches: ["main"]
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
16+
permissions:
17+
contents: read
18+
pages: write
19+
id-token: write
20+
21+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
22+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
23+
concurrency:
24+
group: "pages"
25+
cancel-in-progress: false
26+
27+
jobs:
28+
# Build job
29+
build:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Setup pnpm 7
36+
uses: pnpm/action-setup@v2
37+
with:
38+
version: 7
39+
40+
- name: Setup Node
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: "20"
44+
cache: ${{ steps.detect-package-manager.outputs.manager }}
45+
46+
- name: Setup Pages
47+
uses: actions/configure-pages@v4
48+
with:
49+
# Automatically inject basePath in your Next.js configuration file and disable
50+
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
51+
#
52+
# You may remove this line if you want to manage the configuration yourself.
53+
static_site_generator: next
54+
55+
- name: Restore cache
56+
uses: actions/cache@v3
57+
with:
58+
path: |
59+
.next/cache
60+
# Generate a new cache whenever packages or source files change.
61+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
62+
# If source files changed but packages didn't, rebuild from a prior cache.
63+
restore-keys: |
64+
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-
65+
66+
- name: Install Dependencies
67+
run: pnpm i
68+
69+
- name: Build with Next.js
70+
working-directory: apps/docs
71+
run: pnpm build
72+
73+
- name: Upload artifact
74+
uses: actions/upload-pages-artifact@v3
75+
with:
76+
path: apps/docs/out
77+
78+
# Deployment job
79+
deploy:
80+
environment:
81+
name: github-pages
82+
url: ${{ steps.deployment.outputs.page_url }}
83+
runs-on: ubuntu-latest
84+
needs: build
85+
steps:
86+
- name: Deploy to GitHub Pages
87+
id: deployment
88+
uses: actions/deploy-pages@v4

.github/workflows/release.nopeyml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# name: Release
2+
3+
# on:
4+
# push:
5+
# branches:
6+
# - main
7+
8+
# concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
# jobs:
11+
# release:
12+
# name: Release
13+
# runs-on: ubuntu-latest
14+
# steps:
15+
# - name: Checkout Repo
16+
# uses: actions/checkout@v2
17+
18+
# - name: Setup pnpm 7
19+
# uses: pnpm/action-setup@v2
20+
# with:
21+
# version: 7
22+
23+
# - name: Setup Node.js 18.x
24+
# uses: actions/setup-node@v2
25+
# with:
26+
# node-version: 18.x
27+
28+
# - name: Install Dependencies
29+
# run: pnpm i
30+
31+
# - name: Create Release Pull Request or Publish to npm
32+
# id: changesets
33+
# uses: changesets/action@v1
34+
# with:
35+
# # This expects you to have a script called release which does a build for your packages and calls changeset publish
36+
# publish: pnpm release
37+
# env:
38+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
40+
41+
# - name: Send a Slack notification if a publish happens
42+
# if: steps.changesets.outputs.published == 'true'
43+
# # You can do something when a publish happens.
44+
# run: my-slack-bot send-notification --message "A new version of ${GITHUB_REPOSITORY} was published!"

.github/workflows/release.yml

-44
This file was deleted.

README.md

+54-49
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,78 @@
1-
# Turborepo Design System starter with Changesets
1+
<p align="center"><a href="https://github.com/Handfish/ajel" target="_blank"><img src="https://raw.githubusercontent.com/Handfish/ajel/main/apps/docs/public/ajel2.svg" width="100" alt="Laravel Logo"></a></p>
22

3-
This is an official React design system starter powered by Turborepo. Versioning and package publishing is handled by [Changesets](https://github.com/changesets/changesets) and fully automated with GitHub Actions.
3+
<p align="center">Ajel is a <b>312 byte</b> set of functions that encourage you to handle errors in a way that is similar to Golang.</p>
44

5-
## Using this example
5+
<p align="center">
6+
<a href="https://www.npmjs.com/ajel" target="_blank"><img src="https://img.shields.io/npm/v/ajel.svg" alt="NPM Version" /></a>
7+
<a href="https://www.npmjs.com/ajel" target="_blank"><img src="https://img.shields.io/npm/l/ajel.svg" alt="Package License" /></a>
8+
<a href="https://www.npmjs.com/ajel" target="_blank"><img src="https://img.shields.io/npm/dt/ajel.svg" alt="NPM Downloads" /></a>
9+
<a href="https://handfish.github.io/ajel" target="_blank"><img src="https://img.shields.io/badge/GitHub%20Pages-222222?style=for-the-badge&logo=GitHub%20Pages&logoColor=white" /></a>
10+
<a href="https://github.com/Handfish/ajel" target="_blank"><img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white" /></a>
11+
</p>
612

7-
Run the following command:
813

9-
```sh
10-
npx create-turbo@latest -e with-changesets
11-
```
12-
13-
## What's inside?
14-
15-
This Turborepo includes the following:
16-
17-
### Apps and Packages
18-
19-
- `docs`: A placeholder documentation site powered by [Next.js](https://nextjs.org/)
20-
- `@ajel/core`: core React components
21-
- `@ajel/utils`: shared React utilities
22-
- `@ajel/tsconfig`: shared `tsconfig.json`s used throughout the monorepo
23-
- `@ajel/eslint-config`: ESLint preset
2414

25-
Each package and app is 100% [TypeScript](https://www.typescriptlang.org/).
15+
# [ajel](https://handfish.github.io/ajel)
2616

27-
### Utilities
17+
### Installation
2818

29-
This Turborepo has some additional tools already setup for you:
19+
`yarn add ajel eslint-plugin-ajel`
3020

31-
- [TypeScript](https://www.typescriptlang.org/) for static type checking
32-
- [ESLint](https://eslint.org/) for code linting
33-
- [Prettier](https://prettier.io) for code formatting
21+
`pnpm add ajel eslint-plugin-ajel`
3422

35-
### Useful commands
3623

37-
- `yarn build` - Build all packages and the docs site
38-
- `yarn dev` - Develop all packages and the docs site
39-
- `yarn lint` - Lint all packages
40-
- `yarn changeset` - Generate a changeset
41-
- `yarn clean` - Clean up all `node_modules` and `dist` folders (runs each package's clean script)
24+
### Example usage
25+
```typescript
26+
// Handling async functions that throw
27+
import { ajel } from 'ajel';
4228

43-
### Changing the npm organization scope
29+
async function main() {
30+
const [result, err] = await ajel(Promise.resolve('hello world'));
4431

45-
The npm organization scope for this design system starter is `@ajel`. To change this, it's a bit manual at the moment, but you'll need to do the following:
32+
if (err) {
33+
return err;
34+
}
4635

47-
- Rename folders in `packages/*` to replace `ajel` with your desired scope
48-
- Search and replace `ajel` with your desired scope
49-
- Re-run `yarn install`
36+
return result;
37+
}
38+
```
5039

51-
## Versioning and Publishing packages
40+
```typescript
41+
// Handling synchronous functions that throw
42+
import { sjel } from 'ajel';
5243

53-
Package publishing has been configured using [Changesets](https://github.com/changesets/changesets). Please review their [documentation](https://github.com/changesets/changesets#documentation) to familiarize yourself with the workflow.
44+
function main() {
45+
const [result, err] = sjel(JSON.parse)("{}");
5446

55-
This example comes with automated npm releases setup in a [GitHub Action](https://github.com/changesets/action). To get this working, you will need to create an `NPM_TOKEN` and `GITHUB_TOKEN` in your repository settings. You should also install the [Changesets bot](https://github.com/apps/changeset-bot) on your GitHub repository as well.
47+
if (err) {
48+
return err;
49+
}
5650

57-
For more information about this automation, refer to the official [changesets documentation](https://github.com/changesets/changesets/blob/main/docs/automating-changesets.md)
51+
return result;
52+
}
53+
```
5854

59-
### npm
55+
`ajel` and `sjel` are a set of functions that return a tuple representing a potential result and a potential error.
56+
On success, the result item has value. On error, the error item has value. It's that simple.
6057

61-
If you want to publish package to the public npm registry and make them publicly available, this is already setup.
58+
More interestingly, it comes with a series of linting tools to help enforce the paradigm available in the package `eslint-plugin-ajel`
6259

63-
To publish packages to a private npm organization scope, **remove** the following from each of the `package.json`'s
60+
### Basic eslintrc
6461

65-
```diff
66-
- "publishConfig": {
67-
- "access": "public"
68-
- },
62+
```javascript
63+
{
64+
plugins: ['ajel'],
65+
extends: [
66+
'plugin:ajel/recommended',
67+
],
68+
}
6969
```
7070

71-
### GitHub Package Registry
71+
### What's inside this repo?
7272

73-
See [Working with the npm registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#publishing-a-package-using-publishconfig-in-the-packagejson-file)
73+
#### Apps and Packages
74+
75+
- `docs`: A placeholder documentation site powered by [Next.js](https://nextjs.org/)
76+
- `ajel`: The core library (function)
77+
- `eslint-plugin-ajel`: Eslint rules for proper usage and error handling paradigm
78+
- `benchmarks`: Testing ajel's performance against other methods

apps/docs/.eslintrc.js renamed to apps/docs/.eslintrc.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: true,
3-
extends: ["@acme/eslint-config/next.js"],
3+
extends: ["@ajel/eslint-config/next.js"],
44
parser: "@typescript-eslint/parser",
55
parserOptions: {
66
project: true,

apps/docs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
out

apps/docs/next.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ const withNextra = nextra({
99
themeConfig: './theme.config.jsx'
1010
})
1111

12-
export default withNextra()
12+
export default withNextra({
13+
output: "export",
14+
images: {
15+
unoptimized: true
16+
},
17+
basePath: '/ajel',
18+
})

apps/docs/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
1212
},
1313
"dependencies": {
14-
"@ajel/core": "workspace:*",
14+
"@next/eslint-plugin-next": "^14.0.4",
15+
"ajel": "workspace:*",
1516
"next": "^14.0.4",
1617
"nextra": "^2.13.2",
1718
"nextra-theme-blog": "^2.13.2",

apps/docs/src/components/NavLogo.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// import Image from "next/image";
2+
13
export default function NavLogo() {
24
return (
35
<div
@@ -8,9 +10,8 @@ export default function NavLogo() {
810
fontSize: "32px",
911
}}
1012
>
11-
{/* TODO: figure out how to size Logo and use that here instead */}
1213
<img
13-
src="/ajel2.svg"
14+
src="/ajel/ajel2.svg"
1415
style={{ height: "calc(var(--nextra-navbar-height) - 35px)" }}
1516
alt="ajel logo"
1617
/>

apps/docs/src/pages/_document.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Html, Head, Main, NextScript } from 'next/document'
2+
3+
export default function Document() {
4+
return (
5+
<Html lang="en">
6+
<Head>
7+
<link rel="shortcut icon" href="/ajel/favicon.ico" />
8+
</Head>
9+
<body>
10+
<Main />
11+
<NextScript />
12+
</body>
13+
</Html>
14+
)
15+
}

0 commit comments

Comments
 (0)