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
23 changes: 15 additions & 8 deletions automation/utils/bin/rui-include-oss-in-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function main(): Promise<void> {
if (!htmlAsset) {
console.log(chalk.yellow("⚠️ No HTML file found in release - nothing to include"));
console.log(chalk.gray(" Skipping MPK modification\n"));
process.exit(0);
return;
}

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

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

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

console.log(chalk.green(`✅ Successfully replaced MPK asset (ID: ${newAsset.id})`));
console.log(chalk.bold.green(`\n🎉 Process completed successfully!\n`));

// Summary
console.log(chalk.bold.green(`\n🎉 Process completed successfully!`));
console.log(chalk.gray(` Release: ${releaseTag}`));
console.log(chalk.gray(` MPK: ${mpkAsset.name} (with embedded READMEOSS)\n`));
} finally {
// Step 8: Cleanup temp files
// Cleanup temp files
console.log(chalk.gray("🧹 Cleaning up temporary files..."));
await rm("-rf", tmpFolder);
}
}

main().catch(error => {
console.error(chalk.red(`\n❌ Error: ${error.message}\n`));
console.error(error);
main().catch((error: unknown) => {
const message = error instanceof Error ? error.message : String(error);
console.error(chalk.red(`\n❌ Error: ${message}\n`));
if (error instanceof Error && error.stack) {
console.error(chalk.gray(error.stack));
}
process.exit(1);
});
13 changes: 2 additions & 11 deletions automation/utils/src/oss-clearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,8 @@
import { homedir, tmpdir } from "node:os";
import { mkdtemp, stat } from "node:fs/promises";
import { chmod, cp, exec, mkdir, mv, rm, unzip, zip } from "./shell";
import chalk from "chalk";

Check warning on line 6 in automation/utils/src/oss-clearance.ts

View workflow job for this annotation

GitHub Actions / Run code quality check

'chalk' is defined but never used. Allowed unused vars must match /^_|createElement/u

export function findOssReadme(packageRoot: string, widgetName: string, version: string): string | undefined {
const readmeossPattern = `**/*${widgetName}__${version}__READMEOSS_*.html`;

console.info(`Looking for READMEOSS file matching pattern: ${readmeossPattern}`);

// Use glob to find files matching the pattern in package root
const matchingFiles = globSync(readmeossPattern, { cwd: packageRoot, absolute: true, ignore: "**/dist/**" });

return matchingFiles[0];
}

export function findAllReadmeOssLocally(): string[] {
const readmeossPattern = join("**", `*__*__READMEOSS_*.html`);
const path1 = join(homedir(), "Downloads");
Expand Down Expand Up @@ -90,5 +79,7 @@

// zip it back
await zip(unzipTarget, mpkPath);

// remove tmp folder
rm("-rf", unzipTarget);
}
48 changes: 0 additions & 48 deletions automation/utils/src/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { ModuleInfo, PackageInfo, WidgetInfo } from "./package-info";
import { addFilesToPackageXml, PackageType } from "./package-xml";
import { chmod, cp, ensureFileExists, exec, find, mkdir, popd, pushd, rm, unzip, zip } from "./shell";
import chalk from "chalk";
import { findOssReadme } from "./oss-clearance";

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

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

export async function addREADMEOSSToMpk({ config, info }: ModuleStepParams): Promise<void> {
logStep("Add READMEOSS to mpk");

// Check that READMEOSS file exists in package root and find it by name pattern
const packageRoot = config.paths.package;
const widgetName = info.mxpackage.name;
const version = info.version.format();

// We'll search for files matching the name and version, ignoring timestamp
const readmeossFile = findOssReadme(packageRoot, widgetName, version);

if (!readmeossFile) {
console.warn(`⚠️ READMEOSS file not found for ${widgetName} version ${version}.`);
console.warn(` Skipping READMEOSS addition to mpk.`);
return;
}

console.info(`Found READMEOSS file: ${parse(readmeossFile).base}`);

const mpk = config.output.files.modulePackage;
const mpkEntry = parse(mpk);
const target = join(mpkEntry.dir, "tmp");

rm("-rf", target);

console.info("Unzip module mpk");
await unzip(mpk, target);
chmod("-R", "a+rw", target);

console.info(`Add READMEOSS file to ${mpkEntry.base}`);
// Copy the READMEOSS file to the target directory
cp(readmeossFile, target);

console.info("Create module zip archive");
await zip(target, mpk);
rm("-rf", target);
}

export async function moveModuleToDist({ info, config }: ModuleStepParams): Promise<void> {
logStep("Move module to dist");

Expand All @@ -244,15 +205,6 @@ export async function moveModuleToDist({ info, config }: ModuleStepParams): Prom
mkdir("-p", join(paths.dist, info.version.format()));
// Can't use mv because of https://github.com/shelljs/shelljs/issues/878
cp(output.files.modulePackage, output.files.mpk);

// Prepare OSS clearance folder structure
const ossClearanceFolder = join(paths.dist, "SBOM_GENERATOR", `${info.mxpackage.name} ${info.version.format()}`);
mkdir("-p", ossClearanceFolder);

// Copy module package to OSS clearance folder
console.info(`Copying module package to OSS clearance folder: ${ossClearanceFolder}`);
cp(output.files.modulePackage, join(ossClearanceFolder, `${info.mxpackage.name} ${info.version.format()}.mpk`));

rm(output.files.modulePackage);
}

Expand Down
2 changes: 0 additions & 2 deletions packages/modules/calendar/scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env ts-node-script

import {
addREADMEOSSToMpk,
addWidgetsToMpk,
cloneTestProject,
copyModuleLicense,
Expand All @@ -24,7 +23,6 @@ async function main(): Promise<void> {
copyWidgetsToProject,
createModuleMpk,
addWidgetsToMpk,
addREADMEOSSToMpk,
moveModuleToDist
]
});
Expand Down
2 changes: 0 additions & 2 deletions packages/modules/data-widgets/scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env ts-node-script

import {
addREADMEOSSToMpk,
addWidgetsToMpk,
cloneTestProject,
copyActionsFiles,
Expand Down Expand Up @@ -31,7 +30,6 @@ async function main(): Promise<void> {
copyModuleLicense,
createModuleMpk,
addWidgetsToMpk,
addREADMEOSSToMpk,
moveModuleToDist
]
});
Expand Down
2 changes: 0 additions & 2 deletions packages/modules/file-uploader/scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env ts-node-script

