chore(deps): Updated to Theia 1.39.0 (#2144)

- update Theia to `1.39.0`,
 - remove the application packager and fix the security vulnerabilities,
 - bundle the backed application with `webpack`, and
 - enhance the developer docs.

Co-authored-by: Akos Kitta <a.kitta@arduino.cc>
Co-authored-by: per1234 <accounts@perglass.com>

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta
2023-08-14 12:12:05 +02:00
committed by GitHub
parent 144df893d0
commit 9a6a457bc4
143 changed files with 5011 additions and 8095 deletions

View File

@@ -4,9 +4,7 @@ const transifex = require('./transifex');
const path = require('path');
const fs = require('node:fs/promises');
const util = require('util');
const shell = require('shelljs');
const fetch = require('node-fetch');
const download = require('download');
const { default: fetch } = require('node-fetch');
const getLanguages = async (organization, project) => {
const url = transifex.url(
@@ -14,8 +12,8 @@ const getLanguages = async (organization, project) => {
);
const json = await fetch(url, { headers: transifex.authHeader() })
.catch(err => {
shell.echo(err);
shell.exit(1);
console.error(err)
process.exit(1);
})
.then(res => res.json());
let languages = [];
@@ -46,8 +44,8 @@ const requestTranslationDownload = async (relationships) => {
body: JSON.stringify(data)
})
.catch(err => {
shell.echo(err);
shell.exit(1);
console.error(err)
process.exit(1);
})
.then(res => res.json());
@@ -62,13 +60,14 @@ const getTranslationDownloadStatus = async (language, downloadRequestId) => {
const url = transifex.url(
util.format('resource_translations_async_downloads/%s', downloadRequestId)
);
/** @type {import('node-fetch').RequestInit} */
const options = {
headers: transifex.authHeader(),
redirect: 'manual'
};
const res = await fetch(url, options).catch(err => {
shell.echo(err);
shell.exit(1);
console.error(err)
process.exit(1);
});
if (res.status === 303) {
@@ -101,12 +100,12 @@ const getTranslationDownloadStatus = async (language, downloadRequestId) => {
const { organization, project, resource } = await transifex.credentials();
const translationsDirectory = process.argv[2];
if (!translationsDirectory) {
shell.echo('Translations directory not specified');
shell.exit(1);
console.error('Translations directory not specified')
process.exit(1);
}
const languages = await getLanguages(organization, project);
shell.echo('translations found:', languages.join(', '));
console.log('translations found:', languages.join(', '));
// Remove data managed on Transifex to avoid accumulation of vestigial files
const translationFilenames = await fs.readdir(translationsDirectory);
@@ -141,10 +140,11 @@ const getTranslationDownloadStatus = async (language, downloadRequestId) => {
const res = await Promise.all(
downloadIds.map(d => getTranslationDownloadStatus(d['language'], d['id']))
).catch(err => {
shell.echo(err);
shell.exit(1);
console.error(err)
process.exit(1);
});
const { default: download } = await import('@xhmikosr/downloader');
await Promise.all(
res.map(r => {
return download(r['downloadUrl'], translationsDirectory, {
@@ -152,9 +152,9 @@ const getTranslationDownloadStatus = async (language, downloadRequestId) => {
});
})
).catch(err => {
shell.echo(err);
shell.exit(1);
console.error(err)
process.exit(1);
});
shell.echo('Translation files downloaded.');
console.log('Translation files downloaded.');
})();

View File

@@ -1,9 +1,8 @@
// @ts-check
const transifex = require('./transifex');
const fetch = require('node-fetch');
const { default: fetch } = require('node-fetch');
const fs = require('fs');
const shell = require('shelljs');
const util = require('util');
const uploadSourceFile = async (organization, project, resource, filePath) => {
@@ -31,8 +30,8 @@ const uploadSourceFile = async (organization, project, resource, filePath) => {
headers['Content-Type'] = 'application/vnd.api+json';
const json = await fetch(url, { method: 'POST', headers, body: JSON.stringify(data) })
.catch(err => {
shell.echo(err);
shell.exit(1);
console.error(err)
process.exit(1);
})
.then(res => res.json());
@@ -48,8 +47,8 @@ const getSourceUploadStatus = async (uploadId) => {
while (true) {
const json = await fetch(url, { headers })
.catch(err => {
shell.echo(err);
shell.exit(1);
console.error(err)
process.exit(1);
})
.then(res => res.json());
@@ -76,21 +75,21 @@ const getSourceUploadStatus = async (uploadId) => {
const { organization, project, resource } = await transifex.credentials();
const sourceFile = process.argv[2];
if (!sourceFile) {
shell.echo('Translation source file not specified');
shell.exit(1);
console.error('Translation source file not specified')
process.exit(1);
}
const uploadId = await uploadSourceFile(organization, project, resource, sourceFile)
.catch(err => {
shell.echo(err);
shell.exit(1);
console.error(err)
process.exit(1);
});
await getSourceUploadStatus(uploadId)
.catch(err => {
shell.echo(err);
shell.exit(1);
console.error(err)
process.exit(1);
});
shell.echo("Translation source file uploaded");
console.log("Translation source file uploaded");
})()

View File

@@ -1,15 +1,14 @@
// @ts-check
const shell = require('shelljs');
const util = require('util');
const TRANSIFEX_ENDPOINT = 'https://rest.api.transifex.com/';
const apiKey = () => {
const apiKey = process.env.TRANSIFEX_API_KEY;
if (apiKey === '') {
shell.echo('missing TRANSIFEX_API_KEY environment variable');
shell.exit(1)
if (!apiKey) {
console.error('missing TRANSIFEX_API_KEY environment variable');
process.exit(1);
}
return apiKey
}
@@ -19,19 +18,19 @@ exports.credentials = async () => {
const project = process.env.TRANSIFEX_PROJECT;
const resource = process.env.TRANSIFEX_RESOURCE;
if (organization === '') {
shell.echo('missing TRANSIFEX_ORGANIZATION environment variable');
shell.exit(1)
if (!organization) {
console.error('missing TRANSIFEX_ORGANIZATION environment variable');
process.exit(1);
}
if (project === '') {
shell.echo('missing TRANSIFEX_PROJECT environment variable');
shell.exit(1)
if (!project) {
console.error('missing TRANSIFEX_PROJECT environment variable');
process.exit(1);
}
if (resource === '') {
shell.echo('missing TRANSIFEX_RESOURCE environment variable');
shell.exit(1)
if (!resource) {
console.error('missing TRANSIFEX_RESOURCE environment variable');
process.exit(1);
}
return { organization, project, resource }

12
scripts/package.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash -i
set -e
yarn install --immutable \
&& yarn --cwd arduino-ide-extension build \
&& yarn test \
&& yarn --cwd arduino-ide-extension test:slow \
&& yarn --cwd arduino-ide-extension lint \
&& yarn --cwd electron-app rebuild \
&& yarn --cwd electron-app build \
&& yarn --cwd electron-app package