Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

Commit

Permalink
fix: faas-cli package dist
Browse files Browse the repository at this point in the history
  • Loading branch information
echosoar committed Dec 25, 2019
1 parent ec6cf5f commit 302de75
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/command-core/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('load plugin', () => {
core.addPlugin(InvokePlugin);
await core.ready();
const allCommands = core.getCommands();
assert(allCommands.invoke && allCommands.invoke.lifecycleEvents.length === 6);
assert(allCommands.invoke && allCommands.invoke.lifecycleEvents.length === 2);
});

it('multi plugins', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/faas-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"@midwayjs/runtime-mock": "^0.1.5",
"@midwayjs/spec-builder": "^0.1.5",
"minimist": "^1.2.0",
"ora": "^4.0.3",
"ts-node": "^8.5.2",
"urllib": "^2.34.1",
"websocket": "^1.0.30"
Expand All @@ -25,6 +24,7 @@
"files": [
"bin",
"src",
"dist",
"package.json"
],
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions packages/faas-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class Cli {
log: console,
});
this.loadDefaultPlugin();
this.loadPlatformPlugin();
this.loadUserPlugin();
}

Expand All @@ -40,6 +41,9 @@ export class Cli {
this.core.addPlugin(CommandPlugin);
return;
}
}

loadPlatformPlugin() {
this.core.addPlugin('npm::serverless-midway-plugin');
}

Expand Down
5 changes: 0 additions & 5 deletions packages/faas-cli/src/plugins/pluginManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { getCoreBaseDir } = require('@midwayjs/command-core/dist/npm');
import { existsSync, readdirSync, readFileSync } from 'fs';
import { join } from 'path';
import { exec } from 'child_process';
import * as ora from 'ora';

class PluginManager extends BasePlugin {

Expand Down Expand Up @@ -76,10 +75,8 @@ class PluginManager extends BasePlugin {
async install() {
if (typeof this.options.install === 'string') {
const plugin = this.options.install.replace(/@.*$/, '');
const spinner = ora(` - install plugin ${plugin}`).start();
const dir: string = getCoreBaseDir();
await this.execPromise(`cd ${join(dir, '../')};${ this.options.npm || 'npm'} install ${this.options.install} --production`);
spinner.stop();
this.core.cli.log(` - installed '${plugin}'`);
} else {
this.core.cli.log(`please user plugin -i=<plugin name>`);
Expand Down Expand Up @@ -111,12 +108,10 @@ class PluginManager extends BasePlugin {

async updatePlugin(newPlugin) {
const plugin = newPlugin.replace(/@.*$/, '');
const spinner = ora(` - update plugin ${plugin}`).start();
const oldVersion = this.getPluginVersion(plugin);
const dir: string = getCoreBaseDir();
await this.execPromise(`cd ${dir};rm -rf ${plugin}`);
await this.execPromise(`cd ${join(dir, '../')};${ this.options.npm || 'npm'} install ${newPlugin} --production`);
spinner.stop();
const newVersion = this.getPluginVersion(plugin);
this.core.cli.log(` - update '${plugin}'${ oldVersion ? ` from ${oldVersion}` : ''}${ newVersion ? ` to ${newVersion}` : ''}`);
}
Expand Down

0 comments on commit 302de75

Please sign in to comment.