Skip to content

Commit

Permalink
chore(setup): update skeleton and add test 🎉🚨🔨
Browse files Browse the repository at this point in the history
  • Loading branch information
eokwukwe committed Jul 14, 2023
1 parent 4e28df6 commit f4202c0
Show file tree
Hide file tree
Showing 12 changed files with 17,551 additions and 9,023 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test

on: ['push', 'pull_request']

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
lib: ['sqlite', 'better_sqlite']
node-version: [14, 16, 18]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: npm install

- name: Run Tests
run: npm run test
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# adonis-package-skeleton
> A skeleton repository for creating AdonisJS packages
# adonis-hashids
> A package to generate YouTube-like IDs for AdonisJS Lucid models
[![npm-image]][npm-url] [![license-image]][license-url] [![typescript-image]][typescript-url]
[![gh-workflow-image]][gh-workflow-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url] [![download-image]][download-url]

This repo can be used to quickly scaffold an AdonisJS package. To get started, follow the steps below:

* Clone this repo by clicking the "Use this template" button at the top of this repo.
* Swap out any placeholders (e.g skeleton) and start building your package.
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/eokwukwe/adonis-hashids/test.yml?style=for-the-badge
[gh-workflow-url]: https://github.com/eokwukwe/adonis-hashids/actions/workflows/test.yml "Github action"

## Learn AdonisJS
Want to learn how to build AdonisJS packages? Check out the [AdonisJS package development](https://adonismastery.com/courses/adonisjs-package-development) course. You can also check out other courses and tutorials on [Adonis Mastery](https://adonismastery.com), where you get to learn AdonisJS through practical screencasts.
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[typescript-url]: "typescript"

[npm-image]: https://img.shields.io/npm/v/adonis-confirm-password.svg?style=for-the-badge&logo=npm
[npm-url]: https://npmjs.org/package/adonis-confirm-password "npm"
[npm-image]: https://img.shields.io/npm/v/@fcodes/adonis-hashids/latest.svg?style=for-the-badge&logo=npm
[npm-url]: https://npmjs.org/package/@fcodes/adonis-hashids/v/latest "npm"

[license-image]: https://img.shields.io/npm/l/adonis-confirm-password?color=blueviolet&style=for-the-badge
[license-image]: https://img.shields.io/npm/l/@fcodes/adonis-hashids?color=blueviolet&style=for-the-badge
[license-url]: LICENSE.md "license"

[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[typescript-url]: "typescript"
[download-image]: https://img.shields.io/npm/dm/%40fcodes/adonis-hashids?style=for-the-badge&logo=npm&label=Downloads
[download-url]: "download"
44 changes: 44 additions & 0 deletions adonis-typings/hashids.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* @fcodes/adonis-hashids
*
* (c) Okwukwe Ewurum <okwukwe.ewurum@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare module '@ioc:Adonis/Addons/LucidHashIds' {
import Hashids from 'hashids'
import { LucidModel } from '@ioc:Adonis/Lucid/Orm'
import { NormalizeConstructor } from '@ioc:Adonis/Core/Helpers'

export interface LucidHashIdsMixin {
<T extends NormalizeConstructor<LucidModel>>(
superclass: T
): T & {
routeLookupKey: string

saveHashId<Model extends LucidModel & T>(model: Model): Promise<void>

getId(hashid: string): number | string

$generateHashId(primaryKeyValue: number | string): string

$salt(): string

$minLength(): number

$alphabet(): string

$hashidsInstance(): Hashids

new (...args: any[]): {
hashid: string
}
}
}

const LucidHashIds: LucidHashIdsMixin

export default LucidHashIds
}
2 changes: 1 addition & 1 deletion adonis-typings/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/// <reference path="./skeleton.ts" />
/// <reference path="./hashids.ts" />
5 changes: 0 additions & 5 deletions adonis-typings/skeleton.ts

This file was deleted.

11 changes: 11 additions & 0 deletions bin/japa_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import '@japa/runner'

declare module '@japa/runner' {
interface TestContext {
// notify TypeScript about custom context properties
}

interface Test<TestData> {
// notify TypeScript about custom test properties
}
}
38 changes: 38 additions & 0 deletions bin/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { assert } from '@japa/assert'
import { specReporter } from '@japa/spec-reporter'
import { runFailedTests } from '@japa/run-failed-tests'
import { processCliArgs, configure, run } from '@japa/runner'

/*
|--------------------------------------------------------------------------
| 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.
*/
configure({
...processCliArgs(process.argv.slice(2)),
...{
files: ['tests/**/*.spec.ts'],
plugins: [assert(), runFailedTests()],
reporters: [specReporter()],
importer: (filePath) => import(filePath),
forceExit: true,
},
})

/*
|--------------------------------------------------------------------------
| Run tests
|--------------------------------------------------------------------------
|
| The following "run" method is required to execute all the tests.
|
*/
run()

0 comments on commit f4202c0

Please sign in to comment.