@hardkas/artifacts 0.7.4-alpha → 0.7.6-alpha
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 +27 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@hardkas/artifacts",
|
|
4
|
-
version: "0.7.
|
|
4
|
+
version: "0.7.6-alpha",
|
|
5
5
|
type: "module",
|
|
6
6
|
license: "MIT",
|
|
7
7
|
author: "Javier Rodriguez",
|
|
@@ -1362,8 +1362,33 @@ import path from "path";
|
|
|
1362
1362
|
import { writeFileAtomic } from "@hardkas/core";
|
|
1363
1363
|
var bigIntReplacer = (_key, value) => typeof value === "bigint" ? value.toString() : value;
|
|
1364
1364
|
async function writeArtifact(filePath, artifact) {
|
|
1365
|
+
let targetPath = filePath;
|
|
1366
|
+
try {
|
|
1367
|
+
const stats = await fs2.stat(filePath);
|
|
1368
|
+
if (stats.isDirectory()) {
|
|
1369
|
+
const artifactObj = typeof artifact === "string" ? JSON.parse(artifact) : artifact;
|
|
1370
|
+
const id = artifactObj.planId || artifactObj.signedId || artifactObj.txId || Date.now().toString(36);
|
|
1371
|
+
const prefix = artifactObj.schema ? artifactObj.schema.split(".")[1] || "artifact" : "artifact";
|
|
1372
|
+
targetPath = path.join(filePath, `${prefix}-${id}.json`);
|
|
1373
|
+
console.log(
|
|
1374
|
+
`
|
|
1375
|
+
Note: Provided path is a directory. Auto-generating artifact filename: ${path.basename(targetPath)}`
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1378
|
+
} catch (e) {
|
|
1379
|
+
if (filePath.endsWith("/") || filePath.endsWith("\\")) {
|
|
1380
|
+
const artifactObj = typeof artifact === "string" ? JSON.parse(artifact) : artifact;
|
|
1381
|
+
const id = artifactObj.planId || artifactObj.signedId || artifactObj.txId || Date.now().toString(36);
|
|
1382
|
+
const prefix = artifactObj.schema ? artifactObj.schema.split(".")[1] || "artifact" : "artifact";
|
|
1383
|
+
targetPath = path.join(filePath, `${prefix}-${id}.json`);
|
|
1384
|
+
console.log(
|
|
1385
|
+
`
|
|
1386
|
+
Note: Provided path is a directory. Auto-generating artifact filename: ${path.basename(targetPath)}`
|
|
1387
|
+
);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1365
1390
|
const content = typeof artifact === "string" ? artifact : JSON.stringify(artifact, bigIntReplacer, 2) + "\n";
|
|
1366
|
-
await writeFileAtomic(
|
|
1391
|
+
await writeFileAtomic(targetPath, content);
|
|
1367
1392
|
}
|
|
1368
1393
|
function getDefaultReceiptPath(txId, cwd = process.cwd()) {
|
|
1369
1394
|
return path.join(cwd, "artifacts", "receipts", `${txId}.json`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/artifacts",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Javier Rodriguez",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"zod": "^3.24.1",
|
|
27
|
-
"@hardkas/
|
|
28
|
-
"@hardkas/
|
|
27
|
+
"@hardkas/core": "0.7.6-alpha",
|
|
28
|
+
"@hardkas/tx-builder": "0.7.6-alpha"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"tsup": "^8.3.5",
|