create-mercato-app 0.5.1-develop.2744.9c8be0dd93 → 0.5.1-develop.2756.cce1739df3
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/package.json
CHANGED
package/template/.env.example
CHANGED
|
@@ -178,10 +178,10 @@ CACHE_TTL=300000
|
|
|
178
178
|
#CACHE_REDIS_URL=redis://localhost:6379
|
|
179
179
|
|
|
180
180
|
# SQLite configuration (for sqlite strategy)
|
|
181
|
-
CACHE_SQLITE_PATH
|
|
181
|
+
CACHE_SQLITE_PATH=./.mercato/cache/cache.db
|
|
182
182
|
|
|
183
183
|
# JSON file configuration (for jsonfile strategy)
|
|
184
|
-
#CACHE_JSON_FILE_PATH
|
|
184
|
+
#CACHE_JSON_FILE_PATH=./.mercato/cache/cache.json
|
|
185
185
|
|
|
186
186
|
# Database pooling settings
|
|
187
187
|
DB_POOL_MIN=5
|
|
@@ -55,9 +55,9 @@ const {
|
|
|
55
55
|
stripAnsi,
|
|
56
56
|
wrapListLines,
|
|
57
57
|
} = await import(resolveSplashHelpersImport())
|
|
58
|
-
const { resolveSpawnCommand } = await import(resolveSpawnUtilsImport())
|
|
58
|
+
const { resolveProjectBinary, resolveSpawnCommand } = await import(resolveSpawnUtilsImport())
|
|
59
59
|
|
|
60
|
-
const command = process.platform === 'win32' ? 'mercato.cmd' : 'mercato'
|
|
60
|
+
const command = resolveProjectBinary(process.platform === 'win32' ? 'mercato.cmd' : 'mercato')
|
|
61
61
|
const classic = process.argv.includes('--classic') || isEnabledEnvFlag(process.env.OM_DEV_CLASSIC)
|
|
62
62
|
const verbose = !classic && (process.argv.includes('--verbose') || process.env.MERCATO_DEV_OUTPUT === 'verbose')
|
|
63
63
|
const rawPassthrough = classic || verbose
|
|
@@ -412,10 +412,10 @@ function spawnMercato(args) {
|
|
|
412
412
|
return child
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
function waitForExit(child) {
|
|
415
|
+
function waitForExit(child, label = 'Child process') {
|
|
416
416
|
return new Promise((resolve) => {
|
|
417
417
|
child.on('exit', (code, signal) => {
|
|
418
|
-
resolve({ code, signal })
|
|
418
|
+
resolve({ label, code, signal })
|
|
419
419
|
})
|
|
420
420
|
})
|
|
421
421
|
}
|
|
@@ -441,6 +441,32 @@ function resolveChildExitCode(result, fallback = 1) {
|
|
|
441
441
|
return fallback
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
+
function formatChildExitStatus(result) {
|
|
445
|
+
if (typeof result?.code === 'number') {
|
|
446
|
+
return `exit code ${result.code}`
|
|
447
|
+
}
|
|
448
|
+
if (result?.signal) {
|
|
449
|
+
return `signal ${result.signal}`
|
|
450
|
+
}
|
|
451
|
+
return 'an unknown status'
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function resolveUnexpectedExitCode(result) {
|
|
455
|
+
const exitCode = resolveChildExitCode(result, 1)
|
|
456
|
+
return exitCode === 0 ? 1 : exitCode
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function reportUnexpectedChildExit(result) {
|
|
460
|
+
const message = `❌ ${result?.label ?? 'Child process'} exited unexpectedly with ${formatChildExitStatus(result)}`
|
|
461
|
+
console.error(message)
|
|
462
|
+
rememberRawLog(message)
|
|
463
|
+
publishRuntimeFailure(message, {
|
|
464
|
+
progressCurrent: splashState.progressCurrent >= runtimeProgressCurrent ? splashState.progressCurrent : runtimeProgressCurrent,
|
|
465
|
+
progressLabel: splashState.progressLabel || startupProgress.label,
|
|
466
|
+
failureLines: [...collectRuntimeFailureLines(), message].slice(-10),
|
|
467
|
+
})
|
|
468
|
+
}
|
|
469
|
+
|
|
444
470
|
function joinBaseUrl(baseUrl, pathname) {
|
|
445
471
|
return `${String(baseUrl ?? '').replace(/\/$/, '')}${pathname}`
|
|
446
472
|
}
|
|
@@ -1521,12 +1547,16 @@ async function runClassicRuntime() {
|
|
|
1521
1547
|
|
|
1522
1548
|
const watch = spawnMercato(['generate', 'watch', '--skip-initial'])
|
|
1523
1549
|
const server = spawnMercato(['server', 'dev'])
|
|
1524
|
-
const result = await Promise.race([
|
|
1550
|
+
const result = await Promise.race([
|
|
1551
|
+
waitForExit(watch, 'Generator watch'),
|
|
1552
|
+
waitForExit(server, 'App runtime'),
|
|
1553
|
+
])
|
|
1525
1554
|
if (isGracefulShutdownResult(result)) {
|
|
1526
1555
|
return
|
|
1527
1556
|
}
|
|
1528
1557
|
|
|
1529
|
-
|
|
1558
|
+
reportUnexpectedChildExit(result)
|
|
1559
|
+
shutdown(resolveUnexpectedExitCode(result))
|
|
1530
1560
|
}
|
|
1531
1561
|
|
|
1532
1562
|
if (classic) {
|
|
@@ -1541,7 +1571,11 @@ printRuntimePackagesSummary()
|
|
|
1541
1571
|
const watch = startFilteredChild(['generate', 'watch', '--skip-initial'], 'Generator watch', classifyWatchLine)
|
|
1542
1572
|
const server = startFilteredChild(['server', 'dev'], 'App runtime', classifyServerLine)
|
|
1543
1573
|
|
|
1544
|
-
const result = await Promise.race([
|
|
1574
|
+
const result = await Promise.race([
|
|
1575
|
+
waitForExit(watch, 'Generator watch'),
|
|
1576
|
+
waitForExit(server, 'App runtime'),
|
|
1577
|
+
])
|
|
1545
1578
|
if (!isGracefulShutdownResult(result)) {
|
|
1546
|
-
|
|
1579
|
+
reportUnexpectedChildExit(result)
|
|
1580
|
+
shutdown(resolveUnexpectedExitCode(result))
|
|
1547
1581
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
1
4
|
function isWindowsCmdScript(command, platform = process.platform) {
|
|
2
5
|
return platform === 'win32' && /\.(cmd|bat)$/i.test(String(command))
|
|
3
6
|
}
|
|
@@ -23,6 +26,34 @@ function assertWindowsCmdSafeValue(value, label) {
|
|
|
23
26
|
return stringValue
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
export function resolveProjectBinary(command, options = {}) {
|
|
30
|
+
const safeCommand = assertProcessSafeValue(command, 'Process command')
|
|
31
|
+
const cwd = options.cwd ?? process.cwd()
|
|
32
|
+
const platform = options.platform ?? process.platform
|
|
33
|
+
|
|
34
|
+
if (path.isAbsolute(safeCommand) || safeCommand.includes('/') || safeCommand.includes('\\')) {
|
|
35
|
+
return safeCommand
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const binDir = path.join(cwd, 'node_modules', '.bin')
|
|
39
|
+
const candidates = platform === 'win32'
|
|
40
|
+
? [
|
|
41
|
+
path.join(binDir, safeCommand),
|
|
42
|
+
path.join(binDir, `${safeCommand}.cmd`),
|
|
43
|
+
path.join(binDir, `${safeCommand}.bat`),
|
|
44
|
+
path.join(binDir, `${safeCommand}.exe`),
|
|
45
|
+
]
|
|
46
|
+
: [path.join(binDir, safeCommand)]
|
|
47
|
+
|
|
48
|
+
for (const candidate of candidates) {
|
|
49
|
+
if (fs.existsSync(candidate)) {
|
|
50
|
+
return candidate
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return safeCommand
|
|
55
|
+
}
|
|
56
|
+
|
|
26
57
|
export function resolveSpawnCommand(command, commandArgs = [], options = {}) {
|
|
27
58
|
const platform = options.platform ?? process.platform
|
|
28
59
|
const safeCommand = assertProcessSafeValue(command, 'Process command')
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process'
|
|
2
|
+
import { existsSync } from 'node:fs'
|
|
2
3
|
|
|
3
4
|
const reinstall = process.argv.includes('--reinstall')
|
|
4
5
|
const classic = process.argv.includes('--classic')
|
|
6
|
+
|
|
7
|
+
if (!existsSync('node_modules/cross-spawn')) {
|
|
8
|
+
const bootstrap = spawnSync('yarn', ['install'], {
|
|
9
|
+
stdio: 'inherit',
|
|
10
|
+
shell: process.platform === 'win32',
|
|
11
|
+
})
|
|
12
|
+
if (bootstrap.status !== 0) process.exit(bootstrap.status ?? 1)
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
const result = spawnSync(
|
|
6
16
|
process.execPath,
|
|
7
17
|
['./scripts/dev.mjs', '--setup', ...(reinstall ? ['--reinstall'] : []), ...(classic ? ['--classic'] : [])],
|
|
File without changes
|