Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite and tsc #2200

Merged
merged 29 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1c01104
TSC is compiling background.ts
rathboma May 11, 2024
9b7f192
First steps to removing Vue cli
rathboma May 11, 2024
2219fe5
Background process (main) build working, renderer still broken
rathboma May 11, 2024
1e30267
cannot find module schema/compiler
rathboma May 11, 2024
91de74c
Dev mode working, vite still having problems
rathboma May 13, 2024
f49f87e
possible esbuild config, not working right now
rathboma May 14, 2024
9a42c8e
Solved SCSS issues for vue
rathboma May 14, 2024
a6bc089
ESBuild working for renderer and main, but error on load
rathboma May 15, 2024
d1aeb04
Holy shit, it's working
rathboma May 15, 2024
0fea4af
Esbuild is copying font files now too
rathboma May 15, 2024
fd299c2
fixme
rathboma May 15, 2024
fb03371
fixed build
rathboma May 15, 2024
6b2a25d
More graceful reloads for the renderer
rathboma May 16, 2024
a936c72
sigint is better
rathboma May 16, 2024
f169b80
Working tabulator + resolved all icons and images
rathboma May 16, 2024
4f192ec
App protocol for safely loading contents of the asar package only
rathboma May 16, 2024
885ba74
one command to rule them all
rathboma May 16, 2024
8818858
this should unbreak some vue stuff
rathboma May 16, 2024
819aad6
missing menu item
rathboma May 16, 2024
cf54c73
more tweaks
rathboma May 21, 2024
c675a71
loading source maps from node_modules is working
rathboma May 29, 2024
31795db
Merge branch 'master' into vite-and-tsc
not-night-but Jun 12, 2024
bb88bdc
fix
not-night-but Jun 12, 2024
f2e349f
fix build
not-night-but Jun 13, 2024
dcc639e
missing package
not-night-but Jun 13, 2024
5e7591a
Merge branch 'master' into vite-and-tsc
not-night-but Jun 13, 2024
9fa3cb2
genuinely don't know what's going on
not-night-but Jun 13, 2024
2d8399a
a dumb fix
not-night-but Jun 13, 2024
865cd39
Merge branch 'master' into vite-and-tsc
not-night-but Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/sqltools/src/assets/styles/app/_base.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Fonts
$material-icons-font-path: '~material-icons/iconfont/';
$material-icons-font-path: 'material-icons/iconfont/';
$font-family: 'Roboto';
$font-family-mono: 'Source Code Pro';
$base-font-size: 1rem; // ~14px

@import '~material-icons/iconfont/material-icons.scss';
@import 'material-icons/iconfont/material-icons.scss';

*, *:after, *:before {
box-sizing: border-box;
Expand All @@ -19,4 +19,4 @@ $base-font-size: 1rem; // ~14px
body {
font-size: 1rem;
background: $theme-bg;
}
}
2 changes: 1 addition & 1 deletion apps/sqltools/src/assets/styles/themes/dark/variables.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$material-icons-font-path: '~material-icons/iconfont/';
$material-icons-font-path: 'material-icons/iconfont/';

// Theme
// ---------------------------
Expand Down
6 changes: 3 additions & 3 deletions apps/sqltools/src/assets/styles/themes/light/theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "~codemirror/theme/xq-light";
@import "codemirror/theme/xq-light";
@import "./app/vendor/codemirror";


