From 472779ed3652a0343a50dd269e064aeabd4877b4 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Wed, 6 Nov 2024 17:25:54 +0800 Subject: [PATCH 01/27] docs: make intro clear --- README.md | 69 ++++++++++++++++++++-------------------- config/config.default.js | 4 +-- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 08582ab..f1a6c47 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,26 @@ # egg-mongoose + [![NPM version][npm-image]][npm-url] -[![build status][travis-image]][travis-url] +[![Run tests](https://github.com/eggjs/egg-mongoose/actions/workflows/autoUnitTest.yml/badge.svg)](https://github.com/eggjs/egg-mongoose/actions/workflows/autoUnitTest.yml) [![Test coverage][codecov-image]][codecov-url] -[![David deps][david-image]][david-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][download-url] -[npm-image]: https://img.shields.io/npm/@oneWalker/egg-mongoose.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@oneWalker/egg-mongoose -[travis-image]: https://img.shields.io/travis/eggjs/egg-mongoose.svg?style=flat-square -[travis-url]: https://travis-ci.org/eggjs/egg-mongoose +[npm-image]: https://img.shields.io/npm/v/egg-mongoose.svg?style=flat-square +[npm-url]: https://www.npmjs.com/package/@onewalker/egg-mongoose [codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-mongoose.svg?style=flat-square [codecov-url]: https://codecov.io/github/eggjs/egg-mongoose?branch=master -[david-image]: https://img.shields.io/david/eggjs/egg-mongoose.svg?style=flat-square -[david-url]: https://david-dm.org/eggjs/egg-mongoose [snyk-image]: https://snyk.io/test/npm/egg-mongoose/badge.svg?style=flat-square [snyk-url]: https://snyk.io/test/npm/egg-mongoose -[download-image]: https://img.shields.io/npm/dm/@oneWalker/egg-mongoose.svg?style=flat-square -[download-url]: https://npmjs.org/package/@oneWalker/egg-mongoose +[download-image]: https://img.shields.io/npm/dm/@onewalker/egg-mongoose.svg?style=flat-square +[download-url]: https://www.npmjs.com/package/@onewalker/egg-mongoose + Egg's mongoose plugin. ## Notice -The version of Egg's mongoose plugin add two new features, place the model files in the location you want and rename the delegate property to `Context`. It published for the original one seems like not to be maintained by the maintainers. When the original one merge the reuqest, you can also use the original one. +This version of Egg's mongoose plugin adds two new features: placing the model files in a custom location and renaming the delegate property to `Context`. It was published because the original one seems to be unmaintained. When the original one merges the request, you can also use the original one. ## Install @@ -33,16 +30,16 @@ $ npm i @onewalker/egg-mongoose --save ## Configuration -Change `{app_root}/config/plugin.js` to enable `egg-mongoose` plugin: +Enable the `egg-mongoose` plugin by modifying `{app_root}/config/plugin.js`: ```js exports.mongoose = { enable: true, - package: 'egg-mongoose', + package: '@onewalker/egg-mongoose', }; ``` -## Simple connection +## Simple Connection ### Config @@ -54,10 +51,11 @@ exports.mongoose = { // mongoose global plugins, expected a function or an array of function and options plugins: [createdPlugin, [updatedPlugin, pluginOptions]], }; -// recommended + +// Recommended exports.mongoose = { - //baseDir:'model', //models in `app/${model}` - //delegate:'model' //lood to `app[delegate]` + // baseDir: 'model', // models in `app/${model}`, // define the dir of model + // delegate: 'model' // load to `app[delegate]` // define the delegate client: { url: 'mongodb://127.0.0.1/example', options: {}, @@ -76,20 +74,20 @@ module.exports = app => { const Schema = mongoose.Schema; const UserSchema = new Schema({ - userName: { type: String }, - password: { type: String }, + userName: { type: String }, + password: { type: String }, }); return mongoose.model('User', UserSchema); -} +}; // {app_root}/app/controller/user.js exports.index = function* (ctx) { ctx.body = yield ctx.model.User.find({}); -} +}; ``` -## Multiple connections +## Multiple Connections ### Config @@ -102,7 +100,7 @@ exports.mongoose = { url: 'mongodb://127.0.0.1/example1', options: {}, // client scope plugin array - plugins: [] + plugins: [], }, db2: { url: 'mongodb://127.0.0.1/example2', @@ -110,18 +108,18 @@ exports.mongoose = { }, }, // public scope plugin array - plugins: [] + plugins: [], }; ``` ### Example ```js -// {app_root}/app/model/user.js +// {app_root}/app/{baseDir}/user.js module.exports = app => { const mongoose = app.mongoose; const Schema = mongoose.Schema; - const conn = app.mongooseDB.get('db1'); + const conn = app.mongooseDB.get('db1'); const UserSchema = new Schema({ userName: { type: String }, @@ -129,9 +127,9 @@ module.exports = app => { }); return conn.model('User', UserSchema); -} +}; -// {app_root}/app/model/book.js +// {app_root}/app/{baseDir}/book.js module.exports = app => { const mongoose = app.mongoose; const Schema = mongoose.Schema; @@ -142,24 +140,24 @@ module.exports = app => { }); return conn.model('Book', BookSchema); -} +}; // app/controller/user.js exports.index = function* (ctx) { ctx.body = yield ctx.model.User.find({}); // get data from db1 -} +}; // app/controller/book.js exports.index = function* (ctx) { ctx.body = yield ctx.model.Book.find({}); // get data from db2 -} +}; ``` -### Default config +### Default Config -see [config/config.default.js](config/config.default.js) for more detail. +See [config/config.default.js](config/config.default.js) for more details. -## Multi-mongos support +## Multi-Mongos Support ```js // {app_root}/config/config.default.js @@ -183,4 +181,5 @@ If you are a contributor, follow [CONTRIBUTING](https://eggjs.org/zh-cn/contribu ## License -[MIT](LICENSE) \ No newline at end of file +[MIT](LICENSE) + diff --git a/config/config.default.js b/config/config.default.js index a3b1ad3..3fe5ba6 100644 --- a/config/config.default.js +++ b/config/config.default.js @@ -14,6 +14,6 @@ exports.mongoose = { loadModel: true, app: true, agent: false, - baseDir: 'model', // models in `app/${model}`,the deafault is `app/model` - delegate: 'model', // lood to `app[delegate]`,the deafault is app.model + baseDir: 'model', // models in `app/${model}`,the default is `app/model` + delegate: 'model', // load to `app[delegate]`,the default is app.model }; From 80d2cbbfcbf160125ff1dea38d6b56272f5e1189 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Wed, 6 Nov 2024 17:44:48 +0800 Subject: [PATCH 02/27] docs: update readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f1a6c47..71f41af 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,12 @@ Egg's mongoose plugin. ## Notice +The plugin is a ahead version of egg-mongoose with some features not supported in the official one. +It's keep up to date with the latest version of official [egg-mongoose](https://github.com/eggjs/egg-mongoose). +The new features are not supported in the current official one. Pull Requests link: https://xgithub.com/eggjs/egg-mongoose/pull/60 +- place the model files in a custom location +- rename the delegate property to `Context`. -This version of Egg's mongoose plugin adds two new features: placing the model files in a custom location and renaming the delegate property to `Context`. It was published because the original one seems to be unmaintained. When the original one merges the request, you can also use the original one. ## Install From fd35faea6267e5f2a2eebaf7f4cc73334168546f Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Wed, 6 Nov 2024 22:43:54 +0800 Subject: [PATCH 03/27] format: the ci process --- .github/workflows/autoUnitTest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autoUnitTest.yml b/.github/workflows/autoUnitTest.yml index e33f89c..6fbece7 100644 --- a/.github/workflows/autoUnitTest.yml +++ b/.github/workflows/autoUnitTest.yml @@ -2,9 +2,9 @@ name: Run tests on: push: - branches: [ master ] - pull_request: - branches: [ master ] + branches: [ ** ] + # pull_request: + # branches: [ master ] jobs: build: From 92b88d00ec07dea7ae93969fd281eaaf19c39467 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Wed, 6 Nov 2024 22:47:05 +0800 Subject: [PATCH 04/27] build: grammar error --- .github/workflows/autoUnitTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/autoUnitTest.yml b/.github/workflows/autoUnitTest.yml index 6fbece7..84f28d6 100644 --- a/.github/workflows/autoUnitTest.yml +++ b/.github/workflows/autoUnitTest.yml @@ -2,7 +2,7 @@ name: Run tests on: push: - branches: [ ** ] + branches: [ '**' ] # pull_request: # branches: [ master ] From fb40a1a189dbf3b6fb97fc01cb921396528eba20 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Wed, 6 Nov 2024 23:04:05 +0800 Subject: [PATCH 05/27] docs: make the intro more clear --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 71f41af..b2f9cbf 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # egg-mongoose [![NPM version][npm-image]][npm-url] -[![Run tests](https://github.com/eggjs/egg-mongoose/actions/workflows/autoUnitTest.yml/badge.svg)](https://github.com/eggjs/egg-mongoose/actions/workflows/autoUnitTest.yml) +[![Run tests](https://github.com/eggjs/egg-mongoose/actions/workflows/autoUnitTest.yml/badge.svg)](https://github.com/oneWalker/egg-mongoose/actions/workflows/autoUnitTest.yml) [![Test coverage][codecov-image]][codecov-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][download-url] -[npm-image]: https://img.shields.io/npm/v/egg-mongoose.svg?style=flat-square +[npm-image]: https://img.shields.io/npm/v/@onewalker/egg-mongoose.svg?style=flat-square [npm-url]: https://www.npmjs.com/package/@onewalker/egg-mongoose -[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-mongoose.svg?style=flat-square -[codecov-url]: https://codecov.io/github/eggjs/egg-mongoose?branch=master +[codecov-image]: https://img.shields.io/codecov/c/github/oneWalker/egg-mongoose.svg?style=flat-square +[codecov-url]: https://app.codecov.io/github/oneWalker/egg-mongoose?branch=cur-publish-dev [snyk-image]: https://snyk.io/test/npm/egg-mongoose/badge.svg?style=flat-square [snyk-url]: https://snyk.io/test/npm/egg-mongoose [download-image]: https://img.shields.io/npm/dm/@onewalker/egg-mongoose.svg?style=flat-square From e8b4099c8f8c78ec42cee865db861f9b800f6539 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Wed, 6 Nov 2024 23:13:55 +0800 Subject: [PATCH 06/27] build: publish when merge cur-publish --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b169d46..746ba46 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ name: Release on: push: - branches: [ master ] + branches: [ cur-publish ] jobs: release: From b87438a9db21e495e61a9d4491c60fd523da7fb3 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Wed, 6 Nov 2024 23:19:33 +0800 Subject: [PATCH 07/27] feat: add new version no --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4734fd3..75083ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onewalker/egg-mongoose", - "version": "4.1.0", + "version": "4.1.3", "description": "egg mongoose plugin advanced by @oneWalker", "eggPlugin": { "name": "mongoose" From 6a779218e639d125b7831837dcc3f918bae09f6f Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Wed, 6 Nov 2024 23:21:49 +0800 Subject: [PATCH 08/27] build: make ci better --- .github/workflows/autoUnitTest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autoUnitTest.yml b/.github/workflows/autoUnitTest.yml index 84f28d6..da6b14f 100644 --- a/.github/workflows/autoUnitTest.yml +++ b/.github/workflows/autoUnitTest.yml @@ -2,9 +2,9 @@ name: Run tests on: push: - branches: [ '**' ] - # pull_request: - # branches: [ master ] + branches: [ cur-publish, master ] + pull_request: + branches: [ master, cur-publish ] jobs: build: From a818ed2b9a92bf94966710e6171789bae5b6cbfc Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Wed, 6 Nov 2024 23:30:03 +0800 Subject: [PATCH 09/27] build:test --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 746ba46..0b6c0af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,14 @@ name: Release on: push: - branches: [ cur-publish ] + branches: [ cur-publish,cur-publish-dev ] jobs: release: name: Node.js uses: eggjs/github-actions/.github/workflows/node-release.yml@master + permissions: + id-token: write secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} GIT_TOKEN: ${{ secrets.GIT_TOKEN }} From e9f81112fe2cd1b6ffbd9e47c6255d4e9d07a61b Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Wed, 6 Nov 2024 23:31:10 +0800 Subject: [PATCH 10/27] build:test --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b6c0af..e5031c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,6 +9,8 @@ jobs: uses: eggjs/github-actions/.github/workflows/node-release.yml@master permissions: id-token: write + contents: write + deployments: write secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} GIT_TOKEN: ${{ secrets.GIT_TOKEN }} From bbf8605dc116e182984501fef365dbc2fed6479e Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:00:51 +0800 Subject: [PATCH 11/27] build: test action_ref --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e5031c1..f517b8a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,3 +17,4 @@ jobs: with: checkTest: false install: 'npm install --legacy-peer-deps --no-package-lock --no-fund' + action_ref: cur-publish-dev From fdbd883dce4bb3cab9024d9f386eec3cf2f15df2 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:20:39 +0800 Subject: [PATCH 12/27] build: publish test --- .github/workflows/release.yml | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f517b8a..b186893 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,20 +1,20 @@ -name: Release +name: Publish my node package + on: push: - branches: [ cur-publish,cur-publish-dev ] - -jobs: - release: - name: Node.js - uses: eggjs/github-actions/.github/workflows/node-release.yml@master - permissions: - id-token: write - contents: write - deployments: write - secrets: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - GIT_TOKEN: ${{ secrets.GIT_TOKEN }} - with: - checkTest: false - install: 'npm install --legacy-peer-deps --no-package-lock --no-fund' - action_ref: cur-publish-dev + branches: [cur-publish, cur-publish-dev] +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + - run: npm ci + - run: npm test + - uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + - uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + registry: "https://npm.pkg.github.com" \ No newline at end of file From b12f34fca3d8c208e2789fd742663bd989c73a1b Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:25:03 +0800 Subject: [PATCH 13/27] build: publish test --- .github/workflows/release.yml | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b186893..d4977c9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,15 +6,32 @@ on: jobs: publish: runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14.x, 16.x, 18.x, 20.x] + mongodb-version: ['6.0'] + steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - - run: npm ci - - run: npm test - - uses: JS-DevTools/npm-publish@v3 + - name: Git checkout + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - name: Install dependencies + run: npm i + + - name: Run Unit Tests + run: npm run ci + + - name: Publish to npm + uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} - - uses: JS-DevTools/npm-publish@v3 + + - name: Publish to github package registry + uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.GITHUB_TOKEN }} registry: "https://npm.pkg.github.com" \ No newline at end of file From 1dae84b827c626d4a4372843c528a085ac5c4bc4 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:26:22 +0800 Subject: [PATCH 14/27] build: publish test --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d4977c9..77a7f63 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,5 +33,5 @@ jobs: - name: Publish to github package registry uses: JS-DevTools/npm-publish@v3 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GIT_TOKEN }} registry: "https://npm.pkg.github.com" \ No newline at end of file From 5f6c0f9de43b4e336028fd57015f1f157ecc18fe Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:36:08 +0800 Subject: [PATCH 15/27] build: test --- .github/workflows/release.yml | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77a7f63..59dc22c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,18 +12,32 @@ jobs: mongodb-version: ['6.0'] steps: - - name: Git checkout - uses: actions/checkout@v3 + # Checkout action repository + - name: Checkout action repository + uses: actions/checkout@v4 + with: + repository: node-modules/github-actions + path: action_repo - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + # Checkout project repository + - name: Checkout project repository + uses: actions/checkout@v4 with: - node-version: ${{ matrix.node-version }} - - name: Install dependencies - run: npm i + path: main_repo + token: ${{ secrets.GIT_TOKEN }} - - name: Run Unit Tests - run: npm run ci + # Setup Node.js environment + - name: Setup Node.js + uses: actions/setup-node@v4 + + # Install action dependencies + - name: Install action dependencies + run: npm i --no-package-lock --no-fund --omit=dev + working-directory: action_repo/scripts/release + + # Install dependencies + - name: Install dependencies + run: npm i --no-package-lock --no-fund - name: Publish to npm uses: JS-DevTools/npm-publish@v3 From 19262b3796a46a1c5b0dc6a4c5d6006707c59a17 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:37:22 +0800 Subject: [PATCH 16/27] build: test --- .github/workflows/release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59dc22c..359d02f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,10 +6,6 @@ on: jobs: publish: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [14.x, 16.x, 18.x, 20.x] - mongodb-version: ['6.0'] steps: # Checkout action repository From 37e7890589ef576b2570084df476767945897679 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:39:53 +0800 Subject: [PATCH 17/27] build: test --- .github/workflows/release.yml | 85 ++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 359d02f..d3d9c1d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,45 +3,50 @@ name: Publish my node package on: push: branches: [cur-publish, cur-publish-dev] + jobs: publish: - runs-on: ubuntu-latest - - steps: - # Checkout action repository - - name: Checkout action repository - uses: actions/checkout@v4 - with: - repository: node-modules/github-actions - path: action_repo - - # Checkout project repository - - name: Checkout project repository - uses: actions/checkout@v4 - with: - path: main_repo - token: ${{ secrets.GIT_TOKEN }} - - # Setup Node.js environment - - name: Setup Node.js - uses: actions/setup-node@v4 - - # Install action dependencies - - name: Install action dependencies - run: npm i --no-package-lock --no-fund --omit=dev - working-directory: action_repo/scripts/release - - # Install dependencies - - name: Install dependencies - run: npm i --no-package-lock --no-fund - - - name: Publish to npm - uses: JS-DevTools/npm-publish@v3 - with: - token: ${{ secrets.NPM_TOKEN }} - - - name: Publish to github package registry - uses: JS-DevTools/npm-publish@v3 - with: - token: ${{ secrets.GIT_TOKEN }} - registry: "https://npm.pkg.github.com" \ No newline at end of file + runs-on: ubuntu-latest + + steps: + # Checkout action repository + - name: Checkout action repository + uses: actions/checkout@v4 + with: + repository: node-modules/github-actions + path: action_repo + + # Checkout project repository + - name: Checkout project repository + uses: actions/checkout@v4 + with: + path: main_repo + token: ${{ secrets.GIT_TOKEN }} + + # Setup Node.js environment + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '14' # Specify the Node.js version + + # Install action dependencies + - name: Install action dependencies + run: npm i --no-package-lock --no-fund --omit=dev + working-directory: action_repo/scripts/release + + # Install project dependencies + - name: Install project dependencies + run: npm i --no-package-lock --no-fund + + # Publish to npm + - name: Publish to npm + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + + # Publish to GitHub package registry + - name: Publish to GitHub package registry + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.GIT_TOKEN }} + registry: "https://npm.pkg.github.com" \ No newline at end of file From 3a7a52a7b6b8e5ff53c41355932ad95fc82a2be5 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:46:08 +0800 Subject: [PATCH 18/27] build: test --- .github/workflows/release.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3d9c1d..08e2930 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,19 +9,9 @@ jobs: runs-on: ubuntu-latest steps: - # Checkout action repository - - name: Checkout action repository - uses: actions/checkout@v4 - with: - repository: node-modules/github-actions - path: action_repo - - # Checkout project repository - - name: Checkout project repository - uses: actions/checkout@v4 - with: - path: main_repo - token: ${{ secrets.GIT_TOKEN }} + + - name: Git checkout + uses: actions/checkout@v3 # Setup Node.js environment - name: Setup Node.js From a35cc72f7ea73dc916e71fc637c7082c4f64914e Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:48:23 +0800 Subject: [PATCH 19/27] build: test --- .github/workflows/release.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 08e2930..52a9945 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,17 +17,13 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '14' # Specify the Node.js version + node-version: '20' # Specify the Node.js version # Install action dependencies - name: Install action dependencies run: npm i --no-package-lock --no-fund --omit=dev working-directory: action_repo/scripts/release - # Install project dependencies - - name: Install project dependencies - run: npm i --no-package-lock --no-fund - # Publish to npm - name: Publish to npm uses: JS-DevTools/npm-publish@v3 From 2c393b96239905fb3a9a819364fbb74844180a0b Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:54:10 +0800 Subject: [PATCH 20/27] build: test --- .github/workflows/release.yml | 46 +++++++++++++++-------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52a9945..ad3b40d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,38 +1,32 @@ -name: Publish my node package +name: Publish Package on: push: - branches: [cur-publish, cur-publish-dev] + branches: [ cur-publish, cur-publish-dev ] -jobs: +jobs: publish: runs-on: ubuntu-latest steps: - - - name: Git checkout - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v4 - # Setup Node.js environment - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' # Specify the Node.js version + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' - # Install action dependencies - - name: Install action dependencies - run: npm i --no-package-lock --no-fund --omit=dev - working-directory: action_repo/scripts/release + - name: Install dependencies + run: npm install - # Publish to npm - - name: Publish to npm - uses: JS-DevTools/npm-publish@v3 - with: - token: ${{ secrets.NPM_TOKEN }} + - name: Publish to npmjs + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - # Publish to GitHub package registry - - name: Publish to GitHub package registry - uses: JS-DevTools/npm-publish@v3 - with: - token: ${{ secrets.GIT_TOKEN }} - registry: "https://npm.pkg.github.com" \ No newline at end of file + - name: Publish to GitHub Packages + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GIT_TOKEN }} + registry-url: 'https://npm.pkg.github.com/' \ No newline at end of file From 95a34f65fa1639fe6f032ed8ab9fe80d0e6102c9 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 00:59:05 +0800 Subject: [PATCH 21/27] build test --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad3b40d..36e01d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,9 +21,7 @@ jobs: run: npm install - name: Publish to npmjs - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm login --registry=https://registry.npmjs.org/ -//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} && npm publish - name: Publish to GitHub Packages run: npm publish From 478fa5d8e358199810e2e34cb0f70ca1cb21ce72 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 01:01:01 +0800 Subject: [PATCH 22/27] build:test --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 36e01d4..d0ade28 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: run: npm install - name: Publish to npmjs - run: npm login --registry=https://registry.npmjs.org/ -//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} && npm publish + run: npm publish --//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} - name: Publish to GitHub Packages run: npm publish From 17d88a775667f4a50a624d264fcbf263fb616ef0 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 01:03:31 +0800 Subject: [PATCH 23/27] build:test --- .github/workflows/release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0ade28..5092f10 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,11 +20,11 @@ jobs: - name: Install dependencies run: npm install - - name: Publish to npmjs - run: npm publish --//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + # - name: Publish to npmjs + # run: npm publish --//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + + - name: Configure npm for GitHub Packages + run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }}" > ~/.npmrc - name: Publish to GitHub Packages - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.GIT_TOKEN }} - registry-url: 'https://npm.pkg.github.com/' \ No newline at end of file + run: npm publish \ No newline at end of file From b530864cb9f81b3abf72d775dc026e556137f026 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 01:07:18 +0800 Subject: [PATCH 24/27] build:test --- .github/workflows/release.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5092f10..444180f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,9 +22,6 @@ jobs: # - name: Publish to npmjs # run: npm publish --//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} - - - name: Configure npm for GitHub Packages - run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }}" > ~/.npmrc - + - name: Publish to GitHub Packages - run: npm publish \ No newline at end of file + run: npm publish --//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }} \ No newline at end of file From 2ab6b516c1279878abbef5ba2a8df6c65b8eea2e Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 01:10:35 +0800 Subject: [PATCH 25/27] build: test --- .github/workflows/release.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 444180f..480f953 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,6 +22,14 @@ jobs: # - name: Publish to npmjs # run: npm publish --//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} - + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: https://npm.pkg.github.com + - name: Publish to GitHub Packages - run: npm publish --//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }} \ No newline at end of file + run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GIT_TOKEN}} \ No newline at end of file From 23812822d94dee3f14613613490b12d08d7ccaf4 Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 01:13:45 +0800 Subject: [PATCH 26/27] build: complete the publish package automatically --- .github/workflows/release.yml | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 480f953..b949d2d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Publish Package on: push: - branches: [ cur-publish, cur-publish-dev ] + branches: [ cur-publish] jobs: publish: @@ -20,8 +20,8 @@ jobs: - name: Install dependencies run: npm install - # - name: Publish to npmjs - # run: npm publish --//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + - name: Publish to npmjs + run: npm publish --//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} - name: Set up Node.js uses: actions/setup-node@v4 diff --git a/package.json b/package.json index 75083ef..e94b04d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onewalker/egg-mongoose", - "version": "4.1.3", + "version": "4.1.4", "description": "egg mongoose plugin advanced by @oneWalker", "eggPlugin": { "name": "mongoose" From 53246729643d34c96beebc81d9dbe0876feb69ee Mon Sep 17 00:00:00 2001 From: "Brian,Kun Liu" Date: Thu, 7 Nov 2024 01:21:10 +0800 Subject: [PATCH 27/27] docs: change document --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b2f9cbf..c380b0e 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,11 @@ Egg's mongoose plugin. ## Notice The plugin is a ahead version of egg-mongoose with some features not supported in the official one. + It's keep up to date with the latest version of official [egg-mongoose](https://github.com/eggjs/egg-mongoose). -The new features are not supported in the current official one. Pull Requests link: https://xgithub.com/eggjs/egg-mongoose/pull/60 + +The new features are not supported in the current official one but can be used with this one. Pull Requests to official one link: https://xgithub.com/eggjs/egg-mongoose/pull/60 + - place the model files in a custom location - rename the delegate property to `Context`.