Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2c605f8

Browse files
committed
Built action
1 parent 0625baa commit 2c605f8

File tree

1 file changed

+40
-20
lines changed

1 file changed

+40
-20
lines changed

‎dist/index.js‎

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,18 +1545,22 @@ const ColorMap = {
15451545
red: '9f5c58',
15461546
teal: '467870'
15471547
};
1548-
const constructNewContents = (categories_map,color_schema_unit_key) => {
1548+
const constructNewContents = (categoriesMap,colorSchemaUnitKey,base64SchemaUnitKey) => {
15491549
const newContents = [];
1550-
for (const [category, category_info] of categories_map) {
1550+
for (const [category, categoryInfo] of categoriesMap) {
15511551
const content = [
1552-
`<h3><img height="20px" src="https://img.shields.io/badge/${external_querystring_default().escape(category)}-${ColorMap[category_info.color]}"/></h3>`
1552+
`<h3><img height="20px" src="https://img.shields.io/badge/${external_querystring_default().escape(category)}-${ColorMap[categoryInfo.color]}"/></h3>`
15531553
];
1554-
category_info.items.forEach((item) => {
1555-
var _a, _b;
1554+
categoryInfo.items.forEach((item) => {
1555+
var _a, _b,_c;
15561556
const title = item.title && item.title[0][0];
15571557
if (!title)
15581558
throw new Error(`Each row must have value in the Name column`);
1559-
content.push(`<span><img src="https://img.shields.io/badge/-${external_querystring_default().escape(title)}-${(_b = (_a = item[color_schema_unit_key]) === null || _a === void 0 ? void 0 : _a[0][0]) !== null && _b !== void 0 ? _b : 'black'}?style=flat-square&amp;logo=${external_querystring_default().escape(title)}" alt="${title}"/></span>`);
1559+
let logo = external_querystring_default().escape(title);
1560+
if ((_a = item[base64SchemaUnitKey]) === null || _a === void 0 ? void 0 : _a[0][0]) {
1561+
logo = item[base64SchemaUnitKey][0][0];
1562+
}
1563+
content.push(`<span><img src="https://img.shields.io/badge/-${external_querystring_default().escape(title)}-${(_c = (_b = item[colorSchemaUnitKey]) === null || _b === void 0 ? void 0 : _b[0][0]) !== null && _c !== void 0 ? _c : 'black'}?style=flat-square&amp;logo=${logo}" alt="${title}"/></span>`);
15601564
});
15611565
newContents.push(...content, '<hr>');
15621566
}
@@ -1595,20 +1599,36 @@ const fetchData = (id, table, http) => fetchData_awaiter(void 0, void 0, void 0,
15951599
;// CONCATENATED MODULE: ./src/utils/getSchemaEntries.ts
15961600

15971601
const getSchemaEntries = (schema) => {
1598-
const schema_entries = Object.entries(schema), category_schema_entry = schema_entries.find(([, schema_entry_value]) => schema_entry_value.type === 'select' &&
1599-
schema_entry_value.name === 'Category'), name_schema_entry = schema_entries.find(([, schema_entry_value]) => schema_entry_value.type === 'title' &&
1600-
schema_entry_value.name === 'Name'), color_schema_entry = schema_entries.find(([, schema_entry_value]) => schema_entry_value.type === 'text' &&
1601-
schema_entry_value.name === 'Color');
1602-
if (!category_schema_entry)
1602+
const schemaEntries = Object.entries(schema);
1603+
let categorySchemaEntry = undefined, nameSchemaEntry = undefined, colorSchemaEntry = undefined, base64SchemaEntry = undefined;
1604+
schemaEntries.forEach((schemaEntry) => {
1605+
if (schemaEntry[1].type === 'text' && schemaEntry[1].name === 'Color') {
1606+
colorSchemaEntry = schemaEntry;
1607+
}
1608+
else if (schemaEntry[1].type === 'title' &&
1609+
schemaEntry[1].name === 'Name') {
1610+
nameSchemaEntry = schemaEntry;
1611+
}
1612+
else if (schemaEntry[1].type === 'select' &&
1613+
schemaEntry[1].name === 'Category') {
1614+
categorySchemaEntry = schemaEntry;
1615+
}
1616+
else if (schemaEntry[1].type === 'text' &&
1617+
schemaEntry[1].name === 'Base64') {
1618+
base64SchemaEntry = schemaEntry;
1619+
}
1620+
});
1621+
if (!categorySchemaEntry)
16031622
core.setFailed("Couldn't find Category named select type column in the database");
1604-
if (!color_schema_entry)
1623+
if (!nameSchemaEntry)
16051624
core.setFailed("Couldn't find Color named text type column in the database");
1606-
if (!name_schema_entry)
1625+
if (!colorSchemaEntry)
16071626
core.setFailed("Couldn't find Name named title type column in the database");
16081627
return [
1609-
category_schema_entry,
1610-
color_schema_entry,
1611-
name_schema_entry
1628+
categorySchemaEntry,
1629+
colorSchemaEntry,
1630+
nameSchemaEntry,
1631+
base64SchemaEntry
16121632
];
16131633
};
16141634

@@ -1708,15 +1728,15 @@ function action() {
17081728
const { recordMap } = JSON.parse(yield response.readBody());
17091729
core.info('Fetched rows');
17101730
const { schema } = collection;
1711-
const [category_schema_entry,color_schema_entry] = ActionUtils.getSchemaEntries(schema);
1731+
const [categorySchemaEntry,colorSchemaEntry,,base64SchemaEntry] = ActionUtils.getSchemaEntries(schema);
17121732
const rows = ActionUtils.modifyRows(recordMap, databaseId);
1713-
const categories_map = ActionUtils.constructCategoriesMap(category_schema_entry[1]);
1714-
ActionUtils.populateCategoriesMapItems(rows, category_schema_entry[0], categories_map);
1733+
const categoriesMap = ActionUtils.constructCategoriesMap(categorySchemaEntry[1]);
1734+
ActionUtils.populateCategoriesMapItems(rows, categorySchemaEntry[0], categoriesMap);
17151735
const README_PATH = `${process.env.GITHUB_WORKSPACE}/README.md`;
17161736
core.info(`Reading from ${README_PATH}`);
17171737
const readmeLines = external_fs_default().readFileSync(README_PATH, 'utf-8').split('\n');
17181738
const [startIdx, endIdx] = ActionUtils.checkForSections(readmeLines);
1719-
const newLines = ActionUtils.constructNewContents(categories_map,color_schema_entry[0]);
1739+
const newLines = ActionUtils.constructNewContents(categoriesMap,colorSchemaEntry[0],base64SchemaEntry[0]);
17201740
const finalLines = [
17211741
...readmeLines.slice(0, startIdx + 1),
17221742
...newLines,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /