From 2f82b1f62f1efb8756e93e410f64de50d7d7f66d Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 7 Aug 2021 11:47:52 -0300 Subject: [PATCH 1/2] Add prettier and eslint support for cjs and mjs. --- .eslintrc.json | 20 ++++++++++++++++++-- .mocharc.js | 2 +- generators/generator-base.js | 2 +- package.json | 10 +++++----- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index d44c6f5dd3e..c618631c1ac 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,14 +1,30 @@ { "env": { "node": true, - "es6": true, - "mocha": true + "es2020": true }, "extends": ["airbnb-base", "plugin:prettier/recommended"], "plugins": ["mocha", "prettier", "chai-friendly"], "settings": { "import/core-modules": ["generator-jhipster", "generator-jhipster/support"] }, + "overrides": [ + { + "files": ["**/*.mjs"], + "parserOptions": { + "ecmaVersion": 11 + }, + "rules": { + "import/extensions": [0, { "pattern": { "{c,m,}js": "always" } }] + } + }, + { + "files": ["**/*.spec.{c,m,}js", "test/**/*.{c,m,}js"], + "env": { + "mocha": true + } + } + ], "rules": { "prettier/prettier": "error", "linebreak-style": 0, diff --git a/.mocharc.js b/.mocharc.js index fb3e5ca0d07..cdd229926a9 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -4,7 +4,7 @@ module.exports = { slow: 0, timeout: 30000, ui: 'bdd', - extension: ['js', 'cjs'], + extension: ['js', 'spec.cjs', 'spec.mjs'], require: 'mocha-expect-snapshot', parallel: true, }; diff --git a/generators/generator-base.js b/generators/generator-base.js index 9c9fdf6bbad..fca023677ae 100644 --- a/generators/generator-base.js +++ b/generators/generator-base.js @@ -278,7 +278,7 @@ module.exports = class JHipsterBaseGenerator extends PrivateBase { getPrettierExtensions() { let prettierExtensions = 'md,json,yml,html'; if (!this.skipClient && !this.jhipsterConfig.skipClient) { - prettierExtensions = `${prettierExtensions},js,ts,tsx,css,scss`; + prettierExtensions = `${prettierExtensions},cjs,mjs,js,ts,tsx,css,scss`; if (this.jhipsterConfig.clientFramework === VUE) { prettierExtensions = `${prettierExtensions},vue`; } diff --git a/package.json b/package.json index 681471601cf..b977d9d32f8 100644 --- a/package.json +++ b/package.json @@ -55,17 +55,17 @@ "completion": "tabtab install --name jhipster --auto", "ejs-lint": "mocha test/ejslint.js", "ejslint": "ejslint", - "eslint": "eslint . --ext .js,.cjs", + "eslint": "eslint . --ext .js,.cjs,.mjs", "jdl:test": "mocha test/jdl --no-insight --forbid-only -p", "jdl:test-watch": "npm run jdl:test -- --watch", "jsdoc": "jsdoc --configure jsdoc-conf.json", "lint": "npm run eslint && npm run ejs-lint", "lint-fix": "npm run prettier:format && npm run eslint -- --fix", - "prettier:check": "prettier --check \"{,**/}*.{js,cjs,json,md,yml,java}\"", - "prettier:format": "prettier --write \"{,**/}*.{js,cjs,json,md,yml,java}\"", + "prettier:check": "prettier --check \"{,**/}*.{js,cjs,mjs,json,md,yml,java}\"", + "prettier:format": "prettier --write \"{,**/}*.{js,cjs,mjs,json,md,yml,java}\"", "pretest": "npm run lint", - "test": "mocha test \"generators/**/*.spec.cjs\" --no-insight --forbid-only --parallel", - "update-snapshots": "npm run update-snapshot -- test \"generators/**/*.spec.cjs\"", + "test": "mocha test generators --no-insight --forbid-only --parallel", + "update-snapshots": "npm run update-snapshot -- test generators", "update-snapshot": "mocha --no-insight --no-parallel --updateSnapshot --" }, "dependencies": { From c66abdeee49fbe68ddbdbe2ee7bbc40b5eee3c22 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Wed, 11 Aug 2021 00:22:33 -0300 Subject: [PATCH 2/2] Add esm entry points. --- generators/app/esm.mjs | 21 +++++++++ generators/app/generator.spec.mjs | 47 +++++++++++++++++++ generators/aws/esm.mjs | 21 +++++++++ generators/aws/generator.spec.mjs | 47 +++++++++++++++++++ generators/azure-app-service/esm.mjs | 21 +++++++++ .../azure-app-service/generator.spec.mjs | 47 +++++++++++++++++++ generators/azure-spring-cloud/esm.mjs | 21 +++++++++ .../azure-spring-cloud/generator.spec.mjs | 47 +++++++++++++++++++ generators/base/esm.mjs | 21 +++++++++ generators/base/generator.spec.mjs | 44 +++++++++++++++++ generators/bootstrap/esm.mjs | 21 +++++++++ generators/bootstrap/generator.spec.mjs | 44 +++++++++++++++++ generators/bootstrap/index.js | 2 + generators/ci-cd/esm.mjs | 21 +++++++++ generators/ci-cd/generator.spec.mjs | 47 +++++++++++++++++++ generators/ci-cd/index.js | 6 +-- generators/client/esm.mjs | 21 +++++++++ generators/client/generator.spec.mjs | 47 +++++++++++++++++++ generators/cloudfoundry/esm.mjs | 21 +++++++++ generators/cloudfoundry/generator.spec.mjs | 47 +++++++++++++++++++ generators/common/esm.mjs | 21 +++++++++ generators/common/generator.spec.mjs | 47 +++++++++++++++++++ generators/cypress/esm.mjs | 21 +++++++++ generators/cypress/generator.spec.mjs | 47 +++++++++++++++++++ .../database-changelog-liquibase/esm.mjs | 21 +++++++++ .../generator.spec.mjs | 47 +++++++++++++++++++ .../database-changelog-liquibase/index.js | 2 + generators/database-changelog/esm.mjs | 21 +++++++++ .../database-changelog/generator.spec.mjs | 47 +++++++++++++++++++ generators/docker-compose/esm.mjs | 21 +++++++++ generators/docker-compose/generator.spec.mjs | 44 +++++++++++++++++ generators/entities-client/esm.mjs | 21 +++++++++ generators/entities-client/generator.spec.mjs | 47 +++++++++++++++++++ generators/entities/esm.mjs | 21 +++++++++ generators/entities/generator.spec.mjs | 47 +++++++++++++++++++ generators/entity-client/esm.mjs | 21 +++++++++ generators/entity-client/generator.spec.mjs | 47 +++++++++++++++++++ generators/entity-i18n/esm.mjs | 21 +++++++++ generators/entity-i18n/generator.spec.mjs | 47 +++++++++++++++++++ generators/entity-i18n/index.js | 4 +- generators/entity-server/esm.mjs | 21 +++++++++ generators/entity-server/generator.spec.mjs | 47 +++++++++++++++++++ generators/entity/esm.mjs | 21 +++++++++ generators/entity/generator.spec.mjs | 47 +++++++++++++++++++ generators/entity/index.js | 4 +- generators/export-jdl/esm.mjs | 21 +++++++++ generators/export-jdl/generator.spec.mjs | 44 +++++++++++++++++ generators/gae/esm.mjs | 21 +++++++++ generators/gae/generator.spec.mjs | 47 +++++++++++++++++++ generators/gae/index.js | 4 -- generators/generator-list.js | 23 ++++++--- generators/heroku/esm.mjs | 21 +++++++++ generators/heroku/generator.spec.mjs | 47 +++++++++++++++++++ generators/info/esm.mjs | 21 +++++++++ generators/info/generator.spec.mjs | 44 +++++++++++++++++ generators/info/index.js | 2 + generators/kubernetes-helm/esm.mjs | 21 +++++++++ generators/kubernetes-helm/generator.spec.mjs | 44 +++++++++++++++++ generators/kubernetes-knative/esm.mjs | 21 +++++++++ .../kubernetes-knative/generator.spec.mjs | 44 +++++++++++++++++ generators/kubernetes/esm.mjs | 21 +++++++++ generators/kubernetes/generator.spec.mjs | 44 +++++++++++++++++ generators/languages/esm.mjs | 21 +++++++++ generators/languages/generator.spec.mjs | 47 +++++++++++++++++++ generators/openapi-client/esm.mjs | 21 +++++++++ generators/openapi-client/generator.spec.mjs | 47 +++++++++++++++++++ generators/openapi-client/index.js | 4 +- generators/openshift/esm.mjs | 21 +++++++++ generators/openshift/generator.spec.mjs | 44 +++++++++++++++++ generators/page/esm.mjs | 21 +++++++++ generators/page/generator.spec.mjs | 47 +++++++++++++++++++ generators/server/esm.mjs | 21 +++++++++ generators/server/generator.spec.mjs | 47 +++++++++++++++++++ generators/spring-controller/esm.mjs | 21 +++++++++ .../spring-controller/generator.spec.mjs | 47 +++++++++++++++++++ generators/spring-service/esm.mjs | 21 +++++++++ generators/spring-service/generator.spec.mjs | 47 +++++++++++++++++++ generators/upgrade-config/esm.mjs | 21 +++++++++ generators/upgrade-config/generator.spec.mjs | 44 +++++++++++++++++ generators/upgrade/esm.mjs | 21 +++++++++ generators/upgrade/generator.spec.mjs | 44 +++++++++++++++++ generators/workspaces/esm.mjs | 21 +++++++++ generators/workspaces/generator.spec.mjs | 47 +++++++++++++++++++ package.json | 45 ++++++++++++++++++ test/support/index.cjs | 47 ++++++++++++------- 85 files changed, 2590 insertions(+), 36 deletions(-) create mode 100644 generators/app/esm.mjs create mode 100644 generators/app/generator.spec.mjs create mode 100644 generators/aws/esm.mjs create mode 100644 generators/aws/generator.spec.mjs create mode 100644 generators/azure-app-service/esm.mjs create mode 100644 generators/azure-app-service/generator.spec.mjs create mode 100644 generators/azure-spring-cloud/esm.mjs create mode 100644 generators/azure-spring-cloud/generator.spec.mjs create mode 100644 generators/base/esm.mjs create mode 100644 generators/base/generator.spec.mjs create mode 100644 generators/bootstrap/esm.mjs create mode 100644 generators/bootstrap/generator.spec.mjs create mode 100644 generators/ci-cd/esm.mjs create mode 100644 generators/ci-cd/generator.spec.mjs create mode 100644 generators/client/esm.mjs create mode 100644 generators/client/generator.spec.mjs create mode 100644 generators/cloudfoundry/esm.mjs create mode 100644 generators/cloudfoundry/generator.spec.mjs create mode 100644 generators/common/esm.mjs create mode 100644 generators/common/generator.spec.mjs create mode 100644 generators/cypress/esm.mjs create mode 100644 generators/cypress/generator.spec.mjs create mode 100644 generators/database-changelog-liquibase/esm.mjs create mode 100644 generators/database-changelog-liquibase/generator.spec.mjs create mode 100644 generators/database-changelog/esm.mjs create mode 100644 generators/database-changelog/generator.spec.mjs create mode 100644 generators/docker-compose/esm.mjs create mode 100644 generators/docker-compose/generator.spec.mjs create mode 100644 generators/entities-client/esm.mjs create mode 100644 generators/entities-client/generator.spec.mjs create mode 100644 generators/entities/esm.mjs create mode 100644 generators/entities/generator.spec.mjs create mode 100644 generators/entity-client/esm.mjs create mode 100644 generators/entity-client/generator.spec.mjs create mode 100644 generators/entity-i18n/esm.mjs create mode 100644 generators/entity-i18n/generator.spec.mjs create mode 100644 generators/entity-server/esm.mjs create mode 100644 generators/entity-server/generator.spec.mjs create mode 100644 generators/entity/esm.mjs create mode 100644 generators/entity/generator.spec.mjs create mode 100644 generators/export-jdl/esm.mjs create mode 100644 generators/export-jdl/generator.spec.mjs create mode 100644 generators/gae/esm.mjs create mode 100644 generators/gae/generator.spec.mjs create mode 100644 generators/heroku/esm.mjs create mode 100644 generators/heroku/generator.spec.mjs create mode 100644 generators/info/esm.mjs create mode 100644 generators/info/generator.spec.mjs create mode 100644 generators/kubernetes-helm/esm.mjs create mode 100644 generators/kubernetes-helm/generator.spec.mjs create mode 100644 generators/kubernetes-knative/esm.mjs create mode 100644 generators/kubernetes-knative/generator.spec.mjs create mode 100644 generators/kubernetes/esm.mjs create mode 100644 generators/kubernetes/generator.spec.mjs create mode 100644 generators/languages/esm.mjs create mode 100644 generators/languages/generator.spec.mjs create mode 100644 generators/openapi-client/esm.mjs create mode 100644 generators/openapi-client/generator.spec.mjs create mode 100644 generators/openshift/esm.mjs create mode 100644 generators/openshift/generator.spec.mjs create mode 100644 generators/page/esm.mjs create mode 100644 generators/page/generator.spec.mjs create mode 100644 generators/server/esm.mjs create mode 100644 generators/server/generator.spec.mjs create mode 100644 generators/spring-controller/esm.mjs create mode 100644 generators/spring-controller/generator.spec.mjs create mode 100644 generators/spring-service/esm.mjs create mode 100644 generators/spring-service/generator.spec.mjs create mode 100644 generators/upgrade-config/esm.mjs create mode 100644 generators/upgrade-config/generator.spec.mjs create mode 100644 generators/upgrade/esm.mjs create mode 100644 generators/upgrade/generator.spec.mjs create mode 100644 generators/workspaces/esm.mjs create mode 100644 generators/workspaces/generator.spec.mjs diff --git a/generators/app/esm.mjs b/generators/app/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/app/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/app/generator.spec.mjs b/generators/app/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/app/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/aws/esm.mjs b/generators/aws/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/aws/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/aws/generator.spec.mjs b/generators/aws/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/aws/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/azure-app-service/esm.mjs b/generators/azure-app-service/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/azure-app-service/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/azure-app-service/generator.spec.mjs b/generators/azure-app-service/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/azure-app-service/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/azure-spring-cloud/esm.mjs b/generators/azure-spring-cloud/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/azure-spring-cloud/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/azure-spring-cloud/generator.spec.mjs b/generators/azure-spring-cloud/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/azure-spring-cloud/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/base/esm.mjs b/generators/base/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/base/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/base/generator.spec.mjs b/generators/base/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/base/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/bootstrap/esm.mjs b/generators/bootstrap/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/bootstrap/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/bootstrap/generator.spec.mjs b/generators/bootstrap/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/bootstrap/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/bootstrap/index.js b/generators/bootstrap/index.js index 948773c5282..ad3ec81e2ab 100644 --- a/generators/bootstrap/index.js +++ b/generators/bootstrap/index.js @@ -69,6 +69,8 @@ module.exports = class extends BaseGenerator { this.jhipsterConfig.withGeneratedFlag = this.options.withGeneratedFlag; } + if (this.options.help) return; + // Load common runtime options. this.parseCommonRuntimeOptions(); } diff --git a/generators/ci-cd/esm.mjs b/generators/ci-cd/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/ci-cd/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/ci-cd/generator.spec.mjs b/generators/ci-cd/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/ci-cd/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/ci-cd/index.js b/generators/ci-cd/index.js index efd9ec66786..dc6e0dc333d 100644 --- a/generators/ci-cd/index.js +++ b/generators/ci-cd/index.js @@ -25,7 +25,7 @@ const BaseBlueprintGenerator = require('../generator-base-blueprint'); const statistics = require('../statistics'); const constants = require('../generator-constants'); const { MAVEN, GRADLE } = require('../../jdl/jhipster/build-tool-types'); -const { GENERATOR_CICD } = require('../generator-list'); +const { GENERATOR_CI_CD } = require('../generator-list'); const REACT = constants.SUPPORTED_CLIENT_FRAMEWORKS.REACT; @@ -77,7 +77,7 @@ module.exports = class extends BaseBlueprintGenerator { description: 'Automatically configure CircleCI', }); - useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_CICD); + useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_CI_CD); } // Public API method used by the getter and also by Blueprints @@ -151,7 +151,7 @@ module.exports = class extends BaseBlueprintGenerator { return { insight() { if (this.abort) return; - statistics.sendSubGenEvent('generator', GENERATOR_CICD); + statistics.sendSubGenEvent('generator', GENERATOR_CI_CD); }, setTemplateConstants() { if (this.abort) return; diff --git a/generators/client/esm.mjs b/generators/client/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/client/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/client/generator.spec.mjs b/generators/client/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/client/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/cloudfoundry/esm.mjs b/generators/cloudfoundry/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/cloudfoundry/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/cloudfoundry/generator.spec.mjs b/generators/cloudfoundry/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/cloudfoundry/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/common/esm.mjs b/generators/common/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/common/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/common/generator.spec.mjs b/generators/common/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/common/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/cypress/esm.mjs b/generators/cypress/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/cypress/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/cypress/generator.spec.mjs b/generators/cypress/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/cypress/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/database-changelog-liquibase/esm.mjs b/generators/database-changelog-liquibase/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/database-changelog-liquibase/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/database-changelog-liquibase/generator.spec.mjs b/generators/database-changelog-liquibase/generator.spec.mjs new file mode 100644 index 00000000000..518c284d7a9 --- /dev/null +++ b/generators/database-changelog-liquibase/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe.skip('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/database-changelog-liquibase/index.js b/generators/database-changelog-liquibase/index.js index 3cb13bfb71b..1023b9ea435 100644 --- a/generators/database-changelog-liquibase/index.js +++ b/generators/database-changelog-liquibase/index.js @@ -41,6 +41,8 @@ module.exports = class extends BaseBlueprintGenerator { constructor(args, options, features) { super(args, options, features); + if (this.options.help) return; + assert(this.options.databaseChangelog, 'Changelog is required'); this.databaseChangelog = this.options.databaseChangelog; if (!this.databaseChangelog.changelogDate) { diff --git a/generators/database-changelog/esm.mjs b/generators/database-changelog/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/database-changelog/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/database-changelog/generator.spec.mjs b/generators/database-changelog/generator.spec.mjs new file mode 100644 index 00000000000..518c284d7a9 --- /dev/null +++ b/generators/database-changelog/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe.skip('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/docker-compose/esm.mjs b/generators/docker-compose/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/docker-compose/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/docker-compose/generator.spec.mjs b/generators/docker-compose/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/docker-compose/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/entities-client/esm.mjs b/generators/entities-client/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/entities-client/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/entities-client/generator.spec.mjs b/generators/entities-client/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/entities-client/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/entities/esm.mjs b/generators/entities/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/entities/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/entities/generator.spec.mjs b/generators/entities/generator.spec.mjs new file mode 100644 index 00000000000..518c284d7a9 --- /dev/null +++ b/generators/entities/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe.skip('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/entity-client/esm.mjs b/generators/entity-client/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/entity-client/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/entity-client/generator.spec.mjs b/generators/entity-client/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/entity-client/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/entity-i18n/esm.mjs b/generators/entity-i18n/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/entity-i18n/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/entity-i18n/generator.spec.mjs b/generators/entity-i18n/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/entity-i18n/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/entity-i18n/index.js b/generators/entity-i18n/index.js index cf58a26ead5..109ce720c9b 100644 --- a/generators/entity-i18n/index.js +++ b/generators/entity-i18n/index.js @@ -19,7 +19,7 @@ /* eslint-disable consistent-return */ const writeFiles = require('./files').writeFiles; const utils = require('../utils'); -const { GENERATOR_ENTITY_I18N } = require('../generator-list'); +const { GENERATOR_ENTITY_I_18_N } = require('../generator-list'); const BaseBlueprintGenerator = require('../generator-base-blueprint'); /* constants used throughout */ @@ -32,7 +32,7 @@ module.exports = class extends BaseBlueprintGenerator { this.entity = this.options.context; this.jhipsterContext = this.options.jhipsterContext || this.options.context; - useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_ENTITY_I18N, { context: this.options.context }); + useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_ENTITY_I_18_N, { context: this.options.context }); } // Public API method used by the getter and also by Blueprints diff --git a/generators/entity-server/esm.mjs b/generators/entity-server/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/entity-server/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/entity-server/generator.spec.mjs b/generators/entity-server/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/entity-server/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/entity/esm.mjs b/generators/entity/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/entity/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/entity/generator.spec.mjs b/generators/entity/generator.spec.mjs new file mode 100644 index 00000000000..518c284d7a9 --- /dev/null +++ b/generators/entity/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe.skip('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/entity/index.js b/generators/entity/index.js index a1f4badc1bc..82bfc5fc14c 100644 --- a/generators/entity/index.js +++ b/generators/entity/index.js @@ -43,7 +43,7 @@ const { GENERATOR_ENTITIES, GENERATOR_ENTITY, GENERATOR_ENTITY_CLIENT, - GENERATOR_ENTITY_I18N, + GENERATOR_ENTITY_I_18_N, GENERATOR_ENTITY_SERVER, } = require('../generator-list'); const { CommonDBTypes, RelationalOnlyDBTypes, BlobTypes } = require('../../jdl/jhipster/field-types'); @@ -535,7 +535,7 @@ class EntityGenerator extends BaseBlueprintGenerator { skipInstall: this.options.skipInstall, }); if (this.jhipsterConfig.enableTranslation) { - this.composeWithJHipster(GENERATOR_ENTITY_I18N, this.arguments, { + this.composeWithJHipster(GENERATOR_ENTITY_I_18_N, this.arguments, { context, skipInstall: this.options.skipInstall, }); diff --git a/generators/export-jdl/esm.mjs b/generators/export-jdl/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/export-jdl/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/export-jdl/generator.spec.mjs b/generators/export-jdl/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/export-jdl/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/gae/esm.mjs b/generators/gae/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/gae/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/gae/generator.spec.mjs b/generators/gae/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/gae/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/gae/index.js b/generators/gae/index.js index 56a1d8df834..24139dca130 100644 --- a/generators/gae/index.js +++ b/generators/gae/index.js @@ -611,10 +611,6 @@ module.exports = class extends BaseBlueprintGenerator { return this._prompting(); } - get default() { - return {}; - } - _configuring() { return { insight() { diff --git a/generators/generator-list.js b/generators/generator-list.js index f1954d4178d..043f186dc19 100644 --- a/generators/generator-list.js +++ b/generators/generator-list.js @@ -21,9 +21,12 @@ const Generators = { GENERATOR_ADD: 'add', GENERATOR_APP: 'app', GENERATOR_AWS: 'aws', - GENERATOR_BOOTSTRAP: 'bootstrap', GENERATOR_AZURE_APP_SERVICE: 'azure-app-service', GENERATOR_AZURE_SPRING_CLOUD: 'azure-spring-cloud', + GENERATOR_BASE: 'base', + GENERATOR_BOOTSTRAP: 'bootstrap', + GENERATOR_CI_CD: 'ci-cd', + /* @deprecated */ GENERATOR_CICD: 'ci-cd', GENERATOR_CLIENT: 'client', GENERATOR_CLOUDFOUNDRY: 'cloudfoundry', @@ -35,28 +38,34 @@ const Generators = { GENERATOR_ENTITIES: 'entities', GENERATOR_ENTITIES_CLIENT: 'entities-client', GENERATOR_ENTITY: 'entity', - GENERATOR_ENTITY_I18N: 'entity-i18n', GENERATOR_ENTITY_CLIENT: 'entity-client', + GENERATOR_ENTITY_I_18_N: 'entity-i18n', + /* @deprecated */ + GENERATOR_ENTITY_I18N: 'entity-i18n', GENERATOR_ENTITY_SERVER: 'entity-server', GENERATOR_EXPORT_JDL: 'export-jdl', GENERATOR_GAE: 'gae', GENERATOR_GRADLE: 'gradle', GENERATOR_HEROKU: 'heroku', + GENERATOR_INFO: 'info', + GENERATOR_INIT: 'init', + GENERATOR_JAVA: 'java', GENERATOR_KUBERNETES: 'kubernetes', GENERATOR_KUBERNETES_HELM: 'kubernetes-helm', GENERATOR_KUBERNETES_KNATIVE: 'kubernetes-knative', - GENERATOR_INIT: 'init', - GENERATOR_JAVA: 'java', - GENERATOR_MAVEN: 'maven', GENERATOR_LANGUAGES: 'languages', + GENERATOR_MAVEN: 'maven', + GENERATOR_OPENAPI_CLIENT: 'openapi-client', + GENERATOR_OPENSHIFT: 'openshift', GENERATOR_PAGE: 'page', GENERATOR_PROJECT_NAME: 'project-name', GENERATOR_SERVER: 'server', - GENERATOR_OPENAPI: 'openapi-client', - GENERATOR_OPENSHIFT: 'openshift', GENERATOR_SPRING_BOOT: 'spring-boot', GENERATOR_SPRING_CONTROLLER: 'spring-controller', GENERATOR_SPRING_SERVICE: 'spring-service', + GENERATOR_UPGRADE: 'upgrade', + GENERATOR_UPGRADE_CONFIG: 'upgrade-config', + GENERATOR_WORKSPACES: 'workspaces', }; module.exports = Generators; diff --git a/generators/heroku/esm.mjs b/generators/heroku/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/heroku/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/heroku/generator.spec.mjs b/generators/heroku/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/heroku/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/info/esm.mjs b/generators/info/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/info/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/info/generator.spec.mjs b/generators/info/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/info/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/info/index.js b/generators/info/index.js index 57894aacae2..1559fb475c0 100644 --- a/generators/info/index.js +++ b/generators/info/index.js @@ -34,6 +34,8 @@ module.exports = class extends BaseGenerator { defaults: true, }); + if (this.options.help) return; + this.env.options.skipInstall = true; } diff --git a/generators/kubernetes-helm/esm.mjs b/generators/kubernetes-helm/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/kubernetes-helm/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/kubernetes-helm/generator.spec.mjs b/generators/kubernetes-helm/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/kubernetes-helm/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/kubernetes-knative/esm.mjs b/generators/kubernetes-knative/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/kubernetes-knative/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/kubernetes-knative/generator.spec.mjs b/generators/kubernetes-knative/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/kubernetes-knative/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/kubernetes/esm.mjs b/generators/kubernetes/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/kubernetes/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/kubernetes/generator.spec.mjs b/generators/kubernetes/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/kubernetes/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/languages/esm.mjs b/generators/languages/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/languages/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/languages/generator.spec.mjs b/generators/languages/generator.spec.mjs new file mode 100644 index 00000000000..518c284d7a9 --- /dev/null +++ b/generators/languages/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe.skip('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/openapi-client/esm.mjs b/generators/openapi-client/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/openapi-client/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/openapi-client/generator.spec.mjs b/generators/openapi-client/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/openapi-client/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/openapi-client/index.js b/generators/openapi-client/index.js index e7c6ffa0e4a..7420e46739a 100644 --- a/generators/openapi-client/index.js +++ b/generators/openapi-client/index.js @@ -19,7 +19,7 @@ /* eslint-disable consistent-return */ const shelljs = require('shelljs'); const chalk = require('chalk'); -const { GENERATOR_OPENAPI } = require('../generator-list'); +const { GENERATOR_OPENAPI_CLIENT } = require('../generator-list'); const { OpenAPIOptionsNames, OpenAPIDefaultValues } = require('../../jdl/jhipster/openapi-options'); const prompts = require('./prompts'); const { writeFiles, customizeFiles } = require('./files'); @@ -35,7 +35,7 @@ module.exports = class extends BaseBlueprintGenerator { type: Boolean, defaults: OpenAPIDefaultValues.REGEN, }); - useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_OPENAPI); + useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_OPENAPI_CLIENT); } _initializing() { diff --git a/generators/openshift/esm.mjs b/generators/openshift/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/openshift/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/openshift/generator.spec.mjs b/generators/openshift/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/openshift/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/page/esm.mjs b/generators/page/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/page/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/page/generator.spec.mjs b/generators/page/generator.spec.mjs new file mode 100644 index 00000000000..518c284d7a9 --- /dev/null +++ b/generators/page/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe.skip('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/server/esm.mjs b/generators/server/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/server/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/server/generator.spec.mjs b/generators/server/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/server/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/spring-controller/esm.mjs b/generators/spring-controller/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/spring-controller/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/spring-controller/generator.spec.mjs b/generators/spring-controller/generator.spec.mjs new file mode 100644 index 00000000000..518c284d7a9 --- /dev/null +++ b/generators/spring-controller/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe.skip('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/spring-service/esm.mjs b/generators/spring-service/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/spring-service/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/spring-service/generator.spec.mjs b/generators/spring-service/generator.spec.mjs new file mode 100644 index 00000000000..518c284d7a9 --- /dev/null +++ b/generators/spring-service/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe.skip('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/generators/upgrade-config/esm.mjs b/generators/upgrade-config/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/upgrade-config/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/upgrade-config/generator.spec.mjs b/generators/upgrade-config/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/upgrade-config/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/upgrade/esm.mjs b/generators/upgrade/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/upgrade/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/upgrade/generator.spec.mjs b/generators/upgrade/generator.spec.mjs new file mode 100644 index 00000000000..0879129ab26 --- /dev/null +++ b/generators/upgrade/generator.spec.mjs @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import Generator from './index.js'; + +const { snakeCase } = lodash; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); +}); diff --git a/generators/workspaces/esm.mjs b/generators/workspaces/esm.mjs new file mode 100644 index 00000000000..45d9243c55a --- /dev/null +++ b/generators/workspaces/esm.mjs @@ -0,0 +1,21 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import generator from './index.js'; + +export default generator; diff --git a/generators/workspaces/generator.spec.mjs b/generators/workspaces/generator.spec.mjs new file mode 100644 index 00000000000..65ad35ce31f --- /dev/null +++ b/generators/workspaces/generator.spec.mjs @@ -0,0 +1,47 @@ +/** + * Copyright 2013-2021 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. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import expect from 'expect'; +import lodash from 'lodash'; +import { basename, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +import testSupport from '../../test/support/index.cjs'; +import Generator from './index.js'; + +const { snakeCase } = lodash; +const { testBlueprintSupport } = testSupport; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const generator = basename(__dirname); + +describe(`JHipster ${generator} generator`, () => { + it('generator-list constant matches folder name', async () => { + await expect((await import('../generator-list.js')).default[`GENERATOR_${snakeCase(generator).toUpperCase()}`]).toBe(generator); + }); + it('should be exported at package.json', async () => { + await expect((await import(`generator-jhipster/generators/${generator}`)).default).toBe(Generator); + }); + it('should support features parameter', () => { + const instance = new Generator([], { help: true }, { bar: true }); + expect(instance.features.bar).toBe(true); + }); + describe('blueprint support', () => testBlueprintSupport(generator)); +}); diff --git a/package.json b/package.json index b977d9d32f8..a0ef8f2c3f6 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,51 @@ }, "exports": { ".": "./lib/index.js", + "./generators/add": "./generators/add/index.cjs", + "./generators/app": "./generators/app/esm.mjs", + "./generators/aws": "./generators/aws/esm.mjs", + "./generators/azure-app-service": "./generators/azure-app-service/esm.mjs", + "./generators/azure-spring-cloud": "./generators/azure-spring-cloud/esm.mjs", + "./generators/base": "./generators/base/esm.mjs", + "./generators/bootstrap": "./generators/bootstrap/esm.mjs", + "./generators/ci-cd": "./generators/ci-cd/esm.mjs", + "./generators/client": "./generators/client/esm.mjs", + "./generators/cloudfoundry": "./generators/cloudfoundry/esm.mjs", + "./generators/common": "./generators/common/esm.mjs", + "./generators/cypress": "./generators/cypress/esm.mjs", + "./generators/database-changelog": "./generators/database-changelog/esm.mjs", + "./generators/database-changelog-liquibase": "./generators/database-changelog-liquibase/esm.mjs", + "./generators/docker-compose": "./generators/docker-compose/esm.mjs", + "./generators/entities": "./generators/entities/esm.mjs", + "./generators/entities-client": "./generators/entities-client/esm.mjs", + "./generators/entity": "./generators/entity/esm.mjs", + "./generators/entity-client": "./generators/entity-client/esm.mjs", + "./generators/entity-i18n": "./generators/entity-i18n/esm.mjs", + "./generators/entity-server": "./generators/entity-server/esm.mjs", + "./generators/export-jdl": "./generators/export-jdl/esm.mjs", + "./generators/gae": "./generators/gae/esm.mjs", + "./generators/generate-blueprint": "./generators/generate-blueprint/index.cjs", + "./generators/gradle": "./generators/gradle/index.cjs", + "./generators/heroku": "./generators/heroku/esm.mjs", + "./generators/info": "./generators/info/esm.mjs", + "./generators/init": "./generators/init/index.cjs", + "./generators/java": "./generators/java/index.cjs", + "./generators/kubernetes": "./generators/kubernetes/esm.mjs", + "./generators/kubernetes-helm": "./generators/kubernetes-helm/esm.mjs", + "./generators/kubernetes-knative": "./generators/kubernetes-knative/esm.mjs", + "./generators/languages": "./generators/languages/esm.mjs", + "./generators/maven": "./generators/maven/index.cjs", + "./generators/openapi-client": "./generators/openapi-client/esm.mjs", + "./generators/openshift": "./generators/openshift/esm.mjs", + "./generators/page": "./generators/page/esm.mjs", + "./generators/project-name": "./generators/project-name/index.cjs", + "./generators/server": "./generators/server/esm.mjs", + "./generators/spring-boot": "./generators/spring-boot/index.cjs", + "./generators/spring-controller": "./generators/spring-controller/esm.mjs", + "./generators/spring-service": "./generators/spring-service/esm.mjs", + "./generators/upgrade": "./generators/upgrade/esm.mjs", + "./generators/upgrade-config": "./generators/upgrade-config/esm.mjs", + "./generators/workspaces": "./generators/workspaces/esm.mjs", "./support": "./lib/support/index.cjs" }, "main": "lib/index.js", diff --git a/test/support/index.cjs b/test/support/index.cjs index 7838efc2d91..e3cb33727c5 100644 --- a/test/support/index.cjs +++ b/test/support/index.cjs @@ -1,10 +1,11 @@ const expect = require('expect'); const path = require('path'); const sinon = require('sinon'); +const { existsSync } = require('fs'); const { GENERATOR_JHIPSTER } = require('../../generators/generator-constants'); const { skipPrettierHelpers: helpers } = require('../utils/utils'); -const { PRIORITY_PREFIX, PRIORITY_NAMES } = require('../../lib/support/priorities.cjs'); +const { PRIORITY_NAMES } = require('../../lib/support/priorities.cjs'); const testOptions = data => { const { generatorPath, customOptions, contextBuilder = () => helpers.create(generatorPath) } = data; @@ -151,28 +152,39 @@ const basicTests = data => { }); }; -const testBlueprintSupport = generatorName => { +const testBlueprintSupport = (generatorName, skipSbsBlueprint = false) => { + let generatorPath = path.join(__dirname, `../../generators/${generatorName}/index.cjs`); + if (!existsSync(generatorPath)) { + generatorPath = path.join(__dirname, `../../generators/${generatorName}/index.js`); + } const addSpies = generator => { + const { taskPrefix = '' } = generator.features; + const apiPrefix = taskPrefix ? '' : '_'; const prioritiesSpy = sinon.spy(); let prioritiesCount = 0; PRIORITY_NAMES.forEach(priority => { let callback; - if (Object.getOwnPropertyDescriptor(Object.getPrototypeOf(generator), `${PRIORITY_PREFIX}${priority}`)) { + if (Object.getOwnPropertyDescriptor(Object.getPrototypeOf(generator), `${taskPrefix}${priority}`)) { prioritiesCount++; callback = prioritiesSpy; } else { callback = () => { - throw new Error(`${priority} should not be called`); + throw new Error(`${apiPrefix}${priority} should not be called`); }; } - Object.defineProperty(generator, priority, { - get() { - callback(); - return {}; - }, - enumerable: true, - configurable: true, - }); + const property = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(generator), `${apiPrefix}${priority}`); + if (property && property.value && typeof property.value === 'function') { + generator[`${apiPrefix}${priority}`] = callback; + } else { + Object.defineProperty(generator, `${apiPrefix}${priority}`, { + get() { + callback(); + return {}; + }, + enumerable: true, + configurable: true, + }); + } }); return { prioritiesSpy, prioritiesCount }; }; @@ -181,7 +193,7 @@ const testBlueprintSupport = generatorName => { let spy; before(async () => { result = await helpers - .run(path.join(__dirname, `../../generators/${generatorName}/index.cjs`)) + .run(generatorPath) .withMockedGenerators([`jhipster-foo:${generatorName}`]) .withOptions({ blueprint: 'foo', skipChecks: true }) .on('ready', generator => { @@ -198,11 +210,14 @@ const testBlueprintSupport = generatorName => { describe('with sbs blueprint', () => { let result; let spy; - before(async () => { + before(async function () { + if (skipSbsBlueprint) { + this.skip(); + } const context = helpers - .run(path.join(__dirname, `../../generators/${generatorName}/index.cjs`)) + .run(generatorPath) .withMockedGenerators([`jhipster-foo-sbs:${generatorName}`]) - .withOptions({ blueprint: 'foo-sbs', skipChecks: true, configure: true }) + .withOptions({ blueprint: 'foo-sbs', skipChecks: true }) .on('ready', generator => { spy = addSpies(generator); });