mirror of
https://github.com/podman-desktop/podman-desktop
synced 2026-04-21 09:37:22 +00:00
Some checks are pending
Argos CI Screenshots / take screenshots (push) Waiting to run
Publish codecov report from main branch / Run tests and push coverage result (push) Waiting to run
e2e-kubernetes-tests-main / Run All E2E tests (push) Waiting to run
e2e-tests-main / Run All E2E tests (push) Waiting to run
e2e-tests-main / windows-11-arm update e2e tests - custom-extensions (push) Waiting to run
e2e-tests-main / windows-2025 update e2e tests - custom-extensions (push) Waiting to run
e2e-tests-main / windows-11-arm update e2e tests - vanilla (push) Waiting to run
e2e-tests-main / windows-2025 update e2e tests - vanilla (push) Waiting to run
e2e-tests-main / macos-15-intel update e2e tests (push) Waiting to run
e2e-tests-main / macos-26 update e2e tests (push) Waiting to run
Managed configuration tests / Managed configuration tests - macos-latest (push) Waiting to run
Managed configuration tests / Managed configuration tests - ubuntu-latest (push) Waiting to run
Managed configuration tests / Managed configuration tests - windows-2025 (push) Waiting to run
next build / Build / windows-2025 (push) Blocked by required conditions
next build / Release (push) Blocked by required conditions
next build / Tagging (push) Waiting to run
next build / Build / macos-15 (push) Blocked by required conditions
next build / Build / ubuntu-24.04 (push) Blocked by required conditions
Publish NPM packages to npmjs.com using OIDC / Prepare version info (push) Waiting to run
Publish NPM packages to npmjs.com using OIDC / Publish to npm (push) Blocked by required conditions
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Publish Website / Build and deploy website (push) Waiting to run
chore(website): prefer-import-in-mock Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com>
81 lines
3.2 KiB
TypeScript
81 lines
3.2 KiB
TypeScript
/**********************************************************************
|
|
* Copyright (C) 2024 Red Hat, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
***********************************************************************/
|
|
|
|
import { existsSync } from 'node:fs';
|
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
|
|
import type {
|
|
DefaultParseFrontMatter,
|
|
ParseFrontMatterParams,
|
|
ParseFrontMatterResult,
|
|
} from '@docusaurus/types/src/config';
|
|
|
|
export async function createNotesFiles(
|
|
params: ParseFrontMatterParams & {
|
|
defaultParseFrontMatter: DefaultParseFrontMatter;
|
|
},
|
|
): Promise<ParseFrontMatterResult> {
|
|
const result = await params.defaultParseFrontMatter(params);
|
|
// eslint-disable-next-line sonarjs/slow-regex
|
|
const versionRegex = /\d+\.\d+/;
|
|
if (
|
|
result.frontMatter.title &&
|
|
/[Rr]elease/.exec(String(result.frontMatter.title)) &&
|
|
versionRegex.exec(String(result.frontMatter.title))
|
|
) {
|
|
const versionMatch = versionRegex.exec(String(result.frontMatter.title)) ?? [];
|
|
const version = versionMatch ? versionMatch[0] : '';
|
|
if (version) {
|
|
const folderName = './static/release-notes';
|
|
const fileContent = await readFile(params.filePath, { encoding: 'utf-8' });
|
|
const resultText = fileContent.split('---', 3);
|
|
|
|
// get release image url
|
|
const imagePath = /image: (.+)\n/.exec(resultText[1]);
|
|
const imageName = imagePath ? imagePath[1] : '';
|
|
const imageUrl = imageName ? `https://podman-desktop.io${imageName}` : '';
|
|
const pageName = /slug: (.+)\n/.exec(resultText[1]);
|
|
const blogName = pageName ? pageName[1] : `podman-desktop-release-${version}`;
|
|
const blogUrl = `https://podman-desktop.io/blog/${blogName}`;
|
|
|
|
// get summary part of release notes
|
|
const text = resultText[2]
|
|
.replace(/!\[.+\)\n/, '') // remove image link
|
|
.replace(/\[Click here to download it\]\(.+\)!/, '') //remove download new version
|
|
.replace(/\n(\n)+/g, '\n') // change all multi-newlines chars to one newline char
|
|
.split('\n');
|
|
|
|
const summary = text.filter(line => line.includes('- **')); // all summary bullet points start with "- **"
|
|
const summaryText = summary.slice(0, 4).join('\n'); // limit the number of bullet points to 4
|
|
const titleText = text.filter(line => !line.includes('import') && line)[0];
|
|
|
|
const jsonInput = { image: imageUrl, blog: blogUrl, title: titleText, summary: summaryText };
|
|
|
|
if (!existsSync(folderName)) {
|
|
try {
|
|
await mkdir(folderName);
|
|
} catch (error) {
|
|
// directory already exists
|
|
}
|
|
}
|
|
|
|
await writeFile(`${folderName}/${version}.json`, JSON.stringify(jsonInput));
|
|
}
|
|
}
|
|
return result;
|
|
}
|