Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/cli/.config/esbuild.cli.build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ const config = {

// Handle special cases with plugins.
plugins: [
unicodeTransformPlugin(),
// Environment variable replacement must run AFTER unicode transform.
envVarReplacementPlugin(inlinedEnvVars),
unicodeTransformPlugin(),
{
name: 'resolve-socket-packages',
setup(build) {
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
"build:watch": "node --max-old-space-size=8192 --import=./scripts/load.mjs scripts/build.mjs --watch",
"restore-cache": "node --import=./scripts/load.mjs scripts/restore-cache.mjs",
"build:sea": "node --max-old-space-size=8192 --import=./scripts/load.mjs scripts/build-sea.mjs",
"build:sea:internal:bootstrap": "node --max-old-space-size=8192 .config/esbuild.sea-bootstrap.build.mjs",
"build:js": "node scripts/build-js.mjs",
"dev:watch": "pnpm run build:watch",
"publish:sea": "node --import=./scripts/load.mjs scripts/publish-sea.mjs",
"check": "node ../../scripts/check.mjs",
"check-ci": "pnpm run check",
"lint": "oxlint -c ../../.oxlintrc.json",
Expand All @@ -52,7 +50,6 @@
"dev:npx": "cross-env SOCKET_CLI_MODE=npx node --experimental-strip-types src/cli-dispatch.mts",
"e2e-tests": "dotenvx -q run -f .env.test -- vitest run --config vitest.e2e.config.mts",
"e2e:js": "node scripts/e2e.mjs --js",
"e2e:smol": "node scripts/e2e.mjs --smol",
"e2e:sea": "node scripts/e2e.mjs --sea",
"e2e:all": "node scripts/e2e.mjs --all",
"test": "run-s check test:*",
Expand Down
16 changes: 12 additions & 4 deletions packages/cli/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ async function main() {
},
)

if (watchResult.code !== 0) {
process.exitCode = watchResult.code
throw new Error(`Watch mode failed with exit code ${watchResult.code}`)
if (!watchResult || watchResult.code !== 0) {
process.exitCode = watchResult?.code ?? 1
throw new Error(`Watch mode failed with exit code ${watchResult?.code ?? 1}`)
}
return
}
Expand Down Expand Up @@ -265,7 +265,7 @@ async function main() {
logger.step('Phase 4: Post-processing (parallel)...')
}

await Promise.all([
const postResults = await Promise.allSettled([
// Copy CLI bundle to dist (required for dist/index.js to work).
(async () => {
copyFileSync('build/cli.js', 'dist/cli.js')
Expand Down Expand Up @@ -297,6 +297,14 @@ async function main() {
})(),
])

const postFailed = postResults.filter(r => r.status === 'rejected')
if (postFailed.length > 0) {
for (const r of postFailed) {
logger.error(`Post-processing failed: ${r.reason?.message ?? r.reason}`)
}
throw new Error('Post-processing step(s) failed')
}

if (!quiet) {
printSuccess('Build completed')
printFooter()
Expand Down
12 changes: 8 additions & 4 deletions packages/cli/scripts/download-assets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,19 @@ ${content}
*/
async function downloadAssets(assetNames, parallel = true) {
if (parallel) {
const results = await Promise.all(
const settled = await Promise.allSettled(
assetNames.map(name => downloadAsset(ASSETS[name])),
)

const failed = results.filter(r => !r.ok)
const failed = settled.filter(
r => r.status === 'rejected' || (r.status === 'fulfilled' && !r.value.ok),
)
if (failed.length > 0) {
logger.error(`\n${failed.length} asset(s) failed:`)
for (const { name } of failed) {
logger.error(` - ${name}`)
for (const r of failed) {
logger.error(
` - ${r.status === 'rejected' ? r.reason?.message ?? r.reason : r.value.name}`,
)
}
process.exitCode = 1
}
Expand Down
10 changes: 6 additions & 4 deletions scripts/download-iocraft-binaries.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,17 @@ async function downloadBinaries(platformFilter = null) {
`Downloading iocraft binaries for ${configs.length} platform(s)...`,
)

const results = await Promise.all(
const settled = await Promise.allSettled(
configs.map(config => downloadIocraftBinary(config)),
)

const failed = results.filter(r => !r.ok)
const failed = settled.filter(
r => r.status === 'rejected' || (r.status === 'fulfilled' && !r.value.ok),
)
if (failed.length > 0) {
logger.error(`\n${failed.length} platform(s) failed:`)
for (const { target } of failed) {
logger.error(` - ${target}`)
for (const r of failed) {
logger.error(` - ${r.status === 'rejected' ? r.reason?.message ?? r.reason : r.value.target}`)
}
return false
}
Expand Down
Loading