Skip to content

Commit

Permalink
feat: initial working commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Oct 25, 2024
0 parents commit 09296e2
Show file tree
Hide file tree
Showing 29 changed files with 1,505 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .editorconfig
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
26 changes: 26 additions & 0 deletions .github/lock.yml
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
24 changes: 24 additions & 0 deletions .github/stale.yml
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
15 changes: 15 additions & 0 deletions .github/workflows/checks.yml
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
15 changes: 15 additions & 0 deletions .github/workflows/labels.yml
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 }}
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
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 }}
14 changes: 14 additions & 0 deletions .gitignore
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
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
docs
coverage
*.html
tests/fixtures
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The MIT License

Copyright (c) 2024

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.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Youch core

<br />

[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]

## Introduction

## Official Documentation

## 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

<pkg-name> is open-sourced software licensed under the [MIT license](LICENSE.md).

[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/poppinss/youch-core/checks.yml?style=for-the-badge
[gh-workflow-url]: https://github.com/poppinss/youch-core/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/youch-core.svg?style=for-the-badge&logo=npm
[npm-url]: https://npmjs.org/package/youch-core 'npm'
[license-image]: https://img.shields.io/npm/l/youch-core?color=blueviolet&style=for-the-badge
[license-url]: LICENSE.md 'license'
21 changes: 21 additions & 0 deletions bin/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect } from '@japa/expect'
import { assert } from '@japa/assert'
import { fileSystem } from '@japa/file-system'
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(),
assert(),
fileSystem({
autoClean: false,
basePath: new URL('../tests/fixtures', import.meta.url),
}),
expectTypeOf(),
],
})

run()
4 changes: 4 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { configPkg } from '@adonisjs/eslint-config'
export default configPkg({
ignores: ['tests/fixtures/*'],
})
53 changes: 53 additions & 0 deletions examples/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import ansis from 'ansis'
import { readFile } from 'node:fs/promises'
import { highlight } from 'tinyhighlight/picocolors'
import { ErrorParser } from '../src/parser.js'
import { ParsedError } from '../src/types.js'
import stripAnsi from 'strip-ansi'

function print(error: ParsedError) {
console.log('')
console.log(ansis.red(error.message))
if (error.hint) {
console.log(`${ansis.blue('●')} ${error.hint}`)
}

console.log('')
let frameSourcePrinted = false

error.frames.forEach((frame) => {
if (frame.type === 'app' && !frameSourcePrinted && frame.source) {
console.log(ansis.yellow(`‐ ${frame.raw!.trim()}`))
// console.log('')
frameSourcePrinted = true
const chunks = highlight(frame.source.map((c) => c.chunk).join('\n')).split('\n')

frame.source.map(({ lineNumber }, index) => {
const chunk = chunks[index]
if (lineNumber === frame.lineNumber) {
console.log(
ansis.bgRed(
`${ansis.visible('❯')} ${ansis.visible(`${lineNumber}`)} ${ansis.visible('┃')} ${ansis.visible(stripAnsi(chunk))}`
)
)
} else {
console.log(` ${ansis.dim(`${lineNumber}`)} ${ansis.dim('┃')} ${chunk}`)
}
})
// console.log('')
} else {
console.log(ansis.dim(`‐ ${frame.raw!.trim()}`))
}
})
}

async function run(): Promise<void> {
try {
await readFile('./foo.txt')
} catch (error) {
const parsed = await new ErrorParser().parse(error)
print(parsed)
}
}

await run()
10 changes: 10 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* youch-error
*
* (c) Poppinss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

export { ErrorParser } from './src/parser.js'
Loading

0 comments on commit 09296e2

Please sign in to comment.