feature/IO-3702-ESPD-UI-AND-FIXES - Stage 5 (Lint)
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
#!/usr/bin/env node
|
||||
// Cross-platform script to set artifact naming based on version
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawn } = require('child_process');
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { spawn } = require("child_process");
|
||||
|
||||
// Read the package.json to get the version
|
||||
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
const packageJsonPath = path.join(__dirname, "..", "package.json");
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
||||
const version = packageJson.version;
|
||||
|
||||
console.log(`Current version: ${version}`);
|
||||
|
||||
// Determine the artifact suffix based on the version
|
||||
let artifactSuffix = '';
|
||||
let artifactSuffix = "";
|
||||
|
||||
if (version.includes('alpha')) {
|
||||
artifactSuffix = `alpha-${version}-`;
|
||||
console.log(`Detected alpha version, setting suffix to: ${artifactSuffix}`);
|
||||
} else if (version.includes('beta')) {
|
||||
artifactSuffix = `beta-${version}-`;
|
||||
console.log(`Detected beta version, setting suffix to: ${artifactSuffix}`);
|
||||
if (version.includes("alpha")) {
|
||||
artifactSuffix = `alpha-${version}-`;
|
||||
console.log(`Detected alpha version, setting suffix to: ${artifactSuffix}`);
|
||||
} else if (version.includes("beta")) {
|
||||
artifactSuffix = `beta-${version}-`;
|
||||
console.log(`Detected beta version, setting suffix to: ${artifactSuffix}`);
|
||||
} else {
|
||||
artifactSuffix = '';
|
||||
console.log('Detected release version, no suffix will be added');
|
||||
artifactSuffix = "";
|
||||
console.log("Detected release version, no suffix will be added");
|
||||
}
|
||||
|
||||
// Set the environment variable for the current process
|
||||
@@ -33,21 +33,23 @@ console.log(`ARTIFACT_SUFFIX set to: '${artifactSuffix}'`);
|
||||
|
||||
// If arguments are passed, execute the remaining command with the environment variable set
|
||||
if (process.argv.length > 2) {
|
||||
const command = process.argv[2];
|
||||
const args = process.argv.slice(3);
|
||||
const command = process.argv[2];
|
||||
const args = process.argv.slice(3);
|
||||
|
||||
console.log(`Executing: ${command} ${args.join(' ')}`);
|
||||
console.log(`Executing: ${command} ${args.join(" ")}`);
|
||||
|
||||
const child = spawn(command, args, {
|
||||
stdio: 'inherit',
|
||||
env: { ...process.env, ARTIFACT_SUFFIX: artifactSuffix },
|
||||
shell: true
|
||||
});
|
||||
const child = spawn(command, args, {
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, ARTIFACT_SUFFIX: artifactSuffix },
|
||||
shell: true,
|
||||
});
|
||||
|
||||
child.on('close', (code) => {
|
||||
process.exit(code);
|
||||
});
|
||||
child.on("close", (code) => {
|
||||
process.exit(code);
|
||||
});
|
||||
} else {
|
||||
// Just setting the environment variable
|
||||
console.log('Environment variable set. Use this script with additional arguments to run commands with the variable set.');
|
||||
// Just setting the environment variable
|
||||
console.log(
|
||||
"Environment variable set. Use this script with additional arguments to run commands with the variable set.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,64 +1,64 @@
|
||||
#!/usr/bin/env node
|
||||
// Cross-platform test script to demonstrate artifact naming for different versions
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
console.log('=== Artifact Naming Test (Cross-Platform) ===');
|
||||
console.log('');
|
||||
console.log("=== Artifact Naming Test (Cross-Platform) ===");
|
||||
console.log("");
|
||||
|
||||
// Get current version
|
||||
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
const packageJsonPath = path.join(__dirname, "..", "package.json");
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
||||
const currentVersion = packageJson.version;
|
||||
|
||||
console.log(`Current version: ${currentVersion}`);
|
||||
|
||||
// Function to get artifact suffix
|
||||
function getArtifactSuffix(version) {
|
||||
if (version.includes('alpha')) {
|
||||
return `alpha-${version}-`;
|
||||
} else if (version.includes('beta')) {
|
||||
return `beta-${version}-`;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
if (version.includes("alpha")) {
|
||||
return `alpha-${version}-`;
|
||||
} else if (version.includes("beta")) {
|
||||
return `beta-${version}-`;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Test scenarios
|
||||
const testVersions = [
|
||||
'1.0.5', // Release version
|
||||
'1.0.5-alpha.2', // Alpha version
|
||||
'1.0.5-beta.1', // Beta version
|
||||
'2.0.0-alpha.1', // Another alpha
|
||||
'1.5.0-beta.3' // Another beta
|
||||
"1.0.5", // Release version
|
||||
"1.0.5-alpha.2", // Alpha version
|
||||
"1.0.5-beta.1", // Beta version
|
||||
"2.0.0-alpha.1", // Another alpha
|
||||
"1.5.0-beta.3", // Another beta
|
||||
];
|
||||
|
||||
console.log('Test scenarios:');
|
||||
console.log('==================');
|
||||
console.log("Test scenarios:");
|
||||
console.log("==================");
|
||||
|
||||
testVersions.forEach(version => {
|
||||
const suffix = getArtifactSuffix(version);
|
||||
|
||||
// Different artifact names for different platforms
|
||||
const windowsArtifact = `imex-partner-${suffix}x64.exe`;
|
||||
const macArtifact = `imex-partner-${suffix}x64.dmg`;
|
||||
const linuxArtifact = `imex-partner-${suffix}x64.AppImage`;
|
||||
|
||||
console.log(`Version: ${version}`);
|
||||
console.log(` Suffix: '${suffix}'`);
|
||||
console.log(` Windows: ${windowsArtifact}`);
|
||||
console.log(` Mac: ${macArtifact}`);
|
||||
console.log(` Linux: ${linuxArtifact}`);
|
||||
console.log('');
|
||||
testVersions.forEach((version) => {
|
||||
const suffix = getArtifactSuffix(version);
|
||||
|
||||
// Different artifact names for different platforms
|
||||
const windowsArtifact = `imex-partner-${suffix}x64.exe`;
|
||||
const macArtifact = `imex-partner-${suffix}x64.dmg`;
|
||||
const linuxArtifact = `imex-partner-${suffix}x64.AppImage`;
|
||||
|
||||
console.log(`Version: ${version}`);
|
||||
console.log(` Suffix: '${suffix}'`);
|
||||
console.log(` Windows: ${windowsArtifact}`);
|
||||
console.log(` Mac: ${macArtifact}`);
|
||||
console.log(` Linux: ${linuxArtifact}`);
|
||||
console.log("");
|
||||
});
|
||||
|
||||
console.log('Current configuration will produce:');
|
||||
console.log("Current configuration will produce:");
|
||||
const currentSuffix = getArtifactSuffix(currentVersion);
|
||||
console.log(` Windows: imex-partner-${currentSuffix}x64.exe`);
|
||||
console.log(` Mac: imex-partner-${currentSuffix}x64.dmg`);
|
||||
console.log(` Linux: imex-partner-${currentSuffix}x64.AppImage`);
|
||||
|
||||
console.log('');
|
||||
console.log("");
|
||||
console.log(`Platform detected: ${process.platform}`);
|
||||
console.log(`Architecture: ${process.arch}`);
|
||||
|
||||
Reference in New Issue
Block a user