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 Aug 25, 2024
2 parents 977db68 + 69f1f24 commit 6513ca9
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .githooks/set-scripts-executable-now.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set +e
dirs=".scripts .github src bin"

for dir in $dirs; do
[[ -f "$dir" ]] && find $dir -type f \( -iname "*.sh" -o -iname "*.mjs" -o -iname "*.mts" \) -print0 | xargs -0II chmod a+x I
[[ -d "$dir" ]] && find $dir -type f \( -iname "*.sh" -o -iname "*.mjs" -o -iname "*.mts" \) -print0 | xargs -0II chmod a+x I
done

set -e
Expand Down
2 changes: 1 addition & 1 deletion .githooks/set-scripts-executable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set +e
dirs=".scripts .github"

for dir in $dirs; do
[[ -f "$dir" ]] && find $dir -type f \( -iname "*.sh" -o -iname "*.mjs" -o -iname "*.mts" \) -print0 | xargs -0II git update-index --ignore-missing --chmod=+x I
[[ -d "$dir" ]] && find $dir -type f \( -iname "*.sh" -o -iname "*.mjs" -o -iname "*.mts" \) -print0 | xargs -0II git update-index --ignore-missing --chmod=+x I
done

find .githooks -type f -print0 | xargs -0II git update-index --ignore-missing --chmod=+x I
Expand Down
1 change: 0 additions & 1 deletion .vscode/launch.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"name": "Midway Dev",
"type": "node",
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"env": {
"MIDWAY_SERVER_ENV": "local",
"NODE_ENV": "local",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@types/koa": "2",
"@types/mocha": "10",
"@types/node": "22",
"@waiting/eslint-config": "^11.2.0",
"@waiting/eslint-config": "^12.0.0",
"@waiting/shared-core": "^23.20.2",
"@waiting/shared-types": "^23.20.2",
"autocannon": "7",
Expand Down
13 changes: 7 additions & 6 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,29 @@
"tsconfig.json",
"tsconfig.base.json",
"asset",
"src/**/*.ts",
"bin",
"database",
"dist",
"!**/*.spec.*",
"!**/*.tsbuildinfo"
"src",
"!**/*.spec.*"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "npm run tsc && tsc-alias && npm run rp",
"build": "npm run tsc",
"build:unit": "tsc -p test/tsconfig.json",
"build:prod": "npm run tsc -- --declaration --declarationMap && tsc-alias && npm run rp",
"build:unit": "tsc -p test/tsconfig.json",
"clean": "npm run clean:lock && npm run clean:dist && npm run clean:log",
"clean:cache": "rm -rf .eslintcache .tsbuildinfo",
"clean:dist": "npm run clean:cache && rm -rf dist/*",
"clean:lock": "rm -f package-lock.json",
"clean:log": "rm -rf ./logs ./run",
"cov": "c8 --all npm run test --",
"lint": "eslint --fix --cache src test ",
"cov": "c8 --all npm run test",
"lint": "eslint --fix --cache src test",
"lint:nofix": "eslint --cache src test",
"postbuild": "tsc-alias && npm run rp",
"pretest": "npm run build:unit",
"rp": "tsx bin-hashbang.js",
"test": "cross-env NODE_ENV=test TS_NODE_PROJECT=test/tsconfig.json mocha",
Expand Down
14 changes: 0 additions & 14 deletions packages/midway-component-fetch/.eslintrc.yml

This file was deleted.

23 changes: 12 additions & 11 deletions packages/mw-demo/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# [@mw-components/demo](https://www.npmjs.com/package/@mw-components/demo)
demo for midway framework.
# [@mwcp/demo](https://www.npmjs.com/package/@mwcp/demo)

Demo Component for [Midway.js]


## Installation
```sh
npm i @mw-components/demo
npm i @mwcp/demo
```


Expand All @@ -15,10 +16,9 @@ npm i @mw-components/demo
Edit `${app_root}/src/configuration.ts`:

```ts
import { join } from 'path'
import { ILifeCycle } from '@midwayjs/core'
import { Configuration } from '@midwayjs/decorator'
import * as demo from '@mw-components/demo'
import { join } from 'node:path'
import { ILifeCycle, Configuration } from '@midwayjs/core'
import * as demo from '@mwcp/demo'

import * as DefaultConfig from './config/config.default.js'
import * as LocalConfig from './config/config.local.js'
Expand All @@ -32,9 +32,7 @@ import * as UnittestConfig from './config/config.unittest.js'
unittest: UnittestConfig,
},
],
imports: [
demo,
],
imports: [ demo ],
})
export class ContainerConfiguration implements ILifeCycle { }

Expand All @@ -43,9 +41,12 @@ export class ContainerConfiguration implements ILifeCycle { }
### Add Configurations

### Swagger API
- start `npm run build && npm run dev`
- start `npm run dev`
- open `http://localhost:7001/swagger-ui/index.html` in browser

## License
[MIT](LICENSE)


[Midway.js]: https://midwayjs.org/

10 changes: 5 additions & 5 deletions packages/mw-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"license": "MIT",
"dependencies": {
"@mwcp/otel": "37"
"@mwcp/otel": "^37.2.0"
},
"devDependencies": {
},
Expand All @@ -51,15 +51,13 @@
"database",
"dist",
"src",
"!**/*.spec.*",
"!**/*.tsbuildinfo"
"!**/*.spec.*"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "npm run tsc && tsc-alias",
"build:prod": "npm run tsc -- --declaration --declarationMap && tsc-alias",
"build": "npm run tsc",
"build:unit": "tsc -p test/tsconfig.json",
"clean": "npm run clean:lock && npm run clean:dist && npm run clean:log",
"clean:cache": "rm -rf .eslintcache .tsbuildinfo",
Expand All @@ -71,11 +69,13 @@
"dev": "cross-env MIDWAY_SERVER_ENV=local mwtsc --watch --run @midwayjs/mock/app",
"lint": "eslint --fix --cache src test",
"lint:nofix": "eslint --cache src test",
"postbuild": "tsc-alias",
"predev": "npm run build",
"pretest": "npm run build:unit",
"start": "cross-env NODE_ENV=production node ./bootstrap.js",
"start:gc": "cross-env NODE_ENV=local node --trace_gc ./bootstrap.js",
"test": "cross-env MIDWAY_SERVER_ENV=unittest TS_NODE_PROJECT=test/tsconfig.json mocha --parallel=false",
"test:deb": "npm run test",
"tsc": "tsc -b"
}
}
10 changes: 10 additions & 0 deletions packages/mw-demo/src/config/config.default.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { RouterOption } from '@midwayjs/core'

