Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade deps #31

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .autod.conf.js

This file was deleted.

32 changes: 8 additions & 24 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,32 +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: [ master ]

pull_request:
branches: [ master ]

jobs:
build:

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
node-version: [8, 10, 12]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm i -g npminstall && npminstall
- run: npm run ci
env:
CI: true
Job:
name: Node.js
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest, macos-latest'
version: '14, 16, 18, 20, 22'
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

10 changes: 3 additions & 7 deletions agent.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
'use strict';

const path = require('path');
const path = require('node:path');
const fs = require('node:fs/promises');
const debounce = require('debounce');
const multimatch = require('multimatch');
const rimraf = require('mz-modules/rimraf');
const fs = require('mz/fs');


module.exports = agent => {
// clean all timing json
Expand All @@ -14,7 +10,7 @@ module.exports = agent => {
const files = await fs.readdir(rundir);
for (const file of files) {
if (!/^(agent|application)_timing/.test(file)) continue;
await rimraf(path.join(agent.config.rundir, file));
await fs.rm(path.join(agent.config.rundir, file), { force: true, recursive: true });
}
});

Expand Down
2 changes: 0 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

module.exports = app => {
// if true, then don't need to wait at local development mode
if (app.config.development.fastReady) process.nextTick(() => app.ready(true));
Expand Down
10 changes: 4 additions & 6 deletions app/middleware/egg_loader_trace.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

const path = require('path');
const fs = require('mz/fs');
const utility = require('utility');
const path = require('node:path');
const fs = require('node:fs/promises');
const { readJSON } = require('utility');

module.exports = (_, app) => {
return async (ctx, next) => {
Expand All @@ -19,7 +17,7 @@ async function loadTimingData(app) {
const data = [];
for (const file of files) {
if (!/^(agent|application)_timing/.test(file)) continue;
const json = await utility.readJSON(path.join(rundir, file));
const json = await readJSON(path.join(rundir, file));
const isAgent = /^agent/.test(file);
for (const item of json) {
if (isAgent) {
Expand Down
2 changes: 0 additions & 2 deletions config/config.default.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

/**
* @member Config#development
* @property {Array} watchDirs - dirs needed watch, when files under these change, application will reload, use relative path
Expand Down
35 changes: 12 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,26 @@
],
"dependencies": {
"debounce": "^1.1.0",
"multimatch": "^2.1.0",
"mz": "^2.7.0",
"mz-modules": "^2.1.0",
"utility": "^1.13.1"
"multimatch": "^5.0.0",
"utility": "^2.1.0"
},
"devDependencies": {
"autod": "^3.0.1",
"egg": "^2.3.0",
"egg-bin": "^4.3.7",
"egg-ci": "^1.8.0",
"egg-mock": "^3.14.0",
"eslint": "^4.17.0",
"eslint-config-egg": "^7.0.0",
"mz": "^2.7.0",
"mz-modules": "^2.0.0",
"egg": "3",
"egg-bin": "6",
"egg-mock": "5",
"eslint": "8",
"eslint-config-egg": "12",
"supertest": "^3.4.2"
},
"engines": {
"node": ">=8.0.0"
"node": ">=14.0.0"
},
"scripts": {
"test": "npm run lint -- --fix && egg-bin pkgfiles && npm run test-local",
"test-local": "egg-bin test",
"cov": "egg-bin cov",
"test": "npm run lint -- --fix && npm run test-local",
"test-local": "egg-bin test --ts false",
"cov": "egg-bin cov --ts false",
"lint": "eslint .",
"ci": "npm run lint && egg-bin pkgfiles --check && npm run cov",
"autod": "autod"
},
"ci": {
"version": "8, 10, 12",
"type": "travis, github"
"ci": "npm run lint && npm run cov"
},
"repository": {
"type": "git",
Expand Down
14 changes: 6 additions & 8 deletions test/absolute.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
'use strict';

const fs = require('node:fs/promises');
const path = require('node:path');
const mm = require('egg-mock');
const fs = require('mz/fs');
const path = require('path');
const { rimraf, mkdirp, sleep } = require('mz-modules');
const { sleep } = require('./utils');

describe('test/absolute.test.js', () => {
let app;
before(async () => {
await rimraf(path.join(__dirname, 'fixtures/absolute/lib'));
await fs.rm(path.join(__dirname, 'fixtures/absolute/lib'), { force: true, recursive: true });

// FIXME: ONLY WATCH EXIST DIR
const filepath = path.join(__dirname, 'fixtures/absolute/lib/a/b.js');
await mkdirp(path.dirname(filepath));
await fs.mkdir(path.dirname(filepath), { recursive: true });
await fs.writeFile(filepath, '');

mm.env('local');
Expand All @@ -29,7 +27,7 @@ describe('test/absolute.test.js', () => {

it('should reload at absolute path', async () => {
const filepath = path.join(__dirname, 'fixtures/absolute/lib/a/b.js');
await mkdirp(path.dirname(filepath));
await fs.mkdir(path.dirname(filepath), { recursive: true });
console.log(`write file to ${filepath}`);
await fs.writeFile(filepath, 'console.log(1);');
await sleep(5000);
Expand Down
9 changes: 3 additions & 6 deletions test/custom.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict';

const fs = require('fs/promises');
const path = require('node:path');
const mm = require('egg-mock');
const fs = require('mz/fs');
const path = require('path');
const sleep = require('mz-modules/sleep');
const { escape } = require('./utils');
const { escape, sleep } = require('./utils');

describe('test/custom.test.js', () => {
let app;
Expand Down
11 changes: 4 additions & 7 deletions test/development.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
'use strict';

const fs = require('node:fs/promises');
const path = require('node:path');
const assert = require('node:assert');
const mm = require('egg-mock');
const fs = require('mz/fs');
const path = require('path');
const sleep = require('mz-modules/sleep');
const assert = require('assert');
const { escape } = require('./utils');
const { escape, sleep } = require('./utils');

describe('test/development.test.js', () => {
let app;
Expand Down
4 changes: 1 addition & 3 deletions test/fast_ready_false.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

const mm = require('egg-mock');
const sleep = require('mz-modules/sleep');
const { sleep } = require('./utils');

describe('fastReady = false', () => {
let app;
Expand Down
9 changes: 3 additions & 6 deletions test/not-reload.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict';

const fs = require('node:fs/promises');
const path = require('node:path');
const mm = require('egg-mock');
const fs = require('mz/fs');
const path = require('path');
const sleep = require('mz-modules/sleep');
const { escape } = require('./utils');
const { escape, sleep } = require('./utils');

describe('test/not-reload.test.js', () => {
let app;
Expand Down
9 changes: 3 additions & 6 deletions test/override.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict';

const fs = require('node:fs/promises');
const path = require('node:path');
const mm = require('egg-mock');
const fs = require('mz/fs');
const path = require('path');
const sleep = require('mz-modules/sleep');
const { escape } = require('./utils');
const { escape, sleep } = require('./utils');

describe('test/override.test.js', () => {
let app;
Expand Down
10 changes: 4 additions & 6 deletions test/process_mode_single.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict';

const fs = require('mz/fs');
const path = require('path');
const sleep = require('mz-modules/sleep');
const fs = require('node:fs/promises');
const path = require('node:path');
const assert = require('node:assert');
const request = require('supertest');
const mm = require('egg-mock');
const assert = require('assert');
const { sleep } = require('./utils');

describe('test/process_mode_single.test.js', () => {
let app;
Expand Down
23 changes: 10 additions & 13 deletions test/timing.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
'use strict';

const assert = require('node:assert');
const fs = require('node:fs/promises');
const path = require('node:path');
const mm = require('egg-mock');
const fs = require('mz/fs');
const path = require('path');
const mkdirp = require('mz-modules/mkdirp');
const sleep = require('mz-modules/sleep');
const assert = require('assert');

const { sleep } = require('./utils');

describe('test/timing.test.js', () => {
const timingJSON = path.join(__dirname, 'fixtures/timing/run/agent_timing_11111.json');
const configJSON = path.join(__dirname, 'fixtures/timing/run/application_config.json');
let app;
before(async () => {
await mkdirp(path.dirname(timingJSON));
await fs.mkdir(path.dirname(timingJSON), { recursive: true });
await fs.writeFile(timingJSON, '[]');
await fs.writeFile(configJSON, '{}');
mm.env('local');
Expand Down Expand Up @@ -41,7 +37,7 @@ describe('test/timing.test.js', () => {

let json = res.text.match(/data = (.*?);/);
json = JSON.parse(json[1]);
assert(json.length === 111);
assert.equal(json.length, 114);

const first = json[0];
assert(first.type === 'agent');
Expand All @@ -50,9 +46,10 @@ describe('test/timing.test.js', () => {
assert(first.title === 'agent(0)');

const last = json[json.length - 1];
assert(/^app_\d+$/.test(last.type));
assert(typeof last.pid === 'string');
// console.log(last);
assert.match(last.type, /^app_\d+$/);
assert.equal(typeof last.pid, 'string');
assert.deepEqual(last.range, [ last.start, last.end ]);
assert(/^app_\d+\(65\)$/.test(last.title));
assert.match(last.title, /^app_\d+\(67\)$/);
});
});
10 changes: 7 additions & 3 deletions test/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
'use strict';

exports.escape = function(str) {
exports.escape = str => {
return str
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
.replace(/-/g, '\\x2d');
};

exports.sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
Loading