@genesislcap/build-kit 14.159.0 → 14.160.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { PathOrFileDescriptor } from 'node:fs';
2
2
  export declare const render: (template: any, data: any) => string;
3
3
  export declare const renderFile: (file: PathOrFileDescriptor, data: object, templateFile?: PathOrFileDescriptor) => void;
4
+ export declare const registerPartial: (name: string, templateFile: any) => void;
4
5
  //# sourceMappingURL=handlebars.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handlebars.d.ts","sourceRoot":"","sources":["../../src/utils/handlebars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAA+B,MAAM,SAAS,CAAC;AA0C5E,eAAO,MAAM,MAAM,sCAAyD,CAAC;AAE7E,eAAO,MAAM,UAAU,SACf,oBAAoB,QACpB,MAAM,iBACG,oBAAoB,SAKpC,CAAC"}
1
+ {"version":3,"file":"handlebars.d.ts","sourceRoot":"","sources":["../../src/utils/handlebars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAA+B,MAAM,SAAS,CAAC;AA6C5E,eAAO,MAAM,MAAM,sCAAyD,CAAC;AAE7E,eAAO,MAAM,UAAU,SACf,oBAAoB,QACpB,MAAM,iBACG,oBAAoB,SAKpC,CAAC;AAEF,eAAO,MAAM,eAAe,SAAU,MAAM,4BAG3C,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderFile = exports.render = void 0;
3
+ exports.registerPartial = exports.renderFile = exports.render = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_fs_1 = require("node:fs");
6
6
  const change_case_1 = require("change-case");
@@ -31,6 +31,9 @@ handlebars_1.default.registerHelper('pathCase', (s) => s && (0, change_case_1.pa
31
31
  handlebars_1.default.registerHelper('sentenceCase', (s) => s && (0, change_case_1.sentenceCase)(s));
32
32
  handlebars_1.default.registerHelper('snakeCase', (s) => s && (0, change_case_1.snakeCase)(s));
33
33
  handlebars_1.default.registerHelper('upperCase', (s) => s && s.toUpperCase());
34
+ handlebars_1.default.registerHelper('ifEquals', (arg1, arg2, options) => {
35
+ return arg1 === arg2 ? options.fn(this) : options.inverse(this);
36
+ });
34
37
  const render = (template, data) => handlebars_1.default.compile(template)(data);
35
38
  exports.render = render;
36
39
  const renderFile = (file, data, templateFile) => {
@@ -39,3 +42,8 @@ const renderFile = (file, data, templateFile) => {
39
42
  (0, node_fs_1.writeFileSync)(file, output, 'utf8');
40
43
  };
41
44
  exports.renderFile = renderFile;
45
+ const registerPartial = (name, templateFile) => {
46
+ const template = (0, node_fs_1.readFileSync)(templateFile, 'utf8');
47
+ handlebars_1.default.registerPartial(name, template);
48
+ };
49
+ exports.registerPartial = registerPartial;
@@ -1 +1 @@
1
- {"version":3,"file":"seed.setup.d.ts","sourceRoot":"","sources":["../../src/utils/seed.setup.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,eAAe,qDAmC3B,CAAC;AAGF,eAAO,MAAM,gBAAgB,iGAMnB,OAAO,kBAyChB,CAAC"}
1
+ {"version":3,"file":"seed.setup.d.ts","sourceRoot":"","sources":["../../src/utils/seed.setup.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,eAAe,qDAmC3B,CAAC;AAGF,eAAO,MAAM,gBAAgB,iGAMnB,OAAO,kBA0ChB,CAAC"}
@@ -54,6 +54,7 @@ const configureSeedApp = (seedInfo, fetchSeedResult, params, dir, skipOptionalPr
54
54
  consola_1.consola.debug('Loaded seed data', data);
55
55
  const utils = {
56
56
  writeFileWithData: handlebars_1.renderFile,
57
+ registerPartial: handlebars_1.registerPartial,
57
58
  editJSONFile: json_1.editJSONFile,
58
59
  replaceObjectKeys: object_1.replaceObjectKeys,
59
60
  listAllFiles: fs_1.listAllFiles,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/build-kit",
3
3
  "description": "Build utilities & types",
4
- "version": "14.159.0",
4
+ "version": "14.160.0",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@esbuild-kit/cjs-loader": "2.4.2",
39
- "@genesislcap/foundation-testing": "14.159.0",
39
+ "@genesislcap/foundation-testing": "14.160.0",
40
40
  "@types/http-proxy": "^1.17.8",
41
41
  "@types/node": "^20.8.7",
42
42
  "tsm": "^2.2.1",
@@ -51,5 +51,5 @@
51
51
  "publishConfig": {
52
52
  "access": "public"
53
53
  },
54
- "gitHead": "ca4f78e47565e5b813a263c4fe40f52c9be221ca"
54
+ "gitHead": "f8c85f5e0a1928e51aacd7403607bd2e7457f510"
55
55
  }
@@ -39,6 +39,9 @@ handlebars.registerHelper('pathCase', (s) => s && pathCase(s));
39
39
  handlebars.registerHelper('sentenceCase', (s) => s && sentenceCase(s));
40
40
  handlebars.registerHelper('snakeCase', (s) => s && snakeCase(s));
41
41
  handlebars.registerHelper('upperCase', (s) => s && s.toUpperCase());
42
+ handlebars.registerHelper('ifEquals', (arg1, arg2, options) => {
43
+ return arg1 === arg2 ? options.fn(this) : options.inverse(this);
44
+ });
42
45
 
43
46
  export const render = (template, data) => handlebars.compile(template)(data);
44
47
 
@@ -51,3 +54,8 @@ export const renderFile = (
51
54
  const output = render(template, data);
52
55
  writeFileSync(file, output, 'utf8');
53
56
  };
57
+
58
+ export const registerPartial = (name: string, templateFile) => {
59
+ const template = readFileSync(templateFile, 'utf8');
60
+ handlebars.registerPartial(name, template);
61
+ };
@@ -3,7 +3,7 @@ import { resolve } from 'node:path';
3
3
  import { consola } from 'consola';
4
4
  import { runAsync } from './child-process';
5
5
  import { listAllFiles, rename, rm } from './fs';
6
- import { renderFile } from './handlebars';
6
+ import { registerPartial, renderFile } from './handlebars';
7
7
  import { editJSONFile } from './json';
8
8
  import { replaceObjectKeys } from './object';
9
9
  import { getData } from './prompts';
@@ -77,6 +77,7 @@ export const configureSeedApp = async (
77
77
 
78
78
  const utils = {
79
79
  writeFileWithData: renderFile,
80
+ registerPartial,
80
81
  editJSONFile,
81
82
  replaceObjectKeys,
82
83
  listAllFiles,
@@ -254,6 +254,18 @@ const scenarios = [
254
254
  data: { name: 'ab cd' },
255
255
  expected: '{ "name": "" }',
256
256
  },
257
+ {
258
+ description: 'ifEquals',
259
+ template: '{{#ifEquals type "pie"}}true{{/ifEquals}}',
260
+ data: { type: 'pie' },
261
+ expected: 'true',
262
+ },
263
+ {
264
+ description: 'ifEquals',
265
+ template: '{{#ifEquals type "pie"}}true{{else}}false{{/ifEquals}}',
266
+ data: { type: 'line' },
267
+ expected: 'false',
268
+ },
257
269
  ];
258
270
 
259
271
  scenarios.forEach((scenario) => {