Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/cli/generators/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = class ControllerGenerator extends ArtifactGenerator {
}

promptArtifactType() {
debug(g.f('Prompting for controller type'));
debug('Prompting for controller type');
if (this.shouldExit()) return;

super.promptWarningMsgForName();
Expand Down
15 changes: 9 additions & 6 deletions packages/cli/generators/datasource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ module.exports = class DataSourceGenerator extends ArtifactGenerator {
const prompts = [
{
name: 'connector',
message: `Select the connector for ${chalk.yellow(
this.artifactInfo.name,
)}:`,
message: g.f(
'Select the connector for %s: ',
chalk.yellow(this.artifactInfo.name),
),
type: 'list',
default: 'memory',
choices: this.connectorChoices,
Expand Down Expand Up @@ -191,9 +192,11 @@ module.exports = class DataSourceGenerator extends ArtifactGenerator {
break;
default:
console.warn(
`Using default input of type input for setting ${key} as ${
setting.type || undefined
} is not supported`,
g.f(
'Using default input of type input for setting %s as %s is not supported',
key,
setting.type || undefined,
),
);
// Default to input type
question.type = 'input';
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/generators/discover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ module.exports = class DiscoveryGenerator extends ArtifactGenerator {
promptColNamingConvention() {
this.namingConvention = [
{
name: 'Camel case (exampleColumn) (Recommended)',
name: g.f('Camel case (exampleColumn) (Recommended)'),
value: 'camelCase',
},
{
name: 'No conversion (EXAMPLE_COLUMN)',
name: g.f('No conversion (EXAMPLE_COLUMN)'),
value: 'noCase',
},
];
Expand All @@ -233,7 +233,9 @@ module.exports = class DiscoveryGenerator extends ArtifactGenerator {
if (props.disableCamelCase) {
this.log(
chalk.red(
'By disabling Camel case, you might need to specify these customized names in relation definition.',
g.f(
'By disabling Camel case, you might need to specify these customized names in relation definition.',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

截屏2020-04-21下午5 18 19

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "By disabling Camel case" supposed to still be in English?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the PR, they are supposed to be in English. And those screenshots are showing that the globalized string in English can be translated ( but we don't do the translation ourselves).

),
),
);
}
Expand Down
9 changes: 6 additions & 3 deletions packages/cli/generators/example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ module.exports = class extends BaseGenerator {
if (this.shouldExit()) return;
if (this.exampleName in EXAMPLES) return;
this.exit(
`Invalid example name: ${this.exampleName}\n` +
'Run "lb4 example --help" to print the list of available example names.',
g.f(
'Invalid example name: %s\n' +
'Run "lb4 example --help" to print the list of available example names.',
this.exampleName,
),
);
}

Expand All @@ -143,7 +146,7 @@ module.exports = class extends BaseGenerator {
async end() {
await super.end();
this.log();
this.log(`The example was cloned to ${chalk.green(this.outDir)}.`);
this.log(g.f('The example was cloned to %s.', chalk.green(this.outDir)));
this.log();
}
};
4 changes: 2 additions & 2 deletions packages/cli/generators/openapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ module.exports = class OpenApiGenerator extends BaseGenerator {
specPath: matchedDs.specPath,
};
this.log(
'Datasource %s - %s found for OpenAPI: %s',
g.f('Datasource %s - %s found for OpenAPI: %s'),
this.options.datasource,
this.dataSourceInfo.className,
this.dataSourceInfo.specPath,
Expand Down Expand Up @@ -180,7 +180,7 @@ module.exports = class OpenApiGenerator extends BaseGenerator {
specPath: answers.dataSource.specPath,
};
this.log(
'Datasource %s - %s selected: %s',
g.f('Datasource %s - %s selected: %s'),
this.dataSourceInfo.name,
this.dataSourceInfo.className,
this.dataSourceInfo.specPath,
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/generators/relation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,11 @@ module.exports = class RelationGenerator extends ArtifactGenerator {
{
type: 'confirm',
name: 'registerInclusionResolver',
message: `Allow ${chalk.yellow(
this.artifactInfo.sourceModel,
)} queries to include data from related ${chalk.yellow(
this.artifactInfo.destinationModel,
)} instances?`,
message: g.f(
'Allow %s queries to include data from related %s instances? ',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

chalk.yellow(this.artifactInfo.sourceModel),
chalk.yellow(this.artifactInfo.destinationModel),
),
default: true,
},
]);
Expand Down
25 changes: 19 additions & 6 deletions packages/cli/intl/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,27 @@
"1464cbc7a74f0f53a7acec08c638b376": "Do you want to update package.json and LICENSE?",
"1a0b53a1a5323fa92b6634ae16264892": "JSON file name or value to configure options",
"1b41d41e2416c5a532ad20e34338a19b": "Copyright owner",
"1d8b3191def358326ca3c1f5d011c96e": "Promote anonymous schemas as models",
"21840a025087b2fd39b9dd37b7498473": "Using default input of type input for setting {0} as {1} is not supported",
"22097832e90dd9481994416927ad1ecc": "Name for the {0}",
"2384e2eb575c2a7377a3de641b7556e3": "Select controllers to be generated:",
"23fe9f126c159af41d59b9b16b594c05": "A basic RPC server using a made-up protocol.",
"25613bcc246af27bb9adbffb15808516": "Upgrade project dependencies",
"2619c842fedf79c6759daa768ba137fb": "The project was originally generated by @loopback/cli@{0}.",
"2680da6ffe85172d7053e97f8e21d1ff": "A simple hello-world application using LoopBack 4.",
"2b0116dbacdad4756240911be1e71d34": "was created in",
"2d3e0ddbc158e249765cb0bb8f544217": "Format generated code using npm run lint:fix",
"2d5745f8e3d91cf55dcc84f354a43e6c": "Allow <sourceModel> queries to include data from related <destinationModel>",
"3190bfdf06a7237a3593ef7291031507": "A valid based model",
"3411753432848b4f4c6d3e3d73c09f4e": "Type of array items:",
"34a1d0defdf4035829eb9d2bd790b061": "Component class name:",
"35f7f1974164ebad7093cb795630a84f": "By disabling Camel case, you might need to specify these customized names in relation definition.",
"377a709c8cc8bff5d976a4e0da06ef47": "What is the name of ID property?",
"3a4acc1cb8bfc709718a49bfbeeb8460": "Select the model(s) you want to generate a CRUD REST endpoint",
"3cd28c0bc408abf4517f346f8cbe359e": "Is {0} the ID property?",
"3e7a1e0430f90996d14c5065c281fdcf": "Is it a global interceptor?",
"407fbe4b3fc192f22b4e90442c5980a1": "Select the models which to discover",
"40cf3ed09f01e543265ffe4519bd08a5": "Project name for the {0}",
"43036093921e1f4595967e0eb6fcdb8b": "How do you want to proceed?",
"44ae9235f4eab024b184b59fedd71f9c": "Abort now",
"44d2743e9d8e6106410b7fea1fcb69a0": "An example extension project for LoopBack 4.",
"4670d311aa36fb13d626ec4ab55d4f19": "Next steps:",
"48b75482f8e08e012b70a495df71d514": "Mark the project private (excluded from npm publish)",
Expand All @@ -40,6 +45,8 @@
"5225c88650d6a337fb4c215cca812f96": "An access control example migrated from the LoopBack 3 repository loopback-example-access-control.",
"5226c72e763d99e9a316a9ce9875fde9": "Include Dockerfile and .dockerignore",
"52e1f166e76bb9545daf180fb2e63782": "Please select the relation type",
"52f7167a7c775a0e66ef8d5b9ade1fc1": "{0} {1} will be created in src/{2}/{3}.{4}.ts",
"5337dcf1ffc5bb73817a6fe76bb5eb0a": "were created in",
"536024b4c8926c72705ad6796e7629b6": "Boolean to discover views",
"542d9b2310d9bb9f8c4bf792dbb7d6cd": "Application class name:",
"57fc5239f1ed8537950c0dc19a61b85f": "Select the connector to discover",
Expand All @@ -48,11 +55,10 @@
"5a0085f46605278c8b83284484cfa858": "Group name for ordering the global interceptor",
"5a5169e28fedd5752a79ae01155f47a1": "License name:",
"5bdddebdf72c7027a9e24aa500a35dd7": "Default value {0}:",
"5d0490e5ebfdca22d238997aa3882bb9": "Enter the OpenAPI spec url or file path:",
"5dd3fd8d55f85cec0f63ef7c370df454": "Prompting for controller type",
"5eb4697c2c62ae3b805af415847dd069": "No models found in",
"5f9d9ca636cc3bd7e133455d51fa410b": "Please select source model",
"6114abcc1315a8f1e0bef7748b00eb14": "Use preconfigured VSCode settings",
"61d043027dd4251cb87fe4419d35ffd8": "Allow {0} queries to include data from related {1} instances? ",
"635110efac9ccc161e67007e2df6db06": "Schema to discover",
"6393c8247a668f277bae18632fb260c1": "Name of the observer group for ordering",
"63a2b68c48f278cfafe6e2682b30e261": "install prettier to format code conforming to rules",
Expand All @@ -62,12 +68,15 @@
"67ee888416f9432e38942252993cc304": "class does not exist. Please create repository first with \"lb4 repository\" command.",
"693de1283bf4c567269b4984d3d82d82": "Source property name for the relation getter (will be the relation name)",
"6e6a3836ad202ae5c263855b6e98ac85": "Check version compatibility using semver semantics",
"6faaa64820277d3607d43a208ce3da13": "The example was cloned to {0}.",
"70067103913204b5125f9192be23086c": "Is the id omitted when creating a new instance?",
"7228a5fab7ef8492cf66a3ef8df74ddf": "If discovering a model from a dataSource, specify the schema which contains it",
"72e0cfd29751146d9e94bb4d5cf25133": "An example application to demonstrate how to implement multi-tenancy with LoopBack 4.",
"7321493f5e514208aba16acbc3a8d1c9": "No datasources found at",
"74cc43ebc62b786995ac784b37d3764f": "Fail on install dependencies error",
"7652193b0c43b9ffe80339f63574cb63": "{0} class name:",
"76657b97b9993e79fdba1bff7c2a69ed": "add VSCode config files",
"791d59188157facefbdbfb866792462e": "Camel case (exampleColumn) (Recommended)",
"79461416ce81d6f5c3ce3418fc191224": "install mocha to run tests",
"794df3791a8c800841516007427a2aa3": "License",
"7bcd10e0c597ed32f22b06726d10cb2b": "What is the name of your CRUD repository?",
Expand All @@ -88,6 +97,7 @@
"93d2bb2103d07f905ef0e83ea0e63e0b": "Path to your LoopBack 3.x application. This can be a project directory (e.g. \"my-lb3-app\") or the server file (e.g. \"my-lb3-app/server/server.js\").",
"958ae3d061270d7e85cfe6b9c191feaf": "Local service provider bound to application context",
"982e471119e413bad610f51015bf80e0": "Enable eslint",
"9885cdb6ead91df9a95786bad4e66702": "No conversion (EXAMPLE_COLUMN)",
"9a95948dd5623ba2e0486c3fbdd582af": "Relation name",
"9d393adbce56c1a77f232c3d51256be2": "add a linter with pre-configured lint rules",
"9e2f6b14adb66ccd111b6a2fe13cc53c": "Group name for the global interceptor: ('')",
Expand All @@ -101,20 +111,21 @@
"a7f90f78abfa210e6d490268ea98ea80": "A valid model name",
"a8dbe656477e8eab5c8763a9b1ff0f84": "Select models to import:",
"aa2ea1f299d456d85ba42aab96581fe5": "Exclude files that match the pattern",
"aa7af2a74b80e89d69be64f87140314e": "Include ApiConnectComponent",
"ac0a68d90df6320ff454590a5732e748": "An example showing how to implement the extension point/extension pattern.",
"ad5df45eb6b1da34ba7f75bec5b6a3d5": "Flag to indicate a global interceptor",
"aebb8636dacf73a5ea8811fafbe3ed68": "Property type:",
"afdaa0dc3b913a7b3bd5f20489f5c76d": "A valid base path",
"b06ea51aa53522aff2889a64d68d1055": "Relation type",
"b0e22938bbbbeb3d5f4692390820f4de": "Please select the model base class",
"b3c1afbfb1c87daaac414bab981ee7bd": "Error reading file",
"b48768d73c204b1a2ebcc3f44792b556": "Invalid example name: {0}\nRun \"lb4 example --help\" to print the list of available example names.",
"b68ecbcaa4f94151658f5ad32e6cf6fd": "Local service class bound to application context",
"b9356b7d2debc8b04dd6f2fd9bf5f83f": "What example would you like to clone?",
"bcebec8d7974acc21a208c7325a06e9c": "A simplified version of the Todo example that only requires a model and a datasource.",
"be65fa55f75dd126a2af5ec2ad4b8f8b": "An example on how to integrate SOAP web services.",
"be687f67487ae57f311148f55cc2df76": "Foreign key name to define on the source model",
"bfd42878b3c50994368322098aed9e42": "include Dockerfile and .dockerignore",
"c0c9631ff3d1d1ad49a123b03328fe9c": "URL or file path of the OpenAPI spec",
"c1f96ff7ee37bcc6aa150ae5d0dbc3bb": "What is the type of your ID?",
"c3eece87ffd6970cb83a75715824dce7": "include service-proxy imports and ServiceMixin",
"c87a36fbb5183525d0006021aec56a91": "Destination model foreign key name",
Expand All @@ -135,11 +146,13 @@
"d963128609dd73445bd8b96b6a34eb68": "Type for the {0}",
"da3f136dd75297a4944bd013b8e166ee": "Continuation of the todo example using relations in LoopBack 4.",
"db8c853ec3ce3b65e1513d198a9bd2e9": "Enable mocha",
"dd9b2e815dc04519c82ded4787c1a53a": "The following dependencies are incompatible with @loopback/cli@{0}:",
"ddb67f6cad9d36d2acf42898c4fe58f5": "Component name",
"e05247fa3388c64e6cc5ab608dd34346": "Validate the OpenAPI spec",
"e06dcb9b794d62f93022ac5a189f9072": "Skip upgrading project dependencies",
"e4765958ab33531b244d9d1d6fb2b705": "Target model primary key does not exist.",
"e4a87a58bb56e705349a97dbc23ecd6d": "Default relation name",
"e4ca073d5042621174cf6950ad25b40e": "Project description:",
"e9ad06649c24ed76b5185c3d705fa2a9": "Select the connector for {0}: ",
"eaa7f2ab653690e3bfb202db78a00ff0": "A simple Express application that uses LoopBack 4 REST API.",
"ec0d3215aa6ad3aeae52f51dd7962879": "Service type - proxy, class or provider",
"ec5b5f03d997ee0da0157737a7b10d7b": "Source model",
Expand Down
14 changes: 12 additions & 2 deletions packages/cli/lib/artifact-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,17 @@ module.exports = class ArtifactGenerator extends BaseGenerator {
* >> Model MyModel will be created in src/models/my-model.model.ts
**/
promptClassFileName(type, typePlural, name) {
utils.logClassCreation(type, typePlural, name, this.log.bind(this));
this.log(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

g.f(
'%s %s will be created in src/%s/%s.%s.ts',
utils.toClassName(type),
chalk.yellow(name),
typePlural,
chalk.yellow(utils.toFileName(name)),
type,
),
);
this.log();
}

scaffold() {
Expand Down Expand Up @@ -118,7 +128,7 @@ module.exports = class ArtifactGenerator extends BaseGenerator {
this.log(
utils.toClassName(this.artifactInfo.type),
chalk.yellow(classesOutput),
classes.length > 1 ? 'were created in' : 'was created in',
classes.length > 1 ? g.f('were created in') : g.f('was created in'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

截屏2020-04-21下午4 19 48

`${this.artifactInfo.relPath}/`,
);
this.log();
Expand Down
19 changes: 13 additions & 6 deletions packages/cli/lib/version-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const chalk = require('chalk');
const latestVersion = require('latest-version');

const cliPkg = require('../package.json');
const g = require('./globalize');
const templateDeps = cliPkg.config.templateDependencies;

/**
Expand Down Expand Up @@ -102,13 +103,19 @@ async function checkDependencies(generator) {
const originalCliVersion = generator.config.get('update') || '<unknown>';
generator.log(
chalk.red(
`The project was originally generated by @loopback/cli@${originalCliVersion}.`,
g.f(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

'The project was originally generated by @loopback/cli@%s.',
originalCliVersion,
),
),
);

generator.log(
chalk.red(
`The following dependencies are incompatible with @loopback/cli@${cliPkg.version}:`,
g.f(
'The following dependencies are incompatible with @loopback/cli@%s:',
cliPkg.version,
),
),
);
for (const d in incompatibleDeps) {
Expand Down Expand Up @@ -172,24 +179,24 @@ async function checkLoopBackProject(generator) {

const choices = [
{
name: 'Upgrade project dependencies',
name: g.f('Upgrade project dependencies'),
value: 'upgrade',
},
{
name: 'Skip upgrading project dependencies',
name: g.f('Skip upgrading project dependencies'),
value: 'continue',
},
];
if (generator.command !== 'update') {
choices.unshift({
name: 'Abort now',
name: g.f('Abort now'),
value: 'abort',
});
}
const prompts = [
{
name: 'decision',
message: `How do you want to proceed?`,
message: g.f('How do you want to proceed?'),
type: 'list',
choices,
default: 0,
Expand Down