cloudcmd 17.2.0 → 17.3.0
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 +16 -0
- package/HELP.md +7 -5
- package/README.md +1 -1
- package/bin/cloudcmd.mjs +11 -4
- package/dist/cloudcmd.common.js +3 -3
- package/dist/cloudcmd.common.js.map +1 -1
- package/dist/cloudcmd.css +1 -1
- package/dist/cloudcmd.js +1 -1
- package/dist/cloudcmd.js.map +1 -1
- package/dist/config.css +1 -1
- package/dist/index.html +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 +1 -1
- 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 +4 -2
- package/dist/themes/dark.css +1 -0
- package/dist/themes/light.css +1 -0
- package/dist/user-menu.css +1 -1
- package/dist-dev/cloudcmd.css +28 -23
- package/dist-dev/cloudcmd.js +36 -2
- package/dist-dev/config.css +2 -1
- package/dist-dev/index.html +3 -0
- package/dist-dev/modules/config.js +1 -1
- package/dist-dev/sw.js +4 -2
- package/dist-dev/themes/dark.css +49 -0
- package/dist-dev/themes/light.css +9 -0
- package/dist-dev/user-menu.css +1 -1
- package/json/config.json +1 -0
- package/json/help.json +1 -0
- package/man/cloudcmd.1 +1 -0
- package/package.json +1 -1
- package/server/cloudcmd.mjs +3 -3
- package/server/{columns.js → columns.mjs} +13 -12
- package/server/columns.spec.mjs +40 -0
- package/server/{route.js → route.mjs} +24 -23
- package/server/route.spec.mjs +2 -2
- package/server/theme.mjs +33 -0
- package/server/themes.spec.mjs +31 -0
- package/server/{validate.js → validate.mjs} +24 -10
- package/server/validate.spec.mjs +30 -1
- package/tmpl/config.hbs +7 -1
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const {getColumns} = require(`./columns`);
|
|
20
|
-
const Template = require(`./template`);
|
|
1
|
+
import {createRequire} from 'node:module';
|
|
2
|
+
import {extname} from 'node:path';
|
|
3
|
+
import _win32 from 'win32';
|
|
4
|
+
import ponse from 'ponse';
|
|
5
|
+
import rendy from 'rendy';
|
|
6
|
+
import format from 'format-io';
|
|
7
|
+
import currify from 'currify';
|
|
8
|
+
import wraptile from 'wraptile';
|
|
9
|
+
import tryToCatch from 'try-to-catch';
|
|
10
|
+
import once from 'once';
|
|
11
|
+
import pipe from 'pipe-io';
|
|
12
|
+
import {contentType} from 'mime-types';
|
|
13
|
+
import root from './root.js';
|
|
14
|
+
import prefixer from './prefixer.js';
|
|
15
|
+
import CloudFunc from '../common/cloudfunc.js';
|
|
16
|
+
import Template from './template.js';
|
|
17
|
+
import {getColumns} from './columns.mjs';
|
|
18
|
+
import {getThemes} from './theme.mjs';
|
|
21
19
|
|
|
20
|
+
const require = createRequire(import.meta.url);
|
|
22
21
|
const {stringify} = JSON;
|
|
23
22
|
const {FS} = CloudFunc;
|
|
24
23
|
|
|
@@ -46,7 +45,7 @@ const getReadDir = (config, {win32 = _win32} = {}) => {
|
|
|
46
45
|
/**
|
|
47
46
|
* routing of server queries
|
|
48
47
|
*/
|
|
49
|
-
|
|
48
|
+
export default currify((config, options, request, response, next) => {
|
|
50
49
|
const name = ponse.getPathName(request);
|
|
51
50
|
const isFS = RegExp(`^/$|^${FS}`).test(name);
|
|
52
51
|
|
|
@@ -61,7 +60,7 @@ module.exports = currify((config, options, request, response, next) => {
|
|
|
61
60
|
}).catch(next);
|
|
62
61
|
});
|
|
63
62
|
|
|
64
|
-
|
|
63
|
+
export const _getReadDir = getReadDir;
|
|
65
64
|
|
|
66
65
|
async function route({config, options, request, response}) {
|
|
67
66
|
const name = ponse.getPathName(request);
|
|
@@ -166,6 +165,7 @@ function indexProcessing(config, options) {
|
|
|
166
165
|
prefix: getPrefix(config),
|
|
167
166
|
config: stringify(config('*')),
|
|
168
167
|
columns: getColumns()[config('columns')],
|
|
168
|
+
themes: getThemes()[config('theme')],
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
return data;
|
|
@@ -184,7 +184,8 @@ function buildIndex(config, html, data) {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
export const _hideKeysPanel = hideKeysPanel;
|
|
188
|
+
|
|
188
189
|
function hideKeysPanel(html) {
|
|
189
190
|
const keysPanel = '<div id="js-keyspanel" class="{{ className }}"';
|
|
190
191
|
const keysPanelRegExp = '<div id="?js-keyspanel"? class="?{{ className }}"?';
|
package/server/route.spec.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import tryToCatch from 'try-to-catch';
|
|
|
6
6
|
import {test, stub} from 'supertape';
|
|
7
7
|
import serveOnce from 'serve-once';
|
|
8
8
|
import cloudcmd from './cloudcmd.mjs';
|
|
9
|
-
import {_getReadDir} from './route.
|
|
9
|
+
import {_getReadDir} from './route.mjs';
|
|
10
10
|
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = dirname(__filename);
|
|
@@ -325,7 +325,7 @@ test('cloudcmd: route: buttons: no terminal', async (t) => {
|
|
|
325
325
|
t.end();
|
|
326
326
|
});
|
|
327
327
|
|
|
328
|
-
test('cloudcmd: route: no
|
|
328
|
+
test('cloudcmd: route: no terminal: /fs', async (t) => {
|
|
329
329
|
const config = {
|
|
330
330
|
terminal: false,
|
|
331
331
|
};
|
package/server/theme.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import path, {dirname} from 'node:path';
|
|
2
|
+
import {fileURLToPath} from 'node:url';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import fullstore from 'fullstore';
|
|
6
|
+
import nanomemoizeDefault from 'nano-memoize';
|
|
7
|
+
import readFilesSync from '@cloudcmd/read-files-sync';
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
const isMap = (a) => /\.map$/.test(a);
|
|
12
|
+
const not = (fn) => (a) => !fn(a);
|
|
13
|
+
|
|
14
|
+
const _isDev = fullstore(process.env.NODE_ENV === 'development');
|
|
15
|
+
const getDist = (isDev) => isDev ? 'dist-dev' : 'dist';
|
|
16
|
+
|
|
17
|
+
export const isDev = _isDev;
|
|
18
|
+
|
|
19
|
+
export const getThemes = ({isDev = _isDev()} = {}) => {
|
|
20
|
+
return readFilesSyncMemo(isDev);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const {nanomemoize} = nanomemoizeDefault;
|
|
24
|
+
|
|
25
|
+
const readFilesSyncMemo = nanomemoize((isDev) => {
|
|
26
|
+
const dist = getDist(isDev);
|
|
27
|
+
const themesDir = path.join(__dirname, '..', dist, 'themes');
|
|
28
|
+
const names = fs
|
|
29
|
+
.readdirSync(themesDir)
|
|
30
|
+
.filter(not(isMap));
|
|
31
|
+
|
|
32
|
+
return readFilesSync(themesDir, names, 'utf8');
|
|
33
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {dirname} from 'node:path';
|
|
2
|
+
import {fileURLToPath} from 'node:url';
|
|
3
|
+
import test from 'supertape';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import {getThemes, isDev} from './theme.mjs';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
test('themes: dev', (t) => {
|
|
11
|
+
const themes = getThemes({
|
|
12
|
+
isDev: true,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const css = fs.readFileSync(`${__dirname}/../css/themes/dark.css`, 'utf8');
|
|
16
|
+
|
|
17
|
+
t.equal(themes.dark, css);
|
|
18
|
+
t.end();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('themes: no args', (t) => {
|
|
22
|
+
const currentIsDev = isDev();
|
|
23
|
+
isDev(true);
|
|
24
|
+
const themes = getThemes();
|
|
25
|
+
|
|
26
|
+
const css = fs.readFileSync(`${__dirname}/../css/themes/light.css`, 'utf8');
|
|
27
|
+
isDev(currentIsDev);
|
|
28
|
+
|
|
29
|
+
t.equal(themes.light, css);
|
|
30
|
+
t.end();
|
|
31
|
+
});
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import {statSync as _statSync} from 'node:fs';
|
|
2
|
+
import tryCatch from 'try-catch';
|
|
3
|
+
import _exit from './exit.js';
|
|
4
|
+
import {getColumns as _getColumns} from './columns.mjs';
|
|
5
|
+
import {getThemes as _getThemes} from './theme.mjs';
|
|
2
6
|
|
|
3
|
-
const {statSync: _statSync} = require('node:fs');
|
|
4
|
-
const tryCatch = require('try-catch');
|
|
5
|
-
|
|
6
|
-
const _exit = require('./exit');
|
|
7
|
-
const {getColumns: _getColumns} = require('./columns');
|
|
8
7
|
const isString = (a) => typeof a === 'string';
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
export const root = (dir, config, {exit = _exit, statSync = _statSync} = {}) => {
|
|
11
10
|
if (!isString(dir))
|
|
12
11
|
throw Error('dir should be a string');
|
|
13
12
|
|
|
@@ -23,21 +22,21 @@ module.exports.root = (dir, config, {exit = _exit, statSync = _statSync} = {}) =
|
|
|
23
22
|
return exit('cloudcmd --root: %s', error.message);
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
export const editor = (name, {exit = _exit} = {}) => {
|
|
27
26
|
const reg = /^(dword|edward|deepword)$/;
|
|
28
27
|
|
|
29
28
|
if (!reg.test(name))
|
|
30
29
|
exit('cloudcmd --editor: could be "dword", "edward" or "deepword" only');
|
|
31
30
|
};
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
export const packer = (name, {exit = _exit} = {}) => {
|
|
34
33
|
const reg = /^(tar|zip)$/;
|
|
35
34
|
|
|
36
35
|
if (!reg.test(name))
|
|
37
36
|
exit('cloudcmd --packer: could be "tar" or "zip" only');
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
export const columns = (type, {exit = _exit, getColumns = _getColumns} = {}) => {
|
|
41
40
|
const addQuotes = (a) => `"${a}"`;
|
|
42
41
|
const all = Object
|
|
43
42
|
.keys(getColumns())
|
|
@@ -51,3 +50,18 @@ module.exports.columns = (type, {exit = _exit, getColumns = _getColumns} = {}) =
|
|
|
51
50
|
if (!all.includes(type))
|
|
52
51
|
exit(`cloudcmd --columns: can be only one of: ${names}`);
|
|
53
52
|
};
|
|
53
|
+
|
|
54
|
+
export const theme = (type, {exit = _exit, getThemes = _getThemes} = {}) => {
|
|
55
|
+
const addQuotes = (a) => `"${a}"`;
|
|
56
|
+
const all = Object
|
|
57
|
+
.keys(getThemes())
|
|
58
|
+
.concat('');
|
|
59
|
+
|
|
60
|
+
const names = all
|
|
61
|
+
.filter(Boolean)
|
|
62
|
+
.map(addQuotes)
|
|
63
|
+
.join(', ');
|
|
64
|
+
|
|
65
|
+
if (!all.includes(type))
|
|
66
|
+
exit(`cloudcmd --theme: can be only one of: ${names}`);
|
|
67
|
+
};
|
package/server/validate.spec.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {test, stub} from 'supertape';
|
|
2
2
|
import tryCatch from 'try-catch';
|
|
3
|
-
import validate from './validate.
|
|
3
|
+
import * as validate from './validate.mjs';
|
|
4
4
|
import cloudcmd from './cloudcmd.mjs';
|
|
5
5
|
|
|
6
6
|
test('validate: root: bad', (t) => {
|
|
@@ -102,3 +102,32 @@ test('validate: columns: wrong', (t) => {
|
|
|
102
102
|
t.calledWith(exit, [msg], 'should call exit');
|
|
103
103
|
t.end();
|
|
104
104
|
});
|
|
105
|
+
|
|
106
|
+
test('validate: theme', (t) => {
|
|
107
|
+
const exit = stub();
|
|
108
|
+
|
|
109
|
+
validate.theme('dark', {
|
|
110
|
+
exit,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
t.notCalled(exit, 'should not call exit');
|
|
114
|
+
t.end();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('validate: theme: wrong', (t) => {
|
|
118
|
+
const getThemes = stub().returns({
|
|
119
|
+
light: '',
|
|
120
|
+
dark: '',
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const exit = stub();
|
|
124
|
+
const msg = 'cloudcmd --theme: can be only one of: "light", "dark"';
|
|
125
|
+
|
|
126
|
+
validate.theme('hello', {
|
|
127
|
+
exit,
|
|
128
|
+
getThemes,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
t.calledWith(exit, [msg], 'should call exit');
|
|
132
|
+
t.end();
|
|
133
|
+
});
|
package/tmpl/config.hbs
CHANGED
|
@@ -43,8 +43,14 @@
|
|
|
43
43
|
Zip
|
|
44
44
|
</label>
|
|
45
45
|
</li>
|
|
46
|
+
<li title="Theme">
|
|
47
|
+
<select data-name="js-theme" class="form-control full-width" title="Theme">
|
|
48
|
+
<option {{ light-selected }}>light</option>
|
|
49
|
+
<option {{ dark-selected }}>dark</option>
|
|
50
|
+
</select>
|
|
51
|
+
</li>
|
|
46
52
|
<li title="Visible Columns">
|
|
47
|
-
<select data-name="js-
|
|
53
|
+
<select data-name="js-themes" class="form-control full-width" title="Visible Columns">
|
|
48
54
|
<option {{ name-size-date-owner-mode-selected }}>name-size-date-owner-mode</option>
|
|
49
55
|
<option {{ name-size-date-selected }}>name-size-date</option>
|
|
50
56
|
<option {{ name-size-selected }}>name-size</option>
|