diff --git a/.github/workflows/code-qa.yml b/.github/workflows/code-qa.yml index 0fbd581fe7..271ecc1f28 100644 --- a/.github/workflows/code-qa.yml +++ b/.github/workflows/code-qa.yml @@ -134,8 +134,8 @@ jobs: working-directory: apps/vscode-e2e run: xvfb-run -a pnpm test:ci - unit-test: - needs: [platform-unit-test] # [platform-unit-test, integration-test] + qa: + needs: [check-translations, knip, compile, platform-unit-test, integration-test] runs-on: ubuntu-latest steps: - name: NO-OP diff --git a/MONOREPO.md b/MONOREPO.md index 65c21d8b1e..f436b116eb 100644 --- a/MONOREPO.md +++ b/MONOREPO.md @@ -24,6 +24,19 @@ pnpm install If things are in good working order then you should be able to build a vsix and install it in VSCode: ```sh -pnpm build --out ../bin/roo-code-main.vsix && \ +pnpm build -- --out ../bin/roo-code-main.vsix && \ code --install-extension bin/roo-code-main.vsix ``` + +To fully stress the monorepo setup, run the following: + +```sh +pnpm clean && pnpm lint +pnpm clean && pnpm check-types +pnpm clean && pnpm test +pnpm clean && pnpm bundle +pnpm clean && pnpm build +pnpm clean && pnpm npx turbo watch:bundle +pnpm clean && pnpm npx turbo watch:tsc +cd apps/vscode-e2e && pnpm test:ci +``` diff --git a/packages/types/README.md b/packages/types/npm/README.md similarity index 100% rename from packages/types/README.md rename to packages/types/npm/README.md diff --git a/packages/types/npm/package.json b/packages/types/npm/package.json new file mode 100644 index 0000000000..a1e46de317 --- /dev/null +++ b/packages/types/npm/package.json @@ -0,0 +1,40 @@ +{ + "name": "@roo-code/types", + "version": "1.19.0", + "description": "TypeScript type definitions for Roo Code.", + "publishConfig": { + "access": "public", + "name": "@roo-code/types" + }, + "author": "Roo Code Team", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/RooCodeInc/Roo-Code.git" + }, + "bugs": { + "url": "https://github.com/RooCodeInc/Roo-Code/issues" + }, + "homepage": "https://github.com/RooCodeInc/Roo-Code/tree/main/packages/types", + "keywords": [ + "roo", + "roo-code", + "ai" + ], + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } + } + }, + "files": [ + "dist" + ] +} diff --git a/packages/types/package.json b/packages/types/package.json index e1accd1282..db05e3921b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,58 +1,26 @@ { "name": "@roo-code/types", - "version": "1.16.0", - "description": "TypeScript type definitions for Roo Code.", - "publishConfig": { - "access": "public", - "main": "./dist/index.js", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } - } - }, - "author": "Roo Code Team", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/RooCodeInc/Roo-Code.git" - }, - "bugs": { - "url": "https://github.com/RooCodeInc/Roo-Code/issues" - }, - "homepage": "https://github.com/RooCodeInc/Roo-Code/tree/main/packages/types", - "keywords": [ - "roo", - "roo-code", - "ai" - ], - "main": "./dist/index.js", + "version": "0.0.0", + "type": "module", + "main": "./dist/index.cjs", "exports": { ".": { "types": "./src/index.ts", "import": "./src/index.ts", "require": { - "types": "./dist/index.d.ts", - "default": "./dist/index.js" + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" } } }, - "files": [ - "dist" - ], "scripts": { "lint": "eslint src --ext=ts --max-warnings=0", "check-types": "tsc --noEmit", "test": "vitest --globals --run", "build": "tsup", - "prepublishOnly": "pnpm run build", - "publish:test": "pnpm publish --dry-run", - "publish": "pnpm publish", - "clean": "rimraf dist .turbo" + "npm:publish:test": "tsup --outDir npm/dist && cd npm && npm publish --dry-run", + "npm:publish": "tsup --outDir npm/dist && cd npm && npm publish", + "clean": "rimraf dist npm/dist .turbo" }, "dependencies": { "zod": "^3.24.2" diff --git a/packages/types/src/__tests__/cjs-import.test.ts b/packages/types/src/__tests__/cjs-import.test.ts deleted file mode 100644 index 09ca107a44..0000000000 --- a/packages/types/src/__tests__/cjs-import.test.ts +++ /dev/null @@ -1,64 +0,0 @@ -// npx vitest run src/__tests__/cjs-import.test.ts - -import { resolve } from "path" - -describe("CommonJS Import Tests", () => { - const packageRoot = resolve(__dirname, "../..") - const cjsPath = resolve(packageRoot, "dist", "index.js") - - it("should import types using require() syntax", () => { - // Clear require cache to ensure fresh import. - delete require.cache[cjsPath] - - // Use require to test CJS functionality. - // eslint-disable-next-line @typescript-eslint/no-require-imports - const module = require(cjsPath) - - // Verify that key exports are available - expect(module.GLOBAL_STATE_KEYS).toBeDefined() - expect(Array.isArray(module.GLOBAL_STATE_KEYS)).toBe(true) - expect(module.GLOBAL_STATE_KEYS.length).toBeGreaterThan(0) - }) - - it("should import specific exports using destructuring", () => { - // Clear require cache. - delete require.cache[cjsPath] - - // Test destructured require. - // eslint-disable-next-line @typescript-eslint/no-require-imports - const { GLOBAL_STATE_KEYS, SECRET_STATE_KEYS } = require(cjsPath) - - expect(GLOBAL_STATE_KEYS).toBeDefined() - expect(SECRET_STATE_KEYS).toBeDefined() - expect(Array.isArray(GLOBAL_STATE_KEYS)).toBe(true) - expect(Array.isArray(SECRET_STATE_KEYS)).toBe(true) - }) - - it("should have default export available", () => { - // Clear require cache - delete require.cache[cjsPath] - - // eslint-disable-next-line @typescript-eslint/no-require-imports - const module = require(cjsPath) - - // Check if module has expected structure - expect(typeof module).toBe("object") - expect(module).not.toBeNull() - }) - - it("should maintain consistency between multiple require calls", () => { - // Clear require cache first. - delete require.cache[cjsPath] - - // Multiple require calls should return the same cached module. - // eslint-disable-next-line @typescript-eslint/no-require-imports - const firstRequire = require(cjsPath) - - // eslint-disable-next-line @typescript-eslint/no-require-imports - const secondRequire = require(cjsPath) - - // Should be the exact same object (cached). - expect(firstRequire).toBe(secondRequire) - expect(firstRequire.GLOBAL_STATE_KEYS).toBe(secondRequire.GLOBAL_STATE_KEYS) - }) -}) diff --git a/packages/types/src/__tests__/esm-import.test.ts b/packages/types/src/__tests__/esm-import.test.ts deleted file mode 100644 index 786ae62e8c..0000000000 --- a/packages/types/src/__tests__/esm-import.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -// npx vitest run src/__tests__/esm-import.test.ts - -describe("ESM Import Tests", () => { - it("should import types using ESM syntax", async () => { - // Dynamic import to test ESM functionality. - const module = await import("../index.js") - - // Verify that key exports are available. - expect(module.GLOBAL_STATE_KEYS).toBeDefined() - expect(Array.isArray(module.GLOBAL_STATE_KEYS)).toBe(true) - expect(module.GLOBAL_STATE_KEYS.length).toBeGreaterThan(0) - }) - - it("should import specific exports using ESM syntax", async () => { - // Test named imports. - const { GLOBAL_STATE_KEYS, SECRET_STATE_KEYS } = await import("../index.js") - - expect(GLOBAL_STATE_KEYS).toBeDefined() - expect(SECRET_STATE_KEYS).toBeDefined() - expect(Array.isArray(GLOBAL_STATE_KEYS)).toBe(true) - expect(Array.isArray(SECRET_STATE_KEYS)).toBe(true) - }) - - it("should have consistent exports between static and dynamic imports", async () => { - // Static import. - const staticImport = await import("../index.js") - - // Dynamic import. - const dynamicImport = await import("../index.js") - - // Both should have the same exports. - expect(Object.keys(staticImport)).toEqual(Object.keys(dynamicImport)) - expect(staticImport.GLOBAL_STATE_KEYS).toEqual(dynamicImport.GLOBAL_STATE_KEYS) - }) -}) diff --git a/packages/types/src/__tests__/index.test.ts b/packages/types/src/__tests__/index.test.ts index fd1e9e1c88..c3df37fa97 100644 --- a/packages/types/src/__tests__/index.test.ts +++ b/packages/types/src/__tests__/index.test.ts @@ -1,4 +1,4 @@ -// npx vitest run --globals src/__tests__/index.test.ts +// npx vitest run src/__tests__/index.test.ts import { GLOBAL_STATE_KEYS } from "../index.js" diff --git a/packages/types/src/__tests__/package-exports.test.ts b/packages/types/src/__tests__/package-exports.test.ts deleted file mode 100644 index d6c09d42dd..0000000000 --- a/packages/types/src/__tests__/package-exports.test.ts +++ /dev/null @@ -1,83 +0,0 @@ -// npx vitest run src/__tests__/package-exports.test.ts - -import { resolve } from "path" - -describe("Package Exports Integration Tests", () => { - const packageRoot = resolve(__dirname, "../..") - const distPath = resolve(packageRoot, "dist") - - it("should import from built ESM file", async () => { - const esmPath = resolve(distPath, "index.mjs") - - // Dynamic import of the built ESM file - const module = await import(esmPath) - - expect(module.GLOBAL_STATE_KEYS).toBeDefined() - expect(Array.isArray(module.GLOBAL_STATE_KEYS)).toBe(true) - expect(module.GLOBAL_STATE_KEYS.length).toBeGreaterThan(0) - }) - - it("should import from built CJS file", () => { - const cjsPath = resolve(distPath, "index.js") - - // Clear require cache to ensure fresh import - delete require.cache[cjsPath] - - // Require the built CJS file - // eslint-disable-next-line @typescript-eslint/no-require-imports - const module = require(cjsPath) - - expect(module.GLOBAL_STATE_KEYS).toBeDefined() - expect(Array.isArray(module.GLOBAL_STATE_KEYS)).toBe(true) - expect(module.GLOBAL_STATE_KEYS.length).toBeGreaterThan(0) - }) - - it("should have consistent exports between ESM and CJS builds", async () => { - const esmPath = resolve(distPath, "index.mjs") - const cjsPath = resolve(distPath, "index.js") - - // Clear require cache. - delete require.cache[cjsPath] - - // Import both versions. - const esmModule = await import(esmPath) - // eslint-disable-next-line @typescript-eslint/no-require-imports - const cjsModule = require(cjsPath) - - // Compare key exports. - expect(esmModule.GLOBAL_STATE_KEYS).toEqual(cjsModule.GLOBAL_STATE_KEYS) - expect(esmModule.SECRET_STATE_KEYS).toEqual(cjsModule.SECRET_STATE_KEYS) - - // Ensure both have the same export keys. - const esmKeys = Object.keys(esmModule).sort() - const cjsKeys = Object.keys(cjsModule).sort() - expect(esmKeys).toEqual(cjsKeys) - }) - - it("should import using package name resolution (simulated)", async () => { - // This simulates how the package would be imported by consumers. - // We test the source files since we can't easily test the published package. - const module = await import("../index.js") - - // Verify the main exports that consumers would use. - expect(module.GLOBAL_STATE_KEYS).toBeDefined() - expect(module.SECRET_STATE_KEYS).toBeDefined() - - // Test some common type exports exist. - expect(typeof module.GLOBAL_STATE_KEYS).toBe("object") - expect(typeof module.SECRET_STATE_KEYS).toBe("object") - }) - - it("should have TypeScript definitions available", () => { - const dtsPath = resolve(distPath, "index.d.ts") - // eslint-disable-next-line @typescript-eslint/no-require-imports - const fs = require("fs") - - // Check that the .d.ts file exists and has content. - expect(fs.existsSync(dtsPath)).toBe(true) - - const dtsContent = fs.readFileSync(dtsPath, "utf8") - expect(dtsContent.length).toBeGreaterThan(0) - expect(dtsContent).toContain("export") - }) -}) diff --git a/packages/types/tsup.config.ts b/packages/types/tsup.config.ts index fccbcc170a..9c96eb1901 100644 --- a/packages/types/tsup.config.ts +++ b/packages/types/tsup.config.ts @@ -8,9 +8,4 @@ export default defineConfig({ splitting: false, sourcemap: true, outDir: "dist", - outExtension({ format }) { - return { - js: format === "cjs" ? ".js" : ".mjs", - } - }, })