Skip to content

Commit

Permalink
refactor: move to v6
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Mar 15, 2024
1 parent 4425b2e commit 055a856
Show file tree
Hide file tree
Showing 26 changed files with 691 additions and 669 deletions.
7 changes: 0 additions & 7 deletions .bin/test.js

This file was deleted.

16 changes: 0 additions & 16 deletions adonis-typings/container.ts

This file was deleted.

89 changes: 0 additions & 89 deletions adonis-typings/slugify.ts

This file was deleted.

21 changes: 21 additions & 0 deletions bin/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* @adonisjs/lucid-slugify
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import { assert } from '@japa/assert'
import { fileSystem } from '@japa/file-system'
import { configure, processCLIArgs, run } from '@japa/runner'

processCLIArgs(process.argv.splice(2))

configure({
files: ['tests/**/*.spec.ts'],
plugins: [assert(), fileSystem()],
})

run()
21 changes: 21 additions & 0 deletions configure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* @adonisjs/lucid-slugify
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import type Configure from '@adonisjs/core/commands/configure'

export async function configure(command: Configure) {
const codemods = await command.createCodemods()

/**
* Publish provider
*/
await codemods.updateRcFile((rcFile) => {
rcFile.addProvider('@adonisjs/lucid-slugify/slugify_provider')
})
}
5 changes: 2 additions & 3 deletions adonis-typings/index.ts → index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
* @adonisjs/lucid-slugify
*
* (c) Harminder Virk <[email protected]>
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/// <reference path="./slugify.ts" />
/// <reference path="./container.ts" />
export { configure } from './configure.js'
24 changes: 23 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
"files": [
"build"
],
"exports": {
".": "./build/index.js",
"./types": "./build/src/types.js",
"./decorator": "./build/services/slugify.js",
"./services/main": "./build/services/main.js",
"./slugify_provider": "./build/providers/slugify_provider.js"
},
"scripts": {
"clean": "del-cli build",
"copy:templates": "copyfiles --up 1 \"stubs/**/*.stub\" build",
Expand All @@ -27,11 +34,11 @@
"test:mssql": "DB=mssql FORCE_COLOR=true node --enable-source-maps --loader--loader=ts-node/esm ./bin/test.js",
"test:pg": "DB=pg FORCE_COLOR=true node --enable-source-maps --loader--loader=ts-node/esm ./bin/test.js",
"test:docker": "npm run test:mysql && npm run test:mysql_legacy && npm run test:pg && npm run test:mssql",
"test": "docker-compose -f docker-compose.yml -f docker-compose-test.yml build && docker-compose -f docker-compose.yml -f docker-compose-test.yml run --rm test && npm run test:sqlite",
"version": "npm run build",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@adonisjs/assembler": "^7.2.3",
"@adonisjs/core": "^6.3.1",
"@adonisjs/eslint-config": "^1.3.0",
"@adonisjs/lucid": "^20.4.0",
Expand All @@ -48,6 +55,7 @@
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"husky": "^9.0.11",
"luxon": "^3.4.4",
"mysql": "^2.18.1",
"np": "^10.0.1",
"pg": "^8.11.3",
Expand Down Expand Up @@ -111,5 +119,19 @@
"tests/**",
"tests_helpers/**"
]
},
"tsup": {
"entry": [
"./index.ts",
"./src/types.ts",
"./providers/slugify_provider.ts",
"./services/main.ts",
"./services/slugify.ts"
],
"outDir": "./build",
"clean": true,
"format": "esm",
"dts": false,
"target": "esnext"
}
}
29 changes: 0 additions & 29 deletions providers/SlugifyProvider.ts

This file was deleted.

42 changes: 42 additions & 0 deletions providers/slugify_provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* @adonisjs/lucid-slugify
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/// <reference types="@adonisjs/lucid/database_provider" />

import type { ApplicationService } from '@adonisjs/core/types'

import { SlugifyDecorator } from '../src/types.js'
import type { SlugifyManager } from '../src/slugify_manager.js'

declare module '@adonisjs/core/types' {
export interface ContainerBindings {
'slugify.manager': SlugifyManager
'slugify.decorator': SlugifyDecorator
}
}

export default class SlugifyProvider {
constructor(protected app: ApplicationService) {}

register() {
this.app.container.singleton('slugify.manager', async () => {
const db = await this.app.container.make('lucid.db')
const { SlugifyManager } = await import('../src/slugify_manager.js')

return new SlugifyManager(db)
})

this.app.container.singleton('slugify.decorator', async (resolver) => {
const { Slugify } = await import('../src/decorators/slugify.js')
const slugify = new Slugify(await resolver.make('slugify.manager'))

return slugify.slugifyDecorator.bind(slugify)
})
}
}
19 changes: 19 additions & 0 deletions services/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* @adonisjs/lucid-slugify
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import app from '@adonisjs/core/services/app'
import { SlugifyManager } from '../src/slugify_manager.js'

let slugifyManager: SlugifyManager

await app.booted(async () => {
slugifyManager = await app.container.make('slugify.manager')
})

export { slugifyManager as default }
19 changes: 19 additions & 0 deletions services/slugify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* @adonisjs/lucid-slugify
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import app from '@adonisjs/core/services/app'
import { SlugifyDecorator } from '../src/types.js'

let slugify: SlugifyDecorator

await app.booted(async () => {
slugify = await app.container.make('slugify.decorator')
})

export { slugify as default }
Loading

0 comments on commit 055a856

Please sign in to comment.