Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add descriptions to Yeoman questions #373

Merged
merged 1 commit into from
Jan 20, 2022
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
59 changes: 49 additions & 10 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions packages/generator-langium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"publish:latest": "npm publish --tag latest"
},
"dependencies": {
"colors": "^1.4.0",
"chalk": "^4.1.2",
"lodash": "^4.17.21",
"yeoman-generator": "^5.3.0"
"yeoman-generator": "^5.5.2"
},
"devDependencies": {
"@types/lodash": "^4.14.170",
Expand All @@ -53,7 +53,7 @@
},
"bugs": "https://github.com/langium/langium/issues",
"author": {
"name": "TypeFox",
"url": "https://www.typefox.io"
"name": "TypeFox",
"url": "https://www.typefox.io"
}
}
25 changes: 21 additions & 4 deletions packages/generator-langium/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import Generator from 'yeoman-generator';
import _ from 'lodash';
import chalk from 'chalk';
spoenemann marked this conversation as resolved.
Show resolved Hide resolved
import path from 'path';
import 'colors';

const TEMPLATE_DIR = '../langium-template';
const USER_DIR = '.';
Expand Down Expand Up @@ -38,6 +38,10 @@ function printLogo(log: (message: string) => void): void {
log('');
}

function description(...d: string[]): string {
return chalk.reset(chalk.dim(d.join(' ') + '\n')) + chalk.green('?');
}

class LangiumGenerator extends Generator {
private answers: Answers;

Expand All @@ -51,12 +55,22 @@ class LangiumGenerator extends Generator {
{
type: 'input',
name: 'extensionName',
prefix: description(
'Welcome to Langium!',
'This tool generates a VS Code extension with a "Hello World" language to get started quickly.',
'The extension name is an identifier used in the extension marketplace or package registry.'
),
message: 'Your extension name:',
default: 'hello-world',
},
{
type: 'input',
name: 'rawLanguageName',
prefix: description(
'The language name is used to identify your language in VS Code.',
'Please provide a name to be shown in the UI.',
'CamelCase and kebab-case variants will be created and used in different parts of the extension and language server.'
),
message: 'Your language name:',
default: 'Hello World',
validate: (input: string): boolean | string =>
Expand All @@ -67,13 +81,16 @@ class LangiumGenerator extends Generator {
{
type: 'input',
name: 'fileExtensions',
message:
'File extensions of your language, separated by commas:',
prefix: description(
'Source files of your language are identified by their file name extension.',
'You can specify multiple file extensions separated by commas.'
),
message: 'File extensions:',
default: '.hello',
validate: (input: string): boolean | string =>
/^\.?\w+(\s*,\s*\.?\w+)*$/.test(input)
? true
: 'The file extension can start with . and must contain only letters and digits. Extensions must be separated by commas.',
: 'A file extension can start with . and must contain only letters and digits. Extensions must be separated by commas.',
},
]);
}
Expand Down