import {
initialConfig,
Expand All @@ -24,3 +25,12 @@ export const demoMiddlewareConfig: Readonly<Omit<MiddlewareConfig, 'match'>> = {
},
}

export const swagger = {
routerFilter: (url: string, options: RouterOption) => {
void options
if (url.startsWith('/_')) {
return true
}
},
}

3 changes: 1 addition & 2 deletions packages/mw-demo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export * from './interface.js'
export * from './lib/index.js'
export * from './middleware/index.middleware.js'

// @ts-expect-error for midway
declare module '@midwayjs/core/dist/interface' {
declare module '@midwayjs/core/dist/interface.js' {
interface MidwayConfig {
[ConfigKey.config]: Partial<Config>
[ConfigKey.middlewareConfig]: Partial<MiddlewareConfig>
Expand Down
2 changes: 2 additions & 0 deletions packages/mw-demo/test/root.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IncomingHttpHeaders } from 'node:http'
import { join } from 'node:path'

import type { ValidateService } from '@midwayjs/validate'
import type { Application, IMidwayContainer, JsonResp } from '@mwcp/share'
import { genCurrentDirname } from '@waiting/shared-core'
import type { Response, SuperTest, Test } from 'supertest'
Expand Down Expand Up @@ -35,6 +36,7 @@ export interface TestConfig {
container: IMidwayContainer
host: string
httpRequest: SuperTest<Test>
validateService: ValidateService
}

const testAppDir = join(testDir, 'fixtures', 'base-app')
Expand Down
2 changes: 2 additions & 0 deletions packages/mw-demo/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import assert from 'node:assert'

import { createApp, close, createHttpRequest } from '@midwayjs/mock'
import { ValidateService } from '@midwayjs/validate'
import type { Application } from '@mwcp/share'
import type { Suite } from 'mocha'

Expand Down Expand Up @@ -57,6 +58,7 @@ async function updateConfig(mockApp: Application, config: TestConfig): Promise<v
config.host = url

config.container = mockApp.getApplicationContext()
config.validateService = await config.container.getAsync(ValidateService)
// const svc = await testConfig.container.getAsync(TaskQueueService)
}

Expand Down

0 comments on commit 6513ca9

Please sign in to comment.