🐛 Fix formatting and testing code
This commit is contained in:
@@ -39,8 +39,8 @@
|
|||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
"cli": "cross-env NODE_ENV=development rollup -c -w",
|
"cli": "cross-env NODE_ENV=development rollup -c -w",
|
||||||
"cli:build": "cross-env NODE_ENV=production rollup -c",
|
"cli:build": "cross-env NODE_ENV=production rollup -c",
|
||||||
"test": "npm run cli:build && PAKE_CREATE_APP=1 node tests/index.js",
|
"test": "npm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js",
|
||||||
"format": "prettier --write . --ignore-unknown && cd src-tauri && cargo fmt --verbose",
|
"format": "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose",
|
||||||
"prepublishOnly": "npm run cli:build"
|
"prepublishOnly": "npm run cli:build"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -28,11 +28,7 @@ pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) ->
|
|||||||
serde_json::to_string(&window_config).unwrap()
|
serde_json::to_string(&window_config).unwrap()
|
||||||
);
|
);
|
||||||
|
|
||||||
let window_title = window_config
|
let window_title = window_config.title.as_deref().unwrap_or("");
|
||||||
.title
|
|
||||||
.as_ref()
|
|
||||||
.map(|t| t.as_str())
|
|
||||||
.unwrap_or("");
|
|
||||||
|
|
||||||
let mut window_builder = WebviewWindowBuilder::new(app, "pake", url)
|
let mut window_builder = WebviewWindowBuilder::new(app, "pake", url)
|
||||||
.title(window_title)
|
.title(window_title)
|
||||||
|
|||||||
110
tests/index.js
110
tests/index.js
@@ -610,11 +610,64 @@ class PakeTestRunner {
|
|||||||
async () => {
|
async () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const testName = "GitHubRealBuild";
|
const testName = "GitHubRealBuild";
|
||||||
const appFile = path.join(config.PROJECT_ROOT, `${testName}.app`);
|
// Platform-specific output files
|
||||||
const dmgFile = path.join(config.PROJECT_ROOT, `${testName}.dmg`);
|
const outputFiles = {
|
||||||
|
darwin: {
|
||||||
|
app: path.join(config.PROJECT_ROOT, `${testName}.app`),
|
||||||
|
installer: path.join(config.PROJECT_ROOT, `${testName}.dmg`),
|
||||||
|
},
|
||||||
|
linux: {
|
||||||
|
app: path.join(
|
||||||
|
config.PROJECT_ROOT,
|
||||||
|
`src-tauri/target/release/bundle/deb/${testName.toLowerCase()}_*.deb`,
|
||||||
|
),
|
||||||
|
installer: path.join(
|
||||||
|
config.PROJECT_ROOT,
|
||||||
|
`src-tauri/target/release/bundle/appimage/${testName.toLowerCase()}_*.AppImage`,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
win32: {
|
||||||
|
app: path.join(config.PROJECT_ROOT, `${testName}.exe`),
|
||||||
|
installer: path.join(config.PROJECT_ROOT, `${testName}.msi`),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const platform = process.platform;
|
||||||
|
const expectedFiles = outputFiles[platform] || outputFiles.darwin;
|
||||||
|
|
||||||
|
// Helper function to check if files exist (handles wildcards for Linux)
|
||||||
|
const checkFileExists = (filePath) => {
|
||||||
|
if (filePath.includes("*")) {
|
||||||
|
const dir = path.dirname(filePath);
|
||||||
|
const pattern = path.basename(filePath);
|
||||||
|
try {
|
||||||
|
const files = fs.readdirSync(dir);
|
||||||
|
const regex = new RegExp(pattern.replace(/\*/g, ".*"));
|
||||||
|
return files.some((file) => regex.test(file));
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fs.existsSync(filePath);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getActualFilePath = (filePath) => {
|
||||||
|
if (filePath.includes("*")) {
|
||||||
|
const dir = path.dirname(filePath);
|
||||||
|
const pattern = path.basename(filePath);
|
||||||
|
try {
|
||||||
|
const files = fs.readdirSync(dir);
|
||||||
|
const regex = new RegExp(pattern.replace(/\*/g, ".*"));
|
||||||
|
const match = files.find((file) => regex.test(file));
|
||||||
|
return match ? path.join(dir, match) : filePath;
|
||||||
|
} catch {
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filePath;
|
||||||
|
};
|
||||||
|
|
||||||
console.log(`🔧 Starting real build test for GitHub.com...`);
|
console.log(`🔧 Starting real build test for GitHub.com...`);
|
||||||
console.log(`📝 Expected output: ${appFile}`);
|
console.log(`📝 Expected output: ${expectedFiles.app}`);
|
||||||
|
|
||||||
const command = `node "${config.CLI_PATH}" "https://github.com" --name "${testName}" --width 1200 --height 800 --hide-title-bar`;
|
const command = `node "${config.CLI_PATH}" "https://github.com" --name "${testName}" --width 1200 --height 800 --hide-title-bar`;
|
||||||
|
|
||||||
@@ -630,8 +683,6 @@ class PakeTestRunner {
|
|||||||
|
|
||||||
let buildStarted = false;
|
let buildStarted = false;
|
||||||
let compilationStarted = false;
|
let compilationStarted = false;
|
||||||
let bundlingStarted = false;
|
|
||||||
let buildCompleted = false;
|
|
||||||
|
|
||||||
// Track progress without too much noise
|
// Track progress without too much noise
|
||||||
child.stdout.on("data", (data) => {
|
child.stdout.on("data", (data) => {
|
||||||
@@ -648,11 +699,9 @@ class PakeTestRunner {
|
|||||||
console.log(" ⚙️ Compiling...");
|
console.log(" ⚙️ Compiling...");
|
||||||
}
|
}
|
||||||
if (output.includes("Bundling")) {
|
if (output.includes("Bundling")) {
|
||||||
bundlingStarted = true;
|
|
||||||
console.log(" 📦 Bundling...");
|
console.log(" 📦 Bundling...");
|
||||||
}
|
}
|
||||||
if (output.includes("Built application at:")) {
|
if (output.includes("Built application at:")) {
|
||||||
buildCompleted = true;
|
|
||||||
console.log(" ✅ Build completed!");
|
console.log(" ✅ Build completed!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -661,31 +710,35 @@ class PakeTestRunner {
|
|||||||
const output = data.toString();
|
const output = data.toString();
|
||||||
if (output.includes("Building app")) buildStarted = true;
|
if (output.includes("Building app")) buildStarted = true;
|
||||||
if (output.includes("Compiling")) compilationStarted = true;
|
if (output.includes("Compiling")) compilationStarted = true;
|
||||||
if (output.includes("Bundling")) bundlingStarted = true;
|
|
||||||
if (output.includes("Finished"))
|
if (output.includes("Finished"))
|
||||||
console.log(" ✅ Compilation finished!");
|
console.log(" ✅ Compilation finished!");
|
||||||
if (output.includes("Built application at:")) buildCompleted = true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Real timeout - 8 minutes for actual build
|
// Real timeout - 8 minutes for actual build
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
const appExists = fs.existsSync(appFile);
|
const appExists = checkFileExists(expectedFiles.app);
|
||||||
const dmgExists = fs.existsSync(dmgFile);
|
const installerExists = checkFileExists(expectedFiles.installer);
|
||||||
|
|
||||||
if (appExists) {
|
if (appExists) {
|
||||||
console.log(
|
console.log(
|
||||||
" 🎉 Build completed successfully (app file exists)!",
|
" 🎉 Build completed successfully (app file exists)!",
|
||||||
);
|
);
|
||||||
console.log(` 📱 App location: ${appFile}`);
|
console.log(
|
||||||
if (dmgExists) {
|
` 📱 App location: ${getActualFilePath(expectedFiles.app)}`,
|
||||||
console.log(` 💿 DMG location: ${dmgFile}`);
|
);
|
||||||
|
if (installerExists) {
|
||||||
|
console.log(
|
||||||
|
` 💿 Installer location: ${getActualFilePath(expectedFiles.installer)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
console.log(" ✨ Build artifacts preserved for inspection");
|
console.log(" ✨ Build artifacts preserved for inspection");
|
||||||
child.kill("SIGTERM");
|
child.kill("SIGTERM");
|
||||||
resolve(true);
|
resolve(true);
|
||||||
} else {
|
} else {
|
||||||
console.log(" ❌ Build timeout - no app file generated");
|
console.log(
|
||||||
console.log(` 📍 Expected location: ${appFile}`);
|
" ⚠️ Build process completed but no app file found",
|
||||||
|
);
|
||||||
|
console.log(` 📍 Expected location: ${expectedFiles.app}`);
|
||||||
child.kill("SIGTERM");
|
child.kill("SIGTERM");
|
||||||
reject(new Error("Real build test timeout"));
|
reject(new Error("Real build test timeout"));
|
||||||
}
|
}
|
||||||
@@ -694,18 +747,18 @@ class PakeTestRunner {
|
|||||||
child.on("close", (code) => {
|
child.on("close", (code) => {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
|
|
||||||
const appExists = fs.existsSync(appFile);
|
const appExists = checkFileExists(expectedFiles.app);
|
||||||
const dmgExists = fs.existsSync(dmgFile);
|
const installerExists = checkFileExists(expectedFiles.installer);
|
||||||
|
const actualAppPath = getActualFilePath(expectedFiles.app);
|
||||||
// DON'T track files for cleanup - let user see the results
|
const actualInstallerPath = getActualFilePath(
|
||||||
// this.trackTempFile(appFile);
|
expectedFiles.installer,
|
||||||
// this.trackTempFile(dmgFile);
|
);
|
||||||
|
|
||||||
if (appExists) {
|
if (appExists) {
|
||||||
console.log(" 🎉 Real build test SUCCESS: App file generated!");
|
console.log(" 🎉 Real build test SUCCESS: App file generated!");
|
||||||
console.log(` 📱 App location: ${appFile}`);
|
console.log(` 📱 App location: ${actualAppPath}`);
|
||||||
if (dmgExists) {
|
if (installerExists) {
|
||||||
console.log(` 💿 DMG location: ${dmgFile}`);
|
console.log(` 💿 Installer location: ${actualInstallerPath}`);
|
||||||
}
|
}
|
||||||
console.log(" ✨ Build artifacts preserved for inspection");
|
console.log(" ✨ Build artifacts preserved for inspection");
|
||||||
resolve(true);
|
resolve(true);
|
||||||
@@ -713,7 +766,7 @@ class PakeTestRunner {
|
|||||||
console.log(
|
console.log(
|
||||||
" ⚠️ Build process completed but no app file found",
|
" ⚠️ Build process completed but no app file found",
|
||||||
);
|
);
|
||||||
console.log(` 📍 Expected location: ${appFile}`);
|
console.log(` 📍 Expected location: ${expectedFiles.app}`);
|
||||||
resolve(false);
|
resolve(false);
|
||||||
} else {
|
} else {
|
||||||
reject(new Error(`Real build test failed with code ${code}`));
|
reject(new Error(`Real build test failed with code ${code}`));
|
||||||
@@ -762,9 +815,6 @@ class PakeTestRunner {
|
|||||||
|
|
||||||
let buildStarted = false;
|
let buildStarted = false;
|
||||||
let compilationStarted = false;
|
let compilationStarted = false;
|
||||||
let bundlingStarted = false;
|
|
||||||
let buildCompleted = false;
|
|
||||||
let multiArchDetected = false;
|
|
||||||
|
|
||||||
// Track progress
|
// Track progress
|
||||||
child.stdout.on("data", (data) => {
|
child.stdout.on("data", (data) => {
|
||||||
@@ -784,11 +834,9 @@ class PakeTestRunner {
|
|||||||
output.includes("universal-apple-darwin") ||
|
output.includes("universal-apple-darwin") ||
|
||||||
output.includes("Universal")
|
output.includes("Universal")
|
||||||
) {
|
) {
|
||||||
multiArchDetected = true;
|
|
||||||
console.log(" 🔀 Universal binary target detected");
|
console.log(" 🔀 Universal binary target detected");
|
||||||
}
|
}
|
||||||
if (output.includes("Bundling")) {
|
if (output.includes("Bundling")) {
|
||||||
bundlingStarted = true;
|
|
||||||
console.log(" 📦 Bundling universal binary...");
|
console.log(" 📦 Bundling universal binary...");
|
||||||
}
|
}
|
||||||
if (output.includes("Built application at:")) {
|
if (output.includes("Built application at:")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user