@twilio-labs/plugin-flex 4.3.0-flex-ui-2.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -23
- package/dist/clients/ServerlessClient.d.ts +27 -0
- package/dist/clients/ServerlessClient.js +53 -2
- package/dist/clients/ServerlessClient.js.map +1 -1
- package/dist/commands/flex/plugins/archive/configuration.d.ts +1 -1
- package/dist/commands/flex/plugins/archive/plugin-version.d.ts +23 -1
- package/dist/commands/flex/plugins/archive/plugin-version.js +86 -1
- package/dist/commands/flex/plugins/archive/plugin-version.js.map +1 -1
- package/dist/commands/flex/plugins/archive/plugin.d.ts +12 -1
- package/dist/commands/flex/plugins/archive/plugin.js +54 -1
- package/dist/commands/flex/plugins/archive/plugin.js.map +1 -1
- package/dist/commands/flex/plugins/deploy.js +1 -2
- package/dist/commands/flex/plugins/deploy.js.map +1 -1
- package/dist/commands/flex/plugins/describe/configuration.d.ts +1 -1
- package/dist/commands/flex/plugins/describe/plugin-version.d.ts +1 -1
- package/dist/commands/flex/plugins/describe/plugin.d.ts +1 -1
- package/dist/commands/flex/plugins/describe/release.d.ts +1 -1
- package/dist/commands/flex/plugins/diff.d.ts +1 -2
- package/dist/commands/flex/plugins/diff.js.map +1 -1
- package/dist/commands/flex/plugins/list/configurations.d.ts +1 -1
- package/dist/commands/flex/plugins/list/plugin-versions.d.ts +1 -1
- package/dist/commands/flex/plugins/list/plugins.d.ts +1 -1
- package/dist/commands/flex/plugins/list/releases.d.ts +1 -1
- package/dist/commands/flex/plugins/release.d.ts +5 -2
- package/dist/commands/flex/plugins/upgrade-plugin.d.ts +6 -11
- package/dist/commands/flex/plugins/upgrade-plugin.js +11 -68
- package/dist/commands/flex/plugins/upgrade-plugin.js.map +1 -1
- package/dist/prints/index.d.ts +1 -3
- package/dist/prints/upgradePlugin.d.ts +1 -3
- package/dist/prints/upgradePlugin.js +3 -21
- package/dist/prints/upgradePlugin.js.map +1 -1
- package/dist/sub-commands/archive-resource.js +4 -1
- package/dist/sub-commands/archive-resource.js.map +1 -1
- package/dist/sub-commands/create-configuration.d.ts +1 -1
- package/dist/sub-commands/flex-plugin.d.ts +11 -14
- package/dist/sub-commands/flex-plugin.js +38 -34
- package/dist/sub-commands/flex-plugin.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +15 -16
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ OPTIONS
|
|
|
81
81
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
_See code: [dist/commands/flex/plugins/archive/configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
84
|
+
_See code: [dist/commands/flex/plugins/archive/configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/archive/configuration.js)_
|
|
85
85
|
|
|
86
86
|
## `twilio flex:plugins:archive:plugin`
|
|
87
87
|
|
|
@@ -99,7 +99,7 @@ OPTIONS
|
|
|
99
99
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
_See code: [dist/commands/flex/plugins/archive/plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
102
|
+
_See code: [dist/commands/flex/plugins/archive/plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/archive/plugin.js)_
|
|
103
103
|
|
|
104
104
|
## `twilio flex:plugins:archive:plugin-version`
|
|
105
105
|
|
|
@@ -118,7 +118,7 @@ OPTIONS
|
|
|
118
118
|
--version=version (required) The Flex Plugin Version to archive.
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
_See code: [dist/commands/flex/plugins/archive/plugin-version.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
121
|
+
_See code: [dist/commands/flex/plugins/archive/plugin-version.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/archive/plugin-version.js)_
|
|
122
122
|
|
|
123
123
|
## `twilio flex:plugins:build`
|
|
124
124
|
|
|
@@ -135,7 +135,7 @@ OPTIONS
|
|
|
135
135
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
_See code: [dist/commands/flex/plugins/build.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
138
|
+
_See code: [dist/commands/flex/plugins/build.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/build.js)_
|
|
139
139
|
|
|
140
140
|
## `twilio flex:plugins:create NAME`
|
|
141
141
|
|
|
@@ -166,7 +166,7 @@ DESCRIPTION
|
|
|
166
166
|
name Name of your plugin. This command needs to be invoked inside a plugin directory.
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
_See code: [dist/commands/flex/plugins/create.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
169
|
+
_See code: [dist/commands/flex/plugins/create.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/create.js)_
|
|
170
170
|
|
|
171
171
|
## `twilio flex:plugins:create-configuration`
|
|
172
172
|
|
|
@@ -191,7 +191,7 @@ OPTIONS
|
|
|
191
191
|
as a shortcut for enabling the latest version of the plugin. Use additional
|
|
192
192
|
--enable-plugin to provide other plugins to enable.
|
|
193
193
|
|
|
194
|
-
--name=name (required) [default: Autogenerated Release
|
|
194
|
+
--name=name (required) [default: Autogenerated Release 1642182641243] The friendly name of the
|
|
195
195
|
Flex Plugin Configuration.
|
|
196
196
|
|
|
197
197
|
--new Creates a new Flex Plugin Configuration, otherwise will append to existing active
|
|
@@ -202,7 +202,7 @@ OPTIONS
|
|
|
202
202
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
-
_See code: [dist/commands/flex/plugins/create-configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
205
|
+
_See code: [dist/commands/flex/plugins/create-configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/create-configuration.js)_
|
|
206
206
|
|
|
207
207
|
## `twilio flex:plugins:deploy`
|
|
208
208
|
|
|
@@ -226,7 +226,7 @@ OPTIONS
|
|
|
226
226
|
--version=version Publishes the version (SemVer).
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
_See code: [dist/commands/flex/plugins/deploy.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
229
|
+
_See code: [dist/commands/flex/plugins/deploy.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/deploy.js)_
|
|
230
230
|
|
|
231
231
|
## `twilio flex:plugins:describe:configuration`
|
|
232
232
|
|
|
@@ -245,7 +245,7 @@ OPTIONS
|
|
|
245
245
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
246
246
|
```
|
|
247
247
|
|
|
248
|
-
_See code: [dist/commands/flex/plugins/describe/configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
248
|
+
_See code: [dist/commands/flex/plugins/describe/configuration.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/describe/configuration.js)_
|
|
249
249
|
|
|
250
250
|
## `twilio flex:plugins:describe:plugin`
|
|
251
251
|
|
|
@@ -264,7 +264,7 @@ OPTIONS
|
|
|
264
264
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
265
265
|
```
|
|
266
266
|
|
|
267
|
-
_See code: [dist/commands/flex/plugins/describe/plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
267
|
+
_See code: [dist/commands/flex/plugins/describe/plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/describe/plugin.js)_
|
|
268
268
|
|
|
269
269
|
## `twilio flex:plugins:describe:plugin-version`
|
|
270
270
|
|
|
@@ -284,7 +284,7 @@ OPTIONS
|
|
|
284
284
|
--version=version (required) The Flex Plugin Version to describe.
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
_See code: [dist/commands/flex/plugins/describe/plugin-version.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
287
|
+
_See code: [dist/commands/flex/plugins/describe/plugin-version.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/describe/plugin-version.js)_
|
|
288
288
|
|
|
289
289
|
## `twilio flex:plugins:describe:release`
|
|
290
290
|
|
|
@@ -304,7 +304,7 @@ OPTIONS
|
|
|
304
304
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
305
305
|
```
|
|
306
306
|
|
|
307
|
-
_See code: [dist/commands/flex/plugins/describe/release.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
307
|
+
_See code: [dist/commands/flex/plugins/describe/release.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/describe/release.js)_
|
|
308
308
|
|
|
309
309
|
## `twilio flex:plugins:diff ID1 [ID2]`
|
|
310
310
|
|
|
@@ -325,7 +325,7 @@ OPTIONS
|
|
|
325
325
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
326
326
|
```
|
|
327
327
|
|
|
328
|
-
_See code: [dist/commands/flex/plugins/diff.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
328
|
+
_See code: [dist/commands/flex/plugins/diff.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/diff.js)_
|
|
329
329
|
|
|
330
330
|
## `twilio flex:plugins:list:configurations`
|
|
331
331
|
|
|
@@ -343,7 +343,7 @@ OPTIONS
|
|
|
343
343
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
344
344
|
```
|
|
345
345
|
|
|
346
|
-
_See code: [dist/commands/flex/plugins/list/configurations.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
346
|
+
_See code: [dist/commands/flex/plugins/list/configurations.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/list/configurations.js)_
|
|
347
347
|
|
|
348
348
|
## `twilio flex:plugins:list:plugin-versions`
|
|
349
349
|
|
|
@@ -362,7 +362,7 @@ OPTIONS
|
|
|
362
362
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
363
363
|
```
|
|
364
364
|
|
|
365
|
-
_See code: [dist/commands/flex/plugins/list/plugin-versions.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
365
|
+
_See code: [dist/commands/flex/plugins/list/plugin-versions.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/list/plugin-versions.js)_
|
|
366
366
|
|
|
367
367
|
## `twilio flex:plugins:list:plugins`
|
|
368
368
|
|
|
@@ -380,7 +380,7 @@ OPTIONS
|
|
|
380
380
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
381
381
|
```
|
|
382
382
|
|
|
383
|
-
_See code: [dist/commands/flex/plugins/list/plugins.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
383
|
+
_See code: [dist/commands/flex/plugins/list/plugins.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/list/plugins.js)_
|
|
384
384
|
|
|
385
385
|
## `twilio flex:plugins:list:releases`
|
|
386
386
|
|
|
@@ -398,7 +398,7 @@ OPTIONS
|
|
|
398
398
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
399
399
|
```
|
|
400
400
|
|
|
401
|
-
_See code: [dist/commands/flex/plugins/list/releases.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
401
|
+
_See code: [dist/commands/flex/plugins/list/releases.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/list/releases.js)_
|
|
402
402
|
|
|
403
403
|
## `twilio flex:plugins:release`
|
|
404
404
|
|
|
@@ -426,7 +426,7 @@ OPTIONS
|
|
|
426
426
|
pluginName@latest as a shortcut for enabling the latest version of the plugin.
|
|
427
427
|
Use additional --enable-plugin to provide other plugins to enable.
|
|
428
428
|
|
|
429
|
-
--name=name [default: Autogenerated Release
|
|
429
|
+
--name=name [default: Autogenerated Release 1642182641243] The friendly name of the Flex
|
|
430
430
|
Plugin Configuration.
|
|
431
431
|
|
|
432
432
|
--new Creates a new Flex Plugin Configuration, otherwise will append to existing
|
|
@@ -437,7 +437,7 @@ OPTIONS
|
|
|
437
437
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
438
438
|
```
|
|
439
439
|
|
|
440
|
-
_See code: [dist/commands/flex/plugins/release.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
440
|
+
_See code: [dist/commands/flex/plugins/release.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/release.js)_
|
|
441
441
|
|
|
442
442
|
## `twilio flex:plugins:start`
|
|
443
443
|
|
|
@@ -462,7 +462,7 @@ OPTIONS
|
|
|
462
462
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
463
463
|
```
|
|
464
464
|
|
|
465
|
-
_See code: [dist/commands/flex/plugins/start.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
465
|
+
_See code: [dist/commands/flex/plugins/start.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/start.js)_
|
|
466
466
|
|
|
467
467
|
## `twilio flex:plugins:test`
|
|
468
468
|
|
|
@@ -479,7 +479,7 @@ OPTIONS
|
|
|
479
479
|
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
|
|
480
480
|
```
|
|
481
481
|
|
|
482
|
-
_See code: [dist/commands/flex/plugins/test.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
482
|
+
_See code: [dist/commands/flex/plugins/test.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/test.js)_
|
|
483
483
|
|
|
484
484
|
## `twilio flex:plugins:upgrade-plugin`
|
|
485
485
|
|
|
@@ -495,7 +495,6 @@ OPTIONS
|
|
|
495
495
|
--beta If set, will upgrade to the latest beta version.
|
|
496
496
|
--clear-terminal Clears the terminal before running the command.
|
|
497
497
|
--dev If set, will upgrade to the latest dev version.
|
|
498
|
-
--flex-ui-2.0 Update your plugin dependencies to be compatible with Flex UI 2.0.
|
|
499
498
|
--install If set, will install the dependencies.
|
|
500
499
|
--nightly If set, will upgrade to the latest nightly version.
|
|
501
500
|
|
|
@@ -509,5 +508,5 @@ OPTIONS
|
|
|
509
508
|
--yes If set, will answer yes to all prompts.
|
|
510
509
|
```
|
|
511
510
|
|
|
512
|
-
_See code: [dist/commands/flex/plugins/upgrade-plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0
|
|
511
|
+
_See code: [dist/commands/flex/plugins/upgrade-plugin.js](https://github.com/twilio/flex-plugin-builder/blob/v4.3.0/dist/commands/flex/plugins/upgrade-plugin.js)_
|
|
513
512
|
<!-- commandsstop -->
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ServiceInstance, ServiceListInstance, ServiceListInstanceCreateOptions } from 'twilio/lib/rest/serverless/v1/service';
|
|
2
|
+
import { BuildInstance, BuildListInstanceCreateOptions } from 'twilio/lib/rest/serverless/v1/service/build';
|
|
2
3
|
import { Logger } from 'flex-dev-utils';
|
|
4
|
+
import { EnvironmentInstance } from 'twilio/lib/rest/serverless/v1/service/environment';
|
|
3
5
|
/**
|
|
4
6
|
* Wrapper Twilio Serverless Public API
|
|
5
7
|
*/
|
|
@@ -40,6 +42,31 @@ export default class ServerlessClient {
|
|
|
40
42
|
* @param pluginName the plugin name
|
|
41
43
|
*/
|
|
42
44
|
removeLegacy(serviceSid: string, pluginName: string): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a {@link BuildInstance} and deploys/activates it
|
|
47
|
+
* @param serviceSid the serviceSid the {@link BuildInstance} belongs to
|
|
48
|
+
* @param pluginName the plugin name that the build belongs to
|
|
49
|
+
* @param request the {@link BuildListInstanceCreateOptions} option
|
|
50
|
+
*/
|
|
51
|
+
createBuildAndDeploy(serviceSid: string, pluginName: string, request: BuildListInstanceCreateOptions): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the {@link BuildInstance} belonging to the plugin name
|
|
54
|
+
* @param serviceSid the service sid
|
|
55
|
+
* @param pluginName the plugin name
|
|
56
|
+
*/
|
|
57
|
+
getBuild(serviceSid: string, pluginName: string): Promise<BuildInstance | undefined>;
|
|
58
|
+
/**
|
|
59
|
+
* Deletes the {@link EnvironmentInstance}
|
|
60
|
+
* @param serviceSid the service sid
|
|
61
|
+
* @param environment the environment sid
|
|
62
|
+
*/
|
|
63
|
+
deleteEnvironment(serviceSid: string, environmentSid: string): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the {@link EnvironmentInstance}
|
|
66
|
+
* @param serviceSid the service sid
|
|
67
|
+
* @param pluginName the plugin name
|
|
68
|
+
*/
|
|
69
|
+
getEnvironment(serviceSid: string, pluginName: string): Promise<EnvironmentInstance | null>;
|
|
43
70
|
/**
|
|
44
71
|
* Fetches the {@link BuildInstance}
|
|
45
72
|
* @param serviceSid the service sid
|
|
@@ -72,15 +72,66 @@ class ServerlessClient {
|
|
|
72
72
|
.filter((asset) => !asset.path.includes(`/plugins/${pluginName}/0.0.0/bundle.js`))
|
|
73
73
|
.map((asset) => asset.sid);
|
|
74
74
|
const functions = build.functionVersions.map((func) => func).map((func) => func.sid);
|
|
75
|
-
const
|
|
75
|
+
const request = {
|
|
76
76
|
assetVersions: assets,
|
|
77
77
|
functionVersions: functions,
|
|
78
78
|
// @ts-ignore this is a type definition error in Twilio; dependencies should be object[] not a string
|
|
79
79
|
dependencies: build.dependencies,
|
|
80
80
|
};
|
|
81
|
-
|
|
81
|
+
await this.createBuildAndDeploy(serviceSid, pluginName, request);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a {@link BuildInstance} and deploys/activates it
|
|
85
|
+
* @param serviceSid the serviceSid the {@link BuildInstance} belongs to
|
|
86
|
+
* @param pluginName the plugin name that the build belongs to
|
|
87
|
+
* @param request the {@link BuildListInstanceCreateOptions} option
|
|
88
|
+
*/
|
|
89
|
+
async createBuildAndDeploy(serviceSid, pluginName, request) {
|
|
90
|
+
const { environment } = await this.getBuildAndEnvironment(serviceSid, pluginName);
|
|
91
|
+
if (!environment) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const newBuild = await this.createBuild(serviceSid, request);
|
|
82
95
|
await environment.deployments().create({ buildSid: newBuild.sid });
|
|
83
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns the {@link BuildInstance} belonging to the plugin name
|
|
99
|
+
* @param serviceSid the service sid
|
|
100
|
+
* @param pluginName the plugin name
|
|
101
|
+
*/
|
|
102
|
+
async getBuild(serviceSid, pluginName) {
|
|
103
|
+
const { build } = await this.getBuildAndEnvironment(serviceSid, pluginName);
|
|
104
|
+
return build;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Deletes the {@link EnvironmentInstance}
|
|
108
|
+
* @param serviceSid the service sid
|
|
109
|
+
* @param environment the environment sid
|
|
110
|
+
*/
|
|
111
|
+
async deleteEnvironment(serviceSid, environmentSid) {
|
|
112
|
+
const service = await this.getService(serviceSid);
|
|
113
|
+
if (!service) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return service.environments().get(environmentSid).remove();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns the {@link EnvironmentInstance}
|
|
120
|
+
* @param serviceSid the service sid
|
|
121
|
+
* @param pluginName the plugin name
|
|
122
|
+
*/
|
|
123
|
+
async getEnvironment(serviceSid, pluginName) {
|
|
124
|
+
const service = await this.getService(serviceSid);
|
|
125
|
+
if (!service) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const list = await service.environments().list();
|
|
129
|
+
const environment = list.find((e) => e.uniqueName === pluginName);
|
|
130
|
+
if (!environment || !environment.sid) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return environment;
|
|
134
|
+
}
|
|
84
135
|
/**
|
|
85
136
|
* Fetches the {@link BuildInstance}
|
|
86
137
|
* @param serviceSid the service sid
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerlessClient.js","sourceRoot":"","sources":["../../src/clients/ServerlessClient.ts"],"names":[],"mappings":";;AAMA,mDAAwD;AAaxD;;GAEG;AACH,MAAqB,gBAAgB;IAcnC,YAAY,MAA2B,EAAE,MAAc;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAC,UAAkB;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,yBAAyB;QAC7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAC1F,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC;SAChB;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,iBAAiB,CAAC,UAAkB;QACxC,M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AAC;oBAC1B,YAAY,CAAC,SAAS,CAAC,CAAC;oBAExB,OAAO,CAAC,KAAK,CAAC,CAAC;iBAChB;YACH,CAAC,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACK,cAAc,CAAC,KAAoB,EAAE,UAAkB;QAC7D,OAAO,KAAK,CAAC,aAAa;aACvB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAoB,CAAC;aACpC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,UAAU,kBAAkB,CAAC,CAAC;IAC9E,CAAC;;AArPH,mCAsPC;AArPe,2BAAU,GAAqC;IAC3D,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,sDAAsD;CACrE,CAAC;AAEK,4BAAW,GAAG,KAAK,CAAC;AAEpB,oCAAmB,GAAG,GAAG,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Configuration } from 'flex-plugins-api-
|
|
1
|
+
import { Configuration } from 'flex-plugins-api-client';
|
|
2
2
|
import { OutputFlags } from '@oclif/parser/lib/parse';
|
|
3
3
|
import * as flags from '../../../../utils/flags';
|
|
4
4
|
import ArchiveResource from '../../../../sub-commands/archive-resource';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginVersion } from 'flex-plugins-api-
|
|
1
|
+
import { PluginVersion } from 'flex-plugins-api-client';
|
|
2
2
|
import { OutputFlags } from '@oclif/parser/lib/parse';
|
|
3
3
|
import * as flags from '../../../../utils/flags';
|
|
4
4
|
import ArchiveResource from '../../../../sub-commands/archive-resource';
|
|
@@ -24,6 +24,28 @@ export default class FlexPluginsArchivePluginVersion extends ArchiveResource<Plu
|
|
|
24
24
|
* @override
|
|
25
25
|
*/
|
|
26
26
|
getResourceType(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Archives the resource on flex-plugins-api service
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
private archiveOnPluginsAPI;
|
|
32
|
+
/**
|
|
33
|
+
* Removes the serverless files
|
|
34
|
+
* @param build the active {@link BuildInstance} to remove the files from
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
private removeServerlessFiles;
|
|
38
|
+
/**
|
|
39
|
+
* Filters the asset by path
|
|
40
|
+
* @param asset the asset to filter
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
private filterAssetExists;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the {@link BuildInstance} if found. It will also return undefined if the pluginVersion is not part of this build
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
private getBuildIfActive;
|
|
27
49
|
/**
|
|
28
50
|
* @override
|
|
29
51
|
*/
|
|
@@ -22,15 +22,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const flex_dev_utils_1 = require("flex-dev-utils");
|
|
25
26
|
const flags = __importStar(require("../../../../utils/flags"));
|
|
26
27
|
const archive_resource_1 = __importDefault(require("../../../../sub-commands/archive-resource"));
|
|
27
28
|
const general_1 = require("../../../../utils/general");
|
|
28
29
|
class FlexPluginsArchivePluginVersion extends archive_resource_1.default {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
/**
|
|
33
|
+
* Filters the asset by path
|
|
34
|
+
* @param asset the asset to filter
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
// The type definition for this from the twilio-node library is broken
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
39
|
+
this.filterAssetExists = (asset) => {
|
|
40
|
+
const path = `/plugins/${this._flags.name}/${this._flags.version}/`;
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
return asset.path.includes(path);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
29
45
|
/**
|
|
30
46
|
* @override
|
|
31
47
|
*/
|
|
32
48
|
async doArchive() {
|
|
33
|
-
|
|
49
|
+
const pluginVersion = await flex_dev_utils_1.progress('Archiving Flex Plugin Version', async () => this.archiveOnPluginsAPI());
|
|
50
|
+
await flex_dev_utils_1.progress('Cleaning up Twilio Assets', async () => {
|
|
51
|
+
const build = await this.getBuildIfActive();
|
|
52
|
+
if (!build) {
|
|
53
|
+
throw new flex_dev_utils_1.TwilioApiError(20400, 'Plugin version is already archived', 400);
|
|
54
|
+
}
|
|
55
|
+
await this.removeServerlessFiles(build);
|
|
56
|
+
});
|
|
57
|
+
return pluginVersion;
|
|
34
58
|
}
|
|
35
59
|
/**
|
|
36
60
|
* @override
|
|
@@ -45,6 +69,67 @@ class FlexPluginsArchivePluginVersion extends archive_resource_1.default {
|
|
|
45
69
|
getResourceType() {
|
|
46
70
|
return 'Flex Plugin Version';
|
|
47
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Archives the resource on flex-plugins-api service
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
async archiveOnPluginsAPI() {
|
|
77
|
+
try {
|
|
78
|
+
return await this.pluginsApiToolkit.archivePluginVersion({
|
|
79
|
+
name: this._flags.name,
|
|
80
|
+
version: this._flags.version,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
if (general_1.instanceOf(e, flex_dev_utils_1.TwilioApiError) && e.status === 400) {
|
|
85
|
+
return this.pluginsApiToolkit.describePluginVersion({
|
|
86
|
+
name: this._flags.name,
|
|
87
|
+
version: this._flags.version,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Removes the serverless files
|
|
95
|
+
* @param build the active {@link BuildInstance} to remove the files from
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
async removeServerlessFiles(build) {
|
|
99
|
+
var _a, _b, _c, _d;
|
|
100
|
+
const request = {
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
+
functionVersions: (_a = build.functionVersions) === null || _a === void 0 ? void 0 : _a.map((f) => f.sid),
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
+
assetVersions: (_b = build.assetVersions) === null || _b === void 0 ? void 0 : _b.filter((a) => !this.filterAssetExists(a)).map((a) => a.sid),
|
|
105
|
+
// @ts-ignore this is a type definition error in Twilio; dependencies should be object[] not a string
|
|
106
|
+
dependencies: build.dependencies,
|
|
107
|
+
runtime: 'node12',
|
|
108
|
+
};
|
|
109
|
+
if (((_c = request.assetVersions) === null || _c === void 0 ? void 0 : _c.length) === 0 && ((_d = request.functionVersions) === null || _d === void 0 ? void 0 : _d.length) === 0) {
|
|
110
|
+
const environment = await this.serverlessClient.getEnvironment(build.serviceSid, this._flags.name);
|
|
111
|
+
if (environment) {
|
|
112
|
+
await this.serverlessClient.deleteEnvironment(build.serviceSid, environment.sid);
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
await this.serverlessClient.createBuildAndDeploy(build.serviceSid, this._flags.name, request);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns the {@link BuildInstance} if found. It will also return undefined if the pluginVersion is not part of this build
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
122
|
+
async getBuildIfActive() {
|
|
123
|
+
const serviceSid = await this.flexConfigurationClient.getServerlessSid();
|
|
124
|
+
if (!serviceSid) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
const build = await this.serverlessClient.getBuild(serviceSid, this._flags.name);
|
|
128
|
+
if (!(build === null || build === void 0 ? void 0 : build.assetVersions.find(this.filterAssetExists))) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
return build;
|
|
132
|
+
}
|
|
48
133
|
/**
|
|
49
134
|
* @override
|
|
50
135
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-version.js","sourceRoot":"","sources":["../../../../../src/commands/flex/plugins/archive/plugin-version.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugin-version.js","sourceRoot":"","sources":["../../../../../src/commands/flex/plugins/archive/plugin-version.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,mDAA0D;AAI1D,+DAAiD;AACjD,iGAAwE;AACxE,uDAA0E;AAE1E,MAAqB,+BAAgC,SAAQ,0BAA8B;IAA3F;;QAkGE;;;;WAIG;QACH,uEAAuE;QACvE,wDAAwD;QAChD,sBAAiB,GAAG,CAAC,KAAa,EAAE,EAAE;YAC5C,MAAM,IAAI,GAAG,YAAY,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC;YACpE,8DAA8D;YAC9D,OAAQ,KAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC,CAAC;IA2BJ,CAAC;IAvHC;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,aAAa,GAAG,MAAM,yBAAQ,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAC9G,MAAM,yBAAQ,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;YACrD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC5C,IAAI,CAAC,KAAK,EAAE;gBACV,MAAM,IAAI,+BAAc,CAAC,KAAK,EAAE,oCAAoC,EAAE,GAAG,CAAC,CAAC;aAC5E;YACD,MAAM,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEH,O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KAAK,CAAC,+BAA+B,CAAC,CAAC,KAAK,CAAC;IAC3D,CAAC;;AAvIH,kDAwIC;AAvIQ,yCAAS,GAAG,qCAAqC,CAAC;AAElD,2CAAW,GAAG,2BAAiB,CAAC,+BAA+B,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAE1F,qCAAK,mCACP,0BAAe,CAAC,KAAK,KACxB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;QACjB,WAAW,EAAE,+BAA+B,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI;QAC7D,QAAQ,EAAE,IAAI;KACf,CAAC,EACF,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,+BAA+B,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO;QAChE,QAAQ,EAAE,IAAI;KACf,CAAC,IACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from 'flex-plugins-api-
|
|
1
|
+
import { Plugin } from 'flex-plugins-api-client';
|
|
2
2
|
import { OutputFlags } from '@oclif/parser/lib/parse';
|
|
3
3
|
import * as flags from '../../../../utils/flags';
|
|
4
4
|
import ArchiveResource from '../../../../sub-commands/archive-resource';
|
|
@@ -23,6 +23,17 @@ export default class FlexPluginsArchivePlugin extends ArchiveResource<Plugin> {
|
|
|
23
23
|
* @override
|
|
24
24
|
*/
|
|
25
25
|
getResourceType(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Archives the resource on flex-plugins-api service
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
private archiveOnPluginsAPI;
|
|
31
|
+
/**
|
|
32
|
+
* Removes the {@link EnvironmentInstance}
|
|
33
|
+
* @param alreadyArchived whether the resource on plugins-api is already archived or not
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
private removeServerlessEnvironment;
|
|
26
37
|
/**
|
|
27
38
|
* @override
|
|
28
39
|
*/
|
|
@@ -22,6 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const flex_dev_utils_1 = require("flex-dev-utils");
|
|
25
26
|
const flags = __importStar(require("../../../../utils/flags"));
|
|
26
27
|
const archive_resource_1 = __importDefault(require("../../../../sub-commands/archive-resource"));
|
|
27
28
|
const general_1 = require("../../../../utils/general");
|
|
@@ -30,7 +31,9 @@ class FlexPluginsArchivePlugin extends archive_resource_1.default {
|
|
|
30
31
|
* @override
|
|
31
32
|
*/
|
|
32
33
|
async doArchive() {
|
|
33
|
-
|
|
34
|
+
const response = await flex_dev_utils_1.progress('Archiving Flex Plugin', async () => this.archiveOnPluginsAPI());
|
|
35
|
+
await flex_dev_utils_1.progress('Cleaning up Twilio Environment', async () => this.removeServerlessEnvironment(response.alreadyArchived));
|
|
36
|
+
return response.plugin;
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
36
39
|
* @override
|
|
@@ -44,6 +47,56 @@ class FlexPluginsArchivePlugin extends archive_resource_1.default {
|
|
|
44
47
|
getResourceType() {
|
|
45
48
|
return 'Flex Plugin';
|
|
46
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Archives the resource on flex-plugins-api service
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
async archiveOnPluginsAPI() {
|
|
55
|
+
try {
|
|
56
|
+
const plugin = await this.pluginsApiToolkit.archivePlugin({ name: this._flags.name });
|
|
57
|
+
return {
|
|
58
|
+
plugin,
|
|
59
|
+
alreadyArchived: false,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
if (general_1.instanceOf(e, flex_dev_utils_1.TwilioApiError) && e.status === 400) {
|
|
64
|
+
const plugin = await this.pluginsApiToolkit.describePlugin({
|
|
65
|
+
name: this._flags.name,
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
plugin,
|
|
69
|
+
alreadyArchived: true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
throw e;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Removes the {@link EnvironmentInstance}
|
|
77
|
+
* @param alreadyArchived whether the resource on plugins-api is already archived or not
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
async removeServerlessEnvironment(alreadyArchived) {
|
|
81
|
+
const serviceSid = await this.flexConfigurationClient.getServerlessSid();
|
|
82
|
+
if (!serviceSid) {
|
|
83
|
+
if (alreadyArchived) {
|
|
84
|
+
throw new flex_dev_utils_1.TwilioApiError(20400, 'Plugin is already archived', 400);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const environment = await this.serverlessClient.getEnvironment(serviceSid, this._flags.name);
|
|
89
|
+
if (!environment) {
|
|
90
|
+
if (alreadyArchived) {
|
|
91
|
+
throw new flex_dev_utils_1.TwilioApiError(20400, 'Plugin is already archived', 400);
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const isSuccessful = await this.serverlessClient.deleteEnvironment(serviceSid, environment.sid);
|
|
96
|
+
if (!isSuccessful) {
|
|
97
|
+
throw new flex_dev_utils_1.TwilioCliError('Could not archive your plugin due to failure in deleting the environment hosting your plugin. Please retry by running the archive command.');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
47
100
|
/**
|
|
48
101
|
* @override
|
|
49
102
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../../src/commands/flex/plugins/archive/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../../src/commands/flex/plugins/archive/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA,mDAA0E;AAE1E,+DAAiD;AACjD,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("@oclif/parser/lib/errors");
|
|
29
29
|
const flex_dev_utils_1 = require("flex-dev-utils");
|
|
30
30
|
const fs_1 = require("flex-dev-utils/dist/fs");
|
|
31
|
-
const inquirer_1 = require("flex-dev-utils/dist/inquirer");
|
|
32
31
|
const flags = __importStar(require("../../../utils/flags"));
|
|
33
32
|
const general_1 = require("../../../utils/general");
|
|
34
33
|
const flex_plugin_1 = __importDefault(require("../../../sub-commands/flex-plugin"));
|
|
@@ -108,7 +107,7 @@ class FlexPluginsDeploy extends flex_plugin_1.default {
|
|
|
108
107
|
if (!collision) {
|
|
109
108
|
return false;
|
|
110
109
|
}
|
|
111
|
-
return
|
|
110
|
+
return flex_dev_utils_1.confirm('Plugin package has already been uploaded previously for this version of the plugin. Would you like to overwrite it?', 'N');
|
|
112
111
|
}
|
|
113
112
|
/**
|
|
114
113
|
* Validates that the provided next plugin version is valid
|