Skip to content

Commit

Permalink
refactor: migrate to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Jun 23, 2023
1 parent dba3ec3 commit 6360c15
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 136 deletions.
45 changes: 10 additions & 35 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,14 @@
name: test
name: checks
on:
- push
- pull_request

jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 16.15.1
- 18.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:
- 16.15.1
- 18.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
test:
uses: japa/.github/.github/workflows/test.yml@main

lint:
uses: japa/.github/.github/workflows/lint.yml@main

typecheck:
uses: japa/.github/.github/workflows/typecheck.yml@main
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
build
coverage
12 changes: 1 addition & 11 deletions bin/japa_types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
import '@japa/runner'

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

interface Test<TestData> {
// notify TypeScript about custom test properties
}
}
declare module '@japa/runner' {}
3 changes: 2 additions & 1 deletion bin/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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'
import { pathToFileURL } from 'node:url'

/*
|--------------------------------------------------------------------------
Expand All @@ -22,7 +23,7 @@ configure({
files: ['tests/**/*.spec.ts'],
plugins: [assert(), runFailedTests()],
reporters: [specReporter()],
importer: (filePath) => import(filePath),
importer: (filePath) => import(pathToFileURL(filePath).href),
},
})

Expand Down
127 changes: 59 additions & 68 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,112 +1,103 @@
{
"name": "@japa/expect-type",
"version": "1.0.3",
"description": "Write assertions for TypeScript types",
"version": "1.0.3",
"main": "./build/index.js",
"type": "module",
"files": [
"index.ts",
"src",
"build/src",
"build/index.d.ts",
"build/index.js",
"build/index.d.ts"
"build/index.d.ts.map"
],
"exports": {
".": "./build/index.js"
},
"type": "commonjs",
"scripts": {
"pretest": "npm run lint",
"test": "node --require=@adonisjs/require-ts/build/register bin/test.ts",
"pretest": "npm run lint && npm run typecheck",
"test": "c8 npm run quick:test",
"clean": "del-cli build",
"compile": "npm run lint && npm run clean && tsc",
"build": "npm run compile",
"release": "np --message=\"chore(release): %s\"",
"version": "npm run build",
"prepublishOnly": "npm run build",
"lint": "eslint . --ext=.ts",
"typecheck": "tsc --noEmit",
"format": "prettier --write .",
"sync-labels": "github-label-sync --labels .github/labels.json japa/expect-type"
},
"publishConfig": {
"access": "public",
"tag": "latest"
"quick:test": "node --loader ts-node/esm bin/test.ts",
"sync-labels": "github-label-sync --labels .github/labels.json japa/file-system"
},
"keywords": [],
"author": "virk,japa",
"license": "MIT",
"devDependencies": {
"@adonisjs/require-ts": "^2.0.13",
"@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2",
"@japa/assert": "^1.3.7",
"@adonisjs/eslint-config": "^1.1.5",
"@adonisjs/prettier-config": "^1.1.5",
"@adonisjs/tsconfig": "^1.1.5",
"@commitlint/cli": "^17.6.5",
"@commitlint/config-conventional": "^17.6.5",
"@japa/assert": "^1.4.1",
"@japa/run-failed-tests": "^1.1.1",
"@japa/runner": "^2.2.3",
"@japa/spec-reporter": "^1.3.2",
"@types/node": "^18.13.0",
"@japa/runner": "^2.5.1",
"@japa/spec-reporter": "^1.3.3",
"@swc/core": "^1.3.66",
"@types/node": "^20.3.1",
"c8": "^8.0.0",
"del-cli": "^5.0.0",
"eslint": "^8.33.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-adonis": "^3.0.3",
"eslint-plugin-prettier": "^4.0.0",
"github-label-sync": "^2.2.0",
"eslint": "^8.43.0",
"github-label-sync": "^2.3.1",
"husky": "^8.0.3",
"np": "^7.6.3",
"prettier": "^2.8.3",
"typescript": "^4.9.5"
"np": "^8.0.4",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
"typescript": "^5.1.3"
},
"dependencies": {
"expect-type": "^0.16.0"
},
"peerDependencies": {
"@japa/runner": "^2.2.3"
},
"dependencies": {
"expect-type": "^0.15.0"
"author": "virk,japa",
"license": "MIT",
"homepage": "https://github.com/japa/expect-type#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/japa/expect-type.git"
},
"eslintConfig": {
"extends": [
"plugin:adonis/typescriptPackage",
"prettier"
],
"plugins": [
"prettier"
],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
]
}
"bugs": {
"url": "https://github.com/japa/expect-type/issues"
},
"eslintIgnore": [
"build"
],
"prettier": {
"trailingComma": "es5",
"semi": false,
"singleQuote": true,
"useTabs": false,
"quoteProps": "consistent",
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 100
"keywords": [],
"eslintConfig": {
"extends": "@adonisjs/eslint-config/package"
},
"prettier": "@adonisjs/prettier-config",
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"publishConfig": {
"access": "public",
"tag": "next"
},
"np": {
"message": "chore(release): %s",
"tag": "latest",
"tag": "next",
"branch": "main",
"anyBranch": false
},
"c8": {
"reporter": [
"text",
"html"
],
"exclude": [
"tests/**"
]
},
"directories": {
"test": "tests"
},
"repository": {
"type": "git",
"url": "git+https://github.com/japa/expect-type.git"
},
"bugs": {
"url": "https://github.com/japa/expect-type/issues"
},
"homepage": "https://github.com/japa/expect-type#readme"
}
}
24 changes: 3 additions & 21 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
{
"extends": "@adonisjs/tsconfig/tsconfig.package.json",
"compilerOptions": {
"target": "ES2022",
"module": "CommonJS",
"lib": ["ES2022"],
"noUnusedLocals": true,
"noUnusedParameters": true,
"isolatedModules": true,
"removeComments": true,
"declaration": true,
"rootDir": "./",
"outDir": "./build",
"strictNullChecks": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"skipLibCheck": true,
"types": ["@types/node"]
},
"include": ["./**/*"],
"exclude": ["./node_modules", "./build"]
"outDir": "./build"
}
}

0 comments on commit 6360c15

Please sign in to comment.