Skip to content

Commit aab1373

Browse files
authored
chore: remove dead code on release (#2025)
2 parents 28804cf + c9863a8 commit aab1373

8 files changed

Lines changed: 17 additions & 77 deletions

File tree

automation/utils/bin/rui-include-oss-in-artifact.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function main(): Promise<void> {
5454
if (!htmlAsset) {
5555
console.log(chalk.yellow("⚠️ No HTML file found in release - nothing to include"));
5656
console.log(chalk.gray(" Skipping MPK modification\n"));
57-
process.exit(0);
57+
return;
5858
}
5959

6060
console.log(chalk.green(`✅ Found HTML: ${htmlAsset.name}`));
@@ -80,8 +80,8 @@ async function main(): Promise<void> {
8080
await includeReadmeOssIntoMpk(htmlPath, mpkPath);
8181
console.log(chalk.green("✅ Merge completed"));
8282

83-
// Step 5: Remove old assets, upload patched MPK
84-
console.log(chalk.blue("\n🔄 Replacing MPK asset in release..."));
83+
// Step 5: Remove old assets and upload patched MPK
84+
console.log(chalk.blue("\n🔄 Replacing assets in release..."));
8585

8686
console.log(chalk.gray(` → Deleting old MPK asset...`));
8787
await gh.deleteReleaseAsset(mpkAsset.id);
@@ -93,16 +93,23 @@ async function main(): Promise<void> {
9393
const newAsset = await gh.uploadReleaseAsset(releaseId, mpkPath, mpkAsset.name);
9494

9595
console.log(chalk.green(`✅ Successfully replaced MPK asset (ID: ${newAsset.id})`));
96-
console.log(chalk.bold.green(`\n🎉 Process completed successfully!\n`));
96+
97+
// Summary
98+
console.log(chalk.bold.green(`\n🎉 Process completed successfully!`));
99+
console.log(chalk.gray(` Release: ${releaseTag}`));
100+
console.log(chalk.gray(` MPK: ${mpkAsset.name} (with embedded READMEOSS)\n`));
97101
} finally {
98-
// Step 8: Cleanup temp files
102+
// Cleanup temp files
99103
console.log(chalk.gray("🧹 Cleaning up temporary files..."));
100104
await rm("-rf", tmpFolder);
101105
}
102106
}
103107

104-
main().catch(error => {
105-
console.error(chalk.red(`\n❌ Error: ${error.message}\n`));
106-
console.error(error);
108+
main().catch((error: unknown) => {
109+
const message = error instanceof Error ? error.message : String(error);
110+
console.error(chalk.red(`\n❌ Error: ${message}\n`));
111+
if (error instanceof Error && error.stack) {
112+
console.error(chalk.gray(error.stack));
113+
}
107114
process.exit(1);
108115
});

automation/utils/src/oss-clearance.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@ import { mkdtemp, stat } from "node:fs/promises";
55
import { chmod, cp, exec, mkdir, mv, rm, unzip, zip } from "./shell";
66
import chalk from "chalk";
77

8-
export function findOssReadme(packageRoot: string, widgetName: string, version: string): string | undefined {
9-
const readmeossPattern = `**/*${widgetName}__${version}__READMEOSS_*.html`;
10-
11-
console.info(`Looking for READMEOSS file matching pattern: ${readmeossPattern}`);
12-
13-
// Use glob to find files matching the pattern in package root
14-
const matchingFiles = globSync(readmeossPattern, { cwd: packageRoot, absolute: true, ignore: "**/dist/**" });
15-
16-
return matchingFiles[0];
17-
}
18-
198
export function findAllReadmeOssLocally(): string[] {
209
const readmeossPattern = join("**", `*__*__READMEOSS_*.html`);
2110
const path1 = join(homedir(), "Downloads");
@@ -90,5 +79,7 @@ export async function includeReadmeOssIntoMpk(readmeOssPath: string, mpkPath: st
9079

9180
// zip it back
9281
await zip(unzipTarget, mpkPath);
82+
83+
// remove tmp folder
9384
rm("-rf", unzipTarget);
9485
}

automation/utils/src/steps.ts

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ 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-clearance";
1817

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

@@ -197,44 +196,6 @@ export async function addWidgetsToMpk({ config }: ModuleStepParams): Promise<voi
197196
rm("-rf", target);
198197
}
199198

200-
export async function addREADMEOSSToMpk({ config, info }: ModuleStepParams): Promise<void> {
201-
logStep("Add READMEOSS to mpk");
202-
203-
// Check that READMEOSS file exists in package root and find it by name pattern
204-
const packageRoot = config.paths.package;
205-
const widgetName = info.mxpackage.name;
206-
const version = info.version.format();
207-
208-
// We'll search for files matching the name and version, ignoring timestamp
209-
const readmeossFile = findOssReadme(packageRoot, widgetName, version);
210-
211-
if (!readmeossFile) {
212-
console.warn(`⚠️ READMEOSS file not found for ${widgetName} version ${version}.`);
213-
console.warn(` Skipping READMEOSS addition to mpk.`);
214-
return;
215-
}
216-
217-
console.info(`Found READMEOSS file: ${parse(readmeossFile).base}`);
218-
219-
const mpk = config.output.files.modulePackage;
220-
const mpkEntry = parse(mpk);
221-
const target = join(mpkEntry.dir, "tmp");
222-
223-
rm("-rf", target);
224-
225-
console.info("Unzip module mpk");
226-
await unzip(mpk, target);
227-
chmod("-R", "a+rw", target);
228-
229-
console.info(`Add READMEOSS file to ${mpkEntry.base}`);
230-
// Copy the READMEOSS file to the target directory
231-
cp(readmeossFile, target);
232-
233-
console.info("Create module zip archive");
234-
await zip(target, mpk);
235-
rm("-rf", target);
236-
}
237-
238199
export async function moveModuleToDist({ info, config }: ModuleStepParams): Promise<void> {
239200
logStep("Move module to dist");
240201

@@ -244,15 +205,6 @@ export async function moveModuleToDist({ info, config }: ModuleStepParams): Prom
244205
mkdir("-p", join(paths.dist, info.version.format()));
245206
// Can't use mv because of https://github.com/shelljs/shelljs/issues/878
246207
cp(output.files.modulePackage, output.files.mpk);
247-
248-
// Prepare OSS clearance folder structure
249-
const ossClearanceFolder = join(paths.dist, "SBOM_GENERATOR", `${info.mxpackage.name} ${info.version.format()}`);
250-
mkdir("-p", ossClearanceFolder);
251-
252-
// Copy module package to OSS clearance folder
253-
console.info(`Copying module package to OSS clearance folder: ${ossClearanceFolder}`);
254-
cp(output.files.modulePackage, join(ossClearanceFolder, `${info.mxpackage.name} ${info.version.format()}.mpk`));
255-
256208
rm(output.files.modulePackage);
257209
}
258210

packages/modules/calendar/scripts/release.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env ts-node-script
22

33
import {
4-
addREADMEOSSToMpk,
54
addWidgetsToMpk,
65
cloneTestProject,
76
copyModuleLicense,
@@ -24,7 +23,6 @@ async function main(): Promise<void> {
2423
copyWidgetsToProject,
2524
createModuleMpk,
2625
addWidgetsToMpk,
27-
addREADMEOSSToMpk,
2826
moveModuleToDist
2927
]
3028
});

packages/modules/data-widgets/scripts/release.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env ts-node-script
22

33
import {
4-
addREADMEOSSToMpk,
54
addWidgetsToMpk,
65
cloneTestProject,
76
copyActionsFiles,
@@ -31,7 +30,6 @@ async function main(): Promise<void> {
3130
copyModuleLicense,
3231
createModuleMpk,
3332
addWidgetsToMpk,
34-
addREADMEOSSToMpk,
3533
moveModuleToDist
3634
]
3735
});

packages/modules/file-uploader/scripts/release.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env ts-node-script
22

33
import {
4-
addREADMEOSSToMpk,
54
addWidgetsToMpk,
65
cloneTestProject,
76
copyModuleLicense,
@@ -24,7 +23,6 @@ async function main(): Promise<void> {
2423
copyWidgetsToProject,
2524
createModuleMpk,
2625
addWidgetsToMpk,
27-
addREADMEOSSToMpk,
2826
moveModuleToDist
2927
]
3028
});

packages/modules/google-tag/scripts/release.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env ts-node-script
22

33
import {
4-
addREADMEOSSToMpk,
54
addWidgetsToMpk,
65
cloneTestProject,
76
copyActionsFiles,
@@ -24,7 +23,6 @@ async function main(): Promise<void> {
2423
writeVersionAndLicenseToJSActions,
2524
createModuleMpk,
2625
addWidgetsToMpk,
27-
addREADMEOSSToMpk,
2826
moveModuleToDist
2927
]
3028
});

packages/modules/web-actions/scripts/release.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
addREADMEOSSToMpk,
32
cloneTestProject,
43
copyActionsFiles,
54
createModuleMpk,
@@ -30,7 +29,6 @@ async function main(): Promise<void> {
3029
copyThemesourceToProject,
3130
writeVersionAndLicenseToJSActions,
3231
createModuleMpk,
33-
addREADMEOSSToMpk,
3432
moveModuleToDist
3533
]
3634
});

0 commit comments

Comments
 (0)