Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,8 @@ function replaceStaticImagesInJsonBlob(cfg: any, staticAssetHandler: (fileLocati
return pxt.replaceStringsInJsonBlob(cfg, /^\.?\/static\/.+\.(png|gif|jpeg|jpg|svg|mp4|ico)$/i, staticAssetHandler);
}

const GENERATED_FILE_DECLARATION = `<!-- This file is generated from pxtarget.json during "pxt serve". Do not edit. -->\n\n`;

function saveThemeJson(cfg: pxt.TargetBundle, localDir?: boolean, packaged?: boolean) {
cfg.appTheme.id = cfg.id
cfg.appTheme.title = cfg.title
Expand Down Expand Up @@ -1929,19 +1931,15 @@ function saveThemeJson(cfg: pxt.TargetBundle, localDir?: boolean, packaged?: boo
if (targetConfig?.galleries) {
const docsRoot = nodeutil.targetDir;
let gcards: pxt.CodeCard[] = [];
let tocmd: string =
`# Projects

`;
let tocmd: string = GENERATED_FILE_DECLARATION + `# Projects\n`;
Object.keys(targetConfig.galleries).forEach(k => {
targetStrings[k] = k;
const galleryUrl = getGalleryUrl(targetConfig.galleries[k])
const gallerymd = nodeutil.resolveMd(docsRoot, galleryUrl);
const gallery = pxt.gallery.parseGalleryMardown(gallerymd);
const gurl = `/${galleryUrl.replace(/^\//, '')}`;
tocmd +=
`* [${k}](${gurl})
`;
`* [${k}](${gurl})\n`;
const gcard: pxt.CodeCard = {
name: k,
url: gurl
Expand All @@ -1964,18 +1962,21 @@ function saveThemeJson(cfg: pxt.TargetBundle, localDir?: boolean, packaged?: boo
});

nodeutil.writeFileSync(path.join(docsRoot, "docs/projects/SUMMARY.md"), tocmd, { encoding: "utf8" });
nodeutil.writeFileSync(path.join(docsRoot, "docs/projects.md"),
`# Projects

\`\`\`codecard
${JSON.stringify(gcards, null, 4)}
\`\`\`

## See Also

${gcards.map(gcard => `[${gcard.name}](${gcard.url})`).join(',\n')}

`, { encoding: "utf8" });
const PROJECTS_MD_CONTENT = [
GENERATED_FILE_DECLARATION,
'',
'# Projects',
'',
'```codecard',
JSON.stringify(gcards, null, 4),
'```',
'',
'## See Also',
'',
gcards.map(gcard => `[${gcard.name}](${gcard.url})`).join(',\n')
].join('\n');

Comment on lines 1964 to +1978
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The builds for SUMMARY.md and PROJECTS.md share a similar pattern; consider extracting a helper to assemble header + body arrays into a string to reduce duplication and improve readability.

Copilot uses AI. Check for mistakes.
nodeutil.writeFileSync(path.join(docsRoot, "docs/projects.md"), PROJECTS_MD_CONTENT, { encoding: "utf8" });
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider appending a trailing newline to PROJECTS_MD_CONTENT to ensure the generated file ends with a newline, following POSIX conventions.

Suggested change
nodeutil.writeFileSync(path.join(docsRoot, "docs/projects.md"), PROJECTS_MD_CONTENT, { encoding: "utf8" });
nodeutil.writeFileSync(path.join(docsRoot, "docs/projects.md"), PROJECTS_MD_CONTENT + '\n', { encoding: "utf8" });

Copilot uses AI. Check for mistakes.
}
const multiplayerGames = targetConfig?.multiplayer?.games;
for (const game of (multiplayerGames ?? [])) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pxt-core",
"version": "11.4.7",
"version": "11.4.8",
"description": "Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors",
"keywords": [
"TypeScript",
Expand Down
Loading