Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cardinalby/webext-buildtools-chrome-crx-builder

webext-buildtools builder for packing and signing Chrome Web Extension for offline distribution
https://github.com/cardinalby/webext-buildtools-chrome-crx-builder

Last synced: about 5 hours ago
JSON representation

webext-buildtools builder for packing and signing Chrome Web Extension for offline distribution

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.com/cardinalby/webext-buildtools-chrome-crx-builder.svg?branch=master)](https://travis-ci.com/cardinalby/webext-buildtools-chrome-crx-builder)
### Introduction
*webext-buildtools* builder for packing and signing Chrome Web Extension for offline distribution built
on base of [crx](https://github.com/oncletom/crx) package.

If you need a **complete solution** for Web Extension build/deploy, go to
[webext-buildtools-integrated-builder](https://github.com/cardinalby/webext-buildtools-integrated-builder) repo.

To read what are *webext-buildtools* and *builders* go to
[webext-buildtools-builder-types](https://github.com/cardinalby/webext-buildtools-builder-types) repo.

### Installation
`npm install webext-buildtools-chrome-crx-builder`

### Purpose
Builder allows you to build and sign your Web Extension for offline distribution.
Read more details at [Alternative Extension Distribution Options](https://developer.chrome.com/docs/extensions/mv3/external_extensions/).

### Usage example
```js
const ChromeCrxBuilder = require('webext-buildtools-chrome-crx-builder').default;
const fs = require('fs-extra');

const options = { ... }; // see description below
const logMethod = console.log;
const builder = new ChromeCrxBuilder(options, logMethod);

// if you omit manifest it will be extracted from the zip buffer
builder.setInputManifest(await fs.readJson('./ext_dir/manifest.json'))
builder.setInputZipBuffer(await fs.readFile('./packed.zip'));

builder.requireCrxFile();
builder.requireUpdateXmlFile();

const buildResult = await builder.build();
```

### Options
Options object described in [declarations/options.d.ts](declarations/options.d.ts)

[See](https://github.com/cardinalby/webext-buildtools-integrated-builder/blob/master/logMethod.md) how to get `logMethod` for pretty output.

### Inputs
1. **`setInputManifest(...)`**. Object with parsed extension's `package.json`.
Required to produce `update.xml` file. If omitted, will be extracted from zip buffer.
2. **`setInputZipBuffer(...)`**. Buffer with zipped extension dir. Required to produce packed `crx` file

You can use [webext-buildtools-dir-reader-mw](https://www.npmjs.com/package/webext-buildtools-dir-reader-mw)
to generate needed inputs from extension directory.

### Outputs
#### crx
packed and signed (using private key specified in options) crx file

*Required options:* `privateKey` or `privateKeyFilePath`, `crxFilePath` for file

*Require methods:* `requireCrxFile()`, `requireCrxBuffer()`

*Assets:*

`const buffer = buildResult.getAssets().crxBuffer.getValue()`

`const crxFilePath = buildResult.getAssets().crxFile.getValue()`

#### update.xml
updateXML for extensions hosted not on Chrome Web Store. This xml is used as response
at url, specified in manifest's `update_url` key.
See [https://developer.chrome.com/docs/apps/autoupdate/#update_url](https://developer.chrome.com/docs/apps/autoupdate/#update_url)
for details.

*Required options:* `updateXml.outFilePath` (for not temporary file), `updateXml.codebaseUrl`

*Require methods:* `requireUpdateXmlFile()`, `requireUpdateXmlBuffer()`

*Assets:*

`const buffer = buildResult.getAssets().updateXmlBuffer.getValue()`

`const xmlFilePath = buildResult.getAssets().updateXmlFile.getValue()`