forked from baidu/amis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-editor-to-internal.sh
107 lines (73 loc) · 3.79 KB
/
publish-editor-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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
###
# @description 文件
# @return {*}
###
#!/bin/bash
editorLatestVersion=`npm info @fex/amis-editor --registry=http://registry.npm.baidu-int.com | grep "latest:"`
editroCoreLatestVersion=`npm info @fex/amis-editor-core --registry=http://registry.npm.baidu-int.com | grep "latest:"`
echo "amis-editor最新版本:${editorLatestVersion}"
echo "amis-editor-core最新版本:${editroCoreLatestVersion}"
read -p "请输入amis-editor版本: " version1
read -p "请输入amis-editor-core版本: " version2
sed -i '' -e 's/\"version\": \".*\"/\"version\": \"'${version1}'\"/g' ./packages/amis-editor/package.json
sed -i '' -e 's/\"version\": \".*\"/\"version\": \"'${version2}'\"/g' ./packages/amis-editor-core/package.json
set -e
rm -rf npm
npm run build --workspace=amis-editor --workspace=amis-editor-core
mkdir -p npm/amis-editor
mkdir -p npm/amis-editor-core
cp -rf packages/amis-editor/lib npm/amis-editor
cp -rf packages/amis-editor/esm npm/amis-editor
cp packages/amis-editor/package.json npm/amis-editor
cp -rf packages/amis-editor-core/lib npm/amis-editor-core
cp -rf packages/amis-editor-core/esm npm/amis-editor-core
cp -rf packages/amis-editor-core/static npm/amis-editor-core
cp packages/amis-editor-core/package.json npm/amis-editor-core
cp packages/amis-editor-core/src/locale/* npm/amis-editor-core/lib/locale
cd npm
funTransContent(){
# 把代码里面import的部分换成内部包名称
for f in $(find $1 -type f -name "*.[tj]s"); do
# 正则那个 | 用不了,还不知道为何
#sed -i '' -e "s#\('|\"\)\(amis|amis-formula|amis-core|amis-ui|amis-editor|amis-editor-core\)\('|\"|\/\)#\1@fex\/\2\3#g" $f
sed -i '' -e "s#'\(amis\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(amis\)\(['\"/]\)#\"@fex\/\1\2#g" $f
sed -i '' -e "s#'\(amis-formula\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(amis-formula\)\(['\"/]\)#\"@fex\/\1\2#g" $f
sed -i '' -e "s#'\(amis-core\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(amis-core\)\(['\"/]\)#\"@fex\/\1\2#g" $f
sed -i '' -e "s#'\(amis-ui\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(amis-ui\)\(['\"/]\)#\"@fex\/\1\2#g" $f
sed -i '' -e "s#'\(amis-editor\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(amis-editor\)\(['\"/]\)#\"@fex\/\1\2#g" $f
sed -i '' -e "s#'\(amis-editor-core\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(amis-editor-core\)\(['\"/]\)#\"@fex\/\1\2#g" $f
sed -i '' -e "s#'\(amis-editor-comp\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(amis-editor-comp\)\(['\"/]\)#\"@fex\/\1\2#g" $f
sed -i '' -e "s#'\(amis-theme-editor\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(amis-theme-editor\)\(['\"/]\)#\"@fex\/\1\2#g" $f
sed -i '' -e "s#'\(amis-postcss\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(amis-postcss\)\(['\"/]\)#\"@fex\/\1\2#g" $f
sed -i '' -e "s#'\(amis-theme-editor-helper\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(amis-theme-editor-helper\)\(['\"/]\)#\"@fex\/\1\2#g" $f
sed -i '' -e "s#'\(i18n-runtime\)\(['\"/]\)#'@fex\/\1\2#g" $f
sed -i '' -e "s#\"\(i18n-runtime\)\(['\"/]\)#\"@fex\/\1\2#g" $f
done
}
echo "处理 amis-editor 包文件内容中……"
funTransContent './amis-editor'
echo "处理 amis-editor-core 包文件内容中……"
funTransContent './amis-editor-core'
echo '处理pacakge.json文件内容'
# package.json 里面把包名称换了
for f in $(find ./ -name "package.json"); do
sed -i '' -e 's/\"name\": \"amis/\"name\": \"@fex\/amis/g' $f
sed -i '' -e 's/\"amis-/\"@fex\/amis-/g' $f
sed -i '' -e 's/\"amis\":/\"@fex\/amis\":/g' $f
sed -i '' -e 's/\"i18n-runtime\":/\"@fex\/i18n-runtime\":/g' $f
done
echo "正在发版……"
cd ./amis-editor-core
npm publish --registry=http://registry.npm.baidu-int.com
cd ../amis-editor
npm publish --registry=http://registry.npm.baidu-int.com