CI / typecheck + test + build (windows) (push) Canceled after 0s
P1: - settingsStore: back up an unparseable settings.json to .bak before falling back to defaults, so the next mutation can no longer silently wipe custom themes/highlight rules - ptyDispatcher: fan out per-session data/exit handlers (Set instead of a single slot) so SSH split panes stop stealing each other's stream - FilePanel: monotonic refresh token keeps stale listings from painting over a newer navigation; upload finish no longer yanks the panel back - settings.css: active settings-tab label derives from --chrome-fg so it stays visible on the shipped light themes P2 (main/renderer): - paste guard: a paste ending in a newline always confirms - Workspace: closing an SSH pane no longer seeds the local cwd with a remote path - tray: skip close-dialog continuation on a destroyed window - commands: close zombie 'in-progress' session logs at hydrate - zmodem: clear the stale offer timer before arming a new one - connectionsStore: coerce/validate renderer input before persisting - sftp: OperationError marker class keeps translated errors out of the transport-retry classifier - CommandsPanel: surface save failures inside the dialog - ConnectionSidebar: drop a tautological tooltip condition P2 (i18n/tooling/tests): - localize the 16 ANSI color labels and the highlight sample text (21 new keys across zh-CN/zh-TW/en/ja) - sync-changelog: keep ### subheadings, normalize CRLF notes - release.cjs: GitHub release reuse-by-tag (idempotent re-runs); fail loudly on a failed Gitea asset listing - commands-store test: absent historyEnabled now truly tests absence
84 lines
4.0 KiB
JavaScript
84 lines
4.0 KiB
JavaScript
/* Merge per-language release notes into the matching CHANGELOG file as the
|
|
section for the current package.json version. Idempotent: a version already
|
|
present is skipped. Run BEFORE `npm run dist` — the changelogs are bundled
|
|
into the app and shown per interface language.
|
|
Usage: node scripts/sync-changelog.cjs
|
|
|
|
RELEASE_NOTES.md (Simplified Chinese) is required; the other three are
|
|
optional — a version without a translation falls back to zh-CN in the UI. */
|
|
const fs = require('node:fs')
|
|
const path = require('node:path')
|
|
|
|
const ROOT = path.join(__dirname, '..')
|
|
const pkgVersion = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version
|
|
|
|
const TARGETS = [
|
|
{ notes: 'RELEASE_NOTES.md', changelog: 'CHANGELOG.md', header: '# OpenTerminal 更新日志', required: true },
|
|
{ notes: 'RELEASE_NOTES.zh-TW.md', changelog: 'CHANGELOG.zh-TW.md', header: '# OpenTerminal 更新日誌' },
|
|
{ notes: 'RELEASE_NOTES.en.md', changelog: 'CHANGELOG.en.md', header: '# OpenTerminal Changelog' },
|
|
{ notes: 'RELEASE_NOTES.ja.md', changelog: 'CHANGELOG.ja.md', header: '# OpenTerminal 更新履歴' }
|
|
]
|
|
|
|
const sync = ({ notes, changelog, header, required }) => {
|
|
const notesPath = path.join(ROOT, notes)
|
|
const changelogPath = path.join(ROOT, changelog)
|
|
if (!fs.existsSync(notesPath)) {
|
|
if (required) {
|
|
console.error(`${notes} is missing — write the release notes first`)
|
|
process.exit(1)
|
|
}
|
|
console.log(`${changelog}: no ${notes} — left unchanged`)
|
|
return
|
|
}
|
|
|
|
const body = fs
|
|
.readFileSync(notesPath, 'utf8')
|
|
// Normalize newlines first: a CRLF notes file would otherwise keep its `\r`
|
|
// in every line, and the join below re-adds the changelog's ending on top —
|
|
// every line of the merged section rendering as `\r\r\n` (doubled blanks).
|
|
.replace(/\r\n/g, '\n')
|
|
// Drop only the notes' own title and the `## v<pkgVersion>` heading: the
|
|
// section heading is built here so every changelog stays uniform
|
|
// (`## vX.Y.Z - date`). Stripping every `#`-line (the old behaviour) also
|
|
// removed `###` subheadings, merging 新功能/修复 groups into one flat list.
|
|
.replace(new RegExp(`^# .*\\n|^## v${pkgVersion}.*\\n`, 'gm'), '')
|
|
.replace(/^\s+/, '')
|
|
.trimEnd()
|
|
|
|
if (!body) {
|
|
console.error(`${notes} is empty — write the release notes first`)
|
|
process.exit(1)
|
|
}
|
|
|
|
const existing = fs.existsSync(changelogPath) ? fs.readFileSync(changelogPath, 'utf8') : ''
|
|
if (existing.includes(`## v${pkgVersion} `)) {
|
|
console.log(`${changelog}: already has v${pkgVersion} — nothing to do`)
|
|
return
|
|
}
|
|
|
|
// The header pattern must match the file's own newlines: a checkout with
|
|
// core.autocrlf=true leaves these files CRLF, and an `\n`-only pattern then
|
|
// matches nothing — the write below becomes a silent no-op that still logs
|
|
// success (exactly what bit the v1.0.17 sync). The inserted section follows
|
|
// the file's dominant ending so it does not create mixed line endings.
|
|
const nl = existing.includes('\r\n') ? '\r\n' : '\n'
|
|
const section =
|
|
`## v${pkgVersion} - ${new Date().toISOString().slice(0, 10)}${nl}${nl}` +
|
|
`${body.split('\n').join(nl)}${nl}`
|
|
// Function replacement, not a string: a notes body containing `$&`, `$1`, `` $` ``
|
|
// or `$'` would otherwise be expanded by String.replace and corrupt the merge.
|
|
const updated = existing
|
|
? existing.replace(new RegExp(`^(${header}\\r?\\n\\r?\\n)`), (_m, head) => `${head}${section}${nl}`)
|
|
: `${header}${nl}${nl}${section}`
|
|
fs.writeFileSync(changelogPath, updated, 'utf8')
|
|
// Belt and braces: the header replace is the only thing that places the
|
|
// section, so prove it landed instead of trusting the pattern.
|
|
if (!fs.readFileSync(changelogPath, 'utf8').includes(`## v${pkgVersion} `)) {
|
|
console.error(`${changelog}: header pattern did not match — section was NOT inserted`)
|
|
process.exit(1)
|
|
}
|
|
console.log(`${changelog}: added v${pkgVersion} (${body.split('\n').length} lines)`)
|
|
}
|
|
|
|
for (const target of TARGETS) sync(target)
|