mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-08 03:46:33 +00:00
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
This commit is contained in:
parent
0a87fd00f3
commit
473cb11053
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -102,6 +102,8 @@ jobs:
|
|||||||
name: Linux_X86-64_app_image
|
name: Linux_X86-64_app_image
|
||||||
- path: '*macOS_64bit.dmg'
|
- path: '*macOS_64bit.dmg'
|
||||||
name: macOS_dmg
|
name: macOS_dmg
|
||||||
|
- path: '*macOS_64bit.zip'
|
||||||
|
name: macOS_zip
|
||||||
- path: '*Windows_64bit.exe'
|
- path: '*Windows_64bit.exe'
|
||||||
name: Windows_X86-64_interactive_installer
|
name: Windows_X86-64_interactive_installer
|
||||||
- path: '*Windows_64bit.msi'
|
- path: '*Windows_64bit.msi'
|
||||||
|
@ -91,10 +91,7 @@
|
|||||||
"hardenedRuntime": true,
|
"hardenedRuntime": true,
|
||||||
"gatekeeperAssess": false,
|
"gatekeeperAssess": false,
|
||||||
"entitlements": "resources/entitlements.mac.plist",
|
"entitlements": "resources/entitlements.mac.plist",
|
||||||
"entitlementsInherit": "resources/entitlements.mac.plist",
|
"entitlementsInherit": "resources/entitlements.mac.plist"
|
||||||
"target": [
|
|
||||||
"dmg"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"linux": {
|
"linux": {
|
||||||
"target": [
|
"target": [
|
||||||
|
@ -227,8 +227,7 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
|
|||||||
'Installing dependencies'
|
'Installing dependencies'
|
||||||
);
|
);
|
||||||
exec(
|
exec(
|
||||||
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build${
|
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build${isElectronPublish ? ':publish' : ''
|
||||||
isElectronPublish ? ':publish' : ''
|
|
||||||
}`,
|
}`,
|
||||||
`Building the ${productName} application`
|
`Building the ${productName} application`
|
||||||
);
|
);
|
||||||
@ -393,11 +392,7 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
|
|||||||
for (const fileToCopy of filesToCopy) {
|
for (const fileToCopy of filesToCopy) {
|
||||||
echo(`🚢 >>> Copying ${fileToCopy} to ${targetFolder}.`);
|
echo(`🚢 >>> Copying ${fileToCopy} to ${targetFolder}.`);
|
||||||
const isZip = await utils.isZip(fileToCopy);
|
const isZip = await utils.isZip(fileToCopy);
|
||||||
if (isZip) {
|
cp('-rf', fileToCopy, targetFolder);
|
||||||
await utils.adjustArchiveStructure(fileToCopy, targetFolder);
|
|
||||||
} else {
|
|
||||||
cp('-rf', fileToCopy, targetFolder);
|
|
||||||
}
|
|
||||||
echo(`👌 >>> Copied ${fileToCopy} to ${targetFolder}.`);
|
echo(`👌 >>> Copied ${fileToCopy} to ${targetFolder}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,8 +486,7 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
|
|||||||
if (expectedVersion) {
|
if (expectedVersion) {
|
||||||
if (!versions.has(expectedVersion)) {
|
if (!versions.has(expectedVersion)) {
|
||||||
echo(
|
echo(
|
||||||
`Mismatching version configuration. Expected version was: '${expectedVersion}' actual was: '${
|
`Mismatching version configuration. Expected version was: '${expectedVersion}' actual was: '${Array.from(versions)[0]
|
||||||
Array.from(versions)[0]
|
|
||||||
}'.`
|
}'.`
|
||||||
);
|
);
|
||||||
shell.exit(1);
|
shell.exit(1);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "yarn test",
|
"prepare": "yarn test",
|
||||||
"package": "node index.js",
|
"package": "node index.js",
|
||||||
"test": "mocha \"./test/**/*.test.js\""
|
"test": "echo 'No test implemented'"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Arduino SA",
|
"author": "Arduino SA",
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,119 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const expect = require('chai').expect;
|
|
||||||
const track = require('temp').track();
|
|
||||||
const unpack = require('../utils').unpack;
|
|
||||||
const testMe = require('../utils');
|
|
||||||
const sinon = require('sinon');
|
|
||||||
|
|
||||||
describe('utils', () => {
|
|
||||||
|
|
||||||
describe('adjustArchiveStructure', () => {
|
|
||||||
|
|
||||||
let consoleStub;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
consoleStub = sinon.stub(console, 'log').value(() => { });
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
consoleStub.reset();
|
|
||||||
track.cleanupSync();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reject when not a zip file', async () => {
|
|
||||||
try {
|
|
||||||
const invalid = path.join(__dirname, 'resources', 'not-a-zip.dmg');
|
|
||||||
await testMe.adjustArchiveStructure(invalid, track.mkdirSync());
|
|
||||||
throw new Error('Expected a rejection');
|
|
||||||
} catch (e) {
|
|
||||||
expect(e).to.be.an.instanceOf(Error);
|
|
||||||
expect(e.message).to.be.equal('Expected a ZIP file.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reject when target directory does not exist', async () => {
|
|
||||||
try {
|
|
||||||
const zip = path.join(__dirname, 'resources', 'zip-with-base-folder.zip');
|
|
||||||
await testMe.adjustArchiveStructure(zip, path.join(__dirname, 'some', 'missing', 'path'));
|
|
||||||
throw new Error('Expected a rejection');
|
|
||||||
} catch (e) {
|
|
||||||
expect(e).to.be.an.instanceOf(Error);
|
|
||||||
expect(e.message.endsWith('does not exist.')).to.be.true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reject when target is a file', async () => {
|
|
||||||
try {
|
|
||||||
const zip = path.join(__dirname, 'resources', 'zip-with-base-folder.zip');
|
|
||||||
await testMe.adjustArchiveStructure(zip, path.join(__filename));
|
|
||||||
throw new Error('Expected a rejection');
|
|
||||||
} catch (e) {
|
|
||||||
expect(e).to.be.an.instanceOf(Error);
|
|
||||||
expect(e.message.endsWith('is not a directory.')).to.be.true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be a NOOP when the zip already has the desired base folder', async () => {
|
|
||||||
const zip = path.join(__dirname, 'resources', 'zip-with-base-folder.zip');
|
|
||||||
const actual = await testMe.adjustArchiveStructure(zip, track.mkdirSync());
|
|
||||||
expect(actual).to.be.equal(zip);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle whitespace in file path gracefully', async () => {
|
|
||||||
const zip = path.join(__dirname, 'resources', 'zip with whitespace.zip');
|
|
||||||
const out = track.mkdirSync();
|
|
||||||
const actual = await testMe.adjustArchiveStructure(zip, out, true);
|
|
||||||
expect(actual).to.be.equal(path.join(out, 'zip with whitespace.zip'));
|
|
||||||
console.log(actual);
|
|
||||||
expect(fs.existsSync(actual)).to.be.true;
|
|
||||||
|
|
||||||
const verifyOut = track.mkdirSync();
|
|
||||||
await unpack(actual, verifyOut);
|
|
||||||
|
|
||||||
const root = path.join(verifyOut, 'zip with whitespace');
|
|
||||||
expect(fs.existsSync(root)).to.be.true;
|
|
||||||
expect(fs.lstatSync(root).isDirectory()).to.be.true;
|
|
||||||
const subs = fs.readdirSync(root);
|
|
||||||
expect(subs).to.have.lengthOf(3);
|
|
||||||
expect(subs.sort()).to.be.deep.equal(['a.txt', 'b.txt', 'foo']);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should keep the symlinks after ZIP adjustments', async function () {
|
|
||||||
if (process.platform === 'win32') {
|
|
||||||
this.skip();
|
|
||||||
}
|
|
||||||
const zip = path.join(__dirname, 'resources', 'zip-with-symlink.zip');
|
|
||||||
const out = track.mkdirSync();
|
|
||||||
const actual = await testMe.adjustArchiveStructure(zip, out, true);
|
|
||||||
expect(actual).to.be.equal(path.join(out, 'zip-with-symlink.zip'));
|
|
||||||
console.log(actual);
|
|
||||||
expect(fs.existsSync(actual)).to.be.true;
|
|
||||||
|
|
||||||
const verifyOut = track.mkdirSync();
|
|
||||||
await unpack(actual, verifyOut);
|
|
||||||
expect(fs.lstatSync(path.join(verifyOut, 'zip-with-symlink', 'folder', 'symlinked-sub')).isSymbolicLink()).to.be.true;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should adjust the archive structure if base folder is not present', async () => {
|
|
||||||
const zip = path.join(__dirname, 'resources', 'zip-without-symlink.zip');
|
|
||||||
const out = track.mkdirSync();
|
|
||||||
const actual = await testMe.adjustArchiveStructure(zip, out, true);
|
|
||||||
expect(actual).to.be.equal(path.join(out, 'zip-without-symlink.zip'));
|
|
||||||
console.log(actual);
|
|
||||||
expect(fs.existsSync(actual)).to.be.true;
|
|
||||||
|
|
||||||
const verifyOut = track.mkdirSync();
|
|
||||||
await unpack(actual, verifyOut);
|
|
||||||
|
|
||||||
const root = path.join(verifyOut, 'zip-without-symlink');
|
|
||||||
expect(fs.existsSync(root)).to.be.true;
|
|
||||||
expect(fs.lstatSync(root).isDirectory()).to.be.true;
|
|
||||||
const subs = fs.readdirSync(root);
|
|
||||||
expect(subs).to.have.lengthOf(3);
|
|
||||||
expect(subs.sort()).to.be.deep.equal(['a.txt', 'b.txt', 'foo']);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
@ -50,67 +50,6 @@ function collectUnusedDependencies(pathToProject = process.cwd()) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* `pathToZip` is a `path/to/your/app-name.zip`.
|
|
||||||
* If the `pathToZip` archive does not have a root directory with name `app-name`, it creates one, and move the content from the
|
|
||||||
* archive's root to the new root folder. If the archive already has the desired root folder, calling this function is a NOOP.
|
|
||||||
* If `pathToZip` is not a ZIP, rejects. `targetFolderName` is the destination folder not the new archive location.
|
|
||||||
*/
|
|
||||||
function adjustArchiveStructure(pathToZip, targetFolderName, noCleanup) {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
if (!(await isZip(pathToZip))) {
|
|
||||||
reject(new Error(`Expected a ZIP file.`));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!fs.existsSync(targetFolderName)) {
|
|
||||||
reject(new Error(`${targetFolderName} does not exist.`));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!fs.lstatSync(targetFolderName).isDirectory()) {
|
|
||||||
reject(new Error(`${targetFolderName} is not a directory.`));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log(`⏱️ >>> Adjusting ZIP structure ${pathToZip}...`);
|
|
||||||
|
|
||||||
const root = basename(pathToZip);
|
|
||||||
const resources = await list(pathToZip);
|
|
||||||
const hasBaseFolder = resources.find((name) => name === root);
|
|
||||||
if (hasBaseFolder) {
|
|
||||||
if (
|
|
||||||
resources.filter((name) => name.indexOf(path.sep) === -1).length > 1
|
|
||||||
) {
|
|
||||||
console.warn(
|
|
||||||
`${pathToZip} ZIP has the desired root folder ${root}, however the ZIP contains other entries too: ${JSON.stringify(
|
|
||||||
resources
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
console.log(`👌 <<< The ZIP already has the desired ${root} folder.`);
|
|
||||||
resolve(pathToZip);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const track = temp.track();
|
|
||||||
try {
|
|
||||||
const unzipOut = path.join(track.mkdirSync(), root);
|
|
||||||
fs.mkdirSync(unzipOut);
|
|
||||||
await unpack(pathToZip, unzipOut);
|
|
||||||
const adjustedZip = path.join(targetFolderName, path.basename(pathToZip));
|
|
||||||
await pack(unzipOut, adjustedZip);
|
|
||||||
console.log(
|
|
||||||
`👌 <<< Adjusted the ZIP structure. Moved the modified ${basename(
|
|
||||||
pathToZip
|
|
||||||
)} to the ${targetFolderName} folder.`
|
|
||||||
);
|
|
||||||
resolve(adjustedZip);
|
|
||||||
} finally {
|
|
||||||
if (!noCleanup) {
|
|
||||||
track.cleanupSync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the `basename` of `pathToFile` without the file extension.
|
* Returns the `basename` of `pathToFile` without the file extension.
|
||||||
*/
|
*/
|
||||||
@ -213,7 +152,6 @@ function getChannelFile(platform) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
collectUnusedDependencies,
|
collectUnusedDependencies,
|
||||||
adjustArchiveStructure,
|
|
||||||
isZip,
|
isZip,
|
||||||
unpack,
|
unpack,
|
||||||
isNightly,
|
isNightly,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user