From f2877386c8091a0f3ad582d611b2b6f738222e0c Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sat, 22 May 2021 21:21:37 -0500 Subject: [PATCH 01/12] Unified Shortcut Script, Windows finished --- Launch-Scripts/create-shortcut.js | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Launch-Scripts/create-shortcut.js diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js new file mode 100644 index 000000000..17f367b2c --- /dev/null +++ b/Launch-Scripts/create-shortcut.js @@ -0,0 +1,52 @@ +const path = require("path"); +const fs = require("fs"); +const process = require("process"); +const { exec } = require("child_process"); +const os = require("os"); + +// Get the name of the main directory +let cwd = process.cwd(); +let dirs = cwd.split(path.sep); +let name = dirs[dirs.length - 2]; + +if (os.platform() == "win32") { + // Paths and Icon for Windows shortcuts + let target = path.join( process.cwd(), "launch-windows.bat") + let icon = path.join( process.cwd(), "superalgos.ico") + let ShortcutPaths = [ + path.join( os.homedir(), "Desktop", `${name}.lnk`), + path.join( os.homedir(), "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", "Superalgos.lnk") + ] + + // Place Shortcuts using powershell + let dir; + for (dir in ShortcutPaths) { + let command = `$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("${ShortcutPaths[dir]}"); $S.TargetPath = "${target}"; $S.IconLocation = "${icon}"; $S.Save()`; + + exec( command, + { + shell: "powershell.exe", + execArgv: "-ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command" + }, + function ( error, stdout ){ + if (error) { + console.log(''); + console.log("There was an error installing a shortcut: "); + console.log(''); + console.log( error ); + return; + } else { + console.log(''); + console.log("A shortcut added successfully!"); + } + }); + + }; + +} else if (os.platform() == "linux") { + // Paths and Icon for Windows shortcuts + console.log("still working on linux") + +} else if (os.platform() == "darwin") { + console.log( "Automatic shortcut creation is not currently supported on mac yet. If you would like to see this feature add, ask the devs on telegram or discord!") +} \ No newline at end of file From 46cfe71c32bfb73faa154a9c02eb0bb6a025d624 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 10:05:09 -0600 Subject: [PATCH 02/12] Modify: Unified create-shortcut Script --- Launch-Scripts/create-shortcut.js | 73 ++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js index 17f367b2c..8a24baa2d 100644 --- a/Launch-Scripts/create-shortcut.js +++ b/Launch-Scripts/create-shortcut.js @@ -9,19 +9,20 @@ let cwd = process.cwd(); let dirs = cwd.split(path.sep); let name = dirs[dirs.length - 2]; +// Windows Shortcuts if (os.platform() == "win32") { // Paths and Icon for Windows shortcuts - let target = path.join( process.cwd(), "launch-windows.bat") - let icon = path.join( process.cwd(), "superalgos.ico") - let ShortcutPaths = [ + let target = path.join( process.cwd(), "launch-windows.bat"); + let icon = path.join( process.cwd(), "superalgos.ico"); + let shortcutPaths = [ path.join( os.homedir(), "Desktop", `${name}.lnk`), path.join( os.homedir(), "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", "Superalgos.lnk") ] // Place Shortcuts using powershell let dir; - for (dir in ShortcutPaths) { - let command = `$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("${ShortcutPaths[dir]}"); $S.TargetPath = "${target}"; $S.IconLocation = "${icon}"; $S.Save()`; + for (dir in shortcutPaths) { + let command = `$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("${shortcutPaths[dir]}"); $S.TargetPath = "${target}"; $S.IconLocation = "${icon}"; $S.Save()`; exec( command, { @@ -37,16 +38,68 @@ if (os.platform() == "win32") { return; } else { console.log(''); - console.log("A shortcut added successfully!"); + console.log("Shortcut added successfully!"); } }); - }; +// Linux Shortcuts } else if (os.platform() == "linux") { - // Paths and Icon for Windows shortcuts - console.log("still working on linux") + // Check for Ubuntu + let version = os.version(); + if (version.includes("Ubuntu")) { + // Paths and Icon for Ubuntu shortcuts + let icon = path.join( process.cwd(),"..", "/Projects/Superalgos/Icons/superalgos.png"); + let shortcutPaths = [ + path.join( os.homedir(), "Desktop/" ), + path.join( os.homedir(), "local/share/applications/" ) + ] + // Create .desktop shortcut file + console.log("still working on linux", icon, shortcutPaths) + fs.writeFileSync( `${name}.desktop`, + `[Desktop Entry] + Type=Application + Encoding=UTF-8 + Name=${name} + Comment=Launch Shortcut for Superalgos + Path=${process.cwd()} + Exec=gnome-terminal -e ${process.cwd()}/launch-linux.sh + Terminal=true + Icon=${icon} + Categories=Application;`, + ); + + // Set shortcut as executable + fs.chmodSync( `${name}.desktop`, "775" ); + + // Place shortcut in proper folders + let command = `cp ${name}.desktop ~/Desktop/${name}.desktop & cp ${name}.desktop ~/.local/share/applications/${name}.desktop` + exec( command, + function ( error, stdout ){ + if (error) { + console.log(''); + console.log("There was an error installing a shortcut: "); + console.log(''); + console.log( error ); + return; + } else { + console.log(''); + console.log("Shortcuts added successfully!"); + } + // Remove temporary .desktop file + fs.unlinkSync( `${name}.desktop` ) + }); + + } else { + console.log( "Automatic shortcut creation is not yet supported on your flavor of linux. If you would like to see this feature add, message @harrellbm on telegram or discord to ask how you can help!") + } + +// Mac Shortcuts } else if (os.platform() == "darwin") { - console.log( "Automatic shortcut creation is not currently supported on mac yet. If you would like to see this feature add, ask the devs on telegram or discord!") + console.log( "Automatic shortcut creation is not yet supported on Mac. If you would like to see this feature add, message @harrellbm on telegram or discord to ask how you can help!") + +// Misc Operating System +} else { + console.log("Automatic shortcut creation is not currently supported on your operating system. If you would like to see your operating system added please reachout on discord or telegram to let the devs know.") } \ No newline at end of file From 8e87370cfb81b2ee4c5b7f61ff557e67eb3cc63d Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 10:06:16 -0600 Subject: [PATCH 03/12] Delete: Old create-shortcut Scripts --- Launch-Scripts/create-shortcut-ubuntu.sh | 26 ---------------------- Launch-Scripts/create-shortcut-windows.bat | 12 ---------- 2 files changed, 38 deletions(-) delete mode 100755 Launch-Scripts/create-shortcut-ubuntu.sh delete mode 100644 Launch-Scripts/create-shortcut-windows.bat diff --git a/Launch-Scripts/create-shortcut-ubuntu.sh b/Launch-Scripts/create-shortcut-ubuntu.sh deleted file mode 100755 index ff10a98c4..000000000 --- a/Launch-Scripts/create-shortcut-ubuntu.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -PWD=`pwd` -DIR=${PWD%/*} - -touch Superalgos.desktop - -echo "[Desktop Entry] -Type=Application -Encoding=UTF-8 -Name=Superalgos -Comment=Launch Shortcut for Superalgos -Path=$PWD -Exec=gnome-terminal -e $PWD/launch-linux.sh -Terminal=true -Icon=$DIR/Projects/Superalgos/Icons/superalgos.png -Categories=Application;" > Superalgos.desktop - -chmod +x Superalgos.desktop - -cp Superalgos.desktop ~/Desktop/Superalgos.desktop -cp Superalgos.desktop ~/.local/share/applications/Superalgos.desktop - -rm Superalgos.desktop - -# Keep terminal open for debugging -#$SHELL \ No newline at end of file diff --git a/Launch-Scripts/create-shortcut-windows.bat b/Launch-Scripts/create-shortcut-windows.bat deleted file mode 100644 index 40d28012b..000000000 --- a/Launch-Scripts/create-shortcut-windows.bat +++ /dev/null @@ -1,12 +0,0 @@ -set TARGET='%CD%\launch-windows.bat' -set SHORTCUT='%USERPROFILE%\Desktop\Superalgos.lnk' -set STARTMENU='%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Superalgos.lnk' -set ICON='%CD%\superalgos.ico' -set PWS=powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile - -%PWS% -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut(%SHORTCUT%); $S.TargetPath = %Target%; $S.IconLocation = %ICON%; $S.Save()" - -%PWS% -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut(%STARTMENU%); $S.TargetPath = %Target%; $S.IconLocation = %ICON%; $S.Save()" - -REM Keep terminal open for debug -REM cmd /k echo "keep open" \ No newline at end of file From 8d64c231c0c247d795b0c0e3983d590fb18a2068 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 12:01:34 -0600 Subject: [PATCH 04/12] Add: Create Shortcut Command to Setup Script --- setup.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/setup.js b/setup.js index e0c0c26d5..41c3fec1c 100644 --- a/setup.js +++ b/setup.js @@ -2,6 +2,24 @@ const path = require("path"); const process = require("process"); const { exec } = require("child_process"); +// Handle adding shortcuts +if (process.argv.includes("noShortcuts")) { + // Cancel running script if flag provided + console.log('noShortcuts ................................................... Setting up without shortcuts.') + +} else { + // Run create-shortcuts script + try { + const { fork } = require('child_process') + fork('./Launch-Scripts/create-shortcut.js') + } catch (err) { + console.log('') + console.log(err) + console.log('') + + } +} + // Create Operating System compatable paths to each node_modules directory. let nodeModulesDirs = [ path.join( process.cwd(), "Client"), From eef8f6e03c2a6c151c0d9a25ad81925ebdab5903 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 12:06:13 -0600 Subject: [PATCH 05/12] Fix: Adjust Paths for Setup Run --- Launch-Scripts/create-shortcut.js | 13 ++++--------- setup.js | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js index 8a24baa2d..17e0567d8 100644 --- a/Launch-Scripts/create-shortcut.js +++ b/Launch-Scripts/create-shortcut.js @@ -5,7 +5,7 @@ const { exec } = require("child_process"); const os = require("os"); // Get the name of the main directory -let cwd = process.cwd(); +let cwd = __dirname; let dirs = cwd.split(path.sep); let name = dirs[dirs.length - 2]; @@ -49,22 +49,17 @@ if (os.platform() == "win32") { let version = os.version(); if (version.includes("Ubuntu")) { // Paths and Icon for Ubuntu shortcuts - let icon = path.join( process.cwd(),"..", "/Projects/Superalgos/Icons/superalgos.png"); - let shortcutPaths = [ - path.join( os.homedir(), "Desktop/" ), - path.join( os.homedir(), "local/share/applications/" ) - ] + let icon = path.join( __dirname,"..", "/Projects/Superalgos/Icons/superalgos.png"); // Create .desktop shortcut file - console.log("still working on linux", icon, shortcutPaths) fs.writeFileSync( `${name}.desktop`, `[Desktop Entry] Type=Application Encoding=UTF-8 Name=${name} Comment=Launch Shortcut for Superalgos - Path=${process.cwd()} - Exec=gnome-terminal -e ${process.cwd()}/launch-linux.sh + Path=${__dirname} + Exec=gnome-terminal -e ${__dirname}/launch-linux.sh Terminal=true Icon=${icon} Categories=Application;`, diff --git a/setup.js b/setup.js index 41c3fec1c..2f7860277 100644 --- a/setup.js +++ b/setup.js @@ -5,6 +5,7 @@ const { exec } = require("child_process"); // Handle adding shortcuts if (process.argv.includes("noShortcuts")) { // Cancel running script if flag provided + console.log(''); console.log('noShortcuts ................................................... Setting up without shortcuts.') } else { From 8319db6588c320d516023ba0d729dd809520d357 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 12:52:13 -0600 Subject: [PATCH 06/12] Modify: Optimize Launch Script for Linux and Mac --- Launch-Scripts/create-shortcut.js | 2 +- Launch-Scripts/launch-linux-mac.sh | 4 ++++ Launch-Scripts/launch-linux.sh | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100755 Launch-Scripts/launch-linux-mac.sh delete mode 100755 Launch-Scripts/launch-linux.sh diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js index 17e0567d8..e3c62d1a4 100644 --- a/Launch-Scripts/create-shortcut.js +++ b/Launch-Scripts/create-shortcut.js @@ -59,7 +59,7 @@ if (os.platform() == "win32") { Name=${name} Comment=Launch Shortcut for Superalgos Path=${__dirname} - Exec=gnome-terminal -e ${__dirname}/launch-linux.sh + Exec=gnome-terminal -e ${__dirname}/launch-linux-mac.sh Terminal=true Icon=${icon} Categories=Application;`, diff --git a/Launch-Scripts/launch-linux-mac.sh b/Launch-Scripts/launch-linux-mac.sh new file mode 100755 index 000000000..d67c15fd6 --- /dev/null +++ b/Launch-Scripts/launch-linux-mac.sh @@ -0,0 +1,4 @@ +#!/bin/sh +cd .. +node run +"$SHELL" \ No newline at end of file diff --git a/Launch-Scripts/launch-linux.sh b/Launch-Scripts/launch-linux.sh deleted file mode 100755 index cdbe490aa..000000000 --- a/Launch-Scripts/launch-linux.sh +++ /dev/null @@ -1 +0,0 @@ -x-terminal-emulator -e "cd .. && node run && $SHELL" \ No newline at end of file From 32eee8307365fcf74549095caf417824e12cec39 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 13:14:33 -0600 Subject: [PATCH 07/12] Add: Unified uninstall Script Finished Ubuntu side --- Launch-Scripts/uninstall.js | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Launch-Scripts/uninstall.js diff --git a/Launch-Scripts/uninstall.js b/Launch-Scripts/uninstall.js new file mode 100644 index 000000000..305fd55d3 --- /dev/null +++ b/Launch-Scripts/uninstall.js @@ -0,0 +1,39 @@ +const path = require("path"); +const os = require("os"); +const { exec } = require("child_process"); + +// Get the name of the main directory +let cwd = __dirname; +let dirs = cwd.split(path.sep); +let name = dirs[dirs.length - 2]; + +// Windows Shortcuts +if (os.platform() == "win32") { + +// Linux Shortcuts +} else if (os.platform() == "linux") { + // Check for Ubuntu + let version = os.version(); + if (version.includes("Ubuntu")) { + + // Remove .desktop files + let command = `rm ~/Desktop/${name}.desktop & rm ~/.local/share/applications/${name}.desktop` + exec( command, + function ( error, stdout ){ + if (error) { + console.log(''); + console.log("There was an error uninstalling shortcuts: "); + console.log(''); + console.log( error ); + return; + } else { + console.log(''); + console.log("Shortcuts have been uninstalled successfully."); + } + }); + } + +// Mac Shortcuts +} else if (os.platform() == "darwin") { + // Uninstall Mac shortcuts here once they have been added. +} \ No newline at end of file From 987eb760234e4dda5cec945756305978d638cdbb Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 15:21:10 -0500 Subject: [PATCH 08/12] Add: Finish Unified Uninstall Script --- Launch-Scripts/create-shortcut.js | 7 +++--- Launch-Scripts/uninstall.js => uninstall.js | 24 ++++++++++++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) rename Launch-Scripts/uninstall.js => uninstall.js (56%) diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js index e3c62d1a4..97f443bae 100644 --- a/Launch-Scripts/create-shortcut.js +++ b/Launch-Scripts/create-shortcut.js @@ -1,6 +1,5 @@ const path = require("path"); const fs = require("fs"); -const process = require("process"); const { exec } = require("child_process"); const os = require("os"); @@ -12,11 +11,11 @@ let name = dirs[dirs.length - 2]; // Windows Shortcuts if (os.platform() == "win32") { // Paths and Icon for Windows shortcuts - let target = path.join( process.cwd(), "launch-windows.bat"); - let icon = path.join( process.cwd(), "superalgos.ico"); + let target = path.join( __dirname, "launch-windows.bat"); + let icon = path.join( __dirname, "superalgos.ico"); let shortcutPaths = [ path.join( os.homedir(), "Desktop", `${name}.lnk`), - path.join( os.homedir(), "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", "Superalgos.lnk") + path.join( os.homedir(), "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", `${name}.lnk`) ] // Place Shortcuts using powershell diff --git a/Launch-Scripts/uninstall.js b/uninstall.js similarity index 56% rename from Launch-Scripts/uninstall.js rename to uninstall.js index 305fd55d3..0203d7e5d 100644 --- a/Launch-Scripts/uninstall.js +++ b/uninstall.js @@ -5,12 +5,30 @@ const { exec } = require("child_process"); // Get the name of the main directory let cwd = __dirname; let dirs = cwd.split(path.sep); -let name = dirs[dirs.length - 2]; +let name = dirs[dirs.length - 1]; -// Windows Shortcuts +// Remove Windows Shortcuts if (os.platform() == "win32") { + let desktop = path.join( os.homedir(), "Desktop", `${name}.lnk`) + let startMenu = path.join( os.homedir(), "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", `${name}.lnk`) -// Linux Shortcuts + // Remove .desktop files + let command = `del "${desktop}" & del "${startMenu}"` + exec( command, + function ( error ){ + if (error) { + console.log(''); + console.log("There was an error uninstalling shortcuts: "); + console.log(''); + console.log( error ); + return; + } else { + console.log(''); + console.log("Shortcuts have been uninstalled successfully."); + } + }); + +// Remove Linux Shortcuts } else if (os.platform() == "linux") { // Check for Ubuntu let version = os.version(); From b1bd4a350ab478a7bea2bc093c02d939af51548b Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 15:21:50 -0500 Subject: [PATCH 09/12] Delete: Old Uninstall Script --- Launch-Scripts/uninstall-shortcut-windows.bat | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 Launch-Scripts/uninstall-shortcut-windows.bat diff --git a/Launch-Scripts/uninstall-shortcut-windows.bat b/Launch-Scripts/uninstall-shortcut-windows.bat deleted file mode 100644 index 8067f9130..000000000 --- a/Launch-Scripts/uninstall-shortcut-windows.bat +++ /dev/null @@ -1,5 +0,0 @@ -del "%USERPROFILE%\Desktop\Superalgos.lnk" -del "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Superalgos.lnk" - -REM Keep terminal open for debug -REM cmd /k echo "keep open" \ No newline at end of file From a3ff7c3116e74a1c77a2818aef1f1d9824fa4468 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 16:13:22 -0500 Subject: [PATCH 10/12] Update: Docs for Launch-Scripts --- .../launch-scripts-001-launch-scripts.json | 165 +++++++++--------- 1 file changed, 81 insertions(+), 84 deletions(-) diff --git a/Projects/Superalgos/Schemas/Docs-Topics/launch-scripts-001-launch-scripts.json b/Projects/Superalgos/Schemas/Docs-Topics/launch-scripts-001-launch-scripts.json index fdafba90b..9e00fae18 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/launch-scripts-001-launch-scripts.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/launch-scripts-001-launch-scripts.json @@ -1,10 +1,10 @@ { "topic": "Launch Scripts", "pageNumber": "1", - "type": "Launch Scripts", + "type": "Launch Scripts and Shortcuts", "definition": { - "text": "There are a number of scripts to help make lauching Superalgos easier and feel more native. The eventual goal is to make Superalgos feel like any other program installed on an operating system.", - "updated": 1620052836275 + "text": "There are a number of scripts to help make launching Superalgos easier and feel more native. The eventual goal is to make Superalgos feel like any other program installed on an operating system.", + "updated": 1621801562983 }, "paragraphs": [ { @@ -24,8 +24,8 @@ }, { "style": "Text", - "text": "Due to the nature of scripts, there are different scripts for each type of operating system. The following page includes a description of each script and what it accomplishes.", - "updated": 1620052862888 + "text": "The following page includes a description of each script and what it accomplishes.", + "updated": 1621801618461 }, { "style": "Note", @@ -55,24 +55,18 @@ }, { "style": "Subtitle", - "text": "Linux" + "text": "Linux and Mac", + "updated": 1621801647118 }, { "style": "Json", - "text": "launch-linux.sh" + "text": "launch-linux-mac.sh", + "updated": 1621801639324 }, { "style": "Text", - "text": "This script uses the x-terminal-emulator command for maximum compatiblity across linux flavors." - }, - { - "style": "Subtitle", - "text": "Mac" - }, - { - "style": "Important", - "text": "Collaborator needed.", - "updated": 1620052924921 + "text": "This script uses basic shell commands to be compatible with both Linux and OSX systems.", + "updated": 1621801760692 }, { "style": "Subtitle", @@ -80,58 +74,90 @@ }, { "style": "Title", - "text": "Desktop/Launcher Shortcut Scripts", - "updated": 1620052680945 + "text": "Create Desktop/Launcher Shortcuts", + "updated": 1621802101953 + }, + { + "style": "Json", + "text": "create-shortcut.js", + "updated": 1621802056957 }, { "style": "Text", - "text": "These scripts automatically create and place shortcuts to the launch scripts. They can be run from the command line or file browser.", - "updated": 1620504518909 + "text": "There is one unifed script to automatically create and place shortcuts to the appropriate launch script. This script is automatically run during the \"node setup\" command. It can also be run individual as follows.", + "updated": 1621802202684 + }, + { + "style": "Callout", + "text": "In a terminal or command prompt, navigate to the Launch-Scripts file and type:", + "updated": 1621802248464 + }, + { + "style": "Json", + "text": "node create-shortcut" + }, + { + "style": "Text", + "text": "This will place shortcuts within your Start Menu/Launcher as well as on your Desktop. In Windows the start menu shortcut is also searchable using the start menu search bar.", + "updated": 1621802356143 }, { "style": "Subtitle", + "text": "Shortcut Locations" + }, + { + "style": "Text", + "text": "Depending on your operating system, shortcuts will be placed within different directories. Listed below are the locations by operating system.", + "updated": 1621802761147 + }, + { + "style": "Text", "text": "Windows" }, { - "style": "Json", - "text": "create-shortcut-windows.bat", - "updated": 1620053219653 + "style": "List", + "text": "Users\\[Your Name]\\Desktop" + }, + { + "style": "List", + "text": "Users\\[Your Name]\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs", + "updated": 1621802654652 }, { "style": "Text", - "text": "This script places shortcuts within the user's start menu and desktop. The start menu shortcut is also searchable using the start menu search bar.", - "updated": 1620789169171 + "text": "Ubuntu" + }, + { + "style": "List", + "text": "~/Desktop", + "updated": 1621803704659 + }, + { + "style": "List", + "text": "~/.local/share/applications", + "updated": 1621803711854 + }, + { + "style": "Text", + "text": "Mac" + }, + { + "style": "Important", + "text": "Currently unhandled collaborator needed.", + "updated": 1621802848597 }, { "style": "Subtitle", - "text": "Ubuntu", - "updated": 1620053330166 - }, - { - "style": "Json", - "text": "create-shortcut-ubuntu.sh", - "updated": 1620504490683 + "text": "Additional set up needed on Ubuntu", + "updated": 1621802397032 }, { "style": "Text", - "text": "This script places shortcuts within the user's launcher and desktop. Shortcuts are placed in the following locations:", - "updated": 1620504828523 + "text": "Most shortcuts will work out of the box. Ubuntu desktop shortcuts, however, take a few additional steps to set up. The following section will walk you through these steps.", + "updated": 1621802969207 }, { - "style": "List", - "text": "~/Desktop/Superalgos.desktop" - }, - { - "style": "List", - "text": "~/.local/share/applications/Superalgos.desktop" - }, - { - "style": "Note", - "text": "After running create-shortcut-ubuntu.sh the launcher shortcut will work out of the box. There are a few additional steps to set up the desktop shortcut. The following section will walk you through these steps.", - "updated": 1620505700097 - }, - { - "style": "Text", + "style": "Callout", "text": "First, desktop icons need to be enabled within the Tweaks app.", "updated": 1620505123531 }, @@ -157,7 +183,8 @@ }, { "style": "List", - "text": "Under extensions turn on Desktop Icons" + "text": "Under extensions turn on Desktop Icons.", + "updated": 1621803788239 }, { "style": "Gif", @@ -169,7 +196,7 @@ "updated": 1620505754854 }, { - "style": "Text", + "style": "Callout", "text": "Finally, you will need to enable the desktop shortcut.", "updated": 1620505790748 }, @@ -183,49 +210,19 @@ "text": "GIFs/Superalgos/Docs/launch-scripts/allow-launching.gif", "updated": 1620505894840 }, - { - "style": "Subtitle", - "text": "Mac" - }, - { - "style": "Important", - "text": "Collaborator needed." - }, { "style": "Title", "text": "Uninstall Shortcuts", "updated": 1620789208012 }, - { - "style": "Subtitle", - "text": "Windows", - "updated": 1620789368194 - }, { "style": "Text", - "text": "Open a file browser and navigate to the Superalgos directory." - }, - { - "style": "Text", - "text": "Under the folder titled Launch-Scripts double-click the script:", - "updated": 1620789459938 + "text": "There is one unifed script to automatically uninstall shortcuts. To ese it open a command prompt or terminal. Then navigate to your Superalgos directory and type the following command:", + "updated": 1621804036052 }, { "style": "Json", - "text": "uninstall-shortcut-windows.bat", - "updated": 1620789508304 - }, - { - "style": "Subtitle", - "text": "Ubuntu" - }, - { - "style": "Text", - "text": "Open a terminal and run the following command:" - }, - { - "style": "Javascript", - "text": "rm ~/Desktop/Superalgos.desktop && rm ~/.local/share/applications/Superalgos.desktop" + "text": "node uninstall" } ] } \ No newline at end of file From e2ff7ecac653c61c767d6f9034c5815d939aca4d Mon Sep 17 00:00:00 2001 From: B Harrell <55707292+harrellbm@users.noreply.github.com> Date: Sun, 23 May 2021 16:55:51 -0500 Subject: [PATCH 11/12] Update: Readme for Unified Scripts Explanations for automatic shortcut creation, noShortcuts flag and unified Uninstall added. --- README.md | 73 ++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index e7ef08ce4..36a7d11ac 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ It is also required to install the Node Package Manager for dependancy managemen ``` sudo apt install npm ``` -You may also type the following to verify the Node.js and NPM installation and version. +You may also type the following to verify Node.js and NPM installation and version. ``` node -v ``` @@ -134,12 +134,26 @@ node setup Then wait until you are able to type within the terminal again. -This command will install and configure all additional dependencies needed by Superalgos. +This command will install and configure all additional dependencies needed by Superalgos. It will also install desktop and start menu shortcuts. + +**NOTE FOR USERS INSTALLING MULTIPLE INSTANCES OF SUPERALGOS ON THE SAME MACHINE:** In order to avoid name conflicts between shortcuts, make sure to rename your main directory before running `node setup`. Congratulations your installation is complete! > **The Usage section below explains how to run the app.** +
+ +**DEPENDENCY INSTALLATION FOR RASPBERRY PI USERS** + +As noted above, running `node setup` installs GUI shortcuts by default. To suppress this behavior in headless installations, add the `noShortcuts` flag as follows: + +``` +node setup noShortcuts +``` + +
+ ## 4. Installation Notes **A.** You need to make a fork so that you may contribute work. Superalgos is a Community project and you are expected to contribute, like everyone else. You don't need to be a technical person to contribute. Fixing a typo in the docs or translating a paragraph into your native language are valuable contributions too. Superalgos has built-in features that make contributing easy. Help make Superalgos better and Superalgos will better serve you! [Free-riding is not cool](https://en.wikipedia.org/wiki/Free-rider_problem), particularly on free, open-source, Community-driven projects. @@ -162,8 +176,14 @@ Congratulations your installation is complete! ``` node setup ``` +Then wait until you are able to type within the terminal again. + +**NOTE FOR USERS RUNNING IN HEADLESS ENVIRONMENT:** You will need to add the `noShortcuts` flag while running `node setup` to suppress installing GUI shortcuts. To do this type: + +``` +node setup noShortcuts +``` - Then wait until you are able to type within the terminal again. ### Refactorings @@ -198,31 +218,13 @@ then node run minMemo noBrowser ``` -## 2. Add a Desktop/Launcher Shortcut for Superalgos +In addition, you may use any of the automatically installed desktop and start menu shortcuts to launch Superalgos. -There are a number of scripts available to help make lauching Superalgos easier and feel more native. To use these scripts, follow the steps for your operating system. +**NOTE:** Shortcuts are not currently supported on Mac. Collaborators are needed to finish this feature. -## For **Windows** Users +**B.** Enable Desktop Shortcut on Ubuntu -Open a file browser and navigate to the Superalgos Directory. - -Under the folder titled `Launch-Scripts` double-click the script `create-shortcut-windows.bat`. - -After running this script there will be two shortcuts added. One to your start menu and one to your desktop. You can now lauch Superalgos from any of these shortcuts, or search `Superalgos` in the start menu search bar. - -## For **Ubuntu** Users - -Open a terminal and run the following commands: -``` -cd Superalgos/Launch-Scripts -``` -``` -bash create-shortcut-ubuntu.sh -``` - -After running these commands there will be two shortcuts added. One to your launcher and one to your desktop. The launcher shortcut will work out of the box. The desktop shortcut, however, requires a few additional steps to set up. The following section will walk you through these steps. - -**A.** Enable Desktop Shortcut +The majority of shortcuts that are automatically installed will work out of the box. Desktop shortcuts on Ubuntu, however, require a few additional steps to set up. First, desktop icons need to be enabled within the Tweaks app. * Check if Tweaks is installed. @@ -240,7 +242,7 @@ Finally, you will need to enable the desktop shortcut. ![allow-launching](https://user-images.githubusercontent.com/55707292/117553933-fcfc5b80-b019-11eb-872c-4fad81b184d2.gif) -Now both shortcuts will launch Superalgos like any other program on your computer. +Now both launcher and desktop shortcuts will launch Superalgos like any other program on your computer. ## 3. Usage Notes @@ -291,22 +293,15 @@ journalctl -u superalgos -f # Uninstall -Superalgos writes nothing outside of the ```Superalgos``` folder. To completely uninstall the software, just delete the folder. +Superalgos writes nothing outside of the ```Superalgos``` folder other than shortcut files. To uninstall the software, follow these steps: -If you have installed shortcuts for Superalgos you can remove them as follows: - -## For **Windows** Users - -Open a file browser and navigate to the Superalgos directory. - -Under the folder titled `Launch-Scripts` double-click the script `uninstall-shortcut-windows.bat`. - -## For **Ubuntu** Users - -Open a terminal and run the following command: +Open a terminal or command prompt and navigate to your main Superalgos directory and type the following command: ``` -rm ~/Desktop/Superalgos.desktop && rm ~/.local/share/applications/Superalgos.desktop +node uninstall ``` +This will remove any shortcut files that have been installed. + +Then simply delete the `Superalgos` folder. There will be nothing left on your computor. # Welcome Tutorial From df1fb3f0ef5fefa79198dfc0a6f4a10ed83aa6da Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 20:24:06 -0500 Subject: [PATCH 12/12] Fix: clean up code --- Launch-Scripts/create-shortcut.js | 9 +++++---- setup.js | 8 +++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js index 97f443bae..09ec86e99 100644 --- a/Launch-Scripts/create-shortcut.js +++ b/Launch-Scripts/create-shortcut.js @@ -19,16 +19,15 @@ if (os.platform() == "win32") { ] // Place Shortcuts using powershell - let dir; - for (dir in shortcutPaths) { - let command = `$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("${shortcutPaths[dir]}"); $S.TargetPath = "${target}"; $S.IconLocation = "${icon}"; $S.Save()`; + for (let dir of shortcutPaths) { + let command = `$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("${dir}"); $S.TargetPath = "${target}"; $S.IconLocation = "${icon}"; $S.Save()`; exec( command, { shell: "powershell.exe", execArgv: "-ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command" }, - function ( error, stdout ){ + function ( error, stdout){ if (error) { console.log(''); console.log("There was an error installing a shortcut: "); @@ -38,6 +37,8 @@ if (os.platform() == "win32") { } else { console.log(''); console.log("Shortcut added successfully!"); + console.log(''); + console.log(stdout); } }); }; diff --git a/setup.js b/setup.js index 2f7860277..14cdf84e3 100644 --- a/setup.js +++ b/setup.js @@ -37,14 +37,12 @@ console.log(''); console.log(nodeModulesDirs); console.log(''); - -let dir; -for (dir in nodeModulesDirs) { +for (let dir of nodeModulesDirs) { // Loop through directories and run npm ci in a child process shell. - let command = "echo Results of install at "+ nodeModulesDirs[dir] + " & npm ci"; + let command = "echo Results of install at "+ dir + " & npm ci"; exec( command, { - cwd: nodeModulesDirs[dir] + cwd: dir }, function ( error, stdout ){ if (error) {