Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
if: matrix.os == 'macos-latest'
run: |
cd release/build
zip -r mac-unpacked.zip mac
zip -r mac-arm64-unpacked.zip mac-arm64
- name: List Artifacts
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion bundler/configs/webpack.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import webpack from 'webpack';
import webpackPaths from './webpack.paths';
import webpackPaths from './webpack.paths.ts';

const configuration: webpack.Configuration = {
externals: [],
Expand Down
18 changes: 4 additions & 14 deletions bundler/configs/webpack.config.main.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import webpack from 'webpack';
import { merge } from 'webpack-merge';
import TerserPlugin from 'terser-webpack-plugin';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import baseConfig from './webpack.config.base';
import webpackPaths from './webpack.paths';
import checkNodeEnv from '../scripts/check-node-env';
import deleteSourceMaps from '../scripts/delete-source-maps';
import baseConfig from './webpack.config.base.ts';
import webpackPaths from './webpack.paths.ts';
import checkNodeEnv from '../scripts/check-node-env.js';
import deleteSourceMaps from '../scripts/delete-source-maps.js';

checkNodeEnv('production');
deleteSourceMaps();
Expand Down Expand Up @@ -67,16 +67,6 @@ const configuration: webpack.Configuration = {
START_MINIMIZED: false,
}),
],

/**
* Disables webpack processing of __dirname and __filename.
* If you run the bundle in node.js it falls back to these values of node.js.
* https://github.com/webpack/webpack/issues/2010
*/
node: {
__dirname: true,
__filename: true,
},
};

export default merge(baseConfig, configuration);
9 changes: 5 additions & 4 deletions bundler/configs/webpack.paths.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const path = require('path');
import path from 'path';
import { fileURLToPath } from 'url';

const rootPath = path.join(__dirname, '../..');

const dllPath = path.join(__dirname, '../dll');
const dirname = path.dirname(fileURLToPath(import.meta.url));
const rootPath = path.join(dirname, '../..');
const dllPath = path.join(dirname, '../dll');

const srcPath = path.join(rootPath, 'src');
const srcMainPath = path.join(srcPath, 'main');
Expand Down
76 changes: 31 additions & 45 deletions bundler/scripts/beforePack.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
const process = require('process');
const { spawn } = require('node:child_process');
const path = require('node:path');
const fs = require('node:fs');
const unzip = require('extract-zip');
const chalk = require('chalk');
const { execSync } = require('child_process');
const { createSpinner } = require('nanospinner');
const { default: axios } = require('axios');
const { exit } = require('process');

const assetPath = path.join(__dirname, '../..', 'assets');
import process from 'process';
import { spawn } from 'node:child_process';
import path from 'node:path';
import fs from 'node:fs';
import { Readable } from 'node:stream';
import { pipeline } from 'node:stream/promises';
import unzip from 'extract-zip';
import chalk from 'chalk';
import { execSync } from 'child_process';
import { createSpinner } from 'nanospinner';
import { exit } from 'process';
import { fileURLToPath } from 'node:url';

const assetPath = path.join(
path.dirname(fileURLToPath(import.meta.url)),
'../..',
'assets',
);

