mazey 3.3.6 → 3.3.8

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/package.json CHANGED
@@ -1,110 +1,111 @@
1
- {
2
- "name": "mazey",
3
- "version": "3.3.6",
4
- "description": "Mazey's library for front-end.",
5
- "main": "lib/index.cjs.js",
6
- "module": "lib/index.esm.js",
7
- "typings": "lib/index.d.ts",
8
- "mainEntryPointFilePath": "lib/index.d.ts",
9
- "directories": {
10
- "lib": "./lib"
11
- },
12
- "scripts": {
13
- "dev": "webpack-dev-server --config ./scripts/webpack.config.dev.js --open",
14
- "build": "rollup --config ./scripts/rollup.config.js",
15
- "test": "jest",
16
- "docs": "typedoc",
17
- "lint-and-fix": "eslint ./src/index.ts --ext 'ts,tsx' --fix",
18
- "preview": "npm run docs && npm run build && npm run test",
19
- "release": "npm run preview && node ./scripts/release.js"
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "git+https://github.com/mazeyqian/mazey.git"
24
- },
25
- "keywords": [
26
- "javascript",
27
- "function",
28
- "math",
29
- "load",
30
- "css",
31
- "debounce",
32
- "throttle",
33
- "trim",
34
- "clone",
35
- "json",
36
- "random",
37
- "dom",
38
- "style",
39
- "url",
40
- "hash",
41
- "storage",
42
- "cookie",
43
- "calculate",
44
- "formula",
45
- "browser",
46
- "performance",
47
- "pwa",
48
- "console"
49
- ],
50
- "author": {
51
- "name": "Mazey Chu",
52
- "email": "mazeyqian@gmail.com",
53
- "url": "https://blog.mazey.net"
54
- },
55
- "license": "MIT",
56
- "bugs": {
57
- "url": "https://github.com/mazeyqian/mazey/issues"
58
- },
59
- "homepage": "https://github.com/mazeyqian/mazey#readme",
60
- "devDependencies": {
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",
67
- "@commitlint/cli": "^8.3.5",
68
- "@commitlint/config-conventional": "^8.3.4",
69
- "@typescript-eslint/eslint-plugin": "^4.22.0",
70
- "@typescript-eslint/parser": "^4.22.0",
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
- "execa": "^4.1.0",
80
- "html-webpack-plugin": "^3.2.0",
81
- "husky": "^4.3.8",
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": "^2.79.1",
87
- "rollup-plugin-babel": "^4.3.3",
88
- "rollup-plugin-cleaner": "^1.0.0",
89
- "rollup-plugin-commonjs": "^10.1.0",
90
- "rollup-plugin-copy": "^3.4.0",
91
- "rollup-plugin-terser": "^7.0.2",
92
- "rollup-plugin-typescript2": "^0.27.2",
93
- "ts-loader": "^8.0.2",
94
- "typedoc": "^0.18.0",
95
- "typescript": "^3.9.7",
96
- "webpack": "^4.30.0",
97
- "webpack-cli": "^3.3.2",
98
- "webpack-dev-server": "^3.10.3"
99
- },
100
- "husky": {
101
- "hooks": {
102
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
103
- "pre-commit": "lint-staged"
104
- }
105
- },
106
- "dependencies": {
107
- "@babel/runtime-corejs3": "^7.11.2",
108
- "core-js": "^3.6.5"
109
- }
110
- }
1
+ {
2
+ "name": "mazey",
3
+ "version": "3.3.8",
4
+ "description": "Mazey's library for front-end.",
5
+ "main": "lib/index.cjs.js",
6
+ "module": "lib/index.esm.js",
7
+ "typings": "lib/index.d.ts",
8
+ "mainEntryPointFilePath": "lib/index.d.ts",
9
+ "directories": {
10
+ "lib": "./lib"
11
+ },
12
+ "scripts": {
13
+ "dev": "webpack-dev-server --config ./scripts/webpack.config.dev.js --open",
14
+ "build": "rollup --config ./scripts/rollup.config.js",
15
+ "test": "jest",
16
+ "docs": "typedoc",
17
+ "lint-and-fix": "eslint ./src/index.ts --ext 'ts,tsx' --fix",
18
+ "preview": "npm run docs && npm run build && npm run test",
19
+ "release": "npm run preview && cross-env SCRIPTS_NPM_PACKAGE_VERSION=$npm_package_version node ./scripts/release.js"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/mazeyqian/mazey.git"
24
+ },
25
+ "keywords": [
26
+ "javascript",
27
+ "function",
28
+ "math",
29
+ "load",
30
+ "css",
31
+ "debounce",
32
+ "throttle",
33
+ "trim",
34
+ "clone",
35
+ "json",
36
+ "random",
37
+ "dom",
38
+ "style",
39
+ "url",
40
+ "hash",
41
+ "storage",
42
+ "cookie",
43
+ "calculate",
44
+ "formula",
45
+ "browser",
46
+ "performance",
47
+ "pwa",
48
+ "console"
49
+ ],
50
+ "author": {
51
+ "name": "Mazey Chu",
52
+ "email": "mazeyqian@gmail.com",
53
+ "url": "https://blog.mazey.net"
54
+ },
55
+ "license": "MIT",
56
+ "bugs": {
57
+ "url": "https://github.com/mazeyqian/mazey/issues"
58
+ },
59
+ "homepage": "https://github.com/mazeyqian/mazey#readme",
60
+ "devDependencies": {
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",
67
+ "@commitlint/cli": "^8.3.5",
68
+ "@commitlint/config-conventional": "^8.3.4",
69
+ "@typescript-eslint/eslint-plugin": "^4.22.0",
70
+ "@typescript-eslint/parser": "^4.22.0",
71
+ "clean-webpack-plugin": "^1.0.1",
72
+ "cross-env": "^7.0.3",
73
+ "date-fns": "^2.29.3",
74
+ "eslint": "^6.8.0",
75
+ "eslint-config-standard": "^14.1.0",
76
+ "eslint-plugin-import": "^2.20.1",
77
+ "eslint-plugin-node": "^11.0.0",
78
+ "eslint-plugin-promise": "^4.2.1",
79
+ "eslint-plugin-standard": "^4.0.1",
80
+ "execa": "^4.1.0",
81
+ "html-webpack-plugin": "^3.2.0",
82
+ "husky": "^4.3.8",
83
+ "jest": "^27.5.1",
84
+ "lint-staged": "^10.0.8",
85
+ "prettier": "^1.19.1",
86
+ "prettier-eslint-cli": "^5.0.0",
87
+ "rollup": "^2.79.1",
88
+ "rollup-plugin-babel": "^4.3.3",
89
+ "rollup-plugin-cleaner": "^1.0.0",
90
+ "rollup-plugin-commonjs": "^10.1.0",
91
+ "rollup-plugin-copy": "^3.4.0",
92
+ "rollup-plugin-terser": "^7.0.2",
93
+ "rollup-plugin-typescript2": "^0.27.2",
94
+ "ts-loader": "^8.0.2",
95
+ "typedoc": "^0.18.0",
96
+ "typescript": "^3.9.7",
97
+ "webpack": "^4.30.0",
98
+ "webpack-cli": "^3.3.2",
99
+ "webpack-dev-server": "^3.10.3"
100
+ },
101
+ "husky": {
102
+ "hooks": {
103
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
104
+ "pre-commit": "lint-staged"
105
+ }
106
+ },
107
+ "dependencies": {
108
+ "@babel/runtime-corejs3": "^7.11.2",
109
+ "core-js": "^3.6.5"
110
+ }
111
+ }
@@ -1,17 +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
- };
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 CHANGED
@@ -1,22 +1,22 @@
1
- /* eslint-disable no-undef */
2
- /* eslint-disable @typescript-eslint/no-var-requires */
3
- // const execa = require('execa');
4
- const { getGitCurrentBranch } = require('./github-helper');
5
-
6
- (async () => {
7
- // const { stdout: pushMsg = '' } = await execa('git', ['push'], { stdio: 'pipe' })
8
- // .catch(error => {
9
- // console.log('error:', error.message);
10
- // });
11
- // try {
12
- // await execa('git', ['push'], { stdio: 'pipe' });
13
- // } catch (error) {
14
- // console.log('error:', error.message);
15
- // const { stdout: currentBranch } = await execa('git', ['branch', '--show-current'], { stdio: 'pipe' });
16
- // console.log('currentBranch:', currentBranch); // currentBranch: fix/rollup_dependences_mon_oct_31st_2022
17
- // await execa('git', ['push', '--set-upstream', 'origin', currentBranch]);
18
- // }
19
- // console.log('pushMsg:', pushMsg);
20
- const cb = await getGitCurrentBranch('fix returns value');
21
- console.log('bbb', cb);
22
- })();
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable @typescript-eslint/no-var-requires */
3
+ // const execa = require('execa');
4
+ const { getGitCurrentBranch } = require('./github-helper');
5
+
6
+ (async () => {
7
+ // const { stdout: pushMsg = '' } = await execa('git', ['push'], { stdio: 'pipe' })
8
+ // .catch(error => {
9
+ // console.log('error:', error.message);
10
+ // });
11
+ // try {
12
+ // await execa('git', ['push'], { stdio: 'pipe' });
13
+ // } catch (error) {
14
+ // console.log('error:', error.message);
15
+ // const { stdout: currentBranch } = await execa('git', ['branch', '--show-current'], { stdio: 'pipe' });
16
+ // console.log('currentBranch:', currentBranch); // currentBranch: fix/rollup_dependences_mon_oct_31st_2022
17
+ // await execa('git', ['push', '--set-upstream', 'origin', currentBranch]);
18
+ // }
19
+ // console.log('pushMsg:', pushMsg);
20
+ const cb = await getGitCurrentBranch('fix returns value');
21
+ console.log('bbb', cb);
22
+ })();
@@ -1,110 +1,117 @@
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
- // commit
21
- await getCommit('stage');
22
- // marge
23
- await gitMergeMaster2Release();
24
- // build
25
- await execa('npm', ['run', 'preview']);
26
- await execa('npm', ['publish']);
27
- // git branch --show-current
28
- // console.log('git push --set-upstream origin <branch>');
29
- // Commit Stdout
30
- const { stdout: diffStdout } = await execa('git', ['diff'], { stdio: 'pipe' });
31
- if (diffStdout) {
32
- console.log('Committing changes...');
33
- await execa('git', ['add', '-A']);
34
- await execa('git', ['commit', '-m', `release: ${releaseVersion}`]);
35
- } else {
36
- console.log('No changes to commit.');
37
- }
38
- // Push
39
- console.log('Pushing to GitHub...');
40
- await execa('git', ['tag', '-a', `${releaseVersion}`, '-m', `Release ${releaseVersion}`]);
41
- await execa('git', ['push', 'origin', `refs/tags/${releaseVersion}`]);
42
- await gitPush(); // execa('git', ['push']);
43
-
44
- console.log('All done.');
45
- }
46
-
47
- /**
48
- * Push code.
49
- */
50
- async function gitPush () {
51
- try {
52
- await execa('git', ['push'], { stdio: 'pipe' });
53
- } catch (error) {
54
- console.log('error:', error.message);
55
- const { stdout: currentBranch } = await execa('git', ['branch', '--show-current'], { stdio: 'pipe' });
56
- console.log('currentBranch:', currentBranch); // currentBranch: fix/rollup_dependences_mon_oct_31st_2022
57
- await execa('git', ['push', '--set-upstream', 'origin', currentBranch]);
58
- }
59
- return true;
60
- }
61
-
62
- /**
63
- * Merge master to current branch.
64
- */
65
- async function gitMergeMaster2Release () {
66
- const currentBranch = await getGitCurrentBranch();
67
- await execa('git', ['checkout', 'master']);
68
- await execa('git', ['pull']);
69
- await execa('git', ['checkout', currentBranch]);
70
- await execa('git', ['merge', 'master']);
71
- return true;
72
- }
73
-
74
- /**
75
- * Get git current branch.
76
- */
77
- async function getGitCurrentBranch () {
78
- let currentBranch = '';
79
- try {
80
- ({ stdout: currentBranch } = await execa('git', ['branch', '--show-current'], { stdio: 'pipe' }));
81
- } catch (error) {
82
- // console.log('error:', error.message);
83
- ({ stdout: currentBranch } = await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { stdio: 'pipe' }));
84
- }
85
- console.log('currentBranch:', currentBranch);
86
- return currentBranch;
87
- }
88
-
89
- /**
90
- * Commit current code.
91
- */
92
- async function getCommit (releaseVersion = 0) {
93
- const { stdout: diffStdout } = await execa('git', ['diff'], { stdio: 'pipe' });
94
- if (diffStdout) {
95
- console.log('Committing changes...');
96
- await execa('git', ['add', '-A']);
97
- await execa('git', ['commit', '-m', `release: ${releaseVersion}`]);
98
- } else {
99
- console.log('No changes to commit.');
100
- }
101
- return true;
102
- }
103
-
104
- module.exports = {
105
- release,
106
- gitPush,
107
- gitMergeMaster2Release,
108
- getGitCurrentBranch,
109
- getCommit,
110
- };
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
+ if (!ver) {
18
+ ver = process.env.SCRIPTS_NPM_PACKAGE_VERSION;
19
+ }
20
+ if (!ver) {
21
+ console.error('Fail to get the current version.');
22
+ return;
23
+ }
24
+ const releaseVersion = `v${ver}`;
25
+ const { stdout: releaseStdout } = await execa('echo', [`Start release ${releaseVersion}...`]);
26
+ console.log(releaseStdout);
27
+ // commit
28
+ await getCommit('stage');
29
+ // marge
30
+ await gitMergeMaster2Release();
31
+ // build
32
+ await execa('npm', ['run', 'preview']);
33
+ await execa('npm', ['publish']);
34
+ // git branch --show-current
35
+ // console.log('git push --set-upstream origin <branch>');
36
+ // Commit Stdout
37
+ const { stdout: diffStdout } = await execa('git', ['diff'], { stdio: 'pipe' });
38
+ if (diffStdout) {
39
+ console.log('Committing changes...');
40
+ await execa('git', ['add', '-A']);
41
+ await execa('git', ['commit', '-m', `release: ${releaseVersion}`]);
42
+ } else {
43
+ console.log('No changes to commit.');
44
+ }
45
+ // Push
46
+ console.log('Pushing to GitHub...');
47
+ await execa('git', ['tag', '-a', `${releaseVersion}`, '-m', `Release ${releaseVersion}`]);
48
+ await execa('git', ['push', 'origin', `refs/tags/${releaseVersion}`]);
49
+ await gitPush(); // execa('git', ['push']);
50
+
51
+ console.log('All done.');
52
+ }
53
+
54
+ /**
55
+ * Push code.
56
+ */
57
+ async function gitPush () {
58
+ try {
59
+ await execa('git', ['push'], { stdio: 'pipe' });
60
+ } catch (error) {
61
+ console.log('error:', error.message);
62
+ const { stdout: currentBranch } = await execa('git', ['branch', '--show-current'], { stdio: 'pipe' });
63
+ console.log('currentBranch:', currentBranch); // currentBranch: fix/rollup_dependences_mon_oct_31st_2022
64
+ await execa('git', ['push', '--set-upstream', 'origin', currentBranch]);
65
+ }
66
+ return true;
67
+ }
68
+
69
+ /**
70
+ * Merge master to current branch.
71
+ */
72
+ async function gitMergeMaster2Release () {
73
+ const currentBranch = await getGitCurrentBranch();
74
+ await execa('git', ['checkout', 'master']);
75
+ await execa('git', ['pull']);
76
+ await execa('git', ['checkout', currentBranch]);
77
+ await execa('git', ['merge', 'master']);
78
+ return true;
79
+ }
80
+
81
+ /**
82
+ * Get git current branch.
83
+ */
84
+ async function getGitCurrentBranch () {
85
+ let currentBranch = '';
86
+ try {
87
+ ({ stdout: currentBranch } = await execa('git', ['branch', '--show-current'], { stdio: 'pipe' }));
88
+ } catch (error) {
89
+ // console.log('error:', error.message);
90
+ ({ stdout: currentBranch } = await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { stdio: 'pipe' }));
91
+ }
92
+ console.log('currentBranch:', currentBranch);
93
+ return currentBranch;
94
+ }
95
+
96
+ /**
97
+ * Commit current code.
98
+ */
99
+ async function getCommit (releaseVersion = 0) {
100
+ const { stdout: diffStdout } = await execa('git', ['diff'], { stdio: 'pipe' });
101
+ if (diffStdout) {
102
+ console.log('Committing changes...');
103
+ await execa('git', ['add', '-A']);
104
+ await execa('git', ['commit', '-m', `release: ${releaseVersion}`]);
105
+ } else {
106
+ console.log('No changes to commit.');
107
+ }
108
+ return true;
109
+ }
110
+
111
+ module.exports = {
112
+ release,
113
+ gitPush,
114
+ gitMergeMaster2Release,
115
+ getGitCurrentBranch,
116
+ getCommit,
117
+ };
@@ -1,7 +1,9 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- /* eslint-disable no-undef */
3
- // release
4
- const { release } = require('./github-helper');
5
- const pkgVersion = process.env.VERSION || require('../package.json').version;
6
-
7
- release(pkgVersion);
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ /* eslint-disable no-undef */
3
+ // release
4
+ const { release } = require('./github-helper');
5
+ const pkgVersion = process.env.SCRIPTS_NPM_PACKAGE_VERSION || process.env.VERSION || require('../package.json').version;
6
+
7
+ console.log('release: SCRIPTS_NPM_PACKAGE_VERSION', process.env.SCRIPTS_NPM_PACKAGE_VERSION);
8
+
9
+ release(pkgVersion);
@@ -1,39 +1,39 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- /* eslint-disable no-undef */
3
- const HtmlWebpackPlugin = require('html-webpack-plugin');
4
- const CleanWebpackPlugin = require('clean-webpack-plugin');
5
- const { _resolve } = require('./build-helper');
6
-
7
- module.exports = {
8
- entry: {
9
- index: _resolve('../examples/index.ts'),
10
- },
11
- output: {
12
- filename: '[name].js',
13
- path: _resolve('../dist'),
14
- },
15
- devServer: {
16
- contentBase: _resolve('../dist'),
17
- },
18
- module: {
19
- rules: [
20
- {
21
- test: /\.tsx?$/,
22
- use: 'ts-loader',
23
- exclude: /node_modules/,
24
- },
25
- ],
26
- },
27
- plugins: [
28
- new HtmlWebpackPlugin({
29
- filename: _resolve('../dist/index.html'),
30
- template: _resolve('../examples/index.html'),
31
- inject: true,
32
- chunksSortMode: 'dependency'
33
- }),
34
- new CleanWebpackPlugin([_resolve('../dist')]),
35
- ],
36
- resolve: {
37
- extensions: ['.tsx', '.ts', '.js'],
38
- },
39
- };
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ /* eslint-disable no-undef */
3
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
4
+ const CleanWebpackPlugin = require('clean-webpack-plugin');
5
+ const { _resolve } = require('./build-helper');
6
+
7
+ module.exports = {
8
+ entry: {
9
+ index: _resolve('../examples/index.ts'),
10
+ },
11
+ output: {
12
+ filename: '[name].js',
13
+ path: _resolve('../dist'),
14
+ },
15
+ devServer: {
16
+ contentBase: _resolve('../dist'),
17
+ },
18
+ module: {
19
+ rules: [
20
+ {
21
+ test: /\.tsx?$/,
22
+ use: 'ts-loader',
23
+ exclude: /node_modules/,
24
+ },
25
+ ],
26
+ },
27
+ plugins: [
28
+ new HtmlWebpackPlugin({
29
+ filename: _resolve('../dist/index.html'),
30
+ template: _resolve('../examples/index.html'),
31
+ inject: true,
32
+ chunksSortMode: 'dependency'
33
+ }),
34
+ new CleanWebpackPlugin([_resolve('../dist')]),
35
+ ],
36
+ resolve: {
37
+ extensions: ['.tsx', '.ts', '.js'],
38
+ },
39
+ };