Skip to content

Commit

Permalink
doc: add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
gutenye committed Dec 27, 2024
1 parent efe3bae commit d8d7ff5
Show file tree
Hide file tree
Showing 29 changed files with 372 additions and 102 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/release.yml

This file was deleted.

1 change: 1 addition & 0 deletions .nvimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts
128 changes: 128 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
Github.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright © <startYear-endYear> <copyright holders>

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.
45 changes: 36 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
# lib.js
# 🧩 LibJS 🧩

## Rules
[![Stars](https://img.shields.io/github/stars/gutenye/lib.js?style=social)](https://github.com/gutenye/lib.js) [![NPM Version](https://img.shields.io/npm/v/@gutenye/lib.js)](https://www.npmjs.com/package/@gutenye/lib.js) [![License](https://img.shields.io/github/license/gutenye/lib.js?color=blue)](https://github.com/gutenye/lib.js/blob/main/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue)](https://github.com/gutenye/lib.js#-contribute)

Javascript utils that you can copy and paste into your projects.

**Show your and support by starring this project and following the author, [Guten Ye](https://github.com/gutenye)!**

## 🌟 Design Goals

This is NOT a library. It's a collection of re-usable code that you can copy and paste into your apps. You do not install it as a dependency. It is not available or distributed via npm.
Pick the code you need. Copy and paste the code into your project and customize to your needs. The code is yours.

- Drop-in replacement
- Copy & paste only, do not publish the package.
- Naming: Can use same name if it's a drop-in replacement, otherwsie use a different name

## Usage
## 📖 List of Utils

- [fs](./fs/README.md)
- [js](./js/README.md)
- [fetch](./fetch/README.md)
- [child_process](./child_process/README.md)
- [raycast](./raycast/README.md)

## 🤝 Contribute

We welcome contributions! Whether it’s bug reports, feature suggestions, or pull requests, your involvement makes this project better.

**How to Contribute:**

1. Fork the Repository
2. Open a Pull Request on Github

---

Thank you for using LibJS! ✨ If you found it helpful, please ⭐️ star the project ️️⭐ on GitHub. If you have any questions or encounter issues, please refer to the documentation or report an issue on GitHub.

**Special thanks to all the contributors:**

[![](https://contrib.rocks/image?repo=gutenye/lib.js)](https://github.com/gutenye/lib.js/graphs/contributors)

```
import fs from '#/utils/fs'
import { spawnPlus } from '#/utils/childProcess'
import { request, createRequest } from '#/utils/fetch'
import { isString } from '#/utils/js'
```
[⬆ Back to top ⬆](#readme)
21 changes: 18 additions & 3 deletions ake
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#!/usr/bin/env script.js
await mixins('package-manager', 'test')

await mixins('test')
globalThis.PACKAGE_MANAGER = 'bun'

app.name(PROJECT_NAME)
const HELP = `
`

app
.name(PROJECT_NAME)
.enableCompletion()
.addHelpText('after', HELP.trimEnd())

app
.command('cmd1 [file]')
.description('Desc')
.argument('[file]', 'Desc', 'default')
.addArgument(new app.Argument('[file]').choices(['file1']))
.option('-o, --option1 [value]', 'Desc', 'default')
.addOption(new app.Option('--option2 [value]').choices(['value1']))
.action(async () => { })
Binary file modified bun.lockb
Binary file not shown.
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
{
"name": "@gutenye/lib.js",
"workspaces": ["packages/*"],
"private": "true",
"type": "module",
"workspaces": ["src/*"],
"scripts": {
"test": "bun test",
"lint": "biome check",
"lint": "biome check --fix",
"lint:ci": "biome ci --reporter=github"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@types/bun": "latest",
"memfs": "^4.14.0",
"nock": "^14.0.0-beta.15"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@raycast/utils": "^1.18.1"
"nock": "^14.0.0-beta.15",
"typescript": "^5.7.2"
}
}
19 changes: 0 additions & 19 deletions packages/fetch/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/js/README.md

This file was deleted.

17 changes: 17 additions & 0 deletions src/child_process/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Child Process

- Drop-in replacement

```ts
import { spawnPlus } from '#/utils/child_process'
```

### spawnPlus

- emit stderr messages on exit
- shell is true by default

```ts
const child = spawnPlus('ls --color')
child.on('errorPlus', (stderr) => {})
```
File renamed without changes.
45 changes: 45 additions & 0 deletions src/fetch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Fetch

```ts
import { createRequest } from '#/utils/fetch'
```

## TODO

- request body auto json stringity

use isPlainObject to detect body type

- createRequest supports global options

createRequst(baseUrl, {
headers: {
Authorization: 'Bearer TOKEN'
}
})

createRequst(baseUrl, ({ body }) => ({
headers: {
Authorization: createSignature(body)
}
}))

## createRequest

- Supports baseUrl
- Default header Content-Type is 'application/json'
- method POST if there's a body
- body JSON stringify
- result JSON parse
- better error message when none 2xx response or invalid json response

```ts
const requst = createRequest('https://example.com/api')
const body = await request('/users', { body: { a: 1 } })
```

## request

```ts
const body = await request('https://example.com/api/users')
```
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit d8d7ff5

Please sign in to comment.