Expand Down Expand Up @@ -177,7 +177,7 @@ select {


.tabulator-row {
&.inserted,
&.inserted,
&.inserted:hover {
background: $row-add;
}
Expand Down Expand Up @@ -266,4 +266,4 @@ select {
// Switch
x-switch {
color: darken($theme-primary, 10%);
}
}
148 changes: 148 additions & 0 deletions apps/studio/electron-builder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@

const fpmOptions = [
"--after-install=build/deb-postinstall"
]

module.exports = {
appId: "io.beekeeperstudio.desktop",
productName: "Beekeeper Studio",
releaseInfo: {
releaseNotesFile: "build/release-notes.md"
},
files: [
'dist/**/*',
'package.json',
'public/icons/**/*',
'!**/node_gyp_bins/*'

],
afterSign: "electron-builder-notarize",
afterPack: "./build/afterPack.js",
extraResources: [
{
from: './extra_resources/demo.db',
to: 'demo.db'
},
{
from: 'build/launcher-script.sh',
to: 'launcher-script.sh'
},
{
from: './vendor',
to: 'vendor'
},
{
from: './public',
to: 'public'
}
],
fileAssociations: [
{
ext: 'db',
name: 'SQLite db file',
mimeType: 'application/vnd.sqlite3',
},
{
ext: 'sqlite3',
name: 'SQLite sqlite3 file',
mimeType: 'application/vnd.sqlite3'
},
{
ext: 'sqlite',
name: 'SQLite sqlite file',
mimeType: 'application/vnd.sqlite3'
}
],
protocols: [
{
name: "Amazon Redshift URL scheme",
schemes: ["redshift"],
role: "Editor"
},
{
name: "CockroachDB URL scheme",
schemes: ["cockroachdb", "cockroach"],
role: "Editor"
},
{
name: "MariaDB URL scheme",
schemes: ["mariadb"],
role: "Editor"
},
{
name: "TiDB URL scheme",
schemes: ["tidb"],
role: "Editor"
},
{
name: "MySQL URL scheme",
schemes: ["mysql"],
role: "Editor"
},
{
name: "PostgreSQL URL scheme",
schemes: ["postgresql", "postgres", "psql"],
role: "Editor"
},
{
name: "SQLite URL scheme",
schemes: ["sqlite"],
role: "Editor"
},
{
name: "SQL Server URL scheme",
schemes: ["sqlserver", "microsoftsqlserver", "mssql"],
role: "Editor"
}
],
mac: {
entitlements: "./build/entitlements.mac.plist",
entitlementsInherit: "./build/entitlements.mac.plist",
icon: './public/icons/mac/bk-icon.icns',
category: "public.app-category.developer-tools",
"hardenedRuntime": true,
publish: ['github']
},
linux: {
icon: './public/icons/png/',
category: "Development",
target: [
'snap',
'deb',
'appImage'
],
desktop: {
'StartupWMClass': 'beekeeper-studio'
},
},
deb: {
publish: [
'github'
],
fpm: fpmOptions,
// when we upgrade Electron we need to check these
depends: ["libgtk-3-0", "libnotify4", "libnss3", "libxss1", "libxtst6", "xdg-utils", "libatspi2.0-0", "libuuid1", "libsecret-1-0", "gnupg"]
},
appImage: {
publish: ['github'],
},
snap: {
publish: [
'github',
'snapStore'
],
environment: {
"ELECTRON_SNAP": "true"
},
plugs: ["default", "ssh-keys", "removable-media", "mount-observe"]
},
win: {
icon: './public/icons/png/512x512.png',
target: ['nsis', 'portable'],
publish: ['github'],
sign: "./build/win/sign.js",
},
portable: {
"artifactName": "${productName}-${version}-portable.exe",
}
}
168 changes: 168 additions & 0 deletions apps/studio/esbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/usr/bin/env node
import esbuild from 'esbuild';
import vuePlugin from 'esbuild-vue'
import {sassPlugin} from 'esbuild-sass-plugin'
import { copy } from 'esbuild-plugin-copy';
import postcss from 'postcss'
import copyAssets from 'postcss-copy-assets';
import { spawn } from 'child_process'
import path from 'path';
const isWatching = process.argv[2] === 'watch';





const externals = ['better-sqlite3', 'sqlite3',
'sequelize', 'reflect-metadata',
'cassandra-driver', 'mysql2', 'ssh2', 'bks-oracledb', 'mysql',
'oracledb', '@electron/remote', "@google-cloud/bigquery",
'pg-query-stream', 'electron'

]

let electron = null

const tabulatorPlugin = {
name: 'tabulator-tables resolver',
setup(build) {
build.onResolve({ filter: /^tabulator-tables$/ }, async (args) => {
const result = await build.resolve('../../node_modules/tabulator-tables/dist/js/tabulator_esm.js', {
kind: 'import-statement',
resolveDir: path.dirname(args.path),
})

if (result.errors.length > 0) {
return { errors: result.errors }
}

return {
path: result.path
}
});
},
}


const electronMainPlugin = {
name: "electron-main-process-restarter",
setup(build) {
if (!isWatching) return
build.onStart(() => console.log("ESBUILD: Building Main 🏗"))
build.onEnd(() => {
console.log("ESBUILD: Built Main ✅")
if (electron) {
process.kill(electron.pid, 'SIGINT')
}
// start electron again
electron = spawn(path.join('../../node_modules/electron/dist/electron'), ['.'], { stdio: 'inherit' })

})
}
}

const electronRendererPlugin = {
name: 'example',
setup(build) {
if (!isWatching) return
build.onStart(() => {
console.log("ESBUILD: Building Renderer 🏗")
})
build.onEnd(async (result) => {
console.log("ESBUILD: Built Renderer ✅")
if (electron) {
process.kill(electron.pid, 'SIGUSR2')
}
})
},
}


const commonArgs = {
platform: 'node',
publicPath: '.',
outdir: 'dist',
bundle: true,
external: [...externals, '*.woff', '*.woff2', '*.ttf', '*.svg', '*.png'],
sourcemap: isWatching,
minify: !isWatching
}

const mainArgs = {
...commonArgs,
entryPoints: ['src/background.ts'],
plugins: [electronMainPlugin,
copy({
resolveFrom: 'cwd',
assets: [
{
from: ['./src/index.html'],
to: './dist/'
},
]
})]
}

const rendererArgs = {
...commonArgs,
entryPoints: ['src/main.ts'],
plugins: [
tabulatorPlugin,
electronRendererPlugin,
vuePlugin(),
copy({
resolveFrom: "cwd",
assets: [{
from: ['../../node_modules/material-icons/**/*.woff*'],
to: ['./dist/material-icons']
},
{
from: './src/assets/logo.svg',
to: 'dist/assets/'
},
{
from: './src/assets/fonts/**/*',
to: 'dist/fonts'
},
{
from: './src/assets/icons/**/*',
to: 'dist/icons'
},
{
from: './src/assets/images/**/*',
to: 'dist/images'
},
{
from: '../../node_modules/typeface-roboto/**/*.woff*',
to: './dist/'
},
{
from: '../../node_modules/xel/**/*.svg',
to: './dist/node_modules/xel'
},
]

}),
sassPlugin({
async transform(source, resolveDir, filePath) {
const { css } = await postcss().use(copyAssets({ base: `dist` })).process(source, { from: filePath, to: `dist/main.css` });
return css;
}
}),

]
}



if(isWatching) {
const main = await esbuild.context(mainArgs)
const renderer = await esbuild.context(rendererArgs)
Promise.all([main.watch(), renderer.watch()])
} else {
Promise.all([
esbuild.build(mainArgs),
esbuild.build(rendererArgs)
])
}
// launch electron
Loading
Loading