mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-09 18:38:33 +00:00
Check for IDE update at startup (#797)
* Remove check for updates on startup setting * Remove useless exported function * Update template-package.json used to package IDE * Add function to get channel file during packaging step * Add updates check * move ide updater on backend * configure updater options * add auto update preferences * TMP check updates on start and download * index on check-update-startup:fcb8f6eTMP check updates on start and download * set version to skip on local storage * add IDE setting to toggle update check on start-up * comment out check for updates on startup and auto update settings * Update Theia to 1.22.1 * updated CI * download changelog and show it in IDE updater dialog * remove useless file * remove useless code * add i18n to updater dialog * fix i18n * refactor UpdateInfo typing * add macos zip to artifacts * Simply use `--ignore-engines` * Use correct --ignore-engines * Fix semver#valid call * Use C++17 * updated documentation * add update channel preference * update updater url * updated documentation * Fix the C++ version * Build flag for cpp * add disclaimer with correct node version * Update `electron-builder` * Fix `Electron.Menu` issue * Skip electron rebuild * Rebuild native dependencies beforehand * Use resolutions section * Update template-package.json as well * move ide-updater to electron application * refactor ide-updater service * update yarn.lock * update i18n * Revert "Add gRPC user agent (#834)" This reverts commit5ab3a747a6. * fix ide download url * update latest file in CI * fix i18n check Co-authored-by: Silvano Cerza <silvanocerza@gmail.com> Co-authored-by: Francesco Stasi <f.stasi@me.com> Co-authored-by: Mark Sujew <msujew@yahoo.de>
This commit is contained in:
committed by
GitHub
parent
9ecff86bbe
commit
f660058c75
@@ -8,87 +8,113 @@ const dateFormat = require('dateformat');
|
||||
const { isNightly, isRelease, git } = require('./utils');
|
||||
|
||||
function artifactName() {
|
||||
const { platform, arch } = process;
|
||||
const id = (() => {
|
||||
if (isRelease) {
|
||||
return getVersion();
|
||||
} else if (isNightly) {
|
||||
return `nightly-${timestamp()}`
|
||||
} else {
|
||||
return getVersion();
|
||||
}
|
||||
})();
|
||||
const name = 'arduino-ide';
|
||||
switch (platform) {
|
||||
case 'win32': {
|
||||
if (arch === 'x64') {
|
||||
return `${name}_${id}_Windows_64bit.\$\{ext}`;
|
||||
}
|
||||
throw new Error(`Unsupported platform, arch: ${platform}, ${arch}`);
|
||||
}
|
||||
case 'darwin': {
|
||||
return `${name}_${id}_macOS_64bit.\$\{ext}`;
|
||||
}
|
||||
case 'linux': {
|
||||
switch (arch) {
|
||||
case 'arm': {
|
||||
return `${name}_${id}_Linux_ARMv7.\$\{ext}`;
|
||||
}
|
||||
case 'arm64': {
|
||||
return `${name}_${id}_Linux_ARM64.\$\{ext}`;
|
||||
}
|
||||
case 'x64': {
|
||||
return `${name}_${id}_Linux_64bit.\$\{ext}`;
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported platform, arch: ${platform}, ${arch}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
default: throw new Error(`Unsupported platform, arch: ${platform}, ${arch}`);
|
||||
const { platform, arch } = process;
|
||||
const id = (() => {
|
||||
if (isRelease) {
|
||||
return getVersion();
|
||||
} else if (isNightly) {
|
||||
return `nightly-${timestamp()}`;
|
||||
} else {
|
||||
return getVersion();
|
||||
}
|
||||
})();
|
||||
const name = 'arduino-ide';
|
||||
switch (platform) {
|
||||
case 'win32': {
|
||||
if (arch === 'x64') {
|
||||
return `${name}_${id}_Windows_64bit.\$\{ext}`;
|
||||
}
|
||||
throw new Error(`Unsupported platform, arch: ${platform}, ${arch}`);
|
||||
}
|
||||
case 'darwin': {
|
||||
return `${name}_${id}_macOS_64bit.\$\{ext}`;
|
||||
}
|
||||
case 'linux': {
|
||||
switch (arch) {
|
||||
case 'arm': {
|
||||
return `${name}_${id}_Linux_ARMv7.\$\{ext}`;
|
||||
}
|
||||
case 'arm64': {
|
||||
return `${name}_${id}_Linux_ARM64.\$\{ext}`;
|
||||
}
|
||||
case 'x64': {
|
||||
return `${name}_${id}_Linux_64bit.\$\{ext}`;
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported platform, arch: ${platform}, ${arch}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported platform, arch: ${platform}, ${arch}`);
|
||||
}
|
||||
}
|
||||
|
||||
function electronPlatform() {
|
||||
switch (process.platform) {
|
||||
case 'win32': {
|
||||
return 'win';
|
||||
}
|
||||
case 'darwin': {
|
||||
return 'mac';
|
||||
}
|
||||
case 'linux': {
|
||||
return 'linux';
|
||||
}
|
||||
default: throw new Error(`Unsupported platform: ${process.platform}.`);
|
||||
switch (process.platform) {
|
||||
case 'win32': {
|
||||
return 'win';
|
||||
}
|
||||
case 'darwin': {
|
||||
return 'mac';
|
||||
}
|
||||
case 'linux': {
|
||||
return 'linux';
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported platform: ${process.platform}.`);
|
||||
}
|
||||
}
|
||||
|
||||
function getVersion() {
|
||||
const repositoryRootPath = git('rev-parse --show-toplevel');
|
||||
let version = JSON.parse(fs.readFileSync(path.join(repositoryRootPath, 'package.json'), { encoding: 'utf8' })).version;
|
||||
if (!semver.valid(version)) {
|
||||
throw new Error(`Could not read version from root package.json. Version was: '${version}'.`);
|
||||
const repositoryRootPath = git('rev-parse --show-toplevel');
|
||||
let version = JSON.parse(
|
||||
fs.readFileSync(path.join(repositoryRootPath, 'package.json'), {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
).version;
|
||||
if (!semver.valid(version)) {
|
||||
throw new Error(
|
||||
`Could not read version from root package.json. Version was: '${version}'.`
|
||||
);
|
||||
}
|
||||
if (!isRelease) {
|
||||
if (isNightly) {
|
||||
version = `${version}-nightly.${timestamp()}`;
|
||||
} else {
|
||||
version = `${version}-snapshot.${currentCommitish()}`;
|
||||
}
|
||||
if (!isRelease) {
|
||||
if (isNightly) {
|
||||
version = `${version}-nightly-${timestamp()}`;
|
||||
} else {
|
||||
version = `${version}-snapshot-${currentCommitish()}`;
|
||||
}
|
||||
if (!semver.valid(version)) {
|
||||
throw new Error(`Invalid patched version: '${version}'.`);
|
||||
}
|
||||
if (isNightly) {
|
||||
version = `${version}-nightly-${timestamp()}`;
|
||||
} else {
|
||||
version = `${version}-snapshot-${currentCommitish()}`;
|
||||
}
|
||||
if (!semver.valid(version)) {
|
||||
throw new Error(`Invalid patched version: '${version}'.`);
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
function getChannel() {
|
||||
if (isRelease) {
|
||||
return 'stable';
|
||||
}
|
||||
if (isNightly) {
|
||||
return 'nightly';
|
||||
}
|
||||
|
||||
return 'none';
|
||||
}
|
||||
|
||||
function timestamp() {
|
||||
return dateFormat(new Date(), 'yyyymmdd');
|
||||
return dateFormat(new Date(), 'yyyymmdd');
|
||||
}
|
||||
|
||||
function currentCommitish() {
|
||||
return git('rev-parse --short HEAD');
|
||||
return git('rev-parse --short HEAD');
|
||||
}
|
||||
|
||||
// function currentBranch() {
|
||||
@@ -96,28 +122,38 @@ function currentCommitish() {
|
||||
// }
|
||||
|
||||
function generateTemplate(buildDate) {
|
||||
// do `export PUBLISH=true yarn package` if you want to mimic CI build locally.
|
||||
// const electronPublish = release || (isCI && currentBranch() === 'main') || process.env.PUBLISH === 'true';
|
||||
const version = getVersion();
|
||||
const productName = 'Arduino IDE';
|
||||
const name = 'arduino-ide';
|
||||
let customizations = {
|
||||
name,
|
||||
description: productName,
|
||||
version,
|
||||
build: {
|
||||
productName,
|
||||
appId: 'arduino.ProIDE',
|
||||
[electronPlatform()]: {
|
||||
artifactName: artifactName()
|
||||
}
|
||||
}
|
||||
};
|
||||
if (buildDate) {
|
||||
customizations = merge(customizations, { theia: { frontend: { config: { buildDate } } } });
|
||||
}
|
||||
const template = require('../build/template-package.json');
|
||||
return merge(template, customizations);
|
||||
// do `export PUBLISH=true yarn package` if you want to mimic CI build locally.
|
||||
// const electronPublish = release || (isCI && currentBranch() === 'main') || process.env.PUBLISH === 'true';
|
||||
const version = getVersion();
|
||||
const productName = 'Arduino IDE';
|
||||
const name = 'arduino-ide';
|
||||
const updateChannel = getChannel();
|
||||
let customizations = {
|
||||
name,
|
||||
description: productName,
|
||||
version,
|
||||
theia: {
|
||||
frontend: {
|
||||
config: {
|
||||
'arduino.ide.updateChannel': updateChannel,
|
||||
},
|
||||
},
|
||||
},
|
||||
build: {
|
||||
productName,
|
||||
appId: 'cc.arduino.IDE2',
|
||||
[electronPlatform()]: {
|
||||
artifactName: artifactName(),
|
||||
},
|
||||
},
|
||||
};
|
||||
if (buildDate) {
|
||||
customizations = merge(customizations, {
|
||||
theia: { frontend: { config: { buildDate } } },
|
||||
});
|
||||
}
|
||||
const template = require('../build/template-package.json');
|
||||
return merge(template, customizations);
|
||||
}
|
||||
|
||||
module.exports = { generateTemplate };
|
||||
|
||||
Reference in New Issue
Block a user