Skip to content

Commit

Permalink
Merge remote-tracking branch 'bp/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Oct 29, 2024
2 parents b56b9e4 + 2923b14 commit a2ebdb3
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 33 deletions.
15 changes: 14 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@

# OTEL_EXPORTER_OTLP_ENDPOINT="http://127.0.0.1:4317"

# POSTGRES_HOST="127.0.0.1"
# POSTGRES_PORT=5432
# POSTGRES_DB=postgres
# POSTGRES_DB=db_ci_test
# POSTGRES_USER=postgres
# POSTGRES_PASSWORD=postgres

# PGMQ_HOST="127.0.0.1"
# PGMQ_PORT=5432
# PGMQ_DB=db_ci_test
# PGMQ_USER=postgres
# PGMQ_PASSWORD=postgres

# PARADEDB_HOST="127.0.0.1"
# PARADEDB_PORT=5432
# PARADEDB_DB=db_ci_test
# PARADEDB_USER=postgres
# PARADEDB_PASSWORD=postgres

5 changes: 1 addition & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
- name: Prepare
run: |
pwd
uname -a
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq --yes > /dev/null
Expand Down Expand Up @@ -81,16 +80,14 @@ jobs:
- name: Install Dependencies
timeout-minutes: 15
run: |
# DO NOT execute: npm config set unsafe-perm=true
export cwd=`pwd`
npm i --no-audit -g c8 lerna madge tsx zx
npm i
npm i --no-audit
env:
CI: true

- name: Build
run: |
pwd
whoami
export cwd=`pwd`
. .scripts/ci/ci-env.sh
Expand Down
102 changes: 102 additions & 0 deletions .scripts/add-mwcp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash
# ---------------------------
# Add sub-package from packages/mw-demo
#
# ---------------------------

cwd=`pwd`
PKGS="$cwd/packages"
tplDir="$PKGS/mw-demo"
tplName="@mwcp/demo"

pkgName="$1"

if [ -z "$pkgName" ]; then
echo -e "Missing package name!"
echo -e "Command examples: "
echo -e " - 'npm run add:mwcp bar' without scope @mwcp"
echo -e "\n"
exit 1
fi

pkgScope="@mwcp"
pkgScopeWoAt="mwcp"
pkgFullName="${pkgScope}/${pkgName}"

if [ -z "$pkgName" ]; then
echo -e "pkgName empty!"
echo -e "Input: \"$pkgFullName\""
echo -e "\n"
exit 1
fi
pkgFullDir="${pkgScopeWoAt}-${pkgName}"

echo -e "-------------------------------------------"
echo -e " Initialize package from tpl $tplName"
echo -e " Name: $pkgFullName "
echo -e " Folder: $pkgFullDir "
echo -e "-------------------------------------------"


# pkgPath="${PKGS}/${pkgName}"
pkgPath="${PKGS}/${pkgFullDir}"

if [ -d "$pkgPath" ]; then
echo -e "pkg path EXITS!"
echo -e "path: \"$pkgPath\""
echo -e "\n"
exit 1
fi

mkdir -p "$pkgPath" "$pkgPath/src"

fReadme="README.md"
f1="package.json"
f2="tsconfig.json"
f4=".editorconfig"
f8="LICENSE"


f03="bootstrap.js"

echo -e "Copying files to folder: $pkgPath/ ..."
cp "$tplDir/$f1" "$pkgPath/"
cp "$tplDir/$f2" "$pkgPath/"
cp "$tplDir/$f4" "$pkgPath/"

cp "$tplDir/$f03" "$pkgPath/"
echo "" >> "$pkgPath/$fReadme"

cp -a "$tplDir/src" "$pkgPath/"

pkgJson="$pkgPath/package.json"
echo -e "Updating file: $pkgJson"

sed -i "s#$tplName#${pkgFullName}#g" "$pkgJson"
sed -i "s#\(private.\+\)true#\1false#g" "$pkgJson"
repo=$(git remote get-url origin)
if [ -n "$repo" ]; then
sed -i "s#\(git+https://\)#${repo}#" "$pkgJson"
fi

testDir="$pkgPath/test"
mkdir -p "$testDir"
cp -a "$tplDir/test/" "$pkgPath/"
rm -rf "$testDir/fixtures/base-app/logs"

echo -e "Git add files..."
git add -f -- "$pkgPath"

git commit -nm "chore: initialize package $pkgFullName"
echo -e "Git add success\n"


rm -rf .nx
npm i --disturl=https://npmmirror.com/dist/
npm run build "$pkgFullName"

echo -e "\nInitialization success. You should git add files under src/ manually!"

echo -e "Packages list:"
lerna list

20 changes: 5 additions & 15 deletions .scripts/add-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,14 @@ f1="package.json"
f2="tsconfig.json"
f4=".editorconfig"
f8="LICENSE"
f9="rollup.config.js"
f10="tsconfig.cjs.json"

echo -e "Copying files to folder: $pkgPath/ ..."
cp "$tplDir/$f1" "$pkgPath/"
cp "$tplDir/$f2" "$pkgPath/"
cp "$tplDir/$f4" "$pkgPath/"
cp "$tplDir/$f8" "$pkgPath/"
cp "$tplDir/$f9" "$pkgPath/"
cp "$tplDir/$f10" "$pkgPath/"

