github-action-readme-generator 1.6.0 → 1.7.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.
- package/CHANGELOG.md +22 -0
- package/README.example.md +2 -0
- package/README.md +55 -47
- package/dist/bin/index.js +321306 -0
- package/dist/mjs/Action.d.ts +33 -0
- package/dist/mjs/Action.js +51 -0
- package/dist/mjs/Action.js.map +1 -0
- package/dist/mjs/config.d.ts +30 -0
- package/dist/mjs/config.js +56 -0
- package/dist/mjs/config.js.map +1 -0
- package/dist/mjs/generate-docs.d.ts +3 -0
- package/dist/mjs/generate-docs.js +21 -0
- package/dist/mjs/generate-docs.js.map +1 -0
- package/dist/mjs/helpers.d.ts +17 -0
- package/dist/mjs/helpers.js +187 -0
- package/dist/mjs/helpers.js.map +1 -0
- package/dist/mjs/index.d.ts +2 -0
- package/dist/mjs/index.js +4 -0
- package/dist/mjs/index.js.map +1 -0
- package/dist/mjs/inputs.d.ts +18 -0
- package/dist/mjs/inputs.js +252 -0
- package/dist/mjs/inputs.js.map +1 -0
- package/dist/mjs/inputs.test.d.ts +2 -0
- package/dist/mjs/inputs.test.js +8 -0
- package/dist/mjs/inputs.test.js.map +1 -0
- package/dist/mjs/logtask/index.d.ts +20 -0
- package/dist/mjs/logtask/index.js +181 -0
- package/dist/mjs/logtask/index.js.map +1 -0
- package/dist/mjs/markdowner/index.d.ts +17 -0
- package/dist/mjs/markdowner/index.js +104 -0
- package/dist/mjs/markdowner/index.js.map +1 -0
- package/dist/mjs/package.json +3 -0
- package/dist/mjs/prettier.d.ts +3 -0
- package/dist/mjs/prettier.js +32 -0
- package/dist/mjs/prettier.js.map +1 -0
- package/dist/mjs/readme-editor.d.ts +10 -0
- package/dist/mjs/readme-editor.js +42 -0
- package/dist/mjs/readme-editor.js.map +1 -0
- package/dist/mjs/save.d.ts +2 -0
- package/dist/mjs/save.js +10 -0
- package/dist/mjs/save.js.map +1 -0
- package/dist/mjs/sections/index.d.ts +2 -0
- package/dist/mjs/sections/index.js +48 -0
- package/dist/mjs/sections/index.js.map +1 -0
- package/dist/mjs/sections/update-badges.d.ts +7 -0
- package/dist/mjs/sections/update-badges.js +71 -0
- package/dist/mjs/sections/update-badges.js.map +1 -0
- package/dist/mjs/sections/update-branding.d.ts +7 -0
- package/dist/mjs/sections/update-branding.js +46 -0
- package/dist/mjs/sections/update-branding.js.map +1 -0
- package/dist/mjs/sections/update-description.d.ts +2 -0
- package/dist/mjs/sections/update-description.js +21 -0
- package/dist/mjs/sections/update-description.js.map +1 -0
- package/dist/mjs/sections/update-inputs.d.ts +2 -0
- package/dist/mjs/sections/update-inputs.js +47 -0
- package/dist/mjs/sections/update-inputs.js.map +1 -0
- package/dist/mjs/sections/update-outputs.d.ts +2 -0
- package/dist/mjs/sections/update-outputs.js +42 -0
- package/dist/mjs/sections/update-outputs.js.map +1 -0
- package/dist/mjs/sections/update-title.d.ts +2 -0
- package/dist/mjs/sections/update-title.js +19 -0
- package/dist/mjs/sections/update-title.js.map +1 -0
- package/dist/mjs/sections/update-usage.d.ts +2 -0
- package/dist/mjs/sections/update-usage.js +49 -0
- package/dist/mjs/sections/update-usage.js.map +1 -0
- package/dist/mjs/svg-editor.d.mts +22 -0
- package/dist/mjs/svg-editor.mjs +138 -0
- package/dist/mjs/svg-editor.mjs.map +1 -0
- package/dist/mjs/working-directory.d.ts +2 -0
- package/dist/mjs/working-directory.js +5 -0
- package/dist/mjs/working-directory.js.map +1 -0
- package/dist/{index.d.ts → types/index.d.ts} +44 -10
- package/package.json +117 -135
- package/dist/index.js +0 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-usage.js","sourceRoot":"","sources":["../../../src/sections/update-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,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AAE,QAAQ,CAAC,CAAC;gBAEtD,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;oBAC/B,kDAAkD;oBAClD,IAAI,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;wBACnD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;qBACvB;oBAED,UAAU;oBACV,OAAO,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;iBACjD;gBAED,aAAa;gBACb,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;gBAE/B,UAAU,GAAG,KAAK,CAAC;aACpB;SACF;KACF;IAED,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEtB,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClD,GAAG,CAAC,OAAO,EAAE,CAAC;AAChB,CAAC","sourcesContent":["import { getCurrentVersionString } from '../helpers.js';\nimport type Inputs from '../inputs.js';\nimport LogTask from '../logtask/index.js';\nimport { wrapDescription } from '../prettier.js';\n\nexport default function updateUsage(token: string, inputs: Inputs): void {\n const log = new LogTask(token);\n log.start();\n const actionName = `${inputs.config.get('owner') as string}/${inputs.config.get('repo')}`;\n log.info(`Action name: ${actionName}`);\n const versionString: string = getCurrentVersionString(inputs);\n\n log.info(`Version string: ${versionString}`);\n\n const actionReference = `${actionName}@${versionString}`;\n\n if (!actionReference) {\n throw new Error('Parameter actionReference must not be empty');\n }\n\n // Build the new README\n const content: string[] = [];\n // Build the new usage section\n content.push('```yaml', `- uses: ${actionReference}`, ' with:');\n\n const inp = inputs.action.inputs;\n let firstInput = true;\n if (inp) {\n for (const key of Object.keys(inp)) {\n const input = inp[key];\n if (input !== undefined) {\n // Line break between inputs\n if (!firstInput) {\n content.push('');\n }\n\n // Constrain the width of the description, and append it\n wrapDescription(input.description, content, ' # ');\n\n if (input.default !== undefined) {\n // Append blank line if description had paragraphs\n if (input.description?.trimEnd().match(/\\n *\\r?\\n/)) {\n content.push(' #');\n }\n\n // Default\n content.push(` # Default: ${input.default}`);\n }\n\n // Input name\n content.push(` ${key}: ''`);\n\n firstInput = false;\n }\n }\n }\n\n content.push('```\\n');\n\n inputs.readmeEditor.updateSection(token, content);\n log.success();\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Container } from '@svgdotjs/svg.js';
|
|
2
|
+
import * as feather from 'feather-icons';
|
|
3
|
+
import { SVGDocument, SVGWindow } from 'svgdom';
|
|
4
|
+
import LogTask from './logtask/index.js';
|
|
5
|
+
type conforms<T, V> = T extends V ? T : V;
|
|
6
|
+
type FeatherIconKeysArray = keyof typeof feather.icons;
|
|
7
|
+
type FeatherIconKeys<T extends string, R = FeatherIconKeysArray> = conforms<T, R>;
|
|
8
|
+
export declare const GITHUB_ACTIONS_BRANDING_ICONS: Set<string>;
|
|
9
|
+
export declare const GITHUB_ACTIONS_BRANDING_COLORS: string[];
|
|
10
|
+
export default class SVGEditor {
|
|
11
|
+
log: LogTask;
|
|
12
|
+
window?: SVGWindow;
|
|
13
|
+
canvas?: Container;
|
|
14
|
+
document?: SVGDocument;
|
|
15
|
+
constructor();
|
|
16
|
+
init(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Generates a svg branding image.
|
|
19
|
+
*/
|
|
20
|
+
generateSvgImage(svgPath: string | undefined, icon?: FeatherIconKeys<keyof typeof feather.icons>, bgcolor?: string): void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { registerWindow, SVG } from '@svgdotjs/svg.js';
|
|
5
|
+
import * as feather from 'feather-icons';
|
|
6
|
+
import { createSVGDocument, createSVGWindow } from 'svgdom'; /// main-module.js';
|
|
7
|
+
import LogTask from './logtask/index.js';
|
|
8
|
+
// function featherType<T extends FeatherIconKeysArray | string>(iconName: T): FeatherIconKeys<T> {
|
|
9
|
+
// return iconName as FeatherIconKeys<T>;
|
|
10
|
+
// }
|
|
11
|
+
const brandingSquareEdgeLengthInPixels = 50;
|
|
12
|
+
// https://help.github.com/en/articles/metadata-syntax-for-github-actions#branding
|
|
13
|
+
const GITHUB_ACTIONS_OMITTED_ICONS = new Set([
|
|
14
|
+
'coffee',
|
|
15
|
+
'columns',
|
|
16
|
+
'divide-circle',
|
|
17
|
+
'divide-square',
|
|
18
|
+
'divide',
|
|
19
|
+
'frown',
|
|
20
|
+
'hexagon',
|
|
21
|
+
'key',
|
|
22
|
+
'meh',
|
|
23
|
+
'mouse-pointer',
|
|
24
|
+
'smile',
|
|
25
|
+
'tool',
|
|
26
|
+
'x-octagon',
|
|
27
|
+
]);
|
|
28
|
+
export const GITHUB_ACTIONS_BRANDING_ICONS = new Set(Object.keys(feather.icons).filter((item) => !GITHUB_ACTIONS_OMITTED_ICONS.has(item)));
|
|
29
|
+
export const GITHUB_ACTIONS_BRANDING_COLORS = [
|
|
30
|
+
'white',
|
|
31
|
+
'yellow',
|
|
32
|
+
'blue',
|
|
33
|
+
'green',
|
|
34
|
+
'orange',
|
|
35
|
+
'red',
|
|
36
|
+
'purple',
|
|
37
|
+
'gray-dark',
|
|
38
|
+
];
|
|
39
|
+
export default class SVGEditor {
|
|
40
|
+
log;
|
|
41
|
+
window;
|
|
42
|
+
canvas;
|
|
43
|
+
document;
|
|
44
|
+
constructor() {
|
|
45
|
+
this.log = new LogTask('SVGEditor');
|
|
46
|
+
}
|
|
47
|
+
async init() {
|
|
48
|
+
if (!this.window) {
|
|
49
|
+
// returns a window with a document and an svg root node
|
|
50
|
+
this.window = createSVGWindow();
|
|
51
|
+
const { document } = this.window;
|
|
52
|
+
// instanceof<typeof createSVGWindow>
|
|
53
|
+
// register window and document
|
|
54
|
+
registerWindow(this.window, document);
|
|
55
|
+
if (!this.canvas) {
|
|
56
|
+
// create canvas
|
|
57
|
+
this.canvas = SVG(document.documentElement);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!this.document) {
|
|
61
|
+
this.document = createSVGDocument();
|
|
62
|
+
}
|
|
63
|
+
if (!this.canvas) {
|
|
64
|
+
// create canvas
|
|
65
|
+
this.canvas = SVG(this.document.documentElement);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Generates a svg branding image.
|
|
70
|
+
*/
|
|
71
|
+
generateSvgImage(svgPath, icon = 'book-open', bgcolor = 'blue') {
|
|
72
|
+
const { log } = this;
|
|
73
|
+
if (svgPath && svgPath.length > 0) {
|
|
74
|
+
fs.mkdirSync(path.dirname(svgPath), { recursive: true });
|
|
75
|
+
this.init()
|
|
76
|
+
.then(() => {
|
|
77
|
+
const { canvas } = this;
|
|
78
|
+
if (!GITHUB_ACTIONS_BRANDING_ICONS.has(icon)) {
|
|
79
|
+
log.fail(`Invalid icon specified for branding: ${icon}`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const color = GITHUB_ACTIONS_BRANDING_COLORS.includes(bgcolor.toLowerCase())
|
|
83
|
+
? bgcolor.toLowerCase()
|
|
84
|
+
: 'blue';
|
|
85
|
+
const svgData = feather.icons[icon];
|
|
86
|
+
log.info(`SVG data generated for ${icon} at ${svgPath} with color ${color}.`);
|
|
87
|
+
log.debug(`SVG data to ingest: ${svgData.toSvg()}`);
|
|
88
|
+
if (canvas) {
|
|
89
|
+
canvas.clear();
|
|
90
|
+
const outerViewBox = 100;
|
|
91
|
+
canvas
|
|
92
|
+
.size(brandingSquareEdgeLengthInPixels, brandingSquareEdgeLengthInPixels)
|
|
93
|
+
.viewbox(`0 0 ${outerViewBox} ${outerViewBox}`)
|
|
94
|
+
.stroke(color.startsWith('white') ? 'white' : 'black')
|
|
95
|
+
.fill('none');
|
|
96
|
+
const circleSize = outerViewBox / 2;
|
|
97
|
+
canvas
|
|
98
|
+
.circle('50%')
|
|
99
|
+
.fill(color)
|
|
100
|
+
.radius(circleSize)
|
|
101
|
+
.cx(circleSize)
|
|
102
|
+
.cy(circleSize)
|
|
103
|
+
.stroke({ width: 0 });
|
|
104
|
+
const iconsvgOuter = canvas.nested();
|
|
105
|
+
iconsvgOuter.attr('overflow', 'visible').height('50%').width('50%').x('25%').y('25%');
|
|
106
|
+
const iconsvg = iconsvgOuter.nested();
|
|
107
|
+
iconsvg.id('icon').svg(svgData.contents);
|
|
108
|
+
for (const attr of Object.keys(svgData.attrs)) {
|
|
109
|
+
iconsvg.attr(attr, svgData.attrs[attr]);
|
|
110
|
+
}
|
|
111
|
+
iconsvg.attr('overflow', 'visible');
|
|
112
|
+
log.info(`SVG icon: rbox: ${iconsvg.rbox()}`);
|
|
113
|
+
log.info(`SVG icon: bbox: ${iconsvg.bbox()}`);
|
|
114
|
+
iconsvg.viewbox(iconsvg.bbox());
|
|
115
|
+
iconsvg.height('auto').width('auto');
|
|
116
|
+
const svgOut = [
|
|
117
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>',
|
|
118
|
+
canvas.svg(),
|
|
119
|
+
'\n',
|
|
120
|
+
].join('\n');
|
|
121
|
+
log.debug(`SVG data to write: ${svgOut}`);
|
|
122
|
+
fs.mkdirSync(path.dirname(svgPath), { recursive: true });
|
|
123
|
+
fs.writeFileSync(svgPath, svgOut, { encoding: 'utf8' });
|
|
124
|
+
log.debug(`SVG image generated: ${svgPath}`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
throw new Error('Canvas not initialized');
|
|
128
|
+
})
|
|
129
|
+
.catch((error) => {
|
|
130
|
+
log.fail(`Error generating svg image: ${svgPath}. Error: ${error}`);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
log.debug('svgPath is not provided');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=sv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;oBACxD,GAAG,CAAC,KAAK,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;oBAC7C,OAAO;iBACR;gBAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC5C,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,GAAG,CAAC,IAAI,CAAC,+BAA+B,OAAO,YAAY,KAAK,EAAE,CAAC,CAAC;YACtE,CAAC,CAAC,CAAC;SACN;aAAM;YACL,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;SACtC;IACH,CAAC;CACF","sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { Container } from '@svgdotjs/svg.js';\nimport { registerWindow, SVG } from '@svgdotjs/svg.js';\nimport * as feather from 'feather-icons';\nimport { createSVGDocument, createSVGWindow, SVGDocument, SVGWindow } from 'svgdom'; /// main-module.js';\n\nimport LogTask from './logtask/index.js';\n\ntype conforms<T, V> = T extends V ? T : V;\ntype FeatherIconKeysArray = keyof typeof feather.icons;\ntype FeatherIconKeys<T extends string, R = FeatherIconKeysArray> = conforms<T, R>;\n// function featherType<T extends FeatherIconKeysArray | string>(iconName: T): FeatherIconKeys<T> {\n// return iconName as FeatherIconKeys<T>;\n// }\nconst brandingSquareEdgeLengthInPixels = 50;\n\n// https://help.github.com/en/articles/metadata-syntax-for-github-actions#branding\nconst GITHUB_ACTIONS_OMITTED_ICONS = new Set([\n 'coffee',\n 'columns',\n 'divide-circle',\n 'divide-square',\n 'divide',\n 'frown',\n 'hexagon',\n 'key',\n 'meh',\n 'mouse-pointer',\n 'smile',\n 'tool',\n 'x-octagon',\n]);\nexport const GITHUB_ACTIONS_BRANDING_ICONS = new Set(\n Object.keys(feather.icons).filter((item) => !GITHUB_ACTIONS_OMITTED_ICONS.has(item))\n);\nexport const GITHUB_ACTIONS_BRANDING_COLORS = [\n 'white',\n 'yellow',\n 'blue',\n 'green',\n 'orange',\n 'red',\n 'purple',\n 'gray-dark',\n];\n\nexport default class SVGEditor {\n log: LogTask;\n\n window?: SVGWindow;\n\n canvas?: Container;\n\n document?: SVGDocument;\n\n constructor() {\n this.log = new LogTask('SVGEditor');\n }\n\n async init(): Promise<void> {\n if (!this.window) {\n // returns a window with a document and an svg root node\n this.window = createSVGWindow();\n\n const { document } = this.window;\n // instanceof<typeof createSVGWindow>\n // register window and document\n registerWindow(this.window, document);\n if (!this.canvas) {\n // create canvas\n this.canvas = SVG(document.documentElement) as Container;\n }\n }\n\n if (!this.document) {\n this.document = createSVGDocument();\n }\n\n if (!this.canvas) {\n // create canvas\n this.canvas = SVG(this.document.documentElement) as Container;\n }\n }\n\n /**\n * Generates a svg branding image.\n */\n generateSvgImage(\n svgPath: string | undefined,\n icon: FeatherIconKeys<keyof typeof feather.icons> = 'book-open',\n bgcolor = 'blue'\n ): void {\n const { log } = this;\n if (svgPath && svgPath.length > 0) {\n fs.mkdirSync(path.dirname(svgPath), { recursive: true });\n this.init()\n .then(() => {\n const { canvas } = this;\n if (!GITHUB_ACTIONS_BRANDING_ICONS.has(icon)) {\n log.fail(`Invalid icon specified for branding: ${icon}`);\n return;\n }\n const color = GITHUB_ACTIONS_BRANDING_COLORS.includes(bgcolor.toLowerCase())\n ? bgcolor.toLowerCase()\n : 'blue';\n\n const svgData = feather.icons[icon];\n log.info(`SVG data generated for ${icon} at ${svgPath} with color ${color}.`);\n log.debug(`SVG data to ingest: ${svgData.toSvg()}`);\n if (canvas) {\n canvas.clear();\n const outerViewBox = 100;\n canvas\n .size(brandingSquareEdgeLengthInPixels, brandingSquareEdgeLengthInPixels)\n .viewbox(`0 0 ${outerViewBox} ${outerViewBox}`)\n .stroke(color.startsWith('white') ? 'white' : 'black')\n .fill('none');\n const circleSize = outerViewBox / 2;\n canvas\n .circle('50%')\n .fill(color)\n .radius(circleSize)\n .cx(circleSize)\n .cy(circleSize)\n .stroke({ width: 0 });\n\n const iconsvgOuter = canvas.nested();\n iconsvgOuter.attr('overflow', 'visible').height('50%').width('50%').x('25%').y('25%');\n const iconsvg = iconsvgOuter.nested();\n\n iconsvg.id('icon').svg(svgData.contents);\n for (const attr of Object.keys(svgData.attrs)) {\n iconsvg.attr(attr, svgData.attrs[attr]);\n }\n iconsvg.attr('overflow', 'visible');\n log.info(`SVG icon: rbox: ${iconsvg.rbox()}`);\n log.info(`SVG icon: bbox: ${iconsvg.bbox()}`);\n iconsvg.viewbox(iconsvg.bbox());\n iconsvg.height('auto').width('auto');\n\n const svgOut = [\n '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>',\n canvas.svg(),\n '\\n',\n ].join('\\n');\n log.debug(`SVG data to write: ${svgOut}`);\n fs.mkdirSync(path.dirname(svgPath), { recursive: true });\n fs.writeFileSync(svgPath, svgOut, { encoding: 'utf8' });\n log.debug(`SVG image generated: ${svgPath}`);\n return;\n }\n\n throw new Error('Canvas not initialized');\n })\n .catch((error) => {\n log.fail(`Error generating svg image: ${svgPath}. Error: ${error}`);\n });\n } else {\n log.debug('svgPath is not provided');\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-directory.js","sourceRoot":"","sources":["../../src/working-directory.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB;IAC9B,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;AAC/E,CAAC;AACD,eAAe,gBAAgB,CAAC","sourcesContent":["export function workingDirectory(): string {\n return process.env.GITHUB_WORKSPACE ?? process.env.INIT_CWD ?? process.cwd();\n}\nexport default workingDirectory;\n"]}
|
|
@@ -4,9 +4,8 @@ declare module "jest.config" {
|
|
|
4
4
|
const config: Config.InitialOptions;
|
|
5
5
|
export default config;
|
|
6
6
|
}
|
|
7
|
-
declare module "__tests__/index.test" { }
|
|
8
7
|
declare module "src/logtask/index" {
|
|
9
|
-
class LogTask {
|
|
8
|
+
export default class LogTask {
|
|
10
9
|
static ingroup_setting: {
|
|
11
10
|
[key: string]: boolean;
|
|
12
11
|
};
|
|
@@ -26,7 +25,6 @@ declare module "src/logtask/index" {
|
|
|
26
25
|
error(description?: string): void;
|
|
27
26
|
title(description?: string): void;
|
|
28
27
|
}
|
|
29
|
-
export default LogTask;
|
|
30
28
|
}
|
|
31
29
|
declare module "src/Action" {
|
|
32
30
|
export interface InputType {
|
|
@@ -59,11 +57,12 @@ declare module "src/Action" {
|
|
|
59
57
|
outputs: OutputsType;
|
|
60
58
|
runs: Runs;
|
|
61
59
|
constructor(actionPath: string);
|
|
60
|
+
inputDefault(inputName: string): string | undefined;
|
|
62
61
|
stringify(): string;
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
declare module "src/helpers" {
|
|
66
|
-
import type { Context } from '@actions/github/lib/context';
|
|
65
|
+
import type { Context } from '@actions/github/lib/context.js';
|
|
67
66
|
import type Inputs from "src/inputs";
|
|
68
67
|
export function undefinedOnEmpty(value: string | undefined): string | undefined;
|
|
69
68
|
export function basename(path: string): string | undefined;
|
|
@@ -93,7 +92,8 @@ declare module "src/readme-editor" {
|
|
|
93
92
|
private readonly filePath;
|
|
94
93
|
private fileContent;
|
|
95
94
|
constructor(filePath: string);
|
|
96
|
-
|
|
95
|
+
getTokenIndexes(token: string): number[];
|
|
96
|
+
updateSection(name: string, providedContent: string | string[], addNewlines?: boolean): void;
|
|
97
97
|
dumpToFile(): Promise<void>;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -102,19 +102,21 @@ declare module "src/working-directory" {
|
|
|
102
102
|
export default workingDirectory;
|
|
103
103
|
}
|
|
104
104
|
declare module "src/inputs" {
|
|
105
|
-
import
|
|
105
|
+
import { Provider } from 'nconf';
|
|
106
106
|
import Action from "src/Action";
|
|
107
107
|
import ReadmeEditor from "src/readme-editor";
|
|
108
108
|
export const configFileName = ".ghadocs.json";
|
|
109
109
|
export const configKeys: string[];
|
|
110
|
+
type ProviderInstance = InstanceType<typeof Provider>;
|
|
110
111
|
export default class Inputs {
|
|
111
|
-
config:
|
|
112
|
+
config: ProviderInstance;
|
|
112
113
|
sections: string[];
|
|
113
114
|
readmePath: string;
|
|
114
115
|
configPath: string;
|
|
115
116
|
action: Action;
|
|
116
117
|
readmeEditor: ReadmeEditor;
|
|
117
118
|
constructor();
|
|
119
|
+
setConfigValueFromActionFileDefault(actionInstance: Action, inputName: string, providedConfigName?: string): void;
|
|
118
120
|
stringify(): string;
|
|
119
121
|
}
|
|
120
122
|
}
|
|
@@ -136,7 +138,7 @@ declare module "src/config" {
|
|
|
136
138
|
title_prefix?: string;
|
|
137
139
|
title?: string;
|
|
138
140
|
paths?: Paths;
|
|
139
|
-
|
|
141
|
+
branding_svg_path?: string;
|
|
140
142
|
versioning?: Versioning;
|
|
141
143
|
readmePath?: string;
|
|
142
144
|
outpath?: string;
|
|
@@ -163,6 +165,38 @@ declare module "src/sections/update-badges" {
|
|
|
163
165
|
}
|
|
164
166
|
export default function updateBadges(token: string, inputs: Inputs): void;
|
|
165
167
|
}
|
|
168
|
+
declare module "src/svg-editor" {
|
|
169
|
+
import type { Container } from '@svgdotjs/svg.js';
|
|
170
|
+
import * as feather from 'feather-icons';
|
|
171
|
+
import { SVGDocument, SVGWindow } from 'svgdom';
|
|
172
|
+
import LogTask from "src/logtask/index";
|
|
173
|
+
type conforms<T, V> = T extends V ? T : V;
|
|
174
|
+
type FeatherIconKeysArray = keyof typeof feather.icons;
|
|
175
|
+
type FeatherIconKeys<T extends string, R = FeatherIconKeysArray> = conforms<T, R>;
|
|
176
|
+
export const GITHUB_ACTIONS_BRANDING_ICONS: Set<string>;
|
|
177
|
+
export const GITHUB_ACTIONS_BRANDING_COLORS: string[];
|
|
178
|
+
export default class SVGEditor {
|
|
179
|
+
log: LogTask;
|
|
180
|
+
window?: SVGWindow;
|
|
181
|
+
canvas?: Container;
|
|
182
|
+
document?: SVGDocument;
|
|
183
|
+
constructor();
|
|
184
|
+
init(): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Generates a svg branding image.
|
|
187
|
+
*/
|
|
188
|
+
generateSvgImage(svgPath: string | undefined, icon?: FeatherIconKeys<keyof typeof feather.icons>, bgcolor?: string): void;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
declare module "src/sections/update-branding" {
|
|
192
|
+
import type Inputs from "src/inputs";
|
|
193
|
+
export interface IBranding {
|
|
194
|
+
alt: string;
|
|
195
|
+
img: string;
|
|
196
|
+
url?: string;
|
|
197
|
+
}
|
|
198
|
+
export default function updateBranding(token: string, inputs: Inputs): void;
|
|
199
|
+
}
|
|
166
200
|
declare module "src/sections/update-description" {
|
|
167
201
|
import type Inputs from "src/inputs";
|
|
168
202
|
export default function updateDescription(token: string, inputs: Inputs): void;
|
|
@@ -209,9 +243,9 @@ declare module "src/sections/index" {
|
|
|
209
243
|
declare module "src/generate-docs" {
|
|
210
244
|
import Inputs from "src/inputs";
|
|
211
245
|
export const inputs: Inputs;
|
|
212
|
-
export
|
|
246
|
+
export function generateDocs(): void;
|
|
213
247
|
}
|
|
214
248
|
declare module "src/index" { }
|
|
215
|
-
declare module "src/
|
|
249
|
+
declare module "src/inputs.test" {
|
|
216
250
|
export default function main(): void;
|
|
217
251
|
}
|