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
279 changes: 279 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"publish:minor": "npx -y np minor"
},
"dependencies": {
"@octokit/rest": "^21.0.2",
"minimist": "^1.2.7",
"picocolors": "^1.0.0",
"semver-compare": "^1.0.0"
Expand Down
1 change: 0 additions & 1 deletion src/mkcert/mkcert.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export class Mkcert {
return undefined;
}

console.log('getSourceInfo', sourceInfo);
return sourceInfo;
}
async initMkcert() {
Expand Down
35 changes: 10 additions & 25 deletions src/mkcert/source.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
import { request } from '../request.js';
import { Octokit } from '@octokit/rest';

const getPlatformIdentifier = () => {
switch (process.platform) {
case 'win32':
return 'windows-amd64.exe';
case 'linux':
return process.arch === 'arm64' ? 'linux-arm64' : process.arch === 'arm' ? 'linux-arm' : 'linux-amd64';
case 'darwin':
return 'darwin-amd64';
default:
throw new Error('Unsupported platform');
}
};

const owner = 'FiloSottile';
const repo = 'mkcert';
const fetchLatestRelease = async () => {
// -H "Authorization: Bearer <YOUR-TOKEN>" \
/** @type {Promise<{ assets: Array<{name: string, browser_download_url: string}>, tag_name?: string }>} */
const res = await request(
`https://api.github.com/repos/${owner}/${repo}/releases/latest`,
{ Accept: 'application/vnd.github+json' },
'json',
);
return res;
const arch = process.arch === 'x64' ? 'amd64' : process.arch;
return process.platform === 'win32'
? `windows-${arch}.exe`
: `${process.platform}-${arch}`;
};

/**
* Download mkcert from github.com
*/
export class GithubSource {
async getSourceInfo() {
const data = await fetchLatestRelease();
const octokit = new Octokit();
const { data } = await octokit.repos.getLatestRelease({
owner: 'FiloSottile',
repo: 'mkcert'
})
const platformIdentifier = getPlatformIdentifier();

const version = data.tag_name;
Expand Down