Skip to content

Commit 275d060

Browse files
committed
Push Desktop Code
0 parents  commit 275d060

16 files changed

+32032
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dist
2+
dist-mac
3+
dist-win
4+
dist-mac-unsigned
5+
node_modules
6+
.DS_Store
7+
.env
8+
.todo
9+
.idea

.vscode/settings.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"workbench.colorCustomizations": {
3+
"commandCenter.border": "#e7e7e799",
4+
"sash.hoverBorder": "#2f7c47",
5+
"statusBar.background": "#215732",
6+
"statusBar.foreground": "#e7e7e7",
7+
"statusBarItem.hoverBackground": "#2f7c47",
8+
"statusBarItem.remoteBackground": "#215732",
9+
"statusBarItem.remoteForeground": "#e7e7e7",
10+
"titleBar.activeBackground": "#215732",
11+
"titleBar.activeForeground": "#e7e7e7",
12+
"titleBar.inactiveBackground": "#21573299",
13+
"titleBar.inactiveForeground": "#e7e7e799"
14+
},
15+
"peacock.color": "#215732"
16+
}

CHANGELOG.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Changelog
2+
3+
## February 2023 Release
4+
5+
**Date**: 2023.02.28
6+
7+
**Version**: `n8n-x_e-1-10-0_n-0-216-2` → desktop version: 1.10.0 | n8n version: 0.216.2
8+
9+
## December 2022 Release
10+
11+
**Date**: 2022.12.29
12+
13+
**Version**: `n8n-x_e-1-9-0_n-0-209-4` → desktop version: 1.9.0 | n8n version: 0.209.4
14+
15+
## November 2022 Release
16+
17+
**Date**: 2022.11.30
18+
19+
**Version**: `n8n-x_e-1-8-0_n-0-204-0` → desktop version: 1.8.0 | n8n version: 0.204.0
20+
21+
- Upgrade to `[email protected]`
22+
23+
## October 2022 Release
24+
25+
**Date**: 2022.10.18
26+
27+
**Version**: `n8n-x_e-1-7-0_n-0-198-2` → desktop version: 1.7.0 | n8n version: 0.198.2
28+
29+
- Upgrade to `[email protected]`
30+
- Set `N8N_DIAGNOSTICS_POSTHOG_DISABLE_RECORDING=false` in `n8n-desktop.env` if missing
31+
32+
## 15 June 2022 Release
33+
34+
**Date**: 2022.06.15
35+
36+
**Version**: `n8n-x_e-1-6-0_n-0-182-0` → desktop version: 1.6.0 | n8n version: 0.182.0
37+
38+
- Upgrade to `[email protected]`
39+
40+
## 6 June 2022 Release
41+
42+
**Date**: 2022.06.10
43+
44+
**Version**: `n8n-x_e-1-5-0_n-0-180-0` → desktop version: 1.5.0 | n8n version: 0.180.0
45+
46+
- Upgrade to `[email protected]`
47+
- New app bar menu item to reset DB to default user state
48+
49+
## April 2022 Release
50+
51+
**Date**: 2022.04.27
52+
53+
**Version**: `n8n-x_e-1-4-0_n-0-174-0` → desktop version: 1.4.0 | n8n version: 0.174.0
54+
55+
- Upgrade to `[email protected]`
56+
57+
## March 2022 Release
58+
59+
**Date**: 2022.03.03
60+
61+
**Version**: `n8n-x_e-1-3-0_n-0-165-1` → desktop version: 1.3.0 | n8n version: 0.165.1
62+
63+
- Upgrade to `[email protected]`
64+
- Read `DESKTOP_ENABLE_OFFLINE_MODE=true` in `n8n-desktop.env` to disable `--tunnel`
65+
66+
## January 2022 Release
67+
68+
**Date**: 2022.01.26
69+
70+
**Version**: `n8n-x_e-1-2-0_n-0-160-0` → desktop version: 1.2.0 | n8n version: 0.160.0
71+
72+
- Upgrade to `[email protected]`
73+
- Auto-detect timezone and set `GENERIC_TIMEZONE` in `n8n-desktop.env` if missing
74+
75+
## December 2021 Release
76+
77+
**Date**: 2021.12.17
78+
79+
**Version**: `n8n-x_e-1-1-0_n-0-153-0` → desktop version: 1.1.0 | n8n version: 0.153.0
80+
81+
- Upgrade to `[email protected]`
82+
- Restart on crash: if the n8n process crashes, desktop auto-recovers from `Connection lost` in 2-3 seconds
83+
- Desktop tunnel creds no longer needed when connecting OAuth creds
84+
- New app bar menu item "Auth" for desktop creds visibility
85+
- General refactorings. Initial groundwork for background processes. Non-user facing improvements.
86+
87+
## November 2021 Release
88+
89+
**Date**: 2021.11.04
90+
91+
**Version**: `n8n-x_e-1-0-0_n-0-147-0` → desktop version: 1.0.0 | n8n version: 0.147.0
92+
93+
- Initial release

