Skip to content

Commit

Permalink
move multistep transform to a dedicated priority
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Feb 12, 2023
1 parent 3424cec commit 7a6bf10
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
6 changes: 3 additions & 3 deletions generators/base-application/priorities.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down Expand Up @@ -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();
Expand Down
19 changes: 15 additions & 4 deletions generators/base/priorities.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;

Expand Down Expand Up @@ -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),
},
{
Expand Down Expand Up @@ -147,8 +155,9 @@ export const PRIORITY_NAMES = {

DEFAULT,
WRITING,
TRANSFORM,
MULTISTEP_TRANSFORM,
POST_WRITING,
TRANSFORM,
PRE_CONFLICTS,
INSTALL,
POST_INSTALL,
Expand All @@ -165,8 +174,9 @@ export const PRIORITY_NAMES_LIST = [

DEFAULT,
WRITING,
TRANSFORM,
MULTISTEP_TRANSFORM,
POST_WRITING,
TRANSFORM,
INSTALL,
POST_INSTALL,
END,
Expand All @@ -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,
Expand Down
24 changes: 13 additions & 11 deletions generators/bootstrap/generator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand Down Expand Up @@ -88,16 +89,16 @@ export default class BootstrapGenerator extends BaseGenerator {
return this.delegateTasksToBlueprint(() => this.initializing);
}

get transform() {
return this.asWritingTaskGroup({
get multistepTransform(): Record<string, (this: this) => unknown | Promise<unknown>> {
return {
queueTransform() {
this.queueMultistepTransform();
},
});
};
}

get [TRANSFORM_PRIORITY]() {
return this.transform;
get [MULTISTEP_TRANSFORM_PRIORITY]() {
return this.multistepTransform;
}

get preConflicts(): GenericTaskGroup<this, BaseGeneratorDefinition['preConflictsTaskParam']> {
Expand Down Expand Up @@ -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,
});
}

Expand Down

0 comments on commit 7a6bf10

Please sign in to comment.