Giter Site home page Giter Site logo

publish-browser-extension's Introduction

Publish Browser Extension

Publish an extension to all the extension stores in a single command!

demo.mp4

Features

  • Publish to the Chrome Web Store, Firefox Addon Store, and Edge Addon Store
  • Helper script to generate secrets and configure options
  • Upload sources ZIP to the Firefox Addon Store

Important

You are responsible for uploading and submitting an extension for the first time by hand. publish-browser-extension does not provide tools for creating a new extension.

Install

npm i -D publish-browser-extension
pnpm i -D publish-browser-extension
yarn add -D publish-browser-extension

CLI Usage

To get started, run the init command. It will walk you through generating all the necessary environment variables/CLI flags, saving them to a .env.submit file:

publish-extension init

All CLI flags can be passed as environment variables instead. For example, setting the CHROME_CLIENT_ID environment variable is equivalent to passing --chrome-client-id. Just convert the flag to UPPER_SNAKE_CASE.

Then, just run the submit command, passing the ZIP files you want to submit:

publish-extension \
  --chrome-zip dist/chrome.zip \
  --firefox-zip dist/firefox.zip --firefox-sources-zip dist/sources.zip \
  --edge-zip dist/chrome.zip

publish-extesion will automatically look for a .env.submit file and load it if it exists.

JS Usage

import { publishExtension } from 'publish-browser-extension';

publishExtension({
  dryRun: true,
  chrome: {
    zip: 'dist/chrome.zip',
    extensionId: '<cws-extension-id>',
    clientId: '<gcp-client-id>',
    clientSecret: '<gcp-client-secret>',
    refreshToken: '<gcp-refresh-token>',
    publishTarget: '<default|trustedTesters>',
    skipSubmitReview: false,
  },
  firefox: {
    zip: 'dist/firefox.zip',
    sourcesZip: 'dist/sources.zip',
    extensionId: '<addons-extension-id>',
    jwtIssuer: '<addons-jwt-issuer>',
    jwtSecret: '<addons-jwt-secret>',
    channel: '<listed|unlisted>',
  },
  edge: {
    zip: 'dist/chrome.zip',
    productId: "<edge-product-id>",
    clientId: "<edge-client-id>",
    clientSecret: "<edge-client-secret>",
    accessTokenUrl: "<edge-access-token-url>",
    skipSubmitReview: false,
  },
})
  .then(results => console.log(results))
  .catch(err => console.error(err));

Contributing

Contributor Setup

  1. Install node
  2. Install pnpm
    corepack enable
  3. Install dependencies
    pnpm i
  4. Run the init command to generate a .env.submit file for testing
    pnpm publish-extension init

    [!WARNING]

    Make sure to set the Firefox channel to "unlisted", chrome's publish target to "trustedTesters", and don't submit the extension for review for Chrome or Edge. This will prevent you from accidentally releasing one of the test extensions publically.

  5. Run the dev commands to upload a test extension to the stores:
    pnpm dev:all
    pnpm dev:chrome
    pnpm dev:firefox
    pnpm dev:edge

publish-browser-extension's People

Contributors

aklinker1 avatar hyoban avatar otard95 avatar uncenter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

publish-browser-extension's Issues

Firefox use temp directory to unzip extension for validation

When running web-ext to sign and validate the firefox extension, a directory must be used for the WEB_EXT_SOURCE_DIR.

The extension should create this directory as a temp directory, extract the zip file there, then use that directory for the WEB_EXT_SOURCE_DIR.

Node >=20 support

It says you have to have Node 18 (and npm 8):

"engines": {
"node": "18",
"pnpm": "8"
},

Pardon my ignorance for not knowing why but consider this issue a feature request to support >=20 :)

I noticed it when testing WXT as I saw:

❯ npx wxt@latest init ghdocser
Need to install the following packages:
[email protected]
Ok to proceed? (y) y
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '18', pnpm: '8' },
npm WARN EBADENGINE   current: { node: 'v20.11.0', npm: '10.2.4' }
npm WARN EBADENGINE }

WXT 0.16.4

Error when working with Firefox Addons API

When trying to submit my extension to Firefox Addons I get an error

Reqeust: https://addons.mozilla.org/api/v5/addons/addon/%7Biitc-button-beta%7D
Response: {
  "_data": {
    "detail": "Not found."
  }
}
 ERROR  [GET] "https://addons.mozilla.org/api/v5/addons/addon/%7Biitc-button-beta%7D": 404 Not Found                                                                                                                                                                                                  12:18:03 PM

  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.897a6909.cjs:274:15)
  at async FirefoxAddonStore.submit (node_modules/publish-browser-extension/dist/cli.cjs:3309:19)
  at async Task.task [as taskFn] (node_modules/publish-browser-extension/dist/cli.cjs:3488:11)
  at async Task.run (node_modules/listr2/dist/index.cjs:2143:11)

The wrappedExtensionId method is required to wrap the extension ID in quotes and as stated in the project code, it is required by the API.
But I removed these lines:

    if (id.includes("@"))
      return id;
    if (!id.startsWith("{"))
      id = "{" + id;
    if (!id.endsWith("}"))
      id += "}";

And now the sending of the extension is successful (at least running with the DRY_RUN key)

UP: I had an error in the extension (the version number did not meet the length requirements) and got this error:

› [firefox] Submitting new version
Request: https://addons.mozilla.org/api/v5/addons/addon/iitc-button-beta/versions/
Response: {
  "_data": {
    "upload": [
      "Upload is not valid."
    ]
Error:  [POST] "https://addons.mozilla.org/api/v5/addons/addon/iitc-button-beta/versions/": 400 Bad Request

When trying to submit using web-ext sign I got a more elaborate error log indicating that the error was in the version number. Is it possible for publish-browser-extension to show a detailed error log?

401 unauthorized "Signature has expired." error with Firefox Add-ons

I've been recently getting this Error: [POST] "https://addons.mozilla.org/api/v5/addons/addon/***/versions/": 401 Unauthorized error when attempting to publish to the Firefox Add-ons store, with the response containing "detail": "Signature has expired." - see https://github.com/catppuccin/github-file-explorer-icons/actions/runs/9531192442/job/26271894539, https://github.com/catppuccin/github-file-explorer-icons/actions/runs/9367734622. The first time I got the error was after updating WXT from 0.17.3 to 0.18.4 (catppuccin/github-file-explorer-icons#55, catppuccin/github-file-explorer-icons#59). After reading through the changelog for those releases, the only possibly connected change seems to be wxt-dev/wxt#501, though even that is a stretch. Between the last successful release and the failed one no credentials were changed, though one of the failed releases today was after ensuring those were updated. This might be an issue for WXT itself but seeing as it is only publishing related I thought asking here first might be better.

Specifically report missing configs

export function validateConfig(config: any): InternalConfig {
const result = InternalConfig.safeParse(config);
if (!result.success) {
throw Error('Missing required config', { cause: result.error });

Now it just throws an error, it might be better to pinpoint the missing config.

I am willing to submit a pull request for this change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.