From 1d7efdccf2382579980d0be8994152d8a64f5637 Mon Sep 17 00:00:00 2001 From: qkiroc <30946345+qkiroc@users.noreply.github.com> Date: Wed, 10 Jan 2024 18:41:12 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96npm=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=B5=81=E7=A8=8B=20(#9396)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> --- .gitignore | 1 + package.json | 7 ++- publish-editor-to-internal.sh | 107 ---------------------------------- publish-theme.sh | 93 ----------------------------- publish-to-internal.sh | 56 ------------------ publish.json | 11 ++++ 6 files changed, 16 insertions(+), 259 deletions(-) delete mode 100644 publish-editor-to-internal.sh delete mode 100644 publish-theme.sh delete mode 100644 publish-to-internal.sh create mode 100644 publish.json diff --git a/.gitignore b/.gitignore index 2e4fce9bd..c64882e09 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ revision.json !/.vscode/iconConfig.json +publish.sh diff --git a/package.json b/package.json index cb4dddbe1..a6d84a880 100644 --- a/package.json +++ b/package.json @@ -26,9 +26,9 @@ "release": "npm run build --workspaces && lerna publish from-package --registry=https://registry.npmjs.org --ignore-scripts", "revision": "ts-node ./scripts/generate-revision.ts", "getChangeLog": "ts-node ./scripts/getChangeLog", - "publish-to-internal": "sh ./publish-to-internal.sh", "stylelint": "npx stylelint 'packages/**/*.scss'", - "typecheck": "tsc --noEmit" + "typecheck": "tsc --noEmit", + "publish": "npx publish" }, "husky": { "hooks": { @@ -60,6 +60,7 @@ "@types/react": "^18.0.24", "@types/react-dom": "^18.0.8", "@vitejs/plugin-react": "^2.2.0", + "amis-publish": "^0.0.0-beta.8", "copy-to-clipboard": "3.3.1", "echarts": "5.4.0", "express": "^4.18.2", @@ -143,4 +144,4 @@ "printBasicPrototype": false } } -} +} \ No newline at end of file diff --git a/publish-editor-to-internal.sh b/publish-editor-to-internal.sh deleted file mode 100644 index a7a614b41..000000000 --- a/publish-editor-to-internal.sh +++ /dev/null @@ -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 diff --git a/publish-theme.sh b/publish-theme.sh deleted file mode 100644 index b0449eacb..000000000 --- a/publish-theme.sh +++ /dev/null @@ -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 - - diff --git a/publish-to-internal.sh b/publish-to-internal.sh deleted file mode 100644 index f428e0bdb..000000000 --- a/publish-to-internal.sh +++ /dev/null @@ -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 diff --git a/publish.json b/publish.json new file mode 100644 index 000000000..40db1ac60 --- /dev/null +++ b/publish.json @@ -0,0 +1,11 @@ +{ + "privateKeyPath": "../npm.key", + "companyKey": "npm", + "appKey": "npm", + "pageKey": "npm", + "clientId": "u8w6gTAeR9gfMdxxPMsCyv", + "package": [ + "amis", + "amis-theme-editor-helper" + ] +} \ No newline at end of file