Skip to content

Commit

Permalink
Add initial build setup (#24)
Browse files Browse the repository at this point in the history
* fix 'Failed to minify the code from this file' issue

* fix build 'error TS2300: Duplicate identifier 'Element'' issue

* fix missing gear icon from parent pr selector

* add initial extension build setup
  • Loading branch information
rikukissa committed Dec 30, 2017
1 parent e9f9175 commit de16c73
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 150 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

*.pem
5 changes: 0 additions & 5 deletions dom-chef.d.ts

This file was deleted.

3 changes: 3 additions & 0 deletions jsx-dom-svg.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module "jsx-dom/svg" {
export * from "jsx-dom";
}
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@
"dependencies": {
"@types/qs": "^6.5.1",
"axios": "^0.17.1",
"dom-chef": "^3.0.0",
"emotion": "^8.0.12",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"jsx-dom": "^5.2.0",
"react-scripts-ts": "2.8.0",
"select-dom": "^4.1.1"
},
"scripts": {
"start": "HTTPS=true react-scripts-ts start",
"build": "react-scripts-ts build",
"build": "react-scripts-ts build && ./post-build",
"test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject"
"eject": "react-scripts-ts eject",
"pack-extension": "node scripts/pack.js"
},
"devDependencies": {
"@types/jest": "^21.1.9",
"@types/node": "^8.5.2",
"@types/react": "^16.0.31",
"@types/react-dom": "^16.0.3",
"crx": "^3.2.1",
"prettier": "^1.9.2",
"tslint-config-prettier": "^1.6.0"
}
Expand Down
7 changes: 7 additions & 0 deletions post-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rm build/asset-manifest.json
rm build/favicon.ico
rm build/index.html
rm build/service-worker.js
mv build/static/js/*.js.map build/bundle.js.map
mv build/static/js/*.js build/bundle.js
rm -r build/static
24 changes: 11 additions & 13 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
"version": "0.0.1",
"name": "Stacker",
"manifest_version": 2,
"description": "Stacked pull requests for Github",
"update_url": "http://www.example.com/update.xml",
"content_scripts": [{
"js": ["bundle.js"],
"matches": ["*://*/*"]
}],
"permissions": ["*://*/*" ],
"content_security_policy": "default-src 'self'; script-src 'self'; style-src * 'unsafe-inline'; img-src 'self' data:;"
}
20 changes: 20 additions & 0 deletions scripts/pack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require("fs");
const ChromeExtension = require("crx");
const path = require("path");

const argv = require("minimist")(process.argv.slice(2));

const keyPath = argv.key || "key.pem";
const existsKey = fs.existsSync(keyPath);

const crx = new ChromeExtension({
privateKey: existsKey ? fs.readFileSync(keyPath) : null
});

crx
.load(path.join(__dirname, "../build"))
.then(() => crx.pack())
.then(crxBuffer => {
fs.writeFileSync("./build/stacker.crx", crxBuffer);
})
.catch(err => console.error(err));
2 changes: 1 addition & 1 deletion src/features/diff-select.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from "dom-chef";
import { h } from "jsx-dom";
import {
getPullRequest,
getPullRequestCommits,
Expand Down
2 changes: 1 addition & 1 deletion src/features/merge-warning.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from "dom-chef";
import { h } from "jsx-dom";
import { getPullRequests } from "../api";
import {
createIdForPullRequest,
Expand Down
7 changes: 3 additions & 4 deletions src/features/parent-pr-select/components/PRSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { h } from "dom-chef";
// tslint:disable-next-line no-submodule-imports
import { h } from "jsx-dom/svg";

import { IGithubPullRequest } from "../../../api";
import PullRequest from "./PullRequest";

Expand Down Expand Up @@ -49,7 +51,6 @@ export default function PRSelector(
aria-label="Close"
className="octicon octicon-x js-menu-close"
height="16"
role="img"
version="1.1"
viewBox="0 0 12 16"
width="12"
Expand All @@ -68,7 +69,6 @@ export default function PRSelector(
aria-label="Close"
className="octicon octicon-x js-menu-close"
height="16"
role="img"
version="1.1"
viewBox="0 0 12 16"
width="12"
Expand Down Expand Up @@ -99,7 +99,6 @@ export default function PRSelector(
<div
data-filterable-for="prs-filter-field"
data-filterable-type="substring"
role="menu"
>
{pullRequests.map(pr => PullRequest(pr, selectPR))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/features/parent-pr-select/components/PullRequest.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from "dom-chef";
import { h } from "jsx-dom";
import { IGithubPullRequest } from "../../../api";
import { createIdForPullRequest } from "../../../lib/base";

Expand Down
27 changes: 14 additions & 13 deletions src/features/show-stacking-in-list.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { h } from "dom-chef";
import { css } from "emotion";
import { h } from "jsx-dom";
import { getPullRequests, IGithubPullRequest } from "../api";
import {
BaseId,
Expand Down Expand Up @@ -102,7 +102,7 @@ function getBadge(pullRequest: IGithubPullRequest, pullRequestGraph: INode) {
stackNode.node.children.length === 0 &&
stackNode.node.parent === null
) {
return null;
return <div />;
}

const childCount = stackNode.node.children.length;
Expand All @@ -125,17 +125,18 @@ function getBadge(pullRequest: IGithubPullRequest, pullRequestGraph: INode) {
}}
>
<span className={numberStyle}>part {stackNode.number + 1}</span>
{branches &&
childCount > 0 && (
<div
className={ball}
style={{
"background-color": childColor
}}
>
<span>+{childCount}</span>
</div>
)}
{branches && childCount > 0 ? (
<div
className={ball}
style={{
"background-color": childColor
}}
>
<span>+{childCount}</span>
</div>
) : (
<div />
)}
</div>
);
})}
Expand Down
Loading

0 comments on commit de16c73

Please sign in to comment.