Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Merged to master
Browse files Browse the repository at this point in the history
  • Loading branch information
wizage committed Sep 17, 2019
2 parents 730ae9e + 69277d7 commit 5912d08
Show file tree
Hide file tree
Showing 51 changed files with 1,622 additions and 571 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<img src="https://img.shields.io/npm/v/amplify-category-video.svg" />
</a>
</p>

An open source plugin for the Amplify CLI that makes it easy to incorporate video streaming into your mobile and web applications powered by [AWS Amplify](https://aws-amplify.github.io/) and [AWS Media Services](https://aws.amazon.com/media-services/)

## Installation Guide
Expand Down
16 changes: 16 additions & 0 deletions amplify-plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "video",
"type": "category",
"commands": [
"add",
"help",
"get-info",
"push",
"remove",
"setup-obs",
"setup",
"start",
"stop",
"update"
]
}
26 changes: 24 additions & 2 deletions commands/video/add.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
const fs = require('fs');
const serviceMetadata = JSON.parse(fs.readFileSync(`${__dirname}/../../provider-utils/supported-services.json`));
const subcommand = 'add';
const category = 'video';

let options;

module.exports = {
name: 'add',
name: subcommand,
run: async (context) => {
context.createLiveStream();
const {amplify} = context;
return amplify.serviceSelectionPrompt(context, category, serviceMetadata).then((results) => {
options = {
service: category,
serviceType: results.service,
providerPlugin: results.providerName,
};
const providerController =
require(`../../provider-utils/${results.providerName}/index`);
if (!providerController) {
context.print.error('Provider not configured for this category');
return;
}
return providerController.addResource(context, results.service, options);
});
},

};
36 changes: 34 additions & 2 deletions commands/video/get-info.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
const inquirer = require('inquirer');
const subcommand = 'get-info';
const category = 'video';

module.exports = {
name: 'get-info',
name: subcommand,
run: async (context) => {
context.getInfo();
const {amplify} = context;
const amplifyMeta = amplify.getProjectMeta();

if (!(category in amplifyMeta) || Object.keys(amplifyMeta[category]).length === 0) {
context.print.error(`You have no ${category} projects.`);
return
}

const chooseProject = [
{
type: 'list',
name: 'resourceName',
message: 'Choose what project you want to get info for?',
choices: Object.keys(amplifyMeta[category]),
default: Object.keys(amplifyMeta[category])[0],
},
];
let props = await inquirer.prompt(chooseProject);

let options = amplifyMeta.video[props.resourceName];

const infoController =
require(`../../provider-utils/${options.providerPlugin}/utils/video-getinfo`);
if (!infoController) {
context.print.error('Info controller not configured for this category');
return;
}

return infoController.getVideoInfo(context, props.resourceName);
},
};
10 changes: 6 additions & 4 deletions commands/video/push.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const inquirer = require('inquirer');
const subcommand = 'push';
const category = 'video';

