Skip to content

Commit

Permalink
detect port count instead of hardcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Matos authored and Javier Matos committed Jul 16, 2024
1 parent a2541b6 commit 7fc27b6
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 55 deletions.
4 changes: 2 additions & 2 deletions en/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@
<div class="vcpkg-center-heading"><h2>About vcpkg</h2></div>
<div class="vcpkg-center-description">
vcpkg is a free C/C++ package manager for acquiring and managing libraries.
Choose from over 1500 open source libraries to download and build in a single step or add
Choose from 2451 open source libraries to download and build in a single step or add
your own private libraries to simplify your build process. Maintained by the Microsoft
C++ team and open source contributors.
C++ team and open source contributors.
</div>
</div>
</div>
Expand Down
118 changes: 113 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,117 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.6.0.min.js"></script>
<script src="dist/common.js"></script>
<script src="dist/localization.js"></script>
<title>vcpkg - Open source C/C++ dependency manager from Microsoft</title>
<meta name="description" content="vcpkg product homepage for C and C++ developers. Download, build, and manage C and C++ libraries for all platforms, buildsystems, and workflows.">
<meta name="keywords" content="vcpkg, C, C++, cpp, Microsoft, library, libraries, package manager, library manager">
<!-- Bing Webmaster Tools integration -->
<meta name="viewport" content="width=device-width">
<meta name="msvalidate.01" content="5704D9CB14CCA7C4612DC0FE14669DD1" />

<!-- our style sheet and fonts -->
<link href="/css/index.css" rel="stylesheet" />



<!-- our scripts -->
<script src="/dist/index.js"></script>
</head>
<body></body>
<body>
<div id="cookie-banner"></div>
<div id="loadNavBar"></div>
<div class="margin-box">
<div tabindex="-1" role="main" id="main">
<div class="header-block">
<img
class="logo-design-first-upper"
src="/assets/mark/mark-left.svg"
alt="vcpkg logo"
title="vcpkg logo"
/>
<div class="header-text-block">
<div class="vcpkg-name"><h1>vcpkg</h1></div>
<div class="vcpkg-description">
C/C++ dependency manager from Microsoft
<p><span>For all platforms, buildsystems, and workflows</span></p>
</div>

<a role="button" class="btn-lg vcpkg-btn-left text-nowrap" href="getting-started"
>Get started</a
>

<a role="button" class="btn-lg vcpkg-btn-right text-nowrap" href="packages"
>Browse Packages</a
>
</div>
<div style="position: relative">
<div class="vcpkg-center-block">
<div class="vcpkg-center-heading"><h2>About vcpkg</h2></div>
<div class="vcpkg-center-description">
vcpkg is a free C/C++ package manager for acquiring and managing libraries.
Choose from 2451 open source libraries to download and build in a single step or add
your own private libraries to simplify your build process. Maintained by the Microsoft
C++ team and open source contributors.
</div>
</div>
</div>

<div style="position: relative">
<img
class="logo-design-second-upper"
src="/assets/mark/logo-right.svg"
alt="vcpkg logo"
title="vcpkg logo"
/>
</div>
</div>
<div class="questions">
<p class="questions2"><h3>Simplicity and flexibility are central to vcpkg.</h3></p>
</div>
<div class="why-us-box-shadow">
<div class="why-us-flexbox">
<div class="why-us-group">
<img class="why-us-icon" src="/assets/mark/easy.svg" alt="easy icon" />
<div class="why-us-heading">Easy To Use</div>
<p class="why-us-description">
Download and build popular libraries in a single step.
Never worry about upstream dependencies or version conflicts.
Declare dependencies with commandline actions or in a manifest that can live with your repo.
Get support from the development team, documentation, and an active community.
</p>
</div>
<div class="why-us-group">
<img class="why-us-icon" src="/assets/mark/reliable.svg" alt="Universal" />
<div class="why-us-heading">Universal</div>
<p class="why-us-description">
vcpkg works with your preferred OS,
buildsystem, target architectures, IDE, editor, and continuous integration
process. Libraries are built from source and can be configured.
</p>
</div>
<div class="why-us-group">
<img class="why-us-icon" src="/assets/mark/secure.svg" alt="Reliable" />
<div class="why-us-heading">Reliable</div>
<p class="why-us-description">
Maintain consistency between local developer and CI/CD workflows.
Stay on your preferred library versions. Sync your dependency ecosystem with the rest of your team.
</p>
</div>
<div class="why-us-group">
<img class="why-us-icon" src="/assets/mark/open.svg" alt="For Everyone" />
<div class="why-us-heading">For Everyone</div>
<p class="why-us-description">
Whether you are a one-person team on a small open source project or a large
enterprise with complex build and security needs, take advantage of the latest
vcpkg features for your workflow. Cache binaries for faster consumption,
avoid diamond dependency resolution issues, reproduce identical builds for all developers,
CI machines, and containers. Bring your own libraries or consume popular public ones.
Take advantage of existing Visual Studio and Visual Studio Code integration.
</p>
</div>
</div>
</div>
</div>
</div>
<div id="loadFooter"></div>
</body>
</html>
52 changes: 37 additions & 15 deletions scripts/generateDetailedPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function generateGithubFileUrls(packageInfo, commitHash, vcpkgDir) {
}


