Skip to content

Commit

Permalink
chore: update tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Aug 24, 2024
1 parent 257d0d3 commit 9666d59
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 78 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"postinstall": "node tools/yarn/postinstall.js && cd docs && yarn install && cd .. && node ./tools/github-sponsors/bin/github-sponsors.js",
"configure": "monorepo ci configure",
"clean": "monorepo clean workspace",
"test": "lerna run test --concurrency 2",
"test": "vitest run",
"test:ci": "yarn test:lint && yarn test:core && yarn test:specs && yarn test:platform && yarn test:integration && yarn test:graphql && yarn test:orm && yarn test:security && yarn test:formio && yarn test:third-parties",
"test:lint": "eslint '**/*.{ts,js}'",
"test:lint:fix": "eslint '**/*.{ts,js}' --fix",
Expand Down
18 changes: 15 additions & 3 deletions tools/typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ async function main() {
const tsConfigBuildCjsPath = join(path, "tsconfig.cjs.json");
const tsConfigBuildSpecPath = join(path, "tsconfig.spec.json");
const npmignore = join(path, ".npmignore");
const vitestPath = join(path, "vitest.config.mts");
const vitePath = join(path, "vite.config.mts");

const hasFiles = await globby(["{src,test}/**/*.spec.ts", "!node_modules"], {
cwd: path
Expand Down Expand Up @@ -101,10 +103,20 @@ async function main() {
.forEach((dep) => {
paths["@tsed/" + dep.name] = [relative(dirname(pkg.path), dirname(dep.path)) + "/src"];
});
tsConfigTemplateSpec.compilerOptions.paths = paths;
tsConfigTemplateSpec.compilerOptions.rootDir = relative(dirname(tsConfigBuildSpecPath), packagesRootDir);
const tsCopy = cloneDeep(tsConfigTemplateSpec);
tsCopy.compilerOptions.paths = paths;
tsCopy.compilerOptions.rootDir = relative(dirname(tsConfigBuildSpecPath), packagesRootDir);

await fs.writeJSON(tsConfigBuildSpecPath, tsConfigTemplateSpec, {spaces: 2});
if (fs.existsSync(vitestPath)) {
tsCopy.include.push("vitest.config.mts");
tsCopy.compilerOptions.types = ["vite/client", "vitest/globals"];
}

if (fs.existsSync(vitePath)) {
tsCopy.include.push("vite.config.mts");
}

await fs.writeJSON(tsConfigBuildSpecPath, tsCopy, {spaces: 2});
}

await fs.writeJson(tsConfigPath, tsConfig, {spaces: 2});
Expand Down
10 changes: 9 additions & 1 deletion tools/vitest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ async function main() {
const promises = packages.map(async (pkg) => {
if (pkg.pkg.scripts && pkg.pkg.scripts["test"]) {
pkg.pkg.scripts["test"] = "vitest run";
pkg.pkg.scripts["test:ci"] = "vitest run --coverage.autoUpdate=true";
pkg.pkg.scripts["test:ci"] = "vitest run --coverage.thresholds.autoUpdate=true";
pkg.pkg.devDependencies["vitest"] = monoRepo.rootPkg.devDependencies["vitest"];
pkg.pkg.devDependencies["jest"] = undefined;
pkg.pkg.devDependencies["jest-coverage-thresholds-bumper"] = undefined;

await fs.writeJson(pkg.path, pkg.pkg, {spaces: 2});
await fs.writeFile(join(dirname(pkg.path), "vitest.config.mts"), vitestTemplate);

const jestFile = join(dirname(pkg.path), "jest.config.js");

if (fs.existsSync(jestFile)) {
await fs.removeSync(jestFile);
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion tools/vitest/presets/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {sync} from "globby";
import {readFileSync} from "node:fs";
import {basename, dirname, join} from "node:path";

const root = join(import.meta.dirname, "../..");
const root = join(import.meta.dirname, "../../..");

function deps(pkg, pkgs, set = new Set()) {
Object.keys({
Expand Down
39 changes: 20 additions & 19 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
"moduleResolution": "node",
"skipLibCheck": true
},
"include": ["vite.workspace.mts"],
"references": [
{
"path": "./packages/core/tsconfig.json"
"path": "./packages/engines/tsconfig.json"
},
{
"path": "./packages/engines/tsconfig.json"
"path": "./packages/core/tsconfig.json"
},
{
"path": "./packages/specs/openspec/tsconfig.json"
Expand Down Expand Up @@ -71,10 +72,10 @@
"path": "./packages/graphql/apollo/tsconfig.json"
},
{
"path": "./packages/graphql/typegraphql/tsconfig.json"
"path": "./packages/graphql/graphql-ws/tsconfig.json"
},
{
"path": "./packages/graphql/graphql-ws/tsconfig.json"
"path": "./packages/graphql/typegraphql/tsconfig.json"
},
{
"path": "./packages/specs/ajv/tsconfig.json"
Expand All @@ -88,6 +89,9 @@
{
"path": "./packages/orm/adapters-redis/tsconfig.json"
},
{
"path": "./packages/orm/objection/tsconfig.json"
},
{
"path": "./packages/orm/mongoose/tsconfig.json"
},
Expand All @@ -97,9 +101,6 @@
{
"path": "./packages/orm/mikro-orm/tsconfig.json"
},
{
"path": "./packages/orm/objection/tsconfig.json"
},
{
"path": "./packages/orm/prisma/tsconfig.json"
},
Expand All @@ -116,10 +117,10 @@
"path": "./packages/platform/platform-test-sdk/tsconfig.json"
},
{
"path": "./packages/platform/platform-koa/tsconfig.json"
"path": "./packages/platform/platform-express/tsconfig.json"
},
{
"path": "./packages/platform/platform-express/tsconfig.json"
"path": "./packages/platform/platform-koa/tsconfig.json"
},
{
"path": "./packages/platform/platform-serverless-testing/tsconfig.json"
Expand All @@ -136,18 +137,18 @@
{
"path": "./packages/security/oidc-provider/tsconfig.json"
},
{
"path": "./packages/security/passport/tsconfig.json"
},
{
"path": "./packages/security/oidc-provider-plugin-wildcard-redirect-uri/tsconfig.json"
},
{
"path": "./packages/third-parties/bullmq/tsconfig.json"
"path": "./packages/security/passport/tsconfig.json"
},
{
"path": "./packages/third-parties/agenda/tsconfig.json"
},
{
"path": "./packages/third-parties/bullmq/tsconfig.json"
},
{
"path": "./packages/third-parties/event-emitter/tsconfig.json"
},
Expand All @@ -158,10 +159,10 @@
"path": "./packages/third-parties/formio/tsconfig.json"
},
{
"path": "./packages/third-parties/schema-formio/tsconfig.json"
"path": "./packages/third-parties/pulse/tsconfig.json"
},
{
"path": "./packages/third-parties/pulse/tsconfig.json"
"path": "./packages/third-parties/schema-formio/tsconfig.json"
},
{
"path": "./packages/third-parties/socketio-testing/tsconfig.json"
Expand All @@ -176,16 +177,16 @@
"path": "./packages/third-parties/stripe/tsconfig.json"
},
{
"path": "./packages/third-parties/vike/tsconfig.json"
"path": "./packages/third-parties/temporal/tsconfig.json"
},
{
"path": "./packages/third-parties/vite-ssr-plugin/tsconfig.json"
"path": "./packages/third-parties/terminus/tsconfig.json"
},
{
"path": "./packages/third-parties/terminus/tsconfig.json"
"path": "./packages/third-parties/vike/tsconfig.json"
},
{
"path": "./packages/third-parties/temporal/tsconfig.json"
"path": "./packages/third-parties/vite-ssr-plugin/tsconfig.json"
},
{
"path": "./tools/integration/tsconfig.json"
Expand Down
3 changes: 3 additions & 0 deletions vitest.workspace.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default [
'packages/**/vitest.config.{mts,ts}',
]
Loading

0 comments on commit 9666d59

Please sign in to comment.