balena-image-fs 7.5.4-build-renovate-major-22-node-c1a86c902bc021178b6f5f4f12b4f2d89e3423bb-1 → 7.6.0-build-add-explore-partition-ecb711e7c56f1c2348df5faf45fa3ca8523339bc-1
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/CHANGELOG.md +2 -2
- package/README.md +26 -0
- package/build/index.d.ts +21 -0
- package/build/index.js +44 -3
- package/build/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,9 @@ All notable changes to this project will be documented in this file
|
|
|
4
4
|
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
-
## 7.
|
|
7
|
+
## 7.6.0 - 2026-01-13
|
|
8
8
|
|
|
9
|
-
*
|
|
9
|
+
* Add `explorePartition` function for exploring well-known partitions of a balenaOS image [Matthew Yarmolinsky]
|
|
10
10
|
|
|
11
11
|
## 7.5.3 - 2025-04-09
|
|
12
12
|
|
package/README.md
CHANGED
|
@@ -27,6 +27,19 @@ $ npm install --save balena-image-fs
|
|
|
27
27
|
Documentation
|
|
28
28
|
-------------
|
|
29
29
|
|
|
30
|
+
|
|
31
|
+
* [imagefs](#module_imagefs)
|
|
32
|
+
* [~BalenaPartition](#module_imagefs..BalenaPartition)
|
|
33
|
+
* [~interact()](#module_imagefs..interact)
|
|
34
|
+
* [~explorePartition(imagePath, partitionId, exploreFn)](#module_imagefs..explorePartition) ⇒ <code>T</code>
|
|
35
|
+
|
|
36
|
+
<a name="module_imagefs..BalenaPartition"></a>
|
|
37
|
+
|
|
38
|
+
### imagefs~BalenaPartition
|
|
39
|
+
Values are the base name for a partition on disk
|
|
40
|
+
|
|
41
|
+
**Kind**: inner property of [<code>imagefs</code>](#module_imagefs)
|
|
42
|
+
**Summary**: IDs for the standard balenaOS partitions
|
|
30
43
|
<a name="module_imagefs..interact"></a>
|
|
31
44
|
|
|
32
45
|
### imagefs~interact()
|
|
@@ -39,6 +52,19 @@ const contents = await interact('/foo/bar.img', 5, async (fs) => {
|
|
|
39
52
|
});
|
|
40
53
|
console.log(contents);
|
|
41
54
|
```
|
|
55
|
+
<a name="module_imagefs..explorePartition"></a>
|
|
56
|
+
|
|
57
|
+
### imagefs~explorePartition(imagePath, partitionId, exploreFn) ⇒ <code>T</code>
|
|
58
|
+
**Kind**: inner method of [<code>imagefs</code>](#module_imagefs)
|
|
59
|
+
**Summary**: Allow a provided function to explore the contents of one of the well-known
|
|
60
|
+
partitions of a balenaOS image
|
|
61
|
+
|
|
62
|
+
| Param | Type | Description |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| imagePath | <code>string</code> | pathname of image for search |
|
|
65
|
+
| partitionId | <code>BalenaPartition</code> | partition to find |
|
|
66
|
+
| exploreFn | <code>function</code> | function for exploration |
|
|
67
|
+
|
|
42
68
|
|
|
43
69
|
Support
|
|
44
70
|
-------
|
package/build/index.d.ts
CHANGED
|
@@ -14,3 +14,24 @@ export { findPartition, FindPartitionResult } from './utils';
|
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
16
|
export declare function interact<T>(disk: Disk | string, partition: number | undefined, fn: (fs: typeof Fs) => Promise<T>): Promise<T>;
|
|
17
|
+
/**
|
|
18
|
+
* @summary IDs for the standard balenaOS partitions
|
|
19
|
+
* @description Values are the base name for a partition on disk
|
|
20
|
+
*/
|
|
21
|
+
export declare enum BalenaPartition {
|
|
22
|
+
BOOT = "boot",
|
|
23
|
+
ROOTA = "rootA",
|
|
24
|
+
ROOTB = "rootB",
|
|
25
|
+
STATE = "state",
|
|
26
|
+
DATA = "data"
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @summary Allow a provided function to explore the contents of one of the well-known
|
|
30
|
+
* partitions of a balenaOS image
|
|
31
|
+
*
|
|
32
|
+
* @param {string} imagePath - pathname of image for search
|
|
33
|
+
* @param {BalenaPartition} partitionId - partition to find
|
|
34
|
+
* @param {function(fs): Promise<T>} - function for exploration
|
|
35
|
+
* @returns {T}
|
|
36
|
+
*/
|
|
37
|
+
export declare function explorePartition<T>(imagePath: string, partitionId: BalenaPartition, exploreFn: (fs: typeof Fs) => Promise<T>): Promise<T>;
|
package/build/index.js
CHANGED
|
@@ -15,8 +15,9 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.findPartition = exports.LabelNotFound = exports.getFsLabel = void 0;
|
|
18
|
+
exports.BalenaPartition = exports.findPartition = exports.LabelNotFound = exports.getFsLabel = void 0;
|
|
19
19
|
exports.interact = interact;
|
|
20
|
+
exports.explorePartition = explorePartition;
|
|
20
21
|
/**
|
|
21
22
|
* @module imagefs
|
|
22
23
|
*/
|
|
@@ -27,11 +28,12 @@ const util_1 = require("util");
|
|
|
27
28
|
const file_disk_1 = require("file-disk");
|
|
28
29
|
const partitioninfo = require("partitioninfo");
|
|
29
30
|
const typed_error_1 = require("typed-error");
|
|
31
|
+
const utils_1 = require("./utils");
|
|
30
32
|
var fsLabel_1 = require("./fsLabel");
|
|
31
33
|
Object.defineProperty(exports, "getFsLabel", { enumerable: true, get: function () { return fsLabel_1.getFsLabel; } });
|
|
32
34
|
Object.defineProperty(exports, "LabelNotFound", { enumerable: true, get: function () { return fsLabel_1.LabelNotFound; } });
|
|
33
|
-
var
|
|
34
|
-
Object.defineProperty(exports, "findPartition", { enumerable: true, get: function () { return
|
|
35
|
+
var utils_2 = require("./utils");
|
|
36
|
+
Object.defineProperty(exports, "findPartition", { enumerable: true, get: function () { return utils_2.findPartition; } });
|
|
35
37
|
class MountError extends typed_error_1.TypedError {
|
|
36
38
|
}
|
|
37
39
|
const SECTOR_SIZE = 512;
|
|
@@ -164,4 +166,43 @@ async function interact(disk, partition, fn) {
|
|
|
164
166
|
throw new Error('image must be a String (file path) or a Disk instance');
|
|
165
167
|
}
|
|
166
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* @summary IDs for the standard balenaOS partitions
|
|
171
|
+
* @description Values are the base name for a partition on disk
|
|
172
|
+
*/
|
|
173
|
+
var BalenaPartition;
|
|
174
|
+
(function (BalenaPartition) {
|
|
175
|
+
BalenaPartition["BOOT"] = "boot";
|
|
176
|
+
BalenaPartition["ROOTA"] = "rootA";
|
|
177
|
+
BalenaPartition["ROOTB"] = "rootB";
|
|
178
|
+
BalenaPartition["STATE"] = "state";
|
|
179
|
+
BalenaPartition["DATA"] = "data";
|
|
180
|
+
})(BalenaPartition || (exports.BalenaPartition = BalenaPartition = {}));
|
|
181
|
+
/**
|
|
182
|
+
* @summary Allow a provided function to explore the contents of one of the well-known
|
|
183
|
+
* partitions of a balenaOS image
|
|
184
|
+
*
|
|
185
|
+
* @param {string} imagePath - pathname of image for search
|
|
186
|
+
* @param {BalenaPartition} partitionId - partition to find
|
|
187
|
+
* @param {function(fs): Promise<T>} - function for exploration
|
|
188
|
+
* @returns {T}
|
|
189
|
+
*/
|
|
190
|
+
async function explorePartition(imagePath, partitionId, exploreFn) {
|
|
191
|
+
return await (0, file_disk_1.withOpenFile)(imagePath, 'r', async (handle) => {
|
|
192
|
+
const disk = new file_disk_1.FileDisk(handle, true, false, false);
|
|
193
|
+
const partitionInfo = await partitioninfo.getPartitions(disk, {
|
|
194
|
+
includeExtended: false,
|
|
195
|
+
getLogical: true,
|
|
196
|
+
});
|
|
197
|
+
const findResult = await (0, utils_1.findPartition)(disk, partitionInfo, [
|
|
198
|
+
`resin-${partitionId}`,
|
|
199
|
+
`flash-${partitionId}`,
|
|
200
|
+
`balena-${partitionId}`,
|
|
201
|
+
]);
|
|
202
|
+
if (findResult == null) {
|
|
203
|
+
throw new Error(`Can't find partition for ${partitionId}`);
|
|
204
|
+
}
|
|
205
|
+
return await interact(disk, findResult.index, exploreFn);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
167
208
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;EAcE;;;AAmLF,4BAeC;AAuBD,4CAuBC;AA9OD;;GAEG;AAEH,iCAAiC;AACjC,+BAA+B;AAC/B,yBAAyB;AACzB,+BAAiC;AACjC,yCAAyD;AACzD,+CAA+C;AAC/C,6CAAyC;AACzC,mCAAwC;AAExC,qCAAqD;AAA5C,qGAAA,UAAU,OAAA;AAAE,wGAAA,aAAa,OAAA;AAClC,iCAA4D;AAAnD,sGAAA,aAAa,OAAA;AAEtB,MAAM,UAAW,SAAQ,wBAAU;CAAG;AAEtC,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,KAAK,UAAU,QAAQ,CACtB,IAAU,EACV,MAAc,EACd,IAAY,EACZ,EAAiC;IAEjC,SAAS,cAAc,CAAC,MAAc;QACrC,OAAO,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,CAAC;IACD,MAAM,GAAG,GAAG,KAAK,CAAC,gBAAgB,CAAC;QAClC,UAAU,EAAE,WAAW;QACvB,UAAU,EAAE,IAAI,GAAG,WAAW;QAC9B,WAAW,EAAE,KAAK,EACjB,MAAc,EACd,IAAY,EACZ,QAIS,EACO,EAAE;YAClB,IAAI,CAAC;gBACJ,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAC5C,IAAI,EACJ,CAAC,EACD,IAAI,CAAC,MAAM,EACX,cAAc,CAAC,MAAM,CAAC,CACtB,CAAC;gBACF,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YACnC,CAAC;YAAC,OAAO,CAAM,EAAE,CAA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AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "balena-image-fs",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0-build-add-explore-partition-ecb711e7c56f1c2348df5faf45fa3ca8523339bc-1",
|
|
4
4
|
"description": "Image filesystem manipulation utilities",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"homepage": "https://github.com/balena-io-modules/balena-image-fs",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@balena/lint": "^9.1.6",
|
|
42
42
|
"@types/mocha": "^10.0.1",
|
|
43
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^20.0.0",
|
|
44
44
|
"@types/tmp": "^0.2.3",
|
|
45
45
|
"jsdoc-to-markdown": "^9.0.0",
|
|
46
46
|
"mocha": "^11.0.0",
|
|
@@ -59,6 +59,6 @@
|
|
|
59
59
|
"node": ">=16"
|
|
60
60
|
},
|
|
61
61
|
"versionist": {
|
|
62
|
-
"publishedAt": "
|
|
62
|
+
"publishedAt": "2026-01-13T16:13:10.194Z"
|
|
63
63
|
}
|
|
64
64
|
}
|