mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
chore: 优化npm发布流程 (#9396)
Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
This commit is contained in:
parent
efcf8e2c66
commit
1d7efdccf2
1
.gitignore
vendored
1
.gitignore
vendored
@ -41,3 +41,4 @@ revision.json
|
|||||||
|
|
||||||
|
|
||||||
!/.vscode/iconConfig.json
|
!/.vscode/iconConfig.json
|
||||||
|
publish.sh
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
"release": "npm run build --workspaces && lerna publish from-package --registry=https://registry.npmjs.org --ignore-scripts",
|
"release": "npm run build --workspaces && lerna publish from-package --registry=https://registry.npmjs.org --ignore-scripts",
|
||||||
"revision": "ts-node ./scripts/generate-revision.ts",
|
"revision": "ts-node ./scripts/generate-revision.ts",
|
||||||
"getChangeLog": "ts-node ./scripts/getChangeLog",
|
"getChangeLog": "ts-node ./scripts/getChangeLog",
|
||||||
"publish-to-internal": "sh ./publish-to-internal.sh",
|
|
||||||
"stylelint": "npx stylelint 'packages/**/*.scss'",
|
"stylelint": "npx stylelint 'packages/**/*.scss'",
|
||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit",
|
||||||
|
"publish": "npx publish"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
@ -60,6 +60,7 @@
|
|||||||
"@types/react": "^18.0.24",
|
"@types/react": "^18.0.24",
|
||||||
"@types/react-dom": "^18.0.8",
|
"@types/react-dom": "^18.0.8",
|
||||||
"@vitejs/plugin-react": "^2.2.0",
|
"@vitejs/plugin-react": "^2.2.0",
|
||||||
|
"amis-publish": "^0.0.0-beta.8",
|
||||||
"copy-to-clipboard": "3.3.1",
|
"copy-to-clipboard": "3.3.1",
|
||||||
"echarts": "5.4.0",
|
"echarts": "5.4.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
###
|
|
||||||
# @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
|
|
@ -1,93 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
source ./scripts/utils.sh
|
|
||||||
|
|
||||||
echo "请选择发布内网or外网:"
|
|
||||||
publish_types=("internal" "external")
|
|
||||||
|
|
||||||
select_option "${publish_types[@]}"
|
|
||||||
|
|
||||||
publish_type=$selected_option
|
|
||||||
|
|
||||||
echo "请选择发布版本的类型:"
|
|
||||||
|
|
||||||
options=("latest" "beta" "alpha" "custom")
|
|
||||||
|
|
||||||
select_option "${options[@]}"
|
|
||||||
|
|
||||||
if [ "$selected_option" == "custom" ]; then
|
|
||||||
read -p "请自定义输入版本: " version
|
|
||||||
npm_get_tag $version
|
|
||||||
tag=$npm_tag
|
|
||||||
else
|
|
||||||
tag=$selected_option
|
|
||||||
if [ "$publish_type" == "internal" ]; then
|
|
||||||
current_version=`npm show @fex/amis-theme-editor-helper@${tag} version --registry=http://registry.npm.baidu-int.com`
|
|
||||||
else
|
|
||||||
current_version=`npm show amis-theme-editor-helper@${tag} version`
|
|
||||||
fi
|
|
||||||
if [ -z "${current_version}" ]; then
|
|
||||||
echo "没有找到的${tag}版本"
|
|
||||||
read -p "请自定义输入版本: " version
|
|
||||||
npm_get_tag $version
|
|
||||||
tag=$npm_tag
|
|
||||||
else
|
|
||||||
echo "当前版本:${current_version}"
|
|
||||||
npm_version $current_version $tag
|
|
||||||
version=$new_version
|
|
||||||
read -p "确认更新y or n: " confirm
|
|
||||||
if [ "$confirm" != "y" ]; then
|
|
||||||
read -p "请自定义输入版本: " version
|
|
||||||
npm_get_tag $version
|
|
||||||
tag=$npm_tag
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
sed -i '' -e 's/\"version\": \".*\"/\"version\": \"'${version}'\"/g' ./packages/amis-theme-editor-helper/package.json
|
|
||||||
|
|
||||||
npm run build --workspace=amis-theme-editor-helper
|
|
||||||
|
|
||||||
rm -rf theme-npm
|
|
||||||
|
|
||||||
mkdir -p theme-npm/amis-theme-editor-helper
|
|
||||||
|
|
||||||
cp -rf packages/amis-theme-editor-helper/lib theme-npm/amis-theme-editor-helper
|
|
||||||
cp -rf packages/amis-theme-editor-helper/esm theme-npm/amis-theme-editor-helper
|
|
||||||
cp packages/amis-theme-editor-helper/package.json theme-npm/amis-theme-editor-helper
|
|
||||||
|
|
||||||
cd theme-npm/amis-theme-editor-helper
|
|
||||||
|
|
||||||
if [ "$publish_type" == "internal" ]; then
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 把代码里面import的部分换成内部包名称
|
|
||||||
for f in $(find ./ -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-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#'\(i18n-runtime\)\(['\"/]\)#'@fex\/\1\2#g" $f
|
|
||||||
sed -i '' -e "s#\"\(i18n-runtime\)\(['\"/]\)#\"@fex\/\1\2#g" $f
|
|
||||||
done
|
|
||||||
|
|
||||||
npm publish --tag=$tag --registry=http://registry.npm.baidu-int.com
|
|
||||||
else
|
|
||||||
npm publish --tag=$tag
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
|||||||
#!/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
|
|
11
publish.json
Normal file
11
publish.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"privateKeyPath": "../npm.key",
|
||||||
|
"companyKey": "npm",
|
||||||
|
"appKey": "npm",
|
||||||
|
"pageKey": "npm",
|
||||||
|
"clientId": "u8w6gTAeR9gfMdxxPMsCyv",
|
||||||
|
"package": [
|
||||||
|
"amis",
|
||||||
|
"amis-theme-editor-helper"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user