From 5d93b4598f6aefaca2c9c929b90b49a5cd14e307 Mon Sep 17 00:00:00 2001 From: jroytman Date: Tue, 14 Oct 2025 20:15:56 -0700 Subject: [PATCH 1/3] switching to @profoundlogic/hogan --- package-lock.json | 80 +++++++++++++++++++------------------------- package.json | 2 +- scripts/hulk.ts | 8 ++--- src/hoganjs-utils.ts | 2 +- 4 files changed, 41 insertions(+), 51 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7ec34605..d6ed6f6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "3.0.0-beta.1", "license": "MIT", "dependencies": { - "diff": "^7.0.0", - "hogan.js": "3.0.2" + "@profoundlogic/hogan": "^3.0.4", + "diff": "^7.0.0" }, "devDependencies": { "@eslint/js": "^9.17.0", @@ -2663,6 +2663,39 @@ "node": ">= 8" } }, + "node_modules/@profoundlogic/hogan": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@profoundlogic/hogan/-/hogan-3.0.4.tgz", + "integrity": "sha512-pmNVGuooS30Mm7YbZd5T7E5zYVO6D5Ct91sn4T39mUvMUc3sCGridcnhAufL1/Bz2QzAtzEn0agNrdk3+5yWzw==", + "license": "Apache-2.0", + "dependencies": { + "nopt": "1.0.10" + }, + "bin": { + "hulk": "bin/hulk" + } + }, + "node_modules/@profoundlogic/hogan/node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "license": "ISC" + }, + "node_modules/@profoundlogic/hogan/node_modules/nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", + "license": "MIT", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -8695,49 +8728,6 @@ "node": ">=12.0.0" } }, - "node_modules/hogan.js": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/hogan.js/-/hogan.js-3.0.2.tgz", - "integrity": "sha512-RqGs4wavGYJWE07t35JQccByczmNUXQT0E12ZYV1VKYu5UiAU9lsos/yBAcf840+zrUQQxgVduCR5/B8nNtibg==", - "dependencies": { - "mkdirp": "0.3.0", - "nopt": "1.0.10" - }, - "bin": { - "hulk": "bin/hulk" - } - }, - "node_modules/hogan.js/node_modules/abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", - "license": "ISC" - }, - "node_modules/hogan.js/node_modules/mkdirp": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", - "integrity": "sha512-OHsdUcVAQ6pOtg5JYWpCBo9W/GySVuwvP9hueRMW7UqshC0tbfzLv8wjySTPm3tfUZ/21CE9E1pJagOA91Pxew==", - "deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)", - "license": "MIT/X11", - "engines": { - "node": "*" - } - }, - "node_modules/hogan.js/node_modules/nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", - "license": "MIT", - "dependencies": { - "abbrev": "1" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/hpack.js": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz", diff --git a/package.json b/package.json index daf3f52c..dc48fd07 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ }, "dependencies": { "diff": "^7.0.0", - "hogan.js": "3.0.2" + "@profoundlogic/hogan": "^3.0.4" }, "optionalDependencies": { "highlight.js": "11.9.0" diff --git a/scripts/hulk.ts b/scripts/hulk.ts index 019a36f2..0d2ac8fd 100755 --- a/scripts/hulk.ts +++ b/scripts/hulk.ts @@ -16,7 +16,7 @@ import * as path from 'path'; import * as fs from 'fs'; -import * as hogan from 'hogan.js'; +import * as hogan from '@profoundlogic/hogan'; import nopt from 'nopt'; import * as mkderp from 'mkdirp'; @@ -118,7 +118,7 @@ function wrap(file: string, name: string, openedFile: string): string { case 'amd': return `define(${ !options.outputdir ? `"${path.join(path.dirname(file), name)}", ` : '' - }["hogan.js"], function(Hogan) { return ${hoganTemplateString}; });`; + }["@profoundlogic/hogan"], function(Hogan) { return ${hoganTemplateString}; });`; case 'node': // If we have a template per file the export will expose the template directly @@ -139,12 +139,12 @@ function prepareOutput(content: string): string { case 'node': return `(function() { if (!!!global.${variableName}) global.${variableName} = {}; -var Hogan = require("hogan.js"); +var Hogan = require("@profoundlogic/hogan); ${content} ${!options.outputdir ? `module.exports = global.${variableName};\n` : ''})();`; case 'ts': - return `import * as Hogan from "hogan.js"; + return `import * as Hogan from "@profoundlogic/hogan"; type CompiledTemplates = { [name: string]: Hogan.Template }; export const ${variableName}: CompiledTemplates = {}; ${content}`; diff --git a/src/hoganjs-utils.ts b/src/hoganjs-utils.ts index 4b0fbc71..9e3e0c7c 100644 --- a/src/hoganjs-utils.ts +++ b/src/hoganjs-utils.ts @@ -1,4 +1,4 @@ -import * as Hogan from 'hogan.js'; +import * as Hogan from '@profoundlogic/hogan'; import { defaultTemplates } from './diff2html-templates'; From cab8530889dcf591e5ca90345d60e8a4d7fa77b2 Mon Sep 17 00:00:00 2001 From: jroytman Date: Mon, 10 Nov 2025 17:33:18 -0800 Subject: [PATCH 2/3] Fixing build issues --- package.json | 9 ++++++ scripts/hulk.ts | 3 ++ scripts/profoundlogic__hogan.d.ts | 52 +++++++++++++++++++++++++++++++ tsconfig.json | 5 +-- typings/profoundlogic__hogan.d.ts | 52 +++++++++++++++++++++++++++++++ 5 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 scripts/profoundlogic__hogan.d.ts create mode 100644 typings/profoundlogic__hogan.d.ts diff --git a/package.json b/package.json index dc48fd07..35a839fa 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,15 @@ "main": "./lib/diff2html.js", "module": "./lib-esm/diff2html.js", "types": "./lib/diff2html.d.ts", + "ts-node": { + "compilerOptions": { + "module": "commonjs", + "typeRoots": [ + "./node_modules/@types", + "./typings" + ] + } + }, "lint-staged": { "**/*.+(js|jsx|ts|tsx|json)": [ "prettier --write", diff --git a/scripts/hulk.ts b/scripts/hulk.ts index 0d2ac8fd..85f3ecf7 100755 --- a/scripts/hulk.ts +++ b/scripts/hulk.ts @@ -13,6 +13,9 @@ * limitations under the License. */ +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// + import * as path from 'path'; import * as fs from 'fs'; diff --git a/scripts/profoundlogic__hogan.d.ts b/scripts/profoundlogic__hogan.d.ts new file mode 100644 index 00000000..e9af5269 --- /dev/null +++ b/scripts/profoundlogic__hogan.d.ts @@ -0,0 +1,52 @@ +declare module '@profoundlogic/hogan' { + export interface Context { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: any; + } + + export interface SectionTags { + o: string; + c: string; + } + + export interface HoganOptions { + asString?: boolean | undefined; + sectionTags?: readonly SectionTags[] | undefined; + delimiters?: string | undefined; + disableLambda?: boolean | undefined; + } + + export interface Token { + tag: string; + otag?: string | undefined; + ctag?: string | undefined; + i?: number | undefined; + n?: string | undefined; + text?: string | undefined; + } + + export interface Leaf extends Token { + end: number; + nodes: Token[]; + } + + export type Tree = Leaf[]; + + export interface Partials { + [symbol: string]: HoganTemplate; + } + + export class HoganTemplate { + render(context: Context, partials?: Partials, indent?: string): string; + } + + export { HoganTemplate as Template, HoganTemplate as template }; + + export function compile(text: string, options?: HoganOptions & { asString: false }): HoganTemplate; + export function compile(text: string, options?: HoganOptions & { asString: true }): string; + export function compile(text: string, options?: HoganOptions): HoganTemplate | string; + + export function scan(text: string, delimiters?: string): Token[]; + + export function parse(tokens: readonly Token[], text?: undefined, options?: HoganOptions): Tree; +} diff --git a/tsconfig.json b/tsconfig.json index 62cbf976..72e6983b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["src/**/*", "typings/**/*"], + "include": ["src/**/*", "typings/**/*", "scripts/**/*"], "exclude": ["node_modules", "src/__tests__/**"], "compilerOptions": { "outDir": "bundles-out", @@ -32,6 +32,7 @@ "preserveConstEnums": true, "alwaysStrict": true, "noImplicitAny": true, - "noImplicitThis": true + "noImplicitThis": true, + "typeRoots": ["./node_modules/@types", "./typings"] } } diff --git a/typings/profoundlogic__hogan.d.ts b/typings/profoundlogic__hogan.d.ts new file mode 100644 index 00000000..e9af5269 --- /dev/null +++ b/typings/profoundlogic__hogan.d.ts @@ -0,0 +1,52 @@ +declare module '@profoundlogic/hogan' { + export interface Context { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: any; + } + + export interface SectionTags { + o: string; + c: string; + } + + export interface HoganOptions { + asString?: boolean | undefined; + sectionTags?: readonly SectionTags[] | undefined; + delimiters?: string | undefined; + disableLambda?: boolean | undefined; + } + + export interface Token { + tag: string; + otag?: string | undefined; + ctag?: string | undefined; + i?: number | undefined; + n?: string | undefined; + text?: string | undefined; + } + + export interface Leaf extends Token { + end: number; + nodes: Token[]; + } + + export type Tree = Leaf[]; + + export interface Partials { + [symbol: string]: HoganTemplate; + } + + export class HoganTemplate { + render(context: Context, partials?: Partials, indent?: string): string; + } + + export { HoganTemplate as Template, HoganTemplate as template }; + + export function compile(text: string, options?: HoganOptions & { asString: false }): HoganTemplate; + export function compile(text: string, options?: HoganOptions & { asString: true }): string; + export function compile(text: string, options?: HoganOptions): HoganTemplate | string; + + export function scan(text: string, delimiters?: string): Token[]; + + export function parse(tokens: readonly Token[], text?: undefined, options?: HoganOptions): Tree; +} From 14613377167052abfc0b5fb8e4c0a0d03576d34a Mon Sep 17 00:00:00 2001 From: jroytman Date: Tue, 18 Nov 2025 21:01:15 -0800 Subject: [PATCH 3/3] Remove duplicate profoundlogic__hogan.d.ts from scripts directory The type definitions in typings/ directory are sufficient. Updated the triple-slash reference in scripts/hulk.ts to point to the correct location. --- scripts/hulk.ts | 2 +- scripts/profoundlogic__hogan.d.ts | 52 ------------------------------- 2 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 scripts/profoundlogic__hogan.d.ts diff --git a/scripts/hulk.ts b/scripts/hulk.ts index 85f3ecf7..ed487f3b 100755 --- a/scripts/hulk.ts +++ b/scripts/hulk.ts @@ -14,7 +14,7 @@ */ // eslint-disable-next-line @typescript-eslint/triple-slash-reference -/// +/// import * as path from 'path'; import * as fs from 'fs'; diff --git a/scripts/profoundlogic__hogan.d.ts b/scripts/profoundlogic__hogan.d.ts deleted file mode 100644 index e9af5269..00000000 --- a/scripts/profoundlogic__hogan.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -declare module '@profoundlogic/hogan' { - export interface Context { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; - } - - export interface SectionTags { - o: string; - c: string; - } - - export interface HoganOptions { - asString?: boolean | undefined; - sectionTags?: readonly SectionTags[] | undefined; - delimiters?: string | undefined; - disableLambda?: boolean | undefined; - } - - export interface Token { - tag: string; - otag?: string | undefined; - ctag?: string | undefined; - i?: number | undefined; - n?: string | undefined; - text?: string | undefined; - } - - export interface Leaf extends Token { - end: number; - nodes: Token[]; - } - - export type Tree = Leaf[]; - - export interface Partials { - [symbol: string]: HoganTemplate; - } - - export class HoganTemplate { - render(context: Context, partials?: Partials, indent?: string): string; - } - - export { HoganTemplate as Template, HoganTemplate as template }; - - export function compile(text: string, options?: HoganOptions & { asString: false }): HoganTemplate; - export function compile(text: string, options?: HoganOptions & { asString: true }): string; - export function compile(text: string, options?: HoganOptions): HoganTemplate | string; - - export function scan(text: string, delimiters?: string): Token[]; - - export function parse(tokens: readonly Token[], text?: undefined, options?: HoganOptions): Tree; -}