@loopback/cli 4.2.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.yo-rc.json CHANGED
@@ -691,7 +691,6 @@
691
691
  "type": "String",
692
692
  "required": false,
693
693
  "description": "A valid repository base class",
694
- "default": "DefaultCrudRepository",
695
694
  "name": "repositoryBaseClass",
696
695
  "hide": false
697
696
  },
@@ -1415,7 +1414,7 @@
1415
1414
  "foreignKeyName": {
1416
1415
  "type": "String",
1417
1416
  "required": false,
1418
- "description": "Destination model foreign key name",
1417
+ "description": "Destination model foreign key name (optional, provide only when there is a custom foreign key)",
1419
1418
  "name": "foreignKeyName",
1420
1419
  "hide": false
1421
1420
  },
@@ -1,5 +1,5 @@
1
1
  # Check out https://hub.docker.com/_/node to select a new base image
2
- FROM node:16-slim
2
+ FROM node:18-slim
3
3
 
4
4
  # Set to a non-root built-in user `node`
5
5
  USER node
@@ -292,12 +292,13 @@ module.exports = class OpenApiGenerator extends BaseGenerator {
292
292
  });
293
293
  }
294
294
 
295
- _generateControllers() {
295
+ _generateControllers(withImplementation) {
296
296
  const source = this.templatePath(
297
297
  'src/controllers/controller-template.ts.ejs',
298
298
  );
299
299
  for (const c of this.selectedControllers) {
300
300
  const controllerFile = c.fileName;
301
+ c.withImplementation = withImplementation;
301
302
  if (debug.enabled) {
302
303
  debug(`Artifact output filename set to: ${controllerFile}`);
303
304
  }
@@ -478,7 +479,7 @@ module.exports = class OpenApiGenerator extends BaseGenerator {
478
479
  this._generateModels();
479
480
  await this._updateIndex(MODEL);
480
481
  if (this.options.server !== false) {
481
- this._generateControllers();
482
+ this._generateControllers(this.options.client);
482
483
  await this._updateIndex(CONTROLLER);
483
484
  }
484
485
  if (this.options.client === true) {
@@ -349,6 +349,24 @@ function buildMethodSpec(controllerSpec, op, options) {
349
349
  if (op.spec['x-implementation']) {
350
350
  methodSpec.implementation = op.spec['x-implementation'];
351
351
  }
352
+ if (!methodSpec.implementation) {
353
+ const methodParameters = {};
354
+ methodParameters[methodName] = [];
355
+ if (parameters) {
356
+ parameters.forEach(param => {
357
+ methodParameters[methodName].push(param.name);
358
+ });
359
+ }
360
+ if (op.spec.requestBody) {
361
+ methodParameters[methodName].push('_requestBody');
362
+ }
363
+ controllerSpec.serviceClassNameCamelCase = camelCase(
364
+ controllerSpec.serviceClassName,
365
+ );
366
+ methodSpec.implementation = `return this.${
367
+ controllerSpec.serviceClassNameCamelCase
368
+ }.${methodName}(${methodParameters[methodName].join(', ')});`;
369
+ }
352
370
  return methodSpec;
353
371
 
354
372
  /**
@@ -1,4 +1,8 @@
1
- import {api, operation, param, requestBody} from '@loopback/rest';
1
+ import {api, operation, param, requestBody} from '@loopback/rest';<%if (withImplementation) { %>
2
+ import {inject} from '@loopback/core';
3
+
4
+ import {<%- serviceClassName %>} from '../services';
5
+ <% } %>
2
6
  <%_
3
7
  imports.forEach(i => {
4
8
  -%>
@@ -18,9 +22,11 @@ imports.forEach(i => {
18
22
  <%_ } -%>
19
23
  */
20
24
  <%- decoration %>
21
- export class <%- className %> {
22
- constructor() {}
23
-
25
+ export class <%- className %> {<% if(withImplementation){ %>
26
+ constructor(@inject('services.<%- serviceClassName %>')
27
+ protected <%- serviceClassNameCamelCase %>: <%- serviceClassName %>) {}
28
+ <% } else { %>
29
+ constructor() {} <% } %>
24
30
  <%_ for (const m of methods) { -%>
25
31
  /**
26
32
  <%_ for (const c of m.comments) {
@@ -35,9 +41,8 @@ export class <%- className %> {
35
41
  */
36
42
  <%- m.decoration %>
37
43
  <%- m.signature %> {
38
- <%- m.implementation || "throw new Error('Not implemented');" %>
44
+ <% if(withImplementation){ %> <%- m.implementation %> <% } else{ %> throw new Error('Not implemented'); <% } %>
39
45
  }
40
-
41
46
  <%_ } -%>
42
47
  }
43
48
 
@@ -12,7 +12,7 @@
12
12
  "main": "dist/index.js",
13
13
  "types": "dist/index.d.ts",
14
14
  "engines": {
15
- "node": "14 || 16 || 18 || 19"
15
+ "node": "16 || 18 || 20"
16
16
  },
17
17
  "scripts": {
18
18
  "build": "lb-tsc",
@@ -12,7 +12,7 @@
12
12
  "main": "dist/index.js",
13
13
  "types": "dist/index.d.ts",
14
14
  "engines": {
15
- "node": "14 || 16 || 18 || 19"
15
+ "node": "16 || 18 || 20"
16
16
  },
17
17
  "scripts": {
18
18
  "build": "tsc",
@@ -128,7 +128,9 @@ module.exports = class RelationGenerator extends ArtifactGenerator {
128
128
  this.option('foreignKeyName', {
129
129
  type: String,
130
130
  required: false,
131
- description: g.f('Destination model foreign key name'),
131
+ description: g.f(
132
+ 'Destination model foreign key name (optional, provide only when there is a custom foreign key)',
133
+ ),
132
134
  });
133
135
 
134
136
  this.option('relationName', {
@@ -612,6 +614,9 @@ module.exports = class RelationGenerator extends ArtifactGenerator {
612
614
  }
613
615
 
614
616
  async _promptKeyFromOnThroughModel() {
617
+ if (this.options.sourceKeyOnThrough) {
618
+ this.artifactInfo.sourceKeyOnThrough = this.options.sourceKeyOnThrough;
619
+ }
615
620
  if (this.shouldExit()) return false;
616
621
  return this.prompt([
617
622
  {
@@ -623,7 +628,7 @@ module.exports = class RelationGenerator extends ArtifactGenerator {
623
628
  )} to define on the through model`,
624
629
  ),
625
630
  default: this.artifactInfo.defaultSourceKeyOnThrough,
626
- when: !this.options.sourceKeyOnThrough,
631
+ when: !this.artifactInfo.sourceKeyOnThrough,
627
632
  validate: utils.validateKeyName,
628
633
  },
629
634
  ]).then(props => {
@@ -635,6 +640,9 @@ module.exports = class RelationGenerator extends ArtifactGenerator {
635
640
 
636
641
  async _promptKeyToOnThroughModel() {
637
642
  if (this.shouldExit()) return false;
643
+ if (this.options.targetKeyOnThrough) {
644
+ this.artifactInfo.targetKeyOnThrough = this.options.targetKeyOnThrough;
645
+ }
638
646
  return this.prompt([
639
647
  {
640
648
  type: 'string',
@@ -645,7 +653,7 @@ module.exports = class RelationGenerator extends ArtifactGenerator {
645
653
  )} to define on the through model`,
646
654
  ),
647
655
  default: this.artifactInfo.defaultTargetKeyOnThrough,
648
- when: !this.options.targetKeyOnThrough,
656
+ when: !this.artifactInfo.targetKeyOnThrough,
649
657
  validate: input =>
650
658
  utils.validateKeyToKeyFrom(
651
659
  input,
@@ -728,6 +736,8 @@ module.exports = class RelationGenerator extends ArtifactGenerator {
728
736
 
729
737
  async promptRegisterInclusionResolver() {
730
738
  if (this.shouldExit()) return false;
739
+ this.artifactInfo.registerInclusionResolver =
740
+ this.options.registerInclusionResolver;
731
741
  const props = await this.prompt([
732
742
  {
733
743
  type: 'confirm',
@@ -737,6 +747,7 @@ module.exports = class RelationGenerator extends ArtifactGenerator {
737
747
  chalk.yellow(this.artifactInfo.sourceModel),
738
748
  chalk.yellow(this.artifactInfo.destinationModel),
739
749
  ),
750
+ when: this.artifactInfo.registerInclusionResolver === undefined,
740
751
  default: true,
741
752
  },
742
753
  ]);
@@ -15,8 +15,8 @@ import {
15
15
  post,
16
16
  requestBody,
17
17
  } from '@loopback/rest';
18
- import {
19
- <%= sourceModelClassName %>,
18
+ import {<%if (sourceModelClassName != targetModelClassName) { %>
19
+ <%= sourceModelClassName %>,<% } %>
20
20
  <%= throughModelClassName %>,
21
21
  <%= targetModelClassName %>,
22
22
  } from '../models';
@@ -188,7 +188,6 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator {
188
188
  type: String,
189
189
  required: false,
190
190
  description: g.f('A valid repository base class'),
191
- default: 'DefaultCrudRepository',
192
191
  });
193
192
 
194
193
  return super._setupGenerator();
@@ -411,6 +410,8 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator {
411
410
  return this.exit(err);
412
411
  }
413
412
 
413
+ this.artifactInfo.repositoryBaseClass =
414
+ this.artifactInfo.repositoryTypeClass;
414
415
  if (this.options.repositoryBaseClass) {
415
416
  debug(
416
417
  `Base repository received from command line: ${this.options.repositoryBaseClass}`,
@@ -151,7 +151,7 @@
151
151
  "bfd42878b3c50994368322098aed9e42": "include Dockerfile and .dockerignore",
152
152
  "c1f96ff7ee37bcc6aa150ae5d0dbc3bb": "What is the type of your ID?",
153
153
  "c3eece87ffd6970cb83a75715824dce7": "include service-proxy imports and ServiceMixin",
154
- "c87a36fbb5183525d0006021aec56a91": "Destination model foreign key name",
154
+ "c87a36fbb5183525d0006021aec56a91": "Destination model foreign key name (optional, provide only when there is a custom foreign key)",
155
155
  "c8d3e70199f75ca1f1d0bd9af1d62d38": "model does not exist.",
156
156
  "c92e838c1513ce96008d7bfee201e1e9": "A valid datasource name",
157
157
  "ca660806a44ff651cd28cf4a3dddc686": "Do not remember prompt answers",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loopback/cli",
3
3
  "description": "Yeoman generator for LoopBack 4",
4
- "version": "4.2.1",
4
+ "version": "5.0.0",
5
5
  "keywords": [
6
6
  "LoopBack",
7
7
  "CLI",
@@ -21,7 +21,7 @@
21
21
  "directory": "packages/cli"
22
22
  },
23
23
  "engines": {
24
- "node": "14 || 16 || 18 || 19"
24
+ "node": "16 || 18 || 20"
25
25
  },
26
26
  "scripts": {
27
27
  "test": "lb-mocha --lang en_US.UTF-8 \"test/**/*.js\"",
@@ -47,19 +47,19 @@
47
47
  "change-case": "^4.1.2",
48
48
  "debug": "^4.3.4",
49
49
  "fs-extra": "^11.1.1",
50
- "glob": "^10.0.0",
50
+ "glob": "^10.2.4",
51
51
  "inquirer-autocomplete-prompt": "^2.0.0",
52
52
  "json5": "^2.2.3",
53
53
  "latest-version": "^5.1.0",
54
54
  "lodash": "^4.17.21",
55
55
  "minimatch": "^9.0.0",
56
56
  "minimist": "^1.2.8",
57
- "mkdirp": "^3.0.0",
57
+ "mkdirp": "^3.0.1",
58
58
  "natural-compare": "^1.4.0",
59
- "pacote": "^15.1.1",
59
+ "pacote": "^15.1.3",
60
60
  "pluralize": "^8.0.0",
61
61
  "regenerate": "^1.4.2",
62
- "semver": "^7.4.0",
62
+ "semver": "^7.5.1",
63
63
  "slash": "^3.0.0",
64
64
  "spdx-license-list": "^6.6.0",
65
65
  "stringify-object": "^3.3.0",
@@ -76,28 +76,28 @@
76
76
  "update-notifier": "^5.1.0",
77
77
  "url-slug": "^3.0.4",
78
78
  "validate-npm-package-name": "^5.0.0",
79
- "write-file-atomic": "^5.0.0",
80
- "yeoman-environment": "^3.15.1",
79
+ "write-file-atomic": "^5.0.1",
80
+ "yeoman-environment": "^3.16.2",
81
81
  "yeoman-generator": "^5.8.0"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@lerna/bootstrap": "6.5.1",
85
- "@loopback/build": "^9.0.10",
86
- "@loopback/eslint-config": "^13.0.10",
87
- "@loopback/testlab": "^5.0.10",
85
+ "@loopback/build": "^10.0.0",
86
+ "@loopback/eslint-config": "^14.0.0",
87
+ "@loopback/testlab": "^6.0.0",
88
88
  "@types/ejs": "^3.1.2",
89
89
  "@types/fs-extra": "^11.0.1",
90
90
  "@types/minimatch": "^5.1.2",
91
- "@types/node": "^14.18.42",
91
+ "@types/node": "^14.18.47",
92
92
  "@types/yeoman-environment": "^2.10.8",
93
93
  "@types/yeoman-generator": "^5.2.11",
94
94
  "loopback": "^3.28.0",
95
- "loopback-datasource-juggler": "^4.28.3",
95
+ "loopback-datasource-juggler": "^4.28.5",
96
96
  "mem-fs": "^2.3.0",
97
97
  "mem-fs-editor": "^9.7.0",
98
98
  "mock-stdin": "^1.0.0",
99
99
  "rimraf": "^5.0.0",
100
- "sinon": "^15.0.3",
100
+ "sinon": "^15.0.4",
101
101
  "strong-globalize-cli": "7.1.0",
102
102
  "yeoman-assert": "^3.1.1",
103
103
  "yeoman-test": "^6.3.0"
@@ -106,97 +106,97 @@
106
106
  "templateDependencies": {
107
107
  "tslib": "^2.0.0",
108
108
  "@types/mocha": "^10.0.1",
109
- "@types/node": "^14.18.42",
109
+ "@types/node": "^14.18.47",
110
110
  "cross-spawn": "^7.0.3",
111
111
  "debug": "^4.3.4",
112
112
  "fs-extra": "^11.1.1",
113
113
  "mocha": "^10.2.0",
114
114
  "nyc": "^15.1.0",
115
- "prettier": "^2.8.7",
115
+ "prettier": "^2.8.8",
116
116
  "rimraf": "^5.0.0",
117
117
  "source-map-support": "^0.5.21",
118
118
  "typescript": "~4.9.5",
119
- "@loopback/authentication": "^9.0.10",
120
- "@loopback/boot": "^5.0.10",
121
- "@loopback/build": "^9.0.10",
122
- "@loopback/cli": "^4.2.1",
123
- "@loopback/context": "^5.0.10",
124
- "@loopback/core": "^4.0.10",
125
- "@loopback/metadata": "^5.0.10",
126
- "@loopback/openapi-spec-builder": "^5.0.10",
127
- "@loopback/openapi-v3": "^8.0.10",
128
- "@loopback/repository-json-schema": "^6.1.4",
129
- "@loopback/repository": "^5.1.5",
130
- "@loopback/rest": "^12.0.10",
131
- "@loopback/testlab": "^5.0.10",
132
- "@loopback/docs": "^5.2.1",
133
- "glob": "^10.0.0",
134
- "@loopback/example-hello-world": "^5.0.10",
135
- "@loopback/example-log-extension": "^5.0.10",
136
- "@loopback/example-rpc-server": "^5.0.10",
137
- "@loopback/example-todo": "^6.0.10",
138
- "@loopback/example-soap-calculator": "^5.0.10",
139
- "@loopback/service-proxy": "^5.0.10",
140
- "@loopback/http-caching-proxy": "^4.0.10",
141
- "@loopback/http-server": "^4.0.10",
142
- "@loopback/example-todo-list": "^6.0.10",
119
+ "@loopback/authentication": "^10.0.0",
120
+ "@loopback/boot": "^6.0.0",
121
+ "@loopback/build": "^10.0.0",
122
+ "@loopback/cli": "^5.0.0",
123
+ "@loopback/context": "^6.0.0",
124
+ "@loopback/core": "^5.0.0",
125
+ "@loopback/metadata": "^6.0.0",
126
+ "@loopback/openapi-spec-builder": "^6.0.0",
127
+ "@loopback/openapi-v3": "^9.0.0",
128
+ "@loopback/repository-json-schema": "^7.0.0",
129
+ "@loopback/repository": "^6.0.0",
130
+ "@loopback/rest": "^13.0.0",
131
+ "@loopback/testlab": "^6.0.0",
132
+ "@loopback/docs": "^6.0.0",
133
+ "glob": "^10.2.4",
134
+ "@loopback/example-hello-world": "^6.0.0",
135
+ "@loopback/example-log-extension": "^6.0.0",
136
+ "@loopback/example-rpc-server": "^6.0.0",
137
+ "@loopback/example-todo": "^7.0.0",
138
+ "@loopback/example-soap-calculator": "^6.0.0",
139
+ "@loopback/service-proxy": "^6.0.0",
140
+ "@loopback/http-caching-proxy": "^5.0.0",
141
+ "@loopback/http-server": "^5.0.0",
142
+ "@loopback/example-todo-list": "^7.0.0",
143
143
  "@loopback/dist-util": "^0.4.0",
144
- "@loopback/rest-explorer": "^5.0.10",
145
- "@loopback/eslint-config": "^13.0.10",
144
+ "@loopback/rest-explorer": "^6.0.0",
145
+ "@loopback/eslint-config": "^14.0.0",
146
146
  "express-composition": "^1.1.0",
147
- "@loopback/example-express-composition": "^5.0.10",
148
- "@loopback/example-greeter-extension": "^5.0.10",
149
- "@loopback/booter-lb3app": "^4.0.10",
150
- "@loopback/example-lb3-application": "^5.0.10",
151
- "eslint": "^8.38.0",
147
+ "@loopback/example-express-composition": "^6.0.0",
148
+ "@loopback/example-greeter-extension": "^6.0.0",
149
+ "@loopback/booter-lb3app": "^5.0.0",
150
+ "@loopback/example-lb3-application": "^6.0.0",
151
+ "eslint": "^8.40.0",
152
152
  "eslint-plugin-mocha": "^10.1.0",
153
- "@loopback/example-greeting-app": "^5.0.10",
154
- "@loopback/example-context": "^5.0.10",
155
- "@typescript-eslint/eslint-plugin": "^5.58.0",
156
- "@typescript-eslint/parser": "^5.58.0",
153
+ "@loopback/example-greeting-app": "^6.0.0",
154
+ "@loopback/example-context": "^6.0.0",
155
+ "@typescript-eslint/eslint-plugin": "^5.59.6",
156
+ "@typescript-eslint/parser": "^5.59.6",
157
157
  "eslint-plugin-eslint-plugin": "^5.0.8",
158
158
  "eslint-config-prettier": "^8.8.0",
159
- "@loopback/repository-tests": "^0.21.10",
160
- "@loopback/health": "^0.11.10",
161
- "@loopback/authorization": "^0.12.10",
162
- "@loopback/rest-crud": "^0.15.9",
163
- "@loopback/security": "^0.8.10",
164
- "@loopback/authentication-passport": "^5.0.10",
165
- "@loopback/example-metrics-prometheus": "^0.10.10",
166
- "@loopback/metrics": "^0.11.10",
167
- "@loopback/model-api-builder": "^4.0.10",
168
- "@loopback/logging": "^0.9.10",
169
- "@loopback/example-access-control-migration": "^5.0.10",
170
- "@loopback/example-file-transfer": "^4.0.10",
171
- "@loopback/example-rest-crud": "^4.0.10",
172
- "@loopback/apiconnect": "^0.10.10",
173
- "@loopback/example-validation-app": "^4.0.10",
174
- "@loopback/cron": "^0.9.10",
175
- "@loopback/example-multi-tenancy": "^0.13.10",
176
- "@loopback/example-passport-login": "^4.0.10",
177
- "@loopback/authentication-jwt": "^0.12.10",
178
- "@loopback/context-explorer": "^0.8.10",
179
- "@loopback/express": "^5.0.10",
159
+ "@loopback/repository-tests": "^0.22.0",
160
+ "@loopback/health": "^0.12.0",
161
+ "@loopback/authorization": "^0.13.0",
162
+ "@loopback/rest-crud": "^0.16.0",
163
+ "@loopback/security": "^0.9.0",
164
+ "@loopback/authentication-passport": "^6.0.0",
165
+ "@loopback/example-metrics-prometheus": "^0.11.0",
166
+ "@loopback/metrics": "^0.12.0",
167
+ "@loopback/model-api-builder": "^5.0.0",
168
+ "@loopback/logging": "^0.10.0",
169
+ "@loopback/example-access-control-migration": "^6.0.0",
170
+ "@loopback/example-file-transfer": "^5.0.0",
171
+ "@loopback/example-rest-crud": "^5.0.0",
172
+ "@loopback/apiconnect": "^0.11.0",
173
+ "@loopback/example-validation-app": "^5.0.0",
174
+ "@loopback/cron": "^0.10.0",
175
+ "@loopback/example-multi-tenancy": "^0.14.0",
176
+ "@loopback/example-passport-login": "^5.0.0",
177
+ "@loopback/authentication-jwt": "^0.13.0",
178
+ "@loopback/context-explorer": "^0.9.0",
179
+ "@loopback/express": "^6.0.0",
180
180
  "@types/js-yaml": "^3.12.4",
181
181
  "js-yaml": "^3.13.1",
182
- "@loopback/example-todo-jwt": "^4.0.10",
183
- "@loopback/mock-oauth2-provider": "^0.6.10",
182
+ "@loopback/example-todo-jwt": "^5.0.0",
183
+ "@loopback/mock-oauth2-provider": "^0.7.0",
184
184
  "lodash": "^4.17.21",
185
- "@loopback/pooling": "^0.8.10",
186
- "@loopback/typeorm": "^0.7.10",
187
- "@loopback/example-graphql": "^0.7.10",
188
- "@loopback/graphql": "^0.8.10",
189
- "@loopback/filter": "^3.0.10",
190
- "@loopback/rest-msgpack": "^0.8.10",
191
- "@loopback/example-binding-resolution": "^0.7.10",
192
- "@loopback/example-webpack": "^0.8.10",
193
- "@loopback/example-socketio": "^0.6.10",
194
- "@loopback/socketio": "^0.6.10",
195
- "@loopback/monorepo": "^0.5.10",
196
- "@loopback/tsdocs": "^4.0.10",
197
- "@loopback/example-references-many": "^6.0.10",
198
- "@loopback/sequelize": "^0.2.0"
185
+ "@loopback/pooling": "^0.9.0",
186
+ "@loopback/typeorm": "^0.8.0",
187
+ "@loopback/example-graphql": "^0.8.0",
188
+ "@loopback/graphql": "^0.9.0",
189
+ "@loopback/filter": "^4.0.0",
190
+ "@loopback/rest-msgpack": "^0.9.0",
191
+ "@loopback/example-binding-resolution": "^0.8.0",
192
+ "@loopback/example-webpack": "^0.9.0",
193
+ "@loopback/example-socketio": "^0.7.0",
194
+ "@loopback/socketio": "^0.7.0",
195
+ "@loopback/monorepo": "^0.6.0",
196
+ "@loopback/tsdocs": "^5.0.0",
197
+ "@loopback/example-references-many": "^7.0.0",
198
+ "@loopback/sequelize": "^0.3.0"
199
199
  }
200
200
  },
201
- "gitHead": "3a98ded2622420d0f09dbc3c0fe961c0234b097f"
201
+ "gitHead": "97a26bd5973830a1d5f28aa2f58040f953995c17"
202
202
  }