fix(sdk): skip comment-only chunks when splitting migrations

This commit is contained in:
LukeGus committed 2026-10-15 21:52:11 -05:00
1 parent cc5dce18e2
commit d2851982a6
6 files changed
+28 -5

No files matched your search

+6
View File
@@ -1,5 +1,11 @@
# Changelog
## 1.0.7
### Fixed
- A migration file, or a part of one, holding only comments made core fail to start the plugin
## 1.0.6
### Added
+1 -1
View File
@@ -1,6 +1,6 @@
# Termix plugin guide
SDK 1.0.6 | Plugin API 1.2.0
SDK 1.0.7 | Plugin API 1.2.0
This guide is for anyone, person or AI coding tool, building a Termix plugin. It ships inside
`@termix-ssh/plugin-sdk`, so the copy in your `node_modules` always matches the SDK you have installed.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@termix-ssh/plugin-sdk",
"version": "1.0.6",
"version": "1.0.7",
"description": "The contract between Termix core and a plugin: types, the capability catalog and the manifest schema.",
"license": "Apache-2.0",
"repository": {
+12 -2
View File
@@ -309,17 +309,27 @@ export function splitStatements(source: string): string[] {
continue;
}
if (char === ";") {
if (current.trim()) statements.push(current.trim());
if (hasSql(current)) statements.push(current.trim());
current = "";
continue;
}
current += char;
}
if (current.trim()) statements.push(current.trim());
if (hasSql(current)) statements.push(current.trim());
return statements;
}
/** False for a chunk that is only comments, which a driver refuses to run. */
function hasSql(chunk: string): boolean {
return (
chunk
.replace(/--[^\n]*/g, "")
.replace(/\/\*[\s\S]*?\*\//g, "")
.trim() !== ""
);
}
/** DROP statement for a definition, for removePluginData. */
export function dropTableSql(
dialect: SqlDialect,