-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1fed86a
Showing
15 changed files
with
4,920 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: test | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
linux: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: | ||
- 18.x | ||
- 19.x | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install | ||
run: npm install | ||
- name: Run tests | ||
run: npm test | ||
windows: | ||
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
node-version: | ||
- 18.x | ||
- 19.x | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install | ||
run: npm install | ||
- name: Run tests | ||
run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
node_modules | ||
build | ||
coverage | ||
poc | ||
doc.md | ||
.env | ||
cache.sqlite3 | ||
.todo.md | ||
|
||
# Frontend assets compiled code | ||
docs/public/hot | ||
docs/public/build | ||
docs/public/assets | ||
|
||
# Build tools specific | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# Editors specific | ||
.fleet | ||
.idea | ||
.vscode | ||
|
||
# Static export | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# The MIT License | ||
|
||
Copyright (c) 2023 | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# AdonisJS package starter kit | ||
> A boilerplate for creating AdonisJS packages | ||
This repo contains the default folder structure, development, and peer dependencies to create a package for AdonisJS v6. | ||
|
||
You can create a package from scratch with your folder structure and workflow. However, using a default starter kit can speed up the process, as you have fewer decisions to make. | ||
|
||
## Folder structure | ||
|
||
The starter kit mimics the folder structure of the official packages. Feel free to rename files and folders as per your requirements. | ||
|
||
``` | ||
├── providers | ||
├── src | ||
├── stubs | ||
├── index.ts | ||
├── LICENSE.md | ||
├── package.json | ||
├── README.md | ||
└── tsconfig.json | ||
``` | ||
|
||
- The `providers` directory is used to store service providers. | ||
- The `src` directory contains the source code of the package. All business logic should be inside this folder. | ||
- The `stubs` directory is used to keep scaffolding stubs. You might copy some stubs to the user application once they configure the package. | ||
- The `index.ts` file is the main entry point of the package. | ||
|
||
### File system naming convention | ||
|
||
We use `snake_case` naming conventions for the file system. The rule is enforced using ESLint. However, feel free to disable the rule and use your preferred naming conventions. | ||
|
||
## Peer dependencies | ||
|
||
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. | ||
|
||
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`. | ||
|
||
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 all the source code of your repo to npm, you must cherry-pick files and folders to publish only the required files. | ||
|
||
The cherry-picking is done using the `files` property inside the `package.json` file. By default, we publish the following files and folders. | ||
|
||
```json | ||
{ | ||
"files": [ | ||
"src", | ||
"providers", | ||
"index.ts", | ||
"build/src", | ||
"build/providers", | ||
"build/stubs", | ||
"build/index.d.ts", | ||
"build/index.d.ts.map", | ||
"build/index.js" | ||
] | ||
} | ||
``` | ||
|
||
If you notice, we are publishing both the source code (written in TypeScript) and the compiled output (JavaScript) to npm. | ||
|
||
- The JavaScript runtime requires compiled output. So that is something you will have to publish. | ||
- Publishing source code is optional. However, if you generate [declaration maps](https://www.typescriptlang.org/tsconfig#declarationMap), then the TypeScript language server (used by code editors like VSCode) will be able to jump to the actual source code when you perform `CTRL + CLICK`. | ||
|
||
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 comes with a Github workflow file to run tests using Github Actions. The tests are executed against `Node.js 18.x` and `Node.js 19.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 at the time of 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 `NodeNext` module system. Meaning the packages are written using ES modules. | ||
- You can perform type checking without compiling the source code using `npm run typecheck` 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. The configuration for both is 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 config, use custom plugins or remove both tools altogether. | ||
|
||
## Using Stale bot (optional) | ||
|
||
The [Stale bot](https://github.com/apps/stale) is a Github application that automatically marks issues and PRs as stale and closes after a certain duration of inactivity. | ||
|
||
You may optionally configure it at the time of scaffolding the package. | ||
|
||
## Unconfigurable bits | ||
|
||
- **License**: The `LICENSE.md` file and the `license` property inside the `package.json` file are set to `MIT`. You can change them manually. | ||
- **Editorconfig**: The `.editorconfig` file is used to define the formatting rules. | ||
- **No package-lock file**: The `.npmrc` file is created with the rule to diable `package-lock.json` file. Feel free to revert the setting or use a different package manager. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { julr } from '@julr/tooling-configs/eslint' | ||
|
||
export default await julr({ | ||
typescript: { | ||
tsconfigPath: [ | ||
'./tsconfig.json', | ||
'./packages/bentocache/tsconfig.json', | ||
'./docs/tsconfig.json', | ||
], | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@unilocks/monorepo", | ||
"description": "Unilocks monorepo", | ||
"version": "0.0.0", | ||
"engines": { | ||
"node": ">=18.16.0" | ||
}, | ||
"scripts": { | ||
"typecheck": "tsc --noEmit", | ||
"lint": "eslint .", | ||
"checks": "pnpm lint && pnpm typecheck" | ||
}, | ||
"devDependencies": { | ||
"@adonisjs/tsconfig": "^1.2.1", | ||
"@japa/assert": "2.1.0", | ||
"@japa/expect-type": "2.0.1", | ||
"@japa/file-system": "2.1.1", | ||
"@japa/runner": "3.1.1", | ||
"@julr/tooling-configs": "2.1.0", | ||
"@swc/core": "1.3.101", | ||
"@types/node": "^20.10.5", | ||
"c8": "^8.0.1", | ||
"copyfiles": "^2.4.1", | ||
"cross-env": "^7.0.3", | ||
"del-cli": "^5.1.0", | ||
"dotenv": "^16.3.1", | ||
"eslint": "^8.56.0", | ||
"prettier": "^3.1.1", | ||
"ts-node": "^10.9.2", | ||
"tsup": "^8.0.1", | ||
"typescript": "~5.2.2" | ||
}, | ||
"author": "Julien Ripouteau <[email protected]>", | ||
"license": "MIT", | ||
"prettier": "@julr/tooling-configs/prettier" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'dotenv/config' | ||
|
||
import { assert } from '@japa/assert' | ||
import { fileSystem } from '@japa/file-system' | ||
import { expectTypeOf } from '@japa/expect-type' | ||
import { processCLIArgs, configure, run } from '@japa/runner' | ||
|
||
import { BASE_URL } from '../test_helpers/index.js' | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Configure tests | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The configure method accepts the configuration to configure the Japa | ||
| tests runner. | ||
| | ||
| The first method call "processCLIArgs" process the command line arguments | ||
| and turns them into a config object. Using this method is not mandatory. | ||
| | ||
| Please consult japa.dev/runner-config for the config docs. | ||
*/ | ||
processCLIArgs(process.argv.slice(2)) | ||
configure({ | ||
files: ['test/**/*.spec.ts'], | ||
plugins: [assert(), expectTypeOf(), fileSystem({ autoClean: true, basePath: BASE_URL })], | ||
}) | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Run tests | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The following "run" method is required to execute all the tests. | ||
| | ||
*/ | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "unilocks", | ||
"version": "0.0.1", | ||
"description": "", | ||
"type": "module", | ||
"scripts": { | ||
"clean": "del-cli build", | ||
"typecheck": "tsc --noEmit", | ||
"lint": "eslint .", | ||
"quick:test": "cross-env NODE_NO_WARNINGS=1 node --enable-source-maps --loader=ts-node/esm bin/test.ts", | ||
"pretest": "pnpm lint", | ||
"test": "c8 pnpm quick:test", | ||
"build": "tsup-node", | ||
"postbuild": "pnpm copy:templates", | ||
"release": "pnpm build && pnpm release-it", | ||
"version": "pnpm build", | ||
"prepublishOnly": "pnpm build", | ||
"checks": "pnpm lint && pnpm typecheck" | ||
}, | ||
"keywords": [], | ||
"author": "Julien Ripouteau <[email protected]>", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const BASE_URL = new URL('./tmp/', import.meta.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "@adonisjs/tsconfig/tsconfig.package.json", | ||
"compilerOptions": { | ||
"rootDir": "./", | ||
"outDir": "./build", | ||
} | ||
} |
Oops, something went wrong.