Skip to content

Commit

Permalink
chore(pr) project init (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutsu3 authored Nov 15, 2024
1 parent 282788a commit 3487024
Show file tree
Hide file tree
Showing 11 changed files with 2,515 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
193 changes: 193 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
<a id="readme-top"></a>

> [!CAUTION]
> This project is currently under development
<!-- PROJECT SHIELDS -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[![npm][npm-sheild]][npm-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![CodeCov][codecov-shield]][codecov-url]
[![CodeClimate][codeclimate-shield]][codeclimate-url]

<!-- PROJECT LOGO -->
<br />
<div align="center">
<a href="https://github.com/tsutsu3/unbound-control-ts">
<img src="images/Unbound_Outlined_Black.svg" alt="Logo" height="100" >
</a>

<h3 align="center">unbound-control-ts</h3>

<p align="center">
A TypeScript library for configuration and control of Unbound DNS.
<br />
<br />
<a href="https://github.com/tsutsu3/unbound-control-ts">Samples</a>
</p>
</div>

> [!IMPORTANT]
> **This is an unofficial project, not affiliated with the official Unbound or its maintainers.**
## Table of Contents

1. [About The Project](#about-the-project)
2. [Key Features](#key-features)
3. [Usage](#usage)
1. [Prerequisites](#prerequisites)
2. [Install](#install)
3. [Example Usage](#example-usage)
4. [Development](#development)
1. [Develop Prerequisites](#develop-prerequisites)
2. [Develop Setup](#develop-setup)
5. [License](#license)


## About The Project

Unbound is a powerful and versatile DNS resolver that is widely used for enhancing network privacy, security, and performance.

This project provides a TypeScript library designed to simplify interaction with Unbound's unbound-control utility, enabling developers to manage and configure Unbound DNS programmatically with ease.

## Key Features

- **Seamless Integration**: Interact with Unbound directly from your TypeScript or JavaScript projects.
- **User-Friendly API**: A clean and intuitive API for common Unbound operations like querying statistics, reloading configurations, or managing zones.
- **Cross-Platform Compatibility**: Works across various platforms where unbound-control is available.
- **Open Source**: Built with community contributions and extensibility in mind.

Here's a suggestion for the "Usage" section, including installation instructions:

## Usage

### Prerequisites

1. Ensure that `unbound-control` is installed and configured on your system.
2. Make sure the process running the script has appropriate permissions to access the Unbound control socket.

For more examples and advanced usage, refer to the [Unbound docs](https://unbound.docs.nlnetlabs.nl/en/latest/getting-started/configuration.html#set-up-remote-control).

### Install

To get started, install the library using your preferred package manager:

#### Using npm:

```bash
npm install unbound-control-ts
```

#### Using yarn:

```bash
yarn add unbound-control-ts
```

### Example Usage

Here's a basic example to demonstrate how to use the library:

```ts
import { UnboundControl } from 'unbound-control-ts';

// Initialize the client with the path to the unbound-control binary
const unbound = new UnboundControl('/path/to/unbound-control');

// Fetch and display Unbound statistics
async function getStats() {
try {
const stats = await unbound.stats();
console.log('Unbound Statistics:', stats);
} catch (error) {
console.error('Error fetching stats:', error);
}
}

getStats();
```

## Development

### Develop Prerequisites

Before you begin, ensure you have the following tools installed on your system:

- **Node.js**: Version 16 or later. [Download Node.js](https://nodejs.org/)
- **npm**: Comes with Node.js, or install it separately if needed.
- **Unbound**: Ensure that `unbound-control` is installed and properly configured. Follow the [Unbound installation guide](https://nlnetlabs.nl/documentation/unbound/) for details.
- **TypeScript**: (Optional) For contributing to or extending the library, TypeScript must be installed globally or as a dev dependency.

### Develop Setup

Follow these steps to set up the project for local development:

1. **Clone the Repository**

```bash
git clone https://github.com/your-username/unbound-control-ts.git
cd unbound-control-ts
```

2. **Install Dependencies**
Use your preferred package manager to install dependencies:

```bash
npm install
```

or

```bash
yarn install
```

3. **Build the Project**
Compile the TypeScript source code into JavaScript:

```bash
npm run build
```

4. **Run Tests**
Verify the project by running tests:

```bash
npm test
```

5. **Code Linting and Formatting**
Use the following commands to ensure code quality:

- Lint the code:

```bash
npm run lint
```

- Format the code:

```bash
npm run format
```

## License

Distributed under the MIT License. See [LICENSE](./LICENSE) for more information.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[issues-shield]: https://img.shields.io/github/issues/tsutsu3/unbound-control-ts?style=for-the-badge
[issues-url]: https://github.com/tsutsu3/unbound-control-ts/issues
[license-shield]: https://img.shields.io/github/license/tsutsu3/unbound-control-ts?style=for-the-badge
[license-url]: https://github.com/tsutsu3/unbound-control-ts/blob/master/LICENSE.txt
[npm-sheild]: https://img.shields.io/npm/dm/unbound-control-ts?style=for-the-badge&logo=npm

[npm-url]: https://www.npmjs.com/package/unbound-control-ts
[codecov-shield]: https://img.shields.io/codecov/c/github/tsutsu3/unbound-control-ts?token=KLIM50QN1V&style=for-the-badge&logo=codecov
[codecov-url]: https://codecov.io/gh/tsutsu3/unbound-control-ts
[codeclimate-shield]: https://img.shields.io/codeclimate/maintainability/tsutsu3/unbound-control-ts?style=for-the-badge&logo=codeclimate
[codeclimate-url]: https://codeclimate.com/github/tsutsu3/unbound-control-ts/maintainability
81 changes: 81 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# git-cliff ~ default configuration file
# https://git-cliff.org/docs/configuration
#
# Lines starting with "#" are comments.
# Configuration options are organized into tables and keys.
# See documentation for more information on available options.

[changelog]
# template for the changelog header
header = """
# Changelog\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
# template for the changelog footer
footer = """
"""
# remove the leading and trailing s
trim = true
# postprocessors
postprocessors = [
# { pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL
]
# render body even when there are no releases to process
# render_always = true
# output file path
# output = "test.md"

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = true
# process each line of a commit as an individual commit
split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [
# Replace issue numbers
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
# Check spelling of the commit with https://github.com/crate-ci/typos
# If the spelling is incorrect, it will be automatically fixed.
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
]
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore\\(deps.*\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
]
# filter out the commits that are not matched by commit parsers
filter_commits = false
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "newest"
4 changes: 4 additions & 0 deletions examples/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { hello } = require("../../dist/index.cjs");

const result = hello();
console.log(`CJS Result: ${result}`);
4 changes: 4 additions & 0 deletions examples/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { hello } from "../../dist/index.mjs";

const result = hello();
console.log(`ESM Result: ${result}`);
55 changes: 55 additions & 0 deletions images/Unbound_Outlined_Black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3487024

Please sign in to comment.