From 4c3150e56d51786ed54d8713e574855815525b8d Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Tue, 31 Jan 2023 19:25:49 +0800 Subject: [PATCH 01/14] server.js: Add optional cmd line arg --- package.json | 3 ++- server.js | 42 +++++++++++++++++++++++++++++++++++++++++- yarn.lock | 22 ++++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d8b4aa88cd..09cedd7d45 100644 --- a/package.json +++ b/package.json @@ -160,7 +160,8 @@ "webpack": "^5.75.0", "webpack-cli": "^5.0.1", "webpack-dev-server": "^4.11.1", - "workbox-webpack-plugin": "^6.5.4" + "workbox-webpack-plugin": "^6.5.4", + "yargs": "^17.6.2" }, "jest": { "collectCoverageFrom": [ diff --git a/server.js b/server.js index bd3a9b092d..94a309992c 100644 --- a/server.js +++ b/server.js @@ -4,16 +4,26 @@ // @noflow const webpack = require('webpack'); const WebpackDevServer = require('webpack-dev-server'); +const express = require('express'); const config = require('./webpack.config'); const { oneLine, stripIndent } = require('common-tags'); const port = process.env.FX_PROFILER_PORT || 4242; const host = process.env.FX_PROFILER_HOST || 'localhost'; const fs = require('fs'); const path = require('path'); +const yargs = require('yargs'); +const { hideBin } = require('yargs/helpers'); const localConfigExists = fs.existsSync( path.join(__dirname, './webpack.local-config.js') ); +const argv = yargs(hideBin(process.argv)) + .command('* []', 'Open Firefox Profiler, on if included.') + // Disabled --version flag since no version number in package.json. + .version(false) + .strict() + .parseSync(); + const serverConfig = { allowedHosts: ['localhost', '.gitpod.io'], host, @@ -64,6 +74,36 @@ if (localConfigExists) { } } +const profileUrl = `http://${host}:${port}`; +if (argv.profile) { + // Not modifying serverConfig.static because that can roughly triple + // webpack cached build time. + const prevSetupMiddlewares = serverConfig.setupMiddlewares; + serverConfig.setupMiddlewares = (middlewares, devServer) => { + if (prevSetupMiddlewares) { + middlewares = prevSetupMiddlewares(middlewares, devServer); + } + devServer.app.use( + '/profiles/', + express.static(path.resolve(path.dirname(argv.profile))) + ); + return middlewares; + }; + + const profileFromUrl = `${profileUrl}/from-url/${encodeURIComponent( + `${profileUrl}/profiles/${path.basename(argv.profile)}` + )}`; + if ( + typeof serverConfig.open === 'object' && + !Array.isArray(serverConfig.open) && + serverConfig.open !== null + ) { + serverConfig.open.target = [profileFromUrl]; + } else { + serverConfig.open = [profileFromUrl]; + } +} + const server = new WebpackDevServer(serverConfig, webpack(config)); server .start() @@ -72,7 +112,7 @@ server '------------------------------------------------------------------------------------------'; console.log(barAscii); - console.log(`> Firefox Profiler is listening at: http://${host}:${port}\n`); + console.log(`> Firefox Profiler is listening at: ${profileUrl}\n`); if (port === 4242) { console.log( '> You can change this default port with the environment variable FX_PROFILER_PORT.\n' diff --git a/yarn.lock b/yarn.lock index dc66bda6c3..66898c47b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3509,6 +3509,15 @@ cliui@^7.0.2: strip-ansi "^6.0.0" wrap-ansi "^7.0.0" +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.1" + wrap-ansi "^7.0.0" + clone-deep@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" @@ -13151,6 +13160,19 @@ yargs@^17.3.1: y18n "^5.0.5" yargs-parser "^21.0.0" +yargs@^17.6.2: + version "17.6.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.6.2.tgz#2e23f2944e976339a1ee00f18c77fedee8332541" + integrity sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw== + dependencies: + cliui "^8.0.1" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.3" + y18n "^5.0.5" + yargs-parser "^21.1.1" + ylru@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/ylru/-/ylru-1.2.1.tgz#f576b63341547989c1de7ba288760923b27fe84f" From 082befcae40be4c013849f4576aaf71c683f7451 Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sat, 4 Feb 2023 12:31:44 +0800 Subject: [PATCH 02/14] Rename `profileUrl` to `profilerUrl` --- server.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index 94a309992c..d5102a8bb7 100644 --- a/server.js +++ b/server.js @@ -74,7 +74,7 @@ if (localConfigExists) { } } -const profileUrl = `http://${host}:${port}`; +const profilerUrl = `http://${host}:${port}`; if (argv.profile) { // Not modifying serverConfig.static because that can roughly triple // webpack cached build time. @@ -90,8 +90,8 @@ if (argv.profile) { return middlewares; }; - const profileFromUrl = `${profileUrl}/from-url/${encodeURIComponent( - `${profileUrl}/profiles/${path.basename(argv.profile)}` + const profileFromUrl = `${profilerUrl}/from-url/${encodeURIComponent( + `${profilerUrl}/profiles/${path.basename(argv.profile)}` )}`; if ( typeof serverConfig.open === 'object' && @@ -112,7 +112,7 @@ server '------------------------------------------------------------------------------------------'; console.log(barAscii); - console.log(`> Firefox Profiler is listening at: ${profileUrl}\n`); + console.log(`> Firefox Profiler is listening at: ${profilerUrl}\n`); if (port === 4242) { console.log( '> You can change this default port with the environment variable FX_PROFILER_PORT.\n' From 37a1ead06b2c6caa6b7b7ed347a52e1e147aadcf Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sat, 4 Feb 2023 12:34:21 +0800 Subject: [PATCH 03/14] Refactor out the profile dir --- server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index d5102a8bb7..68ecd1fffd 100644 --- a/server.js +++ b/server.js @@ -78,20 +78,21 @@ const profilerUrl = `http://${host}:${port}`; if (argv.profile) { // Not modifying serverConfig.static because that can roughly triple // webpack cached build time. + const profileDir = '/profiles/'; const prevSetupMiddlewares = serverConfig.setupMiddlewares; serverConfig.setupMiddlewares = (middlewares, devServer) => { if (prevSetupMiddlewares) { middlewares = prevSetupMiddlewares(middlewares, devServer); } devServer.app.use( - '/profiles/', + profileDir, express.static(path.resolve(path.dirname(argv.profile))) ); return middlewares; }; const profileFromUrl = `${profilerUrl}/from-url/${encodeURIComponent( - `${profilerUrl}/profiles/${path.basename(argv.profile)}` + `${profilerUrl}${profileDir}${path.basename(argv.profile)}` )}`; if ( typeof serverConfig.open === 'object' && From cf97a59a425d3d03f05024d0d9b72fe7bf6f33c9 Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sat, 4 Feb 2023 12:58:23 +0800 Subject: [PATCH 04/14] Filter out `/profiles/` URLs that are not the profile file --- server.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 68ecd1fffd..629d0a291f 100644 --- a/server.js +++ b/server.js @@ -79,11 +79,22 @@ if (argv.profile) { // Not modifying serverConfig.static because that can roughly triple // webpack cached build time. const profileDir = '/profiles/'; + const profileFile = path.basename(argv.profile); const prevSetupMiddlewares = serverConfig.setupMiddlewares; serverConfig.setupMiddlewares = (middlewares, devServer) => { if (prevSetupMiddlewares) { middlewares = prevSetupMiddlewares(middlewares, devServer); } + devServer.app.use((req, res, next) => { + if ( + req.url.startsWith(profileDir) && + req.url !== `${profileDir}${profileFile}` + ) { + res.sendStatus(404); + } else { + next(); + } + }); devServer.app.use( profileDir, express.static(path.resolve(path.dirname(argv.profile))) @@ -92,7 +103,7 @@ if (argv.profile) { }; const profileFromUrl = `${profilerUrl}/from-url/${encodeURIComponent( - `${profilerUrl}${profileDir}${path.basename(argv.profile)}` + `${profilerUrl}${profileDir}${profileFile}` )}`; if ( typeof serverConfig.open === 'object' && From f44d6069a6fa5338e3c75c88a9310eb6dd213566 Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Fri, 10 Feb 2023 21:17:39 +0800 Subject: [PATCH 05/14] Remove angle brackets around arg name Co-authored-by: Julien Wajsberg --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 629d0a291f..e2ff25ffd3 100644 --- a/server.js +++ b/server.js @@ -18,7 +18,7 @@ const localConfigExists = fs.existsSync( ); const argv = yargs(hideBin(process.argv)) - .command('* []', 'Open Firefox Profiler, on if included.') + .command('* [profile]', 'Open Firefox Profiler, on [profile] if included.') // Disabled --version flag since no version number in package.json. .version(false) .strict() From 279453c3cb0a7def3cf82e66435b3454a831f5a8 Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sat, 11 Feb 2023 18:15:33 +0800 Subject: [PATCH 06/14] Spin up `node:http` server instead for profile --- package.json | 1 + server.js | 59 +++++++++++++++++++++++++--------------------------- yarn.lock | 9 ++++++++ 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index 27ef04b028..eecf436fa3 100644 --- a/package.json +++ b/package.json @@ -146,6 +146,7 @@ "mkdirp": "^2.1.3", "node-fetch": "^2.6.7", "npm-run-all": "^4.1.5", + "open": "^8.4.1", "postcss": "^8.4.21", "postcss-loader": "^7.0.2", "prettier": "^2.8.3", diff --git a/server.js b/server.js index e2ff25ffd3..884ac634a5 100644 --- a/server.js +++ b/server.js @@ -4,7 +4,7 @@ // @noflow const webpack = require('webpack'); const WebpackDevServer = require('webpack-dev-server'); -const express = require('express'); +const http = require('node:http'); const config = require('./webpack.config'); const { oneLine, stripIndent } = require('common-tags'); const port = process.env.FX_PROFILER_PORT || 4242; @@ -13,6 +13,7 @@ const fs = require('fs'); const path = require('path'); const yargs = require('yargs'); const { hideBin } = require('yargs/helpers'); +const open = require('open'); const localConfigExists = fs.existsSync( path.join(__dirname, './webpack.local-config.js') ); @@ -76,44 +77,40 @@ if (localConfigExists) { const profilerUrl = `http://${host}:${port}`; if (argv.profile) { - // Not modifying serverConfig.static because that can roughly triple - // webpack cached build time. - const profileDir = '/profiles/'; - const profileFile = path.basename(argv.profile); - const prevSetupMiddlewares = serverConfig.setupMiddlewares; - serverConfig.setupMiddlewares = (middlewares, devServer) => { - if (prevSetupMiddlewares) { - middlewares = prevSetupMiddlewares(middlewares, devServer); - } - devServer.app.use((req, res, next) => { - if ( - req.url.startsWith(profileDir) && - req.url !== `${profileDir}${profileFile}` - ) { - res.sendStatus(404); - } else { - next(); - } - }); - devServer.app.use( - profileDir, - express.static(path.resolve(path.dirname(argv.profile))) - ); - return middlewares; - }; + // Spin up a simple http server serving the profile file. + const profileServer = http.createServer((req, res) => { + res.setHeader('Access-Control-Allow-Origin', profilerUrl); + const fileStream = fs.createReadStream(argv.profile); + fileStream.pipe(res); + }); + + // Close the profile server on CTRL-C. + process.on('SIGINT', () => profileServer.close()); + process.on('SIGTERM', () => profileServer.close()); - const profileFromUrl = `${profilerUrl}/from-url/${encodeURIComponent( - `${profilerUrl}${profileDir}${profileFile}` - )}`; + // Delete "open" target (if any) in serverConfig. if ( typeof serverConfig.open === 'object' && !Array.isArray(serverConfig.open) && serverConfig.open !== null ) { - serverConfig.open.target = [profileFromUrl]; + delete serverConfig.open.target; } else { - serverConfig.open = [profileFromUrl]; + delete serverConfig.open; } + + // Save and delete "open" property from serverConfig so that + // webpack-dev-server doesn't open anything in tandem. + const openOptions = serverConfig.open; + delete serverConfig.open; + + // Open on profile. + profileServer.listen(0, host, () => { + const profileFromUrl = `${profilerUrl}/from-url/${encodeURIComponent( + `http://${host}:${profileServer.address().port}/` + )}`; + open(profileFromUrl, openOptions); + }); } const server = new WebpackDevServer(serverConfig, webpack(config)); diff --git a/yarn.lock b/yarn.lock index ef2ca289d5..b9b899c6ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9128,6 +9128,15 @@ open@^8.0.9, open@^8.4.0: is-docker "^2.1.1" is-wsl "^2.2.0" +open@^8.4.1: + version "8.4.1" + resolved "https://registry.yarnpkg.com/open/-/open-8.4.1.tgz#2ab3754c07f5d1f99a7a8d6a82737c95e3101cff" + integrity sha512-/4b7qZNhv6Uhd7jjnREh1NjnPxlTq+XNWPG88Ydkj5AILcA5m3ajvcg57pB24EQjKv0dK62XnDqk9c/hkIG5Kg== + dependencies: + define-lazy-prop "^2.0.0" + is-docker "^2.1.1" + is-wsl "^2.2.0" + opencollective-postinstall@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259" From 5d0a1ccc5a0cbed31da4d1962924c4bbc3940e59 Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sun, 12 Feb 2023 14:32:44 +0800 Subject: [PATCH 07/14] Add `fp.sh` script and add to docs --- CONTRIBUTING.md | 1 + bin/fp.sh | 15 +++++++++++++++ docs-developer/loading-in-profiles.md | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 bin/fp.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 13f578590a..bee3224fac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,6 +78,7 @@ The web app doesn't include any performance profiles by default, so you'll need #### 2. Use an existing profile: - On the web, replace the https://profiler.firefox.com with your local server, usually `http://localhost:4242`. Be sure that that the protocol is `http` and not `https` when running the server locally. - Alternatively, if a profile has been previously downloaded, drag and drop it to the loading screen. Compared to the previous solution, refreshing won't work with this particular solution. + - A third alternative on Linux is to run the provided [fp.sh](./bin/fp.sh) script, giving the profile file as the first argument. Both refreshing and symlinking to the script are supported. For more information on loading a profile, visit its [documentation](./docs-developer/loading-in-profiles.md). diff --git a/bin/fp.sh b/bin/fp.sh new file mode 100755 index 0000000000..15db079ce5 --- /dev/null +++ b/bin/fp.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# This script is primarily for running Firefox Profiler on a saved profile. + +if [ "x$1" != "x" ]; then + PROFILEPATH=$(realpath "$1") +fi +PWD=$(pwd) +SCRIPTDIR=$(dirname $(realpath "$0")) +cd "$SCRIPTDIR/.." +if [ "x$1" = "x" ]; then + yarn start +else + yarn start "$PROFILEPATH" +fi +cd "$PWD" diff --git a/docs-developer/loading-in-profiles.md b/docs-developer/loading-in-profiles.md index e9f6838dcd..1adc1af91d 100644 --- a/docs-developer/loading-in-profiles.md +++ b/docs-developer/loading-in-profiles.md @@ -102,4 +102,4 @@ Firefox loads the profiles directly into the front-end through a WebChannel mech > `https://profiler.firefox.com/from-file/` -When you're on [the home page](https://profiler.firefox.com) files can be loaded by either dragging over the profiler.firefox.com client, or using the file upload input. +When you're on [the home page](https://profiler.firefox.com) files can be loaded by either dragging over the profiler.firefox.com client, or using the file upload input. On Linux, the provided [fp.sh](../bin/fp.sh) script can load files. From c0c40bd365f642d2dab0030cfa6b31817b2e4c8d Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sun, 12 Feb 2023 14:49:32 +0800 Subject: [PATCH 08/14] Fix Shellcheck errors --- bin/fp.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/fp.sh b/bin/fp.sh index 15db079ce5..1941d68c59 100755 --- a/bin/fp.sh +++ b/bin/fp.sh @@ -5,11 +5,12 @@ if [ "x$1" != "x" ]; then PROFILEPATH=$(realpath "$1") fi PWD=$(pwd) -SCRIPTDIR=$(dirname $(realpath "$0")) -cd "$SCRIPTDIR/.." +SCRIPTPATH=$(realpath "$0") +SCRIPTDIR=$(dirname "$SCRIPTPATH") +cd "$SCRIPTDIR/.." || exit if [ "x$1" = "x" ]; then yarn start else yarn start "$PROFILEPATH" fi -cd "$PWD" +cd "$PWD" || exit From 6723ea89ce42f173214fd8d30b531298a82da93a Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sun, 12 Feb 2023 19:56:14 +0800 Subject: [PATCH 09/14] Run `npx yarn-deduplicate` --- yarn.lock | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9cfeea3880..6ca5db40f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9127,16 +9127,7 @@ only@~0.0.2: resolved "https://registry.yarnpkg.com/only/-/only-0.0.2.tgz#2afde84d03e50b9a8edc444e30610a70295edfb4" integrity sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q= -open@^8.0.9, open@^8.4.0: - version "8.4.0" - resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8" - integrity sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q== - dependencies: - define-lazy-prop "^2.0.0" - is-docker "^2.1.1" - is-wsl "^2.2.0" - -open@^8.4.1: +open@^8.0.9, open@^8.4.0, open@^8.4.1: version "8.4.1" resolved "https://registry.yarnpkg.com/open/-/open-8.4.1.tgz#2ab3754c07f5d1f99a7a8d6a82737c95e3101cff" integrity sha512-/4b7qZNhv6Uhd7jjnREh1NjnPxlTq+XNWPG88Ydkj5AILcA5m3ajvcg57pB24EQjKv0dK62XnDqk9c/hkIG5Kg== @@ -13172,20 +13163,7 @@ yargs@^16.0.0, yargs@^16.0.3: y18n "^5.0.5" yargs-parser "^20.2.2" -yargs@^17.3.1: - version "17.4.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.4.1.tgz#ebe23284207bb75cee7c408c33e722bfb27b5284" - integrity sha512-WSZD9jgobAg3ZKuCQZSa3g9QOJeCCqLoLAykiWgmXnDo9EPnn4RPf5qVTtzgOx66o6/oqhcA5tHtJXpG8pMt3g== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.3" - y18n "^5.0.5" - yargs-parser "^21.0.0" - -yargs@^17.6.2: +yargs@^17.3.1, yargs@^17.6.2: version "17.6.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.6.2.tgz#2e23f2944e976339a1ee00f18c77fedee8332541" integrity sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw== From c1ee8cfc9e45752f08656d2217416d91b2c5155b Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sun, 12 Feb 2023 20:02:04 +0800 Subject: [PATCH 10/14] Run `yarn install` --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 6ca5db40f9..78141658a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13128,7 +13128,7 @@ yargs-parser@^20.2.2, yargs-parser@^20.2.3: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== -yargs-parser@^21.0.0, yargs-parser@^21.1.1: +yargs-parser@^21.1.1: version "21.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== From 1722a14f82f16118e75493d086b4b93711942a81 Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sat, 4 Mar 2023 15:59:02 +0800 Subject: [PATCH 11/14] Rename `fp.sh` to `launch-fp.sh` --- bin/{fp.sh => launch-fp.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bin/{fp.sh => launch-fp.sh} (100%) diff --git a/bin/fp.sh b/bin/launch-fp.sh similarity index 100% rename from bin/fp.sh rename to bin/launch-fp.sh From 974ad6d7738e5f73ac29e390f9ee9c31e6414b99 Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sat, 4 Mar 2023 16:09:45 +0800 Subject: [PATCH 12/14] Add `launch-fp.sh` examples --- bin/launch-fp.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/launch-fp.sh b/bin/launch-fp.sh index 1941d68c59..41411418fe 100755 --- a/bin/launch-fp.sh +++ b/bin/launch-fp.sh @@ -1,5 +1,12 @@ #!/bin/sh # This script is primarily for running Firefox Profiler on a saved profile. +# +# For example: +# launch-fp.sh CPU.20230124.095804.8433.0.001.cpuprofile +# will launch the Firefox Profiler server and open a browser tab with the above +# Node.js profile. If the profile is omitted: +# launch-fp.sh +# then only the server will be launched. if [ "x$1" != "x" ]; then PROFILEPATH=$(realpath "$1") From fe0bbab29c07ae25a948b2e412e7cdcdcbba6a4b Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sat, 4 Mar 2023 16:20:56 +0800 Subject: [PATCH 13/14] Add note to `from-url` datasource section instead --- docs-developer/loading-in-profiles.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs-developer/loading-in-profiles.md b/docs-developer/loading-in-profiles.md index 1adc1af91d..f441c19cfa 100644 --- a/docs-developer/loading-in-profiles.md +++ b/docs-developer/loading-in-profiles.md @@ -92,6 +92,8 @@ server.listen(PORT, err => { }); ``` +Note that if you have a copy of the project locally, you can simply add the profile path as a parameter to `yarn start` and a server serving this profile will be spawned for you. On Linux, the provided [launch-fp.sh](../bin/launch-fp.sh) script can do this for you as well, from any working directory. + ### Directly from Firefox > `https://profiler.firefox.com/from-browser/` @@ -102,4 +104,4 @@ Firefox loads the profiles directly into the front-end through a WebChannel mech > `https://profiler.firefox.com/from-file/` -When you're on [the home page](https://profiler.firefox.com) files can be loaded by either dragging over the profiler.firefox.com client, or using the file upload input. On Linux, the provided [fp.sh](../bin/fp.sh) script can load files. +When you're on [the home page](https://profiler.firefox.com) files can be loaded by either dragging over the profiler.firefox.com client, or using the file upload input. From fb1b549e23971d34a736658468ed837944db47ca Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Sat, 4 Mar 2023 16:47:31 +0800 Subject: [PATCH 14/14] Remove simply word from `loading-in-profiles.md` --- docs-developer/loading-in-profiles.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs-developer/loading-in-profiles.md b/docs-developer/loading-in-profiles.md index f441c19cfa..c9fa19031a 100644 --- a/docs-developer/loading-in-profiles.md +++ b/docs-developer/loading-in-profiles.md @@ -92,7 +92,7 @@ server.listen(PORT, err => { }); ``` -Note that if you have a copy of the project locally, you can simply add the profile path as a parameter to `yarn start` and a server serving this profile will be spawned for you. On Linux, the provided [launch-fp.sh](../bin/launch-fp.sh) script can do this for you as well, from any working directory. +Note that if you have a copy of the project locally, you can add the profile path as a parameter to `yarn start` and a server serving this profile will be spawned for you. On Linux, the provided [launch-fp.sh](../bin/launch-fp.sh) script can do this for you as well, from any working directory. ### Directly from Firefox