mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-22 18:29:26 +00:00
feature: convert to ESM
This commit is contained in:
parent
770a0812aa
commit
3e565109b3
26 changed files with 242 additions and 291 deletions
|
|
@ -33,7 +33,7 @@ export default {
|
|||
'lint:fresh': () => run('lint', '--fresh'),
|
||||
'fix:lint': () => run('lint', '--fix'),
|
||||
'lint:stream': () => run('lint', '-f stream'),
|
||||
'test': () => [testEnv, `tape 'test/**/*.js' '{client,static,common,server}/**/*.spec.js' -f fail`],
|
||||
'test': () => [testEnv, `tape 'test/**/*.{js,mjs}' '{client,static,common,server}/**/*.spec.{js,mjs}' -f fail`],
|
||||
'test:client': () => `tape 'test/client/**/*.js'`,
|
||||
'test:server': () => `tape 'test/**/*.js' 'server/**/*.spec.js' 'common/**/*.spec.js'`,
|
||||
'wisdom': () => run(['lint:all', 'build', 'test']),
|
||||
|
|
|
|||
|
|
@ -5587,7 +5587,7 @@ fix:
|
|||
- (rest) onDelete: func(null, body) -> func
|
||||
- (rest) onStat: add var
|
||||
- (cloudcmd) change index path
|
||||
- (server) start: url -> URL
|
||||
- (server) start: url -> PREFIX
|
||||
- (server) start: SSLPort -> sslPort
|
||||
- (server) start: Port -> port
|
||||
- (dom) getCurrentDirPath: "," -> ";"
|
||||
|
|
|
|||
2
HELP.md
2
HELP.md
|
|
@ -133,7 +133,7 @@ Cloud Commander supports the following command-line parameters:
|
|||
|
||||
For options not specified by command-line parameters, Cloud Commander then reads configuration data from `~/.cloudcmd.json`. It uses port `8000` by default.
|
||||
|
||||
To begin using the web client, go to this URL in your browser:
|
||||
To begin using the web client, go to this PREFIX in your browser:
|
||||
|
||||
```
|
||||
http://localhost:8000
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/coderaiser/cloudcmd.git"
|
||||
},
|
||||
"main": "server/cloudcmd.js",
|
||||
"main": "server/cloudcmd.mjs",
|
||||
"keywords": [
|
||||
"console",
|
||||
"terminal",
|
||||
|
|
|
|||
|
|
@ -1,38 +1,34 @@
|
|||
'use strict';
|
||||
import path, {dirname, join} from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import fullstore from 'fullstore';
|
||||
import process from 'node:process';
|
||||
import fs from 'node:fs';
|
||||
import currify from 'currify';
|
||||
import apart from 'apart';
|
||||
import ponse from 'ponse';
|
||||
import restafary from 'restafary';
|
||||
import restbox from 'restbox';
|
||||
import konsole from 'console-io';
|
||||
import edward from 'edward';
|
||||
import dword from 'dword';
|
||||
import deepword from 'deepword';
|
||||
import nomine from 'nomine';
|
||||
import fileop from '@cloudcmd/fileop';
|
||||
import cloudfunc from '../common/cloudfunc.js';
|
||||
import authentication from './auth.js';
|
||||
import {createConfig, configPath} from './config.js';
|
||||
import modulas from './modulas.js';
|
||||
import userMenu from './user-menu.mjs';
|
||||
import rest from './rest/index.js';
|
||||
import route from './route.js';
|
||||
import validate from './validate.js';
|
||||
import prefixer from './prefixer.js';
|
||||
import terminal from './terminal.js';
|
||||
import distribute from './distribute/index.js';
|
||||
import {createDepStore} from './depstore.js';
|
||||
|
||||
const {join} = require('node:path');
|
||||
const fullstore = require('fullstore');
|
||||
const process = require('node:process');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
|
||||
const currify = require('currify');
|
||||
const apart = require('apart');
|
||||
const ponse = require('ponse');
|
||||
const restafary = require('restafary');
|
||||
const restbox = require('restbox');
|
||||
const konsole = require('console-io');
|
||||
const edward = require('edward');
|
||||
const dword = require('dword');
|
||||
const deepword = require('deepword');
|
||||
const nomine = require('nomine');
|
||||
const fileop = require('@cloudcmd/fileop');
|
||||
|
||||
const cloudfunc = require('../common/cloudfunc');
|
||||
|
||||
const authentication = require('./auth');
|
||||
const {createConfig, configPath} = require(`./config`);
|
||||
|
||||
const modulas = require(`./modulas`);
|
||||
|
||||
const userMenu = require(`./user-menu`);
|
||||
const rest = require(`./rest/index.js`);
|
||||
const route = require(`./route`);
|
||||
const validate = require(`./validate`);
|
||||
const prefixer = require(`./prefixer`);
|
||||
const terminal = require(`./terminal`);
|
||||
const distribute = require(`./distribute`);
|
||||
const {createDepStore} = require('./depstore');
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const {assign} = Object;
|
||||
const DIR = `${__dirname}/`;
|
||||
const DIR_ROOT = join(DIR, '..');
|
||||
|
|
@ -50,7 +46,7 @@ const clean = (a) => a.filter(notEmpty);
|
|||
const isUndefined = (a) => typeof a === 'undefined';
|
||||
const isFn = (a) => typeof a === 'function';
|
||||
|
||||
module.exports = cloudcmd;
|
||||
export default cloudcmd;
|
||||
|
||||
function cloudcmd(params) {
|
||||
const p = params || {};
|
||||
|
|
@ -97,14 +93,12 @@ function cloudcmd(params) {
|
|||
|
||||
const depStore = createDepStore();
|
||||
|
||||
assign(cloudcmd, {
|
||||
depStore,
|
||||
});
|
||||
export const createConfigManager = createConfig;
|
||||
export {
|
||||
configPath,
|
||||
};
|
||||
|
||||
module.exports.createConfigManager = createConfig;
|
||||
module.exports.configPath = configPath;
|
||||
|
||||
module.exports._getIndexPath = getIndexPath;
|
||||
export const _getIndexPath = getIndexPath;
|
||||
|
||||
function defaultValue(config, name, options) {
|
||||
const value = options[name];
|
||||
|
|
@ -116,7 +110,8 @@ function defaultValue(config, name, options) {
|
|||
return value;
|
||||
}
|
||||
|
||||
module.exports._getPrefix = getPrefix;
|
||||
export const _getPrefix = getPrefix;
|
||||
|
||||
function getPrefix(prefix) {
|
||||
if (isFn(prefix))
|
||||
return prefix() || '';
|
||||
|
|
@ -124,8 +119,7 @@ function getPrefix(prefix) {
|
|||
return prefix || '';
|
||||
}
|
||||
|
||||
module.exports._initAuth = _initAuth;
|
||||
function _initAuth(config, accept, reject, username, password) {
|
||||
export function _initAuth(config, accept, reject, username, password) {
|
||||
if (!config('auth'))
|
||||
return accept();
|
||||
|
||||
|
|
@ -270,8 +264,9 @@ function logout(req, res, next) {
|
|||
res.sendStatus(401);
|
||||
}
|
||||
|
||||
module.exports._isDev = isDev;
|
||||
module.exports._replaceDist = replaceDist;
|
||||
export const _isDev = isDev;
|
||||
export const _replaceDist = replaceDist;
|
||||
|
||||
function replaceDist(url) {
|
||||
if (!isDev())
|
||||
return url;
|
||||
|
|
@ -297,3 +292,8 @@ function setSW(req, res, next) {
|
|||
|
||||
next();
|
||||
}
|
||||
|
||||
assign(cloudcmd, {
|
||||
depStore,
|
||||
createConfigManager,
|
||||
});
|
||||
|
|
@ -1,23 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('node:path');
|
||||
const {test, stub} = require('supertape');
|
||||
const cloudcmd = require('./cloudcmd.js');
|
||||
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
config: {
|
||||
auth: false,
|
||||
dropbox: false,
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
import path, {dirname} from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import serveOnce from 'serve-once';
|
||||
import {test, stub} from 'supertape';
|
||||
import cloudcmd, {
|
||||
_isDev,
|
||||
_replaceDist,
|
||||
createConfigManager,
|
||||
_getPrefix,
|
||||
_initAuth,
|
||||
} = cloudcmd;
|
||||
_getIndexPath,
|
||||
} from './cloudcmd.mjs';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
config: {
|
||||
auth: false,
|
||||
dropbox: false,
|
||||
},
|
||||
});
|
||||
|
||||
test('cloudcmd: defaults: config', (t) => {
|
||||
const configManager = createConfigManager();
|
||||
|
|
@ -158,7 +160,7 @@ test('cloudcmd: getIndexPath: production', (t) => {
|
|||
const isDev = false;
|
||||
const name = path.join(__dirname, '..', 'dist', 'index.html');
|
||||
|
||||
t.equal(cloudcmd._getIndexPath(isDev), name);
|
||||
t.equal(_getIndexPath(isDev), name);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -166,7 +168,7 @@ test('cloudcmd: getIndexPath: development', (t) => {
|
|||
const isDev = true;
|
||||
const name = path.join(__dirname, '..', 'dist-dev', 'index.html');
|
||||
|
||||
t.equal(cloudcmd._getIndexPath(isDev), name);
|
||||
t.equal(_getIndexPath(isDev), name);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -1,17 +1,12 @@
|
|||
'use strict';
|
||||
import {createRequire} from 'node:module';
|
||||
import {test, stub} from 'supertape';
|
||||
import {createConfig, _cryptoPass} from './config.js';
|
||||
import {apiURL} from '../common/cloudfunc.js';
|
||||
import {connect} from '../test/before.mjs';
|
||||
|
||||
const {test, stub} = require('supertape');
|
||||
const require = createRequire(import.meta.url);
|
||||
const fixture = require('./config.fixture.json');
|
||||
|
||||
const root = '../';
|
||||
const configPath = './config';
|
||||
|
||||
const {createConfig, _cryptoPass} = require(configPath);
|
||||
|
||||
const {apiURL} = require(`${root}common/cloudfunc`);
|
||||
|
||||
const fixture = require('./config.fixture');
|
||||
|
||||
const {connect} = require('../test/before');
|
||||
const config = createConfig();
|
||||
|
||||
test('config: manage', (t) => {
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
'use strict';
|
||||
import Config from '../config.js';
|
||||
import {once} from 'node:events';
|
||||
import test from 'supertape';
|
||||
import io from 'socket.io-client';
|
||||
import {connect} from '../../test/before.mjs';
|
||||
|
||||
const {once} = require('node:events');
|
||||
|
||||
const test = require('supertape');
|
||||
const io = require('socket.io-client');
|
||||
|
||||
const {connect} = require('../../test/before');
|
||||
const config = require('../config').createConfig();
|
||||
const config = Config.createConfig();
|
||||
|
||||
test('distribute: export', async (t) => {
|
||||
const defaultConfig = {
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
'use strict';
|
||||
import {createRequire} from 'node:module';
|
||||
import process from 'node:process';
|
||||
import test from 'supertape';
|
||||
import {promisify} from 'node:util';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import {connect} from '../../test/before.mjs';
|
||||
import {createConfigManager} from '../cloudcmd.mjs';
|
||||
|
||||
const process = require('node:process');
|
||||
const test = require('supertape');
|
||||
const {promisify} = require('node:util');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
|
||||
const {connect} = require('../../test/before');
|
||||
const {createConfigManager} = require('../cloudcmd');
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const distribute = {
|
||||
import: promisify(require('./import')),
|
||||
|
|
@ -1,28 +1,24 @@
|
|||
'use strict';
|
||||
import fs from 'node:fs';
|
||||
import {join} from 'node:path';
|
||||
import {promisify} from 'node:util';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import test from 'supertape';
|
||||
import serveOnce from 'serve-once';
|
||||
import markdown from './index.js';
|
||||
import cloudcmd from '../cloudcmd.mjs';
|
||||
|
||||
const fs = require('node:fs');
|
||||
const {join} = require('node:path');
|
||||
const {promisify} = require('node:util');
|
||||
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const serveOnce = require('serve-once');
|
||||
const test = require('supertape');
|
||||
|
||||
const markdown = require('.');
|
||||
|
||||
const cloudcmd = require('../..');
|
||||
const config = {
|
||||
auth: false,
|
||||
};
|
||||
|
||||
const configManager = cloudcmd.createConfigManager();
|
||||
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
config,
|
||||
configManager,
|
||||
});
|
||||
|
||||
const fixtureDir = join(__dirname, 'fixture');
|
||||
const fixtureDir = new URL('fixture', import.meta.url).pathname;
|
||||
|
||||
const _markdown = promisify(markdown);
|
||||
|
||||
|
|
@ -93,7 +89,7 @@ test('cloudcmd: markdown: no request', async (t) => {
|
|||
|
||||
test('cloudcmd: markdown', async (t) => {
|
||||
const configManager = cloudcmd.createConfigManager();
|
||||
const fixtureDir = join(__dirname, 'fixture');
|
||||
const fixtureDir = new URL('fixture', import.meta.url).pathname;
|
||||
const config = {
|
||||
auth: false,
|
||||
root: fixtureDir,
|
||||
|
|
@ -112,7 +108,7 @@ test('cloudcmd: markdown', async (t) => {
|
|||
|
||||
test('cloudcmd: markdown: zip', async (t) => {
|
||||
const configManager = cloudcmd.createConfigManager();
|
||||
const fixtureDir = join(__dirname, 'fixture');
|
||||
const fixtureDir = new URL('fixture', import.meta.url).pathname;
|
||||
const config = {
|
||||
auth: false,
|
||||
root: fixtureDir,
|
||||
|
|
@ -1,18 +1,15 @@
|
|||
'use strict';
|
||||
import path, {dirname} from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {Readable} from 'node:stream';
|
||||
import fs from 'node:fs';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import {test, stub} from 'supertape';
|
||||
import serveOnce from 'serve-once';
|
||||
import cloudcmd from './cloudcmd.mjs';
|
||||
import {_getReadDir} from './route.js';
|
||||
|
||||
const {Readable} = require('node:stream');
|
||||
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {test, stub} = require('supertape');
|
||||
|
||||
const cloudcmd = require('./cloudcmd');
|
||||
|
||||
const serveOnce = require('serve-once');
|
||||
|
||||
const {_getReadDir} = require('./route');
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const fixtureDir = path.join(__dirname, '..', 'test', 'fixture');
|
||||
const {createConfigManager} = cloudcmd;
|
||||
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
import cloudcmd from './cloudcmd.js';
|
||||
import http from 'node:http';
|
||||
import {promisify} from 'node:util';
|
||||
import process from 'node:process';
|
||||
import currify from 'currify';
|
||||
import squad from 'squad';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import wraptile from 'wraptile';
|
||||
import compression from 'compression';
|
||||
import threadIt from 'thread-it';
|
||||
import exit from './exit.js';
|
||||
import opn from 'open';
|
||||
import express from 'express';
|
||||
import {Server} from 'socket.io';
|
||||
import tryRequire from 'tryrequire';
|
||||
import process from 'node:process';
|
||||
import wraptile from 'wraptile';
|
||||
import compression from 'compression';
|
||||
import threadIt from 'thread-it';
|
||||
import exit from './exit.js';
|
||||
import cloudcmd from './cloudcmd.mjs';
|
||||
|
||||
const bind = (f, self) => f.bind(self);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const {test, stub} = require('supertape');
|
||||
|
||||
const terminal = require('./terminal');
|
||||
const {createConfigManager} = require('./cloudcmd');
|
||||
import {test, stub} from 'supertape';
|
||||
import terminal from './terminal.js';
|
||||
import {createConfigManager} from './cloudcmd.mjs';
|
||||
|
||||
test('cloudcmd: terminal: disabled', (t) => {
|
||||
const config = createConfigManager();
|
||||
|
|
@ -1,26 +1,25 @@
|
|||
'use strict';
|
||||
import {createRequire} from 'node:module';
|
||||
import {homedir} from 'node:os';
|
||||
import {readFile as _readFile} from 'node:fs/promises';
|
||||
import {join} from 'node:path';
|
||||
import montag from 'montag';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import currify from 'currify';
|
||||
import threadIt from 'thread-it';
|
||||
import {codeframe} from 'putout';
|
||||
|
||||
const {homedir} = require('node:os');
|
||||
const {readFile: _readFile} = require('node:fs/promises');
|
||||
|
||||
const {join} = require('node:path');
|
||||
|
||||
const montag = require('montag');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const currify = require('currify');
|
||||
const threadIt = require('thread-it');
|
||||
const {codeframe} = require('putout');
|
||||
const require = createRequire(import.meta.url);
|
||||
const putout = threadIt(require.resolve('putout'));
|
||||
|
||||
threadIt.init();
|
||||
// warm up worker cache
|
||||
transpile('');
|
||||
|
||||
const URL = '/api/v1/user-menu';
|
||||
const DEFAULT_MENU_PATH = join(__dirname, '../static/user-menu.js');
|
||||
const PREFIX = '/api/v1/user-menu';
|
||||
const DEFAULT_MENU_PATH = new URL('../static/user-menu.js', import.meta.url).pathname;
|
||||
|
||||
module.exports = currify(async ({menuName, readFile = _readFile}, req, res, next) => {
|
||||
if (req.url.indexOf(URL))
|
||||
export default currify(async ({menuName, readFile = _readFile}, req, res, next) => {
|
||||
if (!req.url.startsWith(PREFIX))
|
||||
return next();
|
||||
|
||||
const {method} = req;
|
||||
|
|
@ -38,7 +37,7 @@ module.exports = currify(async ({menuName, readFile = _readFile}, req, res, next
|
|||
|
||||
async function onGET({req, res, menuName, readFile}) {
|
||||
const {dir} = req.query;
|
||||
const url = req.url.replace(URL, '');
|
||||
const url = req.url.replace(PREFIX, '');
|
||||
|
||||
if (url === '/default')
|
||||
return sendDefaultMenu(res);
|
||||
|
|
@ -1,20 +1,19 @@
|
|||
'use strict';
|
||||
import {dirname, join} from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {test, stub} from 'supertape';
|
||||
import serveOnce from 'serve-once';
|
||||
import threadIt from 'thread-it';
|
||||
import userMenu from './user-menu.mjs';
|
||||
import {readFileSync} from 'node:fs';
|
||||
|
||||
const {join} = require('node:path');
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const {test, stub} = require('supertape');
|
||||
|
||||
const serveOnce = require('serve-once');
|
||||
const threadIt = require('thread-it');
|
||||
|
||||
const userMenu = require('./user-menu');
|
||||
|
||||
const {readFileSync} = require('node:fs');
|
||||
const {request} = serveOnce(userMenu);
|
||||
const userMenuPath = join(__dirname, '..', '.cloudcmd.menu.js');
|
||||
const userMenuFile = readFileSync(userMenuPath, 'utf8');
|
||||
|
||||
const fixtureDir = join(__dirname, 'fixture-user-menu');
|
||||
const fixtureDir = new URL('fixture-user-menu', import.meta.url).pathname;
|
||||
const fixtureMoveName = join(fixtureDir, 'io-mv.js');
|
||||
const fixtureMoveFixName = join(fixtureDir, 'io-mv-fix.js');
|
||||
const fixtureCopyName = join(fixtureDir, 'io-cp.js');
|
||||
|
|
@ -1,10 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const {test, stub} = require('supertape');
|
||||
const tryCatch = require('try-catch');
|
||||
|
||||
const validate = require('./validate');
|
||||
const cloudcmd = require('./cloudcmd');
|
||||
import {test, stub} from 'supertape';
|
||||
import tryCatch from 'try-catch';
|
||||
import validate from './validate.js';
|
||||
import cloudcmd from './cloudcmd.mjs';
|
||||
|
||||
test('validate: root: bad', (t) => {
|
||||
const config = {
|
||||
|
|
@ -1,24 +1,25 @@
|
|||
'use strict';
|
||||
import process from 'node:process';
|
||||
import http from 'node:http';
|
||||
import os from 'node:os';
|
||||
import express from 'express';
|
||||
import {Server} from 'socket.io';
|
||||
import writejson from 'writejson';
|
||||
import readjson from 'readjson';
|
||||
import {promisify} from 'node:util';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {dirname} from 'node:path';
|
||||
import cloudcmd from '../server/cloudcmd.mjs';
|
||||
|
||||
const process = require('node:process');
|
||||
const http = require('node:http');
|
||||
const os = require('node:os');
|
||||
|
||||
const express = require('express');
|
||||
const io = require('socket.io');
|
||||
const writejson = require('writejson');
|
||||
const readjson = require('readjson');
|
||||
const {promisify} = require('node:util');
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
const cloudcmd = require('../server/cloudcmd');
|
||||
const {assign} = Object;
|
||||
|
||||
const pathConfig = os.homedir() + '/.cloudcmd.json';
|
||||
const currentConfig = readjson.sync.try(pathConfig);
|
||||
|
||||
module.exports = before;
|
||||
export default before;
|
||||
|
||||
function before(options, fn = options) {
|
||||
const {
|
||||
|
|
@ -38,7 +39,7 @@ function before(options, fn = options) {
|
|||
server.close(cb);
|
||||
};
|
||||
|
||||
const socket = io(server);
|
||||
const socket = new Server(server);
|
||||
|
||||
app.use(cloudcmd({
|
||||
socket,
|
||||
|
|
@ -54,7 +55,7 @@ function before(options, fn = options) {
|
|||
});
|
||||
}
|
||||
|
||||
module.exports.connect = promisify((options, fn = options) => {
|
||||
export const connect = promisify((options, fn = options) => {
|
||||
before(options, (port, done) => {
|
||||
fn(null, {
|
||||
port,
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
'use strict';
|
||||
import serveOnce from 'serve-once';
|
||||
import test from 'supertape';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
|
||||
const test = require('supertape');
|
||||
|
||||
const cloudcmd = require('../..');
|
||||
const configManager = cloudcmd.createConfigManager();
|
||||
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
config: {
|
||||
auth: false,
|
||||
},
|
||||
|
|
@ -1,24 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
const {mkdirSync} = require('node:fs');
|
||||
const {join} = require('node:path');
|
||||
const test = require('supertape');
|
||||
const rimraf = require('rimraf');
|
||||
import {dirname, join} from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import serveOnce from 'serve-once';
|
||||
import {mkdirSync} from 'node:fs';
|
||||
import test from 'supertape';
|
||||
import {rimraf} from 'rimraf';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const config = {
|
||||
root: join(__dirname, '..'),
|
||||
root: new URL('..', import.meta.url).pathname,
|
||||
};
|
||||
|
||||
const cloudcmd = require('../..');
|
||||
const configManager = cloudcmd.createConfigManager();
|
||||
|
||||
configManager('auth', false);
|
||||
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
config,
|
||||
configManager,
|
||||
});
|
||||
|
||||
const fixtureDir = join(__dirname, '..', 'fixture') + '/';
|
||||
|
||||
test('cloudcmd: rest: copy', async (t) => {
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
'use strict';
|
||||
import serveOnce from 'serve-once';
|
||||
import test from 'supertape';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
|
||||
const test = require('supertape');
|
||||
|
||||
const cloudcmd = require('../..');
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
config: {
|
||||
auth: false,
|
||||
},
|
||||
|
|
@ -1,28 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
const wait = require('@iocmd/wait');
|
||||
const {EventEmitter} = require('node:events');
|
||||
const fs = require('node:fs');
|
||||
|
||||
const {test, stub} = require('supertape');
|
||||
const {Volume} = require('memfs');
|
||||
const {ufs} = require('unionfs');
|
||||
const serveOnce = require('serve-once');
|
||||
|
||||
const cloudcmd = require('../../server/cloudcmd.js');
|
||||
import wait from '@iocmd/wait';
|
||||
import {EventEmitter} from 'node:events';
|
||||
import {test, stub} from 'supertape';
|
||||
import serveOnce from 'serve-once';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
|
||||
test('cloudcmd: rest: move', async (t) => {
|
||||
const volume = {
|
||||
'/fixture/move.txt': 'hello',
|
||||
'/fixture/tmp/a.txt': 'a',
|
||||
};
|
||||
|
||||
const vol = Volume.fromJSON(volume, '/');
|
||||
|
||||
const unionFS = ufs
|
||||
.use(vol)
|
||||
.use(fs);
|
||||
|
||||
const move = new EventEmitter();
|
||||
const moveFiles = stub().returns(move);
|
||||
|
||||
|
|
@ -103,4 +85,3 @@ test('cloudcmd: rest: move: no to', async (t) => {
|
|||
t.equal(body, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -1,18 +1,16 @@
|
|||
'use strict';
|
||||
import fs from 'node:fs';
|
||||
import {join, dirname} from 'node:path';
|
||||
import {promisify} from 'node:util';
|
||||
import test from 'supertape';
|
||||
import tar from 'tar-stream';
|
||||
import gunzip from 'gunzip-maybe';
|
||||
import pullout from 'pullout';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
import serveOnce from 'serve-once';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
|
||||
const mockRequire = require('mock-require');
|
||||
const fs = require('node:fs');
|
||||
const {join} = require('node:path');
|
||||
const {promisify} = require('node:util');
|
||||
|
||||
const test = require('supertape');
|
||||
const tar = require('tar-stream');
|
||||
const gunzip = require('gunzip-maybe');
|
||||
const pullout = require('pullout');
|
||||
|
||||
const cloudcmd = require('../../server/cloudcmd.js');
|
||||
const serveOnce = require('serve-once');
|
||||
const {reRequire} = mockRequire;
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const pathZipFixture = join(__dirname, '..', 'fixture/pack.zip');
|
||||
|
||||
const pathTarFixture = join(__dirname, '..', 'fixture/pack.tar.gz');
|
||||
|
|
@ -20,7 +18,7 @@ const pathTarFixture = join(__dirname, '..', 'fixture/pack.tar.gz');
|
|||
const defaultOptions = {
|
||||
config: {
|
||||
auth: false,
|
||||
root: join(__dirname, '..'),
|
||||
root: new URL('..', import.meta.url).pathname,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -38,7 +36,6 @@ const once = promisify((name, extract, fn) => {
|
|||
});
|
||||
|
||||
test('cloudcmd: rest: pack: tar: get', async (t) => {
|
||||
debugger;
|
||||
const config = {
|
||||
packer: 'tar',
|
||||
auth: false,
|
||||
|
|
@ -67,7 +64,9 @@ test('cloudcmd: rest: pack: tar: get', async (t) => {
|
|||
|
||||
t.equal(file, data, 'should pack data');
|
||||
t.end();
|
||||
}, {timeout: 7000});
|
||||
}, {
|
||||
timeout: 7000,
|
||||
});
|
||||
|
||||
test('cloudcmd: rest: pack: tar: put: file', async (t) => {
|
||||
const config = {
|
||||
|
|
@ -233,4 +232,3 @@ function getPackOptions(to, names = ['pack']) {
|
|||
from: '/fixture',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1,17 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('node:fs');
|
||||
|
||||
const test = require('supertape');
|
||||
const {Volume} = require('memfs');
|
||||
const {ufs} = require('unionfs');
|
||||
|
||||
const serveOnce = require('serve-once');
|
||||
|
||||
const cloudcmd = require('../../server/cloudcmd.js');
|
||||
const cloudcmdPath = '../../';
|
||||
const dir = `${cloudcmdPath}server/`;
|
||||
const restPath = `${dir}rest`;
|
||||
import fs from 'node:fs';
|
||||
import test from 'supertape';
|
||||
import {Volume} from 'memfs';
|
||||
import {ufs} from 'unionfs';
|
||||
import serveOnce from 'serve-once';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
|
||||
test('cloudcmd: rest: rename', async (t) => {
|
||||
const volume = {
|
||||
|
|
@ -100,4 +92,3 @@ test('cloudcmd: rest: rename: no to', async (t) => {
|
|||
t.equal(body, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
'use strict';
|
||||
import path, {dirname} from 'node:path';
|
||||
import {once} from 'node:events';
|
||||
import test from 'supertape';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {createRequire} from 'node:module';
|
||||
import io from 'socket.io-client';
|
||||
import {connect} from '../before.mjs';
|
||||
|
||||
const path = require('node:path');
|
||||
const {once} = require('node:events');
|
||||
|
||||
const test = require('supertape');
|
||||
const io = require('socket.io-client');
|
||||
|
||||
const {connect} = require('../before');
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const require = createRequire(import.meta.url);
|
||||
const configPath = path.join(__dirname, '../..', 'server', 'config');
|
||||
const configFn = require(configPath).createConfig();
|
||||
|
||||
|
|
@ -1,16 +1,21 @@
|
|||
'use strict';
|
||||
import {createRequire} from 'node:module';
|
||||
import {dirname, join} from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
|
||||
const {join} = require('node:path');
|
||||
const {test, stub} = require('supertape');
|
||||
import serveOnce from 'serve-once';
|
||||
import {test, stub} from 'supertape';
|
||||
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const require = createRequire(import.meta.url);
|
||||
const cloudcmdPath = join(__dirname, '..', '..');
|
||||
|
||||
const modulesPath = join(cloudcmdPath, 'json', 'modules.json');
|
||||
|
||||
const localModules = require(modulesPath);
|
||||
const modulas = require(`${cloudcmdPath}/server/modulas`);
|
||||
|
||||
const cloudcmd = require(cloudcmdPath);
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
const modulas = require(`../../server/modulas`);
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
config: {
|
||||
auth: false,
|
||||
dropbox: false,
|
||||
|
|
@ -1,17 +1,14 @@
|
|||
'use strict';
|
||||
import serveOnce from 'serve-once';
|
||||
import test from 'supertape';
|
||||
import criton from 'criton';
|
||||
import cloudcmd from '../server/cloudcmd.mjs';
|
||||
|
||||
const test = require('supertape');
|
||||
const criton = require('criton');
|
||||
|
||||
const cloudcmd = require('..');
|
||||
const config = {
|
||||
auth: false,
|
||||
};
|
||||
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
config,
|
||||
});
|
||||
|
||||
const configFn = cloudcmd.createConfigManager();
|
||||
|
||||
test('cloudcmd: static', async (t) => {
|
||||
Loading…
Add table
Add a link
Reference in a new issue