mazey 3.3.4 → 3.3.6

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,108 +1,110 @@
1
- {
2
- "name": "mazey",
3
- "version": "3.3.4",
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 webpack.config.dev.js --open",
14
- "build": "rollup -c",
15
- "test": "jest",
16
- "docs": "typedoc",
17
- "lint-and-fix": "eslint ./src/index.ts --ext 'ts,tsx' --fix",
18
- "preview": "npm run build && npm run test && npm run docs",
19
- "release": "npm run preview && npm publish && 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
- "eslint": "^6.8.0",
73
- "eslint-config-standard": "^14.1.0",
74
- "eslint-plugin-import": "^2.20.1",
75
- "eslint-plugin-node": "^11.0.0",
76
- "eslint-plugin-promise": "^4.2.1",
77
- "eslint-plugin-standard": "^4.0.1",
78
- "execa": "^4.1.0",
79
- "html-webpack-plugin": "^3.2.0",
80
- "husky": "^4.3.8",
81
- "jest": "^27.5.1",
82
- "lint-staged": "^10.0.8",
83
- "prettier": "^1.19.1",
84
- "prettier-eslint-cli": "^5.0.0",
85
- "rollup": "^1.31.1",
86
- "rollup-plugin-babel": "^4.3.3",
87
- "rollup-plugin-cleaner": "^1.0.0",
88
- "rollup-plugin-commonjs": "^10.1.0",
89
- "rollup-plugin-terser": "^7.0.2",
90
- "rollup-plugin-typescript2": "^0.27.2",
91
- "ts-loader": "^8.0.2",
92
- "typedoc": "^0.18.0",
93
- "typescript": "^3.9.7",
94
- "webpack": "^4.30.0",
95
- "webpack-cli": "^3.3.2",
96
- "webpack-dev-server": "^3.10.3"
97
- },
98
- "husky": {
99
- "hooks": {
100
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
101
- "pre-commit": "lint-staged"
102
- }
103
- },
104
- "dependencies": {
105
- "@babel/runtime-corejs3": "^7.11.2",
106
- "core-js": "^3.6.5"
107
- }
108
- }
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
+ }
@@ -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,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,40 +1,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
- const releaseVersion = `v${ver}`;
18
- const { stdout: releaseStdout } = await execa('echo', [`Start release ${releaseVersion}...`]);
19
- console.log(releaseStdout);
20
- // Commit Stdout
21
- const { stdout: diffStdout } = await execa('git', ['diff'], { stdio: 'pipe' });
22
- if (diffStdout) {
23
- console.log('Committing changes...');
24
- await execa('git', ['add', '-A']);
25
- await execa('git', ['commit', '-m', `release: ${releaseVersion}`]);
26
- } else {
27
- console.log('No changes to commit.');
28
- }
29
- // Push
30
- console.log('Pushing to GitHub...');
31
- await execa('git', ['tag', '-a', `${releaseVersion}`, '-m', `Release ${releaseVersion}`]);
32
- await execa('git', ['push', 'origin', `refs/tags/${releaseVersion}`]);
33
- await execa('git', ['push']);
34
-
35
- console.log('All done.');
36
- }
37
-
38
- module.exports = {
39
- release,
40
- };
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,7 +1,7 @@
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.VERSION || require('../package.json').version;
6
+
7
+ release(pkgVersion);
@@ -1,39 +1,39 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- /* eslint-disable no-undef */
3
- const path = require('path');
4
- const HtmlWebpackPlugin = require('html-webpack-plugin');
5
- const CleanWebpackPlugin = require('clean-webpack-plugin');
6
-
7
- module.exports = {
8
- entry: {
9
- index: './examples/index.ts'
10
- },
11
- output: {
12
- filename: '[name].js',
13
- path: path.resolve(__dirname, 'dist')
14
- },
15
- devServer: {
16
- contentBase: './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: path.resolve(__dirname, 'dist/index.html'),
30
- template: path.resolve(__dirname, 'examples/index.html'),
31
- inject: true,
32
- chunksSortMode: 'dependency'
33
- }),
34
- new CleanWebpackPlugin(['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
+ };