Skip to content

Commit b0d036f

Browse files
committed
chore: Add BB id to logo file name to assure uniqueness
1 parent 35ff598 commit b0d036f

File tree

13 files changed

+43
-31
lines changed

13 files changed

+43
-31
lines changed

index.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ function findBuildingBlockLogo(buildingBlockDir) {
9595

9696
files.forEach((file) => {
9797
if (file.endsWith(".png") || file.endsWith(".svg")) {
98+
const { id, platform } = getIdAndPlatform(buildingBlockDir);
9899
const sourcePath = path.join(buildingBlockDir, file);
99-
const destinationPath = path.join(assetsDir, path.basename(file));
100+
const destinationPath = path.join(assetsDir, `${id}${path.extname(file)}`);
100101

101102
fs.mkdirSync(assetsDir, { recursive: true });
102103
fs.copyFileSync(sourcePath, destinationPath);
@@ -112,12 +113,10 @@ function findBuildingBlockLogo(buildingBlockDir) {
112113
* Parse README.md and extract relevant data
113114
*/
114115
function parseReadme(filePath) {
116+
const buildingBlockDir = path.dirname(filePath);
115117
const content = fs.readFileSync(filePath, "utf-8");
116118
const { data, content: body } = matter(content);
117-
const relativePath = filePath.replace(process.cwd(), "").replace(/\\/g, "/");
118-
const pathParts = relativePath.split(path.sep).filter(Boolean);
119-
const id = pathParts.slice(1, pathParts.length - 2).join("-");
120-
const platform = pathParts.length > 1 ? pathParts[1] : "unknown";
119+
const { id, platform } = getIdAndPlatform(buildingBlockDir);
121120
const howToMatch = body.match(/## How to Use([\s\S]*?)(##|$)/);
122121
const resourcesMatch = body.match(/## Resources([\s\S]*)/);
123122
const inputsMatch = body.match(/## Inputs([\s\S]*?)## Outputs/);
@@ -141,7 +140,7 @@ function parseReadme(filePath) {
141140
console.log(`🔗 GitHub remote URLs: ${JSON.stringify(githubUrls)}`);
142141
console.log(`🔗 File path: ${filePath}`);
143142

144-
const buildingBlockLogoPath = findBuildingBlockLogo(path.dirname(filePath));
143+
const buildingBlockLogoPath = findBuildingBlockLogo(buildingBlockDir);
145144

146145
return {
147146
id: id,
@@ -156,6 +155,21 @@ function parseReadme(filePath) {
156155
};
157156
}
158157

158+
/**
159+
* This returns the id and platform type from the file path.
160+
*
161+
* @param filePath The buildingblock directory
162+
*/
163+
function getIdAndPlatform(filePath) {
164+
const relativePath = filePath.replace(process.cwd(), "").replace(/\\/g, "/");
165+
const pathParts = relativePath.split(path.sep).filter(Boolean);
166+
// pathParts = [modules, <platform>, <module-name>, buildingblock]
167+
const id = pathParts.slice(1, pathParts.length - 1).join("-");
168+
const platform = pathParts.length > 1 ? pathParts[1] : "unknown";
169+
170+
return { id, platform };
171+
}
172+
159173
const repoRoot = path.resolve(__dirname, 'modules');
160174
const platformLogos = findPlatformLogos();
161175
const readmeFiles = findReadmes(repoRoot);

website/angular.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"cli": {
119119
"schematicCollections": [
120120
"@angular-eslint/schematics"
121-
]
121+
],
122+
"analytics": false
122123
}
123124
}
-9.65 KB
Binary file not shown.
-135 KB
Binary file not shown.

website/public/assets/building-block-logos/git-repo.svg

Lines changed: 0 additions & 2 deletions
This file was deleted.
-53.7 KB
Binary file not shown.

website/public/assets/building-block-logos/key-vault.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.
-46.6 KB
Binary file not shown.
-14.6 KB
Binary file not shown.
-103 KB
Binary file not shown.

0 commit comments

Comments
 (0)