Only show BookmarksBar on Chrome

Fixes #302
master
rubenwardy 2022-04-23 17:32:44 +01:00
parent c191ab7f87
commit a6f319d4ad
6 changed files with 17 additions and 15 deletions

View File

@ -11,11 +11,11 @@
"start": "concurrently \"npm run start:app\" \"npm run start:server\" ",
"start:app": "npm run trans:compile && concurrently \"webpack --watch\" \"live-server dist/webext/app --port=8085\"",
"start:server": "concurrently \"tsc --preserveWatchOutput --watch --outDir dist/server --project tsconfig.server.json\" \"NODE_PATH=dist/server nodemon dist/server/server/index.js\"",
"start:firefox": "npm run trans:compile && concurrently \"webpack --watch\" \"web-ext run -t firefox-desktop -s ./dist/webext/ -i app/manifest.json -i manifest.firefox.json -i app/index.html \" \"npm run start:server\"",
"start:chrome": "npm run trans:compile && concurrently \"webpack --watch\" \"web-ext run -t chromium -s ./dist/webext/ -i app/manifest.json -i manifest.firefox.json -i app/index.html\" \"npm run start:server\"",
"start:chrome": "export TARGET=chrome && npm run trans:compile && concurrently \"webpack --watch\" \"web-ext run -t chromium -s ./dist/webext/ -i app/manifest.json -i manifest.firefox.json -i app/index.html\" \"npm run start:server\"",
"start:firefox": "export TARGET=firefox && npm run trans:compile && concurrently \"webpack --watch\" \"web-ext run -t firefox-desktop -s ./dist/webext/ -i app/manifest.json -i manifest.firefox.json -i app/index.html \" \"npm run start:server\"",
"package:webext": "npm run package:chrome && npm run package:firefox",
"package:chrome": "npm run build:app && web-ext build -s ./dist/webext/ -i app/manifest.json -i app/index.html -i manifest.firefox.json -i 'app/*.map' -n chrome.zip --overwrite-dest",
"package:firefox": "npm run build:app && cp src/webext/manifest.firefox.json dist/webext/manifest.json && web-ext build -s ./dist/webext/ -i app/manifest.json -i manifest.firefox.json -i app/index.html -i 'app/*.map' -n firefox.zip --overwrite-dest",
"package:chrome": "export TARGET=chrome && npm run build:app && web-ext build -s ./dist/webext/ -i app/manifest.json -i app/index.html -i manifest.chrome.json -i manifest.firefox.json -i 'app/*.map' -n chrome.zip --overwrite-dest",
"package:firefox": "export TARGET=firefox && npm run build:app && web-ext build -s ./dist/webext/ -i app/manifest.json -i manifest.chrome.json -i manifest.firefox.json -i app/index.html -i 'app/*.map' -n firefox.zip --overwrite-dest",
"lint": "eslint 'src/**/*.{js,ts,tsx}' --max-warnings 0",
"fixlint": "eslint 'src/**/*.{js,ts,tsx}' --fix",
"test": "TS_NODE_FILES=1 NODE_PATH=src mocha -r ts-node/register 'tests/app/**/*.test.ts'",

View File

@ -47,7 +47,7 @@ export default function App() {
const [query, setQuery] = useState("");
const [locale, setLocale] = useStorage<string>("locale", getUserLocale());
const [showBookmarksBar, setShowBookmarksBar] = useStorage("showBookmarksBar", true);
const [showBookmarksBar, setShowBookmarksBar] = useStorage("showBookmarksBar", app_version.target == "chrome");
const [messages] = usePromise(() => locale ? getTranslation(locale) : Promise.reject(null), [locale]);
const [background, setBackground] = useBackground();
const [theme, setTheme] = useStorage<ThemeConfig>("theme", {});

1
src/app/custom.d.ts vendored
View File

@ -3,6 +3,7 @@ interface Version {
is_debug: boolean;
commit: string;
environment: string;
target: ("firefox" | "chrome");
}

View File

@ -16,12 +16,6 @@
"chrome_url_overrides" : {
"newtab": "app/webext.html"
},
"browser_specific_settings": {
"gecko": {
"id": "{166411f2-402a-4bca-a3da-38b795ec8007}",
"strict_min_version": "78.0"
}
},
"permissions": [
"storage",
"search"

View File

@ -27,7 +27,7 @@ echo "Creating $type release..."
tag=$(npm -no-git-tag-version version ${type})
version=${tag:1}
sed -i "s/\/$old_version/\/$version/g" src/server/index.ts
sed -i "s/\"$old_version\"/\"$version\"/g" src/webext/manifest.json
sed -i "s/\"$old_version\"/\"$version\"/g" src/webext/manifest.chrome.json
sed -i "s/\"$old_version\"/\"$version\"/g" src/webext/manifest.firefox.json
git add .

View File

@ -13,6 +13,11 @@ const gitRevisionPlugin = new GitRevisionPlugin({
const isProd = process.env.NODE_ENV === "production";
const dest = path.resolve(__dirname, "dist/webext/app");
const target = process.env.TARGET ?? "firefox";
if (target !== "firefox" && target !== "chrome") {
throw new Error(`Unknown target: ${target}`);
}
const configFile = path.resolve(__dirname, "config.json");
function getConfig() {
const config = JSON.parse(fs.readFileSync(configFile).toString());
@ -21,13 +26,13 @@ function getConfig() {
return {
API_URL: JSON.stringify(config.API_URL),
PROXY_URL: JSON.stringify(config.PROXY_URL),
SENTRY_DSN: JSON.stringify(config.SENTRY_DSN)
SENTRY_DSN: JSON.stringify(config.SENTRY_DSN),
};
}
const mode = isProd ? "production" : "development";
console.log(`Webpack is building in ${mode}`);
console.log(`Webpack is building in ${mode} for ${target}`);
module.exports = {
mode: mode,
@ -40,14 +45,16 @@ module.exports = {
is_debug: !isProd,
commit: JSON.stringify(gitRevisionPlugin.commithash()),
environment: JSON.stringify(gitRevisionPlugin.version().includes("-") ? "development" : "production"),
target: JSON.stringify(target),
},
config: getConfig(),
}),
new CopyPlugin({
patterns: [
{ from: "src/webext/", to: path.resolve(__dirname, "dist/webext/") },
{ from: "src/webext/", to: path.resolve(__dirname, "dist/webext/"), globOptions: { ignore: ["**/webext/manifest.*"] } },
{ from: "src/app/public/", to: dest },
{ from: "node_modules/webextension-polyfill/dist/browser-polyfill.min.js", to: dest },
{ from: `src/webext/manifest.${target}.json`, to: path.resolve(__dirname, "dist/webext/manifest.json") },
]
}),
new MiniCssExtractPlugin({