chore: remove all desktop packaging from web app

This commit is contained in:
thecodrr
2021-07-07 00:59:49 +05:00
parent b3381bc1f2
commit 49e9def5b5
10 changed files with 45 additions and 1367 deletions

View File

@@ -28,13 +28,17 @@ jobs:
run: |
mkdir -p ~/private_keys/
echo '${{ secrets.api_key }}' > ~/private_keys/AuthKey_${{ secrets.api_key_id }}.p8
- name: Change directory to ./desktop
run: cd desktop
- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.PERSONAL_GH_TOKEN }}
build_script_name: "build:desktop"
build_script_name: "release"
# macOS code signing certificate
mac_certs: ${{ secrets.mac_certs }}
mac_certs_password: ${{ secrets.mac_certs_password }}

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 353 KiB

View File

@@ -1,15 +1,15 @@
{
"name": "notesnook",
"productName": "Notesnook",
"description": "Your private note taking space",
"version": "1.4.1",
"private": true,
"main": "./build/electron.js",
"main": "./src/App.js",
"homepage": "https://notesnook.com/",
"repository": "https://github.com/streetwriters/notesnook",
"dependencies": {
"@mdi/js": "^5.9.55",
"@mdi/react": "^1.4.0",
"@notesnook/desktop": "./desktop/",
"@rebass/forms": "^4.0.6",
"@tinymce/tinymce-react": "^3.12.6",
"clipboard": "^2.0.6",
@@ -17,9 +17,8 @@
"compressorjs": "^1.0.7",
"currency-symbol-map": "^5.0.1",
"dayjs": "^1.10.4",
"electron-serve": "^1.1.0",
"electron-updater": "^4.3.8",
"emotion-theming": "^10.0.19",
"esbuild": "^0.12.15",
"eventsource": "^1.0.7",
"fast-sort": "^2.1.1",
"framer-motion": "^3.3.0",
@@ -27,7 +26,6 @@
"immer": "^8.0.1",
"localforage": "^1.7.3",
"localforage-getitems": "https://github.com/thecodrr/localForage-getItems.git",
"node-fetch": "^2.6.1",
"notes-core": "npm:@streetwriters/notesnook-core@latest",
"print-js": "^1.6.0",
"qclone": "^1.0.4",
@@ -56,10 +54,6 @@
"@types/quill": "^2.0.5",
"babel-eslint": "^10.1.0",
"chalk": "^4.1.0",
"electron": "^12.0.0",
"electron-builder": "^22.10.5",
"electron-builder-notarize": "^1.2.0",
"electron-reloader": "^1.2.1",
"env-cmd": "^10.1.0",
"eslint": "^7.20.0",
"eslint-config-react-app": "^6.0.0",
@@ -77,7 +71,6 @@
},
"scripts": {
"start": "env-cmd -e all,dev,web react-scripts start",
"start:desktop": "env-cmd -e all,dev,desktop react-scripts start && yarn electron-dev",
"build": "env-cmd -e all,web react-scripts build",
"build:desktop": "env-cmd -e all,desktop react-scripts build",
"deploy": "./scripts/deploy.sh",
@@ -85,10 +78,7 @@
"test": "REACT_APP_CI=true BROWSER= jest --runInBand -c jest.e2e.config.js",
"eject": "react-scripts eject",
"update": "npm i @streetwriters/editor@latest @streetwriters/notesnook-core@latest @streetwriters/theme@latest",
"analyze": "source-map-explorer 'build/static/js/*.js'",
"electron-dev": "ELECTRON_START_URL=http://localhost:3000 electron ./public/electron.js",
"electron-prod": "electron build/electron.js",
"electron-build": "electron-builder"
"analyze": "source-map-explorer 'build/static/js/*.js'"
},
"eslintConfig": {
"extends": "react-app"
@@ -112,101 +102,5 @@
"name": "Streetwriters (Private) Ltd.",
"email": "support@streetwriters.co",
"url": "https://streetwriters.co"
},
"build": {
"appId": "com.streetwriters.notesnook",
"productName": "Notesnook",
"copyright": "Copyright © 2021 Streetwriters (Private) Ltd.",
"files": [
"!*.chunk.js.map",
"!*.chunk.js.LICENSE.txt",
"build/",
"!node_modules",
"node_modules/node-fetch",
"node_modules/electron-updater",
"node_modules/lazy-val",
"node_modules/builder-util-runtime",
"node_modules/fs-extra",
"node_modules/js-yaml",
"node_modules/lodash.isequal",
"node_modules/semver",
"node_modules/debug",
"node_modules/ms",
"node_modules/lru-cache",
"node_modules/yallist",
"node_modules/universalify",
"node_modules/graceful-fs",
"node_modules/at-least-node",
"node_modules/jsonfile",
"node_modules/sax"
],
"afterSign": "electron-builder-notarize",
"afterPack": "./scripts/removeLocales.js",
"mac": {
"target": [
"dmg",
"zip"
],
"electronLanguages": [
"en-US"
],
"category": "public.app-category.productivity",
"darkModeSupport": true,
"type": "distribution",
"hardenedRuntime": true,
"entitlements": "assets/entitlements.mac.plist",
"entitlementsInherit": "assets/entitlements.mac.plist",
"gatekeeperAssess": false,
"icon": "assets/icons/app.icns"
},
"dmg": {
"contents": [
{
"x": 130,
"y": 220
},
{
"x": 410,
"y": 220,
"type": "link",
"path": "/Applications"
}
],
"icon": "assets/icons/app.icns",
"title": "Install Notesnook"
},
"win": {
"target": [
"nsis"
],
"icon": "assets/icons/app.ico"
},
"nsis": {
"oneClick": true,
"createDesktopShortcut": "always"
},
"linux": {
"target": [
"AppImage",
"deb",
"rpm"
],
"category": "Office",
"icon": "assets/icons/app.icns",
"description": "Your private note taking space",
"executableName": "Notesnook"
},
"extraResources": [
"./assets/**"
],
"directories": {
"buildResources": "assets",
"output": "dist/"
},
"publish": {
"provider": "github",
"repo": "notesnook",
"owner": "streetwriters"
}
}
}

