Skip to content

Commit

Permalink
chore: stale changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Suryansh-23 committed Dec 28, 2024
1 parent eaf7bbc commit 5bf6e8c
Show file tree
Hide file tree
Showing 9 changed files with 284 additions and 211 deletions.
298 changes: 149 additions & 149 deletions .erb/configs/webpack.config.renderer.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,176 +13,176 @@ import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
// When an ESLint server is running, we can't set the NODE_ENV so we'll check if it's
// at the dev webpack config is not accidentally run in a production environment
if (process.env.NODE_ENV === 'production') {
checkNodeEnv('development');
checkNodeEnv('development');
}

const port = process.env.PORT || 1212;
const manifest = path.resolve(webpackPaths.dllPath, 'renderer.json');
const requiredByDLLConfig = module.parent.filename.includes(
'webpack.config.renderer.dev.dll'
'webpack.config.renderer.dev.dll'
);

/**
* Warn if the DLL is not built
*/
if (
!requiredByDLLConfig &&
!(fs.existsSync(webpackPaths.dllPath) && fs.existsSync(manifest))
!requiredByDLLConfig &&
!(fs.existsSync(webpackPaths.dllPath) && fs.existsSync(manifest))
) {
console.log(
chalk.black.bgYellow.bold(
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"'
)
);
execSync('npm run postinstall');
console.log(
chalk.black.bgYellow.bold(
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"'
)
);
execSync('npm run postinstall');
}

const configuration: webpack.Configuration = {
devtool: 'inline-source-map',

mode: 'development',

target: 'electron-renderer',

resolve: {
fallback: {
fs: 'empty',
assert: require.resolve('assert'),
buffer: require.resolve('buffer'),
events: require.resolve('events'),
path: require.resolve('path-browserify'),
punycode: require.resolve('punycode'),
string_decoder: require.resolve('string_decoder'),
sys: require.resolve('util'),
url: require.resolve('url'),
util: require.resolve('util'),
}
},

entry: [
`webpack-dev-server/client?http://localhost:${port}/dist`,
'webpack/hot/only-dev-server',
'core-js',
'regenerator-runtime/runtime',
path.join(webpackPaths.srcRendererPath, 'index.tsx'),
],

output: {
path: webpackPaths.distRendererPath,
publicPath: '/',
filename: 'renderer.dev.js',
},

module: {
rules: [
{
test: /\.s?css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
sourceMap: true,
importLoaders: 1,
devtool: 'inline-source-map',

mode: 'development',

target: 'electron-renderer',

resolve: {
fallback: {
fs: 'empty',
assert: require.resolve('assert'),
buffer: require.resolve('buffer'),
events: require.resolve('events'),
path: require.resolve('path-browserify'),
punycode: require.resolve('punycode'),
string_decoder: require.resolve('string_decoder'),
sys: require.resolve('util'),
url: require.resolve('url'),
util: require.resolve('util'),
},
},

entry: [
`webpack-dev-server/client?http://localhost:${port}/dist`,
'webpack/hot/only-dev-server',
'core-js',
'regenerator-runtime/runtime',
path.join(webpackPaths.srcRendererPath, 'index.tsx'),
],

output: {
path: webpackPaths.distRendererPath,
publicPath: '/',
filename: 'renderer.dev.js',
},

module: {
rules: [
{
test: /\.s?css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
sourceMap: true,
importLoaders: 1,
},
},
'sass-loader',
],
include: /\.module\.s?(c|a)ss$/,
},
{
test: /\.s?css$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
exclude: /\.module\.s?(c|a)ss$/,
},
// Fonts
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
// Images
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
},
'sass-loader',
],
include: /\.module\.s?(c|a)ss$/,
},
{
test: /\.s?css$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
exclude: /\.module\.s?(c|a)ss$/,
},
// Fonts
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
// Images
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
],
},
plugins: [
requiredByDLLConfig
? null
: new webpack.DllReferencePlugin({
context: webpackPaths.dllPath,
manifest: require(manifest),
sourceType: 'var',
},
plugins: [
requiredByDLLConfig
? null
: new webpack.DllReferencePlugin({
context: webpackPaths.dllPath,
manifest: require(manifest),
sourceType: 'var',
}),

new webpack.NoEmitOnErrorsPlugin(),

/**
* Create global constants which can be configured at compile time.
*
* Useful for allowing different behaviour between development builds and
* release builds
*
* NODE_ENV should be production so that modules do not perform certain
* development checks
*
* By default, use 'development' as NODE_ENV. This can be overriden with
* 'staging', for example, by changing the ENV variables in the npm scripts
*/
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
}),

new webpack.NoEmitOnErrorsPlugin(),

/**
* Create global constants which can be configured at compile time.
*
* Useful for allowing different behaviour between development builds and
* release builds
*
* NODE_ENV should be production so that modules do not perform certain
* development checks
*
* By default, use 'development' as NODE_ENV. This can be overriden with
* 'staging', for example, by changing the ENV variables in the npm scripts
*/
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
}),

