@palettelab/cli 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/dev.js +13 -2
- package/lib/ports.js +2 -2
- package/package.json +1 -1
package/lib/commands/dev.js
CHANGED
|
@@ -8,8 +8,8 @@ const { parseFlags } = require("../environments")
|
|
|
8
8
|
const { resolveDevPorts } = require("../ports")
|
|
9
9
|
const publish = require("./publish")
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const DEFAULT_PLATFORM_IMAGE = "ghcr.io/palette-lab/platform-dev:latest"
|
|
12
|
+
const DEFAULT_IMAGE = process.env.PALETTE_DEV_IMAGE || DEFAULT_PLATFORM_IMAGE
|
|
13
13
|
const COMPOSE_FILE = path.resolve(__dirname, "..", "..", "platform-dev", "docker-compose.yml")
|
|
14
14
|
|
|
15
15
|
function ensureDocker() {
|
|
@@ -38,6 +38,17 @@ function tryPullImage(image) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function ensureImageAvailable(image) {
|
|
41
|
+
if (!process.env.PALETTE_DEV_IMAGE && image === DEFAULT_PLATFORM_IMAGE) {
|
|
42
|
+
const pulled = tryPullImage(image)
|
|
43
|
+
if (pulled.ok) return pulled
|
|
44
|
+
if (imageExistsLocally(image)) {
|
|
45
|
+
console.warn(
|
|
46
|
+
`[pltt] could not refresh ${image}; using the local cached image instead.`,
|
|
47
|
+
)
|
|
48
|
+
return { ok: true, output: pulled.output }
|
|
49
|
+
}
|
|
50
|
+
return pulled
|
|
51
|
+
}
|
|
41
52
|
// Accept a locally-built image (e.g. `platform-dev:test` from `docker build`)
|
|
42
53
|
// without attempting a registry pull — local is authoritative if present.
|
|
43
54
|
if (imageExistsLocally(image)) return { ok: true, output: "" }
|
package/lib/ports.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const net = require("net")
|
|
4
4
|
|
|
5
|
-
function canBindPort(port, host = "
|
|
5
|
+
function canBindPort(port, host = "0.0.0.0") {
|
|
6
6
|
return new Promise((resolve) => {
|
|
7
7
|
const server = net.createServer()
|
|
8
8
|
server.once("error", () => resolve(false))
|
|
@@ -13,7 +13,7 @@ function canBindPort(port, host = "127.0.0.1") {
|
|
|
13
13
|
})
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async function findFreePort(preferred, { host = "
|
|
16
|
+
async function findFreePort(preferred, { host = "0.0.0.0", maxAttempts = 100 } = {}) {
|
|
17
17
|
const start = Number(preferred)
|
|
18
18
|
if (!Number.isInteger(start) || start <= 0 || start > 65535) {
|
|
19
19
|
throw new Error(`invalid port: ${preferred}`)
|