Skip to content

Commit

Permalink
build: use column sets instead in daily digest (#10463)
Browse files Browse the repository at this point in the history
  • Loading branch information
yiqing-zhao authored Nov 30, 2023
1 parent db6027e commit c8030e7
Showing 1 changed file with 84 additions and 86 deletions.
170 changes: 84 additions & 86 deletions .github/scripts/get-dailydigest-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,126 +91,124 @@ async function getTemplatesDependencies() {
return dependenciesMap;
}

function generateAdaptiveCardTable(arr) {
if (arr.length === 0) return {};
let table = {
type: "Table",
firstRowAsHeaders: true,
columns: [
{
width: 2,
},
{
width: 1,
},
{
width: 3,
},
{
width: 2,
},
],
rows: [
{
type: "TableRow",
cells: [
{
type: "TableCell",
items: [
{
type: "TextBlock",
text: "Name",
wrap: true,
weight: "Bolder",
},
],
},
{
type: "TableCell",
items: [
{
type: "TextBlock",
text: "Version",
wrap: true,
weight: "Bolder",
},
],
},
{
type: "TableCell",
items: [
{
type: "TextBlock",
text: "Templates",
wrap: true,
weight: "Bolder",
},
],
},
{
type: "TableCell",
items: [
{
type: "TextBlock",
text: "Owners",
wrap: true,
weight: "Bolder",
},
],
},
],
style: "accent",
},
],
};
for (const entry of arr) {
table.rows.push({
type: "TableRow",
cells: [
function generateAdaptiveCardColumnSets(arr) {
if (arr.length === 0) {
return [];
}
let columnSets = [
{
type: "ColumnSet",
columns: [
{
type: "TableCell",
type: "Column",
width: 25,
items: [
{
type: "TextBlock",
text: `[${entry.name}](https://www.npmjs.com/package/${entry.name})`,
text: "Name",
wrap: true,
weight: "Bolder",
},
],
verticalContentAlignment: "Center",
},
{
type: "TableCell",
type: "Column",
width: 15,
items: [
{
type: "TextBlock",
text: entry.version,
text: "Version",
wrap: true,
weight: "Bolder",
},
],
verticalContentAlignment: "Center",
},
{
type: "TableCell",
type: "Column",
width: 40,
items: [
{
type: "TextBlock",
text: entry.dependencies.join("\n\r"),
text: "Templates",
wrap: true,
weight: "Bolder",
},
],
verticalContentAlignment: "Center",
},
{
type: "TableCell",
type: "Column",
width: 20,
items: [
{
type: "TextBlock",
text: entry.owners.join("\n\r"),
text: "Owners",
wrap: true,
weight: "Bolder",
},
],
verticalContentAlignment: "Center",
},
],
separator: true,
},
];
for (items of arr) {
columnSets.push({
type: "ColumnSet",
columns: [
{
type: "Column",
width: 25,
items: [
{
type: "TextBlock",
text: `[${items.name}](https://www.npmjs.com/package/${items.name})`,
wrap: true,
},
],
},
{
type: "Column",
width: 15,
items: [
{
type: "TextBlock",
text: items.version,
wrap: true,
},
],
},
{
type: "Column",
width: 40,
items: [
{
type: "TextBlock",
text: items.dependencies.join("\n\r"),
wrap: true,
},
],
},
{
type: "Column",
width: 20,
items: [
{
type: "TextBlock",
text: items.owners.join("\n\r"),
wrap: true,
},
],
},
],
separator: true,
});
}
return table;

return columnSets;
}

async function main() {
Expand All @@ -233,7 +231,7 @@ async function main() {
}
});
}
const table = generateAdaptiveCardTable(arr);
const table = generateAdaptiveCardColumnSets(arr);
const tableString = JSON.stringify(table);
return JSON.stringify(tableString);
}
Expand Down

0 comments on commit c8030e7

Please sign in to comment.