From 7a6bf10d374be2bcc85bcb87e93a68b471da47ef Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 11 Feb 2023 12:55:12 -0300 Subject: [PATCH] move multistep transform to a dedicated priority --- generators/base-application/priorities.mjs | 6 +++--- generators/base/priorities.mjs | 19 +++++++++++++---- generators/bootstrap/generator.mts | 24 ++++++++++++---------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/generators/base-application/priorities.mjs b/generators/base-application/priorities.mjs index 9811225f9106..71e2ae0e683f 100644 --- a/generators/base-application/priorities.mjs +++ b/generators/base-application/priorities.mjs @@ -19,7 +19,7 @@ import { QUEUE_PREFIX, PRIORITY_NAMES as PRIORITY_NAMES_BASE, QUEUES as QUEUES_BASE } from '../base/priorities.mjs'; -const { DEFAULT, TRANSFORM, PRE_CONFLICTS } = PRIORITY_NAMES_BASE; +const { DEFAULT, TRANSFORM, MULTISTEP_TRANSFORM } = PRIORITY_NAMES_BASE; const CONFIGURING_EACH_ENTITY = 'configuringEachEntity'; const CONFIGURING_EACH_ENTITY_QUEUE = `${QUEUE_PREFIX}${CONFIGURING_EACH_ENTITY}`; @@ -85,13 +85,13 @@ export const CUSTOM_PRIORITIES = [ { priorityName: WRITING_ENTITIES, queueName: WRITING_ENTITIES_QUEUE, - before: TRANSFORM, + before: MULTISTEP_TRANSFORM, skip: true, }, { priorityName: POST_WRITING_ENTITIES, queueName: POST_WRITING_ENTITIES_QUEUE, - before: PRE_CONFLICTS, + before: TRANSFORM, skip: true, }, ].reverse(); diff --git a/generators/base/priorities.mjs b/generators/base/priorities.mjs index 0791394c40bd..d9f89617fa6b 100644 --- a/generators/base/priorities.mjs +++ b/generators/base/priorities.mjs @@ -49,6 +49,9 @@ const LOADING_QUEUE = `${QUEUE_PREFIX}${LOADING}`; const PREPARING = 'preparing'; const PREPARING_QUEUE = `${QUEUE_PREFIX}${PREPARING}`; +const MULTISTEP_TRANSFORM = 'multistepTransform'; +const MULTISTEP_TRANSFORM_QUEUE = `${QUEUE_PREFIX}${MULTISTEP_TRANSFORM}`; + const POST_WRITING = 'postWriting'; const POST_WRITING_QUEUE = `${QUEUE_PREFIX}${POST_WRITING}`; @@ -107,10 +110,15 @@ export const CUSTOM_PRIORITIES = [ args: generator => generator.getArgsForPriority(WRITING), edit: true, }, + { + priorityName: MULTISTEP_TRANSFORM, + queueName: MULTISTEP_TRANSFORM_QUEUE, + before: POST_WRITING, + }, { priorityName: POST_WRITING, queueName: POST_WRITING_QUEUE, - before: PRE_CONFLICTS, + before: TRANSFORM, args: generator => generator.getArgsForPriority(POST_WRITING), }, { @@ -147,8 +155,9 @@ export const PRIORITY_NAMES = { DEFAULT, WRITING, - TRANSFORM, + MULTISTEP_TRANSFORM, POST_WRITING, + TRANSFORM, PRE_CONFLICTS, INSTALL, POST_INSTALL, @@ -165,8 +174,9 @@ export const PRIORITY_NAMES_LIST = [ DEFAULT, WRITING, - TRANSFORM, + MULTISTEP_TRANSFORM, POST_WRITING, + TRANSFORM, INSTALL, POST_INSTALL, END, @@ -182,8 +192,9 @@ export const QUEUES = { DEFAULT_QUEUE: DEFAULT, WRITING_QUEUE: WRITING, - TRANSFORM_QUEUE: TRANSFORM, + MULTISTEP_TRANSFORM_QUEUE, POST_WRITING_QUEUE, + TRANSFORM_QUEUE: TRANSFORM, PRE_CONFLICTS_QUEUE, INSTALL_QUEUE: INSTALL, POST_INSTALL_QUEUE, diff --git a/generators/bootstrap/generator.mts b/generators/bootstrap/generator.mts index fd72881dafcf..b1cae1115fdb 100644 --- a/generators/bootstrap/generator.mts +++ b/generators/bootstrap/generator.mts @@ -29,13 +29,14 @@ import MultiStepTransform from './multi-step-transform/index.mjs'; import { prettierTransform, generatedAnnotationTransform } from './transforms.mjs'; import { PRETTIER_EXTENSIONS } from '../generator-constants.mjs'; import { GENERATOR_UPGRADE } from '../generator-list.mjs'; -import { PRIORITY_NAMES } from '../base-application/priorities.mjs'; +import { PRIORITY_NAMES, QUEUES } from '../base-application/priorities.mjs'; import type { BaseGeneratorDefinition, GenericTaskGroup } from '../base/tasks.mjs'; import { detectCrLf } from './utils.mjs'; import { normalizeLineEndings } from '../base/support/index.mjs'; import command from './command.mjs'; -const { TRANSFORM, PRE_CONFLICTS } = PRIORITY_NAMES; +const { MULTISTEP_TRANSFORM, PRE_CONFLICTS } = PRIORITY_NAMES; +const { MULTISTEP_TRANSFORM_QUEUE } = QUEUES; const { createConflicterCheckTransform, createConflicterStatusTransform, @@ -45,11 +46,11 @@ const { patternSpy, } = environmentTransfrom; -const TRANSFORM_PRIORITY = BaseGenerator.asPriority(TRANSFORM); +const MULTISTEP_TRANSFORM_PRIORITY = BaseGenerator.asPriority(MULTISTEP_TRANSFORM); const PRE_CONFLICTS_PRIORITY = BaseGenerator.asPriority(PRE_CONFLICTS); export default class BootstrapGenerator extends BaseGenerator { - static TRANSFORM = TRANSFORM_PRIORITY; + static MULTISTEP_TRANSFORM = MULTISTEP_TRANSFORM_PRIORITY; static PRE_CONFLICTS = PRE_CONFLICTS_PRIORITY; @@ -88,16 +89,16 @@ export default class BootstrapGenerator extends BaseGenerator { return this.delegateTasksToBlueprint(() => this.initializing); } - get transform() { - return this.asWritingTaskGroup({ + get multistepTransform(): Record unknown | Promise> { + return { queueTransform() { this.queueMultistepTransform(); }, - }); + }; } - get [TRANSFORM_PRIORITY]() { - return this.transform; + get [MULTISTEP_TRANSFORM_PRIORITY]() { + return this.multistepTransform; } get preConflicts(): GenericTaskGroup { @@ -139,8 +140,9 @@ export default class BootstrapGenerator extends BaseGenerator { // eslint-disable-next-line @typescript-eslint/no-explicit-any return env.applyTransforms([new MultiStepTransform() as unknown as Transform], { stream } as any); }, - taskName: 'jhipster:transformStream', - queueName: 'transform', + taskName: MULTISTEP_TRANSFORM_QUEUE, + queueName: MULTISTEP_TRANSFORM_QUEUE, + once: true, }); }