-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change introduces a new set of commands around retrieving and modifying environment variables from already deployed environments. re #249
- Loading branch information
Showing
25 changed files
with
1,151 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/plugin-serverless/src/commands/serverless/env/get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands; | ||
|
||
const { | ||
handler, | ||
cliInfo, | ||
describe, | ||
} = require('twilio-run/dist/commands/env/env-get'); | ||
const { | ||
convertYargsOptionsToOclifFlags, | ||
normalizeFlags, | ||
createExternalCliOptions, | ||
getRegionAndEdge, | ||
} = require('../../../utils'); | ||
|
||
const { flags, aliasMap } = convertYargsOptionsToOclifFlags(cliInfo.options); | ||
|
||
class EnvGet extends TwilioClientCommand { | ||
async run() { | ||
await super.run(); | ||
|
||
let { flags, args } = this.parse(EnvGet); | ||
flags = normalizeFlags(flags, aliasMap, process.argv); | ||
|
||
const externalOptions = createExternalCliOptions(flags, this.twilioClient); | ||
|
||
const { edge, region } = getRegionAndEdge(flags, this); | ||
flags.region = region; | ||
flags.edge = edge; | ||
|
||
const opts = Object.assign({}, flags, args); | ||
return handler(opts, externalOptions); | ||
} | ||
} | ||
|
||
EnvGet.description = describe; | ||
|
||
EnvGet.flags = Object.assign(flags, { | ||
profile: TwilioClientCommand.flags.profile, | ||
}); | ||
|
||
module.exports = EnvGet; |
41 changes: 41 additions & 0 deletions
41
packages/plugin-serverless/src/commands/serverless/env/import.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands; | ||
|
||
const { | ||
handler, | ||
cliInfo, | ||
describe, | ||
} = require('twilio-run/dist/commands/env/env-import'); | ||
const { | ||
convertYargsOptionsToOclifFlags, | ||
normalizeFlags, | ||
createExternalCliOptions, | ||
getRegionAndEdge, | ||
} = require('../../../utils'); | ||
|
||
const { flags, aliasMap } = convertYargsOptionsToOclifFlags(cliInfo.options); | ||
|
||
class EnvironmentImport extends TwilioClientCommand { | ||
async run() { | ||
await super.run(); | ||
|
||
let { flags, args } = this.parse(EnvironmentImport); | ||
flags = normalizeFlags(flags, aliasMap, process.argv); | ||
|
||
const externalOptions = createExternalCliOptions(flags, this.twilioClient); | ||
|
||
const { edge, region } = getRegionAndEdge(flags, this); | ||
flags.region = region; | ||
flags.edge = edge; | ||
|
||
const opts = Object.assign({}, flags, args); | ||
return handler(opts, externalOptions); | ||
} | ||
} | ||
|
||
EnvironmentImport.description = describe; | ||
|
||
EnvironmentImport.flags = Object.assign(flags, { | ||
profile: TwilioClientCommand.flags.profile, | ||
}); | ||
|
||
module.exports = EnvironmentImport; |
41 changes: 41 additions & 0 deletions
41
packages/plugin-serverless/src/commands/serverless/env/list.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands; | ||
|
||
const { | ||
handler, | ||
cliInfo, | ||
describe, | ||
} = require('twilio-run/dist/commands/env/env-list'); | ||
const { | ||
convertYargsOptionsToOclifFlags, | ||
normalizeFlags, | ||
createExternalCliOptions, | ||
getRegionAndEdge, | ||
} = require('../../../utils'); | ||
|
||
const { flags, aliasMap } = convertYargsOptionsToOclifFlags(cliInfo.options); | ||
|
||
class EnvList extends TwilioClientCommand { | ||
async run() { | ||
await super.run(); | ||
|
||
let { flags, args } = this.parse(EnvList); | ||
flags = normalizeFlags(flags, aliasMap, process.argv); | ||
|
||
const externalOptions = createExternalCliOptions(flags, this.twilioClient); | ||
|
||
const { edge, region } = getRegionAndEdge(flags, this); | ||
flags.region = region; | ||
flags.edge = edge; | ||
|
||
const opts = Object.assign({}, flags, args); | ||
return handler(opts, externalOptions); | ||
} | ||
} | ||
|
||
EnvList.description = describe; | ||
|
||
EnvList.flags = Object.assign(flags, { | ||
profile: TwilioClientCommand.flags.profile, | ||
}); | ||
|
||
module.exports = EnvList; |
41 changes: 41 additions & 0 deletions
41
packages/plugin-serverless/src/commands/serverless/env/unset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands; | ||
|
||
const { | ||
handler, | ||
cliInfo, | ||
describe, | ||
} = require('twilio-run/dist/commands/env/env-unset'); | ||
const { | ||
convertYargsOptionsToOclifFlags, | ||
normalizeFlags, | ||
createExternalCliOptions, | ||
getRegionAndEdge, | ||
} = require('../../../utils'); | ||
|
||
const { flags, aliasMap } = convertYargsOptionsToOclifFlags(cliInfo.options); | ||
|
||
class EnvUnset extends TwilioClientCommand { | ||
async run() { | ||
await super.run(); | ||
|
||
let { flags, args } = this.parse(EnvUnset); | ||
flags = normalizeFlags(flags, aliasMap, process.argv); | ||
|
||
const externalOptions = createExternalCliOptions(flags, this.twilioClient); | ||
|
||
const { edge, region } = getRegionAndEdge(flags, this); | ||
flags.region = region; | ||
flags.edge = edge; | ||
|
||
const opts = Object.assign({}, flags, args); | ||
return handler(opts, externalOptions); | ||
} | ||
} | ||
|
||
EnvUnset.description = describe; | ||
|
||
EnvUnset.flags = Object.assign(flags, { | ||
profile: TwilioClientCommand.flags.profile, | ||
}); | ||
|
||
module.exports = EnvUnset; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Sid } from '../../types'; | ||
|
||
const SidRegEx = /^[A-Z]{2}[a-f0-9]{32}$/; | ||
|
||
export function isSid(value: unknown): value is Sid { | ||
if (typeof value !== 'string') { | ||
return false; | ||
} | ||
|
||
if (value.length !== 34) { | ||
return false; | ||
} | ||
|
||
return SidRegEx.test(value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.