Skip to content

Commit

Permalink
update generator-jhipster to 8.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jhipster-bot committed Sep 26, 2024
1 parent 22de23b commit c64523e
Show file tree
Hide file tree
Showing 17 changed files with 3,448 additions and 3,727 deletions.
24 changes: 24 additions & 0 deletions .blueprint/github-build-matrix/build-matrix.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { RECOMMENDED_JAVA_VERSION, RECOMMENDED_NODE_VERSION } from 'generator-jhipster';
import { fromMatrix } from 'generator-jhipster/testing';

const defaultMatrix = {
os: ['ubuntu-latest'],
'node-version': [RECOMMENDED_NODE_VERSION],
'java-version': [RECOMMENDED_JAVA_VERSION],
'default-environment': ['prod'],
};

export const buildMatrix = ({ samples, samplesFolder }) => {
return {
include: Object.values(
fromMatrix({
...defaultMatrix,
'sample-name': samples,
}),
).map(sample => ({
...sample,
'job-name': sample['sample-name'],
'extra-args': `--samples-folder ${samplesFolder}`,
})),
};
};
18 changes: 18 additions & 0 deletions .blueprint/github-build-matrix/command.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @type {import('generator-jhipster').JHipsterCommandDefinition}
*/
const command = {
configs: {
samplesFolder: {
description: 'Samples folder',
cli: {
type: String,
},
default: 'samples',
scope: 'generator',
},
},
options: {},
};

export default command;
29 changes: 29 additions & 0 deletions .blueprint/github-build-matrix/generator.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { appendFileSync, existsSync } from 'node:fs';
import os from 'node:os';
import BaseGenerator from 'generator-jhipster/generators/base';
import { getSamples } from '../generate-sample/get-samples.mjs';
import { buildMatrix } from './build-matrix.mjs';

export default class extends BaseGenerator {
samplesFolder;

constructor(args, opts, features) {
super(args, opts, { ...features, queueCommandTasks: true, jhipsterBootstrap: false });
}

get [BaseGenerator.WRITING]() {
return this.asWritingTaskGroup({
async buildMatrix() {
const samplesFolder = this.samplesFolder ?? 'samples';
const samples = await getSamples(this.templatePath(`../../generate-sample/templates/${samplesFolder}`));
const matrix = buildMatrix({ samples, samplesFolder });
const matrixoutput = `matrix<<EOF${os.EOL}${JSON.stringify(matrix)}${os.EOL}EOF${os.EOL}`;
const filePath = process.env.GITHUB_OUTPUT;
console.log(matrixoutput);
if (filePath && existsSync(filePath)) {
appendFileSync(filePath, matrixoutput, { encoding: 'utf8' });
}
},
});
}
}
2 changes: 2 additions & 0 deletions .blueprint/github-build-matrix/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './generator.mjs';
export { default as command } from './command.mjs';
5 changes: 2 additions & 3 deletions .github/workflows/generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'npm'
- run: git config --global user.name "JHipster Bot"; git config --global user.email "[email protected]"; git config --global init.defaultBranch main
- run: npm ci
- run: npm run test
7 changes: 3 additions & 4 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Prettier configuration

printWidth: 140
singleQuote: true
tabWidth: 2
useTabs: false

# js and ts rules:
arrowParens: avoid
bracketSameLine: false
plugins:
- prettier-plugin-packagejson
4 changes: 3 additions & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
}
},
"githubWorkflows": true,
"jhipsterVersion": "7.7.0",
"jhipsterVersion": "8.7.1",
"js": true,
"localBlueprint": false,
"packageJsonType": "module",
"prettierDefaultIndent": 2,
"projectName": "JHipster Migrate Blueprint",
"sampleWritten": true,
"skipCommitHook": true,
"skipDevBlueprint": true,
"subGenerators": []
}
}
2 changes: 2 additions & 0 deletions cli/cli-customizations.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// This file will not be overwritten by generate-blueprint
module.exports = {};
14 changes: 10 additions & 4 deletions cli/cli.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env node

const { dirname, join } = require('path');
const { dirname, basename, join } = require('path');
const { version, bin } = require('../package.json');

// Get package name to use as namespace.
// Allows blueprints to be aliased.
const packagePath = dirname(__dirname);
const packageFolderName = basename(packagePath);
const devBlueprintPath = join(packagePath, '.blueprint');
const blueprint = packageFolderName.startsWith('jhipster-') ? `generator-${packageFolderName}` : packageFolderName;

