This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f6b1df3
Showing
22 changed files
with
6,524 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github: [antfu] | ||
opencollective: antfu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
run_install: false | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
cache: pnpm | ||
|
||
- run: pnpm i -g @antfu/ni | ||
- run: nci | ||
- run: nr lint | ||
- run: nr typecheck | ||
|
||
test: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
node: [lts/*] | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
run_install: false | ||
- name: Set node ${{ matrix.node }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
cache: pnpm | ||
|
||
- run: pnpm i -g @antfu/ni | ||
- run: nci | ||
- run: nr build | ||
- run: nr test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Release | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: pnpm/action-setup@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- run: pnpm dlx changelogithub | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
# # Uncomment the following lines to publish to npm on CI | ||
# | ||
# - run: pnpm install | ||
# - run: pnpm publish -r --access public | ||
# env: | ||
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
# NPM_CONFIG_PROVENANCE: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.cache | ||
.DS_Store | ||
.idea | ||
*.log | ||
*.tgz | ||
coverage | ||
dist | ||
lib-cov | ||
logs | ||
node_modules | ||
temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore-workspace-root-check=true | ||
shell-emulator=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
// Disable the default formatter, use eslint instead | ||
"prettier.enable": false, | ||
"editor.formatOnSave": false, | ||
|
||
// Auto fix | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit", | ||
"source.organizeImports": "never" | ||
}, | ||
|
||
// Silent the stylistic rules in you IDE, but still auto fix them | ||
"eslint.rules.customizations": [ | ||
{ "rule": "style/*", "severity": "off" }, | ||
{ "rule": "*-indent", "severity": "off" }, | ||
{ "rule": "*-spacing", "severity": "off" }, | ||
{ "rule": "*-spaces", "severity": "off" }, | ||
{ "rule": "*-order", "severity": "off" }, | ||
{ "rule": "*-dangle", "severity": "off" }, | ||
{ "rule": "*-newline", "severity": "off" }, | ||
{ "rule": "*quotes", "severity": "off" }, | ||
{ "rule": "*semi", "severity": "off" } | ||
], | ||
|
||
// Enable eslint for all supported languages | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"typescript", | ||
"typescriptreact", | ||
"vue", | ||
"html", | ||
"markdown", | ||
"json", | ||
"jsonc", | ||
"yaml" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Please refer to https://github.com/antfu/contribute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Anthony Fu <https://github.com/antfu> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# oniguruma-to-js | ||
|
||
[![npm version][npm-version-src]][npm-version-href] | ||
[![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
[![bundle][bundle-src]][bundle-href] | ||
[![JSDocs][jsdocs-src]][jsdocs-href] | ||
[![License][license-src]][license-href] | ||
|
||
Covert Oniguruma-flavor Regexp to JavaScript native RegExp. | ||
|
||
Supported Oniguruma features: | ||
|
||
- `[:alnum:]`, `[:alpha:]` etc. POSIX bracket expressions | ||
- `(?x)` extended, free-spacing mode | ||
- `(?i:..)` flags modifiers | ||
|
||
## Usage | ||
|
||
```bash | ||
npm i oniguruma-to-js | ||
``` | ||
|
||
```ts | ||
import { onigurumaToRegexp } from 'oniguruma-to-js' | ||
|
||
const re = onigurumaToRegexp(`[[:alnum:]_]+`) | ||
console.log(re) // /^[a-zA-Z0-9_]+$/ | ||
``` | ||
|
||
```ts | ||
import { construct, syntaxLowering } from 'oniguruma-to-js' | ||
|
||
const pattern = syntaxLowering(`(?x: | ||
\d+ # Match one or more digits | ||
\s* # Match zero or more whitespace characters | ||
[A-Z]+ # Match one or more uppercase letters | ||
)`) | ||
console.log(pattern) // "\d+\s*[A-Z]+" | ||
|
||
const re = construct(pattern) | ||
console.log(re) // /\d+\s*[A-Z]+/ | ||
``` | ||
|
||
## Sponsors | ||
|
||
<p align="center"> | ||
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg"> | ||
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/> | ||
</a> | ||
</p> | ||
|
||
## License | ||
|
||
[MIT](./LICENSE) License © 2024-PRESENT [Anthony Fu](https://github.com/antfu) | ||
|
||
<!-- Badges --> | ||
|
||
[npm-version-src]: https://img.shields.io/npm/v/oniguruma-to-js?style=flat&colorA=080f12&colorB=1fa669 | ||
[npm-version-href]: https://npmjs.com/package/oniguruma-to-js | ||
[npm-downloads-src]: https://img.shields.io/npm/dm/oniguruma-to-js?style=flat&colorA=080f12&colorB=1fa669 | ||
[npm-downloads-href]: https://npmjs.com/package/oniguruma-to-js | ||
[bundle-src]: https://img.shields.io/bundlephobia/minzip/oniguruma-to-js?style=flat&colorA=080f12&colorB=1fa669&label=minzip | ||
[bundle-href]: https://bundlephobia.com/result?p=oniguruma-to-js | ||
[license-src]: https://img.shields.io/github/license/antfu/oniguruma-to-js.svg?style=flat&colorA=080f12&colorB=1fa669 | ||
[license-href]: https://github.com/antfu/oniguruma-to-js/blob/main/LICENSE | ||
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669 | ||
[jsdocs-href]: https://www.jsdocs.io/package/oniguruma-to-js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineBuildConfig } from 'unbuild' | ||
|
||
export default defineBuildConfig({ | ||
entries: [ | ||
'src/index', | ||
], | ||
declaration: true, | ||
clean: true, | ||
rollup: { | ||
emitCJS: true, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// @ts-check | ||
import antfu from '@antfu/eslint-config' | ||
|
||
export default antfu( | ||
{ | ||
type: 'lib', | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"name": "oniguruma-to-js", | ||
"type": "module", | ||
"version": "0.0.0", | ||
"packageManager": "pnpm@9.9.0", | ||
"description": "Covert Oniguruma-flavor Regexp to JavaScript native RegExp", | ||
"author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
"license": "MIT", | ||
"funding": "https://github.com/sponsors/antfu", | ||
"homepage": "https://github.com/antfu/oniguruma-to-js#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/antfu/oniguruma-to-js.git" | ||
}, | ||
"bugs": "https://github.com/antfu/oniguruma-to-js/issues", | ||
"keywords": [ | ||
"oniguruma", | ||
"regexp", | ||
"regex" | ||
], | ||
"sideEffects": false, | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.cjs" | ||
} | ||
}, | ||
"main": "./dist/index.mjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"./dist/*", | ||
"./dist/index.d.ts" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "unbuild", | ||
"dev": "unbuild --stub", | ||
"lint": "eslint .", | ||
"prepublishOnly": "nr build", | ||
"release": "bumpp && npm publish", | ||
"start": "esno src/index.ts", | ||
"test": "vitest", | ||
"typecheck": "tsc --noEmit", | ||
"prepare": "simple-git-hooks" | ||
}, | ||
"devDependencies": { | ||
"@antfu/eslint-config": "^3.0.0", | ||
"@antfu/ni": "^0.23.0", | ||
"@antfu/utils": "^0.7.10", | ||
"@types/node": "^22.5.1", | ||
"bumpp": "^9.5.2", | ||
"eslint": "^9.9.1", | ||
"esno": "^4.7.0", | ||
"lint-staged": "^15.2.9", | ||
"pnpm": "^9.9.0", | ||
"simple-git-hooks": "^2.11.1", | ||
"typescript": "^5.5.4", | ||
"unbuild": "^2.0.0", | ||
"vite": "^5.4.2", | ||
"vitest": "^2.0.5" | ||
}, | ||
"simple-git-hooks": { | ||
"pre-commit": "pnpm lint-staged" | ||
}, | ||
"lint-staged": { | ||
"*": "eslint --fix" | ||
} | ||
} |
Oops, something went wrong.