Skip to content

Commit

Permalink
refactor(childs): update childs using node v20
Browse files Browse the repository at this point in the history
  • Loading branch information
Iru89 committed Feb 21, 2024
1 parent 28fdfbf commit 3a1fea6
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 180 deletions.
5 changes: 2 additions & 3 deletions childs/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ module.exports = {
],
],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-runtime',
require('@babel/plugin-transform-modules-commonjs'),
require('@babel/plugin-transform-runtime'),
],
}
18 changes: 18 additions & 0 deletions childs/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const path = require('path')

module.exports = {
rootDir: "tests",
transform: {
"^.+\\.jsx?$": [
"babel-jest",
{ "configFile": path.resolve(__dirname, "babel.config.js") },
],
},
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"
}
}
86 changes: 38 additions & 48 deletions childs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,50 @@
"version": "1.0.0",
"scripts": {
"build": "webpack --env target=all --mode=production",
"start": "webpack serve --env target=dev --mode=development",
"test": "jest",
"train:ner": "ts-node src/nlp/tasks/ner/train.ts",
"train:intent-classification": "ts-node src/nlp/tasks/intent-classification/train.ts"
},
"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"
}
"start": "webpack-dev-server --env target=dev --mode=development",
"deploy": "botonic deploy -c build",
"test": "jest"
},
"dependencies": {
"@babel/runtime": "^7.12.5",
"@botonic/react": "~0.21.0"
"@babel/runtime": "^7.23.9",
"@botonic/react": "0.25.0-alpha.4"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/preset-react": "^7.12.10",
"@hot-loader/react-dom": "^17.0.1",
"analytics-node": "^3.4.0-beta.3",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"chokidar": "^3.4.3",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^7.0.0",
"css-loader": "^5.0.1",
"@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",
"@hot-loader/react-dom": "^16.14.0",
"analytics-node": "^3.5.0",
"babel-jest": "^29.7.0",
"babel-loader": "^9.1.3",
"chokidar": "^3.6.0",
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.10.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.0.0-alpha.17",
"imagemin-gifsicle": "^6.0.0",
"imagemin-jpegtran": "^6.0.0",
"imagemin-optipng": "^7.0.0",
"imagemin-svgo": "^7.0.0",
"imagemin-webpack": "^5.0.0",
"jest": "^26.6.3",
"node-sass": "^8.0.0",
"html-webpack-plugin": "^5.6.0",
"image-minimizer-webpack-plugin": "^4.0.0",
"imagemin": "^8.0.1",
"imagemin-gifsicle": "^7.0.0",
"imagemin-jpegtran": "^7.0.0",
"imagemin-optipng": "^8.0.0",
"imagemin-svgo": "^10.0.1",
"jest": "^29.7.0",
"null-loader": "^4.0.1",
"process": "^0.11.10",
"react-hot-loader": "^4.13.0",
"sass": "^1.30.0",
"sass-loader": "^10.1.0",
"style-loader": "^2.0.0",
"terser": "^5.5.1",
"terser-webpack-plugin": "^5.0.3",
"ts-node": "^10.4.0",
"typescript": "^4.4.4",
"webpack": "^5.10.3",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "4.13.3"
"react-hot-loader": "4.12.21",
"sass": "^1.71.1",
"sass-loader": "^14.1.1",
"style-loader": "^3.3.4",
"svgo": "^3.2.0",
"terser": "^5.27.2",
"terser-webpack-plugin": "^5.3.10",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "5.0.2"
},
"engines": {
"node": ">=20.0.0"
}
}
Empty file removed childs/src/nlp/data/en/.gitkeep
Empty file.
Empty file.
68 changes: 0 additions & 68 deletions childs/src/nlp/tasks/intent-classification/train.ts

This file was deleted.

51 changes: 30 additions & 21 deletions childs/tests/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ 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: hi.js', async () => {
await expect(i.text('Hi')).resolves.toBe(
o.text(
const response = await input.text('Hi', session)
await expect(response).toBe(
output.text(
'Hi! Choose what you want to eat:',
o.replies(
output.replies(
{ text: 'Pizza', payload: 'pizza' },
{ text: 'Pasta', path: 'pasta' }
)
Expand All @@ -27,10 +29,11 @@ test('TEST: hi.js', async () => {
})

test('TEST: pizza.js', async () => {
await expect(i.payload('pizza', {}, 'hi')).resolves.toBe(
o.text(
const response = await input.payload('pizza', session, 'hi')
expect(response).toBe(
output.text(
'You chose Pizza! Choose one ingredient:',
o.replies(
output.replies(
{ text: 'Sausage', payload: 'sausage' },
{ text: 'Bacon', payload: 'bacon' }
)
Expand All @@ -39,22 +42,25 @@ test('TEST: pizza.js', async () => {
})

test('TEST: sausage.js', async () => {
await expect(i.payload('sausage', {}, 'hi/pizza')).resolves.toBe(
o.text('You chose Sausage on Pizza')
const response = await input.payload('sausage', session, 'hi/pizza')
expect(response).toBe(
output.text('You chose Sausage on Pizza')
)
})

test('TEST: bacon.js', async () => {
await expect(i.path('bacon', {}, 'hi/pizza')).resolves.toBe(
o.text('You chose Bacon on Pizza')
const response = await input.path('bacon', session, 'hi/pizza')
expect(response).toBe(
output.text('You chose Bacon on Pizza')
)
})

test('TEST: pasta.js', async () => {
await expect(i.payload('pasta', {}, 'hi')).resolves.toBe(
o.text(
const response = await input.payload('pasta', session, 'hi')
expect(response).toBe(
output.text(
'You chose Pasta! Choose one ingredient:',
o.replies(
output.replies(
{ text: 'Cheese', payload: 'cheese' },
{ text: 'Tomato', payload: 'tomato' }
)
Expand All @@ -63,19 +69,22 @@ test('TEST: pasta.js', async () => {
})

test('TEST: cheese.js', async () => {
await expect(i.payload('cheese', {}, 'hi/pasta')).resolves.toBe(
o.text('You chose Cheese on Pasta')
const response = await input.payload('cheese', session, 'hi/pasta')
expect(response).toBe(
output.text('You chose Cheese on Pasta')
)
})

test('TEST: tomato.js', async () => {
await expect(i.path('tomato', {}, 'hi/pasta')).resolves.toBe(
o.text('You chose Tomato on Pasta')
const response = await input.path('tomato', session, 'hi/pasta')
expect(response).toBe(
output.text('You chose Tomato on Pasta')
)
})

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")
)
})
53 changes: 13 additions & 40 deletions childs/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
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 ImageMinimizerPlugin = require('image-minimizer-webpack-plugin')

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 @@ -121,8 +103,6 @@ const babelLoaderConfig = {
],
],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-runtime',
],
},
Expand Down Expand Up @@ -165,16 +145,17 @@ const stylesLoaderConfig = {
],
}

const imageminPlugin = new ImageminPlugin({
bail: false,
cache: false,
imageminOptions: {
plugins: [
['imagemin-gifsicle', { interlaced: true }],
['imagemin-jpegtran', { progressive: true }],
['imagemin-optipng', { optimizationLevel: 5 }],
['imagemin-svgo', { removeViewBox: true }],
],
const imageminPlugin = new ImageMinimizerPlugin({
minimizer: {
implementation: ImageMinimizerPlugin.imageminMinify,
options: {
plugins: [
"imagemin-gifsicle",
"imagemin-jpegtran",
"imagemin-optipng",
"imagemin-svgo",
],
},
},
})

Expand All @@ -200,7 +181,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 @@ -333,14 +314,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 3a1fea6

Please sign in to comment.