From 4ec8b1b34035f1055cb0484616028c59d901f95f Mon Sep 17 00:00:00 2001 From: William Durand Date: Tue, 5 Jan 2021 17:37:16 +0100 Subject: [PATCH] Update config to run frontend locally --- README.md | 4 +--- bin/proxy.js | 5 +++-- config/development-local.js | 10 ++++++++++ config/development.js | 2 +- config/uitests.js | 20 -------------------- package.json | 27 ++++++++------------------- 6 files changed, 23 insertions(+), 45 deletions(-) create mode 100644 config/development-local.js delete mode 100644 config/uitests.js diff --git a/README.md b/README.md index 251eb66a396..cd8e8b9e342 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,9 @@ Here are some commands you can run: | Command | Description | | --- | --- | -| yarn amo | Start the dev server/proxy (for amo) using data from Docker. _This is not currently working. See [issue-7196][]_. | +| yarn amo:olympia | Start the dev server/proxy (for amo) using data from a local addons-server environment. | | yarn amo:dev | Start the dev server/proxy (for amo) using data from the dev server (https://addons-dev.allizom.org/) | | yarn amo:dev-https | Same as `amo:dev` but with HTTPS, available at: https://example.com:3000/. [Read about setting up this environment](docs/moz-addon-manager.md#developing-with-a-local-https-server-recommended) | -| yarn amo:no-proxy | Start the dev server without a proxy (for amo) using data from Docker | | yarn amo:stage | Start the dev server/proxy (for amo) using data from the staging server (https://addons.allizom.org/) | | yarn build | Build the app. | | yarn build-ci | Run the `build` and `bundlesize` npm scripts. | @@ -388,6 +387,5 @@ curl https://addons-dev.allizom.org/__version__ - Unit tests with high coverage (aiming for 100%) [bundlesize]: https://github.com/siddharthkp/bundlesize -[issue-7196]: https://github.com/mozilla/addons-frontend/issues/7196 [jest]: https://jestjs.io/docs/en/getting-started.html [prettier]: https://prettier.io/ diff --git a/bin/proxy.js b/bin/proxy.js index 5218f8ab7d9..a42ee981cd1 100644 --- a/bin/proxy.js +++ b/bin/proxy.js @@ -19,7 +19,8 @@ const useHttpsForDev = process.env.USE_HTTPS_FOR_DEV; const protocol = useHttpsForDev ? 'https' : 'http'; const apiHost = config.get('proxyApiHost', null) || config.get('apiHost'); -const frontendHost = `${protocol}://${config.get('serverHost')}:${config.get('serverPort')}`; +const serverPort = parseInt(config.get('serverPort'), 10); +const frontendHost = `${protocol}://${config.get('serverHost')}:${serverPort}`; log.info(`apiHost: ${apiHost}`); log.info(`frontendHost: ${frontendHost}`); @@ -94,7 +95,7 @@ proxy.on('error', (error, req, res) => { }); const host = useHttpsForDev ? process.env.SERVER_HOST : 'localhost'; -const port = parseInt(config.get('proxyPort', '3333'), 10); +const port = parseInt(config.get('proxyPort'), 10); log.info(`🚦 Proxy running at ${protocol}://${host}:${port}`); server.listen(port); diff --git a/config/development-local.js b/config/development-local.js new file mode 100644 index 00000000000..e92f8172770 --- /dev/null +++ b/config/development-local.js @@ -0,0 +1,10 @@ +// This config should be used with a local addons-server setup. +module.exports = { + apiHost: 'http://olympia.test', + proxyApiHost: 'http://olympia.test', + proxyPort: 4000, + webpackServerPort: 4001, + mozillaUserId: 10968, + CSP: false, + enableNodeStatics: true, +}; diff --git a/config/development.js b/config/development.js index bf646ad2166..617dd182fec 100644 --- a/config/development.js +++ b/config/development.js @@ -38,7 +38,7 @@ module.exports = { enableStrictMode: true, - serverPort: 3000, + serverPort: 3333, webpackServerHost, webpackServerPort, webpackHost, diff --git a/config/uitests.js b/config/uitests.js deleted file mode 100644 index 110dfde81e9..00000000000 --- a/config/uitests.js +++ /dev/null @@ -1,20 +0,0 @@ -// For use on addons-server, or with the command `amo:ui-tests`. -module.exports = { - apiHost: 'http://olympia.test', - proxyApiHost: 'http://olympia.test', - proxyPort: 3000, - proxyEnabled: true, - mozillaUserId: 10968, - - CSP: false, - - // Setting this to false returns add-ons that are not compatible but means - // developers can pull from a much larger dataset on the local/-dev/-stage - // servers. Set this to true to only get compatible add-ons (this is what - // happens in production) but get a lot fewer add-ons in search results. - restrictSearchResultsToAppVersion: false, - fxaConfig: 'default', - trackingEnabled: false, - loggingLevel: 'debug', - enableNodeStatics: true, -}; diff --git a/package.json b/package.json index 1364a1b0d40..1fe229f2364 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,11 @@ "bundlesize": "bundlesize", "extract-locales": "better-npm-run extract-locales", "clean": "rimraf './dist/*!(.gitkeep)' './webpack-assets.json' './src/locale/**(!.gitkeep)'", - "amo": "better-npm-run amo", "amo:dev": "better-npm-run amo:dev", "amo:dev-https": "better-npm-run amo:dev-https", - "amo:ui-tests": "better-npm-run amo:ui-tests", - "amo:no-proxy": "better-npm-run amo:no-proxy", + "amo:olympia": "better-npm-run amo:olympia", "amo:stage": "better-npm-run amo:stage", + "amo:ui-tests": "npm run amo:olympia", "eslint": "eslint .", "flow": "flow", "flow:check": "flow check", @@ -52,8 +51,11 @@ "NODE_PATH": "./:./src" } }, - "amo": { - "command": "better-npm-run start-dev-proxy" + "amo:olympia": { + "command": "better-npm-run start-dev-proxy", + "env": { + "NODE_APP_INSTANCE": "local" + } }, "amo:dev": { "command": "better-npm-run start-dev-proxy", @@ -71,18 +73,6 @@ "WEBPACK_SERVER_HOST": "example.com" } }, - "amo:ui-tests": { - "command": "better-npm-run start-dev-proxy", - "env": { - "NODE_ENV": "production" - } - }, - "amo:no-proxy": { - "command": "better-npm-run start-dev", - "env": { - "PROXY_ENABLED": "false" - } - }, "amo:stage": { "command": "better-npm-run start-dev-proxy", "env": { @@ -115,8 +105,7 @@ "ENABLE_PIPING": "true", "NODE_ENV": "development", "NODE_ICU_DATA": "./node_modules/full-icu", - "NODE_PATH": "./:./src", - "SERVER_PORT": "3333" + "NODE_PATH": "./:./src" } }, "node": {