Skip to content

Commit c3bafb4

Browse files
author
Boshra Ariguib
committed
Merge branch 'main' of github.com:JuliaPluto/PlutoDesktop
2 parents bcbe5f4 + f39668d commit c3bafb4

26 files changed

+897
-753
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
if: matrix.os == 'macos-latest'
4646
run: |
4747
cd release/build
48-
zip -r mac-unpacked.zip mac
48+
zip -r mac-arm64-unpacked.zip mac-arm64
4949
5050
- name: List Artifacts
5151
shell: bash

bundler/configs/webpack.config.base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import webpack from 'webpack';
6-
import webpackPaths from './webpack.paths';
6+
import webpackPaths from './webpack.paths.ts';
77

88
const configuration: webpack.Configuration = {
99
externals: [],

bundler/configs/webpack.config.main.prod.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import webpack from 'webpack';
77
import { merge } from 'webpack-merge';
88
import TerserPlugin from 'terser-webpack-plugin';
99
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
10-
import baseConfig from './webpack.config.base';
11-
import webpackPaths from './webpack.paths';
12-
import checkNodeEnv from '../scripts/check-node-env';
13-
import deleteSourceMaps from '../scripts/delete-source-maps';
10+
import baseConfig from './webpack.config.base.ts';
11+
import webpackPaths from './webpack.paths.ts';
12+
import checkNodeEnv from '../scripts/check-node-env.js';
13+
import deleteSourceMaps from '../scripts/delete-source-maps.js';
1414

1515
checkNodeEnv('production');
1616
deleteSourceMaps();
@@ -67,16 +67,6 @@ const configuration: webpack.Configuration = {
6767
START_MINIMIZED: false,
6868
}),
6969
],
70-
71-
/**
72-
* Disables webpack processing of __dirname and __filename.
73-
* If you run the bundle in node.js it falls back to these values of node.js.
74-
* https://github.com/webpack/webpack/issues/2010
75-
*/
76-
node: {
77-
__dirname: true,
78-
__filename: true,
79-
},
8070
};
8171

8272
export default merge(baseConfig, configuration);

bundler/configs/webpack.paths.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const path = require('path');
1+
import path from 'path';
2+
import { fileURLToPath } from 'url';
23

3-
const rootPath = path.join(__dirname, '../..');
4-
5-
const dllPath = path.join(__dirname, '../dll');
4+
const dirname = path.dirname(fileURLToPath(import.meta.url));
5+
const rootPath = path.join(dirname, '../..');
6+
const dllPath = path.join(dirname, '../dll');
67

78
const srcPath = path.join(rootPath, 'src');
89
const srcMainPath = path.join(srcPath, 'main');

bundler/scripts/beforePack.js

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
const process = require('process');
2-
const { spawn } = require('node:child_process');
3-
const path = require('node:path');
4-
const fs = require('node:fs');
5-
const unzip = require('extract-zip');
6-
const chalk = require('chalk');
7-
const { execSync } = require('child_process');
8-
const { createSpinner } = require('nanospinner');
9-
const { default: axios } = require('axios');
10-
const { exit } = require('process');
11-
12-
const assetPath = path.join(__dirname, '../..', 'assets');
1+
import process from 'process';
2+
import { spawn } from 'node:child_process';
3+
import path from 'node:path';
4+
import fs from 'node:fs';
5+
import { Readable } from 'node:stream';
6+
import { pipeline } from 'node:stream/promises';
7+
import unzip from 'extract-zip';
8+
import chalk from 'chalk';
9+
import { execSync } from 'child_process';
10+
import { createSpinner } from 'nanospinner';
11+
import { exit } from 'process';
12+
import { fileURLToPath } from 'node:url';
13+
14+
const assetPath = path.join(
15+
path.dirname(fileURLToPath(import.meta.url)),
16+
'../..',
17+
'assets',
18+
);
1319

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

52-
const response = await axios.get(JULIA_URL, {
53-
responseType: 'stream',
54-
onDownloadProgress: (progressEvent) => {
55-
const percentage = Math.round(
56-
(progressEvent.loaded * 100) / progressEvent.total,
57-
);
58-
spinner
59-
.update({ text: `\tDownloading Julia ${JULIA_VERSION} ${percentage}%` })
60-
.spin();
61-
},
62-
});
57+
const response = await fetch(JULIA_URL);
58+
if (!response.ok) {
59+
throw new Error(`HTTP error! status: ${response.status}`);
60+
}
6361

64-
response.data.pipe(writer);
62+
const filePath = path.join(assetPath, ZIP_NAME);
63+
const writeStream = fs.createWriteStream(filePath);
64+
const readStream = Readable.fromWeb(response.body);
6565

66-
return new Promise((resolve, reject) => {
67-
if (response.status > 399) {
68-
reject(response.statusText);
69-
}
70-
response.data.on('error', (e) => {
71-
console.log();
72-
reject(e);
73-
});
74-
writer.on('error', (e) => {
75-
console.log();
76-
reject(e);
77-
});
78-
writer.on('finish', (args) => {
79-
spinner.success({
80-
text: `\tDownloaded Julia (for ${platform}) (size: ${(response.data.length / 1024 / 1024).toFixed(2)} MB)`,
81-
mark: '✓',
82-
});
83-
resolve(args);
84-
});
66+
await pipeline(readStream, writeStream);
67+
68+
spinner.success({
69+
text: `\tDownloaded Julia (for ${platform})`,
70+
mark: '✓',
8571
});
8672
};
8773

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

277-
exports.default = async (context) => {
263+
export default async (context) => {
278264
let files = fs.readdirSync(assetPath);
279265

280266
if (!files.includes(JULIA_DIR_NAME)) {

bundler/scripts/beforeSign.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ See https://github.com/JuliaPluto/PlutoDesktop/pull/91
1414
1515
*/
1616

17-
const { execSync } = require('child_process');
18-
const path = require('path');
19-
const fs = require('fs');
17+
import { execSync } from 'child_process';
18+
import path from 'path';
19+
import fs from 'fs';
2020

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

2929
if (electronPlatformName !== 'darwin') {
@@ -149,4 +149,4 @@ exports.default = async function afterPack(context) {
149149
} catch (error) {
150150
console.warn('Failed to sign app bundle:', error.message);
151151
}
152-
};
152+
}

bundler/scripts/build-precompile.jl

Lines changed: 0 additions & 13 deletions
This file was deleted.

bundler/scripts/check-build-exists.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import path from 'path';
33
import chalk from 'chalk';
44
import fs from 'fs';
5-
import webpackPaths from '../configs/webpack.paths';
5+
import webpackPaths from '../configs/webpack.paths.ts';
66

77
const mainPath = path.join(webpackPaths.distMainPath, 'main.js');
88
const rendererPath = path.join(webpackPaths.distRendererPath, 'renderer.js');

bundler/scripts/check-native-dep.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import fs from 'fs';
22
import chalk from 'chalk';
33
import { execSync } from 'child_process';
4-
import { dependencies } from '../../package.json';
4+
import packageJson from '../../package.json' with { type: 'json' };
55

6-
if (dependencies) {
7-
const dependenciesKeys = Object.keys(dependencies);
6+
if (packageJson.dependencies) {
7+
const dependenciesKeys = Object.keys(packageJson.dependencies);
88
const nativeDeps = fs
99
.readdirSync('node_modules')
1010
.filter((folder) => fs.existsSync(`node_modules/${folder}/binding.gyp`));

bundler/scripts/check-port-in-use.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)