LICENSE.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
## Sustainable Use License
2+
3+
Version 1.0
4+
5+
### Acceptance
6+
7+
By using the software, you agree to all of the terms and conditions below.
8+
9+
### Copyright License
10+
11+
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
12+
to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
13+
to the limitations below.
14+
15+
### Limitations
16+
17+
You may use or modify the software only for your own internal business purposes or for non-commercial or
18+
personal use. You may distribute the software or provide it to others only if you do so free of charge for
19+
non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
20+
the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
21+
22+
### Patents
23+
24+
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
25+
license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
26+
subject to the limitations and conditions in this license. This license does not cover any patent claims that
27+
you cause to be infringed by modifications or additions to the software. If you or your company make any
28+
written claim that the software infringes or contributes to infringement of any patent, your patent license
29+
for the software granted under these terms ends immediately. If your company makes such a claim, your patent
30+
license ends immediately for work on behalf of your company.
31+
32+
### Notices
33+
34+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
35+
terms. If you modify the software, you must include in any modified copies of the software a prominent notice
36+
stating that you have modified the software.
37+
38+
### No Other Rights
39+
40+
These terms do not imply any licenses other than those expressly granted in these terms.
41+
42+
### Termination
43+
44+
If you use the software in violation of these terms, such use is not licensed, and your license will
45+
automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
46+
violation of this license no later than 30 days after you receive that notice, your license will be reinstated
47+
retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
48+
terms will cause your license to terminate automatically and permanently.
49+
50+
### No Liability
51+
52+
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
53+
not be liable to you for any damages arising out of these terms or the use or nature of the software, under
54+
any kind of legal claim.
55+
56+
### Definitions
57+
58+
The “licensor” is the entity offering these terms.
59+
60+
The “software” is the software the licensor makes available under these terms, including any portion of it.
61+
62+
“You” refers to the individual or entity agreeing to these terms.
63+
64+
“Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
65+
all organizations that have control over, are under the control of, or are under common control with that
66+
organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
67+
management and policies by vote, contract, or otherwise. Control can be direct or indirect.
68+
69+
“Your license” is the license granted to you for the software under these terms.
70+
71+
“Use” means anything you do with the software requiring your license.
72+
73+
“Trademark” means trademarks, service marks, and similar rights.

