@loopback/cli 4.0.0 → 4.1.2
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 +22 -0
- package/LICENSE +1 -1
- package/bin/cli-main.js +1 -1
- package/generators/app/index.js +1 -1
- package/generators/controller/index.js +1 -1
- package/generators/copyright/fs.js +1 -1
- package/generators/copyright/git.js +1 -1
- package/generators/copyright/header.js +1 -1
- package/generators/copyright/index.js +7 -8
- package/generators/copyright/license.js +5 -6
- package/generators/datasource/index.js +1 -1
- package/generators/discover/import-discovered-model.js +1 -1
- package/generators/discover/index.js +72 -10
- package/generators/example/downloader.js +1 -1
- package/generators/example/index.js +1 -1
- package/generators/extension/index.js +1 -1
- package/generators/extension/templates/src/providers/README.md +2 -2
- package/generators/import-lb3-models/index.js +1 -1
- package/generators/import-lb3-models/lb3app-loader.js +1 -1
- package/generators/import-lb3-models/migrate-model.js +1 -1
- package/generators/import-lb3-models/model-names.js +1 -1
- package/generators/interceptor/index.js +1 -1
- package/generators/model/index.js +1 -1
- package/generators/model/property-definition.js +1 -1
- package/generators/model/templates/model.ts.ejs +11 -4
- package/generators/observer/index.js +1 -1
- package/generators/openapi/index.js +1 -1
- package/generators/openapi/schema-helper.js +1 -1
- package/generators/openapi/spec-helper.js +1 -1
- package/generators/openapi/spec-loader.js +1 -1
- package/generators/openapi/utils.js +1 -1
- package/generators/relation/base-relation.generator.js +1 -1
- package/generators/relation/belongs-to-relation.generator.js +1 -1
- package/generators/relation/has-many-relation.generator.js +1 -1
- package/generators/relation/has-many-through-relation.generator.js +1 -1
- package/generators/relation/has-one-relation.generator.js +1 -1
- package/generators/relation/index.js +1 -1
- package/generators/relation/references-many-relation.generator.js +1 -1
- package/generators/relation/utils.generator.js +1 -1
- package/generators/repository/index.js +1 -1
- package/generators/rest-crud/crud-rest-component.js +1 -1
- package/generators/rest-crud/index.js +23 -1
- package/generators/rest-crud/templates/src/model-endpoints/model.rest-config-template.ts.ejs +1 -0
- package/generators/service/index.js +1 -1
- package/generators/update/index.js +1 -1
- package/lib/artifact-generator.js +1 -1
- package/lib/ast-helper.js +1 -1
- package/lib/base-generator.js +16 -13
- package/lib/cli.js +1 -1
- package/lib/debug.js +2 -2
- package/lib/globalize.js +1 -1
- package/lib/model-discoverer.js +1 -1
- package/lib/project-generator.js +2 -2
- package/lib/tab-completion.js +1 -1
- package/lib/update-index.js +1 -1
- package/lib/utils.js +7 -7
- package/lib/version-helper.js +3 -4
- package/package.json +99 -97
package/.yo-rc.json
CHANGED
|
@@ -1251,6 +1251,13 @@
|
|
|
1251
1251
|
"name": "views",
|
|
1252
1252
|
"hide": false
|
|
1253
1253
|
},
|
|
1254
|
+
"relations": {
|
|
1255
|
+
"type": "Boolean",
|
|
1256
|
+
"description": "Discover and create relations",
|
|
1257
|
+
"default": false,
|
|
1258
|
+
"name": "relations",
|
|
1259
|
+
"hide": false
|
|
1260
|
+
},
|
|
1254
1261
|
"schema": {
|
|
1255
1262
|
"type": "String",
|
|
1256
1263
|
"description": "Schema to discover",
|
|
@@ -1270,6 +1277,13 @@
|
|
|
1270
1277
|
"description": "Specify the directory into which the `model.model.ts` files will be placed",
|
|
1271
1278
|
"name": "outDir",
|
|
1272
1279
|
"hide": false
|
|
1280
|
+
},
|
|
1281
|
+
"optionalId": {
|
|
1282
|
+
"type": "Boolean",
|
|
1283
|
+
"description": "Boolean to mark id property as optional field",
|
|
1284
|
+
"default": false,
|
|
1285
|
+
"name": "optionalId",
|
|
1286
|
+
"hide": false
|
|
1273
1287
|
}
|
|
1274
1288
|
},
|
|
1275
1289
|
"arguments": [
|
|
@@ -1577,6 +1591,14 @@
|
|
|
1577
1591
|
"name": "basePath",
|
|
1578
1592
|
"hide": false
|
|
1579
1593
|
},
|
|
1594
|
+
"readonly": {
|
|
1595
|
+
"type": "Boolean",
|
|
1596
|
+
"required": false,
|
|
1597
|
+
"description": "Create readonly APIs",
|
|
1598
|
+
"default": false,
|
|
1599
|
+
"name": "readonly",
|
|
1600
|
+
"hide": false
|
|
1601
|
+
},
|
|
1580
1602
|
"config": {
|
|
1581
1603
|
"type": "String",
|
|
1582
1604
|
"alias": "c",
|
package/LICENSE
CHANGED
package/bin/cli-main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
3
3
|
// Node module: @loopback/cli
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
package/generators/app/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2017,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2017,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -8,7 +8,6 @@ const BaseGenerator = require('../../lib/base-generator');
|
|
|
8
8
|
const {updateFileHeaders} = require('./header');
|
|
9
9
|
const {spdxLicenseList, updateLicense} = require('./license');
|
|
10
10
|
const g = require('../../lib/globalize');
|
|
11
|
-
const _ = require('lodash');
|
|
12
11
|
const chalk = require('chalk');
|
|
13
12
|
const autocomplete = require('inquirer-autocomplete-prompt');
|
|
14
13
|
|
|
@@ -77,19 +76,19 @@ module.exports = class CopyrightGenerator extends BaseGenerator {
|
|
|
77
76
|
|
|
78
77
|
async promptOwnerAndLicense() {
|
|
79
78
|
const pkgFile = this.destinationPath('package.json');
|
|
80
|
-
|
|
81
|
-
if (pkg == null) {
|
|
79
|
+
if (!this.existsDestination('package.json')) {
|
|
82
80
|
this.exit(`${pkgFile} does not exist.`);
|
|
83
81
|
return;
|
|
84
82
|
}
|
|
85
|
-
this.packageJson
|
|
86
|
-
let author = _.get(pkg, 'author');
|
|
83
|
+
let author = this.packageJson.get('author');
|
|
87
84
|
if (typeof author === 'object') {
|
|
88
85
|
author = author.name;
|
|
89
86
|
}
|
|
90
87
|
const owner =
|
|
91
|
-
this.options.copyrightOwner ||
|
|
92
|
-
|
|
88
|
+
this.options.copyrightOwner ||
|
|
89
|
+
this.packageJson.get('copyright.owner') ||
|
|
90
|
+
author;
|
|
91
|
+
let license = this.options.license || this.packageJson.get('license');
|
|
93
92
|
const licenses = [...this.licenseList];
|
|
94
93
|
if (license != null) {
|
|
95
94
|
// find the matching license by id and move it to the front of the list
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -43,7 +43,7 @@ This project is licensed under the ${license.name}, full text below.
|
|
|
43
43
|
${text}
|
|
44
44
|
`;
|
|
45
45
|
/*
|
|
46
|
-
Copyright (c) IBM Corp. 2018,2019. All Rights Reserved.
|
|
46
|
+
Copyright (c) IBM Corp. and LoopBack contributors 2018,2019. All Rights Reserved.
|
|
47
47
|
Node module: @loopback/boot
|
|
48
48
|
This project is licensed under the MIT License, full text below.
|
|
49
49
|
|
|
@@ -86,13 +86,12 @@ async function updateLicense(projectRoot, pkg, options) {
|
|
|
86
86
|
if (typeof licenseId === 'object') {
|
|
87
87
|
licenseId = licenseId.id;
|
|
88
88
|
}
|
|
89
|
-
pkg.license
|
|
90
|
-
pkg
|
|
91
|
-
await fs.writeJSON(path.join(projectRoot, 'package.json'), pkg);
|
|
89
|
+
pkg.set('license', licenseId);
|
|
90
|
+
pkg.set('copyright.owner', options.copyrightOwner);
|
|
92
91
|
await fs.write(
|
|
93
92
|
path.join(projectRoot, 'LICENSE'),
|
|
94
93
|
renderLicense({
|
|
95
|
-
name: pkg.name,
|
|
94
|
+
name: pkg.get('name'),
|
|
96
95
|
owner: options.copyrightOwner,
|
|
97
96
|
license: options.license,
|
|
98
97
|
years: await getYears(projectRoot),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -31,6 +31,12 @@ module.exports = class DiscoveryGenerator extends ArtifactGenerator {
|
|
|
31
31
|
default: true,
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
+
this.option('relations', {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
description: g.f('Discover and create relations'),
|
|
37
|
+
default: false,
|
|
38
|
+
});
|
|
39
|
+
|
|
34
40
|
this.option('schema', {
|
|
35
41
|
type: String,
|
|
36
42
|
description: g.f('Schema to discover'),
|
|
@@ -50,6 +56,12 @@ module.exports = class DiscoveryGenerator extends ArtifactGenerator {
|
|
|
50
56
|
),
|
|
51
57
|
default: undefined,
|
|
52
58
|
});
|
|
59
|
+
|
|
60
|
+
this.option('optionalId', {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
description: g.f('Boolean to mark id property as optional field'),
|
|
63
|
+
default: false,
|
|
64
|
+
});
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
_setupGenerator() {
|
|
@@ -277,16 +289,26 @@ module.exports = class DiscoveryGenerator extends ArtifactGenerator {
|
|
|
277
289
|
for (let i = 0; i < this.discoveringModels.length; i++) {
|
|
278
290
|
const modelInfo = this.discoveringModels[i];
|
|
279
291
|
debug(`Discovering: ${modelInfo.name}...`);
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
),
|
|
292
|
+
const modelDefinition = await modelMaker.discoverSingleModel(
|
|
293
|
+
this.artifactInfo.dataSource,
|
|
294
|
+
modelInfo.name,
|
|
295
|
+
{
|
|
296
|
+
schema: modelInfo.owner,
|
|
297
|
+
disableCamelCase: this.artifactInfo.disableCamelCase,
|
|
298
|
+
associations: this.options.relations,
|
|
299
|
+
},
|
|
289
300
|
);
|
|
301
|
+
if (this.options.optionalId) {
|
|
302
|
+
// Find id properties (can be multiple ids if using composite key)
|
|
303
|
+
const idProperties = Object.values(modelDefinition.properties).filter(
|
|
304
|
+
property => property.id,
|
|
305
|
+
);
|
|
306
|
+
// Mark as not required
|
|
307
|
+
idProperties.forEach(property => {
|
|
308
|
+
property.required = false;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
this.artifactInfo.modelDefinitions.push(modelDefinition);
|
|
290
312
|
debug(`Discovered: ${modelInfo.name}`);
|
|
291
313
|
}
|
|
292
314
|
}
|
|
@@ -321,6 +343,46 @@ module.exports = class DiscoveryGenerator extends ArtifactGenerator {
|
|
|
321
343
|
);
|
|
322
344
|
debug(`Writing: ${fullPath}`);
|
|
323
345
|
|
|
346
|
+
if (this.options.relations) {
|
|
347
|
+
const relationImports = [];
|
|
348
|
+
const relationDestinationImports = [];
|
|
349
|
+
const foreignKeys = {};
|
|
350
|
+
for (const relationName in templateData.settings.relations) {
|
|
351
|
+
const relation = templateData.settings.relations[relationName];
|
|
352
|
+
const targetModel = this.artifactInfo.modelDefinitions.find(
|
|
353
|
+
model => model.name === relation.model,
|
|
354
|
+
);
|
|
355
|
+
// If targetModel is not in discovered models, skip creating relation
|
|
356
|
+
if (targetModel) {
|
|
357
|
+
Object.assign(templateData.properties[relation.foreignKey], {
|
|
358
|
+
relation,
|
|
359
|
+
});
|
|
360
|
+
relationImports.push(relation.type);
|
|
361
|
+
relationDestinationImports.push(relation.model);
|
|
362
|
+
|
|
363
|
+
foreignKeys[relationName] = {};
|
|
364
|
+
Object.assign(foreignKeys[relationName], {
|
|
365
|
+
name: relationName,
|
|
366
|
+
entity: relation.model,
|
|
367
|
+
entityKey: Object.entries(targetModel.properties).find(
|
|
368
|
+
x => x?.[1].id === 1,
|
|
369
|
+
)?.[0],
|
|
370
|
+
foreignKey: relation.foreignKey,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
templateData.relationImports = relationImports;
|
|
375
|
+
templateData.relationDestinationImports = relationDestinationImports;
|
|
376
|
+
// Delete relation from modelSettings
|
|
377
|
+
delete templateData.settings.relations;
|
|
378
|
+
if (Object.keys(foreignKeys)?.length > 0) {
|
|
379
|
+
Object.assign(templateData.settings, {foreignKeys});
|
|
380
|
+
}
|
|
381
|
+
templateData.modelSettings = utils.stringifyModelSettings(
|
|
382
|
+
templateData.settings,
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
324
386
|
this.copyTemplatedFiles(
|
|
325
387
|
modelDiscoverer.MODEL_TEMPLATE_PATH,
|
|
326
388
|
fullPath,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2017,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -26,7 +26,7 @@ which exports this provider with a binding key of `extension-starter.timer`. You
|
|
|
26
26
|
can learn more about components in the
|
|
27
27
|
[related resources section](#related-resources).
|
|
28
28
|
|
|
29
|
-
This provider makes
|
|
29
|
+
This provider makes available to your application a timer function which given a
|
|
30
30
|
start time _(given as an array [seconds, nanoseconds])_ can give you a total
|
|
31
31
|
time elapsed since the start in milliseconds. The timer can also start timing if
|
|
32
32
|
no start time is given. This is used by LogComponent to allow a user to time a
|
|
@@ -58,7 +58,7 @@ import {ExtensionStarterBindings} from 'HelloExtensions';
|
|
|
58
58
|
const key = ExtensionStarterBindings.LOG_ACTION;
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
LogProvider gives us a
|
|
61
|
+
LogProvider gives us a sequence action and a `startTimer` function. In order to
|
|
62
62
|
use the sequence action, you must define your own sequence as shown below.
|
|
63
63
|
|
|
64
64
|
**Example: Sequence**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<% if (isModelBaseBuiltin) { -%>
|
|
2
|
-
import {<%= modelBaseClass %>, model, property} from '@loopback/repository';
|
|
2
|
+
import {<%= modelBaseClass %>, model, property<%if (locals.relationImports) {%><% relationImports.forEach((relation) => {-%>, <%= relation %> <%_})-%><%}%>} from '@loopback/repository';
|
|
3
3
|
<% } else { -%>
|
|
4
|
-
import {model, property} from '@loopback/repository';
|
|
4
|
+
import {model, property<%if (locals.relationImports) {%><% relationImports.forEach((relation) => {-%> , <%= relation %> <%_})-%><%}%>} from '@loopback/repository';
|
|
5
5
|
import {<%= modelBaseClass %>} from '.';
|
|
6
6
|
<% } -%>
|
|
7
|
+
<%_ if (locals.relationDestinationImports && locals.relationDestinationImports.length > 0) { -%>
|
|
8
|
+
import {<% relationDestinationImports.forEach((model, index) => {-%><%= model %><%if (index!==relationDestinationImports.length-1) {%>,<% } %> <%_}) -%>} from '.';
|
|
9
|
+
<%_ } -%>
|
|
7
10
|
|
|
8
11
|
<% if (modelSettings) { -%>
|
|
9
12
|
@model(<%- modelSettings %>)
|
|
@@ -12,13 +15,17 @@ import {<%= modelBaseClass %>} from '.';
|
|
|
12
15
|
<% } -%>
|
|
13
16
|
export class <%= className %> extends <%= modelBaseClass %> {
|
|
14
17
|
<% Object.entries(properties).forEach(([key, val]) => { -%>
|
|
18
|
+
<% if (val.relation) { -%>
|
|
19
|
+
@<%= val.relation.type %>(() => <%= val.relation.model %>)
|
|
20
|
+
<% } else { -%>
|
|
15
21
|
@property({
|
|
16
22
|
<%_ Object.entries(val).forEach(([propKey, propVal]) => { -%>
|
|
17
|
-
|
|
23
|
+
<%_ if (!['tsType', 'relation'].includes(propKey)) { -%>
|
|
18
24
|
<%= propKey %>: <%- propVal %>,
|
|
19
|
-
|
|
25
|
+
<%_ } -%>
|
|
20
26
|
<%_ }) -%>
|
|
21
27
|
})
|
|
28
|
+
<% } -%>
|
|
22
29
|
<%= key %><%if (!val.required) {%>?<% } %>: <%= val.tsType %>;
|
|
23
30
|
|
|
24
31
|
<% }) -%>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -26,6 +26,7 @@ const PROMPT_MESSAGE_MODEL = g.f(
|
|
|
26
26
|
);
|
|
27
27
|
const PROMPT_MESSAGE_DATA_SOURCE = g.f('Please select the datasource');
|
|
28
28
|
const PROMPT_MESSAGE_BASE_PATH = g.f('Please specify the base path');
|
|
29
|
+
const PROMPT_MESSAGE_READONLY = g.f('Do you want to create readonly APIs?');
|
|
29
30
|
|
|
30
31
|
const ERROR_NO_DATA_SOURCES_FOUND = g.f('No datasources found at');
|
|
31
32
|
const ERROR_NO_MODELS_FOUND = g.f('No models found at');
|
|
@@ -93,6 +94,13 @@ module.exports = class RestCrudGenerator extends ArtifactGenerator {
|
|
|
93
94
|
description: g.f('A valid base path'),
|
|
94
95
|
});
|
|
95
96
|
|
|
97
|
+
this.option('readonly', {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
required: false,
|
|
100
|
+
description: g.f('Create readonly APIs'),
|
|
101
|
+
default: false,
|
|
102
|
+
});
|
|
103
|
+
|
|
96
104
|
return super._setupGenerator();
|
|
97
105
|
}
|
|
98
106
|
|
|
@@ -308,6 +316,20 @@ module.exports = class RestCrudGenerator extends ArtifactGenerator {
|
|
|
308
316
|
}
|
|
309
317
|
}
|
|
310
318
|
|
|
319
|
+
async promptReadonly() {
|
|
320
|
+
const props = await this.prompt([
|
|
321
|
+
{
|
|
322
|
+
type: 'confirm',
|
|
323
|
+
name: 'readonly',
|
|
324
|
+
message: PROMPT_MESSAGE_READONLY,
|
|
325
|
+
default: false,
|
|
326
|
+
},
|
|
327
|
+
]);
|
|
328
|
+
if (props) {
|
|
329
|
+
this.artifactInfo.readonly = props.readonly;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
311
333
|
async scaffold() {
|
|
312
334
|
if (this.shouldExit()) return false;
|
|
313
335
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2017,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
package/lib/ast-helper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
package/lib/base-generator.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2017,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
5
5
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
+
const _ = require('lodash');
|
|
8
9
|
const Generator = require('yeoman-generator');
|
|
9
10
|
const chalk = require('chalk');
|
|
10
11
|
const {StatusConflicter, readTextFromStdin} = require('./utils');
|
|
@@ -15,6 +16,8 @@ const updateIndex = require('./update-index');
|
|
|
15
16
|
const {checkLoopBackProject} = require('./version-helper');
|
|
16
17
|
const g = require('./globalize');
|
|
17
18
|
|
|
19
|
+
_.extend(Generator.prototype, require('yeoman-generator/lib/actions/install'));
|
|
20
|
+
|
|
18
21
|
const supportedPackageManagers = ['npm', 'yarn'];
|
|
19
22
|
|
|
20
23
|
debug('Is stdin interactive (isTTY)?', process.stdin.isTTY);
|
|
@@ -47,10 +50,9 @@ module.exports = class BaseGenerator extends Generator {
|
|
|
47
50
|
constructor(args, opts) {
|
|
48
51
|
super(args, opts);
|
|
49
52
|
debug('Initializing generator', this.constructor.name);
|
|
50
|
-
this.conflicter = new StatusConflicter(
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
);
|
|
53
|
+
this.conflicter = new StatusConflicter(this.env.adapter, {
|
|
54
|
+
force: this.options.force,
|
|
55
|
+
});
|
|
54
56
|
this._setupGenerator();
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -479,14 +481,15 @@ module.exports = class BaseGenerator extends Generator {
|
|
|
479
481
|
|
|
480
482
|
// Check all files being generated to ensure they succeeded
|
|
481
483
|
_isGenerationSuccessful() {
|
|
482
|
-
const generationStatus = !!Object.entries(
|
|
483
|
-
|
|
484
|
-
).find(([key, val]) => {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
});
|
|
488
|
-
debug(`Generation status: ${generationStatus}`);
|
|
489
|
-
return generationStatus;
|
|
484
|
+
// const generationStatus = !!Object.entries(
|
|
485
|
+
// this.conflicter.generationStatus,
|
|
486
|
+
// ).find(([key, val]) => {
|
|
487
|
+
// // If a file was modified, update the indexes and say stuff about it
|
|
488
|
+
// return val !== 'skip' && val !== 'identical';
|
|
489
|
+
// });
|
|
490
|
+
// debug(`Generation status: ${generationStatus}`);
|
|
491
|
+
// return generationStatus;
|
|
492
|
+
return true; // FixMe: Conflicter does not work
|
|
490
493
|
}
|
|
491
494
|
|
|
492
495
|
async _updateIndexFile(dir, file) {
|
package/lib/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
package/lib/debug.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -12,5 +12,5 @@ const debug = require('debug');
|
|
|
12
12
|
* @param {String=} scope The scope to use for the debug statement.
|
|
13
13
|
*/
|
|
14
14
|
module.exports = function (scope) {
|
|
15
|
-
return debug(
|
|
15
|
+
return debug('loopback:cli').extend(scope);
|
|
16
16
|
};
|
package/lib/globalize.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
package/lib/model-discoverer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
package/lib/project-generator.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2017,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -96,7 +96,7 @@ module.exports = class ProjectGenerator extends BaseGenerator {
|
|
|
96
96
|
* from files that have it during project generation.
|
|
97
97
|
*/
|
|
98
98
|
_setupRenameTransformer() {
|
|
99
|
-
this.
|
|
99
|
+
this.queueTransformStream(utils.renameEJS());
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
async setOptions() {
|
package/lib/tab-completion.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
package/lib/update-index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
package/lib/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2017,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -23,7 +23,7 @@ const toVarName = require('change-case').camelCase;
|
|
|
23
23
|
const pluralize = require('pluralize');
|
|
24
24
|
const urlSlug = require('url-slug');
|
|
25
25
|
const validate = require('validate-npm-package-name');
|
|
26
|
-
const Conflicter = require('yeoman-
|
|
26
|
+
const Conflicter = require('yeoman-environment/conflicter');
|
|
27
27
|
const connectors = require('./connectors.json');
|
|
28
28
|
const tsquery = require('./ast-helper');
|
|
29
29
|
const stringifyObject = require('stringify-object');
|
|
@@ -300,8 +300,8 @@ exports.validateUrlSlug = function (name) {
|
|
|
300
300
|
* Extends conflicter so that it keeps track of conflict status
|
|
301
301
|
*/
|
|
302
302
|
exports.StatusConflicter = class StatusConflicter extends Conflicter {
|
|
303
|
-
constructor(adapter,
|
|
304
|
-
super(adapter,
|
|
303
|
+
constructor(adapter, opts) {
|
|
304
|
+
super(adapter, opts);
|
|
305
305
|
this.generationStatus = {}; // keeps track of file conflict history
|
|
306
306
|
}
|
|
307
307
|
|
|
@@ -587,7 +587,7 @@ exports.getInterceptorFileName = function (interceptorName) {
|
|
|
587
587
|
*
|
|
588
588
|
* Returns the connector property for the datasource file
|
|
589
589
|
* @param {string} datasourcesDir path for sources
|
|
590
|
-
* @param {string} dataSourceClass class name for the
|
|
590
|
+
* @param {string} dataSourceClass class name for the datasource
|
|
591
591
|
*/
|
|
592
592
|
exports.getDataSourceConnectorName = function (
|
|
593
593
|
datasourcesDir,
|
|
@@ -606,7 +606,7 @@ exports.getDataSourceConnectorName = function (
|
|
|
606
606
|
* connectorType supplied for the given connector name
|
|
607
607
|
* @param {string} connectorType single or a comma separated string array
|
|
608
608
|
* @param {string} datasourcesDir path for sources
|
|
609
|
-
* @param {string} dataSourceClass class name for the
|
|
609
|
+
* @param {string} dataSourceClass class name for the datasource
|
|
610
610
|
*/
|
|
611
611
|
exports.isConnectorOfType = function (
|
|
612
612
|
connectorType,
|
|
@@ -688,7 +688,7 @@ function readDataSourceConfigFromJSON(datasourcesDir, dataSourceClass) {
|
|
|
688
688
|
*
|
|
689
689
|
* returns the name property inside the datasource json file
|
|
690
690
|
* @param {string} datasourcesDir path for sources
|
|
691
|
-
* @param {string} dataSourceClass class name for the
|
|
691
|
+
* @param {string} dataSourceClass class name for the datasource
|
|
692
692
|
*/
|
|
693
693
|
exports.getDataSourceName = function (datasourcesDir, dataSourceClass) {
|
|
694
694
|
if (!dataSourceClass) {
|
package/lib/version-helper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
1
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
2
2
|
// Node module: @loopback/cli
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
@@ -35,7 +35,6 @@ function printVersions(log = console.log) {
|
|
|
35
35
|
*/
|
|
36
36
|
async function checkDependencies(generator) {
|
|
37
37
|
const pkg = generator.fs.readJSON(generator.destinationPath('package.json'));
|
|
38
|
-
generator.packageJson = pkg;
|
|
39
38
|
|
|
40
39
|
const isUpdate = generator.command === 'update';
|
|
41
40
|
const pkgDeps = pkg
|
|
@@ -131,7 +130,7 @@ async function checkDependencies(generator) {
|
|
|
131
130
|
return;
|
|
132
131
|
}
|
|
133
132
|
|
|
134
|
-
const originalCliVersion = generator.config.get('
|
|
133
|
+
const originalCliVersion = generator.config.get('version') || '<unknown>';
|
|
135
134
|
generator.log(
|
|
136
135
|
chalk.red(
|
|
137
136
|
g.f(
|
|
@@ -169,7 +168,7 @@ async function checkDependencies(generator) {
|
|
|
169
168
|
*/
|
|
170
169
|
function updateDependencies(generator) {
|
|
171
170
|
const pkg =
|
|
172
|
-
generator.packageJson ||
|
|
171
|
+
generator.packageJson.getAll() ||
|
|
173
172
|
generator.fs.readJSON(generator.destinationPath('package.json'));
|
|
174
173
|
const depUpdates = [];
|
|
175
174
|
for (const d in templateDeps) {
|
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.
|
|
4
|
+
"version": "4.1.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"LoopBack",
|
|
7
7
|
"CLI",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"lb4": "bin/cli-main.js"
|
|
13
13
|
},
|
|
14
14
|
"main": "generators/app/index.js",
|
|
15
|
-
"author": "IBM Corp.",
|
|
16
|
-
"copyright.owner": "IBM Corp.",
|
|
15
|
+
"author": "IBM Corp. and LoopBack contributors",
|
|
16
|
+
"copyright.owner": "IBM Corp. and LoopBack contributors",
|
|
17
17
|
"homepage": "https://github.com/loopbackio/loopback-next/tree/master/packages/cli",
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
@@ -39,29 +39,29 @@
|
|
|
39
39
|
".yo-rc.json"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@lerna/project": "^4.0
|
|
43
|
-
"@openapi-contrib/openapi-schema-to-json-schema": "^3.
|
|
42
|
+
"@lerna/project": "^5.4.0",
|
|
43
|
+
"@openapi-contrib/openapi-schema-to-json-schema": "^3.2.0",
|
|
44
44
|
"@phenomnomnominal/tsquery": "^4.2.0",
|
|
45
45
|
"camelcase-keys": "^7.0.2",
|
|
46
46
|
"chalk": "^4.1.2",
|
|
47
47
|
"change-case": "^4.1.2",
|
|
48
48
|
"debug": "^4.3.4",
|
|
49
49
|
"fs-extra": "^10.1.0",
|
|
50
|
-
"glob": "^8.0.
|
|
50
|
+
"glob": "^8.0.3",
|
|
51
51
|
"inquirer-autocomplete-prompt": "^2.0.0",
|
|
52
52
|
"json5": "^2.2.1",
|
|
53
53
|
"latest-version": "^5.1.0",
|
|
54
54
|
"lodash": "^4.17.21",
|
|
55
|
-
"minimatch": "^5.0
|
|
55
|
+
"minimatch": "^5.1.0",
|
|
56
56
|
"minimist": "^1.2.6",
|
|
57
57
|
"mkdirp": "^1.0.4",
|
|
58
58
|
"natural-compare": "^1.4.0",
|
|
59
|
-
"pacote": "^13.
|
|
59
|
+
"pacote": "^13.6.1",
|
|
60
60
|
"pluralize": "^8.0.0",
|
|
61
61
|
"regenerate": "^1.4.2",
|
|
62
62
|
"semver": "^7.3.7",
|
|
63
63
|
"slash": "^3.0.0",
|
|
64
|
-
"spdx-license-list": "^6.
|
|
64
|
+
"spdx-license-list": "^6.6.0",
|
|
65
65
|
"stringify-object": "^3.3.0",
|
|
66
66
|
"strong-globalize": "^6.0.5",
|
|
67
67
|
"swagger-parser": "^10.0.3",
|
|
@@ -70,129 +70,131 @@
|
|
|
70
70
|
"terminal-link": "^2.1.1",
|
|
71
71
|
"tildify": "^2.0.0",
|
|
72
72
|
"ts-morph": "^12.2.0",
|
|
73
|
-
"typescript": "~4.
|
|
73
|
+
"typescript": "~4.7.4",
|
|
74
74
|
"unicode-10.0.0": "^0.7.5",
|
|
75
75
|
"untildify": "^4.0.0",
|
|
76
76
|
"update-notifier": "^5.1.0",
|
|
77
|
-
"url-slug": "^3.0.
|
|
77
|
+
"url-slug": "^3.0.4",
|
|
78
78
|
"validate-npm-package-name": "^4.0.0",
|
|
79
79
|
"write-file-atomic": "^4.0.1",
|
|
80
|
-
"yeoman-environment": "^
|
|
81
|
-
"yeoman-generator": "^
|
|
80
|
+
"yeoman-environment": "^3.10.0",
|
|
81
|
+
"yeoman-generator": "^5.7.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@loopback/build": "^9.0.
|
|
85
|
-
"@loopback/eslint-config": "^13.0.
|
|
86
|
-
"@loopback/testlab": "^5.0.
|
|
87
|
-
"@types/ejs": "^3.1.
|
|
84
|
+
"@loopback/build": "^9.0.2",
|
|
85
|
+
"@loopback/eslint-config": "^13.0.2",
|
|
86
|
+
"@loopback/testlab": "^5.0.2",
|
|
87
|
+
"@types/ejs": "^3.1.1",
|
|
88
88
|
"@types/fs-extra": "^9.0.13",
|
|
89
89
|
"@types/minimatch": "^3.0.5",
|
|
90
|
-
"@types/node": "^
|
|
90
|
+
"@types/node": "^14.18.23",
|
|
91
|
+
"@types/yeoman-environment": "^2.10.7",
|
|
92
|
+
"@types/yeoman-generator": "^5.2.10",
|
|
91
93
|
"loopback": "^3.28.0",
|
|
92
94
|
"loopback-datasource-juggler": "^4.27.1",
|
|
93
95
|
"mem-fs": "^2.2.1",
|
|
94
|
-
"mem-fs-editor": "^9.
|
|
96
|
+
"mem-fs-editor": "^9.5.0",
|
|
95
97
|
"mock-stdin": "^1.0.0",
|
|
96
98
|
"rimraf": "^3.0.2",
|
|
97
99
|
"sinon": "^11.1.2",
|
|
98
100
|
"strong-globalize-cli": "7.1.0",
|
|
99
101
|
"yeoman-assert": "^3.1.1",
|
|
100
|
-
"yeoman-test": "^
|
|
102
|
+
"yeoman-test": "^6.3.0"
|
|
101
103
|
},
|
|
102
104
|
"config": {
|
|
103
105
|
"templateDependencies": {
|
|
104
106
|
"tslib": "^2.0.0",
|
|
105
107
|
"@types/mocha": "^9.1.1",
|
|
106
|
-
"@types/node": "^
|
|
108
|
+
"@types/node": "^14.18.21",
|
|
107
109
|
"cross-spawn": "^7.0.3",
|
|
108
110
|
"debug": "^4.3.4",
|
|
109
111
|
"fs-extra": "^10.1.0",
|
|
110
112
|
"mocha": "^10.0.0",
|
|
111
113
|
"nyc": "^15.1.0",
|
|
112
|
-
"prettier": "^2.
|
|
114
|
+
"prettier": "^2.7.1",
|
|
113
115
|
"rimraf": "^3.0.2",
|
|
114
116
|
"source-map-support": "^0.5.21",
|
|
115
|
-
"typescript": "~4.
|
|
116
|
-
"@loopback/authentication": "^9.0.
|
|
117
|
-
"@loopback/boot": "^5.0.
|
|
118
|
-
"@loopback/build": "^9.0.
|
|
119
|
-
"@loopback/cli": "^4.
|
|
120
|
-
"@loopback/context": "^5.0.
|
|
121
|
-
"@loopback/core": "^4.0.
|
|
122
|
-
"@loopback/metadata": "^5.0.
|
|
123
|
-
"@loopback/openapi-spec-builder": "^5.0.
|
|
124
|
-
"@loopback/openapi-v3": "^8.0.
|
|
125
|
-
"@loopback/repository-json-schema": "^6.0.
|
|
126
|
-
"@loopback/repository": "^5.0.
|
|
127
|
-
"@loopback/rest": "^12.0.
|
|
128
|
-
"@loopback/testlab": "^5.0.
|
|
129
|
-
"@loopback/docs": "^5.
|
|
130
|
-
"glob": "^8.0.
|
|
131
|
-
"@loopback/example-hello-world": "^5.0.
|
|
132
|
-
"@loopback/example-log-extension": "^5.0.
|
|
133
|
-
"@loopback/example-rpc-server": "^5.0.
|
|
134
|
-
"@loopback/example-todo": "^6.0.
|
|
135
|
-
"@loopback/example-soap-calculator": "^5.0.
|
|
136
|
-
"@loopback/service-proxy": "^5.0.
|
|
137
|
-
"@loopback/http-caching-proxy": "^4.0.
|
|
138
|
-
"@loopback/http-server": "^4.0.
|
|
139
|
-
"@loopback/example-todo-list": "^6.0.
|
|
117
|
+
"typescript": "~4.7.4",
|
|
118
|
+
"@loopback/authentication": "^9.0.2",
|
|
119
|
+
"@loopback/boot": "^5.0.2",
|
|
120
|
+
"@loopback/build": "^9.0.2",
|
|
121
|
+
"@loopback/cli": "^4.1.1",
|
|
122
|
+
"@loopback/context": "^5.0.2",
|
|
123
|
+
"@loopback/core": "^4.0.2",
|
|
124
|
+
"@loopback/metadata": "^5.0.2",
|
|
125
|
+
"@loopback/openapi-spec-builder": "^5.0.2",
|
|
126
|
+
"@loopback/openapi-v3": "^8.0.2",
|
|
127
|
+
"@loopback/repository-json-schema": "^6.0.2",
|
|
128
|
+
"@loopback/repository": "^5.0.2",
|
|
129
|
+
"@loopback/rest": "^12.0.2",
|
|
130
|
+
"@loopback/testlab": "^5.0.2",
|
|
131
|
+
"@loopback/docs": "^5.1.1",
|
|
132
|
+
"glob": "^8.0.3",
|
|
133
|
+
"@loopback/example-hello-world": "^5.0.2",
|
|
134
|
+
"@loopback/example-log-extension": "^5.0.2",
|
|
135
|
+
"@loopback/example-rpc-server": "^5.0.2",
|
|
136
|
+
"@loopback/example-todo": "^6.0.2",
|
|
137
|
+
"@loopback/example-soap-calculator": "^5.0.2",
|
|
138
|
+
"@loopback/service-proxy": "^5.0.2",
|
|
139
|
+
"@loopback/http-caching-proxy": "^4.0.2",
|
|
140
|
+
"@loopback/http-server": "^4.0.2",
|
|
141
|
+
"@loopback/example-todo-list": "^6.0.2",
|
|
140
142
|
"@loopback/dist-util": "^0.4.0",
|
|
141
|
-
"@loopback/rest-explorer": "^5.0.
|
|
142
|
-
"@loopback/eslint-config": "^13.0.
|
|
143
|
+
"@loopback/rest-explorer": "^5.0.2",
|
|
144
|
+
"@loopback/eslint-config": "^13.0.2",
|
|
143
145
|
"express-composition": "^1.1.0",
|
|
144
|
-
"@loopback/example-express-composition": "^5.0.
|
|
145
|
-
"@loopback/example-greeter-extension": "^5.0.
|
|
146
|
-
"@loopback/booter-lb3app": "^4.0.
|
|
147
|
-
"@loopback/example-lb3-application": "^5.0.
|
|
148
|
-
"eslint": "^8.
|
|
149
|
-
"eslint-plugin-mocha": "10.0.
|
|
150
|
-
"@loopback/example-greeting-app": "^5.0.
|
|
151
|
-
"@loopback/example-context": "^5.0.
|
|
152
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
153
|
-
"@typescript-eslint/parser": "^5.
|
|
154
|
-
"eslint-plugin-eslint-plugin": "^4.1
|
|
146
|
+
"@loopback/example-express-composition": "^5.0.2",
|
|
147
|
+
"@loopback/example-greeter-extension": "^5.0.2",
|
|
148
|
+
"@loopback/booter-lb3app": "^4.0.2",
|
|
149
|
+
"@loopback/example-lb3-application": "^5.0.2",
|
|
150
|
+
"eslint": "^8.19.0",
|
|
151
|
+
"eslint-plugin-mocha": "^10.0.5",
|
|
152
|
+
"@loopback/example-greeting-app": "^5.0.2",
|
|
153
|
+
"@loopback/example-context": "^5.0.2",
|
|
154
|
+
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
|
155
|
+
"@typescript-eslint/parser": "^5.30.6",
|
|
156
|
+
"eslint-plugin-eslint-plugin": "^4.4.1",
|
|
155
157
|
"eslint-config-prettier": "^8.5.0",
|
|
156
|
-
"@loopback/repository-tests": "^0.21.
|
|
157
|
-
"@loopback/health": "^0.11.
|
|
158
|
-
"@loopback/authorization": "^0.12.
|
|
159
|
-
"@loopback/rest-crud": "^0.
|
|
160
|
-
"@loopback/security": "^0.8.
|
|
161
|
-
"@loopback/authentication-passport": "^5.0.
|
|
162
|
-
"@loopback/example-metrics-prometheus": "^0.10.
|
|
163
|
-
"@loopback/metrics": "^0.11.
|
|
164
|
-
"@loopback/model-api-builder": "^4.0.
|
|
165
|
-
"@loopback/logging": "^0.9.
|
|
166
|
-
"@loopback/example-access-control-migration": "^5.0.
|
|
167
|
-
"@loopback/example-file-transfer": "^4.0.
|
|
168
|
-
"@loopback/example-rest-crud": "^4.0.
|
|
169
|
-
"@loopback/apiconnect": "^0.10.
|
|
170
|
-
"@loopback/example-validation-app": "^4.0.
|
|
171
|
-
"@loopback/cron": "^0.9.
|
|
172
|
-
"@loopback/example-multi-tenancy": "^0.13.
|
|
173
|
-
"@loopback/example-passport-login": "^4.0.
|
|
174
|
-
"@loopback/authentication-jwt": "^0.12.
|
|
175
|
-
"@loopback/context-explorer": "^0.8.
|
|
176
|
-
"@loopback/express": "^5.0.
|
|
158
|
+
"@loopback/repository-tests": "^0.21.2",
|
|
159
|
+
"@loopback/health": "^0.11.2",
|
|
160
|
+
"@loopback/authorization": "^0.12.2",
|
|
161
|
+
"@loopback/rest-crud": "^0.15.1",
|
|
162
|
+
"@loopback/security": "^0.8.2",
|
|
163
|
+
"@loopback/authentication-passport": "^5.0.2",
|
|
164
|
+
"@loopback/example-metrics-prometheus": "^0.10.2",
|
|
165
|
+
"@loopback/metrics": "^0.11.2",
|
|
166
|
+
"@loopback/model-api-builder": "^4.0.2",
|
|
167
|
+
"@loopback/logging": "^0.9.2",
|
|
168
|
+
"@loopback/example-access-control-migration": "^5.0.2",
|
|
169
|
+
"@loopback/example-file-transfer": "^4.0.2",
|
|
170
|
+
"@loopback/example-rest-crud": "^4.0.2",
|
|
171
|
+
"@loopback/apiconnect": "^0.10.2",
|
|
172
|
+
"@loopback/example-validation-app": "^4.0.2",
|
|
173
|
+
"@loopback/cron": "^0.9.2",
|
|
174
|
+
"@loopback/example-multi-tenancy": "^0.13.2",
|
|
175
|
+
"@loopback/example-passport-login": "^4.0.2",
|
|
176
|
+
"@loopback/authentication-jwt": "^0.12.2",
|
|
177
|
+
"@loopback/context-explorer": "^0.8.2",
|
|
178
|
+
"@loopback/express": "^5.0.2",
|
|
177
179
|
"@types/js-yaml": "^3.12.4",
|
|
178
180
|
"js-yaml": "^3.13.1",
|
|
179
|
-
"@loopback/example-todo-jwt": "^4.0.
|
|
180
|
-
"@loopback/mock-oauth2-provider": "^0.6.
|
|
181
|
+
"@loopback/example-todo-jwt": "^4.0.2",
|
|
182
|
+
"@loopback/mock-oauth2-provider": "^0.6.2",
|
|
181
183
|
"lodash": "^4.17.21",
|
|
182
|
-
"@loopback/pooling": "^0.8.
|
|
183
|
-
"@loopback/typeorm": "^0.7.
|
|
184
|
-
"@loopback/example-graphql": "^0.7.
|
|
185
|
-
"@loopback/graphql": "^0.8.
|
|
186
|
-
"@loopback/filter": "^3.0.
|
|
187
|
-
"@loopback/rest-msgpack": "^0.8.
|
|
188
|
-
"@loopback/example-binding-resolution": "^0.7.
|
|
189
|
-
"@loopback/example-webpack": "^0.8.
|
|
190
|
-
"@loopback/example-socketio": "^0.6.
|
|
191
|
-
"@loopback/socketio": "^0.6.
|
|
192
|
-
"@loopback/monorepo": "^0.5.
|
|
193
|
-
"@loopback/tsdocs": "^4.0.
|
|
194
|
-
"@loopback/example-references-many": "^6.0.
|
|
184
|
+
"@loopback/pooling": "^0.8.2",
|
|
185
|
+
"@loopback/typeorm": "^0.7.2",
|
|
186
|
+
"@loopback/example-graphql": "^0.7.2",
|
|
187
|
+
"@loopback/graphql": "^0.8.2",
|
|
188
|
+
"@loopback/filter": "^3.0.2",
|
|
189
|
+
"@loopback/rest-msgpack": "^0.8.2",
|
|
190
|
+
"@loopback/example-binding-resolution": "^0.7.2",
|
|
191
|
+
"@loopback/example-webpack": "^0.8.2",
|
|
192
|
+
"@loopback/example-socketio": "^0.6.2",
|
|
193
|
+
"@loopback/socketio": "^0.6.2",
|
|
194
|
+
"@loopback/monorepo": "^0.5.2",
|
|
195
|
+
"@loopback/tsdocs": "^4.0.2",
|
|
196
|
+
"@loopback/example-references-many": "^6.0.2"
|
|
195
197
|
}
|
|
196
198
|
},
|
|
197
|
-
"gitHead": "
|
|
199
|
+
"gitHead": "cc63323e20cf39c62402f1dee108bf9e9d23e133"
|
|
198
200
|
}
|