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
package/dist/types/index.d.ts
CHANGED
|
@@ -1,1106 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare module "__tests__/action.constants" {
|
|
6
|
-
export const actTestYmlPath = "./action.test.yml";
|
|
7
|
-
export const actionTestString = "name: Test Action\nauthor: Test Author\ndescription: Test Description\nbranding:\n color: white\n icon: activity\ninputs:\n input1:\n description: Test Input 1\n required: true\n default: default1\n input2:\n description: Test Input 2\noutputs:\n output1:\n description: Test Output 1\nruns:\n using: container\n image: test-image\n main: test-main\n pre: test-pre\n";
|
|
8
|
-
export const ghadocsTestString = "{\n \"owner\": \"user-from-config\",\n \"repo\": \"repo-from-config\",\n \"paths\": {\n \"action\": \"action.test-config.yml\",\n \"readme\": \"README.test-config.md\"\n },\n \"branding_svg_path\": \".github/ghadocs/branding-config.svg\",\n \"versioning\": {\n \"enabled\": true,\n \"prefix\": \"config\",\n \"override\": \"\",\n \"branch\": \"config\"\n }\n}\n";
|
|
9
|
-
export const gitConfigTestString = "[remote \"origin\"]\nurl = https://github.com/ownergit/repogit.git\n";
|
|
10
|
-
export const payloadTestString = "{\n \"action\": \"opened\",\n \"repository\": {\n \"owner\": {\n \"login\": \"userpayload\"\n },\n \"name\": \"testpayload\"\n },\n \"issue\": {\n \"number\": 1\n },\n \"sender\": {\n \"type\": \"User\"\n }\n}";
|
|
11
|
-
}
|
|
12
|
-
declare module "__mocks__/node:fs" {
|
|
13
|
-
import type { BigIntStats, PathLike, PathOrFileDescriptor, Stats, StatSyncOptions } from 'node:fs';
|
|
14
|
-
export type { BigIntStats, PathLike, PathOrFileDescriptor, Stats, StatSyncOptions } from 'node:fs';
|
|
15
|
-
export const statSync: import("vitest").Mock<(path: PathLike, options?: StatSyncOptions | undefined) => Stats | BigIntStats | undefined>;
|
|
16
|
-
export const existsSync: import("vitest").Mock<(filename: PathLike) => boolean>;
|
|
17
|
-
export const readFileSync: import("vitest").Mock<(filename: PathOrFileDescriptor) => string | Buffer>;
|
|
18
|
-
}
|
|
19
|
-
declare module "src/util" {
|
|
20
|
-
export type Nullable<T> = T | null | undefined;
|
|
21
|
-
export function notEmpty(str: Nullable<string>): str is string;
|
|
22
|
-
}
|
|
23
|
-
declare module "src/logtask/index" {
|
|
24
|
-
enum LogGroup {
|
|
25
|
-
NO_GROUP = 0,
|
|
26
|
-
START_GROUP = 1,
|
|
27
|
-
END_GROUP = 2,
|
|
28
|
-
IS_ERROR = 3,
|
|
29
|
-
IS_FAILED = 4,
|
|
30
|
-
IS_TITLE = 5
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Represents a logging task with various log step methods.
|
|
34
|
-
*/
|
|
35
|
-
export default class LogTask {
|
|
36
|
-
/**
|
|
37
|
-
* Map of ingroup settings per task name.
|
|
38
|
-
*/
|
|
39
|
-
private static ingroupSettings;
|
|
40
|
-
/**
|
|
41
|
-
* The width of the indentation for log messages.
|
|
42
|
-
*/
|
|
43
|
-
private static indentWidth;
|
|
44
|
-
/**
|
|
45
|
-
* Checks if debug mode is enabled.
|
|
46
|
-
* @returns A boolean indicating if debug mode is enabled.
|
|
47
|
-
*/
|
|
48
|
-
static isDebug(): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* The name of the task.
|
|
51
|
-
*/
|
|
52
|
-
private name;
|
|
53
|
-
/**
|
|
54
|
-
* Creates a new instance of the LogTask class.
|
|
55
|
-
* @param name - The name of the task.
|
|
56
|
-
*/
|
|
57
|
-
constructor(name: string);
|
|
58
|
-
/**
|
|
59
|
-
* Gets the ingroup setting for the task.
|
|
60
|
-
*/
|
|
61
|
-
get ingroup(): boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Sets the ingroup setting for this task.
|
|
64
|
-
*/
|
|
65
|
-
set ingroup(value: boolean);
|
|
66
|
-
getMessageString(step: string, desc: string, emojiStr: string): string;
|
|
67
|
-
/**
|
|
68
|
-
* Logs a step with the given emoji, type, message and group.
|
|
69
|
-
* @param emojiStr - The emoji string to display.
|
|
70
|
-
* @param step - The step type.
|
|
71
|
-
* @param message - The message of the step.
|
|
72
|
-
* @param startGroup - The start group type.
|
|
73
|
-
*/
|
|
74
|
-
logStep(emojiStr: string, step: string, message: string, startGroup?: LogGroup): void;
|
|
75
|
-
/**
|
|
76
|
-
* Logs a debug message.
|
|
77
|
-
* @param message - The message of the debug message.
|
|
78
|
-
*/
|
|
79
|
-
debug(message?: string): void;
|
|
80
|
-
/**
|
|
81
|
-
* Logs a start message.
|
|
82
|
-
* @param message - The message of the start message.
|
|
83
|
-
*/
|
|
84
|
-
start(message?: string): void;
|
|
85
|
-
/**
|
|
86
|
-
* Logs an info message.
|
|
87
|
-
* @param message - The message of the info message.
|
|
88
|
-
*/
|
|
89
|
-
info(message?: string): void;
|
|
90
|
-
/**
|
|
91
|
-
* Logs a warning message.
|
|
92
|
-
* @param message - The message of the warning message.
|
|
93
|
-
*/
|
|
94
|
-
warn(message?: string): void;
|
|
95
|
-
/**
|
|
96
|
-
* Logs a success message.
|
|
97
|
-
* @param message - The message of the success message.
|
|
98
|
-
* @param ingroup - Indicates whether the success message is in a group.
|
|
99
|
-
*/
|
|
100
|
-
success(message?: string, ingroup?: boolean): void;
|
|
101
|
-
/**
|
|
102
|
-
* Logs a failure message.
|
|
103
|
-
* @param message - The message of the failure message.
|
|
104
|
-
* @param ingroup - Indicates whether the failure message is in a group.
|
|
105
|
-
*/
|
|
106
|
-
fail(message?: string, ingroup?: boolean): void;
|
|
107
|
-
/**
|
|
108
|
-
* Logs an error message.
|
|
109
|
-
* @param message - The message of the error message.
|
|
110
|
-
*/
|
|
111
|
-
error(message?: string): void;
|
|
112
|
-
/**
|
|
113
|
-
* Logs a title message.
|
|
114
|
-
* @param message - The message of the title message.
|
|
115
|
-
*/
|
|
116
|
-
title(message?: string): void;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
declare module "src/constants" {
|
|
120
|
-
/**
|
|
121
|
-
* Represents the Feather icon names.
|
|
122
|
-
*/
|
|
123
|
-
import type { FeatherIconNames } from 'feather-icons';
|
|
124
|
-
/**
|
|
125
|
-
* Represents the sections of the README.
|
|
126
|
-
*/
|
|
127
|
-
export const README_SECTIONS: readonly ["title", "branding", "description", "usage", "inputs", "outputs", "contents", "badges"];
|
|
128
|
-
/**
|
|
129
|
-
* Represents a single section of the README.
|
|
130
|
-
*/
|
|
131
|
-
export type ReadmeSection = (typeof README_SECTIONS)[number];
|
|
132
|
-
/**
|
|
133
|
-
* Represents the file name for the configuration file.
|
|
134
|
-
*/
|
|
135
|
-
export const configFileName = ".ghadocs.json";
|
|
136
|
-
/**
|
|
137
|
-
* Enumerates the keys for the configuration options.
|
|
138
|
-
*/
|
|
139
|
-
/**
|
|
140
|
-
* Valid version source options for determining action version.
|
|
141
|
-
*/
|
|
142
|
-
export const VERSION_SOURCES: readonly ["git-tag", "git-branch", "git-sha", "package-json", "explicit"];
|
|
143
|
-
/**
|
|
144
|
-
* Type for version source options.
|
|
145
|
-
*/
|
|
146
|
-
export type VersionSource = (typeof VERSION_SOURCES)[number];
|
|
147
|
-
/**
|
|
148
|
-
* Checks if the given value is a valid version source.
|
|
149
|
-
*/
|
|
150
|
-
export function isValidVersionSource(value: string): value is VersionSource;
|
|
151
|
-
export enum ConfigKeys {
|
|
152
|
-
Owner = "owner",
|
|
153
|
-
Repo = "repo",
|
|
154
|
-
TitlePrefix = "title_prefix",
|
|
155
|
-
Prettier = "prettier",
|
|
156
|
-
Save = "save",
|
|
157
|
-
pathsAction = "paths:action",
|
|
158
|
-
pathsReadme = "paths:readme",
|
|
159
|
-
BrandingSvgPath = "branding_svg_path",
|
|
160
|
-
BrandingAsTitlePrefix = "branding_as_title_prefix",
|
|
161
|
-
VersioningEnabled = "versioning:enabled",
|
|
162
|
-
VersioningOverride = "versioning:override",
|
|
163
|
-
VersioningPrefix = "versioning:prefix",
|
|
164
|
-
VersioningBranch = "versioning:branch",
|
|
165
|
-
VersioningSource = "versioning:source",
|
|
166
|
-
IncludeGithubVersionBadge = "versioning:badge",
|
|
167
|
-
DebugNconf = "debug:nconf",
|
|
168
|
-
DebugReadme = "debug:readme",
|
|
169
|
-
DebugConfig = "debug:config",
|
|
170
|
-
DebugAction = "debug:action",
|
|
171
|
-
DebugGithub = "debug:github"
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Represents the edge length (in pixels) for the branding square.
|
|
175
|
-
*/
|
|
176
|
-
export const brandingSquareEdgeLengthInPixels = 50;
|
|
177
|
-
/**
|
|
178
|
-
* Represents the default brand color.
|
|
179
|
-
*/
|
|
180
|
-
export const DEFAULT_BRAND_COLOR = "blue";
|
|
181
|
-
/**
|
|
182
|
-
* Represents the default brand icon.
|
|
183
|
-
*/
|
|
184
|
-
export const DEFAULT_BRAND_ICON = "activity";
|
|
185
|
-
/**
|
|
186
|
-
* Represents the markup for center alignment.
|
|
187
|
-
*/
|
|
188
|
-
export const ALIGNMENT_MARKUP = "<div align=\"center\">";
|
|
189
|
-
/**
|
|
190
|
-
* Represents the set of icons that are omitted in GitHub Actions branding.
|
|
191
|
-
*/
|
|
192
|
-
export const GITHUB_ACTIONS_OMITTED_ICONS: Set<string>;
|
|
193
|
-
/**
|
|
194
|
-
* Represents the set of icons available for GitHub Actions branding.
|
|
195
|
-
*/
|
|
196
|
-
export const GITHUB_ACTIONS_BRANDING_ICONS: Set<string>;
|
|
197
|
-
/**
|
|
198
|
-
* Represents the available colors for GitHub Actions branding.
|
|
199
|
-
*/
|
|
200
|
-
export const GITHUB_ACTIONS_BRANDING_COLORS: readonly ["white", "yellow", "blue", "green", "orange", "red", "purple", "gray-dark"];
|
|
201
|
-
/**
|
|
202
|
-
* Represents the available brand colors.
|
|
203
|
-
*/
|
|
204
|
-
export type BrandColors = (typeof GITHUB_ACTIONS_BRANDING_COLORS)[number];
|
|
205
|
-
/**
|
|
206
|
-
* Checks if the given icon is valid for GitHub Actions branding.
|
|
207
|
-
* @param {Partial<FeatherIconNames>} icon - The icon to validate.
|
|
208
|
-
* @returns A boolean indicating if the icon is valid.
|
|
209
|
-
*/
|
|
210
|
-
export function isValidIcon(icon: Partial<FeatherIconNames>): icon is FeatherIconNames;
|
|
211
|
-
/**
|
|
212
|
-
* Checks if the given color is valid for GitHub Actions branding.
|
|
213
|
-
* @param {Partial<BrandColors>} color - The color to validate.
|
|
214
|
-
* @returns A boolean indicating if the color is valid.
|
|
215
|
-
*/
|
|
216
|
-
export function isValidColor(color: Partial<BrandColors>): color is BrandColors;
|
|
217
|
-
/**
|
|
218
|
-
* Represents the branding information for the action.
|
|
219
|
-
*/
|
|
220
|
-
export interface Branding {
|
|
221
|
-
/** Color for the action branding */
|
|
222
|
-
color: Partial<BrandColors>;
|
|
223
|
-
icon: Partial<FeatherIconNames>;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
declare module "src/Action" {
|
|
227
|
-
import { type Branding } from "src/constants";
|
|
228
|
-
import LogTask from "src/logtask/index";
|
|
229
|
-
/**
|
|
230
|
-
* Represents an input for the action.
|
|
231
|
-
*/
|
|
232
|
-
export type Input = {
|
|
233
|
-
/** Description of the input */
|
|
234
|
-
description: string;
|
|
235
|
-
/** Whether the input is required */
|
|
236
|
-
required?: boolean;
|
|
237
|
-
/** Default value for the input */
|
|
238
|
-
default?: string;
|
|
239
|
-
/** Optional If the input parameter is used, this string is this.logged as a warning message. You can use this warning to notify users that the input is deprecated and mention any alternatives. */
|
|
240
|
-
deprecationMessage?: string;
|
|
241
|
-
};
|
|
242
|
-
/**
|
|
243
|
-
* Represents an output for the action.
|
|
244
|
-
*/
|
|
245
|
-
export interface Output {
|
|
246
|
-
/** Description of the output */
|
|
247
|
-
description?: string;
|
|
248
|
-
value?: string;
|
|
249
|
-
}
|
|
250
|
-
type CompositeAction = 'composite';
|
|
251
|
-
type ContainerAction = 'docker';
|
|
252
|
-
type JavascriptAction = `Node${string}` | `node${string}`;
|
|
253
|
-
/**
|
|
254
|
-
* Defines the runs property for container actions.
|
|
255
|
-
*/
|
|
256
|
-
type RunsContainer = {
|
|
257
|
-
using: ContainerAction;
|
|
258
|
-
image: string;
|
|
259
|
-
args?: string[];
|
|
260
|
-
'pre-entrypoint'?: string;
|
|
261
|
-
'post-entrypoint'?: string;
|
|
262
|
-
entrypoint?: string;
|
|
263
|
-
};
|
|
264
|
-
/**
|
|
265
|
-
* Defines the runs property for JavaScript actions.
|
|
266
|
-
*/
|
|
267
|
-
type RunsJavascript = {
|
|
268
|
-
/** The runner used to execute the action */
|
|
269
|
-
using: JavascriptAction;
|
|
270
|
-
/** The entrypoint file for the action */
|
|
271
|
-
main: string;
|
|
272
|
-
pre?: string;
|
|
273
|
-
'pre-if'?: string;
|
|
274
|
-
'post-if'?: string;
|
|
275
|
-
post?: string;
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* Defines the steps property for composite actions.
|
|
279
|
-
*/
|
|
280
|
-
type Steps = {
|
|
281
|
-
shell?: string;
|
|
282
|
-
if?: string;
|
|
283
|
-
run?: string;
|
|
284
|
-
name?: string;
|
|
285
|
-
id?: string;
|
|
286
|
-
'working-directory'?: string;
|
|
287
|
-
env: {
|
|
288
|
-
[key: string]: string;
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
|
-
/**
|
|
292
|
-
* Defines the runs property for composite actions.
|
|
293
|
-
*/
|
|
294
|
-
type RunsComposite = {
|
|
295
|
-
/** The runner used to execute the action */
|
|
296
|
-
using: CompositeAction;
|
|
297
|
-
steps: Steps;
|
|
298
|
-
};
|
|
299
|
-
export type ActionType = RunsContainer | RunsJavascript | RunsComposite;
|
|
300
|
-
/**
|
|
301
|
-
* Defines how the action is run.
|
|
302
|
-
*/
|
|
303
|
-
export type ActionYaml = {
|
|
304
|
-
name: string;
|
|
305
|
-
author?: string;
|
|
306
|
-
/** Description of the action */
|
|
307
|
-
description: string;
|
|
308
|
-
/** Branding information */
|
|
309
|
-
branding?: Branding;
|
|
310
|
-
/** Input definitions */
|
|
311
|
-
inputs?: {
|
|
312
|
-
[key: string]: Input;
|
|
313
|
-
};
|
|
314
|
-
/** Output definitions */
|
|
315
|
-
outputs?: {
|
|
316
|
-
[key: string]: Output;
|
|
317
|
-
};
|
|
318
|
-
/** How the action is run */
|
|
319
|
-
runs: ActionType;
|
|
320
|
-
/** Path to the action */
|
|
321
|
-
path: string;
|
|
322
|
-
};
|
|
323
|
-
/**
|
|
324
|
-
* Parses and represents metadata from action.yml.
|
|
325
|
-
*/
|
|
326
|
-
export default class Action implements ActionYaml {
|
|
327
|
-
static validate(obj: unknown): obj is ActionType;
|
|
328
|
-
log: LogTask;
|
|
329
|
-
/** Name of the action */
|
|
330
|
-
name: string;
|
|
331
|
-
author?: string;
|
|
332
|
-
/** Description of the action */
|
|
333
|
-
description: string;
|
|
334
|
-
/** Branding information */
|
|
335
|
-
branding?: Branding;
|
|
336
|
-
/** Input definitions */
|
|
337
|
-
inputs?: {
|
|
338
|
-
[key: string]: Input;
|
|
339
|
-
};
|
|
340
|
-
/** Output definitions */
|
|
341
|
-
outputs?: {
|
|
342
|
-
[key: string]: Output;
|
|
343
|
-
};
|
|
344
|
-
/** How the action is run */
|
|
345
|
-
runs: ActionType;
|
|
346
|
-
/** Path to the action */
|
|
347
|
-
path: string;
|
|
348
|
-
/** the original file content */
|
|
349
|
-
rawYamlString: string;
|
|
350
|
-
/**
|
|
351
|
-
* Creates a new instance of the Action class by loading and parsing action.yml.
|
|
352
|
-
*
|
|
353
|
-
* @param actionPath The path to the action.yml file.
|
|
354
|
-
*/
|
|
355
|
-
constructor(actionPath: string, log?: LogTask);
|
|
356
|
-
loadActionFrom(actionPath: string): ActionYaml;
|
|
357
|
-
/**
|
|
358
|
-
* Gets the value of an input.
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Gets the default value for an input.
|
|
363
|
-
*
|
|
364
|
-
* @param inputName The name of the input.
|
|
365
|
-
* @returns The default value if defined,or undefined
|
|
366
|
-
*/
|
|
367
|
-
inputDefault(inputName: string): string | boolean | undefined;
|
|
368
|
-
/**
|
|
369
|
-
* Stringifies the action back to YAML.
|
|
370
|
-
*
|
|
371
|
-
* @returns The YAML string for debugging.
|
|
372
|
-
*/
|
|
373
|
-
stringify(): string;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
declare module "__tests__/action.test" { }
|
|
377
|
-
declare module "__tests__/constants.test" { }
|
|
378
|
-
declare module "__tests__/env.test" { }
|
|
379
|
-
declare module "src/prettier" {
|
|
380
|
-
/**
|
|
381
|
-
* Formats a YAML string using `prettier`.
|
|
382
|
-
* @param {string} value - The YAML string to format.
|
|
383
|
-
* @param {string} [filepath] - The optional filepath.
|
|
384
|
-
* @returns {Promise<string>} A promise that resolves with the formatted YAML string.
|
|
385
|
-
*/
|
|
386
|
-
export function formatYaml(value: string, filepath?: string): Promise<string>;
|
|
387
|
-
/**
|
|
388
|
-
* Formats a Markdown string using `prettier`.
|
|
389
|
-
* @param {string} value - The Markdown string to format.
|
|
390
|
-
* @param {string} [filepath] - The optional filepath.
|
|
391
|
-
* @returns {Promise<string>} A promise that resolves with the formatted Markdown string.
|
|
392
|
-
*/
|
|
393
|
-
export function formatMarkdown(value: string, filepath?: string): Promise<string>;
|
|
394
|
-
/**
|
|
395
|
-
* Wraps a description text with a prefix and formats it using `prettier`.
|
|
396
|
-
* @param {string | undefined} value - The description text to wrap and format.
|
|
397
|
-
* @param {string[]} content - The array of content to update.
|
|
398
|
-
* @param {string} [prefix=' # '] - The optional prefix to wrap the description lines.
|
|
399
|
-
* @returns {Promise<string[]>} A promise that resolves with the updated content array.
|
|
400
|
-
*/
|
|
401
|
-
export function wrapDescription(value: string | undefined, content: string[], prefix?: string): Promise<string[]>;
|
|
402
|
-
}
|
|
403
|
-
declare module "src/readme-editor" {
|
|
404
|
-
import LogTask from "src/logtask/index";
|
|
405
|
-
/**
|
|
406
|
-
* The format for the start token of a section.
|
|
407
|
-
*/
|
|
408
|
-
export const startTokenFormat = "(^|[^`\\\\])<!--\\s+start\\s+%s\\s+-->";
|
|
409
|
-
/**
|
|
410
|
-
* The format for the end token of a section.
|
|
411
|
-
*/
|
|
412
|
-
export const endTokenFormat = "(^|[^`\\\\])<!--\\s+end\\s+%s\\s+-->";
|
|
413
|
-
export default class ReadmeEditor {
|
|
414
|
-
private log;
|
|
415
|
-
/**
|
|
416
|
-
* The path to the README file.
|
|
417
|
-
*/
|
|
418
|
-
private readonly filePath;
|
|
419
|
-
private fileContent;
|
|
420
|
-
/**
|
|
421
|
-
* Creates a new instance of `ReadmeEditor`.
|
|
422
|
-
* @param {string} filePath - The path to the README file.
|
|
423
|
-
*/
|
|
424
|
-
constructor(filePath: string);
|
|
425
|
-
/**
|
|
426
|
-
* Gets the current README content.
|
|
427
|
-
* @returns {string} - The README file content.
|
|
428
|
-
*/
|
|
429
|
-
getReadmeContent(): string;
|
|
430
|
-
/**
|
|
431
|
-
* Gets the indexes of the start and end tokens for a given section.
|
|
432
|
-
* @param {string} token - The section token.
|
|
433
|
-
* @returns {number[]} - The indexes of the start and end tokens.
|
|
434
|
-
*/
|
|
435
|
-
getTokenIndexes(token: string, logTask?: LogTask): number[];
|
|
436
|
-
/**
|
|
437
|
-
* Updates a specific section in the README file with the provided content.
|
|
438
|
-
* @param {string} name - The name of the section.
|
|
439
|
-
* @param {string | string[]} providedContent - The content to update the section with.
|
|
440
|
-
* @param {boolean} addNewlines - Whether to add newlines before and after the content.
|
|
441
|
-
*/
|
|
442
|
-
updateSection(name: string, providedContent: string | string[], addNewlines?: boolean): void;
|
|
443
|
-
/**
|
|
444
|
-
* Dumps the modified content back to the README file.
|
|
445
|
-
* @returns {Promise<void>}
|
|
446
|
-
*/
|
|
447
|
-
dumpToFile(): Promise<void>;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
declare module "src/inputs" {
|
|
451
|
-
import { context as githubContext } from '@actions/github';
|
|
452
|
-
import nconf from 'nconf';
|
|
453
|
-
type Context = typeof githubContext;
|
|
454
|
-
const Context: new () => Context;
|
|
455
|
-
import Action, { type Input } from "src/Action";
|
|
456
|
-
import { type ReadmeSection } from "src/constants";
|
|
457
|
-
import LogTask from "src/logtask/index";
|
|
458
|
-
import ReadmeEditor from "src/readme-editor";
|
|
459
|
-
const Provider: typeof nconf.Provider;
|
|
460
|
-
type IOptions = nconf.IOptions;
|
|
461
|
-
/**
|
|
462
|
-
* Change working directory to output of workingDirectory()
|
|
463
|
-
*/
|
|
464
|
-
export const metaActionPath = "../../action.yml";
|
|
465
|
-
export type ArgvOptionProperties = {
|
|
466
|
-
[key: string]: {
|
|
467
|
-
alias: string | string[];
|
|
468
|
-
describe: string;
|
|
469
|
-
parseValues?: boolean;
|
|
470
|
-
type?: string;
|
|
471
|
-
};
|
|
472
|
-
};
|
|
473
|
-
/**
|
|
474
|
-
* Interface for key/value pair object
|
|
475
|
-
*/
|
|
476
|
-
type KVPairType = {
|
|
477
|
-
key: string;
|
|
478
|
-
value: string | undefined;
|
|
479
|
-
};
|
|
480
|
-
/**
|
|
481
|
-
* Type alias for Provider instance
|
|
482
|
-
*/
|
|
483
|
-
type ProviderInstance = InstanceType<typeof Provider>;
|
|
484
|
-
export function transformGitHubInputsToArgv(log: LogTask, _config: ProviderInstance, obj: KVPairType): undefined | KVPairType;
|
|
485
|
-
/**
|
|
486
|
-
* Sets config value from action file default
|
|
487
|
-
*
|
|
488
|
-
* @param {Action} actionInstance - The action instance
|
|
489
|
-
* @param {string} inputName - The input name
|
|
490
|
-
* @returns {string | boolean | undefined} The default value
|
|
491
|
-
*/
|
|
492
|
-
export function setConfigValueFromActionFileDefault(log: LogTask, actionInstance: Action, inputName: string): string | boolean | undefined;
|
|
493
|
-
/**
|
|
494
|
-
* Collects all default values from action file
|
|
495
|
-
*
|
|
496
|
-
* @returns {IOptions} The default values object
|
|
497
|
-
*/
|
|
498
|
-
export function collectAllDefaultValuesFromAction(log: LogTask, providedMetaActionPath?: string, providedDefaults?: {
|
|
499
|
-
[key: string]: Input;
|
|
500
|
-
}): IOptions;
|
|
501
|
-
/**
|
|
502
|
-
* Loads the configuration
|
|
503
|
-
*
|
|
504
|
-
* @returns {ProviderInstance} The configuration instance
|
|
505
|
-
*/
|
|
506
|
-
export function loadConfig(log: LogTask, providedConfig?: ProviderInstance, configFilePath?: string): ProviderInstance;
|
|
507
|
-
/**
|
|
508
|
-
* Loads the default configuration
|
|
509
|
-
*
|
|
510
|
-
* @param {ProviderInstance} config - The config instance
|
|
511
|
-
* @returns {ProviderInstance} The updated config instance
|
|
512
|
-
*/
|
|
513
|
-
export function loadDefaultConfig(log: LogTask, config: ProviderInstance, providedContext?: Context): ProviderInstance;
|
|
514
|
-
/**
|
|
515
|
-
* Loads the required configuration
|
|
516
|
-
*
|
|
517
|
-
* @param {ProviderInstance} config - The config instance
|
|
518
|
-
* @returns {ProviderInstance} The updated config instance
|
|
519
|
-
*/
|
|
520
|
-
export function loadRequiredConfig(log: LogTask, config: ProviderInstance, requiredInputs?: readonly string[]): ProviderInstance;
|
|
521
|
-
/**
|
|
522
|
-
*
|
|
523
|
-
*/
|
|
524
|
-
export function loadAction(log: LogTask, actionPath: string): Action;
|
|
525
|
-
export type InputContext = {
|
|
526
|
-
/**
|
|
527
|
-
* The configuration instance
|
|
528
|
-
*/
|
|
529
|
-
config?: ProviderInstance;
|
|
530
|
-
/**
|
|
531
|
-
* The readme sections
|
|
532
|
-
*/
|
|
533
|
-
sections?: ReadmeSection[];
|
|
534
|
-
/**
|
|
535
|
-
* The readme file path
|
|
536
|
-
*/
|
|
537
|
-
readmePath?: string;
|
|
538
|
-
/**
|
|
539
|
-
* The config file path
|
|
540
|
-
*/
|
|
541
|
-
configPath?: string;
|
|
542
|
-
/**
|
|
543
|
-
* The action instance
|
|
544
|
-
*/
|
|
545
|
-
action?: Action;
|
|
546
|
-
/**
|
|
547
|
-
* The readme editor instance
|
|
548
|
-
*/
|
|
549
|
-
readmeEditor?: ReadmeEditor;
|
|
550
|
-
/**
|
|
551
|
-
* The repository owner
|
|
552
|
-
*/
|
|
553
|
-
owner?: string;
|
|
554
|
-
/**
|
|
555
|
-
* The repository name
|
|
556
|
-
*/
|
|
557
|
-
repo?: string;
|
|
558
|
-
};
|
|
559
|
-
/**
|
|
560
|
-
* Main Inputs class that handles configuration
|
|
561
|
-
*/
|
|
562
|
-
export default class Inputs {
|
|
563
|
-
/**
|
|
564
|
-
* The configuration instance
|
|
565
|
-
*/
|
|
566
|
-
config: ProviderInstance;
|
|
567
|
-
/**
|
|
568
|
-
* The readme sections
|
|
569
|
-
*/
|
|
570
|
-
sections: ReadmeSection[];
|
|
571
|
-
/**
|
|
572
|
-
* The readme file path
|
|
573
|
-
*/
|
|
574
|
-
readmePath: string;
|
|
575
|
-
/**
|
|
576
|
-
* The config file path
|
|
577
|
-
*/
|
|
578
|
-
configPath: string;
|
|
579
|
-
/**
|
|
580
|
-
* The action instance
|
|
581
|
-
*/
|
|
582
|
-
action: Action;
|
|
583
|
-
/**
|
|
584
|
-
* The readme editor instance
|
|
585
|
-
*/
|
|
586
|
-
readmeEditor: ReadmeEditor;
|
|
587
|
-
/**
|
|
588
|
-
* The repository owner
|
|
589
|
-
*/
|
|
590
|
-
owner: string;
|
|
591
|
-
/**
|
|
592
|
-
* The repository name
|
|
593
|
-
*/
|
|
594
|
-
repo: string;
|
|
595
|
-
/** The logger for this instance */
|
|
596
|
-
log: LogTask;
|
|
597
|
-
/**
|
|
598
|
-
* Initializes a new instance of the Inputs class.
|
|
599
|
-
*/
|
|
600
|
-
constructor(providedInputContext?: InputContext, log?: LogTask);
|
|
601
|
-
stringify(): string;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
declare module "src/unicode-word-match" {
|
|
605
|
-
export const unicodeWordMatch: RegExp;
|
|
606
|
-
}
|
|
607
|
-
declare module "src/helpers" {
|
|
608
|
-
import { context } from '@actions/github';
|
|
609
|
-
import type Inputs from "src/inputs";
|
|
610
|
-
import LogTask from "src/logtask/index";
|
|
611
|
-
import { type Nullable } from "src/util";
|
|
612
|
-
type Context = typeof context;
|
|
613
|
-
/**
|
|
614
|
-
* Returns the input value if it is not empty, otherwise returns undefined.
|
|
615
|
-
* @param value - The input value to check.
|
|
616
|
-
* @returns The input value if it is not empty, otherwise undefined.
|
|
617
|
-
*/
|
|
618
|
-
export function undefinedOnEmpty(value: string | undefined): string | undefined;
|
|
619
|
-
/**
|
|
620
|
-
* Returns the basename of the given path.
|
|
621
|
-
* @param pathStr - The path to extract the basename from.
|
|
622
|
-
* @returns The basename of the path.
|
|
623
|
-
*/
|
|
624
|
-
export function basename(pathStr: string): string | undefined;
|
|
625
|
-
/**
|
|
626
|
-
* Removes the "refs/heads/" or "refs/tags/" prefix from the given path.
|
|
627
|
-
*
|
|
628
|
-
* @param pathStr - The path to remove the prefix from
|
|
629
|
-
* @returns The path without the prefix, or null if path is empty
|
|
630
|
-
*/
|
|
631
|
-
export function stripRefs(pathStr: string): string | null;
|
|
632
|
-
/**
|
|
633
|
-
* Converts the given text to title case.
|
|
634
|
-
* @param text - The text to convert.
|
|
635
|
-
* @returns The text converted to title case.
|
|
636
|
-
* @throws {TypeError} If the input is not a string.
|
|
637
|
-
*/
|
|
638
|
-
export function titlecase(text: string): string | undefined;
|
|
639
|
-
/**
|
|
640
|
-
* Parses the given text and converts it to title case, replacing underscores and dashes with spaces.
|
|
641
|
-
* @param text - The text to parse and convert.
|
|
642
|
-
* @returns The parsed text converted to title case.
|
|
643
|
-
*/
|
|
644
|
-
export function prefixParser(text: string | undefined): string | undefined;
|
|
645
|
-
/**
|
|
646
|
-
* Wraps the given text into multiple lines with a maximum width of 80 characters.
|
|
647
|
-
* @param text - The text to wrap.
|
|
648
|
-
* @param content - The array to store the wrapped lines.
|
|
649
|
-
* @param prepend - The string to prepend to each wrapped line.
|
|
650
|
-
* @returns The array of wrapped lines.
|
|
651
|
-
*/
|
|
652
|
-
export function wrapText(text: string | undefined, content: string[], prepend?: string): string[];
|
|
653
|
-
/**
|
|
654
|
-
* Represents a repository with owner and repo properties.
|
|
655
|
-
*/
|
|
656
|
-
export interface Repo {
|
|
657
|
-
owner: string;
|
|
658
|
-
repo: string;
|
|
659
|
-
}
|
|
660
|
-
export function readFile(filename: string): string;
|
|
661
|
-
export function repoObjFromRepoName(repository: Nullable<string>, log: LogTask, from?: string): Nullable<Repo>;
|
|
662
|
-
export const remoteGitUrlPattern: RegExp;
|
|
663
|
-
/**
|
|
664
|
-
* Finds the repository information from the input, context, environment variables, or git configuration.
|
|
665
|
-
* @param inputRepo - The input repository string.
|
|
666
|
-
* @param context - The GitHub context object.
|
|
667
|
-
* @param baseDir - Optional base directory to look for .git/config (defaults to CWD).
|
|
668
|
-
* @returns The repository information (owner and repo) or null if not found.
|
|
669
|
-
*/
|
|
670
|
-
export function repositoryFinder(inputRepo: Nullable<string>, context: Nullable<Context>, baseDir?: string): Repo | null;
|
|
671
|
-
/**
|
|
672
|
-
* Returns the default branch of the git repository.
|
|
673
|
-
* @returns The default branch.
|
|
674
|
-
*/
|
|
675
|
-
/**
|
|
676
|
-
* Gets the default branch for the Git repository.
|
|
677
|
-
*
|
|
678
|
-
* @returns The name of the default branch.
|
|
679
|
-
*/
|
|
680
|
-
export function getDefaultGitBranch(): string;
|
|
681
|
-
/**
|
|
682
|
-
* Formats the given value as a column header.
|
|
683
|
-
* @param value - The value to format.
|
|
684
|
-
* @returns The formatted column header.
|
|
685
|
-
*/
|
|
686
|
-
export function columnHeader(value: string): string;
|
|
687
|
-
/**
|
|
688
|
-
* Formats the given value as a row header in HTML.
|
|
689
|
-
*
|
|
690
|
-
* Removes formatting from the string and converts it to bold code style.
|
|
691
|
-
*
|
|
692
|
-
* @param value - The string to format as a header
|
|
693
|
-
* @returns The formatted row header string wrapped in bold and code tags
|
|
694
|
-
*/
|
|
695
|
-
export function rowHeader(value: string): string;
|
|
696
|
-
export function getCurrentVersionString(inputs: Inputs): string;
|
|
697
|
-
export function indexOfRegex(str: string, providedRegex: RegExp): number;
|
|
698
|
-
export function lastIndexOfRegex(str: string, providedRegex: RegExp): number;
|
|
699
|
-
export function isObject(value: unknown): value is object;
|
|
700
|
-
}
|
|
701
|
-
declare module "__tests__/helpers.test" { }
|
|
702
|
-
declare module "__tests__/inputs.test" { }
|
|
703
|
-
declare module "__tests__/integration-bundled-binary.test" { }
|
|
704
|
-
declare module "src/sections/update-badges" {
|
|
705
|
-
/**
|
|
706
|
-
* 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.
|
|
707
|
-
* The function is responsible for updating the badges section in the README.md file based on the provided inputs.
|
|
708
|
-
* It utilizes the 'LogTask' class for logging purposes.
|
|
709
|
-
*/
|
|
710
|
-
import type { ReadmeSection } from "src/constants";
|
|
711
|
-
import type Inputs from "src/inputs";
|
|
712
|
-
/**
|
|
713
|
-
* Interface for a badge.
|
|
714
|
-
*/
|
|
715
|
-
export interface IBadge {
|
|
716
|
-
alt: string;
|
|
717
|
-
img: string;
|
|
718
|
-
url?: string;
|
|
719
|
-
}
|
|
720
|
-
export default function updateBadges(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
721
|
-
}
|
|
722
|
-
declare module "src/svg-editor" {
|
|
723
|
-
import type { FeatherIconNames } from 'feather-icons';
|
|
724
|
-
import type { BrandColors } from "src/constants";
|
|
725
|
-
/**
|
|
726
|
-
* Utility class for generating SVG images.
|
|
727
|
-
*/
|
|
728
|
-
export default class SVGEditor {
|
|
729
|
-
private log;
|
|
730
|
-
private window?;
|
|
731
|
-
private canvas?;
|
|
732
|
-
private document?;
|
|
733
|
-
/**
|
|
734
|
-
* Initializes a new SVGEditor instance.
|
|
735
|
-
*/
|
|
736
|
-
constructor();
|
|
737
|
-
/**
|
|
738
|
-
* Initializes the SVG window, document, and canvas if not already set up.
|
|
739
|
-
*/
|
|
740
|
-
initSVG(): void;
|
|
741
|
-
/**
|
|
742
|
-
* Generates a branded SVG image.
|
|
743
|
-
* @param {string | undefined} svgPath - Path to write the generated SVG file to.
|
|
744
|
-
* @param {Partial<FeatherIconNames>} icon - Name of the icon to use.
|
|
745
|
-
* @param {Partial<BrandColors>} bgcolor - Background color for the image.
|
|
746
|
-
* @returns {Promise<void>} A promise that resolves when the image is generated.
|
|
747
|
-
*/
|
|
748
|
-
generateSvgImage(svgPath: string | undefined, icon?: Partial<FeatherIconNames>, bgcolor?: Partial<BrandColors>): void;
|
|
749
|
-
/**
|
|
750
|
-
* Writes the SVG xml to disk.
|
|
751
|
-
* @param {string} svgPath - File path to save the SVG to.
|
|
752
|
-
* @param {string} svgContent - The XML for the SVG file.
|
|
753
|
-
*/
|
|
754
|
-
writeSVGFile(svgPath: string, svgContent: string): void;
|
|
755
|
-
/**
|
|
756
|
-
* Generates the SVG content for the branding image.
|
|
757
|
-
* @param {FeatherIconNames} icon - Name of the icon to use.
|
|
758
|
-
* @param {BrandColors} color - Background color for the image.
|
|
759
|
-
* @param {number} outerViewBox - Size of the canvas for the image.
|
|
760
|
-
* @returns {string} The generated SVG content.
|
|
761
|
-
*/
|
|
762
|
-
generateSVGContent(icon: FeatherIconNames, color: BrandColors, outerViewBox?: number): string;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
declare module "src/sections/update-branding" {
|
|
766
|
-
import type { FeatherIconNames } from 'feather-icons';
|
|
767
|
-
import type { BrandColors } from "src/constants";
|
|
768
|
-
import { type ReadmeSection } from "src/constants";
|
|
769
|
-
import type Inputs from "src/inputs";
|
|
770
|
-
export interface IBranding {
|
|
771
|
-
alt: string;
|
|
772
|
-
img: string;
|
|
773
|
-
url?: string;
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Generates a svg branding image.
|
|
777
|
-
* example:
|
|
778
|
-
* ```ts
|
|
779
|
-
* generateSvgImage('/path/to/file.svg', 'home', 'red')
|
|
780
|
-
* ```
|
|
781
|
-
*
|
|
782
|
-
* @param svgPath - The path to where the svg file will be saved
|
|
783
|
-
* @param icon - The icon name from the feather-icons list
|
|
784
|
-
* @param bgcolor - The background color of the circle behind the icon
|
|
785
|
-
*/
|
|
786
|
-
export function generateSvgImage(svgPath: string, icon: Partial<FeatherIconNames>, bgcolor: Partial<BrandColors>): void;
|
|
787
|
-
/**
|
|
788
|
-
* This function returns a valid icon name based on the provided branding.
|
|
789
|
-
* If the branding is undefined or not a valid icon name, an error is thrown.
|
|
790
|
-
* It checks if the branding icon is present in the GITHUB_ACTIONS_BRANDING_ICONS set,
|
|
791
|
-
* and if so, returns the corresponding feather icon key array.
|
|
792
|
-
* If the branding icon is present in the GITHUB_ACTIONS_OMITTED_ICONS set,
|
|
793
|
-
* an error is thrown specifying that the icon is part of the omitted icons list.
|
|
794
|
-
* If the branding icon is not a valid icon from the feather-icons list, an error is thrown.
|
|
795
|
-
* @param brand - The branding object
|
|
796
|
-
* @returns The corresponding feather icon key array
|
|
797
|
-
* @throws Error if the branding icon is undefined, not a valid icon name, or part of the omitted icons list
|
|
798
|
-
*/
|
|
799
|
-
export function getValidIconName(icon?: Partial<FeatherIconNames>): FeatherIconNames;
|
|
800
|
-
/**
|
|
801
|
-
* This function generates an HTML image markup with branding information.
|
|
802
|
-
* It takes inputs and an optional width parameter.
|
|
803
|
-
* If the branding_svg_path is provided, it generates an action.yml branding image for the specified icon and color.
|
|
804
|
-
* Otherwise, it returns an error message.
|
|
805
|
-
*
|
|
806
|
-
* @param inputs - The inputs instance with data for the function.
|
|
807
|
-
* @param width - The width of the image (default is '15%').
|
|
808
|
-
* @returns The HTML image markup with branding information or an error message.
|
|
809
|
-
*/
|
|
810
|
-
export function generateImgMarkup(inputs: Inputs, width?: string): string;
|
|
811
|
-
/**
|
|
812
|
-
* This is a TypeScript function named "updateBranding" that takes in a sectionToken string and an object of inputs.
|
|
813
|
-
* It exports the function as the default export.
|
|
814
|
-
* The function logs the brand details from the inputs, starts a log task, generates image markup,
|
|
815
|
-
* updates a section in the readme editor using the sectionToken and content, and logs success or failure messages.
|
|
816
|
-
*
|
|
817
|
-
* @param sectionToken - The sectionToken string that is used to identify the section in the readme editor.
|
|
818
|
-
* @param inputs - The inputs object that contains data for the function.
|
|
819
|
-
*/
|
|
820
|
-
export default function updateBranding(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
821
|
-
}
|
|
822
|
-
declare module "src/sections/update-contents" {
|
|
823
|
-
/**
|
|
824
|
-
* This TypeScript code exports a function named 'updateContents' which generates
|
|
825
|
-
* a table of contents from the README.md headers.
|
|
826
|
-
* @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
|
|
827
|
-
* @param {Inputs} inputs - The Inputs class instance.
|
|
828
|
-
*/
|
|
829
|
-
import type { ReadmeSection } from "src/constants";
|
|
830
|
-
import type Inputs from "src/inputs";
|
|
831
|
-
export default function updateContents(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
832
|
-
}
|
|
833
|
-
declare module "src/sections/update-description" {
|
|
834
|
-
/**
|
|
835
|
-
* This TypeScript code exports a function named 'updateDescription' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.
|
|
836
|
-
* The function is responsible for updating the description section in the README.md file based on the provided inputs.
|
|
837
|
-
* It utilizes the 'LogTask' class for logging purposes.
|
|
838
|
-
* @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
|
|
839
|
-
* @param {Inputs} inputs - The Inputs class instance.
|
|
840
|
-
*/
|
|
841
|
-
import type { ReadmeSection } from "src/constants";
|
|
842
|
-
import type Inputs from "src/inputs";
|
|
843
|
-
export default function updateDescription(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
844
|
-
}
|
|
845
|
-
declare module "src/markdowner/index" {
|
|
846
|
-
/**
|
|
847
|
-
* Types representing a 2D array of strings for a Markdown table.
|
|
848
|
-
*/
|
|
849
|
-
export type MarkdownArrayRowType = string[][];
|
|
850
|
-
export type MarkdownArrayItemType = string;
|
|
851
|
-
/**
|
|
852
|
-
* Fills a string to a desired width by padding with spaces.
|
|
853
|
-
*
|
|
854
|
-
* @param text - The text to pad.
|
|
855
|
-
* @param width - The desired total width.
|
|
856
|
-
* @param paddingStart - Number of spaces to pad at the start.
|
|
857
|
-
* @returns The padded string.
|
|
858
|
-
*/
|
|
859
|
-
export function padString(text: string, width: number, paddingStart: number): string;
|
|
860
|
-
/**
|
|
861
|
-
* Escapes special Markdown characters in a string.
|
|
862
|
-
*
|
|
863
|
-
* @param text - The text to escape.
|
|
864
|
-
* @returns The escaped text.
|
|
865
|
-
*/
|
|
866
|
-
export function markdownEscapeTableCell(text: string): string;
|
|
867
|
-
/**
|
|
868
|
-
* Escapes inline code blocks in a Markdown string.
|
|
869
|
-
*
|
|
870
|
-
* @param content - Markdown string.
|
|
871
|
-
* @returns String with escaped inline code blocks.
|
|
872
|
-
*/
|
|
873
|
-
export function markdownEscapeInlineCode(content: string): string;
|
|
874
|
-
/**
|
|
875
|
-
* Clones a 2D array.
|
|
876
|
-
*
|
|
877
|
-
* @param arr - Array to clone.
|
|
878
|
-
* @returns Cloned array.
|
|
879
|
-
*/
|
|
880
|
-
export function cloneArray(arr: MarkdownArrayRowType): MarkdownArrayRowType;
|
|
881
|
-
/**
|
|
882
|
-
* Gets max and min column counts from 2D array.
|
|
883
|
-
*
|
|
884
|
-
* @param data - 2D string array.
|
|
885
|
-
* @returns Object with max and min cols.
|
|
886
|
-
*/
|
|
887
|
-
export function getColumnCounts(data: MarkdownArrayRowType): {
|
|
888
|
-
maxCols: number;
|
|
889
|
-
minCols: number;
|
|
890
|
-
};
|
|
891
|
-
/**
|
|
892
|
-
* Pads 2D array rows to equal length.
|
|
893
|
-
*
|
|
894
|
-
* @param data - 2D array to pad.
|
|
895
|
-
* @param maxCols - Number of columns to pad to.
|
|
896
|
-
* @returns Padded 2D array.
|
|
897
|
-
*/
|
|
898
|
-
export function padArrayRows(data: MarkdownArrayRowType, maxCols: number): MarkdownArrayRowType;
|
|
899
|
-
/**
|
|
900
|
-
* Converts a 2D array of strings to a Markdown table.
|
|
901
|
-
*
|
|
902
|
-
* @param data - 2D string array.
|
|
903
|
-
* @returns Markdown table string.
|
|
904
|
-
*/
|
|
905
|
-
export function ArrayOfArraysToMarkdownTable(providedTableContent: MarkdownArrayRowType): string;
|
|
906
|
-
export default ArrayOfArraysToMarkdownTable;
|
|
907
|
-
}
|
|
908
|
-
declare module "src/sections/update-inputs" {
|
|
909
|
-
/**
|
|
910
|
-
* This TypeScript code exports a function named 'updateInputs' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.
|
|
911
|
-
* The function is responsible for updating the inputs section in the README.md file based on the provided inputs.
|
|
912
|
-
* 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.
|
|
913
|
-
* @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
|
|
914
|
-
* @param {Inputs} inputs - The Inputs class instance.
|
|
915
|
-
*/
|
|
916
|
-
import type { ReadmeSection } from "src/constants";
|
|
917
|
-
import type Inputs from "src/inputs";
|
|
918
|
-
export default function updateInputs(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
919
|
-
}
|
|
920
|
-
declare module "src/sections/update-outputs" {
|
|
921
|
-
/**
|
|
922
|
-
* This TypeScript code exports a function named 'updateOutputs' which takes a sectionToken (string) and an instance of the 'Inputs' class as its parameters.
|
|
923
|
-
* The function is responsible for updating the outputs section in the README.md file based on the provided inputs.
|
|
924
|
-
* It generates a table with three columns: Output name, Description, and Value (for composite actions).
|
|
925
|
-
* 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.
|
|
926
|
-
* @param {ReadmeSection} sectionToken - The sectionToken used for identifying the section.
|
|
927
|
-
* @param {Inputs} inputs - The Inputs class instance.
|
|
928
|
-
*/
|
|
929
|
-
import type { ReadmeSection } from "src/constants";
|
|
930
|
-
import type Inputs from "src/inputs";
|
|
931
|
-
export default function updateOutputs(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
932
|
-
}
|
|
933
|
-
declare module "src/sections/update-title" {
|
|
934
|
-
/**
|
|
935
|
-
* This TypeScript code exports a function named 'updateTitle' which takes a sectionToken (ReadmeSection) and an instance of the 'Inputs' class as its parameters.
|
|
936
|
-
* The function is responsible for updating the title section in the README.md file based on the provided inputs.
|
|
937
|
-
* It utilizes the 'LogTask' class for logging purposes, the 'generateImgMarkup' function from './update-branding.js' for generating image markup.
|
|
938
|
-
* @param {ReadmeSection} sectionToken - The sectionToken representing the section of the README to update.
|
|
939
|
-
* @param {Inputs} inputs - The Inputs class instance.
|
|
940
|
-
*/
|
|
941
|
-
import type { ReadmeSection } from "src/constants";
|
|
942
|
-
import type Inputs from "src/inputs";
|
|
943
|
-
export default function updateTitle(sectionToken: ReadmeSection, inputs: Inputs): Record<string, string>;
|
|
944
|
-
}
|
|
945
|
-
declare module "src/sections/update-usage" {
|
|
946
|
-
import type { ReadmeSection } from "src/constants";
|
|
947
|
-
import type Inputs from "src/inputs";
|
|
948
|
-
export default function updateUsage(sectionToken: ReadmeSection, inputs: Inputs): Promise<Record<string, string>>;
|
|
949
|
-
}
|
|
950
|
-
declare module "src/sections/index" {
|
|
951
|
-
/**
|
|
952
|
-
* This TypeScript code exports a function named 'updateSection' which takes a section (ReadmeSection) and an instance of the 'Inputs' class as its parameters.
|
|
953
|
-
* The function is responsible for updating different sections of the README.md file based on the provided section input.
|
|
954
|
-
* It utilizes various update functions (e.g., updateBranding, updateBadges) to update specific sections.
|
|
955
|
-
* @param {ReadmeSection} section - The section of the README to update.
|
|
956
|
-
* @param {Inputs} inputs - The Inputs class instance.
|
|
957
|
-
* @returns {Promise<void>} A promise that resolves once the section is updated.
|
|
958
|
-
*/
|
|
959
|
-
import type { ReadmeSection } from "src/constants";
|
|
960
|
-
import type Inputs from "src/inputs";
|
|
961
|
-
export default function updateSection(section: ReadmeSection, inputs: Inputs): Promise<Record<string, string>>;
|
|
962
|
-
}
|
|
963
|
-
declare module "src/readme-generator" {
|
|
964
|
-
import type { ReadmeSection } from "src/constants";
|
|
965
|
-
import type Inputs from "src/inputs";
|
|
966
|
-
import type LogTask from "src/logtask/index";
|
|
967
|
-
export type SectionKV = Record<string, string>;
|
|
968
|
-
/**
|
|
969
|
-
* Class for managing README generation.
|
|
970
|
-
*/
|
|
971
|
-
export class ReadmeGenerator {
|
|
972
|
-
/**
|
|
973
|
-
* The Inputs instance.
|
|
974
|
-
*/
|
|
975
|
-
private inputs;
|
|
976
|
-
/**
|
|
977
|
-
* The Logger instance.
|
|
978
|
-
*/
|
|
979
|
-
private log;
|
|
980
|
-
/**
|
|
981
|
-
* Initializes the ReadmeGenerator.
|
|
982
|
-
*
|
|
983
|
-
* @param inputs - The Inputs instance
|
|
984
|
-
* @param log - The Logger instance
|
|
985
|
-
*/
|
|
986
|
-
constructor(inputs: Inputs, log: LogTask);
|
|
987
|
-
/**
|
|
988
|
-
* Updates the README sections.
|
|
989
|
-
*
|
|
990
|
-
* @param sections - The sections array
|
|
991
|
-
* @returns Promise array of section KV objects
|
|
992
|
-
*/
|
|
993
|
-
updateSections(sections: ReadmeSection[]): Promise<SectionKV>[];
|
|
994
|
-
/**
|
|
995
|
-
* Resolves the section update promises.
|
|
996
|
-
*
|
|
997
|
-
* @param promises - The promise array
|
|
998
|
-
* @returns Promise resolving to combined sections KV
|
|
999
|
-
*/
|
|
1000
|
-
resolveUpdates(promises: Promise<SectionKV>[]): Promise<SectionKV>;
|
|
1001
|
-
/**
|
|
1002
|
-
* Outputs the sections KV to GitHub output.
|
|
1003
|
-
*
|
|
1004
|
-
* @param sections - The sections KV
|
|
1005
|
-
*/
|
|
1006
|
-
outputSections(sections: SectionKV): void;
|
|
1007
|
-
/**
|
|
1008
|
-
* Generates the README documentation.
|
|
1009
|
-
*
|
|
1010
|
-
* @returns Promise resolving when done
|
|
1011
|
-
*/
|
|
1012
|
-
generate(providedSections?: ReadmeSection[]): Promise<void>;
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
declare module "__tests__/integration-external-repo.test" { }
|
|
1016
|
-
declare module "__tests__/integration-issue-335.test" { }
|
|
1017
|
-
declare module "__tests__/markdowner.test" { }
|
|
1018
|
-
declare module "__tests__/prettier.test" { }
|
|
1019
|
-
declare module "__tests__/readme-generator.test" { }
|
|
1020
|
-
declare module "__tests__/update-contents.test" { }
|
|
1021
|
-
declare module "__tests__/logtask/index.test" { }
|
|
1022
|
-
declare module "src/config" {
|
|
1023
|
-
import type Inputs from "src/inputs";
|
|
1024
|
-
/**
|
|
1025
|
-
* Represents the versioning configuration for GitHub Actions documentation.
|
|
1026
|
-
*/
|
|
1027
|
-
export interface Versioning {
|
|
1028
|
-
enabled?: boolean;
|
|
1029
|
-
prefix?: string;
|
|
1030
|
-
override?: string;
|
|
1031
|
-
branch?: string;
|
|
1032
|
-
badge?: string;
|
|
1033
|
-
}
|
|
1034
|
-
/**
|
|
1035
|
-
* Represents the paths configuration for GitHub Actions documentation.
|
|
1036
|
-
*/
|
|
1037
|
-
export interface Paths {
|
|
1038
|
-
action: string;
|
|
1039
|
-
readme: string;
|
|
1040
|
-
}
|
|
1041
|
-
/**
|
|
1042
|
-
* Represents the configuration for generating GitHub Actions documentation.
|
|
1043
|
-
*/
|
|
1044
|
-
export class GHActionDocsConfig {
|
|
1045
|
-
owner?: string;
|
|
1046
|
-
repo?: string;
|
|
1047
|
-
title_prefix?: string;
|
|
1048
|
-
title?: string;
|
|
1049
|
-
paths?: Paths;
|
|
1050
|
-
branding_svg_path?: string;
|
|
1051
|
-
versioning?: Versioning;
|
|
1052
|
-
prettier?: boolean;
|
|
1053
|
-
/**
|
|
1054
|
-
* Loads the configuration from the provided `Inputs` object.
|
|
1055
|
-
* @param {Inputs} inputs - The `Inputs` object containing the configuration values.
|
|
1056
|
-
*/
|
|
1057
|
-
loadInputs(inputs: Inputs): void;
|
|
1058
|
-
/**
|
|
1059
|
-
* Saves the configuration to a file. If the file exists, it will be overwritten.
|
|
1060
|
-
* @param {string} configPath - The path to the configuration file.
|
|
1061
|
-
*/
|
|
1062
|
-
save(configPath: string): Promise<void>;
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
declare module "src/save" {
|
|
1066
|
-
import type Inputs from "src/inputs";
|
|
1067
|
-
import type LogTask from "src/logtask/index";
|
|
1068
|
-
/**
|
|
1069
|
-
* This script rebuilds the usage section in the README.md to be consistent with the action.yml
|
|
1070
|
-
* @param {Inputs} inputs - the inputs class
|
|
1071
|
-
*/
|
|
1072
|
-
export default function save(inputs: Inputs, log: LogTask): void;
|
|
1073
|
-
}
|
|
1074
|
-
declare module "src/index" {
|
|
1075
|
-
/**
|
|
1076
|
-
* Creates a ReadmeGenerator instance and generates docs.
|
|
1077
|
-
*/
|
|
1078
|
-
export function generateReadme(): Promise<void>;
|
|
1079
|
-
}
|
|
1080
|
-
declare module "src/working-directory" {
|
|
1081
|
-
/**
|
|
1082
|
-
* Returns the working directory path based on the environment variables.
|
|
1083
|
-
* The order of preference is GITHUB_WORKSPACE, INIT_CWD, and then the current working directory.
|
|
1084
|
-
* @returns The working directory path.
|
|
1085
|
-
*/
|
|
1086
|
-
export default function workingDirectory(): string;
|
|
1087
|
-
}
|
|
1088
|
-
declare module "src/errors/error-type" {
|
|
1089
|
-
export enum ErrorType {
|
|
1090
|
-
FILE = "file",
|
|
1091
|
-
SCHEMA = "schema",
|
|
1092
|
-
VALIDATION = "validation",
|
|
1093
|
-
INPUTS = "inputs",
|
|
1094
|
-
URL = "url"
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
declare module "src/errors/is-error" {
|
|
1098
|
-
/**
|
|
1099
|
-
* Type guard to check if an `unknown` value is an `Error` object.
|
|
1100
|
-
*
|
|
1101
|
-
* @param value - The value to check.
|
|
1102
|
-
*
|
|
1103
|
-
* @returns `true` if the value is an `Error` object, otherwise `false`.
|
|
1104
|
-
*/
|
|
1105
|
-
export const isError: (value: unknown) => value is Error;
|
|
1106
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Creates a ReadmeGenerator instance and generates docs.
|
|
3
|
+
*/
|
|
4
|
+
export declare function generateReadme(): Promise<void>;
|