eeditiones / tei-publisher-app

The main TEI Publisher app
https://teipublisher.com
GNU General Public License v3.0
68 stars 33 forks source link

Broken app generation if \templates\basic\modules\config.xqm file has CRLF line encoding #198

Open daliboris opened 1 year ago

daliboris commented 1 year ago

When the \templates\basic\modules\config.xqm file is uploaded on the server with CRLF end of lines (on Windows) the TEI Publisher is unabled to generate an application.

The generation ends with the following exception thrown in the Roaster.

<exception>
    <path>/db/apps/teilex0-publisher/modules/lib/api-dba.xql</path>
    <message>err:XPTY0004 checking function parameter 3 in call map:put($error, &quot;description&quot;, router:error-description(untyped-value-check[xs:string, $error?description], untyped-value-check[xs:integer, $error?line], untyped-value-check[xs:integer, $error?column], untyped-value-check[xs:string, $error?module], $error?value)): XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: router:error-description($description as xs:string, $line as xs:integer?, $column as xs:integer?, $module as xs:string?, $value as item()*) xs:string. Expected cardinality: exactly one, got 0. [at line 424, column 40, source: D:\eXist-db\data\expathrepo\roaster-1.8.1\content\router.xql]
    In function:
        router:error-description(xs:string, xs:integer?, xs:integer?, xs:string?, item()*) [424:9:D:\eXist-db\data\expathrepo\roaster-1.8.1\content\router.xql]
        router:default-error-handler(xs:integer, map(*)) [415:9:D:\eXist-db\data\expathrepo\roaster-1.8.1\content\router.xql]
        router:error(xs:integer, map(*), function(*)) [145:17:D:\eXist-db\data\expathrepo\roaster-1.8.1\content\router.xql]
        router:route(xs:string+, function(*), function(*)*) [80:5:D:\eXist-db\data\expathrepo\roaster-1.8.1\content\router.xql]
        roaster:route(xs:string+, function(*)) [20:14:D:\eXist-db\data\expathrepo\roaster-1.8.1\content\roaster.xqm]
    </message>
</exception>

If EOL is changed to LF, TEI Publisher can generate applications as usual.

daliboris commented 1 year ago

After some time of coding, the problem with the application generation error reappeared and changing EOL in the config.xqm file didn't help.

Workaround of this problem was generating the TEI Lex-0 application using GitHub Actions and installing the application back on the eXist-db.

The comparison between local files and files in generated package was obvious: local files used CRLF line encoding, generated files LF.

Promissing and long-term solution: changing EOL in all module files + setting LF for the workspace in Visual Studion Code: "files.eol": "\n",

For changing all file on Windows machine I used solution described in StackOverflow:

Prerequsities:

EOL Conversion

$path = Get-Location
# These files are not in the `modules` directory, just to be sure
$exclude_patterns = "^.*(\.git|\.idea|node_modules|\.next|\.(jpeg|jpg|png|gif|mp4|mkv|mp3|wav)$).*$"
# Find files to convert
$files = Get-ChildItem -Path $path -Recurse -Include *.* -File -Force | Where-Object {$_.FullName -notmatch $exclude_patterns}
Write-Host "Found $($files.Count) files"
$files | ForEach-Object { dos2unix $_.FullName }

All files have been converted and even synchronized with the eXist-db server.

daliboris commented 1 year ago

The solution used by Luka (from Slack):

After replacing the whole modules folder with the one on GitHub I can generate new applications, so that fixed it.

duncdrum commented 2 months ago

@line-o are you aware of this? Could this be fixed on roasters end? Should the bug move there?