@open-mercato/starter 0.10.1-develop.8004.1.a8a79ee43f → 0.10.1-develop.8024.1.02dbc16b49
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/README.md +5 -2
- package/bin/om-start.mjs +1 -1
- package/package.json +1 -1
- package/src/__tests__/port-diagnostics.test.mjs +2 -2
- package/src/__tests__/providers.test.mjs +1 -1
- package/src/__tests__/service-selection.test.mjs +25 -0
- package/src/__tests__/setup-streaming.test.mjs +33 -0
- package/src/__tests__/stage-progress.test.mjs +15 -2
- package/src/cli.mjs +3 -3
- package/src/company.mjs +1 -1
- package/src/infra-preflight.mjs +2 -2
- package/src/init-summary.mjs +63 -0
- package/src/service-modes.mjs +1 -1
- package/src/setup-logs.mjs +1 -1
- package/src/setup-session.mjs +11 -3
- package/src/steps.mjs +27 -7
- package/src/supervise.mjs +2 -2
- package/src/ui.mjs +2 -2
package/README.md
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
The central, cross-platform way to stand up an Open Mercato dev environment. One command, idempotent, platform-aware:
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
#
|
|
6
|
+
# Outside a clone (clones the repo into ./open-mercato first):
|
|
7
7
|
npx @open-mercato/starter
|
|
8
8
|
|
|
9
|
-
# Inside a clone
|
|
9
|
+
# Inside a fresh clone, before the first `yarn install`:
|
|
10
|
+
node packages/starter/bin/om-start.mjs
|
|
11
|
+
|
|
12
|
+
# Inside a clone once dependencies are installed:
|
|
10
13
|
yarn setup # same as `yarn om up`: everything from install to a running app
|
|
11
14
|
yarn om # alias for node packages/starter/bin/om-start.mjs
|
|
12
15
|
```
|
package/bin/om-start.mjs
CHANGED
|
@@ -42,7 +42,7 @@ async function ensureRepo(args) {
|
|
|
42
42
|
process.exit(2)
|
|
43
43
|
}
|
|
44
44
|
console.log(`No checkout found — cloning open-mercato (${branch}) into ${dir} ...`)
|
|
45
|
-
const clone = spawnSync('git', ['clone', '--branch', branch, REPO_URL, dir], { stdio: 'inherit' })
|
|
45
|
+
const clone = spawnSync('git', ['clone', '--filter=blob:none', '--branch', branch, REPO_URL, dir], { stdio: 'inherit' })
|
|
46
46
|
if (clone.status !== 0) {
|
|
47
47
|
console.error('❌ git clone failed. Behind a corporate proxy? Configure git first (ask IT for the proxy address):')
|
|
48
48
|
console.error(' git config --global http.proxy http://proxy.example.com:8080')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/starter",
|
|
3
|
-
"version": "0.10.1-develop.
|
|
3
|
+
"version": "0.10.1-develop.8024.1.02dbc16b49",
|
|
4
4
|
"description": "One-command, cross-platform bootstrap for Open Mercato dev environments: prerequisite doctor, corporate TLS trust, idempotent setup steps, and a supervised hybrid or fully containerized stack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -97,10 +97,10 @@ test('interactive diagnostics color service, port, variables and commands and ho
|
|
|
97
97
|
test('consent separates warning emojis and the continuing paragraph from the answer', async () => {
|
|
98
98
|
const lines = []
|
|
99
99
|
assert.equal(await requestExistingServicesConsent(problem, { input: { isTTY: true }, output: { isTTY: false }, env: {}, question: async () => 'y', log: (line) => lines.push(line) }), true)
|
|
100
|
-
assert.ok(lines.some((line) => line.startsWith('
|
|
100
|
+
assert.ok(lines.some((line) => line.startsWith(' ❗ mercato-postgres')))
|
|
101
101
|
const continuing = lines.findIndex((line) => line.includes('Continuing with'))
|
|
102
102
|
assert.equal(lines[continuing - 1], '')
|
|
103
|
-
assert.ok(lines[continuing].startsWith('
|
|
103
|
+
assert.ok(lines[continuing].startsWith(' ❗ '))
|
|
104
104
|
assert.match(lines.join('\n'), /Listener PID: 1234/)
|
|
105
105
|
})
|
|
106
106
|
|
|
@@ -152,5 +152,5 @@ test('a user can still configure a provider interactively and synchronize the ap
|
|
|
152
152
|
|
|
153
153
|
test('optional AI skip output separates its warning with a blank line and wide-glyph spacing', async () => {
|
|
154
154
|
const result = await runProvider({ step: true })
|
|
155
|
-
assert.match(result.output, /\n[ \t]*\n[ \t]
|
|
155
|
+
assert.match(result.output, /\n[ \t]*\n[ \t]*❗ Continuing without AI/)
|
|
156
156
|
})
|
|
@@ -254,6 +254,31 @@ test('the starter session hands its token to the dev runner and releases on fail
|
|
|
254
254
|
}
|
|
255
255
|
})
|
|
256
256
|
|
|
257
|
+
test('the starter setup session uses the checkout recovery and keeps the hard stop when non-interactive', async () => {
|
|
258
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'om-starter-recovery-'))
|
|
259
|
+
try {
|
|
260
|
+
fs.mkdirSync(path.join(dir, 'scripts'))
|
|
261
|
+
for (const file of ['dev-session-guard.mjs', 'dev-session-recovery.mjs']) {
|
|
262
|
+
fs.copyFileSync(path.join(repoRoot, 'scripts', file), path.join(dir, 'scripts', file))
|
|
263
|
+
}
|
|
264
|
+
const { acquireSetupSession } = await import('../setup-session.mjs')
|
|
265
|
+
const first = await acquireSetupSession(dir, { interactive: false })
|
|
266
|
+
try {
|
|
267
|
+
await assert.rejects(acquireSetupSession(dir, { interactive: false }), /Another Open Mercato dev session already owns this workspace/)
|
|
268
|
+
} finally {
|
|
269
|
+
first.release()
|
|
270
|
+
}
|
|
271
|
+
const lockDirectory = path.join(dir, '.mercato', 'dev-session.lock')
|
|
272
|
+
fs.mkdirSync(path.join(lockDirectory, 'members'), { recursive: true })
|
|
273
|
+
fs.writeFileSync(path.join(lockDirectory, 'owner.json'), JSON.stringify({ token: '00000000-0000-4000-8000-000000000000', pid: 2147483647, mode: 'setup:hybrid', workspaceRoot: fs.realpathSync(dir) }))
|
|
274
|
+
const recovered = await acquireSetupSession(dir, { interactive: false })
|
|
275
|
+
assert.notEqual(recovered.token, '00000000-0000-4000-8000-000000000000', 'a lock left by an exited process is replaced')
|
|
276
|
+
recovered.release()
|
|
277
|
+
} finally {
|
|
278
|
+
fs.rmSync(dir, { recursive: true, force: true })
|
|
279
|
+
}
|
|
280
|
+
})
|
|
281
|
+
|
|
257
282
|
test('a fresh clone without Docker or services fails within seconds, before yarn install or builds', { skip: process.platform === 'win32' ? 'fake shims are POSIX shell scripts' : false }, async () => {
|
|
258
283
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'om-starter-fresh-'))
|
|
259
284
|
try {
|
|
@@ -220,6 +220,39 @@ test('database setup records successful migration but never a failed initializat
|
|
|
220
220
|
assert.equal(fs.existsSync(path.join(repoRoot, STARTER_STATE_DIR, ctx.dbMarker)), false)
|
|
221
221
|
})
|
|
222
222
|
|
|
223
|
+
test('database setup keeps the initialization credentials visible when output is folded', async (t) => {
|
|
224
|
+
const repoRoot = temporaryRepo(t)
|
|
225
|
+
const rule = `\u001b[48;2;57;62;70m${'━'.repeat(30)}\u001b[0m`
|
|
226
|
+
const panel = [
|
|
227
|
+
rule,
|
|
228
|
+
`\u001b[48;2;57;62;70m${' '.repeat(30)}\u001b[0m`,
|
|
229
|
+
`\u001b[48;2;57;62;70m 🔑 DEVELOPMENT ACCOUNTS \u001b[0m`,
|
|
230
|
+
`\u001b[48;2;57;62;70m Email: admin@acme.com\u001b[0m`,
|
|
231
|
+
`\u001b[48;2;57;62;70m Password: secret \u001b[0m`,
|
|
232
|
+
rule,
|
|
233
|
+
]
|
|
234
|
+
const folded = []
|
|
235
|
+
const visible = []
|
|
236
|
+
const logs = { interactive: true, raw: (chunk) => folded.push(chunk), suspend() {}, resume() {}, resumeActivity() {} }
|
|
237
|
+
const ctx = {
|
|
238
|
+
repoRoot, env: {}, flags: { noInfra: true }, log() {}, logs,
|
|
239
|
+
promptLog: (line) => visible.push(line),
|
|
240
|
+
assertDatabaseWriteAllowedImpl: async () => ({ remote: false }),
|
|
241
|
+
dbMigrationsMarker: 'db-migrations-test', dbMarker: 'db-initialized-test', migrationsFingerprint: 'fingerprint',
|
|
242
|
+
runStreamingImpl: async (_command, args, options) => {
|
|
243
|
+
if (args[0] === 'initialize') {
|
|
244
|
+
const output = ['Seeding demo data...', ...panel, 'Done.\n'].join('\n')
|
|
245
|
+
options.logs.raw(output.slice(0, 120))
|
|
246
|
+
options.logs.raw(output.slice(120))
|
|
247
|
+
}
|
|
248
|
+
return 0
|
|
249
|
+
},
|
|
250
|
+
}
|
|
251
|
+
await databaseStep.apply(ctx)
|
|
252
|
+
assert.ok(folded.join('').includes('Password: secret'))
|
|
253
|
+
assert.deepEqual(visible, panel.map((line) => ` ${line}`))
|
|
254
|
+
})
|
|
255
|
+
|
|
223
256
|
test('infrastructure awaits asynchronous image preparation before streaming compose up', async () => {
|
|
224
257
|
const preparation = deferred()
|
|
225
258
|
const order = []
|
|
@@ -6,7 +6,7 @@ import path from 'node:path'
|
|
|
6
6
|
import { spawnSync } from 'node:child_process'
|
|
7
7
|
import test from 'node:test'
|
|
8
8
|
import vm from 'node:vm'
|
|
9
|
-
import { createSpinner } from '../ui.mjs'
|
|
9
|
+
import { createSpinner, statusLine } from '../ui.mjs'
|
|
10
10
|
import { createSetupLogs } from '../setup-logs.mjs'
|
|
11
11
|
import { llmProviderStep, runSteps } from '../steps.mjs'
|
|
12
12
|
|
|
@@ -21,6 +21,19 @@ test('stage headings restore the original prefix and style only Expected:', () =
|
|
|
21
21
|
assert.match(result.stdout, /\x1b\[1m\x1b\[33mExpected:\x1b\[0m\x1b\[0m migrations \+ seed/)
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
+
test('status lines use emoji that every terminal draws two columns wide', () => {
|
|
25
|
+
const lines = []
|
|
26
|
+
for (const kind of ['ok', 'warn', 'fail', 'info']) statusLine(kind, 'message', { log: (line) => lines.push(line.replace(/\u001b\[[0-9;]*m/g, '')) })
|
|
27
|
+
assert.deepEqual(lines, [' ✅ message', ' ❗ message', ' ❌ message', ' 💡 message'])
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
test('setup output avoids variation-selector emoji whose width differs between terminals', () => {
|
|
31
|
+
const sourceDir = new URL('../', import.meta.url)
|
|
32
|
+
const offenders = fs.readdirSync(sourceDir).filter((name) => name.endsWith('.mjs'))
|
|
33
|
+
.filter((name) => fs.readFileSync(new URL(name, sourceDir), 'utf8').includes('️'))
|
|
34
|
+
assert.deepEqual(offenders, [])
|
|
35
|
+
})
|
|
36
|
+
|
|
24
37
|
test('working spinner animates with elapsed time, pauses, and is replaced on completion', () => {
|
|
25
38
|
const output = []
|
|
26
39
|
const statuses = []
|
|
@@ -70,7 +83,7 @@ test('stage activity stops on success, skip and failure and never starts over a
|
|
|
70
83
|
setActivity(activity) { if (activity) { events.push('attach'); activity.resume() } }, resumeActivity() {},
|
|
71
84
|
}
|
|
72
85
|
const ctx = { flags: {}, logs, log: (line) => events.push(String(line)), createSpinnerImpl(label) {
|
|
73
|
-
assert.equal(label, '
|
|
86
|
+
assert.equal(label, '🔧 working…')
|
|
74
87
|
events.push('create')
|
|
75
88
|
return { pause() { events.push('pause') }, resume() { events.push('resume') }, stop() { events.push('stop') } }
|
|
76
89
|
} }
|
package/src/cli.mjs
CHANGED
|
@@ -179,7 +179,7 @@ async function commandUp(flags) {
|
|
|
179
179
|
let session = null
|
|
180
180
|
if (!containerized) {
|
|
181
181
|
try {
|
|
182
|
-
session = await acquireSetupSession(repoRoot)
|
|
182
|
+
session = await acquireSetupSession(repoRoot, { interactive: flags.nonInteractive ? false : undefined })
|
|
183
183
|
} catch (error) {
|
|
184
184
|
console.error(`❌ ${error instanceof Error ? error.message : String(error)}`)
|
|
185
185
|
console.error(' No service configuration, .env file or container was changed.')
|
|
@@ -387,7 +387,7 @@ async function commandStop(flags) {
|
|
|
387
387
|
process.exit(status)
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
console.log('
|
|
390
|
+
console.log('💡 Infra containers left running (--keep-infra or no docker). Foreground `yarn dev` sessions stop with Ctrl+C.')
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
async function commandStatus(flags) {
|
|
@@ -431,7 +431,7 @@ async function commandReset(flags) {
|
|
|
431
431
|
// down only sees THIS project's resources; fixed-name containers/volumes
|
|
432
432
|
// created by another checkout of the repo survive it — sweep by name.
|
|
433
433
|
if (!removeLeftoverComposeResources(repoRoot, { composeFile })) {
|
|
434
|
-
console.warn('
|
|
434
|
+
console.warn('❗ Some volumes could not be removed — the next run would reuse the old data. Fix the items above and re-run reset.')
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
437
|
fs.rmSync(path.join(repoRoot, STARTER_STATE_DIR), { recursive: true, force: true })
|
package/src/company.mjs
CHANGED
|
@@ -64,7 +64,7 @@ export async function loadCompanyConfig(repoRoot, { warn = console.warn } = {})
|
|
|
64
64
|
const module = await import(pathToFileURL(filePath).href)
|
|
65
65
|
config = mergeConfig(config, module.default)
|
|
66
66
|
} catch (error) {
|
|
67
|
-
warn(
|
|
67
|
+
warn(`❗ Ignoring starters/company/${candidate} — it failed to load: ${error instanceof Error ? error.message : String(error)}`)
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
return config
|
package/src/infra-preflight.mjs
CHANGED
|
@@ -245,7 +245,7 @@ export async function requestExistingServicesConsent(problem, {
|
|
|
245
245
|
for (const entry of problem.ports ?? problem.services ?? []) {
|
|
246
246
|
const identity = colors.service(entry.containerName || entry.service)
|
|
247
247
|
const state = diagnosticText(entry.state || 'unknown')
|
|
248
|
-
log(`
|
|
248
|
+
log(` ❗ ${identity}${entry.port ? ` on port ${colors.port(entry.port)}` : ''}: ${state}${entry.health ? ` (${diagnosticText(entry.health)})` : ''}`)
|
|
249
249
|
log(` ${listenerSummary(entry, colors)}`)
|
|
250
250
|
if (entry.containerName && (state === 'restarting' || entry.health === 'unhealthy')) log(` Inspect the restart/health failure: ${colors.command(`docker logs ${diagnosticText(entry.containerName)}`)}`)
|
|
251
251
|
}
|
|
@@ -267,7 +267,7 @@ export async function requestExistingServicesConsent(problem, {
|
|
|
267
267
|
const answer = await (question ? question(prompt) : new Promise((resolve) => reader.question(prompt, resolve)))
|
|
268
268
|
if (!/^(y|yes)$/i.test(String(answer).trim())) return false
|
|
269
269
|
log('')
|
|
270
|
-
log('
|
|
270
|
+
log(' ❗ Continuing with the services configured in .env.')
|
|
271
271
|
if (configuredServices) {
|
|
272
272
|
log(' Configured services will not be started, stopped or reconfigured.')
|
|
273
273
|
} else {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Folded setup output hides `mercato init`; this pulls back the part the
|
|
2
|
+
// operator must see — the credentials panel (or the legacy ╔ box) on a first
|
|
3
|
+
// run, or the "already initialized" notice on a re-run. Mirrors
|
|
4
|
+
// extractInitSummaryLines in scripts/dev-orchestration-log-policy.mjs; the
|
|
5
|
+
// starter is published build-free, so it cannot import repo scripts.
|
|
6
|
+
|
|
7
|
+
const ANSI_PATTERN = /\u001b\[[0-9;?]*[A-Za-z]/g
|
|
8
|
+
const BOX_CHARS = /[╔║╠╚]/
|
|
9
|
+
|
|
10
|
+
const stripAnsi = (value) => String(value ?? '').replace(ANSI_PATTERN, '')
|
|
11
|
+
|
|
12
|
+
function sliceVisibleColumns(line, column) {
|
|
13
|
+
let offset = 0
|
|
14
|
+
let visible = 0
|
|
15
|
+
while (visible < column && offset < line.length) {
|
|
16
|
+
const escape = line.slice(offset).match(/^\u001b\[[0-9;]*m/)
|
|
17
|
+
if (escape) offset += escape[0].length
|
|
18
|
+
else {
|
|
19
|
+
offset += 1
|
|
20
|
+
visible += 1
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return line.slice(offset).replace(/^(?:\u001b\[0m)+/, '')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function extractPanel(lines) {
|
|
27
|
+
const plain = lines.map(stripAnsi)
|
|
28
|
+
for (let heading = plain.length - 1; heading > 1; heading -= 1) {
|
|
29
|
+
if (!plain[heading].includes(' 🔑 ')) continue
|
|
30
|
+
const start = heading - 2
|
|
31
|
+
const column = plain[start].indexOf('━')
|
|
32
|
+
if (column < 0 || !/^━+\s*$/.test(plain[start].slice(column))) continue
|
|
33
|
+
const rule = plain[start].slice(column).trim()
|
|
34
|
+
const end = plain.findIndex((line, index) => index > heading && line.slice(column).trim() === rule)
|
|
35
|
+
if (end === -1) return []
|
|
36
|
+
return lines.slice(start, end + 1).map((line) => sliceVisibleColumns(line, column))
|
|
37
|
+
}
|
|
38
|
+
return []
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function extractBox(lines) {
|
|
42
|
+
const plain = lines.map((line) => stripAnsi(line).replace(/\s+$/, ''))
|
|
43
|
+
const start = plain.findLastIndex((line) => line.includes('╔'))
|
|
44
|
+
if (start === -1) return []
|
|
45
|
+
const box = []
|
|
46
|
+
for (const line of plain.slice(start)) {
|
|
47
|
+
const column = line.search(BOX_CHARS)
|
|
48
|
+
if (column === -1) return []
|
|
49
|
+
box.push(line.slice(column))
|
|
50
|
+
if (line.includes('╚')) return box
|
|
51
|
+
}
|
|
52
|
+
return []
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function extractInitSummaryLines(lines) {
|
|
56
|
+
if (!Array.isArray(lines)) return []
|
|
57
|
+
const panel = extractPanel(lines)
|
|
58
|
+
if (panel.length > 0) return panel
|
|
59
|
+
const box = extractBox(lines)
|
|
60
|
+
if (box.length > 0) return box
|
|
61
|
+
const kept = lines.map((line) => stripAnsi(line).trim()).find((line) => line.includes('Database already initialized'))
|
|
62
|
+
return kept ? [kept] : []
|
|
63
|
+
}
|
package/src/service-modes.mjs
CHANGED
|
@@ -332,7 +332,7 @@ export async function configureServiceMode({ mode, projectDir, env = process.env
|
|
|
332
332
|
|
|
333
333
|
export function printManualSetup({ log = console.error, monorepo = false } = {}) {
|
|
334
334
|
log('')
|
|
335
|
-
log('
|
|
335
|
+
log('🔨 Setup did not complete. Manual setup:')
|
|
336
336
|
log('')
|
|
337
337
|
log(' 1. Configure PostgreSQL, Redis and Meilisearch in your .env file:')
|
|
338
338
|
log(monorepo ? ' apps/mercato/.env' : ' .env')
|
package/src/setup-logs.mjs
CHANGED
|
@@ -54,7 +54,7 @@ export function createSetupLogs({
|
|
|
54
54
|
if (fileFailed) return
|
|
55
55
|
fileFailed = true
|
|
56
56
|
activity?.pause()
|
|
57
|
-
write('
|
|
57
|
+
write(' ❗ Could not save setup logs; terminal output is still available.\n')
|
|
58
58
|
if (active && !visible) activity?.resume()
|
|
59
59
|
}
|
|
60
60
|
|
package/src/setup-session.mjs
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
// (scripts/dev-session-guard.mjs, also used by scripts/dev.mjs). The starter
|
|
5
5
|
// claims it BEFORE it writes .env, configures services or touches Compose, so
|
|
6
6
|
// a second setup in an active checkout stops without disturbing the running
|
|
7
|
-
// session.
|
|
7
|
+
// session. Interactive runs use the checkout's dev-session recovery, which asks
|
|
8
|
+
// before stopping the conflicting session or discarding its stale lock. The
|
|
9
|
+
// token travels to the dev runner through childEnv.
|
|
8
10
|
import fs from 'node:fs'
|
|
9
11
|
import path from 'node:path'
|
|
10
12
|
import { pathToFileURL } from 'node:url'
|
|
@@ -18,11 +20,17 @@ import { verifyServiceConnections } from './service-connections.mjs'
|
|
|
18
20
|
// Works before the first `yarn install`, unlike `yarn setup --no-infra`.
|
|
19
21
|
export const FRESH_CLONE_NO_INFRA_COMMAND = 'node packages/starter/bin/om-start.mjs up --no-infra'
|
|
20
22
|
|
|
21
|
-
export async function acquireSetupSession(repoRoot, { mode = 'setup:hybrid', role = 'starter' } = {}) {
|
|
23
|
+
export async function acquireSetupSession(repoRoot, { mode = 'setup:hybrid', role = 'starter', interactive } = {}) {
|
|
22
24
|
const guardPath = path.join(repoRoot, 'scripts', 'dev-session-guard.mjs')
|
|
23
25
|
if (!fs.existsSync(guardPath)) return null
|
|
26
|
+
const options = { workspaceRoot: repoRoot, mode, role }
|
|
27
|
+
const recoveryPath = path.join(repoRoot, 'scripts', 'dev-session-recovery.mjs')
|
|
28
|
+
if (fs.existsSync(recoveryPath)) {
|
|
29
|
+
const { acquireDevSessionWithRecovery } = await import(pathToFileURL(recoveryPath).href)
|
|
30
|
+
return acquireDevSessionWithRecovery(options, interactive === undefined ? {} : { interactive })
|
|
31
|
+
}
|
|
24
32
|
const { acquireDevSession } = await import(pathToFileURL(guardPath).href)
|
|
25
|
-
return acquireDevSession(
|
|
33
|
+
return acquireDevSession(options)
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
function readEnvFile(file) {
|
package/src/steps.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { loadCompanyConfig, resolveCompanyCertBundles } from './company.mjs'
|
|
|
9
9
|
import { CAPTURED_CA_BUNDLE, DEFAULT_OPENCODE_BASE_IMAGE, OPENCODE_SERVICE_IMAGE, STARTER_STATE_DIR, resolveStackPorts } from './constants.mjs'
|
|
10
10
|
import { checkBuildToolchain, checkContainerRuntime, checkGit, checkNodeVersion, checkWsl2, detectHostGateway } from './doctor.mjs'
|
|
11
11
|
import { ensureEnvFiles } from './env-setup.mjs'
|
|
12
|
+
import { extractInitSummaryLines } from './init-summary.mjs'
|
|
12
13
|
import { addEnvValue, readEnvValue } from './env-file.mjs'
|
|
13
14
|
import { describeInfraProblem, startInfra } from './infra.mjs'
|
|
14
15
|
import { configureServiceMode } from './service-modes.mjs'
|
|
@@ -19,6 +20,8 @@ import { verifyServiceConnections } from './service-connections.mjs'
|
|
|
19
20
|
import { createSetupLogs } from './setup-logs.mjs'
|
|
20
21
|
import { color, createSpinner, formatDuration, guideBox, statusLine, stepHeader } from './ui.mjs'
|
|
21
22
|
|
|
23
|
+
const INIT_OUTPUT_TAIL = 256 * 1024
|
|
24
|
+
|
|
22
25
|
// The idempotent convergence pipeline behind `up`. Every step follows the same
|
|
23
26
|
// contract so re-running is always safe and always cheap when nothing changed:
|
|
24
27
|
// check(ctx) -> { ok, detail } did reality already match the goal?
|
|
@@ -286,7 +289,7 @@ export const prerequisitesStep = {
|
|
|
286
289
|
// corepack and activate the exact version pinned in package.json.
|
|
287
290
|
const spec = JSON.parse(fs.readFileSync(path.join(ctx.repoRoot, 'package.json'), 'utf8')).packageManager.split('+')[0]
|
|
288
291
|
const enable = await runStreaming('corepack', ['enable'], { cwd: ctx.repoRoot, env: ctx.env, logs: ctx.logs })
|
|
289
|
-
if (enable !== 0) ctx.log('
|
|
292
|
+
if (enable !== 0) ctx.log('❗ corepack enable failed (PATH not writable?) — falling back to running yarn through corepack.')
|
|
290
293
|
const prepare = await runStreaming('corepack', ['prepare', spec, '--activate'], { cwd: ctx.repoRoot, env: ctx.env, logs: ctx.logs })
|
|
291
294
|
if (prepare !== 0) {
|
|
292
295
|
throw new Error(`corepack prepare ${spec} failed. Behind a corporate proxy? Set HTTPS_PROXY and re-run — the starter provisions the corporate CA automatically in the next step; if this step itself is blocked, set COREPACK_NPM_REGISTRY to your internal mirror (see starters/company/).`)
|
|
@@ -342,7 +345,7 @@ export const corporateCertsStep = {
|
|
|
342
345
|
ctx.tlsProbes = probes
|
|
343
346
|
if (intercepted.length === 0 && companyBundles.length === 0 && vendorBundles.length === 0) {
|
|
344
347
|
if (unreachable.length > 0) {
|
|
345
|
-
ctx.log(`
|
|
348
|
+
ctx.log(` ❗ unreachable during TLS probe: ${unreachable.map((entry) => `${entry.host} (${entry.reason})`).join(', ')} — continuing; expect trouble if installs need those hosts.`)
|
|
346
349
|
}
|
|
347
350
|
return { ok: true, detail: 'no TLS interception detected' }
|
|
348
351
|
}
|
|
@@ -409,7 +412,7 @@ export const buildToolchainStep = {
|
|
|
409
412
|
const installConverged = fs.existsSync(path.join(ctx.repoRoot, 'node_modules'))
|
|
410
413
|
&& readState(ctx.repoRoot, 'install.hash') === hashFiles(ctx.repoRoot, ['yarn.lock', 'package.json'])
|
|
411
414
|
if (installConverged) {
|
|
412
|
-
ctx.log('
|
|
415
|
+
ctx.log(' ❗ VC++ build toolchain not found — dependencies are already installed, so this is not blocking now.')
|
|
413
416
|
ctx.log(' ↳ the next dependency change may need it: winget install Microsoft.VisualStudio.2022.BuildTools --override "--wait --quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"')
|
|
414
417
|
return { ok: true, detail: 'toolchain missing, but the workspace install already converged (prebuilt binaries)' }
|
|
415
418
|
}
|
|
@@ -428,7 +431,7 @@ export const envFilesStep = {
|
|
|
428
431
|
return { ok: false, detail: 'converging (never overwrites existing values)' }
|
|
429
432
|
},
|
|
430
433
|
async apply(ctx) {
|
|
431
|
-
ensureEnvFiles(ctx.repoRoot, { log: (line) => ctx.log(` ${String(line).trimStart()}`), warn: (line) => ctx.log(`
|
|
434
|
+
ensureEnvFiles(ctx.repoRoot, { log: (line) => ctx.log(` ${String(line).trimStart()}`), warn: (line) => ctx.log(` ❗ ${line}`), extraDefaults: ctx.company.env })
|
|
432
435
|
},
|
|
433
436
|
}
|
|
434
437
|
|
|
@@ -494,7 +497,7 @@ export const llmProviderStep = {
|
|
|
494
497
|
skipPrompt: ctx.flags.skipLlmPrompt,
|
|
495
498
|
nonInteractive: ctx.flags.nonInteractive,
|
|
496
499
|
log: (line) => ctx.log(` ${String(line).trimStart()}`),
|
|
497
|
-
warn: (line) => ctx.log(`
|
|
500
|
+
warn: (line) => ctx.log(` ❗ ${line}`),
|
|
498
501
|
})
|
|
499
502
|
},
|
|
500
503
|
async check() {
|
|
@@ -741,8 +744,18 @@ export const databaseStep = {
|
|
|
741
744
|
// has no users, so it seeds either way; the flag is left off there.
|
|
742
745
|
const initArgs = ctx.dbReinitialize ? ['initialize'] : ['initialize', '--', '--skip-if-initialized']
|
|
743
746
|
await authorizeWrites()
|
|
747
|
+
let initOutput = ''
|
|
748
|
+
const initLogs = ctx.logs && Object.create(ctx.logs, {
|
|
749
|
+
raw: {
|
|
750
|
+
value: (chunk, displayChunk) => {
|
|
751
|
+
initOutput = `${initOutput}${chunk}`.slice(-INIT_OUTPUT_TAIL)
|
|
752
|
+
ctx.logs.raw(chunk, displayChunk)
|
|
753
|
+
},
|
|
754
|
+
},
|
|
755
|
+
})
|
|
744
756
|
await runYarn({
|
|
745
757
|
...ctx,
|
|
758
|
+
logs: initLogs,
|
|
746
759
|
env: {
|
|
747
760
|
...ctx.env,
|
|
748
761
|
OM_INIT_DEV_AUTOSTART: '1',
|
|
@@ -750,6 +763,13 @@ export const databaseStep = {
|
|
|
750
763
|
OM_INIT_SUMMARY_COLOR: process.stdout.isTTY && ctx.env.NO_COLOR === undefined ? '1' : '0',
|
|
751
764
|
},
|
|
752
765
|
}, initArgs)
|
|
766
|
+
if (ctx.logs?.interactive) {
|
|
767
|
+
const summary = extractInitSummaryLines(initOutput.split(/\r?\n/))
|
|
768
|
+
if (summary.length > 0) {
|
|
769
|
+
for (const line of summary) (ctx.promptLog ?? ctx.log)(` ${line}`)
|
|
770
|
+
ctx.logs.resumeActivity?.()
|
|
771
|
+
}
|
|
772
|
+
}
|
|
753
773
|
}
|
|
754
774
|
writeState(ctx.repoRoot, ctx.dbMarker, new Date().toISOString())
|
|
755
775
|
}
|
|
@@ -810,7 +830,7 @@ export const hostGatewayStep = {
|
|
|
810
830
|
} else if (outcome.status === 'skip') {
|
|
811
831
|
ctx.log(' probe container could not run — skipping (run `yarn om doctor` for the full audit)')
|
|
812
832
|
} else {
|
|
813
|
-
ctx.log(`
|
|
833
|
+
ctx.log(` ❗ containers cannot reach this machine on port ${ports.mcp} — Windows Firewall likely blocks the WSL adapter`)
|
|
814
834
|
ctx.log(` ↳ allow it (elevated PowerShell): New-NetFirewallRule -DisplayName "Open Mercato MCP dev" -Direction Inbound -Action Allow -Protocol TCP -LocalPort ${ports.mcp} -Profile Any`)
|
|
815
835
|
ctx.log(' ↳ then re-run — OpenCode waits for the MCP server and recovers once the port answers')
|
|
816
836
|
}
|
|
@@ -891,7 +911,7 @@ export async function runSteps(steps, ctx) {
|
|
|
891
911
|
const startedAt = Date.now()
|
|
892
912
|
if (step.interactive) logs.suspend()
|
|
893
913
|
else if (logs.interactive) {
|
|
894
|
-
spinner = (ctx.createSpinnerImpl ?? createSpinner)('
|
|
914
|
+
spinner = (ctx.createSpinnerImpl ?? createSpinner)('🔧 working…', { startPaused: true, frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] })
|
|
895
915
|
logs.setActivity?.(spinner)
|
|
896
916
|
}
|
|
897
917
|
ctx.log = step.interactive ? log : (...args) => logs.log(...args)
|
package/src/supervise.mjs
CHANGED
|
@@ -87,7 +87,7 @@ export async function stopDetached(repoRoot, { log = console.log, graceMs = 8000
|
|
|
87
87
|
const state = readRunState(repoRoot)
|
|
88
88
|
if (!state || !isPidAlive(state.pid)) {
|
|
89
89
|
if (state) fs.rmSync(runStatePath(repoRoot), { force: true })
|
|
90
|
-
log('
|
|
90
|
+
log('💡 No detached dev runtime is running.')
|
|
91
91
|
return true
|
|
92
92
|
}
|
|
93
93
|
log(`Stopping dev runtime (pid ${state.pid}) ...`)
|
|
@@ -199,7 +199,7 @@ export function tailLogs(repoRoot, { follow = false, lines = 60, log = console.l
|
|
|
199
199
|
files = []
|
|
200
200
|
}
|
|
201
201
|
if (files.length === 0) {
|
|
202
|
-
log(
|
|
202
|
+
log(`💡 No logs yet under ${path.relative(repoRoot, logDir)} — start the stack first.`)
|
|
203
203
|
return
|
|
204
204
|
}
|
|
205
205
|
const newest = files[0]
|
package/src/ui.mjs
CHANGED
|
@@ -57,9 +57,9 @@ export function stepHeader(index, total, title, expectation, { log = console.log
|
|
|
57
57
|
|
|
58
58
|
export const icons = {
|
|
59
59
|
ok: color.green('✅'),
|
|
60
|
-
warn: color.yellow('
|
|
60
|
+
warn: color.yellow('❗'),
|
|
61
61
|
fail: color.red('❌'),
|
|
62
|
-
info: color.cyan('
|
|
62
|
+
info: color.cyan('💡'),
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export function statusLine(kind, message, { log = console.log } = {}) {
|