Skip to content

Commit 3d3e326

Browse files
committed
feat: modernize toolchain
1 parent 1a3b57a commit 3d3e326

42 files changed

Lines changed: 47728 additions & 6219 deletions

Some content is hidden

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

.babelrc

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,38 @@ name: Build and Test
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12-
12+
1313
steps:
14-
- uses: actions/checkout@v3
15-
16-
- name: Set up Node.js
17-
uses: actions/setup-node@v3
18-
with:
19-
node-version: 22
20-
cache: 'npm'
21-
22-
- name: Install dependencies
23-
run: npm install
24-
25-
- name: Build
26-
run: npm run build
27-
28-
- name: Test and upload coverage to Coveralls
29-
run: npm run coveralls
30-
env:
31-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@v2
18+
with:
19+
bun-version: latest
20+
21+
- name: Install dependencies
22+
run: bun install
23+
24+
- name: Lint
25+
run: bun run lint
26+
27+
- name: Build
28+
run: bun run build
29+
30+
- name: Test with coverage
31+
run: bun run test:coverage
32+
33+
- name: Upload coverage to Codecov
34+
uses: codecov/codecov-action@v5
35+
with:
36+
token: ${{ secrets.CODECOV_TOKEN }}
37+
files: ./coverage/coverage-final.json
38+
fail_ci_if_error: false
39+
verbose: true

.github/workflows/release.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build and Test"]
6+
types: [completed]
7+
branches: [main]
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13+
permissions:
14+
contents: write
15+
id-token: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Get package version
23+
id: package
24+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
25+
26+
- name: Check if tag exists
27+
id: tag_check
28+
run: |
29+
if git rev-parse "v${{ steps.package.outputs.version }}" >/dev/null 2>&1; then
30+
echo "exists=true" >> $GITHUB_OUTPUT
31+
else
32+
echo "exists=false" >> $GITHUB_OUTPUT
33+
fi
34+
35+
- name: Check if version exists on npm
36+
id: npm_check
37+
run: |
38+
if npm view transliteration@${{ steps.package.outputs.version }} version >/dev/null 2>&1; then
39+
echo "exists=true" >> $GITHUB_OUTPUT
40+
else
41+
echo "exists=false" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Setup Bun
45+
if: steps.npm_check.outputs.exists == 'false'
46+
uses: oven-sh/setup-bun@v2
47+
with:
48+
bun-version: latest
49+
50+
- name: Setup Node.js for npm publish
51+
if: steps.npm_check.outputs.exists == 'false'
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: '20'
55+
registry-url: 'https://registry.npmjs.org'
56+
57+
- name: Update npm for OIDC support
58+
if: steps.npm_check.outputs.exists == 'false'
59+
run: npm install -g npm@latest
60+
61+
- name: Install dependencies
62+
if: steps.npm_check.outputs.exists == 'false'
63+
run: bun install
64+
65+
- name: Build
66+
if: steps.npm_check.outputs.exists == 'false'
67+
run: bun run build
68+
69+
- name: Publish to npm
70+
if: steps.npm_check.outputs.exists == 'false'
71+
run: npm publish
72+
73+
- name: Create and push tag
74+
if: steps.tag_check.outputs.exists == 'false'
75+
run: |
76+
git config user.name "github-actions[bot]"
77+
git config user.email "github-actions[bot]@users.noreply.github.com"
78+
git tag -a "v${{ steps.package.outputs.version }}" -m "Release v${{ steps.package.outputs.version }}"
79+
git push origin "v${{ steps.package.outputs.version }}"
80+
81+
- name: Create GitHub Release
82+
if: steps.tag_check.outputs.exists == 'false'
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
tag_name: v${{ steps.package.outputs.version }}
86+
name: v${{ steps.package.outputs.version }}
87+
generate_release_notes: true
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,38 @@
1+
# Dependencies
12
node_modules/
2-
coverage/
3+
4+
# Build output
35
dist/
46
lib/
5-
.vscode
6-
.nyc_output
7-
.rpt2_cache
7+
8+
# Generated data
9+
data/charmap.ts
10+
11+
# Coverage
12+
coverage/
13+
14+
# IDE
15+
.vscode/
16+
.idea/
17+
18+
# Cache
19+
.nyc_output/
20+
.rpt2_cache/
21+
*.tsbuildinfo
22+
23+
# Lock files (use bun.lockb)
824
package-lock.json
25+
yarn.lock
26+
pnpm-lock.yaml
27+
28+
# Logs
29+
*.log
30+
npm-debug.log*
31+
32+
# OS
33+
.DS_Store
34+
Thumbs.db
35+
36+
# Temp
37+
*.tmp
38+
*.temp

