-
Notifications
You must be signed in to change notification settings - Fork 142
Update markbind deploy success log message #2852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import type { DeployResult } from '@markbind/core'; | ||
| import * as logger from './logger.js'; | ||
|
|
||
| export function logDeployResult(result: DeployResult) { | ||
| if (result.ghActionsUrl) { | ||
| logger.info(`GitHub Actions deployment initiated. Check status at: ${result.ghActionsUrl}`); | ||
| } | ||
| if (result.ghPagesUrl) { | ||
| logger.info(`The website will be deployed at: ${result.ghPagesUrl}`); | ||
| } | ||
| if (!result.ghActionsUrl && !result.ghPagesUrl) { | ||
| logger.info('Deployed!'); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,16 @@ export type DeployOptions = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| user?: { name: string; email: string; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export type DeployResult = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ghPagesUrl: string | null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ghActionsUrl: string | null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type ParsedGitHubRepo = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repoName: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Handles the deployment of the generated site to GitHub Pages or other configured remote repositories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -40,7 +50,7 @@ export class SiteDeployManager { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Helper function for deploy(). Returns the ghpages link where the repo will be hosted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Helper function for deploy(). Returns the deployment URLs (GitHub Pages and GitHub Actions). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async generateDepUrl(ciTokenVar: boolean | string, defaultDeployConfig: DeployOptions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!this.siteConfig) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -144,7 +154,7 @@ export class SiteDeployManager { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repoSlugMatch = repoSlugRegex.exec(repo); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!repoSlugMatch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error('-c/--ci expects a GitHub repository.\n' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| + `The specified repository ${repo} is not valid.`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| + `The specified repository ${repo} is not valid.`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [, repoSlug] = repoSlugMatch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return repoSlug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -159,57 +169,80 @@ export class SiteDeployManager { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Gets the deployed website's url, returning null if there was an error retrieving it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Parses a GitHub remote URL (HTTPS or SSH) and extracts the owner name and repo name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Returns null if the URL format is not recognized. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static async getDeploymentUrl(git: SimpleGit, options: DeployOptions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static parseGitHubRemoteUrl(remoteUrl: string): ParsedGitHubRepo | null { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const HTTPS_PREAMBLE = 'https://'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const SSH_PREAMBLE = 'git@github.com:'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const GITHUB_IO_PART = 'github.io'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // https://<name|org name>.github.io/<repo name>/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function constructGhPagesUrl(remoteUrl: string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!remoteUrl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const parts = remoteUrl.split('/'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (remoteUrl.startsWith(HTTPS_PREAMBLE)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // https://github.com/<name|org>/<repo>.git (HTTPS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repoNameWithExt = parts[parts.length - 1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repoName = repoNameWithExt.substring(0, repoNameWithExt.lastIndexOf('.')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const name = parts[parts.length - 2].toLowerCase(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return `https://${name}.${GITHUB_IO_PART}/${repoName}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (remoteUrl.startsWith(SSH_PREAMBLE)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // git@github.com:<name|org>/<repo>.git (SSH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repoNameWithExt = parts[parts.length - 1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repoName = repoNameWithExt.substring(0, repoNameWithExt.lastIndexOf('.')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const name = parts[0].substring(SSH_PREAMBLE.length); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return `https://${name}.${GITHUB_IO_PART}/${repoName}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!remoteUrl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const parts = remoteUrl.split('/'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (remoteUrl.startsWith(HTTPS_PREAMBLE)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // https://github.com/<name|org>/<repo>.git (HTTPS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repoNameWithExt = parts[parts.length - 1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repoName = repoNameWithExt.substring(0, repoNameWithExt.lastIndexOf('.')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const name = parts[parts.length - 2].toLowerCase(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { name, repoName }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+175
to
+188
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (remoteUrl.startsWith(SSH_PREAMBLE)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // git@github.com:<name|org>/<repo>.git (SSH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repoNameWithExt = parts[parts.length - 1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repoName = repoNameWithExt.substring(0, repoNameWithExt.lastIndexOf('.')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+184
to
+192
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // https://github.com/<name|org>/<repo>.git (HTTPS) | |
| const repoNameWithExt = parts[parts.length - 1]; | |
| const repoName = repoNameWithExt.substring(0, repoNameWithExt.lastIndexOf('.')); | |
| const name = parts[parts.length - 2].toLowerCase(); | |
| return { name, repoName }; | |
| } else if (remoteUrl.startsWith(SSH_PREAMBLE)) { | |
| // git@github.com:<name|org>/<repo>.git (SSH) | |
| const repoNameWithExt = parts[parts.length - 1]; | |
| const repoName = repoNameWithExt.substring(0, repoNameWithExt.lastIndexOf('.')); | |
| // https://github.com/<name|org>/<repo>[.git] (HTTPS) | |
| const repoNameWithExt = parts[parts.length - 1]; | |
| const repoName = repoNameWithExt.toLowerCase().endsWith('.git') | |
| ? repoNameWithExt.slice(0, -4) | |
| : repoNameWithExt; | |
| const name = parts[parts.length - 2].toLowerCase(); | |
| return { name, repoName }; | |
| } else if (remoteUrl.startsWith(SSH_PREAMBLE)) { | |
| // git@github.com:<name|org>/<repo>[.git] (SSH) | |
| const repoNameWithExt = parts[parts.length - 1]; | |
| const repoName = repoNameWithExt.toLowerCase().endsWith('.git') | |
| ? repoNameWithExt.slice(0, -4) | |
| : repoNameWithExt; |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseGitHubRemoteUrl derives repoName via substring(0, lastIndexOf('.')), which becomes an empty string when the remote URL does not end with a file extension (e.g. https://github.com/user/repo). It can also truncate repo names containing dots when .git is absent. Consider stripping a trailing .git only when present (otherwise keep the full last path segment) so URL construction remains correct for common remote formats.
| // https://github.com/<name|org>/<repo>.git (HTTPS) | |
| const repoNameWithExt = parts[parts.length - 1]; | |
| const repoName = repoNameWithExt.substring(0, repoNameWithExt.lastIndexOf('.')); | |
| const name = parts[parts.length - 2].toLowerCase(); | |
| return { name, repoName }; | |
| } else if (remoteUrl.startsWith(SSH_PREAMBLE)) { | |
| // git@github.com:<name|org>/<repo>.git (SSH) | |
| const repoNameWithExt = parts[parts.length - 1]; | |
| const repoName = repoNameWithExt.substring(0, repoNameWithExt.lastIndexOf('.')); | |
| const name = parts[0].substring(SSH_PREAMBLE.length); | |
| // https://github.com/<name|org>/<repo>[.git] (HTTPS) | |
| const repoSegment = parts[parts.length - 1] || ''; | |
| const repoName = repoSegment.endsWith('.git') | |
| ? repoSegment.substring(0, repoSegment.length - 4) | |
| : repoSegment; | |
| const name = (parts[parts.length - 2] || '').toLowerCase(); | |
| if (!name || !repoName) { | |
| return null; | |
| } | |
| return { name, repoName }; | |
| } else if (remoteUrl.startsWith(SSH_PREAMBLE)) { | |
| // git@github.com:<name|org>/<repo>[.git] (SSH) | |
| const lastPart = parts[parts.length - 1] || ''; | |
| const repoName = lastPart.endsWith('.git') | |
| ? lastPart.substring(0, lastPart.length - 4) | |
| : lastPart; | |
| const ownerAndHost = parts[0] || ''; | |
| const name = ownerAndHost.substring(SSH_PREAMBLE.length).toLowerCase(); | |
| if (!name || !repoName) { | |
| return null; | |
| } |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring says “Constructs the GitHub Pages URL from a remote URL”, but this function takes a parsed { name, repoName } object, not a URL. Consider updating the comment to avoid confusion about expected inputs.
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring says “Constructs the GitHub Actions URL from a remote URL”, but this function takes a parsed { name, repoName } object, not a URL. Consider updating the comment to reflect the actual input type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ghPagesUrlcan be a bare domain fromCNAME(e.g.custom.domain.com), which is not a URL without a scheme. To match the intent of logging a deployed URL, consider normalizingghPagesUrlfor display (e.g. prefixinghttps://when no scheme is present).