cloudcmd 16.16.0 → 16.16.2
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 +12 -0
- package/HELP.md +3 -1
- package/README.md +3 -5
- package/bin/cloudcmd.mjs +2 -2
- package/bin/release.mjs +1 -1
- package/common/base64.js +2 -2
- package/common/cloudfunc.js +1 -1
- package/common/datetime.js +1 -1
- package/common/util.js +4 -3
- package/dist/cloudcmd.common.js +3 -3
- package/dist/cloudcmd.common.js.map +1 -1
- package/dist/cloudcmd.js +1 -1
- package/dist/cloudcmd.js.map +1 -1
- package/dist/modules/cloud.js +1 -1
- package/dist/modules/cloud.js.map +1 -1
- package/dist/modules/command-line.js +1 -1
- package/dist/modules/command-line.js.map +1 -1
- package/dist/modules/config.js +1 -1
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/contact.js +1 -1
- package/dist/modules/contact.js.map +1 -1
- package/dist/modules/edit-file-vim.js +1 -1
- package/dist/modules/edit-file-vim.js.map +1 -1
- package/dist/modules/edit-file.js +1 -1
- package/dist/modules/edit-file.js.map +1 -1
- package/dist/modules/edit-names-vim.js +1 -1
- package/dist/modules/edit-names-vim.js.map +1 -1
- package/dist/modules/edit-names.js +1 -1
- package/dist/modules/edit-names.js.map +1 -1
- package/dist/modules/edit.js +2 -2
- package/dist/modules/edit.js.map +1 -1
- package/dist/modules/help.js +1 -1
- package/dist/modules/help.js.map +1 -1
- package/dist/modules/konsole.js +1 -1
- package/dist/modules/konsole.js.map +1 -1
- package/dist/modules/markdown.js +1 -1
- package/dist/modules/markdown.js.map +1 -1
- package/dist/modules/menu.js +1 -1
- package/dist/modules/menu.js.map +1 -1
- package/dist/modules/operation.js +1 -1
- package/dist/modules/operation.js.map +1 -1
- package/dist/modules/polyfill.js +1 -1
- package/dist/modules/polyfill.js.map +1 -1
- package/dist/modules/terminal-run.js +1 -1
- package/dist/modules/terminal-run.js.map +1 -1
- package/dist/modules/terminal.js +1 -1
- package/dist/modules/terminal.js.map +1 -1
- package/dist/modules/upload.js +1 -1
- package/dist/modules/upload.js.map +1 -1
- package/dist/modules/user-menu.js +1 -1
- package/dist/modules/user-menu.js.map +1 -1
- package/dist/modules/view.js +1 -1
- package/dist/modules/view.js.map +1 -1
- package/dist/sw.js +1 -1
- package/dist/sw.js.map +1 -1
- package/dist-dev/cloudcmd.common.js +63 -15
- package/dist-dev/cloudcmd.js +7 -7
- package/dist-dev/modules/config.js +1 -1
- package/dist-dev/modules/contact.js +1 -1
- package/dist-dev/modules/edit.js +1 -1
- package/dist-dev/modules/markdown.js +1 -1
- package/dist-dev/modules/menu.js +1 -1
- package/dist-dev/modules/operation.js +2 -2
- package/dist-dev/modules/terminal-run.js +1 -1
- package/dist-dev/modules/terminal.js +1 -1
- package/dist-dev/modules/upload.js +1 -1
- package/dist-dev/modules/user-menu.js +2 -2
- package/dist-dev/modules/view.js +1 -1
- package/dist-dev/sw.js +1 -1
- package/package.json +8 -7
- package/server/cloudcmd.js +2 -2
- package/server/config.js +1 -1
- package/server/markdown/index.js +2 -2
- package/server/prefixer.js +3 -1
- package/server/rest/index.js +9 -12
- package/server/validate.js +2 -1
- package/static/user-menu.js +1 -2
package/dist-dev/modules/view.js
CHANGED
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
/***/ (function(module, exports, __webpack_require__) {
|
|
164
164
|
|
|
165
165
|
"use strict";
|
|
166
|
-
eval("/* global CloudCmd, DOM */\n\n\n\n__webpack_require__(/*! ../../../css/view.css */ \"./css/view.css\");\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst modal = __webpack_require__(/*! @cloudcmd/modal */ \"./node_modules/@cloudcmd/modal/lib/modal.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n time\n} = __webpack_require__(/*! ../../../common/util */ \"./common/util.js\");\nconst {\n FS\n} = __webpack_require__(/*! ../../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst {\n isImage,\n isAudio,\n getType\n} = __webpack_require__(/*! ./types */ \"./client/modules/view/types.js\");\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\nconst Events = __webpack_require__(/*! ../../dom/events */ \"./client/dom/events/index.js\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\nconst {\n assign\n} = Object;\nconst {\n isArray\n} = Array;\nconst lifo = currify((fn, el, cb, name) => fn(name, el, cb));\nconst series = wraptile(
|
|
166
|
+
eval("/* global CloudCmd, DOM */\n\n\n\n__webpack_require__(/*! ../../../css/view.css */ \"./css/view.css\");\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst modal = __webpack_require__(/*! @cloudcmd/modal */ \"./node_modules/@cloudcmd/modal/lib/modal.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n time\n} = __webpack_require__(/*! ../../../common/util */ \"./common/util.js\");\nconst {\n FS\n} = __webpack_require__(/*! ../../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst {\n isImage,\n isAudio,\n getType\n} = __webpack_require__(/*! ./types */ \"./client/modules/view/types.js\");\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\nconst Events = __webpack_require__(/*! ../../dom/events */ \"./client/dom/events/index.js\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\nconst isString = a => typeof a === 'string';\nconst {\n assign\n} = Object;\nconst {\n isArray\n} = Array;\nconst lifo = currify((fn, el, cb, name) => fn(name, el, cb));\nconst series = wraptile((...a) => {\n for (const f of a) f();\n});\nconst isFn = a => typeof a === 'function';\nconst noop = () => {};\nconst addEvent = lifo(Events.add);\nconst loadCSS = load.css;\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nlet Loading = false;\nconst Name = 'View';\nCloudCmd[Name] = module.exports;\nconst Info = DOM.CurrentInfo;\nconst {\n Key\n} = CloudCmd;\nconst basename = a => a.split('/').pop();\nlet El;\nlet TemplateAudio;\nlet Overlay;\nconst Config = {\n beforeShow: () => {\n Images.hide();\n Key.unsetBind();\n },\n beforeClose: () => {\n Events.rmKey(listener);\n Key.setBind();\n },\n afterShow: () => {\n El.focus();\n },\n onOverlayClick,\n afterClose: noop,\n autoSize: false,\n helpers: {\n title: {}\n }\n};\nmodule.exports._Config = Config;\nmodule.exports.init = async () => {\n await loadAll();\n const events = ['click', 'contextmenu'];\n events.forEach(addEvent(Overlay, onOverlayClick));\n};\nasync function show(data, options = {}) {\n const prefixURL = CloudCmd.prefixURL + FS;\n if (Loading) return;\n if (!options || options.bindKeys !== false) Events.addKey(listener);\n El = createElement('div', {\n className: 'view',\n notAppend: true\n });\n El.tabIndex = 0;\n if (data) {\n if (isArray(data)) El.append(...data);else El.append(data);\n modal.open(El, initConfig(options));\n return;\n }\n Images.show.load();\n const path = prefixURL + Info.path;\n const type = options.raw ? '' : await getType(path);\n switch (type) {\n default:\n return await viewFile();\n case 'markdown':\n return await CloudCmd.Markdown.show(Info.path);\n case 'html':\n return viewHtml(path);\n case 'image':\n return viewImage(Info.path, prefixURL);\n case 'media':\n return await viewMedia(path);\n case 'pdf':\n return viewPDF(path);\n }\n}\nmodule.exports._createIframe = createIframe;\nfunction createIframe(src) {\n const element = createElement('iframe', {\n src,\n width: '100%',\n height: '100%'\n });\n element.addEventListener('load', () => {\n element.contentWindow.addEventListener('keydown', listener);\n });\n return element;\n}\nmodule.exports._viewHtml = viewHtml;\nfunction viewHtml(src) {\n modal.open(createIframe(src), Config);\n}\nfunction viewPDF(src) {\n const element = createIframe(src);\n const options = assign({}, Config);\n if (CloudCmd.config('showFileName')) options.title = Info.name;\n modal.open(element, options);\n}\nasync function viewMedia(path) {\n const [e, element] = await getMediaElement(path);\n if (e) return alert(e);\n const allConfig = {\n ...Config,\n ...{\n autoSize: true,\n afterShow: () => {\n element.querySelector('audio, video').focus();\n }\n }\n };\n modal.open(element, allConfig);\n}\nasync function viewFile() {\n const [error, data] = await Info.getData();\n if (error) return Images.hide();\n const element = document.createTextNode(data);\n const options = Config;\n if (CloudCmd.config('showFileName')) options.title = Info.name;\n El.append(element);\n modal.open(El, options);\n}\nconst copy = a => assign({}, a);\nmodule.exports._initConfig = initConfig;\nfunction initConfig(options) {\n const config = copy(Config);\n if (!options) return config;\n const names = Object.keys(options);\n for (const name of names) {\n const isConfig = Boolean(config[name]);\n const item = options[name];\n if (!isFn(item) || !isConfig) {\n config[name] = options[name];\n continue;\n }\n const fn = config[name];\n config[name] = series(fn, item);\n }\n return config;\n}\nfunction hide() {\n modal.close();\n}\nfunction viewImage(path, prefixURL) {\n const isSupportedImage = a => isImage(a) || a === path;\n const makeTitle = path => ({\n href: `${prefixURL}${path}`,\n title: encode(basename(path))\n });\n const names = Info.files.map(DOM.getCurrentPath).filter(isSupportedImage);\n const titles = names.map(makeTitle);\n const index = names.indexOf(Info.path);\n const imageConfig = {\n index,\n autoSize: true,\n arrows: true,\n keys: true,\n helpers: {\n title: {}\n }\n };\n const config = {\n ...Config,\n ...imageConfig\n };\n modal.open(titles, config);\n}\nasync function getMediaElement(src) {\n check(src);\n const [error, template] = await tryToCatch(Files.get, 'view/media-tmpl');\n if (error) return [error];\n const {\n name\n } = Info;\n if (!TemplateAudio) TemplateAudio = template;\n const is = isAudio(name);\n const type = is ? 'audio' : 'video';\n const innerHTML = rendy(TemplateAudio, {\n src,\n type,\n name\n });\n const element = createElement('div', {\n innerHTML\n });\n return [null, element];\n}\nfunction check(src) {\n if (!isString(src)) throw Error('src should be a string!');\n}\n\n/**\n * function loads css and js of FancyBox\n * @callback - executes, when everything loaded\n */\nasync function loadAll() {\n const {\n DIR_DIST\n } = CloudCmd;\n time(`${Name} load`);\n Loading = true;\n await loadCSS(`${DIR_DIST}/view.css`);\n Loading = false;\n}\nfunction onOverlayClick(event) {\n const position = {\n x: event.clientX,\n y: event.clientY\n };\n setCurrentByPosition(position);\n}\nfunction setCurrentByPosition(position) {\n const element = DOM.getCurrentByPosition(position);\n if (!element) return;\n const {\n files,\n filesPassive\n } = Info;\n const isFiles = files.includes(element);\n const isFilesPassive = filesPassive.includes(element);\n if (!isFiles && !isFilesPassive) return;\n const isCurrent = DOM.isCurrentFile(element);\n if (isCurrent) return;\n DOM.setCurrentFile(element);\n}\nfunction listener({\n keyCode\n}) {\n if (keyCode === Key.ESC) hide();\n}\n\n//# sourceURL=file://cloudcmd/client/modules/view/index.js");
|
|
167
167
|
|
|
168
168
|
/***/ }),
|
|
169
169
|
|
package/dist-dev/sw.js
CHANGED
|
@@ -101,7 +101,7 @@ var serviceWorkerOption = {
|
|
|
101
101
|
/***/ (function(module, exports, __webpack_require__) {
|
|
102
102
|
|
|
103
103
|
"use strict";
|
|
104
|
-
eval("\n\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 = \"development\" === '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 = \"
|
|
104
|
+
eval("\n\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 = \"development\" === '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 = \"Wed Aug 09 2023 19:04:41 GMT+0300 (Eastern European Summer 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");
|
|
105
105
|
|
|
106
106
|
/***/ }),
|
|
107
107
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcmd",
|
|
3
|
-
"version": "16.16.
|
|
3
|
+
"version": "16.16.2",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "File manager for the web with console and editor",
|
|
@@ -85,6 +85,8 @@
|
|
|
85
85
|
},
|
|
86
86
|
"subdomain": "cloudcmd",
|
|
87
87
|
"dependencies": {
|
|
88
|
+
"@babel/core": "^7.22.9",
|
|
89
|
+
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
88
90
|
"@cloudcmd/dropbox": "^4.0.1",
|
|
89
91
|
"@cloudcmd/fileop": "^7.0.0",
|
|
90
92
|
"@cloudcmd/move-files": "^7.0.0",
|
|
@@ -126,8 +128,8 @@
|
|
|
126
128
|
"package-json": "^8.1.0",
|
|
127
129
|
"ponse": "^7.0.0",
|
|
128
130
|
"pullout": "^4.0.0",
|
|
129
|
-
"putout": "^
|
|
130
|
-
"redzip": "^
|
|
131
|
+
"putout": "^31.0.3",
|
|
132
|
+
"redzip": "^3.0.0",
|
|
131
133
|
"rendy": "^3.0.0",
|
|
132
134
|
"restafary": "^11.0.0",
|
|
133
135
|
"restbox": "^3.0.0",
|
|
@@ -147,15 +149,14 @@
|
|
|
147
149
|
"yargs-parser": "^21.0.0"
|
|
148
150
|
},
|
|
149
151
|
"devDependencies": {
|
|
150
|
-
"@babel/code-frame": "^7.
|
|
151
|
-
"@babel/core": "^7.0.0",
|
|
152
|
-
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
|
|
152
|
+
"@babel/code-frame": "^7.22.5",
|
|
153
153
|
"@babel/preset-env": "^7.0.0",
|
|
154
154
|
"@cloudcmd/clipboard": "^2.0.0",
|
|
155
155
|
"@cloudcmd/create-element": "^2.0.0",
|
|
156
156
|
"@cloudcmd/modal": "^3.0.0",
|
|
157
157
|
"@cloudcmd/olark": "^3.0.2",
|
|
158
158
|
"@cloudcmd/stub": "^4.0.1",
|
|
159
|
+
"@putout/babel": "^1.0.5",
|
|
159
160
|
"auto-globals": "^3.0.0",
|
|
160
161
|
"babel-loader": "^8.0.0",
|
|
161
162
|
"babel-plugin-macros": "^3.0.0",
|
|
@@ -169,7 +170,7 @@
|
|
|
169
170
|
"emitify": "^4.0.1",
|
|
170
171
|
"eslint": "^8.0.1",
|
|
171
172
|
"eslint-plugin-n": "^16.0.1",
|
|
172
|
-
"eslint-plugin-putout": "^
|
|
173
|
+
"eslint-plugin-putout": "^19.0.3",
|
|
173
174
|
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
|
|
174
175
|
"gritty": "^7.0.0",
|
|
175
176
|
"gunzip-maybe": "^1.3.1",
|
package/server/cloudcmd.js
CHANGED
|
@@ -109,7 +109,7 @@ module.exports._getPrefix = getPrefix;
|
|
|
109
109
|
function getPrefix(prefix) {
|
|
110
110
|
if (isFn(prefix))
|
|
111
111
|
return prefix() || '';
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
return prefix || '';
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -258,7 +258,7 @@ module.exports._replaceDist = replaceDist;
|
|
|
258
258
|
function replaceDist(url) {
|
|
259
259
|
if (!isDev)
|
|
260
260
|
return url;
|
|
261
|
-
|
|
261
|
+
|
|
262
262
|
return url.replace(/^\/dist\//, '/dist-dev/');
|
|
263
263
|
}
|
|
264
264
|
|
package/server/config.js
CHANGED
package/server/markdown/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const threadIt = require('thread-it');
|
|
|
9
9
|
const {read} = require('redzip');
|
|
10
10
|
|
|
11
11
|
const root = require('../root');
|
|
12
|
-
|
|
12
|
+
const isString = (a) => typeof a === 'string';
|
|
13
13
|
const parse = threadIt(join(__dirname, 'worker'));
|
|
14
14
|
|
|
15
15
|
threadIt.init();
|
|
@@ -56,7 +56,7 @@ async function onPUT(request) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function check(name, request) {
|
|
59
|
-
if (
|
|
59
|
+
if (!isString(name))
|
|
60
60
|
throw Error('name should be string!');
|
|
61
61
|
|
|
62
62
|
if (!request)
|
package/server/prefixer.js
CHANGED
package/server/rest/index.js
CHANGED
|
@@ -22,7 +22,8 @@ const ponse = require('ponse');
|
|
|
22
22
|
|
|
23
23
|
const copymitter = require('copymitter');
|
|
24
24
|
const moveFiles = require('@cloudcmd/move-files');
|
|
25
|
-
|
|
25
|
+
const isString = (a) => typeof a === 'string';
|
|
26
|
+
const isFn = (a) => typeof a === 'function';
|
|
26
27
|
const swap = wraptile((fn, a, b) => fn(b, a));
|
|
27
28
|
const isWin32 = process.platform === 'win32';
|
|
28
29
|
const {apiURL} = CloudFunc;
|
|
@@ -148,7 +149,7 @@ function onGET(params, config, callback) {
|
|
|
148
149
|
function getPackReg(packer) {
|
|
149
150
|
if (packer === 'zip')
|
|
150
151
|
return /\.zip$/;
|
|
151
|
-
|
|
152
|
+
|
|
152
153
|
return /\.tar\.gz$/;
|
|
153
154
|
}
|
|
154
155
|
|
|
@@ -167,14 +168,11 @@ function streamPack(cmd, response, packer) {
|
|
|
167
168
|
function getCMD(cmd) {
|
|
168
169
|
if (cmd[0] === '/')
|
|
169
170
|
return cmd.slice(1);
|
|
170
|
-
|
|
171
|
+
|
|
171
172
|
return cmd;
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
const getMoveMsg = (names) =>
|
|
175
|
-
const msg = formatMsg('move', names);
|
|
176
|
-
return msg;
|
|
177
|
-
};
|
|
175
|
+
const getMoveMsg = (names) => formatMsg('move', names);
|
|
178
176
|
|
|
179
177
|
const getRenameMsg = (from, to) => {
|
|
180
178
|
const msg = formatMsg('rename', {
|
|
@@ -376,9 +374,8 @@ module.exports._getWin32RootMsg = getWin32RootMsg;
|
|
|
376
374
|
|
|
377
375
|
function getWin32RootMsg() {
|
|
378
376
|
const message = 'Could not copy from/to root on windows!';
|
|
379
|
-
const error = Error(message);
|
|
380
377
|
|
|
381
|
-
return
|
|
378
|
+
return Error(message);
|
|
382
379
|
}
|
|
383
380
|
|
|
384
381
|
function parseData(data) {
|
|
@@ -398,12 +395,12 @@ function formatMsg(msg, data, status) {
|
|
|
398
395
|
}
|
|
399
396
|
|
|
400
397
|
function checkPut(name, body, callback) {
|
|
401
|
-
if (
|
|
398
|
+
if (!isString(name))
|
|
402
399
|
throw Error('name should be a string!');
|
|
403
400
|
|
|
404
|
-
if (
|
|
401
|
+
if (!isString(body))
|
|
405
402
|
throw Error('body should be a string!');
|
|
406
403
|
|
|
407
|
-
if (
|
|
404
|
+
if (!isFn(callback))
|
|
408
405
|
throw Error('callback should be a function!');
|
|
409
406
|
}
|
package/server/validate.js
CHANGED
|
@@ -4,9 +4,10 @@ const tryCatch = require('try-catch');
|
|
|
4
4
|
|
|
5
5
|
const exit = require('./exit');
|
|
6
6
|
const columns = require('./columns');
|
|
7
|
+
const isString = (a) => typeof a === 'string';
|
|
7
8
|
|
|
8
9
|
module.exports.root = (dir, config) => {
|
|
9
|
-
if (
|
|
10
|
+
if (!isString(dir))
|
|
10
11
|
throw Error('dir should be a string');
|
|
11
12
|
|
|
12
13
|
if (dir === '/')
|
package/static/user-menu.js
CHANGED
|
@@ -131,9 +131,8 @@ async function createDefaultMenu({path, data, DOM, CloudCmd}) {
|
|
|
131
131
|
|
|
132
132
|
async function readDefaultMenu({prefix}) {
|
|
133
133
|
const res = await fetch(`${prefix}/api/v1/user-menu/default`);
|
|
134
|
-
const data = await res.text();
|
|
135
134
|
|
|
136
|
-
return
|
|
135
|
+
return await res.text();
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
module.exports._selectNames = selectNames;
|