Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.js text eol=lf
*.json text eol=lf
*.mjs text eol=lf
*.ts text eol=lf
*.txt text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
14 changes: 8 additions & 6 deletions src/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ export class Asset implements Asset {
throw new Error('PAT auth: Username is empty');
}
console.error(`Authenticating PAT for ${username}`);
const url = `https://hub.docker.com/v2/users/login`;
const url = `https://hub.docker.com/v2/auth/token`;
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
username: username,
password: this.config.auth?.token,
identifier: username,
secret: this.config.auth?.token?.trim(),
}),
});
if (!response.ok) {
Expand All @@ -217,9 +217,11 @@ export class Asset implements Asset {
);
}
const data = (await response.json()) as {
token: string;
refresh_token: string;
access_token: string;
};
return data.token;
if (!data.access_token) {
throw new Error(`Failed to authenticate PAT for ${username}: missing access token`);
}
return data.access_token;
}
}
4 changes: 3 additions & 1 deletion src/scripts/toolsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ function loadCurrentToolsList(): { tools: Tool[] } {

function loadCurrentToolsNames(): string[] {
const toolsList = fs.readFileSync(path.join(__dirname, '../..', 'tools.txt'), 'utf8');
return toolsList.split('\n').map((line) => line.split('- name: ')[1].replace(/^"|"$/g, ''));
return toolsList
.split('\n')
.map((line) => line.trimEnd().split('- name: ')[1].replace(/^"|"$/g, ''));
}

function saveToolsList(toolsList: { tools: Tool[] }) {
Expand Down