(async () => {
const { runJHipster, done, logger } = await import('generator-jhipster/cli');
Expand All @@ -15,14 +17,18 @@ const devBlueprintPath = join(packagePath, '.blueprint');
runJHipster({
executableName,
executableVersion: version,
defaultCommand: 'migrate',
defaultCommand: 'app',
devBlueprintPath,
commands: require('./commands.cjs'),
blueprints: {
[blueprint]: version,
},
printBlueprintLogo: () => {
console.log('===================== JHipster migrate =====================');
console.log('===================== JHipster Migrate =====================');
console.log('');
},
lookups: [{ packagePaths: [packagePath] }],
commands: require('./commands.cjs'),
...require('./cli-customizations.cjs'),
}).catch(done);

process.on('unhandledRejection', up => {
Expand Down
14 changes: 10 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import globals from 'globals';
import prettierRecommended from 'eslint-plugin-prettier/recommended';
import jhipsterRecommended from 'generator-jhipster/eslint/recommended';
import prettier from 'eslint-plugin-prettier/recommended';
import jhipster from 'generator-jhipster/eslint/recommended';

// Workaround for jhipster export issue.
delete jhipster.recommended.recommended;
// jhipster-needle-eslint-add-import - JHipster will add additional import here

export default [
{
Expand All @@ -10,6 +14,8 @@ export default [
},
},
},
jhipsterRecommended,
prettierRecommended,
{ ignores: ['coverage/**'] },
jhipster.recommended,
// jhipster-needle-eslint-add-config - JHipster will add additional config here
prettier,
];
11 changes: 4 additions & 7 deletions generators/migrate/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import chalk from 'chalk';

const choices = '(none, current, bundled, any npm version)';

/**
* @type {import('generator-jhipster').JHipsterCommandDefinition}
*/
const command = {
import { asCommand } from 'generator-jhipster';

export default asCommand({
options: {},
configs: {
sourceCli: {
Expand Down Expand Up @@ -86,6 +85,4 @@ const command = {
scope: 'generator',
},
},
};

export default command;
});
16 changes: 8 additions & 8 deletions generators/migrate/generator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setTimeout } from 'timers/promises';
import { readFile, rm, readdir, appendFile } from 'fs/promises';
import { appendFile, readFile, readdir, rm } from 'fs/promises';
import { join } from 'path';
import chalk from 'chalk';
import { transform } from 'p-transform';
Expand All @@ -15,28 +15,28 @@ import { ResetMode } from 'simple-git';
import BaseGenerator from 'generator-jhipster/generators/base-application';
import getNode from 'get-node';
import {
createPrettierTransform,
createESLintTransform,
createPrettierTransform,
createRemoveUnusedImportsTransform,
} from 'generator-jhipster/generators/bootstrap/support';
import packageVersions from 'pkg-versions';

import { GENERATOR_JHIPSTER } from 'generator-jhipster';
import { GENERATOR_BOOTSTRAP } from 'generator-jhipster/generators';
import {
ACTUAL_APPLICATION,
BASE_APPLICATION,
DEFAULT_CLI_OPTIONS,
DEFAULT_CLI_OPTIONS_V7,
GIT_DRIVER_PACKAGEJSON,
GIT_DRIVER_PACKAGEJSON_REF,
GIT_VERSION_NOT_ALLOW_MERGE_UNRELATED_HISTORIES,
MIGRATE_SOURCE_BRANCH,
JSON_DRIVER_GIT_CONFIG,
MIGRATE_CONFIG_FILE,
MIGRATE_SOURCE_BRANCH,
MIGRATE_TARGET_BRANCH,
MIGRATE_TMP_FOLDER,
SERVER_MAIN_RES_DIR,
JSON_DRIVER_GIT_CONFIG,
GIT_DRIVER_PACKAGEJSON,
GIT_DRIVER_PACKAGEJSON_REF,
ACTUAL_APPLICATION,
BASE_APPLICATION,
V7_NODE,
} from './constants.js';
import command from './command.js';
Expand Down
2 changes: 1 addition & 1 deletion generators/migrate/generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('SubGenerator migrate of migrate JHipster blueprint', () => {
apply updated prettier to actual application
apply updated prettier to source application
migration application generated with JHipster bundled (source)
Initial version of upgradeTest generated by generator-jhipster@undefined"
initial"
`);
},
);
Expand Down
Loading

0 comments on commit c64523e

Please sign in to comment.