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
42 changes: 41 additions & 1 deletion automation/run-e2e/lib/dev.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { spawnSync } from "node:child_process";
import { spawnSync, execSync } from "node:child_process";
import { delimiter } from "node:path";
import { fileURLToPath } from "node:url";
import parseArgs from "yargs-parser";
import c from "ansi-colors";
import enquirer from "enquirer";
import sh from "shelljs";
import { setupTestProject } from "./setup-test-project.mjs";
import { updateTestProject } from "./update-test-project.mjs";
import { await200 } from "./utils.mjs";
import * as config from "./config.mjs";

const { ls, exec } = sh;

export async function dev() {
console.log(c.cyan("Run e2e tests in development environment"));

Expand All @@ -29,6 +32,20 @@ export async function dev() {
}
};

if (!process.env.GITHUB_TOKEN) {
console.log("GITHUB_TOKEN not found. Fetching from GitHub CLI...");

const result = exec("gh auth token", { silent: true });

if (result.code === 0) {
process.env.GITHUB_TOKEN = result.stdout.trim();
console.log("Successfully set GITHUB_TOKEN from gh CLI.");
} else {
console.error('Error: Could not retrieve token. Ensure you are logged in via "gh auth login".');
process.exit(1);
}
}

// We add local node_modules/.bin to PATH to make cypress bin is available for
// any package in monorepo.
const packageBinariesPath = fileURLToPath(new URL("../node_modules/.bin", import.meta.url));
Expand All @@ -53,6 +70,29 @@ export async function dev() {
)
);

// Print out Mendix version from MPR file
try {
const mprFiles = ls(config.mprFileGlob);
if (mprFiles.length > 0) {
const mprFile = mprFiles[0];
try {
const version = execSync(`sqlite3 "${mprFile}" "select _ProductVersion from _MetaData;"`, {
encoding: "utf-8",
stdio: ["pipe", "pipe", "pipe"]
}).trim();
console.log(c.cyan(`Test project was created with Mendix version: ${c.bold(version)}`));
} catch (error) {
if (error.message.includes("sqlite3") || error.code === "ENOENT") {
console.log(c.gray("sqlite3 command not found, unable to get Mendix version info"));
} else {
console.log(c.gray("Unable to read Mendix version from project file"));
}
}
}
} catch {
console.log(c.gray("Unable to determine Mendix version"));
}

await enquirer.prompt({
type: "confirm",
name: "__ignore__",
Expand Down
12 changes: 9 additions & 3 deletions automation/utils/bin/rui-include-oss-in-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { gh } from "../src/github";
import { includeReadmeOssIntoMpk } from "../src/oss-clearance";
import { rm } from "../src/shell";
import { mkdtemp } from "node:fs/promises";
import { mkdtemp, stat } from "node:fs/promises";
import { join } from "node:path";
import { tmpdir } from "node:os";
import chalk from "chalk";
Expand Down Expand Up @@ -48,7 +48,7 @@ async function main(): Promise<void> {
throw new Error(`No MPK file found in release '${releaseTag}'`);
}

console.log(chalk.green(`✅ Found MPK: ${mpkAsset.name}`));
console.log(chalk.green(`✅ Found MPK: ${mpkAsset.name} (${mpkAsset.size} bytes)`));

// Step 2: Check if HTML file exists
if (!htmlAsset) {
Expand All @@ -57,7 +57,7 @@ async function main(): Promise<void> {
return;
}

console.log(chalk.green(`✅ Found HTML: ${htmlAsset.name}`));
console.log(chalk.green(`✅ Found HTML: ${htmlAsset.name} (${htmlAsset.size} bytes)`));

// Step 3: Download both files to temp directory
console.log(chalk.blue("\n📥 Downloading artifacts..."));
Expand All @@ -80,6 +80,11 @@ async function main(): Promise<void> {
await includeReadmeOssIntoMpk(htmlPath, mpkPath);
console.log(chalk.green("✅ Merge completed"));

// Get modified MPK size
const modifiedMpkStats = await stat(mpkPath);
const sizeDiff = modifiedMpkStats.size - mpkAsset.size;
console.log(chalk.cyan(`ℹ️ Modified MPK size: ${modifiedMpkStats.size} bytes (+${sizeDiff} bytes)`));

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

Expand All @@ -93,6 +98,7 @@ 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.cyan(`ℹ️ New MPK size: ${newAsset.size} bytes`));

// Summary
console.log(chalk.bold.green(`\n🎉 Process completed successfully!`));
Expand Down
Loading
Loading