### Install @electron/asar Source: https://github.com/electron/asar/blob/main/README.md Install the @electron/asar module using npm. Requires Node 22.12.0 or later. ```bash npm install --engine-strict @electron/asar ``` -------------------------------- ### Asar Header JSON Structure Example Source: https://github.com/electron/asar/blob/main/README.md Provides an example of the JSON structure used for the Asar archive header, detailing file organization and metadata. ```json { "files": { "tmp": { "files": {} }, "usr" : { "files": { "bin": { "files": { "ls": { "offset": "0", "size": 100, "executable": true, "integrity": { "algorithm": "SHA256", "hash": "...", "blockSize": 1024, "blocks": ["...", "..."] } }, "cd": { "offset": "100", "size": 100, "executable": true, "integrity": { "algorithm": "SHA256", "hash": "...", "blockSize": 1024, "blocks": ["...", "..."] } } } } } }, "etc": { "files": { "hosts": { "offset": "200", "size": 32, "integrity": { "algorithm": "SHA256", "hash": "...", "blockSize": 1024, "blocks": ["...", "..."] } } } } } } ``` -------------------------------- ### Create ASAR Package Programmatically Source: https://github.com/electron/asar/blob/main/README.md Create an ASAR archive from a source directory to a destination file using the @electron/asar library. Note: No error handling is provided in this example. ```javascript import { createPackage } from '@electron/asar'; const src = 'some/path/'; const dest = 'name.asar'; await createPackage(src, dest); console.log('done.'); ``` -------------------------------- ### ASAR CLI Usage Help Source: https://github.com/electron/asar/blob/main/README.md Display the help information for the ASAR command-line interface, showing available commands and options. ```bash asar --help ``` -------------------------------- ### Create ASAR Package with Transform Stream Source: https://github.com/electron/asar/blob/main/README.md Create an ASAR archive with options, including a transform function to process files before they are added to the archive. This can be used for compression or other transformations. ```javascript import { createPackageWithOptions } from '@electron/asar'; const src = 'some/path/'; const dest = 'name.asar'; function transform (filename) { return new CustomTransformStream() } await createPackageWithOptions(src, dest, { transform: transform }); console.log('done.'); ``` -------------------------------- ### Exclude Resources from ASAR Pack (Simple) Source: https://github.com/electron/asar/blob/main/README.md Pack files into an ASAR archive while excluding specific top-level directories like 'x1' and 'x2'. ```bash asar pack app app.asar --unpack-dir "{x1,x2}" ``` -------------------------------- ### Asar Archive Format Structure Source: https://github.com/electron/asar/blob/main/README.md Illustrates the high-level structure of an Asar archive, showing the sequence of header size, header, and file data. ```markdown | UInt32: header_size | String: header | Bytes: file1 | ... | Bytes: file42 | ``` -------------------------------- ### Exclude Resources from ASAR Pack (Recursive) Source: https://github.com/electron/asar/blob/main/README.md Pack files into an ASAR archive, excluding directories named 'x1' or 'x2' at any level within the source directory. ```bash asar pack app app.asar --unpack-dir "**/{x1,x2}" ``` -------------------------------- ### Exclude Specific Resources from ASAR Pack Source: https://github.com/electron/asar/blob/main/README.md Pack files into an ASAR archive, excluding specific directories like 'x1', 'x2' at any level, and a specific nested directory 'z4/w1'. ```bash asar pack app app.asar --unpack-dir "{**/x1,**/x2,z4/w1}" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.