build: migrate Fastly config script to the official fastly-js client - #372
Conversation
Replace the unmaintained fastly@2.2.0 (thisandagain) client with the official fastly@15 (fastly-js), which is promise-native and covers the full API. fastly-extended.js now wraps the per-resource API classes and keeps promise-returning, upsert-by-name helper signatures, so configure-fastly.js keeps the same behavior: the same conditions, headers, and response objects are created. Also modernized to const/let, arrow functions, and template literals. One behavior change: authenticate() fails fast at startup when the API key is unset, rather than deferring the error to the first API call.
There was a problem hiding this comment.
Pull request overview
This PR migrates the Fastly configuration tooling from the legacy callback-based fastly@2.2.0 client to the official promise-native fastly@15.1.0 client, updating the wrapper helpers and the configuration script accordingly.
Changes:
- Upgrade dependency from
fastly@2.2.0tofastly@15.1.0(and update lockfile). - Rewrite
bin/lib/fastly-extended.jsto use fastly-js resource API classes with promise-based, upsert-by-name helpers. - Simplify
bin/configure-fastly.jsby removingutil.promisifyusage and calling promise-native helpers directly.
Reviewed changes
Copilot reviewed 1 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| package.json | Updates fastly dependency version to the official client. |
| package-lock.json | Reflects new dependency tree after migrating to fastly@15.1.0. |
| bin/lib/fastly-extended.js | Replaces the legacy wrapper with promise-based helpers built on fastly-js APIs. |
| bin/configure-fastly.js | Removes promisify shims and updates callers to use the new promise-based wrapper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "express": "4.17.1", | ||
| "fastly": "2.2.0", | ||
| "fastly": "15.1.0", | ||
| "html-loader": "5.1.0", |
There was a problem hiding this comment.
As of right now, this is the latest version of fastly, and overriding superagent to a non-deprecated version by force would mean jumping several major versions. Best case, that's unsupported territory; worst case, it just plain doesn't work. I'm sure fastly will upgrade their superagent dep at some point.
Proposed Changes
fastly@2.2.0(thisandagain) client with the officialfastly@15(fastly-js).bin/lib/fastly-extended.jsto wrap the official per-resource API classes (Version/Condition/Header/ResponseObject/Purge), keeping the same promise-returning, upsert-by-name helper signatures.util.promisifyshims inbin/configure-fastly.js; call the now promise-native helpers directly.const/let, arrow functions, and template literals.Reason for Changes
fastly@2.2.0is unmaintained and callback-based. The official fastly-js client is promise-native, maintained, and covers the full API (including VCL snippets, which the follow-up redirect-config rework will use).request-based dependency subtree.Test Coverage
node --check,eslint --no-ignoreclean, and a smoke test (module loads, authenticates, and a missing-service error propagates through the script's.catch).authenticate()fails fast at startup ifFASTLY_API_KEYis unset, rather than deferring to the first API call.