Skip to content

build: migrate Fastly config script to the official fastly-js client - #372

Merged
cwillisf merged 1 commit into
developfrom
refactor/migrate-fastly-js-client
Jul 16, 2026
Merged

build: migrate Fastly config script to the official fastly-js client#372
cwillisf merged 1 commit into
developfrom
refactor/migrate-fastly-js-client

Conversation

@cwillisf

@cwillisf cwillisf commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

  • Replace the unmaintained fastly@2.2.0 (thisandagain) client with the official fastly@15 (fastly-js).
  • Rewrite bin/lib/fastly-extended.js to wrap the official per-resource API classes (Version/Condition/Header/ResponseObject/Purge), keeping the same promise-returning, upsert-by-name helper signatures.
  • Drop the util.promisify shims in bin/configure-fastly.js; call the now promise-native helpers directly.
  • Modernize both files to const/let, arrow functions, and template literals.

Reason for Changes

  • fastly@2.2.0 is 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).
  • Removes the deprecated request-based dependency subtree.

Test Coverage

  • Behavior-preserving: the same conditions, headers, and response objects are created.
  • Verified locally: node --check, eslint --no-ignore clean, and a smoke test (module loads, authenticates, and a missing-service error propagates through the script's .catch).
  • Not yet exercised against a live Fastly service: the create/update API calls, the 404-upsert fallback, and param shapes should be confirmed on a staging deploy.
  • One behavior change: authenticate() fails fast at startup if FASTLY_API_KEY is unset, rather than deferring to the first API call.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.0 to fastly@15.1.0 (and update lockfile).
  • Rewrite bin/lib/fastly-extended.js to use fastly-js resource API classes with promise-based, upsert-by-name helpers.
  • Simplify bin/configure-fastly.js by removing util.promisify usage 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.

Comment thread package.json
Comment on lines 37 to 39
"express": "4.17.1",
"fastly": "2.2.0",
"fastly": "15.1.0",
"html-loader": "5.1.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cwillisf
cwillisf merged commit c97f0bf into develop Jul 16, 2026
5 checks passed
@cwillisf
cwillisf deleted the refactor/migrate-fastly-js-client branch July 16, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants