Fix/multiple build target#10
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds npm packaging + install-time staging to support distributing a native SEA-built cmdly binary, and updates the release workflow to use versioned asset names.
Changes:
- Add a
prepackstaging script to copy the default binary into./bin/cmdly. - Add a
postinstallscript intended to swap in the correct platform binary fromdist/<target>/cmdly. - Update
package.jsonmetadata/scripts for publishing and update the release workflow’s artifact naming.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
scripts/stage-default-bin.mjs |
Stages dist/linux-x64/cmdly into bin/cmdly prior to packing/publishing. |
scripts/postinstall.mjs |
Installs the target-specific binary into bin/cmdly at install time. |
package.json |
Adds bin mapping + files allowlist; adjusts build/staging/publish scripts. |
.github/workflows/release.yml |
Uses pnpm build and versioned asset names for release artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+47
to
+52
| if (!target) { | ||
| console.warn( | ||
| `[postinstall] skipping unsupported target ${process.platform}-${process.arch}; supported: ${supportedTargets.join(", ")}`, | ||
| ); | ||
| return; | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| const __dirname = dirname(__filename); | ||
| const rootDir = resolve(__dirname, ".."); | ||
|
|
||
| const source = join(rootDir, "dist", "linux-x64", "cmdly"); |
Comment on lines
+12
to
+20
| const run = (cmd, args, opts) => { | ||
| const result = spawnSync(cmd, args, { | ||
| cwd: rootDir, | ||
| stdio: "inherit", | ||
| ...opts, | ||
| }); | ||
| if (result.status !== 0) { | ||
| process.exit(result.status ?? 1); | ||
| } |
|
|
||
| run("pnpm", ["build"]); | ||
| run("pnpm", ["stage:bin"]); | ||
| run("pnpm", ["vitest"]); |
Comment on lines
+63
to
+64
| const sourcePath = join(packageRoot, "dist", target, "cmdly"); | ||
| installBinary(sourcePath); |
Comment on lines
+24
to
+31
| "bin": { | ||
| "cmdly": "./bin/cmdly" | ||
| }, | ||
| "files": [ | ||
| "bin/cmdly", | ||
| "dist", | ||
| "scripts/postinstall.mjs" | ||
| ], |
Comment on lines
+9
to
+16
| const source = join(rootDir, "dist", "linux-x64", "cmdly"); | ||
| const targetDir = join(rootDir, "bin"); | ||
| const target = join(targetDir, "cmdly"); | ||
|
|
||
| mkdirSync(targetDir, { recursive: true }); | ||
| rmSync(target, { force: true }); | ||
| copyFileSync(source, target); | ||
| chmodSync(target, 0o755); |
Comment on lines
+63
to
+77
| const sourcePath = join(packageRoot, "dist", target, "cmdly"); | ||
| installBinary(sourcePath); | ||
|
|
||
| console.log(`[postinstall] installed ${target} binary`); | ||
| }; | ||
|
|
||
| try { | ||
| main(); | ||
| } catch (error) { | ||
| const target = detectTarget(); | ||
| const message = error instanceof Error ? error.message : String(error); | ||
|
|
||
| if (target) { | ||
| console.error(`[postinstall] native install failed for ${target}: ${message}`); | ||
| process.exit(1); |
Comment on lines
+36
to
+38
| const savedDevEnginesPackageManager = JSON.parse( | ||
| JSON.stringify(pkg.devEngines?.packageManager), | ||
| ); |
Comment on lines
+40
to
+55
| original.scripts.postinstall = "node scripts/postinstall.mjs"; | ||
| original.packageManager = `npm@${npmVersion}`; | ||
| if (original.devEngines) { | ||
| original.devEngines.packageManager = { | ||
| name: "npm", | ||
| version: npmVersion, | ||
| }; | ||
| } | ||
| writeFileSync(pkgPath, `${JSON.stringify(original, null, "\t")}\n`, "utf8"); | ||
|
|
||
| run("pnpm", ["build"]); | ||
| run("pnpm", ["stage:bin"]); | ||
| run("pnpm", ["vitest"]); | ||
| run("changeset", ["publish"]); | ||
| run("changeset", ["tag"]); | ||
| run("git", ["push", "--tags"]); |
| "prepack": "pnpm build && pnpm stage:bin", | ||
| "prepare": "effect-language-service patch", | ||
| "clean": "rm -rf dist .sea", | ||
| "clean": "rm -rf dist", |
| encoding: "utf8", | ||
| stdio: "pipe", | ||
| }); | ||
| return result.stdout.trim(); |
c0deb10 to
3dd19e9
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.