new webpack.LoaderOptionsPlugin({
debug: true,
}),

new ReactRefreshWebpackPlugin(),

new HtmlWebpackPlugin({
filename: path.join('index.html'),
template: path.join(webpackPaths.srcRendererPath, 'index.ejs'),
minify: {
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
},
isBrowser: false,
env: process.env.NODE_ENV,
isDevelopment: process.env.NODE_ENV !== 'production',
nodeModules: webpackPaths.appNodeModulesPath,
}),
],

node: {
__dirname: false,
__filename: false,
},

devServer: {
port,
compress: true,
hot: true,
headers: { 'Access-Control-Allow-Origin': '*' },
static: {
publicPath: '/',
},
historyApiFallback: {
verbose: true,
new webpack.LoaderOptionsPlugin({
debug: true,
}),

new ReactRefreshWebpackPlugin(),

new HtmlWebpackPlugin({
filename: path.join('index.html'),
template: path.join(webpackPaths.srcRendererPath, 'index.ejs'),
minify: {
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
},
isBrowser: false,
env: process.env.NODE_ENV,
isDevelopment: process.env.NODE_ENV !== 'production',
nodeModules: webpackPaths.appNodeModulesPath,
}),
],

node: {
__dirname: false,
__filename: false,
},
onBeforeSetupMiddleware() {
console.log('Starting Main Process...');
spawn('npm', ['run', 'start:main'], {
shell: true,
env: process.env,
stdio: 'inherit',
})
.on('close', (code) => process.exit(code))
.on('error', (spawnError) => console.error(spawnError));

devServer: {
port,
compress: true,
hot: true,
headers: { 'Access-Control-Allow-Origin': '*' },
static: {
publicPath: '/',
},
historyApiFallback: {
verbose: true,
},
onBeforeSetupMiddleware() {
console.log('Starting Main Process...');
spawn('npm', ['run', 'start:main'], {
shell: true,
env: process.env,
stdio: 'inherit',
})
.on('close', (code) => process.exit(code))
.on('error', (spawnError) => console.error(spawnError));
},
},
},
};

export default merge(baseConfig, configuration);
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ npm-debug.log.*
*.css.d.ts
*.sass.d.ts
*.scss.d.ts


.VSCodeCounter/**
Binary file modified python/main.exe
Binary file not shown.
Binary file added python/tmp.exe
Binary file not shown.
21 changes: 21 additions & 0 deletions src/checksum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import crypto from 'crypto';
import fs from 'fs';

export default function verifyFileChecksum(
filePath: string,
hashURLIndex: number // Use 0 for File-Vault Zip and 1 for python API
): boolean {
const hashURLS = [
'4cb313ea0fc16f9b7fd78e498686ce886579ea21ff9ba4afafc08e2c1c43cf01',
'a735ee27e06dc1424037f32da21dbc8102d92a77d06ec0ef91c28d6e7e0c0371',
];

const fileBuffer = fs.readFileSync(filePath);

const sha256sum = crypto.createHash('sha256');
sha256sum.update(fileBuffer);

const genHash = sha256sum.digest('hex');

return hashURLS[hashURLIndex] === genHash;
}
Loading

0 comments on commit 5bf6e8c

Please sign in to comment.