Skip to content

Commit

Permalink
Merge pull request #23393 from mshima/skip_ci-with-entities
Browse files Browse the repository at this point in the history
drop --with-entities option
  • Loading branch information
DanielFran authored Sep 4, 2023
2 parents 97cb68b + 69f2d10 commit 1306436
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .blueprint/from-issue/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class extends BaseGenerator {
}
}
if (this.yoRcContent) {
await this.runNonInteractive({ cwd: this.projectFolder, generatorOptions: { withEntities: true } });
await this.runNonInteractive({ cwd: this.projectFolder });
}
setOutput(RESULT_OUTPUT, SUCCESS);

Expand Down
2 changes: 1 addition & 1 deletion .blueprint/generate-sample/support/generate-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const generateSample = async (
}

// Generate the application
await execa(jhipsterBin, ['--with-entities', ...commonCliOptions, ...extraArgs], { stdio: 'inherit' });
await execa(jhipsterBin, [...commonCliOptions, ...extraArgs], { stdio: 'inherit' });
}

await execa(jhipsterBin, ['info'], { stdio: 'inherit' });
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/generator-database-changelog-liquibase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ jobs:
- name: 'GENERATION: config'
run: $JHI_SCRIPTS/11-generate-config.sh
- name: 'GENERATION: project'
run: $JHI_SCRIPTS/12-generate-project.sh --with-entities --force --creation-timestamp '2020-01-01'
run: $JHI_SCRIPTS/12-generate-project.sh --force --creation-timestamp '2020-01-01'
env:
JHI_SAMPLES: ${{ github.workspace }}/generator-jhipster/test-integration/incremental-changelog-samples
- name: 'GENERATION: incremental project'
run: $JHI_SCRIPTS/12-generate-project.sh --incremental-changelog --with-entities --force
run: $JHI_SCRIPTS/12-generate-project.sh --incremental-changelog --force
env:
JHI_SAMPLES: ${{ github.workspace }}/generator-jhipster/test-integration/incremental-changelog-samples
JHI_APP: ${{ matrix.app-type }}-post
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generator-generate-blueprint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
- name: 'GENERATION: config'
run: $JHI_SCRIPTS/11-generate-config.sh
- name: 'GENERATION: project'
run: $JHI_SCRIPTS/12-generate-project.sh ${{ matrix.extra-args }} ${{ matrix.new-extra-args }} --with-entities --blueprints foo
run: $JHI_SCRIPTS/12-generate-project.sh ${{ matrix.extra-args }} ${{ matrix.new-extra-args }} --blueprints foo
- name: 'GENERATION: jhipster info'
run: $JHI_SCRIPTS/14-jhipster-info.sh
#----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ jhipster
Depending on which parts of the generator you have changed, do not forget to run jhipster command with the proper arguments e.g. when updating the entity template run:

```shell
jhipster --with-entities
jhipster
```

You should see your changes reflected in the generated project.
Expand Down
91 changes: 0 additions & 91 deletions generators/app/composing.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -140,96 +140,5 @@ describe('generator - app - composing', () => {
assert.equal(MockedGenerator.callCount, 0);
});
});

