diff --git a/.webpack/js.js b/.webpack/js.js index f828becd..18d14262 100644 --- a/.webpack/js.js +++ b/.webpack/js.js @@ -74,26 +74,26 @@ module.exports = { }, entry: { cloudcmd: `${dir}/cloudcmd.js`, - [modules + '/edit']: `${dirModules}/edit.js`, - [modules + '/edit-file']: `${dirModules}/edit-file.js`, - [modules + '/edit-file-vim']: `${dirModules}/edit-file-vim.js`, - [modules + '/edit-names']: `${dirModules}/edit-names.js`, - [modules + '/edit-names-vim']: `${dirModules}/edit-names-vim.js`, - [modules + '/menu']: `${dirModules}/menu.js`, - [modules + '/view']: `${dirModules}/view/index.js`, - [modules + '/help']: `${dirModules}/help.js`, - [modules + '/markdown']: `${dirModules}/markdown.js`, - [modules + '/config']: `${dirModules}/config/index.js`, - [modules + '/contact']: `${dirModules}/contact.js`, - [modules + '/upload']: `${dirModules}/upload.js`, - [modules + '/operation']: `${dirModules}/operation/index.js`, - [modules + '/konsole']: `${dirModules}/konsole.js`, - [modules + '/terminal']: `${dirModules}/terminal.js`, - [modules + '/terminal-run']: `${dirModules}/terminal-run.js`, - [modules + '/cloud']: `${dirModules}/cloud.js`, - [modules + '/user-menu']: `${dirModules}/user-menu/index.js`, - [modules + '/polyfill']: `${dirModules}/polyfill.js`, - [modules + '/command-line']: `${dirModules}/command-line.js`, + [`${modules}/edit`]: `${dirModules}/edit.js`, + [`${modules}/edit-file`]: `${dirModules}/edit-file.js`, + [`${modules}/edit-file-vim`]: `${dirModules}/edit-file-vim.js`, + [`${modules}/edit-names`]: `${dirModules}/edit-names.js`, + [`${modules}/edit-names-vim`]: `${dirModules}/edit-names-vim.js`, + [`${modules}/menu`]: `${dirModules}/menu.js`, + [`${modules}/view`]: `${dirModules}/view/index.js`, + [`${modules}/help`]: `${dirModules}/help.js`, + [`${modules}/markdown`]: `${dirModules}/markdown.js`, + [`${modules}/config`]: `${dirModules}/config/index.js`, + [`${modules}/contact`]: `${dirModules}/contact.js`, + [`${modules}/upload`]: `${dirModules}/upload.js`, + [`${modules}/operation`]: `${dirModules}/operation/index.js`, + [`${modules}/konsole`]: `${dirModules}/konsole.js`, + [`${modules}/terminal`]: `${dirModules}/terminal.js`, + [`${modules}/terminal-run`]: `${dirModules}/terminal-run.js`, + [`${modules}/cloud`]: `${dirModules}/cloud.js`, + [`${modules}/user-menu`]: `${dirModules}/user-menu/index.js`, + [`${modules}/polyfill`]: `${dirModules}/polyfill.js`, + [`${modules}/command-line`]: `${dirModules}/command-line.js`, }, output: { filename: '[name].js', diff --git a/bin/cloudcmd.mjs b/bin/cloudcmd.mjs index 301e01dc..387f2fa1 100755 --- a/bin/cloudcmd.mjs +++ b/bin/cloudcmd.mjs @@ -250,7 +250,7 @@ async function main() { } async function validateRoot(root, config) { - const validate = await simport(DIR_SERVER + 'validate.js'); + const validate = await simport(`${DIR_SERVER}validate.js`); validate.root(root, config); if (root === '/') @@ -269,7 +269,7 @@ function version() { } async function start(options, config) { - const SERVER = DIR_SERVER + 'server.mjs'; + const SERVER = `${DIR_SERVER}server.mjs`; if (!args.server) return; @@ -326,7 +326,7 @@ async function help() { function repl() { console.log('REPL mode enabled (telnet localhost 1337)'); - require(DIR_SERVER + 'repl'); + require(`${DIR_SERVER}repl`); } async function checkUpdate() { @@ -342,7 +342,7 @@ async function showUpdateInfo(version) { const chalk = await simport('chalk'); - const latestVersion = chalk.green.bold('v' + version); + const latestVersion = chalk.green.bold(`v${version}`); const latest = `update available: ${latestVersion}`; const current = chalk.dim(`(current: v${Info.version})`); diff --git a/bin/release.mjs b/bin/release.mjs index d484991c..bceb2c9f 100755 --- a/bin/release.mjs +++ b/bin/release.mjs @@ -47,7 +47,7 @@ async function replaceVersion(name, version, versionNew) { if (error) return console.error(error); - console.log('done: ' + name); + console.log(`done: ${name}`); } async function cl() { diff --git a/client/client.js b/client/client.js index a0ca9bf8..6f909207 100644 --- a/client/client.js +++ b/client/client.js @@ -141,7 +141,7 @@ function CloudCmdProto(DOM) { async function loadStyle() { const {prefix} = CloudCmd; - const name = prefix + '/dist/cloudcmd.common.css'; + const name = `${prefix}/dist/cloudcmd.common.css`; await load.css(name); } @@ -303,7 +303,7 @@ function CloudCmdProto(DOM) { async function ajaxLoad(path, options = {}, panel) { const {RESTful} = DOM; - CloudCmd.log('reading dir: "' + path + '";'); + CloudCmd.log(`reading dir: "${path}";`); const dirStorage = CloudCmd.config('dirStorage'); const json = dirStorage && await Storage.getJson(path); diff --git a/client/dom/current-file.js b/client/dom/current-file.js index da52d748..917de0a0 100644 --- a/client/dom/current-file.js +++ b/client/dom/current-file.js @@ -115,7 +115,7 @@ module.exports.getCurrentDirName = () => { .replace(/\/$/, ''); const substr = href.substr(href, href.lastIndexOf('/')); - const ret = href.replace(substr + '/', '') || '/'; + const ret = href.replace(`${substr}/`, '') || '/'; return ret; }; diff --git a/client/dom/directory.js b/client/dom/directory.js index e9e3d722..8579b930 100644 --- a/client/dom/directory.js +++ b/client/dom/directory.js @@ -72,6 +72,6 @@ function uploadFile(url, data) { } function uploadDir(url) { - return DOM.load.put(url + '?dir'); + return DOM.load.put(`${url}?dir`); } diff --git a/client/dom/dom-tree.js b/client/dom/dom-tree.js index 2927f97e..ffd6f5e2 100644 --- a/client/dom/dom-tree.js +++ b/client/dom/dom-tree.js @@ -41,7 +41,7 @@ module.exports.getByTag = (tag, element = document) => { * @param Id - id */ module.exports.getById = (id, element = document) => { - return element.querySelector('#' + id); + return element.querySelector(`#${id}`); }; /** diff --git a/client/dom/events/index.js b/client/dom/events/index.js index 85c24a3d..307768c3 100644 --- a/client/dom/events/index.js +++ b/client/dom/events/index.js @@ -33,7 +33,7 @@ function EventsProto() { switch(type) { default: if (!type.endsWith('element')) - throw Error('unknown eventName: ' + type); + throw Error(`unknown eventName: ${type}`); parseArgs( args[EVENT_NAME], diff --git a/client/dom/files.js b/client/dom/files.js index 6d9627d4..9fac8ee1 100644 --- a/client/dom/files.js +++ b/client/dom/files.js @@ -13,7 +13,7 @@ const FILES_JSON = 'config|modules'; const FILES_HTML = 'file|path|link|pathLink|media'; const FILES_HTML_ROOT = 'view/media-tmpl|config-tmpl|upload'; const DIR_HTML = '/tmpl/'; -const DIR_HTML_FS = DIR_HTML + 'fs/'; +const DIR_HTML_FS = `${DIR_HTML}fs/`; const DIR_JSON = '/json/'; const timeout = getTimeoutOnce(2000); @@ -72,7 +72,7 @@ function getPath(name, isHTML, isJSON) { } function showError(name) { - const str = 'Wrong file name: ' + name; + const str = `Wrong file name: ${name}`; const error = Error(str); throw error; diff --git a/client/dom/images.js b/client/dom/images.js index ac3592f2..8c597ea3 100644 --- a/client/dom/images.js +++ b/client/dom/images.js @@ -127,7 +127,7 @@ module.exports.setProgress = (value, title) => { if (!element) return Images; - element.setAttribute(DATA, value + '%'); + element.setAttribute(DATA, `${value}%`); if (title) element.title = title; diff --git a/client/dom/index.js b/client/dom/index.js index 42424d16..54a2839e 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -79,7 +79,7 @@ module.exports.promptNewFile = async () => { async function promptNew(typeName) { const {Dialog} = DOM; const dir = DOM.getCurrentDirPath(); - const msg = 'New ' + typeName || 'File'; + const msg = `New ${typeName}` || 'File'; const getName = () => { const name = DOM.getCurrentName(); @@ -115,7 +115,7 @@ module.exports.getCurrentDirName = () => { .replace(/\/$/, ''); const substr = href.substr(href, href.lastIndexOf('/')); - const ret = href.replace(substr + '/', '') || '/'; + const ret = href.replace(`${substr}/`, '') || '/'; return ret; }; @@ -457,7 +457,7 @@ module.exports.getFilenames = (files) => { * check storage hash */ module.exports.checkStorageHash = async (name) => { - const nameHash = name + '-hash'; + const nameHash = `${name}-hash`; if (typeof name !== 'string') throw Error('name should be a string!'); @@ -486,8 +486,8 @@ module.exports.saveDataToStorage = async (name, data, hash) => { hash = hash || await DOM.loadCurrentHash(); - const nameHash = name + '-hash'; - const nameData = name + '-data'; + const nameHash = `${name}-hash`; + const nameData = `${name}-data`; await Storage.set(nameHash, hash); await Storage.set(nameData, data); diff --git a/client/dom/io/index.js b/client/dom/io/index.js index 1219631a..79944724 100644 --- a/client/dom/io/index.js +++ b/client/dom/io/index.js @@ -133,7 +133,7 @@ module.exports.Markdown = { read: async (url) => { return await sendRequest({ method: 'GET', - url: '/markdown' + url, + url: `/markdown${url}`, imgPosition, notLog: true, }); diff --git a/client/key/set-current-by-char.js b/client/key/set-current-by-char.js index 5ab4599a..c74876a4 100644 --- a/client/key/set-current-by-char.js +++ b/client/key/set-current-by-char.js @@ -12,7 +12,7 @@ module.exports = function setCurrentByChar(char, charStore) { let i = 0; const escapeChar = escapeRegExp(char); - const regExp = new RegExp('^' + escapeChar + '.*$', 'i'); + const regExp = new RegExp(`^${escapeChar}.*$`, 'i'); const {files} = Info; const chars = charStore(); const n = chars.length; diff --git a/client/key/vim/find.spec.js b/client/key/vim/find.spec.js index 6dbe073d..3e3d6d3e 100644 --- a/client/key/vim/find.spec.js +++ b/client/key/vim/find.spec.js @@ -10,7 +10,7 @@ global.DOM = getDOM(); const { _next, _previous, -} = require(dir + 'find'); +} = require(`${dir}find`); test('cloudcmd: client: vim: _next', (t) => { const result = _next(1, 2); diff --git a/client/key/vim/index.spec.js b/client/key/vim/index.spec.js index 3d26e6c8..a28badcc 100644 --- a/client/key/vim/index.spec.js +++ b/client/key/vim/index.spec.js @@ -462,7 +462,7 @@ test('cloudcmd: client: key: N', (t) => { findPrevious, }); - const vim = reRequire(dir + 'vim'); + const vim = reRequire(`${dir}vim`); const event = {}; vim('N', event); diff --git a/client/listeners/index.js b/client/listeners/index.js index d923c3ed..054b3f7e 100644 --- a/client/listeners/index.js +++ b/client/listeners/index.js @@ -147,7 +147,7 @@ const getPanel = (side) => { if (!itype.string(side)) return side; - return DOM.getByDataName('js-' + side); + return DOM.getByDataName(`js-${side}`); }; module.exports.setOnPanel = (side) => { diff --git a/client/modules/config/index.js b/client/modules/config/index.js index 130cd183..bf72c661 100644 --- a/client/modules/config/index.js +++ b/client/modules/config/index.js @@ -57,7 +57,7 @@ module.exports.init = async () => { [Template] = await Promise.all([ Files.get('config-tmpl'), loadSocket(), - loadCSS(prefix + '/dist/config.css'), + loadCSS(`${prefix}/dist/config.css`), CloudCmd.View(), ]); @@ -94,7 +94,7 @@ function initSocket() { const socket = io.connect(href + prefixSocket + '/config', { reconnectionAttempts: Infinity, reconnectionDelay: ONE_MINUTE, - path: prefix + '/socket.io', + path: `${prefix}/socket.io`, }); const save = (data) => { @@ -148,9 +148,9 @@ async function fillTemplate() { ...obj } = input.convert(config); - obj[editor + '-selected'] = 'selected'; - obj[packer + '-selected'] = 'selected'; - obj[columns + '-selected'] = 'selected'; + obj[`${editor}-selected`] = 'selected'; + obj[`${packer}-selected`] = 'selected'; + obj[`${columns}-selected`] = 'selected'; obj.configAuth = configAuth ? '' : 'hidden'; const innerHTML = rendy(Template, obj); diff --git a/client/modules/edit-file.js b/client/modules/edit-file.js index e34e7345..32616edb 100644 --- a/client/modules/edit-file.js +++ b/client/modules/edit-file.js @@ -177,7 +177,7 @@ function getMenuData() { } function setMsgChanged(name) { - MSG_CHANGED = 'Do you want to save changes to ' + name + '?'; + MSG_CHANGED = `Do you want to save changes to ${name}?`; } module.exports.isChanged = isChanged; diff --git a/client/modules/edit.js b/client/modules/edit.js index 289a7bd8..1cdcb205 100644 --- a/client/modules/edit.js +++ b/client/modules/edit.js @@ -52,7 +52,7 @@ function create() { function checkFn(name, fn) { if (typeof fn !== 'function') - throw Error(name + ' should be a function!'); + throw Error(`${name} should be a function!`); } function initConfig(options = {}) { @@ -104,7 +104,7 @@ const loadFiles = async (element) => { const prefixSocket = `${CloudCmd.prefixSocket}/${EditorName}`; const url = `${prefix}/${EditorName}.js`; - time(Name + ' load'); + time(`${Name} load`); await loadJS(url); @@ -116,7 +116,7 @@ const loadFiles = async (element) => { socketPath, }); - timeEnd(Name + ' load'); + timeEnd(`${Name} load`); editor = ed; Loading = false; }; diff --git a/client/modules/konsole.js b/client/modules/konsole.js index e52e5910..5c2ade00 100644 --- a/client/modules/konsole.js +++ b/client/modules/konsole.js @@ -133,14 +133,14 @@ module.exports.show = (callback) => { }; const load = async () => { - Util.time(Name + ' load'); + Util.time(`${Name} load`); const prefix = getPrefix(); - const url = prefix + '/console.js'; + const url = `${prefix}/console.js`; const [error] = await tryToCatch(loadJS, url); Loaded = true; - Util.timeEnd(Name + ' load'); + Util.timeEnd(`${Name} load`); if (error) return Dialog.alert(error.message, { diff --git a/client/modules/menu.js b/client/modules/menu.js index 4ecc17cb..fa85dabc 100644 --- a/client/modules/menu.js +++ b/client/modules/menu.js @@ -239,7 +239,7 @@ async function _uploadTo(nameModule) { const {name} = Info; CloudCmd.execFromModule(nameModule, 'uploadFile', name, data); - CloudCmd.log('Uploading to ' + name + '...'); + CloudCmd.log(`Uploading to ${name}...`); } function uploadFromCloud() { @@ -275,7 +275,7 @@ function download(type) { const isDir = DOM.isCurrentIsDir(file); const path = DOM.getCurrentPath(file); - CloudCmd.log('downloading file ' + path + '...'); + CloudCmd.log(`downloading file ${path}...`); /* * if we send ajax request - * no need in hash so we escape # diff --git a/client/modules/operation/index.js b/client/modules/operation/index.js index 4d7dd527..99436763 100644 --- a/client/modules/operation/index.js +++ b/client/modules/operation/index.js @@ -421,7 +421,7 @@ async function _processFiles(options, data) { function checkEmpty(name, operation) { if (!operation) - throw Error(name + ' could not be empty!'); + throw Error(`${name} could not be empty!`); } function twopack(operation, type) { @@ -487,9 +487,9 @@ async function prompt(msg, to, names) { msg += ' '; if (names.length > 1) - msg += n + ' file(s)'; + msg += `${n} file(s)`; else - msg += '"' + name + '"'; + msg += `"${name}"`; msg += ' to'; diff --git a/client/modules/operation/set-listeners.js b/client/modules/operation/set-listeners.js index 486a7145..8d436ef5 100644 --- a/client/modules/operation/set-listeners.js +++ b/client/modules/operation/set-listeners.js @@ -72,7 +72,8 @@ module.exports = (options) => (emitter) => { return; } - const [cancel] = await Dialog.confirm(error + '\n Continue?'); + const [cancel] = await Dialog.confirm(`${error} + Continue?`); if (!done && !cancel) return emitter.continue(); diff --git a/client/modules/view/index.js b/client/modules/view/index.js index 260d11f0..a53681fe 100644 --- a/client/modules/view/index.js +++ b/client/modules/view/index.js @@ -320,7 +320,7 @@ function check(src) { async function loadAll() { const {DIR_DIST} = CloudCmd; - time(Name + ' load'); + time(`${Name} load`); Loading = true; await loadCSS(`${DIR_DIST}/view.css`); diff --git a/common/cloudfunc.js b/common/cloudfunc.js index ab56d8a3..4b686014 100644 --- a/common/cloudfunc.js +++ b/common/cloudfunc.js @@ -29,9 +29,9 @@ module.exports.formatMsg = (msg, name, status) => { name = name || ''; if (name) - name = '("' + name + '")'; + name = `("${name}")`; - return msg + ': ' + status + name; + return `${msg}: ${status}${name}`; }; /** @@ -82,10 +82,10 @@ function getPathLink(url, prefix, template) { const isLast = i === n - 1; if (i) - path += name + '/'; + path += `${name}/`; if (i && isLast) { - lines.push(name + '/'); + lines.push(`${name}/`); continue; } @@ -164,7 +164,7 @@ module.exports.buildFromJSON = (params) => { /* сохраняем путь */ Path(path); - fileTable += header + '