Skip to content

Commit f0f40a8

Browse files
authored
Merge pull request #6133 from ethereum/fixloggingdesktop
desktop things
2 parents f002d36 + eccba46 commit f0f40a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+947
-1161
lines changed

.circleci/config.yml

Lines changed: 0 additions & 672 deletions
Large diffs are not rendered by default.

apps/remix-ide-e2e/src/commands/hideToolTips.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import EventEmitter from 'events'
33

44
class HideToolTips extends EventEmitter {
55
command(this: NightwatchBrowser) {
6+
console.log('Hiding tooltips...')
67
browser
78
.perform((done) => {
89
browser.execute(function () {

apps/remix-ide-e2e/src/githttpbackend/setup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ rm -rf git/bare2.git
55
rm -rf git
66
mkdir -p git
77
cd git
8+
git config --global user.name "ci-bot"
9+
git config --global user.email "[email protected]"
810
git clone --bare https://github.com/ethereum/awesome-remix bare.git
911
git clone --bare https://github.com/ethereum/awesome-remix bare2.git

apps/remix-ide/src/app/files/electronProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class ElectronProvider extends FileProvider {
107107
throw new Error(e)
108108
}
109109
}
110-
console.log('json', json)
110+
111111
return json
112112
}
113113

apps/remixdesktop/after-pack.js

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

apps/remixdesktop/afterbuild.js

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,99 @@
11
const fs = require('fs');
2+
const path = require('path');
3+
const { spawn } = require('child_process');
24

35
exports.default = async function afterbuild(context) {
4-
// do not run when not on macOS or when not on CIRCLECI
5-
if (process.platform !== 'darwin' || !process.env.CIRCLE_BRANCH) {
6+
const isCI = process.env.CIRCLE_BRANCH || process.env.GITHUB_REF;
7+
if (!isCI) {
68
return;
79
}
810

911
console.log('AFTER BUILD', context);
1012

13+
// Handle macOS DMG notarization
14+
if (process.platform === 'darwin') {
15+
await handleMacOSNotarization(context);
16+
}
17+
18+
// Handle Windows installer signing
19+
if (process.platform === 'win32') {
20+
await handleWindowsSigning(context);
21+
}
22+
};
23+
24+
async function handleMacOSNotarization(context) {
1125
const artifactPaths = context.artifactPaths;
12-
const newDmgs = artifactPaths.filter((dmg) => dmg.endsWith('.dmg')).map((dmg) => dmg); // Removed unnecessary quotes for consistency
26+
const newDmgs = artifactPaths.filter((dmg) => dmg.endsWith('.dmg')).map((dmg) => dmg);
1327

1428
let existingDmgs = [];
1529
try {
16-
// Attempt to read the existing dmgs.json file
1730
const data = fs.readFileSync('dmgs.json', 'utf8');
1831
const parsedData = JSON.parse(data);
19-
existingDmgs = parsedData.dmgs || []; // Ensure existingDmgs is an array
32+
existingDmgs = parsedData.dmgs || [];
2033
} catch (error) {
21-
// If there's an error reading the file (e.g., file does not exist), proceed with an empty array
2234
console.log('No existing dmgs.json or error reading file, creating new one.');
2335
}
2436

25-
// Combine existing and new dmgs, avoiding duplicates
2637
const combinedDmgs = [...new Set([...existingDmgs, ...newDmgs])];
27-
28-
// Write/overwrite the dmgs.json with the combined list of dmgs
2938
fs.writeFileSync('dmgs.json', JSON.stringify({ dmgs: combinedDmgs }, null, 2));
30-
};
39+
}
40+
41+
async function handleWindowsSigning(context) {
42+
try {
43+
// Get version from package.json
44+
const packageJsonPath = path.join(__dirname, 'package.json');
45+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
46+
const version = packageJson.version;
47+
48+
// Construct the installer path
49+
const installerPath = path.join(__dirname, 'release', `Remix-Desktop-Setup-${version}.exe`);
50+
51+
if (!fs.existsSync(installerPath)) {
52+
console.log(`Windows installer not found at ${installerPath}, skipping signing`);
53+
return;
54+
}
55+
56+
console.log(`Signing Windows installer: ${installerPath}`);
57+
58+
// Check if we have the required environment variables for signing
59+
const requiredEnvVars = ['SM_API_KEY', 'SM_CLIENT_CERT_FILE_B64', 'SM_CODE_SIGNING_CERT_SHA1_HASH'];
60+
const missingEnvVars = requiredEnvVars.filter(envVar => !process.env[envVar]);
61+
62+
if (missingEnvVars.length > 0) {
63+
console.log(`Missing required environment variables for signing: ${missingEnvVars.join(', ')}`);
64+
console.log('Skipping Windows installer signing');
65+
return;
66+
}
67+
68+
// Use the existing sign-windows.sh script
69+
await signWithScript(installerPath);
70+
71+
console.log(`Successfully signed Windows installer: ${installerPath}`);
72+
73+
} catch (error) {
74+
console.error('Error signing Windows installer:', error);
75+
// Don't fail the build, just log the error
76+
}
77+
}
78+
79+
function signWithScript(filePath) {
80+
return new Promise((resolve, reject) => {
81+
const child = spawn(
82+
'bash',
83+
[
84+
path.resolve(__dirname, 'sign-windows.sh'),
85+
filePath
86+
],
87+
{ stdio: 'inherit' }
88+
);
89+
90+
child.on('exit', (code) => {
91+
if (code === 0) {
92+
console.log('Windows installer signing completed successfully.');
93+
resolve();
94+
} else {
95+
reject(new Error(`Signing script exited with code ${code}`));
96+
}
97+
});
98+
});
99+
}

apps/remixdesktop/aftersign.js

Lines changed: 109 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,120 @@
1-
const { notarize } = require('@electron/notarize')
2-
const fs = require('fs')
3-
const { exec } = require('child_process') // Import the exec function
4-
5-
// read the environment variables from process
1+
const { notarize } = require('@electron/notarize');
2+
const { spawn, exec } = require('child_process');
3+
const path = require('path');
4+
5+
// Windows signing function
6+
function signWindowsBinaries(appOutDir) {
7+
const filesToSign = [
8+
path.join(appOutDir, 'Remix-Desktop.exe'),
9+
path.join(appOutDir, 'resources', 'app.asar.unpacked', 'node_modules', 'node-pty', 'build', 'Release', 'winpty-agent.exe'),
10+
path.join(appOutDir, 'resources', 'app.asar.unpacked', 'node_modules', '@vscode', 'ripgrep', 'bin', 'rg.exe'),
11+
];
12+
13+
console.log('Signing the following Windows files:', filesToSign);
14+
15+
return new Promise((resolve, reject) => {
16+
const child = spawn(
17+
'bash',
18+
[
19+
path.resolve(__dirname, 'sign-windows.sh'),
20+
filesToSign.join(';')
21+
],
22+
{ stdio: 'inherit' }
23+
);
24+
25+
child.on('exit', (code) => {
26+
if (code === 0) {
27+
console.log('Windows signing completed successfully.');
28+
resolve();
29+
} else {
30+
reject(new Error(`Signing script exited with code ${code}`));
31+
}
32+
});
33+
});
34+
}
635

7-
console.log(process.env.DO_NOT_NOTARIZE)
36+
// macOS notarization function
37+
async function notarizeMac(context) {
38+
const { electronPlatformName, appOutDir } = context;
839

9-
if (process.env.DO_NOT_NOTARIZE) {
10-
console.log('NOTARIZING DISABLED')
11-
exports.default = async function notarizing(context) {
12-
return []
40+
if (electronPlatformName !== 'darwin') {
41+
console.log('Skipping notarization: not darwin or CIRCLE_BRANCH not set.');
42+
return;
1343
}
14-
} else {
15-
16-
exports.default = async function notarizing(context) {
17-
const { electronPlatformName, appOutDir } = context // Provided by electron-builder
18-
19-
console.log('NOTARIZING')
20-
21-
if (electronPlatformName !== 'darwin' || !process.env.CIRCLE_BRANCH) {
22-
return
23-
}
24-
25-
const appName = context.packager.appInfo.productFilename
26-
const appPath = `${appOutDir}/${appName}.app`
2744

28-
// Function to promisify the exec command
29-
function execShellCommand(cmd) {
30-
return new Promise((resolve, reject) => {
31-
exec(cmd, (error, stdout, stderr) => {
32-
if (error) {
33-
reject(new Error(`Error: ${error.message}`));
34-
return;
35-
}
36-
if (stderr) {
37-
reject(new Error(`Stderr: ${stderr}`));
38-
return;
39-
}
40-
console.log(`stdout: ${stdout}`);
41-
resolve(stdout);
42-
});
45+
const appName = context.packager.appInfo.productFilename;
46+
const appPath = `${appOutDir}/${appName}.app`;
47+
48+
async function execShellCommand(cmd) {
49+
return new Promise((resolve, reject) => {
50+
exec(cmd, (error, stdout, stderr) => {
51+
if (error) {
52+
reject(new Error(`Error: ${error.message}`));
53+
return;
54+
}
55+
if (stderr) {
56+
reject(new Error(`Stderr: ${stderr}`));
57+
return;
58+
}
59+
console.log(`stdout: ${stdout}`);
60+
resolve(stdout);
4361
});
44-
}
62+
});
63+
}
4564

46-
// Function to check if the app is stapled
47-
// Async function to check the stapling status
48-
async function checkStapleStatus() {
49-
try {
50-
console.log(`xcrun stapler validate "${appPath}"`)
51-
await execShellCommand(`xcrun stapler validate "${appPath}"`);
52-
console.log('App is already stapled. No action needed.');
53-
return true
54-
} catch (error) {
55-
console.log(`App is not stapled: ${error.message}`);
56-
return false
57-
}
65+
async function checkStapleStatus() {
66+
try {
67+
console.log(`xcrun stapler validate "${appPath}"`);
68+
await execShellCommand(`xcrun stapler validate "${appPath}"`);
69+
console.log('App is already stapled.');
70+
return true;
71+
} catch (error) {
72+
console.log(`App is not stapled: ${error.message}`);
73+
return false;
5874
}
75+
}
5976

77+
async function runNotarize() {
78+
console.log('Notarizing app...');
79+
await notarize({
80+
appBundleId: 'org.ethereum.remix-ide',
81+
appPath,
82+
appleId: process.env.APPLE_ID,
83+
appleIdPassword: process.env.APPLE_ID_PASSWORD,
84+
teamId: process.env.APPLE_TEAM_ID,
85+
});
86+
87+
console.log('Stapling...');
88+
await execShellCommand(`xcrun stapler staple "${appPath}"`);
89+
}
6090

91+
if (!(await checkStapleStatus())) {
92+
await runNotarize();
93+
await checkStapleStatus();
94+
}
95+
}
96+
97+
// Main export
98+
exports.default = async function afterSign(context) {
99+
const { appOutDir } = context;
100+
101+
// Skip signing for local builds
102+
const isCI = process.env.CI ||
103+
process.env.GITHUB_ACTIONS ||
104+
process.env.CIRCLECI ||
105+
process.env.APPVEYOR ||
106+
process.env.TRAVIS;
107+
108+
if (!isCI || process.env.DO_NOT_NOTARIZE == 'true' || process.env.DO_NOT_SIGN == 'true') {
109+
console.log('Skipping signing: local build detected (no CI environment).');
110+
return;
111+
}
61112

62-
63-
async function runNotarize() {
64-
65-
console.log('NOTARIZING + ', `xcrun stapler staple "${appPath}"`)
66-
console.log({
67-
appBundleId: 'org.ethereum.remix-ide', // Your app's bundle ID
68-
appPath: `${appOutDir}/${appName}.app`, // Path to your .app
69-
appleId: process.env.APPLE_ID, // Your Apple ID
70-
appleIdPassword: process.env.APPLE_ID_PASSWORD, // App-specific password
71-
teamId: process.env.APPLE_TEAM_ID, // Your Apple Developer team ID (optional)
72-
})
73-
74-
try {
75-
const r = await notarize({
76-
appBundleId: 'org.ethereum.remix-ide', // Your app's bundle ID
77-
appPath: `${appOutDir}/${appName}.app`, // Path to your .app
78-
appleId: process.env.APPLE_ID, // Your Apple ID
79-
appleIdPassword: process.env.APPLE_ID_PASSWORD, // App-specific password
80-
teamId: process.env.APPLE_TEAM_ID, // Your Apple Developer team ID (optional)
81-
})
82-
83-
console.log(r)
84-
85-
// Stapling the app
86-
console.log('STAPLING', `xcrun stapler staple "${appPath}"`)
87-
88-
await execShellCommand(`xcrun stapler staple "${appPath}"`)
89-
90-
} catch (error) {
91-
console.error('Error during notarization:', error)
92-
throw new Error('Error during notarization', error)
93-
}
94-
95-
}
96-
97-
if (!await checkStapleStatus()) {
98-
await runNotarize()
99-
await checkStapleStatus()
100-
} else {
101-
return []
102-
}
113+
if (process.platform === 'darwin') {
114+
await notarizeMac(context);
115+
} else if (process.platform === 'win32') {
116+
await signWindowsBinaries(appOutDir);
117+
} else {
118+
console.log('No signing needed for this platform.');
103119
}
104-
}
120+
};

apps/remixdesktop/checkabi.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const os = require('os');
2+
console.log('Electron:', process.versions.electron);
3+
console.log('Node:', process.versions.node);
4+
console.log('ABI:', process.versions.modules)
5+
console.log(os.platform(), os.arch());

apps/remixdesktop/latest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"productName": "Remix-Desktop",
33
"appId": "org.ethereum.remix-ide",
44
"asar": true,
5+
"npmRebuild": false,
56
"generateUpdatesFilesForAllChannels": false,
67
"icon": "assets",
78
"files": [

0 commit comments

Comments
 (0)