pear-build 1.1.0 → 1.1.2

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.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/index.js +24 -2
  3. package/package.json +23 -8
package/README.md CHANGED
@@ -6,6 +6,14 @@
6
6
  npm install -g pear-build
7
7
  ```
8
8
 
9
+ ## Supported Platforms
10
+
11
+ - Linux: `linux-arm64`, `linux-x64`
12
+ - macOS: `darwin-arm64`, `darwin-x64`
13
+ - Windows: `win32-arm64`, `win32-x64`
14
+ - iOS: `ios-arm64`, `ios-arm64-simulator`, `ios-x64-simulator`
15
+ - Android: `android-arm64`
16
+
9
17
  ## Usage
10
18
 
11
19
  Create a build dir outside the project root.
@@ -28,6 +36,7 @@ node bin.js \
28
36
  --linux-arm64-app ./test/fixtures/hello-pear-electron/out/HelloPear-linux-arm64/HelloPear.AppImage \
29
37
  --linux-x64-app ./test/fixtures/hello-pear-electron/out/HelloPear-linux-x64/HelloPear.AppImage \
30
38
  --win32-x64-app ./test/fixtures/hello-pear-electron/out/HelloPear-win32-x64/HelloPear.msix \
39
+ --win32-arm64-app ./test/fixtures/hello-pear-electron/out/HelloPear-win32-arm64/HelloPear.msix \
31
40
  --ios-arm64 ./test/fixtures/hello-pear-react-native/ota/ios/HelloPear \
32
41
  --ios-arm64-simulator ./test/fixtures/hello-pear-react-native/ota/ios/HelloPear \
33
42
  --ios-x64-simulator ./test/fixtures/hello-pear-react-native/ota/ios/HelloPear \
@@ -68,6 +77,9 @@ my-build
68
77
  │   ├── linux-x64
69
78
  │   │   └── app
70
79
  │   │   └── HelloPear.AppImage
80
+ │   ├── win32-arm64
81
+ │   │   └── app
82
+ │   │   └── HelloPear.msix
71
83
  │   └── win32-x64
72
84
  │   └── app
73
85
  │   └── HelloPear.msix
package/index.js CHANGED
@@ -3,6 +3,7 @@ const path = require('path')
3
3
  const fs = require('fs')
4
4
  const { EventEmitter } = require('events')
5
5
  const Localdrive = require('localdrive')
6
+ const { ERR_NOT_FOUND, ERR_INVALID_INPUT, ERR_INVALID_APP_NAME } = require('pear-errors')
6
7
 
7
8
  class Build extends EventEmitter {
8
9
  constructor(opts) {
@@ -12,8 +13,26 @@ class Build extends EventEmitter {
12
13
  }
13
14
 
14
15
  async run(opts) {
16
+ if (!opts.package) throw ERR_INVALID_INPUT('package.json path must be specified.')
15
17
  const pkgPath = path.resolve(opts.package)
16
- const pkg = require(pkgPath)
18
+
19
+ const pkgFile = await fs.promises.readFile(pkgPath, 'utf8').catch((err) => {
20
+ if (err.code === 'ENOENT') {
21
+ throw ERR_NOT_FOUND('package.json not found', { path: pkgPath, cause: err })
22
+ }
23
+ if (err.code === 'EISDIR') {
24
+ throw ERR_INVALID_INPUT('package.json must be a file', { path: pkgPath, cause: err })
25
+ }
26
+ throw err
27
+ })
28
+
29
+ let pkg
30
+ try {
31
+ pkg = JSON.parse(pkgFile)
32
+ } catch (err) {
33
+ throw ERR_INVALID_INPUT('package.json is not a valid JSON', { path: pkgPath })
34
+ }
35
+
17
36
  const { target = path.resolve(pkg.name + '-' + pkg.version) } = opts
18
37
  const darwinArm64App = opts.darwinArm64App
19
38
  ? ['darwin-arm64', path.resolve(opts.darwinArm64App)]
@@ -66,7 +85,10 @@ class Build extends EventEmitter {
66
85
  const promises = []
67
86
  for (const [arch, app] of apps) {
68
87
  if (path.basename(app, path.extname(app)) !== appName) {
69
- throw new Error(`expected directory ${appName} but got ${path.basename(app)} for ${arch}`)
88
+ throw ERR_INVALID_APP_NAME(
89
+ `expected directory ${appName} but got ${path.basename(app)} for ${arch}`,
90
+ { arch, app }
91
+ )
70
92
  }
71
93
  const archApp = path.join(byArch, arch, 'app')
72
94
  await fs.promises.mkdir(archApp, { recursive: true })
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "pear-build",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "main": "index.js",
5
5
  "type": "commonjs",
6
- "bin": "bin.js",
6
+ "bin": {
7
+ "pear-build": "bin.js"
8
+ },
7
9
  "description": "Create project deployment folder",
8
10
  "author": "Holepunch Inc",
9
11
  "license": "Apache-2.0",
@@ -44,24 +46,37 @@
44
46
  "scripts": {
45
47
  "format": "prettier --write .",
46
48
  "lint": "prettier --check . && lunte",
49
+ "make:test": "brittle-make-test test/all.mjs test/*.test.js",
47
50
  "test": "npm run test:node && npm run test:bare",
48
- "test:bare": "brittle-bare --coverage test/all.js",
49
- "test:node": "brittle-node --coverage test/all.js"
51
+ "test:bare": "brittle-bare --coverage test/all.mjs",
52
+ "test:node": "brittle-node --coverage test/all.mjs"
50
53
  },
51
54
  "dependencies": {
52
55
  "bare-events": "^2.8.2",
53
56
  "bare-fs": "^4.5.3",
54
57
  "bare-path": "^3.0.0",
55
58
  "localdrive": "^2.2.0",
56
- "paparam": "^1.10.0"
59
+ "paparam": "^1.10.0",
60
+ "pear-errors": "^1.0.1"
57
61
  },
58
62
  "devDependencies": {
59
- "bare-fs": "^4.5.3",
60
- "brittle": "^3.19.1",
63
+ "brittle": "^4.0.0",
61
64
  "lunte": "^1.6.0",
62
65
  "mirror-drive": "^1.13.0",
63
66
  "prettier": "^3.7.4",
64
67
  "prettier-config-holepunch": "^2.0.0",
65
68
  "test-tmp": "^1.4.0"
66
- }
69
+ },
70
+ "directories": {
71
+ "test": "test"
72
+ },
73
+ "repository": {
74
+ "type": "git",
75
+ "url": "git+https://github.com/holepunchto/pear-build.git"
76
+ },
77
+ "keywords": [],
78
+ "bugs": {
79
+ "url": "https://github.com/holepunchto/pear-build/issues"
80
+ },
81
+ "homepage": "https://github.com/holepunchto/pear-build#readme"
67
82
  }