// YOU CAN EDIT ME
const JULIA_VERSION_PARTS = [1, 10, 10];
Expand Down Expand Up @@ -47,41 +53,21 @@ const downloadJulia = async () => {
const spinner = createSpinner(
`\tDownloading Julia ${JULIA_VERSION} for ${platform}`,
).start();
const writer = fs.createWriteStream(path.join(assetPath, ZIP_NAME));

const response = await axios.get(JULIA_URL, {
responseType: 'stream',
onDownloadProgress: (progressEvent) => {
const percentage = Math.round(
(progressEvent.loaded * 100) / progressEvent.total,
);
spinner
.update({ text: `\tDownloading Julia ${JULIA_VERSION} ${percentage}%` })
.spin();
},
});
const response = await fetch(JULIA_URL);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

response.data.pipe(writer);
const filePath = path.join(assetPath, ZIP_NAME);
const writeStream = fs.createWriteStream(filePath);
const readStream = Readable.fromWeb(response.body);

return new Promise((resolve, reject) => {
if (response.status > 399) {
reject(response.statusText);
}
response.data.on('error', (e) => {
console.log();
reject(e);
});
writer.on('error', (e) => {
console.log();
reject(e);
});
writer.on('finish', (args) => {
spinner.success({
text: `\tDownloaded Julia (for ${platform}) (size: ${(response.data.length / 1024 / 1024).toFixed(2)} MB)`,
mark: '✓',
});
resolve(args);
});
await pipeline(readStream, writeStream);

spinner.success({
text: `\tDownloaded Julia (for ${platform})`,
mark: '✓',
});
};

Expand Down Expand Up @@ -274,7 +260,7 @@ const extractJulia = async () => {
spinner1.success({ text: '\tExtracted!', mark: '✓' });
};

exports.default = async (context) => {
export default async (context) => {
let files = fs.readdirSync(assetPath);

if (!files.includes(JULIA_DIR_NAME)) {
Expand Down
10 changes: 5 additions & 5 deletions bundler/scripts/beforeSign.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ See https://github.com/JuliaPluto/PlutoDesktop/pull/91

*/

const { execSync } = require('child_process');
const path = require('path');
const fs = require('fs');
import { execSync } from 'child_process';
import path from 'path';
import fs from 'fs';

/**
* Ensures all components of the macOS app are signed consistently with ad-hoc signature
* This is necessary when no Developer ID certificate is available
* This runs in the afterPack hook, which executes after packaging but before electron-builder's signing step
*/
exports.default = async function afterPack(context) {
export default async function afterPack(context) {
const { electronPlatformName, appOutDir } = context;

if (electronPlatformName !== 'darwin') {
Expand Down Expand Up @@ -149,4 +149,4 @@ exports.default = async function afterPack(context) {
} catch (error) {
console.warn('Failed to sign app bundle:', error.message);
}
};
}
13 changes: 0 additions & 13 deletions bundler/scripts/build-precompile.jl

This file was deleted.

2 changes: 1 addition & 1 deletion bundler/scripts/check-build-exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import path from 'path';
import chalk from 'chalk';
import fs from 'fs';
import webpackPaths from '../configs/webpack.paths';
import webpackPaths from '../configs/webpack.paths.ts';

const mainPath = path.join(webpackPaths.distMainPath, 'main.js');
const rendererPath = path.join(webpackPaths.distRendererPath, 'renderer.js');
Expand Down
6 changes: 3 additions & 3 deletions bundler/scripts/check-native-dep.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'fs';
import chalk from 'chalk';
import { execSync } from 'child_process';
import { dependencies } from '../../package.json';
import packageJson from '../../package.json' with { type: 'json' };

if (dependencies) {
const dependenciesKeys = Object.keys(dependencies);
if (packageJson.dependencies) {
const dependenciesKeys = Object.keys(packageJson.dependencies);
const nativeDeps = fs
.readdirSync('node_modules')
.filter((folder) => fs.existsSync(`node_modules/${folder}/binding.gyp`));
Expand Down
16 changes: 0 additions & 16 deletions bundler/scripts/check-port-in-use.js

This file was deleted.

2 changes: 1 addition & 1 deletion bundler/scripts/clean.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import process from 'process';
import path from 'node:path';
import fs from 'node:fs';
import webpackPaths from '../configs/webpack.paths';
import webpackPaths from '../configs/webpack.paths.ts';

const args = process.argv.slice(2);
const commandMap = {
Expand Down
46 changes: 0 additions & 46 deletions bundler/scripts/create-tracefile.jl

This file was deleted.

6 changes: 3 additions & 3 deletions bundler/scripts/delete-source-maps.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import rimraf from 'rimraf';
import * as rimraf from 'rimraf';
import fs from 'node:fs';
import webpackPaths from '../configs/webpack.paths';
import webpackPaths from '../configs/webpack.paths.ts';

export default function deleteSourceMaps() {
rimraf.sync(path.join(webpackPaths.distMainPath, '*.js.map'));
rimraf.sync(path.join(webpackPaths.distMainPath, '*.js.map'), { glob: true });
}
10 changes: 5 additions & 5 deletions bundler/scripts/notarize.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { notarize } = require('@electron/notarize');
const { build } = require('../../package.json');
import { notarize } from '@electron/notarize';
import packageJson from '../../package.json' with { type: 'json' };

exports.default = async function notarizeMacos(context) {
export default async function notarizeMacos(context) {
const { electronPlatformName, appOutDir } = context;
if (electronPlatformName !== 'darwin') {
return;
Expand All @@ -22,9 +22,9 @@ exports.default = async function notarizeMacos(context) {
const appName = context.packager.appInfo.productFilename;

await notarize({
appBundleId: build.appId,
appBundleId: packageJson.build.appId,
appPath: `${appOutDir}/${appName}.app`,
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASS,
});
};
}
46 changes: 46 additions & 0 deletions bundler/scripts/run-webpack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*

🤖 This is AI written code I didnt review this. -f

*/

import webpack from 'webpack';
import path from 'path';
import { fileURLToPath, pathToFileURL } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootPath = path.join(__dirname, '../..');

// Get the config path from args
const configIndex = process.argv.indexOf('--config');
let configPath =
configIndex !== -1 ? process.argv[configIndex + 1] : './webpack.config.js';

// Resolve relative paths
if (!path.isAbsolute(configPath)) {
configPath = path.resolve(rootPath, configPath);
}

// Convert to file URL for import
const configUrl = pathToFileURL(configPath).href;

// Dynamically import the config
const configModule = await import(configUrl);
const config = configModule.default;

// Run webpack
const compiler = webpack(config);
compiler.run((err, stats) => {
if (err) {
console.error(err);
process.exit(1);
}

if (stats?.hasErrors()) {
console.error(stats.toString({ colors: true }));
process.exit(1);
}

console.log(stats?.toString({ colors: true }));
process.exit(0);
});
Loading