cbornet/generator-jhipster-grpc

Cannot generate gRPC service for already exist entity with service

lokinell opened this issue · 13 comments

Dear @cbornet , thank you in advance for nice tool.
However, when I try to use it to generator rpc service in my jhipster project, I have below error:

Composing JHipster configuration with module grpc
WARNING! DEPRECATED! The JHipster module sub-generator is deprecated.
WARNING! Please import the generator-base.js using commonJS require or ES2015 import.
WARNING! See http://www.jhipster.tech/modules/creating-a-module for more details.

Running JHipster gRPC Generator! v0.15.0

Reading the JHipster project configuration for your module
TypeError: /Users/admin/datarx/PalanBI/node_modules/generator-jhipster-grpc/generators/entity/templates/_entity.proto:86
    84| 
    85| <%_ }} _%>
 >> 86| <%_ var protobufFieldNumber = 2;
    87| 
    88| for (field of fields) {
    89|     var isOneOf = false;

Cannot read property 'replace' of undefined
    at eval (eval at compile (/Users/admin/datarx/PalanBI/node_modules/ejs/lib/ejs.js:549:12), <anonymous>:225:42)

Hi @lokinell, can you provide the result of jhipster info ? Or a github project that I can clone to test ?
Without this info, I can't do anything.

I have the same issue. When I add the comments for a field.
Like this:

/**
 * The CreditLimits entity.
 * @author A true hipster
 */
entity CreditLimits {
       /**
         * UserID from user table.
         */
        userId String,
        currencyName String,
        limit BigDecimal required,
        postition BigDecimal required
}

I resovled it by remove the comment of userId.

@zhanyigo are you sure that’s the exact same bug ? Could you provide the result of yo jhipster:info so I can investigate ?

Yes, I'm sure. I need a little time to do it.

I reduced the issue.

Steps:

  1. yo jhipster with the default values;
  2. jhipster import-jdl;
  3. yo jhipster-grpc

The error messages:

Reading the JHipster project configuration for your module
TypeError: /Users/zhanyi/node_modules/generator-jhipster-grpc/generators/entity/templates/_entity.proto:86
    84|
    85| <%_ }} _%>
 >> 86| <%_ var protobufFieldNumber = 2;
    87|
    88| for (field of fields) {
    89|     var isOneOf = false;

Cannot read property 'replace' of undefined
    at eval (eval at compile (/Users/zhanyi/node_modules/ejs/lib/ejs.js:584:12), <anonymous>:225:42)
    at returnedFn (/Users/zhanyi/node_modules/ejs/lib/ejs.js:615:17)
    at Object.exports.render (/Users/zhanyi/node_modules/ejs/lib/ejs.js:414:37)
    at process (/Users/zhanyi/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/copy-tpl.js:12:18)
    at applyProcessingFunc (/Users/zhanyi/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/copy.js:13:16)
    at EditionInterface.exports._copySingle (/Users/zhanyi/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/copy.js:51:16)
    at EditionInterface.exports.copy (/Users/zhanyi/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/copy.js:23:17)
    at EditionInterface.module.exports [as copyTpl] (/Users/zhanyi/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/copy-tpl.js:10:8)
    at child.template (/Users/zhanyi/node_modules/yeoman-generator/lib/actions/actions.js:134:11)
    at child.writeFiles (/Users/zhanyi/node_modules/generator-jhipster-grpc/generators/entity/index.js:155:18)
/**
 * The TradeAccount entity.
 *
 */
entity TradeAccount {
        /**
         * User Id . (Remove this comment, and the issue was gone.)
         */
        userId String,
        status Status
}
 ✘ zhanyi@ZhanYi-MacBook-Pro  ~/xxx/m1   master ●  jhipster info
Using JHipster version installed locally in current project's node_modules
Executing jhipster:info
Options:
Welcome to the JHipster Information Sub-Generator

##### **JHipster Version(s)**

m-1@0.0.0 /Users/zhanyi/xxxx/m1
└── generator-jhipster@4.14.1



##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**


<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "org.z.m1",
      "nativeLanguage": "zh-cn"
    },
    "jhipsterVersion": "4.14.1",
    "baseName": "m1",
    "packageName": "org.z.m1",
    "packageFolder": "org/z/m1",
    "serverPort": "8080",
    "authenticationType": "oauth2",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "clientFramework": "angularX",
    "useSass": false,
    "clientPackageManager": "yarn",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "zh-cn",
    "languages": [
      "zh-cn"
    ]
  }
}
</pre>
</details>


##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>
/**
 * The TradeAccount entity.
 */
entity TradeAccount (trade_account) {
  /**
   * User Id
   */
  userId String,
  status Status
}
</pre>
</details>


##### **Environment and Tools**

java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

git version 2.15.1 (Apple Git-101)

node: v9.7.1

npm: 5.6.0

bower: 1.8.0

yeoman: 2.0.1

yarn: 1.5.1

Docker version 17.12.0-ce, build c97c6d6

docker-compose version 1.18.0, build 8dd22a9

Congratulations, JHipster execution is complete!

Thanks. I'll have a look.
Please note that node v9 is not supported by JHipster. We only support LTS v8 so that may explain your issue.

I changed reinstalled the node v8. It not work.

Running post run module hooks

Composing JHipster configuration with module grpc
WARNING! DEPRECATED! The JHipster module sub-generator is deprecated.
WARNING! Please import the generator-base.js using commonJS require or ES2015 import.
WARNING! See http://www.jhipster.tech/modules/creating-a-module for more details.

Running JHipster gRPC Generator! v0.15.0

Reading the JHipster project configuration for your module
TypeError: /Users/zhanyi/node_modules/generator-jhipster-grpc/generators/entity/templates/_entity.proto:86
    84|
    85| <%_ }} _%>
 >> 86| <%_ var protobufFieldNumber = 2;
    87|
    88| for (field of fields) {
    89|     var isOneOf = false;

Cannot read property 'replace' of undefined
    at eval (eval at compile (/Users/zhanyi/node_modules/ejs/lib/ejs.js:584:12), <anonymous>:225:42)
    at returnedFn (/Users/zhanyi/node_modules/ejs/lib/ejs.js:615:17)
    at Object.exports.render (/Users/zhanyi/node_modules/ejs/lib/ejs.js:414:37)
    at process (/Users/zhanyi/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/copy-tpl.js:12:18)
    at applyProcessingFunc (/Users/zhanyi/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/copy.js:13:16)
    at EditionInterface.exports._copySingle (/Users/zhanyi/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/copy.js:51:16)
    at EditionInterface.exports.copy (/Users/zhanyi/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/copy.js:23:17)
    at EditionInterface.module.exports [as copyTpl] (/Users/zhanyi/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/copy-tpl.js:10:8)
    at child.template (/Users/zhanyi/node_modules/yeoman-generator/lib/actions/actions.js:134:11)
    at child.writeFiles (/Users/zhanyi/node_modules/generator-jhipster-grpc/generators/entity/index.js:155:18)

jhipster info:

##### **Environment and Tools**

java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

git version 2.15.1 (Apple Git-101)

node: v8.11.1

npm: 5.6.0

bower: 1.8.0

yeoman: 2.0.1

yarn: 1.5.1

Docker version 17.12.0-ce, build c97c6d6

docker-compose version 1.18.0, build 8dd22a9

@zhanyigo can you check that the fix is OK for you ?

Sorry. Which version I need to check?

The master branch. I'm waiting for your confirmation to release a fixed version. Are you able to test with the master branch ?

I try it.
How to build? Copy the code to node_modules?

It’s the same as for the main generator. See the instructions here

It's fixed. And I found other issues.