@mux/cli 0.6.2 → 0.7.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 +63 -35
- package/lib/command-bases/asset-base.d.ts +5 -3
- package/lib/command-bases/base.d.ts +2 -1
- package/lib/command-bases/base.js +25 -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/config.d.ts +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +32 -32
- package/src/command-bases/asset-base.ts +6 -1
- package/src/command-bases/base.ts +31 -21
- 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/yarn.lock +2428 -1256
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.7.0 linux-x64 node-v14.18.3
|
|
25
25
|
$ mux --help [COMMAND]
|
|
26
26
|
USAGE
|
|
27
27
|
$ mux COMMAND
|
|
@@ -42,6 +42,7 @@ 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)
|
|
@@ -64,7 +65,7 @@ OPTIONS
|
|
|
64
65
|
-p, --private add a private playback policy to the created asset
|
|
65
66
|
```
|
|
66
67
|
|
|
67
|
-
_See code: [src/commands/assets/create.ts](https://github.com/muxinc/cli/blob/v0.
|
|
68
|
+
_See code: [src/commands/assets/create.ts](https://github.com/muxinc/cli/blob/v0.7.0/src/commands/assets/create.ts)_
|
|
68
69
|
|
|
69
70
|
## `mux assets:upload PATH`
|
|
70
71
|
|
|
@@ -80,10 +81,10 @@ ARGUMENTS
|
|
|
80
81
|
OPTIONS
|
|
81
82
|
-c, --concurrent=concurrent [default: 3] max number of files to upload at once
|
|
82
83
|
-f, --filter=filter regex that filters the selected destination if the provided path is a folder
|
|
83
|
-
-p, --private
|
|
84
|
+
-p, --private
|
|
84
85
|
```
|
|
85
86
|
|
|
86
|
-
_See code: [src/commands/assets/upload.ts](https://github.com/muxinc/cli/blob/v0.
|
|
87
|
+
_See code: [src/commands/assets/upload.ts](https://github.com/muxinc/cli/blob/v0.7.0/src/commands/assets/upload.ts)_
|
|
87
88
|
|
|
88
89
|
## `mux autocomplete [SHELL]`
|
|
89
90
|
|
|
@@ -106,7 +107,7 @@ EXAMPLES
|
|
|
106
107
|
$ mux autocomplete --refresh-cache
|
|
107
108
|
```
|
|
108
109
|
|
|
109
|
-
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/
|
|
110
|
+
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.1.1/src/commands/autocomplete/index.ts)_
|
|
110
111
|
|
|
111
112
|
## `mux commands`
|
|
112
113
|
|
|
@@ -117,20 +118,20 @@ USAGE
|
|
|
117
118
|
$ mux commands
|
|
118
119
|
|
|
119
120
|
OPTIONS
|
|
120
|
-
-h, --help
|
|
121
|
-
-j, --json display unfiltered api data in json format
|
|
121
|
+
-h, --help Show CLI help.
|
|
122
122
|
-x, --extended show extra columns
|
|
123
123
|
--columns=columns only show provided columns (comma-separated)
|
|
124
124
|
--csv output is csv format [alias: --output=csv]
|
|
125
125
|
--filter=filter filter property by partial string matching, ex: name=foo
|
|
126
126
|
--hidden show hidden commands
|
|
127
|
+
--json Format output as json.
|
|
127
128
|
--no-header hide table header from output
|
|
128
129
|
--no-truncate do not truncate output to fit screen
|
|
129
130
|
--output=csv|json|yaml output in a more machine friendly format
|
|
130
131
|
--sort=sort property to sort by (prepend '-' for descending)
|
|
131
132
|
```
|
|
132
133
|
|
|
133
|
-
_See code: [@oclif/plugin-commands](https://github.com/oclif/plugin-commands/blob/
|
|
134
|
+
_See code: [@oclif/plugin-commands](https://github.com/oclif/plugin-commands/blob/v2.0.2/src/commands/commands.ts)_
|
|
134
135
|
|
|
135
136
|
## `mux help [COMMAND]`
|
|
136
137
|
|
|
@@ -147,7 +148,7 @@ OPTIONS
|
|
|
147
148
|
--all see all commands in CLI
|
|
148
149
|
```
|
|
149
150
|
|
|
150
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.
|
|
151
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.18/src/commands/help.ts)_
|
|
151
152
|
|
|
152
153
|
## `mux init [ENVFILE]`
|
|
153
154
|
|
|
@@ -159,9 +160,12 @@ USAGE
|
|
|
159
160
|
|
|
160
161
|
ARGUMENTS
|
|
161
162
|
ENVFILE path to a Mux access token .env file
|
|
163
|
+
|
|
164
|
+
OPTIONS
|
|
165
|
+
-f, --force Will initialize a new file even if one already exists.
|
|
162
166
|
```
|
|
163
167
|
|
|
164
|
-
_See code: [src/commands/init.ts](https://github.com/muxinc/cli/blob/v0.
|
|
168
|
+
_See code: [src/commands/init.ts](https://github.com/muxinc/cli/blob/v0.7.0/src/commands/init.ts)_
|
|
165
169
|
|
|
166
170
|
## `mux live:complete STREAMNAME`
|
|
167
171
|
|
|
@@ -179,7 +183,7 @@ OPTIONS
|
|
|
179
183
|
-t, --streamId=stream-id [default: stream-id] the type of the provided reference name
|
|
180
184
|
```
|
|
181
185
|
|
|
182
|
-
_See code: [src/commands/live/complete.ts](https://github.com/muxinc/cli/blob/v0.
|
|
186
|
+
_See code: [src/commands/live/complete.ts](https://github.com/muxinc/cli/blob/v0.7.0/src/commands/live/complete.ts)_
|
|
183
187
|
|
|
184
188
|
## `mux live:disable STREAMNAME`
|
|
185
189
|
|
|
@@ -196,7 +200,7 @@ OPTIONS
|
|
|
196
200
|
-t, --streamId=stream-id [default: stream-id] the type of the provided reference name
|
|
197
201
|
```
|
|
198
202
|
|
|
199
|
-
_See code: [src/commands/live/disable.ts](https://github.com/muxinc/cli/blob/v0.
|
|
203
|
+
_See code: [src/commands/live/disable.ts](https://github.com/muxinc/cli/blob/v0.7.0/src/commands/live/disable.ts)_
|
|
200
204
|
|
|
201
205
|
## `mux live:enable STREAMNAME`
|
|
202
206
|
|
|
@@ -213,39 +217,60 @@ OPTIONS
|
|
|
213
217
|
-t, --streamId=stream-id [default: stream-id] the type of the provided reference name
|
|
214
218
|
```
|
|
215
219
|
|
|
216
|
-
_See code: [src/commands/live/enable.ts](https://github.com/muxinc/cli/blob/v0.
|
|
220
|
+
_See code: [src/commands/live/enable.ts](https://github.com/muxinc/cli/blob/v0.7.0/src/commands/live/enable.ts)_
|
|
217
221
|
|
|
218
222
|
## `mux plugins`
|
|
219
223
|
|
|
220
|
-
|
|
224
|
+
List installed plugins.
|
|
221
225
|
|
|
222
226
|
```
|
|
223
227
|
USAGE
|
|
224
228
|
$ mux plugins
|
|
225
229
|
|
|
226
230
|
OPTIONS
|
|
227
|
-
--core
|
|
231
|
+
--core Show core plugins.
|
|
228
232
|
|
|
229
233
|
EXAMPLE
|
|
230
234
|
$ mux plugins
|
|
231
235
|
```
|
|
232
236
|
|
|
233
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
237
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/index.ts)_
|
|
238
|
+
|
|
239
|
+
## `mux plugins:inspect PLUGIN...`
|
|
240
|
+
|
|
241
|
+
Displays installation properties of a plugin.
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
USAGE
|
|
245
|
+
$ mux plugins:inspect PLUGIN...
|
|
246
|
+
|
|
247
|
+
ARGUMENTS
|
|
248
|
+
PLUGIN [default: .] Plugin to inspect.
|
|
249
|
+
|
|
250
|
+
OPTIONS
|
|
251
|
+
-h, --help Show CLI help.
|
|
252
|
+
-v, --verbose
|
|
253
|
+
|
|
254
|
+
EXAMPLE
|
|
255
|
+
$ mux plugins:inspect myplugin
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/inspect.ts)_
|
|
234
259
|
|
|
235
260
|
## `mux plugins:install PLUGIN...`
|
|
236
261
|
|
|
237
|
-
|
|
262
|
+
Installs a plugin into the CLI.
|
|
238
263
|
|
|
239
264
|
```
|
|
240
265
|
USAGE
|
|
241
266
|
$ mux plugins:install PLUGIN...
|
|
242
267
|
|
|
243
268
|
ARGUMENTS
|
|
244
|
-
PLUGIN
|
|
269
|
+
PLUGIN Plugin to install.
|
|
245
270
|
|
|
246
271
|
OPTIONS
|
|
247
|
-
-f, --force yarn install with force flag
|
|
248
|
-
-h, --help
|
|
272
|
+
-f, --force Run yarn install with force flag.
|
|
273
|
+
-h, --help Show CLI help.
|
|
249
274
|
-v, --verbose
|
|
250
275
|
|
|
251
276
|
DESCRIPTION
|
|
@@ -266,11 +291,11 @@ EXAMPLES
|
|
|
266
291
|
$ mux plugins:install someuser/someplugin
|
|
267
292
|
```
|
|
268
293
|
|
|
269
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
294
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/install.ts)_
|
|
270
295
|
|
|
271
296
|
## `mux plugins:link PLUGIN`
|
|
272
297
|
|
|
273
|
-
|
|
298
|
+
Links a plugin into the CLI for development.
|
|
274
299
|
|
|
275
300
|
```
|
|
276
301
|
USAGE
|
|
@@ -280,24 +305,24 @@ ARGUMENTS
|
|
|
280
305
|
PATH [default: .] path to plugin
|
|
281
306
|
|
|
282
307
|
OPTIONS
|
|
283
|
-
-h, --help
|
|
308
|
+
-h, --help Show CLI help.
|
|
284
309
|
-v, --verbose
|
|
285
310
|
|
|
286
311
|
DESCRIPTION
|
|
287
312
|
Installation of a linked plugin will override a user-installed or core plugin.
|
|
288
313
|
|
|
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
|
-
|
|
314
|
+
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
315
|
+
command will override the user-installed or core plugin implementation. This is useful for development work.
|
|
291
316
|
|
|
292
317
|
EXAMPLE
|
|
293
318
|
$ mux plugins:link myplugin
|
|
294
319
|
```
|
|
295
320
|
|
|
296
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
321
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/link.ts)_
|
|
297
322
|
|
|
298
323
|
## `mux plugins:uninstall PLUGIN...`
|
|
299
324
|
|
|
300
|
-
|
|
325
|
+
Removes a plugin from the CLI.
|
|
301
326
|
|
|
302
327
|
```
|
|
303
328
|
USAGE
|
|
@@ -307,7 +332,7 @@ ARGUMENTS
|
|
|
307
332
|
PLUGIN plugin to uninstall
|
|
308
333
|
|
|
309
334
|
OPTIONS
|
|
310
|
-
-h, --help
|
|
335
|
+
-h, --help Show CLI help.
|
|
311
336
|
-v, --verbose
|
|
312
337
|
|
|
313
338
|
ALIASES
|
|
@@ -315,22 +340,22 @@ ALIASES
|
|
|
315
340
|
$ mux plugins:remove
|
|
316
341
|
```
|
|
317
342
|
|
|
318
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
343
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/uninstall.ts)_
|
|
319
344
|
|
|
320
345
|
## `mux plugins:update`
|
|
321
346
|
|
|
322
|
-
|
|
347
|
+
Update installed plugins.
|
|
323
348
|
|
|
324
349
|
```
|
|
325
350
|
USAGE
|
|
326
351
|
$ mux plugins:update
|
|
327
352
|
|
|
328
353
|
OPTIONS
|
|
329
|
-
-h, --help
|
|
354
|
+
-h, --help Show CLI help.
|
|
330
355
|
-v, --verbose
|
|
331
356
|
```
|
|
332
357
|
|
|
333
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
358
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.0.12/src/commands/plugins/update.ts)_
|
|
334
359
|
|
|
335
360
|
## `mux sign PLAYBACK-ID`
|
|
336
361
|
|
|
@@ -350,7 +375,7 @@ OPTIONS
|
|
|
350
375
|
-t, --type=video|thumbnail|gif [default: video] What type of token this signature is for.
|
|
351
376
|
```
|
|
352
377
|
|
|
353
|
-
_See code: [src/commands/sign.ts](https://github.com/muxinc/cli/blob/v0.
|
|
378
|
+
_See code: [src/commands/sign.ts](https://github.com/muxinc/cli/blob/v0.7.0/src/commands/sign.ts)_
|
|
354
379
|
|
|
355
380
|
## `mux update [CHANNEL]`
|
|
356
381
|
|
|
@@ -359,7 +384,10 @@ update the mux CLI
|
|
|
359
384
|
```
|
|
360
385
|
USAGE
|
|
361
386
|
$ mux update [CHANNEL]
|
|
387
|
+
|
|
388
|
+
OPTIONS
|
|
389
|
+
--from-local interactively choose an already installed version
|
|
362
390
|
```
|
|
363
391
|
|
|
364
|
-
_See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/
|
|
392
|
+
_See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/v2.1.5/src/commands/update.ts)_
|
|
365
393
|
<!-- 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,10 +1,11 @@
|
|
|
1
|
-
import { Video as MuxVideo, Data as MuxData } from '@mux/mux-node';
|
|
1
|
+
import Mux, { Video as MuxVideo, Data as MuxData } 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
11
|
JWT: any;
|
|
@@ -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,31 @@ 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
|
-
if (this.id === 'init')
|
|
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.Video = this.Mux.Video;
|
|
57
|
+
this.Data = this.Mux.Data;
|
|
58
|
+
this.JWT = mux_node_1.default.JWT;
|
|
52
59
|
}
|
|
53
60
|
}
|
|
54
61
|
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/config.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export declare const MuxCliConfigV1: RT.Record<{
|
|
|
3
3
|
configVersion: RT.Literal<1>;
|
|
4
4
|
tokenId: RT.String;
|
|
5
5
|
tokenSecret: RT.String;
|
|
6
|
-
signingKeyId: RT.
|
|
7
|
-
signingKeySecret: RT.
|
|
6
|
+
signingKeyId: RT.Union<[RT.String, RT.Literal<undefined>]>;
|
|
7
|
+
signingKeySecret: RT.Union<[RT.String, RT.Literal<undefined>]>;
|
|
8
8
|
baseUrl: RT.String;
|
|
9
9
|
}, false>;
|
|
10
10
|
export declare type MuxCliConfigV1 = RT.Static<typeof MuxCliConfigV1>;
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.
|
|
1
|
+
{"version":"0.7.0","commands":{"init":{"id":"init","description":"set up a user-level config","pluginName":"@mux/cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Will initialize a new file even if one already exists.","allowNo":false}},"args":[{"name":"envFile","description":"path to a Mux access token .env file","required":false}]},"sign":{"id":"sign","description":"Creates a new signed URL token for a playback ID","pluginName":"@mux/cli","pluginType":"core","aliases":[],"flags":{"expiresIn":{"name":"expiresIn","type":"option","char":"e","description":"How long the signature is valid for. If no unit is specified, milliseconds is assumed.","default":"7d"},"type":{"name":"type","type":"option","char":"t","description":"What type of token this signature is for.","options":["video","thumbnail","gif"],"default":"video"}},"args":[{"name":"playback-id","description":"Playback ID to create a signed URL token for.","required":true}]},"assets:create":{"id":"assets:create","description":"Create a new asset in Mux using a file that's already available online","pluginName":"@mux/cli","pluginType":"core","aliases":[],"flags":{"private":{"name":"private","type":"boolean","char":"p","description":"add a private playback policy to the created asset","allowNo":false}},"args":[{"name":"input","description":"input URL for the file you'd like to create this asset from","required":true}]},"assets:upload":{"id":"assets:upload","description":"Create a new asset in Mux via a local file","pluginName":"@mux/cli","pluginType":"core","aliases":[],"flags":{"private":{"name":"private","type":"boolean","char":"p","allowNo":false},"filter":{"name":"filter","type":"option","char":"f","description":"regex that filters the selected destination if the provided path is a folder"},"concurrent":{"name":"concurrent","type":"option","char":"c","description":"max number of files to upload at once","default":3}},"args":[{"name":"path","description":"local path for the file (or folder) you'd like to upload","required":true}]},"live:complete":{"id":"live:complete","description":"Signal to Mux that a live stream has concluded and should be closed.","pluginName":"@mux/cli","pluginType":"core","aliases":[],"flags":{"streamId":{"name":"streamId","type":"option","char":"t","description":"the type of the provided reference name","options":["stream-id"],"default":"stream-id"},"disableAfterCompletion":{"name":"disableAfterCompletion","type":"boolean","char":"d","description":"If set, disables the stream upon completion.","allowNo":false}},"args":[{"name":"streamName","description":"the name (coupled with --reference-type) to look up in Mux to yield this livestream","required":true}]},"live:disable":{"id":"live:disable","description":"Disables a live stream and prevents encoders from streaming to it.","pluginName":"@mux/cli","pluginType":"core","aliases":[],"flags":{"streamId":{"name":"streamId","type":"option","char":"t","description":"the type of the provided reference name","options":["stream-id"],"default":"stream-id"}},"args":[{"name":"streamName","description":"the name (coupled with --reference-type) to look up in Mux to yield this livestream","required":true}]},"live:enable":{"id":"live:enable","description":"Enables a live stream, allowing encoders to streaming to it.","pluginName":"@mux/cli","pluginType":"core","aliases":[],"flags":{"streamId":{"name":"streamId","type":"option","char":"t","description":"the type of the provided reference name","options":["stream-id"],"default":"stream-id"}},"args":[{"name":"streamName","description":"the name (coupled with --reference-type) to look up in Mux to yield this livestream","required":true}]}}}
|