Skip to content

Commit

Permalink
Botonic with Node v20 (#2780)
Browse files Browse the repository at this point in the history
## Description
This PR includes #2803 and #2790

Removed from version 1.0.0-dev
- botonic-api
- botonic-pulumi
- create-botonic-app package

Removes old AI packages that we won't update anymore
- botonic-nlp
- botonic-intent-classification
- botonic-ner

Removes the package-lock.json from each package

Add the examples folder to the monorepo with the
https://github.com/hubtype/botonic-examples but examples using
@botonic/dx in the devDependencies and the new version of @botonic/react

With node 20 you use npm 10. 
With npm 10 I created a monorepo using npm workspaces. With this
monorepo you do `npm install` in the root of the project and this
creates a shared node_modules in the root. You can run scripts for each
package from the botonic root. For example `npm run build -w
@botonic/core`

Change several things about how builds are done using tsc. It adds a
tsconfig.esm.base.json and tsconfig.cjs.base.json to the root of the
project and extends these two files to create the builds of all
packages.

## Context

This PR updates many dependencies such as Node, npm, webpack (webpack
plugin), jest, eslint (eslint plugins), prettier, axios, etc.
It also updates the github actions so that builds are done properly when
running tests in the repository.

## Approach taken / Explain the design

When using an npm monorepo, symlink internal to the monorepo is used.
When using symlink it is necessary to build @botonic/core before making
changes to a package that requires `@botonic/core`.
For example if you want to change `@botonic/react` code you need to
build `@botonic/core` to make the imports work, pass the lint, pass the
tests etc.
This is also important in the github actions. now you can declare a
BUILD_COMMAND for cases where you need to build core first.

## To document / Usage example

To start developing using all these new versions of node, npm, monorepo,
etc.

- Remove all package-lock.json, all node_modules and lib folders
- With nvm (or similar) use node 20 and npm 10
- From root folder do an `npm i` 
- Then an npm build on `@botonic/core`
- Then an npm build on `@botonic/react`

## Testing

All the tests that already existed are still running locally and in the
GitHub repository.

Update a @botonic/cli deploy.test.ts that used an example published in
the master branch of the external @botonic-examples repository. Now use
the examples folder inside the monorepo so that changes can be made and
tests can be tested before releasing the example bot version.

---------

Co-authored-by: Marc Rabat <[email protected]>
  • Loading branch information
Iru89 and vanbasten17 authored Mar 27, 2024
1 parent 8c11085 commit f038bce
Show file tree
Hide file tree
Showing 818 changed files with 40,843 additions and 71,109 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/botonic-ci-test-all-packages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Botonic test all packages
name: Botonic CI test all packages

on:
workflow_dispatch:
Expand Down Expand Up @@ -49,6 +49,7 @@ jobs:
PACKAGE_NAME: Botonic plugin-dialogflow tests
PACKAGE: botonic-plugin-dialogflow
UNIT_TEST_COMMAND: npm run test_ci
BUILD_COMMAND: 'cd ../botonic-core && npm run build && cd ../botonic-plugin-dialogflow && npm run build'
PUBLISH_TESTS_RESULTS: 'yes'
NEEDS_CODECOV_UPLOAD: 'yes'

Expand All @@ -68,7 +69,7 @@ jobs:
with:
PACKAGE_NAME: Botonic plugin-google-analytics tests
PACKAGE: botonic-plugin-google-analytics
BUILD_COMMAND: ''
BUILD_COMMAND: 'cd ../botonic-core && npm run build && cd ../botonic-plugin-google-analytics && npm run build'
UNIT_TEST_COMMAND: ''

botonic-plugin-inbenta-tests:
Expand Down Expand Up @@ -113,4 +114,5 @@ jobs:
with:
PACKAGE_NAME: Botonic react tests
PACKAGE: botonic-react
BUILD_COMMAND: 'cd ../botonic-core && npm run build && cd ../botonic-react && npm run build'
NEEDS_CODECOV_UPLOAD: 'yes'
16 changes: 8 additions & 8 deletions .github/workflows/botonic-common-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
NODE_VERSION:
type: string
description: 'Node version of the package'
default: '14'
default: '20'
required: false
PACKAGE_NAME:
type: string
Expand Down Expand Up @@ -44,20 +44,20 @@ on:
required: false

jobs:
bot-tests:
botonic-tests:
name: ${{ inputs.PACKAGE_NAME }} tests
runs-on: ubuntu-latest
steps:
- name: Checking out to current branch
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setting up node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.NODE_VERSION }}

- name: Setting up cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -75,8 +75,8 @@ jobs:
role-duration-seconds: 900
role-session-name: HubtypeCITests

- name: Install dev dependencies
run: (cd ./packages/${{ inputs.PACKAGE }} && npm install -D)
- name: Install dependencies
run: npm install

- name: Build
if: ${{ inputs.BUILD_COMMAND != '' }}
Expand All @@ -95,7 +95,7 @@ jobs:
CONTENTFUL_TEST_MANAGE_TOKEN: ${{ secrets.CONTENTFUL_TEST_MANAGE_TOKEN }}

