mirror of
https://github.com/leon-ai/leon.git
synced 2024-09-11 10:25:40 +03:00
refactor(server): make use of node:*
import for all Node.js built-in modules
This commit is contained in:
parent
0a49cb17fa
commit
f68da11f6b
@ -1,8 +1,8 @@
|
||||
import dotenv from 'dotenv'
|
||||
import fs from 'fs'
|
||||
import os from 'os'
|
||||
import { command } from 'execa'
|
||||
import semver from 'semver'
|
||||
import fs from 'node:fs'
|
||||
import os from 'node:os'
|
||||
|
||||
import { version } from '@@/package.json'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import { join } from 'path'
|
||||
import fs from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { SkillDomainHelper } from '@/helpers/skill-domain-helper'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import fs from 'fs'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import dotenv from 'dotenv'
|
||||
import crypto from 'crypto'
|
||||
import fs from 'fs'
|
||||
import { prompt } from 'inquirer'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { StringHelper } from '@/helpers/string-helper'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import dotenv from 'dotenv'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { command } from 'execa'
|
||||
import fs from 'fs'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -11,7 +11,7 @@ import setupStt from './setup-stt'
|
||||
dotenv.config()
|
||||
|
||||
/**
|
||||
* Main entry to setup offline components
|
||||
* Main entry to set up offline components
|
||||
*/
|
||||
;(async () => {
|
||||
try {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { command } from 'execa'
|
||||
import fs from 'fs'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { OSHelper } from '@/helpers/os-helper'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { command } from 'execa'
|
||||
import fs from 'fs'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { OSHelper } from '@/helpers/os-helper'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { prompt } from 'inquirer'
|
||||
import fs from 'fs'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { command } from 'execa'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { commandSync } from 'execa'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { SkillDomainHelper } from '@/helpers/skill-domain-helper'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import { composeFromPattern } from '@nlpjs/utils'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { StringHelper } from '@/helpers/string-helper'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import { composeFromPattern } from '@nlpjs/utils'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import { composeFromPattern } from '@nlpjs/utils'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { SkillDomainHelper } from '@/helpers/skill-domain-helper'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { path as ffmpegPath } from '@ffmpeg-installer/ffmpeg'
|
||||
import Ffmpeg from 'fluent-ffmpeg'
|
||||
import fs from 'fs'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { spawn } from 'child_process'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { spawn } from 'node:child_process'
|
||||
|
||||
import { langs } from '@@/core/langs.json'
|
||||
import { HAS_TTS } from '@/constants'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import fs from 'fs'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import archiver from 'archiver'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Fastify from 'fastify'
|
||||
import fastifyStatic from '@fastify/static'
|
||||
import socketio from 'socket.io'
|
||||
import { join } from 'path'
|
||||
import { join } from 'node:path'
|
||||
|
||||
import { version } from '@@/package.json'
|
||||
import { endpoints } from '@@/core/skills-endpoints.json'
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @nlpjs/core-loader can make use of file system
|
||||
* https://github.com/axa-group/nlp.js/issues/766#issuecomment-750315909
|
||||
*/
|
||||
import fs from 'fs'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { StringHelper } from '@/helpers/string-helper'
|
||||
|
@ -3,10 +3,10 @@ import { Nlp } from '@nlpjs/nlp'
|
||||
import { BuiltinMicrosoft } from '@nlpjs/builtin-microsoft'
|
||||
import { LangAll } from '@nlpjs/lang-all'
|
||||
import request from 'superagent'
|
||||
import fs from 'fs'
|
||||
import { join } from 'path'
|
||||
import { spawn } from 'child_process'
|
||||
import kill from 'tree-kill'
|
||||
import fs from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { spawn } from 'node:child_process'
|
||||
|
||||
import { langs } from '@@/core/langs.json'
|
||||
import { version } from '@@/package.json'
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { google } from 'googleapis'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { waterfall } from 'async'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import Net from 'net'
|
||||
import { EventEmitter } from 'events'
|
||||
import Net from 'node:net'
|
||||
import { EventEmitter } from 'node:events'
|
||||
|
||||
import { IS_PRODUCTION_ENV } from '@/constants'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
2
server/src/global.d.ts
vendored
2
server/src/global.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import { ChildProcessWithoutNullStreams } from 'child_process'
|
||||
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
|
||||
|
||||
import TcpClient from '@/core/tcp-client'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { IS_TESTING_ENV } from '@/constants'
|
||||
import { DateHelper } from '@/helpers/date-helper'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import os from 'os'
|
||||
import os from 'node:os'
|
||||
|
||||
type OSType = 'windows' | 'macos' | 'linux' | 'unknown'
|
||||
type OSName = 'Windows' | 'macOS' | 'Linux' | 'Unknown'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import type { ShortLanguageCode } from '@/helpers/lang-helper'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { spawn } from 'child_process'
|
||||
import { spawn } from 'node:child_process'
|
||||
|
||||
import {
|
||||
TCP_SERVER_HOST,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import wav from 'node-wav'
|
||||
import fs from 'fs'
|
||||
import { Model } from 'stt'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { IS_TESTING_ENV } from '@/constants'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
import stt from '@google-cloud/speech'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LANG } from '@/constants'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { IS_TESTING_ENV } from '@/constants'
|
||||
import Asr from '@/core/asr'
|
||||
|
@ -1,8 +1,8 @@
|
||||
import Stt from 'ibm-watson/speech-to-text/v1'
|
||||
import { IamAuthenticator } from 'ibm-watson/auth'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { Duplex } from 'stream'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { Duplex } from 'node:stream'
|
||||
|
||||
import { LANG } from '@/constants'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
|
@ -2,8 +2,8 @@ import { Polly, SynthesizeSpeechCommand } from '@aws-sdk/client-polly'
|
||||
import Ffmpeg from 'fluent-ffmpeg'
|
||||
import { path as ffmpegPath } from '@ffmpeg-installer/ffmpeg'
|
||||
import { path as ffprobePath } from '@ffprobe-installer/ffprobe'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { StringHelper } from '@/helpers/string-helper'
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { spawn } from 'child_process'
|
||||
import Ffmpeg from 'fluent-ffmpeg'
|
||||
import { path as ffmpegPath } from '@ffmpeg-installer/ffmpeg'
|
||||
import { path as ffprobePath } from '@ffprobe-installer/ffprobe'
|
||||
import fs from 'fs'
|
||||
import { spawn } from 'node:child_process'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { StringHelper } from '@/helpers/string-helper'
|
||||
|
@ -2,8 +2,8 @@ import tts from '@google-cloud/text-to-speech'
|
||||
import Ffmpeg from 'fluent-ffmpeg'
|
||||
import { path as ffmpegPath } from '@ffmpeg-installer/ffmpeg'
|
||||
import { path as ffprobePath } from '@ffprobe-installer/ffprobe'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { StringHelper } from '@/helpers/string-helper'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import events from 'events'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import events from 'node:events'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { LangHelper } from '@/helpers/lang-helper'
|
||||
|
@ -3,8 +3,8 @@ import { IamAuthenticator } from 'ibm-watson/auth'
|
||||
import Ffmpeg from 'fluent-ffmpeg'
|
||||
import { path as ffmpegPath } from '@ffmpeg-installer/ffmpeg'
|
||||
import { path as ffprobePath } from '@ffprobe-installer/ffprobe'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { StringHelper } from '@/helpers/string-helper'
|
||||
|
@ -27,7 +27,7 @@ groups = [
|
||||
},
|
||||
{
|
||||
'name': 'tactics',
|
||||
'a': 'J', # Judjing
|
||||
'a': 'J', # Judging
|
||||
'b': 'P', # Perceiving
|
||||
'questions': [4, 8, 12, 16, 20]
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { command } from 'execa'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import Nlu from '@/core/nlu'
|
||||
import Brain from '@/core/brain'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
describe('are JSON files valid', () => {
|
||||
const rootFolders = ['core', 'packages', 'core/config', 'server/src/data']
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
describe('no punctuation', () => {
|
||||
const rootFolders = ['server/src/data']
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
describe('punctuation', () => {
|
||||
const rootFolders = ['packages']
|
||||
|
@ -1,4 +1,4 @@
|
||||
import fs from 'fs'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import Asr from '@/core/asr'
|
||||
import Stt from '@/stt/stt'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { spawn } from 'child_process'
|
||||
import { spawn } from 'node:child_process'
|
||||
|
||||
import Brain from '@/core/brain'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import path from 'path'
|
||||
import path from 'node:path'
|
||||
|
||||
import Ner from '@/core/ner'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { EventEmitter } from 'events'
|
||||
import { EventEmitter } from 'node:events'
|
||||
|
||||
import server from '@/core/http-server/server'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import fs from 'fs'
|
||||
import fs from 'node:fs'
|
||||
|
||||
import parser from '@/stt/coqui-stt/parser'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import events from 'events'
|
||||
import fs from 'node:fs'
|
||||
import events from 'node:events'
|
||||
|
||||
import synthesizer from '@/tts/flite/synthesizer'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user