Skip to content

Commit

Permalink
Merge pull request #27361 from mshima/blueprint-recreate-package-lock
Browse files Browse the repository at this point in the history
generate-blueprint: add recreatePackageLock option
  • Loading branch information
DanielFran committed Sep 23, 2024
2 parents fe7097a + ac0f3af commit d8a538d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions generators/generate-blueprint/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ import {

const command: JHipsterCommandDefinition = {
configs: {
recreatePackageLock: {
description: 'Recreate package lock',
cli: {
type: Boolean,
},
scope: 'generator',
},
githubRepository: {
cli: {
description: 'Github Repository',
Expand Down
8 changes: 8 additions & 0 deletions generators/generate-blueprint/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { rm } from 'node:fs/promises';
import chalk from 'chalk';
import { camelCase, snakeCase, upperFirst } from 'lodash-es';

Expand Down Expand Up @@ -53,6 +54,7 @@ const defaultPublishedFiles = ['generators', '!**/__*', '!**/*.snap', '!**/*.spe

export default class extends BaseGenerator {
application!: any;
recreatePackageLock!: boolean;

async _beforeQueue() {
if (!this.fromBlueprint) {
Expand Down Expand Up @@ -352,6 +354,12 @@ export default class extends BaseGenerator {
} = this.options;
if (!generateSnapshots) return;

if (this.recreatePackageLock) {
await rm(this.destinationPath('package-lock.json'), { force: true });
await rm(this.destinationPath('node_modules'), { force: true, recursive: true });
await this.spawnCommand('npm', ['install'], { stdio: 'inherit' });
}

try {
if (this.options[LINK_JHIPSTER_DEPENDENCY]) {
this.log.verboseInfo('Linking generator-jhipster');
Expand Down

0 comments on commit d8a538d

Please sign in to comment.