NOTES.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Notes on n8n-desktop
2+
3+
- **Confirmed working on**: 32-bit Win 8.1, 64-bit Win 10, 64-bit Win 11, Intel/M1 Mac w/macOS 10.14.6 to 11.6 as of `8101cba` (Nov 4 launch)
4+
5+
## General notes
6+
7+
- **Processes**: Starting n8n desktop launches an init process that starts n8n at 5679, waits for it to be available, and launches the Electron main process, which creates a renderer process (Chromium instance). The only case where there is a second, third, etc. renderer process is when duplicating a workflow. Closing the Chromium instance throws an error that aborts the init process, bringing down all other processes as well - there is probably a more elegant way to do this. n8n desktop does not run in the background after being closed, by design.
8+
- **Port**: n8n.one requires port 5679 to be free. You can configure the port in `n8n-desktop.env`. This port is protected by default with basic auth.
9+
- **Default env vars**: n8n desktop's env vars are generated at and read from `~/.n8n/n8n-desktop.env` or `C:\Users\<user>\.n8n`. View them here: https://github.com/n8n-io/n8n-one/blob/main/defaultEnv.js
10+
- **Shared DB**: n8n desktop uses by default the same sqlite DB as vanilla n8n. To switch to PG or MySQL, add the relevant env vars in `n8n-desktop.env`, e.g. https://docs.n8n.io/reference/data/database.html#postgresdb
11+
- **Permissions**: If you run n8n desktop as a user with certain permissions, those permissions apply to anything n8n desktop can do, e.g. if the user cannot write to the root dir, neither will the Write File node.
12+
- **Unsupported nodes**: Kafka nodes are unsupported (`kafkajs` breaks build) and so is Edit Image node (requires separate install of `GraphicsMagick`).
13+
- **Logging to file**: If you set `N8N_LOG_OUTPUT=file` and `N8N_LOG_FILE_LOCATION=n8n.log`, then the logs will be written to `~/.n8n/n8n-desktop-logs/n8n.log` or `C:\Users\<user>\.n8n\n8n-desktop-logs\n8n.log`
14+
15+
## Win-specific notes
16+
17+
- **Installing**: Run the installer to install n8n desktop at `C:\Users\<user>\AppData\Local\Programs\n8n-desktop`. It also creates a cache at `C:\Users\<user>\AppData\Roaming\n8n-desktop`
18+
- **Uninstalling**: Run the uninstaller at the install dir. Uninstalling does not affect the .n8n dir or the cache dir.
19+
- **Windows Security screen**: If you see a Windows security screen titled `Windows protected your PC`, please click on `More Info` and then on `Run Anyway`. If the Microsoft malware scan was successful, this security screen should not be shown.
20+
- **Windows Defender Firewall**: If you see a Windows Defender Firewall dialog titled `Windows Defender Firewall has blocked some features of this app`, please click on `Allow access`.
21+
- **Updating**: Uninstall the old version, download the new version and install version. (Pending to test if it is possible to reinstall without uninstalling first.)
22+
- **Min Win version**: 32-bit Win 8.1 (there might be even older supported versions)
23+
24+
## Mac-specific notes
25+
26+
- **Updating**: Trash n8n.app, redownload and rerun.
27+
- **Min macOS version**: Mojave 10.14.6 (there might be even older supported versions)

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
![n8n.io - Workflow Automation](https://user-images.githubusercontent.com/65276001/173571060-9f2f6d7b-bac0-43b6-bdb2-001da9694058.png)
2+
3+
# n8n Desktop
4+
5+
This repository is no longer maintained.
6+
7+
## License
8+
9+
n8n is [fair-code](http://faircode.io) distributed under the [**Sustainable Use License**](https://github.com/n8n-io/n8n/blob/master/packages/cli/LICENSE.md).
10+
11+
Proprietary licenses are available for enterprise customers. [Get in touch](mailto:[email protected])
12+
13+
Additional information about the license can be found in the [docs](https://docs.n8n.io/reference/license/).

assets/icon.png

49.6 KB
Loading

entitlements.mac.plist

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
6+
<true/>
7+
<key>com.apple.security.cs.disable-library-validation</key>
8+
<true/>
9+
</dict>
10+
</plist>

envVars.js

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
const fs = require("fs");
2+
const { readFile, writeFile } = require("fs/promises");
3+
const path = require("path");
4+
const dotenv = require("dotenv");
5+
const moment = require("moment-timezone");
6+
7+
const defaultEnv = `
8+
N8N_DEPLOYMENT_TYPE='${getDeploymentType()}'
9+
EXECUTIONS_PROCESS='main'
10+
EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
11+
EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=true
12+
N8N_BASIC_AUTH_ACTIVE=true
13+
N8N_BASIC_AUTH_USER='${generateRandomString()}'
14+
N8N_BASIC_AUTH_PASSWORD='${generateRandomString()}'
15+
N8N_PORT=5679
16+
`;
17+
18+
// from packages/cli/commands/start.ts
19+
function generateRandomString() {
20+
const availableCharacters = "abcdefghijklmnopqrstuvwxyz0123456789";
21+
return Array.from({ length: 24 })
22+
.map(() => {
23+
return availableCharacters.charAt(
24+
Math.floor(Math.random() * availableCharacters.length)
25+
);
26+
})
27+
.join("");
28+
}
29+
30+
function getDeploymentType() {
31+
if (process.platform === "darwin") return "desktop_mac";
32+
if (process.platform === "win32") return "desktop_win";
33+
throw new Error("Unsupported platform");
34+
}
35+
36+
async function setEnvVars() {
37+
const dotN8nDir = await getDotN8nDir();
38+
39+
await handleLoggingEnvVars(dotN8nDir);
40+
41+
const desktopEnvPath = await getDesktopEnvPath(dotN8nDir);
42+
43+
await addGenericTimezoneEnvVar(desktopEnvPath);
44+
45+
dotenv.config({ path: desktopEnvPath });
46+
}
47+
48+
async function getDotN8nDir() {
49+
const dotN8nDir = path.join(getUserHome(), ".n8n");
50+
51+
if (!fs.existsSync(dotN8nDir)) {
52+
await fs.promises.mkdir(dotN8nDir);
53+
}
54+
55+
return dotN8nDir;
56+
}
57+
58+
// from packages/core/src/UserSettings.ts
59+
function getUserHome() {
60+
let variableName = "HOME";
61+
if (process.platform === "win32") {
62+
variableName = "USERPROFILE";
63+
}
64+
65+
if (process.env[variableName] === undefined) {
66+
// If for some reason the variable does not exist
67+
// fall back to current folder
68+
return process.cwd();
69+
}
70+
71+
return process.env[variableName];
72+
}
73+
74+
async function getDesktopEnvPath(dotN8nDir) {
75+
const desktopEnvPath = path.join(dotN8nDir, "n8n-desktop.env");
76+
77+
if (!fs.existsSync(desktopEnvPath)) {
78+
await fs.promises.writeFile(desktopEnvPath, defaultEnv);
79+
}
80+
81+
return desktopEnvPath;
82+
}
83+
84+
async function addGenericTimezoneEnvVar(desktopEnvPath) {
85+
const envFileContent = await readFile(desktopEnvPath, "utf8");
86+
87+
const containsGenericTimezoneEnvVar = envFileContent
88+
.split("\n")
89+
.some((line) => line.startsWith("GENERIC_TIMEZONE="));
90+
91+
if (containsGenericTimezoneEnvVar) return;
92+
93+
await writeFile(
94+
desktopEnvPath,
95+
[envFileContent, `GENERIC_TIMEZONE='${moment.tz.guess()}'`].join("\n")
96+
);
97+
}
98+
99+
async function handleLoggingEnvVars(dotN8nDir) {
100+
if (
101+
process.env.N8N_LOG_OUTPUT === "file" &&
102+
process.env.N8N_LOG_FILE_LOCATION
103+
) {
104+
const logsDirPath = path.join(dotN8nDir, "n8n-desktop-logs");
105+
106+
if (!fs.existsSync(logsDirPath)) {
107+
await fs.promises.mkdir(logsDirPath);
108+
}
109+
110+
process.env.N8N_LOG_FILE_LOCATION = path.join(
111+
logsDirPath,
112+
process.env.N8N_LOG_FILE_LOCATION
113+
);
114+
}
115+
}
116+
117+
module.exports = { defaultEnv: defaultEnv.trim(), setEnvVars };

0 commit comments

Comments
 (0)