- name: Verify lint
run: (cd ./packages/${{ inputs.PACKAGE }} && npm run lint_ci)
run: (cd ./packages/${{ inputs.PACKAGE }} && npm run lint_core)

- name: Publish Unit Test Results
if: ${{ inputs.PUBLISH_TESTS_RESULTS != '' && always() }}
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/botonic-nlp-tests.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/botonic-nlu-tests.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/botonic-plugin-dialogflow-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
with:
PACKAGE_NAME: Botonic plugin-dialogflow tests
PACKAGE: botonic-plugin-dialogflow
BUILD_COMMAND: 'cd ../botonic-core && npm run build && cd ../botonic-plugin-dialogflow && npm run build'
UNIT_TEST_COMMAND: npm run test_ci
PUBLISH_TESTS_RESULTS: 'yes'
NEEDS_CODECOV_UPLOAD: 'yes'
2 changes: 1 addition & 1 deletion .github/workflows/botonic-plugin-dynamo-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
with:
PACKAGE_NAME: Botonic plugin-dynamodb Tests
PACKAGE: botonic-plugin-dynamodb
BUILD_COMMAND: npm run build_unit_tests
BUILD_COMMAND: 'cd ../botonic-core && npm run build && cd ../botonic-plugin-dynamodb && npm run build_unit_tests'
NEEDS_CODECOV_UPLOAD: 'yes'
NEEDS_AWS_CRED: 'yes'
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
with:
PACKAGE_NAME: Botonic plugin-google-analytics tests
PACKAGE: botonic-plugin-google-analytics
BUILD_COMMAND: ''
BUILD_COMMAND: 'cd ../botonic-core && npm run build && cd ../botonic-plugin-google-analytics && npm run build'
UNIT_TEST_COMMAND: ''
19 changes: 0 additions & 19 deletions .github/workflows/botonic-plugin-intent-classification-tests.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/botonic-plugin-ner-tests.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/botonic-plugin-nlu-tests.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/botonic-react-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ jobs:
with:
PACKAGE_NAME: Botonic react tests
PACKAGE: botonic-react
BUILD_COMMAND: 'cd ../botonic-core && npm run build && cd ../botonic-react && npm run build'
NEEDS_CODECOV_UPLOAD: 'yes'
45 changes: 2 additions & 43 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,13 @@ repos:
entry: bash scripts/qa/old/lint-package.sh packages/botonic-cli
language: system
files: ^packages/botonic-cli/

- id: core
name: core
entry: scripts/qa/old/lint-package.sh packages/botonic-core
language: system
files: ^packages/botonic-core/

- id: core-d-ts
name: core-d-ts
entry: scripts/qa/old/lint-d-ts.sh packages/botonic-core
language: system
files: ^packages/botonic-core/src/.*\.d\.ts

- id: nlu
name: nlu
entry: scripts/qa/old/lint-package.sh packages/botonic-plugin-nlu
language: system
files: ^packages/botonic-plugin-nlu/

- id: nlp
name: nlp
entry: scripts/qa/old/lint-package.sh packages/botonic-nlp
language: system
files: ^packages/botonic-nlp

- id: contentful
name: contentful
entry: scripts/qa/old/lint-package.sh packages/botonic-plugin-contentful
Expand Down Expand Up @@ -74,12 +57,6 @@ repos:
language: system
files: ^packages/botonic-plugin-luis/

- id: plugin-nlu
name: plugin-nlu
entry: scripts/qa/old/lint-package.sh packages/botonic-plugin-nlu
language: system
files: ^packages/botonic-plugin-nlu/

- id: segment
name: segment
entry: scripts/qa/old/lint-package.sh packages/botonic-plugin-segment
Expand All @@ -98,12 +75,6 @@ repos:
language: system
files: ^packages/botonic-react/

- id: react-d-ts
name: react-d-ts
entry: scripts/qa/old/lint-d-ts.sh packages/botonic-react
language: system
files: ^packages/botonic-react/src/.*\.d\.ts

- id: google-analytics
name: google-analytics
entry: scripts/qa/old/lint-package.sh packages/botonic-plugin-google-analytics
Expand All @@ -122,24 +93,12 @@ repos:
language: system
files: ^docs/

- id: plugin-ner
name: plugin-ner
entry: scripts/qa/old/lint-package.sh packages/botonic-plugin-ner
language: system
files: ^packages/botonic-plugin-ner/

- id: plugin-intent-classification
name: plugin-intent-classification
entry: scripts/qa/old/lint-package.sh packages/botonic-plugin-intent-classification
language: system
files: ^packages/botonic-plugin-intent-classification/

- id: plugin-flow-builder
name: plugin-flow-builder
entry: scripts/qa/old/lint-package.sh packages/botonic-plugin-flow-builder
language: system
files: ^packages/botonic-plugin-flow-builder/

- id: hubtype-analytics
name: hubtype-analytics
entry: scripts/qa/old/lint-package.sh packages/botonic-plugin-hubtype-analytics
Expand Down
Loading

0 comments on commit f038bce

Please sign in to comment.