From 9628d2029cf4c09f624727c46fe065b810f83c6d Mon Sep 17 00:00:00 2001 From: Lino Schmidt Date: Mon, 13 Jun 2022 19:30:49 +0200 Subject: [PATCH] Better default paths --- package-lock.json | 133 +++++++++++++++++++++++++++++++++++++ package.json | 3 + src/components/paths.ts | 3 + src/components/settings.ts | 6 +- 4 files changed, 142 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9d5eef7..4b55636 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,8 @@ "electron-log": "^4.4.7", "electron-squirrel-startup": "^1.0.0", "electron-updater": "^5.0.1", + "is-valid-path": "^0.1.1", + "platform-folders": "^0.6.0", "react": "^18.1.0", "react-dom": "^18.1.0", "xml-formatter": "^2.6.1" @@ -25,6 +27,7 @@ "@babel/preset-typescript": "^7.17.12", "@babel/register": "^7.17.7", "@babel/runtime": "^7.18.3", + "@types/is-valid-path": "^0.1.0", "@types/react": "^18.0.9", "@types/react-dom": "^18.0.5", "@types/webpack": "^5.28.0", @@ -2546,6 +2549,12 @@ "@types/node": "*" } }, + "node_modules/@types/is-valid-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@types/is-valid-path/-/is-valid-path-0.1.0.tgz", + "integrity": "sha512-2ontWtpN8O2nf5S7EjDDJ0DwrRa2t7wmS3Wmo322yWYG6yFBYC1QCaLhz4Iz+mzJy8Kf4zP5yVyEd1ANPDmOFQ==", + "dev": true + }, "node_modules/@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -3657,6 +3666,14 @@ "node": ">=8" } }, + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, "node_modules/bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -6093,6 +6110,11 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, "node_modules/filelist": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", @@ -7188,6 +7210,36 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-invalid-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-invalid-path/-/is-invalid-path-0.1.0.tgz", + "integrity": "sha512-aZMG0T3F34mTg4eTdszcGXx54oiZ4NtHSft3hWNJMGJXUUqdIj3cOZuHcU0nCWWcY3jd7yRe/3AEm3vSNTpBGQ==", + "dependencies": { + "is-glob": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-invalid-path/node_modules/is-extglob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "integrity": "sha512-7Q+VbVafe6x2T+Tu6NcOf6sRklazEPmBoB3IWk3WdGZM2iGUwU/Oe3Wtq5lSEkDTTlpp8yx+5t4pzO/i9Ty1ww==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-invalid-path/node_modules/is-glob": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", + "integrity": "sha512-a1dBeB19NXsf/E0+FHqkagizel/LQw2DjSQpvQrj3zT+jYPpaUCryPnrQajXKFLCMuf4I6FhRpaGtw4lPrG6Eg==", + "dependencies": { + "is-extglob": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-negative-zero": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", @@ -7342,6 +7394,17 @@ "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", "dev": true }, + "node_modules/is-valid-path": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-valid-path/-/is-valid-path-0.1.1.tgz", + "integrity": "sha512-+kwPrVDu9Ms03L90Qaml+79+6DZHqHyRoANI6IsZJ/g8frhnfchDOBCa0RbQ6/kdHt5CS5OeIEyrYznNuVN+8A==", + "dependencies": { + "is-invalid-path": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-weakref": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", @@ -8463,6 +8526,18 @@ "node": ">=8" } }, + "node_modules/platform-folders": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/platform-folders/-/platform-folders-0.6.0.tgz", + "integrity": "sha512-CzaJGN1cbL6kwkge7zM7VbXr/L0Qjkg2Z4IzcprziHHSw8y73oORfB9pMLwjAIhb8JcWUemmWvTXAXvc5hnVlg==", + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.5.0" + }, + "engines": { + "node": "^8.16.0 || >=10" + } + }, "node_modules/plist": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.5.tgz", @@ -12816,6 +12891,12 @@ "@types/node": "*" } }, + "@types/is-valid-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@types/is-valid-path/-/is-valid-path-0.1.0.tgz", + "integrity": "sha512-2ontWtpN8O2nf5S7EjDDJ0DwrRa2t7wmS3Wmo322yWYG6yFBYC1QCaLhz4Iz+mzJy8Kf4zP5yVyEd1ANPDmOFQ==", + "dev": true + }, "@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -13684,6 +13765,14 @@ "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -15560,6 +15649,11 @@ "flat-cache": "^3.0.4" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, "filelist": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", @@ -16351,6 +16445,29 @@ "is-path-inside": "^3.0.2" } }, + "is-invalid-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-invalid-path/-/is-invalid-path-0.1.0.tgz", + "integrity": "sha512-aZMG0T3F34mTg4eTdszcGXx54oiZ4NtHSft3hWNJMGJXUUqdIj3cOZuHcU0nCWWcY3jd7yRe/3AEm3vSNTpBGQ==", + "requires": { + "is-glob": "^2.0.0" + }, + "dependencies": { + "is-extglob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "integrity": "sha512-7Q+VbVafe6x2T+Tu6NcOf6sRklazEPmBoB3IWk3WdGZM2iGUwU/Oe3Wtq5lSEkDTTlpp8yx+5t4pzO/i9Ty1ww==" + }, + "is-glob": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", + "integrity": "sha512-a1dBeB19NXsf/E0+FHqkagizel/LQw2DjSQpvQrj3zT+jYPpaUCryPnrQajXKFLCMuf4I6FhRpaGtw4lPrG6Eg==", + "requires": { + "is-extglob": "^1.0.0" + } + } + } + }, "is-negative-zero": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", @@ -16448,6 +16565,14 @@ "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", "dev": true }, + "is-valid-path": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-valid-path/-/is-valid-path-0.1.1.tgz", + "integrity": "sha512-+kwPrVDu9Ms03L90Qaml+79+6DZHqHyRoANI6IsZJ/g8frhnfchDOBCa0RbQ6/kdHt5CS5OeIEyrYznNuVN+8A==", + "requires": { + "is-invalid-path": "^0.1.0" + } + }, "is-weakref": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", @@ -17289,6 +17414,14 @@ } } }, + "platform-folders": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/platform-folders/-/platform-folders-0.6.0.tgz", + "integrity": "sha512-CzaJGN1cbL6kwkge7zM7VbXr/L0Qjkg2Z4IzcprziHHSw8y73oORfB9pMLwjAIhb8JcWUemmWvTXAXvc5hnVlg==", + "requires": { + "bindings": "^1.5.0" + } + }, "plist": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.5.tgz", diff --git a/package.json b/package.json index 8735941..6c2250f 100644 --- a/package.json +++ b/package.json @@ -101,6 +101,8 @@ "electron-log": "^4.4.7", "electron-squirrel-startup": "^1.0.0", "electron-updater": "^5.0.1", + "is-valid-path": "^0.1.1", + "platform-folders": "^0.6.0", "react": "^18.1.0", "react-dom": "^18.1.0", "xml-formatter": "^2.6.1" @@ -113,6 +115,7 @@ "@babel/preset-typescript": "^7.17.12", "@babel/register": "^7.17.7", "@babel/runtime": "^7.18.3", + "@types/is-valid-path": "^0.1.0", "@types/react": "^18.0.9", "@types/react-dom": "^18.0.5", "@types/webpack": "^5.28.0", diff --git a/src/components/paths.ts b/src/components/paths.ts index 76cf223..2de121c 100644 --- a/src/components/paths.ts +++ b/src/components/paths.ts @@ -1,9 +1,12 @@ import path from 'path'; import {app} from '@electron/remote'; +import getPath from 'platform-folders'; export const dataPath = app.getPath('userData'); export const SettingPath = path.join(dataPath, "settings.xml"); +export const defaultOutputPath = path.join(getPath('videos') || "", "StickExporterTX"); + export const blenderPath = path.join("assets", "blender", "blender"); export const templatePath = path.join("assets", "template.blend"); export const blenderScriptPath = path.join("assets", "blenderScript.py"); \ No newline at end of file diff --git a/src/components/settings.ts b/src/components/settings.ts index 3719788..1f316e8 100644 --- a/src/components/settings.ts +++ b/src/components/settings.ts @@ -1,5 +1,5 @@ import formatXML from "xml-formatter"; -import {SettingPath} from './paths'; +import {SettingPath, defaultOutputPath} from './paths'; import fs from "fs"; import logger from "./logger"; @@ -12,8 +12,8 @@ const defaultSettings = { width: 540, stickDistance: 5, stickMode2: true, - log: '"None"', - output: "None" + log: '', + output: defaultOutputPath } let loadedSuccessfully = true;