1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-10 06:47:53 +03:00

feat(tcp server): set up script

This commit is contained in:
louistiti 2022-10-06 23:20:30 +08:00
parent 48688dc6e6
commit b96070085b
4 changed files with 48 additions and 1 deletions

View File

@ -35,6 +35,7 @@
"setup:offline-tts": "ts-node scripts/setup-offline/run-setup-tts.js",
"setup:offline-hotword": "ts-node scripts/setup-offline/run-setup-hotword.js",
"setup:python-bridge": "ts-node scripts/python-bridge/setup-python-bridge.js",
"setup:tcp-server": "ts-node scripts/tcp-server/setup-tcp-server.js",
"preinstall": "node scripts/setup/preinstall.js",
"postinstall": "ts-node scripts/setup/setup.js",
"dev:app": "vite --config app/vite.config.js",

View File

@ -34,6 +34,9 @@ const ARCHIVE_PATH = path.join(DIST_PATH, ARCHIVE_NAME)
const { type } = OSHelper.getInformation()
/**
* Install requirements
*/
try {
if (type === OSTypes.Linux) {
LogHelper.info('Checking whether the "patchelf" utility can be found...')
@ -51,6 +54,9 @@ const ARCHIVE_PATH = path.join(DIST_PATH, ARCHIVE_NAME)
process.exit(1)
}
/**
* Build Python bridge
*/
try {
LogHelper.info('Building the Python bridge...')
@ -66,6 +72,9 @@ const ARCHIVE_PATH = path.join(DIST_PATH, ARCHIVE_NAME)
LogHelper.error(`Failed to build the Python bridge: ${e}`)
}
/**
* Pack distribution entities into a ZIP archive
*/
LogHelper.info(`Packing to ${ARCHIVE_PATH}...`)
const output = fs.createWriteStream(ARCHIVE_PATH)

View File

@ -28,7 +28,9 @@ const PIPFILE_PATH = 'bridges/python/src/Pipfile'
LogHelper.success('Python packages installed')
LogHelper.success('Python bridge development environment ready')
} catch (e) {
LogHelper.error(`Failed to set up the Python bridge: ${e}`)
LogHelper.error(
`Failed to set up the Python bridge development environment: ${e}`
)
} finally {
LoaderHelper.stop()
}

View File

@ -0,0 +1,35 @@
import { command } from 'execa'
import { LogHelper } from '@/helpers/log-helper'
import { LoaderHelper } from '@/helpers/loader-helper'
/**
* Set up TCP server development environment
* 1. Install Python packages from the Pipfile
*/
const PIPFILE_PATH = 'tcp_server/src/Pipfile'
;(async () => {
LoaderHelper.start()
LogHelper.info('Setting up TCP server development environment...')
LogHelper.info(`Installing Python packages from ${PIPFILE_PATH}.lock...`)
try {
process.env.PIPENV_PIPFILE = PIPFILE_PATH
process.env.PIPENV_VENV_IN_PROJECT = true
await command(`pipenv install --site-packages`, {
shell: true
})
LogHelper.success('Python packages installed')
LogHelper.success('TCP server development environment ready')
} catch (e) {
LogHelper.error(
`Failed to set up the TCP server development environment: ${e}`
)
} finally {
LoaderHelper.stop()
}
})()