From 5f7448fa038b5f2cc27e174b46adb3f16b218a77 Mon Sep 17 00:00:00 2001
From: waiting <1661926154@qq.com>
Date: Sun, 13 Oct 2024 20:49:23 +0800
Subject: [PATCH 01/10] ci: update Github Action config
---
.github/workflows/nodejs.yml | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml
index f5b75374..53d6ec3b 100644
--- a/.github/workflows/nodejs.yml
+++ b/.github/workflows/nodejs.yml
@@ -41,7 +41,6 @@ jobs:
- name: Prepare
run: |
- pwd
uname -a
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq --yes > /dev/null
@@ -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
From bddfb8ac3a19593a8451ada4cd0fac5f70d138e8 Mon Sep 17 00:00:00 2001
From: waiting <1661926154@qq.com>
Date: Sun, 13 Oct 2024 22:48:05 +0800
Subject: [PATCH 02/10] docs: update README.md
[skip ci]
---
README.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index cdd3898d..f2edaa0b 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
[![](https://img.shields.io/badge/lang-TypeScript-blue.svg)]()
[![ci](https://github.com/waitingsong/npm-mono-base/actions/workflows/nodejs.yml/badge.svg
)](https://github.com/waitingsong/npm-mono-base/actions)
-[![codecov](https://codecov.io/gh/waitingsong/npm-mono-base/branch/main/graph/badge.svg?token=Voxor5PtnG)](https://codecov.io/gh/waitingsong/npm-mono-base)
+[![codecov](https://codecov.io/gh/waitingsong/npm-mono-base/graph/badge.svg?token=Voxor5PtnG)](https://codecov.io/gh/waitingsong/npm-mono-base)
以下所有命令行操作都在 `git-bash` 窗口中执行
@@ -21,10 +21,10 @@ npm i -g c8 lerna madge rollup tsx zx
## Packages
-| Package | Version | Dependencies | DevDependencies |
-| ------------ | ---------------------- | ---------------------------- | ------------------------------ |
-| [`demo`] | [![main-svg]][main-ch] | [![main-d-svg]][main-d-link] | [![main-dd-svg]][main-dd-link] |
-| [`demo-cli`] | [![cli-svg]][cli-ch] | [![cli-d-svg]][cli-d-link] | [![cli-dd-svg]][cli-dd-link] |
+| Package | Version |
+| ------------ | ---------------------- |
+| [`demo`] | [![main-svg]][main-ch] |
+| [`demo-cli`] | [![cli-svg]][cli-ch] |
## License
@@ -38,12 +38,12 @@ npm i -g c8 lerna madge rollup tsx zx
[`demo`]: https://github.com/waitingsong/npm-mono-base/tree/main/packages/demo
-[main-svg]: https://img.shields.io/npm/v/kmore.svg?maxAge=7200
+[main-svg]: https://img.shields.io/npm/v/kmore.svg?maxAge=300
[main-ch]: https://github.com/waitingsong/kmore/tree/main/packages/demo/CHANGELOG.md
[`demo-cli`]: https://github.com/waitingsong/kmore/tree/main/packages/kmore-cli
-[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
From 76534dd310dd4f8f09c28fc7101a9e730f2ed315 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 15 Oct 2024 01:18:15 +0000
Subject: [PATCH 03/10] chore(deps-dev): bump autocannon from 7.15.0 to 8.0.0
Bumps [autocannon](https://github.com/mcollina/autocannon) from 7.15.0 to 8.0.0.
- [Release notes](https://github.com/mcollina/autocannon/releases)
- [Commits](https://github.com/mcollina/autocannon/compare/v7.15.0...v8.0.0)
---
updated-dependencies:
- dependency-name: autocannon
dependency-type: direct:development
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot]
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index c87a48dc..05b45b20 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
"@waiting/eslint-config": "^15.0.0",
"@waiting/shared-core": "^23.21.0",
"@waiting/shared-types": "^23.21.0",
- "autocannon": "7",
+ "autocannon": "8",
"cross-env": "7",
"mocha": "10",
"mwtsc": "^1.11.2",
From 602287b6c53f1700da380c9abe18e5373e243264 Mon Sep 17 00:00:00 2001
From: waiting <1661926154@qq.com>
Date: Thu, 17 Oct 2024 21:25:27 +0800
Subject: [PATCH 04/10] ci(boilerplate): update .env
---
.env | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/.env b/.env
index 3e9aa598..1ef0b946 100644
--- a/.env
+++ b/.env
@@ -6,3 +6,9 @@
# POSTGRES_USER=postgres
# POSTGRES_PASSWORD=postgres
+# PARADEDB_HOST="127.0.0.1"
+# PARADEDB_PORT=5432
+# PARADEDB_DB=db_ci_test
+# PARADEDB_USER=postgres
+# PARADEDB_PASSWORD=postgres
+
From 90ae1128042bc31ebe38e75c53abecde7622029a Mon Sep 17 00:00:00 2001
From: waiting <1661926154@qq.com>
Date: Thu, 17 Oct 2024 22:47:10 +0800
Subject: [PATCH 05/10] ci(boilerplate): update eslint.config.mjs and .env
---
.env | 6 ++++++
eslint.config.mjs | 2 ++
2 files changed, 8 insertions(+)
diff --git a/.env b/.env
index 1ef0b946..139dd95f 100644
--- a/.env
+++ b/.env
@@ -6,6 +6,12 @@
# 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
diff --git a/eslint.config.mjs b/eslint.config.mjs
index b8dd5671..91976a7f 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -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,
],
@@ -42,6 +43,7 @@ export default eslint.config(
},
{
files: ['packages/*/test/**/*.ts', 'test/**/*.ts'],
+ ignores: ['**/*.d.ts'],
extends: [
...testConfig,
],
From 4c40acb486d72d34bfe82c2bcbbdd5a90a806d7b Mon Sep 17 00:00:00 2001
From: waiting <1661926154@qq.com>
Date: Fri, 18 Oct 2024 12:38:03 +0800
Subject: [PATCH 06/10] ci: update scripts and bump devDeps version
---
.scripts/add-mwcp.sh | 102 +++++++++++++++++++++++++++++++++++++++++++
.scripts/add-pkg.sh | 20 +++------
package.json | 17 ++++----
3 files changed, 116 insertions(+), 23 deletions(-)
create mode 100755 .scripts/add-mwcp.sh
diff --git a/.scripts/add-mwcp.sh b/.scripts/add-mwcp.sh
new file mode 100755
index 00000000..f2e1b29e
--- /dev/null
+++ b/.scripts/add-mwcp.sh
@@ -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
+
diff --git a/.scripts/add-pkg.sh b/.scripts/add-pkg.sh
index 4a647414..9eee41f7 100755
--- a/.scripts/add-pkg.sh
+++ b/.scripts/add-pkg.sh
@@ -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"
@@ -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"
@@ -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!"
diff --git a/package.json b/package.json
index 05b45b20..37a9e906 100644
--- a/package.json
+++ b/package.json
@@ -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",
+ "@waiting/eslint-config": "^15.1.0",
+ "@waiting/shared-core": "^23.22.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"
@@ -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'\" ",
From 7d6c00034001e354ed8526d7ef4968fe573b0256 Mon Sep 17 00:00:00 2001
From: waiting <1661926154@qq.com>
Date: Fri, 18 Oct 2024 13:51:09 +0800
Subject: [PATCH 07/10] chore(boilerplate): add mw-demo/src/app/index.app.ts
---
packages/mw-demo/src/app/index.app.ts | 4 ++++
1 file changed, 4 insertions(+)
create mode 100644 packages/mw-demo/src/app/index.app.ts
diff --git a/packages/mw-demo/src/app/index.app.ts b/packages/mw-demo/src/app/index.app.ts
new file mode 100644
index 00000000..47bde842
--- /dev/null
+++ b/packages/mw-demo/src/app/index.app.ts
@@ -0,0 +1,4 @@
+
+export * from './default.controller.js'
+export * from './default.types.js'
+
From fcee94c8244ccd25dc8bb9934dbcd07700e96d6e Mon Sep 17 00:00:00 2001
From: waiting <1661926154@qq.com>
Date: Fri, 18 Oct 2024 15:04:29 +0800
Subject: [PATCH 08/10] ci: update .env
---
.env | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.env b/.env
index 139dd95f..85ee1f14 100644
--- a/.env
+++ b/.env
@@ -1,8 +1,9 @@
# 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
From 8e4a232beb5d3225b4f8cd4f31fd9f1a7ae84043 Mon Sep 17 00:00:00 2001
From: waiting <1661926154@qq.com>
Date: Fri, 18 Oct 2024 18:08:55 +0800
Subject: [PATCH 09/10] chore(boilerplate): update mw-demo
---
packages/mw-demo/src/app/error.ts | 9 +++++++++
packages/mw-demo/src/app/index.app.ts | 1 +
packages/mw-demo/src/configuration.ts | 14 +++++++++++++-
3 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 packages/mw-demo/src/app/error.ts
diff --git a/packages/mw-demo/src/app/error.ts b/packages/mw-demo/src/app/error.ts
new file mode 100644
index 00000000..0c1f34ef
--- /dev/null
+++ b/packages/mw-demo/src/app/error.ts
@@ -0,0 +1,9 @@
+import { HttpStatus, MidwayHttpError } from '@midwayjs/core'
+
+
+export class ApiNotEnabledHttpError extends MidwayHttpError {
+ constructor() {
+ super('Api not enabled', HttpStatus.UNAUTHORIZED)
+ }
+}
+
diff --git a/packages/mw-demo/src/app/index.app.ts b/packages/mw-demo/src/app/index.app.ts
index 47bde842..825e400d 100644
--- a/packages/mw-demo/src/app/index.app.ts
+++ b/packages/mw-demo/src/app/index.app.ts
@@ -1,4 +1,5 @@
export * from './default.controller.js'
export * from './default.types.js'
+export * from './error.js'
diff --git a/packages/mw-demo/src/configuration.ts b/packages/mw-demo/src/configuration.ts
index c323257a..24718624 100644
--- a/packages/mw-demo/src/configuration.ts
+++ b/packages/mw-demo/src/configuration.ts
@@ -1,4 +1,3 @@
-
import assert from 'node:assert'
import {
@@ -80,5 +79,18 @@ export class AutoConfiguration implements ILifeCycle {
this.logger.info(`[${ConfigKey.componentName}] onReady`)
}
+ async onStop(container: IMidwayContainer): Promise {
+ void container
+ this.logger.info(`[${ConfigKey.componentName}] stopping`)
+
+ // const out = 10_000
+ // const p1 = new Promise(done => setTimeout(done, out))
+ // const p2 = this.dbSourceManager.stop()
+ // await Promise.race([p1, p2])
+ // .catch((ex: Error) => {
+ // console.error(ex.message)
+ // })
+ this.logger.info(`[${ConfigKey.componentName}] stopped`)
+ }
}
From 2923b14ca2e41e72d4f884e758d5dc06ea7b3dfd Mon Sep 17 00:00:00 2001
From: waiting <1661926154@qq.com>
Date: Tue, 29 Oct 2024 17:48:23 +0800
Subject: [PATCH 10/10] chore(boilerplate): bump deps version
---
package.json | 2 +-
packages/mw-demo/package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index 37a9e906..3c2441c8 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"@types/mocha": "10",
"@types/node": "22",
"@waiting/eslint-config": "^15.1.0",
- "@waiting/shared-core": "^23.22.0",
+ "@waiting/shared-core": "^23.23.0",
"@waiting/shared-types": "^23.22.0",
"autocannon": "8",
"cross-env": "7",
diff --git a/packages/mw-demo/package.json b/packages/mw-demo/package.json
index 7ef66bbb..e4f605e1 100644
--- a/packages/mw-demo/package.json
+++ b/packages/mw-demo/package.json
@@ -32,7 +32,7 @@
},
"license": "MIT",
"dependencies": {
- "@mwcp/otel": "^38.0.0"
+ "@mwcp/otel": "^39.0.0"
},
"devDependencies": {
},