0
0
Fork 0

fix: ASCII-fy add_library.py comment, clean dist/scripts on build, global ASCII test

- add_library.py line 49 had UTF-8 box-drawing dashes in a comment with no
  coding declaration -- latent IronPython 2.7 source-encoding risk.
- build now removes dist/scripts before copying, so deleted/renamed
  templates (compile_project.py.bak, probe_app_error_state.py,
  set_library_namespace.py) no longer ship in the npm tarball.
- script-manager test now asserts EVERY template is ASCII-only instead of
  per-phase lists.
This commit is contained in:
Karstein Phobic Nyvold Kvistad 2026-06-12 13:43:27 +02:00
parent 5fbe5687de
commit e9aa71415e
3 changed files with 12 additions and 2 deletions

View file

@ -12,7 +12,7 @@
"LICENSE"
],
"scripts": {
"build": "tsc && node -e \"require('fs').cpSync('src/scripts','dist/scripts',{recursive:true})\"",
"build": "tsc && node -e \"const fs=require('fs');fs.rmSync('dist/scripts',{recursive:true,force:true});fs.cpSync('src/scripts','dist/scripts',{recursive:true})\"",
"test": "vitest --run",
"test:watch": "vitest",
"typecheck": "tsc --noEmit",

View file

@ -46,7 +46,7 @@ FORCE_DUP = "{FORCE_DUP}" == "1"
ALLOW_UNRESOLVED = "{ALLOW_UNRESOLVED}" == "1"
# ─── SP-version detection ─────────────────────────────────────────────────
# --- SP-version detection -------------------------------------------------
#
# CODESYS reports its build through `sys.version` in the IronPython
# embedding (e.g. "CODESYS V3.5 SP22 Patch 1, ScriptEngine 4.2.0.0").

View file

@ -84,6 +84,16 @@ describe('ScriptManager', () => {
expect(result).toBe('path = r"C:\\Program Files\\CODESYS"');
});
it('EVERY script template is ASCII-only (IronPython 2.7, no coding declaration)', () => {
const fs = require('fs');
const dir = path.join(__dirname, '..', '..', 'src', 'scripts');
for (const f of fs.readdirSync(dir) as string[]) {
const body = fs.readFileSync(path.join(dir, f), 'latin1');
// eslint-disable-next-line no-control-regex
expect(/^[\x00-\x7F]*$/.test(body), `${f} must be ASCII-only`).toBe(true);
}
});
it('dollar sequences in values are NOT treated as regex replacement patterns', () => {
// IEC string literals use $ escapes ($R$N, $$ for a literal $). A plain
// string replacement would collapse '$$' to '$' and expand '$&'.