Skip to content

Commit b3f9ab2

Browse files
committed
feat(build): add --platform and --arch flags for consistency
Add support for --platform and --arch flags to root build script to match node-sea-builder syntax, while maintaining backward compatibility with --target combined syntax. Changes: - Add --platform and --arch flag parsing - Support both syntaxes: --target darwin-arm64 OR --platform darwin --arch arm64 - Update help text and documentation - Update README.md and docs/build/README.md with both syntaxes Benefits: - Consistent with node-sea-builder flags - Flexibility for users (choose preferred syntax) - Backward compatible (--target still works)
1 parent 97e8b2a commit b3f9ab2

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,11 @@ pnpm run build --target cli
178178
# Build SEA binary
179179
pnpm run build --target sea
180180

181-
# Build specific platform binary
181+
# Build specific platform binary (combined syntax)
182182
pnpm run build --target darwin-arm64
183+
184+
# Build specific platform binary (separate flags - matches node-sea-builder)
185+
pnpm run build --platform darwin --arch arm64
183186
```
184187

185188
#### Multiple target builds

docs/build/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ The Socket CLI build system builds packages in this order:
4949
| `pnpm build` | Smart build with caching (skips unchanged packages) |
5050
| `pnpm build --force` | Force rebuild everything |
5151
| `pnpm build --target <name>` | Build specific target (see targets below) |
52+
| `pnpm build --platform <p> --arch <a>` | Build specific platform/arch (matches node-sea-builder syntax) |
5253
| `pnpm build --targets <t1,t2,...>` | Build multiple targets |
5354
| `pnpm build --platforms` | Build all platform binaries (8 platforms) |
5455
| `pnpm build --platforms --parallel` | Build platforms in parallel (faster) |
@@ -97,6 +98,12 @@ Available targets for `pnpm build --target <name>`:
9798
# Build just the CLI
9899
pnpm build --target cli
99100

101+
# Build for specific platform (combined syntax)
102+
pnpm build --target darwin-arm64
103+
104+
# Build for specific platform (separate flags - matches node-sea-builder)
105+
pnpm build --platform darwin --arch arm64
106+
100107
# Build multiple targets
101108
pnpm build --targets cli,sea
102109

scripts/build.mjs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ function parseArgs() {
9999
let parallel = false
100100
let force = false
101101
let help = false
102+
let platform = null
103+
let arch = null
102104
const buildArgs = []
103105

104106
for (let i = 0; i < args.length; i++) {
@@ -107,6 +109,14 @@ function parseArgs() {
107109
target = args[++i]
108110
} else if (arg === '--targets' && i + 1 < args.length) {
109111
targets = args[++i].split(',').map(t => t.trim())
112+
} else if (arg === '--platform' && i + 1 < args.length) {
113+
platform = args[++i]
114+
} else if (arg.startsWith('--platform=')) {
115+
platform = arg.split('=')[1]
116+
} else if (arg === '--arch' && i + 1 < args.length) {
117+
arch = args[++i]
118+
} else if (arg.startsWith('--arch=')) {
119+
arch = arg.split('=')[1]
110120
} else if (arg === '--platforms') {
111121
platforms = true
112122
} else if (arg === '--parallel') {
@@ -120,7 +130,12 @@ function parseArgs() {
120130
}
121131
}
122132

123-
return { buildArgs, force, help, parallel, platforms, target, targets }
133+
// If --platform and --arch are provided, combine them into target.
134+
if (platform && arch) {
135+
target = `${platform}-${arch}`
136+
}
137+
138+
return { arch, buildArgs, force, help, parallel, platform, platforms, target, targets }
124139
}
125140

126141
/**
@@ -134,6 +149,7 @@ function showHelp() {
134149
logger.log(' pnpm run build # Smart build (skips unchanged)')
135150
logger.log(' pnpm run build --force # Force rebuild all')
136151
logger.log(' pnpm run build --target <name> # Build specific target')
152+
logger.log(' pnpm run build --platform <p> --arch <a> # Build specific platform/arch')
137153
logger.log(' pnpm run build --targets <t1,t2,...> # Build multiple targets')
138154
logger.log(' pnpm run build --platforms # Build all platform binaries')
139155
logger.log(' pnpm run build --platforms --parallel # Build platforms in parallel')

0 commit comments

Comments
 (0)