cloudcmd 17.3.0 → 17.3.1
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 +5 -0
- package/HELP.md +6 -3
- package/README.md +1 -1
- package/bin/cloudcmd.mjs +2 -2
- package/dist/sw.js +1 -1
- package/dist-dev/sw.js +1 -1
- package/package.json +1 -1
- package/server/cloudcmd.mjs +2 -2
- package/server/distribute/{export.js → export.mjs} +7 -12
- package/server/distribute/{import.js → import.mjs} +10 -12
- package/server/distribute/import.spec.mjs +2 -4
- package/server/distribute/log.mjs +52 -0
- package/server/distribute/log.spec.mjs +34 -0
- package/server/distribute/index.js +0 -4
- package/server/distribute/log.js +0 -41
package/ChangeLog
CHANGED
package/HELP.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Cloud Commander v17.3.
|
|
1
|
+
# Cloud Commander v17.3.1
|
|
2
2
|
|
|
3
3
|
### [Main][MainURL] [Blog][BlogURL] [Support][SupportURL] [Demo][DemoURL]
|
|
4
4
|
|
|
@@ -93,7 +93,8 @@ Cloud Commander supports the following command-line parameters:
|
|
|
93
93
|
| `--terminal-command` | set command to run in terminal (shell by default)
|
|
94
94
|
| `--terminal-auto-restart` | restart command on exit
|
|
95
95
|
| `--vim` | enable vim hot keys
|
|
96
|
-
| `--
|
|
96
|
+
| `--columns` | set visible columns
|
|
97
|
+
| `--theme` | set theme 'light' or 'dark'"
|
|
97
98
|
| `--export` | enable export of config through a server
|
|
98
99
|
| `--export-token` | authorization token used by export server
|
|
99
100
|
| `--import` | enable import of config
|
|
@@ -429,6 +430,7 @@ Some config options can be overridden with environment variables, such as:
|
|
|
429
430
|
- `CLOUDCMD_OPEN` - open web browser when server started
|
|
430
431
|
- `CLOUDCMD_EDITOR` - set editor
|
|
431
432
|
- `CLOUDCMD_COLUMNS` - set visible themes
|
|
433
|
+
- `CLOUDCMD_THEME` - set themes "light" or "dark"
|
|
432
434
|
- `CLOUDCMD_CONTACT` - enable contact
|
|
433
435
|
- `CLOUDCMD_CONFIG_DIALOG` - enable config dialog
|
|
434
436
|
- `CLOUDCMD_CONFIG_AUTH` - enable auth change in config dialog
|
|
@@ -1093,6 +1095,7 @@ There are a lot of ways to be involved in `Cloud Commander` development:
|
|
|
1093
1095
|
|
|
1094
1096
|
## Version history
|
|
1095
1097
|
|
|
1098
|
+
- *2024.03.29*, **[v17.3.1](//github.com/coderaiser/cloudcmd/releases/tag/v17.3.1)**
|
|
1096
1099
|
- *2024.03.29*, **[v17.3.0](//github.com/coderaiser/cloudcmd/releases/tag/v17.3.0)**
|
|
1097
1100
|
- *2024.03.29*, **[v17.2.1](//github.com/coderaiser/cloudcmd/releases/tag/v17.2.1)**
|
|
1098
1101
|
- *2024.03.22*, **[v17.2.0](//github.com/coderaiser/cloudcmd/releases/tag/v17.2.0)**
|
|
@@ -1546,7 +1549,7 @@ There are a lot of ways to be involved in `Cloud Commander` development:
|
|
|
1546
1549
|
|
|
1547
1550
|
## Special Thanks
|
|
1548
1551
|
|
|
1549
|
-
- [Olena Zalitok](
|
|
1552
|
+
- [Olena Zalitok](https://www.linkedin.com/in/ozalitok-ux-ui/ "Olena Zalitok") for **logo** and **favicon**.
|
|
1550
1553
|
- [TarZak](https://github.com/tarzak "TarZak")
|
|
1551
1554
|
- Russian and Ukrainian translations;
|
|
1552
1555
|
- config template and style;
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Cloud Commander v17.3.
|
|
1
|
+
# Cloud Commander v17.3.1 [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Codacy][CodacyIMG]][CodacyURL] [![Gitter][GitterIMGURL]][GitterURL]
|
|
2
2
|
|
|
3
3
|
### [Main][MainURL] [Blog][BlogURL] [Support][SupportURL] [Demo][DemoURL]
|
|
4
4
|
|
package/bin/cloudcmd.mjs
CHANGED
|
@@ -241,8 +241,8 @@ async function main() {
|
|
|
241
241
|
if (args.showConfig)
|
|
242
242
|
await showConfig();
|
|
243
243
|
|
|
244
|
-
const
|
|
245
|
-
const importConfig = promisify(
|
|
244
|
+
const {distributeImport} = await simport('../server/distribute/import.mjs');
|
|
245
|
+
const importConfig = promisify(distributeImport);
|
|
246
246
|
|
|
247
247
|
await start(options, config);
|
|
248
248
|
|
package/dist/sw.js
CHANGED
|
@@ -7,5 +7,5 @@ var serviceWorkerOption = {
|
|
|
7
7
|
]
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/dist/",n(n.s=0)}([function(t,e,n){"use strict";const r=n(1),o=n(2),i=n(3),u="development"===r.env.NODE_ENV,c=i((t,e)=>e.waitUntil(t())),s=i((t,e)=>{const{request:n}=e,{url:r}=n,o=a(r);r.endsWith("/")||/\^\/fs/.test(o)||"GET"===n.method&&(t=>"basic"===t.type)(n)&&(o.startsWith("/api")||/^socket.io/.test(o)||e.respondWith(t(e)))}),a=t=>new URL(t).pathname,f="cloudcmd: Fri Mar 29 2024
|
|
10
|
+
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/dist/",n(n.s=0)}([function(t,e,n){"use strict";const r=n(1),o=n(2),i=n(3),u="development"===r.env.NODE_ENV,c=i((t,e)=>e.waitUntil(t())),s=i((t,e)=>{const{request:n}=e,{url:r}=n,o=a(r);r.endsWith("/")||/\^\/fs/.test(o)||"GET"===n.method&&(t=>"basic"===t.type)(n)&&(o.startsWith("/api")||/^socket.io/.test(o)||e.respondWith(t(e)))}),a=t=>new URL(t).pathname,f="cloudcmd: Fri Mar 29 2024 15:03:06 GMT+0200 (Eastern European Standard Time)",l=(t,e)=>"/"!==t?e:(t=>new Request(t,{credentials:"same-origin"}))("/");self.addEventListener("install",c((async function(){console.info("cloudcmd: sw: install: "+f),await self.skipWaiting()}))),self.addEventListener("fetch",s((async function(t){const{request:e}=t,{url:n}=e,r=a(n),i=l(r,t.request),c=await caches.open(f),s=await c.match(e);if(!u&&s)return s;const[d,h]=await o(fetch,i,{credentials:"same-origin"});return d?new Response(d.message):(await async function(t,e){return(await caches.open(f)).put(t,e)}(e,h.clone()),h)}))),self.addEventListener("activate",c((async function(){console.info("cloudcmd: sw: activate: "+f),await self.clients.claim();const t=await caches.keys(),e=caches.delete.bind(caches);await Promise.all(t.map(e))})))},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function c(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){r=u}}();var s,a=[],f=!1,l=-1;function d(){f&&s&&(f=!1,s.length?a=s.concat(a):l=-1,a.length&&h())}function h(){if(!f){var t=c(d);f=!0;for(var e=a.length;e;){for(s=a,a=[];++l<e;)s&&s[l].run();l=-1,e=a.length}s=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function m(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];a.push(new p(t,e)),1!==a.length||f||c(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,n){"use strict";t.exports=async(t,...e)=>{!function(t){if("function"!=typeof t)throw Error("fn should be a function!")}(t);try{return[null,await t(...e)]}catch(t){return[t]}}},function(t,e,n){"use strict";const r=(t,...e)=>{if(function(t){if("function"!=typeof t)throw Error("fn should be function!")}(t),e.length>=t.length)return t(...e);const n=(...n)=>r(t,...e,...n),o=t.length-e.length-1;return(t=>[function(e){return t(...arguments)},function(e,n){return t(...arguments)},function(e,n,r){return t(...arguments)},function(e,n,r,o){return t(...arguments)},function(e,n,r,o,i){return t(...arguments)}])(n)[o]||n};t.exports=r}]);
|
|
11
11
|
//# sourceMappingURL=sw.js.map
|
package/dist-dev/sw.js
CHANGED
|
@@ -103,7 +103,7 @@ var serviceWorkerOption = {
|
|
|
103
103
|
/***/ (function(module, exports, __webpack_require__) {
|
|
104
104
|
|
|
105
105
|
"use strict";
|
|
106
|
-
eval("\n\nconst process = __webpack_require__(/*! node:process */ \"./node_modules/process/browser.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst isDev = process.env.NODE_ENV === 'development';\nconst isGet = a => a.method === 'GET';\nconst isBasic = a => a.type === 'basic';\nconst wait = currify((f, e) => e.waitUntil(f()));\nconst respondWith = currify((f, e) => {\n const {\n request\n } = e;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n if (url.endsWith('/') || /\\^\\/fs/.test(pathname)) return;\n if (!isGet(request)) return;\n if (!isBasic(request)) return;\n if (pathname.startsWith('/api')) return;\n if (/^socket.io/.test(pathname)) return;\n e.respondWith(f(e));\n});\nconst getPathName = url => new URL(url).pathname;\nconst date = \"Fri Mar 29 2024
|
|
106
|
+
eval("\n\nconst process = __webpack_require__(/*! node:process */ \"./node_modules/process/browser.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst isDev = process.env.NODE_ENV === 'development';\nconst isGet = a => a.method === 'GET';\nconst isBasic = a => a.type === 'basic';\nconst wait = currify((f, e) => e.waitUntil(f()));\nconst respondWith = currify((f, e) => {\n const {\n request\n } = e;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n if (url.endsWith('/') || /\\^\\/fs/.test(pathname)) return;\n if (!isGet(request)) return;\n if (!isBasic(request)) return;\n if (pathname.startsWith('/api')) return;\n if (/^socket.io/.test(pathname)) return;\n e.respondWith(f(e));\n});\nconst getPathName = url => new URL(url).pathname;\nconst date = \"Fri Mar 29 2024 15:03:14 GMT+0200 (Eastern European Standard Time)\";\nconst NAME = `cloudcmd: ${date}`;\nconst createRequest = a => new Request(a, {\n credentials: 'same-origin'\n});\nconst getRequest = (a, request) => {\n if (a !== '/') return request;\n return createRequest('/');\n};\nself.addEventListener('install', wait(onInstall));\nself.addEventListener('fetch', respondWith(onFetch));\nself.addEventListener('activate', wait(onActivate));\nasync function onActivate() {\n console.info(`cloudcmd: sw: activate: ${NAME}`);\n await self.clients.claim();\n const keys = await caches.keys();\n const deleteCache = caches.delete.bind(caches);\n await Promise.all(keys.map(deleteCache));\n}\nasync function onInstall() {\n console.info(`cloudcmd: sw: install: ${NAME}`);\n await self.skipWaiting();\n}\nasync function onFetch(event) {\n const {\n request\n } = event;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n const newRequest = getRequest(pathname, event.request);\n const cache = await caches.open(NAME);\n const response = await cache.match(request);\n if (!isDev && response) return response;\n const [e, resp] = await tryToCatch(fetch, newRequest, {\n credentials: 'same-origin'\n });\n if (e) return new Response(e.message);\n await addToCache(request, resp.clone());\n return resp;\n}\nasync function addToCache(request, response) {\n const cache = await caches.open(NAME);\n return cache.put(request, response);\n}\n\n//# sourceURL=file://cloudcmd/client/sw/sw.js");
|
|
107
107
|
|
|
108
108
|
/***/ }),
|
|
109
109
|
|
package/package.json
CHANGED
package/server/cloudcmd.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import route from './route.mjs';
|
|
|
24
24
|
import * as validate from './validate.mjs';
|
|
25
25
|
import prefixer from './prefixer.js';
|
|
26
26
|
import terminal from './terminal.js';
|
|
27
|
-
import
|
|
27
|
+
import {distributeExport} from './distribute/export.mjs';
|
|
28
28
|
import {createDepStore} from './depstore.js';
|
|
29
29
|
|
|
30
30
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -175,7 +175,7 @@ function listen({prefixSocket, socket, config}) {
|
|
|
175
175
|
autoRestart: config('terminalAutoRestart'),
|
|
176
176
|
});
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
distributeExport(config, socket);
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
function cloudcmdMiddle({modules, config}) {
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const omit = require('object.omit');
|
|
7
|
-
|
|
8
|
-
const log = require('./log');
|
|
9
|
-
|
|
10
|
-
const {
|
|
1
|
+
import currify from 'currify';
|
|
2
|
+
import wraptile from 'wraptile';
|
|
3
|
+
import squad from 'squad';
|
|
4
|
+
import omit from 'object.omit';
|
|
5
|
+
import log, {
|
|
11
6
|
exportStr,
|
|
12
7
|
connectedStr,
|
|
13
8
|
disconnectedStr,
|
|
@@ -16,7 +11,7 @@ const {
|
|
|
16
11
|
getMessage,
|
|
17
12
|
getDescription,
|
|
18
13
|
logWraped,
|
|
19
|
-
}
|
|
14
|
+
} from './log.mjs';
|
|
20
15
|
|
|
21
16
|
const omitList = [
|
|
22
17
|
'auth',
|
|
@@ -38,7 +33,7 @@ const omitList = [
|
|
|
38
33
|
|
|
39
34
|
const omitConfig = (config) => omit(config, omitList);
|
|
40
35
|
|
|
41
|
-
|
|
36
|
+
export const distributeExport = (config, socket) => {
|
|
42
37
|
if (!config('export'))
|
|
43
38
|
return;
|
|
44
39
|
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import currify from 'currify';
|
|
2
|
+
import wraptile from 'wraptile';
|
|
3
|
+
import squad from 'squad';
|
|
4
|
+
import fullstore from 'fullstore';
|
|
5
|
+
import io from 'socket.io-client';
|
|
6
|
+
import log from './log.mjs';
|
|
7
|
+
import env from '../env.js';
|
|
8
|
+
import _forEachKey from 'for-each-key';
|
|
2
9
|
|
|
3
|
-
const currify = require('currify');
|
|
4
|
-
const wraptile = require('wraptile');
|
|
5
|
-
const squad = require('squad');
|
|
6
|
-
const fullstore = require('fullstore');
|
|
7
|
-
|
|
8
|
-
const io = require('socket.io-client');
|
|
9
|
-
const log = require('./log');
|
|
10
|
-
|
|
11
|
-
const env = require('../env');
|
|
12
10
|
const noop = () => {};
|
|
13
|
-
const forEachKey = currify(
|
|
11
|
+
const forEachKey = currify(_forEachKey);
|
|
14
12
|
|
|
15
13
|
const {
|
|
16
14
|
importStr,
|
|
@@ -67,7 +65,7 @@ const updateConfig = currify((config, data) => {
|
|
|
67
65
|
}
|
|
68
66
|
});
|
|
69
67
|
|
|
70
|
-
|
|
68
|
+
export const distributeImport = (config, options, fn) => {
|
|
71
69
|
fn = fn || options;
|
|
72
70
|
|
|
73
71
|
if (!config('import'))
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {createRequire} from 'node:module';
|
|
2
1
|
import process from 'node:process';
|
|
3
2
|
import test from 'supertape';
|
|
4
3
|
import {promisify} from 'node:util';
|
|
5
4
|
import tryToCatch from 'try-to-catch';
|
|
6
5
|
import {connect} from '../../test/before.mjs';
|
|
7
6
|
import {createConfigManager} from '../cloudcmd.mjs';
|
|
8
|
-
|
|
9
|
-
const require = createRequire(import.meta.url);
|
|
7
|
+
import {distributeImport} from './import.mjs';
|
|
10
8
|
|
|
11
9
|
const distribute = {
|
|
12
|
-
import: promisify(
|
|
10
|
+
import: promisify(distributeImport),
|
|
13
11
|
};
|
|
14
12
|
|
|
15
13
|
const config = createConfigManager();
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import wraptile from 'wraptile';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import datetime from '../../common/datetime.js';
|
|
4
|
+
|
|
5
|
+
const {assign} = Object;
|
|
6
|
+
|
|
7
|
+
const log = (isLog, name, msg) => isLog && console.log(`${datetime()} -> ${name}: ${msg}`);
|
|
8
|
+
|
|
9
|
+
export const makeColor = (a) => chalk.blue(a);
|
|
10
|
+
export const getMessage = (e) => e.message || e;
|
|
11
|
+
export const getDescription = (e) => e.message;
|
|
12
|
+
|
|
13
|
+
export default log;
|
|
14
|
+
|
|
15
|
+
export const logWraped = wraptile(log);
|
|
16
|
+
|
|
17
|
+
export const importStr = 'import';
|
|
18
|
+
export const exportStr = 'export';
|
|
19
|
+
export const connectedStr = chalk.green('connected');
|
|
20
|
+
export const disconnectedStr = chalk.red('disconnected');
|
|
21
|
+
export const tokenRejectedStr = chalk.red('token rejected');
|
|
22
|
+
export const authTryStr = chalk.yellow('try to auth');
|
|
23
|
+
|
|
24
|
+
export function stringToRGB(a) {
|
|
25
|
+
return [
|
|
26
|
+
a.charCodeAt(0),
|
|
27
|
+
a.length,
|
|
28
|
+
crc(a),
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const add = (a, b) => a + b.charCodeAt(0);
|
|
33
|
+
|
|
34
|
+
function crc(a) {
|
|
35
|
+
return a
|
|
36
|
+
.split('')
|
|
37
|
+
.reduce(add, 0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
assign(log, {
|
|
41
|
+
getMessage,
|
|
42
|
+
makeColor,
|
|
43
|
+
getDescription,
|
|
44
|
+
authTryStr,
|
|
45
|
+
stringToRGB,
|
|
46
|
+
logWraped,
|
|
47
|
+
importStr,
|
|
48
|
+
exportStr,
|
|
49
|
+
connectedStr,
|
|
50
|
+
disconnectedStr,
|
|
51
|
+
tokenRejectedStr,
|
|
52
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import test from 'supertape';
|
|
2
|
+
import log from './log.mjs';
|
|
3
|
+
import {createConfig} from '../config.js';
|
|
4
|
+
|
|
5
|
+
test('distribute: log: getMessage', (t) => {
|
|
6
|
+
const e = 'hello';
|
|
7
|
+
const result = log.getMessage(e);
|
|
8
|
+
|
|
9
|
+
t.equal(e, result);
|
|
10
|
+
t.end();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('distribute: log: getMessage: message', (t) => {
|
|
14
|
+
const message = 'hello';
|
|
15
|
+
const result = log.getMessage({
|
|
16
|
+
message,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
t.equal(result, message);
|
|
20
|
+
t.end();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('distribute: log: config', (t) => {
|
|
24
|
+
const config = createConfig();
|
|
25
|
+
const logOriginal = config('log');
|
|
26
|
+
|
|
27
|
+
config('log', true);
|
|
28
|
+
log('log', 'test message');
|
|
29
|
+
config('log', logOriginal);
|
|
30
|
+
|
|
31
|
+
t.end();
|
|
32
|
+
}, {
|
|
33
|
+
checkAssertionsCount: false,
|
|
34
|
+
});
|
package/server/distribute/log.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const wraptile = require('wraptile');
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
|
|
6
|
-
const datetime = require('../../common/datetime');
|
|
7
|
-
|
|
8
|
-
const log = (isLog, name, msg) => isLog && console.log(`${datetime()} -> ${name}: ${msg}`);
|
|
9
|
-
const makeColor = (a) => chalk.blue(a);
|
|
10
|
-
const getMessage = (e) => e.message || e;
|
|
11
|
-
const getDescription = (e) => e.message;
|
|
12
|
-
|
|
13
|
-
module.exports = log;
|
|
14
|
-
module.exports.logWraped = wraptile(log);
|
|
15
|
-
module.exports.stringToRGB = stringToRGB;
|
|
16
|
-
module.exports.makeColor = makeColor;
|
|
17
|
-
module.exports.getMessage = getMessage;
|
|
18
|
-
module.exports.getDescription = getDescription;
|
|
19
|
-
|
|
20
|
-
module.exports.importStr = 'import';
|
|
21
|
-
module.exports.exportStr = 'export';
|
|
22
|
-
module.exports.connectedStr = chalk.green('connected');
|
|
23
|
-
module.exports.disconnectedStr = chalk.red('disconnected');
|
|
24
|
-
module.exports.tokenRejectedStr = chalk.red('token rejected');
|
|
25
|
-
module.exports.authTryStr = chalk.yellow('try to auth');
|
|
26
|
-
|
|
27
|
-
function stringToRGB(a) {
|
|
28
|
-
return [
|
|
29
|
-
a.charCodeAt(0),
|
|
30
|
-
a.length,
|
|
31
|
-
crc(a),
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const add = (a, b) => a + b.charCodeAt(0);
|
|
36
|
-
|
|
37
|
-
function crc(a) {
|
|
38
|
-
return a
|
|
39
|
-
.split('')
|
|
40
|
-
.reduce(add, 0);
|
|
41
|
-
}
|