.npmignore

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
1-
.*
2-
data/
1+
# Source files
32
src/
3+
data/
44
scripts/
55
test/
6-
ts*.json
7-
rollup.config.js
8-
renovate.json
6+
7+
# Config files
8+
*.json
9+
*.ts
10+
!package.json
11+
biome.json
12+
tsconfig.json
13+
tsup.config.ts
14+
vitest.config.ts
15+
16+
# Dot files
17+
.*
18+
!.npmignore
19+
20+
# Documentation (keep README)
21+
CHANGELOG.md
22+
23+
# Lock files
24+
bun.lockb
25+
package-lock.json
26+
yarn.lock
27+
28+
# Coverage
29+
.nyc_output/
30+
coverage/

.prettierignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,49 @@
1-
### 2.2.0
1+
# Changelog
22

3-
- Fix #229 data issue
4-
- Add an option `fixChineseSpacing` option for improving performance for none-Chinese languages
5-
- Fix #202 replace related issues.
6-
- Update dependencies
3+
## 2.4.0
74

8-
### 2.1.0
5+
- Modernized toolchain: migrated from Rollup/Babel to tsup/Bun for faster builds
6+
- Added comprehensive test suites with 100% code coverage
7+
- Fixed slugify to collapse consecutive separators (e.g., `hello---world``hello-world`)
8+
- Fixed slugify to properly strip leading/trailing separators
9+
- Replaced TSLint/Prettier with Biome for linting
10+
- Minimum Node.js requirement is now v20.0.0
11+
- Refactored utilities and added edge case handling
12+
- Added Vitest as modern test runner with jsdom environment for browser tests
913

10-
- Add `transliterate` as a global variable for browser builds. Keep `transl` for backward compatibility.
14+
## 2.2.0
1115

12-
### 2.0.0
16+
- Fixed data issue (#229)
17+
- Added `fixChineseSpacing` option for improving performance with non-Chinese languages
18+
- Fixed replace-related issues (#202)
19+
- Updated dependencies
1320

14-
- **CDN file structure changed**: [https://www.jsdelivr.com/package/npm/transliteration](https://www.jsdelivr.com/package/npm/transliteration)
15-
- The entire module had been refactored in Typescript, with big performance improvements as well as a reduced package size.
16-
- Better code quality. 100% unit tested.
17-
- `bower` support was dropped. Please use CDN or `webpack`/`rollup`.
18-
- As according to RFC 3986, more characters(`/a-zA-Z0-9-_.~/`) are kept as allowed characters in the result for `slugify`, and it is configurable.
19-
- Added `uppercase` as an option for `slugify`, if is set to `true` then the generated slug will be converted to uppercase letters.
20-
- Unknown characters will be transliterated as empty string by default, instead of a meaningless `[?]`.
21+
## 2.1.0
2122

22-
### 1.6.6
23+
- Added `transliterate` as a global variable for browser builds (kept `transl` for backward compatibility)
2324

24-
- Added support for `TypeScript`. #77
25+
## 2.0.0
2526

26-
### 1.5.0
27+
- **Breaking**: CDN file structure changed — see [jsDelivr](https://www.jsdelivr.com/package/npm/transliteration)
28+
- Refactored entire module in TypeScript with significant performance improvements and reduced package size
29+
- Improved code quality with 100% unit test coverage
30+
- Dropped `bower` support — use CDN or bundlers like webpack/rollup instead
31+
- Per RFC 3986, more characters (`a-zA-Z0-9-_.~`) are now allowed in `slugify` output (configurable)
32+
- Added `uppercase` option for `slugify` to convert output to uppercase
33+
- Unknown characters are now transliterated as empty string by default (previously `[?]`)
2734

28-
- Minimum node requirement: 6.0+
35+
## 1.6.6
2936

30-
### 1.0.0
37+
- Added TypeScript support (#77)
3138

32-
- Code had been entirely refactored since version 1.0.0. Be careful when you plan to upgrade from v0.1.x or v0.2.x to v1.0.x
33-
- The `options` parameter of `transliterate` now is an `Object` (In 0.1.x it's a string `unknown`).
34-
- Added `transliterate.config` and `slugify.config`.
35-
- Unknown string will be transliterated as `[?]` instead of `?`.
36-
- In the browser, global variables have been changed to `window.transl` and `windnow.slugify`. Other global variables are removed.
39+
## 1.5.0
40+
41+
- Minimum Node.js requirement: v6.0+
42+
43+
## 1.0.0
44+
45+
- **Breaking**: Entire codebase refactored — upgrade carefully from v0.1.x or v0.2.x
46+
- The `options` parameter of `transliterate` is now an object (previously a string for `unknown`)
47+
- Added `transliterate.config()` and `slugify.config()` methods
48+
- Unknown characters are now transliterated as `[?]` instead of `?`
49+
- Browser global variables changed to `window.transl` and `window.slugify` (other globals removed)

0 commit comments

Comments
 (0)