Skip to content

Commit

Permalink
refactor(blank-typescript): upgrade packages, config jest, tsconfig a…
Browse files Browse the repository at this point in the history
…nd remove nlp dependencies
  • Loading branch information
Iru89 committed Feb 21, 2024
1 parent 4e2e103 commit 1f60b51
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 57 deletions.
1 change: 1 addition & 0 deletions blank-typescript/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
'@babel/typescript',
],
plugins: [
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-transform-runtime',
],
}
17 changes: 17 additions & 0 deletions blank-typescript/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const path = require('path')

module.exports = {
rootDir: "tests",
transform: {
"^.+\\.[j|t]sx?$": [
"ts-jest",
],
},
transformIgnorePatterns: [
"/node_modules/(?!@botonic).+\\.(js|jsx|ts|tsx)$"
],
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(scss|css|less)$": "<rootDir>/__mocks__/styleMock.js"
}
}
33 changes: 12 additions & 21 deletions blank-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,41 @@
"deploy": "botonic deploy -c build",
"test": "jest"
},
"jest": {
"rootDir": "tests",
"transformIgnorePatterns": [
"/node_modules/(?!@botonic).+\\.(js|jsx|ts|tsx|mjs)$"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(scss|css|less)$": "<rootDir>/__mocks__/styleMock.js"
}
},
"dependencies": {
"@babel/runtime": "^7.23.9",
"@botonic/react": "0.25.0-alpha.4"
},
"devDependencies": {
"@babel/core": "^7.23.9",
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"@babel/plugin-transform-runtime": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@hot-loader/react-dom": "^16.14.0",
"analytics-node": "^3.5.0",
"babel-jest": "^29.7.0",
"babel-loader": "^8.3.0",
"babel-loader": "^9.1.3",
"chokidar": "^3.6.0",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^7.0.0",
"css-loader": "^5.2.7",
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.10.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.6.0",
"imagemin-gifsicle": "^6.0.1",
"imagemin-jpegtran": "^6.0.0",
"imagemin-optipng": "^7.1.0",
"imagemin-svgo": "^7.1.0",
"image-minimizer-webpack-plugin": "^4.0.0",
"imagemin-gifsicle": "^7.0.0",
"imagemin-jpegtran": "^7.0.0",
"imagemin-optipng": "^8.0.0",
"imagemin-svgo": "^10.0.1",
"imagemin-webpack": "^5.1.1",
"jest": "^29.7.0",
"null-loader": "^4.0.1",
"process": "^0.11.10",
"react-hot-loader": "4.12.21",
"sass": "^1.71.0",
"sass-loader": "^10.5.2",
"sass": "^1.71.1",
"sass-loader": "^14.1.1",
"style-loader": "^3.3.4",
"terser": "^5.27.2",
"terser-webpack-plugin": "^5.3.10",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^4.9.5",
"webpack": "^5.90.3",
Expand Down
2 changes: 1 addition & 1 deletion blank-typescript/src/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { PluginConfig } from '@botonic/core'
import type { PluginConfig } from '@botonic/core'

export const plugins: PluginConfig<any>[] = []
10 changes: 5 additions & 5 deletions blank-typescript/tests/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { routes } from '../src/routes'

const app = new NodeApp({ routes, locales, plugins, ...config })

const i = new BotonicInputTester(app)
const o = new BotonicOutputTester(app)
const session = { user: { id: '123' } }
const input = new BotonicInputTester(app)
const output = new BotonicOutputTester(app)

test('TEST: (404) NOT FOUND', async () => {
await expect(i.text('whatever')).resolves.toBe(
o.text("I don't understand you")
)
const response = await input.text('whatever', session)
expect(response).toBe(output.text("I don't understand you"))
})
5 changes: 3 additions & 2 deletions blank-typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
//ERROR in [at-loader] ./node_modules/@botonic/react/node_modules/@types/react/index.d.ts:2814:14
//TS2300: Duplicate identifier 'LibraryManagedAttributes'.
"sourceMap": true,
"target": "ES2022",
"module": "ES2015",
"target": "ES2015",
"module": "Node16",
"moduleResolution": "Node16",
"baseUrl": "src",
"paths": {
"*": ["src/*", "lib/*", "types/*"]
Expand Down
29 changes: 1 addition & 28 deletions blank-typescript/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
const path = require('path')
const webpack = require('webpack')
const CopyPlugin = require('copy-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const ImageminPlugin = require('imagemin-webpack')

const ROOT = path.resolve(__dirname, 'src')
const NLP_DIRNAME = 'nlp'
const ASSETS_DIRNAME = 'assets'
const MODELS_DIRNAME = 'models'
const TASKS_DIRNAME = 'tasks'

const INTENT_CLASSIFICATION_DIRNAME = 'intent-classification'
const OUTPUT_PATH = path.resolve(__dirname, 'dist')
const WEBVIEWS_PATH = path.resolve(OUTPUT_PATH, 'webviews')
const TASKS_PATH = path.join(ROOT, NLP_DIRNAME, TASKS_DIRNAME)

const INTENT_CLASSIFICATION_MODELS_PATH = path.join(
NLP_DIRNAME,
TASKS_DIRNAME,
INTENT_CLASSIFICATION_DIRNAME,
MODELS_DIRNAME
)
const INTENTS_ASSETS_MODELS_PATH = path.join(
ASSETS_DIRNAME,
TASKS_DIRNAME,
INTENT_CLASSIFICATION_DIRNAME,
MODELS_DIRNAME
)

const BOTONIC_PATH = path.resolve(
__dirname,
Expand Down Expand Up @@ -199,7 +180,7 @@ function botonicDevConfig(mode) {
},
resolve: resolveConfig,
devServer: {
static: [OUTPUT_PATH, TASKS_PATH],
static: [OUTPUT_PATH],
liveReload: true,
historyApiFallback: true,
hot: true,
Expand Down Expand Up @@ -332,14 +313,6 @@ function botonicNodeConfig(mode) {
IS_NODE: true,
HUBTYPE_API_URL: JSON.stringify(process.env.HUBTYPE_API_URL),
}),
new CopyPlugin({
patterns: [
{
from: INTENT_CLASSIFICATION_MODELS_PATH,
to: INTENTS_ASSETS_MODELS_PATH,
},
],
}),
],
}
}
Expand Down

0 comments on commit 1f60b51

Please sign in to comment.