awslabs / amplify-video

An open source Category Plugin for the AWS Amplify-CLI that makes it easy to deploy live and file based streaming video services and integrate them into your Amplify applications.
https://www.npmjs.com/package/amplify-category-video
Apache License 2.0
267 stars 56 forks source link

Rework question files structure #250

Closed spaniernathan closed 3 years ago

spaniernathan commented 3 years ago

Is your feature request related to a problem? Please describe. When building the permutation script I needed to create a new file that is a copy of the question file but with a different structure. The new structure enable people to add new questions without having to add code or worry about breaking the actual code. With the actual structure adding a new questions to a question file without being cautious may break the code that handle in which order the question are asked. Also because we use array indexes to invoke questions it is not explicit on which question is handled:

const nameProject = [
    {
      type: inputs[0].type,
      name: inputs[0].key,
      message: inputs[0].question,
      validate: amplify.inputValidation(inputs[0]),
      ...
    },
  ];

Describe the solution you'd like Right now questions are hold in an array and are invoked with their index. I suggest to change that array to an object: From this structure

{
  "inputs": [
        {
            "key": "resourceName",
            "question": "Provide a friendly name for your resource to be used as a label for this category in the project:",
            "validation": {
                "operator": "regex",
                "value": "^[a-zA-Z0-9\\-]+$",
                "onErrorMsg": "Resource name should be alphanumeric"
            },
            "required": true
        },
        ...
  ]
}

to this structure

{
    "resourceName": {
        "key": "resourceName",
        "question": "Provide a friendly name for your resource to be used as a label for this category in the project:",
        "validation": {
            "operator": "regex",
            "value": "^[a-zA-Z0-9\\-]+$",
            "onErrorMsg": "Resource name should be alphanumeric"
        },
        "required": true,
        "default": "myivs",
        "next": "channelQuality"
    },
    ...
}

Reworking those file will also enable us to only use one file to manage questions and the generations of all the permutations in #210 In this new structure it might also be useful to move default-values in question file instead of having them in a separated file. Also add documentation on how to build / modify the question files so new contributors can easily add new services or update existing ones.

Additional context Reworking those files will mainly require the refactor of the service-walkthroughs files and the permutation script present in the pull-request #210

wizage commented 3 years ago

Merged in and new structure exists