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.
npm install
npm run startWrangler 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:
/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.
ALLOW_HOSTS(comma-separated) to limit allowed source hosts.MAX_ZIP_BYTESandCPU_REPACKAGE_BYTESto cap input size.PACKAGE_INDEX_URLto override the preferred compact package registry URL.WORKSPACE_URLto 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.
Continuously:
npm run testOr just once:
npm run test -- runProduction 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):
-
Authenticate once with
npx wrangler login(or setCLOUDFLARE_API_TOKENin your environment). -
Update
wrangler.tomlif you need a different worker name or account-specific settings. -
Push a test build:
npm run deploy
Wrangler will upload the bundled worker to your Cloudflare account and print the URL for immediate testing.