Skip to content

Fix hardcoded logic entry point in TemplateArchiveProcessor #107

@Sup-ri-tha

Description

@Sup-ri-tha

Bug Report

Description

In TemplateArchiveProcessor.ts, both the trigger() and init() methods
hardcode the logic entry point as logic/logic.ts when looking up compiled code:

code: compiledCode['logic/logic.ts'].code, // TODO DCS - how to find the code to run?

This assumes the logic file is always named exactly logic/logic.ts. If a template
uses any other filename, compiledCode['logic/logic.ts'] returns undefined,
causing an unhelpful crash:

TypeError: Cannot read properties of undefined (reading 'code')

Location

  • File: src/TemplateArchiveProcessor.ts
  • Lines: 120 and 169 (both trigger() and init() methods)

Fix

Dynamically find the entry point by searching for a file directly inside the
logic/ folder that is not auto-generated:

const entryPoint = Object.keys(compiledCode).find(
    key => key.startsWith('logic/') && !key.includes('generated/')
);
if (!entryPoint) {
    throw new Error('Could not find compiled logic entry point');
}
code: compiledCode[entryPoint].code,

Additional Notes

The // TODO DCS comment on both lines suggests this was flagged by the
original author as needing a proper fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions