Skip to content

Commit

Permalink
chore: reconfigure modules and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Dec 25, 2024
1 parent ac29fa9 commit 4a5eacf
Show file tree
Hide file tree
Showing 17 changed files with 638 additions and 79 deletions.
8 changes: 7 additions & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,21 @@
"build": "rollup -c rollup.config.ts"
},
"devDependencies": {
"@npmcli/arborist": "^9.0.0",
"@rollup/plugin-replace": "^5.0.5",
"@types/jest": "^29.5.12",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.0",
"@types/pacote": "^11.1.8",
"@types/request": "^2.48.12",
"electron": "33.2.1",
"eslint": "8.57.0",
"eslint-plugin-jest": "^27.9.0",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"jest-runner": "^29.7.0",
"pacote": "^21.0.0",
"request": "^2.88.2",
"request-progress": "^3.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.38.5",
"rollup-plugin-commonjs": "^9.1.8",
Expand Down
16 changes: 12 additions & 4 deletions core/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export default [
// Allow json resolution
json(),
// Compile TypeScript files
typescript({ useTsconfigDeclarationDir: true}),
typescript({
useTsconfigDeclarationDir: true,
exclude: ['**/*.test.ts', 'src/node/**'],
}),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
// commonjs(),
// Allow node_modules resolution, so you can use 'external' to control
Expand All @@ -44,7 +47,9 @@ export default [
},
{
input: `src/node/index.ts`,
output: [{ file: 'dist/node/index.cjs.js', format: 'cjs', sourcemap: true }],
output: [
{ file: 'dist/node/index.cjs.js', format: 'cjs', sourcemap: true },
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [
'fs/promises',
Expand All @@ -70,7 +75,10 @@ export default [
// Allow json resolution
json(),
// Compile TypeScript files
typescript({ useTsconfigDeclarationDir: true}),
typescript({
useTsconfigDeclarationDir: true,
exclude: ['**/*.test.ts', 'src/browser/**'],
}),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs(),
// Allow node_modules resolution, so you can use 'external' to control
Expand All @@ -82,4 +90,4 @@ export default [
sourceMaps(),
],
},
]
]
20 changes: 7 additions & 13 deletions core/src/node/api/processors/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ jest.mock('../../helper', () => ({
}))
import { App } from './app'

it('should call stopServer', () => {
const app = new App()
const stopServerMock = jest.fn().mockResolvedValue('Server stopped')
jest.mock('@janhq/server', () => ({
stopServer: stopServerMock,
}))
app.stopServer()
expect(stopServerMock).toHaveBeenCalled()
})

it('should correctly retrieve basename', () => {
const app = new App()
const result = app.baseName('/path/to/file.txt')
Expand All @@ -23,15 +13,17 @@ it('should correctly retrieve basename', () => {
it('should correctly identify subdirectories', () => {
const app = new App()
const basePath = process.platform === 'win32' ? 'C:\\path\\to' : '/path/to'
const subPath = process.platform === 'win32' ? 'C:\\path\\to\\subdir' : '/path/to/subdir'
const subPath =
process.platform === 'win32' ? 'C:\\path\\to\\subdir' : '/path/to/subdir'
const result = app.isSubdirectory(basePath, subPath)
expect(result).toBe(true)
})

it('should correctly join multiple paths', () => {
const app = new App()
const result = app.joinPath(['path', 'to', 'file'])
const expectedPath = process.platform === 'win32' ? 'path\\to\\file' : 'path/to/file'
const expectedPath =
process.platform === 'win32' ? 'path\\to\\file' : 'path/to/file'
expect(result).toBe(expectedPath)
})

Expand All @@ -52,5 +44,7 @@ it('should retrieve the directory name from a file path (Unix/Windows)', async (
it('should retrieve the directory name when using file protocol', async () => {
const app = new App()
const path = 'file:/models/file.txt'
expect(await app.dirName(path)).toBe(process.platform === 'win32' ? 'app\\models' : 'app/models')
expect(await app.dirName(path)).toBe(
process.platform === 'win32' ? 'app\\models' : 'app/models'
)
})
5 changes: 3 additions & 2 deletions core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"declarationDir": "dist/types",
"outDir": "dist/lib",
"importHelpers": true,
"types": ["jest", "node"]
},
"include": ["src"],
"exclude": ["**/*.test.ts"]
}
"exclude": ["*.test.ts"]
}
60 changes: 30 additions & 30 deletions extensions/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -606,151 +606,151 @@ __metadata:

"@janhq/core@file:../../core::locator=%40janhq%2Fassistant-extension%40workspace%3Aassistant-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Fassistant-extension%40workspace%3Aassistant-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Fassistant-extension%40workspace%3Aassistant-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Fconversational-extension%40workspace%3Aconversational-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Fconversational-extension%40workspace%3Aconversational-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Fconversational-extension%40workspace%3Aconversational-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Finference-anthropic-extension%40workspace%3Ainference-anthropic-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Finference-anthropic-extension%40workspace%3Ainference-anthropic-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Finference-anthropic-extension%40workspace%3Ainference-anthropic-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Finference-cohere-extension%40workspace%3Ainference-cohere-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Finference-cohere-extension%40workspace%3Ainference-cohere-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Finference-cohere-extension%40workspace%3Ainference-cohere-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Finference-cortex-extension%40workspace%3Ainference-cortex-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Finference-cortex-extension%40workspace%3Ainference-cortex-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Finference-cortex-extension%40workspace%3Ainference-cortex-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Finference-groq-extension%40workspace%3Ainference-groq-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Finference-groq-extension%40workspace%3Ainference-groq-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Finference-groq-extension%40workspace%3Ainference-groq-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Finference-martian-extension%40workspace%3Ainference-martian-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Finference-martian-extension%40workspace%3Ainference-martian-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Finference-martian-extension%40workspace%3Ainference-martian-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Finference-mistral-extension%40workspace%3Ainference-mistral-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Finference-mistral-extension%40workspace%3Ainference-mistral-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Finference-mistral-extension%40workspace%3Ainference-mistral-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Finference-nvidia-extension%40workspace%3Ainference-nvidia-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Finference-nvidia-extension%40workspace%3Ainference-nvidia-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Finference-nvidia-extension%40workspace%3Ainference-nvidia-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Finference-openai-extension%40workspace%3Ainference-openai-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Finference-openai-extension%40workspace%3Ainference-openai-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Finference-openai-extension%40workspace%3Ainference-openai-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Finference-openrouter-extension%40workspace%3Ainference-openrouter-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Finference-openrouter-extension%40workspace%3Ainference-openrouter-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Finference-openrouter-extension%40workspace%3Ainference-openrouter-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Finference-triton-trt-llm-extension%40workspace%3Ainference-triton-trtllm-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Finference-triton-trt-llm-extension%40workspace%3Ainference-triton-trtllm-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Finference-triton-trt-llm-extension%40workspace%3Ainference-triton-trtllm-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Fmodel-extension%40workspace%3Amodel-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Fmodel-extension%40workspace%3Amodel-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Fmodel-extension%40workspace%3Amodel-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Fmonitoring-extension%40workspace%3Amonitoring-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Fmonitoring-extension%40workspace%3Amonitoring-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Fmonitoring-extension%40workspace%3Amonitoring-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

"@janhq/core@file:../../core::locator=%40janhq%2Ftensorrt-llm-extension%40workspace%3Atensorrt-llm-extension":
version: 0.1.10
resolution: "@janhq/core@file:../../core#../../core::hash=439325&locator=%40janhq%2Ftensorrt-llm-extension%40workspace%3Atensorrt-llm-extension"
resolution: "@janhq/core@file:../../core#../../core::hash=c9eb84&locator=%40janhq%2Ftensorrt-llm-extension%40workspace%3Atensorrt-llm-extension"
dependencies:
rxjs: "npm:^7.8.1"
ulidx: "npm:^2.3.0"
checksum: 10c0/5814fccb8dd7a90788caad0b03bf14eed9efac06fa26061449b30fa2db37b9f3265de5aff6a24d0da8788f6dde15b11eae338c026b2b5c9073695b565524a200
checksum: 10c0/60b6477bcd5ec8dc1db6b520dc09c2fe37e06a48e84e4b89693f9a02d2de29dc9315d1d42d8456ab93d914f5911460782dabe229993fb2ac234f992049c8887b
languageName: node
linkType: hard

Expand Down
6 changes: 4 additions & 2 deletions joi/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "@janhq/joi",
"version": "0.0.0",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"main": "dist/esm/index.js",
"types": "dist/index.d.ts",
"description": "A collection of UI component",
"files": [
Expand Down Expand Up @@ -55,11 +54,14 @@
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.12",
"@types/react": "^18.3.12",
"@types/react-dom": "^19",
"class-variance-authority": "^0.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-transform-css": "^6.0.1",
"prettier": "^3.0.3",
"prettier-plugin-tailwindcss": "^0.5.6",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rimraf": "^6.0.1",
"rollup": "4.12.0",
"rollup-plugin-bundle-size": "1.0.3",
Expand Down
17 changes: 8 additions & 9 deletions joi/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ export default [
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: false,
exports: 'named',
name: packageJson.name,
},
{
file: packageJson.module,
format: 'es',
exports: 'named',
sourcemap: false,
Expand All @@ -56,7 +49,13 @@ export default [
tsconfig: './tsconfig.json',
typescript: typescriptEngine,
sourceMap: false,
exclude: ['docs', 'dist', 'node_modules/**'],
exclude: [
'docs',
'dist',
'node_modules/**',
'**/*.test.ts',
'**/*.test.tsx',
],
}),
terser(),
sass(),
Expand All @@ -78,4 +77,4 @@ export default [
bundleSize(),
],
},
]
]
2 changes: 1 addition & 1 deletion joi/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"esModuleInterop": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "*.test.ts"]
}
1 change: 1 addition & 0 deletions web/containers/CopyInstruction/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import CopyOverInstruction from './index'
// Mock the `useAtom` hook from jotai
jest.mock('jotai', () => ({
useAtom: jest.fn(),
atom: jest.fn(),
}))

describe('CopyOverInstruction', () => {
Expand Down
8 changes: 1 addition & 7 deletions web/containers/CopyInstruction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@ import { ChangeEvent, useCallback } from 'react'

import { Switch } from '@janhq/joi'
import { useAtom } from 'jotai'
import { atomWithStorage } from 'jotai/utils'

const COPY_OVER_INSTRUCTION_ENABLED = 'copy_over_instruction_enabled'

export const copyOverInstructionEnabledAtom = atomWithStorage(
COPY_OVER_INSTRUCTION_ENABLED,
false
)
import { copyOverInstructionEnabledAtom } from '@/helpers/atoms/App.atom'

const CopyOverInstruction: React.FC = () => {
const [copyOverInstructionEnabled, setCopyOverInstructionEnabled] = useAtom(
Expand Down
Loading

0 comments on commit 4a5eacf

Please sign in to comment.