mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature: common: cloudfunc: migrate to ESM
This commit is contained in:
parent
a063353a27
commit
64654e8d5c
19 changed files with 78 additions and 88 deletions
|
|
@ -14,12 +14,12 @@ import dword from 'dword';
|
|||
import deepword from 'deepword';
|
||||
import nomine from 'nomine';
|
||||
import fileop from '@cloudcmd/fileop';
|
||||
import cloudfunc from '../common/cloudfunc.js';
|
||||
import * as cloudfunc from '../common/cloudfunc.mjs';
|
||||
import authentication from './auth.js';
|
||||
import {createConfig, configPath} from './config.js';
|
||||
import {createConfig, configPath} from './config.mjs';
|
||||
import modulas from './modulas.mjs';
|
||||
import userMenu from './user-menu.mjs';
|
||||
import rest from './rest/index.js';
|
||||
import rest from './rest/index.mjs';
|
||||
import route from './route.mjs';
|
||||
import * as validate from './validate.mjs';
|
||||
import prefixer from './prefixer.js';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
'use strict';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {dirname} from 'node:path';
|
||||
import {createRequire} from 'node:module';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const require = createRequire(import.meta.url);
|
||||
const DIR_SERVER = `${__dirname}/`;
|
||||
const DIR_COMMON = '../common/';
|
||||
|
||||
const path = require('node:path');
|
||||
|
||||
const fs = require('node:fs');
|
||||
|
|
@ -21,7 +26,7 @@ const {tryCatch} = require('try-catch');
|
|||
const criton = require('criton');
|
||||
const exit = require(`${DIR_SERVER}exit`);
|
||||
|
||||
const CloudFunc = require(`${DIR_COMMON}cloudfunc`);
|
||||
const CloudFunc = require('../common/cloudfunc.mjs');
|
||||
const isUndefined = (a) => typeof a === 'undefined';
|
||||
const DIR = `${DIR_SERVER}../`;
|
||||
const HOME = homedir();
|
||||
|
|
@ -36,7 +41,6 @@ const key = (a) => Object
|
|||
.pop();
|
||||
|
||||
const ConfigPath = path.join(DIR, 'json/config.json');
|
||||
const ConfigHome = path.join(HOME, '.cloudcmd.json');
|
||||
|
||||
const connection = currify(_connection);
|
||||
const connectionWrapped = wraptile(_connection);
|
||||
|
|
@ -65,8 +69,7 @@ function read(filename) {
|
|||
};
|
||||
}
|
||||
|
||||
module.exports.createConfig = createConfig;
|
||||
module.exports.configPath = ConfigHome;
|
||||
export const configPath = path.join(HOME, '.cloudcmd.json');
|
||||
|
||||
const manageListen = currify((manage, socket, auth) => {
|
||||
if (!manage('configDialog'))
|
||||
|
|
@ -84,7 +87,7 @@ function initWrite(filename, configManager) {
|
|||
return resolve;
|
||||
}
|
||||
|
||||
function createConfig({configPath} = {}) {
|
||||
export function createConfig({configPath} = {}) {
|
||||
const config = {};
|
||||
const changeEmitter = new Emitter();
|
||||
|
||||
|
|
@ -237,7 +240,8 @@ function traverse([manage, json]) {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports._cryptoPass = cryptoPass;
|
||||
export const _cryptoPass = cryptoPass;
|
||||
|
||||
function cryptoPass(manage, json) {
|
||||
const algo = manage('algo');
|
||||
|
||||
|
|
@ -1,26 +1,21 @@
|
|||
'use strict';
|
||||
import path from 'node:path';
|
||||
import _fs from 'node:fs';
|
||||
import process from 'node:process';
|
||||
import jaguar from 'jaguar';
|
||||
import onezip from 'onezip';
|
||||
import inly from 'inly';
|
||||
import wraptile from 'wraptile';
|
||||
import currify from 'currify';
|
||||
import pullout from 'pullout';
|
||||
import json from 'jonny';
|
||||
import ponse from 'ponse';
|
||||
import copymitter from 'copymitter';
|
||||
import _moveFiles from '@cloudcmd/move-files';
|
||||
import root from '../root.js';
|
||||
import * as CloudFunc from '../../common/cloudfunc.mjs';
|
||||
import markdown from '../markdown/index.js';
|
||||
import info from './info.js';
|
||||
|
||||
const path = require('node:path');
|
||||
const _fs = require('node:fs');
|
||||
|
||||
const process = require('node:process');
|
||||
|
||||
const jaguar = require('jaguar');
|
||||
const onezip = require('onezip');
|
||||
const inly = require('inly');
|
||||
const wraptile = require('wraptile');
|
||||
const currify = require('currify');
|
||||
const pullout = require('pullout');
|
||||
const json = require('jonny');
|
||||
const ponse = require('ponse');
|
||||
|
||||
const copymitter = require('copymitter');
|
||||
const _moveFiles = require('@cloudcmd/move-files');
|
||||
|
||||
const root = require(`../root`);
|
||||
const CloudFunc = require(`../../common/cloudfunc`);
|
||||
const markdown = require(`../markdown/index.js`);
|
||||
const info = require('./info');
|
||||
const isUndefined = (a) => typeof a === 'undefined';
|
||||
const isRootAll = (root, names) => names.some(isRootWin32(root));
|
||||
const isString = (a) => typeof a === 'string';
|
||||
|
|
@ -37,7 +32,7 @@ const UserError = (msg) => {
|
|||
return error;
|
||||
};
|
||||
|
||||
module.exports = currify(({config, fs = _fs, moveFiles = _moveFiles}, request, response, next) => {
|
||||
export default currify(({config, fs = _fs, moveFiles = _moveFiles}, request, response, next) => {
|
||||
const name = ponse.getPathName(request);
|
||||
const regExp = RegExp(`^${apiURL}`);
|
||||
const is = regExp.test(name);
|
||||
|
|
@ -188,7 +183,8 @@ const getRenameMsg = (from, to) => {
|
|||
return msg;
|
||||
};
|
||||
|
||||
module.exports._onPUT = onPUT;
|
||||
export const _onPUT = onPUT;
|
||||
|
||||
function onPUT({name, fs, moveFiles, config, body}, callback) {
|
||||
checkPut(name, body, callback);
|
||||
|
||||
|
|
@ -368,10 +364,10 @@ const isRootWin32 = currify((root, path) => {
|
|||
return isWin32 && isRoot && isConfig;
|
||||
});
|
||||
|
||||
module.exports._isRootWin32 = isRootWin32;
|
||||
module.exports._isRootAll = isRootAll;
|
||||
export const _isRootWin32 = isRootWin32;
|
||||
export const _isRootAll = isRootAll;
|
||||
|
||||
module.exports._getWin32RootMsg = getWin32RootMsg;
|
||||
export const _getWin32RootMsg = getWin32RootMsg;
|
||||
|
||||
function getWin32RootMsg() {
|
||||
const message = 'Could not copy from/to root on windows!';
|
||||
|
|
@ -388,7 +384,7 @@ function parseData(data) {
|
|||
return json.stringify(data);
|
||||
}
|
||||
|
||||
module.exports._formatMsg = formatMsg;
|
||||
export const _formatMsg = formatMsg;
|
||||
|
||||
function formatMsg(msg, data, status) {
|
||||
const value = parseData(data);
|
||||
|
|
@ -12,7 +12,7 @@ import pipe from 'pipe-io';
|
|||
import {contentType} from 'mime-types';
|
||||
import root from './root.js';
|
||||
import prefixer from './prefixer.js';
|
||||
import CloudFunc from '../common/cloudfunc.js';
|
||||
import * as CloudFunc from '../common/cloudfunc.mjs';
|
||||
import Template from './template.js';
|
||||
import {getColumns} from './columns.mjs';
|
||||
import {getThemes} from './theme.mjs';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue