Skip to content

Commit caef300

Browse files
authored
chore: add removal of readmeos file (#1881)
2 parents a0930e6 + 4a28dc1 commit caef300

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

automation/utils/src/changelog.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { gh } from "./github";
22
import { PublishedInfo } from "./package-info";
33
import { exec, popd, pushd } from "./shell";
4+
import { findOssReadme } from "./oss-readme";
5+
import { join } from "path";
46

57
export async function updateChangelogsAndCreatePR(
68
info: PublishedInfo,
@@ -50,14 +52,22 @@ export async function updateChangelogsAndCreatePR(
5052
const { stdout: root } = await exec(`git rev-parse --show-toplevel`, { stdio: "pipe" });
5153
pushd(root.trim());
5254
await exec(`git add '*/CHANGELOG.md'`);
55+
56+
const path = process.cwd();
57+
const readmeossFile = findOssReadme(path, info.mxpackage.name, info.version.format());
58+
if (readmeossFile) {
59+
console.log(`Removing OSS clearance readme file '${readmeossFile}'...`);
60+
await exec(`git rm '${join(path, readmeossFile)}'`);
61+
}
62+
5363
await exec(`git commit -m "chore(${info.name}): update changelog"`);
5464
await exec(`git push ${remoteName} ${releaseBranchName}`);
5565
popd();
5666

5767
console.log(`Creating pull request for '${releaseBranchName}'`);
5868
await gh.createGithubPRFrom({
5969
title: `${appName} v${info.version.format()}: Update changelog`,
60-
body: "This is an automated PR that merges changelog update to master.",
70+
body: "This is an automated PR that merges changelog update to main branch.",
6171
base: "main",
6272
head: releaseBranchName,
6373
repo: info.repository.url

automation/utils/src/oss-readme.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { parse } from "path";
2+
import { find } from "./shell";
3+
4+
export function findOssReadme(packageRoot: string, widgetName: string, version: string): string | undefined {
5+
const readmeossPattern = `*${widgetName}__${version}__READMEOSS_*.html`;
6+
7+
console.info(`Looking for READMEOSS file matching pattern: ${readmeossPattern}`);
8+
9+
// Find files matching the pattern in package root
10+
const matchingFiles = find(packageRoot).filter(file => {
11+
const fileName = parse(file).base;
12+
// Check if filename contains the widget name, version, and READMEOSS
13+
return fileName.includes(`${widgetName}__${version}__READMEOSS_`) && fileName.endsWith(".html");
14+
});
15+
16+
return matchingFiles[0];
17+
}

automation/utils/src/steps.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ModuleInfo, PackageInfo, WidgetInfo } from "./package-info";
1414
import { addFilesToPackageXml, PackageType } from "./package-xml";
1515
import { chmod, cp, ensureFileExists, exec, find, mkdir, popd, pushd, rm, unzip, zip } from "./shell";
1616
import chalk from "chalk";
17+
import { findOssReadme } from "./oss-readme";
1718

1819
type Step<Info, Config> = (params: { info: Info; config: Config }) => Promise<void>;
1920

@@ -205,30 +206,17 @@ export async function addREADMEOSSToMpk({ config, info }: ModuleStepParams): Pro
205206
const version = info.version.format();
206207

207208
// We'll search for files matching the name and version, ignoring timestamp
208-
const readmeossPattern = `*${widgetName}__${version}__READMEOSS_*.html`;
209+
const readmeossFile = findOssReadme(packageRoot, widgetName, version);
209210

210-
console.info(`Looking for READMEOSS file matching pattern: ${readmeossPattern}`);
211-
212-
// Find files matching the pattern in package root
213-
const matchingFiles = find(packageRoot).filter(file => {
214-
const fileName = parse(file).base;
215-
// Check if filename contains the widget name, version, and READMEOSS
216-
return fileName.includes(`${widgetName}__${version}__READMEOSS_`) && fileName.endsWith(".html");
217-
});
218-
219-
if (matchingFiles.length === 0) {
220-
console.warn(
221-
`⚠️ READMEOSS file not found for ${widgetName} version ${version}. Expected pattern: ${readmeossPattern}`
222-
);
211+
if (!readmeossFile) {
212+
console.warn(`⚠️ READMEOSS file not found for ${widgetName} version ${version}.`);
223213
console.warn(` Skipping READMEOSS addition to mpk.`);
224214
return;
225215
}
226216

227-
const readmeossFile = matchingFiles[0];
228217
console.info(`Found READMEOSS file: ${parse(readmeossFile).base}`);
229218

230219
const mpk = config.output.files.modulePackage;
231-
const widgets = await getMpkPaths(config.dependencies);
232220
const mpkEntry = parse(mpk);
233221
const target = join(mpkEntry.dir, "tmp");
234222

0 commit comments

Comments
 (0)