chore: import upstream snapshot with attribution
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
// goproxy module — latest version + origin metadata for one Go module.
|
||||
//
|
||||
// Hits `https://proxy.golang.org/<module>/@latest`, returning the canonical
|
||||
// version, publish time, and the upstream VCS / commit / tag the proxy resolved.
|
||||
import { cli, Strategy } from '@jackwener/opencli/registry';
|
||||
import { EmptyResultError } from '@jackwener/opencli/errors';
|
||||
import { GOPROXY_BASE, goproxyJson, requireModulePath, trimDate } from './utils.js';
|
||||
|
||||
cli({
|
||||
site: 'goproxy',
|
||||
name: 'module',
|
||||
access: 'read',
|
||||
description: 'Latest version + VCS origin metadata for a Go module on proxy.golang.org',
|
||||
domain: 'proxy.golang.org',
|
||||
strategy: Strategy.PUBLIC,
|
||||
browser: false,
|
||||
args: [
|
||||
{ name: 'module', positional: true, type: 'string', required: true, help: 'Go module path (e.g. "github.com/gin-gonic/gin", "golang.org/x/net")' },
|
||||
],
|
||||
columns: [
|
||||
'module', 'version', 'publishedAt', 'vcs', 'repository',
|
||||
'commit', 'ref', 'pkgGoDevUrl', 'url',
|
||||
],
|
||||
func: async (args) => {
|
||||
const modulePath = requireModulePath(args.module);
|
||||
// GOPROXY spec requires lowercase percent-encoding for capital letters in the
|
||||
// module path (e.g. github.com/Foo/Bar -> github.com/!foo/!bar). Module paths
|
||||
// we accept here are lowercase-only by convention; we still encode each segment.
|
||||
const encoded = modulePath.split('/').map(encodeURIComponent).join('/');
|
||||
const detail = await goproxyJson(`${GOPROXY_BASE}/${encoded}/@latest`, `goproxy module ${modulePath}`);
|
||||
if (!detail || !detail.Version) {
|
||||
throw new EmptyResultError('goproxy module', `proxy.golang.org returned no @latest entry for "${modulePath}".`);
|
||||
}
|
||||
const origin = detail.Origin && typeof detail.Origin === 'object' ? detail.Origin : {};
|
||||
return [{
|
||||
module: modulePath,
|
||||
version: String(detail.Version),
|
||||
publishedAt: trimDate(detail.Time),
|
||||
vcs: String(origin.VCS ?? '').trim(),
|
||||
repository: String(origin.URL ?? '').trim(),
|
||||
commit: String(origin.Hash ?? '').trim(),
|
||||
ref: String(origin.Ref ?? '').trim(),
|
||||
pkgGoDevUrl: `https://pkg.go.dev/${modulePath}`,
|
||||
url: `${GOPROXY_BASE}/${encoded}/@latest`,
|
||||
}];
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user