From 6b9d43e9ab8ed2b4a4fa2be7e6541dd0dabd6870 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 9 Jul 2023 09:51:29 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20cloudcmd:=20actions:=20lint=20?= =?UTF-8?q?=E2=98=98=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .madrun.mjs | 2 +- HELP.md | 1 + client/client.js | 1 + client/dom/index.js | 1 + client/listeners/index.js | 7 +++---- client/modules/menu.js | 2 ++ client/modules/operation/index.js | 1 + client/modules/user-menu/parse-error.spec.js | 1 + common/cloudfunc.js | 1 + common/cloudfunc.spec.js | 2 ++ server/rest/index.js | 3 +-- static/user-menu.js | 6 ++++++ test/before.js | 3 +-- test/client/listeners/get-range.js | 3 +++ test/server/console.js | 2 ++ test/static.js | 1 + 16 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.madrun.mjs b/.madrun.mjs index 440fd4b1..17191346 100644 --- a/.madrun.mjs +++ b/.madrun.mjs @@ -8,7 +8,7 @@ const testEnv = { }; const is17 = /^v1[789]/.test(process.version); -const is20 = /^v2/.test(process.version); +const is20 = process.version.startsWith('v2'); // fix for ERR_OSSL_EVP_UNSUPPORTED on node v17 // flag '--openssl-legacy-provider' not supported diff --git a/HELP.md b/HELP.md index 07449236..a715f9c9 100644 --- a/HELP.md +++ b/HELP.md @@ -500,6 +500,7 @@ export default { const data = await readDefaultMenu({ prefix, }); + await createDefaultMenu({ path, data, diff --git a/client/client.js b/client/client.js index cdf33629..da0b5d95 100644 --- a/client/client.js +++ b/client/client.js @@ -327,6 +327,7 @@ function CloudCmdProto(DOM) { if (!newObj) // that's OK, error handled by RESTful return; + options.sort = sort; options.order = order; diff --git a/client/dom/index.js b/client/dom/index.js index bb58eac8..adf2abc9 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -142,6 +142,7 @@ module.exports.getNotCurrentDirPath = () => { const panel = DOM.getPanel({ active: false, }); + const path = DOM.getCurrentDirPath(panel); return path; diff --git a/client/listeners/index.js b/client/listeners/index.js index 42595f3b..02038407 100644 --- a/client/listeners/index.js +++ b/client/listeners/index.js @@ -216,10 +216,8 @@ async function onPathElementClick(panel, event) { function copyPath(el) { clipboard .writeText(el - .parentElement - .title) - .then(CloudCmd - .log) + .parentElement.title) + .then(CloudCmd.log) .catch(CloudCmd.log); } @@ -402,6 +400,7 @@ function dragndrop() { return uploadFiles(files); const isFile = (item) => item.kind === 'file'; + const dirFiles = Array .from(items) .filter(isFile); diff --git a/client/modules/menu.js b/client/modules/menu.js index 69ea8a66..c0dc664f 100644 --- a/client/modules/menu.js +++ b/client/modules/menu.js @@ -37,9 +37,11 @@ module.exports.init = () => { const fm = DOM.getFM(); const menuData = getMenuData(isAuth); + const options = getOptions({ type: 'context', }); + const optionsFile = getOptions({ type: 'file', }); diff --git a/client/modules/operation/index.js b/client/modules/operation/index.js index 98d461f7..597f50b8 100644 --- a/client/modules/operation/index.js +++ b/client/modules/operation/index.js @@ -96,6 +96,7 @@ async function initOperations(prefix, socketPrefix, fn) { prefix, socketPrefix, }); + operator.on('connect', authCheck(operator, onConnect(fn))); } diff --git a/client/modules/user-menu/parse-error.spec.js b/client/modules/user-menu/parse-error.spec.js index 873525a6..cb78fc6d 100644 --- a/client/modules/user-menu/parse-error.spec.js +++ b/client/modules/user-menu/parse-error.spec.js @@ -27,6 +27,7 @@ test('user-menu: parse-error: stack', (t) => { const result = parseError({ stack, }); + const expected = [1, 2]; t.deepEqual(result, expected); diff --git a/common/cloudfunc.js b/common/cloudfunc.js index 8bb1f159..1f96e6b9 100644 --- a/common/cloudfunc.js +++ b/common/cloudfunc.js @@ -71,6 +71,7 @@ function getPathLink(url, prefix, template) { '/', ...names, ]; + const lines = []; const n = allNames.length; diff --git a/common/cloudfunc.spec.js b/common/cloudfunc.spec.js index aa883164..561838c1 100644 --- a/common/cloudfunc.spec.js +++ b/common/cloudfunc.spec.js @@ -43,9 +43,11 @@ test('cloudfunc: buildFromJSON: ..', (t) => { const $ = cheerio.load(html); const el = $('[data-name="js-file-Li4="]'); + const result = el .find('[data-name="js-name"]') .text(); + const expected = '..'; t.equal(result, expected); diff --git a/server/rest/index.js b/server/rest/index.js index 6300a050..91fb816d 100644 --- a/server/rest/index.js +++ b/server/rest/index.js @@ -101,8 +101,7 @@ function sendData(params, config, callback) { return onGET(params, config, callback); case 'PUT': - return pullout(p - .request) + return pullout(p.request) .then((body) => { onPUT({ name: p.name, diff --git a/static/user-menu.js b/static/user-menu.js index b331d82a..fb75540c 100644 --- a/static/user-menu.js +++ b/static/user-menu.js @@ -14,6 +14,7 @@ module.exports = { 'F6 - Copy URL to current file': async ({DOM}) => { const {copyURLToCurrentFile} = await import(`${CDN}/menu/copy-url-to-current-file.js`); + await copyURLToCurrentFile({ DOM, }); @@ -24,6 +25,7 @@ module.exports = { }, 'Y - Convert YouTube to MP3': async ({CloudCmd, DOM}) => { const {convertYouTubeToMp3} = await import(`${CDN}/menu/convert-youtube-to-mp3.js`); + await convertYouTubeToMp3({ CloudCmd, DOM, @@ -32,6 +34,7 @@ module.exports = { 'F - Convert flac to mp3 [ffmpeg]': async ({CloudCmd, DOM}) => { const {convertFlacToMp3} = await import(`${CDN}/menu/ffmpeg.js`); + await convertFlacToMp3({ CloudCmd, DOM, @@ -39,6 +42,7 @@ module.exports = { }, 'M - Convert mp4 to mp3 [ffmpeg]': async ({CloudCmd, DOM}) => { const {convertMp4ToMp3} = await import(`${CDN}/menu/ffmpeg.js`); + await convertMp4ToMp3({ CloudCmd, DOM, @@ -47,6 +51,7 @@ module.exports = { 'O - Convert mov to mp3 [ffmpeg]': async ({CloudCmd, DOM}) => { const {convertMovToMp3} = await import(`${CDN}/menu/ffmpeg.js`); + await convertMovToMp3({ CloudCmd, DOM, @@ -72,6 +77,7 @@ module.exports = { const data = await readDefaultMenu({ prefix, }); + await createDefaultMenu({ path, data, diff --git a/test/before.js b/test/before.js index bc2409da..f8f4f36a 100644 --- a/test/before.js +++ b/test/before.js @@ -49,8 +49,7 @@ function before(options, fn = options) { server.listen(() => { fn(server - .address() - .port, promisify(after)); + .address().port, promisify(after)); }); } diff --git a/test/client/listeners/get-range.js b/test/client/listeners/get-range.js index ab33f52a..b3968809 100644 --- a/test/client/listeners/get-range.js +++ b/test/client/listeners/get-range.js @@ -16,6 +16,7 @@ test('cloudcmd: client: listeners: getRange: direct', (t) => { 'how', 'come', ]; + const result = getRange(0, 1, files); t.deepEqual(result, expected, 'should return range'); @@ -33,6 +34,7 @@ test('cloudcmd: client: listeners: getRange: reverse', (t) => { 'how', 'come', ]; + const result = getRange(1, 0, files); t.deepEqual(result, expected, 'should return range'); @@ -46,6 +48,7 @@ test('cloudcmd: client: listeners: getRange: one', (t) => { 'how', 'come', ]; + const result = getRange(0, 0, files); t.deepEqual(result, expected, 'should return range'); diff --git a/test/server/console.js b/test/server/console.js index 83742d59..c0e9ce58 100644 --- a/test/server/console.js +++ b/test/server/console.js @@ -18,6 +18,7 @@ test('cloudcmd: console: enabled', async (t) => { const {port, done} = await connect({ config, }); + const socket = io(`http://localhost:${port}/console`); socket.emit('auth', configFn('username'), configFn('password')); @@ -39,6 +40,7 @@ test('cloudcmd: console: disabled', async (t) => { const {port, done} = await connect({ config, }); + const socket = io(`http://localhost:${port}/console`); const [error] = await once(socket, 'connect_error'); diff --git a/test/static.js b/test/static.js index 17fe426e..a821a80b 100644 --- a/test/static.js +++ b/test/static.js @@ -95,6 +95,7 @@ test('cloudcmd: /cloudcmd.js: auth: no password', async (t) => { const encoded = Buffer .from(`${username}:`) .toString('base64'); + const authorization = `Basic ${encoded}`; const {status} = await request.get(`/${name}`, {