How to use @oclif/errors - 10 common examples

To help you get started, we’ve selected a few @oclif/errors 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 rucken / cli / src / commands / generator-entity.ts View on Github external
const choices = nxJson.projects && Object.keys(nxJson.projects).filter(key => nxJson.projects[key].tags && nxJson.projects[key].tags.indexOf('client') !== -1 &&
        nxJson.projects[key].tags.indexOf('library') !== -1);
      if (choices.length === 0) {
        throw new CLIError('Library for core frontent entities not founded!');
      }
      try {
        result = await inquirer.prompt([{
          name: 'coreLib',
          message: 'Select lib used for store model for frontend application',
          type: 'list',
          choices,
          validate: (value: string) => value.length > 0
        }]);
        coreLib = result.coreLib;
      } catch (error) {
        throw new CLIError(error);
      }
    }
    coreLibOrg = coreLib &&
      angularJson['projects'] &&
      angularJson['projects'][coreLib] &&
      angularJson['projects'][coreLib]['root'] &&
      angularJson['projects'][coreLib]['root'].split('/').length > 2 &&
      angularJson['projects'][coreLib]['root'].split('/').filter((key: string, index: number) => index === 1)[0];
    const command = schematicsCommandBuilder(process.cwd(), coreTemplate || '', [name], {
      lib: coreLib,
      org: coreLibOrg,
      workspace
    });
    try {
      await runCommand(command, (...args: any[]) => this.debug(...args));
    } catch (error) {
github rucken / cli / src / commands / generator-library-to-application.ts View on Github external
private async prepareNestjsApp(nestjsLib: string | undefined, nestjsApp: string | undefined, angularJson: any, nxJson: any, result: any, nestjsLibOrg: string, nestjsTemplate: string | undefined, workspace: string | undefined) {
    if (
      !nestjsApp ||
      !(angularJson['projects'] && angularJson['projects'][nestjsApp] ||
        nxJson['projects'] && angularJson['projects'][nestjsApp])
    ) {
      const choices = nxJson.projects && Object.keys(nxJson.projects).filter(key => nxJson.projects[key].tags && nxJson.projects[key].tags.indexOf('server') !== -1 &&
        nxJson.projects[key].tags.indexOf('application') !== -1);
      if (choices.length === 0) {
        throw new CLIError('Application for nestjs link not founded!!');
      }
      try {
        result = await inquirer.prompt([{
          name: 'nestjsApp',
          message: `Select nestjs application for link "${nestjsLib}"`,
          type: 'list',
          choices,
          validate: (value: string) => value.length > 0
        }]);
        nestjsApp = result.nestjsApp;
      } catch (error) {
        throw new CLIError(error);
      }
    }
    if (!nestjsLib) {
      throw new CLIError('Library for link not founded!');
github rucken / cli / src / commands / generator-library.ts View on Github external
private async prepareFrontend(angularJson: never, name: any, nxJson: never, frontendTemplate: string | undefined, author: any, email: any, org: any, workspace: string | undefined) {
    if (angularJson['projects'] && angularJson['projects'][name] ||
      nxJson['projects'] && angularJson['projects'][name]) {
      throw new CLIError(`Library with name "${name}" is exists`);
    }
    const command = schematicsCommandBuilder(process.cwd(), frontendTemplate || '', [name], {
      author,
      email,
      org,
      workspace
    });
    try {
      await runCommand(command, (...args: any[]) => this.debug(...args));
    } catch (error) {
      throw new CLIError(error);
    }
  }
}
github rucken / cli / src / commands / generator-entity-to-application.ts View on Github external
private async prepareWeb(name: string, webLib: string | undefined, webApp: string | undefined, angularJson: any, nxJson: any, result: any, webLibOrg: string, webTemplate: string | undefined, coreLib: string | undefined, coreLibOrg: string, workspace: string | undefined) {
    if (
      !webLib ||
      !(angularJson['projects'] && angularJson['projects'][webLib] ||
        nxJson['projects'] && angularJson['projects'][webLib])
    ) {
      const choices = nxJson.projects && Object.keys(nxJson.projects).filter(key => nxJson.projects[key].tags && nxJson.projects[key].tags.indexOf('client') !== -1 &&
        nxJson.projects[key].tags.indexOf('library') !== -1);
      if (choices.length === 0) {
        throw new CLIError('Library for link to application with web entity not founded!');
      }
      try {
        result = await inquirer.prompt([{
          name: 'webLib',
          message: `Select web application for link web entity "${name}"`,
          type: 'list',
          choices,
          validate: (value: string) => value.length > 0
        }]);
        webLib = result.webLib;
      } catch (error) {
        throw new CLIError(error);
      }
    }
    webLibOrg = webLib &&
      angularJson['projects'] &&
github rucken / cli / src / commands / generator-application.ts View on Github external
private async prepareWeb(angularJson: never, name: any, nxJson: never, webTemplate: string | undefined, author: any, email: any, api: any, workspace: string | undefined) {
    if (angularJson['projects'] && angularJson['projects'][name] ||
      nxJson['projects'] && angularJson['projects'][name]) {
      throw new CLIError(`Application with name "${name}" is exists`);
    }
    const command = schematicsCommandBuilder(process.cwd(), webTemplate || '', [name], {
      author,
      email,
      api,
      workspace
    });
    try {
      await runCommand(command, (...args: any[]) => this.debug(...args));
    } catch (error) {
      throw new CLIError(error);
    }
  }
}
github rucken / cli / src / commands / generator-entity-to-application.ts View on Github external
private async prepareWebApp(name: string, webLib: string | undefined, webApp: string | undefined, angularJson: any, nxJson: any, result: any, webLibOrg: string, webTemplate: string | undefined, coreLib: string | undefined, coreLibOrg: string, workspace: string | undefined) {
    if (
      !webApp ||
      !(angularJson['projects'] && angularJson['projects'][webApp] ||
        nxJson['projects'] && angularJson['projects'][webApp])
    ) {
      const choices = nxJson.projects && Object.keys(nxJson.projects).filter(key => nxJson.projects[key].tags && nxJson.projects[key].tags.indexOf('client') !== -1 &&
        nxJson.projects[key].tags.indexOf('application') !== -1);
      if (choices.length === 0) {
        throw new CLIError('Application for link to library with web entity not founded!');
      }
      try {
        result = await inquirer.prompt([{
          name: 'webApp',
          message: `Select web application for link library "${webLib}" with entity "${name}"`,
          type: 'list',
          choices,
          validate: (value: string) => value.length > 0
        }]);
        webApp = result.webApp;
      } catch (error) {
        throw new CLIError(error);
      }
    }
    const command = schematicsCommandBuilder(process.cwd(), webTemplate || '', [name], {
      lib: webLib,
github rucken / cli / src / commands / generator-entity-to-application.ts View on Github external
} catch (error) {
        throw new CLIError(error);
      }
    }
    const command = schematicsCommandBuilder(process.cwd(), ionicTemplate || '', [name], {
      lib: ionicLib,
      org: ionicLibOrg,
      entitiesLib: coreLib,
      entitiesLibOrg: coreLibOrg,
      app: ionicApp,
      workspace
    });
    try {
      await runCommand(command, (...args: any[]) => this.debug(...args));
    } catch (error) {
      throw new CLIError(error);
    }
    return { ionicLib, ionicApp, result, ionicLibOrg };
  }
github rucken / cli / src / commands / generator-entity.ts View on Github external
private async corePrepare(coreLib: string | undefined, angularJson: any, nxJson: any, result: any, coreLibOrg: string, coreTemplate: string | undefined, name: any, workspace: string | undefined) {
    if (
      !coreLib ||
      !(angularJson['projects'] && angularJson['projects'][coreLib] ||
        nxJson['projects'] && angularJson['projects'][coreLib])
    ) {
      const choices = nxJson.projects && Object.keys(nxJson.projects).filter(key => nxJson.projects[key].tags && nxJson.projects[key].tags.indexOf('client') !== -1 &&
        nxJson.projects[key].tags.indexOf('library') !== -1);
      if (choices.length === 0) {
        throw new CLIError('Library for core frontent entities not founded!');
      }
      try {
        result = await inquirer.prompt([{
          name: 'coreLib',
          message: 'Select lib used for store model for frontend application',
          type: 'list',
          choices,
          validate: (value: string) => value.length > 0
        }]);
        coreLib = result.coreLib;
      } catch (error) {
        throw new CLIError(error);
      }
    }
    coreLibOrg = coreLib &&
      angularJson['projects'] &&
github rucken / cli / src / commands / generator-entity.ts View on Github external
private async prepareNestjs(nestjsLib: string | undefined, angularJson: any, nxJson: any, result: any, nestjsLibOrg: string, nestjsTemplate: string | undefined, name: any, timestamp: any, workspace: string | undefined) {
    if (
      !nestjsLib ||
      !(angularJson['projects'] && angularJson['projects'][nestjsLib] ||
        nxJson['projects'] && angularJson['projects'][nestjsLib])
    ) {
      const choices = nxJson.projects && Object.keys(nxJson.projects).filter(key => nxJson.projects[key].tags && nxJson.projects[key].tags.indexOf('server') !== -1 &&
        nxJson.projects[key].tags.indexOf('library') !== -1);
      if (choices.length === 0) {
        throw new CLIError('Library for nestjs entities not founded!');
      }
      try {
        result = await inquirer.prompt([{
          name: 'nestjsLib',
          message: 'Select lib used for store of the entity, the DTO, the service and the controller, for editing the entity data for the backend of the application on NestJS with TypeORM',
          type: 'list',
          choices,
          validate: (value: string) => value.length > 0
        }]);
        nestjsLib = result.nestjsLib;
      } catch (error) {
        throw new CLIError(error);
      }
    }
    nestjsLibOrg = nestjsLib &&
      angularJson['projects'] &&
github rucken / cli / src / commands / generator-application.ts View on Github external
private async prepareIonic(angularJson: never, name: any, nxJson: never, ionicTemplate: string | undefined, author: any, email: any, api: any, workspace: string | undefined) {
    if (angularJson['projects'] && angularJson['projects'][name] ||
      nxJson['projects'] && angularJson['projects'][name]) {
      throw new CLIError(`Application with name "${name}" is exists`);
    }
    const command = schematicsCommandBuilder(process.cwd(), ionicTemplate || '', [name], {
      author,
      email,
      api,
      workspace
    });
    try {
      await runCommand(command, (...args: any[]) => this.debug(...args));
    } catch (error) {
      throw new CLIError(error);
    }
    try {
      await Prepare.run([
        resolve(join(workspace || process.cwd()))
      ]);

@oclif/errors

display friendly CLI errors and log to error log

MIT
Latest version published 2 years ago

Package Health Score

55 / 100
Full package analysis

Popular @oclif/errors functions