Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add esm entry points. #15950

Merged
merged 2 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
21 changes: 21 additions & 0 deletions generators/app/esm.mjs
Original file line number Diff line number Diff line change
@@ -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;
47 changes: 47 additions & 0 deletions generators/app/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -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));
});
21 changes: 21 additions & 0 deletions generators/aws/esm.mjs
Original file line number Diff line number Diff line change
@@ -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;
47 changes: 47 additions & 0 deletions generators/aws/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -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));
});
21 changes: 21 additions & 0 deletions generators/azure-app-service/esm.mjs
Original file line number Diff line number Diff line change
@@ -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;
47 changes: 47 additions & 0 deletions generators/azure-app-service/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -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));
});
21 changes: 21 additions & 0 deletions generators/azure-spring-cloud/esm.mjs
Original file line number Diff line number Diff line change
@@ -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;
47 changes: 47 additions & 0 deletions generators/azure-spring-cloud/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -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));
});
21 changes: 21 additions & 0 deletions generators/base/esm.mjs
Original file line number Diff line number Diff line change
@@ -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;
44 changes: 44 additions & 0 deletions generators/base/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -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);
});
});
Loading