Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CLI getAccountId util #1331

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

brandenrodgers
Copy link
Contributor

Description and Context

This still needs to be tested thoroughly, but I'm fairly certain that we can remove this getAccountId() util in the CLI in favor of the getAccountId in local-dev-lib because now we have the injectAccountIdMiddleware middleware that does everything this old util in the CLI was doing. I'll leave inline comments to explain my thinking.

Screenshots

TODO

Who to Notify

/**
* Obtains accountId using supplied --account flag or from environment variables
*/
export function getAccountId(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This util is just a wrapper around the local-dev-lib's getAccountId, except it also checks for any account env variables.

Now that we have injectAccountIdMiddleware doing this same thing, we should be able to remove this util. Commands can get this same behavior by looking at options.derivedAccountId.

The benefit of removing this is that it cuts down on the number of options for getting account ID's in the project.

@@ -22,23 +23,24 @@ import {
getCwd,
getExt,
} from '@hubspot/local-dev-lib/path';
import { getAccountId, getCmsPublishMode } from './commonOpts';
import { getCmsPublishMode } from './commonOpts';
import { logError } from './errorHandlers/index';

export async function validateAccount(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that these validation checks weren't working correctly. I'm actually not sure if we should even keep them around. Now that I fixed these I'm starting to see them showing up. For example, I'm getting an error if I have env variables set and I try to run a CLI command without using --use-env. But I don't think we need to show an error in that case. The command still works as expected.

I think these checks might be too aggressive, but curious to hear what others think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm yeah that seems unnecessary, you may still want to use your config file after setting env variables. The only thing we really need to check for is using --account and --use-env at the same time, which we already do

Copy link
Contributor

@camden11 camden11 left a comment

Choose a reason for hiding this comment

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

Code all LGTM, lets definitely test this thoroughly before merging though

@@ -22,23 +23,24 @@ import {
getCwd,
getExt,
} from '@hubspot/local-dev-lib/path';
import { getAccountId, getCmsPublishMode } from './commonOpts';
import { getCmsPublishMode } from './commonOpts';
import { logError } from './errorHandlers/index';

export async function validateAccount(
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm yeah that seems unnecessary, you may still want to use your config file after setting env variables. The only thing we really need to check for is using --account and --use-env at the same time, which we already do

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