Skip to content

Commit

Permalink
chore(cli): migrate unit test on vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Sep 14, 2024
1 parent 074348f commit b12605c
Show file tree
Hide file tree
Showing 181 changed files with 3,986 additions and 6,007 deletions.
15 changes: 0 additions & 15 deletions .eslintignore

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged $1
#npx lint-staged $1
76 changes: 76 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import typescriptParser from "@typescript-eslint/parser";
import pluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import pluginSimpleImportSort from "eslint-plugin-simple-import-sort";
import vitest from "eslint-plugin-vitest";
import pluginWorkspaces from "eslint-plugin-workspaces";
import globals from "globals";

export default [
{
ignores: ["coverage", "dist", "processes.config.js"]
},
{
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
parser: typescriptParser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module"
},
globals: {
...globals.node
}
},
plugins: {
"@typescript-eslint": typescriptEslint
},
rules: {
// "@typescript-eslint/lines-between-class-members": [
// "error",
// "always",
// { exceptAfterOverload: true }
// ],
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-non-null-assertion": 0
}
},
{
files: ["**/*.spec.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"], // or any other pattern
plugins: {
vitest
},
rules: {
...vitest.configs.recommended.rules, // you can also use vitest.configs.all.rules to enable all rules
"vitest/consistent-test-it": [
"error",
{ fn: "it", withinDescribe: "it" }
],
"vitest/no-alias-methods": "error"
}
},
{
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
languageOptions: {
parserOptions: {}
},
plugins: {
"simple-import-sort": pluginSimpleImportSort,
workspaces: pluginWorkspaces
},
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"workspaces/no-absolute-imports": "error"
}
},
pluginPrettierRecommended
];
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
"postinstall": "cd docs && yarn install",
"configure": "monorepo ci configure",
"clean": "monorepo clean workspace",
"test": "lerna run test --stream",
"test": "vitest run",
"lint": "eslint '**/*.{ts,js}'",
"test:lint": "lerna run lint --stream",
"test:lint:fix": "lerna run lint:fix --stream",
"lint:fix": "eslint '**/*.{ts,js}' --fix",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"build": "monorepo build --verbose",
"build:references": "node ./tools/typescript",
Expand All @@ -23,7 +22,6 @@
"api:build": "lerna run build && tsdoc",
"vuepress:build": "rm -rf ./docs/api && cd ./docs && yarn vuepress:build",
"vuepress:serve": "vuepress dev docs",
"prettier": "prettier '**/*.{ts,js,json,md,yml,yaml}' --write",
"release": "semantic-release",
"release:dryRun": "semantic-release --dry-run",
"prepare": "is-ci || husky install"
Expand Down Expand Up @@ -64,7 +62,7 @@
"inquirer": "8.2.4",
"inquirer-autocomplete-prompt": "2.0.0",
"js-yaml": "4.1.0",
"lerna": "5.4.3",
"lerna": "8.1.8",
"listr2": "5.0.5",
"module-alias": "2.2.2",
"read-pkg-up": "7.0.1",
Expand All @@ -84,24 +82,25 @@
"@tsed/monorepo-utils": "2.3.5",
"@tsed/ts-doc": "^4.1.0",
"@types/node": "18.7.8",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@typescript-eslint/parser": "^5.33.1",
"@typescript-eslint/eslint-plugin": "8.5.0",
"@typescript-eslint/parser": "8.5.0",
"@vitest/coverage-v8": "^2.1.1",
"concurrently": "7.6.0",
"coveralls": "3.1.1",
"cross-env": "7.0.3",
"entities": "1.1.2",
"eslint": "8.22.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-mocha": "10.1.0",
"eslint-plugin-prettier": "4.2.1",
"eslint": "9.10.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-simple-import-sort": "12.1.1",
"eslint-plugin-vitest": "^0.5.4",
"eslint-plugin-workspaces": "0.8.0",
"gflow": "^5.1.2",
"husky": "8.0.1",
"is-ci": "3.0.1",
"lint-staged": "13.0.3",
"markdown-it": "13.0.1",
"prettier": "2.7.1",
"prettier": "3.3.3",
"semantic-release": "23.0.2",
"semantic-release-slack-bot": "4.0.2",
"sinon": "14.0.0",
Expand Down
13 changes: 0 additions & 13 deletions packages/cli-core/.eslintignore

This file was deleted.

1 change: 0 additions & 1 deletion packages/cli-core/.eslintrc.cjs

This file was deleted.

