From 3890c158c006465dd496e4a9ae2dcac9e7481f1e Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Tue, 11 Jun 2024 15:31:18 +0800 Subject: [PATCH] f --- .github/workflows/codeql-analysis.yml | 70 --------------------------- package.json | 53 ++++++++++++++------ src/egg.ts | 3 +- test/utils.ts | 7 +-- 4 files changed, 40 insertions(+), 93 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 0e621ec6..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,70 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/package.json b/package.json index d3a56d19..d2e029aa 100644 --- a/package.json +++ b/package.json @@ -5,20 +5,13 @@ "node": ">= 18.7.0" }, "description": "A core plugin framework based on koa", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "files": [ - "lib" - ], "scripts": { "lint": "eslint .", "test": "npm run lint -- --fix && npm run test-local -- -p", "test-local": "egg-bin test", - "ci": "egg-bin cov -p", + "ci": "npm run lint && egg-bin cov -p && npm run prepublishOnly", "contributor": "git-contributor", - "clean": "tsc -b --clean", - "tsc": "tsc", - "prepublishOnly": "npm run tsc" + "prepublishOnly": "tshy && tshy-after" }, "repository": { "type": "git", @@ -35,8 +28,8 @@ }, "homepage": "https://github.com/eggjs/egg-core#readme", "dependencies": { - "@eggjs/koa": "^2.17.0", - "@eggjs/router": "^2.0.1", + "@eggjs/koa": "^2.18.1", + "@eggjs/router": "^3.0.0", "@types/depd": "^1.1.32", "co": "^4.6.0", "depd": "^2.0.0", @@ -45,7 +38,7 @@ "extend2": "^1.0.1", "get-ready": "^3.1.0", "globby": "^11.0.2", - "is-type-of": "^1.2.1", + "is-type-of": "^2.1.0", "koa-convert": "^1.2.0", "node-homedir": "^2.0.0", "ready-callback": "^4.0.0", @@ -70,10 +63,40 @@ "spy": "^1.0.0", "supertest": "^4.0.2", "ts-node": "10", - "typescript": "5", - "urllib": "3" + "urllib": "3", + "tshy": "^1.15.1", + "tshy-after": "^1.0.0", + "typescript": "^5.4.5" }, "publishConfig": { "access": "public" - } + }, + "files": [ + "dist", + "src" + ], + "type": "module", + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + } + }, + "exports": { + "./package.json": "./package.json", + ".": { + "import": { + "source": "./src/index.ts", + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "source": "./src/index.ts", + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts" } diff --git a/src/egg.ts b/src/egg.ts index 27459eea..38eda988 100644 --- a/src/egg.ts +++ b/src/egg.ts @@ -2,8 +2,7 @@ import assert from 'node:assert'; import fs from 'node:fs'; import { debuglog } from 'node:util'; import is from 'is-type-of'; -import KoaApplication from '@eggjs/koa'; -import type { MiddlewareFunc } from '@eggjs/koa'; +import KoaApplication, { type MiddlewareFunc } from '@eggjs/koa'; import { EggConsoleLogger } from 'egg-logger'; import { EggRouter as Router } from '@eggjs/router'; import type { ReadyFunctionArg } from 'get-ready'; diff --git a/test/utils.ts b/test/utils.ts index 6e77ac57..a46c38e8 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -1,5 +1,4 @@ import path from 'node:path'; -import { setTimeout } from 'node:timers/promises'; import { Application as EggApplication } from './fixtures/egg'; export function getFilepath(name: string) { @@ -18,11 +17,7 @@ export function createApp(name, options) { } return new CustomApplication(options); -}; - -export async function sleep(ms: number) { - return await setTimeout(ms); -}; +} export const symbol = { view: Symbol('view'),