Skip to content
Closed
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
1 change: 0 additions & 1 deletion packages/cli-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
"macaddress": "0.5.3",
"minimatch": "9.0.8",
"mrmime": "1.0.1",
"network-interfaces": "1.1.0",
"node-abort-controller": "3.1.1",
"node-fetch": "3.3.2",
"open": "8.4.2",
Expand Down
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are vendoring this from https://github.com/Shopify/dev_server, I think we should remove the dependency from there and then update this code.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {assertConnectable, getIpFromHosts} from './network/index.js'
import {assertCompatibleEnvironment} from './env.js'
import * as ni from 'network-interfaces'
import fs from 'node:fs'
import os from 'node:os'

import type {HostOptions} from './types.js'

Expand Down Expand Up @@ -52,7 +52,7 @@ function assertRunning2024(projectName: string): void {
function getBackendIp(projectName: string): string {
try {
const backendIp = resolveBackendHost(projectName)
ni.fromIp(backendIp, {internal: true, ipVersion: 4})
assertIpOnLocalInterface(backendIp)

return backendIp
} catch (error) {
Expand All @@ -75,6 +75,18 @@ function resolveBackendHost(name: string): string {
}
}

function assertIpOnLocalInterface(ip: string): void {
const interfaces = os.networkInterfaces()
for (const addresses of Object.values(interfaces)) {
for (const addr of addresses ?? []) {
if (addr.address === ip && addr.internal && addr.family === 'IPv4') {
return
}
}
}
throw new Error(`No suitable interfaces were found with IP address "${ip}"`)
}

// Allow overrides for more concise test setup. Meh.
let assertRunningOverride: typeof assertRunning2024 | undefined

Expand Down

This file was deleted.

8 changes: 0 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading