1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-09-11 10:25:40 +03:00

chore: upgrade execa to latest and adapt to new API

This commit is contained in:
louistiti 2021-03-04 22:49:52 +08:00
parent 0fce6a1574
commit f5debe3bb5
No known key found for this signature in database
GPG Key ID: 7ECA3DD523793FE6
13 changed files with 145 additions and 67 deletions

118
package-lock.json generated
View File

@ -9006,17 +9006,93 @@
"dev": true
},
"execa": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-0.10.0.tgz",
"integrity": "sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw==",
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-5.0.0.tgz",
"integrity": "sha512-ov6w/2LCiuyO4RLYGdpFGjkcs0wMTgGE8PrkTHikeUy5iJekXyPIKUjifk5CsE0pt7sMCrMZ3YNqoCj6idQOnQ==",
"requires": {
"cross-spawn": "^6.0.0",
"get-stream": "^3.0.0",
"is-stream": "^1.1.0",
"npm-run-path": "^2.0.0",
"p-finally": "^1.0.0",
"signal-exit": "^3.0.0",
"strip-eof": "^1.0.0"
"cross-spawn": "^7.0.3",
"get-stream": "^6.0.0",
"human-signals": "^2.1.0",
"is-stream": "^2.0.0",
"merge-stream": "^2.0.0",
"npm-run-path": "^4.0.1",
"onetime": "^5.1.2",
"signal-exit": "^3.0.3",
"strip-final-newline": "^2.0.0"
},
"dependencies": {
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"requires": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
}
},
"human-signals": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz",
"integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw=="
},
"is-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz",
"integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw=="
},
"mimic-fn": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg=="
},
"npm-run-path": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz",
"integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==",
"requires": {
"path-key": "^3.0.0"
}
},
"onetime": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz",
"integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==",
"requires": {
"mimic-fn": "^2.1.0"
}
},
"path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="
},
"shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"requires": {
"shebang-regex": "^3.0.0"
}
},
"shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="
},
"signal-exit": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA=="
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"requires": {
"isexe": "^2.0.0"
}
}
}
},
"exit": {
@ -9673,9 +9749,9 @@
"dev": true
},
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.0.tgz",
"integrity": "sha512-A1B3Bh1UmL0bidM/YX2NsCOTnGJePL9rO/M+Mw3m9f2gUpfokS0hi5Eah0WSUEWZdZhIZtMjkIYS7mDfOqNHbg=="
},
"get-value": {
"version": "2.0.6",
@ -11004,7 +11080,8 @@
"is-stream": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=",
"dev": true
},
"is-stream-ended": {
"version": "0.1.4",
@ -13616,8 +13693,7 @@
"merge-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
"integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
"dev": true
"integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w=="
},
"methods": {
"version": "1.1.2",
@ -14423,6 +14499,7 @@
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
"integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=",
"dev": true,
"requires": {
"path-key": "^2.0.0"
}
@ -14732,7 +14809,8 @@
"p-finally": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
"integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4="
"integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=",
"dev": true
},
"p-limit": {
"version": "2.2.0",
@ -16861,13 +16939,13 @@
"strip-eof": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8="
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=",
"dev": true
},
"strip-final-newline": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz",
"integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==",
"dev": true
"integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA=="
},
"strip-json-comments": {
"version": "2.0.1",

View File

@ -58,7 +58,7 @@
"cross-env": "^5.2.0",
"deepspeech": "^0.5.0",
"dotenv": "^4.0.0",
"execa": "^0.10.0",
"execa": "^5.0.0",
"express": "^4.17.1",
"fluent-ffmpeg": "^2.1.2",
"googleapis": "^40.0.0",

View File

@ -1,6 +1,6 @@
import dotenv from 'dotenv'
import fs from 'fs'
import { shell } from 'execa'
import { command } from 'execa'
import semver from 'semver'
import log from '@/helpers/log'
@ -41,17 +41,17 @@ export default () => new Promise(async (resolve, reject) => {
// Environment checking
;(await Promise.all([
shell('node --version'),
shell('npm --version'),
shell('pipenv --version')
command('node --version', { shell: true }),
command('npm --version', { shell: true }),
command('pipenv --version', { shell: true })
])).forEach((p) => {
log.info(p.cmd)
log.info(p.command)
if (p.cmd.indexOf('node --version') !== -1 &&
if (p.command.indexOf('node --version') !== -1 &&
!semver.satisfies(semver.clean(p.stdout), `>=${nodeMinRequiredVersion}`)) {
Object.keys(report).forEach((item) => { if (report[item].type === 'error') report[item].v = false })
log.error(`${p.stdout}\nThe Node.js version must be >=${nodeMinRequiredVersion}. Please install it: https://nodejs.org (or use nvm)\n`)
} else if (p.cmd.indexOf('npm --version') !== -1 &&
} else if (p.command.indexOf('npm --version') !== -1 &&
!semver.satisfies(semver.clean(p.stdout), `>=${npmMinRequiredVersion}`)) {
Object.keys(report).forEach((item) => { if (report[item].type === 'error') report[item].v = false })
log.error(`${p.stdout}\nThe npm version must be >=${npmMinRequiredVersion}. Please install it: https://www.npmjs.com/get-npm (or use nvm)\n`)
@ -61,12 +61,12 @@ export default () => new Promise(async (resolve, reject) => {
})
;(await Promise.all([
shell('pipenv --where'),
shell('pipenv run python --version')
command('pipenv --where', { shell: true }),
command('pipenv run python --version', { shell: true })
])).forEach((p) => {
log.info(p.cmd)
log.info(p.command)
if (p.cmd.indexOf('pipenv run python --version') !== -1 &&
if (p.command.indexOf('pipenv run python --version') !== -1 &&
!semver.satisfies(p.stdout.split(' ')[1], `>=${pythonMinRequiredVersion}`)) {
Object.keys(report).forEach((item) => { if (report[item].type === 'error') report[item].v = false })
log.error(`${p.stdout}\nThe Python version must be >=${pythonMinRequiredVersion}. Please install it: https://www.python.org/downloads\n`)
@ -78,11 +78,11 @@ export default () => new Promise(async (resolve, reject) => {
// Module execution checking
try {
const p = await shell('pipenv run python bridges/python/main.py scripts/assets/query-object.json')
log.info(p.cmd)
const p = await command('pipenv run python bridges/python/main.py scripts/assets/query-object.json', { shell: true })
log.info(p.command)
log.success(`${p.stdout}\n`)
} catch (e) {
log.info(e.cmd)
log.info(e.command)
report.can_run_module.v = false
log.error(`${e}\n`)
}

View File

@ -1,4 +1,4 @@
import { shell } from 'execa'
import { command } from 'execa'
import log from '@/helpers/log'
import loader from '@/helpers/loader'
@ -23,7 +23,7 @@ import loader from '@/helpers/loader'
'"test/unit/**/*.js"'
]
await shell(`npx eslint ${globs.join(' ')}`)
await command(`npx eslint ${globs.join(' ')}`, { shell: true })
log.success('Looks great')
loader.stop()

View File

@ -1,4 +1,4 @@
import { shell } from 'execa'
import { command } from 'execa'
import fs from 'fs'
import log from '@/helpers/log'
@ -13,7 +13,7 @@ export default version => new Promise(async (resolve, reject) => {
log.info(`Generating ${changelog}...`)
try {
await shell(`git-changelog --changelogrc .changelogrc --template scripts/assets/CHANGELOG-TEMPLATE.md --file scripts/tmp/${tmpChangelog} --version_name ${version}`)
await command(`git-changelog --changelogrc .changelogrc --template scripts/assets/CHANGELOG-TEMPLATE.md --file scripts/tmp/${tmpChangelog} --version_name ${version}`, { shell: true })
} catch (e) {
log.error(`Error during git-changelog: ${e}`)
reject(e)
@ -23,7 +23,7 @@ export default version => new Promise(async (resolve, reject) => {
log.info('Getting remote origin URL...')
log.info('Getting previous tag...')
const sh = await shell('git config --get remote.origin.url && git tag | tail -n1')
const sh = await command('git config --get remote.origin.url && git tag | tail -n1', { shell: true })
const repoUrl = sh.stdout.substr(0, sh.stdout.lastIndexOf('.git'))
const previousTag = sh.stdout.substr(sh.stdout.indexOf('\n') + 1).trim()

View File

@ -1,4 +1,4 @@
import { shell } from 'execa'
import { command } from 'execa'
import log from '@/helpers/log'
@ -15,7 +15,7 @@ export default version => new Promise(async (resolve, reject) => {
]
for (let i = 0; i < files.length; i += 1) {
promises.push(shell(`json -I -f ${files[i]} -e 'this.version="${version}"'`))
promises.push(command(`json -I -f ${files[i]} -e 'this.version="${version}"'`, { shell: true }))
}
try {

View File

@ -1,4 +1,4 @@
import { shell } from 'execa'
import { command } from 'execa'
import log from '@/helpers/log'
import os from '@/helpers/os'
@ -25,16 +25,16 @@ export default () => new Promise(async (resolve, reject) => {
let cmd = `sudo ${pkgm} sox libsox-fmt-all -y`
if (info.type === 'linux') {
log.info(`Executing the following command: ${cmd}`)
await shell(cmd)
await command(cmd, { shell: true })
} else if (info.type === 'macos') {
cmd = `${pkgm} install swig portaudio sox`
log.info(`Executing the following command: ${cmd}`)
await shell(cmd)
await command(cmd, { shell: true })
}
log.success('System dependencies downloaded')
log.info('Installing hotword dependencies...')
await shell('cd hotword && npm install')
await command('cd hotword && npm install', { shell: true })
log.success('Offline hotword detection installed')
resolve()

View File

@ -1,4 +1,4 @@
import { shell } from 'execa'
import { command } from 'execa'
import fs from 'fs'
import log from '@/helpers/log'
@ -22,13 +22,13 @@ export default () => new Promise(async (resolve, reject) => {
if (!fs.existsSync(`${destDeepSpeechFolder}/lm.binary`)) {
try {
log.info('Downloading pre-trained model...')
await shell(`cd ${tmpDir} && ${downloader} https://github.com/mozilla/DeepSpeech/releases/download/v${deepSpeechVersion}/${archiveName}`)
await command(`cd ${tmpDir} && ${downloader} https://github.com/mozilla/DeepSpeech/releases/download/v${deepSpeechVersion}/${archiveName}`, { shell: true })
log.success('Pre-trained model download done')
log.info('Unpacking...')
await shell(`cd ${tmpDir} && tar xvfz ${archiveName}`)
await command(`cd ${tmpDir} && tar xvfz ${archiveName}`, { shell: true })
log.success('Unpack done')
log.info('Moving...')
await shell(`mv -f ${tmpDir}/deepspeech-${deepSpeechVersion}-models/* ${destDeepSpeechFolder} && rm -rf ${tmpDir}/${archiveName} ${tmpDir}/models`)
await command(`mv -f ${tmpDir}/deepspeech-${deepSpeechVersion}-models/* ${destDeepSpeechFolder} && rm -rf ${tmpDir}/${archiveName} ${tmpDir}/models`, { shell: true })
log.success('Move done')
log.success('Offline speech-to-text installed')

View File

@ -1,4 +1,4 @@
import { shell } from 'execa'
import { command } from 'execa'
import fs from 'fs'
import log from '@/helpers/log'
@ -24,19 +24,19 @@ export default () => new Promise(async (resolve, reject) => {
if (!fs.existsSync(`${destFliteFolder}/flite`)) {
try {
log.info('Downloading run-time synthesis engine...')
await shell(`cd ${tmpDir} && ${downloader} http://www.festvox.org/flite/packed/flite-2.1/flite-2.1-release.tar.bz2`)
await command(`cd ${tmpDir} && ${downloader} http://www.festvox.org/flite/packed/flite-2.1/flite-2.1-release.tar.bz2`, { shell: true })
log.success('Run-time synthesis engine download done')
log.info('Unpacking...')
await shell(`cd ${tmpDir} && tar xfvj flite-2.1-release.tar.bz2 && cp ../assets/leon.lv flite-2.1-release/config`)
await command(`cd ${tmpDir} && tar xfvj flite-2.1-release.tar.bz2 && cp ../assets/leon.lv flite-2.1-release/config`, { shell: true })
log.success('Unpack done')
log.info('Configuring...')
await shell(`cd ${tmpDir}/flite-2.1-release && ./configure --with-langvox=leon`)
await command(`cd ${tmpDir}/flite-2.1-release && ./configure --with-langvox=leon`, { shell: true })
log.success('Configure done')
log.info('Building...')
await shell(`cd ${tmpDir}/flite-2.1-release && make ${makeCores}`)
await command(`cd ${tmpDir}/flite-2.1-release && make ${makeCores}`, { shell: true })
log.success('Build done')
log.info('Cleaning...')
await shell(`cp -f ${tmpDir}/flite-2.1-release/bin/flite ${destFliteFolder} && rm -rf ${tmpDir}/flite-2.1-release*`)
await command(`cp -f ${tmpDir}/flite-2.1-release/bin/flite ${destFliteFolder} && rm -rf ${tmpDir}/flite-2.1-release*`, { shell: true })
log.success('Clean done')
log.success('Offline text-to-speech installed')

View File

@ -1,4 +1,4 @@
import { shellSync } from 'execa'
import { commandSync } from 'execa'
import fs from 'fs'
import path from 'path'
@ -44,7 +44,7 @@ export default () => new Promise((resolve, reject) => {
try {
// Add new module configuration in the config.json file
shellSync(`json -I -f ${configFile} -e 'this.${configSampleModules[j]}=${JSON.stringify(module[configSampleModules[j]])}'`)
commandSync(`json -I -f ${configFile} -e 'this.${configSampleModules[j]}=${JSON.stringify(module[configSampleModules[j]])}'`, { shell: true })
log.success(`"${string.ucfirst(configSampleModules[j])}" module configuration added to ${configFile}`)
} catch (e) {
log.error(`Error while adding "${string.ucfirst(configSampleModules[j])}" module configuration to ${configFile}: ${e}`)

View File

@ -1,4 +1,4 @@
import { shell } from 'execa'
import { command } from 'execa'
import fs from 'fs'
import log from '@/helpers/log'
@ -15,7 +15,7 @@ export default () => new Promise(async (resolve, reject) => {
try {
// Check if Pipenv is installed
const pipenvVersionChild = await shell('pipenv --version')
const pipenvVersionChild = await command('pipenv --version', { shell: true })
let pipenvVersion = pipenvVersionChild.stdout
if (pipenvVersion.indexOf('version') !== -1) {
@ -34,8 +34,8 @@ export default () => new Promise(async (resolve, reject) => {
// Installing Python packages
log.info('Installing Python packages from bridges/python/Pipfile.lock...')
await shell('pipenv --three')
await shell('pipenv install --skip-lock')
await command('pipenv --three', { shell: true })
await command('pipenv install --skip-lock', { shell: true })
log.success('Python packages installed')
resolve()
} catch (e) {

View File

@ -1,4 +1,4 @@
import { shell } from 'execa'
import { command } from 'execa'
import log from '@/helpers/log'
import loader from '@/helpers/loader'
@ -16,8 +16,8 @@ import loader from '@/helpers/loader'
try {
loader.start()
await shell('npm run train expressions:en')
const cmd = await shell(`cross-env PIPENV_PIPFILE=bridges/python/Pipfile LEON_NODE_ENV=testing jest --silent --config=./test/e2e/modules/e2e.modules.jest.json packages/${pkg}/test/${module}.spec.js && npm run train expressions`)
await command('npm run train expressions:en', { shell: true })
const cmd = await command(`cross-env PIPENV_PIPFILE=bridges/python/Pipfile LEON_NODE_ENV=testing jest --silent --config=./test/e2e/modules/e2e.modules.jest.json packages/${pkg}/test/${module}.spec.js && npm run train expressions`, { shell: true })
log.default(cmd.stdout)
log.default(cmd.stderr)

View File

@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'
import execa from 'execa'
import { command } from 'execa'
import Nlu from '@/core/nlu'
import Brain from '@/core/brain'
@ -37,7 +37,7 @@ describe('NLU modules', () => {
process.env.LEON_LANG = langKeys[i]
// Generate new classifier for the tested language
await execa.shell(`npm run train expressions:${lang.short}`)
await command(`npm run train expressions:${lang.short}`, { shell: true })
// Load the new classifier
await nlu.loadModel(global.paths.classifier)
})