@mux/cli 0.6.2 → 0.8.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 +93 -38
- package/lib/command-bases/asset-base.d.ts +5 -3
- package/lib/command-bases/base.d.ts +4 -3
- package/lib/command-bases/base.js +26 -18
- package/lib/commands/assets/create.js +6 -1
- package/lib/commands/assets/upload.d.ts +7 -7
- package/lib/commands/assets/upload.js +9 -1
- package/lib/commands/init.d.ts +7 -6
- package/lib/commands/init.js +22 -3
- package/lib/commands/live/complete.js +6 -1
- package/lib/commands/live/disable.js +6 -1
- package/lib/commands/live/enable.js +6 -1
- package/lib/commands/sign.d.ts +1 -5
- package/lib/commands/sign.js +29 -12
- package/lib/commands/spaces/sign.d.ts +11 -0
- package/lib/commands/spaces/sign.js +79 -0
- package/lib/config.d.ts +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +34 -32
- package/src/command-bases/asset-base.ts +6 -1
- package/src/command-bases/base.ts +35 -24
- package/src/commands/assets/create.ts +6 -1
- package/src/commands/assets/upload.ts +19 -5
- package/src/commands/init.ts +31 -9
- package/src/commands/live/complete.ts +6 -1
- package/src/commands/live/disable.ts +6 -1
- package/src/commands/live/enable.ts +6 -1
- package/src/commands/sign.ts +34 -15
- package/src/commands/spaces/sign.ts +90 -0
- package/yarn.lock +2452 -1301
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# mux-cli
|
|
2
2
|
|
|
3
|
-
Your friendly neighborhood Mux CLI tool
|
|
3
|
+
Your friendly neighborhood Mux CLI tool. **Requires Node 14 or newer.**
|
|
4
4
|
|
|
5
5
|
[](https://oclif.io)
|
|
6
6
|
[](https://npmjs.org/package/@mux/cli)
|
|
@@ -21,7 +21,7 @@ $ npm install -g @mux/cli
|
|
|
21
21
|
$ mux COMMAND
|
|
22
22
|
running command...
|
|
23
23
|
$ mux (-v|--version|version)
|
|
24
|
-
@mux/cli/0.
|
|
24
|
+
@mux/cli/0.8.0 linux-x64 node-v14.18.3
|
|
25
25
|
$ mux --help [COMMAND]
|
|
26
26
|
USAGE
|
|
27
27
|
$ mux COMMAND
|
|
@@ -42,11 +42,13 @@ USAGE
|
|
|
42
42
|
* [`mux live:disable STREAMNAME`](#mux-livedisable-streamname)
|
|
43
43
|
* [`mux live:enable STREAMNAME`](#mux-liveenable-streamname)
|
|
44
44
|
* [`mux plugins`](#mux-plugins)
|
|
45
|
+
* [`mux plugins:inspect PLUGIN...`](#mux-pluginsinspect-plugin)
|
|
45
46
|
* [`mux plugins:install PLUGIN...`](#mux-pluginsinstall-plugin)
|
|
46
47
|
* [`mux plugins:link PLUGIN`](#mux-pluginslink-plugin)
|
|
47
48
|
* [`mux plugins:uninstall PLUGIN...`](#mux-pluginsuninstall-plugin)
|
|
48
49
|
* [`mux plugins:update`](#mux-pluginsupdate)
|
|
49
50
|
* [`mux sign PLAYBACK-ID`](#mux-sign-playback-id)
|
|
51
|
+
* [`mux spaces:sign SPACE-ID`](#mux-spacessign-space-id)
|
|
50
52
|
* [`mux update [CHANNEL]`](#mux-update-channel)
|
|
51
53
|
|
|
52
54
|
## `mux assets:create INPUT`
|
|
@@ -64,7 +66,7 @@ OPTIONS
|
|
|
64
66
|
-p, --private add a private playback policy to the created asset
|
|
65
67
|
```
|
|
66
68
|
|
|
67
|
-
_See code: [src/commands/assets/create.ts](https://github.com/muxinc/cli/blob/v0.
|
|
69
|
+
_See code: [src/commands/assets/create.ts](https://github.com/muxinc/cli/blob/v0.8.0/src/commands/assets/create.ts)_
|
|
68
70
|
|
|
69
71
|
## `mux assets:upload PATH`
|
|
70
72
|
|
|
@@ -80,10 +82,10 @@ ARGUMENTS
|
|
|
80
82
|
OPTIONS
|
|
81
83
|
-c, --concurrent=concurrent [default: 3] max number of files to upload at once
|
|
82
84
|
-f, --filter=filter regex that filters the selected destination if the provided path is a folder
|
|
83
|
-
-p, --private
|
|
85
|
+
-p, --private
|
|
84
86
|
```
|
|
85
87
|
|
|
86
|
-
_See code: [src/commands/assets/upload.ts](https://github.com/muxinc/cli/blob/v0.
|
|
88
|
+
_See code: [src/commands/assets/upload.ts](https://github.com/muxinc/cli/blob/v0.8.0/src/commands/assets/upload.ts)_
|
|
87
89
|
|
|
88
90
|
## `mux autocomplete [SHELL]`
|
|
89
91
|
|
|
@@ -106,7 +108,7 @@ EXAMPLES
|
|
|
106
108
|
$ mux autocomplete --refresh-cache
|
|
107
109
|
```
|
|
108
110
|
|
|
109
|
-
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/
|
|
111
|
+
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.1.1/src/commands/autocomplete/index.ts)_
|
|
110
112
|
|
|
111
113
|
## `mux commands`
|
|
112
114
|
|
|
@@ -117,20 +119,20 @@ USAGE
|
|
|
117
119
|
$ mux commands
|
|
118
120
|
|
|
119
121
|
OPTIONS
|
|
120
|
-
-h, --help
|
|
121
|
-
-j, --json display unfiltered api data in json format
|
|
122
|
+
-h, --help Show CLI help.
|
|
122
123
|
-x, --extended show extra columns
|
|
123
124
|
--columns=columns only show provided columns (comma-separated)
|
|
124
125
|
--csv output is csv format [alias: --output=csv]
|
|
125
126
|
--filter=filter filter property by partial string matching, ex: name=foo
|
|
126
127
|
--hidden show hidden commands
|
|
128
|
+
--json Format output as json.
|
|
127
129
|
--no-header hide table header from output
|
|
128
130
|
--no-truncate do not truncate output to fit screen
|
|
129
131
|
--output=csv|json|yaml output in a more machine friendly format
|
|
130
132
|
--sort=sort property to sort by (prepend '-' for descending)
|
|
131
133
|
```
|
|
132
134
|
|
|
133
|
-
_See code: [@oclif/plugin-commands](https://github.com/oclif/plugin-commands/blob/
|
|
135
|
+
_See code: [@oclif/plugin-commands](https://github.com/oclif/plugin-commands/blob/v2.0.2/src/commands/commands.ts)_
|
|
134
136
|
|
|
135
137
|
## `mux help [COMMAND]`
|
|
136
138
|
|
|
@@ -147,7 +149,7 @@ OPTIONS
|
|
|
147
149
|
--all see all commands in CLI
|
|
148
150
|
```
|
|
149
151
|
|
|
150
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.
|
|
152
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.18/src/commands/help.ts)_
|
|
151
153
|
|
|
152
154
|
## `mux init [ENVFILE]`
|
|
153
155
|
|
|
@@ -159,9 +161,12 @@ USAGE
|
|
|
159
161
|
|
|
160
162
|
ARGUMENTS
|
|
161
163
|
ENVFILE path to a Mux access token .env file
|
|
164
|
+
|
|
165
|
+
OPTIONS
|
|
166
|
+
-f, --force Will initialize a new file even if one already exists.
|
|
162
167
|
```
|
|
163
168
|
|
|
164
|
-
_See code: [src/commands/init.ts](https://github.com/muxinc/cli/blob/v0.
|
|
169
|
+
_See code: [src/commands/init.ts](https://github.com/muxinc/cli/blob/v0.8.0/src/commands/init.ts)_
|
|
165
170
|
|
|
166
171
|
## `mux live:complete STREAMNAME`
|
|
167
172
|
|
|
@@ -179,7 +184,7 @@ OPTIONS
|
|
|
179
184
|
-t, --streamId=stream-id [default: stream-id] the type of the provided reference name
|
|
180
185
|
```
|
|
181
186
|
|
|
182
|
-
_See code: [src/commands/live/complete.ts](https://github.com/muxinc/cli/blob/v0.
|
|
187
|
+
_See code: [src/commands/live/complete.ts](https://github.com/muxinc/cli/blob/v0.8.0/src/commands/live/complete.ts)_
|
|
183
188
|
|
|
184
189
|
## `mux live:disable STREAMNAME`
|
|
185
190
|
|
|
@@ -196,7 +201,7 @@ OPTIONS
|
|
|
196
201
|
-t, --streamId=stream-id [default: stream-id] the type of the provided reference name
|
|
197
202
|
```
|
|
198
203
|
|
|
199
|
-
_See code: [src/commands/live/disable.ts](https://github.com/muxinc/cli/blob/v0.
|
|
204
|
+
_See code: [src/commands/live/disable.ts](https://github.com/muxinc/cli/blob/v0.8.0/src/commands/live/disable.ts)_
|
|
200
205
|
|
|
201
206
|
## `mux live:enable STREAMNAME`
|
|
202
207
|
|
|
@@ -213,39 +218,60 @@ OPTIONS
|
|
|
213
218
|
-t, --streamId=stream-id [default: stream-id] the type of the provided reference name
|
|
214
219
|
```
|
|
215
220
|
|
|
216
|
-
_See code: [src/commands/live/enable.ts](https://github.com/muxinc/cli/blob/v0.
|
|
221
|
+
_See code: [src/commands/live/enable.ts](https://github.com/muxinc/cli/blob/v0.8.0/src/commands/live/enable.ts)_
|
|
217
222
|
|
|
218
223
|
## `mux plugins`
|
|
219
224
|
|
|
220
|
-
|
|
225
|
+
List installed plugins.
|
|
221
226
|
|
|
222
227
|
```
|
|
223
228
|
USAGE
|
|
224
229
|
$ mux plugins
|
|
225
230
|
|
|
226
231
|
OPTIONS
|
|
227
|
-
--core
|
|
232
|
+
--core Show core plugins.
|
|
228
233
|
|
|
229
234
|
EXAMPLE
|
|
230
235
|
$ mux plugins
|
|
231
236
|
```
|
|
232
237
|
|
|
233
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
238
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/index.ts)_
|
|
239
|
+
|
|
240
|
+
## `mux plugins:inspect PLUGIN...`
|
|
241
|
+
|
|
242
|
+
Displays installation properties of a plugin.
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
USAGE
|
|
246
|
+
$ mux plugins:inspect PLUGIN...
|
|
247
|
+
|
|
248
|
+
ARGUMENTS
|
|
249
|
+
PLUGIN [default: .] Plugin to inspect.
|
|
250
|
+
|
|
251
|
+
OPTIONS
|
|
252
|
+
-h, --help Show CLI help.
|
|
253
|
+
-v, --verbose
|
|
254
|
+
|
|
255
|
+
EXAMPLE
|
|
256
|
+
$ mux plugins:inspect myplugin
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/inspect.ts)_
|
|
234
260
|
|
|
235
261
|
## `mux plugins:install PLUGIN...`
|
|
236
262
|
|
|
237
|
-
|
|
263
|
+
Installs a plugin into the CLI.
|
|
238
264
|
|
|
239
265
|
```
|
|
240
266
|
USAGE
|
|
241
267
|
$ mux plugins:install PLUGIN...
|
|
242
268
|
|
|
243
269
|
ARGUMENTS
|
|
244
|
-
PLUGIN
|
|
270
|
+
PLUGIN Plugin to install.
|
|
245
271
|
|
|
246
272
|
OPTIONS
|
|
247
|
-
-f, --force yarn install with force flag
|
|
248
|
-
-h, --help
|
|
273
|
+
-f, --force Run yarn install with force flag.
|
|
274
|
+
-h, --help Show CLI help.
|
|
249
275
|
-v, --verbose
|
|
250
276
|
|
|
251
277
|
DESCRIPTION
|
|
@@ -266,11 +292,11 @@ EXAMPLES
|
|
|
266
292
|
$ mux plugins:install someuser/someplugin
|
|
267
293
|
```
|
|
268
294
|
|
|
269
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
295
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/install.ts)_
|
|
270
296
|
|
|
271
297
|
## `mux plugins:link PLUGIN`
|
|
272
298
|
|
|
273
|
-
|
|
299
|
+
Links a plugin into the CLI for development.
|
|
274
300
|
|
|
275
301
|
```
|
|
276
302
|
USAGE
|
|
@@ -280,24 +306,24 @@ ARGUMENTS
|
|
|
280
306
|
PATH [default: .] path to plugin
|
|
281
307
|
|
|
282
308
|
OPTIONS
|
|
283
|
-
-h, --help
|
|
309
|
+
-h, --help Show CLI help.
|
|
284
310
|
-v, --verbose
|
|
285
311
|
|
|
286
312
|
DESCRIPTION
|
|
287
313
|
Installation of a linked plugin will override a user-installed or core plugin.
|
|
288
314
|
|
|
289
|
-
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
290
|
-
|
|
315
|
+
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
316
|
+
command will override the user-installed or core plugin implementation. This is useful for development work.
|
|
291
317
|
|
|
292
318
|
EXAMPLE
|
|
293
319
|
$ mux plugins:link myplugin
|
|
294
320
|
```
|
|
295
321
|
|
|
296
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
322
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/link.ts)_
|
|
297
323
|
|
|
298
324
|
## `mux plugins:uninstall PLUGIN...`
|
|
299
325
|
|
|
300
|
-
|
|
326
|
+
Removes a plugin from the CLI.
|
|
301
327
|
|
|
302
328
|
```
|
|
303
329
|
USAGE
|
|
@@ -307,7 +333,7 @@ ARGUMENTS
|
|
|
307
333
|
PLUGIN plugin to uninstall
|
|
308
334
|
|
|
309
335
|
OPTIONS
|
|
310
|
-
-h, --help
|
|
336
|
+
-h, --help Show CLI help.
|
|
311
337
|
-v, --verbose
|
|
312
338
|
|
|
313
339
|
ALIASES
|
|
@@ -315,22 +341,22 @@ ALIASES
|
|
|
315
341
|
$ mux plugins:remove
|
|
316
342
|
```
|
|
317
343
|
|
|
318
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
344
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/uninstall.ts)_
|
|
319
345
|
|
|
320
346
|
## `mux plugins:update`
|
|
321
347
|
|
|
322
|
-
|
|
348
|
+
Update installed plugins.
|
|
323
349
|
|
|
324
350
|
```
|
|
325
351
|
USAGE
|
|
326
352
|
$ mux plugins:update
|
|
327
353
|
|
|
328
354
|
OPTIONS
|
|
329
|
-
-h, --help
|
|
355
|
+
-h, --help Show CLI help.
|
|
330
356
|
-v, --verbose
|
|
331
357
|
```
|
|
332
358
|
|
|
333
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
359
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/update.ts)_
|
|
334
360
|
|
|
335
361
|
## `mux sign PLAYBACK-ID`
|
|
336
362
|
|
|
@@ -344,13 +370,39 @@ ARGUMENTS
|
|
|
344
370
|
PLAYBACK-ID Playback ID to create a signed URL token for.
|
|
345
371
|
|
|
346
372
|
OPTIONS
|
|
347
|
-
-e, --expiresIn=expiresIn
|
|
348
|
-
|
|
373
|
+
-e, --expiresIn=expiresIn [default: 7d] How long the signature is valid for. If no unit is specified,
|
|
374
|
+
milliseconds is assumed.
|
|
375
|
+
|
|
376
|
+
-r, --raw If set, emits only the URL+JWT. Defaults to true for non-TTY.
|
|
349
377
|
|
|
350
|
-
-t, --type=video|thumbnail|gif [default: video] What type of token this signature is for.
|
|
378
|
+
-t, --type=video|thumbnail|gif|storyboard [default: video] What type of token this signature is for.
|
|
351
379
|
```
|
|
352
380
|
|
|
353
|
-
_See code: [src/commands/sign.ts](https://github.com/muxinc/cli/blob/v0.
|
|
381
|
+
_See code: [src/commands/sign.ts](https://github.com/muxinc/cli/blob/v0.8.0/src/commands/sign.ts)_
|
|
382
|
+
|
|
383
|
+
## `mux spaces:sign SPACE-ID`
|
|
384
|
+
|
|
385
|
+
Creates a new signed token for a Mux Space
|
|
386
|
+
|
|
387
|
+
```
|
|
388
|
+
USAGE
|
|
389
|
+
$ mux spaces:sign SPACE-ID
|
|
390
|
+
|
|
391
|
+
ARGUMENTS
|
|
392
|
+
SPACE-ID Space ID for which a token shall be generated.
|
|
393
|
+
|
|
394
|
+
OPTIONS
|
|
395
|
+
-R, --role=role [default: publisher] One of 'publisher' or 'subscriber'.
|
|
396
|
+
|
|
397
|
+
-e, --expiresIn=expiresIn [default: 7d] How long the signature is valid for. If no unit is specified,
|
|
398
|
+
milliseconds is assumed.
|
|
399
|
+
|
|
400
|
+
-p, --participantId=participantId Optional, user-specified participant ID.
|
|
401
|
+
|
|
402
|
+
-r, --raw prints a raw JWT to stdout (default if not tty)
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
_See code: [src/commands/spaces/sign.ts](https://github.com/muxinc/cli/blob/v0.8.0/src/commands/spaces/sign.ts)_
|
|
354
406
|
|
|
355
407
|
## `mux update [CHANNEL]`
|
|
356
408
|
|
|
@@ -359,7 +411,10 @@ update the mux CLI
|
|
|
359
411
|
```
|
|
360
412
|
USAGE
|
|
361
413
|
$ mux update [CHANNEL]
|
|
414
|
+
|
|
415
|
+
OPTIONS
|
|
416
|
+
--from-local interactively choose an already installed version
|
|
362
417
|
```
|
|
363
418
|
|
|
364
|
-
_See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/
|
|
419
|
+
_See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/v2.1.5/src/commands/update.ts)_
|
|
365
420
|
<!-- commandsstop -->
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Asset } from '@mux/mux-node';
|
|
2
|
+
import * as Parser from '@oclif/parser';
|
|
2
3
|
import CommandBase from './base';
|
|
4
|
+
export declare type AssetBaseFlags = {
|
|
5
|
+
private: Parser.flags.IBooleanFlag<boolean>;
|
|
6
|
+
};
|
|
3
7
|
export default abstract class AssetCommandBase extends CommandBase {
|
|
4
|
-
static flags:
|
|
5
|
-
private: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
6
|
-
};
|
|
8
|
+
static flags: AssetBaseFlags;
|
|
7
9
|
playbackUrl(asset: Asset): string;
|
|
8
10
|
pollAsset(assetId: string): Promise<Asset>;
|
|
9
11
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Video as MuxVideo, Data as MuxData } from '@mux/mux-node';
|
|
1
|
+
import Mux, { Video as MuxVideo, Data as MuxData, JWT as MuxJWT } from '@mux/mux-node';
|
|
2
2
|
import Command from '@oclif/command';
|
|
3
3
|
import { MuxCliConfigV1 } from '../config';
|
|
4
4
|
export declare const MUX_API_BASE_URL = "https://api.mux.com";
|
|
5
5
|
export default abstract class CommandBase extends Command {
|
|
6
6
|
configFile: string;
|
|
7
7
|
MuxConfig: MuxCliConfigV1;
|
|
8
|
+
Mux: Mux;
|
|
8
9
|
Video: MuxVideo;
|
|
9
10
|
Data: MuxData;
|
|
10
|
-
JWT:
|
|
11
|
-
readConfigV1(): Promise<MuxCliConfigV1
|
|
11
|
+
JWT: typeof MuxJWT;
|
|
12
|
+
readConfigV1(): Promise<MuxCliConfigV1>;
|
|
12
13
|
init(): Promise<void>;
|
|
13
14
|
}
|
|
@@ -15,8 +15,11 @@ class CommandBase extends command_1.default {
|
|
|
15
15
|
}
|
|
16
16
|
async readConfigV1() {
|
|
17
17
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
18
|
+
const configAlreadyExists = await fs.pathExists(this.configFile);
|
|
18
19
|
try {
|
|
19
|
-
const configRaw =
|
|
20
|
+
const configRaw = configAlreadyExists
|
|
21
|
+
? await fs.readJSON(this.configFile)
|
|
22
|
+
: {};
|
|
20
23
|
// Mux SDK configuration options
|
|
21
24
|
configRaw.tokenId = (_a = process.env.MUX_TOKEN_ID) !== null && _a !== void 0 ? _a : configRaw.tokenId;
|
|
22
25
|
configRaw.tokenSecret = (_b = process.env.MUX_TOKEN_SECRET) !== null && _b !== void 0 ? _b : configRaw.tokenSecret;
|
|
@@ -28,27 +31,32 @@ class CommandBase extends command_1.default {
|
|
|
28
31
|
return config_1.MuxCliConfigV1.check(configRaw);
|
|
29
32
|
}
|
|
30
33
|
catch (err) {
|
|
31
|
-
if (
|
|
32
|
-
|
|
34
|
+
if (configAlreadyExists) {
|
|
35
|
+
// we have a bad config file, and should say so
|
|
36
|
+
this.log(chalk `{bold.underline.red Invalid Mux configuration file found at {bold.underline.cyan ${this.configFile}}:}\n\n` +
|
|
37
|
+
Object.entries(err.details).map(tup => " - " + chalk `{cyan ${tup[0]}}` + `: ${tup[1]}`) +
|
|
38
|
+
chalk `\n\nPlease fix the file or run {bold.magenta mux init --force} to create a new one.`);
|
|
33
39
|
}
|
|
34
|
-
|
|
40
|
+
else {
|
|
41
|
+
this.log(chalk `{bold.underline.red No Mux configuration file found!} If you'd like to create ` +
|
|
42
|
+
chalk `one, run the {bold.magenta init} command. Otherwise, make sure to have the ` +
|
|
43
|
+
chalk `{bold.yellow MUX_TOKEN_ID} and {bold.yellow MUX_TOKEN_SECRET} environment variables set. 👋`);
|
|
44
|
+
}
|
|
45
|
+
process.exit(1);
|
|
35
46
|
}
|
|
36
47
|
}
|
|
37
48
|
async init() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return; // If we're initing we're trying to fix this, so don't yell :)
|
|
50
|
-
this.log(chalk `{bold.underline.red No Mux config file found!} If you'd like to create one, run the {bold.magenta init} command. Otherwise, make sure to have the {bold.yellow MUX_TOKEN_ID} and {bold.yellow MUX_TOKEN_SECRET} environment variables set. 👋`);
|
|
51
|
-
}
|
|
49
|
+
if (this.id === 'init')
|
|
50
|
+
return; // If we're initing we don't want any of this!
|
|
51
|
+
const config = await this.readConfigV1();
|
|
52
|
+
const mux = new mux_node_1.default(config === null || config === void 0 ? void 0 : config.tokenId, config === null || config === void 0 ? void 0 : config.tokenSecret, {
|
|
53
|
+
baseUrl: config === null || config === void 0 ? void 0 : config.baseUrl,
|
|
54
|
+
});
|
|
55
|
+
this.Mux = mux;
|
|
56
|
+
this.MuxConfig = config;
|
|
57
|
+
this.Video = this.Mux.Video;
|
|
58
|
+
this.Data = this.Mux.Data;
|
|
59
|
+
this.JWT = mux_node_1.default.JWT;
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
exports.default = CommandBase;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Upload } from '@mux/mux-node';
|
|
2
2
|
import { flags } from '@oclif/command';
|
|
3
|
-
import
|
|
4
|
-
export
|
|
3
|
+
import AssetCommandBase, { AssetBaseFlags } from '../../command-bases/asset-base';
|
|
4
|
+
export declare type AssetCreateFlags = AssetBaseFlags & {
|
|
5
|
+
filter: flags.IOptionFlag<string | undefined>;
|
|
6
|
+
concurrent: flags.IOptionFlag<number>;
|
|
7
|
+
};
|
|
8
|
+
export default class AssetsCreate extends AssetCommandBase {
|
|
5
9
|
static description: string;
|
|
6
10
|
static args: {
|
|
7
11
|
name: string;
|
|
8
12
|
description: string;
|
|
9
13
|
required: boolean;
|
|
10
14
|
}[];
|
|
11
|
-
static flags:
|
|
12
|
-
filter: flags.IOptionFlag<string | undefined>;
|
|
13
|
-
concurrent: import("@oclif/parser/lib/flags").IOptionFlag<number>;
|
|
14
|
-
private: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
15
|
-
};
|
|
15
|
+
static flags: AssetCreateFlags;
|
|
16
16
|
getFilePaths(filePath: string, filter?: string): string[];
|
|
17
17
|
uploadFile(filePath: string, url: string): Promise<unknown>;
|
|
18
18
|
pollUpload(uploadId: string): Promise<Upload>;
|
|
@@ -117,7 +117,12 @@ class AssetsCreate extends asset_base_1.default {
|
|
|
117
117
|
console.log(chalk.redBright('Error:') +
|
|
118
118
|
"\n\n" +
|
|
119
119
|
err);
|
|
120
|
-
|
|
120
|
+
if (err instanceof Error) {
|
|
121
|
+
this.error(err);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
128
|
}
|
|
@@ -137,4 +142,7 @@ AssetsCreate.flags = Object.assign(Object.assign({}, asset_base_1.default.flags)
|
|
|
137
142
|
char: 'c',
|
|
138
143
|
description: 'max number of files to upload at once',
|
|
139
144
|
default: 3,
|
|
145
|
+
}), private: command_1.flags.boolean({
|
|
146
|
+
char: 'p',
|
|
147
|
+
default: false,
|
|
140
148
|
}) });
|
package/lib/commands/init.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import * as Parser from '@oclif/parser';
|
|
1
2
|
import MuxBase from '../command-bases/base';
|
|
3
|
+
import { MuxCliConfigV1 } from '../config';
|
|
4
|
+
export declare type InitFlags = {
|
|
5
|
+
force: Parser.flags.IBooleanFlag<boolean>;
|
|
6
|
+
};
|
|
2
7
|
export default class Init extends MuxBase {
|
|
3
8
|
static description: string;
|
|
4
9
|
static args: {
|
|
@@ -7,13 +12,9 @@ export default class Init extends MuxBase {
|
|
|
7
12
|
description: string;
|
|
8
13
|
parse: (input: string) => string;
|
|
9
14
|
}[];
|
|
15
|
+
static flags: InitFlags;
|
|
10
16
|
Video: any;
|
|
11
17
|
JWT: any;
|
|
12
|
-
muxConfig:
|
|
13
|
-
tokenId?: string;
|
|
14
|
-
tokenSecret?: string;
|
|
15
|
-
signingKeyId?: string;
|
|
16
|
-
signingKeySecret?: string;
|
|
17
|
-
};
|
|
18
|
+
muxConfig: Partial<MuxCliConfigV1>;
|
|
18
19
|
run(): Promise<void>;
|
|
19
20
|
}
|
package/lib/commands/init.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const mux_node_1 = require("@mux/mux-node");
|
|
4
|
+
const command_1 = require("@oclif/command");
|
|
4
5
|
const chalk = require("chalk");
|
|
5
6
|
const dotenv = require("dotenv");
|
|
6
7
|
const fs = require("fs-extra");
|
|
@@ -13,7 +14,7 @@ class Init extends base_1.default {
|
|
|
13
14
|
this.muxConfig = {};
|
|
14
15
|
}
|
|
15
16
|
async run() {
|
|
16
|
-
const { args } = this.parse(Init);
|
|
17
|
+
const { args, flags } = this.parse(Init);
|
|
17
18
|
let prompts = [];
|
|
18
19
|
if (args.envFile) {
|
|
19
20
|
const envFile = path.resolve(args.envFile);
|
|
@@ -43,7 +44,10 @@ class Init extends base_1.default {
|
|
|
43
44
|
},
|
|
44
45
|
];
|
|
45
46
|
}
|
|
46
|
-
await this.
|
|
47
|
+
if (!flags.force && (await fs.pathExists(this.configFile))) {
|
|
48
|
+
this.log(chalk `{bold.underline.red You are attempting to initialize with an existing configuration file!} If this is intentional, please pass {bold.yellow --force}.`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
47
51
|
const signingKeyPrompt = {
|
|
48
52
|
name: 'createSigningKey',
|
|
49
53
|
message: 'Do you want to go ahead and set up a Signing Key? This is used to create tokens for signed playback policies.',
|
|
@@ -58,6 +62,7 @@ class Init extends base_1.default {
|
|
|
58
62
|
let { createSigningKey, tokenId, tokenSecret } = answers;
|
|
59
63
|
// If the token was loaded from an env file they'll already be set in the appropriate environment variables and
|
|
60
64
|
// the prompts themselves will be null.
|
|
65
|
+
this.muxConfig.configVersion = 1;
|
|
61
66
|
this.muxConfig.tokenId = process.env.MUX_TOKEN_ID = tokenId || process.env.MUX_TOKEN_ID;
|
|
62
67
|
this.muxConfig.tokenSecret = process.env.MUX_TOKEN_SECRET = tokenSecret || process.env.MUX_TOKEN_SECRET;
|
|
63
68
|
if (createSigningKey) {
|
|
@@ -79,7 +84,13 @@ class Init extends base_1.default {
|
|
|
79
84
|
await fs.writeFile(this.configFile, JSON.stringify(this.muxConfig), 'utf8');
|
|
80
85
|
}
|
|
81
86
|
catch (err) {
|
|
82
|
-
|
|
87
|
+
// TODO: improve error handling type safety here
|
|
88
|
+
if (err instanceof Error) {
|
|
89
|
+
this.error(err);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
83
94
|
}
|
|
84
95
|
this.log(chalk `{bold.underline Configuration written to:} ${this.configFile}`);
|
|
85
96
|
}
|
|
@@ -94,3 +105,11 @@ Init.args = [
|
|
|
94
105
|
parse: (input) => path.resolve(input),
|
|
95
106
|
},
|
|
96
107
|
];
|
|
108
|
+
Init.flags = {
|
|
109
|
+
force: command_1.flags.boolean({
|
|
110
|
+
name: 'force',
|
|
111
|
+
char: 'f',
|
|
112
|
+
description: 'Will initialize a new file even if one already exists.',
|
|
113
|
+
default: false,
|
|
114
|
+
}),
|
|
115
|
+
};
|
package/lib/commands/sign.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { flags } from '@oclif/command';
|
|
2
1
|
import MuxBase from '../command-bases/base';
|
|
3
2
|
export default class Sign extends MuxBase {
|
|
4
3
|
static description: string;
|
|
@@ -7,9 +6,6 @@ export default class Sign extends MuxBase {
|
|
|
7
6
|
description: string;
|
|
8
7
|
required: boolean;
|
|
9
8
|
}[];
|
|
10
|
-
static flags:
|
|
11
|
-
expiresIn: flags.IOptionFlag<string>;
|
|
12
|
-
type: flags.IOptionFlag<string>;
|
|
13
|
-
};
|
|
9
|
+
static flags: any;
|
|
14
10
|
run(): Promise<void>;
|
|
15
11
|
}
|