mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
run formatter on covector script
This commit is contained in:
@@ -8,47 +8,49 @@ This script is solely intended to be run as part of the `covector publish` step
|
|||||||
check the latest version of a crate, considering the current minor version.
|
check the latest version of a crate, considering the current minor version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const https = require('https')
|
const https = require("https");
|
||||||
|
|
||||||
const kind = process.argv[2]
|
const kind = process.argv[2];
|
||||||
const packageName = process.argv[3]
|
const packageName = process.argv[3];
|
||||||
const packageVersion = process.argv[4]
|
const packageVersion = process.argv[4];
|
||||||
const target = packageVersion.substring(0, packageVersion.lastIndexOf('.'))
|
const target = packageVersion.substring(0, packageVersion.lastIndexOf("."));
|
||||||
|
|
||||||
let url = null
|
let url = null;
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case 'cargo':
|
case "cargo":
|
||||||
url = `https://crates.io/api/v1/crates/${packageName}`
|
url = `https://crates.io/api/v1/crates/${packageName}`;
|
||||||
break;
|
break;
|
||||||
case 'npm':
|
case "npm":
|
||||||
url = `https://registry.npmjs.org/${packageName}`
|
url = `https://registry.npmjs.org/${packageName}`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('unexpected kind ' + kind)
|
throw new Error("unexpected kind " + kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
'Accept': 'application/json',
|
Accept: "application/json",
|
||||||
'User-Agent': 'tauri (https://github.com/tauri-apps/tauri)'
|
"User-Agent": "tauri (https://github.com/tauri-apps/tauri)",
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
https.get(url, options, (response) => {
|
https.get(url, options, (response) => {
|
||||||
let chunks = []
|
let chunks = [];
|
||||||
response.on('data', function (chunk) {
|
response.on("data", function (chunk) {
|
||||||
chunks.push(chunk)
|
chunks.push(chunk);
|
||||||
})
|
});
|
||||||
|
|
||||||
response.on('end', function () {
|
response.on("end", function () {
|
||||||
const data = JSON.parse(chunks.join(''))
|
const data = JSON.parse(chunks.join(""));
|
||||||
if (kind === 'cargo') {
|
if (kind === "cargo") {
|
||||||
const versions = data.versions.filter(v => v.num.startsWith(target))
|
const versions = data.versions.filter((v) => v.num.startsWith(target));
|
||||||
console.log(versions.length ? versions[0].num : '0.0.0')
|
console.log(versions.length ? versions[0].num : "0.0.0");
|
||||||
} else if (kind === 'npm') {
|
} else if (kind === "npm") {
|
||||||
const versions = Object.keys(data.versions).filter(v => v.startsWith(target))
|
const versions = Object.keys(data.versions).filter((v) =>
|
||||||
console.log(versions[versions.length - 1] || '0.0.0')
|
v.startsWith(target)
|
||||||
|
);
|
||||||
|
console.log(versions[versions.length - 1] || "0.0.0");
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user