diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 00000000..39e1aa91 --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,117 @@ +{ + "projectName": "Antares", + "projectOwner": "Fabio286", + "repoType": "github", + "repoHost": "https://github.com", + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": false, + "commitConvention": "angular", + "contributors": [ + { + "login": "Fabio286", + "name": "Fabio Di Stasio", + "avatar_url": "https://avatars.githubusercontent.com/u/31471771?v=4", + "profile": "https://fabiodistasio.it/", + "contributions": [ + "code", + "translation", + "doc" + ] + }, + { + "login": "toriphes", + "name": "Giulio Ganci", + "avatar_url": "https://avatars.githubusercontent.com/u/4192159?v=4", + "profile": "https://www.linkedin.com/in/giulioganci/", + "contributions": [ + "code" + ] + }, + { + "login": "digitalgopnik", + "name": "Christian Ratz", + "avatar_url": "https://avatars.githubusercontent.com/u/2630316?v=4", + "profile": "https://christianratz.de/", + "contributions": [ + "code", + "translation" + ] + }, + { + "login": "reverb6821", + "name": "Giuseppe Gigliotti", + "avatar_url": "https://avatars.githubusercontent.com/u/55198803?v=4", + "profile": "https://reverb6821.github.io/", + "contributions": [ + "translation" + ] + }, + { + "login": "Mohd-PH", + "name": "Mohd-PH", + "avatar_url": "https://avatars.githubusercontent.com/u/9362157?v=4", + "profile": "https://github.com/Mohd-PH", + "contributions": [ + "translation" + ] + }, + { + "login": "hongkfui", + "name": "hongkfui", + "avatar_url": "https://avatars.githubusercontent.com/u/37477191?v=4", + "profile": "https://github.com/hongkfui", + "contributions": [ + "translation" + ] + }, + { + "login": "MrAnyx", + "name": "Robin", + "avatar_url": "https://avatars.githubusercontent.com/u/44176707?v=4", + "profile": "https://github.com/MrAnyx", + "contributions": [ + "translation" + ] + }, + { + "login": "daeleduardo", + "name": "Daniel Eduardo", + "avatar_url": "https://avatars.githubusercontent.com/u/8599078?v=4", + "profile": "https://github.com/daeleduardo", + "contributions": [ + "translation" + ] + }, + { + "login": "datlechin", + "name": "Ngô Quốc Đạt", + "avatar_url": "https://avatars.githubusercontent.com/u/56961917?v=4", + "profile": "https://ngoquocdat.com/", + "contributions": [ + "translation" + ] + }, + { + "login": "IsamuSugi", + "name": "Isamu Sugiura", + "avatar_url": "https://avatars.githubusercontent.com/u/7746658?v=4", + "profile": "https://github.com/IsamuSugi", + "contributions": [ + "translation" + ] + }, + { + "login": "Occhioverde", + "name": "Riccardo Sacchetto", + "avatar_url": "https://avatars.githubusercontent.com/u/18429412?v=4", + "profile": "http://rsacchetto.nexxontech.it/", + "contributions": [ + "platform" + ] + } + ], + "contributorsPerLine": 7 +} diff --git a/.eslintrc b/.eslintrc index 53e07d3c..5c86654c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -46,6 +46,7 @@ "no-undef": "off", "vue/no-side-effects-in-computed-properties": "off", "vue/require-default-prop": "off", + "vue/comment-directive": "off", "vue/no-v-html": "off", "vue/html-indent": [ "error", diff --git a/.gitignore b/.gitignore index dcff5022..60bac061 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,8 @@ .DS_Store -dist/ -node_modules/ +dist +build +node_modules thumbs.db -.idea/ -.vscode NOTES.md *.txt package-lock.json \ No newline at end of file diff --git a/.nvmrc b/.nvmrc index e24183e5..ff650592 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v14.18.1 +v16.13.0 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..a6027bca --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "cwd": "${workspaceFolder}", + "name": "Electron: Main", + "port": 9222, + "protocol": "inspector", + "request": "attach", + "sourceMaps": true, + "type": "node", + "timeout": 1000000 + }, + { + "name": "Electron: Renderer", + "port": 9223, + "request": "attach", + "sourceMaps": true, + "type": "chrome", + "webRoot": "${workspaceFolder}" + } + ], + "compounds": [ + { + "name": "Electron: All", + "configurations": ["Electron: Main", "Electron: Renderer"] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..5b0c8130 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "conventionalCommits.scopes": [ + "UI", + "core", + "MySQL", + "PostgreSQL" + ], + "svg.preview.background": "transparent" +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 05e1ee49..7fd4e9d4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,8 +57,8 @@ The command to build Antares SQL locally is `npm run build:local`. - **PascalCase** for file names (with .vue extension) and including components inside others (``). - "**Base**" prefix for [base component names](https://vuejs.org/v2/style-guide/#Base-component-names-strongly-recommended). -- "**The**" prefix for [single-instance component names](https://vuejs.org/v2/style-guide/#Single-instance-component-names-strongly-recommended). -- [Tightly coupled component names ](https://vuejs.org/v2/style-guide/#Tightly-coupled-component-names-strongly-recommended). +- "**The**" prefix for [single-instance component names](https://vuejs.org/v2/style-guide/#Single-instance-component-names-strongly-recommended). +- [Tightly coupled component names](https://vuejs.org/v2/style-guide/#Tightly-coupled-component-names-strongly-recommended). - [Order of words in component names](https://vuejs.org/v2/style-guide/#Order-of-words-in-component-names-strongly-recommended). - **kebab-case** in templates for property and event names. @@ -74,15 +74,21 @@ The project includes [ESlint](https://eslint.org/) and [StyleLint](https://style Alternatively you can launch following commands to lint the project. Check if all the style rules have been followed: + ```console npm run lint ``` Apply style rules globally if possible: + ```console npm run lint:fix ``` +### Other recommendations + +Please, use if possible **template literals** to compose strings and **avoid unnecessary dependencies**. + ### Commits The commit style adopted for this project is [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). @@ -91,30 +97,11 @@ For Visual Studio Code users may be useful [Conventional Commits](https://market ## Debug -**Dev mode**: +**Debug mode**: ```console -npm run dev +npm run debug ``` -**Visual Studio Code:** - -``` json -{ - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Launch Electron in debugger", - "autoAttachChildProcesses": true, - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-webpack", - "runtimeArgs": [ - "dev" - ], - "env": {}, - "console": "integratedTerminal", - } - ] -} -``` +After running the debug mode Antares will listen on port 9222 (main process) for a debugger. +On **Visual Studio Code** just launch "*Electron: Main*" configurations after running Antares in debug mode. diff --git a/README.md b/README.md index 57406600..af1fe470 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ + +

+ # Antares SQL Client @@ -104,13 +107,34 @@ This is a roadmap with major features will come in near future. - 📖 [Contributors Guide](https://github.com/Fabio286/antares/wiki/Contributors-Guide) - 🚧 [Project Board](https://github.com/users/Fabio286/projects/1) -## Translations +## Contributors ✨ -**Italian** / [Giuseppe Gigliotti](https://github.com/ReverbOD) [[#20](https://github.com/Fabio286/antares/pull/20)] -**Arabic** (needs updates) / [Mohd-PH](https://github.com/Mohd-PH) [[#29](https://github.com/Fabio286/antares/pull/29)] -**Spanish** (needs updates) / [hongkfui](https://github.com/hongkfui) [[#32](https://github.com/Fabio286/antares/pull/32)] -**French** (needs updates) / [MrAnyx](https://github.com/MrAnyx) [[#44](https://github.com/Fabio286/antares/pull/44)] -**Portugues (Brasil)** / [Daniel Eduardo](https://github.com/daeleduardo) [[#54](https://github.com/Fabio286/antares/pull/54)] -**Deutsch (Deutschland)** / [Christian Ratz](https://github.com/digitalgopnik) [[#74](https://github.com/Fabio286/antares/pull/74)] -**Vietnamese** / [Ngô Quốc Đạt](https://github.com/datlechin) [[#111](https://github.com/Fabio286/antares/pull/111)] -**Japanese** / [Isamu Sugiura](https://github.com/IsamuSugi) [[#115](https://github.com/Fabio286/antares/pull/115)] +Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + + + + + + + + + + + + + +

Fabio Di Stasio

💻 🌍 📖

Giulio Ganci

💻

Christian Ratz

💻 🌍

Giuseppe Gigliotti

🌍

Mohd-PH

🌍

hongkfui

🌍

Robin

🌍

Daniel Eduardo

🌍

Ngô Quốc Đạt

🌍

Isamu Sugiura

🌍

Riccardo Sacchetto

📦
+ + + + + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! diff --git a/build/appx/LargeTile.png b/assets/appx/LargeTile.png similarity index 100% rename from build/appx/LargeTile.png rename to assets/appx/LargeTile.png diff --git a/build/appx/SmallTile.png b/assets/appx/SmallTile.png similarity index 100% rename from build/appx/SmallTile.png rename to assets/appx/SmallTile.png diff --git a/build/appx/Square150x150Logo.png b/assets/appx/Square150x150Logo.png similarity index 100% rename from build/appx/Square150x150Logo.png rename to assets/appx/Square150x150Logo.png diff --git a/build/appx/Square44x44Logo.png b/assets/appx/Square44x44Logo.png similarity index 100% rename from build/appx/Square44x44Logo.png rename to assets/appx/Square44x44Logo.png diff --git a/build/appx/StoreLogo.png b/assets/appx/StoreLogo.png similarity index 100% rename from build/appx/StoreLogo.png rename to assets/appx/StoreLogo.png diff --git a/build/appx/Wide310x150Logo.png b/assets/appx/Wide310x150Logo.png similarity index 100% rename from build/appx/Wide310x150Logo.png rename to assets/appx/Wide310x150Logo.png diff --git a/build/icon.icns b/assets/icon.icns similarity index 100% rename from build/icon.icns rename to assets/icon.icns diff --git a/build/icon.ico b/assets/icon.ico similarity index 100% rename from build/icon.ico rename to assets/icon.ico diff --git a/jsconfig.json b/jsconfig.json deleted file mode 100644 index 8c849748..00000000 --- a/jsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "include": [ - "./src/renderer/**/*" - ] - } \ No newline at end of file diff --git a/package.json b/package.json index cb07f243..08617900 100644 --- a/package.json +++ b/package.json @@ -6,22 +6,40 @@ "license": "MIT", "repository": "https://github.com/Fabio286/antares.git", "scripts": { - "dev": "cross-env NODE_ENV=development electron-webpack dev", - "compile": "electron-webpack", + "debug": "npm run rebuild:electron && npm run debug-runner", + "debug-runner": "node scripts/devRunner.js --remote-debug", + "compile": "npm run compile:main && npm run compile:renderer", + "compile:main": "webpack --mode=production --config webpack.main.config.js", + "compile:renderer": "webpack --mode=production --config webpack.renderer.config.js", "build": "cross-env NODE_ENV=production npm run compile", "build:local": "npm run build && electron-builder", "build:appx": "npm run build:local -- --win appx", + "rebuild:electron": "npm run postinstall && electron-rebuild", "release": "standard-version", "release:pre": "npm run release -- --prerelease alpha", + "postinstall": "electron-builder install-app-deps", "test": "npm run lint", "lint": "eslint . --ext .js,.vue && stylelint \"./src/**/*.{css,scss,sass,vue}\"", "lint:fix": "eslint . --ext .js,.vue --fix && stylelint \"./src/**/*.{css,scss,sass,vue}\" --fix", - "postinstall": "electron-builder install-app-deps" + "contributors:add": "all-contributors add", + "contributors:generate": "all-contributors generate" }, "author": "Fabio Di Stasio ", + "main": "./dist/main.js", "build": { "appId": "com.fabio286.antares", "artifactName": "${productName}-${version}-${os}_${arch}.${ext}", + "asar": true, + "directories": { + "output": "build", + "buildResources": "assets" + }, + "asarUnpack": "**\\*.{node,dll}", + "files": [ + "dist/**/*", + "node_modules", + "package.json" + ], "win": { "target": [ "nsis", @@ -81,11 +99,6 @@ ] } }, - "electronWebpack": { - "renderer": { - "webpackConfig": "webpack.config.js" - } - }, "dependencies": { "@electron/remote": "^2.0.1", "@mdi/font": "^6.1.95", @@ -110,28 +123,41 @@ }, "devDependencies": { "@babel/eslint-parser": "^7.15.7", + "@babel/preset-env": "^7.15.8", + "all-contributors-cli": "^6.20.0", "babel-loader": "^8.2.3", + "chalk": "^4.1.2", + "clean-webpack-plugin": "^4.0.0", "cross-env": "^7.0.2", + "css-loader": "^6.5.0", "electron": "^15.3.0", "electron-builder": "^22.13.1", "electron-devtools-installer": "^3.2.0", - "electron-webpack": "^2.8.2", - "electron-webpack-vue": "^2.4.0", + "electron-rebuild": "^3.2.3", "eslint": "^7.32.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.24.2", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.1.0", "eslint-plugin-vue": "^7.18.0", + "file-loader": "^6.2.0", + "html-webpack-plugin": "^5.5.0", + "mini-css-extract-plugin": "^2.4.3", + "node-loader": "^2.0.0", + "progress-webpack-plugin": "^1.0.12", "sass": "^1.42.1", "sass-loader": "^10.2.0", "standard-version": "^9.3.1", + "style-loader": "^3.3.1", "stylelint": "^13.13.1", "stylelint-config-standard": "^22.0.0", "stylelint-scss": "^3.21.0", + "tree-kill": "^1.2.2", "vue": "^2.6.14", "vue-loader": "^15.9.8", "vue-template-compiler": "^2.6.14", - "webpack": "^4.46.0" + "webpack": "^5.60.0", + "webpack-cli": "^4.9.1", + "webpack-dev-server": "^3.11.2" } -} +} \ No newline at end of file diff --git a/scripts/devRunner.js b/scripts/devRunner.js new file mode 100644 index 00000000..bfbea89d --- /dev/null +++ b/scripts/devRunner.js @@ -0,0 +1,130 @@ +process.env.NODE_ENV = 'development'; +// process.env.ELECTRON_ENABLE_LOGGING = true + +const chalk = require('chalk'); +const electron = require('electron'); +const webpack = require('webpack'); +const WebpackDevServer = require('webpack-dev-server'); +const kill = require('tree-kill'); + +const path = require('path'); +const { spawn } = require('child_process'); + +const mainConfig = require('../webpack.main.config'); +const rendererConfig = require('../webpack.renderer.config'); +// const workersConfig = require('../webpack.workers.config'); + +let electronProcess = null; +let manualRestart = null; +const remoteDebugging = process.argv.includes('--remote-debug'); + +if (remoteDebugging) { + // disable dvtools open in electron + process.env.RENDERER_REMOTE_DEBUGGING = true; +} + +async function killElectron (pid) { + return new Promise((resolve, reject) => { + if (pid) { + kill(pid, 'SIGKILL', err => { + if (err) reject(err); + + resolve(); + }); + } + else + resolve(); + }); +} + +async function restartElectron () { + console.log(chalk.gray('\nStarting electron...')); + + const { pid } = electronProcess || {}; + await killElectron(pid); + + electronProcess = spawn(electron, [ + path.join(__dirname, '../dist/main.js'), + // '--enable-logging', // Enable to show logs from all electron processes + remoteDebugging ? '--inspect=9222' : '', + remoteDebugging ? '--remote-debugging-port=9223' : '' + ]); + + electronProcess.stdout.on('data', data => { + console.log(chalk.white(data.toString())); + }); + + electronProcess.stderr.on('data', data => { + console.error(chalk.red(data.toString())); + }); + + electronProcess.on('exit', (code, signal) => { + if (!manualRestart) process.exit(0); + }); +} + +function startMain () { + const webpackSetup = webpack(mainConfig); + + webpackSetup.compilers.forEach((compiler) => { + const { name } = compiler; + + switch (name) { + case 'workers': + compiler.hooks.afterEmit.tap('afterEmit', async () => { + console.log(chalk.gray(`\nCompiled ${name} script!`)); + console.log( + chalk.gray(`\nWatching file changes for ${name} script...`) + ); + }); + break; + case 'main': + default: + compiler.hooks.afterEmit.tap('afterEmit', async () => { + console.log(chalk.gray(`\nCompiled ${name} script!`)); + + manualRestart = true; + await restartElectron(); + + setTimeout(() => { + manualRestart = false; + }, 2500); + + console.log( + chalk.gray(`\nWatching file changes for ${name} script...`) + ); + }); + break; + } + }); + + webpackSetup.watch({ aggregateTimeout: 500 }, err => { + if (err) console.error(chalk.red(err)); + }); +} + +function startRenderer (callback) { + const compiler = webpack(rendererConfig); + const { name } = compiler; + + compiler.hooks.afterEmit.tap('afterEmit', () => { + console.log(chalk.gray(`\nCompiled ${name} script!`)); + console.log(chalk.gray(`\nWatching file changes for ${name} script...`)); + }); + + const server = new WebpackDevServer(compiler, { + contentBase: path.join(__dirname, '../'), + hot: true, + noInfo: true, + overlay: true, + clientLogLevel: 'warning' + }); + + server.listen(9080, '', err => { + if (err) console.error(chalk.red(err)); + + callback(); + }); +} + +startRenderer(startMain); diff --git a/src/main/index.js b/src/main/main.js similarity index 67% rename from src/main/index.js rename to src/main/main.js index cb86a662..570f5b54 100644 --- a/src/main/index.js +++ b/src/main/main.js @@ -44,17 +44,26 @@ async function createMainWindow () { remoteMain.enable(window.webContents); try { - if (isDevelopment) { // - await window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`); + if (isDevelopment) { + const { default: installExtension, VUEJS3_DEVTOOLS } = require('electron-devtools-installer'); + const options = { + loadExtensionOptions: { allowFileAccess: true } + }; - // const { default: installExtension, VUEJS3_DEVTOOLS } = require('electron-devtools-installer'); + try { + const name = await installExtension(VUEJS3_DEVTOOLS, options); + console.log(`Added Extension: ${name}`); + } + catch (err) { + console.log('An error occurred: ', err); + } - // const oldDevToolsID = session.defaultSession.getAllExtensions().find(ext => ext.name === 'Vue.js devtools').id; - // session.defaultSession.removeExtension(oldDevToolsID); - // const toolName = await installExtension(VUEJS3_DEVTOOLS); - // console.log(toolName, 'installed'); + await window.loadURL('http://localhost:9080'); + } + else { + const indexPath = path.resolve(__dirname, 'index.html'); + await window.loadFile(indexPath); } - else await window.loadURL(new URL(`file:///${path.join(__dirname, 'index.html')}`).href); } catch (err) { console.log(err); @@ -89,10 +98,8 @@ else { app.on('activate', async () => { // on macOS it is common to re-create a window even after all windows have been closed - if (mainWindow === null) { + if (mainWindow === null) mainWindow = await createMainWindow(); - if (isDevelopment) mainWindow.webContents.openDevTools(); - } }); // create main BrowserWindow when electron is ready @@ -100,7 +107,8 @@ else { mainWindow = await createMainWindow(); createAppMenu(); - if (isDevelopment) mainWindow.webContents.openDevTools(); + if (isDevelopment) + mainWindow.webContents.openDevTools(); process.on('uncaughtException', (error) => { mainWindow.webContents.send('unhandled-exception', error); @@ -118,7 +126,25 @@ function createAppMenu () { if (isMacOS) { menu = Menu.buildFromTemplate([ { - role: 'appMenu' + label: app.name, + submenu: [ + { role: 'about' }, + { type: 'separator' }, + { + label: 'Check for Updates...', + click: (_menuItem, win) => win.webContents.send('open-updates-preferences') + }, + { + label: 'Preferences', + click: (_menuItem, win) => win.webContents.send('toggle-preferences'), + accelerator: 'CmdOrCtrl+,' + }, + { type: 'separator' }, + { role: 'hide' }, + { role: 'hideOthers' }, + { type: 'separator' }, + { role: 'quit' } + ] }, { role: 'editMenu' diff --git a/src/renderer/components/ModalSettings.vue b/src/renderer/components/ModalSettings.vue index 637e66af..7ea9feac 100644 --- a/src/renderer/components/ModalSettings.vue +++ b/src/renderer/components/ModalSettings.vue @@ -184,7 +184,7 @@ :class="{'selected': applicationTheme === 'dark'}" @click="changeApplicationTheme('dark')" > - +
@@ -197,7 +197,7 @@ :class="{'selected': applicationTheme === 'light'}" @click="changeApplicationTheme('light')" > - +
@@ -280,7 +280,7 @@
- +

{{ appName }}

{{ $t('word.version') }} {{ appVersion }}
diff --git a/src/renderer/components/TheTitleBar.vue b/src/renderer/components/TheTitleBar.vue index f82d6d5d..8480a0ed 100644 --- a/src/renderer/components/TheTitleBar.vue +++ b/src/renderer/components/TheTitleBar.vue @@ -1,11 +1,11 @@