async function GetPackageVersions(pkgName) {
async function getPackageVersions(pkgName) {
const pkgFolder = pkgName.charAt(0) + '-';
const pkgJsonFile = path.join('/', pkgName + '.json');
const versionFile = path.join(versionsDir, pkgFolder, pkgJsonFile);
Expand All @@ -59,7 +59,7 @@ async function GetPackageVersions(pkgName) {
return versionsArray;
}

function GetPackageFeatures(packageObj) {
function getPackageFeatures(packageObj) {
let featuresList = [];
if (packageObj && typeof packageObj.Features === 'object') {
for (const [featureName, featureDetails] of Object.entries(packageObj.Features)) {
Expand Down Expand Up @@ -96,36 +96,58 @@ function transform_dep(dep) {
}
}


async function renderDetailedPackages() {
async function renderAllTemplates() {
const commitHash = await getCommitHash(commitFilePath);

// Load all templates and data once at the beginning.
const [packageTemplate, navbarHtml, footerHtml, commonHeadHtml, packageDataSource] = await Promise.all([
fs.readFile(templatesDir + "/package.html", 'utf8'),
fs.readFile(templatesDir + "/navbar.html"),
fs.readFile(templatesDir + "/footer.html"),
fs.readFile(templatesDir + "/commonhead.html"),
const [packageTemplate, navbarHtml, footerHtml, commonHeadHtml, gettingStartedHtml, indexHtml, packagesHtml, packageDataSource] = await Promise.all([
fs.readFile(path.join(templatesDir, "package.html"), 'utf8'),
fs.readFile(path.join(templatesDir, "navbar.html")),
fs.readFile(path.join(templatesDir, "footer.html")),
fs.readFile(path.join(templatesDir, "commonhead.html")),
fs.readFile(path.join(templatesDir, "getting-started.html"), 'utf8'),
fs.readFile(path.join(templatesDir, "index.html"), 'utf8'),
fs.readFile(path.join(templatesDir, "packages.html"), 'utf8'),
readJsonFile(path.join(destDir, 'output.json'))
]);

const sharedData = {
navbar: navbarHtml,
footer: footerHtml,
commonhead: commonHeadHtml
};

const view = {
...sharedData,
numPackages: packageDataSource.Source.length
};

const commonTemplates = [
{ content: gettingStartedHtml, name: "getting-started.html" },
{ content: indexHtml, name: "index.html" },
{ content: packagesHtml, name: "packages.html" }
];

for (const { content, name } of commonTemplates) {
const renderedTemplate = renderTemplate(content, view);
await fs.writeFile(path.join(rootDir, "/en/", name), renderedTemplate);
}

for (let packageInfo of packageDataSource.Source) {
packageInfo.Documentation = packageInfo.Documentation || '';
packageInfo.LastUpdated = packageInfo.LastModified;
packageInfo.PortVersion = packageInfo['Port-Version'] || 0;
packageInfo.FeaturesContent = GetPackageFeatures(packageInfo);
packageInfo.FeaturesContent = getPackageFeatures(packageInfo);
packageInfo.supportedArchitectures = packageInfo['Supports'] ? [packageInfo['Supports']] : ["Supported on all triplets"];
packageInfo.dependenciesList = (packageInfo.Dependencies || []).map(transform_dep);
packageInfo.githubFileUrls = await generateGithubFileUrls(packageInfo, commitHash, vcpkgDir);
packageInfo.Homepage = packageInfo["homepage"];

// Gather all data needed for rendering.
const renderData = {
navbar: navbarHtml,
footer: footerHtml,
commonhead: commonHeadHtml,
...sharedData,
package: packageInfo,
packageVersions: await GetPackageVersions(packageInfo.Name),
packageVersions: await getPackageVersions(packageInfo.Name),
dependencies: packageInfo.dependenciesList,
features: packageInfo.FeaturesContent
};
Expand All @@ -138,7 +160,7 @@ async function renderDetailedPackages() {

async function main() {
await fs.mkdir(pkgDir, { recursive: true });
await renderDetailedPackages();
await renderAllTemplates();
}

main();
30 changes: 0 additions & 30 deletions scripts/generatePages.js

This file was deleted.

1 change: 0 additions & 1 deletion scripts/rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ fi

npm ci
rm -rf ../en
node generatePages.js
node generateDocs.js
node generateGitHubStars.js ../vcpkg $1
node generatePackages.js ../vcpkg
Expand Down
4 changes: 2 additions & 2 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
<div class="vcpkg-center-heading"><h2>About vcpkg</h2></div>
<div class="vcpkg-center-description">
vcpkg is a free C/C++ package manager for acquiring and managing libraries.
Choose from over 2300 open source libraries to download and build in a single step or add
Choose from {{{numPackages}}} open source libraries to download and build in a single step or add
your own private libraries to simplify your build process. Maintained by the Microsoft
C++ team and open source contributors.
C++ team and open source contributors.
</div>
</div>
</div>
Expand Down

0 comments on commit 7fc27b6

Please sign in to comment.