Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
feat: 移除plugin命令
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Oct 30, 2017
1 parent 431fe66 commit 76abda8
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 312 deletions.
44 changes: 0 additions & 44 deletions app/command/add.ts
Expand Up @@ -8,25 +8,20 @@ const fs = require('fs-extra');
const _ = require('lodash');
const inquirer = require('inquirer');
const prompt = inquirer.createPromptModule();
const observatory = require('observatory');
const which = require('which');
const uniqueString = require('unique-string');
const clipboardy = require('clipboardy');
import chalk from 'chalk';
const __ = require('i18n').__;

const cwd = process.cwd();

import { isExistPath, isLink, normalizePath, runShell } from '../utils';
import config from '../config';
import plugin from '../plugin';
import registry from '../registry';
import globalConfig from '../global-config';
import Gpmrc from '../gpmrc';
import { info, warn } from '../logger';

const ACTION = 'add';

interface Argv$ {
repo: string;
}
Expand All @@ -36,7 +31,6 @@ interface Options$ {
unixify?: boolean;
force?: boolean;
name?: string;
plugin?: string;
ignoreRc?: boolean;
}

Expand Down Expand Up @@ -160,46 +154,8 @@ async function add(repo: string, options: Options$) {
warn(__('commands.add.log.warn_copy_clipboard'));
}
}

// 获取add的相关插件
const plugins = plugin.get(ACTION);

process.chdir(entity.path);

while (plugins.length) {
const plugin: any = plugins.shift();
const task = observatory.add(
__('commands.add.log.info_run_plugin', {
name: chalk.green('gpm-plugin-' + plugin.name)
})
);
await new Promise((resolve, reject) => {
if (!_.isFunction(plugin.add)) {
reject(
new Error(
__('commands.add.log.err_run_plugin', {
name: plugin.name.red
})
)
);
} else {
plugin.add.call(entity, err => {
if (err) {
task.fail(__('global.tips.fail'));
reject(err);
} else {
task.done('global.tips.success');
resolve();
}
});
}
});
}

process.chdir(cwd);
}

export default async function(argv: Argv$, options: Options$) {
plugin.load(ACTION, options.plugin || '');
return await add(argv.repo, options);
}
59 changes: 0 additions & 59 deletions app/command/plugin.ts

This file was deleted.

19 changes: 0 additions & 19 deletions app/gpm.ts
Expand Up @@ -19,7 +19,6 @@ import runtimeHandler from './command/runtime';
import configHandler from './command/config';
import cleanHandler from './command/clean';
import findHandler from './command/find';
import pluginHandler from './command/plugin';
import removeHandler from './command/remove';

inquirer.registerPrompt(
Expand Down Expand Up @@ -253,24 +252,6 @@ class Gpm extends EventEmitter {
.action(function(argv, options) {
return runtimeHandler(argv, options).catch(errorHandler);
});

program
.command('plugin', __('commands.plugin.desc'))
.alias('pl')
.argument('<action>', __('commands.plugin.argv.action.desc'))
.argument('[key]', __('commands.plugin.argv.key.desc'))
.option(FLAGS.unixify.flag, FLAGS.unixify.desc)
.option(FLAGS.force.flag, FLAGS.force.desc)
.option(FLAGS.nolog.flag, FLAGS.nolog.desc)
.action(function(
argv: {
action: any;
key: string;
},
options
) {
return pluginHandler(argv, options).catch(errorHandler);
});
}

/**
Expand Down
160 changes: 0 additions & 160 deletions app/plugin.ts

This file was deleted.

15 changes: 0 additions & 15 deletions locales/en_US.json
Expand Up @@ -113,21 +113,6 @@
},
"runtime": {
"desc": "Print the program runtime, useful for submit issue."
},
"plugin": {
"desc": "A series handler of plugin.",
"argv": {
"action": {
"desc": "Plugin action."
},
"key": {
"desc": "Plugin key."
}
},
"log": {
"require_key": "The [key] must be required, please try again: {{{cmd}}}",
"info_help": "Flow the command line: {{{cmd}}}"
}
}
}
}
15 changes: 0 additions & 15 deletions locales/zh_CN.json
Expand Up @@ -115,21 +115,6 @@
},
"runtime": {
"desc": "输出程序的运行环境,"
},
"plugin": {
"desc": "插件的一系列操作",
"argv": {
"action": {
"desc": "插件的action"
},
"key": {
"desc": "插件的key"
}
},
"log": {
"require_key": "缺少参数 [key], 请再尝试一次命令: {{{cmd}}}",
"info_help": "请遵循这条命令: {{{cmd}}}"
}
}
}
}

0 comments on commit 76abda8

Please sign in to comment.