Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"decompress-unzip": "^4.0.1",
"dotenv": "^10.0.0",
"intercept-stdout": "^0.1.2",
"isomorphic-fetch": "^3.0.0",
"kleur": "^4.1.4",
"node-fetch": "^2.6.9",
"portfinder": "^1.0.28",
"progress-stream": "^2.0.0",
"prompts": "^2.4.1",
Expand All @@ -64,6 +64,7 @@
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.6.0",
"gramma": "^1.6.0",
"husky": "^7.0.0",
"jest": "^27.2.4",
Expand Down
2 changes: 1 addition & 1 deletion src/boot/prepareConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const prepareConfig = (paths) => (argv) => {
const globalConfig = prepareFileConfig(paths.globalConfigFile)
const localConfig = prepareFileConfig(paths.localConfigFile)

if (localConfig && localConfig.api_url === "localhost") {
if (localConfig && localConfig.api_url === "0.0.0.0") {
localConfig.api_url = "inherit"
}

Expand Down
1 change: 0 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node
require("dotenv").config()
require("isomorphic-fetch")

const yargs = require("yargs")
const { version } = require("../package.json")
Expand Down
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require("isomorphic-fetch")

const check = require("./requests/checkViaAPI")
const replaceAll = require("./text-manipulation/replaceAll")

Expand Down
1 change: 1 addition & 0 deletions src/requests/checkViaAPI.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fetch = require("node-fetch")
const queryString = require("query-string")
const initialConfig = require("../initialConfig")
// @ts-ignore
Expand Down
4 changes: 2 additions & 2 deletions src/requests/checkWithFallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const checkWithFallback = async (text, cfg) => {
response = await checkViaAPI(text, session)

if (
cfg.session.api_url.includes("localhost") &&
cfg.session.api_url.includes("0.0.0.0") &&
cfg.session.server_once === "true"
) {
await stopServer(cfg)
}
} catch (error) {
if (error.code === "ECONNREFUSED" || cfg.session.api_url === "localhost") {
if (error.code === "ECONNREFUSED" || cfg.session.api_url === "0.0.0.0") {
if (global.server_path) {
if (!session.markdown) {
console.info(`Checking via local LanguageTool cmd...`)
Expand Down
1 change: 1 addition & 0 deletions src/requests/updates.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require("fs")
const path = require("path")
const kleur = require("kleur")
const fetch = require("node-fetch")
const { version } = require("../../package.json")

const checkForUpdates = async (configDir) => {
Expand Down
2 changes: 1 addition & 1 deletion src/server/installServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const installServer = async (cfg) => {
const serverPath = path.join(serverDir, unpackedDirName)

configure("server_path", serverPath, cfg, true, true)
configure("api_url", "localhost", cfg, true, true)
configure("api_url", "0.0.0.0", cfg, true, true)

console.log(kleur.green(`Server installed in: ${serverDir}`))
}
Expand Down
3 changes: 2 additions & 1 deletion src/server/startServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require("path")
const kleur = require("kleur")
const portfinder = require("portfinder")
const tcpPortUsed = require("tcp-port-used")
const fetch = require("node-fetch")
const configure = require("../actions/configure")
const confirmPort = require("../prompts/confirmPort")

Expand Down Expand Up @@ -73,7 +74,7 @@ const startServer = async (cfg, { port = null, viaCommand = false } = {}) => {
})

// eslint-disable-next-line camelcase
const api_url = `http://localhost:${PORT}/v2/check`
const api_url = `http://0.0.0.0:${PORT}/v2/check`

await pingServer(api_url)

Expand Down
1 change: 1 addition & 0 deletions src/utils/downloadFile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require("fs")
const progressStream = require("progress-stream")
const cliProgress = require("cli-progress")
const fetch = require("node-fetch")

const toMegabytes = (bytes) => {
return Number((bytes / (1000 * 1000)).toFixed(2))
Expand Down
2 changes: 1 addition & 1 deletion src/utils/prepareMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6023,7 +6023,7 @@ function urlToPath(path2) {
function getPathFromURLPosix(url) {
if (url.hostname !== "") {
const error = new TypeError(
'File URL host must be "localhost" or empty on darwin',
'File URL host must be "0.0.0.0" or empty on darwin',
)
error.code = "ERR_INVALID_FILE_URL_HOST"
throw error
Expand Down