cp -a "$tplDir/src" "$pkgPath/"

pkgJson="$pkgPath/package.json"
echo -e "Updating file: $pkgJson"
Expand All @@ -79,14 +77,8 @@ fi

testDir="$pkgPath/test"
mkdir -p "$testDir"
t1="tsconfig.json"
t2="0.dummy.test.ts"

t4="root.hooks.ts"
cp "$tplDir/test/$t1" "$testDir/"
cp "$tplDir/test/$t2" "$testDir/"
cp -a "$tplDir/test/" "$pkgPath/"

cp "$tplDir/test/$t4" "$testDir/"

echo -e "Git add files..."
git add -f -- "$pkgPath"
Expand All @@ -95,10 +87,8 @@ git commit -nm "chore($pkgName): initialize package $pkgFullName"
echo -e "Git add success\n"


cp -a "$tplDir/src" "$pkgPath/"
echo -e "Copying folder src/ done, You should git add files manually!"

npm run bootstrap
rm -rf .nx
npm i --disturl=https://npmmirror.com/dist/
npm run build "$pkgFullName"

echo -e "\nInitialization success. You should git add files under src/ manually!"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,17 +412,17 @@ This repository contains all these packages. Below you will find a summary of ea
[`kmore-cli`]: https://github.com/waitingsong/kmore/tree/main/packages/kmore-cli
[`@mwcp/kmore`]: https://github.com/waitingsong/kmore/tree/main/packages/midway-component-kmore

[kmore-svg]: https://img.shields.io/npm/v/kmore.svg?maxAge=7200
[kmore-svg]: https://img.shields.io/npm/v/kmore.svg?maxAge=300
[kmore-ch]: https://github.com/waitingsong/kmore/tree/main/packages/kmore/CHANGELOG.md

[types-svg]: https://img.shields.io/npm/v/kmore-types.svg?maxAge=7200
[types-svg]: https://img.shields.io/npm/v/kmore-types.svg?maxAge=300
[types-ch]: https://github.com/waitingsong/kmore/tree/main/packages/kmore-types/CHANGELOG.md

[cli-svg]: https://img.shields.io/npm/v/kmore-cli.svg?maxAge=7200
[cli-svg]: https://img.shields.io/npm/v/kmore-cli.svg?maxAge=300
[cli-ch]: https://github.com/waitingsong/kmore/tree/main/packages/kmore-clie/CHANGELOG.md


[mw-svg]: https://img.shields.io/npm/v/@mwcp/kmore.svg?maxAge=7200
[mw-svg]: https://img.shields.io/npm/v/@mwcp/kmore.svg?maxAge=300
[mw-ch]: https://github.com/waitingsong/kmore/tree/main/packages/midway-component-kmore/CHANGELOG.md


Expand Down
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const languageOptions = {
export default eslint.config(
{
files: ['packages/*/src/**/*.ts', 'src/**/*.ts', 'packages/*/demo/**/*.mts' , 'packages/*/demo/**/*.ts'],
ignores: ['**/*.d.ts'],
extends: [
...srcConfig,
],
Expand All @@ -42,6 +43,7 @@ export default eslint.config(
},
{
files: ['packages/*/test/**/*.ts', 'test/**/*.ts'],
ignores: ['**/*.d.ts'],
extends: [
...testConfig,
],
Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
"devDependencies": {
"@commitlint/cli": "19",
"@commitlint/config-conventional": "19",
"@midwayjs/mock": "^3.18.0",
"@midwayjs/swagger": "^3.18.1",
"@midwayjs/validate": "^3.18.0",
"@midwayjs/mock": "^3.18.2",
"@midwayjs/swagger": "^3.18.2",
"@midwayjs/validate": "^3.18.2",
"@types/koa": "2",
"@types/mocha": "10",
"@types/node": "22",
"@waiting/eslint-config": "^15.0.0",
"@waiting/shared-core": "^23.21.0",
"@waiting/shared-types": "^23.21.0",
"autocannon": "7",
"@waiting/eslint-config": "^15.1.0",
"@waiting/shared-core": "^23.23.0",
"@waiting/shared-types": "^23.22.0",
"autocannon": "8",
"cross-env": "7",
"mocha": "10",
"mwtsc": "^1.11.2",
"mwtsc": "^1.12.0",
"swagger-ui-dist": "^5.17.14",
"ts-node": "^10.9.2",
"tsc-alias": "^1.8.10",
"typescript": "^5.6.2"
"typescript": "^5.6.3"
},
"engines": {
"node": ">=20.11.0"
Expand All @@ -33,6 +33,7 @@
],
"scripts": {
"add:pkg": "sh .scripts/add-pkg.sh",
"add:mwcp": "sh .scripts/add-mwcp.sh",
"bp:add": "git remote add bp https://github.com/waitingsong/npm-mono-base",
"bp:sync": "git fetch --all -v && git pull origin && git merge bp/main -m \"Merge remote-tracking branch 'bp/main'\" ",
"bp:sync-force": "git fetch --all -v && git pull origin && git merge bp/main --allow-unrelated-histories -m \"Merge remote-tracking branch 'bp/main'\" ",
Expand Down

0 comments on commit a2ebdb3

Please sign in to comment.