Procházet zdrojové kódy

feat(staking): make sdk ready for release (#1933)

* feat(staking): make sdk ready for release

* fix

* fix
Keyvan Khademi před 1 rokem
rodič
revize
75781f8ecd

+ 4 - 2
governance/pyth_staking_sdk/package.json

@@ -6,9 +6,11 @@
   "exports": {
     ".": "./src/index.ts"
   },
-  "private": true,
+  "publishConfig": {
+    "access": "public"
+  },
   "scripts": {
-    "build": "tsc",
+    "build": "tsc && node scripts/update-package-json.js",
     "test": "pnpm run test:format && pnpm run test:lint && pnpm run test:integration && pnpm run test:types",
     "fix": "pnpm fix:lint && pnpm fix:format",
     "fix:format": "prettier --write .",

+ 22 - 0
governance/pyth_staking_sdk/scripts/update-package-json.js

@@ -0,0 +1,22 @@
+import fs from "fs";
+import path from "path";
+import { fileURLToPath } from "url";
+
+/**
+ * This script updates the package.json file in the dist directory after the TypeScript build.
+ *
+ * This ensures that the published package correctly references the compiled JavaScript
+ * instead of the TypeScript source files.
+ */
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+
+const distPackageJsonPath = path.join(__dirname, "..", "dist", "package.json");
+
+const packageJson = JSON.parse(fs.readFileSync(distPackageJsonPath, "utf8"));
+
+packageJson.exports = {
+  ".": "./src/index.js",
+};
+
+fs.writeFileSync(distPackageJsonPath, JSON.stringify(packageJson, null, 2));