-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Buezas
committed
Sep 16, 2021
1 parent
3c5d7f9
commit 70de736
Showing
19 changed files
with
2,477 additions
and
38,211 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,61 +4,27 @@ | |
"private": false, | ||
"author": "[email protected]", | ||
"dependencies": { | ||
"@testing-library/jest-dom": "^5.14.1", | ||
"@testing-library/react": "^11.2.7", | ||
"@testing-library/user-event": "^12.8.3", | ||
"@types/jest": "^26.0.24", | ||
"@types/node": "^12.20.24", | ||
"@types/react": "^17.0.20", | ||
"@types/react-dom": "^17.0.9", | ||
"date-fns": "^2.23.0", | ||
"esbuild": "^0.12.28", | ||
"react": "^17.0.2", | ||
"react-command-palette": "^0.16.2", | ||
"react-dom": "^17.0.2", | ||
"react-scripts": "4.0.3", | ||
"typescript": "^4.4.2", | ||
"web-vitals": "^1.1.2", | ||
"webextension-polyfill": "^0.8.0" | ||
"webextension-polyfill": "^0.8.0", | ||
"ws": "^8.2.2" | ||
}, | ||
"scripts": { | ||
"dev": "cp ./public/popup-dev.html ./dist/popup.html && craco start", | ||
"start": "craco start & npm-watch & wait", | ||
"build": "./script/build.sh", | ||
"test": "craco test", | ||
"eject": "craco eject" | ||
}, | ||
"watch": { | ||
"build": { | ||
"patterns": [ | ||
"src", | ||
"public" | ||
], | ||
"extensions": "*" | ||
} | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
"start": "node script/build.js", | ||
"build": "NODE_ENV=production node script/build.js", | ||
"upgrade": "npx npm-check -u" | ||
}, | ||
"devDependencies": { | ||
"@craco/craco": "^6.2.0", | ||
"@types/webextension-polyfill": "^0.8.0", | ||
"craco-esbuild": "^0.4.0", | ||
"npm-watch": "^0.11.0", | ||
"webpack-bundle-analyzer": "^4.4.2" | ||
"@types/ws": "^7.4.7", | ||
"npm-watch": "^0.11.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,8 @@ | |
"linux": "Ctrl+Shift+P" | ||
} | ||
} | ||
} | ||
}, | ||
"web_accessible_resources": [ | ||
"date.txt" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta | ||
name="description" | ||
content="Web site created using create-react-app" | ||
/> | ||
<link rel="apple-touch-icon" href="/logo192.png" /> | ||
<link rel="manifest" href="/manifest.json" /> | ||
<title>Chrome Palette</title> | ||
<link href="/bundle.css" rel="stylesheet" /> | ||
<script defer src="/bundle.js"></script> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// @ts-check | ||
const { WebSocketServer } = (WebSocket = require("ws")); | ||
const chokidar = require("chokidar"); | ||
const { execSync } = require("child_process"); | ||
const esbuild = require("esbuild"); | ||
|
||
const date = new Date().toString(); | ||
const isProd = process.env.NODE_ENV === "production"; | ||
|
||
const synchPublic = async () => { | ||
execSync("cp public/* dist/"); | ||
}; | ||
const watchOptn = { | ||
// awaitWriteFinish: {stabilityThreshold:100, pollInterval:50}, | ||
ignoreInitial: true, | ||
}; | ||
async function build() { | ||
execSync("rm -rf dist/"); | ||
execSync("mkdir dist"); | ||
await synchPublic(); | ||
console.time("build"); | ||
const result = await esbuild.build({ | ||
entryPoints: ["src/index.tsx"], | ||
bundle: true, | ||
minify: isProd, | ||
metafile: true, | ||
sourcemap: isProd ? false : "inline", | ||
outfile: "dist/bundle.js", | ||
incremental: !isProd, | ||
define: { | ||
NODE_ENV: process.env.NODE_ENV, | ||
"process.env.NODE_ENV": `"${process.env.NODE_ENV}"`, | ||
"process.env.REACT_APP_BUILD_TIME": `"${date}"`, | ||
}, | ||
}); | ||
console.timeEnd("build"); | ||
|
||
let text = | ||
result.metafile && (await esbuild.analyzeMetafile(result.metafile)); | ||
console.log(text); | ||
|
||
if (isProd) { | ||
execSync("rm chrome-palette.zip"); | ||
execSync("zip -r chrome-palette.zip dist/"); | ||
} else { | ||
const wss = new WebSocketServer({ port: 8081 }); | ||
wss.on("connection", () => console.log(wss.clients.size)); | ||
wss.on("close", () => console.log(wss.clients.size)); | ||
const sendToClients = (/** @type {{ action: string; }} */ message) => { | ||
wss.clients.forEach(function each( | ||
/** @type {{ readyState: number; send: (arg0: string) => void; }} */ client | ||
) { | ||
if (client.readyState === WebSocket.OPEN) { | ||
console.log("sending"); | ||
client.send(JSON.stringify(message)); | ||
} | ||
}); | ||
}; | ||
chokidar.watch("public", watchOptn).on("all", async (...args) => { | ||
console.log(args); | ||
await synchPublic(); | ||
sendToClients({ action: "update-app" }); | ||
}); | ||
chokidar.watch("src", watchOptn).on("all", async (...args) => { | ||
console.log(args); | ||
await result.rebuild?.(); | ||
sendToClients({ action: "update-app" }); | ||
}); | ||
} | ||
} | ||
|
||
build(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
.atom-icon { | ||
float: left; | ||
height: 15px; | ||
width: 15px; | ||
margin-right: 3px; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.