Skip to content

Commit

Permalink
Rename apiKey to pushApiKey in Node.js installer (#528)
Browse files Browse the repository at this point in the history
In PR appsignal/appsignal-nodejs#507
on the Node.js integration we renamed `apiKey` to `pushApiKey` to make
it more consistent with the other integrations. Update the code in the
installer to match.

I've only not updated the `validatePushApiKey` function, because that
meant updating the core package too. I think it would make more sense
to remove that function from the core package and use the Node.js
package's validator instead. Now we only use the core package for this
one function and that function is not used by the core package.

[skip changeset] as users won't notice this change, it only makes it
more readable for us.
[skip review] as it's only a variable name change.
  • Loading branch information
tombruijn authored Dec 7, 2021
1 parent ec7bc54 commit abed290
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/cli/src/installers/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { SUPPORTED_NODEJS_INTEGRATIONS } from "../../constants"
* indendation is intentional, due to JavaScripts handling of multi-line
* strings
*/
const displayOutroMessage = (apiKey: string, name: string) => `
const displayOutroMessage = (pushApiKey: string, name: string) => `
🎉 ${chalk.greenBright(
"Great news!"
)} You've just installed AppSignal to your project!
The next step is adding your Push API key to your project. The best way to do this is with an environment variable:
${chalk.bold(`export APPSIGNAL_PUSH_API_KEY="${apiKey}"`)}
${chalk.bold(`export APPSIGNAL_PUSH_API_KEY="${pushApiKey}"`)}
If you're using a cloud provider such as Heroku etc., seperate instructions on how to add these environment variables are available in our documentation:
Expand Down Expand Up @@ -48,10 +48,10 @@ Need any further help? Feel free to ask a human at ${chalk.bold(
export async function installNode(pkg: { [key: string]: any }) {
const cwd = process.cwd()

const { apiKey, name } = await inquirer.prompt([
const { pushApiKey, name } = await inquirer.prompt([
{
type: "input",
name: "apiKey",
name: "pushApiKey",
message: "What's your Push API Key?",
validate: validateApiKey
},
Expand Down Expand Up @@ -129,7 +129,7 @@ export async function installNode(pkg: { [key: string]: any }) {
...process.env,
APPSIGNAL_APP_ENV: "development",
APPSIGNAL_APP_NAME: name,
APPSIGNAL_PUSH_API_KEY: apiKey
APPSIGNAL_PUSH_API_KEY: pushApiKey
},
stdio: "ignore"
}).unref()
Expand Down Expand Up @@ -159,16 +159,16 @@ export async function installNode(pkg: { [key: string]: any }) {
)
}

console.log(displayOutroMessage(apiKey, name))
console.log(displayOutroMessage(pushApiKey, name))
}

/**
* Validates the answer from Inquirer.js to validate the Push API key that is
* asked for in question one
*/
async function validateApiKey(apiKey: string) {
async function validateApiKey(pushApiKey: string) {
try {
const validated = await validatePushApiKey({ apiKey })
const validated = await validatePushApiKey({ apiKey: pushApiKey })

if (validated === true) {
return validated
Expand Down

0 comments on commit abed290

Please sign in to comment.