moleculerjs / moleculer-cli

:herb: Command line tool for Moleculer
http://moleculer.services/docs/moleculer-cli.html
MIT License
48 stars 28 forks source link

Typescript create service. #36

Closed devalexandre closed 3 years ago

devalexandre commented 3 years ago

@icebob resolved all changes

devalexandre commented 3 years ago

all corrections made :) @icebob

icebob commented 3 years ago

Did you test it? What is the command to generate typescript service?

devalexandre commented 3 years ago

Did you test it? What is the command to generate typescript service?

yes I did

 ./bin/moleculer.js  create service  --typescript

you can run and save file in ./test folder

icebob commented 3 years ago

The create help is not correct: image

devalexandre commented 3 years ago

The create help is not correct: image

resolved, I add in options

AndreMaz commented 3 years ago

Also image

Can you please fix the grammatical error? Also, it would be nice to have the actual filename of the service in the info

AndreMaz commented 3 years ago

Looking at the prompts I think that it should be possible to create a service with default params.

{
    type: "input",
    name: "serviceFolder",
    message: "Service directory",
    default: "./services",
    validate(input) {
        if (!fs.existsSync(path.resolve(input)))
            return `The '${input}' directory is not exists! Full path: ${path.resolve(input)}`;

        return true;
    }
},
{
    type: "input",
    name: "serviceName",
    message: "Service name",
    default: "test"
}

However, it seem that there's an issue. image

Also, there's a typo in The '${input}' directory is not exists!. It should be The '${input}' directory doesn't exist!. Same for the The file ${newServicePath} is exists!. It should be The file ${newServicePath} already exists!

devalexandre commented 3 years ago

Looking at the prompts I think that it should be possible to create a service with default params.

{
  type: "input",
  name: "serviceFolder",
  message: "Service directory",
  default: "./services",
  validate(input) {
      if (!fs.existsSync(path.resolve(input)))
          return `The '${input}' directory is not exists! Full path: ${path.resolve(input)}`;

      return true;
  }
},
{
  type: "input",
  name: "serviceName",
  message: "Service name",
  default: "test"
}

However, it seem that there's an issue. image

Also, there's a typo in The '${input}' directory is not exists!. It should be The '${input}' directory doesn't exist!. Same for the The file ${newServicePath} is exists!. It should be The file ${newServicePath} already exists!

I alter it, and now use a default, if don't input some value

AndreMaz commented 3 years ago

Now I'm getting stuck after a warning Njwl7V7eh3

Please test your code before creating a commit.

Also, fix the typos The '${input}' directory is not exists! should be The '${input}' directory doesn't exist! Moreover, Do you wanna overwrite it?. Please use formal English. Instead of wanna it should be want to.

devalexandre commented 3 years ago

I always test the commits, maybe I missed it this time, I'm sorry for the lack of attention

AndreMaz commented 3 years ago

Thanks for solving the dir issue. One last thing, the service name is starting with a capital letter (name:"Test") but it should be all in lowercase

devalexandre commented 3 years ago

Thanks for solving the dir issue. One last thing, the service name is starting with a capital letter (name:"Test") but it should be all in lowercase

yes, alter it