@tpmjs/tools-sprites-checkpoint-create 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -83,33 +83,39 @@ var spritesCheckpointCreateTool = tool({
|
|
|
83
83
|
throw new Error("Failed to read response from Sprites API");
|
|
84
84
|
}
|
|
85
85
|
const lines = text.trim().split("\n").filter((line) => line.trim());
|
|
86
|
-
let
|
|
86
|
+
let checkpointId = "";
|
|
87
|
+
let createdAt = "";
|
|
87
88
|
for (const line of lines) {
|
|
88
89
|
try {
|
|
89
90
|
const parsed = JSON.parse(line);
|
|
90
|
-
if (parsed.
|
|
91
|
-
|
|
91
|
+
if (parsed.type === "error") {
|
|
92
|
+
throw new Error(`Checkpoint creation failed: ${parsed.data || "Unknown error"}`);
|
|
92
93
|
}
|
|
93
|
-
if (parsed.
|
|
94
|
-
|
|
94
|
+
if (parsed.type === "info" && parsed.data?.trim().startsWith("ID:")) {
|
|
95
|
+
checkpointId = parsed.data.trim().replace("ID:", "").trim();
|
|
96
|
+
}
|
|
97
|
+
if (parsed.type === "info" && parsed.data?.trim().startsWith("Created:")) {
|
|
98
|
+
createdAt = parsed.data.trim().replace("Created:", "").trim();
|
|
99
|
+
}
|
|
100
|
+
if (parsed.type === "complete" && parsed.data && !checkpointId) {
|
|
101
|
+
const match = parsed.data.match(/Checkpoint\s+(\S+)\s+created/);
|
|
102
|
+
if (match && match[1]) {
|
|
103
|
+
checkpointId = match[1];
|
|
104
|
+
}
|
|
95
105
|
}
|
|
96
106
|
} catch (parseError) {
|
|
97
107
|
if (parseError instanceof SyntaxError) continue;
|
|
98
108
|
throw parseError;
|
|
99
109
|
}
|
|
100
110
|
}
|
|
101
|
-
if (!
|
|
102
|
-
|
|
103
|
-
checkpointData = JSON.parse(text);
|
|
104
|
-
} catch {
|
|
105
|
-
throw new Error(`Failed to parse checkpoint response. Raw response: ${text.slice(0, 200)}`);
|
|
106
|
-
}
|
|
111
|
+
if (!checkpointId) {
|
|
112
|
+
throw new Error(`Failed to extract checkpoint ID from response. Raw response: ${text.slice(0, 300)}`);
|
|
107
113
|
}
|
|
108
114
|
return {
|
|
109
|
-
id:
|
|
110
|
-
name:
|
|
111
|
-
createdAt:
|
|
112
|
-
size:
|
|
115
|
+
id: checkpointId,
|
|
116
|
+
name: checkpointName || checkpointId,
|
|
117
|
+
createdAt: createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
118
|
+
size: void 0
|
|
113
119
|
};
|
|
114
120
|
}
|
|
115
121
|
});
|