Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text eol=lf
pnpm-lock.yaml linguist-generated
18 changes: 12 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,32 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['20.x', '22.x', '23.x']
node: ['20.x', '22.x', '24.x', '25.x']
os: [ubuntu-latest]

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.0

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: pnpm

- name: Install with yarn
run: corepack enable && yarn
- name: Install with pnpm
run: pnpm install --frozen-lockfile

- name: Lint
run: yarn lint
run: pnpm lint

- name: Test
run: yarn test
run: pnpm test

- name: Build
run: yarn build
run: pnpm build
104 changes: 104 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Publish to npm

on:
push:
branches:
- main

# Required permissions for npm provenance and GitHub releases
permissions:
contents: write
id-token: write

jobs:
check-version:
runs-on: ubuntu-latest
outputs:
version-changed: ${{ steps.check.outputs.changed }}
version: ${{ steps.check.outputs.version }}
should-publish: ${{ steps.check.outputs.should_publish }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Check if version should be published
id: check
run: |
# Get current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version in package.json: $CURRENT_VERSION"

# Get published version from npm (if it exists)
PUBLISHED_VERSION=$(npm view enwrap version 2>/dev/null || echo "none")
echo "Published version on npm: $PUBLISHED_VERSION"

# Compare versions
if [ "$PUBLISHED_VERSION" = "none" ]; then
echo "Package not yet published to npm"
echo "changed=true" >> $GITHUB_OUTPUT
echo "should_publish=true" >> $GITHUB_OUTPUT
elif [ "$CURRENT_VERSION" = "$PUBLISHED_VERSION" ]; then
echo "Version $CURRENT_VERSION is already published"
echo "changed=false" >> $GITHUB_OUTPUT
echo "should_publish=false" >> $GITHUB_OUTPUT
else
echo "Version changed from $PUBLISHED_VERSION to $CURRENT_VERSION"
echo "changed=true" >> $GITHUB_OUTPUT
echo "should_publish=true" >> $GITHUB_OUTPUT
fi

publish:
needs: check-version
if: needs.check-version.outputs.should-publish == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm lint

- name: Test
run: pnpm test

- name: Build
run: pnpm build

- name: Ensure recent npm for trusted publishing
run: npm install -g npm@latest

- name: Verify npm version
run: npm --version

- name: Publish to npm with provenance
run: npm publish --provenance --access public

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.check-version.outputs.version }}
name: v${{ needs.check-version.outputs.version }}
draft: false
prerelease: false
generate_release_notes: true
23 changes: 19 additions & 4 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@ on: [pull_request]
jobs:
size:
runs-on: ubuntu-latest
env:
CI_JOB_NUMBER: 1
steps:
- uses: actions/checkout@v4
- uses: andresz1/size-limit-action@v1

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version: 10.33.0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Check size
run: pnpm size
15 changes: 4 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
*.log
.DS_Store
.context/
node_modules
dist

# yarn
.yarn-integrity
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
yarn-debug.log*
yarn-error.log*
# pnpm
.pnpm-store/
pnpm-debug.log*
934 changes: 0 additions & 934 deletions .yarn/releases/yarn-4.5.3.cjs

This file was deleted.

7 changes: 0 additions & 7 deletions .yarnrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Unlike other libraries, Enwrap does not require you to learn a new, dramatically
## Installation

```bash
yarn add enwrap
pnpm add enwrap
```

## Usage
Expand Down
66 changes: 66 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import js from '@eslint/js'
import tsPlugin from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import perfectionist from 'eslint-plugin-perfectionist'
import prettierRecommended from 'eslint-plugin-prettier/recommended'
import simpleImportSort from 'eslint-plugin-simple-import-sort'

const tsEslintRecommendedRules =
tsPlugin.configs['eslint-recommended'].overrides[0].rules

const sortOptions = {
fallbackSort: { type: 'unsorted' },
ignoreCase: false,
newlinesBetween: 'ignore',
order: 'asc',
partitionByComment: false,
partitionByNewLine: false,
specialCharacters: 'keep',
type: 'natural',
}

export default [
{
ignores: ['dist/**/*'],
},
js.configs.recommended,
prettierRecommended,
{
files: ['**/*.{ts,tsx,mts,cts}'],
languageOptions: {
ecmaVersion: 2020,
parser: tsParser,
sourceType: 'module',
},
plugins: {
'@typescript-eslint': tsPlugin,
perfectionist,
'simple-import-sort': simpleImportSort,
},
rules: {
...tsEslintRecommendedRules,
...tsPlugin.configs.recommended.rules,
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
varsIgnorePattern: '^_',
},
],
curly: ['error', 'multi-line'],
eqeqeq: ['error', 'always', { null: 'ignore' }],
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
'no-throw-literal': 'error',
'perfectionist/sort-object-types': ['error', sortOptions],
'perfectionist/sort-objects': ['error', sortOptions],
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
},
},
]
33 changes: 16 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"build": "rm -rf dist && tsup src/index.ts --format cjs,esm --dts --minify --treeshake --clean",
"postpublish": "PACKAGE_VERSION=$(cat package.json | grep \\\"version\\\" | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$PACKAGE_VERSION && git push --tags",
"lint": "tsc && eslint src test",
"prepare": "yarn build",
"prepare": "pnpm build",
"size": "size-limit",
"test": "vitest"
},
Expand All @@ -51,23 +51,22 @@
}
],
"devDependencies": {
"@size-limit/preset-small-lib": "^11.2.0",
"@eslint/js": "10.0.1",
"@size-limit/preset-small-lib": "^12.0.1",
"@tsconfig/recommended": "^1.0.8",
"@typescript-eslint/eslint-plugin": "8.24.1",
"@typescript-eslint/parser": "8.24.1",
"eslint": "8.57.1",
"eslint-config-prettier": "10.0.1",
"eslint-import-resolver-typescript": "3.8.2",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-prettier": "5.2.3",
"eslint-plugin-simple-import-sort": "12.1.1",
"eslint-plugin-typescript-sort-keys": "3.3.0",
"prettier": "3.5.1",
"size-limit": "^11.2.0",
"@typescript-eslint/eslint-plugin": "8.58.1",
"@typescript-eslint/parser": "8.58.1",
"eslint": "10.2.0",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-perfectionist": "5.8.0",
"eslint-plugin-prettier": "5.5.5",
"eslint-plugin-simple-import-sort": "13.0.0",
"prettier": "3.8.2",
"size-limit": "^12.0.1",
"tsup": "^8.3.6",
"typescript": "^5.7.3",
"vite": "^6.1.1",
"vitest": "^3.0.6"
"typescript": "6.0.2",
"vite": "^8.0.8",
"vitest": "^4.1.4"
},
"packageManager": "yarn@4.5.3"
"packageManager": "pnpm@10.33.0"
}
Loading
Loading