Skip to content

Commit 473cb11

Browse files
author
Alberto Iannaccone
authored
Remove target section from electron-builder config (#853)
* remove target section from electron-builder config * do not modify zip structure before moving to artifcats folder
1 parent 0a87fd0 commit 473cb11

11 files changed

+7
-195
lines changed

Diff for: .github/workflows/build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ jobs:
102102
name: Linux_X86-64_app_image
103103
- path: '*macOS_64bit.dmg'
104104
name: macOS_dmg
105+
- path: '*macOS_64bit.zip'
106+
name: macOS_zip
105107
- path: '*Windows_64bit.exe'
106108
name: Windows_X86-64_interactive_installer
107109
- path: '*Windows_64bit.msi'

Diff for: electron/build/template-package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@
9191
"hardenedRuntime": true,
9292
"gatekeeperAssess": false,
9393
"entitlements": "resources/entitlements.mac.plist",
94-
"entitlementsInherit": "resources/entitlements.mac.plist",
95-
"target": [
96-
"dmg"
97-
]
94+
"entitlementsInherit": "resources/entitlements.mac.plist"
9895
},
9996
"linux": {
10097
"target": [

Diff for: electron/packager/index.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
227227
'Installing dependencies'
228228
);
229229
exec(
230-
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build${
231-
isElectronPublish ? ':publish' : ''
230+
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build${isElectronPublish ? ':publish' : ''
232231
}`,
233232
`Building the ${productName} application`
234233
);
@@ -393,11 +392,7 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
393392
for (const fileToCopy of filesToCopy) {
394393
echo(`🚢 >>> Copying ${fileToCopy} to ${targetFolder}.`);
395394
const isZip = await utils.isZip(fileToCopy);
396-
if (isZip) {
397-
await utils.adjustArchiveStructure(fileToCopy, targetFolder);
398-
} else {
399-
cp('-rf', fileToCopy, targetFolder);
400-
}
395+
cp('-rf', fileToCopy, targetFolder);
401396
echo(`👌 >>> Copied ${fileToCopy} to ${targetFolder}.`);
402397
}
403398
}
@@ -491,8 +486,7 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
491486
if (expectedVersion) {
492487
if (!versions.has(expectedVersion)) {
493488
echo(
494-
`Mismatching version configuration. Expected version was: '${expectedVersion}' actual was: '${
495-
Array.from(versions)[0]
489+
`Mismatching version configuration. Expected version was: '${expectedVersion}' actual was: '${Array.from(versions)[0]
496490
}'.`
497491
);
498492
shell.exit(1);

Diff for: electron/packager/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"prepare": "yarn test",
99
"package": "node index.js",
10-
"test": "mocha \"./test/**/*.test.js\""
10+
"test": "echo 'No test implemented'"
1111
},
1212
"keywords": [],
1313
"author": "Arduino SA",

Diff for: electron/packager/test/resources/not-a-zip.dmg

-7.99 MB
Binary file not shown.
-1.39 KB
Binary file not shown.
-3.06 KB
Binary file not shown.
-729 Bytes
Binary file not shown.
-1.39 KB
Binary file not shown.

Diff for: electron/packager/test/utils.test.js

-119
This file was deleted.

Diff for: electron/packager/utils.js

-62
Original file line numberDiff line numberDiff line change
@@ -50,67 +50,6 @@ function collectUnusedDependencies(pathToProject = process.cwd()) {
5050
});
5151
}
5252

53-
/**
54-
* `pathToZip` is a `path/to/your/app-name.zip`.
55-
* If the `pathToZip` archive does not have a root directory with name `app-name`, it creates one, and move the content from the
56-
* archive's root to the new root folder. If the archive already has the desired root folder, calling this function is a NOOP.
57-
* If `pathToZip` is not a ZIP, rejects. `targetFolderName` is the destination folder not the new archive location.
58-
*/
59-
function adjustArchiveStructure(pathToZip, targetFolderName, noCleanup) {
60-
return new Promise(async (resolve, reject) => {
61-
if (!(await isZip(pathToZip))) {
62-
reject(new Error(`Expected a ZIP file.`));
63-
return;
64-
}
65-
if (!fs.existsSync(targetFolderName)) {
66-
reject(new Error(`${targetFolderName} does not exist.`));
67-
return;
68-
}
69-
if (!fs.lstatSync(targetFolderName).isDirectory()) {
70-
reject(new Error(`${targetFolderName} is not a directory.`));
71-
return;
72-
}
73-
console.log(`⏱️ >>> Adjusting ZIP structure ${pathToZip}...`);
74-
75-
const root = basename(pathToZip);
76-
const resources = await list(pathToZip);
77-
const hasBaseFolder = resources.find((name) => name === root);
78-
if (hasBaseFolder) {
79-
if (
80-
resources.filter((name) => name.indexOf(path.sep) === -1).length > 1
81-
) {
82-
console.warn(
83-
`${pathToZip} ZIP has the desired root folder ${root}, however the ZIP contains other entries too: ${JSON.stringify(
84-
resources
85-
)}`
86-
);
87-
}
88-
console.log(`👌 <<< The ZIP already has the desired ${root} folder.`);
89-
resolve(pathToZip);
90-
return;
91-
}
92-
93-
const track = temp.track();
94-
try {
95-
const unzipOut = path.join(track.mkdirSync(), root);
96-
fs.mkdirSync(unzipOut);
97-
await unpack(pathToZip, unzipOut);
98-
const adjustedZip = path.join(targetFolderName, path.basename(pathToZip));
99-
await pack(unzipOut, adjustedZip);
100-
console.log(
101-
`👌 <<< Adjusted the ZIP structure. Moved the modified ${basename(
102-
pathToZip
103-
)} to the ${targetFolderName} folder.`
104-
);
105-
resolve(adjustedZip);
106-
} finally {
107-
if (!noCleanup) {
108-
track.cleanupSync();
109-
}
110-
}
111-
});
112-
}
113-
11453
/**
11554
* Returns the `basename` of `pathToFile` without the file extension.
11655
*/
@@ -213,7 +152,6 @@ function getChannelFile(platform) {
213152

214153
module.exports = {
215154
collectUnusedDependencies,
216-
adjustArchiveStructure,
217155
isZip,
218156
unpack,
219157
isNightly,

0 commit comments

Comments
 (0)