4 changes: 0 additions & 4 deletions packages/cli-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"scripts": {
"build": "yarn build:ts",
"build:ts": "tsc --build tsconfig.json",
"lint": "eslint '**/*.{ts,js}'",
"lint:fix": "eslint '**/*.{ts,js}' --fix",
"test": "vitest run",
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
},
Expand Down Expand Up @@ -71,7 +69,6 @@
"uuid": "^8.3.2"
},
"devDependencies": {
"@tsed/eslint": "5.2.10",
"@tsed/typescript": "workspace:*",
"@types/axios": "0.14.0",
"@types/commander": "2.12.2",
Expand All @@ -89,7 +86,6 @@
"@types/uuid": "8.3.4",
"cross-env": "7.0.3",
"deps": "^1.0.0",
"eslint": "8.22.0",
"typescript": "4.9.5",
"vitest": "2.1.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-core/src/services/NpmRegistryClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {CliHttpClient} from "./CliHttpClient";
import {NpmRegistryClient} from "./NpmRegistryClient";

describe("NpmRegistryClient", () => {
beforeEach(CliPlatformTest.create);
afterEach(CliPlatformTest.reset);
beforeEach(() => CliPlatformTest.create());
afterEach(() => CliPlatformTest.reset());

describe("search()", () => {
it("should search packages", async () => {
Expand Down
13 changes: 0 additions & 13 deletions packages/cli-generate-http-client/.eslintignore

This file was deleted.

1 change: 0 additions & 1 deletion packages/cli-generate-http-client/.eslintrc.js

This file was deleted.

6 changes: 5 additions & 1 deletion packages/cli-generate-http-client/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
src
test
tsconfig.compile.json
coverage
tsconfig.json
tsconfig.*.json
__mock__
*.spec.js
*.tsbuildinfo
14 changes: 0 additions & 14 deletions packages/cli-generate-http-client/jest.config.js

This file was deleted.

30 changes: 15 additions & 15 deletions packages/cli-generate-http-client/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{
"name": "@tsed/cli-generate-http-client",
"version": "5.2.10",
"description": "Ts.ED CLI plugin. Export a command that generate an HTTP Client (axios or fetch) from your Ts.ED controllers and OS3 spec.",
"type": "commonjs",
"version": "5.2.10",
"source": "./src/index.ts",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"typings": "./lib/types/index.d.ts",
"exports": {
"types": "./lib/types/index.d.ts",
"import": "./lib/esm/index.js",
"require": "./lib/cjs/index.js",
"default": "./lib/esm/index.js"
".": {
"types": "./lib/types/index.d.ts",
"import": "./lib/esm/index.js",
"require": "./lib/cjs/index.js",
"default": "./lib/esm/index.js"
}
},
"scripts": {
"build": "yarn build:ts",
"build:ts": "tsc --build tsconfig.json && tsc --build tsconfig.esm.json",
"lint": "eslint '**/*.{ts,js}'",
"lint:fix": "eslint '**/*.{ts,js}' --fix",
"test": "cross-env NODE_ENV=test yarn jest --max-workers=2 --passWithNoTests && jest-coverage-thresholds-bumper"
"build:ts": "tsc --build tsconfig.json",
"/test": "vitest run",
"/test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
},
"dependencies": {
"change-case": "4.1.2",
Expand All @@ -26,13 +28,11 @@
"devDependencies": {
"@tsed/cli": "5.2.10",
"@tsed/cli-core": "5.2.10",
"@tsed/eslint": "5.2.10",
"@tsed/jest-config": "5.2.10",
"@tsed/typescript": "5.2.10",
"@tsed/typescript": "workspace:*",
"cross-env": "7.0.3",
"eslint": "8.22.0",
"jest": "29.5.0",
"swagger-typescript-api": "^9.3.1"
"swagger-typescript-api": "^9.3.1",
"typescript": "4.9.5",
"vitest": "2.1.1"
},
"peerDependencies": {
"@tsed/common": ">=7.14.2",
Expand Down
28 changes: 28 additions & 0 deletions packages/cli-generate-http-client/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"extends": "@tsed/typescript/tsconfig.node.json",
"compilerOptions": {
"baseUrl": ".",
"module": "commonjs",
"moduleResolution": "Node16",
"rootDir": "src",
"outDir": "./lib/cjs",
"declaration": true,
"declarationDir": "./lib/types",
"composite": true,
"noEmit": false
},
"include": ["src", "src/**/*.json"],
"exclude": [
"node_modules",
"test",
"lib",
"benchmark",
"coverage",
"spec",
"**/*.benchmark.ts",
"**/*.spec.ts",
"keys",
"**/__mock__/**",
"webpack.config.js"
]
}
19 changes: 4 additions & 15 deletions packages/cli-generate-http-client/tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
"extends": "@tsed/typescript/tsconfig.node.json",
"compilerOptions": {
"baseUrl": ".",
"module": "ES2020",
"module": "ESNext",
"moduleResolution": "nodenext",
"rootDir": "src",
"outDir": "./lib/esm",
"declarationDir": "./lib/types-esm",
"declaration": true,
"declarationDir": "./lib/types",
"composite": true,
"noEmit": false
},
"include": [
"src",
"src/**/*.json"
],
"include": ["src", "src/**/*.json"],
"exclude": [
"node_modules",
"test",
Expand All @@ -24,16 +22,7 @@
"**/*.benchmark.ts",
"**/*.spec.ts",
"keys",
"jest.config.js",
"**/__mock__/**",
"webpack.config.js"
],
"references": [
{
"path": "../cli"
},
{
"path": "../cli-core"
}
]
}
Loading

0 comments on commit b12605c

Please sign in to comment.