Skip to content

Commit

Permalink
chore(dts-generator): add user-agent to HTTP requests
Browse files Browse the repository at this point in the history
To identify the usage of this tool in log files
  • Loading branch information
akudev committed Jun 25, 2024
1 parent 8b44546 commit 4726713
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/dts-generator/src/js-utils/ui5-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export async function getSAPUI5LibsMeta(version) {
const fetch = (await import("node-fetch")).default;
const sapUI5Response = await fetch(
`https://unpkg.com/@sapui5/distribution-metadata@${version}/metadata.json`,
{
headers: {
"User-Agent": "@ui5-dts-generator",
},
},
);
if (!sapUI5Response.ok) {
log.error(`error fetching sapui5 metadata`);
Expand All @@ -57,6 +62,11 @@ export async function getOpenUI5PossibleLibNames() {
const fetch = (await import("node-fetch")).default;
const openUI5OrgResponse = await fetch(
`https://registry.npmjs.com/-/v1/search?text=scope:openui5&size=100`,
{
headers: {
"User-Agent": "@ui5-dts-generator",
},
},
);
if (!openUI5OrgResponse.ok) {
log.error(`error fetching sapui5 metadata`);
Expand Down
6 changes: 5 additions & 1 deletion packages/dts-generator/src/js-utils/write-url-to-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const log = getLogger("@ui5/dts-generator/write-url-to-file");
export default async function writeUrlToFile(url, file) {
const fetch = (await import("node-fetch")).default;
log.info(`fetching: ${url}`);
const response = await fetch(url);
const response = await fetch(url, {
headers: {
"User-Agent": "@ui5-dts-generator",
},
});
if (!response.ok) {
log.error(`error fetching from ${url}`);
return false;
Expand Down

0 comments on commit 4726713

Please sign in to comment.