yeoman-generator 7.2.0 → 7.3.1

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,24 @@ 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
+ const { taskPrefix = '' } = this.features;
109
+ propertyDescriptors = propertyDescriptors.filter(([name]) => name.startsWith(taskPrefix) && queueNames.includes(name.slice(taskPrefix.length)));
110
+ return Object.fromEntries(propertyDescriptors);
111
+ }
112
+ return Object.getOwnPropertyDescriptors(Object.getPrototypeOf(this));
113
+ }
96
114
  /**
97
115
  * Extract tasks from a priority.
98
116
  *
@@ -111,7 +129,9 @@ export class TasksMixin {
111
129
  }
112
130
  const { taskPrefix = this.features.taskPrefix ?? '' } = taskOptions;
113
131
  const propertyName = `${taskPrefix}${name}`;
114
- const property = Object.getOwnPropertyDescriptor(taskOptions.taskOrigin || Object.getPrototypeOf(this), propertyName);
132
+ const property = taskOptions.taskOrigin
133
+ ? Object.getOwnPropertyDescriptor(taskOptions.taskOrigin, propertyName)
134
+ : this.getTaskSourcesPropertyDescriptors()[propertyName];
115
135
  if (!property)
116
136
  return [];
117
137
  const item = property.value ?? property.get?.call(this);
@@ -157,7 +177,7 @@ export class TasksMixin {
157
177
  * Get task names.
158
178
  */
159
179
  getTaskNames() {
160
- const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(this));
180
+ const methods = Object.keys(this.getTaskSourcesPropertyDescriptors());
161
181
  let validMethods = methods.filter(method => methodIsValid(method));
162
182
  const { taskPrefix } = this.features;
163
183
  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.1",
4
4
  "description": "Rails-inspired generator system that provides scaffolding for your apps",
5
5
  "keywords": [
6
6
  "development",