@yeoman/types 0.1.3 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeoman/types",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "description": "Common API for yeoman's generator/environment stack",
6
6
  "keywords": [
@@ -29,11 +29,13 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/inquirer": "^9.0.3",
32
- "mem-fs": "^3.0.0"
32
+ "mem-fs": "^3.0.0",
33
+ "mem-fs-editor": "^10.0.2"
33
34
  },
34
35
  "peerDependencies": {
35
36
  "@types/inquirer": "^9.0.3",
36
- "mem-fs": "^3.0.0"
37
+ "mem-fs": "^3.0.0",
38
+ "mem-fs-editor": "^10.0.2"
37
39
  },
38
40
  "peerDependenciesMeta": {
39
41
  "inquirer": {
@@ -41,6 +43,9 @@
41
43
  },
42
44
  "mem-fs": {
43
45
  "optional": true
46
+ },
47
+ "mem-fs-editor": {
48
+ "optional": true
44
49
  }
45
50
  },
46
51
  "engines": {
@@ -50,5 +55,5 @@
50
55
  "access": "public",
51
56
  "registry": "https://registry.npmjs.org/"
52
57
  },
53
- "gitHead": "ea9353672f5eaac702e0e024f954f43f193ca627"
58
+ "gitHead": "1982816cfe6af4e92f999e344cf9b8539ff308eb"
54
59
  }
@@ -36,14 +36,12 @@ export type InputOutputAdapter = {
36
36
  * Close underline inputs.
37
37
  */
38
38
  close(): void;
39
+ };
39
40
 
40
- /**
41
- * Shows a color-based diff of two strings.
42
- *
43
- * @param actual The actual text.
44
- * @param expected The expected text.
45
- * @param changes The changes returned by `diff`.
46
- * @returns The formatted message.
47
- */
48
- diff(actual: string, expected: string, changes: unknown[]): string;
41
+ type Task<TaskResultType> =
42
+ | ((adapter: InputOutputAdapter) => PromiseLike<TaskResultType>)
43
+ | ((adapter: InputOutputAdapter) => TaskResultType);
44
+
45
+ export type QueuedAdapter = InputOutputAdapter & {
46
+ queue<TaskResultType>(fn: Task<TaskResultType>): Promise<void | TaskResultType>;
49
47
  };
@@ -1,5 +1,6 @@
1
1
  import type { Transform } from 'node:stream';
2
2
  import type { Store } from 'mem-fs';
3
+ import type { MemFsEditorFile } from 'mem-fs-editor';
3
4
 
4
5
  import type { GeneratorBaseOptions } from '../generator/generator-options.js';
5
6
  import type { BaseGenerator } from '../generator/generator.js';
@@ -36,8 +37,8 @@ export type BaseEnvironmentOptions = GeneratorBaseOptions & {
36
37
  export type ApplyTransformsOptions = {
37
38
  name?: string;
38
39
  log?: boolean;
39
- stream?: ReturnType<Store['stream']>;
40
- streamOptions: Parameters<Store['stream']>[0];
40
+ stream?: ReturnType<Store<MemFsEditorFile>['stream']>;
41
+ streamOptions: Parameters<Store<MemFsEditorFile>['stream']>[0];
41
42
  };
42
43
 
43
44
  export type BaseEnvironment<A = InputOutputAdapter, S extends Store = Store> = {
@@ -114,7 +115,7 @@ export type BaseEnvironment<A = InputOutputAdapter, S extends Store = Store> = {
114
115
  * @param task
115
116
  * @param options
116
117
  */
117
- queueTask(priority: string, task: (...args: any[]) => void | Promise<void>, options?: { once?: string, startQueue?: boolean }): void;
118
+ queueTask(priority: string, task: (...args: any[]) => void | Promise<void>, options?: { once?: string; startQueue?: boolean }): void;
118
119
 
119
120
  /**
120
121
  * Add priority
@@ -3,7 +3,18 @@ import type { format } from 'node:util';
3
3
  /**
4
4
  * Provides default color-categories.
5
5
  */
6
- export type DefaultLoggerCategories = 'skip' | 'force' | 'create' | 'invoke' | 'conflict' | 'identical' | 'info';
6
+ export type DefaultLoggerCategories = 'skip' | 'force' | 'create' | 'invoke' | 'conflict' | 'identical' | 'info' | 'added' | 'removed';
7
+
8
+ export type ColoredMessage<Color extends string | number | symbol = DefaultLoggerCategories> = {
9
+ /**
10
+ * Text content.
11
+ */
12
+ message: string;
13
+ /**
14
+ * Color to apply.
15
+ */
16
+ color?: Color;
17
+ };
7
18
 
8
19
  /**
9
20
  * Provides the functionality to log messages.
@@ -50,4 +61,10 @@ export type Logger<LoggerCategories extends string | number | symbol = DefaultLo
50
61
  * Writes an error-message with a prepended cross mark.
51
62
  */
52
63
  error(...args: Parameters<typeof format>): Logger<LoggerCategories>;
64
+
65
+ /**
66
+ * @since `yeoman-environment` version 3.17.0
67
+ * Shows a colored message.
68
+ */
69
+ colored(coloredMessage: Array<ColoredMessage<LoggerCategories>>): Logger<LoggerCategories>;
53
70
  };