From 1a418d66f8f8e238af41a2ac6cd78779162b1241 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 14 Aug 2014 15:08:11 +0800 Subject: [PATCH] remove spm plugin #902 --- bin/spm | 28 ------------------- bin/spm-plugin | 53 ----------------------------------- index.js | 1 - lib/plugin.js | 75 -------------------------------------------------- 4 files changed, 157 deletions(-) delete mode 100755 bin/spm-plugin delete mode 100644 lib/plugin.js diff --git a/bin/spm b/bin/spm index 6e20b6dd..1116faef 100755 --- a/bin/spm +++ b/bin/spm @@ -6,7 +6,6 @@ var commander = require('commander'); require('colorful').colorful(); var run = require('../lib/utils/run'); var log = require('../lib/utils/log'); -var plugin = require('../lib/plugin'); var program = require('../lib/utils/program'); var spawn = require('win-spawn'); @@ -74,7 +73,6 @@ var packageCommands = { commander.on('--help', function() { console.log(' ' + 'System Commands:'.to.bold.magenta.color); console.log(); - program.printHelp(new program('plugin', 'plugin system for spm')); program.printHelp(new program('config', 'configuration for spm')); program.printHelp(new program('help', 'show help information')); console.log(); @@ -85,16 +83,6 @@ commander.on('--help', function() { program.printHelp(new program(key, packageCommands[key])); }); console.log(); - - var extensions = plugin.plugins(); - if (extensions.length) { - console.log(' ' + 'Plugin Commands:'.to.bold.blue.color); - console.log(); - extensions.forEach(function(cmd) { - program.printHelp(cmd); - }); - console.log(); - } }); commander.parse(process.argv); @@ -142,17 +130,6 @@ function executable(subcmd) { var commands = Object.keys(packageCommands); - var extensions = plugin.plugins(); - for (var i = 0; i < extensions.length; i++) { - var cmd = extensions[i]; - - if (subcmd === cmd.name) { - return cmd.binary; - } - - commands.push(cmd.name); - } - function printSimilar() { // guess commands commands = getSimilarCommands(subcmd, commands); @@ -166,11 +143,6 @@ function executable(subcmd) { console.log(' $', 'spm'.to.magenta.color, cmd.to.cyan.color); }); } - console.log(); - console.log(' It is not a built-in command, maybe it\'s a plugin.'); - console.log(' Try install this plugin: '); - console.log(); - console.log(' $', 'spm plugin'.to.magenta.color, 'install', subcmd.to.cyan.color); } try { diff --git a/bin/spm-plugin b/bin/spm-plugin deleted file mode 100755 index 4118461b..00000000 --- a/bin/spm-plugin +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env node - -var commander = require('commander'); -require('colorful').colorful(); -var plugin = require('../lib/plugin'); - -commander.usage(''); - -commander - .command('install ') - .description('install a spm plugin') - .action(install); - -commander - .command('uninstall ') - .description('remove a spm plugin') - .action(plugin.uninstall); - -commander - .command('list') - .description('list all plugins') - .action(plugin.list); - -commander.on('--help', function() { - console.log(' ' + 'How to use:'.to.bold.blue.color); - console.log(); - console.log(' install a plugin by ' + 'npm install'.to.cyan.color); - console.log(); - console.log(' $ ' + 'npm install '.to.cyan.color + 'spm-init'.to.magenta.color + ' -g'); - console.log(); - console.log(' install a plugin by ' + 'spm plugin'.to.cyan.color); - console.log(); - console.log(' $ ' + 'spm plugin install '.to.cyan.color + 'init'.to.magenta.color); - console.log(); -}); - -commander.parse(process.argv); - -var subcmd = commander.args[0]; - -if (!subcmd) { - process.stdout.write(commander.helpInformation()); - commander.emit('--help'); - process.exit(); -} - -function install(plugin) { - if (!/^spm-/.test(plugin)) { - plugin = 'spm-' + plugin; - } - var spawn = require('win-spawn'); - spawn('npm', ['install', '-g', plugin], {stdio: 'inherit', customFds: [0, 1, 2]}); -} diff --git a/index.js b/index.js index 0874f2f2..3cfb672a 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,6 @@ exports = module.exports; exports.version = require('./package').version; exports.client = require('./lib/client'); -exports.plugin = require('./lib/plugin'); exports.config = require('./lib/config'); exports.upload = require('./lib/upload'); exports.build = require('./lib/build'); diff --git a/lib/plugin.js b/lib/plugin.js deleted file mode 100644 index 3ad27227..00000000 --- a/lib/plugin.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Plugin System - * @author: Hsiaoming Yang - * - * ~/.spm/plugins.json - */ - -var path = require('path'); -var color = require('colorful'); -var spmrc = require('spmrc'); -var file = require('./sdk/file'); - -var homedir = spmrc.get('user.home'); -var pluginsPath = path.join(homedir, '.spm', 'plugin-3x.json'); - - -exports.install = function(options) { - // options: - // { - // "name": "init", - // "bin": "spm-init", - // "description": "create template ..." - // } - if (!options.name) { - throw new Error('name is missing.'); - } - options.binary = options.binary || options.bin; - - if (!options.binary) { - throw new Error('bin is missing.'); - } - - // support for shortname desc - options.description = options.description || options.desc; - - var plugins = getPlugins(); - var rv = plugins.filter(function(obj) { - return obj.name !== options.name; - }); - - rv.push({ - name: options.name, - binary: options.binary, - description: options.description - }); - - file.writeJSON(pluginsPath, rv); -}; - -exports.uninstall = function(name) { - var plugins = getPlugins(); - var rv = plugins.filter(function(obj) { - return obj.name !== name; - }); - - file.writeJSON(pluginsPath, rv); -}; - -exports.list = function() { - var plugins = getPlugins(); - plugins.forEach(function(obj) { - console.log(); - console.log(' ' + color.cyan(obj.name)); - if (obj.binary) { - console.log(' bin:', color.magenta(obj.binary)); - } - console.log(' desc:', color.gray(obj.description || '')); - }); -}; - -function getPlugins() { - if (!file.exists(pluginsPath)) return []; - return file.readJSON(pluginsPath); -} -exports.plugins = getPlugins;