Skip to content

Commit b1ab8f8

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

File tree

13 files changed

+44
-31
lines changed

13 files changed

+44
-31
lines changed

index.ts

Lines changed: 21 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/);
@@ -140,8 +139,9 @@ function parseReadme(filePath) {
140139
const githubUrls = getGithubRemoteUrls(filePath);
141140
console.log(`🔗 GitHub remote URLs: ${JSON.stringify(githubUrls)}`);
142141
console.log(`🔗 File path: ${filePath}`);
142+
console.log('ID=' + id);
143143

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

146146
return {
147147
id: id,
@@ -156,6 +156,21 @@ function parseReadme(filePath) {
156156
};
157157
}
158158

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

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

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

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

Lines changed: 0 additions & 1 deletion
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)