Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

The Repackager

The Repackager is a tiny Cloudflare Worker that fetches a remote ZIP archive, peels off the top-level folder, and returns a ZIP (named after the requested package) that is ready to be installed as a Sublime Text .sublime-package. It retains the repackaged archive in the Workers Cache API. On the first request after ten minutes it conditionally checks the upstream ETag, avoiding another repackaging pass when the archive is unchanged. A transient upstream failure serves the retained archive and delays the next check for another ten minutes.

If the original ZIP contains the marker file .no-sublime-package at its root, the suggested filename extension will be .zip. In that case installing the file under "Installed Packages" would not work and users must unzip the file manually into their "Packages" folder.

Run Locally

npm install
npm run start

Wrangler will spin up a local dev server at the URL it prints (typically http://127.0.0.1:8787). Append the same ?url= query you plan to use in production to exercise the worker locally.

Example:

http://localhost:8787/packages/USFM%20Bible?url=https://codeload.github.com/michaelblyons/SublimeSyntax-USFM-Bible/zip/version/st3092/0.1.0

Endpoints

  • /packages/<name>?url=<encoded remote zip>: the path segment supplies the package name; spaces can be URL-encoded. A trailing slash after <name> is accepted. The URL must be registered under that exact package name in the package registry.

Configuration

  • ALLOW_HOSTS (comma-separated) to limit allowed source hosts.
  • MAX_ZIP_BYTES and CPU_REPACKAGE_BYTES to cap input size.
  • PACKAGE_INDEX_URL to override the preferred compact package registry URL.
  • WORKSPACE_URL to use one registry URL instead of the preferred index and fallback.

The Worker first probes https://packages.sublimetext.io/repackager-index.json, then falls back to the crawler's GitHub release workspace.json. The parsed registry is retained in each warm Worker isolate. An unknown package/URL pair triggers one refresh and is checked again, with refresh attempts limited to one per 60 seconds per isolate.

Run Tests

Continuously:

npm run test

Or just once:

npm run test -- run

Deploy to Cloudflare

Production deploys are automatic via the GitHub Actions workflow—pushing to the main branch is enough to publish.

Local/manual deploy (useful for testing changes from your machine or targeting a different account):

  1. Authenticate once with npx wrangler login (or set CLOUDFLARE_API_TOKEN in your environment).

  2. Update wrangler.toml if you need a different worker name or account-specific settings.

  3. Push a test build:

    npm run deploy

Wrangler will upload the bundled worker to your Cloudflare account and print the URL for immediate testing.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages