mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(cloudcmd) remove plugins
This commit is contained in:
parent
b93e759ba6
commit
a61eb22b62
7 changed files with 2 additions and 181 deletions
5
HELP.md
5
HELP.md
|
|
@ -680,10 +680,6 @@ const config = {
|
|||
name: 'cloudcmd :)'
|
||||
};
|
||||
|
||||
const plugins = [
|
||||
__dirname + '/plugin.js'
|
||||
];
|
||||
|
||||
const filePicker = {
|
||||
data: {
|
||||
FilePicker: {
|
||||
|
|
@ -709,7 +705,6 @@ const configManager = createConfigManager({
|
|||
app.use(prefix, cloudcmd({
|
||||
socket, // used by Config, Edit (optional) and Console (required)
|
||||
config, // config data (optional)
|
||||
plugins, // DEPRECATED, use User Menu instead
|
||||
modules, // optional
|
||||
configManager, // optional
|
||||
));
|
||||
|
|
|
|||
|
|
@ -90,10 +90,6 @@ const config = {
|
|||
name: 'cloudcmd :)',
|
||||
};
|
||||
|
||||
const plugins = [
|
||||
__dirname + '/plugin.js'
|
||||
];
|
||||
|
||||
const filePicker = {
|
||||
data: {
|
||||
FilePicker: {
|
||||
|
|
@ -119,7 +115,6 @@ const configManager = createConfigManager({
|
|||
app.use(prefix, cloudcmd({
|
||||
socket, // used by Config, Edit (optional) and Console (required)
|
||||
config, // config data (optional)
|
||||
plugins, // DEPRECATED, use User Menu instead
|
||||
modules, // optional
|
||||
configManager, // optional
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -141,7 +141,6 @@ function CloudCmdProto(DOM) {
|
|||
const func = bind(exec.series, [
|
||||
initModules,
|
||||
baseInit,
|
||||
loadPlugins,
|
||||
loadStyle,
|
||||
exec.with(CloudCmd.route, location.hash),
|
||||
], noop);
|
||||
|
|
@ -182,13 +181,6 @@ function CloudCmdProto(DOM) {
|
|||
load.css(name, callback);
|
||||
}
|
||||
|
||||
function loadPlugins(callback) {
|
||||
const {prefix} = CloudCmd;
|
||||
const plugins = prefix + '/plugins.js';
|
||||
|
||||
load.js(plugins, callback);
|
||||
}
|
||||
|
||||
this.route = (path) => {
|
||||
const query = path.split('/');
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ const rest = require(DIR + 'rest');
|
|||
const route = require(DIR + 'route');
|
||||
const validate = require(DIR + 'validate');
|
||||
const prefixer = require(DIR + 'prefixer');
|
||||
const pluginer = require(DIR + 'plugins');
|
||||
const terminal = require(DIR + 'terminal');
|
||||
const distribute = require(DIR + 'distribute');
|
||||
|
||||
|
|
@ -53,15 +52,10 @@ module.exports = (params) => {
|
|||
configPath,
|
||||
});
|
||||
|
||||
const {
|
||||
modules,
|
||||
plugins,
|
||||
} = p;
|
||||
const {modules} = p;
|
||||
|
||||
const keys = Object.keys(options);
|
||||
|
||||
checkPlugins(plugins);
|
||||
|
||||
for (const name of keys) {
|
||||
let value = options[name];
|
||||
|
||||
|
|
@ -90,7 +84,6 @@ module.exports = (params) => {
|
|||
});
|
||||
|
||||
return cloudcmd({
|
||||
plugins,
|
||||
modules,
|
||||
config,
|
||||
});
|
||||
|
|
@ -181,7 +174,7 @@ function listen({prefixSocket, socket, config}) {
|
|||
distribute.export(config, socket);
|
||||
}
|
||||
|
||||
function cloudcmd({plugins, modules, config}) {
|
||||
function cloudcmd({modules, config}) {
|
||||
const online = apart(config, 'online');
|
||||
const cache = false;
|
||||
const diff = apart(config, 'diff');
|
||||
|
|
@ -256,7 +249,6 @@ function cloudcmd({plugins, modules, config}) {
|
|||
html: defaultHtml,
|
||||
}),
|
||||
|
||||
pluginer(plugins),
|
||||
ponseStatic,
|
||||
]);
|
||||
|
||||
|
|
@ -297,11 +289,3 @@ function setSW(req, res, next) {
|
|||
next();
|
||||
}
|
||||
|
||||
function checkPlugins(plugins) {
|
||||
if (typeof plugins === 'undefined')
|
||||
return;
|
||||
|
||||
if (!Array.isArray(plugins))
|
||||
throw Error('plugins should be an array!');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,22 +23,6 @@ const {request} = require('serve-once')(cloudcmd, {
|
|||
},
|
||||
});
|
||||
|
||||
test('cloudcmd: args: no', (t) => {
|
||||
const fn = () => cloudcmd();
|
||||
|
||||
t.doesNotThrow(fn, /plugins should be an array!/, 'should throw when plugins not an array');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: args: plugins: error', (t) => {
|
||||
const fn = () => cloudcmd({
|
||||
plugins: '',
|
||||
});
|
||||
|
||||
t.throws(fn, /plugins should be an array!/, 'should throw when plugins not an array');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: defaults: config', (t) => {
|
||||
const configManager = createConfigManager();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const {deprecate} = require('util');
|
||||
const currify = require('currify');
|
||||
const {readPipe} = require('files-io');
|
||||
|
||||
module.exports = currify((plugins, req, res, next) => {
|
||||
if (req.url !== '/plugins.js')
|
||||
return next();
|
||||
|
||||
res.setHeader('content-type', 'application/javascript; charset=utf-8');
|
||||
|
||||
if (!plugins || !plugins.length)
|
||||
return res.send('');
|
||||
|
||||
readPlugin(plugins, res);
|
||||
});
|
||||
|
||||
const readPlugin = deprecate((plugins, res) => {
|
||||
readPipe(plugins, res).catch((e) => {
|
||||
res.end(e.message);
|
||||
});
|
||||
}, 'plugins deprecated. Use user menu instead', 'DEP0001');
|
||||
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const test = require('supertape');
|
||||
const cloudcmd = require('./cloudcmd');
|
||||
|
||||
const config = {
|
||||
auth: false,
|
||||
};
|
||||
|
||||
const {request} = require('serve-once')(cloudcmd, {
|
||||
config,
|
||||
});
|
||||
|
||||
test('cloudcmd: plugins: empty', async (t) => {
|
||||
const plugins = [];
|
||||
const options = {
|
||||
plugins,
|
||||
};
|
||||
|
||||
const {body} = await request.get('/plugins.js', {
|
||||
options,
|
||||
});
|
||||
|
||||
t.equal(body, '', 'should content be empty');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: plugins: empty: header', async (t) => {
|
||||
const plugins = [];
|
||||
const options = {
|
||||
plugins,
|
||||
};
|
||||
|
||||
const {headers} = await request.get('/plugins.js', {
|
||||
options,
|
||||
});
|
||||
|
||||
const expected = 'application/javascript; charset=utf-8';
|
||||
|
||||
t.equal(headers.get('content-type'), expected, 'should content be empty');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: plugins: one', async (t) => {
|
||||
const plugins = [
|
||||
__filename,
|
||||
];
|
||||
|
||||
const options = {
|
||||
plugins,
|
||||
};
|
||||
|
||||
const {body} = await request.get('/plugins.js', {
|
||||
options,
|
||||
});
|
||||
|
||||
const file = fs.readFileSync(__filename, 'utf8');
|
||||
|
||||
t.equal(body, file, 'should return file plugin content');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: plugins: one', async (t) => {
|
||||
const plugins = [
|
||||
__filename,
|
||||
];
|
||||
|
||||
const options = {
|
||||
plugins,
|
||||
};
|
||||
|
||||
const {headers} = await request.get('/plugins.js', {
|
||||
options,
|
||||
});
|
||||
|
||||
const expected = 'application/javascript; charset=utf-8';
|
||||
|
||||
t.equal(headers.get('content-type'), expected, 'should content be empty');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: plugins: load error', async (t) => {
|
||||
const noEntry = __filename + Math.random();
|
||||
const plugins = [
|
||||
__filename,
|
||||
noEntry,
|
||||
];
|
||||
|
||||
const msg = `ENOENT: no such file or directory, open '${noEntry}'`;
|
||||
|
||||
const options = {
|
||||
plugins,
|
||||
};
|
||||
|
||||
const {body} = await request.get('/plugins.js', {
|
||||
options,
|
||||
});
|
||||
|
||||
const file = fs.readFileSync(__filename, 'utf8') + msg;
|
||||
|
||||
t.equal(body, file, 'should return file plugin content');
|
||||
t.end();
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue