Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/cli/generators/datasource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module.exports = class DataSourceGenerator extends ArtifactGenerator {
// Set defaults and merge with `setting` to override properties
const question = Object.assign(
{},
{name: key, message: key, suffix: ':'},
{name: key, message: key, suffix: ':', type: 'input'},
setting,
);

Expand All @@ -178,18 +178,25 @@ module.exports = class DataSourceGenerator extends ArtifactGenerator {
*/
switch ((setting.type || '').toLowerCase()) {
case 'string':
question.default = '';
break;
case 'number':
question.type = 'input';
question.default = 0;
break;
case 'object':
question.default = '{}';
question.validate = utils.validateStringObject(setting.type);
break;
case 'array':
question.type = 'input';
question.default = '[]';
question.validate = utils.validateStringObject(setting.type);
break;
case 'boolean':
question.type = 'confirm';
question.default = false;
break;
case 'password':
question.default = '';
break;
default:
console.warn(
Expand Down
1 change: 1 addition & 0 deletions packages/cli/generators/interceptor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ module.exports = class InterceptorGenerator extends ArtifactGenerator {
{
type: 'input',
name: 'group',
default: '',
// capitalization
message: g.f("Group name for the global interceptor: ('')"),
},
Expand Down
1 change: 1 addition & 0 deletions packages/cli/generators/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ module.exports = class ModelGenerator extends ArtifactGenerator {
return true;
}
},
default: '',
},
];

Expand Down
1 change: 1 addition & 0 deletions packages/cli/generators/openapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ module.exports = class OpenApiGenerator extends BaseGenerator {
// This prevents users from accidentally pressing ENTER instead of SPACE
// to select an item from the list
validate: result => !!result.length,
default: choices.map(c => c.value),
},
];
const selections =
Expand Down
1 change: 1 addition & 0 deletions packages/cli/generators/repository/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator {
name: 'modelNameList',
message: PROMPT_MESSAGE_MODEL,
choices: modelList,
default: [],
when: this.artifactInfo.modelNameList === undefined,
// Require at least one model to be selected
// This prevents users from accidentally pressing ENTER instead of SPACE
Expand Down
1 change: 1 addition & 0 deletions packages/cli/generators/rest-crud/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ module.exports = class RestCrudGenerator extends ArtifactGenerator {
name: 'modelNameList',
message: PROMPT_MESSAGE_MODEL,
choices: modelList.map(m => ({name: m, value: m, checked: true})),
default: [],
when: this.artifactInfo.modelNameList === undefined,
// Require at least one model to be selected
// This prevents users from accidentally pressing ENTER instead of SPACE
Expand Down
1 change: 1 addition & 0 deletions packages/cli/lib/project-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ module.exports = class ProjectGenerator extends BaseGenerator {
choices: choices,
// Skip if all features are enabled by cli options
when: choices.length > 0,
default: choices.map(c => c.short),
},
];
return this.prompt(prompts).then(props => {
Expand Down
20 changes: 8 additions & 12 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"sinon": "^9.0.2",
"strong-globalize-cli": "7.0.3",
"yeoman-assert": "^3.1.1",
"yeoman-test": "~2.7.0"
"yeoman-test": "~3.0.0"
},
"dependencies": {
"@lerna/project": "^3.21.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Available commands:
lb4 uninstall-completion
`;


exports[`cli prints commands with --help 1`] = `
Available commands:
lb4 app
Expand All @@ -53,6 +54,7 @@ Available commands:
lb4 uninstall-completion
`;


exports[`cli saves command metadata to .yo-rc.json 1`] = `
{
"commands": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {juggler} from '@loopback/repository';
const config = {
name: 'ds',
connector: 'memory',
localStorage: undefined,
file: undefined
localStorage: '',
file: ''
};

// Observe application's life cycle to disconnect the datasource when
Expand Down Expand Up @@ -46,8 +46,8 @@ import {juggler} from '@loopback/repository';
const config = {
name: 'ds',
connector: 'memory',
localStorage: undefined,
file: undefined
localStorage: '',
file: ''
};

// Observe application's life cycle to disconnect the datasource when
Expand Down Expand Up @@ -78,13 +78,13 @@ import {juggler} from '@loopback/repository';
const config = {
name: 'ds',
connector: 'db2',
dsn: undefined,
host: undefined,
dsn: '',
host: '',
port: 100,
user: undefined,
password: undefined,
database: undefined,
schema: undefined
user: '',
password: '',
database: '',
schema: ''
};

// Observe application's life cycle to disconnect the datasource when
Expand Down Expand Up @@ -115,7 +115,7 @@ import {juggler} from '@loopback/repository';
const config = {
name: 'ds',
connector: 'rest',
baseURL: undefined,
baseURL: '',
options: {
test: 'value'
},
Expand Down Expand Up @@ -155,10 +155,10 @@ const config = {
name: 'ds',
connector: 'cloudant',
url: 'http://user:pass@host.com',
database: undefined,
database: '',
username: 'user',
password: 'pass',
modelIndex: undefined
modelIndex: ''
};

// Observe application's life cycle to disconnect the datasource when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

'use strict';

exports[
`lb4 relation HasManyThrough checks if the controller file created answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","relationName":"myPatients"} controller file has been created with hasManyThrough relation 1`
] = `
exports[`lb4 relation HasManyThrough checks if the controller file created answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","relationName":"myPatients"} controller file has been created with hasManyThrough relation 1`] = `
import {
Count,
CountSchema,
Expand Down Expand Up @@ -123,9 +121,8 @@ export class DoctorPatientController {

`;

exports[
`lb4 relation HasManyThrough checks if the controller file created answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment"} controller file has been created with hasManyThrough relation 1`
] = `

exports[`lb4 relation HasManyThrough checks if the controller file created answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment"} controller file has been created with hasManyThrough relation 1`] = `
import {
Count,
CountSchema,
Expand Down Expand Up @@ -239,9 +236,8 @@ export class DoctorPatientController {

`;

exports[
`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","sourceKeyOnThrough":"customKeyFrom","targetKeyOnThrough":"customKeyTo"} add custom keyTo and/or keyFrom to the through model 1`
] = `

exports[`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","sourceKeyOnThrough":"customKeyFrom","targetKeyOnThrough":"customKeyTo"} add custom keyTo and/or keyFrom to the through model 1`] = `
import {Entity, model, property, hasMany} from '@loopback/repository';
import {Patient} from './patient.model';
import {Appointment} from './appointment.model';
Expand Down Expand Up @@ -270,9 +266,8 @@ export class Doctor extends Entity {

`;

exports[
`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","sourceKeyOnThrough":"customKeyFrom","targetKeyOnThrough":"customKeyTo"} add custom keyTo and/or keyFrom to the through model 2`
] = `

exports[`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","sourceKeyOnThrough":"customKeyFrom","targetKeyOnThrough":"customKeyTo"} add custom keyTo and/or keyFrom to the through model 2`] = `
import {Entity, model, property} from '@loopback/repository';

@model()
Expand Down Expand Up @@ -306,9 +301,8 @@ export class Appointment extends Entity {

`;

exports[
`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","sourceKeyOnThrough":"customKeyFrom"} add custom keyTo and/or keyFrom to the through model 1`
] = `

exports[`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","sourceKeyOnThrough":"customKeyFrom"} add custom keyTo and/or keyFrom to the through model 1`] = `
import {Entity, model, property, hasMany} from '@loopback/repository';
import {Patient} from './patient.model';
import {Appointment} from './appointment.model';
Expand Down Expand Up @@ -337,9 +331,8 @@ export class Doctor extends Entity {

`;

exports[
`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","sourceKeyOnThrough":"customKeyFrom"} add custom keyTo and/or keyFrom to the through model 2`
] = `

exports[`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","sourceKeyOnThrough":"customKeyFrom"} add custom keyTo and/or keyFrom to the through model 2`] = `
import {Entity, model, property} from '@loopback/repository';

@model()
Expand Down Expand Up @@ -373,9 +366,8 @@ export class Appointment extends Entity {

`;

exports[
`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","targetKeyOnThrough":"customKeyTo"} add custom keyTo and/or keyFrom to the through model 1`
] = `

exports[`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","targetKeyOnThrough":"customKeyTo"} add custom keyTo and/or keyFrom to the through model 1`] = `
import {Entity, model, property, hasMany} from '@loopback/repository';
import {Patient} from './patient.model';
import {Appointment} from './appointment.model';
Expand Down Expand Up @@ -404,9 +396,8 @@ export class Doctor extends Entity {

`;

exports[
`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","targetKeyOnThrough":"customKeyTo"} add custom keyTo and/or keyFrom to the through model 2`
] = `

exports[`lb4 relation HasManyThrough generates model relation with custom keyFrom and/or keyTo answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","targetKeyOnThrough":"customKeyTo"} add custom keyTo and/or keyFrom to the through model 2`] = `
import {Entity, model, property} from '@loopback/repository';

@model()
Expand Down Expand Up @@ -440,9 +431,8 @@ export class Appointment extends Entity {

`;

exports[
`lb4 relation HasManyThrough generates model relation with custom relation name answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","relationName":"myPatients"} relation name should be myPatients 1`
] = `

exports[`lb4 relation HasManyThrough generates model relation with custom relation name answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","relationName":"myPatients"} relation name should be myPatients 1`] = `
import {Entity, model, property, hasMany} from '@loopback/repository';
import {Patient} from './patient.model';
import {Appointment} from './appointment.model';
Expand Down Expand Up @@ -471,9 +461,8 @@ export class Doctor extends Entity {

`;

exports[
`lb4 relation HasManyThrough generates model relation with custom relation name answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","relationName":"myPatients"} relation name should be myPatients 2`
] = `

exports[`lb4 relation HasManyThrough generates model relation with custom relation name answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment","relationName":"myPatients"} relation name should be myPatients 2`] = `
import {DefaultCrudRepository, repository, HasManyThroughRepositoryFactory} from '@loopback/repository';
import {Doctor, Patient, Appointment} from '../models';
import {DbDataSource} from '../datasources';
Expand All @@ -499,9 +488,8 @@ export class DoctorRepository extends DefaultCrudRepository<

`;

exports[
`lb4 relation HasManyThrough generates model relation with default values answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment"} has correct default foreign keys 1`
] = `

exports[`lb4 relation HasManyThrough generates model relation with default values answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment"} has correct default foreign keys 1`] = `
import {Entity, model, property} from '@loopback/repository';

@model()
Expand Down Expand Up @@ -535,9 +523,8 @@ export class Appointment extends Entity {

`;

exports[
`lb4 relation HasManyThrough generates model relation with default values answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment"} has correct imports and relation name patients 1`
] = `

exports[`lb4 relation HasManyThrough generates model relation with default values answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment"} has correct imports and relation name patients 1`] = `
import {Entity, model, property, hasMany} from '@loopback/repository';
import {Patient} from './patient.model';
import {Appointment} from './appointment.model';
Expand Down Expand Up @@ -566,9 +553,8 @@ export class Doctor extends Entity {

`;

exports[
`lb4 relation HasManyThrough generates model relation with default values answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment"} has correct imports and relation name patients 2`
] = `

exports[`lb4 relation HasManyThrough generates model relation with default values answers {"relationType":"hasManyThrough","sourceModel":"Doctor","destinationModel":"Patient","throughModel":"Appointment"} has correct imports and relation name patients 2`] = `
import {DefaultCrudRepository, repository, HasManyThroughRepositoryFactory} from '@loopback/repository';
import {Doctor, Patient, Appointment} from '../models';
import {DbDataSource} from '../datasources';
Expand Down