Skip to content

Commit

Permalink
chore: npm run fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Dec 15, 2024
1 parent 19c5a45 commit 93eb293
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 92 deletions.
8 changes: 3 additions & 5 deletions _common/gitea.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ if (module === require.main) {
'https://git.rootprojects.org',
'',
'',
).then(
function (all) {
console.info(JSON.stringify(all, null, 2));
},
);
).then(function (all) {
console.info(JSON.stringify(all, null, 2));
});
}
15 changes: 10 additions & 5 deletions flutter/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ module.exports = async function () {
};

for (let osname of FLUTTER_OSES) {
const response = await fetch(`https://storage.googleapis.com/flutter_infra_release/releases/releases_${osname}.json`, {
method: 'GET',
headers: { Accept: 'application/json' },
});
const response = await fetch(
`https://storage.googleapis.com/flutter_infra_release/releases/releases_${osname}.json`,
{
method: 'GET',
headers: { Accept: 'application/json' },
},
);
if (!response.ok) {
throw new Error(`Failed to fetch data for ${osname}: ${response.statusText}`);
throw new Error(
`Failed to fetch data for ${osname}: ${response.statusText}`,
);
}
const respBody = await response.json();

Expand Down
86 changes: 43 additions & 43 deletions go/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,54 +37,54 @@ async function getDistributables() {
]
};
*/
const response = await fetch('https://golang.org/dl/?mode=json&include=all', {
method: 'GET',
headers: { Accept: 'application/json' },
});
if (!response.ok) {
throw new Error(`Failed to fetch Go releases: ${response.statusText}`);
const response = await fetch('https://golang.org/dl/?mode=json&include=all', {
method: 'GET',
headers: { Accept: 'application/json' },
});
if (!response.ok) {
throw new Error(`Failed to fetch Go releases: ${response.statusText}`);
}

const goReleases = await response.json();
const all = {
releases: [],
download: '',
};

goReleases.forEach((release) => {
// Strip 'go' prefix and standardize version
const parts = release.version.slice(2).split('.');
while (parts.length < 3) {
parts.push('0');
}

const goReleases = await response.json();
const all = {
releases: [],
download: '',
};
const version = parts.join('.');
const fileversion = release.version.slice(2);

goReleases.forEach((release) => {
// Strip 'go' prefix and standardize version
const parts = release.version.slice(2).split('.');
while (parts.length < 3) {
parts.push('0');
release.files.forEach((asset) => {
if (isOdd(asset.filename)) {
return;
}
const version = parts.join('.');
const fileversion = release.version.slice(2);

release.files.forEach((asset) => {
if (isOdd(asset.filename)) {
return;
}

const filename = asset.filename;
const os = osMap[asset.os] || asset.os || '-';
const arch = archMap[asset.arch] || asset.arch || '-';
all.releases.push({
version: version,
_version: fileversion,
lts: (parts[0] > 0 && release.stable) || false,
channel: (release.stable && 'stable') || 'beta',
date: '1970-01-01', // Placeholder
os: os,
arch: arch,
ext: '', // Let normalize run the split/test/join
hash: '-', // Placeholder for hash
download: `https://dl.google.com/go/${filename}`,
});

const filename = asset.filename;
const os = osMap[asset.os] || asset.os || '-';
const arch = archMap[asset.arch] || asset.arch || '-';
all.releases.push({
version: version,
_version: fileversion,
lts: (parts[0] > 0 && release.stable) || false,
channel: (release.stable && 'stable') || 'beta',
date: '1970-01-01', // Placeholder
os: os,
arch: arch,
ext: '', // Let normalize run the split/test/join
hash: '-', // Placeholder for hash
download: `https://dl.google.com/go/${filename}`,
});
});

return all;
}
});

return all;
}

module.exports = getDistributables;

Expand Down
24 changes: 12 additions & 12 deletions iterm2/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ async function getRawReleases() {
const response = await fetch('https://iterm2.com/downloads.html', {
method: 'GET',
headers: {
'Accept': 'text/html', // Explicitly request HTML content
Accept: 'text/html', // Explicitly request HTML content
},
});

// Validate HTTP response
if (!response.ok) {
throw new Error(`Failed to fetch releases: HTTP ${response.status} - ${response.statusText}`);
throw new Error(
`Failed to fetch releases: HTTP ${response.status} - ${response.statusText}`,
);
}

// Validate Content-Type header
Expand All @@ -22,16 +24,14 @@ async function getRawReleases() {
// Parse HTML content
const body = await response.text();
var links = body
.split(/[<>]+/g)
.map(function (str) {
var m = str.match(
/href="(https:\/\/iterm2\.com\/downloads\/.*\.zip)"/,
);
if (m && /iTerm2-[34]/.test(m[1])) {
return m[1];
}
})
.filter(Boolean);
.split(/[<>]+/g)
.map(function (str) {
var m = str.match(/href="(https:\/\/iterm2\.com\/downloads\/.*\.zip)"/);
if (m && /iTerm2-[34]/.test(m[1])) {
return m[1];
}
})
.filter(Boolean);
return links;
}

Expand Down
4 changes: 3 additions & 1 deletion macos/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ async function fetchReleasesForOS(os) {

// Validate HTTP response
if (!response.ok) {
throw new Error(`Failed to fetch URL: ${os.url}. HTTP ${response.status} - ${response.statusText}`);
throw new Error(
`Failed to fetch URL: ${os.url}. HTTP ${response.status} - ${response.statusText}`,
);
}

// Parse the response body
Expand Down
38 changes: 21 additions & 17 deletions node/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,25 @@ async function getDistributables() {
]
*/

// Alternate: 'https://nodejs.org/dist/index.json',
let baseUrl = `https://nodejs.org/download/release`;

// Fetch official builds
let officialP = fetch(`${baseUrl}/index.json`, {
method: 'GET',
headers: { Accept: 'application/json' },
}).then((response) => {
if (!response.ok) {
throw new Error(`Failed to fetch official builds: HTTP ${response.status} - ${response.statusText}`);
}
return response.json();
})
.then((data) => {
transform(baseUrl, data);
});
// Alternate: 'https://nodejs.org/dist/index.json',
let baseUrl = `https://nodejs.org/download/release`;

// Fetch official builds
let officialP = fetch(`${baseUrl}/index.json`, {
method: 'GET',
headers: { Accept: 'application/json' },
})
.then((response) => {
if (!response.ok) {
throw new Error(
`Failed to fetch official builds: HTTP ${response.status} - ${response.statusText}`,
);
}
return response.json();
})
.then((data) => {
transform(baseUrl, data);
});

// Fetch unofficial builds
let unofficialBaseUrl = `https://unofficial-builds.nodejs.org/download/release`;
Expand All @@ -90,7 +92,9 @@ async function getDistributables() {
})
.then((response) => {
if (!response.ok) {
throw new Error(`Failed to fetch unofficial builds: HTTP ${response.status} - ${response.statusText}`);
throw new Error(
`Failed to fetch unofficial builds: HTTP ${response.status} - ${response.statusText}`,
);
}
return response.json();
})
Expand Down
15 changes: 10 additions & 5 deletions terraform/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
async function getDistributables() {
try {
// Fetch the Terraform releases JSON
const response = await fetch('https://releases.hashicorp.com/terraform/index.json', {
method: 'GET',
headers: { Accept: 'application/json' },
});
const response = await fetch(
'https://releases.hashicorp.com/terraform/index.json',
{
method: 'GET',
headers: { Accept: 'application/json' },
},
);

// Validate the HTTP response
if (!response.ok) {
throw new Error(`Failed to fetch releases: HTTP ${response.status} - ${response.statusText}`);
throw new Error(
`Failed to fetch releases: HTTP ${response.status} - ${response.statusText}`,
);
}

// Parse the JSON response
Expand Down
10 changes: 6 additions & 4 deletions zig/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ module.exports = async function () {

// Validate HTTP response
if (!response.ok) {
throw new Error(`Failed to fetch releases: HTTP ${response.status} - ${response.statusText}`);
throw new Error(
`Failed to fetch releases: HTTP ${response.status} - ${response.statusText}`,
);
}

// Parse the JSON response
Expand Down Expand Up @@ -87,13 +89,13 @@ module.exports = async function () {
return {
releases: releases,
};
}catch (err) {
} catch (err) {
console.error('Error fetching Zig releases:', err.message);
return {
releases: [],
};
};
}
}
};

if (module === require.main) {
module.exports().then(function (all) {
Expand Down

0 comments on commit 93eb293

Please sign in to comment.