Skip to content

Commit c089299

Browse files
committed
fix(cli): rename repository/service feature flags
- Rename `--enableRepository` to `--repositories` (notice the plural form) - Rename `--enableServices` to `--services` This commit fixes the inconsistency where `--enableRepository` was using the singular form, while `--enableServices` was using the plural form. It also improves the feature prompt so that the word "enable" is not repeated twice. Before: ? Select project build settings: ❯◉ Enable tslint ◉ Enable prettier ◉ Enable mocha ◉ Enable loopbackBuild ◉ Enable vscode ◉ Enable enableRepository ◉ Enable enableServices After: ? Select features to enable in the project: ❯◉ Enable tslint ◉ Enable prettier ◉ Enable mocha ◉ Enable loopbackBuild ◉ Enable vscode ◉ Enable repositories ◉ Enable services
1 parent ac011f8 commit c089299

File tree

8 files changed

+36
-25
lines changed

8 files changed

+36
-25
lines changed

docs/site/Getting-started.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ Answer the prompts as follows:
4141
? Project description: Getting started tutorial
4242
? Project root directory: (getting-started)
4343
? Application class name: StarterApplication
44-
? Select project build settings: Enable tslint, Enable prettier, Enable mocha, Enable loopbackBuild, Enable vscode
44+
? Select features to enable in the project:
45+
❯◉ Enable tslint
46+
◉ Enable prettier
47+
◉ Enable mocha
48+
◉ Enable loopbackBuild
49+
◉ Enable vscode
50+
◉ Enable repositories
51+
◉ Enable services
4552
```
4653

4754
### Starting the project

docs/site/soap-calculator-tutorial-scaffolding.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Let's start by creating the initial application by running the following
1212
command:
1313

1414
```sh
15-
lb4 app soap-calculator --enableRepository --enableServices
15+
lb4 app soap-calculator --repositories --services
1616
```
1717

18-
**Note:** The option **--enableRepository** instructs the **CLI** to include a
18+
**Note:** The option **--repositories** instructs the **CLI** to include a
1919
`RepositoryMixin` class in the application constructor which will be needed when
20-
we create the datasource. The option **--enableServices** instructs the **CLI**
21-
to include a `ServiceMixin` class in the application constructor which will be
20+
we create the datasource. The option **--services** instructs the **CLI** to
21+
include a `ServiceMixin` class in the application constructor which will be
2222
needed to register our SOAP service client.
2323

2424
**LB4** will ask you a few questions _(you can leave the default options)_. The
@@ -33,20 +33,22 @@ application.ts file.
3333
```
3434

3535
Next you will see a list of options for the build settings, if you did not
36-
specify `--enableRepository` and `--enableServices` in the last command, then
37-
you will see them in this list, make sure you enable both the repository and the
38-
services for the application.
36+
specify `--repositories` and `--services` in the last command, then you will see
37+
them in this list, make sure you enable both the repository and the services for
38+
the application.
3939

4040
**Note:** Enable all options, unless you know what you are doing, see
4141
[The Getting Started guide](Getting-started.md) for more information.
4242

4343
```sh
44-
? Select project build settings: (Press <space> to select, <a> to toggle all, <i> to invert selection)
44+
? Select features to enable in the project:
4545
❯◉ Enable tslint
4646
◉ Enable prettier
4747
◉ Enable mocha
4848
◉ Enable loopbackBuild
4949
◉ Enable vscode
50+
◉ Enable repositories
51+
◉ Enable services
5052
```
5153

5254
#### Run the Application

