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

chore: Refactor profiles usage to projects #257

Merged
merged 2 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/commands/profiles/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ class ProfilesList extends BaseCommand {
accountSid: ENVIRONMENT_ACCOUNT_SID,
region: ENVIRONMENT_REGION,
};
this.userConfig.profiles.unshift(strippedEnvProfile);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should update the comment at line 8 (userConfig.profiles) also to userConfig.projects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing! Changed.

this.userConfig.projects.unshift(strippedEnvProfile);
this.userConfig.setActiveProfile(strippedEnvProfile.id);
}
if (this.userConfig.profiles.length > 0) {
if (this.userConfig.projects.length > 0) {
// If none of the profiles have a region, delete it from all of them so it doesn't show up in the output.
if (!this.userConfig.profiles.some((p) => p.region)) {
this.userConfig.profiles.forEach((p) => delete p.region);
if (!this.userConfig.projects.some((p) => p.region)) {
this.userConfig.projects.forEach((p) => delete p.region);
}
const activeProfile = this.userConfig.getActiveProfile();
this.userConfig.profiles.forEach((p) => {
this.userConfig.projects.forEach((p) => {
p.active = p.id === activeProfile.id;
});
this.output(this.userConfig.profiles);
this.output(this.userConfig.projects);
} else {
this.logger.warn(`No profiles have been configured. Run ${chalk.bold('twilio profiles:create')} to create one!`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/profiles/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ProfilesRemove extends TwilioClientCommand {
'Are you sure you want to remove the active profile? Run "twilio profiles:use" to set another profile as active.',
);
}
if (this.userConfig.profiles.length === 1) {
if (this.userConfig.projects.length === 1) {
this.logger.warn(
'Are you sure you want to remove the last profile? Run "twilio profiles:create" to create another profile.',
);
Expand Down