@merkur/tools 0.26.0 โ†’ 0.28.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,53 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.28.0](https://github.com/mjancarik/merkur/compare/v0.27.6...v0.28.0) (2022-04-20)
7
+
8
+
9
+ ### Code Refactoring
10
+
11
+ * ๐Ÿ’ก move liveReloadServer to merkur/tools ([f81e0e8](https://github.com/mjancarik/merkur/commit/f81e0e89eff4a72985c89d23079be6a9344a3b2e))
12
+
13
+
14
+ ### BREAKING CHANGES
15
+
16
+ * ๐Ÿงจ The liveReloadServer.cjs file is moved to @merkur/tools. The
17
+ @merkur/tool-webpack re-export createLiveReloadServer for keeping
18
+ backward compatability.
19
+
20
+
21
+
22
+
23
+
24
+ ## [0.27.1](https://github.com/mjancarik/merkur/compare/v0.27.0...v0.27.1) (2021-09-30)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * ๐Ÿ› Removed unused @merkur/tools pkg dependencies ([#109](https://github.com/mjancarik/merkur/issues/109)) ([c1a28b0](https://github.com/mjancarik/merkur/commit/c1a28b00f1b9510eeab897ab0232f59a0f6a3c0f))
30
+
31
+
32
+
33
+
34
+
35
+ # [0.27.0](https://github.com/mjancarik/merkur/compare/v0.26.1...v0.27.0) (2021-09-29)
36
+
37
+
38
+ ### Features
39
+
40
+ * ๐ŸŽธ Added eslint plugin import and eslint react-hooks plugi ([#108](https://github.com/mjancarik/merkur/issues/108)) ([db8ca75](https://github.com/mjancarik/merkur/commit/db8ca75e701f1e9d57dc55c3a3a5e1fb7cfc4787))
41
+ * ๐ŸŽธ Automatically generate free port for livereload server ([#101](https://github.com/mjancarik/merkur/issues/101)) ([a083a1b](https://github.com/mjancarik/merkur/commit/a083a1b31edc818a2d94e000a78cbb03cc8dc022))
42
+
43
+
44
+ ### BREAKING CHANGES
45
+
46
+ * ๐Ÿงจ createLiveReloadServer() function must be promise chained in
47
+ webpack.config.js before returning any config array.
48
+
49
+
50
+
51
+
52
+
6
53
  # [0.26.0](https://github.com/mjancarik/merkur/compare/v0.25.0...v0.26.0) (2021-08-27)
7
54
 
8
55
 
package/eslint.config.js CHANGED
@@ -1,25 +1,72 @@
1
1
  module.exports = {
2
2
  root: true,
3
- extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier'],
3
+ extends: [
4
+ 'eslint:recommended',
5
+ 'plugin:react/recommended',
6
+ 'plugin:react-hooks/recommended',
7
+ 'plugin:import/recommended',
8
+ 'prettier',
9
+ ],
4
10
  rules: {
11
+ 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
5
12
  'prettier/prettier': [
6
13
  'error',
7
14
  {
8
15
  singleQuote: true,
9
- jsxBracketSameLine: true,
16
+ jsxSingleQuote: true,
17
+ jsxBracketSameLine: false,
10
18
  },
11
19
  ],
12
-
13
20
  'no-console': [
14
21
  'error',
15
22
  {
16
23
  allow: ['warn', 'error'],
17
24
  },
18
25
  ],
19
-
20
26
  'react/prop-types': 0,
21
27
  'react/wrap-multilines': 0,
22
28
  'react/no-deprecated': 0,
29
+ 'react/jsx-uses-react': 'off',
30
+ 'react/react-in-jsx-scope': 'off',
31
+ 'react/jsx-fragments': 'off',
32
+ 'react/jsx-no-undef': 'off',
33
+ 'import/first': ['error'],
34
+ 'import/no-unresolved': 'off',
35
+ 'import/order': [
36
+ 'error',
37
+ {
38
+ groups: ['builtin', 'external', 'internal'],
39
+ pathGroups: [
40
+ {
41
+ pattern: '{preact|react|svelte}{/**,**}',
42
+ group: 'external',
43
+ position: 'before',
44
+ },
45
+ {
46
+ pattern: '@merkur{/**,**}',
47
+ group: 'external',
48
+ position: 'after',
49
+ },
50
+ {
51
+ pattern: '#/**',
52
+ group: 'internal',
53
+ position: 'after',
54
+ },
55
+ {
56
+ pattern: '*.{css,less,json}',
57
+ group: 'object',
58
+ patternOptions: { matchBase: true },
59
+ position: 'after',
60
+ },
61
+ ],
62
+ pathGroupsExcludedImportTypes: ['#/', '@merkur'],
63
+ 'newlines-between': 'always',
64
+ alphabetize: {
65
+ order: 'asc',
66
+ caseInsensitive: true,
67
+ },
68
+ },
69
+ ],
23
70
  },
24
71
  plugins: ['prettier', 'jest', 'react', 'jasmine'],
25
72
  settings: {
@@ -28,6 +75,10 @@ module.exports = {
28
75
  react: {
29
76
  version: '16',
30
77
  },
78
+ 'import/ignore': [
79
+ 'node_modules',
80
+ '\\.(coffee|scss|css|less|hbs|svg|json)$',
81
+ ],
31
82
  },
32
83
  parserOptions: {
33
84
  sourceType: 'module',
@@ -0,0 +1,20 @@
1
+ const fp = require('find-free-port');
2
+ const WebSocket = require('./websocket.cjs');
3
+
4
+ async function createLiveReloadServer() {
5
+ if (process.env.NODE_ENV === 'development') {
6
+ try {
7
+ const [freePort] = await fp(4321);
8
+ process.env.MERKUR_PLAYGROUND_LIVERELOAD_PORT = freePort;
9
+
10
+ WebSocket.createServer({
11
+ port: freePort,
12
+ });
13
+ } catch (error) {
14
+ console.error(error);
15
+ throw new Error('Unable to retrieve free port for livereload server.');
16
+ }
17
+ }
18
+ }
19
+
20
+ module.exports = { createLiveReloadServer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkur/tools",
3
- "version": "0.26.0",
3
+ "version": "0.28.0",
4
4
  "description": "Merkur tools.",
5
5
  "bin": {
6
6
  "merkur-tools": "./bin/merkurTools.js"
@@ -30,38 +30,30 @@
30
30
  },
31
31
  "homepage": "https://merkur.js.org/",
32
32
  "dependencies": {
33
- "@babel/core": "7.15.0",
34
- "@babel/eslint-parser": "7.15.0",
35
- "@babel/preset-env": "7.15.0",
36
- "babel-jest": "27.0.6",
37
- "babel-loader": "8.2.2",
38
- "clean-webpack-plugin": "^3.0.0",
39
- "compression-webpack-plugin": "^8.0.1",
40
- "core-js": "3.16.2",
41
- "css-loader": "6.2.0",
42
- "eslint": "7.32.0",
33
+ "@babel/core": "7.17.9",
34
+ "@babel/eslint-parser": "7.17.0",
35
+ "@babel/preset-env": "7.16.11",
36
+ "babel-jest": "27.5.1",
37
+ "core-js": "3.22.0",
38
+ "eslint": "8.13.0",
43
39
  "eslint-config-last": "0.0.5",
44
- "eslint-config-prettier": "8.3.0",
45
- "eslint-plugin-jasmine": "4.1.2",
46
- "eslint-plugin-jest": "24.4.0",
47
- "eslint-plugin-prettier": "3.4.0",
48
- "eslint-plugin-react": "7.24.0",
49
- "jest": "27.0.6",
50
- "jest-watch-typeahead": "^0.6.4",
51
- "json-loader": "0.5.7",
52
- "mini-css-extract-plugin": "2.2.0",
53
- "prettier": "2.3.2",
54
- "supertest": "6.1.6",
55
- "webpack-bundle-analyzer": "^4.4.2",
56
- "webpack-manifest-plugin": "4.0.2",
57
- "webpack-modules": "1.0.0",
58
- "webpack-node-externals": "3.0.0",
59
- "webpack-shell-plugin-next": "^2.2.2",
60
- "ws": "8.2.0",
61
- "yargs": "17.1.1"
40
+ "eslint-config-prettier": "8.5.0",
41
+ "eslint-plugin-import": "^2.26.0",
42
+ "eslint-plugin-jasmine": "4.1.3",
43
+ "eslint-plugin-jest": "26.1.4",
44
+ "eslint-plugin-prettier": "4.0.0",
45
+ "eslint-plugin-react": "7.29.4",
46
+ "eslint-plugin-react-hooks": "^4.4.0",
47
+ "find-free-port": "^2.0.0",
48
+ "jest": "27.5.1",
49
+ "jest-watch-typeahead": "^1.0.0",
50
+ "prettier": "2.6.2",
51
+ "supertest": "6.2.2",
52
+ "ws": "8.5.0",
53
+ "yargs": "17.4.1"
62
54
  },
63
55
  "peerDependencies": {
64
56
  "express": "*"
65
57
  },
66
- "gitHead": "be0e958eb5be85eb9d8aefc1110ef4fede9e9df0"
58
+ "gitHead": "8760a1cedbbfc37348055418bacbfc69199a3c06"
67
59
  }
@@ -20,7 +20,7 @@ class WebSocketMerkur {
20
20
  /**
21
21
  * @type {Object}
22
22
  */
23
- this._options = Object.assign({ url: 'ws://localhost:4321' }, options);
23
+ this._options = Object.assign({}, options);
24
24
  }
25
25
 
26
26
  init() {
@@ -124,6 +124,8 @@ class WebSocketMerkur {
124
124
  }
125
125
 
126
126
  window.__merkur_dev__ = window.__merkur_dev__ || {};
127
+ window.__merkur_dev__.webSocketOptions =
128
+ window.__merkur_dev__.webSocketOptions || {};
127
129
  window.__merkur_dev__.webSocket = new WebSocketMerkur(
128
130
  window.__merkur_dev__.webSocketOptions
129
131
  )
package/websocket.cjs CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  const WebSocket = require('ws');
4
4
 
5
- const DEFAULT_OPTIONS = {
6
- port: 4321,
7
- };
8
-
9
5
  function broadcastMessage(server, fromClient, data) {
10
6
  server.clients.forEach(function each(toClient) {
11
7
  sendMessage(fromClient, toClient, data);
@@ -19,12 +15,16 @@ function sendMessage(fromClient, toClient, data) {
19
15
  }
20
16
 
21
17
  function createServer(options = {}) {
22
- options = Object.assign({}, DEFAULT_OPTIONS, options);
18
+ options = Object.assign(
19
+ {},
20
+ { port: process.env.MERKUR_PLAYGROUND_LIVERELOAD_PORT },
21
+ options
22
+ );
23
+
23
24
  let server = null;
24
25
 
25
26
  try {
26
27
  server = new WebSocket.Server(options);
27
-
28
28
  server.on('connection', function connection(ws) {
29
29
  ws.on('message', function incoming(data, isBinary) {
30
30
  data = isBinary ? data : data.toString();
@@ -39,14 +39,16 @@ function createServer(options = {}) {
39
39
  }
40
40
 
41
41
  function createClient(options) {
42
- options = Object.assign({}, DEFAULT_OPTIONS, options);
43
- const client = new WebSocket('ws://localhost:' + options.port);
42
+ options = Object.assign(
43
+ {},
44
+ { port: process.env.MERKUR_PLAYGROUND_LIVERELOAD_PORT },
45
+ options
46
+ );
44
47
 
45
- return client;
48
+ return new WebSocket('ws://localhost:' + options.port);
46
49
  }
47
50
 
48
51
  module.exports = {
49
- DEFAULT_OPTIONS,
50
52
  createServer,
51
53
  createClient,
52
54
  };