describe('with --with-entities', () => {
describe('and 1 entity file', () => {
let runResult;
before(async () => {
runResult = await helpers
.runJHipster(GENERATOR_APP)
.withJHipsterConfig({}, [{ name: 'Foo' }])
.withOptions({
withEntities: true,
})
.withMockedGenerators(allMockedComposedGenerators);
});

it('should compose with bootstrap generator', () => {
assert(runResult.mockedGenerators['jhipster:bootstrap'].called);
});
it('should compose with common generator', () => {
const CommonGenerator = runResult.mockedGenerators['jhipster:common'];
assert(CommonGenerator.calledOnce);
});
it('compose with server generator', () => {
const ServerGenerator = runResult.mockedGenerators['jhipster:server'];
assert(ServerGenerator.calledOnce);
});
it('should compose with client generator', () => {
const ClientGenerator = runResult.mockedGenerators['jhipster:client'];
assert(ClientGenerator.calledOnce);
});
it('should compose with languages generator', () => {
const LanguagesGenerator = runResult.mockedGenerators['jhipster:languages'];
assert(LanguagesGenerator.calledOnce);
});
it('should compose with entities generator once', () => {
assert.equal(runResult.mockedGenerators['jhipster:entities'].callCount, 0);
});
it('should not compose with entity generator', () => {
const MockedGenerator = runResult.mockedGenerators['jhipster:entity'];
assert.equal(MockedGenerator.callCount, 0);
});
it('should not compose with database-changelog generator', () => {
const MockedGenerator = runResult.mockedGenerators['jhipster:database-changelog'];
assert.equal(MockedGenerator.callCount, 0);
});
});

describe('and more than 1 entity file', () => {
let runResult;
before(async () => {
runResult = await helpers
.runJHipster(GENERATOR_APP)
.withJHipsterConfig({}, [
{ name: 'One', changelogDate: '12345678901234' },
{ name: 'Two', changelogDate: '12345678901235' },
{ name: 'Three', changelogDate: '12345678901236' },
])
.withOptions({
withEntities: true,
})
.withMockedGenerators(allMockedComposedGenerators);
});

it('should compose with bootstrap generator', () => {
assert(runResult.mockedGenerators['jhipster:bootstrap'].called);
});
it('should compose with common generator', () => {
const CommonGenerator = runResult.mockedGenerators['jhipster:common'];
assert(CommonGenerator.calledOnce);
});
it('compose with server generator', () => {
const ServerGenerator = runResult.mockedGenerators['jhipster:server'];
assert(ServerGenerator.calledOnce);
});
it('should compose with client generator', () => {
const ClientGenerator = runResult.mockedGenerators['jhipster:client'];
assert(ClientGenerator.calledOnce);
});
it('should compose with languages generator', () => {
const LanguagesGenerator = runResult.mockedGenerators['jhipster:languages'];
assert(LanguagesGenerator.calledOnce);
});
it('should not compose with entity generator', () => {
const EntityGenerator = runResult.mockedGenerators['jhipster:entity'];
assert.equal(EntityGenerator.callCount, 0);
});
it('should not compose with database-changelog generator', () => {
const IncrementalChangelogGenerator = runResult.mockedGenerators['jhipster:database-changelog'];
assert.equal(IncrementalChangelogGenerator.callCount, 0);
});
});
});
});
});
102 changes: 49 additions & 53 deletions generators/base-core/generator-core.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -79,64 +79,60 @@ describe('generator - base', () => {
expect(base.config.get('lastLiquibaseTimestamp')).to.be.equal(parseChangelog('20300101000002').getTime());
});
});
describe('with withEntities option', () => {
describe('with reproducible=false argument', () => {
let firstChangelogDate;
let secondChangelogDate;
beforeEach(() => {
firstChangelogDate = base.dateFormatForLiquibase(false);
secondChangelogDate = base.dateFormatForLiquibase(false);
});
it('should return a valid changelog date', () => {
expect(/^\d{14}$/.test(firstChangelogDate)).to.be.true;
expect(/^\d{14}$/.test(secondChangelogDate)).to.be.true;
});
it('should return a reproducible changelog date incremental to lastLiquibaseTimestamp', () => {
expect(firstChangelogDate).to.not.be.equal(secondChangelogDate);
});
it('should save lastLiquibaseTimestamp', () => {
expect(base.config.get('lastLiquibaseTimestamp')).to.be.equal(parseChangelog(secondChangelogDate).getTime());
});
});
describe('with a past creationTimestamp option', () => {
let firstChangelogDate;
let secondChangelogDate;

before(() => {
options = { withEntities: true };
options = { creationTimestamp: '2000-01-01' };
});
after(() => {
options = undefined;
});
describe('with reproducible=false argument', () => {
let firstChangelogDate;
let secondChangelogDate;
beforeEach(() => {
firstChangelogDate = base.dateFormatForLiquibase(false);
secondChangelogDate = base.dateFormatForLiquibase(false);
});
it('should return a valid changelog date', () => {
expect(/^\d{14}$/.test(firstChangelogDate)).to.be.true;
expect(/^\d{14}$/.test(secondChangelogDate)).to.be.true;
});
it('should return a reproducible changelog date incremental to lastLiquibaseTimestamp', () => {
expect(firstChangelogDate).to.not.be.equal(secondChangelogDate);
});
it('should save lastLiquibaseTimestamp', () => {
expect(base.config.get('lastLiquibaseTimestamp')).to.be.equal(parseChangelog(secondChangelogDate).getTime());
});
});
describe('with a past creationTimestamp option', () => {
let firstChangelogDate;
let secondChangelogDate;
before(() => {
options.creationTimestamp = '2000-01-01';
});
beforeEach(() => {
firstChangelogDate = base.dateFormatForLiquibase();
secondChangelogDate = base.dateFormatForLiquibase();
});
it('should return a valid changelog date', () => {
expect(/^\d{14}$/.test(firstChangelogDate)).to.be.true;
});
it('should return a past changelog date', () => {
expect(firstChangelogDate.startsWith('2000')).to.be.true;
});
it('should return a reproducible changelog date', () => {
expect(firstChangelogDate).to.be.equal('20000101000100');
expect(secondChangelogDate).to.be.equal('20000101000200');
});
it('should save lastLiquibaseTimestamp', () => {
expect(base.config.get('lastLiquibaseTimestamp')).to.be.equal(parseChangelog('20000101000200').getTime());
});
});
describe('with a future creationTimestamp option', () => {
it('should throw', async () => {
options.creationTimestamp = '2030-01-01';
const Dummy = helpers.createDummyGenerator(Base);
const env = await helpers.createTestEnv();
expect(() => new Dummy({ ...options, env, sharedData: {} })).to.throw(
/^Creation timestamp should not be in the future: 2030-01-01\.$/,
);
});

beforeEach(() => {
firstChangelogDate = base.dateFormatForLiquibase();
secondChangelogDate = base.dateFormatForLiquibase();
});
it('should return a valid changelog date', () => {
expect(/^\d{14}$/.test(firstChangelogDate)).to.be.true;
});
it('should return a past changelog date', () => {
expect(firstChangelogDate.startsWith('2000')).to.be.true;
});
it('should return a reproducible changelog date', () => {
expect(firstChangelogDate).to.be.equal('20000101000100');
expect(secondChangelogDate).to.be.equal('20000101000200');
});
it('should save lastLiquibaseTimestamp', () => {
expect(base.config.get('lastLiquibaseTimestamp')).to.be.equal(parseChangelog('20000101000200').getTime());
});
});
describe('with a future creationTimestamp option', () => {
it('should throw', async () => {
const Dummy = helpers.createDummyGenerator(Base);
const env = await helpers.createTestEnv();
expect(() => new Dummy({ ...options, creationTimestamp: '2030-01-01', env, sharedData: {} })).to.throw(
/^Creation timestamp should not be in the future: 2030-01-01\.$/,
);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion generators/base-core/generator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export default class CoreGenerator extends YeomanGenerator<JHipsterGeneratorOpti
let now = new Date();
// Miliseconds is ignored for changelogDate.
now.setMilliseconds(0);
// Run reproducible timestamp when regenerating the project with with-entities option.
// Run reproducible timestamp when regenerating the project with reproducible option or an specific timestamp.
if (reproducible || creationTimestamp) {
if (control.reproducibleLiquibaseTimestamp) {
// Counter already started.
Expand Down
1 change: 0 additions & 1 deletion generators/base/__snapshots__/generator.spec.mts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Options:
--skip-jhipster-dependencies Don't write jhipster dependencies to package.json.
--creation-timestamp <value> Project creation timestamp (used for reproducible builds)
--reproducible Try to reproduce changelog
-e, --with-entities Regenerate the existing entities if any
-h, --help display help for command
Commands:
Expand Down
6 changes: 0 additions & 6 deletions generators/base/command.mts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ const command: JHipsterCommandDefinition = {
type: Boolean,
scope: 'control',
},
withEntities: {
alias: 'e',
description: 'Regenerate the existing entities if any',
type: Boolean,
scope: 'control',
},
},
};

Expand Down
1 change: 0 additions & 1 deletion generators/base/types.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export type Control = {
jhipsterOldVersion: string | null;
useVersionPlaceholders?: boolean;
reproducible?: boolean;
withEntities?: boolean;
/**
* Configure blueprints once per application.
*/
Expand Down
1 change: 0 additions & 1 deletion generators/liquibase/incremental-liquibase.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ describe('generator - app - --incremental-changelog', function () {
incrementalChangelog: true,
skipClient: true,
force: true,
withEntities: true,
};
context('when creating a new application', () => {
let runResult;
Expand Down
5 changes: 1 addition & 4 deletions generators/project-name/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ export default class ProjectNameGenerator extends BaseApplicationGenerator {
}

this.sharedData.getControl().existingProject =
this.options.defaults ||
this.options.withEntities ||
this.options.applicationWithConfig ||
(this.jhipsterConfig.baseName !== undefined && this.config.existed);
this.options.defaults || this.options.applicationWithConfig || (this.jhipsterConfig.baseName !== undefined && this.config.existed);

if (!this.fromBlueprint) {
await this.composeWithBlueprints(GENERATOR_PROJECT_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('generator - app - database changelogs', () => {
runResult = await helpers
.runJHipster(GENERATOR_SPRING_DATA_CASSANDRA)
.withJHipsterConfig({ databaseType: 'cassandra' }, [entityFoo])
.withOptions({ withEntities: true, force: true, skipClient: true });
.withOptions({ force: true, skipClient: true });
});

it('should create database changelog for the entity', () => {
Expand Down
12 changes: 8 additions & 4 deletions generators/upgrade/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ function gitExec(logger, args, options = {}, callback) {
}

export default class UpgradeGenerator extends BaseGenerator {
upgradeV7_9_3App;
fromV7;
fromV7_9_3App;

constructor(args, options, features) {
super(args, options, features);
Expand Down Expand Up @@ -110,12 +111,13 @@ export default class UpgradeGenerator extends BaseGenerator {
);
}

this.fromV7 = this.jhipsterConfig.jhipsterVersion && semver.satisfies(this.jhipsterConfig.jhipsterVersion, '^7.0.0');
const currentNodeVersion = process.versions.node;
if (this.jhipsterConfig.jhipsterVersion === '7.9.3') {
if (!semver.satisfies(currentNodeVersion, '^16.0.0')) {
throw new Error('Upgrading a v7.9.3 generated application requires node 16 to upgrade');
}
this.upgradeV7_9_3App = true;
this.fromV7_9_3App = true;
} else if (!semver.satisfies(currentNodeVersion, packageJson.engines.node)) {
this.log.fatal(
`You are running Node version ${currentNodeVersion}\nJHipster requires Node version ${packageJson.engines.node}\nPlease update your version of Node.`,
Expand Down Expand Up @@ -192,8 +194,10 @@ export default class UpgradeGenerator extends BaseGenerator {
generatorCommand = 'npm exec --no jhipster --';
}
}
const skipChecksOption = this.skipChecks || (!target && this.upgradeV7_9_3App) ? '--skip-checks' : '';
const regenerateCmd = `${generatorCommand} --with-entities --force --skip-install --skip-git --ignore-errors --no-insight ${skipChecksOption}`;
const skipChecksOption = this.skipChecks || (!target && this.fromV7_9_3App) ? '--skip-checks' : '';
const regenerateCmd = `${generatorCommand} ${
this.fromV7 ? '--with-entities ' : ''
}--force --skip-install --skip-git --ignore-errors --no-insight ${skipChecksOption}`;
this.log.verboseInfo(regenerateCmd);
const result = this.spawnCommandSync(regenerateCmd);
if (result.exitCode !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion test-integration/scripts/12-generate-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ else
fi

cd "$JHI_FOLDER_APP"
eval "$JHI_CLI --force --no-insight --skip-checks --with-entities --skip-jhipster-dependencies $@"
eval "$JHI_CLI --force --no-insight --skip-checks --skip-jhipster-dependencies $@"

fi

Expand Down

0 comments on commit 1306436

Please sign in to comment.