From 6a77a327b77a666b703c10595f720e1ac7ea40ba Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sat, 25 Nov 2023 22:33:34 +0800 Subject: [PATCH] feat: add vscode debug config (#52) --- .github/workflows/nodejs.yml | 50 ++++---------------- .github/workflows/release.yml | 13 +++++ README.md | 21 ++++---- boilerplate/.vscode/launch.json | 36 ++++++++++++++ boilerplate/README.md | 14 +++--- boilerplate/_package.json | 24 ++++------ boilerplate/app/controller/home.js | 2 - boilerplate/app/router.js | 2 - boilerplate/config/config.default.js | 2 - boilerplate/config/plugin.js | 2 - boilerplate/test/app/controller/home.test.js | 2 - package.json | 10 +--- 12 files changed, 84 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 boilerplate/.vscode/launch.json diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 9a4cb4d..58f05ed 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,46 +1,16 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Node.js CI +name: CI on: push: - branches: - - main - - master + branches: [ master ] + pull_request: - branches: - - main - - master - schedule: - - cron: '0 2 * * *' + branches: [ master ] jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [16] - os: [ubuntu-latest, windows-latest, macos-latest] - - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i - - - name: Continuous Integration - run: npm run ci - - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} + Job: + name: Node.js + uses: node-modules/github-actions/.github/workflows/node-test.yml@master + with: + os: 'ubuntu-latest' + version: '16, 18, 20' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a2bf04a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,13 @@ +name: Release + +on: + push: + branches: [ master ] + +jobs: + release: + name: Node.js + uses: eggjs/github-actions/.github/workflows/node-release.yml@master + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GIT_TOKEN: ${{ secrets.GIT_TOKEN }} diff --git a/README.md b/README.md index 4ceaf03..1b2c2de 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,17 @@ # egg-boilerplate-simple -Boilerplate for egg quickstart. +Boilerplate for egg quickstart. [![NPM version][npm-image]][npm-url] -[![build status][travis-image]][travis-url] +[![Node.js CI](https://github.com/eggjs/egg-boilerplate-simple/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-boilerplate-simple/actions/workflows/nodejs.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/v/egg-boilerplate-simple.svg?style=flat-square [npm-url]: https://npmjs.org/package/egg-boilerplate-simple -[travis-image]: https://img.shields.io/travis/eggjs/egg-boilerplate-simple.svg?style=flat-square -[travis-url]: https://travis-ci.org/eggjs/egg-boilerplate-simple [codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-boilerplate-simple.svg?style=flat-square [codecov-url]: https://codecov.io/gh/eggjs/egg-boilerplate-simple -[david-image]: https://img.shields.io/david/eggjs/egg-boilerplate-simple.svg?style=flat-square -[david-url]: https://david-dm.org/eggjs/egg-boilerplate-simple [snyk-image]: https://snyk.io/test/npm/egg-boilerplate-simple/badge.svg?style=flat-square [snyk-url]: https://snyk.io/test/npm/egg-boilerplate-simple [download-image]: https://img.shields.io/npm/dm/egg-boilerplate-simple.svg?style=flat-square @@ -27,12 +22,12 @@ Boilerplate for egg quickstart. **Don't `npm i` this directly** ```bash -$ npm i -g egg-init -$ egg-init --type simple showcase -$ cd showcase -$ npm i -$ npm run dev -$ open http://localhost:7001 +npm i -g egg-init +egg-init --type simple showcase +cd showcase +npm i +npm run dev +open http://localhost:7001 ``` See [egg-init](https://github.com/eggjs/egg-init) for more detail. diff --git a/boilerplate/.vscode/launch.json b/boilerplate/.vscode/launch.json new file mode 100644 index 0000000..14b18bb --- /dev/null +++ b/boilerplate/.vscode/launch.json @@ -0,0 +1,36 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Egg Debug", + "runtimeExecutable": "npm", + "runtimeArgs": [ + "run", + "dev", + "--", + "--inspect-brk" + ], + "console": "integratedTerminal", + "restart": true, + "autoAttachChildProcesses": true + }, + { + "type": "node", + "request": "launch", + "name": "Egg Test", + "runtimeExecutable": "npm", + "runtimeArgs": [ + "run", + "test:local", + "--", + "--inspect-brk" + ], + "autoAttachChildProcesses": true + } + ] +} diff --git a/boilerplate/README.md b/boilerplate/README.md index bbccd63..b3d5767 100644 --- a/boilerplate/README.md +++ b/boilerplate/README.md @@ -11,23 +11,21 @@ see [egg docs][egg] for more detail. ### Development ```bash -$ npm i -$ npm run dev -$ open http://localhost:7001/ +npm i +npm run dev +open http://localhost:7001/ ``` ### Deploy ```bash -$ npm start -$ npm stop +npm start +npm stop ``` ### npm scripts - Use `npm run lint` to check code style. - Use `npm test` to run unit test. -- Use `npm run autod` to auto detect dependencies upgrade, see [autod](https://www.npmjs.com/package/autod) for more detail. - -[egg]: https://eggjs.org \ No newline at end of file +[egg]: https://eggjs.org diff --git a/boilerplate/_package.json b/boilerplate/_package.json index 92d8685..3a7fb9f 100644 --- a/boilerplate/_package.json +++ b/boilerplate/_package.json @@ -7,34 +7,28 @@ "declarations": true }, "dependencies": { - "egg": "^3", - "egg-scripts": "^2" + "egg": "^3.17.5", + "egg-scripts": "2" }, "devDependencies": { - "egg-bin": "^5", - "egg-ci": "^2", - "egg-mock": "^5", - "eslint": "^8", - "eslint-config-egg": "^12" + "egg-bin": "6", + "egg-mock": "5", + "eslint": "8", + "eslint-config-egg": "13" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { "start": "egg-scripts start --daemon --title=egg-server-{{name}}", "stop": "egg-scripts stop --title=egg-server-{{name}}", "dev": "egg-bin dev", - "debug": "egg-bin debug", - "test": "npm run lint -- --fix && npm run test-local", - "test-local": "egg-bin test", + "test": "npm run lint -- --fix && npm run test:local", + "test:local": "egg-bin test", "cov": "egg-bin cov", "lint": "eslint .", "ci": "npm run lint && npm run cov" }, - "ci": { - "version": "16, 18", - "type": "github" - }, "repository": { "type": "git", "url": "" diff --git a/boilerplate/app/controller/home.js b/boilerplate/app/controller/home.js index 5752908..3fb22d3 100644 --- a/boilerplate/app/controller/home.js +++ b/boilerplate/app/controller/home.js @@ -1,5 +1,3 @@ -'use strict'; - const { Controller } = require('egg'); class HomeController extends Controller { diff --git a/boilerplate/app/router.js b/boilerplate/app/router.js index 7beabc2..59af36d 100644 --- a/boilerplate/app/router.js +++ b/boilerplate/app/router.js @@ -1,5 +1,3 @@ -'use strict'; - /** * @param {Egg.Application} app - egg application */ diff --git a/boilerplate/config/config.default.js b/boilerplate/config/config.default.js index 076b631..e56a12b 100644 --- a/boilerplate/config/config.default.js +++ b/boilerplate/config/config.default.js @@ -1,7 +1,5 @@ /* eslint valid-jsdoc: "off" */ -'use strict'; - /** * @param {Egg.EggAppInfo} appInfo app info */ diff --git a/boilerplate/config/plugin.js b/boilerplate/config/plugin.js index 5711c6f..a85464e 100644 --- a/boilerplate/config/plugin.js +++ b/boilerplate/config/plugin.js @@ -1,5 +1,3 @@ -'use strict'; - /** @type Egg.EggPlugin */ module.exports = { // had enabled by egg diff --git a/boilerplate/test/app/controller/home.test.js b/boilerplate/test/app/controller/home.test.js index a4f0fc9..9e732c2 100644 --- a/boilerplate/test/app/controller/home.test.js +++ b/boilerplate/test/app/controller/home.test.js @@ -1,5 +1,3 @@ -'use strict'; - const { app, assert } = require('egg-mock/bootstrap'); describe('test/app/controller/home.test.js', () => { diff --git a/package.json b/package.json index b03e306..e2305e2 100644 --- a/package.json +++ b/package.json @@ -20,14 +20,8 @@ }, "author": "TZ ", "devDependencies": { - "egg-ci": "^2.1.0", "egg-init": "^2.3.1", - "eslint": "^8.24.0", - "eslint-config-egg": "^12.1.0", - "npminstall": "^6.5.1" - }, - "ci": { - "version": "16", - "type": "github" + "eslint": "8", + "eslint-config-egg": "13" } }