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

Support for doc generator #1432

Merged
1 commit merged into from Mar 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/core/src/tasks/index.ts
Expand Up @@ -53,6 +53,7 @@ const _getTaskOption = ({ taskInstance }: TaskObj, provider?: string): TaskOptio
isGlobalScope: taskInstance.isGlobalScope,
isPrivate: taskInstance.isPrivate,
params: taskInstance.params,
providers: [],
};

if (taskInstance.description && taskInstance.description !== '') {
Expand All @@ -65,7 +66,7 @@ const _getTaskOption = ({ taskInstance }: TaskObj, provider?: string): TaskOptio
output.subCommand = asArray[1];

if (provider) {
output.provider = provider;
output.providers.push(provider);
}

return output;
Expand All @@ -90,18 +91,20 @@ const _getTaskObj = (taskInstance: RnvTask) => {
export const getAllSuitableTasks = (c: RnvContext): Record<string, TaskOption> => {
const REGISTERED_ENGINES = getRegisteredEngines(c);
const suitableTasks: Record<string, TaskOption> = {};

REGISTERED_ENGINES.forEach((engine) => {
Object.values(engine.tasks).forEach((taskInstance) => {
let taskObj: TaskOption = _getTaskOption(_getTaskObj(taskInstance), engine?.config?.id);
if (!suitableTasks[taskObj.value]) {
suitableTasks[taskObj.value] = taskObj;
} else {
taskObj = suitableTasks[taskObj.value];
// In case of multiple competing tasks (same task name but coming from different engines)
taskObj = suitableTasks[taskObj.value];
// We try to revert to generic description instead.
taskObj.description = DEFAULT_TASK_DESCRIPTIONS[taskObj.value] || taskObj.description;
// In case of multiple competing tasks we assume they are "commonly used"
taskObj.isPriorityOrder = true;
taskObj.providers.push(engine?.config?.id);
}
});
});
Expand Down Expand Up @@ -145,6 +148,7 @@ export const findSuitableTask = async (c: RnvContext, specificTask?: string): Pr
name: `${task.command}...`,
command: task.command,
value: task.command,
providers: [],
};
taskGroups[task.command] = groupTask;
groupedTasks.push(groupTask);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tasks/types.ts
Expand Up @@ -26,7 +26,7 @@ export type TaskOption = {
isGlobalScope?: boolean;
isPrivate?: boolean;
isPriorityOrder?: boolean;
provider?: string;
providers: string[];
params?: Array<RnvTaskParameter>;
};

Expand Down