test: add electron test (#1840)

This commit is contained in:
Himself65
2023-04-24 18:53:36 -05:00
committed by GitHub
parent 9c94d05dd8
commit d3ce90e721
18 changed files with 212 additions and 33 deletions

View File

@@ -1,4 +1,9 @@
const NODE_MAJOR_VERSION = 18;
import { resolve } from 'node:path';
import { fileURLToPath } from 'url';
export const root = fileURLToPath(new URL('..', import.meta.url));
export const NODE_MAJOR_VERSION = 18;
const nativeNodeModulesPlugin = {
name: 'native-node-modules',
@@ -14,7 +19,7 @@ const nativeNodeModulesPlugin = {
const ENV_MACROS = ['AFFINE_GOOGLE_CLIENT_ID', 'AFFINE_GOOGLE_CLIENT_SECRET'];
/** @return {{main: import('esbuild').BuildOptions, preload: import('esbuild').BuildOptions}} */
export default () => {
export const config = () => {
const define = Object.fromEntries(
ENV_MACROS.map(key => [
'process.env.' + key,
@@ -23,8 +28,8 @@ export default () => {
);
return {
main: {
entryPoints: ['layers/main/src/index.ts'],
outdir: 'dist/layers/main',
entryPoints: [resolve(root, './layers/main/src/index.ts')],
outdir: resolve(root, './dist/layers/main'),
bundle: true,
target: `node${NODE_MAJOR_VERSION}`,
platform: 'node',
@@ -33,8 +38,8 @@ export default () => {
define: define,
},
preload: {
entryPoints: ['layers/preload/src/index.ts'],
outdir: 'dist/layers/preload',
entryPoints: [resolve(root, './layers/preload/src/index.ts')],
outdir: resolve(root, './dist/layers/preload'),
bundle: true,
target: `node${NODE_MAJOR_VERSION}`,
platform: 'node',