import {
addREADMEOSSToMpk,
addWidgetsToMpk,
cloneTestProject,
copyModuleLicense,
Expand All @@ -24,7 +23,6 @@ async function main(): Promise<void> {
copyWidgetsToProject,
createModuleMpk,
addWidgetsToMpk,
addREADMEOSSToMpk,
moveModuleToDist
]
});
Expand Down
2 changes: 0 additions & 2 deletions packages/modules/google-tag/scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env ts-node-script

import {
addREADMEOSSToMpk,
addWidgetsToMpk,
cloneTestProject,
copyActionsFiles,
Expand All @@ -24,7 +23,6 @@ async function main(): Promise<void> {
writeVersionAndLicenseToJSActions,
createModuleMpk,
addWidgetsToMpk,
addREADMEOSSToMpk,
moveModuleToDist
]
});
Expand Down
2 changes: 0 additions & 2 deletions packages/modules/web-actions/scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
addREADMEOSSToMpk,
cloneTestProject,
copyActionsFiles,
createModuleMpk,
Expand Down Expand Up @@ -30,7 +29,6 @@ async function main(): Promise<void> {
copyThemesourceToProject,
writeVersionAndLicenseToJSActions,
createModuleMpk,
addREADMEOSSToMpk,
moveModuleToDist
]
});
Expand Down
Loading