From 3ded5ac7ffa8e27c6e4a94cf873e0e281eac859e Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Tue, 2 Jul 2024 02:24:57 +0700 Subject: [PATCH] update scripts --- packages/widget/package.json | 6 ++++-- packages/widget/scripts/prepublish.cjs | 18 ++++++++++++++++++ packages/widget/scripts/prepublish.js | 16 ---------------- 3 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 packages/widget/scripts/prepublish.cjs delete mode 100644 packages/widget/scripts/prepublish.js diff --git a/packages/widget/package.json b/packages/widget/package.json index 08151159..66248749 100644 --- a/packages/widget/package.json +++ b/packages/widget/package.json @@ -28,8 +28,10 @@ "build": "rollup --config rollup.config.js", "lint": "eslint src --ext .ts", "chains:generate": "tsx ./src/scripts/codegen.ts", - "postpublish": "git reset --hard", - "prepublishOnly": "node scripts/prepublish.js" + "postpublish": "git checkout -- package.json", + "prepublishOnly": "npm run build && node scripts/prepublish.cjs", + "prepack": "npm run build && node scripts/prepublish.cjs", + "postpack": "git checkout -- package.json" }, "peerDependencies": { "react": "17.x || 18.x", diff --git a/packages/widget/scripts/prepublish.cjs b/packages/widget/scripts/prepublish.cjs new file mode 100644 index 00000000..d0e8e718 --- /dev/null +++ b/packages/widget/scripts/prepublish.cjs @@ -0,0 +1,18 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ + +const fs = require('fs/promises'); +const path = require('path'); +const packageJson = require('../package.json'); +const coreVersion = require('@skip-go/core/package.json').version; + +async function prepublish() { + delete packageJson.scripts; + delete packageJson.devDependencies; + packageJson.dependencies['@skip-go/core'] = coreVersion; + const targetPath = path.resolve(process.cwd(), 'package.json'); + await fs.writeFile(targetPath, JSON.stringify(packageJson, null, 2), { + encoding: 'utf-8', + }); +} + +void prepublish(); diff --git a/packages/widget/scripts/prepublish.js b/packages/widget/scripts/prepublish.js deleted file mode 100644 index bbd12d0c..00000000 --- a/packages/widget/scripts/prepublish.js +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ - -const fs = require("fs/promises"); -const path = require("path"); -const packageJson = require("../package.json"); - -async function prepublish() { - delete packageJson.scripts; - delete packageJson.devDependencies; - const targetPath = path.resolve(process.cwd(), "package.json"); - await fs.writeFile(targetPath, JSON.stringify(packageJson, null, 2), { - encoding: "utf-8", - }); -} - -void prepublish();