diff --git a/packages/cli/.changesets/remove-dependency-on---appsignal-core-.md b/packages/cli/.changesets/remove-dependency-on---appsignal-core-.md new file mode 100644 index 00000000..8ed954ca --- /dev/null +++ b/packages/cli/.changesets/remove-dependency-on---appsignal-core-.md @@ -0,0 +1,6 @@ +--- +bump: "patch" +type: "remove" +--- + +Remove dependency on `@appsignal/core`. diff --git a/packages/cli/package.json b/packages/cli/package.json index 91f6eb31..d2970881 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -20,7 +20,7 @@ "access": "public" }, "dependencies": { - "@appsignal/core": "=1.1.21", + "isomorphic-unfetch": "=4.0.0", "chalk": "^4.1.0", "commander": "^6.2.1", "inquirer": "^7.3.3" diff --git a/packages/cli/src/installers/node/index.ts b/packages/cli/src/installers/node/index.ts index 85294f23..036933fa 100644 --- a/packages/cli/src/installers/node/index.ts +++ b/packages/cli/src/installers/node/index.ts @@ -2,7 +2,7 @@ import { existsSync } from "fs" import { spawnSync } from "child_process" import chalk from "chalk" import inquirer from "inquirer" -import { validatePushApiKey } from "@appsignal/core" +import { validatePushApiKey } from "../../utils" import * as fs from "fs" import * as path from "path" diff --git a/packages/cli/src/utils.ts b/packages/cli/src/utils.ts index 85cbc9a4..bfd5812b 100644 --- a/packages/cli/src/utils.ts +++ b/packages/cli/src/utils.ts @@ -1,5 +1,6 @@ import { existsSync } from "fs" import { dirname } from "path" +import fetch from "isomorphic-unfetch" // Returns the filesystem location at which the root of the // `@appsignal/nodejs` package was found. @@ -46,3 +47,24 @@ export function checkForAppsignalPackage(): string { process.exit(1) } + +export async function validatePushApiKey({ + endpoint = "https://push.appsignal.com", + apiKey +}: { + endpoint?: string + apiKey: string +}) { + const { status } = await fetch(`${endpoint}/1/auth?api_key=${apiKey}`) + + switch (status) { + case 200: + return true + case 401: + return false + default: + throw new Error( + `Invalid ${status} response from server when authenticating` + ) + } +} diff --git a/packages/core/.changesets/remove-dependency-on--isomorphic-unfetch-.md b/packages/core/.changesets/remove-dependency-on--isomorphic-unfetch-.md new file mode 100644 index 00000000..8c58d8c1 --- /dev/null +++ b/packages/core/.changesets/remove-dependency-on--isomorphic-unfetch-.md @@ -0,0 +1,7 @@ +--- +bump: "patch" +type: "remove" +--- + +Remove dependency on `isomorphic-unfetch`. This fixes an issue where +`isomorphic-unfetch` fails to bundle properly with `esbuild` or `webpack`. diff --git a/packages/core/package.json b/packages/core/package.json index 4c9b4232..970a7b7a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -26,7 +26,6 @@ }, "dependencies": { "@appsignal/types": "=3.0.1", - "isomorphic-unfetch": "^4.0.0", "tslib": "^2.3.0" } } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 50d53781..83087b4e 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -5,7 +5,6 @@ export * from "./utils/error" export * from "./utils/url" export * from "./utils/async" export * from "./utils/environment" -export * from "./utils/push-api" // Classes export { Serializable } from "./serializable" diff --git a/packages/core/src/utils/push-api.ts b/packages/core/src/utils/push-api.ts deleted file mode 100644 index aab51f8e..00000000 --- a/packages/core/src/utils/push-api.ts +++ /dev/null @@ -1,22 +0,0 @@ -import fetch from "isomorphic-unfetch" - -export async function validatePushApiKey({ - endpoint = "https://push.appsignal.com", - apiKey -}: { - endpoint?: string - apiKey: string -}) { - const { status } = await fetch(`${endpoint}/1/auth?api_key=${apiKey}`) - - switch (status) { - case 200: - return true - case 401: - return false - default: - throw new Error( - `Invalid ${status} response from server when authenticating` - ) - } -}