ui5-community / bestofui5-website

"Best of UI5" is the new entry page for the ui5-community.
https://bestofui5.org
Apache License 2.0
27 stars 3 forks source link

add config params to datamodel #78

Closed uxkjaer closed 2 years ago

uxkjaer commented 2 years ago

I'm writing a yeoman generator to add tooling to your ui5 project. I am using the datamodel from this repo as recommended by @petermuessig

I'm thinking that after you've selected your packages you have the option to configure the yaml file as well. For this I need the config params to be read. The easiest for me is that it's part of the data model. See (issue #1)[https://github.com/ui5-community/generator-ui5-tooling-extensions/issues/1] The below function handles it if the jsdoc is added as a typedef and properties. See the example on my deprecated onelogin repo since the onelogin now lives in the showcase 😉

static async fetchParams(): Promise { try { const indexJs = await GitHubRepositoriesProvider.octokit.rest.repos.getContent({ mediaType: { format: "raw", }, owner: "uxkjaer", repo: "ui5-middleware-onelogin", path: lib/index.js, }); const indexString = indexJs.data.toString(); const opt: jsdoc2md.JsdocOptions = { source: indexString, }; const data = jsdoc2md.getTemplateDataSync(opt); const typedef: any = data.filter((x: any) => x.kind === "typedef"); let arr: any = []; typedef[0].properties.forEach((property: any) => { const obj = { ...property }; obj.type = obj.type.names[0]; arr.push(obj); }); console.log(arr); } catch (error) { console.log(error); } }

marianfoo commented 2 years ago

Hi @uxkjaer , yes, Peter had already mentioned something. Very good idea! Of course I like to support this :) I haven't tried the code yet, but as it looks you want an array of typedef per package.

I would have to do: read package --> read yml file --> get entry point(s) --> read jsdoc from entry points

I have to try it out to see what kind of structure i get from it. But i guess i will save the yaml file and jsdoc to the datamodel as well.

petermuessig commented 2 years ago

Hi @marianfoo ,

if you need support on this please let me know.

BR, Peter

uxkjaer commented 2 years ago

If we can maintain this directly in the yaml file that would probably work as well.

marianfoo commented 2 years ago

How would the yaml file look like?

uxkjaer commented 2 years ago

i created a pull request with the code. I added the jsdoc typedef to my onelogin repo in the showcase to illustrate my example after having discussed this with @petermuessig.

the idea is that the extension has the main property in the package.json file and the @typedef and @property maintained in the entrypoint file to fetch the config parameters. Then I can use that to prompt the user in the generator.

It should propably be part of the github issue to add a package as well if we land on this.

marianfoo commented 2 years ago

I had a look at your PR.

Peters tooling packages has a task and middleware. Here there are theoretically two entry points: https://github.com/ui5-community/ui5-ecosystem-showcase/blob/ddbb9f8bff4926608fe0aaca88d466c9dd990afd/packages/ui5-tooling-modules/ui5.yaml#L2-L17

But you can´t define two main entry points in package.json I changed the code to read the entry point(s) from the yaml file.

The data.json looks currently like this: Is this ok?

{
  "name": "ui5-tooling-modules",
  "version": "0.2.7",
  "description": "UI5 tooling extensions to load and convert node modules as UI5 AMD-like modules",
  "author": "Peter Muessig",
  "license": "other",
......
  "jsdoc": {
    "middleware": {
      "params": [
        {
          "type": "string",
          "description": "The path to use",
          "name": "path"
        },
        {
          "type": "string",
          "optional": true,
          "description": "the username",
          "name": "username"
        },
        {
          "type": "string",
          "optional": true,
          "description": "the password",
          "name": "password"
        },
        {
          "type": "boolean",
          "optional": true,
          "description": "use certificate login instead of username/password",
          "name": "useCertificate"
        },
        {
          "type": "boolean",
          "optional": true,
          "description": "see output",
          "name": "debug"
        }
      ]
    },
    "task": {
      "params": [
        {
          "type": "string",
          "description": "The path to use",
          "name": "path"
        },
        {
          "type": "string",
          "optional": true,
          "description": "the username",
          "name": "username"
        },
        {
          "type": "string",
          "optional": true,
          "description": "the password",
          "name": "password"
        },
        {
          "type": "boolean",
          "optional": true,
          "description": "use certificate login instead of username/password",
          "name": "useCertificate"
        },
        {
          "type": "boolean",
          "optional": true,
          "description": "see output",
          "name": "debug"
        }
      ]
    }
  },
  "downloadsCurrentMonth": 377,
  "downloadsLastMonth": 371,
  "downloads365": 1090,
  "downloadsMonthlyGrowth": 1.62,
  "createdAt": "2021-11-09T10:37:13.992Z",
  "updatedAt": "2022-04-11T11:40:10.156Z",
  "npmlink": "https://www.npmjs.com/package/ui5-tooling-modules"
},