From 5b22b2c0d6fbe0eba814dbc01546cfa831a19553 Mon Sep 17 00:00:00 2001 From: Francesco Spissu Date: Tue, 12 Jul 2022 12:10:57 +0200 Subject: [PATCH 1/3] avoid twice serial plotter apps --- arduino-ide-extension/package.json | 2 +- .../src/node/plotter/plotter-backend-contribution.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arduino-ide-extension/package.json b/arduino-ide-extension/package.json index 48103f587..be3654c0a 100644 --- a/arduino-ide-extension/package.json +++ b/arduino-ide-extension/package.json @@ -4,7 +4,7 @@ "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", diff --git a/arduino-ide-extension/src/node/plotter/plotter-backend-contribution.ts b/arduino-ide-extension/src/node/plotter/plotter-backend-contribution.ts index 2dc59d36a..10fe0c5a7 100644 --- a/arduino-ide-extension/src/node/plotter/plotter-backend-contribution.ts +++ b/arduino-ide-extension/src/node/plotter/plotter-backend-contribution.ts @@ -14,7 +14,8 @@ export class PlotterBackendContribution '..', '..', '..', - 'build', + '..', + 'node_modules', 'arduino-serial-plotter-webapp', 'build', ]; From f9bf0092229e7ecd3b7eaa126a19ca4d947c81f9 Mon Sep 17 00:00:00 2001 From: Francesco Spissu Date: Tue, 12 Jul 2022 12:21:26 +0200 Subject: [PATCH 2/3] remove copy-serial-plotter script. --- arduino-ide-extension/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/arduino-ide-extension/package.json b/arduino-ide-extension/package.json index be3654c0a..2cd904e14 100644 --- a/arduino-ide-extension/package.json +++ b/arduino-ide-extension/package.json @@ -9,7 +9,6 @@ "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", From afd8bf8d7924d100f43469852addd43469ade808 Mon Sep 17 00:00:00 2001 From: Francesco Spissu <94986937+francescospissu@users.noreply.github.com> Date: Wed, 13 Jul 2022 11:08:58 +0200 Subject: [PATCH 3/3] Use `require#resolve` to locate the plotter app. (#1178) Signed-off-by: Akos Kitta Co-authored-by: Akos Kitta --- .../plotter/plotter-backend-contribution.ts | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/arduino-ide-extension/src/node/plotter/plotter-backend-contribution.ts b/arduino-ide-extension/src/node/plotter/plotter-backend-contribution.ts index 10fe0c5a7..6cbf13c59 100644 --- a/arduino-ide-extension/src/node/plotter/plotter-backend-contribution.ts +++ b/arduino-ide-extension/src/node/plotter/plotter-backend-contribution.ts @@ -1,30 +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 {} - configure(app: express.Application): void { - const relativePath = [ - '..', - '..', - '..', - '..', - 'node_modules', - '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); }); } }