79222944

Date: 2024-11-25 12:06:56
Score: 1
Natty:
Report link

Since I can not comment to what Petros said, I would like to mention that what he said is not enough. If you try to run the ng generate command using my-component schema it will complain that there is no argument named name.

For the schematic to work with a name argument you need to create schema.json file in my-component folder with the name parameter:

 {
   "properties": {
     "name": {
       "type": "string",
       "minLength": 1
     }
   }
 }

and then you need to update the collection.json file to include a reference to that schema file:

{
  "$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
  "schematics": {
    "my-component": {
      "description": "Create a component and its corresponding Storybook file",
      "factory": "./my-component/index#myComponent",
      "schema": "./my-component/schema.json"
    }
  }
}

and then you can run the command:

ng generate my-component-storybook:my-component --name=my-component-name
Reasons:
  • RegEx Blacklisted phrase (1): can not comment
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Virgil - Alexandru Tanasie