forked from baidu/amis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-to-internal.sh
56 lines (44 loc) · 1.79 KB
/
publish-to-internal.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -e
npm run build --workspace=amis-formula --workspace=amis-core --workspace=amis-ui --workspace=amis
rm -rf npm
mkdir -p npm/packages
# 如果有问题可以注释掉这两行,不知道为啥会导致 cp -rf 挂掉
# rm -rf packages/amis/node_modules/.bin
# rm -rf packages/amis-ui/node_modules/.bin
cp -r packages/{amis-formula,amis-core,amis-ui,amis} npm/packages
cp package.json npm
# 记录last commit,便于区分内网版本包之间的差异
REVISION=revision.json
npm run revision -- $REVISION
if [ -f "$REVISION" ]; then
for dir in $(find ./npm/packages -mindepth 1 -maxdepth 1 -type d); do
[ -d "$dir" ] && cp $REVISION "$dir/$REVISION";
done;
else
echo "$REVISION not exists."
fi
cd npm
# package.json 里面把包名称换了
for f in $(find ./packages -name "package.json"); do
sed -i '' -e 's/\"name\": \"amis/\"name\": \"@fex\/amis/g' $f
sed -i '' -e 's/\"amis-/\"@fex\/amis-/g' $f
done
# 把代码里面import的部分换成内部包名称
for f in $(find ./packages/*/lib -type f -name "*.[tj]s"); do
sed -i '' -e "s/from \'amis/from \'@fex\/amis/g" $f
sed -i '' -e "s/import(\'amis/import(\'@fex\/amis/g" $f
sed -i '' -e "s/import[ ]*\'amis/import \'@fex\/amis/g" $f
sed -i '' -e "s/require(\'amis/require(\'@fex\/amis/g" $f
sed -i '' -e "s/require(\[\'amis/require(\[\'@fex\/amis/g" $f
done
for f in $(find ./packages/*/esm -type f -name "*.[tj]s"); do
sed -i '' -e "s/from \'amis/from \'@fex\/amis/g" $f
sed -i '' -e "s/import(\'amis/import(\'@fex\/amis/g" $f
sed -i '' -e "s/import[ ]*\'amis/import \'@fex\/amis/g" $f
sed -i '' -e "s/require(\'amis/require(\'@fex\/amis/g" $f
sed -i '' -e "s/require(\[\'amis/require(\[\'@fex\/amis/g" $f
done
npm publish --workspaces --registry=http://registry.npm.baidu-int.com --ignore-scripts
cd ..
rm -rf npm