Skip to content

Commit 4853b76

Browse files
wwwzbwcomyugasun
andauthored
breaking: refactor with typescript 🚀 (#177)
* refactory(ts): almost all files are typescript now 🚀 * chore: move files from build to lib for better import, fix error in cdn * test: sleep longer to ensure layer deploy success * fix: update the workflow build scripts * fix: remove dummy file .json * refactory(ts): refactory apigw, ensure type clearer * fix: region type from enum to string * refactor(ts): update cam * refactor(ts): rename camelCase to pascalCase, make more accurate * refactor(ts): update cos to the latest sdk * refactor(ts): add comment and remove any in cynosdb * refactor(ts): check domain, layer, postgresql, remove uneccesary any * refactor(ts): update tag, vpc and error * refactor(ts): update apigw, scf, multi-apigw, multi-scf * refactor(ts): update apigw, scf, multi-apigw, multi-scf * fix: fix bugs after refactor * fix: fix error after rebase * fix(cynosdb): generate password * test(cynosdb): fix * fix(cynosdb): method isSupportZone * fix: fix some logic, naming and apis * chore: update eslint and prettier support * chore: use prettier to format files * chore: update eslint config, fix lint issues * chore: add breaking commit type Co-authored-by: yugasun <yuga_sun@163.com>
1 parent aedab3f commit 4853b76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+6111
-3275
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ coverage
22
dist
33
node_modules
44
example
5+
# ignore for dont check build result
6+
lib
7+
**/*.d.ts

.eslintrc.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
module.exports = {
22
root: true,
33
extends: ['prettier'],
4-
plugins: ['import', 'prettier'],
4+
plugins: ['import', 'prettier', '@typescript-eslint'],
55
env: {
66
es6: true,
77
jest: true,
88
node: true,
99
},
10-
parser: 'babel-eslint',
10+
parser: '@typescript-eslint/parser',
1111
parserOptions: {
1212
ecmaVersion: 2018,
1313
sourceType: 'module',
1414
ecmaFeatures: {
1515
jsx: true,
1616
},
1717
},
18+
overrides: [
19+
{
20+
files: ['./src/**/*.ts', './__test__/**.*.js'],
21+
},
22+
],
1823
globals: {
1924
on: true, // for the Socket file
2025
},
@@ -47,9 +52,9 @@ module.exports = {
4752
'no-const-assign': 'error',
4853
'no-else-return': 'error',
4954
'no-empty': 'off',
50-
'no-shadow': 'error',
55+
'@typescript-eslint/no-shadow': 'error',
5156
'no-undef': 'error',
52-
'no-unused-vars': 'error',
57+
'@typescript-eslint/no-unused-vars': 'error',
5358
'no-use-before-define': 'error',
5459
'no-useless-constructor': 'error',
5560
'object-curly-newline': 'off',

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ jobs:
3737
run: |
3838
npm update --no-save
3939
npm update --save-dev --no-save
40+
41+
- name: Build
42+
run: npm run build
43+
4044
- name: Releasing
4145
run: |
4246
npm run release

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ jobs:
3838
run: |
3939
npm update --no-save
4040
npm update --save-dev --no-save
41+
42+
- name: Build
43+
run: npm run build
44+
4145
- name: Running tests
4246
run: npm run test
4347
env:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ node_modules
1616
dist
1717
.idea
1818
build
19+
lib
1920
.env*
2021
.env.test
2122
!.env.example

__tests__/apigw.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Apigw } = require('../src');
1+
const { Apigw } = require('../lib');
22

33
const deepClone = (obj) => {
44
return JSON.parse(JSON.stringify(obj));

__tests__/cam.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Cam } = require('../src');
1+
const { Cam } = require('../lib');
22

33
describe('Cam', () => {
44
const credentials = {

__tests__/cdn.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { Cdn } = require('../src');
2-
const { getCdnByDomain } = require('../src/modules/cdn/utils');
1+
const { Cdn } = require('../lib');
2+
const { getCdnByDomain } = require('../lib/modules/cdn/utils');
33

44
describe('Cdn', () => {
55
jest.setTimeout(600000);

__tests__/cfs.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { sleep } = require('@ygkit/request');
2-
const { Cfs } = require('../src');
3-
const apis = require('../src/modules/cfs/apis');
2+
const { Cfs } = require('../lib');
3+
const utils = require('../lib/modules/cfs/utils').default;
44

55
describe('Cfs', () => {
66
const credentials = {
@@ -44,7 +44,7 @@ describe('Cfs', () => {
4444
test('should remove CFS success', async () => {
4545
await sleep(1000);
4646
const res = await cfs.remove(inputs);
47-
const detail = await apis.getCfs(cfs.capi, inputs.fileSystemId);
47+
const detail = await utils.getCfs(cfs.capi, inputs.fileSystemId);
4848
expect(res).toEqual({});
4949
expect(detail).toBeUndefined();
5050
});

__tests__/cls.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const { Cls } = require('../src');
1+
const { Cls } = require('../lib');
2+
const { sleep } = require('@ygkit/request');
23

34
describe('Cls', () => {
45
const credentials = {
@@ -42,6 +43,7 @@ describe('Cls', () => {
4243
});
4344

4445
test('should remove cls success', async () => {
46+
await sleep(2000);
4547
await client.remove(outputs);
4648

4749
const detail = await client.cls.getLogset({

0 commit comments

Comments
 (0)