Skip to content

Commit 4f7ad28

Browse files
committed
fix: include configure in files
1 parent 7b66490 commit 4f7ad28

File tree

2 files changed

+42
-103
lines changed

2 files changed

+42
-103
lines changed

README.md

Lines changed: 39 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,52 @@
1-
# AdonisJS package starter kit
1+
# @adocasts.com/actions
22

3-
> A boilerplate for creating AdonisJS packages
3+
Easily strub new action classes inside your AdonisJS 6 project
44

5-
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.
6-
7-
## Setup
8-
9-
- Clone the repo on your computer, or use `giget` to download this repo without the Git history.
10-
```sh
11-
npx giget@latest gh:adonisjs/pkg-starter-kit
5+
## Install With Ace
6+
```shell
7+
node ace add @adocasts.com/actions
128
```
13-
- Install dependencies.
14-
- Update the `package.json` file and define the `name`, `description`, `keywords`, and `author` properties.
15-
- The repo is configured with an MIT license. Feel free to change that if you are not publishing under the MIT license.
16-
17-
## Folder structure
18-
19-
The starter kit mimics the folder structure of the official packages. Feel free to rename files and folders as per your requirements.
9+
- Installs `@adocasts.com/actions`.
10+
- Automatically configures the `make:action` command via your `adonisrc.ts` file.
2011

12+
## Manual Install & Configure
13+
First, install
14+
```shell
15+
npm i @adocasts.com/actions@latest
2116
```
22-
├── providers
23-
├── src
24-
├── bin
25-
├── stubs
26-
├── configure.ts
27-
├── index.ts
28-
├── LICENSE.md
29-
├── package.json
30-
├── README.md
31-
├── tsconfig.json
32-
├── tsnode.esm.js
17+
Then, configure
18+
```shell
19+
node ace configure @adocasts.com/actions
3320
```
3421

35-
- The `configure.ts` file exports the `configure` hook to configure the package using the `node ace configure` command.
36-
- The `index.ts` file is the main entry point of the package.
37-
- The `tsnode.esm.js` file runs TypeScript code using TS-Node + SWC. Please read the code comment in this file to learn more.
38-
- The `bin` directory contains the entry point file to run Japa tests.
39-
- Learn more about [the `providers` directory](./providers/README.md).
40-
- Learn more about [the `src` directory](./src/README.md).
41-
- Learn more about [the `stubs` directory](./stubs/README.md).
42-
43-
### File system naming convention
44-
45-
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.
46-
47-
## Peer dependencies
48-
49-
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.
22+
## Using
23+
Once `@adocasts.com/actions` is installed & configured in your application,
24+
you'll have access to `node ace make:actions [name]`.
5025

51-
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`.
52-
53-
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.
54-
55-
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).
56-
57-
## Published files
58-
59-
Instead of publishing your repo's source code to npm, you must cherry-pick files and folders to publish only the required files.
60-
61-
The cherry-picking uses the `files` property inside the `package.json` file. By default, we publish the following files and folders.
62-
63-
```json
64-
{
65-
"files": ["build/src", "build/providers", "build/stubs", "build/index.d.ts", "build/index.js"]
66-
}
26+
For example, to create a `RegisterFromForm` action, you can do:
27+
```shell
28+
node ace make:action RegisterFromForm
6729
```
68-
69-
If you create additional folders or files, mention them inside the `files` array.
70-
71-
## Exports
72-
73-
[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.
74-
75-
```json
76-
{
77-
"exports": {
78-
".": "./build/index.js",
79-
"./types": "./build/src/types.js"
80-
}
81-
}
30+
Which creates an action class at:
31+
```shell
32+
app/actions/register_from_form.ts
8233
```
8334

84-
- The dot `.` export is the main export.
85-
- The `./types` exports all the types defined inside the `./build/src/types.js` file (the compiled output).
86-
87-
Feel free to change the exports as per your requirements.
88-
89-
## Testing
90-
91-
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.
92-
93-
- `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).
94-
- `npm run quick:test`: Runs only the tests without linting or coverage reporting.
95-
96-
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.
97-
98-
## TypeScript workflow
99-
100-
- The starter kit uses [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html) for compiling the TypeScript to JavaScript when publishing the package.
101-
- [TS-Node](https://typestrong.org/ts-node/) and [SWC](https://swc.rs/) are used to run tests without compiling the source code.
102-
- 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.
103-
- You can perform type checking without compiling the source code using the `npm run type check` script.
104-
105-
Feel free to explore the `tsconfig.json` file for all the configured options.
106-
107-
## ESLint and Prettier setup
108-
109-
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.
110-
111-
## Using Stale bot
35+
### Features
36+
Apps have lots of actions, so it's a great idea to group them into feature/resource folders.
37+
This can be easily done via the `--feature` flag.
38+
```shell
39+
node ace make:action register_from_form --feature=auth
40+
```
41+
This will then create our action class at:
42+
```shell
43+
app/actions/auth/register_from_form.ts
44+
```
45+
Also, note in both the above examples, the file name was normalized.
11246

113-
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.
47+
### HTTP Actions
48+
If your action is going to handle an HTTP Request, you can optionally include an injection of the `HttpContext` directly within your action class via the `--http` flag.
49+
```shell
50+
node ace make:action register_from_form --http --feature=auth
51+
```
11452

115-
Feel free to delete the `.github/stale.yml` and `.github/lock.yml` files if you decide not to use the Stale bot.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"name": "@adocasts.com/actions",
33
"description": "Adds a make:action Ace CLI command to easily create new action handler classes in your AdonisJS 6 application",
4-
"version": "0.0.0",
4+
"version": "0.0.2",
55
"engines": {
66
"node": ">=20.6.0"
77
},
88
"type": "module",
99
"files": [
1010
"build/commands",
1111
"build/stubs",
12+
"build/configure.d.ts",
13+
"build/configure.js",
1214
"build/index.d.ts",
1315
"build/index.js"
1416
],

0 commit comments

Comments
 (0)