Skip to content

Commit

Permalink
feat: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Apr 14, 2024
1 parent b80fb82 commit 4068556
Show file tree
Hide file tree
Showing 17 changed files with 569 additions and 77 deletions.
17 changes: 17 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { join } from 'node:path'
import { julr } from '@julr/tooling-configs/eslint'

export default await julr(
{
enableGitIgnore: {
files: join(import.meta.dirname, '.gitignore'),
root: true,
strict: true,
},
},
{
rules: {
'@typescript-eslint/ban-types': 'off',
},
},
)
30 changes: 13 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"name": "@tuyau/monorepo",
"description": "",
"type": "module",
"version": "0.0.0",
"description": "",
"author": "Julien Ripouteau <[email protected]>",
"license": "ISC",
"keywords": [],
"main": "index.js",
"scripts": {
"typecheck": "pnpm run -r --parallel typecheck",
Expand All @@ -11,30 +15,22 @@
"release": "pnpm run build && changeset publish"
},
"devDependencies": {
"@adonisjs/eslint-config": "^1.3.0",
"@adonisjs/prettier-config": "^1.3.0",
"@adonisjs/tsconfig": "^1.3.0",
"@japa/assert": "^2.1.0",
"@japa/assert": "^3.0.0",
"@japa/expect-type": "^2.0.2",
"@japa/file-system": "^2.3.0",
"@japa/runner": "^3.1.1",
"@swc/core": "^1.4.6",
"@japa/runner": "^3.1.2",
"@julr/tooling-configs": "^2.2.0",
"@swc/core": "^1.4.13",
"c8": "^9.1.0",
"copyfiles": "^2.4.1",
"del-cli": "^5.1.0",
"eslint": "^8.57.0",
"eslint": "^9.0.0",
"nock": "^14.0.0-beta.5",
"prettier": "^3.2.5",
"release-it": "^17.1.1",
"release-it": "^17.2.0",
"ts-node": "^10.9.2",
"tsup": "^8.0.2",
"typescript": "^5.4.2"
},
"author": "Julien Ripouteau <[email protected]>",
"license": "ISC",
"keywords": [],
"eslintConfig": {
"extends": "@adonisjs/eslint-config/package"
"typescript": "^5.4.5"
},
"prettier": "@adonisjs/prettier-config"
"prettier": "@julr/tooling-configs/prettier"
}
22 changes: 11 additions & 11 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{
"name": "@tuyau/client",
"description": "e2e client for AdonisJS",
"type": "module",
"version": "0.0.3",
"description": "e2e client for AdonisJS",
"author": "Julien Ripouteau <[email protected]>",
"license": "ISC",
"keywords": [],
"exports": {
".": "./build/index.js"
},
"main": "build/index.js",
"type": "module",
"files": [
"build"
],
"exports": {
".": "./build/index.js"
},
"scripts": {
"lint": "eslint .",
"typecheck": "tsc --noEmit",
Expand All @@ -19,16 +22,13 @@
"quick:test": "node --loader ts-node/esm bin/test.ts",
"checks": "pnpm lint && pnpm typecheck"
},
"devDependencies": {
"@tuyau/utils": "workspace:*"
},
"dependencies": {
"@poppinss/matchit": "^3.1.2",
"ky": "^1.2.3"
},
"author": "Julien Ripouteau <[email protected]>",
"license": "ISC",
"keywords": [],
"devDependencies": {
"@tuyau/utils": "workspace:*"
},
"tsup": {
"entry": [
"./index.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function createProxy(client: KyInstance, config: any, paths: string[] = []): any
*/
export function createTuyau<const T extends Record<string, any>>(
baseUrl: string,
options?: TuyauOptions
options?: TuyauOptions,
): AdonisClient<T> {
const client = ky.create({ prefixUrl: baseUrl, throwHttpErrors: false, ...options })
return createProxy(client, options)
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class TuyauHTTPError extends Error {
constructor(
public status: number,
public data: unknown
public data: unknown,
) {
super(data + '')
this.name = 'TuyauHTTPError'
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Options as KyOptions } from 'ky'
import { Simplify, Serialize, IsNever, Prettify } from '@tuyau/utils/types'
import type { Simplify, Serialize, IsNever, Prettify } from '@tuyau/utils/types'

/**
* Shape of the response returned by Tuyau
Expand Down
3 changes: 2 additions & 1 deletion packages/client/tests/client.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import nock from 'nock'
import { test } from '@japa/runner'
import type { Serialize, Simplify } from '@tuyau/utils/types'

import { createTuyau } from '../index.js'
import { Serialize, Simplify } from '@tuyau/utils/types'

test.group('Client', () => {
test('post something', async ({ assert, expectTypeOf }) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": "@adonisjs/tsconfig/tsconfig.package.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "./build",
"lib": ["DOM", "ESNext"],
"types": []
"rootDir": "./",
"types": [],
"outDir": "./build"
}
}
15 changes: 8 additions & 7 deletions packages/codegen/commands/routes.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { existsSync } from 'node:fs'
import { mkdir, writeFile } from 'node:fs/promises'
// @ts-expect-error tkt
import matchit from '@poppinss/matchit'
import { fileURLToPath } from 'node:url'
import { dirname, relative, join } from 'node:path'
import { BaseCommand } from '@adonisjs/core/ace'
import { mkdir, writeFile } from 'node:fs/promises'
import { dirname, relative, join } from 'node:path'
import { Node, Project, QuoteKind } from 'ts-morph'
import type { RouteJSON } from '@adonisjs/core/types/http'
import type { MethodDeclaration, SourceFile } from 'ts-morph'
import type { CommandOptions } from '@adonisjs/core/types/ace'
import { parseBindingReference } from '@adonisjs/core/helpers'
import { RouteJSON } from '@adonisjs/core/types/http'
// @ts-ignore
import matchit from '@poppinss/matchit'

type HandlerData = { method: MethodDeclaration; body: Node }

type RouteReferenceParsed = Awaited<ReturnType<typeof parseBindingReference>>

export default class CodegenTypes extends BaseCommand {
Expand Down Expand Up @@ -146,7 +147,7 @@ export default class CodegenTypes extends BaseCommand {
*/
#extractClassHandlerData(
file: SourceFile,
routeHandler: RouteReferenceParsed
routeHandler: RouteReferenceParsed,
): HandlerData | undefined {
const classDef = file.getClasses().find((c) => c.isDefaultExport())
if (!classDef) return
Expand Down Expand Up @@ -185,7 +186,7 @@ export default class CodegenTypes extends BaseCommand {
*/
const routeHandler = await parseBindingReference(route.handler.reference)
const file = sourcesFiles.find((sf) =>
sf.getFilePath().endsWith(`${routeHandler.moduleNameOrPath.replace('#', '')}.ts`)
sf.getFilePath().endsWith(`${routeHandler.moduleNameOrPath.replace('#', '')}.ts`),
)

if (!file) continue
Expand Down
2 changes: 1 addition & 1 deletion packages/codegen/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
|
*/

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

export async function configure(command: ConfigureCommand) {
const codemods = await command.createCodemods()
Expand Down
39 changes: 20 additions & 19 deletions packages/codegen/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
{
"name": "@tuyau/codegen",
"description": "",
"version": "0.0.3",
"engines": {
"node": ">=20.6.0"
},
"type": "module",
"files": [
"build"
],
"version": "0.0.3",
"description": "",
"author": "",
"license": "MIT",
"keywords": [],
"exports": {
".": "./build/index.js",
"./types": "./build/src/types.js",
"./commands": "./build/commands/main.js"
},
"files": [
"build"
],
"engines": {
"node": ">=20.6.0"
},
"scripts": {
"clean": "del-cli build",
"copy:templates": "copyfiles \"stubs/**/*.stub\" build",
Expand All @@ -30,22 +33,20 @@
"version": "npm run build",
"prepublishOnly": "npm run build"
},
"peerDependencies": {
"@adonisjs/core": "^6.2.0"
},
"dependencies": {
"ts-morph": "^22.0.0"
},
"devDependencies": {
"@adonisjs/assembler": "^7.2.3",
"@adonisjs/core": "^6.3.1",
"@adonisjs/assembler": "^7.4.0",
"@adonisjs/core": "^6.5.0",
"@poppinss/matchit": "^3.1.2",
"@tuyau/client": "workspace:*",
"@tuyau/utils": "workspace:*",
"@types/node": "^20.11.25",
"nock": "^14.0.0-beta.5",
"ts-morph": "^22.0.0"
},
"peerDependencies": {
"@adonisjs/core": "^6.2.0"
"@types/node": "^20.12.7"
},
"author": "",
"license": "MIT",
"keywords": [],
"publishConfig": {
"access": "public",
"tag": "latest"
Expand Down
11 changes: 7 additions & 4 deletions packages/codegen/tests/example.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { HttpContext } from '@adonisjs/core/http'
import nock from 'nock'
import { test } from '@japa/runner'
import { createTuyau } from '@tuyau/client'
import { Serialize } from '@tuyau/utils/types'
import { Simplify, ConvertReturnTypeToRecordStatusResponse } from '@tuyau/utils/types'
import nock from 'nock'
import type { HttpContext } from '@adonisjs/core/http'
import type {
Serialize,
Simplify,
ConvertReturnTypeToRecordStatusResponse,
} from '@tuyau/utils/types'

test.group('Typings', () => {
test('status helpers methods', async ({ expectTypeOf }) => {
Expand Down
1 change: 1 addition & 0 deletions packages/codegen/tsnode.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
*/

import { register } from 'node:module'

register('ts-node/esm', import.meta.url)
16 changes: 8 additions & 8 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"name": "@tuyau/utils",
"description": "Utilities for Tuyau",
"type": "module",
"version": "0.0.1",
"description": "Utilities for Tuyau",
"author": "Julien Ripouteau <[email protected]>",
"license": "ISC",
"keywords": [],
"exports": {
"./types": "./build/types.js"
},
"main": "index.js",
"type": "module",
"files": [
"build"
],
"exports": {
"./types": "./build/types.js"
},
"scripts": {
"lint": "eslint .",
"typecheck": "tsc --noEmit",
"release": "pnpm build && pnpm release-it",
"build": "tsup-node",
"checks": "pnpm lint && pnpm typecheck"
},
"author": "Julien Ripouteau <[email protected]>",
"license": "ISC",
"keywords": [],
"publishConfig": {
"access": "public",
"tag": "latest"
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "@adonisjs/tsconfig/tsconfig.package.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "./build",
"types": []
"types": [],
"outDir": "./build"
}
}
Loading

0 comments on commit 4068556

Please sign in to comment.