Skip to content

Commit

Permalink
docs: update README file
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Aug 10, 2024
1 parent dc319d0 commit ec2b014
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 102 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: checks

on:
- push
Expand Down
122 changes: 21 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,115 +1,35 @@
# AdonisJS package starter kit
# @adonisjs/drive

> A boilerplate for creating AdonisJS packages
<br />

This repo provides you with a starting point for creating AdonisJS packages. Of course, you can create a package from scratch with your folder structure and workflow. However, using this starter kit can speed up the process, as you have fewer decisions to make.
[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]

## Setup
## Introduction

- Clone the repo on your computer, or use `giget` to download this repo without the Git history.
```sh
npx giget@latest gh:adonisjs/pkg-starter-kit
```
- Install dependencies.
- Update the `package.json` file and define the `name`, `description`, `keywords`, and `author` properties.
- The repo is configured with an MIT license. Feel free to change that if you are not publishing under the MIT license.
A thin wrapper on top of [Flydrive](https://flydrive.dev/) to work seamlessly with AdonisJS. The package comes pre-configured to serve files from the local filesystem using the AdonisJS HTTP server

## Folder structure
## Official Documentation

The starter kit mimics the folder structure of the official packages. Feel free to rename files and folders as per your requirements.
The documentation is available on the [AdonisJS website](https://docs.adonisjs.com/guides/digging-deeper/drive)

```
├── providers
├── src
├── bin
├── stubs
├── configure.ts
├── index.ts
├── LICENSE.md
├── package.json
├── README.md
├── tsconfig.json
├── tsnode.esm.js
```
## Contributing

- The `configure.ts` file exports the `configure` hook to configure the package using the `node ace configure` command.
- The `index.ts` file is the main entry point of the package.
- The `tsnode.esm.js` file runs TypeScript code using TS-Node + SWC. Please read the code comment in this file to learn more.
- The `bin` directory contains the entry point file to run Japa tests.
- Learn more about [the `providers` directory](./providers/README.md).
- Learn more about [the `src` directory](./src/README.md).
- Learn more about [the `stubs` directory](./stubs/README.md).
One of the primary goals of AdonisJS is to have a vibrant community of users and contributors who believes in the principles of the framework.

### File system naming convention
We encourage you to read the [contribution guide](https://github.com/adonisjs/.github/blob/main/docs/CONTRIBUTING.md) before contributing to the framework.

We use `snake_case` naming conventions for the file system. The rule is enforced using ESLint. However, turn off the rule and use your preferred naming conventions.
## Code of Conduct

## Peer dependencies
In order to ensure that the AdonisJS community is welcoming to all, please review and abide by the [Code of Conduct](https://github.com/adonisjs/.github/blob/main/docs/CODE_OF_CONDUCT.md).

The starter kit has a peer dependency on `@adonisjs/core@6`. Since you are creating a package for AdonisJS, you must make it against a specific version of the framework core.
## License

If your package needs Lucid to be functional, you may install `@adonisjs/lucid` as a development dependency and add it to the list of `peerDependencies`.
AdonisJS Drive is open-sourced software licensed under the [MIT license](LICENSE.md).

As a rule of thumb, packages installed in the user application should be part of the `peerDependencies` of your package and not the main dependency.

For example, if you install `@adonisjs/core` as a main dependency, then essentially, you are importing a separate copy of `@adonisjs/core` and not sharing the one from the user application. Here is a great article explaining [peer dependencies](https://blog.bitsrc.io/understanding-peer-dependencies-in-javascript-dbdb4ab5a7be).

## Published files

Instead of publishing your repo's source code to npm, you must cherry-pick files and folders to publish only the required files.
The cherry-picking uses the `files` property inside the `package.json` file. By default, we publish the following files and folders.
```json
{
"files": ["build/src", "build/providers", "build/stubs", "build/index.d.ts", "build/index.js"]
}
```
If you create additional folders or files, mention them inside the `files` array.
## Exports
[Node.js Subpath exports](https://nodejs.org/api/packages.html#subpath-exports) allows you to define the exports of your package regardless of the folder structure. This starter kit defines the following exports.
```json
{
"exports": {
".": "./build/index.js",
"./types": "./build/src/types.js"
}
}
```
- The dot `.` export is the main export.
- The `./types` exports all the types defined inside the `./build/src/types.js` file (the compiled output).
Feel free to change the exports as per your requirements.
## Testing
We configure the [Japa test runner](https://japa.dev/) with this starter kit. Japa is used in AdonisJS applications as well. Just run one of the following commands to execute tests.
- `npm run test`: This command will first lint the code using ESlint and then run tests and report the test coverage using [c8](https://github.com/bcoe/c8).
- `npm run quick:test`: Runs only the tests without linting or coverage reporting.
The starter kit also has a Github workflow file to run tests using Github Actions. The tests are executed against `Node.js 20.x` and `Node.js 21.x` versions on both Linux and Windows. Feel free to edit the workflow file in the `.github/workflows` directory.
## TypeScript workflow
- The starter kit uses [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html) for compiling the TypeScript to JavaScript when publishing the package.
- [TS-Node](https://typestrong.org/ts-node/) and [SWC](https://swc.rs/) are used to run tests without compiling the source code.
- The `tsconfig.json` file is extended from [`@adonisjs/tsconfig`](https://github.com/adonisjs/tooling-config/tree/main/packages/typescript-config) and uses the `NodeNext` module system. Meaning the packages are written using ES modules.
- You can perform type checking without compiling the source code using the `npm run type check` script.
Feel free to explore the `tsconfig.json` file for all the configured options.
## ESLint and Prettier setup
The starter kit configures ESLint and Prettier. Both configurations are stored within the `package.json` file and use our [shared config](https://github.com/adonisjs/tooling-config/tree/main/packages). Feel free to change the configuration, use custom plugins, or remove both tools altogether.
## Using Stale bot
The [Stale bot](https://github.com/apps/stale) is a Github application that automatically marks issues and PRs as stale and closes after a specific duration of inactivity.
Feel free to delete the `.github/stale.yml` and `.github/lock.yml` files if you decide not to use the Stale bot.
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/drive/checks.yml?style=for-the-badge
[gh-workflow-url]: https://github.com/adonisjs/drive/actions/workflows/checks.yml 'Github action'
[npm-image]: https://img.shields.io/npm/v/@adonisjs/drive/latest.svg?style=for-the-badge&logo=npm
[npm-url]: https://www.npmjs.com/package/@adonisjs/drive/v/latest 'npm'
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[license-url]: LICENSE.md
[license-image]: https://img.shields.io/github/license/adonisjs/drive?style=for-the-badge

0 comments on commit ec2b014

Please sign in to comment.