Avoid twice serial plotter apps (#1174)

* avoid twice serial plotter apps

* remove copy-serial-plotter script.

* Use `require#resolve` to locate the plotter app. (#1178)

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

Co-authored-by: Akos Kitta <a.kitta@arduino.cc>

Co-authored-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Francesco Spissu 2022-07-13 17:20:11 +02:00 committed by GitHub
parent 7fed8febf1
commit c51b201362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 15 deletions

View File

@ -4,12 +4,11 @@
"description": "An extension for Theia building the Arduino IDE",
"license": "AGPL-3.0-or-later",
"scripts": {
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn copy-serial-plotter && yarn copy-i18n && yarn clean && yarn download-examples && yarn build && yarn test",
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn copy-i18n && yarn clean && yarn download-examples && yarn build && yarn test",
"clean": "rimraf lib",
"compose-changelog": "node ./scripts/compose-changelog.js",
"download-cli": "node ./scripts/download-cli.js",
"download-fwuploader": "node ./scripts/download-fwuploader.js",
"copy-serial-plotter": "npx ncp ../node_modules/arduino-serial-plotter-webapp ./build/arduino-serial-plotter-webapp",
"copy-i18n": "npx ncp ../i18n ./build/i18n",
"download-ls": "node ./scripts/download-ls.js",
"download-examples": "node ./scripts/download-examples.js",

View File

@ -1,29 +1,22 @@
import * as path from 'path';
import * as express from 'express';
import { injectable } from '@theia/core/shared/inversify';
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
import path = require('path');
@injectable()
export class PlotterBackendContribution
implements BackendApplicationContribution
{
async initialize(): Promise<void> {}
configure(app: express.Application): void {
const relativePath = [
'..',
'..',
'..',
'build',
'arduino-serial-plotter-webapp',
'build',
];
app.use(express.static(path.join(__dirname, ...relativePath)));
const index = require.resolve(
'arduino-serial-plotter-webapp/build/index.html'
);
app.use(express.static(path.join(index, '..')));
app.get('/plotter', (req, res) => {
console.log(
`Serving serial plotter on http://${req.headers.host}${req.url}`
);
res.sendFile(path.join(__dirname, ...relativePath, 'index.html'));
res.sendFile(index);
});
}
}