From 9bfe5a380aa950e21d6d7d772c3fd3433ec26339 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 30 Oct 2024 20:00:06 +0000 Subject: [PATCH 1/3] Github CI build: __run_2 v6.0.0-rc.1 [ci skip] --- lerna.json | 2 +- package.json | 2 +- packages/barrels/package.json | 2 +- packages/cli-core/package.json | 2 +- packages/cli-generate-http-client/package.json | 2 +- packages/cli-generate-swagger/package.json | 2 +- packages/cli-plugin-eslint/package.json | 2 +- packages/cli-plugin-jest/package.json | 2 +- packages/cli-plugin-mongoose/package.json | 2 +- packages/cli-plugin-oidc-provider/package.json | 2 +- packages/cli-plugin-passport/package.json | 2 +- packages/cli-plugin-prisma/package.json | 2 +- packages/cli-plugin-typegraphql/package.json | 2 +- packages/cli-plugin-typeorm/package.json | 2 +- packages/cli-plugin-vitest/package.json | 2 +- packages/cli-testing/package.json | 2 +- packages/cli/package.json | 2 +- tools/typescript/package.json | 2 +- tools/vitest/package.json | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lerna.json b/lerna.json index 6705309da..a0b8d475a 100644 --- a/lerna.json +++ b/lerna.json @@ -3,5 +3,5 @@ "packages": [ "packages/*" ], - "version": "6.0.0-beta.3" + "version": "6.0.0-rc.1" } \ No newline at end of file diff --git a/package.json b/package.json index 1a6f3f290..a23ebce1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tsed/cli-root", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "description": "CLI to bootstrap your Ts.ED project", "private": true, "type": "module", diff --git a/packages/barrels/package.json b/packages/barrels/package.json index 962200674..5c36f8994 100644 --- a/packages/barrels/package.json +++ b/packages/barrels/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/barrels", "description": "A simple tool to generate barrels for your TypeScript project", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "bin": "bin/barrels.js", "keywords": [ diff --git a/packages/cli-core/package.json b/packages/cli-core/package.json index f1e4602d1..993e1f151 100644 --- a/packages/cli-core/package.json +++ b/packages/cli-core/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-core", "description": "Build your CLI with TypeScript and Decorators", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-generate-http-client/package.json b/packages/cli-generate-http-client/package.json index a205f54b1..ff1dd4bd0 100644 --- a/packages/cli-generate-http-client/package.json +++ b/packages/cli-generate-http-client/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-generate-http-client", "description": "Ts.ED CLI plugin. Export a command that generate an HTTP Client (axios or fetch) from your Ts.ED controllers and OS3 spec.", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-generate-swagger/package.json b/packages/cli-generate-swagger/package.json index 784d6b59b..f02ff292f 100644 --- a/packages/cli-generate-swagger/package.json +++ b/packages/cli-generate-swagger/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-generate-swagger", "description": "Ts.ED CLI plugin. Export a command that generate the swagger.json from your Ts.ED controllers and OS3 spec.", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-plugin-eslint/package.json b/packages/cli-plugin-eslint/package.json index eb8031bb8..03fd2bab0 100644 --- a/packages/cli-plugin-eslint/package.json +++ b/packages/cli-plugin-eslint/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-plugin-eslint", "description": "Ts.ED CLI plugin. Add EsLint support", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-plugin-jest/package.json b/packages/cli-plugin-jest/package.json index 2769fd54f..c4d5e1168 100644 --- a/packages/cli-plugin-jest/package.json +++ b/packages/cli-plugin-jest/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-plugin-jest", "description": "Ts.ED CLI plugin. Add Jest support", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-plugin-mongoose/package.json b/packages/cli-plugin-mongoose/package.json index 487fce5bc..c3f58acad 100644 --- a/packages/cli-plugin-mongoose/package.json +++ b/packages/cli-plugin-mongoose/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-plugin-mongoose", "description": "Ts.ED CLI plugin. Add Mongoose support", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-plugin-oidc-provider/package.json b/packages/cli-plugin-oidc-provider/package.json index 101bb04f1..e1b158186 100644 --- a/packages/cli-plugin-oidc-provider/package.json +++ b/packages/cli-plugin-oidc-provider/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-plugin-oidc-provider", "description": "Ts.ED CLI plugin. Add OIDC Provider", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-plugin-passport/package.json b/packages/cli-plugin-passport/package.json index aa4c642e9..a96abfa5c 100644 --- a/packages/cli-plugin-passport/package.json +++ b/packages/cli-plugin-passport/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-plugin-passport", "description": "Ts.ED CLI plugin. Add Passport.js support", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-plugin-prisma/package.json b/packages/cli-plugin-prisma/package.json index 5999f1ae3..b0ef75714 100644 --- a/packages/cli-plugin-prisma/package.json +++ b/packages/cli-plugin-prisma/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-plugin-prisma", "description": "Ts.ED CLI plugin. Add Prisma project initialisation support.", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-plugin-typegraphql/package.json b/packages/cli-plugin-typegraphql/package.json index 82e605c15..b76bb9a26 100644 --- a/packages/cli-plugin-typegraphql/package.json +++ b/packages/cli-plugin-typegraphql/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-plugin-typegraphql", "description": "Ts.ED CLI plugin. Add TypeGraphql support.", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-plugin-typeorm/package.json b/packages/cli-plugin-typeorm/package.json index 45bb595b2..0e39c09a2 100644 --- a/packages/cli-plugin-typeorm/package.json +++ b/packages/cli-plugin-typeorm/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-plugin-typeorm", "description": "Ts.ED CLI plugin. Add TypeORM support", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-plugin-vitest/package.json b/packages/cli-plugin-vitest/package.json index f2d374368..5e262b31c 100644 --- a/packages/cli-plugin-vitest/package.json +++ b/packages/cli-plugin-vitest/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-plugin-vitest", "description": "Ts.ED CLI plugin. Add Jest support", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli-testing/package.json b/packages/cli-testing/package.json index 404c5fe6c..7fc62ef41 100644 --- a/packages/cli-testing/package.json +++ b/packages/cli-testing/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli-testing", "description": "Utils to test you CLI based on Ts.ED CLI", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/packages/cli/package.json b/packages/cli/package.json index 04236354d..994fe6233 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/cli", "description": "CLI to bootstrap your Ts.ED project", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "type": "module", "main": "./lib/esm/index.js", "source": "./src/index.ts", diff --git a/tools/typescript/package.json b/tools/typescript/package.json index 4c02cb6e2..17c0d2932 100644 --- a/tools/typescript/package.json +++ b/tools/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@tsed/typescript", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "description": "Util to compile source", "type": "module", "private": true, diff --git a/tools/vitest/package.json b/tools/vitest/package.json index d0c621171..a9fcb14d8 100644 --- a/tools/vitest/package.json +++ b/tools/vitest/package.json @@ -1,7 +1,7 @@ { "name": "@tsed/vitest", "type": "module", - "version": "6.0.0-beta.3", + "version": "6.0.0-rc.1", "private": true, "exports": { ".": "./index.js", From 109c0e841c47d9f54b4f668ecdac81cfd717a2fa Mon Sep 17 00:00:00 2001 From: Romain Lenzotti Date: Sat, 9 Nov 2024 18:36:25 +0100 Subject: [PATCH 2/3] fix(barrels): add more test on @tsed/barrels --- packages/barrels/bin/generate-barrel.js | 49 +++++++------------ .../scenario-2/sub-directory-1/file2.ts | 1 + .../scenario-2/sub-directory-2/file2.ts | 1 + .../barrels/test/barrels.integration.spec.js | 26 ++++++++++ 4 files changed, 47 insertions(+), 30 deletions(-) create mode 100644 packages/barrels/test/__mock__/scenario-2/sub-directory-1/file2.ts create mode 100644 packages/barrels/test/__mock__/scenario-2/sub-directory-2/file2.ts diff --git a/packages/barrels/bin/generate-barrel.js b/packages/barrels/bin/generate-barrel.js index 9a989cdd7..4e10180fd 100644 --- a/packages/barrels/bin/generate-barrel.js +++ b/packages/barrels/bin/generate-barrel.js @@ -3,18 +3,24 @@ import path, {dirname, join} from "node:path"; import {globby} from "globby"; -// async function cleanIndex(cwd, excluded) { -// const patterns = [ -// "**/index.ts", -// ...excluded -// ]; -// -// const files = await globby(patterns, { -// cwd: cwd -// }); -// -// return Promise.all(files.map((file) => fs.unlink(join(cwd, file)))); -// } +async function generateIndex(directory, {cwd, excluded}) { + const baseIndex = join(cwd, directory?.path ?? directory); + + const files = await globby(["**/*.{ts,tsx}", "!index.{ts,tsx}", ...excluded], { + cwd: path.join(cwd, directory) + }); + + const exports = files + .sort((a, b) => a.localeCompare(b)) + .map((file) => { + // TODO set .js after all configuration are ok to resolve .js + return `export * from "./${file.replace(".ts", ".js")}";`; + }); + + const content = ["/**", " * @file Automatically generated by @tsed/barrels.", " */", ...exports]; + + await writeFile(join(baseIndex, "index.ts"), content.join("\n") + "\n", {encoding: "utf8"}); +} export async function generateBarrels({exclude, directory, cwd}) { const excluded = exclude.map((path) => `!${path}`).concat(directory.map((path) => `!${path}/index.ts`)); @@ -32,24 +38,7 @@ export async function generateBarrels({exclude, directory, cwd}) { return set.add(dirname(file)); }, new Set()); - const promises = [...directories.keys()].map(async (directory) => { - const baseIndex = join(cwd, directory?.path ?? directory); - - const files = await globby(["**/*.{ts,tsx}", "!index.{ts,tsx}", ...excluded], { - cwd: path.join(cwd, directory) - }); - - const exports = files - .sort((a, b) => a.localeCompare(b)) - .map((file) => { - // TODO set .js after all configuration are ok to resolve .js - return `export * from "./${file.replace(".ts", ".js")}";`; - }); - - const content = ["/**", " * @file Automatically generated by @tsed/barrels.", " */", ...exports]; - - await writeFile(join(baseIndex, "index.ts"), content.join("\n") + "\n", {encoding: "utf8"}); - }); + const promises = [...directories.keys()].map((directory) => generateIndex(directory, {excluded, cwd})); await Promise.all(promises); } diff --git a/packages/barrels/test/__mock__/scenario-2/sub-directory-1/file2.ts b/packages/barrels/test/__mock__/scenario-2/sub-directory-1/file2.ts new file mode 100644 index 000000000..f67f4d372 --- /dev/null +++ b/packages/barrels/test/__mock__/scenario-2/sub-directory-1/file2.ts @@ -0,0 +1 @@ +export const file3 = "file3"; diff --git a/packages/barrels/test/__mock__/scenario-2/sub-directory-2/file2.ts b/packages/barrels/test/__mock__/scenario-2/sub-directory-2/file2.ts new file mode 100644 index 000000000..f67f4d372 --- /dev/null +++ b/packages/barrels/test/__mock__/scenario-2/sub-directory-2/file2.ts @@ -0,0 +1 @@ +export const file3 = "file3"; diff --git a/packages/barrels/test/barrels.integration.spec.js b/packages/barrels/test/barrels.integration.spec.js index 186f53c4b..6d516bd6e 100644 --- a/packages/barrels/test/barrels.integration.spec.js +++ b/packages/barrels/test/barrels.integration.spec.js @@ -30,4 +30,30 @@ describe("barrels.integration.ts", () => { 'export * from "./sub-directory/file2.js";\n' ); }); + + // eslint-disable-next-line vitest/expect-expect + it("should generate barrels (with multiple directories)", async () => { + const cwd = join(import.meta.dirname, "__mock__"); + // Test code here + await generateBarrels({ + cwd, + directory: ["./scenario-2/sub-directory-1", "./scenario-2/sub-directory-2"], + exclude: ["**/__mock__", "**/__mocks__", "**/*.spec.ts"], + delete: true + }); + + const result = await fs.readFile(join(cwd, "scenario-2", "sub-directory-1", "index.ts"), "utf-8"); + + assert.strictEqual( + result, + "/**\n" + " * @file Automatically generated by @tsed/barrels.\n" + " */\n" + 'export * from "./file2.js";\n' + ); + + const result1 = await fs.readFile(join(cwd, "scenario-2", "sub-directory-2", "index.ts"), "utf-8"); + + assert.strictEqual( + result, + "/**\n" + " * @file Automatically generated by @tsed/barrels.\n" + " */\n" + 'export * from "./file2.js";\n' + ); + }); }); From e30b50008230c618108e896221d4ebc507f1847f Mon Sep 17 00:00:00 2001 From: Romain Lenzotti Date: Sat, 9 Nov 2024 18:37:15 +0100 Subject: [PATCH 3/3] chore: update mono repo utils --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index a23ebce1a..9e3c56bdc 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "@swc/core": "1.7.26", "@swc/helpers": "0.5.13", "@tsed/markdown-it-symbols": "3.20.8", - "@tsed/monorepo-utils": "2.3.5", + "@tsed/monorepo-utils": "2.3.10", "@tsed/ts-doc": "^4.1.0", "@types/node": "22.7.4", "@typescript-eslint/eslint-plugin": "8.7.0", diff --git a/yarn.lock b/yarn.lock index cfa9f4c83..ce3f891f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2552,7 +2552,7 @@ __metadata: "@tsed/di": "npm:>=8.0.0-rc.1" "@tsed/logger": "npm:>=6.2.1" "@tsed/markdown-it-symbols": "npm:3.20.8" - "@tsed/monorepo-utils": "npm:2.3.5" + "@tsed/monorepo-utils": "npm:2.3.10" "@tsed/normalize-path": "npm:>=8.0.0-rc.1" "@tsed/openspec": "npm:>=8.0.0-rc.1" "@tsed/schema": "npm:>=8.0.0-rc.1" @@ -2705,9 +2705,9 @@ __metadata: languageName: node linkType: hard -"@tsed/monorepo-utils@npm:2.3.5": - version: 2.3.5 - resolution: "@tsed/monorepo-utils@npm:2.3.5" +"@tsed/monorepo-utils@npm:2.3.10": + version: 2.3.10 + resolution: "@tsed/monorepo-utils@npm:2.3.10" dependencies: "@samverschueren/stream-to-observable": "npm:>=0.3.1" "@typescript-eslint/typescript-estree": "npm:>=6.20.0" @@ -2734,7 +2734,7 @@ __metadata: semantic-release: ">=19" bin: monorepo: bin/monorepo.js - checksum: 10/9336adfbf603e688d391595b9849a144d413da21132dece44ffa41f602e3547fc566b7b338e8c907562d73dfe74c9e809dda0b140f2ed5cbb0b3c5279fd1835e + checksum: 10/712bfc40bc97a658d726f8efd938501fb39222e34018cf2d052fc7b221014944668bc7edbd0b9f7171d24c30f2b5674b1c9cb8295079a2a49e7fb7ff65f50f59 languageName: node linkType: hard