Skip to content

Commit 170465b

Browse files
committed
[scripts] adding script to help with pusblish libs
1 parent 8656b3f commit 170465b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

scripts/publish-libs.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Publishing the packages/libs into npm registry
4+
# ---
5+
# There is an error that I (chalda) haven't been able to fix yet (knowledge+lack of time)
6+
# That pnpm `workspace:` depedency is not correctly translated to npm published package
7+
# and when the dependency uses `workspace:` then command `npm install -g ...` fails
8+
# to load such dependencies when running as a global command at the system.
9+
# I think the `npm` does not understand the `workspace:` prefix as it's from `pnpm`. Not sure though.
10+
11+
12+
# This script thus stripping the `workspace:` prefix from the `dependencies` in `package.json`
13+
# and then publishing the package to npm registry
14+
# and then placing it back to the `package.json` file.
15+
16+
if [ -z "$1" ]; then
17+
echo "Usage: $0 <version>"
18+
exit 1
19+
fi
20+
21+
SCRIPT_PATH=`readlink -f "$0"`
22+
SCRIPT_DIR=`dirname "$SCRIPT_PATH"`
23+
VERSION=`cat $SCRIPT_DIR/../packages/lib/ts-common/package.json | grep version | cut -d '"' -f 4`
24+
NEW_VERSION="$1"
25+
26+
set -e
27+
pnpm install
28+
pnpm build
29+
30+
find -name package.json | xargs -I file sed -i 's/workspace:[ \t]*//' file
31+
find -name package.json | xargs -I file sed -i "s/${VERSION}/${NEW_VERSION}/" file
32+
33+
echo "Going to publish the packages/libs to npm registry, from version ${VERSION} to ${NEW_VERSION}"
34+
read -p "Press enter to continue"
35+
36+
pnpm publish:libs
37+
38+
find -name package.json | xargs -I file sed -i 's/\(@marinade.finance[^:]*: "\)'"${NEW_VERSION}"'/\1workspace: '"${NEW_VERSION}"'/' file
39+
pnpm install

0 commit comments

Comments
 (0)