1
1
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:
louistiti 2022-09-26 23:28:25 +08:00
parent 0a49cb17fa
commit f68da11f6b
No known key found for this signature in database
GPG Key ID: 7ECA3DD523793FE6
51 changed files with 85 additions and 85 deletions

View File

@ -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'

View File

@ -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'

View File

@ -1,4 +1,4 @@
import fs from 'fs'
import fs from 'node:fs'
import { LogHelper } from '@/helpers/log-helper'

View File

@ -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'

View File

@ -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'

View File

@ -1,5 +1,5 @@
import { command } from 'execa'
import fs from 'fs'
import fs from 'node:fs'
import { LogHelper } from '@/helpers/log-helper'

View File

@ -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 {

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -1,5 +1,5 @@
import { prompt } from 'inquirer'
import fs from 'fs'
import fs from 'node:fs'
import { LogHelper } from '@/helpers/log-helper'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -1,4 +1,4 @@
import fs from 'fs'
import fs from 'node:fs'
import { LogHelper } from '@/helpers/log-helper'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -1,4 +1,4 @@
import { ChildProcessWithoutNullStreams } from 'child_process'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import TcpClient from '@/core/tcp-client'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -1,4 +1,4 @@
import { spawn } from 'child_process'
import { spawn } from 'node:child_process'
import {
TCP_SERVER_HOST,

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -27,7 +27,7 @@ groups = [
},
{
'name': 'tactics',
'a': 'J', # Judjing
'a': 'J', # Judging
'b': 'P', # Perceiving
'questions': [4, 8, 12, 16, 20]
}

View File

@ -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'

View File

@ -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']

View File

@ -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']

View File

@ -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']

View File

@ -1,4 +1,4 @@
import fs from 'fs'
import fs from 'node:fs'
import Asr from '@/core/asr'
import Stt from '@/stt/stt'

View File

@ -1,4 +1,4 @@
import { spawn } from 'child_process'
import { spawn } from 'node:child_process'
import Brain from '@/core/brain'

View File

@ -1,4 +1,4 @@
import path from 'path'
import path from 'node:path'
import Ner from '@/core/ner'

View File

@ -1,4 +1,4 @@
import { EventEmitter } from 'events'
import { EventEmitter } from 'node:events'
import server from '@/core/http-server/server'

View File

@ -1,4 +1,4 @@
import fs from 'fs'
import fs from 'node:fs'
import parser from '@/stt/coqui-stt/parser'

View File

@ -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'