Skip to content

Commit

Permalink
Merge branch 'jhipster-upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
yelhouti committed Oct 4, 2022
2 parents 51d3e04 + a46e973 commit 1e79f24
Show file tree
Hide file tree
Showing 749 changed files with 24,216 additions and 50,937 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[{*.{java,java.ejs,xml.ejs,gradle.ejs,sh,sh.ejs,n1ql.ejs,cql.ejs,scala.ejs},USAGE}]
indent_size = 4
877 changes: 457 additions & 420 deletions generators/client/files-angular.js

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions generators/client/generator.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import chalk from 'chalk';
import ClientGenerator from 'generator-jhipster/generators/client';
import { writeFiles as writeAngularFiles } from './files-angular.js';
import _ from 'lodash';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export default class extends ClientGenerator {
constructor(args, opts, features) {
super(args, opts, features);

if (this.options.help) return;

if (!this.options.jhipsterContext) {
throw new Error(`This is a JHipster blueprint and should be used only like ${chalk.yellow('jhipster --blueprints test-blueprint')}`);
}
}

get [ClientGenerator.INITIALIZING]() {
return {
...super.initializing,
async initializingTemplateTask() {},
};
}

get [ClientGenerator.PROMPTING]() {
return {
...super.prompting,
async promptingTemplateTask() {},
};
}

get [ClientGenerator.CONFIGURING]() {
return {
...super.configuring,
async configuringTemplateTask() {},
};
}

get [ClientGenerator.COMPOSING]() {
return {
...super.composing,
async composingTemplateTask() {},
};
}

get [ClientGenerator.LOADING]() {
return {
...super.loading,
// copied from jhipster and replaced "this.fetchFromInstalledJHipster('client', " by path.join('__dirname', with __dirname defined as above since in module
loadPackageJson() {
// Load common client package.json into packageJson
_.merge(
this.dependabotPackageJson,
this.fs.readJSON(path.join(__dirname, 'templates', 'common', 'package.json'))
);
// Load client package.json into packageJson
const clientFramewok = this.application.clientFramework;
_.merge(
this.dependabotPackageJson,
this.fs.readJSON(path.join(__dirname, 'templates', clientFramewok, 'package.json'))
);
},
};
// const loadingFromJhipster = { ...super.loading };
// return Object.fromEntries(Object.entries(loadingFromJhipster).map(([k, v]) => k === 'loadPackageJson' ? v.bind(this) : v));
// return loadingFromJhipster;
}

get [ClientGenerator.PREPARING]() {
return {
...super.preparing,
async preparingTemplateTask() {},
};
}

get [ClientGenerator.DEFAULT]() {
return {
...super.default,
async defaultTemplateTask() {},
};
}

get [ClientGenerator.WRITING]() {
return {
...super.writing,
writeAngularFiles
};
}

get [ClientGenerator.POST_WRITING]() {
return {
...super.postWriting,
async postWritingTemplateTask() {},
};
}

get [ClientGenerator.INSTALL]() {
return {
...super.install,
async installTemplateTask() {},
};
}

get [ClientGenerator.END]() {
return {
...super.end,
async endTemplateTask() {},
};
}
}
28 changes: 28 additions & 0 deletions generators/client/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { expect } from 'expect';

import { helpers, lookups } from '#test-utils';

const SUB_GENERATOR = 'client';
const BLUEPRINT_NAMESPACE = `jhipster:${SUB_GENERATOR}`;

describe('SubGenerator client of test-blueprint JHipster blueprint', () => {
describe('run', () => {
let result;
before(async function () {
result = await helpers
.create(BLUEPRINT_NAMESPACE)
.withOptions({
reproducible: true,
defaults: true,
baseName: 'jhipster',
blueprint: 'test-blueprint',
})
.withLookups(lookups)
.run();
});

it('should succeed', () => {
expect(result.getStateSnapshot()).toMatchSnapshot();
});
});
});
141 changes: 0 additions & 141 deletions generators/client/index.js

This file was deleted.

1 change: 1 addition & 0 deletions generators/client/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './generator.mjs';
6 changes: 3 additions & 3 deletions generators/client/needle-api/needle-client-angular.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2021 the original author or authors from the JHipster project.
* Copyright 2013-2022 the original author or authors from the JHipster project.
*
* This file is part of the JHipster project, see https://www.jhipster.tech/
* for more information.
Expand All @@ -18,8 +18,8 @@
*/
const chalk = require('chalk');
const _ = require('lodash');
const constants = require('generator-jhipster/generators/generator-constants');
const jhipsterUtils = require('generator-jhipster/generators/utils');
const constants = require('generator-jhipster/generators/generator-constants.js');
const jhipsterUtils = require('generator-jhipster/generators/utils.js');
const needleClientBase = require('./needle-client');

module.exports = class extends needleClientBase {
Expand Down
18 changes: 9 additions & 9 deletions generators/client/needle-api/needle-client-i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2021 the original author or authors from the JHipster project.
* Copyright 2013-2022 the original author or authors from the JHipster project.
*
* This file is part of the JHipster project, see https://www.jhipster.tech/
* for more information.
Expand All @@ -20,24 +20,24 @@ const chalk = require('chalk');
const needleClient = require('./needle-client');

module.exports = class extends needleClient {
addElementTranslationKey(key, value, language) {
addElementTranslationKey(key, value, language, webappSrcDir) {
const errorMessage = ' not added as a new entity in the menu.';
this._addTranslationKey(key, value, language, errorMessage, 'jhipster-needle-menu-add-element');
this._addTranslationKey(key, value, language, errorMessage, 'jhipster-needle-menu-add-element', webappSrcDir);
}

addAdminElementTranslationKey(key, value, language) {
addAdminElementTranslationKey(key, value, language, webappSrcDir) {
const errorMessage = ' not added as a new entry in the admin menu.';
this._addTranslationKey(key, value, language, errorMessage, 'jhipster-needle-menu-add-admin-element');
this._addTranslationKey(key, value, language, errorMessage, 'jhipster-needle-menu-add-admin-element', webappSrcDir);
}

addEntityTranslationKey(key, value, language) {
addEntityTranslationKey(key, value, language, webappSrcDir) {
const errorMessage = ' not added as a new entity in the menu.';
this._addTranslationKey(key, value, language, errorMessage, 'jhipster-needle-menu-add-entry');
this._addTranslationKey(key, value, language, errorMessage, 'jhipster-needle-menu-add-entry', webappSrcDir);
}

_addTranslationKey(key, value, language, errorMessage, needle) {
_addTranslationKey(key, value, language, errorMessage, needle, webappSrcDir = this.CLIENT_MAIN_SRC_DIR) {
const fullErrorMessage = `${chalk.yellow(' Reference to ') + language} ${chalk.yellow(errorMessage)}`;
const fullPath = `${this.CLIENT_MAIN_SRC_DIR}i18n/${language}/global.json`;
const fullPath = `${webappSrcDir}i18n/${language}/global.json`;
const rewriteFileModel = this.generateFileModel(fullPath, needle, `"${key}": "${value}",`);

this.addBlockContentToFile(rewriteFileModel, fullErrorMessage);
Expand Down
Loading

0 comments on commit 1e79f24

Please sign in to comment.