add workspace to switch between v1/v2

This commit is contained in:
Amri Toufali 2022-10-10 12:45:47 -07:00
Родитель 22673078fe
Коммит d3d6d6f47b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 75269D7487754F5D
8 изменённых файлов: 82 добавлений и 42 удалений

Просмотреть файл

@ -75,9 +75,7 @@ See here for more on Stylelint config with VSCode: https://github.com/stylelint/
npm start
```
Note: `npm start` uses `onchange` and `nodemon` to automatically detect file
changes, re-compile static assets, and restart the express process. If you want
more control, see the `scripts` section of `package.json` for more commands.
Note: You might run the server using `npm run dev` instead, which uses `nodemon` to detect file changes, re-compile static assets, and restart the express process.
2. Navigate to [localhost:6060/](http://localhost:6060/)

Просмотреть файл

@ -1,17 +0,0 @@
{
"restartable": "rs",
"verbose": false,
"events": {
"//restart": "npm run build"
},
"watch": [
"./*",
".env",
".env-dist"
],
"ignore": [
"public/dist/*",
"tests/*"
],
"ext": "js,css,hbs,json,ftl"
}

37
package-lock.json сгенерированный
Просмотреть файл

@ -8,6 +8,9 @@
"name": "blurts-server",
"version": "1.0.0",
"license": "MPL-2.0",
"workspaces": [
"src"
],
"dependencies": {
"@fluent/bundle": "^0.17.1",
"@fluent/langneg": "^0.6.2",
@ -49,7 +52,7 @@
"eslint-plugin-promise": "^6.0.1",
"jest": "^27.2.5",
"node-mocks-http": "1.11.0",
"nodemon": "2.0.19",
"nodemon": "2.0.20",
"redis-mock": "^0.56.3",
"stylelint": "^14.9.1",
"stylelint-config-standard": "^26.0.0"
@ -6543,6 +6546,10 @@
"npm": ">=6"
}
},
"node_modules/monitor": {
"resolved": "src",
"link": true
},
"node_modules/mozlog": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/mozlog/-/mozlog-3.0.2.tgz",
@ -6638,16 +6645,15 @@
}
},
"node_modules/nodemon": {
"version": "2.0.19",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.19.tgz",
"integrity": "sha512-4pv1f2bMDj0Eeg/MhGqxrtveeQ5/G/UVe9iO6uTZzjnRluSA4PVWf8CW99LUPwGB3eNIA7zUFoP77YuI7hOc0A==",
"version": "2.0.20",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz",
"integrity": "sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
"chokidar": "^3.5.2",
"debug": "^3.2.7",
"ignore-by-default": "^1.0.1",
"minimatch": "^3.0.4",
"minimatch": "^3.1.2",
"pstree.remy": "^1.1.8",
"semver": "^5.7.1",
"simple-update-notifier": "^1.0.7",
@ -9500,6 +9506,12 @@
"engines": {
"node": ">=10"
}
},
"src": {
"name": "monitor",
"version": "1.0.0",
"license": "MPL-2.0",
"devDependencies": {}
}
},
"dependencies": {
@ -14428,6 +14440,9 @@
"resolved": "https://registry.npmjs.org/mmdb-lib/-/mmdb-lib-2.0.2.tgz",
"integrity": "sha512-shi1I+fCPQonhTi7qyb6hr7hi87R7YS69FlfJiMFuJ12+grx0JyL56gLNzGTYXPU7EhAPkMLliGeyHer0K+AVA=="
},
"monitor": {
"version": "file:src"
},
"mozlog": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/mozlog/-/mozlog-3.0.2.tgz",
@ -14508,15 +14523,15 @@
}
},
"nodemon": {
"version": "2.0.19",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.19.tgz",
"integrity": "sha512-4pv1f2bMDj0Eeg/MhGqxrtveeQ5/G/UVe9iO6uTZzjnRluSA4PVWf8CW99LUPwGB3eNIA7zUFoP77YuI7hOc0A==",
"version": "2.0.20",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz",
"integrity": "sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==",
"dev": true,
"requires": {
"chokidar": "^3.5.2",
"debug": "^3.2.7",
"ignore-by-default": "^1.0.1",
"minimatch": "^3.0.4",
"minimatch": "^3.1.2",
"pstree.remy": "^1.1.8",
"semver": "^5.7.1",
"simple-update-notifier": "^1.0.7",
@ -16636,4 +16651,4 @@
"dev": true
}
}
}
}

Просмотреть файл

@ -46,7 +46,7 @@
"eslint-plugin-promise": "^6.0.1",
"jest": "^27.2.5",
"node-mocks-http": "1.11.0",
"nodemon": "2.0.19",
"nodemon": "2.0.20",
"redis-mock": "^0.56.3",
"stylelint": "^14.9.1",
"stylelint-config-standard": "^26.0.0"
@ -57,8 +57,6 @@
},
"homepage": "https://github.com/mozilla/blurts-server",
"license": "MPL-2.0",
"main": "server/app.js",
"type": "module",
"jest": {
"collectCoverageFrom": [
"**/*.js",
@ -80,8 +78,8 @@
"url": "git+https://github.com/mozilla/blurts-server.git"
},
"scripts": {
"start": "npm run build & node server.js",
"dev": "nodemon src/app.js",
"start": "source .env && if [[ $MONITOR_V2 == 'true' ]]; then npm start --workspace=src; else npm run build & node server.js; fi;",
"dev": "source .env && if [[ $MONITOR_V2 == 'true' ]]; then npm run dev --workspace=src; else nodemon server.js; fi;",
"build": "node esbuild.js",
"db:migrate": "knex migrate:latest --knexfile db/knexfile.js",
"docker:build": "docker build -t blurts-server .",
@ -100,5 +98,24 @@
"test:integration-headless-ci": "MOZ_HEADLESS=1 ERROR_SHOTS=1 wdio tests/integration/wdio.conf.js",
"test:integration-docker": "MOZ_HEADLESS=1 wdio tests/integration/wdio.docker.js",
"test": "npm run test:db:migrate && npm run test:tests && npm run test:coveralls"
}
}
},
"workspaces": [
"src"
],
"nodemonConfig": {
"events": {
"restart": "npm run build"
},
"watch": [
"./*",
".env",
".env-dist"
],
"ignore": [
"public/dist/*",
"tests/*"
],
"ext": "js,css,hbs,json,ftl"
},
"supportedLocales": "cak,cs,cy,da,de,el,en,en-CA,en-GB,es-AR,es-CL,es-ES,es-MX,fi,fr,fy-NL,gn,hu,kab,ia,id,it,ja,nb-NO,nl,nn-NO,pt-BR,pt-PT,ro,ru,sk,sl,sq,sv-SE,tr,uk,vi,zh-CN,zh-TW"
}

Просмотреть файл

@ -1,6 +1,7 @@
// TODO: these vars were copy/pasted from the old app-constants.js and should be cleaned up
import * as dotenv from 'dotenv'
import 'dotenv/config.js'
dotenv.config({ path: '../.env' })
const requiredEnvVars = [
'NODE_ENV',
@ -51,7 +52,8 @@ const optionalEnvVars = [
'GEOIP_GEOLITE2_CITY_FILENAME',
'GEOIP_GEOLITE2_COUNTRY_FILENAME',
'VPN_PROMO_BLOCKED_LOCALES',
'EDUCATION_VIDEO_URL_RELAY'
'EDUCATION_VIDEO_URL_RELAY',
'MONITOR_V2'
]
const AppConstants = { }

Просмотреть файл

@ -19,7 +19,7 @@ app.use((req, res, next) => {
// routing
app.use('/', indexRouter)
app.use(express.static('dist'))
app.use(express.static('../dist'))
app.listen(port, function () {
console.log(`Server ready: listening at ${this.address().port}`)

25
src/package.json Normal file
Просмотреть файл

@ -0,0 +1,25 @@
{
"name": "monitor",
"version": "1.0.0",
"description": "Monitor V2",
"type": "module",
"devDependencies": {},
"scripts": {
"start": "node app.js",
"dev": "nodemon app.js"
},
"nodemonConfig": {
"watch": [
"./*",
"../.env",
"../.env-dist"
],
"ext": "js,css,json,ftl"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mozilla/blurts-server.git"
},
"homepage": "https://github.com/mozilla/blurts-server",
"license": "MPL-2.0"
}

Просмотреть файл

@ -16,7 +16,7 @@ let appLocale // set during a request
async function initFluentBundles () {
const promises = supportedLocales.map(async locale => {
const bundle = new FluentBundle(locale, { useIsolating: false })
const dirname = resolve(`locales/${locale}`)
const dirname = resolve(`../locales/${locale}`)
try {
const filenames = readdirSync(dirname).filter(item => item.endsWith('.ftl'))