@geastack/cli 0.1.88 → 0.1.90

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/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ GeaStack cli
2
+ Copyright 2026 GeaStack
3
+
4
+ Licensed under the Apache License, Version 2.0; see LICENSE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/cli",
3
- "version": "0.1.88",
3
+ "version": "0.1.90",
4
4
  "description": "Command-line front door for GeaStack apps, targets, and local toolchains.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -38,13 +38,13 @@
38
38
  "dependencies": {
39
39
  "@clack/prompts": "^1.8.0",
40
40
  "@geastack/simulator": "^0.1.12",
41
- "@geastack/targets": "^0.1.85",
41
+ "@geastack/targets": "^0.1.86",
42
42
  "picocolors": "^1.1.1",
43
43
  "serialport": "^13.0.0"
44
44
  },
45
45
  "starterDependencies": {
46
46
  "@geastack/core": "^0.1.31",
47
- "@geastack/targets": "^0.1.85",
47
+ "@geastack/targets": "^0.1.86",
48
48
  "@geastack/apple": "^0.2.9"
49
49
  },
50
50
  "scripts": {
@@ -1,4 +1,20 @@
1
1
  export const knownBoards = Object.freeze([
2
+ {
3
+ id: 'waveshare-lcd-35b',
4
+ label: 'Waveshare ESP32-S3 Touch LCD 3.5B / 3.5B-C',
5
+ alias: 'lcd-35b',
6
+ target: 'esp32-s3-touch-lcd-3.5b',
7
+ adapter: 'esp32-idf',
8
+ mcu: 'ESP32-S3',
9
+ capabilities: {
10
+ display: '320 × 480 IPS LCD (AXS15231B QSPI)',
11
+ touch: 'AXS15231B capacitive touch',
12
+ wireless: ['WiFi', 'BLE'],
13
+ storage: ['16 MB flash', '8 MB PSRAM', 'microSD'],
14
+ audio: [],
15
+ gps: false
16
+ }
17
+ },
2
18
  {
3
19
  id: 'waveshare-amoled-241',
4
20
  label: 'Waveshare ESP32-S3 Touch AMOLED 2.41 (V1)',
@@ -2,7 +2,7 @@ import { execFileSync } from 'node:child_process'
2
2
  import { existsSync, readdirSync, realpathSync } from 'node:fs'
3
3
  import path from 'node:path'
4
4
 
5
- import { detectSerialDevices } from '../serial-devices.mjs'
5
+ import { detectSerialDevices, serialFromLinuxById } from '../serial-devices.mjs'
6
6
 
7
7
  // A board is identified by its USB SERIAL, never by a /dev path: enumerated
8
8
  // paths change on every plug-in and identical boards routinely share one.
@@ -59,7 +59,10 @@ function linuxSerialByIdCandidates(serial) {
59
59
  if (!existsSync(dir)) return []
60
60
  const needle = normalizedSerial(serial)
61
61
  return readdirSync(dir)
62
- .filter((name) => normalizedSerial(name).includes(needle))
62
+ .filter((name) => {
63
+ const deviceSerial = serialFromLinuxById(name)
64
+ return normalizedSerial(deviceSerial) === needle
65
+ })
63
66
  .map((name) => path.join(dir, name))
64
67
  }
65
68
 
@@ -98,10 +101,6 @@ function macUsbDeviceForSerial(serial, ioreg = runIoreg) {
98
101
  ) || null
99
102
  }
100
103
 
101
- function locationDigits(locationHex) {
102
- return locationHex.toLowerCase().replace(/^0+/, '').replace(/0+$/, '').replace(/[^0-9a-f]/g, '')
103
- }
104
-
105
104
  function macUsbCalloutPortsForSerial(serial, ioreg = runIoreg) {
106
105
  const output = ioreg(['-p', 'IOService', '-l', '-w0'], { maxBuffer: 64 * 1024 * 1024 })
107
106
  const stack = []
@@ -173,21 +172,13 @@ function runIoreg(args, options = {}) {
173
172
  }
174
173
 
175
174
  function resolveMacUsbSerialPort(serial, ioreg = runIoreg) {
176
- const candidates = serialPortCandidates().filter((candidate) => path.basename(candidate).startsWith('cu.'))
177
- const needle = normalizedSerial(serial)
178
- const serialMatches = candidates.filter((candidate) => normalizedSerial(path.basename(candidate)).includes(needle))
179
- if (serialMatches.length === 1) return serialMatches[0]
180
-
181
- const location = macUsbDeviceForSerial(serial, ioreg)?.locationHex || ''
182
- const digits = locationDigits(location)
183
- if (digits) {
184
- const locationMatches = candidates.filter((candidate) => normalizedSerial(path.basename(candidate)).includes(digits))
185
- if (locationMatches.length === 1) return locationMatches[0]
186
- const registryMatches = macUsbCalloutPortsForSerial(serial, ioreg)
187
- if (registryMatches.length === 1) return registryMatches[0]
188
- if (registryMatches.length > 1) {
189
- throw new Error([`USB serial ${serial} maps to multiple /dev/cu.* ports:`, ...registryMatches.map((c) => ` ${c}`)].join('\n'))
190
- }
175
+ // A location fragment is not an identity: "1" also matches usbmodem21301.
176
+ // During re-enumeration that heuristic selected a different connected board.
177
+ // Only accept the callout inherited from this exact serial in IORegistry.
178
+ const registryMatches = macUsbCalloutPortsForSerial(serial, ioreg)
179
+ if (registryMatches.length === 1) return registryMatches[0]
180
+ if (registryMatches.length > 1) {
181
+ throw new Error([`USB serial ${serial} maps to multiple /dev/cu.* ports:`, ...registryMatches.map((c) => ` ${c}`)].join('\n'))
191
182
  }
192
183
  throw new Error(`Could not map USB serial ${serial} to a /dev/cu.* port. Check that the board is attached.`)
193
184
  }
@@ -233,17 +224,25 @@ export async function waitForSerialPort({
233
224
  label = 'USB serial port',
234
225
  pollSeconds = 1,
235
226
  log = (line) => process.stderr.write(`${line}\n`),
236
- resolver = resolveUsbSerialPort
227
+ resolver = resolveUsbSerialPort,
228
+ portPresent = serialPortPresent
237
229
  } = {}) {
238
230
  const startedAt = Date.now()
239
231
  let nextLog = startedAt
240
232
  while (true) {
241
233
  if (port) {
242
- if (serialPortPresent(port)) return port
234
+ if (portPresent(port)) {
235
+ if (!serial) return port
236
+ try {
237
+ if (resolver({ serial }) === port) return port
238
+ } catch {
239
+ // An explicit path does not override the registered board identity.
240
+ }
241
+ }
243
242
  } else if (serial) {
244
243
  try {
245
244
  const resolved = resolver({ serial })
246
- if (resolved && serialPortPresent(resolved)) return resolved
245
+ if (resolved && portPresent(resolved)) return resolved
247
246
  } catch {
248
247
  // not attached yet
249
248
  }
@@ -87,6 +87,17 @@ function ratio(value, where) {
87
87
  if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) fail(`${where} must be a positive number`)
88
88
  return value
89
89
  }
90
+ function boardDefines(raw, where) {
91
+ if (raw === undefined) return []
92
+ if (!isObject(raw)) fail(`${where} must be an object`)
93
+ return Object.entries(raw).map(([name, value]) => {
94
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name) ||
95
+ !['string', 'number', 'boolean'].includes(typeof value) ||
96
+ (typeof value === 'number' && !Number.isFinite(value)) ||
97
+ /[;\n\r]/.test(String(value))) fail(`${where}.${name} must be a valid native define`)
98
+ return `${name}=${typeof value === 'boolean' ? Number(value) : value}`
99
+ })
100
+ }
90
101
  export function validateBuildManifest(manifest) {
91
102
  flatten(manifest.build, 'gea.build')
92
103
  for (const [platform, target] of Object.entries(manifest.targets || {})) {
@@ -98,7 +109,8 @@ export function validateBuildManifest(manifest) {
98
109
  if (!isObject(target.boards)) fail(where + '.boards must be an object')
99
110
  for (const [id, board] of Object.entries(target.boards)) {
100
111
  if (!/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(id) || !isObject(board)) fail(where + '.boards must contain board IDs mapped to objects')
101
- for (const key of Object.keys(board)) if (!['build', 'cssDevicePixelRatio'].includes(key)) fail(`Unknown setting ${where}.boards.${id}.${key}`)
112
+ for (const key of Object.keys(board)) if (!['build', 'cssDevicePixelRatio', 'defines'].includes(key)) fail(`Unknown setting ${where}.boards.${id}.${key}`)
113
+ boardDefines(board.defines, where + '.boards.' + id + '.defines')
102
114
  flatten(board.build, where + '.boards.' + id + '.build')
103
115
  if (board.cssDevicePixelRatio !== undefined) ratio(board.cssDevicePixelRatio, where + '.boards.' + id + '.cssDevicePixelRatio')
104
116
  }
@@ -162,7 +174,10 @@ export function resolveBuildConfig({ app, platform, board = '', targetsRoot = ''
162
174
  apply(boardOverride.build, 'gea.targets.' + platform + '.boards.' + board + '.build', true)
163
175
  const passthroughDefines = []
164
176
  const seenLegacy = new Set()
165
- for (const define of app?.defines || []) {
177
+ const overrides = boardDefines(boardOverride.defines, 'gea.targets.' + platform + '.boards.' + board + '.defines')
178
+ const overridden = new Set(overrides.map(define => define.split('=')[0]))
179
+ const selectedDefines = [...(app?.defines || []).filter(define => !overridden.has(define.split('=')[0])), ...overrides]
180
+ for (const define of selectedDefines) {
166
181
  const [name, ...rest] = define.split('=')
167
182
  if (name === 'GEA_CPP_MINIMAL_GLOBAL_OBJECT' || name === 'GEA_EMBEDDED_NUMBER_F32') fail(`${name} is obsolete and has no active consumer; remove it from gea.defines`)
168
183
  if (['GEA_EMBEDDED_DIRECT_CANVAS_CONTEXT', 'GEA_EMBEDDED_FULL_BOOT_SERVICES'].includes(name)) fail(`${name} is inferred from app capabilities; remove it from gea.defines`)
@@ -130,7 +130,7 @@ function normalizeDevice(input) {
130
130
  }
131
131
  }
132
132
 
133
- function serialFromLinuxById(name) {
133
+ export function serialFromLinuxById(name) {
134
134
  const cleaned = name.replace(/-if\d+.*$/i, '')
135
135
  const parts = cleaned.split('_').map((part) => part.trim()).filter(Boolean)
136
136
  return parts.at(-1) || ''