cli
cli copied to clipboard
Extend CLI with argument to configure linking behaviour (local IDE vs CVS)
Precondition:
- #745
- #722
User story
As a user of the CLI I want to have click through experience for all actionable feedback a get from the audit issues.
At the moment no linking is present. What I need is a way to generate links depending on the current usecase.
- A) The report is located in your local file system
- B) The report is generate in the CI and added to a PR comment
- C) The report is checked in and lives in the repository
CLI argument Example:
-
npx @code-pushup collect
- links in IDE -
npx @code-pushup collect --git.host=https://my-github.com/repo-name --git.provider=github
- links to git
Acceptance criteria
- [ ] The models package
- [ ] The CLI accepts the new git options
- [ ] By default the report links to the local filesystem. If the link is clicked you the fie is opened in the local IDE
- [ ] Over a configuration setting or terminal argument we can tell the CLI to generate links targeting another environment.
- If the configuration targets a local setup the first criteria applies
- If the the configuration targets a git-version e.g. GitLab, GitHub the URLs should get auto discovered
- If the server and git-version cant get autodetected we don't apply a link
Implementation details
PersistConfig Example:
type GitConfig = {
// skipped means local, otherwise remote
git?: {
provider: 'GitHub' | 'GitLab';
host?: string; // for self-hosted only, defaults to https://github.com or https://gitlab.com
}
}
const GitConfigSchema = z.object({
git: z
.object({
provider: z.enum(['GitHub', 'GitLab']),
host: z.string().url().optional(), // Optional host field with URL validation
})
.optional(), // git itself is optional
});
type ReportOptions = {
sourceLinkFormatter: (source?: SourceFileLocation) => string
}
const sourceLinkFormatter = coreConfig.git ? ideLinkFn : cvsLinkFn;
const mdReport = generateMdReport(report: Report, options: ReportOptions) {
//
}
Related Issues:
https://github.com/code-pushup/cli/issues/149