diff --git a/package.json b/package.json index 988f2f12..315f05d4 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,11 @@ "plugin", "rechunk.podspec" ], + "workspaces": [ + "app", + "docs", + "example" + ], "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org" @@ -34,17 +39,21 @@ "build": "tsup", "dev": "tsup --watch", "prepare": "husky", - "prerelease": "scripts/remove-workspace", - "release": "release-it", - "postrelease": "scripts/restore-workspace" + "release": "release-it" }, "release-it": { "git": { "commitMessage": "chore: release v${version}", - "requireCleanWorkingDir": false + "requireCleanWorkingDir": false, + "push": false, + "commit": false }, "github": { "release": true + }, + "hooks": { + "before:init": "scripts/remove-workspace", + "after:release": "scripts/restore-workspace && git add -A && git commit -m \"chore: release\" && git push" } }, "source": "src/react-native/index", diff --git a/scripts/restore-workspace b/scripts/restore-workspace index ab2254ae..0fa5825c 100755 --- a/scripts/restore-workspace +++ b/scripts/restore-workspace @@ -1,10 +1,21 @@ #!/usr/bin/env node const fs = require('fs'); +const path = require('path'); -fs.copyFileSync( - path.resolve(workingPath, 'package.json.bak'), +const workingPath = process.cwd(); + +const {workspaces} = JSON.parse( + fs.readFileSync(path.resolve(workingPath, 'package.json.bak'), 'utf8'), +); + +const packageJson = JSON.parse( + fs.readFileSync(path.resolve(workingPath, 'package.json'), 'utf8'), +); + +fs.writeFileSync( path.resolve(workingPath, 'package.json'), + `${JSON.stringify({...packageJson, workspaces}, null, 2)}\n`, ); fs.unlinkSync(path.resolve(workingPath, 'package.json.bak'));