diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-05-01 19:34:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-01 19:34:25 +0200 |
| commit | 2ee4175437bbfcddf98e5eacba9b019113716ac8 (patch) | |
| tree | aff6c7c9adfc27f0f33ab4e14edcf17829dbb282 /electron/service/utils | |
| parent | eb64c88a8bf9c8fe66c33a5309d28e526b994d25 (diff) | |
Remove electron entirely (#2859)
Co-authored-by: rejbasket
Diffstat (limited to 'electron/service/utils')
| -rw-r--r-- | electron/service/utils/getLocalIP.js | 17 | ||||
| -rw-r--r-- | electron/service/utils/loadEnv.js | 39 | ||||
| -rw-r--r-- | electron/service/utils/logger.js | 72 | ||||
| -rw-r--r-- | electron/service/utils/paths.js | 6 | ||||
| -rw-r--r-- | electron/service/utils/resolveClientEnv.js | 11 | ||||
| -rw-r--r-- | electron/service/utils/spinner.js | 57 |
6 files changed, 0 insertions, 202 deletions
diff --git a/electron/service/utils/getLocalIP.js b/electron/service/utils/getLocalIP.js deleted file mode 100644 index 14926ee2..00000000 --- a/electron/service/utils/getLocalIP.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict' - -const os = require('os') - -module.exports = function getLocalIP() { - const interfaces = os.networkInterfaces() - - for (const devName in interfaces) { - const iface = interfaces[devName] - for (let i = 0; i < iface.length; i++) { - const alias = iface[i] - if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) { - return alias.address - } - } - } -} diff --git a/electron/service/utils/loadEnv.js b/electron/service/utils/loadEnv.js deleted file mode 100644 index 3c054ff6..00000000 --- a/electron/service/utils/loadEnv.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict' - -const path = require('path') -const dotenv = require('dotenv') -const dotenvExpand = require('dotenv-expand') -const { error } = require('./logger') - -module.exports = function loadEnv(mode) { - const basePath = path.resolve(process.cwd(), `.env${mode ? `.${mode}` : ``}`) - const localPath = `${basePath}.local` - - const load = (envPath) => { - try { - const env = dotenv.config({ path: envPath, debug: process.env.DEBUG }) - dotenvExpand.expand(env) - } catch (err) { - // only ignore error if file is not found - if (err.toString().indexOf('ENOENT') < 0) { - error(err) - } - } - } - - load(localPath) - load(basePath) - - // by default, NODE_ENV and BABEL_ENV are set to "development" unless mode - // is production or test. However the value in .env files will take higher - // priority. - if (mode) { - const defaultNodeEnv = mode === 'production' || mode === 'test' ? mode : 'development' - if (process.env.NODE_ENV == null) { - process.env.NODE_ENV = defaultNodeEnv - } - if (process.env.BABEL_ENV == null) { - process.env.BABEL_ENV = defaultNodeEnv - } - } -} diff --git a/electron/service/utils/logger.js b/electron/service/utils/logger.js deleted file mode 100644 index 0d74c52c..00000000 --- a/electron/service/utils/logger.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict' - -const chalk = require('chalk') -const stripAnsi = require('strip-ansi') -const readline = require('readline') -const EventEmitter = require('events') - -exports.events = new EventEmitter() - -function _log(type, tag, message) { - if (process.env.VUE_CLI_API_MODE && message) { - exports.events.emit('log', { - message, - type, - tag, - }) - } -} - -const format = (label, msg) => { - return msg - .split('\n') - .map((line, i) => { - return i === 0 ? `${label} ${line}` : line.padStart(stripAnsi(label).length) - }) - .join('\n') -} - -const chalkTag = (msg) => chalk.bgBlackBright.white.dim(` ${msg} `) - -exports.log = (msg = '', tag = null) => { - tag ? console.log(format(chalkTag(tag), msg)) : console.log(msg) - _log('log', tag, msg) -} - -exports.info = (msg, tag = null) => { - console.log(format(chalk.bgBlue.black(' INFO ') + (tag ? chalkTag(tag) : ''), msg)) - _log('info', tag, msg) -} - -exports.done = (msg, tag = null) => { - console.log(format(chalk.bgGreen.black(' DONE ') + (tag ? chalkTag(tag) : ''), msg)) - _log('done', tag, msg) -} - -exports.warn = (msg, tag = null) => { - console.warn( - format(chalk.bgYellow.black(' WARN ') + (tag ? chalkTag(tag) : ''), chalk.yellow(msg)) - ) - _log('warn', tag, msg) -} - -exports.error = (msg, tag = null) => { - console.error(format(chalk.bgRed(' ERROR ') + (tag ? chalkTag(tag) : ''), chalk.red(msg))) - _log('error', tag, msg) - if (msg instanceof Error) { - console.error(msg.stack) - _log('error', tag, msg.stack) - } -} - -exports.clearConsole = (title) => { - if (process.stdout.isTTY) { - const blank = '\n'.repeat(process.stdout.rows) - console.log(blank) - readline.cursorTo(process.stdout, 0, 0) - readline.clearScreenDown(process.stdout) - if (title) { - console.log(title) - } - } -} diff --git a/electron/service/utils/paths.js b/electron/service/utils/paths.js deleted file mode 100644 index a3e173c3..00000000 --- a/electron/service/utils/paths.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict' - -const path = require('path') - -// gen absolute path -exports.resolve = (...args) => path.posix.join(process.cwd(), ...args) diff --git a/electron/service/utils/resolveClientEnv.js b/electron/service/utils/resolveClientEnv.js deleted file mode 100644 index 4a4505a6..00000000 --- a/electron/service/utils/resolveClientEnv.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict' -const prefixRE = /^VUE_APP_/ - -module.exports = function resolveClientEnv(options, raw) { - process.env.PUBLIC_PATH = options.publicPath - - if (raw) { - return env - } - -}
\ No newline at end of file diff --git a/electron/service/utils/spinner.js b/electron/service/utils/spinner.js deleted file mode 100644 index d643a933..00000000 --- a/electron/service/utils/spinner.js +++ /dev/null @@ -1,57 +0,0 @@ -'use strict' - -const ora = require('ora') -const chalk = require('chalk') - -const spinner = ora() -let lastMsg = null -let isPaused = false - -exports.logWithSpinner = (symbol, msg) => { - if (!msg) { - msg = symbol - symbol = chalk.green('✔') - } - if (lastMsg) { - spinner.stopAndPersist({ - symbol: lastMsg.symbol, - text: lastMsg.text, - }) - } - spinner.text = ' ' + msg - lastMsg = { - symbol: symbol + ' ', - text: msg, - } - spinner.start() -} - -exports.stopSpinner = (persist) => { - if (lastMsg && persist !== false) { - spinner.stopAndPersist({ - symbol: lastMsg.symbol, - text: lastMsg.text, - }) - } else { - spinner.stop() - } - lastMsg = null -} - -exports.pauseSpinner = () => { - if (spinner.isSpinning) { - spinner.stop() - isPaused = true - } -} - -exports.resumeSpinner = () => { - if (isPaused) { - spinner.start() - isPaused = false - } -} - -exports.failSpinner = (text) => { - spinner.fail(text) -} |
