bare-build 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -63,7 +63,12 @@ options = {
63
63
  thumbprint,
64
64
 
65
65
  // Linux signing options
66
- key
66
+ key,
67
+
68
+ // Android signing options
69
+ keystore,
70
+ keystoreKey,
71
+ keystorePassword
67
72
  }
68
73
  ```
69
74
 
@@ -74,29 +79,32 @@ options = {
74
79
  Flags include:
75
80
 
76
81
  ```console
77
- --version|-v Print the current version
78
- --name|-n <name> The application name
79
- --author <name> The name of the application author
80
- --description <text> The description of the application
81
- --icon|-i <path> The application icon
82
- --identifier <id> The unique application identifier
83
- --target|-t <host> The host to target
84
- --out|-o <dir> The output directory
85
- --runtime <specifier> The runtime to use
86
- --standalone Build a standalone executable
87
- --package Package the application for distribution
88
- --sign Sign the application
89
- --identity <id> The macOS signing identity
90
- --application-identity <id> The macOS application signing identity
91
- --installer-identity <id> The macOS installer signing identity
92
- --keychain <name> The macOS signing keychain
93
- --entitlements <path> The macOS signing entitlements
94
- --hardened-runtime Enable the macOS hardened runtime
95
- --subject <id> The Windows signing subject
96
- --subject-name <name> The Windows signing subject friendly name
97
- --thumbprint <sha1> The Windows signing subject thumbprint
98
- --key <hash> The GPG signing key
99
- --help|-h Show help
82
+ --version|-v Print the current version
83
+ --name|-n <name> The application name
84
+ --author <name> The name of the application author
85
+ --description <text> The description of the application
86
+ --icon|-i <path> The application icon
87
+ --identifier <id> The unique application identifier
88
+ --target|-t <host> The host to target
89
+ --out|-o <dir> The output directory
90
+ --runtime <specifier> The runtime to use
91
+ --standalone Build a standalone executable
92
+ --package Package the application for distribution
93
+ --sign Sign the application
94
+ --identity <id> The macOS signing identity
95
+ --application-identity <id> The macOS application signing identity
96
+ --installer-identity <id> The macOS installer signing identity
97
+ --keychain <name> The macOS signing keychain
98
+ --entitlements <path> The macOS signing entitlements
99
+ --hardened-runtime Enable the macOS hardened runtime
100
+ --subject <id> The Windows signing subject
101
+ --subject-name <name> The Windows signing subject friendly name
102
+ --thumbprint <sha1> The Windows signing subject thumbprint
103
+ --key <hash> The GPG signing key
104
+ --keystore <path> The Java-based keystore file
105
+ --keystore-key <name> The name of the certificate to use from the keystore
106
+ --keystore-password <password> The password to the keystore file
107
+ --help|-h Show help
100
108
  ```
101
109
 
102
110
  ## License
package/bin.js CHANGED
@@ -31,6 +31,9 @@ const cmd = command(
31
31
  flag('--subject-name <name>', 'The Windows signing subject friendly name'),
32
32
  flag('--thumbprint <sha1>', 'The Windows signing subject thumbprint'),
33
33
  flag('--key <hash>', 'The GPG signing key'),
34
+ flag('--keystore <path>', 'The Java-based keystore file'),
35
+ flag('--keystore-key <name>', 'The name of the certificate to use from the keystore'),
36
+ flag('--keystore-password <password>', 'The password to the keystore file'),
34
37
  async (cmd) => {
35
38
  const { entry, preflight } = cmd.args
36
39
  let {
@@ -55,7 +58,10 @@ const cmd = command(
55
58
  subject,
56
59
  subjectName,
57
60
  thumbprint,
58
- key
61
+ key,
62
+ keystore,
63
+ keystoreKey,
64
+ keystorePassword
59
65
  } = cmd.flags
60
66
 
61
67
  if (version) return console.log(`v${pkg.version}`)
@@ -82,7 +88,10 @@ const cmd = command(
82
88
  subject,
83
89
  subjectName,
84
90
  thumbprint,
85
- key
91
+ key,
92
+ keystore,
93
+ keystoreKey,
94
+ keystorePassword
86
95
  })) {
87
96
  }
88
97
  } catch (err) {
package/index.js CHANGED
@@ -82,6 +82,12 @@ module.exports = async function* build(entry, preflight = null, opts = {}) {
82
82
  case 'ios-x64-simulator':
83
83
  platform = require('./lib/platform/apple')
84
84
  break
85
+ case 'android-arm64':
86
+ case 'android-arm':
87
+ case 'android-ia32':
88
+ case 'android-x64':
89
+ platform = require('./lib/platform/android')
90
+ break
85
91
  case 'linux-arm64':
86
92
  case 'linux-x64':
87
93
  platform = require('./lib/platform/linux')
@@ -0,0 +1,144 @@
1
+ const path = require('path')
2
+ const link = require('bare-link')
3
+ const fs = require('../fs')
4
+ const prebuilds = require('../prebuilds')
5
+
6
+ module.exports = async function* android(base, bundle, preflight, opts = {}) {
7
+ const { createAppBundle, createAPK, constants } = require('bare-apk') // Optional
8
+
9
+ const {
10
+ hosts = [],
11
+ name,
12
+ identifier = toIdentifier(name),
13
+ minimumSDK = constants.DEFAULT_MINIMUM_SDK,
14
+ targetSDK = constants.DEFAULT_TARGET_SDK,
15
+ runtime = { prebuilds },
16
+ standalone = false,
17
+ package = false,
18
+ out = '.'
19
+ } = opts
20
+
21
+ if (standalone) {
22
+ throw new Error('Standalone mode is not supported for Android')
23
+ }
24
+
25
+ const archs = new Map()
26
+
27
+ for (const host of hosts) {
28
+ let arch
29
+
30
+ switch (host) {
31
+ case 'android-arm64':
32
+ arch = 'arm64-v8a'
33
+ break
34
+ case 'android-arm':
35
+ arch = 'armeabi-v7a'
36
+ break
37
+ case 'android-ia32':
38
+ arch = 'x86'
39
+ break
40
+ case 'android-x64':
41
+ arch = 'x86_64'
42
+ break
43
+ default:
44
+ throw new Error(`Unknown host '${host}'`)
45
+ }
46
+
47
+ archs.set(arch, host)
48
+ }
49
+
50
+ const temp = []
51
+
52
+ try {
53
+ const build = await fs.tempDir()
54
+
55
+ temp.push(build)
56
+
57
+ const lib = path.join(build, 'lib')
58
+ await fs.makeDir(lib)
59
+
60
+ const assets = path.join(build, 'assets')
61
+ await fs.makeDir(assets)
62
+
63
+ const classes = path.join(build, 'dex')
64
+ await fs.makeDir(classes)
65
+
66
+ yield* link(base, { ...opts, hosts, out: lib })
67
+
68
+ for (const [arch, host] of archs) {
69
+ const prebuild = runtime.prebuilds[host]()
70
+
71
+ try {
72
+ for await (const file of await fs.openDir(
73
+ path.resolve(prebuild, '..', path.basename(prebuild, '.so').replace(/^lib/, ''))
74
+ )) {
75
+ switch (path.extname(file.name)) {
76
+ case '.so': {
77
+ const so = path.join(lib, arch, file.name)
78
+ await fs.copyFile(path.join(file.parentPath, file.name), so)
79
+ yield so
80
+ break
81
+ }
82
+ case '.dex': {
83
+ const dex = path.join(classes, file.name)
84
+ await fs.copyFile(path.join(file.parentPath, file.name), dex)
85
+ yield dex
86
+ break
87
+ }
88
+ }
89
+ }
90
+ } catch (err) {
91
+ if (err.code !== 'ENOENT') throw err
92
+ }
93
+
94
+ const so = path.join(lib, arch, path.basename(prebuild))
95
+ await fs.copyFile(prebuild, so)
96
+ yield so
97
+ }
98
+
99
+ const appBundle = path.join(assets, 'app.bundle')
100
+ await fs.writeFile(appBundle, bundle.toBuffer())
101
+ yield appBundle
102
+
103
+ const appManifest = path.join(build, 'AndroidManifest.xml')
104
+ await fs.writeFile(appManifest, createAndroidManifest(name, identifier, minimumSDK, targetSDK))
105
+ yield appManifest
106
+
107
+ const aab = path.join(package ? out : build, name + '.aab')
108
+ await createAppBundle(appManifest, aab, { include: [lib, assets, classes] })
109
+ yield aab
110
+
111
+ if (package) return [aab]
112
+
113
+ const apk = path.join(out, name + '.apk')
114
+ await createAPK(aab, apk, opts)
115
+ yield apk
116
+
117
+ return [apk]
118
+ } finally {
119
+ for (const dir of temp) await fs.rm(dir)
120
+ }
121
+ }
122
+
123
+ function createAndroidManifest(name, identifier, minimumSDK, targetSDK) {
124
+ return `\
125
+ <?xml version="1.0" encoding="utf-8"?>
126
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="${identifier}">
127
+ <uses-sdk android:minSdkVersion="${minimumSDK}" android:targetSdkVersion="${targetSDK}" />
128
+ <uses-permission android:name="android.permission.INTERNET" />
129
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
130
+ <application android:label="${name}" android:hasCode="true" android:usesCleartextTraffic="true">
131
+ <activity android:name="to.holepunch.bare.Activity" android:exported="true">
132
+ <intent-filter>
133
+ <action android:name="android.intent.action.MAIN" />
134
+ <category android:name="android.intent.category.LAUNCHER" />
135
+ </intent-filter>
136
+ </activity>
137
+ </application>
138
+ </manifest>
139
+ `
140
+ }
141
+
142
+ function toIdentifier(input) {
143
+ return input.replace(/[^a-z0-9_]+/gi, '_')
144
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-build",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Application builder for Bare",
5
5
  "exports": {
6
6
  "./package": "./package.json",
@@ -68,7 +68,8 @@
68
68
  "require-asset": "^1.1.0"
69
69
  },
70
70
  "optionalDependencies": {
71
- "bare-app-image": "^0.0.0"
71
+ "bare-apk": "^0.1.1",
72
+ "bare-app-image": "^0.1.0"
72
73
  },
73
74
  "devDependencies": {
74
75
  "bare-bundle": "^1.10.0",