From ead82fc3e19605f8ccf80c88178384ade352ecaf Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Wed, 26 Jan 2022 03:27:19 +0100 Subject: [PATCH 1/5] [renderer][main][preload] add the variables for the command to launch before importing to Publisher in the environment variables --- app/main/src/index.js | 5 +++- app/preload/src/index.js | 4 +-- .../src/components/modals/AddPreviewModal.vue | 30 +++++++++---------- app/renderer/src/locales/en.js | 2 +- app/renderer/src/locales/fr.json | 2 +- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/main/src/index.js b/app/main/src/index.js index 59da0d9..dc2c669 100644 --- a/app/main/src/index.js +++ b/app/main/src/index.js @@ -14,6 +14,7 @@ const colors = require('colors') const iconv = require('iconv-lite') const open = require('open') const windowStateKeeper = require('electron-window-state') +const formatUnicorn = require('format-unicorn/safe') var codePage if (process.platform === 'win32') { codePage = require('win-codepage') @@ -164,16 +165,18 @@ const createWindow = async () => { return store.get('main.isDarkTheme') }) - ipcMain.handle('launch-command:post-exports', (event, command) => { + ipcMain.handle('launch-command:post-exports', (event, command, variables) => { if (command === '') { console.log('No command to launch before importing to Kitsu Publisher.') return false } else { + command = formatUnicorn(command, variables) const commandOutput = { output: '', command: command } const commandSpawn = spawn(command, [], { shell: true, encoding: 'buffer', windowsHide: true, + env: { ...process.env, ...variables }, timeout: 60000 // TODO : make the timeout configurable }) console.log( diff --git a/app/preload/src/index.js b/app/preload/src/index.js index d154d35..a7f0a75 100644 --- a/app/preload/src/index.js +++ b/app/preload/src/index.js @@ -41,8 +41,8 @@ const api = { openDialog: (options) => { return ipcRenderer.invoke('open-dialog:show', options) }, - launchCommandBeforeExport: (command) => { - return ipcRenderer.invoke('launch-command:post-exports', command) + launchCommandBeforeExport: (command, variables) => { + return ipcRenderer.invoke('launch-command:post-exports', command, variables) }, toggleDarkTheme: () => { return ipcRenderer.invoke('dark-theme:toggle') diff --git a/app/renderer/src/components/modals/AddPreviewModal.vue b/app/renderer/src/components/modals/AddPreviewModal.vue index 2a180f9..c781ab0 100644 --- a/app/renderer/src/components/modals/AddPreviewModal.vue +++ b/app/renderer/src/components/modals/AddPreviewModal.vue @@ -248,7 +248,6 @@ import files from '@/lib/files' import FileUpload from '@/components/widgets/FileUpload.vue' import Icon from '@/components/widgets/Icon' import DCCClient from '@/lib/dccutils' -import formatUnicorn from 'format-unicorn/safe' import AnsiUp from 'ansi_up' export default { @@ -375,22 +374,21 @@ export default { this.DCCsExportsDirectory ) ).then((data) => { - const command = formatUnicorn(this.PostExportsCommand, { - exportsDirectory: this.DCCsExportsDirectory, - exportFile: data.file, - exportIsAnimation: isAnimation, - exportIsScreenshot: !isAnimation, - DCCName: DCCClient.DCCName, - DCCVersion: DCCClient.DCCVersion, - currentProject: DCCClient.currentProject, - cameraSelected: DCCClient.cameraSelected, - rendererSelected: DCCClient.rendererSelected, - extensionSelected: isAnimation - ? DCCClient.videoExtensionSelected - : DCCClient.imageExtensionSelected - }) window.electron - .launchCommandBeforeExport(command) + .launchCommandBeforeExport(this.PostExportsCommand, { + exportsDirectory: this.DCCsExportsDirectory, + exportFile: data.file, + exportIsAnimation: isAnimation, + exportIsScreenshot: !isAnimation, + DCCName: DCCClient.DCCName, + DCCVersion: DCCClient.DCCVersion, + currentProject: DCCClient.currentProject, + cameraSelected: DCCClient.cameraSelected, + rendererSelected: DCCClient.rendererSelected, + extensionSelected: isAnimation + ? DCCClient.videoExtensionSelected + : DCCClient.imageExtensionSelected + }) .then((success, _) => { if (!success) { this.exportCommandOutput = null diff --git a/app/renderer/src/locales/en.js b/app/renderer/src/locales/en.js index f6d8817..42263e5 100644 --- a/app/renderer/src/locales/en.js +++ b/app/renderer/src/locales/en.js @@ -746,7 +746,7 @@ export default { 'Choose a directory for exports made by the DCCs', post_exports_command: { description: 'Command to launch after the exports made by the DCCs', - info: 'You can insert variables in your command. You just have to put the choosen variable under curly brackets (for example : {exportFile}). They are listed below:', + info: 'You can insert variables in your command. You just have to put the choosen variable under curly brackets (for example : {exportFile}). These variables are also in the environment variables at runtime. They are listed below:', exportsDirectory: 'exportsDirectory (String) : the directory path where the exports are made.', exportFile: diff --git a/app/renderer/src/locales/fr.json b/app/renderer/src/locales/fr.json index 0f7dee9..361ab9f 100644 --- a/app/renderer/src/locales/fr.json +++ b/app/renderer/src/locales/fr.json @@ -632,7 +632,7 @@ "choose_dccs_exports_directory": "Choisissez un dossier pour les exports faits par les DCCs", "post_exports_command": { "description": "Commande à lancer après les exports des DCCs", - "info": "Vous pouvez insérer des variables dans votre commande. Vous avez juste à les mettre entre des accolades (par exemple: {exportFile}). Elles sont listées ci-dessous :", + "info": "Vous pouvez insérer des variables dans votre commande. Vous avez juste à les mettre entre des accolades (par exemple: {exportFile}). Ces variables sont aussi dans les variables d'environnement lors de l'exécution. Elles sont listées ci-dessous :", "exportsDirectory": "exportsDirectory (String) : le chemin vers le dossier où les exports sont stockés.", "exportFile": "exportFile (String): le chemin vers le fichier qui sera exporté.", "exportIsAnimation": "exportIsAnimation (Boolean) : true si l'export est une animation sinon false.", From 672d641eb0ef94044627440a033c157c3904924a Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Wed, 26 Jan 2022 18:14:34 +0100 Subject: [PATCH 2/5] [scripts] for the connectors zip : add a connectors directory in the root of the archive --- README.md | 4 ++-- scripts/zip_connectors.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 773caae..1fbbb70 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ You need to download the connectors-{version}.zip archive in the [releases](http #### Blender (version>2.80) -- You need to go inside the blender directory. +- You need to go inside the connectors/blender directory. - On Windows (with PowerShell): @@ -158,7 +158,7 @@ You need to download the connectors-{version}.zip archive in the [releases](http #### Toon Boom Harmony -- You need to go inside the harmony directory. +- You need to go inside the connectors/harmony directory. - On Windows (with PowerShell): diff --git a/scripts/zip_connectors.js b/scripts/zip_connectors.js index af3eeb5..5d38db7 100644 --- a/scripts/zip_connectors.js +++ b/scripts/zip_connectors.js @@ -21,6 +21,6 @@ archive.on('error', function (err) { archive.pipe(output) -archive.directory('./connectors', false) +archive.directory('./connectors', 'connectors') archive.finalize() From 53ecc0f2b110d3ac3219ffcdf4ee08ff982218ae Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Wed, 26 Jan 2022 19:28:55 +0100 Subject: [PATCH 3/5] [blender] for blender connector requirements don't use github source for pip --- connectors/blender/setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectors/blender/setup.cfg b/connectors/blender/setup.cfg index 117d38a..5a52330 100644 --- a/connectors/blender/setup.cfg +++ b/connectors/blender/setup.cfg @@ -27,7 +27,7 @@ packages = find: install_requires = fastapi uvicorn - dccutils @ git+https://github.com/cgwire/dccutils.git + dccutils==0.1.5 [options.packages.find] include = dccutils_server* From 381561aceb63b8aa032b6cce98a0de148bd3fe5a Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Thu, 27 Jan 2022 02:45:06 +0100 Subject: [PATCH 4/5] [main] stop using win-codepage it's not working in windows that have a language that is not english --- app/main/src/index.js | 19 ++++++++++++------- package.json | 3 +-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/main/src/index.js b/app/main/src/index.js index dc2c669..48be236 100644 --- a/app/main/src/index.js +++ b/app/main/src/index.js @@ -9,16 +9,12 @@ import { } from 'electron' import { join } from 'path' import { URL } from 'url' -import { spawn } from 'child_process' +import { spawn, exec } from 'child_process' const colors = require('colors') const iconv = require('iconv-lite') const open = require('open') const windowStateKeeper = require('electron-window-state') const formatUnicorn = require('format-unicorn/safe') -var codePage -if (process.platform === 'win32') { - codePage = require('win-codepage') -} import { store, config } from './store' config.set('appVersion', app.getVersion()) @@ -156,8 +152,17 @@ const createWindow = async () => { await mainWindow.loadURL(pageUrl) + var codePage = undefined if (process.platform === 'win32') { - codePage = await codePage() + exec('chcp', (err, stdout, stderr) => { + if (stdout) { + try { + codePage = Number(stdout.split(':')[1]) + } catch { + codePage = undefined + } + } + }) } ipcMain.handle('dark-theme:toggle', () => { @@ -185,7 +190,7 @@ const createWindow = async () => { const manageOutputData = (data, isStdout) => { var output - if (process.platform === 'win32') { + if (process.platform === 'win32' && codePage !== undefined) { // get Windows code page output = iconv.decode(data, `cp${codePage}`) } else { diff --git a/package.json b/package.json index 43db004..d6c320d 100644 --- a/package.json +++ b/package.json @@ -53,8 +53,7 @@ "vue3-popper": "1.4.1", "vuex": "4.0.2", "vuex-router-sync": "6.0.0-rc.1", - "wavesurfer.js": "5.2.0", - "win-codepage": "1.0.0" + "wavesurfer.js": "5.2.0" }, "devDependencies": { "@vitejs/plugin-vue": "2.1.0", From cbb60a1b60a24511f1c125a91aa1735130b64dad Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Thu, 27 Jan 2022 03:05:25 +0100 Subject: [PATCH 5/5] 0.4.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d6c320d..dd701ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kitsu-publisher", - "version": "0.4.1", + "version": "0.4.2", "description": "Desktop publisher for Kitsu", "author": "CGWire ", "repository": "https://github.com/cgwire/kitsu-publisher-next",