Skip to content
Open
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
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 🎨 editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./node_modules/mwts/",
"ignorePatterns": ["node_modules", "dist", "test", "jest.config.js", "interface.ts", "app.js", "agent.js"],
"env": {
"jest": true
}
}
30 changes: 30 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Node.js CI

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: sh ./scripts/startup.sh
- run: npm install && npm install codecov
- run: npm run bootstrap
- run: npm run build --if-present
- run: npm run ci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require('mwts/.prettierrc.json')
}
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

20 changes: 12 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
"release": "rm -f ./packages/.DS*; sh scripts/publish.sh",
"next": "sh scripts/publish.sh --npm-tag next",
"test": "lerna run test",
"cov": "sh scripts/cov.sh",
"cov": "lerna run cov --concurrency=1 --stream",
"ci": "npm run cov",
"build": "lerna run build && cp ./README.md ./packages/nacos/README.md"
"build": "lerna run build && cp ./README.md ./packages/nacos/README.md",
"lint": "lerna exec mwts check",
"lint:fix": "lerna exec mwts fix"
},
"license": "Apache",
"bugs": {
Expand All @@ -21,13 +23,15 @@
"engines": {
"node": ">= 8.0.0"
},
"ci": {
"type": "travis",
"version": "8, 10"
},
"devDependencies": {
"contributors": "^0.5.1",
"@types/jest": "^26.0.10",
"@types/node": "^15.0.1",
"jest": "^26.6.0",
"lerna": "^3.4.3",
"lerna-relinker": "^1.5.0"
"lerna-relinker": "^1.5.0",
"mwts": "^1.0.5",
"ts-jest": "^26.5.5",
"ts-node": "^9.1.1",
"typescript": "^4.1.0"
}
}
7 changes: 7 additions & 0 deletions packages/nacos-config/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['<rootDir>/test/fixtures'],
coveragePathIgnorePatterns: ['<rootDir>/test/'],
setupFilesAfterEnv: ['./jest.setup.js'],
};
1 change: 1 addition & 0 deletions packages/nacos-config/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jest.setTimeout(30000);
28 changes: 9 additions & 19 deletions packages/nacos-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,23 @@
"mz": "^2.7.0",
"mz-modules": "^2.1.0",
"osenv": "^0.1.5",
"sdk-base": "^3.5.0",
"sdk-base": "^3.6.0",
"urlencode": "^1.1.0",
"urllib": "^2.29.1",
"utility": "^1.14.0"
"urllib": "^2.33.3",
"utility": "^1.16.1"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
"@types/node": "^10.9.4",
"contributors": "^0.5.1",
"midway-bin": "1",
"mm": "^2.4.1",
"pedding": "^1.1.0",
"tslint": "^5.11.0",
"typescript": "^3.2.2"
"mm": "^2.5.0",
"pedding": "^1.1.0"
},
"engines": {
"node": ">= 8.0.0"
},
"scripts": {
"autod": "midway-bin autod",
"lint": "tslint . --ext .ts",
"test": "npm run test-local",
"test-local": "TEST_REPORTER=spec midway-bin test --ts",
"cov": "TEST_REPORTER=spec midway-bin cov --ts",
"contributors": "contributors",
"ci": "npm run lint && npm run cov",
"build": "midway-bin build --ts"
"test": "jest",
"cov": "jest --coverage --forceExit",
"ci": "npm run cov",
"build": "tsc"
},
"files": [
"d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/nacos-config/test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const { sleep } = require('mz-modules');

describe('test/client.test.ts', () => {
let client;
before(async () => {
beforeAll(async () => {
client = new DataClient({
appName: 'test',
endpoint: 'acm.aliyun.com',
Expand All @@ -35,7 +35,7 @@ describe('test/client.test.ts', () => {
ssl: false
});
});
after(() => {
afterAll(() => {
client.close();
});
afterEach(mm.restore);
Expand Down
18 changes: 9 additions & 9 deletions packages/nacos-config/test/client_worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ function getClient(configuration) {

describe('test/client_worker.test.ts', () => {

describe('test features in direct mode', () => {
describe.skip('test features in direct mode', () => {

const defaultOptions = {
serverAddr: '106.14.43.196:8848',
serverAddr: '127.0.0.1:8848',
namespace: '',
cacheDir
};
Expand All @@ -56,15 +56,15 @@ describe('test/client_worker.test.ts', () => {

let client: ClientWorker;

before(async () => {
beforeAll(async () => {
client = getClient(configuration);
await client.publishSingle('com.taobao.hsf.redis', 'DEFAULT_GROUP', '10.123.32.1:8080');
await sleep(1000);
await client.ready();
});
afterEach(mm.restore);

after(async () => {
afterAll(async () => {
client.close();
await client.remove('com.taobao.hsf.redis', 'DEFAULT_GROUP');
await client.remove('test-dataId-encoding', 'test-group');
Expand Down Expand Up @@ -214,15 +214,15 @@ describe('test/client_worker.test.ts', () => {
});

let client: ClientWorker;
before(async () => {
beforeAll(async () => {
client = getClient(configuration);
await client.publishSingle('com.taobao.hsf.redis', 'DEFAULT_GROUP', '10.123.32.1:8080');
await sleep(1000);
await client.ready();
});
afterEach(mm.restore);

after(async () => {
afterAll(async () => {
client.close();
await client.remove('com.taobao.hsf.redis', 'DEFAULT_GROUP');
await rimraf(cacheDir);
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('test/client_worker.test.ts', () => {
client.close();
});

it('should publishSingle ok', async () => {
it('should publishSingle ok2', async () => {
let isSuccess = await client.publishSingle('test-dataId', 'test-group', 'test-content');
assert(isSuccess);

Expand Down Expand Up @@ -334,13 +334,13 @@ describe('test/client_worker.test.ts', () => {
});

describe('mock error', () => {
before(async () => {
beforeAll(async () => {
client = getClient(configuration);
await client.ready();
});
afterEach(mm.restore);

after(async () => {
afterAll(async () => {
client.close();
await rimraf(cacheDir);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/nacos-config/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {NacosConfigClient} from '../src';

describe('test/index.test.ts', () => {
let client;
before(async () => {
beforeAll(async () => {
client = new NacosConfigClient({
endpoint: 'acm.aliyun.com',
namespace: '81597370-5076-4216-9df5-538a2b55bac3',
Expand All @@ -35,7 +35,7 @@ describe('test/index.test.ts', () => {
});
await client.ready();
});
after(() => {
afterAll(() => {
client.close();
});
afterEach(mm.restore);
Expand Down
10 changes: 5 additions & 5 deletions packages/nacos-config/test/server_list_mgr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ describe('test/server_list_mgr.test.ts', () => {

const configuration = createDefaultConfiguration(defaultOptions);

before(async () => {
beforeAll(async () => {
serverManager = new ServerListManager({ configuration });
await serverManager.ready();
});

afterEach(mm.restore);

after(async () => {
afterAll(async () => {
serverManager.close();
await rimraf(cacheDir);
await sleep(4000);
Expand Down Expand Up @@ -186,10 +186,10 @@ describe('test/server_list_mgr.test.ts', () => {
describe('use ip and direct mode', () => {
let serverManager: ServerListManager;

before(async () => {
beforeAll(async () => {
const configuration = createDefaultConfiguration({
httpclient,
serverAddr: '106.14.43.196:8848',
serverAddr: '127.0.0.1:8848',
cacheDir,
});
serverManager = new ServerListManager({ configuration });
Expand All @@ -198,7 +198,7 @@ describe('test/server_list_mgr.test.ts', () => {

afterEach(mm.restore);

after(async () => {
afterAll(async () => {
serverManager.close();
await rimraf(cacheDir);
await sleep(4000);
Expand Down
4 changes: 2 additions & 2 deletions packages/nacos-config/test/snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const cacheDir = path.join(__dirname, '.cache');

describe('test/snapshot.test.ts', () => {
let snapshot;
before(async () => {
beforeAll(async () => {
const configuration = createDefaultConfiguration({
cacheDir,
});
snapshot = new Snapshot({ configuration });
await snapshot.ready();
});
afterEach(mm.restore);
after(async () => { await rimraf(cacheDir); });
afterAll(async () => { await rimraf(cacheDir); });

describe('save()', () => {
it('should get/save snapshot ok', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/nacos-config/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Configuration } from '../src/configuration';
import { DEFAULT_OPTIONS } from '../src/const';

export function delay(timeout) {
return new Promise(resolve => {
return new Promise<void>(resolve => {
setTimeout(() => {
resolve();
}, timeout);
Expand Down
22 changes: 6 additions & 16 deletions packages/nacos-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
{
"extends": "../../tsconfig.json",
"compileOnSave": true,
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"stripInternal": true,
"pretty": true,
"declaration": true,
"outDir": "dist",
"lib": ["es2017"],
"sourceMap": true
"rootDir": "src",
"outDir": "dist"
},
"exclude": [
"dist",
"node_modules",
"test"
"include": [
"./src/**/*.ts"
]
}
Loading