loopbackio / loopbackio/loopback-next

[CLI] Prevent usage of already used keywords

Offen
#2,052 8 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@erogleva arbeitet bereits daran.

Seit 09.10.2020.

CLI developer-experience good first issue Hacktoberfest help wanted
Vorherrschende Sprache
TypeScript
Sterne
5.1k
Forks
1.1k
Ø Merge
2 T. 21 Std.
Gemergte PRs (30 T.)
27

Beschreibung

Description / Steps to reproduce / Feature proposal

When using the CLI I can create a model named Entity, or Model. The model is generated but no warning will be emitted (this keyword is already used by Loopback).

Current Behavior

The model/controller/datasource/... is generated.

import {Model, model, property} from '@loopback/repository';

@model()
export class Model extends Model {
  constructor(data?: Partial<Model>) {
    super(data);
  }
}

Expected Behavior

Multiple options here:

  1. add warnings in the creation process
  2. prevent the component (model/controller/...) from being created
    1. by retrying
    2. by exiting
  3. modify the generated file , for a model e.g:
import * as repository from '@loopback/repository';

@repository.model()
export class Model extends repository.Model {
  constructor(data?: Partial<Model>) {
    super(data);
  }
}

Keywords to consider

For controllers: nothing (overwriting existing controllers is already handled)

For datasources: nothing (overwriting existing datasources is already handled)

For models:

  • Entity
  • Model

For repositories:

  • Repository

For services: ?

For openapi: nothing

Anything else ?

Acceptance criteria

Add a Yeoman prompt validator to reject model/repository/controller names that are the same as one of the built-in ones. This way, when a user enters invalid name, Yeoman will print an error and repeat the prompt.

For each of the following generators, provide validation rule that will reject problematic names:


🎆 Hacktoberfest 2020

Greetings 👋 to all Hacktoberfest 2020 participants!

Here are few tips 👀 to make your start easier, see also #6456:

  • Before you start working on this issue, please leave a comment to let others know.
  • This issue consists of several tasks to work on, it may feel like a too big effort to undertake. Don't worry! It's perfectly fine to pick just one item from the list and leave the rest for somebody else. In fact, we prefer to have a dedicated pull request for each part, to make it easier for us to review the changes and get the pull request landed faster. Baby steps FTW! Remember, every little helps.
  • If you are new to GitHub pull requests, then you can learn about the process in Submitting a pull request to LoopBack 4.
  • If this is your first contribution to LoopBack, then please take a look at our Developer guide
  • Feel free to ask for help in #loopback-contributors channel, you can join our Slack workspace here.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.