Application builder for Bare
npm install bare-buildApplication builder for Bare that allows developers to package their JavaScript code as either native application bundles or standalone executables for both desktop and mobile.
```
npm i [-g] bare-build
`js
const build = require('bare-build')
for await (const resource of build('/path/to/app.js', {
base: '/path/to/',
hosts: ['darwin-arm64', 'darwin-x64'],
icon: 'icon.icns',
identifier: 'com.example.App'
})) {
console.log(resource)
}
`
`console`
bare-build \
--host darwin-arm64 --host darwin-x64 \
--icon icon.icns \
--identifier com.example.App \
app.js
| Platform | Unpackaged | --package | --standalone |.AppDir
| :------- | :------------------------- | :---------- | :------------------------------------------------------------ |
| Linux | , Snap compatible | .AppImage | ELF executable with self-extracting .so libraries |.apk
| Android | | .aab | ELF executable with self-extracting .so libraries |.app
| macOS | | .pkg | Mach-O executable with self-extracting .framework libraries |.app
| iOS | | .pkg | Mach-O executable with self-extracting .framework libraries |.msix
| Windows | Plain directory | | PE executable with self-extracting .dll libraries |
bare-build ships with portable runtimes for all supported systems. Similarly to the bare CLI, the portable runtimes are designed to run only the I/O event loop of Bare and they're therefore mostly suited for standalone CLI applications. That's why we refer to them as portable; the same code will run the same way across all systems. For developing native GUI applications, however, the portable runtimes fall short as such applications require tight integration with the native event loop of the corresponding system, such as [CFRunLoop][cfrunloop] in Core Foundation or [Looper][looper] in Android. These applications must instead use a native runtime designed specifically for the system on which they're run.
[cfrunloop]: https://developer.apple.com/documentation/corefoundation/cfrunloop
[looper]: https://developer.android.com/reference/android/os/Looper
For that purpose, an alternative runtime can be specified via the runtime option or the --runtime flag. As with the portable runtimes, we maintain native runtimes for all supported systems.
| Platform | Runtime | API | CLI |
| :------- | :---------------------------------------------------------- | :-------------------------------- | :------------------------------- |
| Linux | bare-gtk | runtime: 'bare-gtk/runtime' | --runtime bare-gtk/runtime |runtime: 'bare-ndk/runtime'
| Android | bare-ndk | | --runtime bare-ndk/runtime |runtime: 'bare-app-kit/runtime'
| macOS | bare-app-kit | | --runtime bare-app-kit/runtime |runtime: 'bare-ui-kit/runtime'
| iOS | bare-ui-kit | | --runtime bare-ui-kit/runtime |runtime: 'bare-win-ui/runtime'
| Windows | bare-win-ui | | --runtime bare-win-ui/runtime |
#### for await (const resource of build(entry[, preflight][, options]))
Options include:
`js
options = {
name: pkg.name,
version: pkg.version,
author: pkg.author,
description: pkg.description,
icon,
identifier,
manifest,
resources,
base: '.',
hosts: [],
out: '.',
runtime,
standalone: false,
package: false,
sign: false,
// Apple signing options
identity: 'Apple Development',
applicationIdentity: identity,
installerIdentity: identity,
keychain,
entitlements,
hardenedRuntime: false,
// Windows signing options
subject,
subjectName,
thumbprint,
// Linux signing options
key,
// Android signing options
keystore,
keystoreKey,
keystorePassword
}
`
#### bare-build [flags]
Flags include:
`console``
--version|-v Print the current version
--name|-n
--author
--description
--icon|-i
--identifier
--manifest
--resources
--base
--host
--out|-o
--runtime
--standalone Build a standalone executable
--package Package the application for distribution
--sign Sign the application
--identity
--application-identity
--installer-identity
--keychain
--entitlements
--hardened-runtime Enable the macOS hardened runtime
--subject
--subject-name
--thumbprint
--key
--keystore
--keystore-key
--keystore-password
--help|-h Show help
Apache-2.0