mazey 3.3.2 → 3.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +100 -68
- package/README_CN.md +1 -1
- package/images/mazey-v1.4.39.svg +1 -0
- package/lib/index.cjs.js +6 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +6 -1
- package/lib/mazey.min.js +6 -1
- package/package.json +30 -30
- package/scripts/build-helper.js +17 -0
- package/scripts/dev.js +19 -0
- package/scripts/github-helper.js +57 -0
- package/scripts/release.js +2 -23
- package/{webpack.config.dev.js → scripts/webpack.config.dev.js} +8 -8
- package/{index.js → src/index.js} +0 -0
- package/src/index.ts +10 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mazey",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.5",
|
|
4
4
|
"description": "Mazey's library for front-end.",
|
|
5
5
|
"main": "lib/index.cjs.js",
|
|
6
6
|
"module": "lib/index.esm.js",
|
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
"lib": "./lib"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"dev": "webpack-dev-server --config webpack.config.dev.js --open",
|
|
14
|
-
"build": "
|
|
13
|
+
"dev": "webpack-dev-server --config ./scripts/webpack.config.dev.js --open",
|
|
14
|
+
"build": "rollup --config ./scripts/rollup.config.js",
|
|
15
15
|
"test": "jest",
|
|
16
|
-
"
|
|
17
|
-
"docs": "npx typedoc",
|
|
16
|
+
"docs": "typedoc",
|
|
18
17
|
"lint-and-fix": "eslint ./src/index.ts --ext 'ts,tsx' --fix",
|
|
19
18
|
"preview": "npm run build && npm run test && npm run docs",
|
|
20
19
|
"release": "npm run preview && npm publish && node ./scripts/release.js"
|
|
@@ -59,42 +58,43 @@
|
|
|
59
58
|
},
|
|
60
59
|
"homepage": "https://github.com/mazeyqian/mazey#readme",
|
|
61
60
|
"devDependencies": {
|
|
62
|
-
"@babel/core": "7.8.4",
|
|
63
|
-
"@babel/plugin-proposal-class-properties": "7.10.4",
|
|
64
|
-
"@babel/plugin-proposal-object-rest-spread": "7.11.0",
|
|
65
|
-
"@babel/plugin-transform-runtime": "7.11.0",
|
|
66
|
-
"@babel/preset-env": "7.5.5",
|
|
67
|
-
"@babel/preset-typescript": "7.10.4",
|
|
61
|
+
"@babel/core": "^7.8.4",
|
|
62
|
+
"@babel/plugin-proposal-class-properties": "^7.10.4",
|
|
63
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
|
|
64
|
+
"@babel/plugin-transform-runtime": "^7.11.0",
|
|
65
|
+
"@babel/preset-env": "^7.5.5",
|
|
66
|
+
"@babel/preset-typescript": "^7.10.4",
|
|
68
67
|
"@commitlint/cli": "^8.3.5",
|
|
69
68
|
"@commitlint/config-conventional": "^8.3.4",
|
|
70
69
|
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
|
71
70
|
"@typescript-eslint/parser": "^4.22.0",
|
|
72
|
-
"clean-webpack-plugin": "1.0.1",
|
|
73
|
-
"
|
|
74
|
-
"eslint
|
|
75
|
-
"eslint-
|
|
76
|
-
"eslint-plugin-
|
|
77
|
-
"eslint-plugin-
|
|
78
|
-
"eslint-plugin-
|
|
71
|
+
"clean-webpack-plugin": "^1.0.1",
|
|
72
|
+
"date-fns": "^2.29.3",
|
|
73
|
+
"eslint": "^6.8.0",
|
|
74
|
+
"eslint-config-standard": "^14.1.0",
|
|
75
|
+
"eslint-plugin-import": "^2.20.1",
|
|
76
|
+
"eslint-plugin-node": "^11.0.0",
|
|
77
|
+
"eslint-plugin-promise": "^4.2.1",
|
|
78
|
+
"eslint-plugin-standard": "^4.0.1",
|
|
79
79
|
"execa": "^4.1.0",
|
|
80
|
-
"html-webpack-plugin": "3.2.0",
|
|
81
|
-
"husky": "4.3.8",
|
|
80
|
+
"html-webpack-plugin": "^3.2.0",
|
|
81
|
+
"husky": "^4.3.8",
|
|
82
82
|
"jest": "^27.5.1",
|
|
83
|
-
"lint-staged": "10.0.8",
|
|
84
|
-
"prettier": "1.19.1",
|
|
85
|
-
"prettier-eslint-cli": "5.0.0",
|
|
86
|
-
"rollup": "^
|
|
83
|
+
"lint-staged": "^10.0.8",
|
|
84
|
+
"prettier": "^1.19.1",
|
|
85
|
+
"prettier-eslint-cli": "^5.0.0",
|
|
86
|
+
"rollup": "^2.79.1",
|
|
87
87
|
"rollup-plugin-babel": "^4.3.3",
|
|
88
88
|
"rollup-plugin-cleaner": "^1.0.0",
|
|
89
89
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
90
90
|
"rollup-plugin-terser": "^7.0.2",
|
|
91
91
|
"rollup-plugin-typescript2": "^0.27.2",
|
|
92
|
-
"ts-loader": "8.0.2",
|
|
93
|
-
"typedoc": "0.18.0",
|
|
94
|
-
"typescript": "3.9.7",
|
|
95
|
-
"webpack": "4.30.0",
|
|
96
|
-
"webpack-cli": "3.3.2",
|
|
97
|
-
"webpack-dev-server": "3.10.3"
|
|
92
|
+
"ts-loader": "^8.0.2",
|
|
93
|
+
"typedoc": "^0.18.0",
|
|
94
|
+
"typescript": "^3.9.7",
|
|
95
|
+
"webpack": "^4.30.0",
|
|
96
|
+
"webpack-cli": "^3.3.2",
|
|
97
|
+
"webpack-dev-server": "^3.10.3"
|
|
98
98
|
},
|
|
99
99
|
"husky": {
|
|
100
100
|
"hooks": {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
/* eslint-disable no-undef */
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const _resolve = (_path) => path.resolve(__dirname, _path);
|
|
5
|
+
const format = require('date-fns/format');
|
|
6
|
+
// Generate version: 20210308.072903
|
|
7
|
+
const genVersion = () => {
|
|
8
|
+
const d = new Date();
|
|
9
|
+
const version = format(d, 'yyyyMMdd.HHmmss');
|
|
10
|
+
return version;
|
|
11
|
+
};
|
|
12
|
+
const version = genVersion();
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
_resolve,
|
|
16
|
+
version,
|
|
17
|
+
};
|
package/scripts/dev.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
|
+
const execa = require('execa');
|
|
4
|
+
|
|
5
|
+
(async () => {
|
|
6
|
+
// const { stdout: pushMsg = '' } = await execa('git', ['push'], { stdio: 'pipe' })
|
|
7
|
+
// .catch(error => {
|
|
8
|
+
// console.log('error:', error.message);
|
|
9
|
+
// });
|
|
10
|
+
try {
|
|
11
|
+
await execa('git', ['push'], { stdio: 'pipe' });
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.log('error:', error.message);
|
|
14
|
+
const { stdout: currentBranch } = await execa('git', ['branch', '--show-current'], { stdio: 'pipe' });
|
|
15
|
+
console.log('currentBranch:', currentBranch); // currentBranch: fix/rollup_dependences_mon_oct_31st_2022
|
|
16
|
+
await execa('git', ['push', '--set-upstream', 'origin', currentBranch]);
|
|
17
|
+
}
|
|
18
|
+
// console.log('pushMsg:', pushMsg);
|
|
19
|
+
})();
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
/* eslint-disable no-undef */
|
|
3
|
+
// Github Helper
|
|
4
|
+
const execa = require('execa');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Release code.
|
|
8
|
+
*
|
|
9
|
+
* Example: Release code with version by `process.env.VERSION` or `package.json`.
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* const pkgVersion = process.env.VERSION || require('../package.json').version;
|
|
13
|
+
* release(pkgVersion);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
async function release (ver) {
|
|
17
|
+
const releaseVersion = `v${ver}`;
|
|
18
|
+
const { stdout: releaseStdout } = await execa('echo', [`Start release ${releaseVersion}...`]);
|
|
19
|
+
console.log(releaseStdout);
|
|
20
|
+
// git branch --show-current
|
|
21
|
+
// console.log('git push --set-upstream origin <branch>');
|
|
22
|
+
// Commit Stdout
|
|
23
|
+
const { stdout: diffStdout } = await execa('git', ['diff'], { stdio: 'pipe' });
|
|
24
|
+
if (diffStdout) {
|
|
25
|
+
console.log('Committing changes...');
|
|
26
|
+
await execa('git', ['add', '-A']);
|
|
27
|
+
await execa('git', ['commit', '-m', `release: ${releaseVersion}`]);
|
|
28
|
+
} else {
|
|
29
|
+
console.log('No changes to commit.');
|
|
30
|
+
}
|
|
31
|
+
// Push
|
|
32
|
+
console.log('Pushing to GitHub...');
|
|
33
|
+
await execa('git', ['tag', '-a', `${releaseVersion}`, '-m', `Release ${releaseVersion}`]);
|
|
34
|
+
await execa('git', ['push', 'origin', `refs/tags/${releaseVersion}`]);
|
|
35
|
+
await gitPush(); // execa('git', ['push']);
|
|
36
|
+
|
|
37
|
+
console.log('All done.');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Git Push
|
|
42
|
+
*/
|
|
43
|
+
async function gitPush () {
|
|
44
|
+
try {
|
|
45
|
+
await execa('git', ['push'], { stdio: 'pipe' });
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.log('error:', error.message);
|
|
48
|
+
const { stdout: currentBranch } = await execa('git', ['branch', '--show-current'], { stdio: 'pipe' });
|
|
49
|
+
console.log('currentBranch:', currentBranch); // currentBranch: fix/rollup_dependences_mon_oct_31st_2022
|
|
50
|
+
await execa('git', ['push', '--set-upstream', 'origin', currentBranch]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = {
|
|
55
|
+
release,
|
|
56
|
+
gitPush,
|
|
57
|
+
};
|
package/scripts/release.js
CHANGED
|
@@ -1,28 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
2
|
/* eslint-disable no-undef */
|
|
3
3
|
// release
|
|
4
|
-
const
|
|
4
|
+
const { release } = require('./github-helper');
|
|
5
5
|
const pkgVersion = process.env.VERSION || require('../package.json').version;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
(async () => {
|
|
9
|
-
const releaseVersion = `v${pkgVersion}`;
|
|
10
|
-
const { stdout: releaseStdout } = await execa('echo', [`Start release ${releaseVersion}...`]);
|
|
11
|
-
console.log(releaseStdout);
|
|
12
|
-
// Commit Stdout
|
|
13
|
-
const { stdout: diffStdout } = await execa('git', ['diff'], { stdio: 'pipe' });
|
|
14
|
-
if (diffStdout) {
|
|
15
|
-
console.log('Committing changes...');
|
|
16
|
-
await execa('git', ['add', '-A']);
|
|
17
|
-
await execa('git', ['commit', '-m', `release: ${releaseVersion}`]);
|
|
18
|
-
} else {
|
|
19
|
-
console.log('No changes to commit.');
|
|
20
|
-
}
|
|
21
|
-
// Push
|
|
22
|
-
console.log('Pushing to GitHub...');
|
|
23
|
-
await execa('git', ['tag', '-a', `${releaseVersion}`, '-m', `Release ${releaseVersion}`]);
|
|
24
|
-
await execa('git', ['push', 'origin', `refs/tags/${releaseVersion}`]);
|
|
25
|
-
await execa('git', ['push']);
|
|
26
|
-
|
|
27
|
-
console.log('All done.');
|
|
28
|
-
})();
|
|
7
|
+
release(pkgVersion);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
2
|
/* eslint-disable no-undef */
|
|
3
|
-
const path = require('path');
|
|
4
3
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
5
4
|
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
|
5
|
+
const { _resolve } = require('./build-helper');
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
8
|
entry: {
|
|
9
|
-
index: '
|
|
9
|
+
index: _resolve('../examples/index.ts'),
|
|
10
10
|
},
|
|
11
11
|
output: {
|
|
12
12
|
filename: '[name].js',
|
|
13
|
-
path:
|
|
13
|
+
path: _resolve('../dist'),
|
|
14
14
|
},
|
|
15
15
|
devServer: {
|
|
16
|
-
contentBase: '
|
|
16
|
+
contentBase: _resolve('../dist'),
|
|
17
17
|
},
|
|
18
18
|
module: {
|
|
19
19
|
rules: [
|
|
@@ -26,14 +26,14 @@ module.exports = {
|
|
|
26
26
|
},
|
|
27
27
|
plugins: [
|
|
28
28
|
new HtmlWebpackPlugin({
|
|
29
|
-
filename:
|
|
30
|
-
template:
|
|
29
|
+
filename: _resolve('../dist/index.html'),
|
|
30
|
+
template: _resolve('../examples/index.html'),
|
|
31
31
|
inject: true,
|
|
32
32
|
chunksSortMode: 'dependency'
|
|
33
33
|
}),
|
|
34
|
-
new CleanWebpackPlugin(['dist'])
|
|
34
|
+
new CleanWebpackPlugin([_resolve('../dist')]),
|
|
35
35
|
],
|
|
36
36
|
resolve: {
|
|
37
37
|
extensions: ['.tsx', '.ts', '.js'],
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
39
|
};
|
|
File without changes
|
package/src/index.ts
CHANGED
|
@@ -1510,24 +1510,28 @@ export function genCustomConsole(prefix = ''): Console {
|
|
|
1510
1510
|
|
|
1511
1511
|
/**
|
|
1512
1512
|
* Verify the validity of axios response.
|
|
1513
|
+
*
|
|
1514
|
+
* Reference: [Handling Errors](https://axios-http.com/docs/handling_errors)
|
|
1513
1515
|
*/
|
|
1514
1516
|
export function zAxiosIsValidRes(res: any, options: {
|
|
1515
|
-
|
|
1517
|
+
validStatusRange: number[];
|
|
1516
1518
|
validCode: number[];
|
|
1517
1519
|
} = {
|
|
1518
|
-
|
|
1520
|
+
validStatusRange: [200, 300],
|
|
1519
1521
|
validCode: [0],
|
|
1520
1522
|
}): boolean {
|
|
1521
|
-
const {
|
|
1523
|
+
const { validStatusRange, validCode } = Object.assign(
|
|
1522
1524
|
{
|
|
1523
|
-
|
|
1525
|
+
validStatusRange: [200, 300],
|
|
1524
1526
|
validCode: [0],
|
|
1525
1527
|
},
|
|
1526
1528
|
options,
|
|
1527
1529
|
);
|
|
1530
|
+
if (validStatusRange.length !== 2) {
|
|
1531
|
+
console.error('valid validStatusRange is required');
|
|
1532
|
+
}
|
|
1528
1533
|
let ret = false;
|
|
1529
|
-
if (res && res.status &&
|
|
1530
|
-
ret = true;
|
|
1534
|
+
if (res && res.status && validStatusRange.length === 2 && res.status >= validStatusRange[0] && res.status < validStatusRange[1]) {
|
|
1531
1535
|
const resData = res.data;
|
|
1532
1536
|
if (resData && validCode.includes(resData.code)) {
|
|
1533
1537
|
ret = true;
|