Skip to content

Commit

Permalink
Move insert-link and settings to separate packages (OctoLinker#435)
Browse files Browse the repository at this point in the history
* Move link creation to packages

* Move insert-link related dependencies

* Remove link indicator option to simplify things

* Update import statements to load insert-link helper

* Move insert-link tests

* Move link realted css

* Mock css to make jest working

For details visit https://facebook.github.io/jest/docs/en/webpack.html

* Revert "Remove link indicator option to simplify things"

This reverts commit 5db577f.

* Revert "Move link realted css"

This reverts commit dd8e0f0.

* Move insert link css

* Move settings into package

* fixup! Revert "Move link realted css"

* Move settings related dependencies

* Update import paths

* fixup! Revert "Remove link indicator option to simplify things"

* Sort octolinker packages

* Fix "wraps once" test setup
  • Loading branch information
stefanbuck authored and josephfrazier committed Jan 31, 2018
1 parent 841ca9a commit e490c86
Show file tree
Hide file tree
Showing 27 changed files with 64 additions and 29 deletions.
1 change: 1 addition & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"firefox-launch": "web-ext run --source-dir dist --pref startup.homepage_welcome_url=https://github.com/OctoLinker/OctoLinker/blob/master/package.json"
},
"jest": {
"moduleNameMapper": {
"\\.css$": "<rootDir>/__mocks__/styleMock.js"
},
"setupFiles": [
"./_jestsetup.js"
]
Expand Down
3 changes: 1 addition & 2 deletions packages/core/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as storage from '@octolinker/helper-settings';
import OctoLinker from './octo-linker.js';
import * as storage from './options/storage.js';
import './app.css';

storage.load().then(() => {
const octoLinker = new OctoLinker();
Expand Down
2 changes: 1 addition & 1 deletion packages/core/background/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as storage from '../options/storage.js';
import * as storage from '@octolinker/helper-settings';
import newTab from './newTab';
import insight from './insight';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/click-handler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $ from 'jquery';
import * as storage from '@octolinker/helper-settings';
import { showTooltip, removeTooltip } from './gh-interface.js';
import * as storage from './options/storage.js';
import fetch from './utils/fetch.js';

const SORRY = "I'm sorry, unable to resolve this link 😱";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/notification.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as storage from '@octolinker/helper-settings';
import { showNotification } from './gh-interface';
import * as storage from './options/storage.js';

const pkgVersion = require('./package.json')
.version.split('.')
Expand Down
4 changes: 2 additions & 2 deletions packages/core/octo-linker.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import injection from 'github-injection';
import BlobReader from '@octolinker/blob-reader';
import insertLink from '@octolinker/helper-insert-link';
import * as storage from '@octolinker/helper-settings';
import notification from './notification';
import clickHandler from './click-handler';
import Plugins from './plugin-manager.js';
import insertLink from './insert-link';
import debugMode from './debug-mode.js';
import * as loadPlugins from './load-plugins';
import * as storage from './options/storage.js';

function initialize(self) {
debugMode(storage.get('debugMode'));
Expand Down
15 changes: 5 additions & 10 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,22 @@
"license": "MIT",
"main": "./index.js",
"dependencies": {
"@octolinker/blob-reader": "1.0.0",
"@octolinker/helper-grammar-regex-collection": "1.0.0",
"@octolinker/helper-insert-link": "1.0.0",
"@octolinker/helper-settings": "1.0.0",
"JSONPath": "^0.11.2",
"builtins": "^1.0.3",
"chrome-promise": "^2.1.1",
"concat-map": "^0.0.1",
"escape-regex-string": "^1.0.4",
"findandreplacedomtext": "^0.4.5",
"github-injection": "^1.0.1",
"github-url-from-git": "^1.5.0",
"github-url-from-username-repo": "^1.0.2",
"giturl": "^1.0.0",
"jquery": "^3.2.1",
"linkstate": "^1.1.0",
"@octolinker/blob-reader": "1.0.0",
"@octolinker/helper-grammar-regex-collection": "1.0.0",
"path-parse": "^1.0.5",
"preact": "^8.2.5",
"primer-core": "^6.4.0",
"primer-forms": "^1.4.0",
"querystring": "^0.2.0",
"semver": "^5.4.1",
"semver-regex": "^1.0.0",
"uuid": "^3.1.0"
"semver-regex": "^1.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/core/plugins/bower-manifest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import insertLink from '@octolinker/helper-insert-link';
import processJSON from './helper/process-json';
import { isSemver } from './helper/version';
import { javascriptFile } from './javascript';
import { jsonRegExKeyValue, jsonRegExValue } from './helper/regex-builder';
import insertLink from '../insert-link';
import liveResolverQuery from '../resolver/live-resolver-query.js';
import gitUrl from '../resolver/git-url.js';
import githubShorthand from '../resolver/github-shorthand.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/plugins/composer-manifest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import insertLink from '@octolinker/helper-insert-link';
import processJSON from './helper/process-json';
import { jsonRegExKeyValue } from './helper/regex-builder';
import insertLink from '../insert-link';
import liveResolverQuery from '../resolver/live-resolver-query.js';

function linkDependency(blob, key, value) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/plugins/dot-net-core.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import insertLink from '@octolinker/helper-insert-link';
import processJSON from './helper/process-json';
import { jsonRegExKeyValue } from './helper/regex-builder';
import insertLink from '../insert-link';
import nugetResolver from '../resolver/nuget';

function linkDependency(blob, key, value) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/plugins/npm-manifest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import insertLink from '@octolinker/helper-insert-link';
import processJSON from './helper/process-json';
import { isSemver } from './helper/version';
import { javascriptFile } from './javascript';
import { jsonRegExKeyValue, jsonRegExValue } from './helper/regex-builder';
import insertLink from '../insert-link';
import liveResolverQuery from '../resolver/live-resolver-query.js';
import gitUrl from '../resolver/git-url.js';
import githubShorthand from '../resolver/github-shorthand.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/resolver/github-search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { extname } from 'path';
import * as storage from '../options/storage.js';
import * as storage from '@octolinker/helper-settings';

export default function({ path, target }) {
const [, user, repo] = path.split('/');
Expand Down
2 changes: 1 addition & 1 deletion packages/helper-grammar-regex-collection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"license": "MIT",
"main": "./index.js",
"dependencies": {
"escape-regex-string": "^1.0.4",
"@octolinker/helper-parser-byline": "^1.0.0",
"escape-regex-string": "^1.0.4",
"xregexp": "^4.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ exports[`insert-link wraps single quotes 1`] = `
exports[`insert-link wraps the element once 1`] = `
<div>
foo
<span>
<i>
Expand All @@ -206,6 +207,7 @@ exports[`insert-link wraps the element once 1`] = `
<i>
"
</i>
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { REQUIRE } from '@octolinker/helper-grammar-regex-collection';
import insertLink from '../insert-link.js';
import insertLink from '../index.js';

describe('insert-link', () => {
const DEFAULT_REGEX = /foo ("\w+")/;
Expand Down Expand Up @@ -77,8 +77,10 @@ describe('insert-link', () => {

it('wraps the element once', () => {
const input = 'foo <span><i>"</i>foo<i>"</i></span>';
const el = helper(input);
insertLink(el, DEFAULT_REGEX, {}, '$1');

expect(helper(input)).toMatchSnapshot();
expect(el).toMatchSnapshot();
});

it('adds the given data-* attributes', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import $ from 'jquery';
import findAndReplaceDOMText from 'findandreplacedomtext';
import * as storage from './options/storage.js';
import * as storage from '@octolinker/helper-settings';
import './style.css';

const CLASS_NAME = 'octolinker-link';
const CLASS_INDICATOR = 'octolinker-line-indicator';
Expand Down
16 changes: 16 additions & 0 deletions packages/helper-insert-link/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@octolinker/helper-insert-link",
"version": "1.0.0",
"description": "",
"repository": "https://github.com/octolinker/octolinker/tree/master/packages/helper-insert-link",
"license": "MIT",
"main": "./index.js",
"dependencies": {
"@octolinker/helper-settings": "1.0.0",
"findandreplacedomtext": "^0.4.5",
"jquery": "^3.2.1"
},
"devDependencies": {
"@octolinker/helper-grammar-regex-collection": "1.0.0"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions packages/helper-settings/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@octolinker/helper-settings",
"version": "1.0.0",
"description": "",
"repository": "https://github.com/octolinker/octolinker/tree/master/packages/helper-settings",
"license": "MIT",
"main": "./index.js",
"dependencies": {
"chrome-promise": "^2.1.1",
"linkstate": "^1.1.0",
"preact": "^8.2.5",
"primer-core": "^6.4.0",
"primer-forms": "^1.4.0",
"uuid": "^3.1.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { h, render, Component } from 'preact';
import linkState from 'linkstate';

import './options.css';
import './style.css';
import { Input, Checkbox } from './components';
import * as storage from './storage';
import * as storage from './index';

const githubTokenDescription = () => (
<span>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
entry: {
app: './packages/core/app',
background: './packages/core/background/index',
options: './packages/core/options/page',
options: './packages/helper-settings/page',
},
devtool: 'source-map',
output: {
Expand Down

0 comments on commit e490c86

Please sign in to comment.