View File

@@ -1,137 +0,0 @@
const { app, protocol, BrowserWindow, ipcMain } = require("electron");
const { autoUpdater } = require("electron-updater");
const path = require("path");
const fs = require("fs");
const os = require("os");
const fetch = require("node-fetch").default;
const FILE_NOT_FOUND = -6;
try {
require("electron-reloader")(module);
} catch (_) {}
const isDev = isDevelopment();
const extensionToMimeType = {
html: "text/html",
json: "application/json",
js: "application/javascript",
css: "text/css",
svg: "image/svg+xml",
png: "image/png",
};
let mainWindow;
async function createWindow() {
mainWindow = new BrowserWindow({
autoHideMenuBar: true,
icon: path.join(
__dirname,
os.platform() === "win32" ? "app.ico" : "favicon-72x72.png"
),
webPreferences: {
devTools: true, // isDev,
nodeIntegration: false, //true,
preload: __dirname + "/preload.js",
},
});
if (isDev)
mainWindow.webContents.openDevTools({ mode: "right", activate: true });
mainWindow.maximize();
// await loadURL(mainWindow);
mainWindow.loadURL(
isDev ? process.env.ELECTRON_START_URL : "https://notesnook"
);
mainWindow.on("closed", () => {
mainWindow = null;
});
}
app.commandLine.appendSwitch("lang", "en-US");
app.on("ready", () => {
protocol.interceptStreamProtocol(
"https",
async (request, callback) => {
const url = new URL(request.url);
if (url.hostname === "notesnook") {
const absoluteFilePath = path.normalize(
`${__dirname}${url.pathname === "/" ? "/index.html" : url.pathname}`
);
const filePath = getPath(absoluteFilePath);
if (!filePath) {
callback({ error: FILE_NOT_FOUND });
return;
}
const fileExtension = path.extname(filePath).replace(".", "");
const data = fs.createReadStream(filePath);
callback({
data,
mimeType: extensionToMimeType[fileExtension],
});
} else {
const response = await fetch(request.url, {
...request,
body: !!request.uploadData ? request.uploadData[0].bytes : null,
headers: { ...request.headers, origin: "https://app.notesnook.com/" },
});
callback({
data: response.body,
headers: response.headers,
mimeType: response.headers.get("Content-Type"),
statusCode: response.status,
});
}
},
(err) => {
if (err) console.error("Failed to register protocol");
}
);
autoUpdater.checkForUpdatesAndNotify().catch((e) => console.log(e));
createWindow();
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (mainWindow === null) {
createWindow();
}
});
ipcMain.on("fromRenderer", (event, ...args) => {
console.log(event, ...args);
});
function isDevelopment() {
if (typeof electron === "string") {
throw new TypeError("Not running in an Electron environment!");
}
const isEnvSet = "ELECTRON_IS_DEV" in process.env;
const getFromEnv = Number.parseInt(process.env.ELECTRON_IS_DEV, 10) === 1;
return isEnvSet ? getFromEnv : !app.isPackaged;
}
function getPath(filePath) {
try {
const result = fs.statSync(filePath);
if (result.isFile()) {
return filePath;
}
if (result.isDirectory()) {
return getPath(path.join(filePath, "index.html"));
}
} catch (_) {}
}

View File

@@ -1,20 +0,0 @@
const { contextBridge, ipcRenderer } = require("electron");
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld("api", {
send: (channel, data) => {
// whitelist channels
let validChannels = ["fromRenderer"];
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data);
}
},
receive: (channel, func) => {
let validChannels = ["fromMain"];
if (validChannels.includes(channel)) {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(channel, (event, ...args) => func(...args));
}
},
});

View File

@@ -1,20 +0,0 @@
export CSC_LINK=$(cat ./scripts/secrets/csc.b64)
export CSC_KEY_PASSWORD="Loveyouall123"
export API_KEY_ID="JD348FXHMN"
export API_KEY_ISSUER_ID=""
export GH_TOKEN=$(cat ./scripts/secrets/gh-token.txt)
export ADBLOCK=true
echo "Building..."
yarn build:desktop
echo "Notarizing..."
mkdir -p ~/private_keys/
cat ./scripts/secrets/AuthKey_$API_KEY_ID.b64 > ~/private_keys/AuthKey_$API_KEY_ID.p8
echo "Building & releasing electrong app..."
electron-builder --mac --publish always

View File

@@ -1,17 +0,0 @@
//https://www.electron.build/configuration/configuration#afterpack
exports.default = async function (context) {
//console.log(context)
var fs = require("fs");
var localeDir = context.appOutDir + "/locales/";
fs.readdir(localeDir, function (err, files) {
//files is array of filenames (basename form)
if (!(files && files.length)) return;
for (var i = 0, len = files.length; i < len; i++) {
var match = files[i].match(/en-US\.pak/);
if (match === null) {
fs.unlinkSync(localeDir + files[i]);
}
}
});
};

File diff suppressed because it is too large Load Diff