Skip to content

Commit

Permalink
feat: change building for overlay lib
Browse files Browse the repository at this point in the history
  • Loading branch information
mikitabut committed Jan 26, 2024
1 parent dcb0f1a commit f814c40
Show file tree
Hide file tree
Showing 31 changed files with 204 additions and 75 deletions.
1 change: 0 additions & 1 deletion apps/ai-dial-chat-e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true,
Expand Down
2 changes: 1 addition & 1 deletion apps/ai-dial-chat/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM node:20-alpine AS production
RUN apk update && apk upgrade --no-cache libcrypto3 libssl3
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY --from=build /app/.next ./.next
COPY --from=build /app/dist/apps/chat/.next ./dist/apps/chat/.next
COPY --from=build /app/public ./public
COPY --from=build /app/package*.json ./
COPY --from=build /app/next.config.js ./next.config.js
Expand Down
2 changes: 1 addition & 1 deletion apps/ai-dial-chat/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { isServerSessionValid } from '@/src/utils/auth/session';
import { timeoutAsync } from '@/src/utils/auth/timeout-async';

import { Translation } from '../types/translation';
import { Feature } from '@/src/types/features';
import { Feature } from 'shared';
import { fallbackModelID } from '@/src/types/openai';

import { AuthActions, AuthSelectors } from '../store/auth/auth.reducers';
Expand Down
3 changes: 3 additions & 0 deletions apps/ai-dial-chat/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"paths": {
"@/*": ["./*"],
"shared": ["../../libs/shared/src/index.ts"],
},
"baseUrl": ".",
"types": [
Expand All @@ -36,6 +37,8 @@
"**/*.jsx",
"next-env.d.ts",
"postcss.config.js",
"../../libs/shared/src/utils/features.ts",
"../../libs/shared/src/types/features.ts",
],
"exclude": ["node_modules"],
}
12 changes: 6 additions & 6 deletions apps/overlay-sandbox/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"incremental": true,
"plugins": [
{
"name": "next"
}
"name": "next",
},
],
"paths": {
"@epam/ai-dial-overlay": ["../../libs/ai-dial-overlay/src/index.ts"],
"@epam/ai-dial-overlay": ["../../libs/overlay/src/index.ts"],
},
},
"include": [
Expand All @@ -28,12 +28,12 @@
"../../apps/overlay-sandbox/.next/types/**/*.ts",
"../../dist/apps/overlay-sandbox/.next/types/**/*.ts",
"next-env.d.ts",
".next/types/**/*.ts"
".next/types/**/*.ts",
],
"exclude": [
"node_modules",
"jest.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts"
]
"src/**/*.test.ts",
],
}
53 changes: 0 additions & 53 deletions libs/ai-dial-overlay/project.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions libs/overlay/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "overlay",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/overlay/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"options": {
"outputPath": "dist/libs/overlay",
"main": "libs/overlay/src/index.ts",
"tsConfig": "libs/overlay/tsconfig.lib.json",
"assets": ["libs/overlay/*.md"],
"clean": false,
"external": "all"
}
},
"publish": {
"command": "node tools/publish-lib.mjs overlay {args.ver} {args.tag}",
"dependsOn": ["build"]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"libs/my-lib/**/*.{ts,tsx,js,jsx}",
"libs/my-lib/package.json"
]
}
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{options.reportsDirectory}"],
"options": {
"reportsDirectory": "../../coverage/libs/overlay"
}
}
},
"tags": []
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { DeferredRequest } from './utils/DeferredRequest';
import { Task } from './utils/Task';
import { Styles, setStyles } from './utils/styleUtils';

import { Task } from './utils/Task';
// eslint-disable-next-line @nx/enforce-module-boundaries
import { Feature } from 'shared';

export interface ChatOverlayOptions {
domain: string;
Expand All @@ -10,7 +12,7 @@ export interface ChatOverlayOptions {
theme?: string;
modelId?: string;

enabledFeatures?: string;
enabledFeatures?: Feature;

requestTimeout?: number;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
"outDir": "../../dist/out-tsc",
"declaration": true,
"emitDeclarationOnly": true,
"declarationDir": "../../dist/libs/ai-dial-overlay"
"declarationDir": "../../dist/libs/overlay",
"paths": {
"shared": ["../shared/src/index.ts"]
},
"declarationMap": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "src/**/*.spec.ts", "src/**/*.test.ts"]
Expand Down
26 changes: 26 additions & 0 deletions libs/overlay/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"baseUrl": ".",
"paths": {
"shared": ["../shared/src/index.ts"],
},
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json",
},
{
"path": "./tsconfig.spec.json",
},
],
}
14 changes: 14 additions & 0 deletions libs/overlay/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"types": ["node"],
"declaration": true,
"sourceMap": true,
"declarationMap": true,
"paths": {
"shared": ["../shared/src/index.ts"]
}
},
"include": ["src/**/*.ts"],
"exclude": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'vite';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/libs/ai-dial-overlay',
cacheDir: '../../node_modules/.vite/libs/overlay',

plugins: [nxViteTsPaths()],

Expand All @@ -19,7 +19,7 @@ export default defineConfig({
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/libs/ai-dial-overlay',
reportsDirectory: '../../coverage/libs/overlay',
provider: 'v8',
},
},
Expand Down
18 changes: 18 additions & 0 deletions libs/shared/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
20 changes: 20 additions & 0 deletions libs/shared/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "shared",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/shared/src",
"projectType": "library",
"targets": {
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{options.reportsDirectory}"],
"options": {
"reportsDirectory": "../../coverage/libs/shared"
}
}
},
"tags": []
}
2 changes: 2 additions & 0 deletions libs/shared/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './types/features';
export * from './utils/features';
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { availableFeatures } from '@/src/types/features';
import { availableFeatures } from '../types/features';

export const validateFeature = (feature: string) => {
return feature in availableFeatures;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"module": "esnext",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"baseUrl": ".",
},
"files": [],
"include": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "../../dist/libs/ai-dial-overlay",
"types": ["node"]
"outDir": "../../dist/out-tsc",
"types": ["node"],
"paths": {
"@/*": ["./*"]
}
},
"include": ["src/**/*.ts"],
"exclude": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
Expand Down
26 changes: 26 additions & 0 deletions libs/shared/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
},
"include": [
"vite.config.ts",
"vitest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
26 changes: 26 additions & 0 deletions libs/shared/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
import { defineConfig } from 'vite';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/libs/shared',

plugins: [nxViteTsPaths()],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

test: {
globals: true,
cache: { dir: '../../node_modules/.vitest' },
environment: 'node',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/libs/shared',
provider: 'v8',
},
},
});
Loading

0 comments on commit f814c40

Please sign in to comment.