Skip to content

Commit

Permalink
feat: Release feature branch (twilio#188)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Storing profiles in config file instead of keytar.
  • Loading branch information
ravali-rimmalapudi committed Jan 7, 2022
1 parent 5b6a3a5 commit 4380dac
Show file tree
Hide file tree
Showing 8 changed files with 384 additions and 53 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Extract branch name
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- name: Slack Notification
if: ${{steps.extract_branch.outputs.branch == 'main' }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEB_HOOK }}
Expand Down
2 changes: 1 addition & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"branches": [
"main",
{
"name": "release_feature_branch",
"name": "release-feature-branch",
"prerelease": "rc"
}
],
Expand Down
77 changes: 77 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,83 @@
- Add `AudioOnly` to create room


### [5.27.1-rc.1](https://github.com/twilio/twilio-cli-core/compare/5.25.0-rc.1...5.27.1-rc.1) (2021-11-12)


### Library - Fixes

* Removed change to stop publish from npm. ([#175](https://github.com/twilio/twilio-cli-core/issues/175)) ([a819b6c](https://github.com/twilio/twilio-cli-core/commit/a819b6c98cbfe99e77664a2efdac28c63e9218cc))

## [5.25.0-rc.1](https://github.com/twilio/twilio-cli-core/compare/5.24.0...5.25.0-rc.1) (2021-11-03)


### Library - Chores

* CLI Profile Remove - Check and Use config file before checking system keychain. ([#126](https://github.com/twilio/twilio-cli-core/issues/126)) ([e326a31](https://github.com/twilio/twilio-cli-core/commit/e326a3195ff9bab2437671f61a4dcdfba15c6100))
* Refactor profiles usage to projects ([#122](https://github.com/twilio/twilio-cli-core/issues/122)) ([782f6c5](https://github.com/twilio/twilio-cli-core/commit/782f6c50dfb7d2e00df52ef75dfd3e94bc45581c))
* refactor the Twilio vendor extensions into single object ([#125](https://github.com/twilio/twilio-cli-core/issues/125)) ([a2e0fca](https://github.com/twilio/twilio-cli-core/commit/a2e0fca112eccf954d86095af4809445042d1bb6))
* Store API Keys in Config File ([#124](https://github.com/twilio/twilio-cli-core/issues/124)) ([9fb9dd3](https://github.com/twilio/twilio-cli-core/commit/9fb9dd394b85dba6185b4a2033bf822c72d5c94a))


### Library - Fixes

* Removed the comment. ([95d4fa4](https://github.com/twilio/twilio-cli-core/commit/95d4fa487886cc05efa75effc38e315d0393ef7c))
* Update release-feature-branch with main ([#137](https://github.com/twilio/twilio-cli-core/issues/137)) ([46c4156](https://github.com/twilio/twilio-cli-core/commit/46c415631e74ab1bcac460299a65532211cb2347)), closes [#130](https://github.com/twilio/twilio-cli-core/issues/130)


### Library - Features

* Added support to make profile input mandatory based on config property ([#135](https://github.com/twilio/twilio-cli-core/issues/135)) ([fbdc36b](https://github.com/twilio/twilio-cli-core/commit/fbdc36ba99be611dcaf5d08e8697a42e2256b59e))
* Merging master into release-feature-branch ([#172](https://github.com/twilio/twilio-cli-core/issues/172)) ([48313d2](https://github.com/twilio/twilio-cli-core/commit/48313d27844d1cf6f5435150deb1e777314cba04)), closes [#130](https://github.com/twilio/twilio-cli-core/issues/130) [#136](https://github.com/twilio/twilio-cli-core/issues/136) [#139](https://github.com/twilio/twilio-cli-core/issues/139) [#138](https://github.com/twilio/twilio-cli-core/issues/138) [#140](https://github.com/twilio/twilio-cli-core/issues/140) [#142](https://github.com/twilio/twilio-cli-core/issues/142) [#145](https://github.com/twilio/twilio-cli-core/issues/145) [#150](https://github.com/twilio/twilio-cli-core/issues/150) [#154](https://github.com/twilio/twilio-cli-core/issues/154) [#156](https://github.com/twilio/twilio-cli-core/issues/156) [#150](https://github.com/twilio/twilio-cli-core/issues/150) [#157](https://github.com/twilio/twilio-cli-core/issues/157) [#158](https://github.com/twilio/twilio-cli-core/issues/158) [#155](https://github.com/twilio/twilio-cli-core/issues/155) [#161](https://github.com/twilio/twilio-cli-core/issues/161) [#157](https://github.com/twilio/twilio-cli-core/issues/157) [#155](https://github.com/twilio/twilio-cli-core/issues/155) [#165](https://github.com/twilio/twilio-cli-core/issues/165) [#166](https://github.com/twilio/twilio-cli-core/issues/166) [#164](https://github.com/twilio/twilio-cli-core/issues/164) [#165](https://github.com/twilio/twilio-cli-core/issues/165) [#164](https://github.com/twilio/twilio-cli-core/issues/164) [#166](https://github.com/twilio/twilio-cli-core/issues/166) [#168](https://github.com/twilio/twilio-cli-core/issues/168) [#166](https://github.com/twilio/twilio-cli-core/issues/166) [#166](https://github.com/twilio/twilio-cli-core/issues/166) [#168](https://github.com/twilio/twilio-cli-core/issues/168) [#169](https://github.com/twilio/twilio-cli-core/issues/169) [#135](https://github.com/twilio/twilio-cli-core/issues/135) [#164](https://github.com/twilio/twilio-cli-core/issues/164) [#150](https://github.com/twilio/twilio-cli-core/issues/150) [#165](https://github.com/twilio/twilio-cli-core/issues/165) [#155](https://github.com/twilio/twilio-cli-core/issues/155) [#169](https://github.com/twilio/twilio-cli-core/issues/169) [#145](https://github.com/twilio/twilio-cli-core/issues/145) [#126](https://github.com/twilio/twilio-cli-core/issues/126) [#122](https://github.com/twilio/twilio-cli-core/issues/122) [#150](https://github.com/twilio/twilio-cli-core/issues/150) [#157](https://github.com/twilio/twilio-cli-core/issues/157) [#155](https://github.com/twilio/twilio-cli-core/issues/155) [#165](https://github.com/twilio/twilio-cli-core/issues/165) [#164](https://github.com/twilio/twilio-cli-core/issues/164) [#166](https://github.com/twilio/twilio-cli-core/issues/166) [#168](https://github.com/twilio/twilio-cli-core/issues/168) [#124](https://github.com/twilio/twilio-cli-core/issues/124) [#157](https://github.com/twilio/twilio-cli-core/issues/157) [#166](https://github.com/twilio/twilio-cli-core/issues/166) [#168](https://github.com/twilio/twilio-cli-core/issues/168) [#130](https://github.com/twilio/twilio-cli-core/issues/130)

## [5.29.0-rc.1](https://github.com/shamantraghav/twilio-cli-core/compare/5.28.0...5.29.0-rc.1) (2021-10-27)


### Library - Features

* Added support to make profile input mandatory based on config property ([#135](https://github.com/shamantraghav/twilio-cli-core/issues/135)) ([fbdc36b](https://github.com/shamantraghav/twilio-cli-core/commit/fbdc36ba99be611dcaf5d08e8697a42e2256b59e))
* Added the github actions to send the slack notifications ([#164](https://github.com/shamantraghav/twilio-cli-core/issues/164)) ([06e2cb1](https://github.com/shamantraghav/twilio-cli-core/commit/06e2cb1e3a8a6eb2486d8575a5da6c5dcbe3708e))
* Enable GitHub actions. ([#150](https://github.com/shamantraghav/twilio-cli-core/issues/150)) ([002dd1f](https://github.com/shamantraghav/twilio-cli-core/commit/002dd1f9593187cd580d7c139609420e5a33317f))


### Library - Chores

* [Snyk] Security upgrade @oclif/plugin-help from 2.2.3 to 3.2.0 ([#165](https://github.com/shamantraghav/twilio-cli-core/issues/165)) ([188120a](https://github.com/shamantraghav/twilio-cli-core/commit/188120a3e323ea07f2e7f26909ec83ac5a03461d))
* Added changes to use scripts instead of community Github actions ([#155](https://github.com/shamantraghav/twilio-cli-core/issues/155)) ([27bd508](https://github.com/shamantraghav/twilio-cli-core/commit/27bd508171b16eaf0036bdff7e0d21117570bf5f))
* Added tests and sonarcloud scan while adding the PR's ([#169](https://github.com/shamantraghav/twilio-cli-core/issues/169)) ([a26d6ee](https://github.com/shamantraghav/twilio-cli-core/commit/a26d6ee81e2a49057581ce0d76b9636295d42f1e))
* Cache processing step for Travis builds ([#145](https://github.com/shamantraghav/twilio-cli-core/issues/145)) ([33cc65d](https://github.com/shamantraghav/twilio-cli-core/commit/33cc65d82412c30f6c9aec40b2c79e43a80d459b))
* CLI Profile Remove - Check and Use config file before checking system keychain. ([#126](https://github.com/shamantraghav/twilio-cli-core/issues/126)) ([e326a31](https://github.com/shamantraghav/twilio-cli-core/commit/e326a3195ff9bab2437671f61a4dcdfba15c6100))
* Refactor profiles usage to projects ([#122](https://github.com/shamantraghav/twilio-cli-core/issues/122)) ([782f6c5](https://github.com/shamantraghav/twilio-cli-core/commit/782f6c50dfb7d2e00df52ef75dfd3e94bc45581c))
* **release:** set `package.json` to 5.29.0 [skip ci] ([8e5a785](https://github.com/shamantraghav/twilio-cli-core/commit/8e5a7851fc12a9ef06683ef9d82284485166b333)), closes [#150](https://github.com/shamantraghav/twilio-cli-core/issues/150)
* **release:** set `package.json` to 5.30.0 [skip ci] ([26e4594](https://github.com/shamantraghav/twilio-cli-core/commit/26e459440a4668903d9593538e637f8726c10525)), closes [#157](https://github.com/shamantraghav/twilio-cli-core/issues/157) [#155](https://github.com/shamantraghav/twilio-cli-core/issues/155)
* **release:** set `package.json` to 5.31.0 [skip ci] ([ad437be](https://github.com/shamantraghav/twilio-cli-core/commit/ad437be6870126db141ddefee9f10a4cb7528728)), closes [#165](https://github.com/shamantraghav/twilio-cli-core/issues/165) [#164](https://github.com/shamantraghav/twilio-cli-core/issues/164)
* **release:** set `package.json` to 5.31.1 [skip ci] ([dc18140](https://github.com/shamantraghav/twilio-cli-core/commit/dc181406a2583d543c719379cc68dafd818efd07)), closes [#166](https://github.com/shamantraghav/twilio-cli-core/issues/166) [#168](https://github.com/shamantraghav/twilio-cli-core/issues/168)
* Store API Keys in Config File ([#124](https://github.com/shamantraghav/twilio-cli-core/issues/124)) ([9fb9dd3](https://github.com/shamantraghav/twilio-cli-core/commit/9fb9dd394b85dba6185b4a2033bf822c72d5c94a))


### Library - Fixes

* fix naming ([#157](https://github.com/shamantraghav/twilio-cli-core/issues/157)) ([d454b81](https://github.com/shamantraghav/twilio-cli-core/commit/d454b811344ae11283e32c13f14e01d9946bfabf))
* Merger main into release feature branch ([fbcd3e8](https://github.com/shamantraghav/twilio-cli-core/commit/fbcd3e82c4a480578a6d2b8561cd0f280ad5cb0d))
* Removed the comment. ([95d4fa4](https://github.com/shamantraghav/twilio-cli-core/commit/95d4fa487886cc05efa75effc38e315d0393ef7c))
* Revert "Resolve sec vulnerability ([#166](https://github.com/shamantraghav/twilio-cli-core/issues/166))" ([#168](https://github.com/shamantraghav/twilio-cli-core/issues/168)) ([7d2a374](https://github.com/shamantraghav/twilio-cli-core/commit/7d2a374b4f5f42106c976616a88d029b2f3bea0a))
* Update release-feature-branch with main ([#137](https://github.com/shamantraghav/twilio-cli-core/issues/137)) ([46c4156](https://github.com/shamantraghav/twilio-cli-core/commit/46c415631e74ab1bcac460299a65532211cb2347)), closes [#130](https://github.com/shamantraghav/twilio-cli-core/issues/130)
* Updated api definitions ([906518f](https://github.com/shamantraghav/twilio-cli-core/commit/906518f5fbdfa154604c5288f4ebd9eaf46a48b3))

---------------------------
**Api**
- Corrected enum values for `emergency_address_status` values in `/IncomingPhoneNumbers` response. **(breaking change)**
- Clarify `emergency_address_status` values in `/IncomingPhoneNumbers` response.

**Messaging**
- Add PUT and List brand vettings api
- Removes beta feature flag based visibility for us_app_to_person_registered and usecase field.Updates test cases to add POLITICAL usecase. **(breaking change)**
- Add brand_feedback as optional field to BrandRegistrations

**Video**
- Add `AudioOnly` to create room


## [5.30.0](https://github.com/twilio/twilio-cli-core/compare/5.29.0...5.30.0) (2021-10-07)


Expand Down
21 changes: 17 additions & 4 deletions src/base-commands/twilio-client-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,32 @@ class TwilioClientCommand extends BaseCommand {
async run() {
await super.run();

// check if profile flag is required as per the config
if (this.userConfig.requireProfileInput && !this.flags.profile) {
throw new TwilioCliError(
`Error: Missing required flag:\n -p, --profile PROFILE ${TwilioClientCommand.flags.profile.description} To disable this check run:\n\n twilio config:set --no-require-profile-input`,
);
}
this.currentProfile = this.userConfig.getProfileById(this.flags.profile);
let keytarFlag = false;
const pluginName = (this.config.userAgent || ' ').split(' ')[0];

const reportUnconfigured = (verb, message = '') => {
const reportUnconfigured = (verb, message = '', commandName = 'create') => {
const profileParam = this.flags.profile ? ` --profile "${this.flags.profile}"` : '';
throw new TwilioCliError(`To ${verb} the profile, run:\n\n twilio profiles:create${profileParam}${message}`);
throw new TwilioCliError(
`To ${verb} the profile, run:\n\n twilio profiles:${commandName}${profileParam}${message}`,
);
};

if (!this.currentProfile) {
const profileName = this.flags.profile ? ` "${this.flags.profile}"` : '';
this.logger.error(`Could not find profile${profileName}.`);
reportUnconfigured('create', `\n\n${HELP_ENVIRONMENT_VARIABLES}`);
if (Object.keys(this.userConfig.profiles).length !== 0 && !profileName) {
this.logger.error(`There is no active profile set.`);
reportUnconfigured('activate', '', 'use');
} else {
this.logger.error(`Could not find profile${profileName}.`);
reportUnconfigured('create', `\n\n${HELP_ENVIRONMENT_VARIABLES}`);
}
}

this.logger.debug(`Using profile: ${this.currentProfile.id}`);
Expand Down
76 changes: 59 additions & 17 deletions src/services/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ const MessageTemplates = require('./messaging/templates');
const CLI_NAME = 'twilio-cli';

class ConfigDataProfile {
constructor(accountSid, region, apiKey, apiSecret) {
this.accountSid = accountSid;
this.region = region;
this.apiKey = apiKey;
this.apiSecret = apiSecret;
}
}

class ConfigDataProject {
constructor(id, accountSid, region) {
this.id = id;
this.accountSid = accountSid;
Expand All @@ -20,8 +29,10 @@ class ConfigData {
this.edge = undefined;
this.email = {};
this.prompts = {};
this.profiles = [];
this.projects = [];
this.activeProfile = null;
this.profiles = {};
this.requireProfileInput = undefined;
}

getProfileFromEnvironment() {
Expand Down Expand Up @@ -55,6 +66,14 @@ class ConfigData {
return undefined;
}

getProfileFromConfigFileById(profileId) {
let profile = this.profiles[profileId];
if (!profile) {
profile = this.projects.find((p) => p.id === profileId);
}
return profile;
}

getProfileById(profileId) {
let profile;

Expand All @@ -66,7 +85,11 @@ class ConfigData {
if (profileId) {
// Clean the profile ID.
profileId = this.sanitize(profileId);
profile = this.profiles.find((p) => p.id === profileId);
profile = this.getProfileFromConfigFileById(profileId);
// Explicitly add `id` to the returned profile
if (profile && !profile.hasOwnProperty('id')) {
profile.id = profileId;
}
} else {
profile = this.getActiveProfile();
}
Expand All @@ -90,39 +113,54 @@ class ConfigData {

getActiveProfile() {
let profile;
if (this.profiles.length > 0) {
if (this.projects.length > 0 || Object.keys(this.profiles).length > 0) {
if (this.activeProfile) {
profile = this.profiles.find((p) => p.id === this.activeProfile);
profile = this.getProfileFromConfigFileById(this.activeProfile);
}

if (!profile) {
profile = this.profiles[0];
profile = this.projects[0];
}
}
return profile;
}

removeProfile(profileToRemove) {
this.profiles = this.profiles.filter((profile) => {
return profile.id !== profileToRemove.id;
});
if (this.profiles[profileToRemove.id]) {
delete this.profiles[profileToRemove.id];
} else {
this.projects = this.projects.filter((profile) => {
return profile.id !== profileToRemove.id;
});
}
if (profileToRemove.id === this.activeProfile) {
this.activeProfile = null;
}
}

addProfile(id, accountSid, region) {
// Clean all the inputs.
addProfile(id, accountSid, region, apiKey, apiSecret) {
// Clean all the inputs.
id = this.sanitize(id);
accountSid = this.sanitize(accountSid);
region = this.sanitize(region);

const existing = this.getProfileById(id);

// Remove if existing in historical projects.
if (existing) {
existing.accountSid = accountSid;
existing.region = region;
} else {
this.profiles.push(new ConfigDataProfile(id, accountSid, region));
this.projects = this.projects.filter((p) => p.id !== existing.id);
}

// Update profiles object
this.profiles[id] = new ConfigDataProfile(accountSid, region, apiKey, apiSecret);
}

addProject(id, accountSid, region) {
id = this.sanitize(id);
accountSid = this.sanitize(accountSid);
region = this.sanitize(region);

this.projects.push(new ConfigDataProject(id, accountSid, region));
}

isPromptAcked(promptId) {
Expand All @@ -145,10 +183,12 @@ class ConfigData {
loadFromObject(configObj) {
this.edge = configObj.edge;
this.email = configObj.email || {};
this.requireProfileInput = configObj.requireProfileInput;
this.prompts = configObj.prompts || {};
// Note the historical 'projects' naming.
configObj.profiles = configObj.projects || [];
configObj.profiles.forEach((profile) => this.addProfile(profile.id, profile.accountSid, profile.region));
configObj.projects = configObj.projects || [];
configObj.projects.forEach((project) => this.addProject(project.id, project.accountSid, project.region));
this.profiles = configObj.profiles || {};
this.setActiveProfile(configObj.activeProject);
}

Expand Down Expand Up @@ -179,9 +219,11 @@ class Config {
configData = {
edge: configData.edge,
email: configData.email,
requireProfileInput: configData.requireProfileInput,
prompts: configData.prompts,
// Note the historical 'projects' naming.
projects: configData.profiles,
projects: configData.projects,
profiles: configData.profiles,
activeProject: configData.activeProfile,
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/twilio-api/twilio_accounts_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -867,4 +867,4 @@
"name": "GA"
}
]
}
}

0 comments on commit 4380dac

Please sign in to comment.