0

Frustratingly probably a simple resolution, but I cannot see the problem I'm having with my new templates in my custom blueprint, they are not found, but they are there.

Generated a blueprint template with jhipster generate-blueprint. Added some new files to the generators/server/templates folder.

Possibly related to how and when to use npm run update-snapshots in a blueprint development cycle.

After adding the new templates, I run npm run update-snapshots and run fails with:

...
1) SubGenerator server of devhipster JHipster blueprint
       run
         "before all" hook for "should succeed":
     Error: Template file helm/Chart.lock was not found at ~/Development/devhipster/generators/server/templates,~/Development/devhipster/node_modules/generator-jhipster/generators/server/templates
      at renderTemplate (node_modules/generator-jhipster/generators/generator-base.js:2521:17)
      at ~/Development/devhipster/node_modules/generator-jhipster/generators/generator-base.js:2681:69
      at Array.map (<anonymous>)
      at default.writeFiles (node_modules/generator-jhipster/generators/generator-base.js:2681:53)
      at default.writingTemplateTask (file://~/Development/devhipster/generators/server/generator.mjs:21:20)
      at Object.<anonymous> (node_modules/generator-jhipster/node_modules/yeoman-generator/lib/index.js:1091:23)
      at ~/Development/devhipster/node_modules/run-async/index.js:49:25
      at new Promise (<anonymous>)
      at ~/Development/devhipster/node_modules/run-async/index.js:26:19
      at ~/Development/devhipster/node_modules/generator-jhipster/node_modules/yeoman-generator/lib/index.js:1092:9
      at new Promise (<anonymous>)
      at default.executeTask (node_modules/generator-jhipster/node_modules/yeoman-generator/lib/index.js:1063:12)
      at runLoop.add.once (node_modules/generator-jhipster/node_modules/yeoman-generator/lib/index.js:1043:14)
      at Immediate.<anonymous> (node_modules/grouped-queue/lib/subqueue.js:48:34)
      at processImmediate (node:internal/timers:466:21)

The file is there. I can see it at ~/Development/devhipster/generators/server/templates/helm/Chart.lock

The generator.mjs for the server uses the following priority and code...

  ...
  ...
  get [WRITING_PRIORITY]() {
    return {
      async writingTemplateTask() {
        await this.writeFiles({
          sections: {
            files: [{
              templates: ['helm/Chart.lock'],
            }],
          },
          context: this,
        });
      },
    };
  }
  ...
  ...

Little more than a replacement of the template-file-server that was there.

diff --git a/generators/server/generator.mjs b/generators/server/generator.mjs
index f15e19f2..88b0518e 100644
--- a/generators/server/generator.mjs
+++ b/generators/server/generator.mjs
@@ -20,7 +20,9 @@ export default class extends ServerGenerator {
       async writingTemplateTask() {
         await this.writeFiles({
           sections: {
-            files: [{ templates: ['template-file-server'] }],
+            files: [{
+              templates: ['helm/Chart.lock'],
+            }],
           },
           context: this,
         });

It's a vexing gap in the dev workflow documentation and how using snapshots fits into that workflow, especially as changes are committed and pipelines deploy the blueprint for consumtion.

2 Answers 2

1

Well, that wes simple. I'll have write up some documentation on that for the website.

noEjs: true, in the template file object array.

diff --git a/generators/server/generator.mjs b/generators/server/generator.mjs
index f15e19f2..0e97d3b1 100644
--- a/generators/server/generator.mjs
+++ b/generators/server/generator.mjs
@@ -20,7 +20,15 @@ export default class extends ServerGenerator {
       async writingTemplateTask() {
         await this.writeFiles({
           sections: {
-            files: [{ templates: ['template-file-server'] }],
+            files: [{
+              templates: [
+                {
+                  sourceFile: 'helm/Chart.lock',
+                  destinationFile: 'helm/Chart.lock',
+                  noEjs: true,
+                },
+              ],
+            }],
           },
           context: this,
         });
1

JHipster defaults to ejs because almost every template is ejs.

An alternative for v7 is to pass transform: false to file block:

  ...
  ...
  get [WRITING_PRIORITY]() {
    return {
      async writingTemplateTask() {
        await this.writeFiles({
          sections: {
            files: [{
              transform: false,
              templates: ['helm/Chart.lock'],
            }],
          },
          context: this,
        });
      },
    };
  }
  ...
  ...

At JHipster 8, noEjs support will probably be dropped. You can see a WIP definition for v8.

1
  • I forgot what Node calls this resolution feature; one sees it with .js files too in require.
    – javafueled
    Mar 6 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.