yeoman-generator 7.2.0 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,6 +38,10 @@ export declare abstract class TasksMixin {
38
38
  * @param taskOptions options.
39
39
  */
40
40
  queueTaskGroup(this: BaseGeneratorImpl, taskGroup: Record<string, Task['method']>, taskOptions: TaskOptions): void;
41
+ /**
42
+ * Get task sources property descriptors.
43
+ */
44
+ getTaskSourcesPropertyDescriptors(this: BaseGeneratorImpl): any;
41
45
  /**
42
46
  * Extract tasks from a priority.
43
47
  *
@@ -93,6 +93,23 @@ export class TasksMixin {
93
93
  this.queueTask(task);
94
94
  }
95
95
  }
96
+ /**
97
+ * Get task sources property descriptors.
98
+ */
99
+ getTaskSourcesPropertyDescriptors() {
100
+ if (this.features.inheritTasks) {
101
+ const queueNames = Object.keys(this._queues);
102
+ let currentPrototype = Object.getPrototypeOf(this);
103
+ let propertyDescriptors = [];
104
+ while (currentPrototype) {
105
+ propertyDescriptors.unshift(...Object.entries(Object.getOwnPropertyDescriptors(currentPrototype)));
106
+ currentPrototype = Object.getPrototypeOf(currentPrototype);
107
+ }
108
+ propertyDescriptors = propertyDescriptors.filter(([name]) => queueNames.includes(name));
109
+ return Object.fromEntries(propertyDescriptors);
110
+ }
111
+ return Object.getOwnPropertyDescriptors(Object.getPrototypeOf(this));
112
+ }
96
113
  /**
97
114
  * Extract tasks from a priority.
98
115
  *
@@ -111,7 +128,9 @@ export class TasksMixin {
111
128
  }
112
129
  const { taskPrefix = this.features.taskPrefix ?? '' } = taskOptions;
113
130
  const propertyName = `${taskPrefix}${name}`;
114
- const property = Object.getOwnPropertyDescriptor(taskOptions.taskOrigin || Object.getPrototypeOf(this), propertyName);
131
+ const property = taskOptions.taskOrigin
132
+ ? Object.getOwnPropertyDescriptor(taskOptions.taskOrigin, propertyName)
133
+ : this.getTaskSourcesPropertyDescriptors()[propertyName];
115
134
  if (!property)
116
135
  return [];
117
136
  const item = property.value ?? property.get?.call(this);
@@ -157,7 +176,7 @@ export class TasksMixin {
157
176
  * Get task names.
158
177
  */
159
178
  getTaskNames() {
160
- const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(this));
179
+ const methods = Object.keys(this.getTaskSourcesPropertyDescriptors());
161
180
  let validMethods = methods.filter(method => methodIsValid(method));
162
181
  const { taskPrefix } = this.features;
163
182
  if (taskPrefix) {
package/dist/types.d.ts CHANGED
@@ -100,6 +100,9 @@ export type BaseFeatures = FeaturesApi & {
100
100
 
101
101
  /** Custom priorities for more fine tuned workflows. */
102
102
  customPriorities?: Priority[];
103
+
104
+ /** Inherit tasks from parent prototypes, implies tasksMatchingPriority */
105
+ inheritTasks?: boolean;
103
106
  };
104
107
 
105
108
  export type BaseOptions = OptionsApi & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeoman-generator",
3
- "version": "7.2.0",
3
+ "version": "7.3.0",
4
4
  "description": "Rails-inspired generator system that provides scaffolding for your apps",
5
5
  "keywords": [
6
6
  "development",