Skip to content

sublimetext-io/pc-e05-therepackager

 
 

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 uses the Workers edge cache to avoid processing the same source archive repeatedly.

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

The legacy root handler / is still available during migration:

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

Endpoints

  • /packages/<name>?url=<encoded remote zip> (preferred): path segment supplies the package name; spaces can be URL-encoded. A trailing slash after <name> is accepted.
  • / (legacy): ?url= and optional &name=.
  • /logs.json: small proxy to ASSET_URL (or default GitHub logs.json) with CORS * and a short cache (max-age=10, s-maxage=10).

Configuration

  • ALLOW_HOSTS (comma-separated) to limit allowed source hosts.
  • MAX_ZIP_BYTES and CPU_REPACKAGE_BYTES to cap input size.
  • ASSET_URL to override the logs.json proxy target.

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.

Troubleshooting

  • The worker caches responses aggressively (max-age=31536000). If you need to invalidate the cache, request the worker with a different query string (for example, add &cacheBust=timestamp).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%