feature: cloudcmd: migrate to ESM

This commit is contained in:
coderiaser 2026-02-03 15:03:49 +02:00
parent e8a81c49ea
commit 4533a25c6f
184 changed files with 339 additions and 388 deletions

View file

@ -1,6 +1,4 @@
'use strict';
module.exports = {
export default {
'F2 - Rename file': async ({DOM}) => {
await DOM.renameCurrent();
},

View file

@ -21,7 +21,7 @@ const buildEnv = (is17 || is20) && {
};
export default {
'start': () => 'node bin/cloudcmd.mjs',
'start': () => 'node bin/cloudcmd.js',
'start:dev': async () => await run('start', null, {
NODE_ENV: 'development',
}),
@ -41,7 +41,7 @@ export default {
'wisdom': async () => await run(['lint:all', 'build', 'test'], null, {
CI: 1,
}),
'wisdom:type': () => 'bin/release.mjs',
'wisdom:type': () => 'bin/release.js',
'coverage': async () => [testEnv, `c8 ${await cutEnv('test')}`],
'coverage:report': () => 'c8 report --reporter=lcov',
'report': () => 'c8 report --reporter=lcov',

View file

@ -20,7 +20,7 @@ bower.json
manifest.yml
deno.json
bin/release.mjs
bin/release.*
client
img/logo/cloudcmd-hq.png

View file

@ -8,7 +8,8 @@
"*.md"
],
"rules": {
"package-json/add-type": "off"
"package-json/add-type": "off",
"esm/add-index-to-import": "off"
},
"match": {
".filesystem.json": {

View file

@ -117,28 +117,28 @@ export default {
'config': `${dirCss}/config.css`,
'terminal': `${dirCss}/terminal.css`,
'user-menu': `${dirCss}/user-menu.css`,
'sw': `${dir}/sw/sw.mjs`,
'cloudcmd': `${dir}/cloudcmd.mjs`,
[`${modules}/edit`]: `${dirModules}/edit.mjs`,
[`${modules}/edit-file`]: `${dirModules}/edit-file.mjs`,
[`${modules}/edit-file-vim`]: `${dirModules}/edit-file-vim.mjs`,
[`${modules}/edit-names`]: `${dirModules}/edit-names.mjs`,
[`${modules}/edit-names-vim`]: `${dirModules}/edit-names-vim.mjs`,
[`${modules}/menu`]: `${dirModules}/menu/index.mjs`,
[`${modules}/view`]: `${dirModules}/view/index.mjs`,
[`${modules}/help`]: `${dirModules}/help.mjs`,
[`${modules}/markdown`]: `${dirModules}/markdown.mjs`,
[`${modules}/config`]: `${dirModules}/config/index.mjs`,
'sw': `${dir}/sw/sw.js`,
'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/index.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.mjs`,
[`${modules}/operation`]: `${dirModules}/operation/index.mjs`,
[`${modules}/konsole`]: `${dirModules}/konsole.mjs`,
[`${modules}/terminal`]: `${dirModules}/terminal.mjs`,
[`${modules}/terminal-run`]: `${dirModules}/terminal-run.mjs`,
[`${modules}/cloud`]: `${dirModules}/cloud.mjs`,
[`${modules}/user-menu`]: `${dirModules}/user-menu/index.mjs`,
[`${modules}/polyfill`]: `${dirModules}/polyfill.mjs`,
[`${modules}/command-line`]: `${dirModules}/command-line.mjs`,
[`${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',

View file

@ -7,10 +7,10 @@ import {tryToCatch} from 'try-to-catch';
import {createSimport} from 'simport';
import parse from 'yargs-parser';
import exit from '../server/exit.js';
import {createConfig, configPath} from '../server/config.mjs';
import * as env from '../server/env.mjs';
import {createConfig, configPath} from '../server/config.js';
import * as env from '../server/env.js';
import prefixer from '../server/prefixer.js';
import * as validate from '../server/validate.mjs';
import * as validate from '../server/validate.js';
process.on('unhandledRejection', exit);
@ -248,7 +248,7 @@ async function main() {
if (args.showConfig)
await showConfig();
const {distributeImport} = await simport('../server/distribute/import.mjs');
const {distributeImport} = await simport('../server/distribute/import.js');
const importConfig = promisify(distributeImport);
await start(options, config);
@ -279,7 +279,7 @@ function version() {
}
async function start(options, config) {
const SERVER = `${DIR_SERVER}server.mjs`;
const SERVER = `../server/server.js`;
if (!args.server)
return;

View file

@ -1,5 +1,3 @@
#!/usr/bin/env node
import {promisify} from 'node:util';
import process from 'node:process';
import {tryToCatch} from 'try-to-catch';

View file

@ -13,10 +13,10 @@ import {
buildFromJSON,
} from '#common/cloudfunc';
import * as Images from '#dom/images';
import {unregisterSW} from './sw/register.mjs';
import {getJsonFromFileTable} from './get-json-from-file-table.mjs';
import {Key} from './key/index.mjs';
import {loadModule} from './load-module.mjs';
import {unregisterSW} from './sw/register.js';
import {getJsonFromFileTable} from './get-json-from-file-table.js';
import {Key} from './key/index.js';
import {loadModule} from './load-module.js';
const noJS = (a) => a.replace(/.js$/, '');

View file

@ -5,10 +5,10 @@ import load from 'load.js';
import * as Util from '#common/util';
import * as CloudFunc from '#common/cloudfunc';
import DOM from '#dom';
import {registerSW, listenSW} from './sw/register.mjs';
import {initSortPanel, sortPanel} from './sort.mjs';
import {createCloudCmd} from './client.mjs';
import * as Listeners from './listeners/index.mjs';
import {registerSW, listenSW} from './sw/register.js';
import {initSortPanel, sortPanel} from './sort.js';
import {createCloudCmd} from './client.js';
import * as Listeners from './listeners/index.js';
const isDev = process.env.NODE_ENV === 'development';

View file

@ -1,7 +1,7 @@
import {test, stub} from 'supertape';
import {create} from 'auto-globals';
import wraptile from 'wraptile';
import * as currentFile from './current-file.mjs';
import * as currentFile from './current-file.js';
const id = (a) => a;

View file

@ -1,7 +1,7 @@
import test from 'supertape';
import {create} from 'auto-globals';
import {tryCatch} from 'try-catch';
import {isContainClass} from './dom-tree.mjs';
import {isContainClass} from './dom-tree.js';
test('dom: isContainClass: no element', (t) => {
const [e] = tryCatch(isContainClass);

View file

@ -1,5 +1,5 @@
import {test} from 'supertape';
import * as eventStore from './event-store.mjs';
import * as eventStore from './event-store.js';
test('event-store: get', (t) => {
const el = {};

View file

@ -1,5 +1,5 @@
import itype from 'itype';
import * as EventStore from './event-store.mjs';
import * as EventStore from './event-store.js';
/**
* safe add event listener

View file

@ -102,13 +102,13 @@ export function show(position, panel) {
/**
* hide load image
*/
export const hide = () => {
export function hide() {
const element = Images.get();
DOM.hide(element);
return Images;
};
}
export const setProgress = (value, title) => {
const DATA = 'data-progress';

View file

@ -7,15 +7,15 @@ import {getExt} from '#common/util';
import * as Storage from '#dom/storage';
import * as RESTful from '#dom/rest';
import * as Images from '#dom/images';
import renameCurrent from './operations/rename-current.mjs';
import * as CurrentFile from './current-file.mjs';
import * as DOMTree from './dom-tree.mjs';
import * as Cmd from './cmd.mjs';
import * as IO from './io/index.mjs';
import {uploadDirectory} from './directory.mjs';
import * as Buffer from './buffer.mjs';
import {loadRemote as _loadRemote} from './load-remote.mjs';
import {selectByPattern} from './select-by-pattern.mjs';
import renameCurrent from './operations/rename-current.js';
import * as CurrentFile from './current-file.js';
import * as DOMTree from './dom-tree.js';
import * as Cmd from './cmd.js';
import * as IO from './io/index.js';
import {uploadDirectory} from './directory.js';
import * as Buffer from './buffer.js';
import {loadRemote as _loadRemote} from './load-remote.js';
import {selectByPattern} from './select-by-pattern.js';
const {assign} = Object;

View file

@ -1,5 +1,5 @@
import {FS} from '#common/cloudfunc';
import {sendRequest as _sendRequest} from './send-request.mjs';
import {sendRequest as _sendRequest} from './send-request.js';
const {assign} = Object;

View file

@ -1,5 +1,5 @@
import {test, stub} from 'supertape';
import * as io from './index.mjs';
import * as io from './index.js';
test('client: dom: io', (t) => {
const sendRequest = stub();

View file

@ -1,5 +1,5 @@
import {test} from 'supertape';
import {_replaceHash} from './send-request.mjs';
import {_replaceHash} from './send-request.js';
test('cloudcmd: client: io: replaceHash', (t) => {
const url = '/hello/####world';

View file

@ -2,7 +2,7 @@
import {callbackify} from 'node:util';
import rendy from 'rendy';
import itype from 'itype';
import load from 'load.js';
import * as load from 'load.js';
import {tryToCatch} from 'try-to-catch';
import {findObjByNameInArr} from '#common/util';
import * as Files from '#dom/files';

View file

@ -3,7 +3,7 @@ import capitalize from 'just-capitalize';
import * as _Dialog from '#dom/dialog';
import * as Storage from '#dom/storage';
import * as RESTful from '#dom/rest';
import * as _currentFile from '../current-file.mjs';
import * as _currentFile from '../current-file.js';
export default async (current, overrides = {}) => {
const {

View file

@ -1,5 +1,5 @@
import {test, stub} from 'supertape';
import renameCurrent from './rename-current.mjs';
import renameCurrent from './rename-current.js';
test('cloudcmd: client: dom: renameCurrent: isCurrentFile', async (t) => {
const current = {};

View file

@ -2,7 +2,7 @@ import {tryToCatch} from 'try-to-catch';
import * as Dialog from '#dom/dialog';
import * as Images from '#dom/images';
import {encode} from '#common/entity';
import * as IO from './io/index.mjs';
import * as IO from './io/index.js';
const handleError = (promise) => async (...args) => {
const [e, data] = await tryToCatch(promise, ...args);

View file

@ -1,10 +1,10 @@
import {alert, prompt} from '#dom/dialog';
import {getRegExp} from '#common/util';
import {getCurrentName} from './current-file.mjs';
import {getCurrentName} from './current-file.js';
import {
isSelected,
toggleSelectedFile,
} from './cmd.mjs';
} from './cmd.js';
let SelectType = '*.*';

View file

@ -5,7 +5,7 @@ import * as load from '#dom/load';
import {alert} from '#dom/dialog';
import {FS} from '#common/cloudfunc';
import * as Images from '#dom/images';
import {getCurrentDirPath} from './current-file.mjs';
import {getCurrentDirPath} from './current-file.js';
const loadFile = wraptile(_loadFile);
const onEnd = wraptile(_onEnd);

View file

@ -2,11 +2,11 @@
import clipboard from '@cloudcmd/clipboard';
import {fullstore} from 'fullstore';
import * as Events from '#dom/events';
import * as Buffer from '../dom/buffer.mjs';
import * as KEY from './key.mjs';
import _vim from './vim/index.mjs';
import setCurrentByChar from './set-current-by-char.mjs';
import {createBinder} from './binder.mjs';
import * as Buffer from '../dom/buffer.js';
import * as KEY from './key.js';
import _vim from './vim/index.js';
import setCurrentByChar from './set-current-by-char.js';
import {createBinder} from './binder.js';
const Chars = fullstore();

View file

@ -1,8 +1,8 @@
import autoGlobals from 'auto-globals';
import supertape from 'supertape';
import {ESC} from './key.mjs';
import {Key, _listener} from './index.mjs';
import {getDOM, getCloudCmd} from './vim/globals.fixture.mjs';
import {ESC} from './key.js';
import {Key, _listener} from './index.js';
import {getDOM, getCloudCmd} from './vim/globals.fixture.js';
const test = autoGlobals(supertape);
const {stub} = supertape;

View file

@ -1,6 +1,6 @@
import test from 'supertape';
import {getDOM} from './globals.fixture.mjs';
import {_next, _previous} from './find.mjs';
import {getDOM} from './globals.fixture.js';
import {_next, _previous} from './find.js';
globalThis.DOM = getDOM();

View file

@ -1,11 +1,11 @@
/* global CloudCmd */
/* global DOM */
import vim from './vim.mjs';
import * as finder from './find.mjs';
import vim from './vim.js';
import * as finder from './find.js';
import {
setCurrent,
selectFileNotParent,
} from './set-current.mjs';
} from './set-current.js';
export default (key, event, overrides = {}) => {
const defaults = {

View file

@ -1,6 +1,6 @@
import {test, stub} from 'supertape';
import {getDOM, getCloudCmd} from './globals.fixture.mjs';
import vim, {selectFile as vimSelectFile} from './index.mjs';
import {getDOM, getCloudCmd} from './globals.fixture.js';
import vim, {selectFile as vimSelectFile} from './index.js';
globalThis.DOM = getDOM();
globalThis.CloudCmd = getCloudCmd();

View file

@ -1,5 +1,5 @@
import {test, stub} from 'supertape';
import vim from './vim.mjs';
import vim from './vim.js';
test('vim: no operations', (t) => {
const result = vim('hello', {});

View file

@ -1,5 +1,5 @@
import test from 'supertape';
import {getIndex} from './get-index.mjs';
import {getIndex} from './get-index.js';
test('cloudcmd: client: listeners: getIndex: not found', (t) => {
const array = ['hello'];

View file

@ -1,5 +1,5 @@
import test from 'supertape';
import {getRange} from './get-range.mjs';
import {getRange} from './get-range.js';
test('cloudcmd: client: listeners: getRange: direct', (t) => {
const expected = [

View file

@ -7,13 +7,13 @@ import clipboard from '@cloudcmd/clipboard';
import * as Events from '#dom/events';
import {uploadFiles} from '#dom/upload-files';
import {FS} from '#common/cloudfunc';
import {getRange} from './get-range.mjs';
import {getIndex} from './get-index.mjs';
import {getRange} from './get-range.js';
import {getIndex} from './get-index.js';
const NBSP_REG = RegExp(String.fromCharCode(160), 'g');
const SPACE = ' ';
export const init = async () => {
export async function init() {
contextMenu();
dragndrop();
unload();
@ -21,7 +21,7 @@ export const init = async () => {
resize();
header();
await config();
};
}
const unselect = (event) => {
const isMac = /Mac/.test(globalThis.navigator.platform);

View file

@ -1,8 +1,7 @@
/* global CloudCmd */
import * as Dialog from '#dom/dialog';
export const init = () => {};
export function init() {}
CloudCmd.CommandLine = {
init,
show,

View file

@ -12,7 +12,7 @@ import * as Events from '#dom/events';
import * as Files from '#dom/files';
import {getTitle} from '#common/cloudfunc';
import * as Images from '#dom/images';
import * as input from './input.mjs';
import * as input from './input.js';
const {Dialog, setTitle} = DOM;
@ -40,7 +40,7 @@ let Template;
const loadCSS = load.css;
export const init = async () => {
export async function init() {
if (!CloudCmd.config('configDialog'))
return;
@ -56,7 +56,7 @@ export const init = async () => {
]);
initSocket();
};
}
const {config, Key} = CloudCmd;

View file

@ -1,36 +1,34 @@
/* global CloudCmd */
/* global DOM */
import olark from '@cloudcmd/olark';
import * as Images from '#dom/images';
'use strict';
CloudCmd.Contact = exports;
const olark = require('@cloudcmd/olark');
const Images = require('#dom/images');
CloudCmd.Contact = {
init,
show,
hide,
};
const {Events} = DOM;
const {Key} = CloudCmd;
module.exports.show = show;
module.exports.hide = hide;
module.exports.init = () => {
export function init() {
Events.addKey(onKey);
olark.identify('6216-545-10-4223');
olark('api.box.onExpand', show);
olark('api.box.onShow', show);
olark('api.box.onShrink', hide);
};
}
function show() {
export function show() {
Key.unsetBind();
Images.hide();
olark('api.box.expand');
}
function hide() {
export function hide() {
Key.setBind();
olark('api.box.hide');
}

View file

@ -25,4 +25,3 @@ export function show() {
export function hide() {
CloudCmd.View.hide();
}

View file

@ -45,7 +45,7 @@ export async function init() {
type: 'file',
});
const {createCloudMenu} = await import('./cloudmenu.mjs');
const {createCloudMenu} = await import('./cloudmenu.js');
const {name} = fm.dataset;

View file

@ -5,9 +5,9 @@ import exec from 'execon';
import load from 'load.js';
import {tryToCatch} from 'try-to-catch';
import {encode} from '#common/entity';
import {removeExtension} from './remove-extension.mjs';
import {setListeners} from './set-listeners.mjs';
import {getNextCurrentName} from './get-next-current-name.mjs';
import {removeExtension} from './remove-extension.js';
import {setListeners} from './set-listeners.js';
import {getNextCurrentName} from './get-next-current-name.js';
const {DOM, CloudCmd} = globalThis;
@ -190,11 +190,11 @@ function getPacker(type) {
return packTarFn;
}
export const hide = () => {
export function hide() {
CloudCmd.View.hide();
};
}
export const show = (operation, data) => {
export function show(operation, data) {
if (!Loaded)
return;
@ -215,7 +215,7 @@ export const show = (operation, data) => {
if (operation === 'extract')
return Operation.extract();
};
}
Operation.copy = processFiles({
type: 'copy',

View file

@ -1,5 +1,5 @@
import test from 'supertape';
import {removeExtension} from './remove-extension.mjs';
import {removeExtension} from './remove-extension.js';
test('cloudcmd: client: modules: operation: removeExtension: .tar.gz', (t) => {
const name = 'hello';

View file

@ -1,7 +1,7 @@
/* global DOM */
import forEachKey from 'for-each-key';
import wraptile from 'wraptile';
import {format} from './format.mjs';
import {format} from './format.js';
const {Dialog, Images} = DOM;

View file

@ -1,5 +1,5 @@
import {test, stub} from 'supertape';
import {scrollIntoViewIfNeeded} from './polyfill.mjs';
import {scrollIntoViewIfNeeded} from './polyfill.js';
test('cloudcmd: client: polyfill: scrollIntoViewIfNeeded', (t) => {
const scroll = stub();

View file

@ -1,5 +1,5 @@
import test from 'supertape';
import {getUserMenu} from './get-user-menu.mjs';
import {getUserMenu} from './get-user-menu.js';
test('user-menu: getUserMenu', (t) => {
const menu = `module.exports = {

View file

@ -10,11 +10,11 @@ import {tryToCatch} from 'try-to-catch';
import {codeFrameColumns} from '@babel/code-frame';
import * as Dialog from '#dom/dialog';
import * as Images from '#dom/images';
import {getUserMenu} from './get-user-menu.mjs';
import {navigate} from './navigate.mjs';
import {parseError} from './parse-error.mjs';
import {parseUserMenu} from './parse-user-menu.mjs';
import {runSelected} from './run.mjs';
import {getUserMenu} from './get-user-menu.js';
import {navigate} from './navigate.js';
import {parseError} from './parse-error.js';
import {parseUserMenu} from './parse-user-menu.js';
import {runSelected} from './run.js';
const loadCSS = load.css;
const sourceStore = fullstore();

View file

@ -4,7 +4,7 @@ import {
K,
UP,
DOWN,
} from '../../key/key.mjs';
} from '../../key/key.js';
const store = fullstore(1);
const isDigit = (a) => /^\d+$/.test(a);

View file

@ -1,11 +1,11 @@
import test from 'supertape';
import {navigate} from './navigate.mjs';
import {navigate} from './navigate.js';
import {
UP,
DOWN,
J,
K,
} from '../../key/key.mjs';
} from '../../key/key.js';
test('cloudcmd: user-menu: navigate: DOWN', (t) => {
const el = {

View file

@ -1,5 +1,5 @@
import test from 'supertape';
import {parseError} from './parse-error.mjs';
import {parseError} from './parse-error.js';
test('user-menu: parse-error', (t) => {
const result = parseError({

View file

@ -1,5 +1,5 @@
import {test, stub} from 'supertape';
import {parseUserMenu} from './parse-user-menu.mjs';
import {parseUserMenu} from './parse-user-menu.js';
test('cloudcmd: user menu: parse', (t) => {
const fn = stub();

View file

@ -1,5 +1,5 @@
import {test, stub} from 'supertape';
import {runSelected} from './run.mjs';
import {runSelected} from './run.js';
test('cloudcmd: client: user menu: run', async (t) => {
const runUserMenu = stub();

View file

@ -16,7 +16,7 @@ import {
isImage,
isAudio,
getType,
} from './types.mjs';
} from './types.js';
const CloudCmd = globalThis.CloudCmd || {};
const DOM = globalThis.DOM || {};

View file

@ -6,7 +6,7 @@ import {
_viewHtml,
_Config,
_createIframe,
} from './index.mjs';
} from './index.js';
const test = autoGlobals(tape);

Some files were not shown because too many files have changed in this diff Show more