module.exports = {
name: 'push',
name: subcommand,
run: async (context) => {
const { amplify } = context;

Expand All @@ -10,14 +12,14 @@ module.exports = {
type: 'list',
name: 'resourceName',
message: 'Choose what project you want to update?',
choices: Object.keys(context.amplify.getProjectMeta().video),
default: Object.keys(context.amplify.getProjectMeta().video)[0],
choices: Object.keys(context.amplify.getProjectMeta()[category]),
default: Object.keys(context.amplify.getProjectMeta()[category])[0],
},
];

const answer = await inquirer.prompt(chooseProject);
amplify.constructExeInfo(context);
return amplify.pushResources(context, 'video', answer.resourceName)
return amplify.pushResources(context, category, answer.resourceName)
.catch((err) => {
context.print.info(err.stack);
context.print.error('There was an error pushing the video resource');
Expand Down
7 changes: 5 additions & 2 deletions commands/video/remove.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const subcommand = 'remove';
const category = 'video';

module.exports = {
name: 'remove',
name: subcommand,
run: async (context) => {
context.removeLiveStream(context);
await context.amplify.removeResource(context, category);
},
};
36 changes: 34 additions & 2 deletions commands/video/setup-obs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
const inquirer = require('inquirer');
const subcommand = 'setup-obs';
const category = 'video';

module.exports = {
name: 'setup-obs',
name: subcommand,
run: async (context) => {
context.setupOBS();
const {amplify} = context;
const amplifyMeta = amplify.getProjectMeta();

if (!(category in amplifyMeta) || Object.keys(amplifyMeta[category]).length === 0) {
context.print.error(`You have no ${category} projects.`);
return
}

const chooseProject = [
{
type: 'list',
name: 'resourceName',
message: 'Choose what project you want to get info for?',
choices: Object.keys(amplifyMeta[category]),
default: Object.keys(amplifyMeta[category])[0],
},
];
let props = await inquirer.prompt(chooseProject);

let options = amplifyMeta.video[props.resourceName];

const obsController =
require(`../../provider-utils/${options.providerPlugin}/utils/livestream-obs`);
if (!obsController && obsController.serviceType != "livestream") {
context.print.error('OBS controller not configured for this project.');
return;
}

return obsController.setupOBS(context, props.resourceName);
},
};
37 changes: 35 additions & 2 deletions commands/video/setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
const inquirer = require('inquirer');
const subcommand = 'setup';
const category = 'video';

module.exports = {
name: 'setup',
name: subcommand,
run: async (context) => {
context.pushStaticFiles();
const {amplify} = context;
const amplifyMeta = amplify.getProjectMeta();

if (!(category in amplifyMeta) || Object.keys(amplifyMeta[category]).length === 0) {
context.print.error(`You have no ${category} projects.`);
return
}

const chooseProject = [
{
type: 'list',
name: 'resourceName',
message: 'Choose what project you want to setup s3 for?',
choices: Object.keys(amplifyMeta[category]),
default: Object.keys(amplifyMeta[category])[0],
},
];

let props = await inquirer.prompt(chooseProject);

let options = amplifyMeta.video[props.resourceName];

const providerController =
require(`../../provider-utils/${options.providerPlugin}/index`);
if (!providerController) {
context.print.error('Provider not configured for this category');
return;
}
return providerController.setupCloudFormation(context, options.serviceType, options, props.resourceName);

},
};
37 changes: 35 additions & 2 deletions commands/video/start.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
const inquirer = require('inquirer');
const subcommand = 'start';
const category = 'video';

module.exports = {
name: 'start',
name: subcommand,
run: async (context) => {
context.startStream();
const {amplify} = context;
const amplifyMeta = amplify.getProjectMeta();

if (!(category in amplifyMeta) || Object.keys(amplifyMeta[category]).length === 0) {
context.print.error(`You have no ${category} projects.`);
return
}

const chooseProject = [
{
type: 'list',
name: 'resourceName',
message: 'Choose what project you want to start?',
choices: Object.keys(amplifyMeta[category]),
default: Object.keys(amplifyMeta[category])[0],
},
];

let props = await inquirer.prompt(chooseProject);

let options = amplifyMeta.video[props.resourceName];

const providerController =
require(`../../provider-utils/${options.providerPlugin}/index`);
if (!providerController) {
context.print.error('Provider not configured for this category');
return;
}

return providerController.livestreamStartStop(context, options.serviceType, options, props.resourceName, false);
},
};
37 changes: 35 additions & 2 deletions commands/video/stop.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
const inquirer = require('inquirer');
const subcommand = 'stop';
const category = 'video';

module.exports = {
name: 'stop',
name: subcommand,
run: async (context) => {
context.stopStream();
const {amplify} = context;
const amplifyMeta = amplify.getProjectMeta();

if (!(category in amplifyMeta) || Object.keys(amplifyMeta[category]).length === 0) {
context.print.error(`You have no ${category} projects.`);
return
}

const chooseProject = [
{
type: 'list',
name: 'resourceName',
message: 'Choose what project you want to stop?',
choices: Object.keys(amplifyMeta[category]),
default: Object.keys(amplifyMeta[category])[0],
},
];

let props = await inquirer.prompt(chooseProject);

let options = amplifyMeta.video[props.resourceName];

const providerController =
require(`../../provider-utils/${options.providerPlugin}/index`);
if (!providerController) {
context.print.error('Provider not configured for this category');
return;
}

return providerController.livestreamStartStop(context, options.serviceType, options, props.resourceName, true);
},
};
38 changes: 36 additions & 2 deletions commands/video/update.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
const inquirer = require('inquirer');
const subcommand = 'update';
const category = 'video';

module.exports = {
name: 'update',
name: subcommand,
run: async (context) => {
context.updateLiveStream();
const {amplify} = context;
const amplifyMeta = amplify.getProjectMeta();

if (!(category in amplifyMeta) || Object.keys(amplifyMeta[category]).length === 0) {
context.print.error(`You have no ${category} projects.`);
return
}

const chooseProject = [
{
type: 'list',
name: 'resourceName',
message: 'Choose what project you want to update?',
choices: Object.keys(amplifyMeta[category]),
default: Object.keys(amplifyMeta[category])[0],
},
];

let props = await inquirer.prompt(chooseProject);

let options = amplifyMeta.video[props.resourceName];

const providerController =
require(`../../provider-utils/${options.providerPlugin}/index`);
if (!providerController) {
context.print.error('Provider not configured for this category');
return;
}

return providerController.updateResource(context, options.serviceType, options, props.resourceName);
},

};
Loading

0 comments on commit 5912d08

Please sign in to comment.