github-action-readme-generator 1.10.10 → 1.11.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/CHANGELOG.md +7 -0
- package/dist/mjs/constants.d.ts +3 -3
- package/dist/mjs/helpers.js.map +1 -1
- package/dist/mjs/inputs.js.map +1 -1
- package/dist/mjs/logtask/index.js.map +1 -1
- package/dist/mjs/prettier.js.map +1 -1
- package/dist/mjs/readme-editor.js.map +1 -1
- package/dist/mjs/readme-generator.js.map +1 -1
- package/dist/mjs/sections/index.js.map +1 -1
- package/dist/mjs/sections/update-branding.js.map +1 -1
- package/dist/mjs/svg-editor.mjs.map +1 -1
- package/dist/types/Action.d.ts +154 -0
- package/dist/types/config.d.ts +47 -0
- package/dist/types/constants.d.ts +105 -0
- package/dist/types/errors/error-type.d.ts +7 -0
- package/dist/types/errors/is-error.d.ts +8 -0
- package/dist/types/helpers.d.ts +93 -0
- package/dist/types/index.d.ts +4 -1106
- package/dist/types/inputs.d.ts +153 -0
- package/dist/types/logtask/index.d.ts +95 -0
- package/dist/types/markdowner/index.d.ts +61 -0
- package/dist/types/prettier.d.ts +31 -0
- package/dist/types/readme-editor.d.ts +50 -0
- package/dist/types/readme-generator.d.ts +57 -0
- package/dist/types/save.d.ts +13 -0
- package/dist/types/sections/index.d.ts +11 -0
- package/dist/types/sections/update-badges.d.ts +16 -0
- package/dist/types/sections/update-branding.d.ts +55 -0
- package/dist/types/sections/update-contents.d.ts +9 -0
- package/dist/types/sections/update-description.d.ts +10 -0
- package/dist/types/sections/update-inputs.d.ts +10 -0
- package/dist/types/sections/update-outputs.d.ts +11 -0
- package/dist/types/sections/update-title.d.ts +10 -0
- package/dist/types/sections/update-usage.d.ts +3 -0
- package/dist/types/svg-editor.d.mts +47 -0
- package/dist/types/unicode-word-match.d.ts +1 -0
- package/dist/types/util.d.ts +2 -0
- package/dist/types/working-directory.d.ts +6 -0
- package/package.json +3 -4
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { context as githubContext } from '@actions/github';
|
|
2
|
+
import nconf from 'nconf';
|
|
3
|
+
type Context = typeof githubContext;
|
|
4
|
+
declare const Context: new () => Context;
|
|
5
|
+
import Action, { type Input } from './Action.js';
|
|
6
|
+
import { type ReadmeSection } from './constants.js';
|
|
7
|
+
import LogTask from './logtask/index.js';
|
|
8
|
+
import ReadmeEditor from './readme-editor.js';
|
|
9
|
+
declare const Provider: typeof nconf.Provider;
|
|
10
|
+
type IOptions = nconf.IOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Change working directory to output of workingDirectory()
|
|
13
|
+
*/
|
|
14
|
+
export declare const metaActionPath = "../../action.yml";
|
|
15
|
+
export type ArgvOptionProperties = {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
alias: string | string[];
|
|
18
|
+
describe: string;
|
|
19
|
+
parseValues?: boolean;
|
|
20
|
+
type?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Interface for key/value pair object
|
|
25
|
+
*/
|
|
26
|
+
type KVPairType = {
|
|
27
|
+
key: string;
|
|
28
|
+
value: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Type alias for Provider instance
|
|
32
|
+
*/
|
|
33
|
+
type ProviderInstance = InstanceType<typeof Provider>;
|
|
34
|
+
export declare function transformGitHubInputsToArgv(log: LogTask, _config: ProviderInstance, obj: KVPairType): undefined | KVPairType;
|
|
35
|
+
/**
|
|
36
|
+
* Sets config value from action file default
|
|
37
|
+
*
|
|
38
|
+
* @param {Action} actionInstance - The action instance
|
|
39
|
+
* @param {string} inputName - The input name
|
|
40
|
+
* @returns {string | boolean | undefined} The default value
|
|
41
|
+
*/
|
|
42
|
+
export declare function setConfigValueFromActionFileDefault(log: LogTask, actionInstance: Action, inputName: string): string | boolean | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Collects all default values from action file
|
|
45
|
+
*
|
|
46
|
+
* @returns {IOptions} The default values object
|
|
47
|
+
*/
|
|
48
|
+
export declare function collectAllDefaultValuesFromAction(log: LogTask, providedMetaActionPath?: string, providedDefaults?: {
|
|
49
|
+
[key: string]: Input;
|
|
50
|
+
}): IOptions;
|
|
51
|
+
/**
|
|
52
|
+
* Loads the configuration
|
|
53
|
+
*
|
|
54
|
+
* @returns {ProviderInstance} The configuration instance
|
|
55
|
+
*/
|
|
56
|
+
export declare function loadConfig(log: LogTask, providedConfig?: ProviderInstance, configFilePath?: string): ProviderInstance;
|
|
57
|
+
/**
|
|
58
|
+
* Loads the default configuration
|
|
59
|
+
*
|
|
60
|
+
* @param {ProviderInstance} config - The config instance
|
|
61
|
+
* @returns {ProviderInstance} The updated config instance
|
|
62
|
+
*/
|
|
63
|
+
export declare function loadDefaultConfig(log: LogTask, config: ProviderInstance, providedContext?: Context): ProviderInstance;
|
|
64
|
+
/**
|
|
65
|
+
* Loads the required configuration
|
|
66
|
+
*
|
|
67
|
+
* @param {ProviderInstance} config - The config instance
|
|
68
|
+
* @returns {ProviderInstance} The updated config instance
|
|
69
|
+
*/
|
|
70
|
+
export declare function loadRequiredConfig(log: LogTask, config: ProviderInstance, requiredInputs?: readonly string[]): ProviderInstance;
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
export declare function loadAction(log: LogTask, actionPath: string): Action;
|
|
75
|
+
export type InputContext = {
|
|
76
|
+
/**
|
|
77
|
+
* The configuration instance
|
|
78
|
+
*/
|
|
79
|
+
config?: ProviderInstance;
|
|
80
|
+
/**
|
|
81
|
+
* The readme sections
|
|
82
|
+
*/
|
|
83
|
+
sections?: ReadmeSection[];
|
|
84
|
+
/**
|
|
85
|
+
* The readme file path
|
|
86
|
+
*/
|
|
87
|
+
readmePath?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The config file path
|
|
90
|
+
*/
|
|
91
|
+
configPath?: string;
|
|
92
|
+
/**
|
|
93
|
+
* The action instance
|
|
94
|
+
*/
|
|
95
|
+
action?: Action;
|
|
96
|
+
/**
|
|
97
|
+
* The readme editor instance
|
|
98
|
+
*/
|
|
99
|
+
readmeEditor?: ReadmeEditor;
|
|
100
|
+
/**
|
|
101
|
+
* The repository owner
|
|
102
|
+
*/
|
|
103
|
+
owner?: string;
|
|
104
|
+
/**
|
|
105
|
+
* The repository name
|
|
106
|
+
*/
|
|
107
|
+
repo?: string;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Main Inputs class that handles configuration
|
|
111
|
+
*/
|
|
112
|
+
export default class Inputs {
|
|
113
|
+
/**
|
|
114
|
+
* The configuration instance
|
|
115
|
+
*/
|
|
116
|
+
config: ProviderInstance;
|
|
117
|
+
/**
|
|
118
|
+
* The readme sections
|
|
119
|
+
*/
|
|
120
|
+
sections: ReadmeSection[];
|
|
121
|
+
/**
|
|
122
|
+
* The readme file path
|
|
123
|
+
*/
|
|
124
|
+
readmePath: string;
|
|
125
|
+
/**
|
|
126
|
+
* The config file path
|
|
127
|
+
*/
|
|
128
|
+
configPath: string;
|
|
129
|
+
/**
|
|
130
|
+
* The action instance
|
|
131
|
+
*/
|
|
132
|
+
action: Action;
|
|
133
|
+
/**
|
|
134
|
+
* The readme editor instance
|
|
135
|
+
*/
|
|
136
|
+
readmeEditor: ReadmeEditor;
|
|
137
|
+
/**
|
|
138
|
+
* The repository owner
|
|
139
|
+
*/
|
|
140
|
+
owner: string;
|
|
141
|
+
/**
|
|
142
|
+
* The repository name
|
|
143
|
+
*/
|
|
144
|
+
repo: string;
|
|
145
|
+
/** The logger for this instance */
|
|
146
|
+
log: LogTask;
|
|
147
|
+
/**
|
|
148
|
+
* Initializes a new instance of the Inputs class.
|
|
149
|
+
*/
|
|
150
|
+
constructor(providedInputContext?: InputContext, log?: LogTask);
|
|
151
|
+
stringify(): string;
|
|
152
|
+
}
|
|
153
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
declare enum LogGroup {
|
|
2
|
+
NO_GROUP = 0,
|
|
3
|
+
START_GROUP = 1,
|
|
4
|
+
END_GROUP = 2,
|
|
5
|
+
IS_ERROR = 3,
|
|
6
|
+
IS_FAILED = 4,
|
|
7
|
+
IS_TITLE = 5
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents a logging task with various log step methods.
|
|
11
|
+
*/
|
|
12
|
+
export default class LogTask {
|
|
13
|
+
/**
|
|
14
|
+
* Map of ingroup settings per task name.
|
|
15
|
+
*/
|
|
16
|
+
private static ingroupSettings;
|
|
17
|
+
/**
|
|
18
|
+
* The width of the indentation for log messages.
|
|
19
|
+
*/
|
|
20
|
+
private static indentWidth;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if debug mode is enabled.
|
|
23
|
+
* @returns A boolean indicating if debug mode is enabled.
|
|
24
|
+
*/
|
|
25
|
+
static isDebug(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The name of the task.
|
|
28
|
+
*/
|
|
29
|
+
private name;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new instance of the LogTask class.
|
|
32
|
+
* @param name - The name of the task.
|
|
33
|
+
*/
|
|
34
|
+
constructor(name: string);
|
|
35
|
+
/**
|
|
36
|
+
* Gets the ingroup setting for the task.
|
|
37
|
+
*/
|
|
38
|
+
get ingroup(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Sets the ingroup setting for this task.
|
|
41
|
+
*/
|
|
42
|
+
set ingroup(value: boolean);
|
|
43
|
+
getMessageString(step: string, desc: string, emojiStr: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Logs a step with the given emoji, type, message and group.
|
|
46
|
+
* @param emojiStr - The emoji string to display.
|
|
47
|
+
* @param step - The step type.
|
|
48
|
+
* @param message - The message of the step.
|
|
49
|
+
* @param startGroup - The start group type.
|
|
50
|
+
*/
|
|
51
|
+
logStep(emojiStr: string, step: string, message: string, startGroup?: LogGroup): void;
|
|
52
|
+
/**
|
|
53
|
+
* Logs a debug message.
|
|
54
|
+
* @param message - The message of the debug message.
|
|
55
|
+
*/
|
|
56
|
+
debug(message?: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Logs a start message.
|
|
59
|
+
* @param message - The message of the start message.
|
|
60
|
+
*/
|
|
61
|
+
start(message?: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Logs an info message.
|
|
64
|
+
* @param message - The message of the info message.
|
|
65
|
+
*/
|
|
66
|
+
info(message?: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Logs a warning message.
|
|
69
|
+
* @param message - The message of the warning message.
|
|
70
|
+
*/
|
|
71
|
+
warn(message?: string): void;
|
|
72
|
+
/**
|
|
73
|
+
* Logs a success message.
|
|
74
|
+
* @param message - The message of the success message.
|
|
75
|
+
* @param ingroup - Indicates whether the success message is in a group.
|
|
76
|
+
*/
|
|
77
|
+
success(message?: string, ingroup?: boolean): void;
|
|
78
|
+
/**
|
|
79
|
+
* Logs a failure message.
|
|
80
|
+
* @param message - The message of the failure message.
|
|
81
|
+
* @param ingroup - Indicates whether the failure message is in a group.
|
|
82
|
+
*/
|
|
83
|
+
fail(message?: string, ingroup?: boolean): void;
|
|
84
|
+
/**
|
|
85
|
+
* Logs an error message.
|
|
86
|
+
* @param message - The message of the error message.
|
|
87
|
+
*/
|
|
88
|
+
error(message?: string): void;
|
|
89
|
+
/**
|
|
90
|
+
* Logs a title message.
|
|
91
|
+
* @param message - The message of the title message.
|
|
92
|
+
*/
|
|
93
|
+
title(message?: string): void;
|
|
94
|
+
}
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types representing a 2D array of strings for a Markdown table.
|
|
3
|
+
*/
|
|
4
|
+
export type MarkdownArrayRowType = string[][];
|
|
5
|
+
export type MarkdownArrayItemType = string;
|
|
6
|
+
/**
|
|
7
|
+
* Fills a string to a desired width by padding with spaces.
|
|
8
|
+
*
|
|
9
|
+
* @param text - The text to pad.
|
|
10
|
+
* @param width - The desired total width.
|
|
11
|
+
* @param paddingStart - Number of spaces to pad at the start.
|
|
12
|
+
* @returns The padded string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function padString(text: string, width: number, paddingStart: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Escapes special Markdown characters in a string.
|
|
17
|
+
*
|
|
18
|
+
* @param text - The text to escape.
|
|
19
|
+
* @returns The escaped text.
|
|
20
|
+
*/
|
|
21
|
+
export declare function markdownEscapeTableCell(text: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Escapes inline code blocks in a Markdown string.
|
|
24
|
+
*
|
|
25
|
+
* @param content - Markdown string.
|
|
26
|
+
* @returns String with escaped inline code blocks.
|
|
27
|
+
*/
|
|
28
|
+
export declare function markdownEscapeInlineCode(content: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Clones a 2D array.
|
|
31
|
+
*
|
|
32
|
+
* @param arr - Array to clone.
|
|
33
|
+
* @returns Cloned array.
|
|
34
|
+
*/
|
|
35
|
+
export declare function cloneArray(arr: MarkdownArrayRowType): MarkdownArrayRowType;
|
|
36
|
+
/**
|
|
37
|
+
* Gets max and min column counts from 2D array.
|
|
38
|
+
*
|
|
39
|
+
* @param data - 2D string array.
|
|
40
|
+
* @returns Object with max and min cols.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getColumnCounts(data: MarkdownArrayRowType): {
|
|
43
|
+
maxCols: number;
|
|
44
|
+
minCols: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Pads 2D array rows to equal length.
|
|
48
|
+
*
|
|
49
|
+
* @param data - 2D array to pad.
|
|
50
|
+
* @param maxCols - Number of columns to pad to.
|
|
51
|
+
* @returns Padded 2D array.
|
|
52
|
+
*/
|
|
53
|
+
export declare function padArrayRows(data: MarkdownArrayRowType, maxCols: number): MarkdownArrayRowType;
|
|
54
|
+
/**
|
|
55
|
+
* Converts a 2D array of strings to a Markdown table.
|
|
56
|
+
*
|
|
57
|
+
* @param data - 2D string array.
|
|
58
|
+
* @returns Markdown table string.
|
|
59
|
+
*/
|
|
60
|
+
export declare function ArrayOfArraysToMarkdownTable(providedTableContent: MarkdownArrayRowType): string;
|
|
61
|
+
export default ArrayOfArraysToMarkdownTable;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code exports three functions: `formatYaml`, `formatMarkdown`, and `wrapDescription`.
|
|
3
|
+
*
|
|
4
|
+
* - `formatYaml` takes a YAML string and an optional filepath as parameters and uses the `prettier` library to format the YAML code. It returns the formatted YAML string.
|
|
5
|
+
* - `formatMarkdown` takes a Markdown string and an optional filepath as parameters and uses the `prettier` library to format the Markdown code. It returns the formatted Markdown string.
|
|
6
|
+
* - `wrapDescription` takes a string value, an array of content, and an optional prefix as parameters. It wraps the description text with the specified prefix and formats it using `prettier`. It returns the updated content array with the formatted description lines.
|
|
7
|
+
*
|
|
8
|
+
* The code utilizes the `prettier` library for code formatting and the `LogTask` class for logging purposes.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Formats a YAML string using `prettier`.
|
|
12
|
+
* @param {string} value - The YAML string to format.
|
|
13
|
+
* @param {string} [filepath] - The optional filepath.
|
|
14
|
+
* @returns {Promise<string>} A promise that resolves with the formatted YAML string.
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatYaml(value: string, filepath?: string): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Formats a Markdown string using `prettier`.
|
|
19
|
+
* @param {string} value - The Markdown string to format.
|
|
20
|
+
* @param {string} [filepath] - The optional filepath.
|
|
21
|
+
* @returns {Promise<string>} A promise that resolves with the formatted Markdown string.
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatMarkdown(value: string, filepath?: string): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Wraps a description text with a prefix and formats it using `prettier`.
|
|
26
|
+
* @param {string | undefined} value - The description text to wrap and format.
|
|
27
|
+
* @param {string[]} content - The array of content to update.
|
|
28
|
+
* @param {string} [prefix=' # '] - The optional prefix to wrap the description lines.
|
|
29
|
+
* @returns {Promise<string[]>} A promise that resolves with the updated content array.
|
|
30
|
+
*/
|
|
31
|
+
export declare function wrapDescription(value: string | undefined, content: string[], prefix?: string): Promise<string[]>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code imports the necessary modules and defines a class named `ReadmeEditor`.
|
|
3
|
+
* The class represents an editor for modifying a README file.
|
|
4
|
+
* It has methods to update specific sections within the file and dump the modified content back to the file.
|
|
5
|
+
*/
|
|
6
|
+
import LogTask from './logtask/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* The format for the start token of a section.
|
|
9
|
+
*/
|
|
10
|
+
export declare const startTokenFormat = "(^|[^`\\\\])<!--\\s+start\\s+%s\\s+-->";
|
|
11
|
+
/**
|
|
12
|
+
* The format for the end token of a section.
|
|
13
|
+
*/
|
|
14
|
+
export declare const endTokenFormat = "(^|[^`\\\\])<!--\\s+end\\s+%s\\s+-->";
|
|
15
|
+
export default class ReadmeEditor {
|
|
16
|
+
private log;
|
|
17
|
+
/**
|
|
18
|
+
* The path to the README file.
|
|
19
|
+
*/
|
|
20
|
+
private readonly filePath;
|
|
21
|
+
private fileContent;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new instance of `ReadmeEditor`.
|
|
24
|
+
* @param {string} filePath - The path to the README file.
|
|
25
|
+
*/
|
|
26
|
+
constructor(filePath: string);
|
|
27
|
+
/**
|
|
28
|
+
* Gets the current README content.
|
|
29
|
+
* @returns {string} - The README file content.
|
|
30
|
+
*/
|
|
31
|
+
getReadmeContent(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the indexes of the start and end tokens for a given section.
|
|
34
|
+
* @param {string} token - The section token.
|
|
35
|
+
* @returns {number[]} - The indexes of the start and end tokens.
|
|
36
|
+
*/
|
|
37
|
+
getTokenIndexes(token: string, logTask?: LogTask): number[];
|
|
38
|
+
/**
|
|
39
|
+
* Updates a specific section in the README file with the provided content.
|
|
40
|
+
* @param {string} name - The name of the section.
|
|
41
|
+
* @param {string | string[]} providedContent - The content to update the section with.
|
|
42
|
+
* @param {boolean} addNewlines - Whether to add newlines before and after the content.
|
|
43
|
+
*/
|
|
44
|
+
updateSection(name: string, providedContent: string | string[], addNewlines?: boolean): void;
|
|
45
|
+
/**
|
|
46
|
+
* Dumps the modified content back to the README file.
|
|
47
|
+
* @returns {Promise<void>}
|
|
48
|
+
*/
|
|
49
|
+
dumpToFile(): Promise<void>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code imports various modules and defines a function named 'generateDocs'.
|
|
3
|
+
* The function is responsible for generating documentation for the README.md file based on the provided inputs.
|
|
4
|
+
* It iterates through each section defined in the 'inputs.sections' array and calls the 'updateSection' function to update the corresponding section in the README.md file.
|
|
5
|
+
* If an error occurs during the update of a section, it logs the error message and stops the process.
|
|
6
|
+
* Finally, it saves the updated README.md file and calls the 'save' function.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReadmeSection } from './constants.js';
|
|
9
|
+
import type Inputs from './inputs.js';
|
|
10
|
+
import type LogTask from './logtask/index.js';
|
|
11
|
+
export type SectionKV = Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Class for managing README generation.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ReadmeGenerator {
|
|
16
|
+
/**
|
|
17
|
+
* The Inputs instance.
|
|
18
|
+
*/
|
|
19
|
+
private inputs;
|
|
20
|
+
/**
|
|
21
|
+
* The Logger instance.
|
|
22
|
+
*/
|
|
23
|
+
private log;
|
|
24
|
+
/**
|
|
25
|
+
* Initializes the ReadmeGenerator.
|
|
26
|
+
*
|
|
27
|
+
* @param inputs - The Inputs instance
|
|
28
|
+
* @param log - The Logger instance
|
|
29
|
+
*/
|
|
30
|
+
constructor(inputs: Inputs, log: LogTask);
|
|
31
|
+
/**
|
|
32
|
+
* Updates the README sections.
|
|
33
|
+
*
|
|
34
|
+
* @param sections - The sections array
|
|
35
|
+
* @returns Promise array of section KV objects
|
|
36
|
+
*/
|
|
37
|
+
updateSections(sections: ReadmeSection[]): Promise<SectionKV>[];
|
|
38
|
+
/**
|
|
39
|
+
* Resolves the section update promises.
|
|
40
|
+
*
|
|
41
|
+
* @param promises - The promise array
|
|
42
|
+
* @returns Promise resolving to combined sections KV
|
|
43
|
+
*/
|
|
44
|
+
resolveUpdates(promises: Promise<SectionKV>[]): Promise<SectionKV>;
|
|
45
|
+
/**
|
|
46
|
+
* Outputs the sections KV to GitHub output.
|
|
47
|
+
*
|
|
48
|
+
* @param sections - The sections KV
|
|
49
|
+
*/
|
|
50
|
+
outputSections(sections: SectionKV): void;
|
|
51
|
+
/**
|
|
52
|
+
* Generates the README documentation.
|
|
53
|
+
*
|
|
54
|
+
* @returns Promise resolving when done
|
|
55
|
+
*/
|
|
56
|
+
generate(providedSections?: ReadmeSection[]): Promise<void>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code exports a function named 'save' which takes an instance of the 'Inputs' class as its parameter.
|
|
3
|
+
* The function reads the configuration inputs from the 'inputs' parameter and uses them to create a new instance of the 'GHActionDocsConfig' class.
|
|
4
|
+
* If the 'save' property is set to true in the configuration inputs, the function saves the configuration to the file specified in the 'configPath' property of the 'inputs' parameter.
|
|
5
|
+
* This script is used to update the usage section in the README.md file to match the contents of the action.yml file.
|
|
6
|
+
*/
|
|
7
|
+
import type Inputs from './inputs.js';
|
|
8
|
+
import type LogTask from './logtask/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* This script rebuilds the usage section in the README.md to be consistent with the action.yml
|
|
11
|
+
* @param {Inputs} inputs - the inputs class
|
|
12
|
+
*/
|
|
13
|
+
export default function save(inputs: Inputs, log: LogTask): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code exports a function named 'updateSection' which takes a section (ReadmeSection) and an instance of the 'Inputs' class as its parameters.
|
|
3
|
+
* The function is responsible for updating different sections of the README.md file based on the provided section input.
|
|
4
|
+
* It utilizes various update functions (e.g., updateBranding, updateBadges) to update specific sections.
|
|
5
|
+
* @param {ReadmeSection} section - The section of the README to update.
|
|
6
|
+
* @param {Inputs} inputs - The Inputs class instance.
|
|
7
|
+
* @returns {Promise<void>} A promise that resolves once the section is updated.
|
|
8
|
+
*/
|
|
9
|
+
import type { ReadmeSection } from '../constants.js';
|
|
10
|
+
import type Inputs from '../inputs.js';
|
|
11
|
+
export default function updateSection(section: ReadmeSection, inputs: Inputs): Promise<Record<string, string>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code imports necessary modules and defines a function named 'updateBadges' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.
|
|
3
|
+
* The function is responsible for updating the badges section in the README.md file based on the provided inputs.
|
|
4
|
+
* It utilizes the 'LogTask' class for logging purposes.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReadmeSection } from '../constants.js';
|
|
7
|
+
import type Inputs from '../inputs.js';
|
|
8
|
+
/**
|
|
9
|
+
* Interface for a badge.
|
|
10
|
+
*/
|
|
11
|
+
export interface IBadge {
|
|
12
|
+
alt: string;
|
|
13
|
+
img: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}
|
|
16
|
+
export default function updateBadges(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { FeatherIconNames } from 'feather-icons';
|
|
2
|
+
import type { BrandColors } from '../constants.js';
|
|
3
|
+
import { type ReadmeSection } from '../constants.js';
|
|
4
|
+
import type Inputs from '../inputs.js';
|
|
5
|
+
export interface IBranding {
|
|
6
|
+
alt: string;
|
|
7
|
+
img: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Generates a svg branding image.
|
|
12
|
+
* example:
|
|
13
|
+
* ```ts
|
|
14
|
+
* generateSvgImage('/path/to/file.svg', 'home', 'red')
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param svgPath - The path to where the svg file will be saved
|
|
18
|
+
* @param icon - The icon name from the feather-icons list
|
|
19
|
+
* @param bgcolor - The background color of the circle behind the icon
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateSvgImage(svgPath: string, icon: Partial<FeatherIconNames>, bgcolor: Partial<BrandColors>): void;
|
|
22
|
+
/**
|
|
23
|
+
* This function returns a valid icon name based on the provided branding.
|
|
24
|
+
* If the branding is undefined or not a valid icon name, an error is thrown.
|
|
25
|
+
* It checks if the branding icon is present in the GITHUB_ACTIONS_BRANDING_ICONS set,
|
|
26
|
+
* and if so, returns the corresponding feather icon key array.
|
|
27
|
+
* If the branding icon is present in the GITHUB_ACTIONS_OMITTED_ICONS set,
|
|
28
|
+
* an error is thrown specifying that the icon is part of the omitted icons list.
|
|
29
|
+
* If the branding icon is not a valid icon from the feather-icons list, an error is thrown.
|
|
30
|
+
* @param brand - The branding object
|
|
31
|
+
* @returns The corresponding feather icon key array
|
|
32
|
+
* @throws Error if the branding icon is undefined, not a valid icon name, or part of the omitted icons list
|
|
33
|
+
*/
|
|
34
|
+
export declare function getValidIconName(icon?: Partial<FeatherIconNames>): FeatherIconNames;
|
|
35
|
+
/**
|
|
36
|
+
* This function generates an HTML image markup with branding information.
|
|
37
|
+
* It takes inputs and an optional width parameter.
|
|
38
|
+
* If the branding_svg_path is provided, it generates an action.yml branding image for the specified icon and color.
|
|
39
|
+
* Otherwise, it returns an error message.
|
|
40
|
+
*
|
|
41
|
+
* @param inputs - The inputs instance with data for the function.
|
|
42
|
+
* @param width - The width of the image (default is '15%').
|
|
43
|
+
* @returns The HTML image markup with branding information or an error message.
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateImgMarkup(inputs: Inputs, width?: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* This is a TypeScript function named "updateBranding" that takes in a sectionToken string and an object of inputs.
|
|
48
|
+
* It exports the function as the default export.
|
|
49
|
+
* The function logs the brand details from the inputs, starts a log task, generates image markup,
|
|
50
|
+
* updates a section in the readme editor using the sectionToken and content, and logs success or failure messages.
|
|
51
|
+
*
|
|
52
|
+
* @param sectionToken - The sectionToken string that is used to identify the section in the readme editor.
|
|
53
|
+
* @param inputs - The inputs object that contains data for the function.
|
|
54
|
+
*/
|
|
55
|
+
export default function updateBranding(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code exports a function named 'updateContents' which generates
|
|
3
|
+
* a table of contents from the README.md headers.
|
|
4
|
+
* @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
|
|
5
|
+
* @param {Inputs} inputs - The Inputs class instance.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReadmeSection } from '../constants.js';
|
|
8
|
+
import type Inputs from '../inputs.js';
|
|
9
|
+
export default function updateContents(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code exports a function named 'updateDescription' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.
|
|
3
|
+
* The function is responsible for updating the description section in the README.md file based on the provided inputs.
|
|
4
|
+
* It utilizes the 'LogTask' class for logging purposes.
|
|
5
|
+
* @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
|
|
6
|
+
* @param {Inputs} inputs - The Inputs class instance.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReadmeSection } from '../constants.js';
|
|
9
|
+
import type Inputs from '../inputs.js';
|
|
10
|
+
export default function updateDescription(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code exports a function named 'updateInputs' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.
|
|
3
|
+
* The function is responsible for updating the inputs section in the README.md file based on the provided inputs.
|
|
4
|
+
* It utilizes the 'LogTask' class for logging purposes, 'columnHeader' and 'rowHeader' functions from '../helpers.js' for formatting table headers, and 'markdowner' function from '../markdowner/index.js' for generating markdown content.
|
|
5
|
+
* @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
|
|
6
|
+
* @param {Inputs} inputs - The Inputs class instance.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReadmeSection } from '../constants.js';
|
|
9
|
+
import type Inputs from '../inputs.js';
|
|
10
|
+
export default function updateInputs(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code exports a function named 'updateOutputs' which takes a sectionToken (string) and an instance of the 'Inputs' class as its parameters.
|
|
3
|
+
* The function is responsible for updating the outputs section in the README.md file based on the provided inputs.
|
|
4
|
+
* It generates a table with three columns: Output name, Description, and Value (for composite actions).
|
|
5
|
+
* It utilizes the 'LogTask' class for logging purposes, 'columnHeader' and 'rowHeader' functions from '../helpers.js' for formatting table headers, and 'markdowner' function from '../markdowner/index.js' for generating markdown content.
|
|
6
|
+
* @param {ReadmeSection} sectionToken - The sectionToken used for identifying the section.
|
|
7
|
+
* @param {Inputs} inputs - The Inputs class instance.
|
|
8
|
+
*/
|
|
9
|
+
import type { ReadmeSection } from '../constants.js';
|
|
10
|
+
import type Inputs from '../inputs.js';
|
|
11
|
+
export default function updateOutputs(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code exports a function named 'updateTitle' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.
|
|
3
|
+
* The function is responsible for updating the title section in the README.md file based on the provided inputs.
|
|
4
|
+
* It utilizes the 'LogTask' class for logging purposes, the 'generateImgMarkup' function from './update-branding.js' for generating image markup.
|
|
5
|
+
* @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
|
|
6
|
+
* @param {Inputs} inputs - The Inputs class instance.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReadmeSection } from '../constants.js';
|
|
9
|
+
import type Inputs from '../inputs.js';
|
|
10
|
+
export default function updateTitle(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This TypeScript code imports necessary modules and defines a class named 'SVGEditor' for generating SVG images.
|
|
3
|
+
* The class has methods for initializing the SVG window, generating SVG content, and writing SVG files.
|
|
4
|
+
* It utilizes various packages such as 'fs', 'path', '@svgdotjs/svg.js', 'feather-icons', and 'svgdom' for SVG manipulation and file operations.
|
|
5
|
+
* The class also defines interfaces for badges and brand colors.
|
|
6
|
+
*/
|
|
7
|
+
import type { FeatherIconNames } from 'feather-icons';
|
|
8
|
+
import type { BrandColors } from './constants.js';
|
|
9
|
+
/**
|
|
10
|
+
* Utility class for generating SVG images.
|
|
11
|
+
*/
|
|
12
|
+
export default class SVGEditor {
|
|
13
|
+
private log;
|
|
14
|
+
private window?;
|
|
15
|
+
private canvas?;
|
|
16
|
+
private document?;
|
|
17
|
+
/**
|
|
18
|
+
* Initializes a new SVGEditor instance.
|
|
19
|
+
*/
|
|
20
|
+
constructor();
|
|
21
|
+
/**
|
|
22
|
+
* Initializes the SVG window, document, and canvas if not already set up.
|
|
23
|
+
*/
|
|
24
|
+
initSVG(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Generates a branded SVG image.
|
|
27
|
+
* @param {string | undefined} svgPath - Path to write the generated SVG file to.
|
|
28
|
+
* @param {Partial<FeatherIconNames>} icon - Name of the icon to use.
|
|
29
|
+
* @param {Partial<BrandColors>} bgcolor - Background color for the image.
|
|
30
|
+
* @returns {Promise<void>} A promise that resolves when the image is generated.
|
|
31
|
+
*/
|
|
32
|
+
generateSvgImage(svgPath: string | undefined, icon?: Partial<FeatherIconNames>, bgcolor?: Partial<BrandColors>): void;
|
|
33
|
+
/**
|
|
34
|
+
* Writes the SVG xml to disk.
|
|
35
|
+
* @param {string} svgPath - File path to save the SVG to.
|
|
36
|
+
* @param {string} svgContent - The XML for the SVG file.
|
|
37
|
+
*/
|
|
38
|
+
writeSVGFile(svgPath: string, svgContent: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Generates the SVG content for the branding image.
|
|
41
|
+
* @param {FeatherIconNames} icon - Name of the icon to use.
|
|
42
|
+
* @param {BrandColors} color - Background color for the image.
|
|
43
|
+
* @param {number} outerViewBox - Size of the canvas for the image.
|
|
44
|
+
* @returns {string} The generated SVG content.
|
|
45
|
+
*/
|
|
46
|
+
generateSVGContent(icon: FeatherIconNames, color: BrandColors, outerViewBox?: number): string;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const unicodeWordMatch: RegExp;
|