Skip to content
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

Prepare master for v5 release. #551

Merged
merged 15 commits into from
Jun 1, 2019
Next Next commit
Prefetch urls in background and insert "real" anchor links (#543)
* Remove lazy loader for relative files

* Add setting to enable support for private repositories

* Insert real href tag

* Add token field to settings page

* Add octolinker api helper

* Align format with new octolinker api

* Use ZEIT now deployment

* Split head from base sha in url

In some cases the file path in PR comment contains head and a base sha like https://github.com/user/repo/pull/123/files/f18370bde83d7f1ced7acf5af54a21d2e53912ff..637d21dd86c8f50e9100b8da656e43cadcccde4d#diff-fd9ad2ea8184b3a5e7d76f54e87ae438

* Resolve urls with either the github or octolinker API

* Update E2E test to work with href attribute

* Correct grammar

See #543 (comment)

* Implement simple GitHub search

* Remove option to toggle line indicator

* Open settings dialog rather than being a new tab

* Fix GitHub API call in Firefox

* Simplify loader

* Add trusted url resolver to reduce load on octolinker api

* Fix tests
  • Loading branch information
stefanbuck authored and Stefan Buck committed Jun 1, 2019
commit 5ad315282c938d1387ccb1ee73f152cd3b18442f
3 changes: 1 addition & 2 deletions assets/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"options_ui": {
"page": "options.html",
"open_in_tab": true,
"chrome_style": true
},
"content_scripts": [
Expand All @@ -42,6 +41,6 @@
"storage",
"https://github.com/",
"https://gist.github.com/",
"https://githublinker.herokuapp.com/"
"https://octolinker.now.sh/"
]
}
16 changes: 4 additions & 12 deletions e2e/automated.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,13 @@ const fixtures = require('./fixtures.json'); // eslint-disable-line import/no-un
const diffFixtures = require('./diff-fixtures.json'); // eslint-disable-line import/no-unresolved

async function executeTest(url, targetUrl, selector) {
await page.goto(url);
if ((await page.url()) !== url) {
await page.goto(url);
}

await page.waitForSelector(selector);

await Promise.all([
page.waitForNavigation(),
// page.click(selector), for some reason page.click is not working
page.$eval(selector, el => el.click()),
]);

await expect(page.url()).toEqual(expect.stringMatching(targetUrl));
await page.waitForSelector(`${selector}[href$="${targetUrl}"]`);
}

jest.setTimeout(20000);

describe('End to End tests', () => {
beforeAll(async () => {
if (!process.env.E2E_USER_NAME || !process.env.E2E_USER_PASSWORD) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"test:watch": "jest --watch",
"version": "json -I -f assets/manifest.json -e \"this.version='`json -f package.json version`'\" && git add assets/manifest.json && json -I -f packages/core/package.json -e \"this.version='`json -f package.json version`'\" && git add packages/core/package.json",
"package": "web-ext build --source-dir dist --artifacts-dir out --overwrite-dest",
"patch-permissions": "yarn json -I -f assets/manifest.json -e 'this.permissions.push(\"https://api.github.com/\")'",
"release:cws": "cd dist && webstore upload --auto-publish",
"release:amo": "cd dist && webext submit",
"release:amo": "cd dist && yarn patch-permissions && webext submit",
"release": "npm run release:cws && npm run release:amo",
"build": "webpack --mode=production",
"watch": "webpack --watch --mode=development",
Expand Down
3 changes: 2 additions & 1 deletion packages/blob-reader/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function mergeRepoAndFilePath(repoPath, filePath) {
const repoUrl = repoPath
.trim()
.split('#')[0]
.replace(/pull\/[0-9]+\/files/, 'blob');
.replace(/pull\/[0-9]+\/files/, 'blob')
.split('..')[0];

return `${repoUrl}/${filePath.trim()}`;
}
Expand Down
29 changes: 29 additions & 0 deletions packages/core/__tests__/loader.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import loader from '../loader';

describe('loader', () => {
const getMatches = (type, urls) => [
{
link: { href: '' },
urls: [
{
type,
urls,
user: 'octolinker',
repo: 'testrepo',
branch: 'master',
path: 'lib/index.js',
},
],
},
];

it('call github api to resolve internal links', () => {
loader(
getMatches('internal-link', [
'https://github.com/octolinker/testrepo/blob/master/lib/index.js',
]),
);
});
it('call octolinker api to resolve external links', () => {});
it('call github and octolinker api to resolve external and internal links', () => {});
});
17 changes: 3 additions & 14 deletions packages/core/background/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import * as storage from '@octolinker/helper-settings';
import newTab from './newTab';
import fetchUrls from '../utils/fetch';

storage.load().then(() => {
newTab();
});

chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.type !== 'fetch') {
return;
}
chrome.runtime.onMessage.addListener(({ action }) => {
if (action !== 'openSettings') return;

fetchUrls(request.urls)
.then(res => {
sendResponse(res);
})
.catch(() => {
sendResponse();
});

return true;
chrome.runtime.openOptionsPage();
});
131 changes: 0 additions & 131 deletions packages/core/click-handler.js

This file was deleted.

Loading