Skip to content

Commit

Permalink
Merge pull request #2 from jhipster/main
Browse files Browse the repository at this point in the history
Mergen from upstream
  • Loading branch information
amatosg authored Oct 21, 2023
2 parents 1190c46 + 1da7aa1 commit 7b89e51
Show file tree
Hide file tree
Showing 784 changed files with 10,780 additions and 10,896 deletions.
2 changes: 1 addition & 1 deletion .blueprint/code-workspace/generator.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from 'path';
import _ from 'lodash';
import * as _ from 'lodash-es';
import BaseGenerator from '../../generators/base/index.mjs';
import { getPackageRoot } from '../../lib/index.mjs';
import command from './command.mjs';
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18.17.1
node-version: 18.18.2
- name: 'SETUP: load npm cache'
uses: actions/cache@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@b69b346013879cedbf50c69f572cd85439a41936
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
ascending: true
stale-issue-label: 'area: stale'
stale-issue-message: |
This issue is stale because it has been open for too long without any activity.
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Go to the [generator-jhipster project](https://github.com/jhipster/generator-jhi
Since v8 `generator-jhipster` is written in typescript.
To run it you need to compile to javascript or use a just-in-time compilation.

#### Runnning jit executable
#### Running jit executable

The executable is located at `bin/jhipster.cjs`.
You can alias it to `jhipster` command:
Expand Down Expand Up @@ -339,7 +339,7 @@ Daily builds samples are prefixed with `daily-`.
#### Samples folder
A common samples folder will be used if `--global` option is used like `jhipster generate-sample ng-default --global`.
At first execution a prompt will ask for the samples folder, the choosen value will be reused at next executions.
At first execution a prompt will ask for the samples folder, the chosen value will be reused at next executions.
At samples folder, a `jhipster-samples.code-workspace` is generated. It provides a single vscode workspace for `generator-jhipster` and samples generated at the samples folder. It's very used for quick looks.

### Testing samples
Expand Down Expand Up @@ -418,7 +418,7 @@ Sub templates should be named with the `ejs` extension because it's the default

<%- include('../common/field_validators', {field, reactive}); -%>

This statement means that [_PersistClass_.java.jhi.jakarta_validation.ejs](generators/server/templates/entity/src/main/java/package/domain/_PersistClass_.java.jhi.jakarta_validation.ejs) template includes [field_validators.ejs](generators/server/templates/entity/src/main/java/package/common/field_validators.ejs) sub template.
This statement means that [_persistClass_.java.jhi.jakarta_validation.ejs](generators/server/templates/entity/src/main/java/package/domain/_persistClass_.java.jhi.jakarta_validation.ejs) template includes [field_validators.ejs](generators/server/templates/entity/src/main/java/package/common/field_validators.ejs) sub template.

Sub templates can be unit tested.

Expand Down
2 changes: 1 addition & 1 deletion cli/cli.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ describe('cli', () => {
expect(stdout).toMatch('Usage: jhipster run jhipster:app [options]');
});
it('should print options', () => {
expect(stdout).toMatch('--application-type <value>');
expect(stdout).toMatch('--defaults');
});
it('should exit with code 0', () => {
expect(exitCode).toBe(0);
Expand Down
7 changes: 4 additions & 3 deletions cli/commands.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const defaultCommands = {
},
gae: {
desc: 'Deploy the current application to Google App Engine',
removed: removedV8,
},
'generate-blueprint': {
desc: 'Generate a blueprint',
Expand Down Expand Up @@ -143,18 +144,18 @@ const defaultCommands = {
desc: 'Run a module or custom generator',
argument: ['[generator]'],
},
'spring-boot': {
desc: 'Create a Spring Boot application (alpha)',
},
'spring-service': {
alias: 'service',
desc: 'Create a new Spring service bean',
removed: removedV8,
},
'spring-controller': {
desc: 'Create a new Spring controller',
removed: removedV8,
},
'openapi-client': {
desc: 'Generates java client code from an OpenAPI/Swagger definition',
removed: removedV8,
},
upgrade: {
desc: 'Upgrade the JHipster version, and upgrade the generated application',
Expand Down
2 changes: 1 addition & 1 deletion cli/environment-builder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { existsSync, readFileSync } from 'fs';
import path, { dirname, resolve } from 'path';
import { fileURLToPath, pathToFileURL } from 'url';
import chalk from 'chalk';
import _ from 'lodash';
import * as _ from 'lodash-es';
import Environment from 'yeoman-environment';
import { QueuedAdapter } from '@yeoman/adapter';

Expand Down
23 changes: 20 additions & 3 deletions cli/jhipster-command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import chalk from 'chalk';
import { Command, Option } from 'commander';
import lodash from 'lodash';
import { convertConfigToOption } from '../lib/internal/index.mjs';

const { kebabCase } = lodash;

Expand Down Expand Up @@ -177,6 +178,16 @@ export default class JHipsterCommand extends Command {
return this;
}

addJHipsterConfigs(configs = {}, blueprintOptionDescription) {
Object.entries(configs).forEach(([name, config]) => {
const option = convertConfigToOption(name, config);
if (option) {
this._addGeneratorOption(kebabCase(option.name), option, blueprintOptionDescription);
}
});
return this;
}

_addGeneratorOption(optionName, optionDefinition, additionalDescription = '') {
if (optionName === 'help') {
return undefined;
Expand All @@ -197,9 +208,15 @@ export default class JHipsterCommand extends Command {
} else if (optionDefinition.type && optionDefinition.type !== Boolean) {
cmdString = optionDefinition.required !== false ? `${cmdString} <value>` : `${cmdString} [value]`;
}
const option = new Option(cmdString, optionDefinition.description + additionalDescription)
.default(optionDefinition.default)
.hideHelp(optionDefinition.hide ?? false);
// Passing default to `commander` (`.default(optionDefinition.default)`), will set at options passed to initial generator, so it's used in entire generation process.
// We want default value to be set on jhipster options parsing so ignore default at commander.
let defaultDescription = '';
if (optionDefinition.default !== undefined && (!Array.isArray(optionDefinition.default) || optionDefinition.default.length !== 0)) {
defaultDescription = ` (default: ${optionDefinition.default})`;
}
const option = new Option(cmdString, optionDefinition.description + defaultDescription + additionalDescription).hideHelp(
optionDefinition.hide ?? false,
);
if (optionDefinition.env) {
option.env(optionDefinition.env);
}
Expand Down
4 changes: 3 additions & 1 deletion cli/program.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const addCommandGeneratorOptions = async (command, generatorMeta, { root, bluepr
const generatorModule = await generatorMeta.importModule();
if (generatorModule.command) {
command.addJHipsterOptions(generatorModule.command.options, blueprintOptionDescription);
command.addJHipsterConfigs(generatorModule.command.configs, blueprintOptionDescription);
}
try {
if (root || !generatorModule.command || generatorModule.command.loadGeneratorOptions) {
Expand Down Expand Up @@ -152,6 +153,7 @@ export const createProgram = ({ executableName = CLI_NAME, executableVersion } =
.option('--skip-regenerate', "Don't regenerate identical files", false)
.option('--skip-yo-resolve', 'Ignore .yo-resolve files', false)
.addJHipsterOptions(command.options)
.addJHipsterConfigs(command.configs)
);
};

Expand Down Expand Up @@ -243,7 +245,7 @@ export const buildCommands = async ({
const boostrapGen = ['bootstrap', generator];
const allDependencies = await buildAllDependencies(boostrapGen, {
env,
blueprintNamespaces: blueprint ? [] : envBuilder.getBlueprintsNamespaces(),
blueprintNamespaces: envBuilder.getBlueprintsNamespaces(),
});
for (const [metaName, { meta: generatorMeta, blueprintNamespace }] of Object.entries(allDependencies)) {
if (blueprintNamespace) {
Expand Down
Loading

0 comments on commit 7b89e51

Please sign in to comment.