-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 8499709
Showing
18 changed files
with
677 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,22 @@ | ||
# http://editorconfig.org | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.json] | ||
insert_final_newline = ignore | ||
|
||
[**.min.js] | ||
indent_style = ignore | ||
insert_final_newline = ignore | ||
|
||
[MakeFile] | ||
indent_style = space | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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,26 @@ | ||
--- | ||
ignoreUnless: { { STALE_BOT } } | ||
--- | ||
# Configuration for Lock Threads - https://github.com/dessant/lock-threads-app | ||
|
||
# Number of days of inactivity before a closed issue or pull request is locked | ||
daysUntilLock: 60 | ||
|
||
# Skip issues and pull requests created before a given timestamp. Timestamp must | ||
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable | ||
skipCreatedBefore: false | ||
|
||
# Issues and pull requests with these labels will be ignored. Set to `[]` to disable | ||
exemptLabels: ['Type: Security'] | ||
|
||
# Label to add before locking, such as `outdated`. Set to `false` to disable | ||
lockLabel: false | ||
|
||
# Comment to post before locking. Set to `false` to disable | ||
lockComment: > | ||
This thread has been automatically locked since there has not been | ||
any recent activity after it was closed. Please open a new issue for | ||
related bugs. | ||
# Assign `resolved` as the reason for locking. Set to `false` to disable | ||
setLockReason: false |
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,24 @@ | ||
--- | ||
ignoreUnless: { { STALE_BOT } } | ||
--- | ||
# Number of days of inactivity before an issue becomes stale | ||
daysUntilStale: 60 | ||
|
||
# Number of days of inactivity before a stale issue is closed | ||
daysUntilClose: 7 | ||
|
||
# Issues with these labels will never be considered stale | ||
exemptLabels: | ||
- 'Type: Security' | ||
|
||
# Label to use when marking an issue as stale | ||
staleLabel: 'Status: Abandoned' | ||
|
||
# Comment to post when marking an issue as stale. Set to `false` to disable | ||
markComment: > | ||
This issue has been automatically marked as stale because it has not had | ||
recent activity. It will be closed if no further activity occurs. Thank you | ||
for your contributions. | ||
# Comment to post when closing a stale issue. Set to `false` to disable | ||
closeComment: false |
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,15 @@ | ||
name: checks | ||
on: | ||
- push | ||
- pull_request | ||
- workflow_call | ||
|
||
jobs: | ||
test: | ||
uses: adonisjs/.github/.github/workflows/test.yml@main | ||
|
||
lint: | ||
uses: adonisjs/.github/.github/workflows/lint.yml@main | ||
|
||
typecheck: | ||
uses: adonisjs/.github/.github/workflows/typecheck.yml@main |
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,15 @@ | ||
name: Sync labels | ||
on: | ||
workflow_dispatch: | ||
permissions: | ||
issues: write | ||
jobs: | ||
labels: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: EndBug/label-sync@v2 | ||
with: | ||
config-file: 'https://raw.githubusercontent.com/thetutlage/static/main/labels.yml' | ||
delete-other-labels: true | ||
token: ${{ secrets.GITHUB_TOKEN }} |
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,32 @@ | ||
name: release | ||
on: workflow_dispatch | ||
permissions: | ||
contents: write | ||
id-token: write | ||
jobs: | ||
checks: | ||
uses: ./.github/workflows/checks.yml | ||
release: | ||
needs: checks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: git config | ||
run: | | ||
git config user.name "${GITHUB_ACTOR}" | ||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
- name: Init npm config | ||
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- run: npm install | ||
- run: npm run release -- --ci | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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,14 @@ | ||
node_modules | ||
coverage | ||
.DS_STORE | ||
.nyc_output | ||
.idea | ||
.vscode/ | ||
*.sublime-project | ||
*.sublime-workspace | ||
*.log | ||
build | ||
dist | ||
yarn.lock | ||
shrinkwrap.yaml | ||
package-lock.json |
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 @@ | ||
package-lock=false |
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,4 @@ | ||
build | ||
docs | ||
coverage | ||
*.html |
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,9 @@ | ||
# The MIT License | ||
|
||
Copyright (c) 2023 | ||
|
||
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,64 @@ | ||
# @poppinss/exception | ||
|
||
> Create custom exceptions with error code, status, and the help description. | ||
<br /> | ||
|
||
[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url] | ||
|
||
## Introduction | ||
|
||
The `@poppinss/exception` package provides with a base `Exception` class that can be used to create custom errors with support for defining the **error status**, **error code**, and **help description**. | ||
|
||
```ts | ||
import { Exception } from '@poppinss/exception' | ||
|
||
class ResourceNotFound extends Exception { | ||
static code = 'E_RESOURCE_NOT_FOUND' | ||
static status = 404 | ||
static message = 'Unable to find resource' | ||
} | ||
|
||
throw new ResourceNotFound() | ||
``` | ||
|
||
### Anonymous error classes | ||
|
||
You can also create an anonymous exception class using the `createError` method. The return value is a class constructor that accepts an array of values to use for message interpolation. | ||
|
||
The interpolation of error message is performed using the [`util.format`](https://nodejs.org/api/util.html#utilformatformat-args) method. | ||
|
||
```ts | ||
import { createError } from '@poppinss/exception' | ||
|
||
const E_RESOURCE_NOT_FOUND = createError<[number]>( | ||
'Unable to find resource with id %d', | ||
'E_RESOURCE_NOT_FOUND' | ||
) | ||
|
||
const id = 1 | ||
throw new E_RESOURCE_NOT_FOUND([id]) | ||
``` | ||
|
||
## Contributing | ||
|
||
One of the primary goals of poppinss is to have a vibrant community of users and contributors who believes in the principles of the framework. | ||
|
||
We encourage you to read the [contribution guide](https://github.com/poppinss/.github/blob/main/docs/CONTRIBUTING.md) before contributing to the framework. | ||
|
||
## Code of Conduct | ||
|
||
In order to ensure that the poppinss community is welcoming to all, please review and abide by the [Code of Conduct](https://github.com/poppinss/.github/blob/main/docs/CODE_OF_CONDUCT.md). | ||
|
||
## License | ||
|
||
Poppinss exception is open-sourced software licensed under the [MIT license](LICENSE.md). | ||
|
||
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/poppinss/exception/checks.yml?style=for-the-badge | ||
[gh-workflow-url]: https://github.com/poppinss/exception/actions/workflows/checks.yml 'Github action' | ||
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript | ||
[typescript-url]: "typescript" | ||
[npm-image]: https://img.shields.io/npm/v/@poppinss/exception.svg?style=for-the-badge&logo=npm | ||
[npm-url]: https://npmjs.org/package/@poppinss/exception 'npm' | ||
[license-image]: https://img.shields.io/npm/l/@poppinss/exception?color=blueviolet&style=for-the-badge | ||
[license-url]: LICENSE.md 'license' |
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 @@ | ||
import { expect } from '@japa/expect' | ||
import { expectTypeOf } from '@japa/expect-type' | ||
import { configure, processCLIArgs, run } from '@japa/runner' | ||
|
||
processCLIArgs(process.argv.splice(2)) | ||
configure({ | ||
files: ['tests/**/*.spec.ts'], | ||
plugins: [expect(), expectTypeOf()], | ||
}) | ||
|
||
run() |
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,4 @@ | ||
import { configPkg } from '@adonisjs/eslint-config' | ||
export default configPkg({ | ||
ignores: ['coverage/*'], | ||
}) |
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,10 @@ | ||
/* | ||
* @poppinss/exception | ||
* | ||
* (c) Poppinss | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
export * from './src/exception.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,110 @@ | ||
{ | ||
"name": "@poppinss/exception", | ||
"description": "Utility to create custom exceptions", | ||
"version": "1.0.0", | ||
"engines": { | ||
"node": ">=20.6.0" | ||
}, | ||
"type": "module", | ||
"files": [ | ||
"build", | ||
"!build/bin", | ||
"!build/tests" | ||
], | ||
"main": "build/index.js", | ||
"exports": { | ||
".": "./build/index.js" | ||
}, | ||
"scripts": { | ||
"pretest": "npm run lint", | ||
"test": "c8 npm run quick:test", | ||
"lint": "eslint .", | ||
"format": "prettier --write .", | ||
"typecheck": "tsc --noEmit", | ||
"precompile": "npm run lint", | ||
"compile": "tsup-node && tsc --emitDeclarationOnly --declaration", | ||
"build": "npm run compile", | ||
"version": "npm run build", | ||
"prepublishOnly": "npm run build", | ||
"release": "release-it", | ||
"quick:test": "node --import=ts-node-maintained/register/esm --enable-source-maps bin/test.ts" | ||
}, | ||
"devDependencies": { | ||
"@adonisjs/eslint-config": "^2.0.0-beta.7", | ||
"@adonisjs/prettier-config": "^1.4.0", | ||
"@adonisjs/tsconfig": "^1.4.0", | ||
"@japa/expect": "^3.0.2", | ||
"@japa/expect-type": "^2.0.2", | ||
"@japa/runner": "^3.1.4", | ||
"@release-it/conventional-changelog": "^9.0.2", | ||
"@swc/core": "^1.8.0", | ||
"@types/node": "^22.9.0", | ||
"c8": "^10.1.2", | ||
"eslint": "^9.14.0", | ||
"prettier": "^3.3.3", | ||
"release-it": "^17.10.0", | ||
"ts-node-maintained": "^10.9.4", | ||
"tsup": "^8.3.5", | ||
"typescript": "^5.6.3" | ||
}, | ||
"homepage": "https://github.com/poppinss/exception#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/poppinss/exception.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/poppinss/exception/issues" | ||
}, | ||
"keywords": [], | ||
"author": "Harminder Virk <[email protected]>", | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true | ||
}, | ||
"tsup": { | ||
"entry": [ | ||
"index.ts" | ||
], | ||
"outDir": "./build", | ||
"clean": true, | ||
"format": "esm", | ||
"dts": false, | ||
"sourcemap": false, | ||
"target": "esnext" | ||
}, | ||
"release-it": { | ||
"git": { | ||
"requireCleanWorkingDir": true, | ||
"requireUpstream": true, | ||
"commitMessage": "chore(release): ${version}", | ||
"tagAnnotation": "v${version}", | ||
"push": true, | ||
"tagName": "v${version}" | ||
}, | ||
"github": { | ||
"release": true | ||
}, | ||
"npm": { | ||
"publish": true, | ||
"skipChecks": true | ||
}, | ||
"plugins": { | ||
"@release-it/conventional-changelog": { | ||
"preset": { | ||
"name": "angular" | ||
} | ||
} | ||
} | ||
}, | ||
"c8": { | ||
"reporter": [ | ||
"text", | ||
"html" | ||
], | ||
"exclude": [ | ||
"tests/**" | ||
] | ||
}, | ||
"prettier": "@adonisjs/prettier-config" | ||
} |
Oops, something went wrong.