-
Notifications
You must be signed in to change notification settings - Fork 37
Add support for distributing prebuilds as platform-specific packages #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kriszyp
wants to merge
10
commits into
prebuild:master
Choose a base branch
from
kriszyp:optional-packages
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2de10c6
Add support for creating prebuild directories that can be published a…
kriszyp 1402100
lint fixes
kriszyp 8ba2bc0
Add documentation on using the optional platform-specific packages
kriszyp 4269a27
Copy more useful package metadata
kriszyp f9fa455
Throw an error on attempts to use optional packages with multi-arch
kriszyp 7eccd86
Add scoped package name if package is unscoped, #63
kriszyp 037151b
Apply suggestions from code review
kriszyp 078095b
Switch from optional-packages to platform-packages
kriszyp 5a884d5
Try using npm package for prebuildify fork
kriszyp 21a0b8c
Update node-abi
kriszyp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,13 @@ function prebuildify (opts, cb) { | |
| if (opts.arch === 'ia32' && opts.platform === 'linux' && opts.arch !== os.arch()) { | ||
| opts.env.CFLAGS = '-m32' | ||
| } | ||
| var packageData | ||
| if (opts.optionalPackages) { | ||
| if (opts.arch.indexOf('+') > -1) { | ||
| throw new Error('Optional packages do not support multi-arch values') | ||
| } | ||
| packageData = JSON.parse(fs.readFileSync(path.join(opts.cwd, 'package.json'))) | ||
| } | ||
|
|
||
| // Since [email protected] npm adds its bundled node-gyp to PATH, taking precedence | ||
| // over the local .bin folder. Counter that by (again) adding .bin to PATH. | ||
|
|
@@ -71,7 +78,26 @@ function prebuildify (opts, cb) { | |
| if (err) return cb(err) | ||
| loop(opts, function (err) { | ||
| if (err) return cb(err) | ||
|
|
||
| if (opts.optionalPackages) { | ||
| var packageName = packageData.name | ||
| var description = 'Platform specific binary for ' + packageName + ' on ' + opts.platform + ' OS with ' + opts.arch + ' architecture' | ||
| fs.writeFileSync(path.join(opts.builds, 'package.json'), JSON.stringify({ | ||
| // append platform, and prefix with scoped name matching package name if unscoped | ||
| name: (packageName[0] === '@' ? '' : '@' + packageName + '/') + packageName + '-' + opts.platform + '-' + opts.arch, | ||
| version: packageData.version, | ||
| os: [opts.platform], | ||
| cpu: [opts.arch], | ||
| // copy some of the useful package metadata, if any of these are missing, should just be skipped when stringified | ||
| license: packageData.license, | ||
| author: packageData.author, | ||
| repository: packageData.repository, | ||
| bugs: packageData.bugs, | ||
| homepage: packageData.homepage, | ||
| description | ||
| }, null, 2)) | ||
vweevers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fs.writeFileSync(path.join(opts.builds, 'index.js'), '') // needed to resolve package | ||
| fs.writeFileSync(path.join(opts.builds, 'README.md'), description) | ||
| } | ||
| if (opts.artifacts) return copyRecursive(opts.artifacts, opts.builds, cb) | ||
| return cb() | ||
| }) | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.