docs/site/todo-tutorial-scaffolding.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ $ lb4 app
2222
? Project description: A todo list API made with LoopBack 4.
2323
? Project root directory: (todo-list)
2424
? Application class name: (TodoListApplication)
25-
? Select project build settings: (Press <space> to select, <a> to toggle all, <i> to inverse selection)
25+
? Select features to enable in the project:
2626
❯◉ Enable tslint
2727
◉ Enable prettier
2828
◉ Enable mocha
2929
◉ Enable loopbackBuild
3030
◉ Enable vscode
31+
◉ Enable repositories
32+
◉ Enable services
3133
# npm will install dependencies now
3234
Application todo-list was created in todo-list.
3335
```

examples/log-extension/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ Initialize your new extension project as follows: `lb4 extension`
7676
- Project description: `An example extension project for LoopBack 4`
7777
- Project root directory: `(loopback4-example-log-extension)`
7878
- Component class name: `LogComponent`
79-
- Select project build settings:
80-
`Enable tslint, Enable prettier, Enable mocha, Enable loopbackBuild`
79+
- Select features to enable in the project': `tslint`, `prettier`, `mocha`,
80+
`loopbackBuild`
8181

8282
Now you can write the extension as follows:
8383

packages/cli/generators/app/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ module.exports = class AppGenerator extends ProjectGenerator {
1111
// Note: arguments and options should be defined in the constructor.
1212
constructor(args, opts) {
1313
super(args, opts);
14-
this.buildOptions.push('enableRepository');
15-
this.buildOptions.push('enableServices');
14+
this.buildOptions.push('repositories');
15+
this.buildOptions.push('services');
1616
}
1717

1818
_setupGenerator() {
@@ -23,12 +23,12 @@ module.exports = class AppGenerator extends ProjectGenerator {
2323
description: 'Application class name',
2424
});
2525

26-
this.option('enableRepository', {
26+
this.option('repositories', {
2727
type: Boolean,
2828
description: 'Include repository imports and RepositoryMixin',
2929
});
3030

31-
this.option('enableServices', {
31+
this.option('services', {
3232
type: Boolean,
3333
description: 'Include service-proxy imports and ServiceMixin',
3434
});
@@ -88,14 +88,14 @@ module.exports = class AppGenerator extends ProjectGenerator {
8888

8989
buildAppClassMixins() {
9090
if (this.shouldExit()) return false;
91-
const {enableRepository, enableServices} = this.projectInfo || {};
92-
if (!enableRepository && !enableServices) return;
91+
const {repositories, services} = this.projectInfo || {};
92+
if (!repositories && !services) return;
9393

9494
let appClassWithMixins = 'RestApplication';
95-
if (enableRepository) {
95+
if (repositories) {
9696
appClassWithMixins = `RepositoryMixin(${appClassWithMixins})`;
9797
}
98-
if (enableServices) {
98+
if (services) {
9999
appClassWithMixins = `ServiceMixin(${appClassWithMixins})`;
100100
}
101101

packages/cli/generators/app/templates/src/application.ts.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {BootMixin} from '@loopback/boot';
22
import {ApplicationConfig} from '@loopback/core';
3-
<% if (project.enableRepository) { -%>
3+
<% if (project.repositories) { -%>
44
import {RepositoryMixin} from '@loopback/repository';
55
<% } -%>
66
import {RestApplication} from '@loopback/rest';
7-
<% if (project.enableServices) { -%>
7+
<% if (project.services) { -%>
88
import {ServiceMixin} from '@loopback/service-proxy';
99
<% } -%>
1010
import {MySequence} from './sequence';

packages/cli/generators/project/templates/package.json.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@
7878
"@loopback/core": "<%= project.dependencies['@loopback/core'] -%>",
7979
"@loopback/dist-util": "<%= project.dependencies['@loopback/dist-util'] -%>",
8080
"@loopback/openapi-v3": "<%= project.dependencies['@loopback/openapi-v3'] -%>",
81-
<% if (project.enableRepository) { -%>
81+
<% if (project.repositories) { -%>
8282
"@loopback/repository": "<%= project.dependencies['@loopback/repository'] -%>",
8383
<% } -%>
84-
<% if (project.enableServices) { -%>
84+
<% if (project.services) { -%>
8585
"@loopback/rest": "<%= project.dependencies['@loopback/rest'] -%>",
8686
"@loopback/service-proxy": "<%= project.dependencies['@loopback/service-proxy'] -%>"
8787
<% } else { -%>

packages/cli/lib/project-generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ module.exports = class ProjectGenerator extends BaseGenerator {
169169
const prompts = [
170170
{
171171
name: 'settings',
172-
message: 'Select project build settings: ',
172+
message: 'Select features to enable in the project',
173173
type: 'checkbox',
174174
choices: choices,
175175
// Skip if all features are enabled by cli options

0 commit comments

Comments
 (0)