How to use @midwayjs/command-core - 4 common examples

To help you get started, we’ve selected a few @midwayjs/command-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github midwayjs / midway-faas / packages / faas-plugin-common / src / plugins / pluginManager / index.ts View on Github external
getAllPlugins() {
    const dir: string = getCoreBaseDir();
    if (!existsSync(dir)) {
      return [];
    }
    const files = readdirSync(dir);

    const plugins = files.filter(file => {
      return /midway-plugin/.test(file);
    });
    return plugins;
  }
github midwayjs / midway-faas / packages / faas-plugin-common / src / plugins / pluginManager / index.ts View on Github external
async updatePlugin(newPlugin) {
    const plugin = newPlugin.replace(/@.*$/, '');
    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`
    );
    const newVersion = this.getPluginVersion(plugin);
    this.core.cli.log(
      `  - update '${plugin}'${oldVersion ? ` from ${oldVersion}` : ''}${
        newVersion ? ` to ${newVersion}` : ''
      }`
    );
  }
github midwayjs / midway-faas / packages / faas-plugin-common / src / plugins / pluginManager / index.ts View on Github external
async install() {
    if (typeof this.options.install === 'string') {
      const plugin = this.options.install.replace(/@.*$/, '');
      const dir: string = getCoreBaseDir();
      await this.execPromise(
        `cd ${join(dir, '../')};${this.options.npm || 'npm'} install ${
          this.options.install
        } --production`
      );
      this.core.cli.log(`  - installed '${plugin}'`);
    } else {
      this.core.cli.log(`please user plugin -i=`);
    }
  }
github midwayjs / midway-faas / packages / faas-plugin-common / src / plugins / pluginManager / index.ts View on Github external
getPluginVersion(plugin) {
    const dir: string = getCoreBaseDir();
    const pkgJson = join(dir, plugin, 'package.json');
    let version = '';
    try {
      version = JSON.parse(readFileSync(pkgJson).toString()).version;
    } catch (E) {}
    return version;
  }

@midwayjs/command-core

基于插件生命周期 + hook的内核

MIT
Latest version published 11 months ago

Package Health Score

39 / 100
Full package analysis

Popular @midwayjs/command-core functions

Similar packages