mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature: cloudcmd: migrate to ESM
This commit is contained in:
parent
e8a81c49ea
commit
4533a25c6f
184 changed files with 339 additions and 388 deletions
|
|
@ -8,7 +8,7 @@ import express from 'express';
|
|||
import {Server} from 'socket.io';
|
||||
import writejson from 'writejson';
|
||||
import readjson from 'readjson';
|
||||
import cloudcmd from '../server/cloudcmd.mjs';
|
||||
import cloudcmd from '../server/cloudcmd.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
|
@ -1,14 +1,15 @@
|
|||
'use strict';
|
||||
import fs from 'node:fs';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {dirname} from 'node:path';
|
||||
import {tryCatch} from 'try-catch';
|
||||
import {test} from 'supertape';
|
||||
import readFilesSync from '@cloudcmd/read-files-sync';
|
||||
import * as CloudFunc from '#common/cloudfunc';
|
||||
import {time, timeEnd} from '#common/util';
|
||||
|
||||
const fs = require('node:fs');
|
||||
|
||||
const {tryCatch} = require('try-catch');
|
||||
const {test} = require('supertape');
|
||||
const readFilesSync = require('@cloudcmd/read-files-sync');
|
||||
|
||||
const CloudFunc = require('#common/cloudfunc');
|
||||
const {time, timeEnd} = require(`../../common/util.mjs`);
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
|
||||
const __dirname = dirname(__filename);
|
||||
const DIR = `${__dirname}/../../`;
|
||||
|
||||
const TMPLDIR = `${DIR}tmpl/`;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import serveOnce from 'serve-once';
|
||||
import test from 'supertape';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
import cloudcmd from '../../server/cloudcmd.js';
|
||||
|
||||
const configManager = cloudcmd.createConfigManager();
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
|
|
@ -4,7 +4,7 @@ import {mkdirSync} from 'node:fs';
|
|||
import serveOnce from 'serve-once';
|
||||
import test from 'supertape';
|
||||
import {rimraf} from 'rimraf';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
import cloudcmd from '../../server/cloudcmd.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import serveOnce from 'serve-once';
|
||||
import test from 'supertape';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
import cloudcmd from '../../server/cloudcmd.js';
|
||||
|
||||
const {request} = serveOnce(cloudcmd, {
|
||||
config: {
|
||||
|
|
@ -2,7 +2,7 @@ import {EventEmitter} from 'node:events';
|
|||
import wait from '@iocmd/wait';
|
||||
import {test, stub} from 'supertape';
|
||||
import serveOnce from 'serve-once';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
import cloudcmd from '../../server/cloudcmd.js';
|
||||
|
||||
test('cloudcmd: rest: move', async (t) => {
|
||||
const move = new EventEmitter();
|
||||
|
|
@ -7,7 +7,7 @@ import tar from 'tar-stream';
|
|||
import gunzip from 'gunzip-maybe';
|
||||
import pullout from 'pullout';
|
||||
import serveOnce from 'serve-once';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
import cloudcmd from '../../server/cloudcmd.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
|
@ -3,7 +3,7 @@ import test from 'supertape';
|
|||
import {Volume} from 'memfs';
|
||||
import {ufs} from 'unionfs';
|
||||
import serveOnce from 'serve-once';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
import cloudcmd from '../../server/cloudcmd.js';
|
||||
|
||||
test('cloudcmd: rest: rename', async (t) => {
|
||||
const volume = {
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import {once} from 'node:events';
|
||||
import test from 'supertape';
|
||||
import io from 'socket.io-client';
|
||||
import {connect} from '../before.mjs';
|
||||
import {createConfig} from '../../server/config.mjs';
|
||||
import {connect} from '../before.js';
|
||||
import {createConfig} from '../../server/config.js';
|
||||
|
||||
const configFn = createConfig();
|
||||
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const process = require('node:process');
|
||||
const {test} = require('supertape');
|
||||
const env = require('../../server/env.mjs');
|
||||
import process from 'node:process';
|
||||
import {test} from 'supertape';
|
||||
import * as env from '../../server/env.js';
|
||||
|
||||
test('env: small', (t) => {
|
||||
process.env.cloudcmd_hello = 'world';
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import {dirname, join} from 'node:path';
|
|||
import {fileURLToPath} from 'node:url';
|
||||
import serveOnce from 'serve-once';
|
||||
import {test, stub} from 'supertape';
|
||||
import cloudcmd from '../../server/cloudcmd.mjs';
|
||||
import modulas from '../../server/modulas.mjs';
|
||||
import cloudcmd from '../../server/cloudcmd.js';
|
||||
import modulas from '../../server/modulas.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const {test} = require('supertape');
|
||||
const {tryCatch} = require('try-catch');
|
||||
|
||||
const showConfig = require('../../server/show-config');
|
||||
|
||||
test('cloudcmd: show-config: no arguments', (t) => {
|
||||
const [error] = tryCatch(showConfig);
|
||||
|
||||
t.equal(error.message, 'config could not be empty!', 'should throw when no config');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: show-config: bad arguments', (t) => {
|
||||
const [error] = tryCatch(showConfig, 'hello');
|
||||
|
||||
t.equal(error.message, 'config should be an object!', 'should throw when config not object');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: show-config: empty: return', (t) => {
|
||||
t.equal(showConfig({}), '', 'should return string');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: show-config: return', (t) => {
|
||||
const config = {
|
||||
hello: 'world',
|
||||
};
|
||||
|
||||
const result = [
|
||||
'+-------+--------------------------------+\n',
|
||||
'| hello | world |\n',
|
||||
'+-------+--------------------------------+\n',
|
||||
].join('');
|
||||
|
||||
t.equal(showConfig(config), result, 'should return table');
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -2,7 +2,7 @@ import {Buffer} from 'node:buffer';
|
|||
import serveOnce from 'serve-once';
|
||||
import test from 'supertape';
|
||||
import criton from 'criton';
|
||||
import cloudcmd from '../server/cloudcmd.mjs';
|
||||
import cloudcmd from '../server/cloudcmd.js';
|
||||
|
||||
const config = {
|
||||
auth: false,
|
||||
Loading…
Add table
Add a link
Reference in a new issue