Skip to content

Commit

Permalink
🧱 Fix CLI updater script
Browse files Browse the repository at this point in the history
  • Loading branch information
tiulpin committed Apr 15, 2024
1 parent ee19938 commit d9d3d01
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
3 changes: 1 addition & 2 deletions common/cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"darwin_arm64": "23383d46ea5f2c92719f4d31581e1672dde6f9dc52df00c87be603ed1181b6ab",
"darwin_x86_64": "6e38b4ea3d59c5e517ce2b5c530fb373acccacff311fbfca283c293e2dfee51c",
"windows_arm64": "eec404334deea68e6f0efffc12e6bd0ff516c1aa9bdd327bb4ef1e0b4d415bab",
"linux_x86_64": "08641aed84e7cb9d422feabbaa60034322f3471d3ae7f5c7b04da0b766981886",
"darwin_all": "698751833e9ed3203264e8078e109f89a2a393b8dd4c16526c18b59a639b745c"
"linux_x86_64": "08641aed84e7cb9d422feabbaa60034322f3471d3ae7f5c7b04da0b766981886"
}
}
2 changes: 0 additions & 2 deletions common/qodana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export function getQodanaSha256(arch: string, platform: string): string {
return checksum['linux_x86_64']
case 'linux_arm64':
return checksum['linux_arm64']
case 'darwin_all':
return checksum['darwin_all']
default:
throw new Error(`Qodana CLI does not exist for ${platform}_${arch}`)
}
Expand Down
16 changes: 10 additions & 6 deletions common/update-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function getLatestRelease() {
};

const release = await makeRequest(options);
return release.tag_name;
return release.tag_name.substring(1);
} catch (error) {
console.error("An error occurred:", error);
}
Expand All @@ -96,7 +96,7 @@ function updateCliChecksums(latestVersion, checksumsPath, cliJsonPath) {
}
}
});
cliJson.version = latestVersion.slice(1);
cliJson.version = latestVersion;
fs.writeFileSync(cliJsonPath, JSON.stringify(cliJson, null, 2));
fs.unlinkSync(checksumsPath);
}
Expand All @@ -114,8 +114,6 @@ function updateCircleCIChecksums(circleCIConfigPath) {
}

function updateVersions(latestVersion, currentVersion) {
latestVersion = latestVersion.slice(1);

const latestVersions = latestVersion.split(".");
const latestMajor = parseInt(latestVersions[0]);
const latestMinor = parseInt(latestVersions[1]);
Expand All @@ -137,27 +135,33 @@ function updateVersions(latestVersion, currentVersion) {
const currentVersions = currentVersion.split(".");
const currentMajor = parseInt(currentVersions[0]);
const currentMinor = parseInt(currentVersions[1]);
const currentPatch = parseInt(currentVersions[2]);

replaceStringsInProject(`${latestMajor}.${latestMinor}.${latestPatch}`, `${currentMajor}.${currentMinor}.${latestPatch}`);
replaceStringsInProject(`${latestMajor}.${latestMinor}.${latestPatch}`, `${currentMajor}.${currentMinor}.${currentPatch}`);
replaceStringsInProject(`${latestMajor}.${latestMinor}`, `${currentMajor}.${currentMinor}`);
replaceStringsInProject(`${latestMajor}`, `${currentMajor}`);
}

function replaceStringsInProject(newString, oldString) {
process.env.LC_ALL = "C";
const isMacOS = process.platform === "darwin";
const command = `cd .. && find . -type f -exec sed -i${isMacOS ? " ''" : ""} 's/${oldString}/${newString}/g' {} +`;
console.log("Running command:", command);
execSync(command, { shell: "/bin/bash" });
}

async function main() {
try {
const currentVersion = JSON.parse(fs.readFileSync(cliJsonPath, "utf-8")).version;
console.log("Current version:", currentVersion);
const latestVersion = await getLatestRelease();
console.log("Latest version:", latestVersion);
console.log("Downloading new checksums...");
await downloadFile(`https://github.com/jetbrains/qodana-cli/releases/latest/download/checksums.txt`, "checksums.txt");
updateVersions(latestVersion, currentVersion);
updateCliChecksums(latestVersion, "checksums.txt", cliJsonPath);
updateCircleCIChecksums("../orb/commands/scan.yml");
console.log("Checksums updated successfully!");
console.log("Versions updated successfully!");
} catch (error) {
console.error("An error occurred:", error);
}
Expand Down
5 changes: 1 addition & 4 deletions scan/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24283,8 +24283,7 @@ var init_cli = __esm({
darwin_arm64: "23383d46ea5f2c92719f4d31581e1672dde6f9dc52df00c87be603ed1181b6ab",
darwin_x86_64: "6e38b4ea3d59c5e517ce2b5c530fb373acccacff311fbfca283c293e2dfee51c",
windows_arm64: "eec404334deea68e6f0efffc12e6bd0ff516c1aa9bdd327bb4ef1e0b4d415bab",
linux_x86_64: "08641aed84e7cb9d422feabbaa60034322f3471d3ae7f5c7b04da0b766981886",
darwin_all: "698751833e9ed3203264e8078e109f89a2a393b8dd4c16526c18b59a639b745c"
linux_x86_64: "08641aed84e7cb9d422feabbaa60034322f3471d3ae7f5c7b04da0b766981886"
};
}
});
Expand Down Expand Up @@ -24331,8 +24330,6 @@ function getQodanaSha256(arch, platform) {
return checksum["linux_x86_64"];
case "linux_arm64":
return checksum["linux_arm64"];
case "darwin_all":
return checksum["darwin_all"];
default:
throw new Error(`Qodana CLI does not exist for ${platform}_${arch}`);
}
Expand Down
5 changes: 1 addition & 4 deletions vsts/QodanaScan/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ var init_cli = __esm({
darwin_arm64: "23383d46ea5f2c92719f4d31581e1672dde6f9dc52df00c87be603ed1181b6ab",
darwin_x86_64: "6e38b4ea3d59c5e517ce2b5c530fb373acccacff311fbfca283c293e2dfee51c",
windows_arm64: "eec404334deea68e6f0efffc12e6bd0ff516c1aa9bdd327bb4ef1e0b4d415bab",
linux_x86_64: "08641aed84e7cb9d422feabbaa60034322f3471d3ae7f5c7b04da0b766981886",
darwin_all: "698751833e9ed3203264e8078e109f89a2a393b8dd4c16526c18b59a639b745c"
linux_x86_64: "08641aed84e7cb9d422feabbaa60034322f3471d3ae7f5c7b04da0b766981886"
};
}
});
Expand Down Expand Up @@ -92,8 +91,6 @@ function getQodanaSha256(arch, platform) {
return checksum["linux_x86_64"];
case "linux_arm64":
return checksum["linux_arm64"];
case "darwin_all":
return checksum["darwin_all"];
default:
throw new Error(`Qodana CLI does not exist for ${platform}_${arch}`);
}
Expand Down

0 comments on commit d9d3d01

Please sign in to comment.