-
Notifications
You must be signed in to change notification settings - Fork 96
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
Display GitHub Pages URL after ng deploy #107
Changes from 5 commits
8cbf49d
573a9d5
825ff9d
a10d268
44532a4
353872b
fb60bf4
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 |
---|---|---|
|
@@ -10,5 +10,6 @@ export const defaults = { | |
cname: undefined, | ||
dryRun: false, | ||
remote: 'origin', | ||
ghPagesUrl: '', | ||
git: 'git' | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,61 @@ describe('engine', () => { | |
expect(finalOptions.repo).toMatch(/angular-schule\/angular-cli-ghpages/); | ||
}); | ||
|
||
it('should discover the github pages url from https repository url', async () => { | ||
const options = { | ||
repo: 'https://github.com/organisation/your-repo.git' | ||
}; | ||
const finalOptions = await engine.prepareOptions(options, logger); | ||
|
||
expect(finalOptions.ghPagesUrl).toBe( | ||
'https://organisation.github.io/your-repo ' | ||
); | ||
}); | ||
|
||
it('should discover the github pages url from url w/o .git suffix', async () => { | ||
const options = { | ||
repo: 'https://github.com/organisation/your-repo' | ||
}; | ||
const finalOptions = await engine.prepareOptions(options, logger); | ||
|
||
expect(finalOptions.ghPagesUrl).toBe( | ||
'https://organisation.github.io/your-repo ' | ||
); | ||
}); | ||
|
||
it('should discover the github pages url from url that ends with splash', async () => { | ||
const options = { | ||
repo: 'https://github.com/organisation/your-repo/' | ||
}; | ||
const finalOptions = await engine.prepareOptions(options, logger); | ||
|
||
expect(finalOptions.ghPagesUrl).toBe( | ||
'https://organisation.github.io/your-repo ' | ||
); | ||
}); | ||
|
||
it('should discover the github pages url from ssh repository url', async () => { | ||
const options = { | ||
repo: '[email protected]:organisation/your-repo.git' | ||
}; | ||
const finalOptions = await engine.prepareOptions(options, logger); | ||
|
||
expect(finalOptions.ghPagesUrl).toBe( | ||
'https://organisation.github.io/your-repo ' | ||
); | ||
}); | ||
|
||
it('should discover the github pages url from https repository url that contains with `.git`', async () => { | ||
const options = { | ||
repo: 'https://github.com/organisation/x.gity.git' | ||
}; | ||
const finalOptions = await engine.prepareOptions(options, logger); | ||
|
||
expect(finalOptions.ghPagesUrl).toBe( | ||
'https://organisation.github.io/x.gity ' | ||
); | ||
}); | ||
|
||
/* | ||
// i was not able to somehow catch an error... :-( | ||
it('should should throw an exception, if remote url could not be discovered', async () => { | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,7 +32,7 @@ export async function run( | |||||
await publishViaGhPages(ghpages, dir, options, logger); | ||||||
|
||||||
logger.info( | ||||||
'🚀 Successfully published via angular-cli-ghpages! Have a nice day!' | ||||||
`🚀 Successfully published ${options.ghPagesUrl}via angular-cli-ghpages! Have a nice day!` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
); | ||||||
} | ||||||
|
||||||
|
@@ -159,6 +159,10 @@ export async function prepareOptions( | |||||
} | ||||||
} | ||||||
|
||||||
if (options.repo) { | ||||||
return tryParseGhPagesUrl(options); | ||||||
} | ||||||
|
||||||
return options; | ||||||
} | ||||||
|
||||||
|
@@ -278,3 +282,20 @@ async function getRemoteUrl(options) { | |||||
const git = new Git(process.cwd(), options.git); | ||||||
return await git.getRemoteUrl(options.remote); | ||||||
} | ||||||
|
||||||
function tryParseGhPagesUrl(options: any): any { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Than you for the review. Instead of adding tryParseGhPagesUrl, it is enough to parse url in if (options.repo) {
// Not assume custom domain page
let trimEndDotGit = options.repo
.replace(/\/\s*$/, '')
.replace(/\.git\s*$/, '');
const matchEndsWithRepoName = trimEndDotGit.match(/github.com(\/|:)(.*)\/(.*)$/);
if (matchEndsWithRepoName) {
options.ghPagesUrl = `https://${matchEndsWithRepoName[2]}.github.io/${matchEndsWithRepoName[3]}`;
}
}
return options; |
||||||
// Not assume custom domain page | ||||||
let trimEndDotGit = options.repo | ||||||
.replace(/\/\s*$/, '') | ||||||
.replace(/\.git\s*$/, ''); | ||||||
|
||||||
const matchEndsWithRepoName = trimEndDotGit.match( | ||||||
/github.com(\/|:)(.*)\/(.*)$/ | ||||||
); | ||||||
if (matchEndsWithRepoName) { | ||||||
options.ghPagesUrl = `https://${matchEndsWithRepoName[2]}.github.io/${matchEndsWithRepoName[3]} `; | ||||||
return options; | ||||||
} | ||||||
|
||||||
return options; | ||||||
} |
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.
probably the prop should just be named
url
? @JohannesHoppe / @fmalcher what do you think?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.
First of all: Thanks for the PR! It's a great start..🤗
Regarding this part:
I don't think this should be an option at all. There is no need to set this via options, it should be only shown in the output. Such a change would also make the overall PR smaller!
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.
I agree with your point:
There is no need to set this via options
.Anyway, I'll make another patch to apply the feedback.