0.6.1 • Published 5 years ago

@bumble/manifest v0.6.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@bumble/manifest

Derive the manifest of a Chrome extension from a package.json and the extension's script files.

Install

$ npm install @bumble/manifest

Usage

import fs from 'fs'
import {
  derivePermissions,
  deriveManifest
} from '@bumble/manifest'
import pkg from './package.json'
import mani from './extension/manifest.json'

// Permissions are optional
const backgroundPage = './extension/background.js'
const code = fs.readFileSync(backgroundPage)
const permissions = derivePermissions(code)

const manifest = deriveManifest(pkg, mani, permissions)

No manifest? Just omit it.

const manifest = deriveManifest(pkg, permittions)

This manifest won't have any entry points (no background page, no content scripts).

API

derivePermissions(code)

code

Type: string

Contents of the JavaScript file from which to derive permissions.

deriveManifest(pkg, manifest, permissions)

pkg

Type: Object

The contents of package.json. Name, version, description, and author will be used.

manifest

Type: Object

Any data included here will overwrite data derived from package.json.

This argument is optional, but if omitted, the derived manifest will not have any entry points (no background page, no content scripts). See How Much Manifest Do I Need? for more info.

permissions

Type: Array<string>

Permissions in addition to manifest.permissions. The final manifest.permissions array will be flattened and deduped.

How Much Manifest Do I Need?

Just your entry points! Something like this will work:

{
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  }
}

Or this:

{
  "content_scripts": [
    {
      "matches": ["http://*.nytimes.com/*"],
      "css": ["myStyles.css"],
      "js": ["contentScript.js"]
    }
  ]
}

License

MIT © jacksteamdev

0.6.1

5 years ago

0.6.0

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago